turtlecode 0.3.22 → 0.3.23

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 (105) hide show
  1. package/assets/assets/{_basePickBy-BuV5p9OF.js → _basePickBy-DL9IPz8d.js} +1 -1
  2. package/assets/assets/{_baseUniq-CgruQt5X.js → _baseUniq-BoADw_d0.js} +1 -1
  3. package/assets/assets/{arc-Xo9tWfZy.js → arc-BMNDPXSl.js} +1 -1
  4. package/assets/assets/{architectureDiagram-2XIMDMQ5-Dwwiik2C.js → architectureDiagram-2XIMDMQ5-eXL2viB8.js} +1 -1
  5. package/assets/assets/{auth-callback-DzfbKURp.js → auth-callback-Bo_aWjxO.js} +1 -1
  6. package/assets/assets/{blockDiagram-WCTKOSBZ-D14iUyJf.js → blockDiagram-WCTKOSBZ-H85W6xMJ.js} +1 -1
  7. package/assets/assets/{c4Diagram-IC4MRINW-BTEGwkgT.js → c4Diagram-IC4MRINW-DMTrPOCa.js} +1 -1
  8. package/assets/assets/channel-B-VkusD5.js +1 -0
  9. package/assets/assets/{chunk-4BX2VUAB-LvGb37pZ.js → chunk-4BX2VUAB-BkYTT9R-.js} +1 -1
  10. package/assets/assets/{chunk-55IACEB6-BHYQFK0r.js → chunk-55IACEB6-DT1jWOUb.js} +1 -1
  11. package/assets/assets/{chunk-FMBD7UC4-DDPwEL1E.js → chunk-FMBD7UC4-BTI-XlSn.js} +1 -1
  12. package/assets/assets/{chunk-JSJVCQXG-ClUobV2O.js → chunk-JSJVCQXG-DtI53WG4.js} +1 -1
  13. package/assets/assets/{chunk-KX2RTZJC-B8M8Fcgs.js → chunk-KX2RTZJC-Bjpt-m3D.js} +1 -1
  14. package/assets/assets/{chunk-NQ4KR5QH-COObsiDL.js → chunk-NQ4KR5QH-CmeD9-yz.js} +1 -1
  15. package/assets/assets/{chunk-QZHKN3VN-3sXsvRQx.js → chunk-QZHKN3VN-BTFiIbVY.js} +1 -1
  16. package/assets/assets/{chunk-WL4C6EOR-C-KVdAYV.js → chunk-WL4C6EOR-CJ9o7iVM.js} +1 -1
  17. package/assets/assets/classDiagram-VBA2DB6C-C-ropUI3.js +1 -0
  18. package/assets/assets/classDiagram-v2-RAHNMMFH-C-ropUI3.js +1 -0
  19. package/assets/assets/clone-CFFEjbU2.js +1 -0
  20. package/assets/assets/{connection-popover-rJ-VRiI0.js → connection-popover-CLXQpTQj.js} +1 -1
  21. package/assets/assets/{context-popover-DrTfmTrn.js → context-popover-DfHXjhOx.js} +1 -1
  22. package/assets/assets/{cose-bilkent-S5V4N54A-CMC5LmtM.js → cose-bilkent-S5V4N54A-BhZXDkvV.js} +1 -1
  23. package/assets/assets/{cssMode-CgrXnPhP.js → cssMode-l2SJhb2i.js} +1 -1
  24. package/assets/assets/{dagre-KLK3FWXG-BQ3EbYun.js → dagre-KLK3FWXG-DtiZbLuc.js} +1 -1
  25. package/assets/assets/{diagram-E7M64L7V-BHeZpgSR.js → diagram-E7M64L7V-CW1lZCyH.js} +1 -1
  26. package/assets/assets/{diagram-IFDJBPK2-b82YQflr.js → diagram-IFDJBPK2-Db2g7I70.js} +1 -1
  27. package/assets/assets/{diagram-P4PSJMXO-pi7FLeUK.js → diagram-P4PSJMXO-BUfU8KO-.js} +1 -1
  28. package/assets/assets/{dialog-clone-project-CTlT0wyo.js → dialog-clone-project-BWg5CxXN.js} +1 -1
  29. package/assets/assets/{dialog-connect-provider-DD-ABicH.js → dialog-connect-provider-Ch23U0DG.js} +2 -2
  30. package/assets/assets/{dialog-create-project-CDuD9Ck4.js → dialog-create-project-hV4lJGVR.js} +1 -1
  31. package/assets/assets/{dialog-edit-project-DsqzrfzM.js → dialog-edit-project-DpPnlKJL.js} +1 -1
  32. package/assets/assets/{dialog-fork-B_U9B5sC.js → dialog-fork-BAqzkh_T.js} +1 -1
  33. package/assets/assets/{dialog-manage-models-BwT1iDMG.js → dialog-manage-models-CR0Dw6KE.js} +1 -1
  34. package/assets/assets/dialog-select-directory-97JJ7Yb-.js +5 -0
  35. package/assets/assets/{dialog-select-file-Bl3u-ykG.js → dialog-select-file-B_o52Q2X.js} +1 -1
  36. package/assets/assets/{dialog-select-mcp-CNXlry4I.js → dialog-select-mcp-u2kkqhGU.js} +1 -1
  37. package/assets/assets/{dialog-select-model-unpaid-BggTZ1GN.js → dialog-select-model-unpaid-C6RP1dAD.js} +2 -2
  38. package/assets/assets/{dialog-select-provider-DCUcnqs5.js → dialog-select-provider-BQqjRbS8.js} +1 -1
  39. package/assets/assets/{dialog-select-server-BFlVrVwv.js → dialog-select-server-Bphwacs-.js} +1 -1
  40. package/assets/assets/dialog-settings-ChnTBHFF.js +1 -0
  41. package/assets/assets/{erDiagram-INFDFZHY-7SAbu9BD.js → erDiagram-INFDFZHY-CrO7khAp.js} +1 -1
  42. package/assets/assets/{flowDiagram-PKNHOUZH-BTJQITbQ.js → flowDiagram-PKNHOUZH-BjYb-wxV.js} +1 -1
  43. package/assets/assets/{freemarker2-DaFW-Bnn.js → freemarker2-DpZw2YqU.js} +1 -1
  44. package/assets/assets/{ganttDiagram-A5KZAMGK-xLMbL7NX.js → ganttDiagram-A5KZAMGK-DEQkpJjm.js} +3 -3
  45. package/assets/assets/{ghostty-web-CSMOh6gY.js → ghostty-web-BSIEXrpM.js} +1 -1
  46. package/assets/assets/{gitGraphDiagram-K3NZZRJ6-CVRO_XHq.js → gitGraphDiagram-K3NZZRJ6-DwUSR09X.js} +1 -1
  47. package/assets/assets/{graph-DApKsqr0.js → graph-CtH8ZjFb.js} +1 -1
  48. package/assets/assets/{handlebars-CUhaHsb1.js → handlebars-GOy2OLfD.js} +1 -1
  49. package/assets/assets/{home-BqphZDxq.js → home-Dg23VJKh.js} +1 -1
  50. package/assets/assets/{html-Do7wwNp4.js → html-CviWPcrp.js} +1 -1
  51. package/assets/assets/{htmlMode-B3WepnYy.js → htmlMode-B65efrcI.js} +1 -1
  52. package/assets/assets/{index-DMyAFOcC.js → index-BawkOegm.js} +433 -433
  53. package/assets/assets/index-D0DTn_ER.css +6 -0
  54. package/assets/assets/{infoDiagram-LFFYTUFH-DifxRd1_.js → infoDiagram-LFFYTUFH-DzpNmWGA.js} +1 -1
  55. package/assets/assets/{ishikawaDiagram-PHBUUO56-DKeD8kjl.js → ishikawaDiagram-PHBUUO56-CsuWDWwK.js} +1 -1
  56. package/assets/assets/{javascript-Ct4IZjTn.js → javascript-L4wILu8Q.js} +1 -1
  57. package/assets/assets/{journeyDiagram-4ABVD52K-cHvgdZfH.js → journeyDiagram-4ABVD52K-DvqSVsYn.js} +1 -1
  58. package/assets/assets/{jsonMode-CqBN0SKr.js → jsonMode-BoZY-mRu.js} +1 -1
  59. package/assets/assets/{kanban-definition-K7BYSVSG-BOdC1ppV.js → kanban-definition-K7BYSVSG-DXa__5Sm.js} +1 -1
  60. package/assets/assets/{layout-CjPJwo23.js → layout-C64ddrfO.js} +1 -1
  61. package/assets/assets/{liquid-Dmi6j_RS.js → liquid-CxH-o0Se.js} +1 -1
  62. package/assets/assets/{list-HsPczU9B.js → list-CrMBY0Hl.js} +1 -1
  63. package/assets/assets/{mdx-CUhMRP6h.js → mdx-DiY_1Evw.js} +1 -1
  64. package/assets/assets/{mermaid.core-CVIbZZUN.js → mermaid.core-C20mIhI4.js} +5 -5
  65. package/assets/assets/{mindmap-definition-YRQLILUH-C7HR3zhx.js → mindmap-definition-YRQLILUH-nuzeSEuJ.js} +1 -1
  66. package/assets/assets/{model-viewer-DDGWhTxL.js → model-viewer-DXWYp1q7.js} +1 -1
  67. package/assets/assets/{pieDiagram-SKSYHLDU-CrJaz2WI.js → pieDiagram-SKSYHLDU-Cn7M1mJs.js} +1 -1
  68. package/assets/assets/{python-BThAKS5B.js → python-DC4uQwuV.js} +1 -1
  69. package/assets/assets/{quadrantDiagram-337W2JSQ-CT_Qyvwc.js → quadrantDiagram-337W2JSQ-D4EwpHyD.js} +1 -1
  70. package/assets/assets/{razor-DLLQQ61x.js → razor-tn9cxD2A.js} +1 -1
  71. package/assets/assets/{requirementDiagram-Z7DCOOCP-DgnbnU65.js → requirementDiagram-Z7DCOOCP-e8FrBwg2.js} +1 -1
  72. package/assets/assets/{sankeyDiagram-WA2Y5GQK-ET7pXSx4.js → sankeyDiagram-WA2Y5GQK-DqdqgVRB.js} +1 -1
  73. package/assets/assets/{select-DxXmJhya.js → select-C71K38b7.js} +1 -1
  74. package/assets/assets/{sequenceDiagram-2WXFIKYE-CUs-VZ-i.js → sequenceDiagram-2WXFIKYE-CPorrKMA.js} +1 -1
  75. package/assets/assets/{server-row-CgIAM5UY.js → server-row-CTeoMzpI.js} +1 -1
  76. package/assets/assets/session-DGEvV6Eo.js +45 -0
  77. package/assets/assets/session-u2OSkes-.css +1 -0
  78. package/assets/assets/{stateDiagram-RAJIS63D-DLkjpkxR.js → stateDiagram-RAJIS63D-DiufrgEY.js} +1 -1
  79. package/assets/assets/stateDiagram-v2-FVOUBMTO-DYrqgyGL.js +1 -0
  80. package/assets/assets/{status-popover-body-DTO1Nt0V.js → status-popover-body-Cr6lUGSA.js} +2 -2
  81. package/assets/assets/{switch-D4TikNGe.js → switch-ix-huecE.js} +1 -1
  82. package/assets/assets/{tabs-b5kQDmsB.js → tabs-7QeVyXuu.js} +1 -1
  83. package/assets/assets/{tag-BHNb4BJv.js → tag-DPqk6yRN.js} +1 -1
  84. package/assets/assets/{timeline-definition-YZTLITO2-Bdm1whZ9.js → timeline-definition-YZTLITO2-B1XBZqWa.js} +1 -1
  85. package/assets/assets/{treemap-KZPCXAKY-DpDSxMOl.js → treemap-KZPCXAKY-CFAfubzi.js} +1 -1
  86. package/assets/assets/{trellis-badge-demo-DYt0hA6f.js → trellis-badge-demo-uf3d7mPO.js} +1 -1
  87. package/assets/assets/{tsMode-BPLjiHaS.js → tsMode-l3nOGsNB.js} +1 -1
  88. package/assets/assets/{typescript-CLDA3AC1.js → typescript-CD0qqirJ.js} +1 -1
  89. package/assets/assets/{vennDiagram-LZ73GAT5-CJrGY5gu.js → vennDiagram-LZ73GAT5-CAExGE02.js} +1 -1
  90. package/assets/assets/{xlsx-editor-D4RVmOqB.js → xlsx-editor-CQjlqJzW.js} +1 -1
  91. package/assets/assets/{xml-BSsdg4yg.js → xml-KSsd_GUG.js} +1 -1
  92. package/assets/assets/{xychartDiagram-JWTSCODW-Bz5-rqDO.js → xychartDiagram-JWTSCODW-BxpruhGL.js} +1 -1
  93. package/assets/assets/{yaml-CX9XdbT4.js → yaml-C-_4qrc6.js} +1 -1
  94. package/assets/index.html +3 -3
  95. package/bin/cli.mjs +67 -4
  96. package/package.json +13 -13
  97. package/assets/assets/channel-lLJpXDom.js +0 -1
  98. package/assets/assets/classDiagram-VBA2DB6C-DjMycBV4.js +0 -1
  99. package/assets/assets/classDiagram-v2-RAHNMMFH-DjMycBV4.js +0 -1
  100. package/assets/assets/clone-g65k7nys.js +0 -1
  101. package/assets/assets/dialog-select-directory-DeBymOq4.js +0 -6
  102. package/assets/assets/dialog-settings-BuGykryo.js +0 -1
  103. package/assets/assets/index-CUuPDPB8.css +0 -6
  104. package/assets/assets/session-fOsXx5rL.js +0 -56
  105. package/assets/assets/stateDiagram-v2-FVOUBMTO-CNJAyXac.js +0 -1
@@ -0,0 +1,45 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dialog-create-project-hV4lJGVR.js","assets/index-BawkOegm.js","assets/index-D0DTn_ER.css","assets/ghostty-web-BSIEXrpM.js","assets/dialog-manage-models-CR0Dw6KE.js","assets/list-CrMBY0Hl.js","assets/switch-ix-huecE.js","assets/dialog-select-provider-BQqjRbS8.js","assets/tag-DPqk6yRN.js","assets/dialog-connect-provider-Ch23U0DG.js","assets/dialog-select-model-unpaid-C6RP1dAD.js","assets/tabs-7QeVyXuu.js","assets/select-C71K38b7.js","assets/transform-BwXaE9hv.js","assets/dialog-select-file-B_o52Q2X.js","assets/xlsx-editor-CQjlqJzW.js","assets/xlsx-editor-DU1FXj8L.css","assets/model-viewer-DXWYp1q7.js","assets/dialog-settings-ChnTBHFF.js","assets/dialog-select-mcp-u2kkqhGU.js","assets/dialog-fork-BAqzkh_T.js"])))=>i.map(i=>d[i]);
2
+ import{H as St,O as $e,a7 as Pt,P as vt,ag as rn,aE as Nr,a1 as bt,t as x,h as ke,o as Mn,a as Hr,aK as Li,u as eo,aa as Pi,e as Zf,b as aa,f as hn,a4 as zn,a3 as br,bP as Fi,c as dr,d as Ri,w as ql,aM as Ur,i as T,aN as uv,E as Sn,bQ as Xr,bR as Zr,bS as Qf,m as s,bd as qo,B as kt,I as Ue,S as E,bT as or,l,bE as fv,bG as ki,aH as Ti,R as Ye,Q as Ot,F as Oe,_ as Kn,r as Ps,J as nt,ae as to,af as ur,aS as gv,a$ as mv,b8 as hv,bU as Jf,aT as pv,aU as vv,aV as Gr,an as Br,bV as bv,al as xr,at as la,bW as xv,aB as os,aA as vr,ax as as,aD as jl,bX as yv,b9 as Fs,ay as ca,v as Kt,bO as xn,bY as Rt,j as Lt,q as G,$ as ue,s as Je,D as ll,ab as Vl,bZ as _i,b_ as eg,b$ as zi,c0 as da,c1 as wv,aL as yr,c2 as ua,A as cr,aJ as Wn,n as Te,c3 as tg,C as ls,Y as Ht,V as Tt,c4 as cl,bq as Hl,bp as ng,bu as Qc,bz as $v,c5 as kv,c6 as _v,c7 as rg,b6 as Pn,c8 as Cv,c9 as dl,ca as fa,a9 as Oi,a8 as ig,cb as Aa,cc as Qr,cd as Uo,ce as ci,Z as Nn,G as no,ac as ji,cf as Sv,aF as Dn,aG as ot,cg as Tv,ch as Jc,ci as Ul,cj as Ar,ck as Av,cl as ed,cm as Dv,cn as td,L as Yr,co as Vr,cp as bi,ah as sg,ai as og,aj as Mv,ak as Wl,ao as ag,aq as lg,ap as ro,ar as Ev,as as Iv,au as cg,aY as dg,av as ga,aw as ma,aC as ug,am as Wo,X as Lv,az as Pv,cq as fg,cr as gg,cs as mg,ct as Fv,cu as Rv,cv as Or,cw as Fn,cx as xi,cy as cs,cz as hg,y as pg,aI as Rs,p as Kl,k as vg,a_ as zv,cA as Ov,cB as rs,cC as Da,cD as Nv,cE as Bv,b3 as kr,cF as qv,cG as ha,bI as bg,cH as jv,cI as Vv,bF as zs,cJ as Hv,cK as Os,cL as Uv,cM as Wv,cN as xg,cO as Kv,cP as Gv,cQ as Yv,cR as pa,cS as Ai,cT as Ko,cU as Di,cV as Ni,cW as yg,cX as nd,cY as wg,cZ as $g,c_ as kg,c$ as Gl,d0 as io,bK as Ns,d1 as Gn,d2 as _g,d3 as Cg,x as Sg,d4 as Hs,d5 as Us,d6 as va,z as Yl,d7 as Xv,d8 as rd,d9 as Zv,da as Tg,db as Qv,dc as Jv,dd as e0,de as t0,df as n0,dg as r0,dh as i0,di as Dr,bJ as ds,dj as Xl,U as gi,dk as s0,dl as Mi,bC as es,dm as o0,dn as a0,dp as id,dq as sd,dr as l0,ds as Ag,dt as c0,du as d0,dv as jo,dw as u0,dx as Dg,dy as Mg,dz as ul,dA as Eg,dB as od,dC as f0,dD as ad,dE as g0,dF as Zl,dG as Ig,dH as Lg,dI as Pg,dJ as m0,dK as ld,dL as h0,dM as p0,dN as Fg,dO as Rg,dP as v0,dQ as zg,dR as Og,dS as Go,dT as b0,dU as Yo,dV as cd,dW as x0,dX as y0,dY as w0,dZ as Ql,d_ as Jl,d$ as $0,e0 as Xo,e1 as k0,e2 as _0,e3 as dd,e4 as ud,e5 as C0,e6 as S0}from"./index-BawkOegm.js";import{c as Zo,T as pr}from"./tabs-7QeVyXuu.js";import{S as Qo}from"./select-C71K38b7.js";import{L as T0,u as mo}from"./list-CrMBY0Hl.js";import{T as fd,P as gd}from"./tag-DPqk6yRN.js";import{s as ar,g as ec,t as A0,j as sr,T as Ma,k as Ea}from"./transform-BwXaE9hv.js";function is(e){const t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{startLine:t,endLine:n,startChar:0,endChar:0}}function D0(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Kr(e,t){if(e=D0(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const M0={passive:!1},Ws={capture:!0,passive:!1};function Ia(e){e.stopImmediatePropagation()}function ts(e){e.preventDefault(),e.stopImmediatePropagation()}function Ng(e){var t=e.document.documentElement,n=ar(e).on("dragstart.drag",ts,Ws);"onselectstart"in t?n.on("selectstart.drag",ts,Ws):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Bg(e,t){var n=e.document.documentElement,r=ar(e).on("dragstart.drag",null);t&&(r.on("click.drag",ts,Ws),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const ho=e=>()=>e;function fl(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:d,dx:c,dy:u,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:d,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:g}})}fl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function E0(e){return!e.ctrlKey&&!e.button}function I0(){return this.parentNode}function L0(e,t){return t??{x:e.x,y:e.y}}function P0(){return navigator.maxTouchPoints||"ontouchstart"in this}function F0(){var e=E0,t=I0,n=L0,r=P0,i={},o=ec("start","drag","end"),a=0,d,c,u,g,f=0;function m(b){b.on("mousedown.drag",p).filter(r).on("touchstart.drag",k).on("touchmove.drag",v,M0).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(b,_){if(!(g||!e.call(this,b,_))){var $=y(this,t.call(this,b,_),b,_,"mouse");$&&(ar(b.view).on("mousemove.drag",w,Ws).on("mouseup.drag",h,Ws),Ng(b.view),Ia(b),u=!1,d=b.clientX,c=b.clientY,$("start",b))}}function w(b){if(ts(b),!u){var _=b.clientX-d,$=b.clientY-c;u=_*_+$*$>f}i.mouse("drag",b)}function h(b){ar(b.view).on("mousemove.drag mouseup.drag",null),Bg(b.view,u),ts(b),i.mouse("end",b)}function k(b,_){if(e.call(this,b,_)){var $=b.changedTouches,D=t.call(this,b,_),L=$.length,V,K;for(V=0;V<L;++V)(K=y(this,D,b,_,$[V].identifier,$[V]))&&(Ia(b),K("start",b,$[V]))}}function v(b){var _=b.changedTouches,$=_.length,D,L;for(D=0;D<$;++D)(L=i[_[D].identifier])&&(ts(b),L("drag",b,_[D]))}function C(b){var _=b.changedTouches,$=_.length,D,L;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),D=0;D<$;++D)(L=i[_[D].identifier])&&(Ia(b),L("end",b,_[D]))}function y(b,_,$,D,L,V){var K=o.copy(),I=Kr(V||$,_),U,Y,S;if((S=n.call(b,new fl("beforestart",{sourceEvent:$,target:m,identifier:L,active:a,x:I[0],y:I[1],dx:0,dy:0,dispatch:K}),D))!=null)return U=S.x-I[0]||0,Y=S.y-I[1]||0,function M(A,F,N){var X=I,B;switch(A){case"start":i[L]=M,B=a++;break;case"end":delete i[L],--a;case"drag":I=Kr(N||F,_),B=a;break}K.call(A,b,new fl(A,{sourceEvent:F,subject:S,target:m,identifier:L,active:B,x:I[0]+U,y:I[1]+Y,dx:I[0]-X[0],dy:I[1]-X[1],dispatch:K}),D)}}return m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:ho(!!b),m):e},m.container=function(b){return arguments.length?(t=typeof b=="function"?b:ho(b),m):t},m.subject=function(b){return arguments.length?(n=typeof b=="function"?b:ho(b),m):n},m.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:ho(!!b),m):r},m.on=function(){var b=o.on.apply(o,arguments);return b===o?m:b},m.clickDistance=function(b){return arguments.length?(f=(b=+b)*b,m):Math.sqrt(f)},m}var R0=1e-12;function md(e){return((e=Math.exp(e))+1/e)/2}function z0(e){return((e=Math.exp(e))-1/e)/2}function O0(e){return((e=Math.exp(2*e))-1)/(e+1)}const N0=(function e(t,n,r){function i(o,a){var d=o[0],c=o[1],u=o[2],g=a[0],f=a[1],m=a[2],p=g-d,w=f-c,h=p*p+w*w,k,v;if(h<R0)v=Math.log(m/u)/t,k=function(D){return[d+D*p,c+D*w,u*Math.exp(t*D*v)]};else{var C=Math.sqrt(h),y=(m*m-u*u+r*h)/(2*u*n*C),b=(m*m-u*u-r*h)/(2*m*n*C),_=Math.log(Math.sqrt(y*y+1)-y),$=Math.log(Math.sqrt(b*b+1)-b);v=($-_)/t,k=function(D){var L=D*v,V=md(_),K=u/(n*C)*(V*O0(t*L+_)-z0(_));return[d+K*p,c+K*w,u*V/md(t*L+_)]}}return k.duration=v*1e3*t/Math.SQRT2,k}return i.rho=function(o){var a=Math.max(.001,+o),d=a*a,c=d*d;return e(a,d,c)},i})(Math.SQRT2,2,4);function qg(e,t){var n,r=1;e==null&&(e=0),t==null&&(t=0);function i(){var o,a=n.length,d,c=0,u=0;for(o=0;o<a;++o)d=n[o],c+=d.x,u+=d.y;for(c=(c/a-e)*r,u=(u/a-t)*r,o=0;o<a;++o)d=n[o],d.x-=c,d.y-=u}return i.initialize=function(o){n=o},i.x=function(o){return arguments.length?(e=+o,i):e},i.y=function(o){return arguments.length?(t=+o,i):t},i.strength=function(o){return arguments.length?(r=+o,i):r},i}function B0(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return jg(this.cover(t,n),t,n,e)}function jg(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o=e._root,a={data:r},d=e._x0,c=e._y0,u=e._x1,g=e._y1,f,m,p,w,h,k,v,C;if(!o)return e._root=a,e;for(;o.length;)if((h=t>=(f=(d+u)/2))?d=f:u=f,(k=n>=(m=(c+g)/2))?c=m:g=m,i=o,!(o=o[v=k<<1|h]))return i[v]=a,e;if(p=+e._x.call(null,o.data),w=+e._y.call(null,o.data),t===p&&n===w)return a.next=o,i?i[v]=a:e._root=a,e;do i=i?i[v]=new Array(4):e._root=new Array(4),(h=t>=(f=(d+u)/2))?d=f:u=f,(k=n>=(m=(c+g)/2))?c=m:g=m;while((v=k<<1|h)===(C=(w>=m)<<1|p>=f));return i[C]=o,i[v]=a,e}function q0(e){var t,n,r=e.length,i,o,a=new Array(r),d=new Array(r),c=1/0,u=1/0,g=-1/0,f=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(o=+this._y.call(null,t))||(a[n]=i,d[n]=o,i<c&&(c=i),i>g&&(g=i),o<u&&(u=o),o>f&&(f=o));if(c>g||u>f)return this;for(this.cover(c,u).cover(g,f),n=0;n<r;++n)jg(this,a[n],d[n],e[n]);return this}function j0(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,o=(r=Math.floor(t))+1;else{for(var a=i-n||1,d=this._root,c,u;n>e||e>=i||r>t||t>=o;)switch(u=(t<r)<<1|e<n,c=new Array(4),c[u]=d,d=c,a*=2,u){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function V0(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function H0(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function lr(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function U0(e,t,n){var r,i=this._x0,o=this._y0,a,d,c,u,g=this._x1,f=this._y1,m=[],p=this._root,w,h;for(p&&m.push(new lr(p,i,o,g,f)),n==null?n=1/0:(i=e-n,o=t-n,g=e+n,f=t+n,n*=n);w=m.pop();)if(!(!(p=w.node)||(a=w.x0)>g||(d=w.y0)>f||(c=w.x1)<i||(u=w.y1)<o))if(p.length){var k=(a+c)/2,v=(d+u)/2;m.push(new lr(p[3],k,v,c,u),new lr(p[2],a,v,k,u),new lr(p[1],k,d,c,v),new lr(p[0],a,d,k,v)),(h=(t>=v)<<1|e>=k)&&(w=m[m.length-1],m[m.length-1]=m[m.length-1-h],m[m.length-1-h]=w)}else{var C=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=C*C+y*y;if(b<n){var _=Math.sqrt(n=b);i=e-_,o=t-_,g=e+_,f=t+_,r=p.data}}return r}function W0(e){if(isNaN(g=+this._x.call(null,e))||isNaN(f=+this._y.call(null,e)))return this;var t,n=this._root,r,i,o,a=this._x0,d=this._y0,c=this._x1,u=this._y1,g,f,m,p,w,h,k,v;if(!n)return this;if(n.length)for(;;){if((w=g>=(m=(a+c)/2))?a=m:c=m,(h=f>=(p=(d+u)/2))?d=p:u=p,t=n,!(n=n[k=h<<1|w]))return this;if(!n.length)break;(t[k+1&3]||t[k+2&3]||t[k+3&3])&&(r=t,v=k)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):t?(o?t[k]=o:delete t[k],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[v]=n:this._root=n),this):(this._root=o,this)}function K0(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function G0(){return this._root}function Y0(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function X0(e){var t=[],n,r=this._root,i,o,a,d,c;for(r&&t.push(new lr(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,o=n.x0,a=n.y0,d=n.x1,c=n.y1)&&r.length){var u=(o+d)/2,g=(a+c)/2;(i=r[3])&&t.push(new lr(i,u,g,d,c)),(i=r[2])&&t.push(new lr(i,o,g,u,c)),(i=r[1])&&t.push(new lr(i,u,a,d,g)),(i=r[0])&&t.push(new lr(i,o,a,u,g))}return this}function Z0(e){var t=[],n=[],r;for(this._root&&t.push(new lr(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var o,a=r.x0,d=r.y0,c=r.x1,u=r.y1,g=(a+c)/2,f=(d+u)/2;(o=i[0])&&t.push(new lr(o,a,d,g,f)),(o=i[1])&&t.push(new lr(o,g,d,c,f)),(o=i[2])&&t.push(new lr(o,a,f,g,u)),(o=i[3])&&t.push(new lr(o,g,f,c,u))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Q0(e){return e[0]}function J0(e){return arguments.length?(this._x=e,this):this._x}function eb(e){return e[1]}function tb(e){return arguments.length?(this._y=e,this):this._y}function tc(e,t,n){var r=new nc(t??Q0,n??eb,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function nc(e,t,n,r,i,o){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function hd(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var fr=tc.prototype=nc.prototype;fr.copy=function(){var e=new nc(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=hd(t),e;for(n=[{source:t,target:e._root=new Array(4)}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=new Array(4)}):t.target[i]=hd(r));return e};fr.add=B0;fr.addAll=q0;fr.cover=j0;fr.data=V0;fr.extent=H0;fr.find=U0;fr.remove=W0;fr.removeAll=K0;fr.root=G0;fr.size=Y0;fr.visit=X0;fr.visitAfter=Z0;fr.x=J0;fr.y=tb;function Ci(e){return function(){return e}}function di(e){return(e()-.5)*1e-6}function nb(e){return e.x+e.vx}function rb(e){return e.y+e.vy}function Vg(e){var t,n,r,i=1,o=1;typeof e!="function"&&(e=Ci(e==null?1:+e));function a(){for(var u,g=t.length,f,m,p,w,h,k,v=0;v<o;++v)for(f=tc(t,nb,rb).visitAfter(d),u=0;u<g;++u)m=t[u],h=n[m.index],k=h*h,p=m.x+m.vx,w=m.y+m.vy,f.visit(C);function C(y,b,_,$,D){var L=y.data,V=y.r,K=h+V;if(L){if(L.index>m.index){var I=p-L.x-L.vx,U=w-L.y-L.vy,Y=I*I+U*U;Y<K*K&&(I===0&&(I=di(r),Y+=I*I),U===0&&(U=di(r),Y+=U*U),Y=(K-(Y=Math.sqrt(Y)))/Y*i,m.vx+=(I*=Y)*(K=(V*=V)/(k+V)),m.vy+=(U*=Y)*K,L.vx-=I*(K=1-K),L.vy-=U*K)}return}return b>p+K||$<p-K||_>w+K||D<w-K}}function d(u){if(u.data)return u.r=n[u.data.index];for(var g=u.r=0;g<4;++g)u[g]&&u[g].r>u.r&&(u.r=u[g].r)}function c(){if(t){var u,g=t.length,f;for(n=new Array(g),u=0;u<g;++u)f=t[u],n[f.index]=+e(f,u,t)}}return a.initialize=function(u,g){t=u,r=g,c()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(i=+u,a):i},a.radius=function(u){return arguments.length?(e=typeof u=="function"?u:Ci(+u),c(),a):e},a}function ib(e){return e.index}function pd(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function Hg(e){var t=ib,n=f,r,i=Ci(30),o,a,d,c,u,g=1;e==null&&(e=[]);function f(k){return 1/Math.min(d[k.source.index],d[k.target.index])}function m(k){for(var v=0,C=e.length;v<g;++v)for(var y=0,b,_,$,D,L,V,K;y<C;++y)b=e[y],_=b.source,$=b.target,D=$.x+$.vx-_.x-_.vx||di(u),L=$.y+$.vy-_.y-_.vy||di(u),V=Math.sqrt(D*D+L*L),V=(V-o[y])/V*k*r[y],D*=V,L*=V,$.vx-=D*(K=c[y]),$.vy-=L*K,_.vx+=D*(K=1-K),_.vy+=L*K}function p(){if(a){var k,v=a.length,C=e.length,y=new Map(a.map((_,$)=>[t(_,$,a),_])),b;for(k=0,d=new Array(v);k<C;++k)b=e[k],b.index=k,typeof b.source!="object"&&(b.source=pd(y,b.source)),typeof b.target!="object"&&(b.target=pd(y,b.target)),d[b.source.index]=(d[b.source.index]||0)+1,d[b.target.index]=(d[b.target.index]||0)+1;for(k=0,c=new Array(C);k<C;++k)b=e[k],c[k]=d[b.source.index]/(d[b.source.index]+d[b.target.index]);r=new Array(C),w(),o=new Array(C),h()}}function w(){if(a)for(var k=0,v=e.length;k<v;++k)r[k]=+n(e[k],k,e)}function h(){if(a)for(var k=0,v=e.length;k<v;++k)o[k]=+i(e[k],k,e)}return m.initialize=function(k,v){a=k,u=v,p()},m.links=function(k){return arguments.length?(e=k,p(),m):e},m.id=function(k){return arguments.length?(t=k,m):t},m.iterations=function(k){return arguments.length?(g=+k,m):g},m.strength=function(k){return arguments.length?(n=typeof k=="function"?k:Ci(+k),w(),m):n},m.distance=function(k){return arguments.length?(i=typeof k=="function"?k:Ci(+k),h(),m):i},m}const sb=1664525,ob=1013904223,vd=4294967296;function ab(){let e=1;return()=>(e=(sb*e+ob)%vd)/vd}function lb(e){return e.x}function cb(e){return e.y}var db=10,ub=Math.PI*(3-Math.sqrt(5));function Ug(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,d=new Map,c=A0(f),u=ec("tick","end"),g=ab();e==null&&(e=[]);function f(){m(),u.call("tick",t),n<r&&(c.stop(),u.call("end",t))}function m(h){var k,v=e.length,C;h===void 0&&(h=1);for(var y=0;y<h;++y)for(n+=(o-n)*i,d.forEach(function(b){b(n)}),k=0;k<v;++k)C=e[k],C.fx==null?C.x+=C.vx*=a:(C.x=C.fx,C.vx=0),C.fy==null?C.y+=C.vy*=a:(C.y=C.fy,C.vy=0);return t}function p(){for(var h=0,k=e.length,v;h<k;++h){if(v=e[h],v.index=h,v.fx!=null&&(v.x=v.fx),v.fy!=null&&(v.y=v.fy),isNaN(v.x)||isNaN(v.y)){var C=db*Math.sqrt(.5+h),y=h*ub;v.x=C*Math.cos(y),v.y=C*Math.sin(y)}(isNaN(v.vx)||isNaN(v.vy))&&(v.vx=v.vy=0)}}function w(h){return h.initialize&&h.initialize(e,g),h}return p(),t={tick:m,restart:function(){return c.restart(f),t},stop:function(){return c.stop(),t},nodes:function(h){return arguments.length?(e=h,p(),d.forEach(w),t):e},alpha:function(h){return arguments.length?(n=+h,t):n},alphaMin:function(h){return arguments.length?(r=+h,t):r},alphaDecay:function(h){return arguments.length?(i=+h,t):+i},alphaTarget:function(h){return arguments.length?(o=+h,t):o},velocityDecay:function(h){return arguments.length?(a=1-h,t):1-a},randomSource:function(h){return arguments.length?(g=h,d.forEach(w),t):g},force:function(h,k){return arguments.length>1?(k==null?d.delete(h):d.set(h,w(k)),t):d.get(h)},find:function(h,k,v){var C=0,y=e.length,b,_,$,D,L;for(v==null?v=1/0:v*=v,C=0;C<y;++C)D=e[C],b=h-D.x,_=k-D.y,$=b*b+_*_,$<v&&(L=D,v=$);return L},on:function(h,k){return arguments.length>1?(u.on(h,k),t):u.on(h)}}}function Wg(){var e,t,n,r,i=Ci(-30),o,a=1,d=1/0,c=.81;function u(p){var w,h=e.length,k=tc(e,lb,cb).visitAfter(f);for(r=p,w=0;w<h;++w)t=e[w],k.visit(m)}function g(){if(e){var p,w=e.length,h;for(o=new Array(w),p=0;p<w;++p)h=e[p],o[h.index]=+i(h,p,e)}}function f(p){var w=0,h,k,v=0,C,y,b;if(p.length){for(C=y=b=0;b<4;++b)(h=p[b])&&(k=Math.abs(h.value))&&(w+=h.value,v+=k,C+=k*h.x,y+=k*h.y);p.x=C/v,p.y=y/v}else{h=p,h.x=h.data.x,h.y=h.data.y;do w+=o[h.data.index];while(h=h.next)}p.value=w}function m(p,w,h,k){if(!p.value)return!0;var v=p.x-t.x,C=p.y-t.y,y=k-w,b=v*v+C*C;if(y*y/c<b)return b<d&&(v===0&&(v=di(n),b+=v*v),C===0&&(C=di(n),b+=C*C),b<a&&(b=Math.sqrt(a*b)),t.vx+=v*p.value*r/b,t.vy+=C*p.value*r/b),!0;if(p.length||b>=d)return;(p.data!==t||p.next)&&(v===0&&(v=di(n),b+=v*v),C===0&&(C=di(n),b+=C*C),b<a&&(b=Math.sqrt(a*b)));do p.data!==t&&(y=o[p.data.index]*r/b,t.vx+=v*y,t.vy+=C*y);while(p=p.next)}return u.initialize=function(p,w){e=p,n=w,g()},u.strength=function(p){return arguments.length?(i=typeof p=="function"?p:Ci(+p),g(),u):i},u.distanceMin=function(p){return arguments.length?(a=p*p,u):Math.sqrt(a)},u.distanceMax=function(p){return arguments.length?(d=p*p,u):Math.sqrt(d)},u.theta=function(p){return arguments.length?(c=p*p,u):Math.sqrt(c)},u}const po=e=>()=>e;function fb(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function La(e){e.stopImmediatePropagation()}function ws(e){e.preventDefault(),e.stopImmediatePropagation()}function gb(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function mb(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function bd(){return this.__zoom||sr}function hb(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function pb(){return navigator.maxTouchPoints||"ontouchstart"in this}function vb(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function Kg(){var e=gb,t=mb,n=vb,r=hb,i=pb,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],d=250,c=N0,u=ec("start","zoom","end"),g,f,m,p=500,w=150,h=0,k=10;function v(S){S.property("__zoom",bd).on("wheel.zoom",L,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",K).filter(i).on("touchstart.zoom",I).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",Y).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(S,M,A,F){var N=S.selection?S.selection():S;N.property("__zoom",bd),S!==N?_(S,M,A,F):N.interrupt().each(function(){$(this,arguments).event(F).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},v.scaleBy=function(S,M,A,F){v.scaleTo(S,function(){var N=this.__zoom.k,X=typeof M=="function"?M.apply(this,arguments):M;return N*X},A,F)},v.scaleTo=function(S,M,A,F){v.transform(S,function(){var N=t.apply(this,arguments),X=this.__zoom,B=A==null?b(N):typeof A=="function"?A.apply(this,arguments):A,O=X.invert(B),z=typeof M=="function"?M.apply(this,arguments):M;return n(y(C(X,z),B,O),N,a)},A,F)},v.translateBy=function(S,M,A,F){v.transform(S,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof A=="function"?A.apply(this,arguments):A),t.apply(this,arguments),a)},null,F)},v.translateTo=function(S,M,A,F,N){v.transform(S,function(){var X=t.apply(this,arguments),B=this.__zoom,O=F==null?b(X):typeof F=="function"?F.apply(this,arguments):F;return n(sr.translate(O[0],O[1]).scale(B.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof A=="function"?-A.apply(this,arguments):-A),X,a)},F,N)};function C(S,M){return M=Math.max(o[0],Math.min(o[1],M)),M===S.k?S:new Ma(M,S.x,S.y)}function y(S,M,A){var F=M[0]-A[0]*S.k,N=M[1]-A[1]*S.k;return F===S.x&&N===S.y?S:new Ma(S.k,F,N)}function b(S){return[(+S[0][0]+ +S[1][0])/2,(+S[0][1]+ +S[1][1])/2]}function _(S,M,A,F){S.on("start.zoom",function(){$(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(F).end()}).tween("zoom",function(){var N=this,X=arguments,B=$(N,X).event(F),O=t.apply(N,X),z=A==null?b(O):typeof A=="function"?A.apply(N,X):A,q=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),Q=N.__zoom,j=typeof M=="function"?M.apply(N,X):M,H=c(Q.invert(z).concat(q/Q.k),j.invert(z).concat(q/j.k));return function(J){if(J===1)J=j;else{var le=H(J),de=q/le[2];J=new Ma(de,z[0]-le[0]*de,z[1]-le[1]*de)}B.zoom(null,J)}})}function $(S,M,A){return!A&&S.__zooming||new D(S,M)}function D(S,M){this.that=S,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(S,M),this.taps=0}D.prototype={event:function(S){return S&&(this.sourceEvent=S),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(S,M){return this.mouse&&S!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&S!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&S!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(S){var M=ar(this.that).datum();u.call(S,this.that,new fb(S,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),M)}};function L(S,...M){if(!e.apply(this,arguments))return;var A=$(this,M).event(S),F=this.__zoom,N=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),X=Kr(S);if(A.wheel)(A.mouse[0][0]!==X[0]||A.mouse[0][1]!==X[1])&&(A.mouse[1]=F.invert(A.mouse[0]=X)),clearTimeout(A.wheel);else{if(F.k===N)return;A.mouse=[X,F.invert(X)],Ea(this),A.start()}ws(S),A.wheel=setTimeout(B,w),A.zoom("mouse",n(y(C(F,N),A.mouse[0],A.mouse[1]),A.extent,a));function B(){A.wheel=null,A.end()}}function V(S,...M){if(m||!e.apply(this,arguments))return;var A=S.currentTarget,F=$(this,M,!0).event(S),N=ar(S.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",q,!0),X=Kr(S,A),B=S.clientX,O=S.clientY;Ng(S.view),La(S),F.mouse=[X,this.__zoom.invert(X)],Ea(this),F.start();function z(Q){if(ws(Q),!F.moved){var j=Q.clientX-B,H=Q.clientY-O;F.moved=j*j+H*H>h}F.event(Q).zoom("mouse",n(y(F.that.__zoom,F.mouse[0]=Kr(Q,A),F.mouse[1]),F.extent,a))}function q(Q){N.on("mousemove.zoom mouseup.zoom",null),Bg(Q.view,F.moved),ws(Q),F.event(Q).end()}}function K(S,...M){if(e.apply(this,arguments)){var A=this.__zoom,F=Kr(S.changedTouches?S.changedTouches[0]:S,this),N=A.invert(F),X=A.k*(S.shiftKey?.5:2),B=n(y(C(A,X),F,N),t.apply(this,M),a);ws(S),d>0?ar(this).transition().duration(d).call(_,B,F,S):ar(this).call(v.transform,B,F,S)}}function I(S,...M){if(e.apply(this,arguments)){var A=S.touches,F=A.length,N=$(this,M,S.changedTouches.length===F).event(S),X,B,O,z;for(La(S),B=0;B<F;++B)O=A[B],z=Kr(O,this),z=[z,this.__zoom.invert(z),O.identifier],N.touch0?!N.touch1&&N.touch0[2]!==z[2]&&(N.touch1=z,N.taps=0):(N.touch0=z,X=!0,N.taps=1+!!g);g&&(g=clearTimeout(g)),X&&(N.taps<2&&(f=z[0],g=setTimeout(function(){g=null},p)),Ea(this),N.start())}}function U(S,...M){if(this.__zooming){var A=$(this,M).event(S),F=S.changedTouches,N=F.length,X,B,O,z;for(ws(S),X=0;X<N;++X)B=F[X],O=Kr(B,this),A.touch0&&A.touch0[2]===B.identifier?A.touch0[0]=O:A.touch1&&A.touch1[2]===B.identifier&&(A.touch1[0]=O);if(B=A.that.__zoom,A.touch1){var q=A.touch0[0],Q=A.touch0[1],j=A.touch1[0],H=A.touch1[1],J=(J=j[0]-q[0])*J+(J=j[1]-q[1])*J,le=(le=H[0]-Q[0])*le+(le=H[1]-Q[1])*le;B=C(B,Math.sqrt(J/le)),O=[(q[0]+j[0])/2,(q[1]+j[1])/2],z=[(Q[0]+H[0])/2,(Q[1]+H[1])/2]}else if(A.touch0)O=A.touch0[0],z=A.touch0[1];else return;A.zoom("touch",n(y(B,O,z),A.extent,a))}}function Y(S,...M){if(this.__zooming){var A=$(this,M).event(S),F=S.changedTouches,N=F.length,X,B;for(La(S),m&&clearTimeout(m),m=setTimeout(function(){m=null},p),X=0;X<N;++X)B=F[X],A.touch0&&A.touch0[2]===B.identifier?delete A.touch0:A.touch1&&A.touch1[2]===B.identifier&&delete A.touch1;if(A.touch1&&!A.touch0&&(A.touch0=A.touch1,delete A.touch1),A.touch0)A.touch0[1]=this.__zoom.invert(A.touch0[0]);else if(A.end(),A.taps===2&&(B=Kr(B,this),Math.hypot(f[0]-B[0],f[1]-B[1])<k)){var O=ar(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return v.wheelDelta=function(S){return arguments.length?(r=typeof S=="function"?S:po(+S),v):r},v.filter=function(S){return arguments.length?(e=typeof S=="function"?S:po(!!S),v):e},v.touchable=function(S){return arguments.length?(i=typeof S=="function"?S:po(!!S),v):i},v.extent=function(S){return arguments.length?(t=typeof S=="function"?S:po([[+S[0][0],+S[0][1]],[+S[1][0],+S[1][1]]]),v):t},v.scaleExtent=function(S){return arguments.length?(o[0]=+S[0],o[1]=+S[1],v):[o[0],o[1]]},v.translateExtent=function(S){return arguments.length?(a[0][0]=+S[0][0],a[1][0]=+S[1][0],a[0][1]=+S[0][1],a[1][1]=+S[1][1],v):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},v.constrain=function(S){return arguments.length?(n=S,v):n},v.duration=function(S){return arguments.length?(d=+S,v):d},v.interpolate=function(S){return arguments.length?(c=S,v):c},v.on=function(){var S=u.on.apply(u,arguments);return S===u?v:S},v.clickDistance=function(S){return arguments.length?(h=(S=+S)*S,v):Math.sqrt(h)},v.tapDistance=function(S){return arguments.length?(k=+S,v):k},v}function Gg(e){let t,n=!1,r,i,o,a;const d=()=>e.bottomThreshold??10,[c,u]=St({contentRef:void 0,userScrolled:!1}),g=()=>e.working()||n,f=$=>$.scrollHeight-$.clientHeight-$.scrollTop,m=$=>$.scrollHeight-$.clientHeight>1,p=$=>{a={top:Math.max(0,$.scrollHeight-$.clientHeight),time:Date.now()},i&&clearTimeout(i),i=setTimeout(()=>{a=void 0,i=void 0},1500)},w=$=>{const D=a;return D?Date.now()-D.time>1500?(a=void 0,!1):Math.abs($.scrollTop-D.top)<2:!1},h=$=>{const D=t;D&&(p(D),D.scrollTop=D.scrollHeight)},k=$=>{if(!$&&!g())return;$&&c.userScrolled&&u("userScrolled",!1);const D=t;if(!D||!$&&c.userScrolled)return;if(f(D)<2){p(D);return}h()},v=()=>{const $=t;if($){if(!m($)){c.userScrolled&&u("userScrolled",!1);return}c.userScrolled||(u("userScrolled",!0),e.onUserInteracted?.())}},C=$=>{if($.deltaY>=0)return;const D=t,V=($.target instanceof Element?$.target:void 0)?.closest("[data-scrollable]");D&&V&&V!==D||v()},y=()=>{const $=t;if($){if(!m($)){c.userScrolled&&u("userScrolled",!1);return}if(f($)<d()){c.userScrolled&&u("userScrolled",!1);return}if(!c.userScrolled&&w($)){k(!1);return}v()}},b=()=>{if(!g())return;const $=window.getSelection();$&&$.toString().length>0&&v()},_=$=>{const D=e.overflowAnchor??"dynamic";if(D==="none"){$.style.overflowAnchor="none";return}if(D==="auto"){$.style.overflowAnchor="auto";return}$.style.overflowAnchor=c.userScrolled?"auto":"none"};return Zo(()=>c.contentRef,()=>{const $=t;if($&&!m($)){c.userScrolled&&u("userScrolled",!1);return}g()&&(c.userScrolled||k(!1))}),$e(Pt(e.working,$=>{if(n=!1,r&&clearTimeout(r),r=void 0,$){c.userScrolled||k(!0);return}n=!0,r=setTimeout(()=>{n=!1},300)})),$e(()=>{c.userScrolled;const $=t;$&&_($)}),vt(()=>{r&&clearTimeout(r),i&&clearTimeout(i),o&&o()}),{scrollRef:$=>{o&&(o(),o=void 0),t=$,$&&(_($),$.addEventListener("wheel",C,{passive:!0}),o=()=>{$.removeEventListener("wheel",C)})},contentRef:$=>u("contentRef",$),handleScroll:y,handleInteraction:b,pause:v,resume:()=>{c.userScrolled&&u("userScrolled",!1),k(!0)},scrollToBottom:()=>k(!1),forceScrollToBottom:()=>k(!0),userScrolled:()=>c.userScrolled}}var bb=x("<div>");function so(e){const[t,n]=rn(e,["direction","edge","size","min","max","onResize","onCollapse","collapseThreshold","class","classList"]),r=i=>{i.preventDefault();const o=t.edge??(t.direction==="vertical"?"start":"end"),a=t.direction==="horizontal"?i.clientX:i.clientY,d=t.size;let c=d;document.body.style.userSelect="none",document.body.style.overflow="hidden";const u=f=>{const m=t.direction==="horizontal"?f.clientX:f.clientY,p=t.direction==="vertical"?o==="end"?m-a:a-m:o==="start"?a-m:m-a;c=d+p;const w=Math.min(t.max,Math.max(t.min,c));t.onResize(w)},g=()=>{document.body.style.userSelect="",document.body.style.overflow="",document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",g);const f=t.collapseThreshold??0;t.onCollapse&&f>0&&c<f&&t.onCollapse()};document.addEventListener("mousemove",u),document.addEventListener("mouseup",g)};return(()=>{var i=bb();return Nr(i,bt(n,{"data-component":"resize-handle",get"data-direction"(){return t.direction},get"data-edge"(){return t.edge??(t.direction==="vertical"?"start":"end")},get classList(){return{...t.classList??{},[t.class??""]:!!t.class}},onMouseDown:r}),!1,!1),i})()}const xb="/assets/android-studio-t3zZ7G0e.svg",yb="/assets/antigravity-m-mWKI7R.svg",wb="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5436_78947)'%3e%3cmask%20id='mask0_5436_78947'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='4'%20y='4'%20width='32'%20height='32'%3e%3cpath%20d='M4%204H36V36H4V4Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5436_78947)'%3e%3cpath%20d='M28.375%204H11.625C7.41383%204%204%207.41383%204%2011.625V28.375C4%2032.5862%207.41383%2036%2011.625%2036H28.375C32.5862%2036%2036%2032.5862%2036%2028.375V11.625C36%207.41383%2032.5862%204%2028.375%204Z'%20fill='black'/%3e%3c/g%3e%3cpath%20d='M29.6214%2014.2072L20.9502%209.12249C20.6718%208.95917%2020.3282%208.95917%2020.0498%209.12249L11.3786%2014.2072C11.1445%2014.3445%2011%2014.5984%2011%2014.8733V25.1267C11%2025.4012%2011.1445%2025.6555%2011.3786%2025.7928L20.0498%2030.8775C20.3282%2031.0408%2020.6718%2031.0408%2020.9502%2030.8775L29.6214%2025.7928C29.8555%2025.6555%2030%2025.4016%2030%2025.1267V14.8733C30%2014.5988%2029.8555%2014.3445%2029.6214%2014.2072ZM29.0767%2015.2843L20.706%2030.0101C20.6494%2030.1093%2020.5%2030.0688%2020.5%2029.9538V20.3115C20.5%2020.1189%2020.3986%2019.9407%2020.2342%2019.8439L12.0124%2015.0226C11.9147%2014.9651%2011.9546%2014.8134%2012.0678%2014.8134H28.8093C29.047%2014.8134%2029.1956%2015.0751%2029.0767%2015.2843Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5436_78947'%3e%3crect%20width='32'%20height='32'%20fill='white'%20transform='translate(4%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",$b="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M16.2414%208.05369L14.955%206.65636C14.7646%206.44946%2014.5333%206.2843%2014.2757%206.17133C14.0182%206.05836%2013.7401%206.00002%2013.4588%206H4.86684C4.753%205.99995%204.64025%206.02234%204.53506%206.06589C4.42987%206.10944%204.33429%206.17329%204.25379%206.25379C4.17329%206.33429%204.10944%206.42987%204.06589%206.53506C4.02234%206.64025%203.99995%206.753%204%206.86684V12.8779L4.04302%2012.8825C4.10268%2012.6706%204.22985%2012.4839%204.40523%2012.3508C4.5806%2012.2177%204.7946%2012.1455%205.01476%2012.1451H13.189C14.3506%2012.1451%2015.4795%2011.6366%2016.1675%2010.7004C16.5166%2010.2255%2016.9726%209.83942%2017.4985%209.57327C18.0244%209.30713%2018.6056%209.16842%2019.195%209.16836H34.9852C35.2544%209.16836%2035.5125%209.27527%2035.7028%209.46557C35.8931%209.65587%2036%209.91398%2036%2010.1831V8.99058C36%208.77152%2035.913%208.56144%2035.7581%208.40654C35.6032%208.25164%2035.3931%208.16462%2035.174%208.16462H16.4953C16.4476%208.16469%2016.4004%208.15486%2016.3567%208.13577C16.313%208.11667%2016.2738%208.08873%2016.2414%208.05369Z'%20fill='url(%23paint0_linear_5437_79060)'/%3e%3cpath%20d='M16.2002%2010.3751C15.8497%2010.8375%2015.397%2011.2125%2014.8774%2011.4707C14.3579%2011.7289%2013.7855%2011.8634%2013.2053%2011.8634H5.01476C4.88147%2011.8634%204.74948%2011.8897%204.62634%2011.9407C4.5032%2011.9917%204.39132%2012.0665%204.29709%2012.1608C4.20286%2012.255%204.12812%2012.3669%204.07714%2012.4901C4.02617%2012.6133%203.99995%2012.7453%204%2012.8785V32.4302C4%2032.6993%204.10691%2032.9574%204.29722%2033.1477C4.48752%2033.338%204.74563%2033.4449%205.01476%2033.4449H34.9852C35.2544%2033.4449%2035.5125%2033.338%2035.7028%2033.1477C35.8931%2032.9574%2036%2032.6993%2036%2032.4302V9.90147C36%209.63234%2035.8931%209.37424%2035.7028%209.18393C35.5125%208.99363%2035.2544%208.88672%2034.9852%208.88672H19.195C18.6148%208.88679%2018.0425%209.0212%2017.5229%209.27942C17.0033%209.53764%2016.5506%209.91265%2016.2002%2010.3751Z'%20fill='url(%23paint1_linear_5437_79060)'/%3e%3cpath%20d='M27.7632%2023.2969H12.2368C11.7852%2023.2968%2011.3379%2023.3857%2010.9207%2023.5585C10.5034%2023.7312%2010.1242%2023.9846%209.80488%2024.3039C9.48553%2024.6233%209.23222%2025.0024%209.05943%2025.4197C8.88664%2025.8369%208.79776%2026.2842%208.79785%2026.7358V33.4448H31.2025V26.7358C31.2021%2024.8364%2029.6626%2023.2969%2027.7632%2023.2969Z'%20fill='url(%23paint2_linear_5437_79060)'/%3e%3cpath%20d='M26.5965%2029.7865H13.404C13.2154%2029.7865%2013.0345%2029.7116%2012.9012%2029.5782C12.7678%2029.4448%2012.6929%2029.264%2012.6929%2029.0754C12.6929%2028.8868%2012.7678%2028.7059%2012.9012%2028.5725C13.0345%2028.4392%2013.2154%2028.3643%2013.404%2028.3643H26.5965C26.7851%2028.3643%2026.966%2028.4392%2027.0993%2028.5725C27.2327%2028.7059%2027.3076%2028.8868%2027.3076%2029.0754C27.3076%2029.264%2027.2327%2029.4448%2027.0993%2029.5782C26.966%2029.7116%2026.7851%2029.7865%2026.5965%2029.7865Z'%20fill='%2310498A'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5437_79060'%20x1='19.7682'%20y1='9.59964'%20x2='19.2608'%20y2='6.75804'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23CE9918'/%3e%3cstop%20offset='0.5902'%20stop-color='%23DF9E00'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_5437_79060'%20x1='26.3559'%20y1='28.492'%20x2='13.062'%20y2='13.1687'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23F5B509'/%3e%3cstop%20offset='1'%20stop-color='%23FECE49'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint2_linear_5437_79060'%20x1='27.4873'%20y1='32.5737'%20x2='7.9015'%20y2='23.2375'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%230161B2'/%3e%3cstop%20offset='1'%20stop-color='%231291DD'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",kb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAB8pJREFUeAHtWG+MXFUV/9375s3szNDturKbLpt0aZo2fvAfpEBEss2iMZJaFTBdG1BrUfGLmohWaGvaQtYYU2miJsRKTQikkhDRIKmRNcEPJGgw1hJFcetu2mJcKrPbmZ2dP++9e6/n3PtmdnbelJnlC3zobc++mXvPu+d3z/87wJVxZby9Q3RZl0T65Pnzu2f94S/Pl70tQYhBpWG0Mn3odRgSJBFIAeOnxKWBPvWvTVj66Vc2DT0ZYzB4CwDlaWN2H5tRT1QvKONJCCHxlodpE6Y1EAxI3PtefOvjvn+Mp7AGgN7vjPnxT6Yr916VScmuem4FQkjq0uDGDR5ky3ukdAQK+O+ywflFjZyU8D3iDZXaMd73m3t8eSc6gOwkWp4xZvLA76uPr0t7nunA+GZz7xkROLTFR7fx4lKEQy8qDGUFqnWjvnSr/8AOz3uYllQ3gNhztm5qF7DmUagCz92W7pm/SHTnbwMCCVTyEtefmvIOHz68SosJr3rif6VPFF/VUBHWTCP9K3uzSRukWoi/N7S9nujALRLVmoB/SZsNu/Z8sR1PAuDZcuqbkqdZloJ7tpLqME/fdSRw+xbP7uFYBJRxpFsoYqL1KH51+7oUqhFx0/+z9Wv2tONJtU/Ml/wt2tA5I6xpXKoaTAz5Tfws/XK5Q5tYM9IB2DggsFACLpb01q4Aq1U9yMcza4hcHumUxnohUINLITwum9xoQQsHkgEMU6AUFiiiA5FvZ02YWIXwKRGjlXRMlAnxnz8+Q2/J5lyD5yObPQTEEpnY6i1rGQIzPf0CKLm7d4ybZ142VIr2s3JCk+0KMAwofZGNROTIajN++jkfp394F/lbABO6OeapVoA7CKD1K3qXXMqC0DHNzL2G3ZN7kPbiAzNA48DyYaR2SFUkEkpPmJjB8CaN+tP6VAyKtVeNXUC6+eXQYCwrUWJgVqpsiVXmFfBkhtYMQgZD34U1iIFHnwwHE81LBXQHSIzaBogTIOJUyScN6xr5a7fByCyZI4LwlNXGB0eBMjGE1oR0APonmilWYGTDED40fgOW6ORUNB04uykBN6wU7cgT3QFacJHbwmB1DQ2LEW7+7h8QVuvkB9JqKiDeyQ9QcJCA0PolQWOhTQ0a1E0Kj508wRUDkjNRbEnJlpVw5og8KE93B8inUrqhM4FEQQsiO6dj9IsVhfcPZVCiZMuHcyLk6hCmz7VYNvuoIBPztlq6Q7HV6HxIqx40yJLJWel9GZ80lmRisCKWyERzo1QOaqGwuLU7mTvaZXOM24q38eiDlM4HWSuqQz+TAKj4FI082J4Mm53bil9+6sMpStLaaU6sYGdTv0kmdLLYETgwKN9oCkDZiw8aZSz10mJxa1WhzOxT38RyuL2q1Fwi1BxszVOtesv+lfEKR7LlZ7kdqleHNGOcqnusJCef13jqhSpVEthy9ctvZ7FAVSEigGaVLzfAiSZsjjMmEyd0T/cYJDbLrsqClxsCGQ5FJSk508ECY7UacLpRaAZScg9jgUlyIRE4SwirwaRWEpWETcN+YcgXm0/tobJ4jlY9ilQZr4kEnyagmqQFFJL1yFigAbf2MaVzXHPnqYum1EPmrNt17bohKwfdAXJisqdvIZlJ429Ht2Hmmf2QaQZpEjyWCBi3VGEoQXkcETl+RFqh8ol3DXo4vO97+OrkXvh90s5HBDQIXWtn9+wJoDFRowFt1OBwsYobpsoonHkKfz12o/UCqJQriy18SklbsuramZk1RIUDIZZx984vYHZmBo89dwpvFAKnZeJnHvY/awnTg4k9Qa1C3E02uhUuXEGpim3fmUN20078+WAOs6e+jqBeRCqdIQdKkeac6e2mFM45akRLxUX8aGoKd39sByZ23IGpR45jocANmW81HFKWDimH1mvamlcaU2vHkwgSX+pFpZCDbqshnP2XA2y85QGMjR/Av6fvx5mHt6Ivm0V+9Cb0Db+PTLceU4ckzs1dwOw/XyaNGtz6yc/hZ88+j6ViBTUS73lpq102g+QAo2oy/4azRMY3y10BXp3HzLlIjwqZjD3bbAgOhghj2x+C99GjqJfnUXrtNOoL/0C5UEb/wGaM3zaOz3/tQfTlcqgu17BcipDyszZ5s0VcN21s3hxcB/x9VqHPF7hmUM51BTiWff3Rl6Lh7Z4n4qLW6GpW/rpPJCysUdAMYHBsAmbjBApFhbv25vHKTGhTR40qDGvM3kc4hZg479j2i4KHoFaqkU1TIa3dfO2lx0+04Ul4pSFP3Xp/qPuNWkmrLXk2MdcyXywDvzji4y+vknY413Vwes2as5cnjevokvXZQ3W8m35hkOslXtqfSbyQCBLqNMQ3PuPtq1Yibt5sZTHkzCY0ca/eNhfFpZGeA1mNI8cDjA1zbyhsjgu0aRJXF67vV1ODMUIXpcmDNQz104WrFOnj92GqIx50HnL/tH766V+Xd2bT3pp+kWHHqFNWnrg+hXym0VkLeyOuU6WZLwi8PKesi/TRHX+ppvXRg/lnPz0qb0ePP300QZ54Jbzv+z/XP8hz9yzQc31ujE5VjrewdxIlTGbIE4/uSx25Lus9iDX+eNS6bh761cV7zpzL7y0UsbkWiKvIn7N8dV4LYOqkBdmiksua+tiInLlp08Un+1//0yO7du1qXqWvjCvjnTj+D8SthzamBKAPAAAAAElFTkSuQmCC",_b="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79067)'%3e%3cpath%20d='M27.395%2036C26.1435%2035.9986%2024.9203%2035.6274%2023.879%2034.933C22.8374%2035.6273%2021.6139%2035.9985%2020.362%2036C19.113%2036%2017.882%2035.625%2016.846%2034.933C15.8189%2035.6241%2014.61%2035.9954%2013.372%2036H13.334C12.4944%2036.0006%2011.6633%2035.8321%2010.8902%2035.5047C10.1171%2035.1772%209.41781%2034.6975%208.83405%2034.094C7.65642%2032.8996%206.99679%2031.2893%206.99805%2029.612V17.362C7.00005%209.995%2012.994%204%2020.362%204C27.731%204%2033.725%209.994%2033.725%2017.363V29.616C33.725%2033.009%2031.099%2035.808%2027.747%2035.991C27.63%2035.998%2027.513%2036%2027.395%2036Z'%20fill='%233551F3'/%3e%3cpath%20d='M27.395%2034.5932C26.2752%2034.5924%2025.1889%2034.2104%2024.315%2033.5102C24.1961%2033.4145%2024.0476%2033.3632%2023.895%2033.3652C23.7174%2033.367%2023.5457%2033.4291%2023.408%2033.5412C22.5392%2034.2237%2021.4668%2034.5951%2020.362%2034.5962C19.2576%2034.5949%2018.1855%2034.2234%2017.317%2033.5412C17.1835%2033.4338%2017.0174%2033.3752%2016.846%2033.3752C16.6747%2033.3752%2016.5085%2033.4338%2016.375%2033.5412C15.518%2034.2199%2014.4581%2034.5914%2013.365%2034.5962H13.332C12.6806%2034.5961%2012.0359%2034.4649%2011.4362%2034.2102C10.8366%2033.9556%2010.2945%2033.5829%209.84201%2033.1142C8.92225%2032.1822%208.40639%2030.9256%208.40601%2029.6162V17.3672C8.40601%2010.7702%2013.77%205.40723%2020.363%205.40723C26.955%205.40723%2032.319%2010.7702%2032.319%2017.3632V29.6162C32.319%2032.2612%2030.277%2034.4432%2027.669%2034.5862C27.5777%2034.5909%2027.4864%2034.5932%2027.395%2034.5932Z'%20fill='black'/%3e%3cpath%20d='M30.912%2017.3635V29.6165C30.912%2031.4925%2029.465%2033.0795%2027.592%2033.1825C26.725%2033.2323%2025.8704%2032.9582%2025.194%2032.4135C24.416%2031.7875%2023.321%2031.8155%2022.536%2032.4345C21.9163%2032.9237%2021.1495%2033.1891%2020.36%2033.1875C19.5714%2033.1889%2018.8056%2032.9235%2018.187%2032.4345C17.8057%2032.1306%2017.3326%2031.9651%2016.845%2031.9651C16.3574%2031.9651%2015.8843%2032.1306%2015.503%2032.4345C14.8904%2032.9183%2014.1336%2033.1834%2013.353%2033.1875C11.405%2033.2015%209.81299%2031.5605%209.81299%2029.6125V17.3625C9.81299%2011.5375%2014.537%206.81348%2020.363%206.81348C26.188%206.81348%2030.912%2011.5375%2030.912%2017.3635Z'%20fill='white'/%3e%3cpath%20d='M18.28%2016.4366L14.35%2014.1666C14.104%2014.0248%2013.8117%2013.9865%2013.5374%2014.06C13.2632%2014.1335%2013.0292%2014.3128%2012.887%2014.5586C12.7452%2014.8045%2012.7067%2015.0966%2012.78%2015.3709C12.8533%2015.6452%2013.0324%2015.8792%2013.278%2016.0216L15.604%2017.3646L13.278%2018.7076C13.045%2018.8559%2012.8783%2019.0886%2012.8126%2019.3569C12.7469%2019.6252%2012.7873%2019.9085%2012.9255%2020.1478C13.0636%2020.387%2013.2887%2020.5637%2013.554%2020.641C13.8192%2020.7183%2014.104%2020.6902%2014.349%2020.5626L18.281%2018.2926C18.4436%2018.1985%2018.5786%2018.0633%2018.6724%2017.9006C18.7662%2017.7379%2018.8156%2017.5534%2018.8156%2017.3656C18.8156%2017.1777%2018.7662%2016.9932%2018.6724%2016.8305C18.5786%2016.6678%2018.4436%2016.5326%2018.281%2016.4386V16.4366H18.28ZM27.182%2016.2906H22.018C21.7338%2016.2906%2021.4613%2016.4034%2021.2604%2016.6044C21.0594%2016.8053%2020.9465%2017.0779%2020.9465%2017.3621C20.9465%2017.6462%2021.0594%2017.9188%2021.2604%2018.1197C21.4613%2018.3207%2021.7338%2018.4336%2022.018%2018.4336H27.182C27.4662%2018.4336%2027.7387%2018.3207%2027.9397%2018.1197C28.1406%2017.9188%2028.2535%2017.6462%2028.2535%2017.3621C28.2535%2017.0779%2028.1406%2016.8053%2027.9397%2016.6044C27.7387%2016.4034%2027.4662%2016.2906%2027.182%2016.2906Z'%20fill='black'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79067'%3e%3crect%20width='27'%20height='32'%20fill='white'%20transform='translate(7%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Cb="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='4'%20y='4'%20width='32'%20height='32'%20rx='6.4'%20fill='url(%23paint0_linear_5437_79079)'/%3e%3crect%20x='4.80005'%20y='4.7998'%20width='30.4'%20height='30.4'%20rx='5.6'%20fill='black'/%3e%3crect%20x='7.19995'%20y='7.2002'%20width='25.6'%20height='25.6'%20rx='3.2'%20fill='%23202A2F'/%3e%3cpath%20d='M25.2454%208.85742H19.2454V20.8574H25.2454V8.85742Z'%20fill='%230EE827'%20fill-opacity='0.35'/%3e%3cpath%20d='M11.7895%2018.9218C11.4758%2018.8949%2011.1817%2018.85%2010.9072%2018.7872C10.6424%2018.7154%2010.3973%2018.6392%2010.1718%2018.5584C9.95613%2018.4776%209.76496%2018.4014%209.59829%2018.3296C9.44145%2018.2488%209.32378%2018.186%209.24536%2018.1412L9.87771%2016.9567C9.94631%2017.0016%2010.064%2017.0644%2010.2306%2017.1452C10.3973%2017.2259%2010.5836%2017.3111%2010.7895%2017.4009C11.0052%2017.4816%2011.2257%2017.5534%2011.4513%2017.6162C11.6768%2017.679%2011.8875%2017.7105%2012.0836%2017.7105C13.064%2017.7105%2013.5542%2017.3381%2013.5542%2016.5933C13.5542%2016.4138%2013.5199%2016.2658%2013.4512%2016.1492C13.3925%2016.0325%2013.2993%2015.9338%2013.1719%2015.853C13.0542%2015.7633%2012.9071%2015.687%2012.7307%2015.6242C12.564%2015.5525%2012.3729%2015.4806%2012.1571%2015.4089C11.7453%2015.2653%2011.3777%2015.1172%2011.0542%2014.9647C10.7405%2014.8032%2010.4708%2014.6237%2010.2454%2014.4263C10.0199%2014.2289%209.8483%2014.0046%209.73063%2013.7534C9.61303%2013.5021%209.5542%2013.2149%209.5542%2012.8919C9.5542%2012.6407%209.60812%2012.3984%209.71596%2012.1651C9.82379%2011.9318%209.97572%2011.7254%2010.1718%2011.546C10.3679%2011.3576%2010.6032%2011.2005%2010.8777%2011.0749C11.1522%2010.9403%2011.4562%2010.8461%2011.7895%2010.7922V8.85742H12.9954V10.7653C13.2503%2010.7922%2013.4954%2010.8326%2013.7307%2010.8865C13.966%2010.9403%2014.1767%2010.9986%2014.363%2011.0614C14.5493%2011.1242%2014.7062%2011.1871%2014.8336%2011.2499C14.9709%2011.3037%2015.0689%2011.3441%2015.1278%2011.371L14.5395%2012.4747C14.4611%2012.4388%2014.3483%2012.3939%2014.2012%2012.3401C14.064%2012.2773%2013.9072%2012.2144%2013.7307%2012.1517C13.5542%2012.0888%2013.363%2012.035%2013.1571%2011.9901C12.9513%2011.9453%2012.7454%2011.9228%2012.5395%2011.9228C12.2062%2011.9228%2011.9071%2011.9856%2011.6424%2012.1112C11.3875%2012.2279%2011.2601%2012.4298%2011.2601%2012.7169C11.2601%2012.8964%2011.2944%2013.058%2011.363%2013.2015C11.4414%2013.3361%2011.5493%2013.4573%2011.6865%2013.5649C11.8336%2013.6726%2012.0101%2013.7758%2012.2159%2013.8745C12.4316%2013.9642%2012.6768%2014.054%2012.9513%2014.1437C13.314%2014.2782%2013.6376%2014.4173%2013.9218%2014.5609C14.2062%2014.7045%2014.4463%2014.866%2014.6424%2015.0455C14.8385%2015.2249%2014.9856%2015.4313%2015.0836%2015.6646C15.1914%2015.8979%2015.2454%2016.1715%2015.2454%2016.4856C15.2454%2016.7548%2015.1964%2017.015%2015.0983%2017.2662C15.0101%2017.5175%2014.8679%2017.7508%2014.6718%2017.9661C14.4856%2018.1815%2014.2503%2018.3699%2013.966%2018.5315C13.6915%2018.684%2013.3679%2018.7962%2012.9954%2018.8679V20.8574H11.7895V18.9218Z'%20fill='%230EE827'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5437_79079'%20x1='20'%20y1='4'%20x2='20'%20y2='36'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23D4E6E8'/%3e%3cstop%20offset='1'%20stop-color='%23767573'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",Sb="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M34.9013%207.2002H10.604C9.83641%207.2002%209.09532%207.84723%208.91004%208.66305L4.03999%2031.3373C3.85472%2032.1532%204.33113%2032.8002%205.0987%2032.8002H29.396C30.1636%2032.8002%2030.9047%2032.1532%2031.09%2031.3373L35.96%208.69118C36.1453%207.87536%2035.6689%207.2002%2034.9013%207.2002Z'%20fill='url(%23paint0_linear_5437_79143)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.7489%2026.5009H25.2421C25.8826%2026.5009%2026.3999%2027.0942%2026.3999%2027.8223C26.3999%2028.5505%2025.8826%2029.1438%2025.2421%2029.1438H19.7489C19.1085%2029.1438%2018.5912%2028.5505%2018.5912%2027.8223C18.5912%2027.0942%2019.1085%2026.5009%2019.7489%2026.5009ZM23.3208%2020.6216C23.2222%2020.8374%2023.0252%2021.0531%2022.6803%2021.3228L12.4575%2029.3596C11.8909%2029.7911%2011.1027%2029.6293%2010.6593%2028.982C10.2405%2028.3347%2010.339%2027.4448%2010.881%2027.0133L20.0938%2019.7047V19.5429L14.305%2012.8006C13.837%2012.2612%2013.8862%2011.3713%2014.4035%2010.8049C14.9455%2010.2655%2015.7584%2010.2655%2016.2264%2010.8049L23.173%2018.8956C23.5917%2019.408%2023.6163%2020.1092%2023.3208%2020.6216Z'%20fill='%232C5591'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M23.2368%2020.6216C23.1387%2020.8374%2022.9426%2021.0531%2022.5993%2021.3228L12.448%2029.3596C11.8841%2029.7911%2011.0994%2029.6293%2010.6581%2028.982C10.2412%2028.3347%2010.3393%2027.4448%2010.8788%2027.0133L20.0492%2019.7047V19.5429L14.287%2012.8006C13.8212%2012.2612%2013.8702%2011.3713%2014.3851%2010.8049C14.9246%2010.2655%2015.7337%2010.2655%2016.1996%2010.8049L23.1142%2018.8956C23.5311%2019.3811%2023.5556%2020.0822%2023.2368%2020.6216ZM19.7795%2026.6357H25.2475C25.885%2026.6357%2026.3999%2027.202%2026.3999%2027.8763C26.3999%2028.5775%2025.885%2029.1168%2025.2475%2029.1168H19.7795C19.142%2029.1168%2018.6271%2028.5505%2018.6271%2027.8763C18.6271%2027.1751%2019.142%2026.6357%2019.7795%2026.6357Z'%20fill='white'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5437_79143'%20x1='9.76654'%20y1='10.3425'%20x2='29.068'%20y2='26.4694'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%232D4664'/%3e%3cstop%20offset='0.169'%20stop-color='%2329405B'/%3e%3cstop%20offset='0.445'%20stop-color='%231E2F43'/%3e%3cstop%20offset='0.79'%20stop-color='%230C131B'/%3e%3cstop%20offset='1'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",Tb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAAA0RJREFUeAHtmM9PE0EUx18pJCRaugUhQkuqXgi3eqDVpJFK+g9w8Ejkohcg4I8DFynECxdEAlz0gA0nNYF4kkODRDQmNQQ8NRhjbd1FrQHankja3XFm7DbN7rQMyS7l0E+y3dmZt/u+mffednYAatSoLpZKg9s//wawRUhKJj2/90QBLNgcocJt+EyvAQo/UBwv2qkeCm7o2P/ri+3OtOuSewcpEL7quvACTsJ2PC5sJf8sPQw9Rh2dnaigwPCjw9WJJmfm0FYyNUt8Ai+f4+Ls3dEHpgnTHndG76NoXFpiaanXdnz8Gh988+rl2LO5GXrd2NgILS0tUFdXB0aSy+Vgf3+fnp/PPYFztvODn2Lx8PXuyxuldroc/BD79u5WMBD4JYnQ0NAAbrfbcHEqiqKAKIpwdHQE7U4XvI683/B3X7lZaqPzLCV+eIg4Qmtrq2niqHP8bBIdAvEpJr57dDbajj1RLCar1Wot9i8vL0MwGAQzRKpgkXbduLZDlmVg4XQ6YXFxkR6kbQZKXtalnE4gwnnBYmhoCKLRKJ3F9fV1mJ6eNlwozkkExwlU5Dzz5lgsBgMDAzA+Pg6SJEF/fz8VOjw8DMYJ1EePO8Qqq6ur0NfXR2eT4PP5wChknhArZUKs4vV6acGQczabhUgkAkbBil693kguK2xkZISeCSsrK7CwsEDDbRSs/OcWqBYFCe38/HwxxEbCSi+9QIUtkAgis1ZO2O7uLpSjq6sLeGD51gnEicq8mVSv2XDNIFIqV3E5eGepEkjmeM0cV8VmIvMILBfi00DhmkFURYFIHz3GX10VBeZ5ZrCaApUzLhAXCcdqpopVjF9xxy8WZPmMVzGqqkCOKrbZbGm1fRqzWZpS2Pehdlwn0C7YdxwOB20fHByYmpPk2alUirYF7FMQhC9aG/1iQZanfNd8gbW3a/R7NZFIQFtbm+Gfn0Sc+uFOCAQCkM/nwlw3PwqFlnp7e09t6+MG9jUxMfGUpaWe1Wm1WO75/f40zomxzc1NyGQyYAaCYIeeHi9ZpYdxhCZZNhW33/AacBBvmd3OpA896WxW/aBHFry/hkr24TTXWrT7dNSmydaUdjQ37+DmFF6tb0CNGmeUfwIH0sS3Pm7dAAAAAElFTkSuQmCC",Ab="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAACs9JREFUeAHtWHmMVdUZ/93tvXffPjvzZpiFwswILkEpIIqMWlAWjVpBTTXGYk1tivoHWhurorVp2miiMRUaW7FWkSaS2IoLdYPUBkXBBkZRUdaZgWHWN2+767n9zrlvGJlhebX/td6bk3lz3z3n+53f9/uW84Bvr//xS/pPXm5vb1d7e3tlfMMrFAp5V2y/wl2FVazUOacCKC+dtDR275U///PU1NT5AUkLecwDH6PTRj6X/kySJRoyXOZae47seXvZ80uXfdL7Sa74UskA5Z0rdv6ipbZtVWY4RxO9b8zaqS7P81gkqct9ff0PNz428SF6xEoBKO29a/9D8WDiPpex0oB5xwyKJSXpFKuf4NJkxT2Q2ffI9KemPzwW5DgATcmmRGWy6n7bdmXmejjdcB0Gx6XhOAjODCA4S6PPbvEZQylrmLajtFaf8cDihsWJsXjG7XH7rR+/WR1JXSJDHgeeMyRuiz5bDHJMFuwxj8BkHDStSUFSJOy7tQtqXIUs0fdEpzPgQA7RirokTMrSeGpdEndndv+mOc/MWnhKBlsq2trhYhx7nA3XJWZMhtg1YVTcXQYWBSzbESN8UQjMoHeyLsLzQvTMhkWsMp2hcU0talaWwy64tJbrM8uOX19iknR29VkXj8UzDmAQAZXWIDCeP5j/lzEGmxY2LQtSUII7xFB+XQKWbMGwDKgTFXqHswmoDSo9M2HYJurvrYbTx2iODKNgiTX4Wq7jHWeDg9QQCGKMV8cCDFqkH9dl/hAL+Z8doTXaPd2Z3TnBgENsNayow+DhNByPdkWu5sPxHAx0DqHt8WY4tBEKVqR3ZuBqLgF0it4oAi3aEJq1PTShKXhSgKlUSmG26zNB9pgQOU0k11ikMcdyhNv2bexEMKkJMFa/ibJ5CRTShgg/PoxhA+WXJIg5hysXalLG7qf30lxLBJOdp7UMH5hvA8KmS+QUagrKSQGSxiROBAflFiPRSDvkpipM/nUK1VdVIDeQh605OLSlm9zpCUDfuaoR3R8fId94AlDXh0cwbcUUeCKAPBze0gdHsWhuAckL40jdXomqW5Iws46wwXXJXD/iT6vBEea4LrgrjJwBvSkgojExPYzz152N1lua8d6j2xCu1IlEhgIZVnQVkkoRGpAhhSTYg46I+lCthtfv3IyJl6dw7m+nITqV5pDK+HMzZxal4zPJySkBIBeuD5K7A5SZdtz5BdQyWcjXGWComJbADz9divU3v4xIlS42VXdOijKuJErZlAXNYDaDVq7g2Xkv4cZNV6N8WhnMQUuA1hIqdj+xn7KAJ2yMBExJDPoR7O+K/7UtG5m+LN666QNoVSrtnhYhEMZhGzf9/WrsfGU3tJAKPRZEYbAg3o3VxqGGFWx/ugPXrb0S2Z4CUHS/XhXC1gf/hUx3FpblHLMjotkpycXF3MRGJ/Jd8vTy3Oy/YscfOxCq0SATW2a/i+k3TsXBjkPk/ghiZTEkqwhchYRPX9uDyXMnIdefJ9dDMP3Zxi/x0vWvwcgbsF2nqLuv58Rx+KCOY9Apvgw/FxbILdVLyhFtoURMGbwwbOLVu99FIKrhzCVtiNWE0bKoWYCQSXtcqyzvonXJZPTvGER+yMS+jw7ANm3Un5fCrNnnQPEU5L8y0bMxDSXKN+uzy3jQ95wWIIq5yUHVZXHM+nELrGFH5DKv2BVMXtRAwUBgZA+de7sxUW+El6TkPeIhlRxj0mZSGUy8oA71C6rI+Kj7JH7PldD2k2YcerEXPRvSBFIlT53OxT0oupS0R2J0OSjH350YYn5xEe4WEny2kCFWGTJZIGsDOarTw1mPciGQHkqLxmHUijfa9XEpyzxveiJ5i8zhsBJc7Po1l7N44G89+OS5r1B/TSUSrWHqCj3kKSEf3NZJLlUwZWYjDKosufoczLwGtTzgR3q/BT1P0eqq6P94CB2kx8KggUlzGqAndSJexvCeHA6+1IdoPEzFNQiJ2zxBFJ8AYDHVMB+kFAH2vt4F6xUTA4cH0bq4GZffMY+iNQ/ToLRhuFi/4U+4ev6N8I5SlFOSk6nUvfDGWixb/n3E9Sgu/un50KsD2PyrbXj3mW2obKxAQA4gEA5RWWRQiBTZY8L22Ou4wlyDmsjmRZ9njxhdop5ajAq+a8D0KOro87K1C5DtNUSE8xEuD+Gddf9Ew2WV6OjYhe6hLpEH40Y5pk45E4NUsxf9rB0WlTxZUUQjq9cGsG7h65AMFUEliKAcQkAJUQpVMSFUh/bXWqM96MmdWIPAsXBnLq1GDbUsKdDjOq79w3wMUz4TZxKSSrIuhkcXP43LVl6EhF6G+kQTZs6ejZnnz0ZNsA5lkTJceO0M/PLspxBOhahKMDGv0G1h2YYFSDTEiB1yIFPgl1eUWOocv3CD+QALPQ4uf2IW8n0meI2KUHk7tPMIVrb9Bqs+vwOFXhPxRBwH3utBc+MkNKWa0LNrEPF4DPlBE/e9dTtWxB7Bns0HoFWqouGxqcNZ+Oxs5DtNSJ5vRzQLpeRBAW7kRZqsBVUMHchCDSg4RE3Au7/7gDpjYPmaa5HvKkBVVCQnxGAM2NADupimaRol7KRoDgY7M1j+5DK8/ej7eOPBrVj0wFw0XZqC9aVFuZSCypUFTSJPsNNoMIVU+NWLOnJHzcPkDb+v49rLFXLIWzl4IXoGG+neDO757GaYfZZY+Z3V7yPeFMZZ17SI/3e9vAddW3tx6Y/mcLOIEetPLvkLIjGdGCFO8grCwQiikSgFSxAq6U+GgqpQLRZuOePkGqS4ouOFNFqCRMnzKInKCOhBUQEk0szC+y+A2euQ6MnlE0PY8vvtiJRFBZuqqiFaFsGujV8gQVWGv5PtMzD/rjlirkx9czBCoALqMd35DQr3sUSpuMc9qQb3Y781ooeRptXjgcLIsKfSHgNwM8Ck79WBn4e0MhWPz3kRVakKfhQiMLIApNCdrCnHk1etR7RaF+WvceYEsAyFhafRRgOkPUXonNsQLf+otMyTAuQStG3LPNY8evwwQwA9DjAIjRbmqcGmVl9PBfDCdZvIqEdwVBzdNSBOa1wzRzoGiCfuzACev2UTRXxEVKcApRQNfASgMK0IEhhpkg3eso/5hWHc+W9N68Z3Jqj17RQfEhPvMtHDUdr2NemZyAwPI5POIprSRTLn7+TTJu459ANRsh5rWQ89HOScivyX6zERiYQRjcVEglYlahCKt2Cdo/Ik1ud0/+O2zxe1fx2PMhbgfuOrN66vvG1lxsmIDt77Winm/3BNStRqBaNBwS53J89nqkqaouNn14d96NuRoV8LCAhxJZPu9Agl40BAMCqe0Rxe7kRrTYPbmKDVSsv3Xjq34BSGTwnwqN1VaNPPK6tUamcwLkC+AJP8QzvzD+miH/Ek4VqZBg8ebrT7g34c/mhQ1FYBhpji7yhFhyskFS4XicBx93JBcHCkS9aR37765d7n1o/FMw4g5+nNoQ1vnhu5sHZK8KwZw84wE/zzX7Y4SO573olw7oRBbogzQu6UFQHKDyhNfC+AcZZHgImk50uf1vOqlVrsyG1dfc/BG+7ECX7hOtXPO0oiVNPwUOXqdWeEvjuDTKs8C3ItjvSFfvfF4N+OYNcTEAi+pBzT2KgxP8I5q47kWh359z9cO7Dqho5CRzdGy0PJAEeuEQtaAomwGw1p+C8uJWvYaaT5IcUsru3i2+v/+fo3XDNIGH8X+FsAAAAASUVORK5CYII=",Db="/assets/vscode-C5BXgFjm.svg",Mb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAACSFJREFUeAHtWG2MXFUZfs+Ze+/M7uwnLNhiqd1dWknaBETS+EO0JRWllRCjjSY2EhP/GP2BMSZG40fU4A/RRIs/FA1iJNaQaAKCiiG1dGu7okVKCK6lFWrb3a3b/ZiZnY/7ca7v855zZ2d3Z5chJIQfPcnZO3vuvec87/N+X6Ir48p4aw/V6TP79+/XpVKpv2twsC+uVHzj+4oaRMbUlDG+Mr5R+SCQFxphSL38O451SrwULUap1nGKe55XNPl8V3jq1PjcxMREmZc0z9TN9UGsc09974EH7v7oRz7+8ziOBiuVCimspnx+Pk9a56hULpHHV8/zyGdwURQxeEM9vT2U8lUxjlq9xr9TynmacjmPYn4mKOT5nqLJixfGv/qlL9w5NjZW4p0Tep1ABc4Lp185UyktbDGGCdFMYCMk3/cYVMAHatI8G/UGU8EgGGwQ+MxiwjOiYpGBpgYyUbVWlfuel+P3cpQw6LBRpyiOIZR5x+br9Zmzr3xuz23v+SmfG7cDpNcASv959fy/5i7PbE6M0dg8x4wVi0W5BnlfDtRMryfAPVJaZfLJ+5kecfX5vhymPdGCh/2YWdzM5/N6cmqarhq86uBDj/zmDn4s1w6P1w78gw8/ctdseXFrsdirw7Aum3qek4nl1UqTYbYUA8XBJjECCSqXTT2fIacCMmHWUqcjrUlYxj+JSRhkwLPAvw3V6zV95969T9AaWm6HPv3Bjw7+tV6rd+dyAKIdG+59BgkI1lRTmQJQkVyzNc0swi4zWmHbEAwzSawpejloRvF7iQi8MD9vRrZuPf/0U3/650pQbdFPzy6k5y9cdCDtIyY17tCMuUzN9iC24+YVQgVBQbQQcgTI1qAZAIbdglnYumag9VrNaobfZ0Ge23nzjltWYlql+l27dg1VGw2xOwvIsiJAmAnYYsKqNknMv7UwFEexPAdHkk3ZbuMYaxYogOFZD4yLaEqAJwmcSYndY++Ao8bQNVcPU5uxCmgvjzjkDYS5VNSMMAM7SqyXyqGwS8X3ARzPJHEijHR3F+m+b32denp6RAjTVLsW54NZ9Pb10Wc/fy+VywscRXwLhMFqZjyndb4joIVCIYfNEOtgj1Aw2MmAivbBDE+Yhkq1qBFCxQz+8swMPTt+QoBmppPZJoTCFV7/2G8fpSeePkqVcllCnhU+5hAY6Y6AVuMYLisGn6YOmAMHlhEfhVXccF6vhTlDU5MX6cTxMWa1u+lkSmVhC94m1FLM9/r6B+jFF07R9Zs385pPEZuInKW06ggo25Gq1+tyEBjKvLvY00df+/IXaeyZI8JIkyU3GxzA//zMOB09fNiBW2ss3bPgVOaTrDn2CdP+La/9Vto5Rioqj5nd3/3iZ/TcP/4uQX8lSMwbt2+neqNG/554SewUNkltnlsWptLE2neSiHnBXo2JOwMaaw2LE6+MokTsD1569MhhYXat8d7b3k8zl/5nYw85QLT+QOKASSHl4mmchUTQ9tm2i2zY2oWeLIjDFjGEjRYHwQG1apXedetOOvX8Seou9pDqpCYjK4jk+9TGWQlja2T1VasMTCEuQvXKBekskyw7IfupbDLYMjxCY0f+so59LhdO0qjzAZBi3F7pGka6CqjmGtIG4kRSIDZG+ZY6la46nu9ve+eN9PbrrmMvft7l9fa22SqczVBZik0FCLQXhXFnQMEoJM3KNclOqbXZ5YctgfjQ3g/TpelpKQMzvjoZYl5uGpdUdPvotLaNKmczArhF9RaczoigxcUK3f6BD9Lfxo9zbOxfJkDrO00pW9YTF48lRhtb6GQV2GsC9TiQIlRkhYMEthWNQnYWpEcuR9B+6g9PSo3aOloBq+z/lnUU0onL/+RsV3XKKG+QIqCjSDCpZQ32SsscYemwYXYiONz48WPrhi9qZZUsCYibSrmAn1o2tOrQ6+NcLuWSXqT1clpYUlltRrQq9OzecwddujTNJrBIayCkpnBNzIqq/PyW0RtsLHUg8bdZTq4YqwK+jqLUuIKD5MW0WQAvy9s8uCqn9+2+nS789xx98lP3UBbos5grlRe/b9sWG5ex0+DgIH3iwD2cxSY4i3VZ+3TnJUmHQLkUlU7SplAuIDhUjYyO0jDPi1x0SGdpKxIO9DXavuMmmp2doQOf/gwVuK0AIyFvslSUaGkEUcah7kQ9Bo2hWN62bZtoDt3t5NSUCIPQ2BFQ3tDYQxLRNvofjPt/+GPasXWLjXmuXCt0FWj76KamrWHedPMt9MtDj8rhNS5uuL60DSHHYszWwhnaiji5oDbo7xugcqXEewVpR0C7unQD9aF2DoUaNAwb4t0nX5ygsy+/LEzhPsxDCl6Ubq6wQB1aZaYD1+NDaJ9bDk86Udu+4FkT8R7KFswoc4eGruZrCEGSjoBOT08voDMsl0q0YcNG6ufYGEWhgJifm2MWu+S3AOErF9oysbYwvyCRYrG6SF2FLnQLYkJQL0BCYHxFESvXupk+OdAw+JSrrwblqtX5joAeO3asHHAbC7uUbAHpXTOXZ0BwFKgVRo9POAUGBKBSv7psxuqTjxMAn5lOxOvQjm1nbH+Slw8WRlgtl8oI2emrZ8+cbAe0bdCanpx6lu1I3E/6d20/D8G2wM7AQL/05AAC9aI0AzCw38f9EGzO93wBxN+raH5hXp7DCIJ8M/uE8vknkW4VLUlQCNInH3v8G+0wtUsDat++fQP3H/zJbIHB2BaYPZmNXhKBtLS2T5pnVYNBsIb2o7vYLQ4C/Ye8HnLuD3xrm9K9smBQPT7v4GQ4oe+aOnauuKfgz2689pq3tQPa9vPJ6dOno9179py/YXRkXxjGCpIvsrozBvGNCQP/25kIq7776JDZIjwbawCknU3CQbNat1mUsAMNb9roDfSyJy593Xtt1fNIPnbX3od+fejQ3Zs2XisMYNMqO0mZAc/MXBa7AosDA4O2PeGXoGb0Wwg5AXt6pn5bENvjss5UshB/LSsW8umGof65+77zbZAG+k2nql8piHnw4V8d2Hnru+/1C8URPqILVepAX48EcrsL2hYjwVo78/BYnYG/lKFg37V6yETqlL08btQalXMXzp34/eN//Mr3v/vNlxwWQ29wdFpivtX2vjKujDdt/B9Vn+PpjUxyeAAAAABJRU5ErkJggg==",Eb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAOdEVYdFNvZnR3YXJlAEZpZ21hnrGWYwAADQlJREFUeAHlWAtwXOV1/u5r3w/tQytpVyvLdoRlG+M4Ia4NxMZ2SELo4IRX6qEtbmEST6epoU3K0EIKZZpCmk7JNCRpaSkJEFJahhhSY9pJggfHJiHYxg2OJSzr4dV7tbvSah939z7y/XfltwyaSTLJTO7Mr6u797///f7vnPOdcy7wG35I+NUcyvbtO9Ldy5bdl2pftDHIY2JivDQ9XejPZDLPvfLK3l1vvnlgeCEL/WoAJpO+jcvfe7KnpyeqV6vw+QK44qoN6OpsR80wEAqF7ZaWNimXzT5+zz07b5/DYeOXAJDz7+d4S8LVk2eeLRbPXecN548n6UVElf1d4ebWW2o1/Y5auFXe8sF1UFUXNFWDbVtWKpWWPW73C3fd9emtfEjhMM974UUPGStXqi13/suj2nvf90nJ7Q3CsM48YV/kKduGVTVhTZdhFSZgl4uw9QoqhmV1PvOAjGoRy7uXw+P2QFEUqJoGRZbNLZs/otxy87XSPIzMeyixr/5wm/+qtU/WTxbtbBnS+6IKVjSpCKu8Kc/h4x/5vBVsy4ZRraA6nYPOUSvNoF4pQy+XoLu86P+ne+EO+hCLxWnqJprfB5fbjRXd3VY+Vxx7+OH7UmeTNB9AKfHo/j/Qlq/+93y2qj59ZQAjVQuPHNMxxnPdmkN2GhAB81LRQLPJ3LGNerUGvVIhc1XIdo3nMt0gT1azWPyTXZg8/Ar8/gBCTU0E2ox4cwInB/pw7bXXGZcsW6Nqqic7NTWhvfTSCxvnBZg+WLdyPTMYuiGC5mdzaAsrOI1rzp2rZOryqOpcZioWsjqB2Y17btkm0zY6vIRrWTiYrUKtzMDKjsB36GWUX34Cer1GE6vweLwo5KeguHwwayV8/IZtWL58pbNuMBidUs5HF//yvqclO7TysfUB6fIXC2gLqsKtnBeLh2ZrNtbHVFSIpnfGQoHAygbg4k3igir8gzMrpoRsTcJARUaz14VVUS+OFy0sG/wREl4NsiyjpuvoTKfxmZ33ohRKIZcrojg1gtdeexWlyiw6O7r/RD4foPvS1TdMztrySNlGUoAjU+CQOSSONU0K9o3XUSLQmCqhTJu7uYONzSqSHmCxT8b7OcfHuZWahYjc2NT+KWBpsgWr5CKSqTRWrLwMiZAPxpW34kAuj71yC5If345MScVoZhgfeP8Hcffdd3xDPR+g7Ap41kYMfO2njEJr7jcOP8EI/zteMOGTJAfgUr59kVdFhPQdmjRw6xIPWTUQ5vXaiBu7RwyaGziUM+AjvRNHDsH2h2DPFKFKFqTNd+CEbmHYDmBJQsbxumx95vprdv2scv0n2hLxnfMFidr+PaN+jauCZ/t0hNwSiMUZLr6IhDiggwTgI+ChkoUNZO4HI3W0hxRcGlGwoUXFnuE6JBLv5Zz/5b0Ov4wyI3XzM3+GbKWGUDiIob5+7F9+PbyhCKpqCFvaXTgwZSP71x/yptPp6MmTJ7PEUzvfxDLoT01c2BQeTzBlHUh5ZOg1XvJeG//XeKtQFqYFvp+p4aG1fswwwj+cdOGJXh390xa2LSGDx3XQ6sjOGhjf/ypa0x3UPRXmTBaDq7dCCcSoZx0wo51ILVoCpXmxE6QENyLAnbLeWUenLGRDElFhNsaKEKmniYQfkggUGLH5is2U1fDNADfzyMEy4nz65UEdFb3hr48eLiPokZxN6p4Atmeew/HMCNKpJPqydWQQRFcqBTmUgOShHgYjUCKtXKX9PMbOOQwJ4sUiank2yOLoLJliVFZr4sUMIhHQvGcbOD3GZ0x84YoAfjxmcBMSnt4UxBs0rWBcqhuwv/8s2rtXMXu4MD06gCNd1yEQiCCrRGDKPm5CobNxaC5cEBMX/GKeGrZjzpmy5TAlzNzulZGl39m8J4bYhGBrXauG+/bPIkmfDVK41n0jh23dXmdDJVcUOz1H0NPXh0XpFH5ysop4tAmSL4YyfEj5XA1riYCcJ31eCJC7FpPteoMdsSdqKupk81jWgGKdtQn+P5U3cdN7PMhzI29Rfja0aVjGQLmE4p4t2GjZ80VEl65CiOltYqAXb3d9DKYWhMWhKS6YXMeqNdzl3DLhnQDaDQZn6G/CnF5eRjWKL68dF5gbCud89nf8+Ku9RYQ1GVsZGAMELPz08Tdn8beXjcH942fw1Leeou+14wfMTqoviFk5Ah/9EpaMIufKpxg0FgqQOxHmqdUa5mWadSLX8RBrLoB4ztH3Juij3RTmYxOG85IJ6mShYMHyhfHYHTfDHWmGz+vB8//1DDLt66G6QkJr4RXJ25KoDpYjSQ2/XyhAkTXMhqyIa+FnGTIjWWc2oDNaH7sujN09VQzmTHxpUwDfOVzBvsEa/uFDAczu/jcEYjG4KCsqy6rx8Ukg0eVErKwwMGzFsYJVb7iKY94FATQbAIVpMRcIAuxs9Yx5JY5Omvwrr5VoWsmRnyf2l+BnceBRJNz7mozwvkecotTl0lCrljDZvhmqzWpHDVAT5lLo3Fqn/H7hDM7JjAAmAkWItl5tyI4Ys9MmPrU+gCpFfJzM7qQfHuW5Tmc3LBXub30KnlgbNIJTWTwODw5BX7oJJjOGSemuMT9YdaEEcPK7XbcuGiTqhQAb/mXXbEfTciUT928Ks6KxnVQndqQpQhct7PgApYR8TM2aeOiaIMr8zTIKePxfD0KLNzvmrdcqGAlfjgeviaDgbUFHawzThoIwJelzu2cQZXGRn8taCwDIIs5qTBbMUfpwyyov7mbZFaEdxS2RQVqZd6eohzEuXuLiIj9HfARqemF+/ZOIhaME12Cvvz8D39W3Y6Dkx3eOMbNoZQQ8CsYYYDdf5sUPB2qOpJ1657sAHDgdBNJctB7qr7GWU9HPKqVIk5oEWCrZTuWcL8xRSnYnczY8hYNodRnMt25omkJ3qCLr7YZf8eDJIyr+cVscO/+7jLxaR5qif3So5tSQkmWfUYd3MbFtn+WD45SMCBfyM+BWxDUEGQQJn0KtM5AnyC3L3TiUqTcaG38EJx74MJSmuGNa0RANDQ5g9e/ei/+fCSAaDOLr+6q4cY0Ho2RvjH48Rokq6tZZQXIhwIvoYMOBBfoIE/4Qgb4+oOPGy3zYdaSCo6N13H6FH1/9vyIOk4VDlJY3v/0wXMyvmqpwqDBqVUzIHTg85sZ9W9OsflyUIwubuzz40du6I1txbl6eI8NhcKEyY5qnqhmgl0l/aUTFapr5/l0FtDPZRhg8//w/08wGUmO+EkC490n2uwTnsCdjfGSUtN8IF7vVv3/JxKUtHqe5+otn89jAjLOE6/WM1hqBQRcxF6iDFthLTLPc12zJKQiErvWNG/jjTSHk2FP0ksk7P8KqmBVsuSq274Jnz6eh+GNOreewV9cxYcaheKKoS2G0JfzYtj6ICvO1iN7tV/pxYqzOIJQcIhiamGbQNXwwY50N6IKuLvU3dTuFSQfMrJAbAYEgNe7wxvV+luYq/vSbOQToj6vTGkanZqB9lynNH4bX64ab2jeaGcRgxw50LOlCrLUTb016UWbn+cJnW3CCrcEXny+I1g9Vo4ElSqBR1p0DdgLDD6jSO5rY0kvlg6yK7/pYqJEjTTgCrNMMX6JuffPVWQTIgijne6d8qO66jUwFHNOqp9irBhGJt2FkNoDjWRVeRrSP/vbQi9O4k5urM+iqIjjmeuodHw3hQI9O7Z2tv5uJoR/fuzseVa0kvyKMn6g19EkEGv0jxV0eYUCs7XQjxFxv9O9F0G05ZhX+p5CJyYlxmO+5CbrhIaMhAlHZ28hYt9iF19kCtIVlZibHmZxMNXpCRwd7mURUtmr9r3/vfDwXNu6RJeHUjqOF3NsjyPzHIsR+bwBtnS6KsX3OQ1U1jtY9l8NFefF4XM6wTAO9/ePQ13weibYU0skkK2YPDnNTXpd0Tj0q3G98oI7J/+xE+o8GEelqxvBXknF+iJo6G86FqS5/olg5/O3PNS297uH0Hw7Kz32+FcPsSb5G8wxRGgSTIu0l8l+G7A07zIkhGvHsxATyiRuglBUMDlFW6G+SVnWWrc6h41S0UhXuuj6E9piG9tsGEW4LmpW39jxIcPl3Z7BxKJGPPvGXvlU3fcHIT1mTk6a87hI3lpHJMFOe1+/B03++Bk3Mt6LPEEOwd6znbVx9+6MINCUQiiVZLHhPe5EIN9GLFRitR5ne3uitIpZQLTXULFeOPv9g7qVbH8A82fidPr8JdmOxrS8+5e64cqOkBjWRZkRa0oa/C/XI31k+v08OBPxO5hgbyZiF1G2KEb+C2YQtpCdEbPK5fcapt7FBglnV9cG9r1YP3PP7pYmfCrMa84FYyAdMFY3X8Ntb2EdnVDyyHFrU3tU32PczKxJtluPxGIplEwPHJ/wIzPgvupJEXeC3QExPV9Doe+WLAftFD6Wpqanzqi2fGI4n2u1IPGmnFi+7GfNlpl/zoXq93lQwmBR9u4rfxuPnTjEKD0h39egAAAAASUVORK5CYII=",Yg="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79109)'%3e%3cmask%20id='mask0_5437_79109'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='5'%20y='5'%20width='30'%20height='30'%3e%3cpath%20d='M5.6001%205.59961H34.4001V34.3996H5.6001V5.59961Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5437_79109)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.3001%207.39961C8.0614%207.39961%207.83248%207.49443%207.6637%207.66321C7.49492%207.832%207.4001%208.06091%207.4001%208.29961V28.0996H5.6001V8.29961C5.6001%207.58352%205.88456%206.89677%206.39091%206.39042C6.89726%205.88407%207.58401%205.59961%208.3001%205.59961H32.4138C33.6165%205.59961%2034.2186%207.05371%2033.3684%207.90421L18.5166%2022.7557H22.7001V20.8996H24.5001V23.206C24.5001%2023.5641%2024.3579%2023.9074%2024.1047%2024.1606C23.8515%2024.4138%2023.5081%2024.556%2023.1501%2024.556H16.7166L13.623%2027.6496H27.6501V16.3996H29.4501V27.6496C29.4501%2028.127%2029.2605%2028.5848%2028.9229%2028.9224C28.5853%2029.26%2028.1275%2029.4496%2027.6501%2029.4496H11.823L8.673%2032.5996H31.7001C31.9388%2032.5996%2032.1677%2032.5048%2032.3365%2032.336C32.5053%2032.1672%2032.6001%2031.9383%2032.6001%2031.6996V11.8996H34.4001V31.6996C34.4001%2032.4157%2034.1156%2033.1024%2033.6093%2033.6088C33.1029%2034.1151%2032.4162%2034.3996%2031.7001%2034.3996H7.5864C6.3837%2034.3996%205.7816%2032.9455%206.6318%2032.095L21.4272%2017.2996H17.3001V19.0996H15.5001V16.8496C15.5001%2016.4916%2015.6423%2016.1482%2015.8955%2015.895C16.1487%2015.6418%2016.4921%2015.4996%2016.8501%2015.4996H23.2272L26.3772%2012.3496H12.3501V23.5996H10.5501V12.3496C10.5501%2011.8722%2010.7397%2011.4144%2011.0773%2011.0768C11.4149%2010.7393%2011.8727%2010.5496%2012.3501%2010.5496H28.1772L31.3272%207.39961H8.3001Z'%20fill='black'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79109'%3e%3crect%20width='28.8'%20height='28.8'%20fill='white'%20transform='translate(5.6001%205.59961)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Ib="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5437_79100)'%3e%3cmask%20id='mask0_5437_79100'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='5'%20y='5'%20width='30'%20height='30'%3e%3cpath%20d='M5.6001%205.59961H34.4001V34.3996H5.6001V5.59961Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_5437_79100)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.3001%207.39961C8.0614%207.39961%207.83248%207.49443%207.6637%207.66321C7.49492%207.832%207.4001%208.06091%207.4001%208.29961V28.0996H5.6001V8.29961C5.6001%207.58352%205.88456%206.89677%206.39091%206.39042C6.89726%205.88407%207.58401%205.59961%208.3001%205.59961H32.4138C33.6165%205.59961%2034.2186%207.05371%2033.3684%207.90421L18.5166%2022.7557H22.7001V20.8996H24.5001V23.206C24.5001%2023.5641%2024.3579%2023.9074%2024.1047%2024.1606C23.8515%2024.4138%2023.5081%2024.556%2023.1501%2024.556H16.7166L13.623%2027.6496H27.6501V16.3996H29.4501V27.6496C29.4501%2028.127%2029.2605%2028.5848%2028.9229%2028.9224C28.5853%2029.26%2028.1275%2029.4496%2027.6501%2029.4496H11.823L8.673%2032.5996H31.7001C31.9388%2032.5996%2032.1677%2032.5048%2032.3365%2032.336C32.5053%2032.1672%2032.6001%2031.9383%2032.6001%2031.6996V11.8996H34.4001V31.6996C34.4001%2032.4157%2034.1156%2033.1024%2033.6093%2033.6088C33.1029%2034.1151%2032.4162%2034.3996%2031.7001%2034.3996H7.5864C6.3837%2034.3996%205.7816%2032.9455%206.6318%2032.095L21.4272%2017.2996H17.3001V19.0996H15.5001V16.8496C15.5001%2016.4916%2015.6423%2016.1482%2015.8955%2015.895C16.1487%2015.6418%2016.4921%2015.4996%2016.8501%2015.4996H23.2272L26.3772%2012.3496H12.3501V23.5996H10.5501V12.3496C10.5501%2011.8722%2010.7397%2011.4144%2011.0773%2011.0768C11.4149%2010.7393%2011.8727%2010.5496%2012.3501%2010.5496H28.1772L31.3272%207.39961H8.3001Z'%20fill='white'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_5437_79100'%3e%3crect%20width='28.8'%20height='28.8'%20fill='white'%20transform='translate(5.6001%205.59961)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Lb="data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_5436_78897)'%3e%3cpath%20d='M35.911%2020.0773C35.911%2019.7026%2035.552%2019.4866%2035.1114%2019.5939L4.79962%2027.0055C4.35812%2027.1135%204%2027.5052%204%2027.8792V35.4541C4%2035.8288%204.35812%2036.0455%204.79962%2035.9375L35.1114%2028.5266C35.552%2028.4187%2035.911%2028.0269%2035.911%2027.6523V20.0774V20.0773Z'%20fill='url(%23paint0_linear_5436_78897)'/%3e%3cpath%20d='M4%2019.8353C4%2020.21%204.35812%2020.6016%204.79962%2020.7097L35.1159%2028.1219C35.5573%2028.2299%2035.9155%2028.0133%2035.9155%2027.6393V20.0637C35.9155%2019.6897%2035.5573%2019.298%2035.1159%2019.19L4.79962%2011.7778C4.35812%2011.6699%204%2011.8858%204%2012.2603V19.8353V19.8353Z'%20fill='%23FF9800'/%3e%3cpath%20d='M35.911%204.51106C35.911%204.1365%2035.552%203.91973%2035.1114%204.02778L4.79962%2011.4387C4.35812%2011.5466%204%2011.9383%204%2012.313V19.8879C4%2020.2626%204.35812%2020.4786%204.79962%2020.3712L35.1114%2012.9596C35.552%2012.8517%2035.911%2012.46%2035.911%2012.086V4.51106Z'%20fill='%23FF9800'/%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_5436_78897'%20x1='1762.84'%20y1='981.852'%20x2='1845.15'%20y2='624.882'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF9700'/%3e%3cstop%20offset='0.53'%20stop-color='%23F48E00'/%3e%3cstop%20offset='1'%20stop-color='%23D06F00'/%3e%3c/linearGradient%3e%3cclipPath%20id='clip0_5436_78897'%3e%3crect%20width='32'%20height='32'%20fill='white'%20transform='translate(4%204)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";var Pb=x("<img data-component=app-icon>");const Fb={vscode:Db,cursor:wb,zed:Yg,"file-explorer":$b,finder:kb,terminal:Tb,iterm2:Cb,ghostty:_b,warp:Mb,xcode:Eb,"android-studio":xb,antigravity:yb,textmate:Ab,powershell:Sb,"sublime-text":Lb},Rb={zed:{light:Yg,dark:Ib}},xd=()=>typeof document!="object"?"light":document.documentElement.dataset.colorScheme==="dark"?"dark":"light",yd=e=>{const[t,n]=rn(e,["id","class","classList","alt","draggable"]),[r,i]=ke(xd());return Mn(()=>{const o=()=>i(xd()),a=new MutationObserver(o);a.observe(document.documentElement,{attributes:!0,attributeFilter:["data-color-scheme"]}),o(),vt(()=>a.disconnect())}),(()=>{var o=Pb();return Nr(o,bt(n,{get src(){return Rb[t.id]?.[r()]??Fb[t.id]},get alt(){return t.alt??""},get draggable(){return t.draggable??!1},get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}),!1,!1),o})()},[zb,wd]=ke();let Pa;function vo(e,t=3e3){Pa&&clearTimeout(Pa),wd(e),Pa=setTimeout(()=>wd(void 0),t)}const $d=zb;var Ob=x('<span class="hidden sm:inline">New Project'),Nb=x('<div class="flex items-center justify-between gap-2 w-fit"><span class="text-13-regular hidden xl:inline flex-1 opacity-50">'),Bb=x('<span class="text-12-regular text-text-weak hidden xl:inline">⌘K'),qb=x('<span class="inline-flex items-center gap-1.5"><span class="hidden sm:inline">Preview'),jb=x('<span class="inline-flex items-center gap-1.5"><span class="hidden sm:inline">Publish'),kd=x('<div class="flex size-5 shrink-0 items-center justify-center [&amp;_[data-component=app-icon]]:size-5">'),Vb=x('<div class="flex items-center"><div class="flex h-[24px] box-border items-center rounded-md border border-border-weak-base bg-surface-panel overflow-hidden">'),Hb=x('<div class="hidden xl:flex items-center">'),Ub=x('<div class="flex items-center gap-1 sm:gap-2">'),Wb=x('<div class="flex items-center gap-1">');const Kb=["vscode","cursor","zed","textmate","antigravity","finder","terminal","iterm2","ghostty","warp","xcode","android-studio","powershell","sublime-text"],Gb=[{id:"vscode",label:"session.header.open.app.vscode",icon:"vscode",openWith:"Visual Studio Code"},{id:"cursor",label:"session.header.open.app.cursor",icon:"cursor",openWith:"Cursor"},{id:"zed",label:"session.header.open.app.zed",icon:"zed",openWith:"Zed"},{id:"textmate",label:"session.header.open.app.textmate",icon:"textmate",openWith:"TextMate"},{id:"antigravity",label:"session.header.open.app.antigravity",icon:"antigravity",openWith:"Antigravity"},{id:"terminal",label:"session.header.open.app.terminal",icon:"terminal",openWith:"Terminal"},{id:"iterm2",label:"session.header.open.app.iterm2",icon:"iterm2",openWith:"iTerm"},{id:"ghostty",label:"session.header.open.app.ghostty",icon:"ghostty",openWith:"Ghostty"},{id:"warp",label:"session.header.open.app.warp",icon:"warp",openWith:"Warp"},{id:"xcode",label:"session.header.open.app.xcode",icon:"xcode",openWith:"Xcode"},{id:"android-studio",label:"session.header.open.app.androidStudio",icon:"android-studio",openWith:"Android Studio"},{id:"sublime-text",label:"session.header.open.app.sublimeText",icon:"sublime-text",openWith:"Sublime Text"}],Yb=[{id:"vscode",label:"session.header.open.app.vscode",icon:"vscode",openWith:"code"},{id:"cursor",label:"session.header.open.app.cursor",icon:"cursor",openWith:"cursor"},{id:"zed",label:"session.header.open.app.zed",icon:"zed",openWith:"zed"},{id:"powershell",label:"session.header.open.app.powershell",icon:"powershell",openWith:"powershell"},{id:"sublime-text",label:"session.header.open.app.sublimeText",icon:"sublime-text",openWith:"Sublime Text"}],Xb=[{id:"vscode",label:"session.header.open.app.vscode",icon:"vscode",openWith:"code"},{id:"cursor",label:"session.header.open.app.cursor",icon:"cursor",openWith:"cursor"},{id:"zed",label:"session.header.open.app.zed",icon:"zed",openWith:"zed"},{id:"sublime-text",label:"session.header.open.app.sublimeText",icon:"sublime-text",openWith:"Sublime Text"}],Zb=e=>{if(e.platform==="desktop"&&e.os)return e.os;if(typeof navigator!="object")return"unknown";const t=navigator.platform||navigator.userAgent;return/Mac/i.test(t)?"macos":/Win/i.test(t)?"windows":/Linux/i.test(t)?"linux":"unknown"},Qb=(e,t)=>{nt({variant:"error",title:e.t("common.requestFailed"),description:t instanceof Error?t.message:String(t)})};function Jb(){const e=Hr(),t=Li();eo(),Pi();const n=Zf(),r=aa(),i=hn();zn();const o=br();Fi();const a=dr(),d=Ri(),[,c]=ql(),{params:u}=Ur();function g(){Kn(async()=>{const{DialogCreateProject:z}=await import("./dialog-create-project-hV4lJGVR.js");return{DialogCreateProject:z}},__vite__mapDeps([0,1,2])).then(({DialogCreateProject:z})=>{a.show(()=>s(z,{onSelect:q=>{if(!q)return;const Q=Array.isArray(q)?q[0]:q;Q&&(e.projects.open(Q),d(`/${Ps(Q)}/session`))}}))})}const f=T(()=>uv(u.dir)??""),m=T(()=>{const z=f();if(z)return e.projects.list().find(q=>q.worktree===z||q.sandboxes?.includes(z))});T(()=>{const z=m();return z?z.name||Sn(z.worktree):Sn(f())});const p=T(()=>t.keybind("file.open")),w=T(()=>Zb(r)),[h,k]=St({finder:!0}),v=T(()=>w()==="macos"?Gb:w()==="windows"?Yb:Xb),C=T(()=>w()==="macos"?{label:"session.header.open.finder",icon:"finder"}:w()==="windows"?{label:"session.header.open.fileExplorer",icon:"file-explorer"}:{label:"session.header.open.fileManager",icon:"finder"});$e(()=>{if(r.platform!=="desktop"||!r.checkAppExists)return;const z=v();k(Object.fromEntries(z.map(q=>[q.id,void 0]))),Promise.all(z.map(q=>Promise.resolve(r.checkAppExists?.(q.openWith)).then(Q=>!!Q).catch(()=>!1).then(Q=>[q.id,Q]))).then(q=>{k(Object.fromEntries(q))})});const y=T(()=>[{id:"finder",label:i.t(C().label),icon:C().icon},...v().filter(z=>h[z.id]).map(z=>({...z,label:i.t(z.label)}))]),[b,_]=Xr(Zr.global("open.app"),St({app:"finder"})),[$,D]=St({open:!1}),[L,V]=St({app:void 0}),[K,I]=St({running:!1}),U=T(()=>r.platform==="desktop"&&!!r.openPath&&n.isLocal()),Y=T(()=>y().find(z=>z.id===b.app)??y()[0]??{id:"finder",label:C().label,icon:C().icon}),S=T(()=>L.app!==void 0);T(()=>K.running);const M=T(()=>Qf(u.id?o.data.message[u.id]:void 0,o.data.agent)),A=z=>{y().some(q=>q.id===z)&&_("app",z)},F=z=>{if(S()||!U()||!r.openPath)return;const q=f();if(!q)return;const Q=y().find(H=>H.id===z),j=Q&&"openWith"in Q?Q.openWith:void 0;V("app",z),r.openPath(q,j).catch(H=>Qb(i,H)).finally(()=>{V("app",void 0)})},N=T(()=>document.getElementById("opencode-titlebar-left")),X=T(()=>document.getElementById("opencode-titlebar-center")),B=T(()=>document.getElementById("opencode-titlebar-right")),O=()=>g();return[s(E,{get when(){return N()},children:z=>s(qo,{get mount(){return z()},get children(){return s(kt,{variant:"secondary",size:"small",class:"h-6 w-7 px-0 text-12-medium sm:w-auto sm:px-3 sm:text-13-medium",onClick:O,"aria-label":"New Project",get children(){return[s(Ue,{name:"plus",size:"small",class:"sm:mr-1"}),Ob()]}})}})}),s(E,{get when(){return X()},children:z=>s(qo,{get mount(){return z()},get children(){return s(or,{placement:"bottom",get title(){return i.t("session.header.searchFiles")},get keybind(){return p()??""},get children(){return s(kt,{variant:"ghost",class:"titlebar-icon hidden h-7 w-8 min-w-0 px-0 justify-center items-center gap-2 rounded-full border border-border-base/40 bg-surface-base/60 lg:flex lg:w-48 lg:justify-between lg:px-3 xl:w-[420px]",onClick:()=>t.trigger("file.open"),get"aria-label"(){return i.t("session.header.searchFiles")},get children(){return[(()=>{var q=Nb(),Q=q.firstChild;return l(q,s(Ue,{name:"magnifying-glass",size:"small",class:"shrink-0"}),Q),l(Q,()=>i.t("session.header.searchFiles")),q})(),Bb()]}})}})}})}),s(E,{get when(){return B()},children:z=>s(qo,{get mount(){return z()},get children(){var q=Ub();return l(q,s(or,{placement:"bottom",get title(){return i.t("session.header.searchFiles")},get keybind(){return p()??""},get children(){return s(kt,{variant:"ghost",class:"titlebar-icon flex h-6 w-7 min-w-0 items-center justify-center rounded-full border border-border-base/40 bg-surface-base/60 px-0 lg:hidden",onClick:()=>t.trigger("file.open"),get"aria-label"(){return i.t("session.header.searchFiles")},get children(){return s(Ue,{name:"magnifying-glass",size:"small",class:"shrink-0"})}})}}),null),l(q,s(kt,{size:"small",class:"h-6 w-7 px-0 text-12-medium bg-white text-black hover:bg-white/90 sm:w-auto sm:px-3 sm:text-13-medium dark:bg-black dark:text-white dark:hover:bg-black/90",onClick:()=>c({view:"browser"}),"aria-label":"Preview",get children(){var Q=qb(),j=Q.firstChild;return l(Q,s(fv,{class:"size-3.5"}),j),Q}}),null),l(q,s(kt,{size:"small",class:"h-6 w-7 px-0 text-12-medium bg-white text-black hover:bg-white/90 sm:w-auto sm:px-3 sm:text-13-medium",onClick:()=>{},"aria-label":"Publish",get children(){var Q=jb(),j=Q.firstChild;return l(Q,s(ki,{class:"size-3.5"}),j),Q}}),null),l(q,s(E,{get when(){return f()},get children(){var Q=Hb();return l(Q,s(E,{get when(){return U()},get fallback(){return Wb()},get children(){var j=Vb(),H=j.firstChild;return l(H,s(kt,{variant:"ghost",class:"rounded-none h-full px-0.5 border-none shadow-none disabled:!cursor-default",get classList(){return{"bg-surface-raised-base-active":S()}},onClick:()=>F(Y().id),get disabled(){return S()},get"aria-label"(){return i.t("session.header.open.ariaLabel",{app:Y().label})},get children(){var J=kd();return l(J,s(E,{get when(){return S()},get fallback(){return s(yd,{get id(){return Y().icon}})},get children(){return s(Ti,{class:"size-3.5",get style(){return{color:M()??"var(--icon-base)"}}})}})),J}}),null),l(H,s(Ye,{gutter:4,placement:"bottom-end",get open(){return $.open},onOpenChange:J=>D("open",J),get children(){return[s(Ye.Trigger,{as:Ot,icon:"chevron-down",variant:"ghost",get disabled(){return S()},class:"rounded-none h-full w-[20px] p-0 border-none shadow-none data-[expanded]:bg-surface-raised-base-active disabled:!cursor-default",get classList(){return{"bg-surface-raised-base-active":S()}},get"aria-label"(){return i.t("session.header.open.menu")}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"[&_[data-slot=dropdown-menu-item]]:pl-1 [&_[data-slot=dropdown-menu-radio-item]]:pl-1 [&_[data-slot=dropdown-menu-radio-item]+[data-slot=dropdown-menu-radio-item]]:mt-1",get children(){return s(Ye.Group,{get children(){return[s(Ye.GroupLabel,{class:"!px-1 !py-1",get children(){return i.t("session.header.openIn")}}),s(Ye.RadioGroup,{class:"mt-1",get value(){return Y().id},onChange:J=>{Kb.includes(J)&&A(J)},get children(){return s(Oe,{get each(){return y()},children:J=>s(Ye.RadioItem,{get value(){return J.id},get disabled(){return S()},onSelect:()=>{D("open",!1),F(J.id)},get children(){return[(()=>{var le=kd();return l(le,s(yd,{get id(){return J.icon}})),le})(),s(Ye.ItemLabel,{get children(){return J.label}}),s(Ye.ItemIndicator,{get children(){return s(Ue,{name:"check-small",size:"small",class:"text-icon-weak"})}})]}})})}})]}})}})}})]}}),null),j}})),Q}}),null),q}})})]}function Is(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(t(r,n,e))return r}}var ex={};jl(ex,{Accordion:()=>us,Content:()=>Qg,Header:()=>Jg,Item:()=>tm,Root:()=>nm,Trigger:()=>rm,useAccordionContext:()=>rc});var Xg=as();function Zg(){const e=os(Xg);if(e===void 0)throw new Error("[kobalte]: `useAccordionItemContext` must be used within a `Accordion.Item` component");return e}function Qg(e){const t=Zg(),n=t.generateId("content"),r=ur({id:n},e),[i,o]=rn(r,["id","style"]);return $e(()=>vt(t.registerContentId(i.id))),s(xv,bt({role:"region",get"aria-labelledby"(){return t.triggerId()},get style(){return la({"--kb-accordion-content-height":"var(--kb-collapsible-content-height)","--kb-accordion-content-width":"var(--kb-collapsible-content-width)"},i.style)}},o))}function Jg(e){const t=Jf();return s(xr,bt({as:"h3"},()=>t.dataset(),e))}var em=as();function rc(){const e=os(em);if(e===void 0)throw new Error("[kobalte]: `useAccordionContext` must be used within a `Accordion.Root` component");return e}function tm(e){const t=rc(),n=`${t.generateId("item")}-${to()}`,r=ur({id:n},e),[i,o]=rn(r,["value","disabled"]),[a,d]=ke(),[c,u]=ke(),g=()=>t.listState().selectionManager(),f=()=>g().isSelected(i.value),m={value:()=>i.value,triggerId:a,contentId:c,generateId:ca(()=>o.id),registerTriggerId:Fs(d),registerContentId:Fs(u)};return s(Xg.Provider,{value:m,get children(){return s(yv,bt({get open(){return f()},get disabled(){return i.disabled}},o))}})}function nm(e){let t;const n=`accordion-${to()}`,r=ur({id:n,multiple:!1,collapsible:!1,shouldFocusWrap:!0},e),[i,o]=rn(r,["id","ref","value","defaultValue","onChange","multiple","collapsible","shouldFocusWrap","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]),[a,d]=ke([]),{DomCollectionProvider:c}=gv({items:a,onItemsChange:d}),u=mv({selectedKeys:()=>i.value,defaultSelectedKeys:()=>i.defaultValue,onSelectionChange:m=>i.onChange?.(Array.from(m)),disallowEmptySelection:()=>!i.multiple&&!i.collapsible,selectionMode:()=>i.multiple?"multiple":"single",dataSource:a});u.selectionManager().setFocusedKey("item-1");const g=hv({selectionManager:()=>u.selectionManager(),collection:()=>u.collection(),disallowEmptySelection:()=>u.selectionManager().disallowEmptySelection(),shouldFocusWrap:()=>i.shouldFocusWrap,disallowTypeAhead:!0,allowsTabNavigation:!0},()=>t),f={listState:()=>u,generateId:ca(()=>i.id)};return s(c,{get children(){return s(em.Provider,{value:f,get children(){return s(xr,bt({as:"div",get id(){return i.id},ref(m){var p=Br(w=>t=w,i.ref);typeof p=="function"&&p(m)},get onKeyDown(){return Gr([i.onKeyDown,g.onKeyDown])},get onMouseDown(){return Gr([i.onMouseDown,g.onMouseDown])},get onFocusIn(){return Gr([i.onFocusIn])},get onFocusOut(){return Gr([i.onFocusOut,g.onFocusOut])}},o))}})}})}function rm(e){let t;const n=rc(),r=Zg(),i=Jf(),o=r.generateId("trigger"),a=ur({id:o},e),[d,c]=rn(a,["ref","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]);pv({getItem:()=>({ref:()=>t,type:"item",key:r.value(),textValue:"",disabled:i.disabled()})});const u=vv({key:()=>r.value(),selectionManager:()=>n.listState().selectionManager(),disabled:()=>i.disabled(),shouldSelectOnPressUp:!0},()=>t),g=f=>{["Enter"," "].includes(f.key)&&f.preventDefault(),vr(f,d.onKeyDown),vr(f,u.onKeyDown)};return $e(()=>vt(r.registerTriggerId(c.id))),s(bv,bt({ref(f){var m=Br(p=>t=p,d.ref);typeof m=="function"&&m(f)},get"data-key"(){return u.dataKey()},get onPointerDown(){return Gr([d.onPointerDown,u.onPointerDown])},get onPointerUp(){return Gr([d.onPointerUp,u.onPointerUp])},get onClick(){return Gr([d.onClick,u.onClick])},onKeyDown:g,get onMouseDown(){return Gr([d.onMouseDown,u.onMouseDown])},get onFocus(){return Gr([d.onFocus,u.onFocus])}},c))}var us=Object.assign(nm,{Content:Qg,Header:Jg,Item:tm,Trigger:rm});function tx(e){const[t,n]=rn(e,["class","classList"]);return s(us,bt(n,{"data-component":"accordion",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}))}function nx(e){const[t,n]=rn(e,["class","classList"]);return s(us.Item,bt(n,{"data-slot":"accordion-item",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}))}function rx(e){const[t,n]=rn(e,["class","classList","children"]);return s(us.Header,bt(n,{"data-slot":"accordion-header",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}},get children(){return t.children}}))}function ix(e){const[t,n]=rn(e,["class","classList","children"]);return s(us.Trigger,bt(n,{"data-slot":"accordion-trigger",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}},get children(){return t.children}}))}function sx(e){const[t,n]=rn(e,["class","classList","children"]);return s(us.Content,bt(n,{"data-slot":"accordion-content",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}},get children(){return t.children}}))}const Bn=Object.assign(tx,{Item:nx,Header:rx,Trigger:ix,Content:sx});function oo(e){return s(Bn.Header,{"data-component":"sticky-accordion-header",get classList(){return{...e.classList??{},[e.class??""]:!!e.class}},get children(){return e.children}})}var ox=x("<div class=scroll-view__thumb style=z-index:100>"),ax=x('<div><div class="scroll-view__viewport bg-background-stronger"tabindex=0 role=region>');const lx=e=>{if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey))switch(e.key){case"PageDown":return"page-down";case"PageUp":return"page-up";case"Home":return"home";case"End":return"end";case"ArrowUp":return"up";case"ArrowDown":return"down"}};function ba(e){const t=xn(),n=bt({orientation:"vertical"},e),[r,i,o]=rn(n,["class","children","viewportRef","orientation","style"],["onScroll","onWheel","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel","onPointerDown","onClick","onKeyDown"]);let a,d,c;const[u,g]=St({isHovered:!1,isDragging:!1,thumbHeight:0,thumbTop:0,showThumb:!1}),f=()=>u.isHovered,m=()=>u.isDragging,p=()=>u.thumbHeight,w=()=>u.thumbTop,h=()=>u.showThumb,k=()=>{if(!d)return;const{scrollTop:_,scrollHeight:$,clientHeight:D}=d;if($<=D||$===0){g("showThumb",!1);return}g("showThumb",!0);const L=8,V=D-L*2,K=32;let I=D/$*V;I=Math.max(I,K);const U=$-D,Y=V-I,S=U>0?_/U*Y:0,M=L+Math.max(0,Math.min(S,Y));g("thumbHeight",I),g("thumbTop",M)};Mn(()=>{r.viewportRef&&r.viewportRef(d);const _=new ResizeObserver(()=>{k()});_.observe(d),d.firstElementChild&&_.observe(d.firstElementChild),vt(()=>{_.disconnect()}),k()});let v=0,C=0;const y=_=>{_.preventDefault(),_.stopPropagation(),g("isDragging",!0),v=_.clientY,C=d.scrollTop,c.setPointerCapture(_.pointerId);const $=L=>{const V=L.clientY-v,{scrollHeight:K,clientHeight:I}=d,U=K-I,Y=I-p();if(Y>0){const S=V*(U/Y);d.scrollTop=C+S}},D=L=>{g("isDragging",!1),c.releasePointerCapture(L.pointerId),c.removeEventListener("pointermove",$),c.removeEventListener("pointerup",D)};c.addEventListener("pointermove",$),c.addEventListener("pointerup",D)},b=_=>{if(document.activeElement&&["INPUT","TEXTAREA","SELECT"].includes(document.activeElement.tagName))return;const $=lx(_);if(!$)return;const D=d.clientHeight*.8,L=40;switch($){case"page-down":_.preventDefault(),d.scrollBy({top:D,behavior:"smooth"});break;case"page-up":_.preventDefault(),d.scrollBy({top:-D,behavior:"smooth"});break;case"home":_.preventDefault(),d.scrollTo({top:0,behavior:"smooth"});break;case"end":_.preventDefault(),d.scrollTo({top:d.scrollHeight,behavior:"smooth"});break;case"up":_.preventDefault(),d.scrollBy({top:-L,behavior:"smooth"});break;case"down":_.preventDefault(),d.scrollBy({top:L,behavior:"smooth"});break}};return(()=>{var _=ax(),$=_.firstChild;_.addEventListener("pointerleave",()=>g("isHovered",!1)),_.addEventListener("pointerenter",()=>g("isHovered",!0));var D=a;typeof D=="function"?Lt(D,_):a=_,Nr(_,bt({get class(){return`scroll-view ${r.class||""}`},get style(){return r.style}},o),!1,!0),$.$$keydown=V=>{b(V),typeof i.onKeyDown=="function"&&i.onKeyDown(V)},Rt($,"click",i.onClick,!0),Rt($,"pointerdown",i.onPointerDown,!0),Rt($,"touchcancel",i.onTouchCancel),Rt($,"touchend",i.onTouchEnd,!0),Rt($,"touchmove",i.onTouchMove,!0),Rt($,"touchstart",i.onTouchStart,!0),Rt($,"wheel",i.onWheel),$.addEventListener("scroll",V=>{k(),typeof i.onScroll=="function"&&i.onScroll(V)});var L=d;return typeof L=="function"?Lt(L,$):d=$,l($,()=>r.children),l(_,s(E,{get when(){return h()},get children(){var V=ox();V.$$pointerdown=y;var K=c;return typeof K=="function"?Lt(K,V):c=V,G(I=>{var U=f()||m(),Y=m(),S=`${p()}px`,M=`translateY(${w()}px)`;return U!==I.e&&ue(V,"data-visible",I.e=U),Y!==I.t&&ue(V,"data-dragging",I.t=Y),S!==I.a&&Je(V,"height",I.a=S),M!==I.o&&Je(V,"transform",I.o=M),I},{e:void 0,t:void 0,a:void 0,o:void 0}),V}}),null),G(()=>ue($,"aria-label",t.t("ui.scrollView.ariaLabel"))),_})()}Kt(["touchstart","touchmove","touchend","pointerdown","click","keydown"]);const bo=e=>Math.ceil(e/4),im=(e,t)=>e/t*100,cx=(e,t)=>Math.round(im(e,t)*10)/10,dx=e=>e.type==="text"?e.text.length:e.type==="file"?e.source?.text.value.length??0:e.type==="agent"?e.source?.value.length??0:0,ux=e=>{if(e.type==="text")return{assistant:e.text.length,tool:0};if(e.type==="reasoning")return{assistant:e.text.length,tool:0};if(e.type!=="tool")return{assistant:0,tool:0};const t=Object.keys(e.state.input).length*16;return e.state.status==="pending"?{assistant:0,tool:t+e.state.raw.length}:e.state.status==="completed"?{assistant:0,tool:t+e.state.output.length}:e.state.status==="error"?{assistant:0,tool:t+e.state.error.length}:{assistant:0,tool:t}},_d=(e,t)=>[{key:"system",tokens:e.system},{key:"user",tokens:e.user},{key:"assistant",tokens:e.assistant},{key:"tool",tokens:e.tool},{key:"other",tokens:e.other}].filter(n=>n.tokens>0).map(n=>({key:n.key,tokens:n.tokens,width:im(n.tokens,t),percent:cx(n.tokens,t)}));function fx(e){if(!e.input)return[];const t=e.messages.reduce((d,c)=>{const u=e.parts[c.id]??[];if(c.role==="user"){const f=u.reduce((m,p)=>m+dx(p),0);return{...d,user:d.user+f}}if(c.role!=="assistant")return d;const g=u.reduce((f,m)=>{const p=ux(m);return{assistant:f.assistant+p.assistant,tool:f.tool+p.tool}},{assistant:0,tool:0});return{...d,assistant:d.assistant+g.assistant,tool:d.tool+g.tool}},{system:e.systemPrompt?.length??0,user:0,assistant:0,tool:0}),n={system:bo(t.system),user:bo(t.user),assistant:bo(t.assistant),tool:bo(t.tool)},r=n.system+n.user+n.assistant+n.tool;if(r<=e.input)return _d({...n,other:e.input-r},e.input);const i=e.input/r,o={system:Math.floor(n.system*i),user:Math.floor(n.user*i),assistant:Math.floor(n.assistant*i),tool:Math.floor(n.tool*i)},a=o.system+o.user+o.assistant+o.tool;return _d({...o,other:Math.max(0,e.input-a)},e.input)}function gx(e){return{number(t){return t===void 0||t===null?"—":t.toLocaleString(e)},percent(t){return t===void 0||t===null?"—":t.toLocaleString(e)+"%"},time(t){return t?ll.fromMillis(t).setLocale(e).toLocaleString(ll.DATETIME_MED):"—"}}}var mx=x('<div class="flex flex-col gap-1"><div class="text-12-regular text-text-weak"></div><div class="text-12-medium text-text-strong">'),hx=x('<div class="flex items-center justify-between gap-2 w-full"><div class="min-w-0 truncate"> <span class=text-text-base>• </span></div><div class="flex items-center gap-3"><div class="shrink-0 text-12-regular text-text-weak">'),px=x("<div class=p-3>"),vx=x('<div class="flex flex-col gap-2"><div class="text-12-regular text-text-weak"></div><div class="h-2 w-full rounded-full bg-surface-base overflow-hidden flex"></div><div class="flex flex-wrap gap-x-3 gap-y-1"></div><div class="hidden text-11-regular text-text-weaker">'),bx=x('<div class="px-6 pt-4 pb-10 flex flex-col gap-10"><div class="grid grid-cols-1 @[32rem]:grid-cols-2 gap-4"></div><div class="flex flex-col gap-2"><div class="text-12-regular text-text-weak">'),xx=x("<div class=h-full>"),yx=x('<div class="flex items-center gap-1 text-11-regular text-text-weak"><div class="size-2 rounded-sm"></div><div></div><div class=text-text-weaker>%'),wx=x('<div class="flex flex-col gap-2"><div class="text-12-regular text-text-weak"></div><div class="border border-border-base rounded-md bg-surface-base px-3 py-2">');const Cd={system:"var(--syntax-info)",user:"var(--syntax-success)",assistant:"var(--syntax-property)",tool:"var(--syntax-warning)",other:"var(--syntax-comment)"};function $x(e){return(()=>{var t=mx(),n=t.firstChild,r=n.nextSibling;return l(n,()=>e.label),l(r,()=>e.value),t})()}function kx(e){const t=T(()=>{const n=e.getParts(e.message.id),r=JSON.stringify({message:e.message,parts:n},null,2);return{name:`${e.message.role}-${e.message.id}.json`,contents:r,cacheKey:da(r)}});return s(wv,{mode:"text",get file(){return t()},overflow:"wrap",class:"select-text",onRendered:()=>requestAnimationFrame(e.onRendered)})}function _x(e){return s(Bn.Item,{get value(){return e.message.id},get children(){return[s(oo,{get children(){return s(Bn.Trigger,{get children(){var t=hx(),n=t.firstChild,r=n.firstChild,i=r.nextSibling;i.firstChild;var o=n.nextSibling,a=o.firstChild;return l(n,()=>e.message.role,r),l(i,()=>e.message.id,null),l(a,()=>e.time(e.message.time.created)),l(o,s(Ue,{name:"chevron-grabber-vertical",size:"small",class:"shrink-0 text-text-weak"}),null),t}})}}),s(Bn.Content,{class:"bg-background-base",get children(){var t=px();return l(t,s(kx,{get message(){return e.message},get getParts(){return e.getParts},get onRendered(){return e.onRendered}})),t}})]}})}const Sd=[],Td=[];function Cx(){const e=br(),t=hn(),n=Vl(),{params:r,view:i}=Ur(),o=T(()=>r.id?e.session.get(r.id):void 0),a=T(()=>{const I=r.id;return I?e.data.message[I]??[]:Sd},Sd,{equals:_i}),d=T(()=>a().filter(I=>I.role==="user"),Td,{equals:_i}),c=T(()=>{const I=o()?.revert?.messageID;return I?d().filter(U=>U.id<I):d()},Td,{equals:_i}),u=T(()=>new Intl.NumberFormat(t.intl(),{style:"currency",currency:"USD"})),g=T(()=>eg(a(),n.all())),f=T(()=>g().context),m=T(()=>gx(t.intl())),p=T(()=>u().format(g().totalCost)),w=T(()=>{const I=a(),U=I.reduce((S,M)=>S+(M.role==="user"?1:0),0),Y=I.reduce((S,M)=>S+(M.role==="assistant"?1:0),0);return{all:I.length,user:U,assistant:Y}}),h=T(()=>{const U=Is(c(),S=>!!S.system)?.system;if(!U)return;const Y=U.trim();if(Y)return Y}),k=T(()=>{const I=f();return I?I.providerLabel:"—"}),v=T(()=>{const I=f();return I?I.modelLabel:"—"}),C=T(Pt(()=>[f()?.message.id,f()?.input,a().length,h()],()=>{const I=f();return I?.input?fx({messages:a(),parts:e.data.part,input:I.input,systemPrompt:h()}):[]})),y=I=>I==="system"?t.t("context.breakdown.system"):I==="user"?t.t("context.breakdown.user"):I==="assistant"?t.t("context.breakdown.assistant"):I==="tool"?t.t("context.breakdown.tool"):t.t("context.breakdown.other"),b=[{label:"context.stats.session",value:()=>o()?.title??r.id??"—"},{label:"context.stats.messages",value:()=>w().all.toLocaleString(t.intl())},{label:"context.stats.provider",value:k},{label:"context.stats.model",value:v},{label:"context.stats.limit",value:()=>m().number(f()?.limit)},{label:"context.stats.totalTokens",value:()=>m().number(f()?.total)},{label:"context.stats.usage",value:()=>m().percent(f()?.usage)},{label:"context.stats.inputTokens",value:()=>m().number(f()?.input)},{label:"context.stats.outputTokens",value:()=>m().number(f()?.output)},{label:"context.stats.reasoningTokens",value:()=>m().number(f()?.reasoning)},{label:"context.stats.cacheTokens",value:()=>`${m().number(f()?.cacheRead)} / ${m().number(f()?.cacheWrite)}`},{label:"context.stats.userMessages",value:()=>w().user.toLocaleString(t.intl())},{label:"context.stats.assistantMessages",value:()=>w().assistant.toLocaleString(t.intl())},{label:"context.stats.totalCost",value:p},{label:"context.stats.sessionCreated",value:()=>m().time(o()?.time.created)},{label:"context.stats.lastActivity",value:()=>m().time(f()?.message.time.created)}];let _,$,D;const L=I=>e.data.part[I]??[],V=()=>{const I=_;if(!I)return;const U=i().scroll("context");U&&(I.scrollTop!==U.y&&(I.scrollTop=U.y),I.scrollLeft!==U.x&&(I.scrollLeft=U.x))},K=I=>{D={x:I.currentTarget.scrollLeft,y:I.currentTarget.scrollTop},$===void 0&&($=requestAnimationFrame(()=>{$=void 0;const U=D;D=void 0,U&&i().setScroll("context",U)}))};return $e(Pt(()=>a().length,()=>{requestAnimationFrame(V)},{defer:!0})),vt(()=>{$!==void 0&&cancelAnimationFrame($)}),s(ba,{class:"@container h-full",viewportRef:I=>{_=I,V()},onScroll:K,get children(){var I=bx(),U=I.firstChild,Y=U.nextSibling,S=Y.firstChild;return l(U,s(Oe,{each:b,children:M=>s($x,{get label(){return t.t(M.label)},get value(){return M.value()}})})),l(I,s(E,{get when(){return C().length>0},get children(){var M=vx(),A=M.firstChild,F=A.nextSibling,N=F.nextSibling,X=N.nextSibling;return l(A,()=>t.t("context.breakdown.title")),l(F,s(Oe,{get each(){return C()},children:B=>(()=>{var O=xx();return G(z=>{var q=`${B.width}%`,Q=Cd[B.key];return q!==z.e&&Je(O,"width",z.e=q),Q!==z.t&&Je(O,"background-color",z.t=Q),z},{e:void 0,t:void 0}),O})()})),l(N,s(Oe,{get each(){return C()},children:B=>(()=>{var O=yx(),z=O.firstChild,q=z.nextSibling,Q=q.nextSibling,j=Q.firstChild;return l(q,()=>y(B.key)),l(Q,()=>B.percent.toLocaleString(t.intl()),j),G(H=>Je(z,"background-color",Cd[B.key])),O})()})),l(X,()=>t.t("context.breakdown.note")),M}}),Y),l(I,s(E,{get when(){return h()},children:M=>(()=>{var A=wx(),F=A.firstChild,N=F.nextSibling;return l(F,()=>t.t("context.systemPrompt.title")),l(N,s(zi,{get text(){return M()},class:"text-12-regular"})),A})()}),Y),l(S,()=>t.t("context.rawMessages.title")),l(Y,s(Bn,{multiple:!0,get children(){return s(Oe,{get each(){return a()},children:M=>s(_x,{message:M,getParts:L,onRendered:V,get time(){return m().time}})})}}),null),I}})}var Sx=x('<span class="relative inline-flex size-4 shrink-0">'),Tx=x('<span class="size-1.5 shrink-0 rounded-full bg-amber-400"aria-hidden>'),Ax=x('<div class="flex items-center gap-x-1.5 min-w-0"><span class="text-14-medium truncate">'),Dx=x('<div class="h-full flex items-center">');function sm(e){return(()=>{var t=Ax(),n=t.firstChild;return l(t,s(E,{get when(){return!e.active},get fallback(){return s(cr,{get node(){return{path:e.path,type:"file"}},class:"size-4 shrink-0"})},get children(){var r=Sx();return l(r,s(cr,{get node(){return{path:e.path,type:"file"}},class:"absolute inset-0 size-4 tab-fileicon-color"}),null),l(r,s(cr,{get node(){return{path:e.path,type:"file"}},mono:!0,class:"absolute inset-0 size-4 tab-fileicon-mono"}),null),r}}),n),l(n,()=>Sn(e.path)),l(t,s(E,{get when(){return e.dirty},get children(){return Tx()}}),null),t})()}function Mx(e){const t=yr(),n=hn(),r=Li(),i=ua(e.tab),o=T(()=>t.pathFromTab(e.tab)),a=T(()=>{const u=o();return u?t.dirty(u):!1}),d=T(()=>{const u=o();if(u)return s(sm,{path:u,get dirty(){return a()}})}),c=()=>{a()&&typeof window<"u"&&!window.confirm("Discard unsaved changes?")||e.onTabClose(e.tab)};return(()=>{var u=Dx();return Lt(i,u,()=>!0),l(u,s(pr.Trigger,{get value(){return e.tab},get closeButton(){return s(or,{get title(){return n.t("common.closeTab")},get keybind(){return r.keybind("tab.close")},placement:"bottom",gutter:10,get children(){return s(Ot,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:c,get"aria-label"(){return n.t("common.closeTab")}})}})},hideCloseButton:!0,onMiddleClick:c,get children(){return s(E,{get when(){return d()},children:g=>g()})}})),G(()=>u.classList.toggle("opacity-0",!!i.isActiveDraggable)),u})()}const Ex=[],fs=e=>{const t=e.review??(()=>!1),n=e.hasReview??(()=>!1),r=T(()=>e.tabs().active()==="context"||e.tabs().all().includes("context")),i=T(()=>{const u=new Set;return e.tabs().all().flatMap(g=>{if(g==="context"||g==="review"||g==="home"||g==="graph"||g==="plan"||g==="explore"||g==="preview"||g==="ship"||g==="cms")return[];const f=e.pathFromTab(g)?e.normalizeTab(g):g;return u.has(f)?[]:(u.add(f),[f])})},Ex,{equals:_i}),o=T(()=>{const u=e.tabs().active();if(u==="context"||u==="home"||u==="plan"||u==="explore"||u==="graph"||u==="preview"||u==="review"||u==="ship"||u==="cms"||u==="design"||u==="review"&&t())return u;if(u&&e.pathFromTab(u))return e.normalizeTab(u);const g=i()[0];return g||(r()?"context":t()&&n()?"review":"empty")}),a=T(()=>{const u=o();return u==="home"?"home":u==="plan"?"plan":u==="explore"?"explore":u==="browser"?"browser":u==="preview"?"preview":u==="data"?"data":u==="assets"?"assets":u==="review"?"review":u==="ship"?"ship":u==="cms"?"cms":u==="design"?"design":"code"}),d=T(()=>{const u=o();if(i().includes(u))return u}),c=T(()=>{const u=o();if(u==="context")return u;if(!(u==="home"||u==="plan"||u==="explore"||u==="graph"||u==="preview"||u==="data"||u==="assets"||u==="ship"||u==="cms"||u==="design")&&i().includes(u))return u});return{contextOpen:r,openedTabs:i,activeTab:o,activeTopTab:a,activeFileTab:d,closableTab:c}},Qi=e=>{const n=document.getElementById(`terminal-wrapper-${e}`)?.querySelector('[data-component="terminal"]');if(!(n instanceof HTMLElement))return!1;const r=n.querySelector("textarea");return r instanceof HTMLTextAreaElement?(r.focus(),!0):(n.focus(),n.dispatchEvent(typeof PointerEvent=="function"?new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0}):new MouseEvent("pointerdown",{bubbles:!0,cancelable:!0})),!0)},Ix=new Set(["Alt","Control","Meta","Shift"]),Lx=e=>Ix.has(e.key)?!1:!(e.ctrlKey||e.metaKey||e.altKey),Px=e=>t=>{Wn(()=>{e.showAllFiles();const n=e.loadFile(t),r=()=>{const i=e.tabForPath(t);e.openTab(i),e.setActive(i)};n instanceof Promise?n.then(r):r()})},Fx=e=>t=>{const n=e.normalizeTab(t);e.openTab(n);const r=e.pathFromTab(n);r&&(e.loadFile(r),e.openReviewPanel(),e.setActive(n))},om=(e,t,n)=>{const r=e.indexOf(t),i=e.indexOf(n);if(!(r===-1||i===-1||r===i))return i},am=()=>{const[e,t]=St({active:!1});let n;const r=()=>{n!==void 0&&(clearTimeout(n),n=void 0),t("active",!1)},i=()=>{n!==void 0&&(clearTimeout(n),n=void 0),t("active",!0)};return Mn(()=>{window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r),window.addEventListener("blur",r),vt(()=>{window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r),window.removeEventListener("blur",r)})}),vt(()=>{n!==void 0&&clearTimeout(n)}),{active:()=>e.active,start:i,touch(){i(),n=window.setTimeout(r,120)}}};var Rx=x('<div class="flex items-center gap-1 text-[12px] ml-1"><span>'),zx=x('<div class="absolute inset-0 flex items-center px-3 bg-muted z-10 pointer-events-auto"><input type=text class="bg-transparent border-none outline-none text-sm min-w-0 flex-1">'),Ox=x('<div class="outline-none focus:outline-none focus-visible:outline-none flex items-center px-2.5 h-full"><div class="relative h-full flex items-center">');function Nx(e){const t=Fi(),n=hn(),r=ua(e.terminal.id),[i,o]=St({editing:!1,title:e.terminal.title,menuOpen:!1,menuPosition:{x:0,y:0},blurEnabled:!1});let a,d,c=!1;const u=()=>{const v=e.terminal.titleNumber;return!Number.isFinite(v)||v<=0?!1:tg(e.terminal.title,v)},g=()=>{if(n.locale(),e.terminal.title&&!u())return e.terminal.title;const v=e.terminal.titleNumber;return Number.isFinite(v)&&v>0?n.t("terminal.title.numbered",{number:v}):e.terminal.title?e.terminal.title:n.t("terminal.title")},f=()=>{const v=t.all().length;t.close(e.terminal.id),v===1&&e.onClose?.()},m=()=>{i.editing||(document.activeElement instanceof HTMLElement&&document.activeElement.blur(),Qi(e.terminal.id))},p=v=>{v&&(v.stopPropagation(),v.preventDefault()),o("blurEnabled",!1),o("title",e.terminal.title),o("editing",!0)},w=()=>{if(!i.blurEnabled)return;const v=i.title.trim();v&&v!==e.terminal.title&&t.update({id:e.terminal.id,title:v}),o("editing",!1)},h=v=>{if(v.key==="Enter"){v.preventDefault(),w();return}v.key==="Escape"&&(v.preventDefault(),o("editing",!1))},k=v=>{v.preventDefault(),o("menuPosition",{x:v.clientX,y:v.clientY}),o("menuOpen",!0)};return $e(()=>{i.editing&&a&&(a.focus(),a.select(),d!==void 0&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=void 0,o("blurEnabled",!0)}))}),vt(()=>{d!==void 0&&cancelAnimationFrame(d)}),(()=>{var v=Ox(),C=v.firstChild;return Lt(r,v,()=>!0),l(C,s(pr.Trigger,{get value(){return e.terminal.id},onClick:m,onMouseDown:y=>y.preventDefault(),onContextMenu:k,class:"!shadow-none px-1.5",classes:{button:"border-0 outline-none focus:outline-none focus-visible:outline-none !shadow-none !ring-0 flex items-center"},get closeButton(){return s(Ot,{icon:"close-small",variant:"ghost",onClick:y=>{y.stopPropagation(),f()},get"aria-label"(){return n.t("terminal.close")}})},get children(){return[s(Ue,{name:"terminal",class:"w-4 h-4"}),(()=>{var y=Rx(),b=y.firstChild;return b.$$dblclick=p,l(b,g),G(()=>b.classList.toggle("invisible",!!i.editing)),y})()]}}),null),l(C,s(E,{get when(){return i.editing},get children(){var y=zx(),b=y.firstChild;b.$$mousedown=$=>$.stopPropagation(),b.$$keydown=h,b.addEventListener("blur",w),b.$$input=$=>o("title",$.currentTarget.value);var _=a;return typeof _=="function"?Lt(_,b):a=b,G(()=>b.value=i.title),y}}),null),l(C,s(Ye,{get open(){return i.menuOpen},onOpenChange:y=>o("menuOpen",y),get children(){return s(Ye.Portal,{get children(){return s(Ye.Content,{class:"fixed",get style(){return{left:`${i.menuPosition.x}px`,top:`${i.menuPosition.y}px`}},onCloseAutoFocus:y=>{c&&(y.preventDefault(),c=!1,requestAnimationFrame(()=>p()))},get children(){return[s(Ye.Item,{onSelect:()=>c=!0,get children(){return[s(Ue,{name:"edit",class:"w-4 h-4 mr-2"}),Te(()=>n.t("common.rename"))]}}),s(Ye.Item,{onSelect:f,get children(){return[s(Ue,{name:"close",class:"w-4 h-4 mr-2"}),Te(()=>n.t("common.close"))]}})]}})}})}}),null),G(()=>v.classList.toggle("opacity-0",!!r.isActiveDraggable)),v})()}Kt(["dblclick","input","keydown","mousedown"]);var Bx=x('<div class="h-12 shrink-0 "aria-hidden>'),qx=x('<div class="flex flex-col items-center gap-6"><svg width=40 height=40 viewBox="0 0 800 800"fill=none xmlns=http://www.w3.org/2000/svg class=shrink-0><path d="M373.362 226.643C388.087 211.919 411.96 211.919 426.684 226.643L573.37 373.324C588.094 388.047 588.094 411.92 573.37 426.644L426.684 573.324C411.96 588.048 388.087 588.048 373.362 573.324L226.677 426.644C211.952 411.92 211.952 388.047 226.677 373.324L373.362 226.643Z"fill=currentColor></path><path d="M586.658 513.282C594.02 505.921 605.956 505.921 613.318 513.282L686.659 586.621C694.021 593.983 694.021 605.919 686.659 613.28L613.318 686.619C605.956 693.981 594.02 693.981 586.658 686.619L513.317 613.28C505.955 605.919 505.955 593.983 513.317 586.621L586.658 513.282Z"fill=currentColor></path><path d="M286.501 586.454C293.957 593.909 293.957 605.997 286.501 613.453L213.5 686.452C206.044 693.907 193.956 693.907 186.5 686.452L113.499 613.453C106.043 605.997 106.043 593.909 113.499 586.454L186.5 513.455C193.956 506 206.044 506 213.5 513.455L286.501 586.454Z"fill=currentColor></path><path d="M406.524 93.4982C402.934 97.088 397.113 97.088 393.523 93.4982L356.523 56.499C352.933 52.9092 352.933 47.089 356.523 43.4992L393.523 6.50002C397.113 2.91025 402.934 2.91025 406.524 6.50003L443.524 43.4992C447.114 47.089 447.114 52.9092 443.524 56.499L406.524 93.4982Z"fill=currentColor></path><path d="M186.502 113.498C193.958 106.042 206.046 106.042 213.502 113.498L286.503 186.496C293.959 193.952 293.959 206.04 286.503 213.496L213.502 286.494C206.046 293.95 193.958 293.95 186.502 286.494L113.501 213.496C106.045 206.04 106.045 193.952 113.501 186.496L186.502 113.498Z"fill=currentColor></path><path d="M686.499 186.483C693.955 193.939 693.955 206.027 686.499 213.482L613.498 286.481C606.042 293.937 593.954 293.937 586.498 286.481L513.497 213.482C506.041 206.027 506.041 193.939 513.497 186.483L586.498 113.484C593.954 106.029 606.042 106.029 613.498 113.484L686.499 186.483Z"fill=currentColor></path><path d="M356.689 756.666C353.007 752.985 353.007 747.017 356.689 743.336L393.359 706.667C397.04 702.986 403.008 702.986 406.689 706.667L443.359 743.336C447.041 747.017 447.041 752.985 443.359 756.666L406.689 793.335C403.008 797.016 397.04 797.016 393.359 793.335L356.689 756.666Z"fill=currentColor></path></svg><div class="text-20-medium text-text-strong">'),jx=x('<div class="w-full flex flex-col gap-4 items-center"><div class="flex items-start justify-center gap-3 min-h-5"><div class="text-12-medium text-text-weak select-text leading-5 min-w-0 max-w-160 break-words text-center"><span class=text-text-strong></span></div></div><div class="flex items-start justify-center gap-1.5 min-h-5"><div class="text-12-medium text-text-weak select-text leading-5 min-w-0 max-w-160 break-words text-center">'),Vx=x('<div><div><div class="w-full max-w-200 flex flex-col items-center text-center gap-4">'),Hx=x('<div class="text-text-strong font-semibold text-[28px] leading-tight">What do you want to create?'),Ux=x('<div class="flex items-start justify-center gap-3 min-h-5"><div class="text-12-medium text-text-weak leading-5 min-w-0 max-w-160 break-words text-center">&nbsp;<span class=text-text-strong>');const Fa="main",Ad="create",Wx="size-full flex flex-col bg-background-stronger",Kx="shrink-0 flex flex-col bg-transparent";function Gx(e){const t=br(),n=zn(),r=hn(),i=T(()=>t.project?.sandboxes??[]),o=T(()=>[Fa,...i(),Ad]),a=T(()=>{const g=e.worktree;return o().includes(g)?g:Fa}),d=T(()=>t.project?.worktree??n.directory),c=T(()=>{const g=t.project;return g?n.directory!==g.worktree:!1}),u=g=>{if(g===Fa){if(c())return r.t("session.new.worktree.main");const f=t.data.vcs?.branch;return f?r.t("session.new.worktree.mainWithBranch",{branch:f}):r.t("session.new.worktree.main")}return g===Ad?r.t("session.new.worktree.create"):Sn(g)};return(()=>{var g=Vx(),f=g.firstChild,m=f.firstChild;return l(g,s(E,{get when(){return!e.compact},get children(){return Bx()}}),f),l(m,s(E,{get when(){return!e.compact},get fallback(){return Hx()},get children(){var p=qx(),w=p.firstChild,h=w.nextSibling;return l(h,()=>r.t("session.new.title")),p}}),null),l(m,s(E,{get when(){return!e.compact},get children(){var p=jx(),w=p.firstChild,h=w.firstChild,k=h.firstChild,v=w.nextSibling,C=v.firstChild;return l(h,()=>ls(d()),k),l(k,()=>Sn(d())),l(v,s(Ue,{name:"branch",size:"small",class:"mt-0.5 shrink-0"}),C),l(C,()=>u(a())),l(p,s(E,{get when(){return t.project},children:y=>(()=>{var b=Ux(),_=b.firstChild,$=_.firstChild,D=$.nextSibling;return l(_,()=>r.t("session.new.lastModified"),$),l(D,()=>ll.fromMillis(y().time.updated??y().time.created).setLocale(r.intl()).toRelative()),b})()}),null),p}}),null),G(p=>{var w=e.compact?Kx:Wx,h={"px-6 flex items-center justify-center text-center":!0,"flex-1 pb-30":!e.compact,"shrink-0 pb-8":e.compact};return w!==p.e&&Ht(g,p.e=w),p.t=Tt(f,h,p.t),p},{e:void 0,t:void 0}),g})()}const gl=e=>typeof e=="object"&&e!==null,Ra=e=>!(!gl(e)||typeof e.length!="number"||typeof e.cursorX!="number"||typeof e.cursorY!="number"||typeof e.baseY!="number"||typeof e.viewportY!="number"||typeof e.getLine!="function"||typeof e.getNullCell!="function"),Dd=e=>{if(!gl(e))return;const t=e.buffer;if(!gl(t))return;const n=Ra(t.active)?t.active:void 0,r=Ra(t.normal)?t.normal:void 0,i=Ra(t.alternate)?t.alternate:void 0;if(!(!n&&!r))return{active:n,normal:r,alternate:i}};function ml(e,t,n){return Math.max(t,Math.min(e,n))}function Yx(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function Xx(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function Zx(e,t){return!!e.isInverse()==!!t.isInverse()&&!!e.isBold()==!!t.isBold()&&!!e.isUnderline()==!!t.isUnderline()&&!!e.isBlink()==!!t.isBlink()&&!!e.isInvisible()==!!t.isInvisible()&&!!e.isItalic()==!!t.isItalic()&&!!e.isDim()==!!t.isDim()&&!!e.isStrikethrough()==!!t.isStrikethrough()}class Qx{constructor(t){this._buffer=t}serialize(t,n){let r=this._buffer.getNullCell();const i=t.start.y,o=t.end.y,a=t.start.x,d=t.end.x;this._beforeSerialize(o-i+1,i,o);for(let c=i;c<=o;c++){const u=this._buffer.getLine(c);if(u){const g=c===t.start.y?a:0,f=Math.min(d,u.length);for(let m=g;m<f;m++){const p=u.getCell(m);p&&(this._nextCell(p,r,c,m),r=p)}}this._rowEnd(c,c===o)}return this._afterSerialize(),this._serializeString(n)}_nextCell(t,n,r,i){}_rowEnd(t,n){}_beforeSerialize(t,n,r){}_afterSerialize(){}_serializeString(t){return""}}class Jx extends Qx{constructor(t,n){super(t),this._terminal=n,this._cursorStyle=this._buffer.getNullCell()}_rowIndex=0;_allRows=[];_allRowSeparators=[];_currentRow="";_nullCellCount=0;_cursorStyle;_firstRow=0;_lastCursorRow=0;_lastCursorCol=0;_lastContentCursorRow=0;_lastContentCursorCol=0;_beforeSerialize(t,n,r){this._allRows=new Array(t),this._allRowSeparators=new Array(t),this._rowIndex=0,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._lastContentCursorRow=n,this._lastCursorRow=n,this._firstRow=n}_rowEnd(t,n){let r="";const o=!!(n?void 0:this._buffer.getLine(t+1))?.isWrapped;this._nullCellCount>0&&o&&(this._currentRow+=" ".repeat(this._nullCellCount)),this._nullCellCount=0,!n&&!o&&(r=`\r
3
+ `,this._lastCursorRow=t+1,this._lastCursorCol=0),this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=r,this._currentRow="",this._nullCellCount=0}_diffStyle(t,n){const r=[],i=!Yx(t,n),o=!Xx(t,n),a=!Zx(t,n);if(i||o||a)if(this._isAttributeDefault(t))this._isAttributeDefault(n)||r.push(0);else{if(a&&(!!t.isInverse()!=!!n.isInverse()&&r.push(t.isInverse()?7:27),!!t.isBold()!=!!n.isBold()&&r.push(t.isBold()?1:22),!!t.isUnderline()!=!!n.isUnderline()&&r.push(t.isUnderline()?4:24),!!t.isBlink()!=!!n.isBlink()&&r.push(t.isBlink()?5:25),!!t.isInvisible()!=!!n.isInvisible()&&r.push(t.isInvisible()?8:28),!!t.isItalic()!=!!n.isItalic()&&r.push(t.isItalic()?3:23),!!t.isDim()!=!!n.isDim()&&r.push(t.isDim()?2:22),!!t.isStrikethrough()!=!!n.isStrikethrough()&&r.push(t.isStrikethrough()?9:29)),i){const d=t.getFgColor(),c=t.getFgColorMode();c===2||c===3||c===-1?r.push(38,2,d>>>16&255,d>>>8&255,d&255):c===1?d>=16?r.push(38,5,d):r.push(d&8?90+(d&7):30+(d&7)):r.push(39)}if(o){const d=t.getBgColor(),c=t.getBgColorMode();c===2||c===3||c===-1?r.push(48,2,d>>>16&255,d>>>8&255,d&255):c===1?d>=16?r.push(48,5,d):r.push(d&8?100+(d&7):40+(d&7)):r.push(49)}}return r}_isAttributeDefault(t){const n=t.getFgColorMode(),r=t.getBgColorMode();if(n===0&&r===0)return!t.isBold()&&!t.isItalic()&&!t.isUnderline()&&!t.isBlink()&&!t.isInverse()&&!t.isInvisible()&&!t.isDim()&&!t.isStrikethrough();const i=t.getFgColor(),o=t.getBgColor(),a=this._buffer.getNullCell(),d=a.getFgColor(),c=a.getBgColor();return i===d&&o===c&&!t.isBold()&&!t.isItalic()&&!t.isUnderline()&&!t.isBlink()&&!t.isInverse()&&!t.isInvisible()&&!t.isDim()&&!t.isStrikethrough()}_nextCell(t,n,r,i){if(t.getWidth()===0)return;const a=t.getCode(),c=a>1114111||a>=55296&&a<=57343||a>=61440&&t.getWidth()===1,u=a===0||t.getChars()===""||c,g=this._diffStyle(t,this._cursorStyle);if(g.length>0){this._nullCellCount>0&&(this._currentRow+=" ".repeat(this._nullCellCount),this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=r,this._lastContentCursorCol=this._lastCursorCol=i,this._currentRow+=`\x1B[${g.join(";")}m`;const p=this._buffer.getLine(r)?.getCell(i);p&&(this._cursorStyle=p)}u?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(this._currentRow+=" ".repeat(this._nullCellCount),this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=r,this._lastContentCursorCol=this._lastCursorCol=i+t.getWidth())}_serializeString(t){let n=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(n=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let r="";for(let f=0;f<n;f++)r+=this._allRows[f],f+1<n&&(r+=this._allRowSeparators[f]);if(t)return r;const i=(this._buffer.baseY??0)+this._buffer.cursorY,o=ml(i-this._firstRow+1,1,Number.MAX_SAFE_INTEGER),a=this._buffer.cursorX+1;r+=`\x1B[${o};${a}H`;const d=this._buffer.getLine(i),c=d?.getCell(this._buffer.cursorX),u=c?c.getWidth()!==0?c:this._buffer.cursorX>0?d?.getCell(this._buffer.cursorX-1)??c:c:this._buffer.getNullCell(),g=this._diffStyle(u,this._cursorStyle);return g.length&&(r+=`\x1B[${g.join(";")}m`),r}}class e1{_terminal;activate(t){this._terminal=t}dispose(){this._terminal=void 0}serialize(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const n=Dd(this._terminal);if(!n)return"";const r=n.normal??n.active,i=n.alternate;if(!r)return"";let o=t?.range?this._serializeBufferByRange(r,t.range,!0):this._serializeBufferByScrollback(r,t?.scrollback);if(!t?.excludeAltBuffer&&n.active?.type==="alternate"&&i){const a=this._serializeBufferByScrollback(i,void 0);o+=`\x1B[?1049h\x1B[H${a}`}return o}serializeAsText(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const n=Dd(this._terminal);if(!n)return"";const r=n.active??n.normal;if(!r)return"";const i=r.length,o=t?.scrollback,a=o===void 0?i:ml(o+this._terminal.rows,0,i),d=i-a,c=i-1,u=[];for(let g=d;g<=c;g++){const f=r.getLine(g);if(f){const m=f.translateToString(t?.trimWhitespace??!0);u.push(m)}}if(t?.trimWhitespace)for(;u.length>0&&u[u.length-1]==="";)u.pop();return u.join(`
4
+ `)}_serializeBufferByScrollback(t,n){const r=t.length,i=this._terminal?.rows??24,o=n===void 0?r:ml(n+i,0,r);return this._serializeBufferByRange(t,{start:r-o,end:r-1},!1)}_serializeBufferByRange(t,n,r){const i=new Jx(t,this._terminal),o=this._terminal?.cols??80;return i.serialize({start:{x:0,y:n.start},end:{x:o,y:n.end}},r)}}const t1="data-pty-id",Vi=()=>({connected:!1,connects:0,rendered:"",settled:0,focusing:0}),lm=()=>{if(typeof window>"u")return;const e=window.__opencode_e2e?.terminal;if(e?.enabled)return e},Hi=()=>{const e=lm();if(e)return e.terminals??={},e.terminals},Md=()=>{const e=lm();if(e)return e.controls??={},e.controls},cm=e=>{const t=n=>{const r=Hi();r&&(r[e]={...r[e]??Vi(),...n})};return{init(){t(Vi())},connect(){const n=Hi();if(!n)return;const r=n[e]??Vi();n[e]={...r,connected:!0,connects:r.connects+1}},render(n){const r=Hi();if(!r)return;const i=r[e]??Vi();r[e]={...i,rendered:i.rendered+n}},settle(){const n=Hi();if(!n)return;const r=n[e]??Vi();n[e]={...r,settled:r.settled+1}},focus(n){t({focusing:Math.max(0,n)})},step(){const n=Hi();if(!n)return;const r=n[e]??Vi();n[e]={...r,focusing:Math.max(0,r.focusing-1)}},control(n){const r=Md();r&&(r[e]={...r[e]??{},...n})},drop(){const n=Hi();n&&delete n[e];const r=Md();r&&delete r[e]}}},Jo=e=>typeof e=="object"&&e!==null,n1=e=>Jo(e)&&typeof e.dispose=="function",$s=e=>{n1(e)&&e.dispose()},r1=e=>Jo(e)&&typeof e.setOption=="function",Ed=(e,t,n)=>{r1(e)&&e.setOption(t,n)},i1=e=>{if(!Jo(e))return;const t=e.currentHoveredLink;if(Jo(t)&&typeof t.text=="string")return t.text};function s1(e,t=queueMicrotask){let n,r,i=!1,o=!1;const a=()=>{if(i||o||n?.length)return;const g=r;if(g?.length){r=void 0;for(const f of g)f()}},d=()=>{if(o)return;i=!1;const g=n;if(!g?.length){a();return}n=void 0,o=!0,e(g.join(""),()=>{if(o=!1,n?.length){if(i)return;i=!0,t(d);return}a()})};return{push:g=>{g&&(n?n.push(g):n=[g],!(i||o)&&(i=!0,t(d)))},flush:g=>{if(!i&&!o&&!n?.length){g?.();return}g&&(r?r.push(g):r=[g]),d()}}}var o1=x('<div class="relative size-full overflow-hidden"><div data-component=terminal>');const a1="terminal.toggle",l1="ctrl+`";let ks;const c1=()=>ks||(ks=Kn(()=>import("./ghostty-web-BSIEXrpM.js"),__vite__mapDeps([3,1,2])).then(async e=>({mod:e,ghostty:await e.Ghostty.load()})).catch(e=>{throw ks=void 0,e}),ks),d1={light:{background:"#fcfcfc",foreground:"#211e1e",cursor:"#211e1e",selectionBackground:cl("#211e1e",.2)},dark:{background:"#191515",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:cl("#d4d4d4",.25)}},u1=e=>{if(!e||typeof e!="object"||!("name"in e))return;const t=e.name;return typeof t=="string"?t:void 0},f1=e=>{const t=o=>{const a=e.term.getSelection();if(!a)return;const d=o.clipboardData;d&&(o.preventDefault(),d.setData("text/plain",a))},n=o=>{const a=o.clipboardData,d=a?.getData("text/plain")??a?.getData("text")??"";d&&(o.preventDefault(),o.stopPropagation(),e.term.paste(d))},r=()=>{e.term.options.cursorBlink=!0},i=()=>{e.term.options.cursorBlink=!1};e.container.addEventListener("copy",t,!0),e.cleanups.push(()=>e.container.removeEventListener("copy",t,!0)),e.container.addEventListener("paste",n,!0),e.cleanups.push(()=>e.container.removeEventListener("paste",n,!0)),e.container.addEventListener("pointerdown",e.handlePointerDown),e.cleanups.push(()=>e.container.removeEventListener("pointerdown",e.handlePointerDown)),e.container.addEventListener("click",e.handleLinkClick,{capture:!0}),e.cleanups.push(()=>e.container.removeEventListener("click",e.handleLinkClick,{capture:!0})),e.term.textarea?.addEventListener("focus",r),e.term.textarea?.addEventListener("blur",i),e.cleanups.push(()=>e.term.textarea?.removeEventListener("focus",r)),e.cleanups.push(()=>e.term.textarea?.removeEventListener("blur",i))},g1=e=>{if(!e.addon||!e.onCleanup||!e.term)return;const t=(()=>{try{return e.addon.serialize()}catch{return""}})();e.onCleanup({id:e.id,buffer:t,cursor:e.cursor,rows:e.term.rows,cols:e.term.cols,scrollY:e.term.getViewportY()})},dm=e=>{const t=aa(),n=zn(),r=Hl(),i=ng(),o=hn(),a=Zf(),d=n.directory,c=n.client,u=n.url,g=a.current?.http;let f;const[m,p]=rn(e,["pty","class","classList","autoFocus","clearOnConnect","onConnect","onConnectError"]),w=m.pty.id,h=cm(w),k=typeof m.pty.buffer=="string"?m.pty.buffer:"",v=k&&typeof m.pty.cols=="number"&&Number.isSafeInteger(m.pty.cols)&&m.pty.cols>0&&typeof m.pty.rows=="number"&&Number.isSafeInteger(m.pty.rows)&&m.pty.rows>0?{cols:m.pty.cols,rows:m.pty.rows}:void 0,C=typeof m.pty.scrollY=="number"?m.pty.scrollY:void 0;let y,b,_,$,D,L,V,K,I,U=!1;const Y=[],[S,M]=ke(!0),A=typeof m.pty.cursor=="number"&&Number.isSafeInteger(m.pty.cursor)?m.pty.cursor:void 0;let F=A??0,N=A!==void 0?A:k?-1:0,X,B,O,z=0;const q=()=>{if(!Y.length)return;const re=Y.splice(0).reverse();for(const ie of re)try{ie()}catch{}},Q=(re,ie)=>c.pty.update({ptyID:w,size:{cols:re,rows:ie}}).catch(be=>{}),H=T(()=>{const re=i.mode()==="dark"?"dark":"light",ie=d1[re],be=i.themes()[i.themeId()];if(!be)return ie;const Fe=re==="dark"?be.dark:be.light;if(!Fe?.seeds&&!Fe?.palette)return ie;const ee=_v(Fe,re==="dark"),_e=ee["text-stronger"]??ie.foreground,xe=ee["background-stronger"]??ie.background,ye=re==="dark"?.25:.2,Le=_e.startsWith("#")?_e:ie.foreground,tt=cl(Le,ye);return{background:xe,foreground:_e,cursor:_e,selectionBackground:tt}}),J=()=>{if($.fit(),b&&b.rows>1){b.resize(b.cols,b.rows-1);const re=Math.max(0,b.buffer.active.length-b.rows);b.scrollToLine(re)}},le=()=>{U||$&&L===void 0&&(L=requestAnimationFrame(()=>{L=void 0,!U&&J()}))},de=(re,ie)=>{if(!U&&!(I?.cols===re&&I?.rows===ie)){if(K={cols:re,rows:ie},!I){I=K,Q(re,ie);return}V===void 0&&(V=setTimeout(()=>{V=void 0;const be=K;be&&(K=void 0,!U&&(I?.cols===be.cols&&I?.rows===be.rows||(I=be,Q(be.cols,be.rows))))},100))}};$e(()=>{const re=H();b&&Ed(b,"theme",re)}),$e(()=>{const re=Qc(r.appearance.font());b&&(Ed(b,"fontFamily",re),le())});let Re=t.webviewZoom?.();$e(()=>{const re=t.webviewZoom?.();re!==void 0&&re!==Re&&(Re=re,le())});const Ve=()=>{const re=b;re&&(re.focus(),re.textarea?.focus(),setTimeout(()=>re.textarea?.focus(),0))},Z=()=>{const re=document.activeElement;re instanceof HTMLElement&&re!==f&&!f.contains(re)&&re.blur(),Ve()},ne=re=>{if(!re.shiftKey&&!re.ctrlKey&&!re.metaKey||re.altKey||re.button!==0)return;const ie=b;if(!ie)return;const be=i1(ie);be&&(re.preventDefault(),re.stopImmediatePropagation(),!rg(be)&&t.openLink(be))};return Mn(()=>{h.init(),Y.push(()=>h.drop()),(async()=>{const ie=await c1();if(U)return;const be=ie.mod,Fe=ie.ghostty,ee=new be.Terminal({cursorBlink:!0,cursorStyle:"bar",cols:v?.cols,rows:v?.rows,fontSize:14,fontFamily:Qc(r.appearance.font()),allowTransparency:!1,convertEol:!1,theme:H(),scrollback:1e4,ghostty:Fe});if(Y.push(()=>ee.dispose()),U){q();return}b=ee,X=s1((st,gt)=>ee.write(st,()=>{h.render(st),h.settle(),gt?.()})),ee.attachCustomKeyEventHandler(st=>{const gt=st.key.toLowerCase();if(st.ctrlKey&&st.shiftKey&&!st.metaKey&&gt==="c")return document.execCommand("copy"),!0;const $n=r.keybinds.get(a1)??l1,Ce=$v($n);return kv(Ce,st)});const _e=new be.FitAddon,xe=new e1;Y.push(()=>$s(_e)),ee.loadAddon(xe),ee.loadAddon(_e),$=_e,_=xe,ee.open(f);const ye=()=>{const st=ee.getViewportY(),gt=ee.buffer.active.length;M(st+ee.rows>=gt)},Le=ee.onScroll(()=>ye());Y.push(()=>$s(Le)),f1({container:f,term:ee,cleanups:Y,handlePointerDown:Z,handleLinkClick:ne}),m.autoFocus!==!1&&Ve(),typeof document<"u"&&document.fonts&&document.fonts.ready.then(le);const tt=ee.onResize(st=>{de(st.cols,st.rows)});Y.push(()=>$s(tt));const ge=ee.onData(st=>{y?.readyState===WebSocket.OPEN&&y.send(st)});Y.push(()=>$s(ge));const qe=ee.onKey(st=>{st.key=="Enter"&&e.onSubmit?.()});Y.push(()=>$s(qe));const we=()=>{_e.observeResize(),D=le,window.addEventListener("resize",D),Y.push(()=>window.removeEventListener("resize",D))},He=st=>new Promise(gt=>{if(!X){gt();return}X.push(st),X.flush(gt)});k&&v?(await He(k),J(),de(ee.cols,ee.rows),C!==void 0&&ee.scrollToLine(C),we()):(J(),de(ee.cols,ee.rows),k?(await He(k),C!==void 0&&ee.scrollToLine(C)):ee.rows>1&&ee.write(`
5
+ `.repeat(ee.rows-1)),we());const Ne={value:!1},Ee=new TextDecoder,rt=st=>{U||Ne.value||(Ne.value=!0,m.onConnectError?.(st))},ct=()=>c.pty.get({ptyID:w}).then(()=>!1).catch(st=>u1(st)==="NotFoundError"),zt=st=>{if(U||O!==void 0)return;const gt=Math.min(250*2**Math.min(z,4),4e3);O=setTimeout(async()=>{if(O=void 0,!U){if(await ct()){if(U)return;rt(st);return}U||(z+=1,xt())}},gt)},xt=()=>{if(U)return;B?.();const st=new URL(u+`/pty/${w}/connect`);st.searchParams.set("directory",d),st.searchParams.set("cursor",String(N)),st.protocol=st.protocol==="https:"?"wss:":"ws:",g?.password&&(st.username=g.username??"opencode",st.password=g.password);const gt=new WebSocket(st);gt.binaryType="arraybuffer",y=gt;let $n=!0;const Ce=()=>{U||(z=0,h.connect(),m.onConnect?.(),de(ee.cols,ee.rows),$n&&m.clearOnConnect&&!k&&($n=!1,gt.send("clear\r")))},Dt=It=>{if(U)return;if(It.data instanceof ArrayBuffer){const oe=new Uint8Array(It.data);if(oe[0]!==0)return;const me=Ee.decode(oe.subarray(1));try{const Ie=JSON.parse(me)?.cursor;typeof Ie=="number"&&Number.isSafeInteger(Ie)&&Ie>=0&&(F=Ie,N=Ie)}catch{}return}const W=typeof It.data=="string"?It.data:"";W&&(X?.push(W),F+=W.length,N=F)},lt=It=>{},At=()=>{gt.removeEventListener("open",Ce),gt.removeEventListener("message",Dt),gt.removeEventListener("error",lt),gt.removeEventListener("close",wt),y===gt&&(y=void 0),B===At&&(B=void 0),gt.readyState!==WebSocket.CLOSED&&gt.readyState!==WebSocket.CLOSING&&gt.close(1e3)},wt=It=>{y===gt&&(y=void 0),B===At&&(B=void 0),gt.removeEventListener("open",Ce),gt.removeEventListener("message",Dt),gt.removeEventListener("error",lt),gt.removeEventListener("close",wt),!U&&It.code!==1e3&&zt(new Error(o.t("terminal.connectionLost.abnormalClose",{code:It.code})))};B=At,gt.addEventListener("open",Ce),gt.addEventListener("message",Dt),gt.addEventListener("error",lt),gt.addEventListener("close",wt)};h.control({disconnect:()=>{y&&y.close(4e3,"e2e")}}),xt()})().catch(ie=>{U||(nt({variant:"error",title:o.t("terminal.connectionLost.title"),description:ie instanceof Error?ie.message:o.t("terminal.connectionLost.description")}),m.onConnectError?.(ie))})}),vt(()=>{U=!0,L!==void 0&&cancelAnimationFrame(L),V!==void 0&&clearTimeout(V),O!==void 0&&clearTimeout(O),B?.(),y&&y.readyState!==WebSocket.CLOSED&&y.readyState!==WebSocket.CLOSING&&y.close(1e3);const re=()=>{g1({term:b,addon:_,cursor:F,id:w,onCleanup:e.onCleanup}),q()};if(!X){re();return}X.flush(re)}),(()=>{var re=o1(),ie=re.firstChild,be=f;return typeof be=="function"?Lt(be,ie):f=ie,Nr(ie,bt({[t1]:w},{"data-prevent-autofocus":"",tabIndex:-1,get style(){return{"background-color":H().background}},get classList(){return{...m.classList??{},"select-text":!0,"size-full pl-4 pb-0 pt-0 font-mono relative overflow-hidden":!0,[m.class??""]:!!m.class}}},p),!1,!1),re})()};var m1=x('<div class="absolute inset-0">'),h1=x('<div><div class="relative overflow-hidden shrink-0"></div><div></div><div class="relative overflow-hidden flex-1 min-w-0 min-h-0">');function p1(e){const t=Fi(),n=e.node.ptyId,r=t.all;return s(E,{get when(){return r().find(i=>i.id===n)},children:i=>(()=>{var o=m1();return o.$$click=()=>t.focusPane(n),ue(o,"id",`terminal-wrapper-${n}`),l(o,s(dm,{get pty(){return i()},get autoFocus(){return Te(()=>!!e.opened)()&&t.focusedPane()===n},get clearOnConnect(){return e.clearOnConnect},onConnect:()=>e.onConnect(n),get onCleanup(){return e.onCleanup},onConnectError:()=>e.onConnectError(n)})),o})()})}function v1(e){const t=Fi(),n=e.node.direction==="h";let r;const[i,o]=ke(0),[a,d]=ke(e.node.ratio);Mn(()=>{if(!r)return;const f=()=>n?r.offsetWidth:r.offsetHeight;o(f());const m=new ResizeObserver(()=>o(f()));m.observe(r),vt(()=>m.disconnect())});const c=()=>Math.floor(i()*a()),u=f=>f.type==="leaf"?f.ptyId:u(f.a),g=f=>{f.preventDefault();const m=n?f.clientX:f.clientY,p=a(),w=i(),h=u(e.node.a);document.body.style.userSelect="none";const k=C=>{const y=n?C.clientX:C.clientY,b=Math.min(.9,Math.max(.1,p+(y-m)/w));d(b),t.resizePane(h,b)},v=()=>{document.body.style.userSelect="",document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",v)};return(()=>{var f=h1(),m=f.firstChild,p=m.nextSibling,w=p.nextSibling,h=r;return typeof h=="function"?Lt(h,f):r=f,Ht(f,`flex ${n?"flex-row":"flex-col"} size-full`),l(m,s(hl,{get node(){return e.node.a},get opened(){return e.opened},get onConnect(){return e.onConnect},get onCleanup(){return e.onCleanup},get onConnectError(){return e.onConnectError}})),p.$$mousedown=g,Ht(p,n?"w-px shrink-0 bg-border-weak-base hover:bg-border-base cursor-col-resize":"h-px shrink-0 bg-border-weak-base hover:bg-border-base cursor-row-resize"),l(w,s(hl,{get node(){return e.node.b},get opened(){return e.opened},get onConnect(){return e.onConnect},get onCleanup(){return e.onCleanup},get onConnectError(){return e.onConnectError}})),G(k=>Pn(m,n?{width:`${c()}px`}:{height:`${c()}px`},k)),f})()}function hl(e){return s(E,{get when(){return Te(()=>e.node.type==="split")()?e.node:void 0},get fallback(){return s(p1,bt(e,{get node(){return e.node}}))},children:t=>s(v1,bt(e,{get node(){return t()}}))})}Kt(["click","mousedown"]);const ea={session:"ses",message:"msg",permission:"per",user:"usr",part:"prt",pty:"pty"},b1=26;let Id=0,za=0;var mr;(e=>{function t(i){return Cv.string().startsWith(ea[i])}e.schema=t;function n(i,o){return Ld(i,!1,o)}e.ascending=n;function r(i,o){return Ld(i,!0,o)}e.descending=r})(mr||(mr={}));function Ld(e,t,n){if(!n)return x1(e,t);if(!n.startsWith(ea[e]))throw new Error(`ID ${n} does not start with ${ea[e]}`);return n}function x1(e,t,n){const r=Date.now();r!==Id&&(Id=r,za=0),za+=1;let i=BigInt(r)*BigInt(4096)+BigInt(za);t&&(i=~i);const o=new Uint8Array(6);for(let a=0;a<6;a+=1)o[a]=Number(i>>BigInt(40-8*a)&BigInt(255));return ea[e]+"_"+y1(o)+w1(b1-12)}function y1(e){let t="";for(let n=0;n<e.length;n+=1)t+=e[n].toString(16).padStart(2,"0");return t}function w1(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n=$1(e);let r="";for(let i=0;i<e;i+=1)r+=t[n[i]%62];return r}function $1(e){const t=new Uint8Array(e),n=typeof globalThis<"u"?globalThis.crypto:void 0;if(n&&typeof n.getRandomValues=="function")return n.getRandomValues(t),t;for(let r=0;r<e;r+=1)t[r]=Math.floor(Math.random()*256);return t}function k1(e){if(!e||typeof e!="object")return;const t=Number(e.startLine),n=Number(e.startChar),r=Number(e.endLine),i=Number(e.endChar);if([t,n,r,i].every(Number.isFinite))return{startLine:t,startChar:n,endLine:r,endChar:i}}function _1(e){return{opencodeComment:{path:e.path,selection:e.selection,comment:e.comment,preview:e.preview,origin:e.origin}}}function C1(e){if(!e||typeof e!="object")return;const t=e.opencodeComment;if(!t||typeof t!="object")return;const n=t.path,r=t.comment;if(typeof n!="string"||typeof r!="string")return;const i=t.preview,o=t.origin;return{path:n,selection:k1(t.selection),comment:r,preview:typeof i=="string"?i:void 0,origin:o==="review"||o==="file"?o:void 0}}function S1(e){const t=e.selection?Math.min(e.selection.startLine,e.selection.endLine):void 0,n=e.selection?Math.max(e.selection.startLine,e.selection.endLine):void 0;return`The user made the following comment regarding ${t===void 0||n===void 0?"this file":t===n?`line ${t}`:`lines ${t} through ${n}`} of ${e.path}: ${e.comment}`}function T1(e){const t=e.match(/^The user made the following comment regarding (this file|line (\d+)|lines (\d+) through (\d+)) of (.+?): ([\s\S]+)$/);if(!t)return;const n=t[2]?Number(t[2]):t[3]?Number(t[3]):void 0,r=t[2]?Number(t[2]):t[4]?Number(t[4]):void 0;return{path:t[5],selection:n!==void 0&&r!==void 0?{startLine:n,startChar:0,endLine:r,endChar:0}:void 0,comment:t[6]}}const um=["image/png","image/jpeg","image/gif","image/webp"],fm=["audio/mpeg","audio/mp3","audio/wav","audio/ogg","audio/flac","audio/aac","audio/mp4","audio/webm","audio/opus","audio/aiff","audio/midi"],gm=["video/mp4","video/quicktime","video/webm","video/ogg","video/x-msvideo","video/x-matroska","video/x-flv","video/x-ms-wmv","video/3gpp","video/3gpp2"],mm=[...um,...fm,...gm,"application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-excel","application/vnd.ms-powerpoint","text/*","application/json","application/ld+json","application/toml","application/x-toml","application/x-yaml","application/xml","application/yaml",".c",".cc",".cjs",".conf",".cpp",".css",".csv",".cts",".env",".go",".gql",".graphql",".h",".hh",".hpp",".htm",".html",".ini",".java",".js",".json",".jsx",".log",".md",".mdx",".mjs",".mts",".py",".rb",".rs",".sass",".scss",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml",".zsh",".docx",".doc",".xlsx",".xls",".pptx",".ppt",".mp3",".wav",".ogg",".oga",".flac",".aac",".m4a",".weba",".opus",".aif",".aiff",".mid",".midi",".mp4",".m4v",".mov",".webm",".ogv",".avi",".mkv",".flv",".wmv",".3gp",".3g2"],A1=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["audio/mpeg","mp3"],["audio/mp3","mp3"],["audio/wav","wav"],["audio/ogg","ogg"],["audio/flac","flac"],["audio/aac","aac"],["audio/mp4","m4a"],["audio/webm","weba"],["audio/opus","opus"],["audio/aiff","aiff"],["audio/midi","mid"],["video/mp4","mp4"],["video/quicktime","mov"],["video/webm","webm"],["video/ogg","ogv"],["video/x-msvideo","avi"],["video/x-matroska","mkv"],["video/x-flv","flv"],["video/x-ms-wmv","wmv"],["video/3gpp","3gp"],["video/3gpp2","3g2"],["application/pdf","pdf"],["application/json","json"],["application/ld+json","jsonld"],["application/toml","toml"],["application/x-toml","toml"],["application/x-yaml","yaml"],["application/xml","xml"],["application/yaml","yaml"],["application/vnd.openxmlformats-officedocument.wordprocessingml.document","docx"],["application/msword","doc"],["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","xlsx"],["application/vnd.ms-excel","xls"],["application/vnd.openxmlformats-officedocument.presentationml.presentation","pptx"],["application/vnd.ms-powerpoint","ppt"]]),D1=["txt","text","md","markdown","log","csv"];Array.from(new Set(mm.flatMap(e=>{if(e.startsWith("."))return[e.slice(1)];if(e==="text/*")return D1;const t=A1.get(e);return t?[t]:[]}))).sort();const M1=new Set(um),E1=new Set(fm),I1=new Set(gm),hm=new Map([["gif","image/gif"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["png","image/png"],["webp","image/webp"]]),pl=new Map([["aac","audio/aac"],["aif","audio/aiff"],["aiff","audio/aiff"],["flac","audio/flac"],["m4a","audio/mp4"],["mid","audio/midi"],["midi","audio/midi"],["mp3","audio/mpeg"],["oga","audio/ogg"],["ogg","audio/ogg"],["opus","audio/opus"],["wav","audio/wav"],["weba","audio/webm"]]),vl=new Map([["3g2","video/3gpp2"],["3gp","video/3gpp"],["avi","video/x-msvideo"],["flv","video/x-flv"],["m4v","video/mp4"],["mkv","video/x-matroska"],["mov","video/quicktime"],["mp4","video/mp4"],["ogv","video/ogg"],["webm","video/webm"],["wmv","video/x-ms-wmv"]]),L1=new Set(["application/json","application/ld+json","application/toml","application/x-toml","application/x-yaml","application/xml","application/yaml"]),P1=new Set(["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-excel","application/vnd.ms-powerpoint"]),pm={docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",doc:"application/msword",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xls:"application/vnd.ms-excel",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ppt:"application/vnd.ms-powerpoint"},F1=4096;function R1(e){return e.split(";",1)[0]?.trim().toLowerCase()??""}function vm(e){const t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function Pd(e){const t=vm(e),n=hm.get(t)??pl.get(t)??vl.get(t);if(n)return n;if(t==="pdf")return"application/pdf";const r=pm[t];return r||"text/plain"}function z1(e){return e?e.startsWith("text/")||L1.has(e)||e.endsWith("+json")?!0:e.endsWith("+xml"):!1}function O1(e){if(e.length===0)return!0;let t=0;for(const n of e){if(n===0)return!1;(n<9||n>13&&n<32)&&(t+=1)}return t/e.length<=.3}async function N1(e){const t=R1(e.type),n=vm(e.name);if(M1.has(t)||E1.has(t)||I1.has(t))return t;if(t.startsWith("audio/")){const o=pl.get(n);if(o)return o}if(t.startsWith("video/")){const o=vl.get(n);if(o)return o}if(t==="application/pdf"||P1.has(t))return t;const r=hm.get(n)??pl.get(n)??vl.get(n)??(n==="pdf"?"application/pdf":void 0)??pm[n];if((!t||t==="application/octet-stream")&&r)return r;if(z1(t))return"text/plain";const i=new Uint8Array(await e.slice(0,F1).arrayBuffer());if(O1(i))return"text/plain"}const Fd=(e,t)=>t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)||/^[A-Za-z]:$/.test(t)||t.startsWith("\\\\")||t.startsWith("//")?t:`${e.replace(/[\\/]+$/,"")}/${t}`,Rd=e=>e?`?start=${e.startLine}&end=${e.endLine}`:"",B1=e=>e.type==="file",q1=e=>e.type==="agent",j1=e=>e.type==="entity",V1=(e,t,n)=>e.type==="text"?{id:e.id,type:"text",text:e.text,synthetic:e.synthetic,ignored:e.ignored,time:e.time,metadata:e.metadata,sessionID:t,messageID:n}:e.type==="file"?{id:e.id,type:"file",mime:e.mime,filename:e.filename,url:e.url,source:e.source,sessionID:t,messageID:n}:{id:e.id,type:"agent",name:e.name,source:e.source,sessionID:t,messageID:n};function H1(e){const t=[{id:mr.ascending("part"),type:"text",text:e.text}],n=e.prompt.filter(B1).map(c=>{const u=Fd(e.sessionDirectory,c.path),g=Pd(c.path);return{id:mr.ascending("part"),type:"file",mime:g,url:`file://${dl(u)}${Rd(c.selection)}`,filename:Sn(c.path),source:{type:"file",text:{value:c.content,start:c.start,end:c.end},path:u}}}),r=e.prompt.filter(q1).map(c=>({id:mr.ascending("part"),type:"agent",name:c.name,source:{value:c.content,start:c.start,end:c.end}})),i=e.prompt.filter(j1).map(c=>({id:mr.ascending("part"),type:"text",text:c.content,synthetic:!0,metadata:{entityType:c.entityType,entityId:c.entityId}})),o=new Set(n.map(c=>c.url)),a=e.context.flatMap(c=>{const u=Fd(e.sessionDirectory,c.path),g=`file://${dl(u)}${Rd(c.selection)}`,f=Pd(c.path),m=c.comment?.trim();if(!m&&o.has(g))return[];o.add(g);const p={id:mr.ascending("part"),type:"file",mime:f,url:g,filename:Sn(c.path)};return m?[{id:mr.ascending("part"),type:"text",text:S1({path:c.path,selection:c.selection,comment:m}),synthetic:!0,metadata:_1({path:c.path,selection:c.selection,comment:m,preview:c.preview,origin:c.commentOrigin})},p]:[p]}),d=e.images.map(c=>({id:mr.ascending("part"),type:"file",mime:c.mime,url:c.dataUrl,filename:c.filename}));return t.push(...n,...a,...r,...i,...d),{requestParts:t,optimisticParts:t.map(c=>V1(c,e.sessionID,e.messageID))}}const U1=200;function zd(e){const t=document.createDocumentFragment();let n=0;for(const i of e)if(i===`
6
+ `&&(n+=1,n>U1)){const o=e.endsWith(`
7
+ `),a=o?e.slice(0,-1):e;return a&&t.appendChild(document.createTextNode(a)),o&&t.appendChild(document.createElement("br")),t}const r=e.split(`
8
+ `);return r.forEach((i,o)=>{i&&t.appendChild(document.createTextNode(i)),o<r.length-1&&t.appendChild(document.createElement("br"))}),t}function bm(e){return e.nodeType===Node.ELEMENT_NODE&&e.tagName==="BR"?1:(e.textContent??"").replace(/\u200B/g,"").length}function xm(e){if(e.nodeType===Node.TEXT_NODE)return(e.textContent??"").replace(/\u200B/g,"").length;if(e.nodeType===Node.ELEMENT_NODE&&e.tagName==="BR")return 1;let t=0;for(const n of Array.from(e.childNodes))t+=xm(n);return t}function oi(e){const t=window.getSelection();if(!t||t.rangeCount===0)return 0;const n=t.getRangeAt(0);if(!e.contains(n.startContainer))return 0;const r=n.cloneRange();return r.selectNodeContents(e),r.setEnd(n.startContainer,n.startOffset),xm(r.cloneContents())}function Yi(e,t){let n=t,r=e.firstChild;for(;r;){const d=bm(r),c=r.nodeType===Node.TEXT_NODE,u=r.nodeType===Node.ELEMENT_NODE&&(r.dataset.type==="file"||r.dataset.type==="agent"),g=r.nodeType===Node.ELEMENT_NODE&&r.tagName==="BR";if(c&&n<=d){const f=document.createRange(),m=window.getSelection();f.setStart(r,n),f.collapse(!0),m?.removeAllRanges(),m?.addRange(f);return}if((u||g)&&n<=d){const f=document.createRange(),m=window.getSelection();if(n===0&&f.setStartBefore(r),n>0&&u&&f.setStartAfter(r),n>0&&g){const p=r.nextSibling;p&&p.nodeType===Node.TEXT_NODE&&f.setStart(p,0),(!p||p.nodeType!==Node.TEXT_NODE)&&f.setStartAfter(r)}f.collapse(!0),m?.removeAllRanges(),m?.addRange(f);return}n-=d,r=r.nextSibling}const i=document.createRange(),o=window.getSelection(),a=e.lastChild;if(a&&a.nodeType===Node.TEXT_NODE){const d=a.textContent?a.textContent.length:0;i.setStart(a,d)}(!a||a.nodeType!==Node.TEXT_NODE)&&i.selectNodeContents(e),i.collapse(!1),o?.removeAllRanges(),o?.addRange(i)}function Ui(e,t,n,r){let i=r;const o=Array.from(e.childNodes);for(const a of o){const d=bm(a),c=a.nodeType===Node.TEXT_NODE,u=a.nodeType===Node.ELEMENT_NODE&&(a.dataset.type==="file"||a.dataset.type==="agent"),g=a.nodeType===Node.ELEMENT_NODE&&a.tagName==="BR";if(c&&i<=d){n==="start"&&t.setStart(a,i),n==="end"&&t.setEnd(a,i);return}if((u||g)&&i<=d){n==="start"&&i===0&&t.setStartBefore(a),n==="start"&&i>0&&t.setStartAfter(a),n==="end"&&i===0&&t.setEndBefore(a),n==="end"&&i>0&&t.setEndAfter(a);return}i-=d}}const _s=new Map,W1=e=>e.map(t=>"content"in t?t.content:"").join(""),K1=e=>e.filter(t=>t.type==="image");async function ym(e){const t=W1(e.draft.prompt),n=K1(e.draft.prompt),[,r]=e.globalSync.child(e.draft.sessionDirectory),i=()=>{e.optimisticBusy&&r("session_status",e.draft.sessionID,{type:"busy"})},o=()=>{e.optimisticBusy&&r("session_status",e.draft.sessionID,{type:"idle"})},a=async()=>await e.before?.()!==!1,[d,...c]=t.split(" "),u=d?.startsWith("/")?d.slice(1):void 0;if(u&&e.sync.data.command.find(k=>k.name===u)){i();try{return await a()?(await e.client.session.command({sessionID:e.draft.sessionID,command:u,arguments:c.join(" "),agent:e.draft.agent,model:`${e.draft.model.providerID}/${e.draft.model.modelID}`,variant:e.draft.variant,parts:n.map(k=>({id:mr.ascending("part"),type:"file",mime:k.mime,url:k.dataUrl,filename:k.filename}))}),!0):(o(),!1)}catch(k){throw o(),k}}const g=e.messageID??mr.ascending("message"),{requestParts:f,optimisticParts:m}=H1({prompt:e.draft.prompt,context:e.draft.context,images:n,text:t,sessionID:e.draft.sessionID,messageID:g,sessionDirectory:e.draft.sessionDirectory}),p={id:g,sessionID:e.draft.sessionID,role:"user",time:{created:Date.now()},agent:e.draft.agent,model:e.draft.model,variant:e.draft.variant},w=()=>e.sync.session.optimistic.add({directory:e.draft.sessionDirectory,sessionID:e.draft.sessionID,message:p,parts:m}),h=()=>e.sync.session.optimistic.remove({directory:e.draft.sessionDirectory,sessionID:e.draft.sessionID,messageID:g});i(),w();try{return await a()?(await e.client.session.promptAsync({sessionID:e.draft.sessionID,agent:e.draft.agent,model:e.draft.model,messageID:g,parts:f,variant:e.draft.variant}),!0):(o(),h(),!1)}catch(k){throw o(),h(),k}}function G1(e){const t=Ri(),n=zn(),r=br(),i=eo(),o=Pi(),a=fa(),d=Oi(),c=Hr(),u=hn(),g=ig(),f=C=>{if(C&&typeof C=="object"&&"data"in C){const y=C.data;if(y?.message)return y.message}return C instanceof Error?C.message:u.t("common.requestFailed")},m=async()=>{const C=g.id;if(!C)return Promise.resolve();i.todo.set(C,[]);const[,y]=i.child(n.directory);y("todo",C,[]),e.onAbort?.();const b=_s.get(C);return b?(b.abort.abort(),b.cleanup(),_s.delete(C),Promise.resolve()):n.client.session.abort({sessionID:C}).catch(()=>{})},p=C=>{for(const y of C)d.context.add({type:"file",path:y.path,selection:y.selection,comment:y.comment,commentID:y.commentID,commentOrigin:y.commentOrigin,preview:y.preview})},w=C=>{for(const y of C)d.context.remove(y.key)},h=()=>{for(const C of d.context.items())d.context.remove(C.key)},k=(C,y)=>{const[,b]=i.child(C);b("session",_=>{const $=Uo.search(_,y.id,L=>L.id),D=[..._];return $.found?(D[$.index]=y,D):(D.splice($.index,0,y),D)})};return{abort:m,handleSubmit:async C=>{C.preventDefault();const y=d.current(),b=y.map(J=>"content"in J?J.content:"").join(""),_=e.imageAttachments().slice(),$=e.mode();if(b.trim().length===0&&_.length===0&&e.commentCount()===0){e.working()&&m();return}const D=o.model.current(),L=o.agent.current(),V=o.model.variant.current();if(!D||!L){nt({title:u.t("prompt.toast.modelAgentRequired.title"),description:u.t("prompt.toast.modelAgentRequired.description")});return}e.addToHistory(y,$),e.resetHistoryNavigation();const K=n.directory,I=!g.id,U=I&&e.autoAccept(),Y=e.newSessionWorktree?.()||"main";let S=K,M=n.client;if(I){if(Y==="create"){const J=await M.worktree.create({directory:K}).then(le=>le.data).catch(le=>{nt({title:u.t("prompt.toast.worktreeCreateFailed.title"),description:f(le)})});if(!J?.directory){nt({title:u.t("prompt.toast.worktreeCreateFailed.title"),description:u.t("common.requestFailed")});return}Aa.pending(J.directory),S=J.directory}Y!=="main"&&Y!=="create"&&(S=Y),S!==K&&(M=n.createClient({directory:S,throwOnError:!0}),i.child(S)),e.onNewSessionWorktreeReset?.()}let A=e.info();if(!A&&I){const J=await M.session.create().then(le=>le.data??void 0).catch(le=>{nt({title:u.t("prompt.toast.sessionCreateFailed.title"),description:f(le)})});J&&(k(S,J),A=J,U&&a.enableAutoAccept(A.id,S),o.session.promote(S,A.id),c.handoff.setTabs(Ps(S),A.id),t(`/${Ps(S)}/session/${A.id}`))}if(!A){nt({title:u.t("prompt.toast.promptSendFailed.title"),description:u.t("prompt.toast.promptSendFailed.description")});return}const F={modelID:D.id,providerID:D.provider.id},N=L.name,X=d.context.items().slice(),B={sessionID:A.id,sessionDirectory:S,prompt:y,context:X,agent:N,model:F,variant:V},O=()=>{d.reset(),e.setMode("normal"),e.setPopover(null)},z=()=>{d.set(y,e.promptLength(y)),e.setMode($),e.setPopover(null),requestAnimationFrame(()=>{const J=e.editor();J&&(J.focus(),Yi(J,e.promptLength(y)),e.queueScroll())})};if(!I&&$==="normal"&&e.shouldQueue?.()){e.onQueue?.(B),h(),O();return}if(e.onSubmit?.(),c.session.setFullscreen(Ps(S),!1),$==="shell"){O(),M.session.shell({sessionID:A.id,agent:N,model:F,command:b}).catch(J=>{nt({title:u.t("prompt.toast.shellSendFailed.title"),description:f(J)}),z()});return}if(b.startsWith("/")){const[J,...le]=b.split(" "),de=J.slice(1);if(r.data.command.find(Ve=>Ve.name===de)){O(),M.session.command({sessionID:A.id,command:de,arguments:le.join(" "),agent:N,model:`${F.providerID}/${F.modelID}`,variant:V,parts:_.map(Ve=>({id:mr.ascending("part"),type:"file",mime:Ve.mime,url:Ve.dataUrl,filename:Ve.filename}))}).catch(Ve=>{nt({title:u.t("prompt.toast.commandSendFailed.title"),description:Qr(Ve,u.t,u.t("common.requestFailed"))}),z()});return}}const q=X.filter(J=>J.type==="file"&&!!J.comment?.trim()),Q=mr.ascending("message"),j=()=>{r.session.optimistic.remove({directory:S,sessionID:A.id,messageID:Q})};w(q),O(),ym({client:M,sync:r,globalSync:i,draft:B,messageID:Q,optimisticBusy:S===K,before:async()=>{const J=Aa.get(S);if(!J||J.status!=="pending")return!0;S===K&&r.set("session_status",A.id,{type:"busy"});const le=new AbortController,de=()=>{S===K&&r.set("session_status",A.id,{type:"idle"}),j(),p(q),z()};_s.set(A.id,{abort:le,cleanup:de});const Re=new Promise(ie=>{if(le.signal.aborted){ie({status:"failed",message:"aborted"});return}le.signal.addEventListener("abort",()=>{ie({status:"failed",message:"aborted"})},{once:!0})}),Ve=300*1e3,Z={id:void 0},ne=new Promise(ie=>{Z.id=window.setTimeout(()=>{ie({status:"failed",message:u.t("workspace.error.stillPreparing")})},Ve)}),re=await Promise.race([Aa.wait(S),Re,ne]).finally(()=>{Z.id!==void 0&&clearTimeout(Z.id)});if(_s.delete(A.id),le.signal.aborted)return!1;if(re.status==="failed")throw new Error(re.message);return!0}}).catch(J=>{_s.delete(A.id),S===K&&r.set("session_status",A.id,{type:"idle"}),nt({title:u.t("prompt.toast.promptSendFailed.title"),description:f(J)}),j(),p(q),z()})}}}function Y1(e,t){e.indexOf(t)===-1&&e.push(t)}function ic(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const mi=(e,t,n)=>n>t?t:n<e?e:n;let sc=()=>{};const hi={},wm=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function X1(e){return typeof e=="object"&&e!==null}const $m=e=>/^0[^.\s]+$/u.test(e);function km(e){let t;return()=>(t===void 0&&(t=e()),t)}const gs=e=>e,Z1=(e,t)=>n=>t(e(n)),oc=(...e)=>e.reduce(Z1),ac=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r};class _m{constructor(){this.subscriptions=[]}add(t){return Y1(this.subscriptions,t),()=>ic(this.subscriptions,t)}notify(t,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,r);else for(let o=0;o<i;o++){const a=this.subscriptions[o];a&&a(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Tr=e=>e*1e3,Pr=e=>e/1e3;function Cm(e,t){return t?e*(1e3/t):0}const Q1=(e,t,n)=>{const r=t-e;return((n-e)%r+r)%r+e},Sm=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,J1=1e-7,ey=12;function ty(e,t,n,r,i){let o,a,d=0;do a=t+(n-t)/2,o=Sm(a,r,i)-e,o>0?n=a:t=a;while(Math.abs(o)>J1&&++d<ey);return a}function ao(e,t,n,r){if(e===t&&n===r)return gs;const i=o=>ty(o,0,1,e,n);return o=>o===0||o===1?o:Sm(i(o),t,r)}const Tm=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Am=e=>t=>1-e(1-t),Dm=ao(.33,1.53,.69,.99),lc=Am(Dm),Mm=Tm(lc),Em=e=>e>=1?1:(e*=2)<1?.5*lc(e):.5*(2-Math.pow(2,-10*(e-1))),cc=e=>1-Math.sin(Math.acos(e)),ny=Am(cc),Im=Tm(cc),ry=ao(.42,0,1,1),iy=ao(0,0,.58,1),Lm=ao(.42,0,.58,1),Pm=e=>Array.isArray(e)&&typeof e[0]!="number";function Fm(e,t){return Pm(e)?e[Q1(0,e.length,t)]:e}const Rm=e=>Array.isArray(e)&&typeof e[0]=="number",sy={linear:gs,easeIn:ry,easeInOut:Lm,easeOut:iy,circIn:cc,circInOut:Im,circOut:ny,backIn:lc,backInOut:Mm,backOut:Dm,anticipate:Em},oy=e=>typeof e=="string",Od=e=>{if(Rm(e)){sc(e.length===4);const[t,n,r,i]=e;return ao(t,n,r,i)}else if(oy(e))return sy[e];return e},xo=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function ay(e,t){let n=new Set,r=new Set,i=!1,o=!1;const a=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function c(g){a.has(g)&&(u.schedule(g),e()),g(d)}const u={schedule:(g,f=!1,m=!1)=>{const w=m&&i?n:r;return f&&a.add(g),w.add(g),g},cancel:g=>{r.delete(g),a.delete(g)},process:g=>{if(d=g,i){o=!0;return}i=!0;const f=n;n=r,r=f,n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(g))}};return u}const ly=40;function zm(e,t){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,a=xo.reduce((y,b)=>(y[b]=ay(o),y),{}),{setup:d,read:c,resolveKeyframes:u,preUpdate:g,update:f,preRender:m,render:p,postRender:w}=a,h=()=>{const y=hi.useManualTiming,b=y?i.timestamp:performance.now();n=!1,y||(i.delta=r?1e3/60:Math.max(Math.min(b-i.timestamp,ly),1)),i.timestamp=b,i.isProcessing=!0,d.process(i),c.process(i),u.process(i),g.process(i),f.process(i),m.process(i),p.process(i),w.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},k=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:xo.reduce((y,b)=>{const _=a[b];return y[b]=($,D=!1,L=!1)=>(n||k(),_.schedule($,D,L)),y},{}),cancel:y=>{for(let b=0;b<xo.length;b++)a[xo[b]].cancel(y)},state:i,steps:a}}const{schedule:Fr,cancel:bl,state:ta}=zm(typeof requestAnimationFrame<"u"?requestAnimationFrame:gs,!0);let Vo;function cy(){Vo=void 0}const Sr={now:()=>(Vo===void 0&&Sr.set(ta.isProcessing||hi.useManualTiming?ta.timestamp:performance.now()),Vo),set:e=>{Vo=e,queueMicrotask(cy)}},Om=e=>t=>typeof t=="string"&&t.startsWith(e),Nm=Om("--"),dy=Om("var(--"),dc=e=>dy(e)?uy.test(e.split("/*")[0].trim()):!1,uy=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Nd(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const ms={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ks={...ms,transform:e=>mi(0,1,e)},yo={...ms,default:1},Bs=e=>Math.round(e*1e5)/1e5,uc=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function fy(e){return e==null}const gy=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,fc=(e,t)=>n=>!!(typeof n=="string"&&gy.test(n)&&n.startsWith(e)||t&&!fy(n)&&Object.prototype.hasOwnProperty.call(n,t)),Bm=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,o,a,d]=r.match(uc);return{[e]:parseFloat(i),[t]:parseFloat(o),[n]:parseFloat(a),alpha:d!==void 0?parseFloat(d):1}},my=e=>mi(0,255,e),Oa={...ms,transform:e=>Math.round(my(e))},wi={test:fc("rgb","red"),parse:Bm("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+Oa.transform(e)+", "+Oa.transform(t)+", "+Oa.transform(n)+", "+Bs(Ks.transform(r))+")"};function hy(e){let t="",n="",r="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const xl={test:fc("#"),parse:hy,transform:wi.transform},lo=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ai=lo("deg"),ns=lo("%"),Ct=lo("px"),py=lo("vh"),vy=lo("vw"),Bd={...ns,parse:e=>ns.parse(e)/100,transform:e=>ns.transform(e*100)},Ji={test:fc("hsl","hue"),parse:Bm("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+ns.transform(Bs(t))+", "+ns.transform(Bs(n))+", "+Bs(Ks.transform(r))+")"},Vn={test:e=>wi.test(e)||xl.test(e)||Ji.test(e),parse:e=>wi.test(e)?wi.parse(e):Ji.test(e)?Ji.parse(e):xl.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?wi.transform(e):Ji.transform(e),getAnimatableNone:e=>{const t=Vn.parse(e);return t.alpha=0,Vn.transform(t)}},by=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function xy(e){return isNaN(e)&&typeof e=="string"&&(e.match(uc)?.length||0)+(e.match(by)?.length||0)>0}const qm="number",jm="color",yy="var",wy="var(",qd="${}",$y=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function ss(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const d=t.replace($y,c=>(Vn.test(c)?(r.color.push(o),i.push(jm),n.push(Vn.parse(c))):c.startsWith(wy)?(r.var.push(o),i.push(yy),n.push(c)):(r.number.push(o),i.push(qm),n.push(parseFloat(c))),++o,qd)).split(qd);return{values:n,split:d,indexes:r,types:i}}function ky(e){return ss(e).values}function Vm({split:e,types:t}){const n=e.length;return r=>{let i="";for(let o=0;o<n;o++)if(i+=e[o],r[o]!==void 0){const a=t[o];a===qm?i+=Bs(r[o]):a===jm?i+=Vn.transform(r[o]):i+=r[o]}return i}}function _y(e){return Vm(ss(e))}const Cy=e=>typeof e=="number"?0:Vn.test(e)?Vn.getAnimatableNone(e):e,Sy=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:Cy(e);function Ty(e){const t=ss(e);return Vm(t)(t.values.map((r,i)=>Sy(r,t.split[i])))}const Rr={test:xy,parse:ky,createTransformer:_y,getAnimatableNone:Ty};function Na(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ay({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,o=0,a=0;if(!t)i=o=a=n;else{const d=n<.5?n*(1+t):n+t-n*t,c=2*n-d;i=Na(c,d,e+1/3),o=Na(c,d,e),a=Na(c,d,e-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(a*255),alpha:r}}function na(e,t){return n=>n>0?t:e}const hs=(e,t,n)=>e+(t-e)*n,Ba=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Dy=[xl,wi,Ji],My=e=>Dy.find(t=>t.test(e));function jd(e){const t=My(e);if(!t)return!1;let n=t.parse(e);return t===Ji&&(n=Ay(n)),n}const Vd=(e,t)=>{const n=jd(e),r=jd(t);if(!n||!r)return na(e,t);const i={...n};return o=>(i.red=Ba(n.red,r.red,o),i.green=Ba(n.green,r.green,o),i.blue=Ba(n.blue,r.blue,o),i.alpha=hs(n.alpha,r.alpha,o),wi.transform(i))},yl=new Set(["none","hidden"]);function Ey(e,t){return yl.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Iy(e,t){return n=>hs(e,t,n)}function gc(e){return typeof e=="number"?Iy:typeof e=="string"?dc(e)?na:Vn.test(e)?Vd:Fy:Array.isArray(e)?Hm:typeof e=="object"?Vn.test(e)?Vd:Ly:na}function Hm(e,t){const n=[...e],r=n.length,i=e.map((o,a)=>gc(o)(o,t[a]));return o=>{for(let a=0;a<r;a++)n[a]=i[a](o);return n}}function Ly(e,t){const n={...e,...t},r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=gc(e[i])(e[i],t[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function Py(e,t){const n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const o=t.types[i],a=e.indexes[o][r[o]],d=e.values[a]??0;n[i]=d,r[o]++}return n}const Fy=(e,t)=>{const n=Rr.createTransformer(t),r=ss(e),i=ss(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?yl.has(e)&&!i.values.length||yl.has(t)&&!r.values.length?Ey(e,t):oc(Hm(Py(r,i),i.values),n):na(e,t)};function Um(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?hs(e,t,n):gc(e)(e,t)}const Ry=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>Fr.update(t,n),stop:()=>bl(t),now:()=>ta.isProcessing?ta.timestamp:Sr.now()}},Wm=(e,t,n=10)=>{let r="";const i=Math.max(Math.round(t/n),2);for(let o=0;o<i;o++)r+=Math.round(e(o/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},ra=2e4;function mc(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<ra;)t+=n,r=e.next(t);return t>=ra?1/0:t}function Km(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(mc(r),ra);return{type:"keyframes",ease:o=>r.next(i*o).value/t,duration:Pr(i)}}const Rn={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function wl(e,t){return e*Math.sqrt(1-t*t)}const zy=12;function Oy(e,t,n){let r=n;for(let i=1;i<zy;i++)r=r-e(r)/t(r);return r}const qa=.001;function Ny({duration:e=Rn.duration,bounce:t=Rn.bounce,velocity:n=Rn.velocity,mass:r=Rn.mass}){let i,o,a=1-t;a=mi(Rn.minDamping,Rn.maxDamping,a),e=mi(Rn.minDuration,Rn.maxDuration,Pr(e)),a<1?(i=u=>{const g=u*a,f=g*e,m=g-n,p=wl(u,a),w=Math.exp(-f);return qa-m/p*w},o=u=>{const f=u*a*e,m=f*n+n,p=Math.pow(a,2)*Math.pow(u,2)*e,w=Math.exp(-f),h=wl(Math.pow(u,2),a);return(-i(u)+qa>0?-1:1)*((m-p)*w)/h}):(i=u=>{const g=Math.exp(-u*e),f=(u-n)*e+1;return-qa+g*f},o=u=>{const g=Math.exp(-u*e),f=(n-u)*(e*e);return g*f});const d=5/e,c=Oy(i,o,d);if(e=Tr(e),isNaN(c))return{stiffness:Rn.stiffness,damping:Rn.damping,duration:e};{const u=Math.pow(c,2)*r;return{stiffness:u,damping:a*2*Math.sqrt(r*u),duration:e}}}const By=["duration","bounce"],qy=["stiffness","damping","mass"];function Hd(e,t){return t.some(n=>e[n]!==void 0)}function jy(e){let t={velocity:Rn.velocity,stiffness:Rn.stiffness,damping:Rn.damping,mass:Rn.mass,isResolvedFromDuration:!1,...e};if(!Hd(e,qy)&&Hd(e,By))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*mi(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Rn.mass,stiffness:i,damping:o}}else{const n=Ny({...e,velocity:0});t={...t,...n,mass:Rn.mass},t.isResolvedFromDuration=!0}return t}function Gs(e=Rn.visualDuration,t=Rn.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:i}=n;const o=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],d={done:!1,value:o},{stiffness:c,damping:u,mass:g,duration:f,velocity:m,isResolvedFromDuration:p}=jy({...n,velocity:-Pr(n.velocity||0)}),w=m||0,h=u/(2*Math.sqrt(c*g)),k=a-o,v=Pr(Math.sqrt(c/g)),C=Math.abs(k)<5;r||(r=C?Rn.restSpeed.granular:Rn.restSpeed.default),i||(i=C?Rn.restDelta.granular:Rn.restDelta.default);let y,b,_,$,D,L;if(h<1)_=wl(v,h),$=(w+h*v*k)/_,y=K=>{const I=Math.exp(-h*v*K);return a-I*($*Math.sin(_*K)+k*Math.cos(_*K))},D=h*v*$+k*_,L=h*v*k-$*_,b=K=>Math.exp(-h*v*K)*(D*Math.sin(_*K)+L*Math.cos(_*K));else if(h===1){y=I=>a-Math.exp(-v*I)*(k+(w+v*k)*I);const K=w+v*k;b=I=>Math.exp(-v*I)*(v*K*I-w)}else{const K=v*Math.sqrt(h*h-1);y=S=>{const M=Math.exp(-h*v*S),A=Math.min(K*S,300);return a-M*((w+h*v*k)*Math.sinh(A)+K*k*Math.cosh(A))/K};const I=(w+h*v*k)/K,U=h*v*I-k*K,Y=h*v*k-I*K;b=S=>{const M=Math.exp(-h*v*S),A=Math.min(K*S,300);return M*(U*Math.sinh(A)+Y*Math.cosh(A))}}const V={calculatedDuration:p&&f||null,velocity:K=>Tr(b(K)),next:K=>{if(!p&&h<1){const U=Math.exp(-h*v*K),Y=Math.sin(_*K),S=Math.cos(_*K),M=a-U*($*Y+k*S),A=Tr(U*(D*Y+L*S));return d.done=Math.abs(A)<=r&&Math.abs(a-M)<=i,d.value=d.done?a:M,d}const I=y(K);if(p)d.done=K>=f;else{const U=Tr(b(K));d.done=Math.abs(U)<=r&&Math.abs(a-I)<=i}return d.value=d.done?a:I,d},toString:()=>{const K=Math.min(mc(V),ra),I=Wm(U=>V.next(K*U).value,K,30);return K+"ms "+I},toTransition:()=>{}};return V}Gs.applyToOptions=e=>{const t=Km(e,100,Gs);return e.ease=t.ease,e.duration=Tr(t.duration),e.type="keyframes",e};const Vy=5;function Gm(e,t,n){const r=Math.max(t-Vy,0);return Cm(n-e(r),t-r)}function $l({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:a,min:d,max:c,restDelta:u=.5,restSpeed:g}){const f=e[0],m={done:!1,value:f},p=L=>d!==void 0&&L<d||c!==void 0&&L>c,w=L=>d===void 0?c:c===void 0||Math.abs(d-L)<Math.abs(c-L)?d:c;let h=n*t;const k=f+h,v=a===void 0?k:a(k);v!==k&&(h=v-f);const C=L=>-h*Math.exp(-L/r),y=L=>v+C(L),b=L=>{const V=C(L),K=y(L);m.done=Math.abs(V)<=u,m.value=m.done?v:K};let _,$;const D=L=>{p(m.value)&&(_=L,$=Gs({keyframes:[m.value,w(m.value)],velocity:Gm(y,L,m.value),damping:i,stiffness:o,restDelta:u,restSpeed:g}))};return D(0),{calculatedDuration:null,next:L=>{let V=!1;return!$&&_===void 0&&(V=!0,b(L),D(L)),_!==void 0&&L>=_?$.next(L-_):(!V&&b(L),m)}}}function Hy(e,t,n){const r=[],i=n||hi.mix||Um,o=e.length-1;for(let a=0;a<o;a++){let d=i(e[a],e[a+1]);if(t){const c=Array.isArray(t)?t[a]||gs:t;d=oc(c,d)}r.push(d)}return r}function Uy(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const o=e.length;if(sc(o===t.length),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const a=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const d=Hy(t,r,i),c=d.length,u=g=>{if(a&&g<e[0])return t[0];let f=0;if(c>1)for(;f<e.length-2&&!(g<e[f+1]);f++);const m=ac(e[f],e[f+1],g);return d[f](m)};return n?g=>u(mi(e[0],e[o-1],g)):u}function Ym(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=ac(0,t,r);e.push(hs(n,1,i))}}function Xm(e){const t=[0];return Ym(t,e.length-1),t}function Wy(e,t){return e.map(n=>n*t)}function Ky(e,t){return e.map(()=>t||Lm).splice(0,e.length-1)}function qs({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=Pm(r)?r.map(Od):Od(r),o={done:!1,value:t[0]},a=Wy(n&&n.length===t.length?n:Xm(t),e),d=Uy(a,t,{ease:Array.isArray(i)?i:Ky(t,i)});return{calculatedDuration:e,next:c=>(o.value=d(c),o.done=c>=e,o)}}const Gy=e=>e!==null;function xa(e,{repeat:t,repeatType:n="loop"},r,i=1){const o=e.filter(Gy),d=i<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!d||r===void 0?o[d]:r}const Yy={decay:$l,inertia:$l,tween:qs,keyframes:qs,spring:Gs};function Zm(e){typeof e.type=="string"&&(e.type=Yy[e.type])}class hc{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Xy=e=>e/100;class Ys extends hc{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Sr.now()&&this.tick(Sr.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Zm(t);const{type:n=qs,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:a=0}=t;let{keyframes:d}=t;const c=n||qs;c!==qs&&typeof d[0]!="number"&&(this.mixKeyframes=oc(Xy,Um(d[0],d[1])),d=[0,100]);const u=c({...t,keyframes:d});o==="mirror"&&(this.mirroredGenerator=c({...t,keyframes:[...d].reverse(),velocity:-a})),u.calculatedDuration===null&&(u.calculatedDuration=mc(u));const{calculatedDuration:g}=u;this.calculatedDuration=g,this.resolvedDuration=g+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=u}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:i,mixKeyframes:o,mirroredGenerator:a,resolvedDuration:d,calculatedDuration:c}=this;if(this.startTime===null)return r.next(0);const{delay:u=0,keyframes:g,repeat:f,repeatType:m,repeatDelay:p,type:w,onUpdate:h,finalKeyframe:k}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const v=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?v<0:v>i;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let y=this.currentTime,b=r;if(f){const L=Math.min(this.currentTime,i)/d;let V=Math.floor(L),K=L%1;!K&&L>=1&&(K=1),K===1&&V--,V=Math.min(V,f+1),!!(V%2)&&(m==="reverse"?(K=1-K,p&&(K-=p/d)):m==="mirror"&&(b=a)),y=mi(0,1,K)*d}let _;C?(this.delayState.value=g[0],_=this.delayState):_=b.next(y),o&&!C&&(_.value=o(_.value));let{done:$}=_;!C&&c!==null&&($=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const D=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&$);return D&&w!==$l&&(_.value=xa(g,this.options,k,this.speed)),h&&h(_.value),D&&this.finish(),_}then(t,n){return this.finished.then(t,n)}get duration(){return Pr(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Pr(t)}get time(){return Pr(this.currentTime)}set time(t){t=Tr(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return Gm(r=>this.generator.next(r).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Sr.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=Pr(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Ry,startTime:n}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Sr.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function Zy(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const $i=e=>e*180/Math.PI,kl=e=>{const t=$i(Math.atan2(e[1],e[0]));return _l(t)},Qy={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:kl,rotateZ:kl,skewX:e=>$i(Math.atan(e[1])),skewY:e=>$i(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},_l=e=>(e=e%360,e<0&&(e+=360),e),Ud=kl,Wd=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Kd=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Jy={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Wd,scaleY:Kd,scale:e=>(Wd(e)+Kd(e))/2,rotateX:e=>_l($i(Math.atan2(e[6],e[5]))),rotateY:e=>_l($i(Math.atan2(-e[2],e[0]))),rotateZ:Ud,rotate:Ud,skewX:e=>$i(Math.atan(e[4])),skewY:e=>$i(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Cl(e){return e.includes("scale")?1:0}function Sl(e,t){if(!e||e==="none")return Cl(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=Jy,i=n;else{const d=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Qy,i=d}if(!i)return Cl(t);const o=r[t],a=i[1].split(",").map(t2);return typeof o=="function"?o(a):a[o]}const e2=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Sl(n,t)};function t2(e){return parseFloat(e.trim())}const ps=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],vs=new Set(ps),Gd=e=>e===ms||e===Ct,n2=new Set(["x","y","z"]),r2=ps.filter(e=>!n2.has(e));function i2(e){const t=[];return r2.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const ui={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:r})=>{const i=e.max-e.min;return r==="border-box"?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Sl(t,"x"),y:(e,{transform:t})=>Sl(t,"y")};ui.translateX=ui.x;ui.translateY=ui.y;const Si=new Set;let Tl=!1,Al=!1,Dl=!1;function Qm(){if(Al){const e=Array.from(Si).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const i=i2(r);i.length&&(n.set(r,i),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([o,a])=>{r.getValue(o)?.set(a)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}Al=!1,Tl=!1,Si.forEach(e=>e.complete(Dl)),Si.clear()}function Jm(){Si.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Al=!0)})}function s2(){Dl=!0,Jm(),Qm(),Dl=!1}class pc{constructor(t,n,r,i,o,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=i,this.element=o,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(Si.add(this),Tl||(Tl=!0,Fr.read(Jm),Fr.resolveKeyframes(Qm))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:i}=this;if(t[0]===null){const o=i?.get(),a=t[t.length-1];if(o!==void 0)t[0]=o;else if(r&&n){const d=r.readValue(n,a);d!=null&&(t[0]=d)}t[0]===void 0&&(t[0]=a),i&&o===void 0&&i.set(t[0])}Zy(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Si.delete(this)}cancel(){this.state==="scheduled"&&(Si.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const o2=e=>e.startsWith("--");function eh(e,t,n){o2(t)?e.style.setProperty(t,n):e.style[t]=n}const a2={};function th(e,t){const n=km(e);return()=>a2[t]??n()}const l2=th(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),nh=th(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ls=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Yd={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ls([0,.65,.55,1]),circOut:Ls([.55,0,1,.45]),backIn:Ls([.31,.01,.66,-.59]),backOut:Ls([.33,1.53,.69,.99])};function rh(e,t){if(e)return typeof e=="function"?nh()?Wm(e,t):"ease-out":Rm(e)?Ls(e):Array.isArray(e)?e.map(n=>rh(n,t)||Yd.easeOut):Yd[e]}function c2(e,t,n,{delay:r=0,duration:i=300,repeat:o=0,repeatType:a="loop",ease:d="easeOut",times:c}={},u=void 0){const g={[t]:n};c&&(g.offset=c);const f=rh(d,i);Array.isArray(f)&&(g.easing=f);const m={delay:r,duration:i,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:a==="reverse"?"alternate":"normal"};return u&&(m.pseudoElement=u),e.animate(g,m)}function vc(e){return typeof e=="function"&&"applyToOptions"in e}function d2({type:e,...t}){return vc(e)&&nh()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class ih extends hc{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:r,keyframes:i,pseudoElement:o,allowFlatten:a=!1,finalKeyframe:d,onComplete:c}=t;this.isPseudoElement=!!o,this.allowFlatten=a,this.options=t,sc(typeof t.type!="string");const u=d2(t);this.animation=c2(n,r,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const g=xa(i,this.options,d,this.speed);this.updateMotionValue&&this.updateMotionValue(g),eh(n,r,g),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const t=this.options?.element;!this.isPseudoElement&&t?.isConnected&&this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return Pr(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Pr(t)}get time(){return Pr(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Tr(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:r,observe:i}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&l2()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),gs):i(this)}}const sh={anticipate:Em,backInOut:Mm,circInOut:Im};function u2(e){return e in sh}function f2(e){typeof e.ease=="string"&&u2(e.ease)&&(e.ease=sh[e.ease])}const ja=10;class g2 extends ih{constructor(t){f2(t),Zm(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:i,element:o,...a}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const d=new Ys({...a,autoplay:!1}),c=Math.max(ja,Sr.now()-this.startTime),u=mi(0,ja,c-ja),g=d.sample(c).value,{name:f}=this.options;o&&f&&eh(o,f,g),n.setWithVelocity(d.sample(Math.max(0,c-u)).value,g,u),d.stop()}}const Xd=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Rr.test(e)||e==="0")&&!e.startsWith("url("));function m2(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function h2(e,t,n,r){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],a=Xd(i,t),d=Xd(o,t);return!a||!d?!1:m2(e)||(n==="spring"||vc(n))&&r}function Ml(e){e.duration=0,e.type="keyframes"}const oh=new Set(["opacity","clipPath","filter","transform"]),p2=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function v2(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&p2.test(e[t]))return!0;return!1}const b2=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),x2=km(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function y2(e){const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:o,type:a,keyframes:d}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:g}=t.owner.getProps();return x2()&&n&&(oh.has(n)||b2.has(n)&&v2(d))&&(n!=="transform"||!g)&&!u&&!r&&i!=="mirror"&&o!==0&&a!=="inertia"}const w2=40;class $2 extends hc{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:a="loop",keyframes:d,name:c,motionValue:u,element:g,...f}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Sr.now();const m={autoplay:t,delay:n,type:r,repeat:i,repeatDelay:o,repeatType:a,name:c,motionValue:u,element:g,...f},p=g?.KeyframeResolver||pc;this.keyframeResolver=new p(d,(w,h,k)=>this.onKeyframesResolved(w,h,m,!k),c,u,g),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,r,i){this.keyframeResolver=void 0;const{name:o,type:a,velocity:d,delay:c,isHandoff:u,onUpdate:g}=r;this.resolvedAt=Sr.now();let f=!0;h2(t,o,a,d)||(f=!1,(hi.instantAnimations||!c)&&g?.(xa(t,r,n)),t[0]=t[t.length-1],Ml(r),r.repeat=0);const p={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>w2?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},w=f&&!u&&y2(p),h=p.motionValue?.owner?.current;let k;if(w)try{k=new g2({...p,element:h})}catch{k=new Ys(p)}else k=new Ys(p);k.finished.then(()=>{this.notifyFinished()}).catch(gs),this.pendingTimeline&&(this.stopTimeline=k.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=k}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),s2()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}class k2{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>t.finished))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t){const n=this.animations.map(r=>r.attachTimeline(t));return()=>{n.forEach((r,i)=>{r&&r(),this.animations[i].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return Zd(this.animations,"duration")}get iterationDuration(){return Zd(this.animations,"iterationDuration")}runAll(t){this.animations.forEach(n=>n[t]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function Zd(e,t){let n=0;for(let r=0;r<e.length;r++){const i=e[r][t];i!==null&&i>n&&(n=i)}return n}class _2 extends k2{then(t,n){return this.finished.finally(t).then(()=>{})}}const C2=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function S2(e){const t=C2.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}function ah(e,t,n=1){const[r,i]=S2(e);if(!r)return;const o=window.getComputedStyle(t).getPropertyValue(r);if(o){const a=o.trim();return wm(a)?parseFloat(a):a}return dc(i)?ah(i,t,n+1):i}const T2={type:"spring",stiffness:500,damping:25,restSpeed:10},A2=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),D2={type:"keyframes",duration:.8},M2={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},E2=(e,{keyframes:t})=>t.length>2?D2:vs.has(e)?e.startsWith("scale")?A2(t[1]):T2:M2;function lh(e,t){if(e?.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function ch(e,t){const n=e?.[t]??e?.default??e;return n!==e?lh(n,e):n}const I2=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function L2(e){for(const t in e)if(!I2.has(t))return!0;return!1}const dh=(e,t,n,r={},i,o)=>a=>{const d=ch(r,e)||{},c=d.delay||r.delay||0;let{elapsed:u=0}=r;u=u-Tr(c);const g={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...d,delay:-u,onUpdate:m=>{t.set(m),d.onUpdate&&d.onUpdate(m)},onComplete:()=>{a(),d.onComplete&&d.onComplete()},name:e,motionValue:t,element:o?void 0:i};L2(d)||Object.assign(g,E2(e,g)),g.duration&&(g.duration=Tr(g.duration)),g.repeatDelay&&(g.repeatDelay=Tr(g.repeatDelay)),g.from!==void 0&&(g.keyframes[0]=g.from);let f=!1;if((g.type===!1||g.duration===0&&!g.repeatDelay)&&(Ml(g),g.delay===0&&(f=!0)),(hi.instantAnimations||hi.skipAnimations||i?.shouldSkipAnimations)&&(f=!0,Ml(g),g.delay=0),g.allowFlatten=!d.type&&!d.ease,f&&!o&&t.get()!==void 0){const m=xa(g.keyframes,d);if(m!==void 0){Fr.update(()=>{g.onUpdate(m),g.onComplete()});return}}return d.isSync?new Ys(g):new $2(g)};function Qd(e){const t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function uh(e,t,n,r){if(typeof t=="function"){const[i,o]=Qd(r);t=t(n!==void 0?n:e.custom,i,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,o]=Qd(r);t=t(n!==void 0?n:e.custom,i,o)}return t}function P2(e,t,n){const r=e.getProps();return uh(r,t,r.custom,e)}const fh=new Set(["width","height","top","left","right","bottom",...ps]),Jd=30,F2=e=>!isNaN(parseFloat(e));class R2{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=Sr.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Sr.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=F2(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new _m);const r=this.events[t].add(n);return t==="change"?()=>{r(),Fr.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Sr.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Jd)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Jd);return Cm(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function pi(e,t){return new R2(e,t)}const z2=e=>Array.isArray(e);function O2(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,pi(n))}function N2(e){return z2(e)?e[e.length-1]||0:e}function B2(e,t){const n=P2(e,t);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const a in o){const d=N2(o[a]);O2(e,a,d)}}const nr=e=>!!(e&&e.getVelocity);function q2(e){return!!(nr(e)&&e.add)}function j2(e,t){const n=e.getValue("willChange");if(q2(n))return n.add(t);if(!n&&hi.WillChange){const r=new hi.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function bc(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const V2="framerAppearId",H2="data-"+bc(V2);function U2(e){return e.props[H2]}function W2({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function K2(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o,transitionEnd:a,...d}=t;const c=e.getDefaultTransition();o=o?lh(o,c):c;const u=o?.reduceMotion;r&&(o=r);const g=[],f=i&&e.animationState&&e.animationState.getState()[i];for(const m in d){const p=e.getValue(m,e.latestValues[m]??null),w=d[m];if(w===void 0||f&&W2(f,m))continue;const h={delay:n,...ch(o||{},m)},k=p.get();if(k!==void 0&&!p.isAnimating()&&!Array.isArray(w)&&w===k&&!h.velocity){Fr.update(()=>p.set(w));continue}let v=!1;if(window.MotionHandoffAnimation){const b=U2(e);if(b){const _=window.MotionHandoffAnimation(b,m,Fr);_!==null&&(h.startTime=_,v=!0)}}j2(e,m);const C=u??e.shouldReduceMotion;p.start(dh(m,p,w,C&&fh.has(m)?{type:!1}:h,e,v));const y=p.animation;y&&g.push(y)}if(a){const m=()=>Fr.update(()=>{a&&B2(e,a)});g.length?Promise.all(g).then(m):m()}return g}const G2={test:e=>e==="auto",parse:e=>e},gh=e=>t=>t.test(e),mh=[ms,Ct,ns,ai,vy,py,G2],eu=e=>mh.find(gh(e));function Y2(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||$m(e):!0}const X2=new Set(["brightness","contrast","saturate","opacity"]);function Z2(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(uc)||[];if(!r)return e;const i=n.replace(r,"");let o=X2.has(t)?1:0;return r!==n&&(o*=100),t+"("+o+i+")"}const Q2=/\b([a-z-]*)\(.*?\)/gu,El={...Rr,getAnimatableNone:e=>{const t=e.match(Q2);return t?t.map(Z2).join(" "):e}},Il={...Rr,getAnimatableNone:e=>{const t=Rr.parse(e);return Rr.createTransformer(e)(t.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},tu={...ms,transform:Math.round},J2={rotate:ai,rotateX:ai,rotateY:ai,rotateZ:ai,scale:yo,scaleX:yo,scaleY:yo,scaleZ:yo,skew:ai,skewX:ai,skewY:ai,distance:Ct,translateX:Ct,translateY:Ct,translateZ:Ct,x:Ct,y:Ct,z:Ct,perspective:Ct,transformPerspective:Ct,opacity:Ks,originX:Bd,originY:Bd,originZ:Ct},xc={borderWidth:Ct,borderTopWidth:Ct,borderRightWidth:Ct,borderBottomWidth:Ct,borderLeftWidth:Ct,borderRadius:Ct,borderTopLeftRadius:Ct,borderTopRightRadius:Ct,borderBottomRightRadius:Ct,borderBottomLeftRadius:Ct,width:Ct,maxWidth:Ct,height:Ct,maxHeight:Ct,top:Ct,right:Ct,bottom:Ct,left:Ct,inset:Ct,insetBlock:Ct,insetBlockStart:Ct,insetBlockEnd:Ct,insetInline:Ct,insetInlineStart:Ct,insetInlineEnd:Ct,padding:Ct,paddingTop:Ct,paddingRight:Ct,paddingBottom:Ct,paddingLeft:Ct,paddingBlock:Ct,paddingBlockStart:Ct,paddingBlockEnd:Ct,paddingInline:Ct,paddingInlineStart:Ct,paddingInlineEnd:Ct,margin:Ct,marginTop:Ct,marginRight:Ct,marginBottom:Ct,marginLeft:Ct,marginBlock:Ct,marginBlockStart:Ct,marginBlockEnd:Ct,marginInline:Ct,marginInlineStart:Ct,marginInlineEnd:Ct,fontSize:Ct,backgroundPositionX:Ct,backgroundPositionY:Ct,...J2,zIndex:tu,fillOpacity:Ks,strokeOpacity:Ks,numOctaves:tu},ew={...xc,color:Vn,backgroundColor:Vn,outlineColor:Vn,fill:Vn,stroke:Vn,borderColor:Vn,borderTopColor:Vn,borderRightColor:Vn,borderBottomColor:Vn,borderLeftColor:Vn,filter:El,WebkitFilter:El,mask:Il,WebkitMask:Il},hh=e=>ew[e],tw=new Set([El,Il]);function ph(e,t){let n=hh(e);return tw.has(n)||(n=Rr),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const nw=new Set(["auto","none","0"]);function rw(e,t,n){let r=0,i;for(;r<e.length&&!i;){const o=e[r];typeof o=="string"&&!nw.has(o)&&ss(o).values.length&&(i=e[r]),r++}if(i&&n)for(const o of t)e[o]=ph(n,i)}class iw extends pc{constructor(t,n,r,i,o){super(t,n,r,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let g=0;g<t.length;g++){let f=t[g];if(typeof f=="string"&&(f=f.trim(),dc(f))){const m=ah(f,n.current);m!==void 0&&(t[g]=m),g===t.length-1&&(this.finalKeyframe=f)}}if(this.resolveNoneKeyframes(),!fh.has(r)||t.length!==2)return;const[i,o]=t,a=eu(i),d=eu(o),c=Nd(i),u=Nd(o);if(c!==u&&ui[r]){this.needsMeasurement=!0;return}if(a!==d)if(Gd(a)&&Gd(d))for(let g=0;g<t.length;g++){const f=t[g];typeof f=="string"&&(t[g]=parseFloat(f))}else ui[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let i=0;i<t.length;i++)(t[i]===null||Y2(t[i]))&&r.push(i);r.length&&rw(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ui[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(r,i).jump(i,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=r.length-1,a=r[o];r[o]=ui[n](t.measureViewportBox(),window.getComputedStyle(t.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([d,c])=>{t.getValue(d).set(c)}),this.resolveNoneKeyframes()}}function sw(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;t&&(r=t.current);const i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(r=>r!=null)}const vh=(e,t)=>t&&typeof e=="number"?t.transform(e):e,{schedule:ow}=zm(queueMicrotask,!1);function bh(e){return X1(e)&&"ownerSVGElement"in e}function aw(e){return bh(e)&&e.tagName==="svg"}function lw(e,t,n={}){const r=e.get();let i=null,o=r,a;const d=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,c=()=>{i&&(i.stop(),i=null),e.animation=void 0},u=()=>{const f=nu(e.get()),m=nu(o);if(f===m){c();return}const p=i?i.getGeneratorVelocity():e.getVelocity();c(),i=new Ys({keyframes:[f,m],velocity:p,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:a})},g=()=>{u(),e.animation=i??void 0,e.events.animationStart?.notify(),i?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((f,m)=>{o=f,a=p=>m(Va(p,d)),Fr.postRender(g)},c),nr(t)){let f=n.skipInitialAnimation===!0;const m=t.on("change",w=>{f?(f=!1,e.jump(Va(w,d),!1)):e.set(Va(w,d))}),p=e.on("destroy",m);return()=>{m(),p()}}return c}function Va(e,t){return t?e+t:e}function nu(e){return typeof e=="number"?e:parseFloat(e)}function ru(e,t,n){return lw(e,t,{type:"spring",...n})}const cw=[...mh,Vn,Rr],dw=e=>cw.find(gh(e)),iu=()=>({min:0,max:0}),yc=()=>({x:iu(),y:iu()}),Xs=new WeakMap;function uw(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function fw(e){return typeof e=="string"||Array.isArray(e)}const gw=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],mw=["initial",...gw];function xh(e){return uw(e.animate)||mw.some(t=>fw(e[t]))}function hw(e){return!!(xh(e)||e.variants)}function pw(e,t,n){for(const r in t){const i=t[r],o=n[r];if(nr(i))e.addValue(r,i);else if(nr(o))e.addValue(r,pi(i,{owner:e}));else if(o!==i)if(e.hasValue(r)){const a=e.getValue(r);a.liveStyle===!0?a.jump(i):a.hasAnimated||a.set(i)}else{const a=e.getStaticValue(r);e.addValue(r,pi(a!==void 0?a:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const Ll={current:null},yh={current:!1},vw=typeof window<"u";function bw(){if(yh.current=!0,!!vw)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Ll.current=e.matches;e.addEventListener("change",t),t()}else Ll.current=!1}const su=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let ou={};class wh{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:i,skipAnimations:o,blockInitialAnimation:a,visualState:d},c={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=pc,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=Sr.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,Fr.render(this.render,!1,!0))};const{latestValues:u,renderState:g}=d;this.latestValues=u,this.baseTarget={...u},this.initialValues=n.initial?{...u}:{},this.renderState=g,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=o,this.options=c,this.blockInitialAnimation=!!a,this.isControllingVariants=xh(n),this.isVariantNode=hw(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:f,...m}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in m){const w=m[p];u[p]!==void 0&&nr(w)&&w.set(u[p])}}mount(t){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=t,Xs.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(yh.current||bw(),this.shouldReduceMotion=Ll.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),bl(this.notifyUpdate),bl(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&oh.has(t)&&this.current instanceof HTMLElement){const{factory:a,keyframes:d,times:c,ease:u,duration:g}=n.accelerate,f=new ih({element:this.current,name:t,keyframes:d,times:c,ease:u,duration:Tr(g)}),m=a(f);this.valueSubscriptions.set(t,()=>{m(),f.cancel()});return}const r=vs.has(t);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",a=>{this.latestValues[t]=a,this.props.onUpdate&&Fr.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in ou){const n=ou[t];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[t]&&i&&r(this.props)&&(this.features[t]=new i(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):yc()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<su.length;r++){const i=su[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,a=t[o];a&&(this.propEventSubscriptions[i]=this.on(i,a))}this.prevMotionValues=pw(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=pi(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(wm(r)||$m(r))?r=parseFloat(r):!dw(r)&&Rr.test(n)&&(r=ph(t,n)),this.setBaseTarget(t,nr(r)?r.get():r)),nr(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=uh(this.props,n,this.presenceContext?.custom);o&&(r=o[t])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!nr(i)?i:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new _m),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){ow.render(this.render)}}class $h extends wh{constructor(){super(...arguments),this.KeyframeResolver=iw}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const r=t.style;return r?r[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;nr(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function xw({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function yw(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function ww(e,t){return xw(yw(e.getBoundingClientRect(),t))}const $w={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},kw=ps.length;function _w(e,t,n){let r="",i=!0;for(let o=0;o<kw;o++){const a=ps[o],d=e[a];if(d===void 0)continue;let c=!0;if(typeof d=="number")c=d===(a.startsWith("scale")?1:0);else{const u=parseFloat(d);c=a.startsWith("scale")?u===1:u===0}if(!c||n){const u=vh(d,xc[a]);if(!c){i=!1;const g=$w[a]||a;r+=`${g}(${u}) `}n&&(t[a]=u)}}return r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function kh(e,t,n){const{style:r,vars:i,transformOrigin:o}=e;let a=!1,d=!1;for(const c in t){const u=t[c];if(vs.has(c)){a=!0;continue}else if(Nm(c)){i[c]=u;continue}else{const g=vh(u,xc[c]);c.startsWith("origin")?(d=!0,o[c]=g):r[c]=g}}if(t.transform||(a||n?r.transform=_w(t,e.transform,n):r.transform&&(r.transform="none")),d){const{originX:c="50%",originY:u="50%",originZ:g=0}=o;r.transformOrigin=`${c} ${u} ${g}`}}function _h(e,{style:t,vars:n},r,i){const o=e.style;let a;for(a in t)o[a]=t[a];i?.applyProjectionStyles(o,r);for(a in n)o.setProperty(a,n[a])}function au(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Cs={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ct.test(e))e=parseFloat(e);else return e;const n=au(e,t.target.x),r=au(e,t.target.y);return`${n}% ${r}%`}},Cw={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=Rr.parse(e);if(i.length>5)return r;const o=Rr.createTransformer(e),a=typeof i[0]!="number"?1:0,d=n.x.scale*t.x,c=n.y.scale*t.y;i[0+a]/=d,i[1+a]/=c;const u=hs(d,c,.5);return typeof i[2+a]=="number"&&(i[2+a]/=u),typeof i[3+a]=="number"&&(i[3+a]/=u),o(i)}},Sw={borderRadius:{...Cs,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Cs,borderTopRightRadius:Cs,borderBottomLeftRadius:Cs,borderBottomRightRadius:Cs,boxShadow:Cw};function Tw(e,{layout:t,layoutId:n}){return vs.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Sw[e]||e==="opacity")}function Ch(e,t,n){const r=e.style,i=t?.style,o={};if(!r)return o;for(const a in r)(nr(r[a])||i&&nr(i[a])||Tw(a,e)||n?.getValue(a)?.liveStyle!==void 0)&&(o[a]=r[a]);return o}function Aw(e){return window.getComputedStyle(e)}class Dw extends $h{constructor(){super(...arguments),this.type="html",this.renderInstance=_h}readValueFromInstance(t,n){if(vs.has(n))return this.projection?.isProjecting?Cl(n):e2(t,n);{const r=Aw(t),i=(Nm(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return ww(t,n)}build(t,n,r){kh(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return Ch(t,n,r)}}function Mw(e,t){return e in t}class Ew extends wh{constructor(){super(...arguments),this.type="object"}readValueFromInstance(t,n){if(Mw(n,t)){const r=t[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(t,n){delete n.output[t]}measureInstanceViewportBox(){return yc()}build(t,n){Object.assign(t.output,n)}renderInstance(t,{output:n}){Object.assign(t,n)}sortInstanceNodePosition(){return 0}}const Iw={offset:"stroke-dashoffset",array:"stroke-dasharray"},Lw={offset:"strokeDashoffset",array:"strokeDasharray"};function Pw(e,t,n=1,r=0,i=!0){e.pathLength=1;const o=i?Iw:Lw;e[o.offset]=`${-r}`,e[o.array]=`${t} ${n}`}const Fw=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Rw(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:a=0,...d},c,u,g){if(kh(e,d,u),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:m}=e;f.transform&&(m.transform=f.transform,delete f.transform),(m.transform||f.transformOrigin)&&(m.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),m.transform&&(m.transformBox=g?.transformBox??"fill-box",delete f.transformBox);for(const p of Fw)f[p]!==void 0&&(m[p]=f[p],delete f[p]);t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),r!==void 0&&(f.scale=r),i!==void 0&&Pw(f,i,o,a,!1)}const Sh=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),zw=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Ow(e,t,n,r){_h(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(Sh.has(i)?i:bc(i),t.attrs[i])}function Nw(e,t,n){const r=Ch(e,t,n);for(const i in e)if(nr(e[i])||nr(t[i])){const o=ps.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=e[i]}return r}class Bw extends $h{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=yc}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(vs.has(n)){const r=hh(n);return r&&r.default||0}return n=Sh.has(n)?n:bc(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return Nw(t,n,r)}build(t,n,r){Rw(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,i){Ow(t,n,r,i)}mount(t){this.isSVGTag=zw(t.tagName),super.mount(t)}}function qw(e,t,n){const r=nr(e)?e:pi(e);return r.start(dh("",r,t,n)),r.animation}function wc(e){return typeof e=="object"&&!Array.isArray(e)}function Th(e,t,n,r){return e==null?[]:typeof e=="string"&&wc(t)?sw(e,n,r):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(i=>i!=null):[e]}function jw(e,t,n){return e*(t+1)}function lu(e,t,n,r){return typeof t=="number"?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,e+parseFloat(t)):t==="<"?n:t.startsWith("<")?Math.max(0,n+parseFloat(t.slice(1))):r.get(t)??e}function Vw(e,t,n){for(let r=0;r<e.length;r++){const i=e[r];i.at>t&&i.at<n&&(ic(e,i),r--)}}function Hw(e,t,n,r,i,o){Vw(e,i,o);for(let a=0;a<t.length;a++)e.push({value:t[a],at:hs(i,o,r[a]),easing:Fm(n,a)})}function Uw(e,t){for(let n=0;n<e.length;n++)e[n]=e[n]/(t+1)}function Ww(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}const Kw="easeInOut";function Gw(e,{defaultTransition:t={},...n}={},r,i){const o=t.duration||.3,a=new Map,d=new Map,c={},u=new Map;let g=0,f=0,m=0;for(let p=0;p<e.length;p++){const w=e[p];if(typeof w=="string"){u.set(w,f);continue}else if(!Array.isArray(w)){u.set(w.name,lu(f,w.at,g,u));continue}let[h,k,v={}]=w;v.at!==void 0&&(f=lu(f,v.at,g,u));let C=0;const y=(b,_,$,D=0,L=0)=>{const V=Yw(b),{delay:K=0,times:I=Xm(V),type:U=t.type||"keyframes",repeat:Y,repeatType:S,repeatDelay:M=0,...A}=_;let{ease:F=t.ease||"easeOut",duration:N}=_;const X=typeof K=="function"?K(D,L):K,B=V.length,O=vc(U)?U:i?.[U||"keyframes"];if(B<=2&&O){let j=100;if(B===2&&Qw(V)){const le=V[1]-V[0];j=Math.abs(le)}const H={...t,...A};N!==void 0&&(H.duration=Tr(N));const J=Km(H,j,O);F=J.ease,N=J.duration}N??(N=o);const z=f+X;I.length===1&&I[0]===0&&(I[1]=1);const q=I.length-V.length;if(q>0&&Ym(I,q),V.length===1&&V.unshift(null),Y){N=jw(N,Y);const j=[...V],H=[...I];F=Array.isArray(F)?[...F]:[F];const J=[...F];for(let le=0;le<Y;le++){V.push(...j);for(let de=0;de<j.length;de++)I.push(H[de]+(le+1)),F.push(de===0?"linear":Fm(J,de-1))}Uw(I,Y)}const Q=z+N;Hw($,V,F,I,z,Q),C=Math.max(X+N,C),m=Math.max(Q,m)};if(nr(h)){const b=cu(h,d);y(k,v,du("default",b))}else{const b=Th(h,k,r,c),_=b.length;for(let $=0;$<_;$++){k=k,v=v;const D=b[$],L=cu(D,d);for(const V in k)y(k[V],Xw(v,V),du(V,L),$,_)}}g=f,f+=C}return d.forEach((p,w)=>{for(const h in p){const k=p[h];k.sort(Ww);const v=[],C=[],y=[];for(let D=0;D<k.length;D++){const{at:L,value:V,easing:K}=k[D];v.push(V),C.push(ac(0,m,L)),y.push(K||"easeOut")}C[0]!==0&&(C.unshift(0),v.unshift(v[0]),y.unshift(Kw)),C[C.length-1]!==1&&(C.push(1),v.push(null)),a.has(w)||a.set(w,{keyframes:{},transition:{}});const b=a.get(w);b.keyframes[h]=v;const{type:_,...$}=t;b.transition[h]={...$,duration:m,ease:y,times:C,...n}}}),a}function cu(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function du(e,t){return t[e]||(t[e]=[]),t[e]}function Yw(e){return Array.isArray(e)?e:[e]}function Xw(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}const Zw=e=>typeof e=="number",Qw=e=>e.every(Zw);function Jw(e){const t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=bh(e)&&!aw(e)?new Bw(t):new Dw(t);n.mount(e),Xs.set(e,n)}function e$(e){const t={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},n=new Ew(t);n.mount(e),Xs.set(e,n)}function t$(e,t){return nr(e)||typeof e=="number"||typeof e=="string"&&!wc(t)}function Ah(e,t,n,r){const i=[];if(t$(e,t))i.push(qw(e,wc(t)&&t.default||t,n&&(n.default||n)));else{if(e==null)return i;const o=Th(e,t,r),a=o.length;for(let d=0;d<a;d++){const c=o[d],u=c instanceof Element?Jw:e$;Xs.has(c)||u(c);const g=Xs.get(c),f={...n};"delay"in f&&typeof f.delay=="function"&&(f.delay=f.delay(d,a)),i.push(...K2(g,{...t,transition:f},{}))}}return i}function n$(e,t,n){const r=[],i=e.map(a=>{if(Array.isArray(a)&&typeof a[0]=="function"){const d=a[0],c=pi(0);return c.on("change",d),a.length===1?[c,[0,1]]:a.length===2?[c,[0,1],a[1]]:[c,a[1],a[2]]}return a});return Gw(i,t,n,{spring:Gs}).forEach(({keyframes:a,transition:d},c)=>{r.push(...Ah(c,a,d))}),r}function r$(e){return Array.isArray(e)&&e.some(Array.isArray)}function i$(e={}){const{scope:t,reduceMotion:n}=e;function r(i,o,a){let d=[],c;if(r$(i)){const{onComplete:g,...f}=o||{};typeof g=="function"&&(c=g),d=n$(i,n!==void 0?{reduceMotion:n,...f}:f,t)}else{const{onComplete:g,...f}=a||{};typeof g=="function"&&(c=g),d=Ah(i,o,n!==void 0?{reduceMotion:n,...f}:f,t)}const u=new _2(d);return c&&u.finished.then(c),t&&(t.animations.push(u),u.finished.then(()=>{ic(t.animations,u)})),u}return r}const ia=i$(),s$=(e,t)=>e?.visualDuration===t?.visualDuration&&e?.bounce===t?.bounce&&e?.stiffness===t?.stiffness&&e?.damping===t?.damping&&e?.mass===t?.mass&&e?.velocity===t?.velocity;function ya(e,t){const n=()=>typeof t=="function"?t():t,[r,i]=ke(e()),o=pi(r()),a=pi(r());let d=n(),c=ru(a,o,d),u=a.on("change",g=>i(g));return $e(()=>{o.set(e())}),$e(()=>{if(!t)return;const g=n();s$(d,g)||(d=g,c(),c=ru(a,o,g),i(a.get()))}),vt(()=>{u(),c(),a.destroy(),o.destroy()}),r}var Dh=x("<div>"),o$=x("<form>");function a$(e){const[t,n]=rn(e,["children","class","classList"]);return(()=>{var r=Dh();return Nr(r,bt(n,{"data-dock-surface":"shell",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}),!1,!0),l(r,()=>t.children),r})()}function l$(e){const[t,n]=rn(e,["children","class","classList"]);return(()=>{var r=o$();return Nr(r,bt(n,{"data-dock-surface":"shell",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}),!1,!0),l(r,()=>t.children),r})()}function bs(e){const[t,n]=rn(e,["attach","children","class","classList"]);return(()=>{var r=Dh();return Nr(r,bt(n,{"data-dock-surface":"tray",get"data-dock-attach"(){return t.attach||"none"},get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}),!1,!0),l(r,()=>t.children),r})()}var c$=x('<div class="flex flex-col gap-1 py-1"><div class=text-13-medium></div><div class="text-12-regular text-text-invert-base"></div><div class="text-12-regular text-text-invert-base">'),d$=x('<div class="text-12-regular text-text-invert-base">');const u$=e=>{const t=hn(),n=c=>{const u=`${c.id} ${c.name}`.toLowerCase();return/claude|anthropic/.test(u)?t.t("model.provider.anthropic"):/gpt|o[1-4]|codex|openai/.test(u)?t.t("model.provider.openai"):/gemini|palm|bard|google/.test(u)?t.t("model.provider.google"):/grok|xai/.test(u)?t.t("model.provider.xai"):/llama|meta/.test(u)?t.t("model.provider.meta"):c.provider.name},r=c=>c==="text"?t.t("model.input.text"):c==="image"?t.t("model.input.image"):c==="audio"?t.t("model.input.audio"):c==="video"?t.t("model.input.video"):c==="pdf"?t.t("model.input.pdf"):c,i=()=>{const c=[];e.latest&&c.push(t.t("model.tag.latest")),e.free&&c.push(t.t("model.tag.free"));const u=c.length?` (${c.join(", ")})`:"";return`${n(e.model)} ${e.model.name}${u}`},o=()=>{if(e.model.capabilities){const g=e.model.capabilities.input,m=["text","image","audio","video","pdf"].filter(p=>g[p]).map(p=>r(p));return m.length?m.join(", "):void 0}const c=e.model.modalities?.input;if(!c)return;const u=c.map(g=>r(g));return u.length?u.join(", "):void 0},a=()=>e.model.capabilities?e.model.capabilities.reasoning?t.t("model.tooltip.reasoning.allowed"):t.t("model.tooltip.reasoning.none"):e.model.reasoning?t.t("model.tooltip.reasoning.allowed"):t.t("model.tooltip.reasoning.none"),d=()=>t.t("model.tooltip.context",{limit:e.model.limit.context.toLocaleString()});return(()=>{var c=c$(),u=c.firstChild,g=u.nextSibling,f=g.nextSibling;return l(u,i),l(c,s(E,{get when(){return o()},children:m=>(()=>{var p=d$();return l(p,()=>t.t("model.tooltip.allows",{inputs:m()})),p})()}),g),l(g,a),l(f,d),c})()};var f$=x('<div class="w-full flex items-center gap-x-2 text-13-regular"><span class=truncate>'),g$=x('<div class="flex items-center gap-1">');const uu=(e,t)=>e==="opencode"&&(!t||t.input===0),Mh=e=>{const t=e.model??Pi().model,n=hn(),r=T(()=>t.list().filter(i=>t.visible({modelID:i.id,providerID:i.provider.id})).filter(i=>e.provider?i.provider.id===e.provider:!0));return s(T0,{get class(){return`flex-1 min-h-0 [&_[data-slot=list-scroll]]:flex-1 [&_[data-slot=list-scroll]]:min-h-0 ${e.class??""}`},get search(){return{placeholder:n.t("dialog.model.search.placeholder"),autofocus:!0,action:e.action}},get emptyMessage(){return n.t("dialog.model.empty")},key:i=>`${i.provider.id}:${i.id}`,items:r,get current(){return t.current()},filterKeys:["provider.name","name","id"],sortBy:(i,o)=>i.name.localeCompare(o.name),groupBy:i=>i.provider.name,sortGroupsBy:(i,o)=>{const a=i.items[0].provider.id,d=o.items[0].provider.id;return ji.includes(a)&&!ji.includes(d)?-1:!ji.includes(a)&&ji.includes(d)?1:ji.indexOf(a)-ji.indexOf(d)},itemWrapper:(i,o)=>s(Nn,{class:"w-full",placement:"right-start",gutter:12,get value(){return s(u$,{model:i,get latest(){return i.latest},get free(){return uu(i.provider.id,i.cost)}})},children:o}),onSelect:i=>{t.set(i?{modelID:i.id,providerID:i.provider.id}:void 0,{recent:!0}),e.onSelect()},children:i=>(()=>{var o=f$(),a=o.firstChild;return l(a,()=>i.name),l(o,s(E,{get when(){return uu(i.provider.id,i.cost)},get children(){return s(fd,{get children(){return n.t("model.tag.free")}})}}),null),l(o,s(E,{get when(){return i.latest},get children(){return s(fd,{get children(){return n.t("model.tag.latest")}})}}),null),o})()})};function Eh(e){const[t,n]=St({open:!1,dismiss:null}),r=dr(),i=()=>{n("open",!1),Kn(()=>import("./dialog-manage-models-CR0Dw6KE.js"),__vite__mapDeps([4,1,2,5,6,7,8,9])).then(d=>{r.show(()=>s(d.DialogManageModels,{}))})},o=()=>{n("open",!1),Kn(()=>import("./dialog-select-provider-BQqjRbS8.js").then(d=>d.d),__vite__mapDeps([7,1,2,5,8,9])).then(d=>{r.show(()=>s(d.DialogSelectProvider,{}))})},a=hn();return s(ci,{get open(){return t.open},onOpenChange:d=>{d&&n("dismiss",null),n("open",d)},modal:!1,placement:"top-start",gutter:4,get children(){return[s(ci.Trigger,bt({get as(){return e.triggerAs??"div"}},()=>e.triggerProps,{get children(){return e.children}})),s(ci.Portal,{get children(){return s(ci.Content,{class:"w-72 h-80 flex flex-col p-2 rounded-md border border-border-base bg-surface-raised-stronger-non-alpha shadow-md z-50 outline-none overflow-hidden",onEscapeKeyDown:d=>{n("dismiss","escape"),n("open",!1),d.preventDefault(),d.stopPropagation()},onPointerDownOutside:()=>{n("dismiss","outside"),n("open",!1)},onFocusOutside:()=>{n("dismiss","outside"),n("open",!1)},onCloseAutoFocus:d=>{t.dismiss==="outside"&&d.preventDefault(),n("dismiss",null)},get children(){return[s(ci.Title,{class:"sr-only",get children(){return a.t("dialog.model.select.title")}}),s(Mh,{get provider(){return e.provider},get model(){return e.model},onSelect:()=>n("open",!1),class:"p-1",get action(){return(()=>{var d=g$();return l(d,s(Nn,{placement:"top",get value(){return a.t("command.provider.connect")},get children(){return s(Ot,{icon:"plus-small",variant:"ghost",iconSize:"normal",class:"size-6",get"aria-label"(){return a.t("command.provider.connect")},onClick:o})}}),null),l(d,s(Nn,{placement:"top",get value(){return a.t("dialog.model.manage")},get children(){return s(Ot,{icon:"sliders",variant:"ghost",iconSize:"normal",class:"size-6",get"aria-label"(){return a.t("dialog.model.manage")},onClick:i})}}),null),d})()}})]}})}})]}})}const m$=e=>{const t=dr(),n=hn(),r=()=>{Kn(()=>import("./dialog-select-provider-BQqjRbS8.js").then(o=>o.d),__vite__mapDeps([7,1,2,5,8,9])).then(o=>{t.show(()=>s(o.DialogSelectProvider,{}))})},i=()=>{Kn(()=>import("./dialog-manage-models-CR0Dw6KE.js"),__vite__mapDeps([4,1,2,5,6,7,8,9])).then(o=>{t.show(()=>s(o.DialogManageModels,{}))})};return s(no,{get title(){return n.t("dialog.model.select.title")},get action(){return s(kt,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:r,get children(){return n.t("command.provider.connect")}})},get children(){return[s(Mh,{get provider(){return e.provider},get model(){return e.model},onSelect:()=>t.close()}),s(kt,{variant:"ghost",class:"ml-3 mt-5 mb-6 text-text-base self-start",onClick:i,get children(){return n.t("dialog.model.manage")}})]}})},h$=Object.freeze(Object.defineProperty({__proto__:null,DialogSelectModel:m$,ModelSelectorPopover:Eh},Symbol.toStringTag,{value:"Module"})),Ih=()=>typeof window>"u"?!1:window.__opencode_e2e?.prompt?.enabled===!0,Ha=()=>{if(Ih())return window.__opencode_e2e?.prompt},Ua={set(e){const t=Ha();t&&(t.current={popover:e.popover,slash:{active:e.slash.active,ids:[...e.slash.ids]},hash:{active:e.hash.active,ids:[...e.hash.ids]},selected:t.current?.selected??null,selects:t.current?.selects??0})},select(e){const t=Ha();if(!t)return;const n=t.current;t.current={popover:n?.popover??null,slash:{active:n?.slash.active??null,ids:[...n?.slash.ids??[]]},hash:{active:n?.hash.active??null,ids:[...n?.hash.ids??[]]},selected:e,selects:(n?.selects??0)+1}},clear(){const e=Ha();e&&(e.current=void 0)}},p$=8e3,v$=120;function b$(e){if(e.length>=p$)return!0;let t=0;for(const n of e)if(n===`
9
+ `&&(t+=1,t>=v$))return!0;return!1}function x$(e){return e.includes("\r")?e.replace(/\r\n?/g,`
10
+ `):e}function y$(e){return b$(e)||e.includes(`
11
+ `)||e.includes("\r")?"manual":"native"}function w$(e,t){return new Promise(n=>{const r=new FileReader;r.addEventListener("error",()=>n("")),r.addEventListener("load",()=>{const i=typeof r.result=="string"?r.result:"",o=i.indexOf(",");if(o===-1){n(i);return}n(`data:${t};base64,${i.slice(o+1)}`)}),r.readAsDataURL(e)})}function $$(e){const t=Oi(),n=hn(),r=()=>{nt({title:n.t("prompt.toast.pasteUnsupported.title"),description:n.t("prompt.toast.pasteUnsupported.description")})},i=async(p,w=!0)=>{const h=await N1(p);if(!h)return w&&r(),!1;const k=e.editor();if(!k)return!1;const v=await w$(p,h);if(!v)return!1;const C={type:"image",id:Sv(),filename:p.name,mime:h,dataUrl:v},y=t.cursor()??oi(k);return t.set([...t.current(),C],y),!0},o=p=>i(p),a=async(p,w=!0)=>{let h=!1;for(const k of p)await i(k,!1)&&(h=!0);return!h&&p.length>0&&w&&r(),h},d=p=>{const h=t.current().filter(k=>k.type!=="image"||k.id!==p);t.set(h,t.cursor())},c=async p=>{const w=p.clipboardData;if(!w)return;p.preventDefault(),p.stopPropagation();const h=Array.from(w.items).flatMap(b=>{if(b.kind!=="file")return[];const _=b.getAsFile();return _?[_]:[]});if(h.length>0){await a(h);return}const k=w.getData("text/plain")??"";if(e.readClipboardImage&&!k){const b=await e.readClipboardImage();if(b){await o(b);return}}if(!k)return;const v=x$(k),C=()=>e.addPart({type:"text",content:v,start:0,end:0})?!0:(e.focusEditor(),e.addPart({type:"text",content:v,start:0,end:0}));if(y$(v)==="manual"){C();return}typeof document.execCommand=="function"&&document.execCommand("insertText",!1,v)||C()},u=p=>{const w=p.target;return w instanceof Element?!!w.closest('[data-scope="filetree"]'):!1},g=p=>{if(e.isDialogActive()||(p.preventDefault(),u(p)))return;const w=p.dataTransfer?.types.includes("Files"),h=p.dataTransfer?.types.includes("text/plain");w?e.setDraggingType("image"):h&&e.setDraggingType("@mention")},f=p=>{e.isDialogActive()||u(p)||p.relatedTarget||e.setDraggingType(null)},m=async p=>{if(e.isDialogActive()||(p.preventDefault(),u(p)))return;e.setDraggingType(null);const w=p.dataTransfer?.getData("text/plain"),h="file:";if(w?.startsWith(h)){const v=w.slice(h.length);e.focusEditor(),e.addPart({type:"file",path:v,content:"@"+v,start:0,end:0});return}const k=p.dataTransfer?.files;k&&await a(Array.from(k))};return Mn(()=>{document.addEventListener("dragover",g),document.addEventListener("dragleave",f),document.addEventListener("drop",m)}),vt(()=>{document.removeEventListener("dragover",g),document.removeEventListener("dragleave",f),document.removeEventListener("drop",m)}),{addAttachment:o,addAttachments:a,removeAttachment:d,handlePaste:c}}const k$=[{type:"text",content:"",start:0,end:0}],_$=100;function C$(e,t,n,r=!1){const i=Math.max(0,Math.min(n,t.length)),o=i===0,a=i===t.length;return r?o||a:e==="up"?i===0&&t.length===0:i===t.length}function sa(e){return e.map(t=>t.type==="text"?{...t}:t.type==="image"?{...t}:t.type==="agent"?{...t}:t.type==="entity"?{...t}:{...t,selection:t.selection?{...t.selection}:void 0})}function S$(e){return{start:e.start,end:e.end,...e.side?{side:e.side}:{},...e.endSide?{endSide:e.endSide}:{}}}function $c(e){return e.map(t=>({...t,selection:S$(t.selection)}))}function js(e){return Array.isArray(e)?{prompt:sa(e),comments:[]}:{prompt:sa(e.prompt),comments:$c(e.comments)}}function ti(e){return e.reduce((t,n)=>t+("content"in n?n.content.length:0),0)}function T$(e,t,n=[],r=_$){const i=t.map(u=>"content"in u?u.content:"").join("").trim(),o=t.some(u=>u.type==="image"),a=n.some(u=>!!u.comment.trim());if(!i&&!o&&!a)return e;const d={prompt:sa(t),comments:$c(n)},c=e[0];return c&&D$(c,d)?e:[d,...e].slice(0,r)}function A$(e,t){return e.path===t.path&&e.comment===t.comment&&e.origin===t.origin&&e.preview===t.preview&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end&&e.selection.side===t.selection.side&&e.selection.endSide===t.selection.endSide}function D$(e,t){const n=js(e),r=js(t);if(n.prompt.length!==r.prompt.length)return!1;for(let i=0;i<n.prompt.length;i++){const o=n.prompt[i],a=r.prompt[i];if(o.type!==a.type||o.type==="text"&&o.content!==(a.type==="text"?a.content:""))return!1;if(o.type==="file"){if(o.path!==(a.type==="file"?a.path:""))return!1;const d=o.selection,c=a.type==="file"?a.selection:void 0;if(!(!d&&!c||!!d&&!!c&&d.startLine===c.startLine&&d.startChar===c.startChar&&d.endLine===c.endLine&&d.endChar===c.endChar))return!1}if(o.type==="agent"&&o.name!==(a.type==="agent"?a.name:"")||o.type==="image"&&o.id!==(a.type==="image"?a.id:""))return!1}if(n.comments.length!==r.comments.length)return!1;for(let i=0;i<n.comments.length;i++){const o=n.comments[i],a=r.comments[i];if(!o||!a||!A$(o,a))return!1}return!0}function M$(e){if(e.direction==="up"){if(e.entries.length===0)return{handled:!1,historyIndex:e.historyIndex,savedPrompt:e.savedPrompt};if(e.historyIndex===-1){const t=js(e.entries[0]);return{handled:!0,historyIndex:0,savedPrompt:{prompt:sa(e.currentPrompt),comments:$c(e.currentComments)},entry:t,cursor:"start"}}if(e.historyIndex<e.entries.length-1){const t=e.historyIndex+1,n=js(e.entries[t]);return{handled:!0,historyIndex:t,savedPrompt:e.savedPrompt,entry:n,cursor:"start"}}return{handled:!1,historyIndex:e.historyIndex,savedPrompt:e.savedPrompt}}if(e.historyIndex>0){const t=e.historyIndex-1,n=js(e.entries[t]);return{handled:!0,historyIndex:t,savedPrompt:e.savedPrompt,entry:n,cursor:"end"}}return e.historyIndex===0?e.savedPrompt?{handled:!0,historyIndex:-1,savedPrompt:null,entry:e.savedPrompt,cursor:"end"}:{handled:!0,historyIndex:-1,savedPrompt:null,entry:{prompt:k$,comments:[]},cursor:"end"}:{handled:!1,historyIndex:e.historyIndex,savedPrompt:e.savedPrompt}}var E$=x('<div class="absolute inset-x-0 -top-2 -translate-y-full origin-bottom-left max-h-80 min-h-10 overflow-auto no-scrollbar flex flex-col p-2 rounded-[12px] bg-surface-raised-stronger-non-alpha shadow-[var(--shadow-lg-border-base)]">'),wo=x('<div class="text-text-weak px-2 py-1">'),I$=x('<div class="text-11-medium uppercase tracking-wide text-text-weak px-2 py-1">'),L$=x('<button class="w-full flex items-center gap-x-2 rounded-md px-2 py-0.5"><span class="text-14-regular text-text-strong whitespace-nowrap">@'),P$=x('<button class="w-full flex items-center gap-x-2 rounded-md px-2 py-0.5"><div class="flex flex-col items-start min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">@</span><span class="text-12-regular text-text-weak truncate"></span></div><span class="ml-auto shrink-0 text-10-medium text-text-subtle px-1.5 py-0.5 bg-surface-base rounded">'),F$=x('<span class="text-text-strong whitespace-nowrap">'),R$=x('<button class="w-full flex items-center gap-x-2 rounded-md px-2 py-0.5"><div class="flex items-center text-14-regular min-w-0"><span class="text-text-weak whitespace-nowrap truncate min-w-0">'),z$=x('<button class="w-full flex items-center gap-x-2 rounded-md px-2 py-0.5"><div class="flex flex-col items-start min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">#</span><span class="text-12-regular text-text-weak truncate">'),O$=x('<button class="w-full flex items-center gap-x-2 rounded-md px-2 py-0.5"><div class="flex flex-col items-start min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">#</span><span class="text-12-regular text-text-weak">'),N$=x('<span class="text-14-regular text-text-weak truncate">'),B$=x('<span class="text-11-regular text-text-subtle px-1.5 py-0.5 bg-surface-base rounded">'),q$=x('<span class="text-12-regular text-text-subtle">'),j$=x('<button><div class="flex items-center gap-2 min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">/</span></div><div class="flex items-center gap-2 shrink-0">'),V$=x('<button class="w-full flex items-center gap-x-2 rounded-md px-2 py-0.5"><div class="flex flex-col items-start min-w-0"><span class="text-14-regular text-text-strong whitespace-nowrap">[[<!>]]</span><span class="text-12-regular text-text-weak truncate"></span></div><span class="ml-auto shrink-0 text-10-medium text-text-subtle px-1.5 py-0.5 bg-surface-base rounded">');const H$=e=>s(E,{get when(){return e.popover},get children(){var t=E$();return t.$$mousedown=n=>n.preventDefault(),Lt(n=>{e.popover==="slash"&&e.setSlashPopoverRef(n)},t),l(t,s(Dn,{get children(){return[s(ot,{get when(){return e.popover==="at"},get children(){return s(E,{get when(){return e.atFlat.length>0},get fallback(){return(()=>{var n=wo();return l(n,()=>e.t("prompt.popover.emptyResults")),n})()},get children(){return s(Oe,{get each(){return e.atGrouped},children:n=>[s(E,{get when(){return n.category},get children(){var r=I$();return l(r,()=>n.category==="agent"&&"Agents",null),l(r,()=>n.category==="entity"&&"Entities",null),l(r,()=>n.category==="recent"&&"Recent",null),l(r,()=>n.category==="file"&&"Files",null),r}}),s(Oe,{get each(){return n.items.slice(0,10)},children:r=>{const i=e.atKey(r);if(r.type==="agent")return(()=>{var c=L$(),u=c.firstChild;return u.firstChild,c.addEventListener("mouseenter",()=>e.setAtActive(i)),c.$$click=()=>e.onAtSelect(r),l(c,s(Ue,{name:"brain",size:"small",class:"text-icon-info-active shrink-0"}),u),l(u,()=>r.name,null),G(()=>c.classList.toggle("bg-surface-raised-base-hover",e.atActive===i)),c})();if(r.type==="entity"){const c=()=>{switch(r.entityType){case"issue":return"checklist";case"milestone":return"trophy";case"decision":return"brain";case"symbol":return"code";default:return"archive"}};return(()=>{var u=P$(),g=u.firstChild,f=g.firstChild;f.firstChild;var m=f.nextSibling,p=g.nextSibling;return u.addEventListener("mouseenter",()=>e.setAtActive(i)),u.$$click=()=>e.onAtSelect(r),l(u,s(Ue,{get name(){return c()},size:"small",class:"text-icon-info-active shrink-0"}),g),l(f,()=>r.entityId,null),l(m,()=>r.display),l(p,()=>r.entityType),G(()=>u.classList.toggle("bg-surface-raised-base-hover",e.atActive===i)),u})()}const o=r.path.endsWith("/"),a=o?r.path:ls(r.path),d=o?"":Sn(r.path);return(()=>{var c=R$(),u=c.firstChild,g=u.firstChild;return c.addEventListener("mouseenter",()=>e.setAtActive(i)),c.$$click=()=>e.onAtSelect(r),l(c,s(cr,{get node(){return{path:r.path,type:"file"}},class:"shrink-0 size-4"}),u),l(g,a),l(u,s(E,{when:!o,get children(){var f=F$();return l(f,d),f}}),null),G(()=>c.classList.toggle("bg-surface-raised-base-hover",e.atActive===i)),c})()}})]})}})}}),s(ot,{get when(){return e.popover==="hash"},get children(){return s(E,{get when(){return e.hashFlat.length>0},get fallback(){return(()=>{var n=wo();return l(n,()=>e.t("prompt.popover.emptyResults")),n})()},get children(){return s(Oe,{get each(){return e.hashFlat.slice(0,10)},children:n=>{const r=`${n.type}-${n.name}`;return n.type==="entity"?(()=>{var i=z$(),o=i.firstChild,a=o.firstChild;a.firstChild;var d=a.nextSibling;return i.addEventListener("mouseenter",()=>e.setHashActive(r)),i.$$click=()=>e.onHashSelect(n),l(i,s(Ue,{name:"archive",size:"small",class:"text-icon-success-active shrink-0"}),o),l(a,()=>n.name,null),l(d,()=>n.display),G(()=>i.classList.toggle("bg-surface-raised-base-hover",e.hashActive===r)),i})():(()=>{var i=O$(),o=i.firstChild,a=o.firstChild;a.firstChild;var d=a.nextSibling;return i.addEventListener("mouseenter",()=>e.setHashActive(r)),i.$$click=()=>e.onHashSelect(n),l(i,s(Ue,{name:"code",size:"small",class:"text-icon-warning-active shrink-0"}),o),l(a,()=>n.name,null),l(d,()=>n.symbolType),G(()=>i.classList.toggle("bg-surface-raised-base-hover",e.hashActive===r)),i})()}})}})}}),s(ot,{get when(){return e.popover==="slash"},get children(){return s(E,{get when(){return e.slashFlat.length>0},get fallback(){return(()=>{var n=wo();return l(n,()=>e.t("prompt.popover.emptyCommands")),n})()},get children(){return s(Oe,{get each(){return e.slashFlat},children:n=>(()=>{var r=j$(),i=r.firstChild,o=i.firstChild;o.firstChild;var a=i.nextSibling;return r.addEventListener("mouseenter",()=>e.setSlashActive(n.id)),r.$$click=()=>e.onSlashSelect(n),l(o,()=>n.trigger,null),l(i,s(E,{get when(){return n.description},get children(){var d=N$();return l(d,()=>n.description),d}}),null),l(a,s(E,{get when(){return Te(()=>n.type==="custom")()&&n.source!=="command"},get children(){var d=B$();return l(d,(()=>{var c=Te(()=>n.source==="skill");return()=>c()?e.t("prompt.slash.badge.skill"):Te(()=>n.source==="mcp")()?e.t("prompt.slash.badge.mcp"):e.t("prompt.slash.badge.custom")})()),d}}),null),l(a,s(E,{get when(){return e.commandKeybind(n.id)},get children(){var d=q$();return l(d,()=>e.commandKeybind(n.id)),d}}),null),G(d=>{var c=n.id,u={"w-full flex items-center justify-between gap-4 rounded-md px-2 py-1":!0,"bg-surface-raised-base-hover":e.slashActive===n.id};return c!==d.e&&ue(r,"data-slash-id",d.e=c),d.t=Tt(r,u,d.t),d},{e:void 0,t:void 0}),r})()})}})}}),s(ot,{get when(){return e.popover==="wiki"},get children(){return s(E,{get when(){return e.wikiFlat.length>0},get fallback(){return(()=>{var n=wo();return l(n,()=>e.t("prompt.popover.emptyResults")),n})()},get children(){return s(Oe,{get each(){return e.wikiFlat.slice(0,10)},children:n=>{const r=`${n.namespace}:${n.target}`,i=()=>{switch(n.namespace){case"issue":return"checklist";case"milestone":return"trophy";case"decision":return"brain";case"file":return"file";default:return"archive"}};return(()=>{var o=V$(),a=o.firstChild,d=a.firstChild,c=d.firstChild,u=c.nextSibling;u.nextSibling;var g=d.nextSibling,f=a.nextSibling;return o.addEventListener("mouseenter",()=>e.setWikiActive(r)),o.$$click=()=>e.onWikiSelect(n),l(o,s(Ue,{get name(){return i()},size:"small",class:"text-icon-info-active shrink-0"}),a),l(d,()=>n.target,u),l(g,()=>n.display),l(f,()=>n.namespace),G(()=>o.classList.toggle("bg-surface-raised-base-hover",e.wikiActive===r)),o})()}})}})}})]}})),t}});Kt(["mousedown","click"]);var U$=x('<div class="flex flex-nowrap items-start gap-2 p-2 overflow-x-auto no-scrollbar">'),W$=x('<div><div class="flex items-center gap-1.5"><div class="flex items-center text-11-regular min-w-0 font-medium"><span class="text-text-strong whitespace-nowrap">'),K$=x('<span class="flex max-w-[300px]"><span class="text-text-invert-base truncate-start [unicode-bidi:plaintext] min-w-0"></span><span class=shrink-0>'),G$=x('<span class="text-text-weak whitespace-nowrap shrink-0">'),Y$=x('<div class="text-12-regular text-text-strong ml-5 pr-1 truncate">');const X$=e=>s(E,{get when(){return e.items.length>0},get children(){var t=U$();return l(t,s(Oe,{get each(){return e.items},children:n=>{const r=ls(n.path),i=Sn(n.path),o=Tv(n.path,14),a=e.active(n);return s(Nn,{get value(){return(()=>{var d=K$(),c=d.firstChild,u=c.nextSibling;return l(c,r),l(u,i),d})()},placement:"top",openDelay:2e3,get children(){var d=W$(),c=d.firstChild,u=c.firstChild,g=u.firstChild;return d.$$click=()=>e.openComment(n),l(c,s(cr,{get node(){return{path:n.path,type:"file"}},class:"shrink-0 size-3.5"}),u),l(g,o),l(u,s(E,{get when(){return n.selection},children:f=>(()=>{var m=G$();return l(m,(()=>{var p=Te(()=>f().startLine===f().endLine);return()=>p()?`:${f().startLine}`:`:${f().startLine}-${f().endLine}`})()),m})()}),null),l(c,s(Ot,{type:"button",icon:"close-small",variant:"ghost",class:"ml-auto size-3.5 text-text-weak hover:text-text-strong transition-all",onClick:f=>{f.stopPropagation(),e.remove(n)},get"aria-label"(){return e.t("prompt.context.removeFile")}}),null),l(d,s(E,{get when(){return n.comment},children:f=>(()=>{var m=Y$();return l(m,f),m})()}),null),G(f=>Tt(d,{"group shrink-0 flex flex-col rounded-[6px] pl-2 pr-1 py-1 max-w-[200px] h-12 cursor-default transition-all transition-transform shadow-xs-border hover:shadow-xs-border-hover":!0,"hover:bg-surface-interactive-weak":!!n.commentID&&!a,"bg-surface-interactive-hover hover:bg-surface-interactive-hover shadow-xs-border-hover":a,"bg-background-stronger":!a},f)),d}})}})),t}});Kt(["click"]);var Z$=x('<div class="flex flex-wrap gap-2 px-3 pt-3">'),Q$=x('<img class="size-16 rounded-md object-cover border border-border-base hover:border-border-strong-base transition-colors">'),J$=x('<div class="relative group"><button type=button class="absolute -top-1.5 -right-1.5 size-5 rounded-full bg-surface-raised-stronger-non-alpha border border-border-base flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-surface-raised-base-hover"></button><div class="absolute bottom-0 left-0 right-0 px-1 py-0.5 bg-black/50 rounded-b-md"><span class="text-10-regular text-white truncate block">'),ek=x('<div class="size-16 rounded-md bg-surface-base flex items-center justify-center border border-border-base">');const tk=e=>e.startsWith("audio/")?"music":e.startsWith("video/")?"video":e==="application/pdf"||e.includes("document")||e.includes("sheet")||e.includes("presentation")?"file-text":"folder",nk=e=>s(E,{get when(){return e.attachments.length>0},get children(){var t=Z$();return l(t,s(Oe,{get each(){return e.attachments},children:n=>(()=>{var r=J$(),i=r.firstChild,o=i.nextSibling,a=o.firstChild;return l(r,s(E,{get when(){return n.mime.startsWith("image/")},get fallback(){return(()=>{var d=ek();return l(d,s(Ue,{get name(){return tk(n.mime)},class:"size-6 text-text-weak"})),d})()},get children(){var d=Q$();return d.$$click=()=>e.onOpen(n),G(c=>{var u=n.dataUrl,g=n.filename;return u!==c.e&&ue(d,"src",c.e=u),g!==c.t&&ue(d,"alt",c.t=g),c},{e:void 0,t:void 0}),d}}),i),i.$$click=()=>e.onRemove(n.id),l(i,s(Ue,{name:"close",class:"size-3 text-text-weak"})),l(a,()=>n.filename),G(()=>ue(i,"aria-label",e.removeLabel)),r})()})),t}});Kt(["click"]);var rk=x('<div class="absolute inset-0 z-10 flex items-center justify-center bg-surface-raised-stronger-non-alpha/90 pointer-events-none"><div class="flex flex-col items-center gap-2 text-text-weak"><span class=text-14-regular>');const fu={image:"photo","@mention":"link"},ik=e=>s(E,{get when(){return e.type!==null},get children(){var t=rk(),n=t.firstChild,r=n.firstChild;return l(n,s(Ue,{get name(){return Te(()=>!!e.type)()?fu[e.type]:fu.image},class:"size-8"}),r),l(r,()=>e.label),t}});function sk(e){return e.mode==="shell"?e.t("prompt.placeholder.shell"):e.commentCount>1?e.t("prompt.placeholder.summarizeComments"):e.commentCount===1?e.t("prompt.placeholder.summarizeComment"):e.suggest?e.t("prompt.placeholder.normal",{example:e.example}):e.t("prompt.placeholder.simple")}var ok=x("<div data-slot=image-preview-header>"),ak=x("<div data-slot=image-preview-body><img data-slot=image-preview-image>"),lk=x("<div data-component=image-preview><div data-slot=image-preview-container>");function Lh(e){const t=xn();return(()=>{var n=lk(),r=n.firstChild;return l(r,s(Jc.Content,{"data-slot":"image-preview-content",get children(){return[(()=>{var i=ok();return l(i,s(Jc.CloseButton,{"data-slot":"image-preview-close",as:Ot,icon:"close",variant:"ghost",get"aria-label"(){return t.t("ui.common.close")}})),i})(),(()=>{var i=ak(),o=i.firstChild;return G(a=>{var d=e.src,c=e.alt??t.t("ui.imagePreview.alt");return d!==a.e&&ue(o,"src",a.e=d),c!==a.t&&ue(o,"alt",a.t=c),a},{e:void 0,t:void 0}),i})()]}})),n})()}var ck=x('<div class="flex items-center gap-2"><span></span><span class="text-icon-base text-12-medium text-[10px]!">'),dk=x('<div class="flex items-center gap-2"><span>'),uk=x('<div class="absolute top-0 inset-x-0 pl-3 pr-2 pt-2 text-14-regular text-text-weak pointer-events-none whitespace-nowrap truncate"style=padding-bottom:56px>'),fk=x('<div class=relative><div class="relative max-h-[240px] overflow-y-auto no-scrollbar"style=scroll-padding-bottom:56px><div data-component=prompt-input role=textbox aria-multiline=true contenteditable=true style=padding-bottom:56px></div></div><div aria-hidden=true class="pointer-events-none absolute inset-x-0 bottom-0"style="height:56px;background:linear-gradient(to top, var(--surface-raised-stronger-non-alpha) calc(100% - 20px), transparent)"></div><div class="pointer-events-none absolute bottom-2 right-2 flex items-center gap-2"><input type=file multiple class=hidden><div class="flex items-center gap-1 pointer-events-auto"></div></div><div class="pointer-events-none absolute bottom-2 left-2"><div class=pointer-events-auto>'),gu=x("<span class=truncate>"),gk=x('<div class="px-1.75 pt-4 pb-1 flex items-center gap-1 min-w-0"><div class="flex items-center gap-1.5 min-w-0 flex-1 relative"><div class="h-7 flex items-center gap-1.5 max-w-[160px] min-w-0 absolute inset-y-0 left-0"style="padding:0 4px 0 8px"><span class="truncate text-13-medium text-text-strong"></span><div class="size-4 shrink-0"></div></div><div class="flex items-center gap-1.5 min-w-0 flex-1"><div data-component=prompt-agent-control></div><div data-component=prompt-model-control></div><div data-component=prompt-variant-control>'),mk=x('<div class="relative size-full _max-h-[320px] flex flex-col gap-0">');const Wa=["prompt.example.1","prompt.example.2","prompt.example.3","prompt.example.4","prompt.example.5","prompt.example.6","prompt.example.7","prompt.example.8","prompt.example.9","prompt.example.10","prompt.example.11","prompt.example.12","prompt.example.13","prompt.example.14","prompt.example.15","prompt.example.16","prompt.example.17","prompt.example.18","prompt.example.19","prompt.example.20","prompt.example.21","prompt.example.22","prompt.example.23","prompt.example.24","prompt.example.25"],hk=/[^\s\u200B]/,pk=e=>{const t=zn(),n=br(),r=Pi(),i=yr(),o=Oi(),a=Hr(),d=Ul(),c=dr(),u=Vl(),g=Li(),f=fa(),m=hn(),p=aa(),{params:w,tabs:h,view:k}=Ur(),v=Ar(),C=Ri();let y,b,_,$;const D={input:!1},L=56,V=()=>{const R=_,se=window.getSelection();if(!R||!se||se.rangeCount===0)return;const fe=se.getRangeAt(0);if(!y.contains(fe.startContainer))return;const Pe=oi(y),dt=ti(o.current().filter(Qt=>Qt.type!=="image"));if(Pe>=dt){R.scrollTop=R.scrollHeight;return}const Qe=fe.getClientRects().item(0)??fe.getBoundingClientRect();if(!Qe.height)return;const pt=R.getBoundingClientRect(),Wt=Qe.top-pt.top+R.scrollTop,mn=Qe.bottom-pt.top+R.scrollTop,$t=12;if(Wt<R.scrollTop+$t){R.scrollTop=Math.max(0,Wt-$t);return}mn>R.scrollTop+R.clientHeight-L&&(R.scrollTop=mn-R.clientHeight+L)},K=(R=2)=>{requestAnimationFrame(()=>{V(),R>1&&K(R-1)})},I=fs({tabs:h,pathFromTab:i.pathFromTab,normalizeTab:R=>R.startsWith("file://")?i.tab(R):R}).activeFileTab,U=R=>{const se=w.id;if(!se)return!1;const fe=n.data.session_diff[se];return fe?fe.some(Pe=>Pe.file===R):!1},Y=R=>{if(!R.commentID)return;const se={file:R.path,id:R.commentID};d.setActive(se);const fe=(Qe=6)=>{const pt=Wt=>{requestAnimationFrame(()=>{d.setFocus({...se}),!(Wt<=0)&&requestAnimationFrame(()=>{const mn=d.focus();mn&&(mn.file!==se.file||mn.id!==se.id||pt(Wt-1))})})};pt(Qe)};if(R.commentOrigin==="review"||R.commentOrigin!=="file"&&U(R.path)){k().reviewPanel.opened()||k().reviewPanel.open(),a.fileTree.setTab("changes"),h().setActive("review"),fe();return}k().reviewPanel.opened()||k().reviewPanel.open(),a.fileTree.setTab("all");const dt=i.tab(R.path);h().open(dt),h().setActive(dt),Promise.resolve(i.load(R.path)).finally(()=>fe())},S=T(()=>{const R=h().all(),se=I(),fe=se?[se,...R.filter(Qe=>Qe!==se)]:R,Pe=new Set,dt=[];for(const Qe of fe){const pt=i.pathFromTab(Qe);pt&&(Pe.has(pt)||(Pe.add(pt),dt.push(pt)))}return dt}),M=T(()=>w.id?n.session.get(w.id):void 0),A=T(()=>n.data.session_status[w.id??""]??{type:"idle"}),F=T(()=>A()?.type!=="idle"),N=()=>F()?(()=>{var R=ck(),se=R.firstChild,fe=se.nextSibling;return l(se,()=>m.t("prompt.action.stop")),l(fe,()=>m.t("common.key.esc")),R})():(()=>{var R=dk(),se=R.firstChild;return l(se,()=>m.t("prompt.action.send")),l(R,s(Ue,{name:"enter",size:"small",class:"text-icon-base"}),null),R})(),X=T(()=>o.current().filter(R=>R.type==="image")),[B,O]=St({popover:null,historyIndex:-1,savedPrompt:null,placeholder:Math.floor(Math.random()*Wa.length),draggingType:null,mode:"normal",applyingHistory:!1}),z=ya(()=>B.mode==="normal"?1:0,{visualDuration:.2,bounce:0}),q=R=>({opacity:R,transform:`scale(${.95+R*.05})`,filter:`blur(${(1-R)*2}px)`,"pointer-events":R>.5?"auto":"none"}),Q=T(()=>q(z())),j=T(()=>q(1-z())),H=T(()=>({height:"28px",...Q()})),J=T(()=>B.mode==="shell"?0:o.context.items().filter(R=>!!R.comment?.trim()).length),le=T(()=>{const R=o.context.items();return B.mode!=="shell"?R:R.filter(se=>!se.comment?.trim())}),de=T(()=>{const R=w.id;if(!R)return!1;const se=n.data.message[R];return se?se.some(fe=>fe.role==="user"):!1}),[Re,Ve]=Xr(Zr.global("prompt-history",["prompt-history.v1"]),St({entries:[]})),[Z,ne]=Xr(Zr.global("prompt-history-shell",["prompt-history-shell.v1"]),St({entries:[]})),re=T(()=>!de()),ie=T(()=>sk({mode:B.mode,commentCount:J(),example:re()?m.t(Wa[B.placeholder]):"",suggest:re(),t:(R,se)=>m.t(R,se)})),be=()=>{const R=new Map(d.all().map(se=>[`${se.file}
12
+ ${se.id}`,se]));return o.context.items().flatMap(se=>{if(se.type!=="file")return[];const fe=se.comment?.trim();if(!fe)return[];const dt=(se.commentID?R.get(`${se.path}
13
+ ${se.commentID}`)?.selection:void 0)??(se.selection?{start:se.selection.startLine,end:se.selection.endLine}:void 0);return dt?[{id:se.commentID??se.key,path:se.path,selection:{...dt},comment:fe,time:se.commentID?R.get(`${se.path}
14
+ ${se.commentID}`)?.time??Date.now():Date.now(),origin:se.commentOrigin,preview:se.preview}]:[]})},Fe=R=>{d.replace(R.map(se=>({id:se.id,file:se.path,selection:{...se.selection},comment:se.comment,time:se.time}))),o.context.replaceComments(R.map(se=>({type:"file",path:se.path,selection:is(se.selection),comment:se.comment,commentID:se.id,commentOrigin:se.origin,preview:se.preview})))},ee=(R,se)=>{const fe=R.prompt,Pe=se==="start"?0:ti(fe);O("applyingHistory",!0),Fe(R.comments),o.set(fe,Pe),requestAnimationFrame(()=>{y.focus(),Yi(y,Pe),O("applyingHistory",!1),K()})},_e=()=>{const R=window.getSelection(),se=ti(o.current());if(!R||R.rangeCount===0)return{collapsed:!1,cursorPosition:0,textLength:se};const fe=R.anchorNode;return!fe||!y.contains(fe)?{collapsed:!1,cursorPosition:0,textLength:se}:{collapsed:R.isCollapsed,cursorPosition:oi(y),textLength:se}},xe=()=>p.platform==="desktop"&&p.os==="macos",ye=()=>b?.click(),Le=R=>{O("mode",R),O("popover",null),requestAnimationFrame(()=>y?.focus())},tt="mod+shift+x",ge="mod+shift+e";g.register("prompt-input",()=>[{id:"file.attach",title:m.t("prompt.action.attachFile"),category:m.t("command.category.file"),keybind:"mod+u",disabled:B.mode!=="normal",onSelect:ye},{id:"prompt.mode.shell",title:m.t("command.prompt.mode.shell"),category:m.t("command.category.session"),keybind:tt,disabled:B.mode==="shell",onSelect:()=>Le("shell")},{id:"prompt.mode.normal",title:m.t("command.prompt.mode.normal"),category:m.t("command.category.session"),keybind:ge,disabled:B.mode==="normal",onSelect:()=>Le("normal")}]);const qe=()=>O("popover",null),we=(R=!1)=>{!R&&(B.historyIndex<0||B.applyingHistory)||(O("historyIndex",-1),O("savedPrompt",null))},He=()=>{y.innerHTML=""},Ne=R=>{He(),y.textContent=R},Ee=()=>{requestAnimationFrame(()=>{y.focus();const R=document.createRange(),se=window.getSelection();R.selectNodeContents(y),R.collapse(!1),se?.removeAllRanges(),se?.addRange(R)})},rt=()=>{const R=window.getSelection();return!R||R.rangeCount===0||!y.contains(R.anchorNode)?null:oi(y)},ct=R=>{const se=rt();Jt(R),se!==null&&Yi(y,se)};$e(()=>{if(w.id,w.id||!re())return;const R=setInterval(()=>{O("placeholder",se=>(se+1)%Wa.length)},6500);vt(()=>clearInterval(R))});const[zt,xt]=ke(!1),st=R=>R.isComposing||zt()||R.keyCode===229,gt=()=>{qe(),xt(!1)},$n=()=>{xt(!0)},Ce=()=>{xt(!1),requestAnimationFrame(()=>{zt()||Ut(o.current().filter(R=>R.type!=="image"))})},Dt=T(()=>n.data.agent.filter(R=>!R.hidden&&R.mode!=="primary").map(R=>({type:"agent",name:R.name,display:R.name}))),lt=T(()=>r.agent.list().map(R=>R.name)),At=R=>{R&&(R.type==="agent"?Zt({type:"agent",name:R.name,content:"@"+R.name}):R.type==="entity"?Zt({type:"entity",entityType:R.entityType,entityId:R.entityId,content:`@${R.entityType}:${R.entityId}`}):Zt({type:"file",path:R.path,content:"@"+R.path}))},wt=R=>R?R.type==="agent"?`agent:${R.name}`:R.type==="entity"?`entity:${R.entityType}:${R.entityId}`:`file:${R.path}`:"",{flat:It,grouped:W,active:oe,setActive:me,onInput:he,onKeyDown:Ie}=mo({items:async R=>{const se=Dt(),fe=S(),Pe=new Set(fe),dt=fe.map(yn=>({type:"file",path:yn,display:yn,recent:!0})),Qe=[],pt=new Set,Wt=yn=>{pt.has(yn.entityId)||(pt.add(yn.entityId),Qe.push(yn))};if(v.ready){const yn=await v.fetchStoreEntities();for(const ce of yn)Wt({type:"entity",entityType:ce.type,entityId:ce.id,display:Av(ce.id)});for(const ce of v.issues)Wt({type:"entity",entityType:"issue",entityId:ce.id,display:`${ce.id}: ${ce.title}`});try{const ce=await v.fetchDecisions({limit:20});for(const Se of ce)Wt({type:"entity",entityType:"decision",entityId:Se.id,display:Se.toolName})}catch{}try{const ce=await v.fetchMilestones();for(const Se of ce)Wt({type:"entity",entityType:"milestone",entityId:Se.id,display:Se.message??Se.id})}catch{}}const mn=Qe.sort((yn,ce)=>ed({id:yn.entityId,type:yn.entityType})-ed({id:ce.entityId,type:ce.entityType})||yn.entityId.localeCompare(ce.entityId));if(!R.trim())return[...se,...dt,...mn.slice(0,20)];const Qt=(await i.searchFilesAndDirectories(R)).filter(yn=>!Pe.has(yn)).map(yn=>({type:"file",path:yn,display:yn})),_t=R.toLowerCase(),qn=mn.filter(yn=>yn.entityId.toLowerCase().includes(_t)||yn.display.toLowerCase().includes(_t)||yn.entityType.toLowerCase().includes(_t)).slice(0,20);return[...se,...dt,...qn,...Qt]},key:wt,filterKeys:["display","entityId","entityType","path","name"],groupBy:R=>R.type==="agent"?"agent":R.type==="entity"?"entity":R.recent?"recent":"file",sortGroupsBy:(R,se)=>{const fe=Pe=>Pe==="agent"?0:Pe==="entity"?1:Pe==="recent"?2:3;return fe(R.category)-fe(se.category)},onSelect:At}),Ae=T(()=>{const R=g.options.filter(fe=>!fe.disabled&&!fe.id.startsWith("suggested.")&&fe.slash).map(fe=>({id:fe.id,trigger:fe.slash,title:fe.title,description:fe.description,keybind:fe.keybind,type:"builtin"}));return[...n.data.command.map(fe=>({id:`custom.${fe.name}`,trigger:fe.name,title:fe.name,description:fe.description,type:"custom",source:fe.source})),...R]}),De=R=>{if(R){if(Ua.select(R.id),qe(),R.type==="custom"){const se=`/${R.trigger} `;Ne(se),o.set([{type:"text",content:se,start:0,end:se.length}],se.length),Ee();return}He(),o.set([{type:"text",content:"",start:0,end:0}],0),g.trigger(R.id,"slash")}},{flat:Ke,active:yt,setActive:Nt,onInput:Ft,onKeyDown:kn}=mo({items:Ae,key:R=>R?.id,filterKeys:["trigger","title"],onSelect:De}),Yt=R=>{R&&Zt({type:"entity",entityType:R.type==="entity"?R.entityType:R.symbolType,entityId:R.name,content:`#${R.name}`})},an=R=>R?`${R.type}:${R.name}`:"",En=R=>{R&&Zt({type:"entity",entityType:R.namespace,entityId:R.target,content:`[[${R.namespace}:${R.target}]]`})},dn=R=>R?`${R.namespace}:${R.target}`:"",{flat:Xt,active:sn,setActive:_n,onInput:fn,onKeyDown:Hn}=mo({items:async R=>{if(!v.ready)return[];const fe=v.issues.map(Qe=>({type:"entity",name:Qe.id,entityType:"issue",display:`${Qe.id}: ${Qe.title}`})),Pe=[],dt=[...fe,...Pe];return R.trim()?dt.filter(Qe=>Qe.name.toLowerCase().includes(R.toLowerCase())||Qe.display.toLowerCase().includes(R.toLowerCase())||Qe.type==="entity"&&Qe.entityType.toLowerCase().includes(R.toLowerCase())).slice(0,10):dt.slice(0,10)},key:an,filterKeys:["name","display","entityType"],groupBy:R=>R.type,sortGroupsBy:(R,se)=>R.category.localeCompare(se.category),onSelect:Yt}),{flat:Xn,active:On,setActive:je,onInput:ht,onKeyDown:vn}=mo({items:async R=>{if(!v.ready)return[];const se=[];for(const Pe of v.issues)se.push({namespace:"issue",target:Pe.id,display:Pe.title});try{const Pe=await v.fetchMilestones();for(const dt of Pe)se.push({namespace:"milestone",target:dt.id,display:dt.message??dt.id})}catch{}try{const Pe=await v.fetchDecisions({limit:20});for(const dt of Pe)se.push({namespace:"decision",target:dt.id,display:dt.toolName})}catch{}if(!R.trim())return se.slice(0,10);const fe=R.toLowerCase();return se.filter(Pe=>Pe.target.toLowerCase().includes(fe)||Pe.display.toLowerCase().includes(fe)||Pe.namespace.includes(fe)).slice(0,10)},key:dn,filterKeys:["target","display","namespace"],onSelect:En}),ln=R=>{const se=document.createElement("span");return se.textContent=R.content,se.setAttribute("data-type",R.type),R.type==="file"&&se.setAttribute("data-path",R.path),R.type==="agent"&&se.setAttribute("data-name",R.name),R.type==="entity"&&(se.setAttribute("data-entity-type",R.entityType),se.setAttribute("data-entity-id",R.entityId),se.style.cursor="pointer",se.addEventListener("click",()=>{R.entityType==="issue"&&C(`/trellis?issue=${R.entityId}`)})),se.setAttribute("contenteditable","false"),se.style.userSelect="text",se},cn=()=>Array.from(y.childNodes).every(R=>{if(R.nodeType===Node.TEXT_NODE){const fe=R.textContent??"";if(!fe.includes("​"))return!0;if(fe!=="​")return!1;const Pe=R.previousSibling,dt=R.nextSibling;return!!(Pe?.nodeType===Node.ELEMENT_NODE&&Pe.tagName==="BR")&&!dt}if(R.nodeType!==Node.ELEMENT_NODE)return!1;const se=R;return se.dataset.type==="file"||se.dataset.type==="agent"||se.dataset.type==="entity"?!0:se.tagName==="BR"}),Jt=R=>{He();for(const fe of R){if(fe.type==="text"){y.appendChild(zd(fe.content));continue}(fe.type==="file"||fe.type==="agent"||fe.type==="entity")&&y.appendChild(ln(fe))}const se=y.lastChild;se?.nodeType===Node.ELEMENT_NODE&&se.tagName==="BR"&&y.appendChild(document.createTextNode("​"))};$e(()=>{const R=yt();!R||!$||requestAnimationFrame(()=>{$.querySelector(`[data-slash-id="${R}"]`)?.scrollIntoView({block:"nearest",behavior:"smooth"})})}),Ih()&&($e(()=>{Ua.set({popover:B.popover==="wiki"?null:B.popover,slash:{active:yt()??null,ids:Ke().map(R=>R.id)},hash:{active:sn()??null,ids:Xt().map(R=>an(R))}})}),vt(()=>Ua.clear()));const en=()=>{if(B.popover==="at"){const R=It();if(R.length===0)return;const se=oe(),fe=R.find(Pe=>wt(Pe)===se)??R[0];At(fe);return}if(B.popover==="slash"){const R=Ke();if(R.length===0)return;const se=yt(),fe=R.find(Pe=>Pe.id===se)??R[0];De(fe);return}if(B.popover==="hash"){const R=Xt();if(R.length===0)return;const se=sn(),fe=R.find(Pe=>an(Pe)===se)??R[0];Yt(fe);return}if(B.popover==="wiki"){const R=Xn();if(R.length===0)return;const se=On(),fe=R.find(Pe=>dn(Pe)===se)??R[0];En(fe)}},Ut=R=>{if(D.input){if(D.input=!1,cn())return;ct(R);return}const se=gn();cn()&&Dv(R,se)||ct(R)};$e(Pt(()=>o.current(),R=>{zt()||Ut(R.filter(se=>se.type!=="image"))}));const gn=()=>{const R=[];let se=0,fe="";const Pe=()=>{let $t=fe;$t.includes("\r")&&($t=$t.replace(/\r\n?/g,`
15
+ `)),$t.includes("​")&&($t=$t.replace(/\u200B/g,"")),fe="",$t&&(R.push({type:"text",content:$t,start:se,end:se+$t.length}),se+=$t.length)},dt=$t=>{const Qt=$t.textContent??"";R.push({type:"file",path:$t.dataset.path,content:Qt,start:se,end:se+Qt.length}),se+=Qt.length},Qe=$t=>{const Qt=$t.textContent??"";R.push({type:"agent",name:$t.dataset.name,content:Qt,start:se,end:se+Qt.length}),se+=Qt.length},pt=$t=>{const Qt=$t.textContent??"";R.push({type:"entity",entityType:$t.dataset.entityType,entityId:$t.dataset.entityId,content:Qt,start:se,end:se+Qt.length}),se+=Qt.length},Wt=$t=>{if($t.nodeType===Node.TEXT_NODE){fe+=$t.textContent??"";return}if($t.nodeType!==Node.ELEMENT_NODE)return;const Qt=$t;if(Qt.dataset.type==="file"){Pe(),dt(Qt);return}if(Qt.dataset.type==="agent"){Pe(),Qe(Qt);return}if(Qt.dataset.type==="entity"){Pe(),pt(Qt);return}if(Qt.tagName==="BR"){fe+=`
16
+ `;return}for(const _t of Array.from(Qt.childNodes))Wt(_t)},mn=Array.from(y.childNodes);return mn.forEach(($t,Qt)=>{const _t=$t.nodeType===Node.ELEMENT_NODE&&["DIV","P"].includes($t.tagName);Wt($t),_t&&Qt<mn.length-1&&(fe+=`
17
+ `)}),Pe(),R.length===0&&R.push(...td),R},Gt=()=>{const R=gn(),se=X(),fe=oi(y),Pe=R.length===1&&R[0]?.type==="text"?R[0].content:R.map(Wt=>"content"in Wt?Wt.content:"").join(""),dt=R.some(Wt=>Wt.type!=="text");if(!hk.test(Pe)&&!dt&&se.length===0){qe(),we(),o.dirty()&&(D.input=!0,o.set(td,0)),K();return}if(B.mode==="shell")qe();else{const Wt=Pe.substring(0,fe).match(/@(\S*)$/),mn=Pe.match(/^\/(\S*)$/),$t=Pe.substring(0,fe).match(/#(\S*)$/),Qt=Pe.substring(0,fe).match(/\[\[([^\]]*?)$/);Qt?(ht(Qt[1]),O("popover","wiki")):Wt?(he(Wt[1]),O("popover","at")):mn?(Ft(mn[1]),O("popover","slash")):$t?(fn($t[1]),O("popover","hash")):qe()}we(),D.input=!0,o.set([...R,...se],fe),K()},Zt=R=>{if(R.type==="image")return!1;const se=window.getSelection();if(!se)return!1;if(se.rangeCount===0||!y.contains(se.anchorNode)){y.focus();const Pe=o.cursor()??ti(o.current());Yi(y,Pe)}if(se.rangeCount===0)return!1;const fe=se.getRangeAt(0);if(!y.contains(fe.startContainer))return!1;if(R.type==="file"||R.type==="agent"||R.type==="entity"){const Pe=oi(y),Qe=o.current().map(_t=>"content"in _t?_t.content:"").join("").substring(0,Pe),pt=Qe.match(/@(\S*)$/),Wt=Qe.match(/#(\S*)$/),mn=Qe.match(/\[\[([^\]]*?)$/),$t=ln(R),Qt=document.createTextNode(" ");if(pt&&(R.type==="file"||R.type==="agent")){const _t=pt.index??Pe-pt[0].length;Ui(y,fe,"start",_t),Ui(y,fe,"end",Pe)}if(Wt&&R.type==="entity"&&!mn){const _t=Wt.index??Pe-Wt[0].length;Ui(y,fe,"start",_t),Ui(y,fe,"end",Pe)}if(mn&&R.type==="entity"){const _t=mn.index??Pe-mn[0].length;Ui(y,fe,"start",_t),Ui(y,fe,"end",Pe)}fe.deleteContents(),fe.insertNode(Qt),fe.insertNode($t),fe.setStartAfter(Qt),fe.collapse(!0),se.removeAllRanges(),se.addRange(fe)}if(R.type==="text"){const Pe=zd(R.content),dt=Pe.lastChild;if(fe.deleteContents(),fe.insertNode(Pe),dt){if(dt.nodeType===Node.TEXT_NODE){const Qe=dt.textContent??"";Qe==="​"&&fe.setStart(dt,0),Qe!=="​"&&fe.setStart(dt,Qe.length)}if(dt.nodeType!==Node.TEXT_NODE){const Qe=dt.nodeType===Node.ELEMENT_NODE&&dt.tagName==="BR",pt=dt.nextSibling,Wt=pt?.nodeType===Node.TEXT_NODE&&(pt.textContent??"")==="";if(Qe&&(!pt||Wt)){const mn=pt&&Wt?pt:document.createTextNode("​");pt||dt.parentNode?.insertBefore(mn,null),mn.textContent="​",fe.setStart(mn,0)}else fe.setStartAfter(dt)}}fe.collapse(!0),se.removeAllRanges(),se.addRange(fe)}return Gt(),qe(),!0},te=(R,se)=>{const fe=se==="shell"?Z:Re,Pe=se==="shell"?ne:Ve,dt=T$(fe.entries,R,se==="shell"?[]:be());dt!==fe.entries&&Pe("entries",dt)};$e(Pt(()=>e.edit?.id,R=>{const se=e.edit;if(!(!R||!se)){for(const fe of o.context.items())o.context.remove(fe.key);for(const fe of se.context)o.context.add({type:fe.type,path:fe.path,selection:fe.selection,comment:fe.comment,commentID:fe.commentID,commentOrigin:fe.commentOrigin,preview:fe.preview});O("mode","normal"),O("popover",null),O("historyIndex",-1),O("savedPrompt",null),o.set(se.prompt,ti(se.prompt)),requestAnimationFrame(()=>{y.focus(),Yi(y,ti(se.prompt)),K()}),e.onEditLoaded?.()}},{defer:!0}));const pe=R=>{const se=M$({direction:R,entries:B.mode==="shell"?Z.entries:Re.entries,historyIndex:B.historyIndex,currentPrompt:o.current(),currentComments:be(),savedPrompt:B.savedPrompt});return se.handled?(O("historyIndex",se.historyIndex),O("savedPrompt",se.savedPrompt),ee(se.entry,se.cursor),!0):!1},{addAttachments:We,removeAttachment:ut,handlePaste:at}=$$({editor:()=>y,isDialogActive:()=>!!c.active,setDraggingType:R=>O("draggingType",R),focusEditor:()=>{y.focus(),Yi(y,ti(o.current()))},addPart:Zt,readClipboardImage:p.readClipboardImage}),Mt=T(()=>["default",...r.model.variant.list()]),Be=T(()=>{const R=w.id;return R?f.isAutoAccepting(R,t.directory):f.isAutoAcceptingDirectory(t.directory)}),ft=T(()=>m.t(Be()?"command.permissions.autoaccept.disable":"command.permissions.autoaccept.enable")),Vt=()=>{if(!w.id){f.toggleAutoAcceptDirectory(t.directory);return}f.toggleAutoAccept(w.id,t.directory)},{abort:Bt,handleSubmit:pn}=G1({info:M,imageAttachments:X,commentCount:J,autoAccept:()=>Be(),mode:()=>B.mode,working:F,editor:()=>y,queueScroll:K,promptLength:ti,addToHistory:te,resetHistoryNavigation:()=>{we(!0)},setMode:R=>O("mode",R),setPopover:R=>O("popover",R),newSessionWorktree:()=>e.newSessionWorktree,onNewSessionWorktreeReset:e.onNewSessionWorktreeReset,shouldQueue:e.shouldQueue,onQueue:e.onQueue,onAbort:e.onAbort,onSubmit:e.onSubmit}),Cn=R=>{if((R.metaKey||R.ctrlKey)&&!R.altKey&&!R.shiftKey&&R.key.toLowerCase()==="u"){if(R.preventDefault(),B.mode!=="normal")return;ye();return}if(R.key==="Backspace"){const fe=window.getSelection();if(fe&&fe.isCollapsed){const Pe=fe.anchorNode,dt=fe.anchorOffset;if(Pe&&Pe.nodeType===Node.TEXT_NODE){const Qe=Pe.textContent??"";if(/^\u200B+$/.test(Qe)&&dt>0){const pt=document.createRange();pt.setStart(Pe,0),pt.collapse(!0),fe.removeAllRanges(),fe.addRange(pt)}}}}if(R.key==="!"&&B.mode==="normal"&&oi(y)===0){O("mode","shell"),O("popover",null),R.preventDefault();return}if(R.key==="Escape"){if(B.popover){qe(),R.preventDefault(),R.stopPropagation();return}if(B.mode==="shell"){O("mode","normal"),R.preventDefault(),R.stopPropagation();return}if(F()){Bt(),R.preventDefault(),R.stopPropagation();return}if(xe()){y.blur(),R.preventDefault(),R.stopPropagation();return}}if(B.mode==="shell"){const{collapsed:fe,cursorPosition:Pe,textLength:dt}=_e();if(R.key==="Backspace"&&fe&&Pe===0&&dt===0){O("mode","normal"),R.preventDefault();return}}if(R.key==="Enter"&&R.shiftKey){Zt({type:"text",content:`
18
+ `}),R.preventDefault();return}if(R.key==="Enter"&&st(R))return;const se=R.ctrlKey&&!R.metaKey&&!R.altKey&&!R.shiftKey;if(B.popover){if(R.key==="Tab"){en(),R.preventDefault();return}const fe=R.key==="ArrowUp"||R.key==="ArrowDown"||R.key==="Enter",Pe=se&&(R.key==="n"||R.key==="p");if(fe||Pe){if(B.popover==="at"){Ie(R),R.preventDefault();return}B.popover==="slash"&&kn(R),B.popover==="hash"&&Hn(R),B.popover==="wiki"&&vn(R),R.preventDefault();return}}if(se&&R.code==="KeyG"){if(B.popover){qe(),R.preventDefault();return}F()&&(Bt(),R.preventDefault());return}if(R.key==="ArrowUp"||R.key==="ArrowDown"){if(R.altKey||R.ctrlKey||R.metaKey)return;const{collapsed:fe}=_e();if(!fe)return;const Pe=oi(y),dt=o.current().map(pt=>"content"in pt?pt.content:"").join(""),Qe=R.key==="ArrowUp"?"up":"down";if(!C$(Qe,dt,Pe,B.historyIndex>=0))return;pe(Qe)&&R.preventDefault();return}if(R.key==="Enter"&&!R.shiftKey){if(R.preventDefault(),R.repeat||F()&&o.current().map(fe=>"content"in fe?fe.content:"").join("").trim().length===0&&X().length===0&&J()===0)return;pn(R)}};return(()=>{var R=mk();return l(R,s(H$,{get popover(){return B.popover},setSlashPopoverRef:se=>$=se,get atFlat(){return It()},get atGrouped(){return W.latest??[]},get atActive(){return oe()??void 0},atKey:wt,setAtActive:me,onAtSelect:At,get slashFlat(){return Ke()},get slashActive(){return yt()??void 0},setSlashActive:Nt,onSlashSelect:De,get hashFlat(){return Xt()},get hashActive(){return sn()??void 0},setHashActive:_n,onHashSelect:Yt,get wikiFlat(){return Xn()},get wikiActive(){return On()??void 0},setWikiActive:je,onWikiSelect:En,get commandKeybind(){return g.keybind},t:se=>m.t(se)}),null),l(R,s(l$,{onSubmit:pn,get classList(){return{"group/prompt-input":!0,"focus-within:shadow-xs-border":!0,"border-icon-info-active border-dashed":B.draggingType!==null,[e.class??""]:!!e.class}},get children(){return[s(ik,{get type(){return B.draggingType},get label(){return m.t(B.draggingType==="@mention"?"prompt.dropzone.file.label":"prompt.dropzone.label")}}),s(X$,{get items(){return le()},active:se=>{const fe=d.active();return!!se.commentID&&se.commentID===fe?.id&&se.path===fe?.file},openComment:Y,remove:se=>{se.commentID&&d.remove(se.path,se.commentID),o.context.remove(se.key)},t:se=>m.t(se)}),s(nk,{get attachments(){return X()},onOpen:se=>c.show(()=>s(Lh,{get src(){return se.dataUrl},get alt(){return se.filename}})),onRemove:ut,get removeLabel(){return m.t("prompt.attachment.remove")}}),(()=>{var se=fk(),fe=se.firstChild,Pe=fe.firstChild,dt=fe.nextSibling,Qe=dt.nextSibling,pt=Qe.firstChild,Wt=pt.nextSibling,mn=Qe.nextSibling,$t=mn.firstChild;se.$$mousedown=_t=>{const qn=_t.target;qn instanceof HTMLElement&&(qn.closest('[data-action="prompt-attach"], [data-action="prompt-submit"], [data-action="prompt-permissions"]')||y?.focus())},Lt(_t=>_=_t,fe),Pe.$$keydown=Cn,Pe.addEventListener("blur",gt),Pe.addEventListener("compositionend",Ce),Pe.addEventListener("compositionstart",$n),Rt(Pe,"paste",at),Pe.$$input=Gt,Lt(_t=>{y=_t,e.ref?.(_t)},Pe),l(fe,s(E,{get when(){return!o.dirty()},get children(){var _t=uk();return l(_t,ie),G(()=>_t.classList.toggle("font-mono!",B.mode==="shell")),_t}}),null),pt.addEventListener("change",_t=>{const qn=_t.currentTarget.files;qn&&We(Array.from(qn)),_t.currentTarget.value=""});var Qt=b;return typeof Qt=="function"?Lt(Qt,pt):b=pt,l(Wt,s(Nn,{placement:"top",get inactive(){return Te(()=>!o.dirty())()&&!F()},get value(){return N()},get children(){return s(Ot,{"data-action":"prompt-submit",type:"submit",get disabled(){return B.mode!=="normal"||!o.dirty()&&!F()&&J()===0},get tabIndex(){return B.mode==="normal"?void 0:-1},get icon(){return F()?"stop":"arrow-up"},variant:"primary",class:"size-8",get style(){return Q()},get"aria-label"(){return Te(()=>!!F())()?m.t("prompt.action.stop"):m.t("prompt.action.send")}})}})),l($t,s(or,{placement:"top",get title(){return m.t("prompt.action.attachFile")},get keybind(){return g.keybind("file.attach")},get children(){return s(kt,{"data-action":"prompt-attach",type:"button",variant:"ghost",class:"size-8 p-0",get style(){return Q()},onClick:ye,get disabled(){return B.mode!=="normal"},get tabIndex(){return B.mode==="normal"?void 0:-1},get"aria-label"(){return m.t("prompt.action.attachFile")},get children(){return s(Ue,{name:"plus",class:"size-4.5"})}})}})),G(_t=>{var qn=ie(),yn=B.mode==="normal"?"sentences":"off",ce=B.mode==="normal"?"on":"off",Se=B.mode==="normal",Xe={"select-text":!0,"w-full pl-3 pr-2 pt-2 text-14-regular text-text-strong focus:outline-none whitespace-pre-wrap":!0,"[&_[data-type=file]]:text-syntax-property":!0,"[&_[data-type=agent]]:text-syntax-type":!0,"font-mono!":B.mode==="shell"},et=mm.join(","),qt=B.mode!=="normal",tn=z()>.5?"auto":"none";return qn!==_t.e&&ue(Pe,"aria-label",_t.e=qn),yn!==_t.t&&ue(Pe,"autocapitalize",_t.t=yn),ce!==_t.a&&ue(Pe,"autocorrect",_t.a=ce),Se!==_t.o&&ue(Pe,"spellcheck",_t.o=Se),_t.i=Tt(Pe,Xe,_t.i),et!==_t.n&&ue(pt,"accept",_t.n=et),qt!==_t.s&&ue($t,"aria-hidden",_t.s=qt),tn!==_t.h&&Je($t,"pointer-events",_t.h=tn),_t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),se})()]}}),null),l(R,s(E,{get when(){return B.mode==="normal"||B.mode==="shell"},get children(){return s(bs,{attach:"top",get children(){var se=gk(),fe=se.firstChild,Pe=fe.firstChild,dt=Pe.firstChild,Qe=Pe.nextSibling,pt=Qe.firstChild,Wt=pt.nextSibling,mn=Wt.nextSibling;return l(dt,()=>m.t("prompt.mode.shell")),l(pt,s(or,{placement:"top",gutter:4,get title(){return m.t("command.agent.cycle")},get keybind(){return g.keybind("agent.cycle")},get children(){return s(Qo,{size:"normal",get options(){return lt()},get current(){return r.agent.current()?.name??""},get onSelect(){return r.agent.set},class:"capitalize max-w-[160px] text-text-base",valueClass:"truncate text-13-regular text-text-base",get triggerStyle(){return H()},triggerProps:{"data-action":"prompt-agent"},variant:"ghost"})}})),l(Wt,s(E,{get when(){return u.free().length===0},get fallback(){return s(or,{placement:"top",gutter:4,get title(){return m.t("command.model.choose")},get keybind(){return g.keybind("model.choose")},get children(){return s(kt,{"data-action":"prompt-model",as:"div",variant:"ghost",size:"normal",class:"min-w-0 max-w-[320px] text-13-regular text-text-base group",get style(){return H()},onClick:()=>{Kn(()=>import("./dialog-select-model-unpaid-C6RP1dAD.js"),__vite__mapDeps([10,1,2,5,8,11,12,13])).then($t=>{c.show(()=>s($t.DialogSelectModelUnpaid,{get model(){return r.model}}))})},get children(){return[s(E,{get when(){return r.model.current()?.provider?.id},get children(){return s(gd,{get id(){return r.model.current()?.provider?.id??""},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}}),(()=>{var $t=gu();return l($t,()=>r.model.current()?.name??m.t("dialog.model.select.title")),$t})(),s(Ue,{name:"chevron-down",size:"small",class:"shrink-0"})]}})}})},get children(){return s(or,{placement:"top",gutter:4,get title(){return m.t("command.model.choose")},get keybind(){return g.keybind("model.choose")},get children(){return s(Eh,{get model(){return r.model},triggerAs:kt,get triggerProps(){return{variant:"ghost",size:"normal",style:H(),class:"min-w-0 max-w-[320px] text-13-regular text-text-base group","data-action":"prompt-model"}},get children(){return[s(E,{get when(){return r.model.current()?.provider?.id},get children(){return s(gd,{get id(){return r.model.current()?.provider?.id??""},class:"size-4 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity duration-150",style:{"will-change":"opacity",transform:"translateZ(0)"}})}}),(()=>{var $t=gu();return l($t,()=>r.model.current()?.name??m.t("dialog.model.select.title")),$t})(),s(Ue,{name:"chevron-down",size:"small",class:"shrink-0"})]}})}})}})),l(mn,s(or,{placement:"top",gutter:4,get title(){return m.t("command.model.variant.cycle")},get keybind(){return g.keybind("model.variant.cycle")},get children(){return s(Qo,{size:"normal",get options(){return Mt()},get current(){return r.model.variant.current()??"default"},label:$t=>$t==="default"?m.t("common.default"):$t,onSelect:$t=>r.model.variant.set($t==="default"?void 0:$t),class:"capitalize max-w-[160px] text-text-base",valueClass:"truncate text-13-regular text-text-base",get triggerStyle(){return H()},triggerProps:{"data-action":"prompt-model-variant"},variant:"ghost"})}})),l(Qe,s(or,{placement:"top",gutter:8,get title(){return ft()},get keybind(){return g.keybind("permissions.autoaccept")},get children(){return s(kt,{"data-action":"prompt-permissions",variant:"ghost",onClick:Vt,get classList(){return{"h-7 w-7 p-0 shrink-0 flex items-center justify-center":!0,"text-text-base":!Be(),"hover:bg-surface-success-base":Be()}},get style(){return H()},get"aria-label"(){return ft()},get"aria-pressed"(){return Be()},get children(){return s(Ue,{name:"shield",size:"small",get classList(){return{"text-icon-success-base":Be()}}})}})}}),null),G($t=>Pn(Pe,{...j()},$t)),se}})}}),null),R})()};Kt(["mousedown","input","keydown"]);var mu=x("<div>"),vk=x("<div data-component=dock-prompt>");function Ph(e){const t=n=>`${e.kind}-${n}`;return(()=>{var n=vk(),r=e.ref;return typeof r=="function"?Lt(r,n):e.ref=n,l(n,s(a$,{get"data-slot"(){return t("body")},get children(){return[(()=>{var i=mu();return l(i,()=>e.header),G(()=>ue(i,"data-slot",t("header"))),i})(),(()=>{var i=mu();return l(i,()=>e.children),G(()=>ue(i,"data-slot",t("content"))),i})()]}}),null),l(n,s(bs,{get"data-slot"(){return t("footer")},get children(){return e.footer}}),null),G(()=>ue(n,"data-kind",e.kind)),n})()}var bk=x("<div data-slot=permission-row><span data-slot=permission-spacer aria-hidden=true></span><div data-slot=permission-hint>"),xk=x("<div data-slot=permission-row><span data-slot=permission-spacer aria-hidden=true></span><div data-slot=permission-patterns>"),yk=x("<div data-slot=permission-row data-variant=header><span data-slot=permission-icon></span><div data-slot=permission-header-title>"),wk=x("<div>"),$k=x("<div data-slot=permission-footer-actions>"),kk=x('<code class="text-12-regular text-text-base break-all">');function _k(e){const t=hn(),n=()=>{const r=`settings.permissions.tool.${e.request.permission}.description`,i=t.t(r);return i===r?"":i};return s(Ph,{kind:"permission",get header(){return(()=>{var r=yk(),i=r.firstChild,o=i.nextSibling;return l(i,s(Ue,{name:"warning",size:"normal"})),l(o,()=>t.t("notification.permission.title")),r})()},get footer(){return[wk(),(()=>{var r=$k();return l(r,s(kt,{variant:"ghost",size:"normal",onClick:()=>e.onDecide("reject"),get disabled(){return e.responding},get children(){return t.t("ui.permission.deny")}}),null),l(r,s(kt,{variant:"secondary",size:"normal",onClick:()=>e.onDecide("always"),get disabled(){return e.responding},get children(){return t.t("ui.permission.allowAlways")}}),null),l(r,s(kt,{variant:"primary",size:"normal",onClick:()=>e.onDecide("once"),get disabled(){return e.responding},get children(){return t.t("ui.permission.allowOnce")}}),null),r})()]},get children(){return[s(E,{get when(){return n()},get children(){var r=bk(),i=r.firstChild,o=i.nextSibling;return l(o,n),r}}),s(E,{get when(){return e.request.patterns.length>0},get children(){var r=xk(),i=r.firstChild,o=i.nextSibling;return l(o,s(Oe,{get each(){return e.request.patterns},children:a=>(()=>{var d=kk();return l(d,a),d})()})),r}})]}})}var Ck=x("<div data-slot=question-text>"),hu=x("<div data-slot=question-hint>"),Sk=x("<form data-slot=question-option data-custom=true><span data-slot=question-option-check aria-hidden=true><span data-slot=question-option-box></span></span><span data-slot=question-option-main><span data-slot=option-label></span><textarea data-slot=question-custom-input rows=1>"),Tk=x("<div data-slot=question-options>"),Ak=x("<div data-slot=question-header-title>"),Dk=x("<div data-slot=question-progress>"),Mk=x("<button type=button data-slot=question-progress-segment>"),Ek=x("<div data-slot=question-footer-actions>"),Ik=x("<span data-slot=option-description>"),Lk=x("<button data-slot=question-option><span data-slot=question-option-check aria-hidden=true><span data-slot=question-option-box></span></span><span data-slot=question-option-main><span data-slot=option-label>"),Ka=x("<span data-slot=question-option-radio-dot>"),Pk=x("<button data-slot=question-option data-custom=true><span data-slot=question-option-check aria-hidden=true><span data-slot=question-option-box></span></span><span data-slot=question-option-main><span data-slot=option-label></span><span data-slot=option-description>");const $o=new Map,Fk=e=>{const t=zn(),n=hn(),r=T(()=>e.request.questions),i=T(()=>r().length),o=$o.get(e.request.id),[a,d]=St({tab:o?.tab??0,answers:o?.answers??[],custom:o?.custom??[],customOn:o?.customOn??[],editing:!1});let c,u=!1;const g=T(()=>r()[a.tab]),f=T(()=>g()?.options??[]),m=T(()=>a.custom[a.tab]??""),p=T(()=>a.customOn[a.tab]===!0),w=T(()=>g()?.multiple===!0),h=T(()=>{const X=Math.min(a.tab+1,i());return n.t("session.question.progress",{current:X,total:i()})}),k=T(()=>a.tab>=i()-1),v=(X,B=p())=>{const O=m().trim(),z=X.trim();if(d("custom",a.tab,X),!!B){if(w()){d("answers",a.tab,(q=[])=>{const Q=O?q.filter(j=>j.trim()!==O):q;return!z||Q.some(j=>j.trim()===z)?Q:[...Q,z]});return}d("answers",a.tab,z?[z]:[])}},C=()=>{if(!c)return;const X=document.querySelector(".scroll-view__viewport"),B=X instanceof HTMLElement?X.firstElementChild:void 0,O=B instanceof HTMLElement&&B.classList.contains("sticky")?B.getBoundingClientRect().bottom:0;if(!O){c.style.removeProperty("--question-prompt-max-height");return}const z=c.closest('[data-component="session-prompt-dock"]');if(!(z instanceof HTMLElement))return;const q=z.getBoundingClientRect().bottom,Q=Math.max(0,q-c.getBoundingClientRect().bottom),H=Math.max(240,Math.floor(q-O-8-Q));c.style.setProperty("--question-prompt-max-height",`${H}px`)};Mn(()=>{let X;const B=()=>{X!==void 0&&cancelAnimationFrame(X),X=requestAnimationFrame(()=>{X=void 0,C()})};B(),window.addEventListener("resize",B);const O=c?.closest('[data-component="session-prompt-dock"]'),z=document.querySelector(".scroll-view__viewport"),q=new ResizeObserver(B);O instanceof HTMLElement&&q.observe(O),z instanceof HTMLElement&&q.observe(z),vt(()=>{window.removeEventListener("resize",B),q.disconnect(),X!==void 0&&cancelAnimationFrame(X)})}),vt(()=>{u||$o.set(e.request.id,{tab:a.tab,answers:a.answers.map(X=>X?[...X]:[]),custom:a.custom.map(X=>X??""),customOn:a.customOn.map(X=>X??!1)})});const y=X=>{const B=X instanceof Error?X.message:String(X);nt({title:n.t("common.requestFailed"),description:B})},b=Yr(()=>({mutationFn:X=>t.client.question.reply({requestID:e.request.id,answers:X}),onMutate:()=>{e.onSubmit()},onSuccess:()=>{u=!0,$o.delete(e.request.id)},onError:y})),_=Yr(()=>({mutationFn:()=>t.client.question.reject({requestID:e.request.id}),onMutate:()=>{e.onSubmit()},onSuccess:()=>{u=!0,$o.delete(e.request.id)},onError:y})),$=T(()=>b.isPending||_.isPending),D=async X=>{$()||await b.mutateAsync(X)},L=async()=>{$()||await _.mutateAsync()},V=()=>void D(r().map((X,B)=>a.answers[B]??[])),K=(X,B=!1)=>{d("answers",a.tab,[X]),B&&d("custom",a.tab,X),B||d("customOn",a.tab,!1),d("editing",!1)},I=X=>{d("answers",a.tab,(B=[])=>B.includes(X)?B.filter(O=>O!==X):[...B,X])},U=()=>{if($())return;if(!w()){d("customOn",a.tab,!0),d("editing",!0),v(m(),!0);return}const X=!p();if(d("customOn",a.tab,X),X){d("editing",!0),v(m(),!0);return}const B=m().trim();B&&d("answers",a.tab,(O=[])=>O.filter(z=>z.trim()!==B)),d("editing",!1)},Y=()=>{$()||(p()||d("customOn",a.tab,!0),d("editing",!0),v(m(),!0))},S=X=>{if($())return;if(X===f().length){Y();return}const B=f()[X];if(B){if(w()){I(B.label);return}K(B.label)}},M=()=>{d("editing",!1),v(m())},A=()=>{if(!$()){if(a.editing&&M(),a.tab>=i()-1){V();return}d("tab",a.tab+1),d("editing",!1)}},F=()=>{$()||a.tab<=0||(d("tab",a.tab-1),d("editing",!1))},N=X=>{$()||(d("tab",X),d("editing",!1))};return s(Ph,{kind:"question",ref:X=>c=X,get header(){return[(()=>{var X=Ak();return l(X,h),X})(),(()=>{var X=Dk();return l(X,s(Oe,{get each(){return r()},children:(B,O)=>(()=>{var z=Mk();return z.$$click=()=>N(O()),G(q=>{var Q=O()===a.tab,j=(a.answers[O()]?.length??0)>0||a.customOn[O()]===!0&&(a.custom[O()]??"").trim().length>0,H=$(),J=`${n.t("ui.tool.questions")} ${O()+1}`;return Q!==q.e&&ue(z,"data-active",q.e=Q),j!==q.t&&ue(z,"data-answered",q.t=j),H!==q.a&&(z.disabled=q.a=H),J!==q.o&&ue(z,"aria-label",q.o=J),q},{e:void 0,t:void 0,a:void 0,o:void 0}),z})()})),X})()]},get footer(){return[s(kt,{variant:"ghost",size:"large",get disabled(){return $()},onClick:L,get children(){return n.t("ui.common.dismiss")}}),(()=>{var X=Ek();return l(X,s(E,{get when(){return a.tab>0},get children(){return s(kt,{variant:"secondary",size:"large",get disabled(){return $()},onClick:F,get children(){return n.t("ui.common.back")}})}}),null),l(X,s(kt,{get variant(){return k()?"primary":"secondary"},size:"large",get disabled(){return $()},onClick:A,get children(){return Te(()=>!!k())()?n.t("ui.common.submit"):n.t("ui.common.next")}}),null),X})()]},get children(){return[(()=>{var X=Ck();return l(X,()=>g()?.question),X})(),s(E,{get when(){return w()},get fallback(){return(()=>{var X=hu();return l(X,()=>n.t("ui.question.singleHint")),X})()},get children(){var X=hu();return l(X,()=>n.t("ui.question.multiHint")),X}}),(()=>{var X=Tk();return l(X,s(Oe,{get each(){return f()},children:(B,O)=>{const z=()=>a.answers[a.tab]?.includes(B.label)??!1;return(()=>{var q=Lk(),Q=q.firstChild,j=Q.firstChild,H=Q.nextSibling,J=H.firstChild;return q.$$click=()=>S(O()),l(j,s(E,{get when(){return w()},get fallback(){return Ka()},get children(){return s(Ue,{name:"check-small",size:"small"})}})),l(J,()=>B.label),l(H,s(E,{get when(){return B.description},get children(){var le=Ik();return l(le,()=>B.description),le}}),null),G(le=>{var de=z(),Re=w()?"checkbox":"radio",Ve=z(),Z=$(),ne=w()?"checkbox":"radio",re=z();return de!==le.e&&ue(q,"data-picked",le.e=de),Re!==le.t&&ue(q,"role",le.t=Re),Ve!==le.a&&ue(q,"aria-checked",le.a=Ve),Z!==le.o&&(q.disabled=le.o=Z),ne!==le.i&&ue(j,"data-type",le.i=ne),re!==le.n&&ue(j,"data-picked",le.n=re),le},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),q})()}}),null),l(X,s(E,{get when(){return a.editing},get fallback(){return(()=>{var B=Pk(),O=B.firstChild,z=O.firstChild,q=O.nextSibling,Q=q.firstChild,j=Q.nextSibling;return B.$$click=Y,O.$$click=H=>{H.preventDefault(),H.stopPropagation(),U()},l(z,s(E,{get when(){return w()},get fallback(){return Ka()},get children(){return s(Ue,{name:"check-small",size:"small"})}})),l(Q,()=>n.t("ui.messagePart.option.typeOwnAnswer")),l(j,()=>m()||n.t("ui.question.custom.placeholder")),G(H=>{var J=p(),le=w()?"checkbox":"radio",de=p(),Re=$(),Ve=w()?"checkbox":"radio",Z=p();return J!==H.e&&ue(B,"data-picked",H.e=J),le!==H.t&&ue(B,"role",H.t=le),de!==H.a&&ue(B,"aria-checked",H.a=de),Re!==H.o&&(B.disabled=H.o=Re),Ve!==H.i&&ue(z,"data-type",H.i=Ve),Z!==H.n&&ue(z,"data-picked",H.n=Z),H},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),B})()},get children(){var B=Sk(),O=B.firstChild,z=O.firstChild,q=O.nextSibling,Q=q.firstChild,j=Q.nextSibling;return B.addEventListener("submit",H=>{H.preventDefault(),M()}),B.$$mousedown=H=>{if($()){H.preventDefault();return}if(H.target instanceof HTMLTextAreaElement)return;const J=H.currentTarget.querySelector('[data-slot="question-custom-input"]');J instanceof HTMLTextAreaElement&&J.focus()},O.$$click=H=>{H.preventDefault(),H.stopPropagation(),U()},l(z,s(E,{get when(){return w()},get fallback(){return Ka()},get children(){return s(Ue,{name:"check-small",size:"small"})}})),l(Q,()=>n.t("ui.messagePart.option.typeOwnAnswer")),j.$$input=H=>{v(H.currentTarget.value),H.currentTarget.style.height="0px",H.currentTarget.style.height=`${H.currentTarget.scrollHeight}px`},j.$$keydown=H=>{if(H.key==="Escape"){H.preventDefault(),d("editing",!1);return}H.key!=="Enter"||H.shiftKey||(H.preventDefault(),M())},Lt(H=>setTimeout(()=>{H.focus(),H.style.height="0px",H.style.height=`${H.scrollHeight}px`},0),j),G(H=>{var J=p(),le=w()?"checkbox":"radio",de=p(),Re=w()?"checkbox":"radio",Ve=p(),Z=n.t("ui.question.custom.placeholder"),ne=$();return J!==H.e&&ue(B,"data-picked",H.e=J),le!==H.t&&ue(B,"role",H.t=le),de!==H.a&&ue(B,"aria-checked",H.a=de),Re!==H.o&&ue(z,"data-type",H.o=Re),Ve!==H.i&&ue(z,"data-picked",H.i=Ve),Z!==H.n&&ue(j,"placeholder",H.n=Z),ne!==H.s&&(j.disabled=H.s=ne),H},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),G(()=>j.value=m()),B}}),null),X})()]}})};Kt(["mousedown","click","keydown","input"]);var Rk=x('<span class="min-w-0 flex-1 truncate text-13-regular text-text-base cursor-default">'),zk=x('<div class="pl-3 pr-2 py-2 flex items-center gap-2"role=button tabindex=0><span class="shrink-0 text-13-medium text-text-strong cursor-default"></span><div class="ml-auto shrink-0">'),Ok=x("<div class=h-5 aria-hidden=true>"),Nk=x('<div class="px-3 pb-7 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar">'),Bk=x('<div class="flex items-center gap-2 min-w-0 py-1"><span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">');function qk(e){const t=hn(),[n,r]=St({collapsed:!1}),i=()=>r("collapsed",c=>!c),o=T(()=>e.items.length),a=T(()=>t.t(o()===1?"session.followupDock.summary.one":"session.followupDock.summary.other",{count:o()})),d=T(()=>e.items[0]?.text??"");return s(bs,{"data-component":"session-followup-dock",style:{"margin-bottom":"-0.875rem","border-bottom-left-radius":0,"border-bottom-right-radius":0},get children(){return[(()=>{var c=zk(),u=c.firstChild,g=u.nextSibling;return c.$$keydown=f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),i())},c.$$click=i,l(u,a),l(c,s(E,{get when(){return Te(()=>!!n.collapsed)()&&d()},get children(){var f=Rk();return l(f,d),f}}),g),l(g,s(Ot,{get"data-collapsed"(){return n.collapsed?"true":"false"},icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${n.collapsed?180:0}deg)`}},onMouseDown:f=>{f.preventDefault(),f.stopPropagation()},onClick:f=>{f.stopPropagation(),i()},get"aria-label"(){return Te(()=>!!n.collapsed)()?t.t("session.followupDock.expand"):t.t("session.followupDock.collapse")}})),c})(),s(E,{get when(){return n.collapsed},get children(){return Ok()}}),s(E,{get when(){return!n.collapsed},get children(){var c=Nk();return l(c,s(Oe,{get each(){return e.items},children:u=>(()=>{var g=Bk(),f=g.firstChild;return l(f,()=>u.text),l(g,s(kt,{size:"small",variant:"secondary",class:"shrink-0",get disabled(){return!!e.sending},onClick:()=>e.onSend(u.id),get children(){return t.t("session.followupDock.sendNow")}}),null),l(g,s(kt,{size:"small",variant:"ghost",class:"shrink-0",get disabled(){return!!e.sending},onClick:()=>e.onEdit(u.id),get children(){return t.t("session.followupDock.edit")}}),null),g})()})),c}})]}})}Kt(["click","keydown"]);var jk=x('<span class="min-w-0 flex-1 truncate text-14-regular text-text-base cursor-default">'),Vk=x('<div class="pl-3 pr-2 py-2 flex items-center gap-2"role=button tabindex=0><span class="shrink-0 text-14-regular text-text-strong cursor-default"></span><div class="ml-auto shrink-0">'),Hk=x("<div class=h-5 aria-hidden=true>"),Uk=x('<div class="px-3 pb-7 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar">'),Wk=x('<div class="flex items-center gap-2 min-w-0 py-1"><span class="min-w-0 flex-1 truncate text-13-regular text-text-strong">');function pu(e){const t=hn(),[n,r]=St({collapsed:!0});$e(()=>{e.items.length,e.items[0]?.id,r("collapsed",!0)});const i=()=>r("collapsed",c=>!c),o=T(()=>e.items.length),a=T(()=>t.t(o()===1?"session.revertDock.summary.one":"session.revertDock.summary.other",{count:o()})),d=T(()=>e.items[0]?.text??"");return s(bs,{"data-component":"session-revert-dock",get children(){return[(()=>{var c=Vk(),u=c.firstChild,g=u.nextSibling;return c.$$keydown=f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),i())},c.$$click=i,l(u,a),l(c,s(E,{get when(){return Te(()=>!!n.collapsed)()&&d()},get children(){var f=jk();return l(f,d),f}}),g),l(g,s(Ot,{get"data-collapsed"(){return n.collapsed?"true":"false"},icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${n.collapsed?180:0}deg)`}},onMouseDown:f=>{f.preventDefault(),f.stopPropagation()},onClick:f=>{f.stopPropagation(),i()},get"aria-label"(){return Te(()=>!!n.collapsed)()?t.t("session.revertDock.expand"):t.t("session.revertDock.collapse")}})),c})(),s(E,{get when(){return n.collapsed},get children(){return Hk()}}),s(E,{get when(){return!n.collapsed},get children(){var c=Uk();return l(c,s(Oe,{get each(){return e.items},children:u=>(()=>{var g=Wk(),f=g.firstChild;return l(f,()=>u.text),l(g,s(kt,{size:"small",variant:"secondary",class:"shrink-0",get disabled(){return e.disabled||!!e.restoring},onClick:()=>e.onRestore(u.id),get children(){return t.t("session.revertDock.restore")}}),null),g})()})),c}})]}})}Kt(["click","keydown"]);var Kk=x('<div class="pl-3 pr-2 py-2 flex items-center gap-2"role=button tabindex=0><span class="flex-1 min-w-0 text-14-regular text-text-strong cursor-default"></span><div class="flex items-center gap-1 shrink-0">'),Gk=x('<div class="px-3 pb-3 flex flex-col gap-1 max-h-40 overflow-y-auto no-scrollbar">'),Yk=x('<div class="flex items-center gap-2 py-0.5 min-w-0"><span class="text-10-medium font-mono w-3 shrink-0 text-center"></span><span class="flex-1 min-w-0 truncate text-13-regular text-text-base">');function Xk(e){const t=hn(),[n,r]=St({collapsed:!0}),i=T(()=>e.files.length),o=T(()=>t.t(i()===1?"session.changeDock.title.one":"session.changeDock.title.other",{count:i()})),a=()=>r("collapsed",c=>!c),d=()=>{e.onReview?e.onReview():a()};return s(bs,{"data-component":"session-change-dock",get children(){return[(()=>{var c=Kk(),u=c.firstChild,g=u.nextSibling;return c.$$keydown=f=>{f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),d())},c.$$click=d,l(c,s(Ot,{icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${n.collapsed?180:0}deg)`}},onMouseDown:f=>{f.preventDefault(),f.stopPropagation()},onClick:f=>{f.stopPropagation(),a()},get"aria-label"(){return Te(()=>!!n.collapsed)()?t.t("session.changeDock.expand"):t.t("session.changeDock.collapse")}}),u),l(u,o),g.$$click=f=>f.stopPropagation(),g.$$mousedown=f=>f.stopPropagation(),l(g,s(kt,{variant:"ghost",size:"normal",get onClick(){return e.onReject},get disabled(){return e.rejecting},get children(){return t.t("session.changeDock.reject")}}),null),l(g,s(kt,{variant:"primary",size:"normal",get onClick(){return e.onAccept},get disabled(){return e.rejecting},get children(){return t.t("session.changeDock.accept")}}),null),c})(),s(E,{get when(){return!n.collapsed},get children(){var c=Gk();return l(c,s(Oe,{get each(){return e.files},children:u=>(()=>{var g=Yk(),f=g.firstChild,m=f.nextSibling;return l(f,(()=>{var p=Te(()=>u.status==="added");return()=>p()?"A":u.status==="deleted"?"D":"M"})()),l(m,()=>u.file),l(g,s(Vr,{class:"shrink-0 text-12-regular",get changes(){return{additions:u.additions,deletions:u.deletions}}}),null),G(p=>{var w=u.status==="added",h=u.status==="deleted",k=u.status==="modified"||!u.status;return w!==p.e&&f.classList.toggle("text-[var(--icon-diff-add-base)]",p.e=w),h!==p.t&&f.classList.toggle("text-[var(--icon-diff-delete-base)]",p.t=h),k!==p.a&&f.classList.toggle("text-text-weak",p.a=k),p},{e:void 0,t:void 0,a:void 0}),g})()})),c}})]}})}Kt(["click","keydown","mousedown"]);var Zk=x('<span data-slot=animated-number-digit><span data-slot=animated-number-strip style="--animated-number-duration:var(--tool-motion-odometer-ms, 600ms)">'),Qk=x("<span data-slot=animated-number-cell>"),Jk=x("<span data-component=animated-number><span data-slot=animated-number-value>");const e3=Array.from({length:30},(e,t)=>t%10);function t3(e){return(e%10+10)%10}function n3(e,t,n){return e===t?0:n>0?(t-e+10)%10:-((e-t+10)%10)}function r3(e){const[t,n]=St({step:e.value+10,animating:!1}),r=()=>t.step,i=()=>t.animating;let o=e.value;return $e(Pt(()=>e.value,a=>{const d=n3(o,a,e.direction);if(o=a,!d){n("animating",!1),n("step",a+10);return}n("animating",!0),n("step",c=>c+d)},{defer:!0})),(()=>{var a=Zk(),d=a.firstChild;return d.addEventListener("transitionend",()=>{n("animating",!1),n("step",c=>t3(c)+10)}),l(d,s(Oe,{each:e3,children:c=>(()=>{var u=Qk();return l(u,c),u})()})),G(c=>{var u=i()?"true":"false",g=`${r()}`;return u!==c.e&&ue(d,"data-animating",c.e=u),g!==c.t&&Je(d,"--animated-number-offset",c.t=g),c},{e:void 0,t:void 0}),a})()}function Pl(e){const t=T(()=>Number.isFinite(e.value)?Math.max(0,Math.round(e.value)):0),[n,r]=St({value:t(),direction:1}),i=()=>n.value,o=()=>n.direction;$e(Pt(t,u=>{const g=i();u!==g&&(r("direction",u>g?1:-1),r("value",u))},{defer:!0}));const a=T(()=>i().toString()),d=T(()=>Array.from(a(),u=>{const g=u.charCodeAt(0)-48;return g<0||g>9?0:g}).reverse()),c=T(()=>`${d().length}ch`);return(()=>{var u=Jk(),g=u.firstChild;return l(g,s(bi,{get each(){return d()},children:f=>s(r3,{get value(){return f()},get direction(){return o()}})})),G(f=>{var m=e.class,p=a(),w=c();return m!==f.e&&Ht(u,f.e=m),p!==f.t&&ue(u,"aria-label",f.t=p),w!==f.a&&Je(g,"--animated-number-width",f.a=w),f},{e:void 0,t:void 0,a:void 0}),u})()}var i3={};jl(i3,{Checkbox:()=>li,Control:()=>Rh,Description:()=>zh,ErrorMessage:()=>Oh,Indicator:()=>Nh,Input:()=>Bh,Label:()=>qh,Root:()=>jh,useCheckboxContext:()=>Bi});var Fh=as();function Bi(){const e=os(Fh);if(e===void 0)throw new Error("[kobalte]: `useCheckboxContext` must be used within a `Checkbox` component");return e}function Rh(e){const t=ro(),n=Bi(),r=ur({id:n.generateId("control")},e),[i,o]=rn(r,["onClick","onKeyDown"]);return s(xr,bt({as:"div",onClick:c=>{vr(c,i.onClick),n.toggle(),n.inputRef()?.focus()},onKeyDown:c=>{vr(c,i.onKeyDown),c.key===ug.Space&&(n.toggle(),n.inputRef()?.focus())}},()=>t.dataset(),()=>n.dataset(),o))}function zh(e){const t=Bi();return s(ma,bt(()=>t.dataset(),e))}function Oh(e){const t=Bi();return s(ga,bt(()=>t.dataset(),e))}function Nh(e){const t=ro(),n=Bi(),[r,i]=ke(),o=ur({id:n.generateId("indicator")},e),[a,d]=rn(o,["ref","forceMount"]),{present:c}=dg({show:()=>a.forceMount||n.indeterminate()||n.checked(),element:()=>r()??null});return s(E,{get when(){return c()},get children(){return s(xr,bt({as:"div",ref(u){var g=Br(i,a.ref);typeof g=="function"&&g(u)}},()=>t.dataset(),()=>n.dataset(),d))}})}function Bh(e){let t;const n=ro(),r=Bi(),i=ur({id:r.generateId("input")},e),[o,a,d]=rn(i,["ref","style","onChange","onFocus","onBlur"],Ev),{fieldProps:c}=Iv(a),[u,g]=ke(!1),f=w=>{if(vr(w,o.onChange),w.stopPropagation(),!u()){const h=w.target;r.setIsChecked(h.checked),h.checked=r.checked()}g(!1)},m=w=>{vr(w,o.onFocus),r.setIsFocused(!0)},p=w=>{vr(w,o.onBlur),r.setIsFocused(!1)};return $e(Pt([()=>r.checked(),()=>r.value()],()=>{g(!0),t?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},{defer:!0})),$e(Pt([()=>t,()=>r.indeterminate(),()=>r.checked()],([w,h])=>{w&&(w.indeterminate=h)})),s(xr,bt({as:"input",ref(w){var h=Br(k=>{r.setInputRef(k),t=k},o.ref);typeof h=="function"&&h(w)},type:"checkbox",get id(){return c.id()},get name(){return n.name()},get value(){return r.value()},get checked(){return r.checked()},get required(){return n.isRequired()},get disabled(){return n.isDisabled()},get readonly(){return n.isReadOnly()},get style(){return la(cg,o.style)},get"aria-label"(){return c.ariaLabel()},get"aria-labelledby"(){return c.ariaLabelledBy()},get"aria-describedby"(){return c.ariaDescribedBy()},get"aria-invalid"(){return n.validationState()==="invalid"||void 0},get"aria-required"(){return n.isRequired()},get"aria-disabled"(){return n.isDisabled()},get"aria-readonly"(){return n.isReadOnly()},onChange:f,onFocus:m,onBlur:p},()=>n.dataset(),()=>r.dataset(),d))}function qh(e){const t=Bi();return s(lg,bt(()=>t.dataset(),e))}function jh(e){let t;const n=`checkbox-${to()}`,r=ur({value:"on",id:n},e),[i,o,a]=rn(r,["ref","children","value","checked","defaultChecked","indeterminate","onChange","onPointerDown"],sg),[d,c]=ke(),[u,g]=ke(!1),{formControlContext:f}=og(o),m=Mv({isSelected:()=>i.checked,defaultIsSelected:()=>i.defaultChecked,onSelectedChange:k=>i.onChange?.(k),isDisabled:()=>f.isDisabled(),isReadOnly:()=>f.isReadOnly()});Wl(()=>t,()=>m.setIsSelected(i.defaultChecked??!1));const p=k=>{vr(k,i.onPointerDown),u()&&k.preventDefault()},w=T(()=>({"data-checked":m.isSelected()?"":void 0,"data-indeterminate":i.indeterminate?"":void 0})),h={value:()=>i.value,dataset:w,checked:()=>m.isSelected(),indeterminate:()=>i.indeterminate??!1,inputRef:d,generateId:ca(()=>Wo(o.id)),toggle:()=>m.toggle(),setIsChecked:k=>m.setIsSelected(k),setIsFocused:g,setInputRef:c};return s(ag.Provider,{value:f,get children(){return s(Fh.Provider,{value:h,get children(){return s(xr,bt({as:"div",ref(k){var v=Br(C=>t=C,i.ref);typeof v=="function"&&v(k)},role:"group",get id(){return Wo(o.id)},onPointerDown:p},()=>f.dataset(),w,a,{get children(){return s(s3,{state:h,get children(){return i.children}})}}))}})}})}function s3(e){const t=Lv(()=>{const n=e.children;return Pv(n)?n(e.state):n});return Te(t)}var li=Object.assign(jh,{Control:Rh,Description:zh,ErrorMessage:Oh,Indicator:Nh,Input:Bh,Label:qh}),o3=x("<div data-slot=checkbox-checkbox-content>"),a3=x('<svg viewBox="0 0 12 12"fill=none width=10 height=10 xmlns=http://www.w3.org/2000/svg><path d="M3 7.17905L5.02703 8.85135L9 3.5"stroke=currentColor stroke-width=1.5 stroke-linecap=square>');function Vh(e){const[t,n]=rn(e,["children","class","label","hideLabel","description","icon"]);return s(li,bt(n,{"data-component":"checkbox",get children(){return[s(li.Input,{"data-slot":"checkbox-checkbox-input"}),s(li.Control,{"data-slot":"checkbox-checkbox-control",get children(){return s(li.Indicator,{"data-slot":"checkbox-checkbox-indicator",get children(){return t.icon||a3()}})}}),(()=>{var r=o3();return l(r,s(E,{get when(){return e.children},get children(){return s(li.Label,{"data-slot":"checkbox-checkbox-label",get classList(){return{"sr-only":t.hideLabel}},get children(){return e.children}})}}),null),l(r,s(E,{get when(){return t.description},get children(){return s(li.Description,{"data-slot":"checkbox-checkbox-description",get children(){return t.description}})}}),null),l(r,s(li.ErrorMessage,{"data-slot":"checkbox-checkbox-error"}),null),r})()]}}))}var l3=x("<span data-component=text-reveal><span data-slot=text-reveal-track><span data-slot=text-reveal-entering></span><span data-slot=text-reveal-leaving>");const c3=(e,t)=>typeof e=="number"?`${e}px`:typeof e=="string"?e:`${t}px`,d3=(e,t)=>typeof e=="number"?`${e}ms`:typeof e=="string"?e:`${t}ms`,u3=(e,t)=>`${e??t}%`;function Hh(e){const[t,n]=St({cur:e.text,old:void 0,width:"auto",ready:!1,swapping:!1}),r=()=>t.cur,i=()=>t.old,o=()=>t.width,a=()=>t.ready,d=()=>t.swapping;let c,u,g,f;const m=()=>c?.scrollWidth??0,p=()=>u?.scrollWidth??0,w=h=>{if(!(h<=0)){if(e.growOnly??!0){const k=Number.parseFloat(o());if(Number.isFinite(k)&&h<=k)return}n("width",`${h}px`)}};return $e(Pt(()=>e.text,(h,k)=>{if(h!==k){if(typeof h=="string"&&typeof k=="string"&&h.startsWith(k)){n("cur",h),w(m());return}if(n("swapping",!0),n("old",k),n("cur",h),typeof requestAnimationFrame!="function"){w(Math.max(m(),p())),g?.offsetHeight,n("swapping",!1);return}f!==void 0&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{w(Math.max(m(),p())),g?.offsetHeight,n("swapping",!1),f=void 0})}})),Mn(()=>{w(m());const h=typeof document<"u"?document.fonts:void 0;if(typeof requestAnimationFrame!="function"){n("ready",!0);return}if(!h){requestAnimationFrame(()=>n("ready",!0));return}h.ready.finally(()=>{w(m()),requestAnimationFrame(()=>n("ready",!0))})}),vt(()=>{f===void 0||typeof cancelAnimationFrame!="function"||cancelAnimationFrame(f)}),(()=>{var h=l3(),k=h.firstChild,v=k.firstChild,C=v.nextSibling,y=g;typeof y=="function"?Lt(y,h):g=h;var b=c;typeof b=="function"?Lt(b,v):c=v,l(v,()=>r()??" ");var _=u;return typeof _=="function"?Lt(_,C):u=C,l(C,()=>i()??" "),G($=>{var D=a()?"true":"false",L=d()?"true":"false",V=e.truncate?"true":"false",K=e.class,I=e.text??"",U=d3(e.duration,450),Y=u3(e.edge,17),S=c3(e.travel,0),M=e.spring??"cubic-bezier(0.34, 1.08, 0.64, 1)",A=e.springSoft??"cubic-bezier(0.34, 1, 0.64, 1)",F=e.truncate?"100%":o();return D!==$.e&&ue(h,"data-ready",$.e=D),L!==$.t&&ue(h,"data-swapping",$.t=L),V!==$.a&&ue(h,"data-truncate",$.a=V),K!==$.o&&Ht(h,$.o=K),I!==$.i&&ue(h,"aria-label",$.i=I),U!==$.n&&Je(h,"--text-reveal-duration",$.n=U),Y!==$.s&&Je(h,"--text-reveal-edge",$.s=Y),S!==$.h&&Je(h,"--text-reveal-travel",$.h=S),M!==$.r&&Je(h,"--text-reveal-spring",$.r=M),A!==$.d&&Je(h,"--text-reveal-spring-soft",$.d=A),F!==$.l&&Je(k,"width",$.l=F),$},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0}),h})()}var f3=x('<span data-component=text-strikethrough style=display:grid><span style="grid-area:1 / 1"></span><span aria-hidden=true style="grid-area:1 / 1;text-decoration:line-through;pointer-events:none">');function g3(e){const t=ya(()=>e.active?1:0,()=>({visualDuration:e.visualDuration??.35,bounce:0}));let n,r;const[i,o]=St({textWidth:0,containerWidth:0}),a=()=>i.textWidth,d=()=>i.containerWidth,c=()=>{n&&o("textWidth",n.scrollWidth),r&&o("containerWidth",r.offsetWidth)};Mn(c),$e(()=>{const m=r;if(!m)return;const p=new ResizeObserver(c);p.observe(m),vt(()=>p.disconnect())});const u=()=>{const m=a();return m>0?t()*m:0},g=()=>{const m=d(),p=a();return m<=0||p<=0?`inset(0 ${(1-t())*100}% 0 0)`:`inset(0 ${Math.max(0,m-u())}px 0 0)`},f=()=>{const m=u();return m<=.5?"none":`inset(0 0 0 ${m}px)`};return(()=>{var m=f3(),p=m.firstChild,w=p.nextSibling,h=r;typeof h=="function"?Lt(h,m):r=m;var k=n;return typeof k=="function"?Lt(k,p):n=p,l(p,()=>e.text),l(w,()=>e.text),G(v=>{var C=e.class,y={...e.style},b=f(),_=g();return C!==v.e&&Ht(m,v.e=C),v.t=Pn(m,y,v.t),b!==v.a&&Je(p,"clip-path",v.a=b),_!==v.o&&Je(w,"clip-path",v.o=_),v},{e:void 0,t:void 0,a:void 0,o:void 0}),m})()}const vu="opencode:e2e:composer",m3=e=>({live:e.live,todos:e.todos?.map(t=>({...t}))}),kc=()=>typeof window>"u"?!1:window.__opencode_e2e?.composer?.enabled===!0,Uh=()=>{if(!kc())return;const e=window.__opencode_e2e?.composer;if(e)return e.sessions??={},e.sessions},h3=e=>{if(!e)return;const t=Uh()?.[e]?.driver;if(t)return m3(t)},p3=e=>{const t=n=>{if(!e)return;const r=Uh();if(!r)return;const i=r[e]??{};r[e]={...i,probe:{...n,states:[...n.states]}}};return{set:t,drop(){t({mounted:!1,collapsed:!1,hidden:!0,count:0,states:[]})}}};var v3=x('<svg viewBox="0 0 12 12"width=12 height=12 fill=currentColor xmlns=http://www.w3.org/2000/svg class=block><circle cx=6 cy=6 r=3 style=animation:var(--animate-pulse-scale);transform-origin:center;transform-box:fill-box>'),b3=x('<div><div data-action=session-todo-toggle class="pl-3 pr-2 py-2 flex items-center gap-2 overflow-visible"role=button tabindex=0><span class="text-14-regular text-text-strong cursor-default inline-flex items-baseline shrink-0 overflow-visible"style=--tool-motion-odometer-ms:600ms;--tool-motion-mask:18%;--tool-motion-mask-height:0px;--tool-motion-spring-ms:560ms;white-space:pre></span><div data-slot=session-todo-preview class="ml-1 min-w-0 overflow-hidden"style="flex:1 1 auto;max-width:100%"></div><div class=ml-auto></div></div><div data-slot=session-todo-list>'),x3=x("<span>"),y3=x('<div class=relative><div class="px-3 pb-11 flex flex-col gap-1.5 max-h-42 overflow-y-auto no-scrollbar"style=overflow-anchor:none></div><div class="pointer-events-none absolute top-0 left-0 right-0 h-4 transition-opacity duration-150"style="background:linear-gradient(to bottom, var(--background-base), transparent)">');const bu="\0done\0",xu="\0total\0";function w3(e){if(e==="in_progress")return(()=>{var t=v3();return t.firstChild,t})()}function $3(e){const t=hn(),[n,r]=St({collapsed:!1,height:320}),i=()=>r("collapsed",$=>!$),o=T(()=>e.todos.length),a=T(()=>e.todos.filter($=>$.status==="completed").length),d=T(()=>t.t("session.todo.progress",{done:a(),total:o()})),c=T(()=>t.t("session.todo.progress",{done:bu,total:xu}).split(/(\u0000done\u0000|\u0000total\u0000)/)),u=T(()=>e.todos.find($=>$.status==="in_progress")??e.todos.find($=>$.status==="pending")??e.todos.filter($=>$.status==="completed").at(-1)??e.todos[0]),g=T(()=>u()?.content??""),f=ya(()=>n.collapsed?1:0,{visualDuration:.3,bounce:0}),m=T(()=>Math.max(0,Math.min(1,e.dockProgress))),p=T(()=>1-m()),w=T(()=>Math.max(0,Math.min(1,f()))),h=T(()=>Math.max(w(),p())),k=T(()=>h()>.98),v=T(()=>Math.max(0,Math.min(1,w()))),C=T(()=>Math.max(78,n.height)),y=kc(),b=p3(e.sessionID);let _;return $e(()=>{const $=_;if(!$)return;const D=()=>{r("height",$.getBoundingClientRect().height)};D();const L=new ResizeObserver(D);L.observe($),vt(()=>L.disconnect())}),$e(()=>{y&&b.set({mounted:!0,collapsed:n.collapsed,hidden:n.collapsed||k(),count:e.todos.length,states:e.todos.map($=>$.status)})}),vt(()=>{y&&b.drop()}),s(bs,{"data-component":"session-todo-dock",get style(){return{"overflow-x":"visible","overflow-y":"hidden","max-height":`${Math.max(78,C()-w()*(C()-78))}px`}},get children(){var $=b3(),D=$.firstChild,L=D.firstChild,V=L.nextSibling,K=V.nextSibling,I=D.nextSibling,U=_;return typeof U=="function"?Lt(U,$):_=$,D.$$keydown=Y=>{Y.key!=="Enter"&&Y.key!==" "||(Y.preventDefault(),i())},D.$$click=i,l(L,s(bi,{get each(){return c()},children:Y=>Y()===bu?s(Pl,{get value(){return a()}}):Y()===xu?s(Pl,{get value(){return o()}}):(()=>{var S=x3();return l(S,Y),S})()})),l(V,s(Hh,{class:"text-14-regular text-text-base cursor-default",get text(){return Te(()=>!!n.collapsed)()?g():void 0},duration:600,travel:25,edge:17,spring:"cubic-bezier(0.34, 1, 0.64, 1)",springSoft:"cubic-bezier(0.34, 1, 0.64, 1)",growOnly:!0,truncate:!0})),l(K,s(Ot,{"data-action":"session-todo-toggle-button",get"data-collapsed"(){return n.collapsed?"true":"false"},icon:"chevron-down",size:"normal",variant:"ghost",get style(){return{transform:`rotate(${v()*180}deg)`}},onMouseDown:Y=>{Y.preventDefault(),Y.stopPropagation()},onClick:Y=>{Y.stopPropagation(),i()},get"aria-label"(){return Te(()=>!!n.collapsed)()?e.expandLabel:e.collapseLabel}})),l(I,s(k3,{get todos(){return e.todos},get open(){return!n.collapsed}})),G(Y=>{var S=d(),M=`${Math.max(0,Math.min(1,1-p()))}`,A=n.collapsed||k(),F=h()>.1,N=k()?"hidden":"visible",X=`${Math.max(0,Math.min(1,1-h()))}`;return S!==Y.e&&ue(L,"aria-label",Y.e=S),M!==Y.t&&Je(L,"opacity",Y.t=M),A!==Y.a&&ue(I,"aria-hidden",Y.a=A),F!==Y.o&&I.classList.toggle("pointer-events-none",Y.o=F),N!==Y.i&&Je(I,"visibility",Y.i=N),X!==Y.n&&Je(I,"opacity",Y.n=X),Y},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),$}})}function k3(e){const[t,n]=St({stuck:!1,scrolling:!1});let r,i;const o=T(()=>e.todos.findIndex(d=>d.status==="in_progress")),a=()=>{if(!e.open||t.scrolling||!r||r.offsetParent===null)return;const d=r.querySelector("[data-in-progress]");if(!(d instanceof HTMLElement))return;const c=16,u=44,g=r.getBoundingClientRect(),f=d.getBoundingClientRect(),m=f.top-g.top+r.scrollTop,p=f.bottom-g.top+r.scrollTop,w=r.scrollTop+c,h=r.scrollTop+r.clientHeight-u;m<w?r.scrollTop=Math.max(0,m-c):p>h&&(r.scrollTop=p-(r.clientHeight-u)),n("stuck",r.scrollTop>0)};return $e(Pt([()=>e.open,o],()=>{!e.open||o()<0||requestAnimationFrame(a)})),vt(()=>{i&&window.clearTimeout(i)}),(()=>{var d=y3(),c=d.firstChild,u=c.nextSibling;c.addEventListener("scroll",f=>{n("stuck",f.currentTarget.scrollTop>0),n("scrolling",!0),i&&window.clearTimeout(i),i=window.setTimeout(()=>{n("scrolling",!1),!(o()<0)&&requestAnimationFrame(a)},250)});var g=r;return typeof g=="function"?Lt(g,c):r=c,l(c,s(bi,{get each(){return e.todos},children:f=>s(Vh,{readOnly:!0,get checked(){return f().status==="completed"},get indeterminate(){return f().status==="in_progress"},get"data-in-progress"(){return f().status==="in_progress"?"":void 0},get"data-state"(){return f().status},get icon(){return w3(f().status)},get style(){return{"--checkbox-align":"flex-start","--checkbox-offset":"1px",transition:"opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",opacity:f().status==="pending"?"0.94":"1"}},get children(){return s(g3,{get active(){return f().status==="completed"||f().status==="cancelled"},get text(){return f().content},class:"text-14-regular min-w-0 break-words",get style(){return{"line-height":"var(--line-height-normal)",transition:"color 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1)), opacity 220ms var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1))",color:f().status==="completed"||f().status==="cancelled"?"var(--text-weak)":"var(--text-strong)",opacity:f().status==="pending"?"0.92":"1"}}})}})})),G(f=>Je(u,"opacity",t.stuck?1:0)),d})()}Kt(["click","keydown"]);const ni={framework:"react",bundler:"vite",language:"typescript",styling:"tailwind",cms:"trellis"},ri=(e,t)=>`Create a ${e} using React, Vite, TypeScript, and Tailwind. Include Trellis CMS and the Trellis client SDK from the start, with schema-backed content collections, typed CMS helpers, and sample data wired into the UI. ${t}`,yu=[{id:"website",label:"Website",description:"Marketing site with CMS-backed pages and sections",stack:ni,prompt:ri("website","Start with editable pages, navigation, hero content, feature sections, testimonials, and posts.")},{id:"app",label:"App",description:"Interactive product app with structured data",stack:ni,prompt:ri("app","Start with dashboard routes, settings, task-like records, activity, and reusable UI components.")},{id:"game",label:"Game",description:"Playable browser game with CMS-tuned content",stack:ni,prompt:ri("game","Start with levels, characters, items, score state, and CMS-editable game configuration.")},{id:"slides",label:"Slide Deck",description:"Presentation deck with editable slides",stack:ni,prompt:ri("slide deck","Start with decks, slides, speaker notes, themes, and keyboard navigation.")},{id:"video",label:"Video",description:"Video/script planning workspace",stack:ni,prompt:ri("video workspace","Start with scenes, scripts, assets, captions, shot lists, and preview-friendly layouts.")},{id:"dashboard",label:"Dashboard",description:"Metrics dashboard with CMS-managed entities",stack:ni,prompt:ri("dashboard","Start with KPI cards, charts, entities, filters, and CMS-backed metric definitions.")},{id:"docs",label:"Docs",description:"Documentation site with structured articles",stack:ni,prompt:ri("documentation site","Start with docs pages, categories, search-friendly navigation, and markdown-style content.")},{id:"store",label:"Storefront",description:"Commerce storefront with editable catalog content",stack:ni,prompt:ri("storefront","Start with products, collections, pricing, cart UI, and CMS-backed merchandising content.")}];var _3=x("<div class=overflow-hidden><div>"),C3=x('<div class="pt-3 flex flex-wrap items-center justify-center gap-2">'),ko=x("<div>"),S3=x("<div data-component=session-prompt-dock><div>"),T3=x('<div class="w-full min-h-32 md:min-h-40 rounded-md border border-border-weak-base bg-background-base/50 px-4 py-3 text-text-weak whitespace-pre-wrap pointer-events-none">'),wu=x("<div class=pb-2>"),A3=x("<button type=button>");function D3(e){const t=Oi(),n=hn(),r=fg(),i=T(()=>gg(r.sessionKey())?.prompt),o=()=>t.current().map(y=>y.type==="file"?`[file:${y.path}]`:y.type==="agent"?`@${y.name}`:y.type==="image"?`[image:${y.filename}]`:y.content).join("").trim(),a=T(()=>{const y=o();return yu.find(b=>b.prompt===y)});$e(()=>{t.ready()&&mg(r.sessionKey(),{prompt:o()})});const[d,c]=St({ready:!1,height:320,body:void 0});let u,g;const f=()=>{u!==void 0&&(window.clearTimeout(u),u=void 0),g!==void 0&&(cancelAnimationFrame(g),g=void 0)};$e(()=>{r.sessionKey();const y=e.ready,b=140;f(),c("ready",!1),y&&(g=requestAnimationFrame(()=>{g=void 0,u=window.setTimeout(()=>{c("ready",!0),u=void 0},b)}))}),vt(f);const m=T(()=>d.ready&&e.state.dock()&&!e.state.closing()),p=ya(()=>m()?1:0,{visualDuration:.3,bounce:0}),w=T(()=>Math.max(0,Math.min(1,p()))),h=T(()=>d.ready&&e.state.dock()||w()>.001),k=T(()=>e.revert?.items.length?e.revert:void 0),v=T(()=>k()?18:36*w()),C=T(()=>Math.max(78,d.height));return $e(()=>{const y=d.body;if(!y)return;const b=()=>{c("height",y.getBoundingClientRect().height)};b();const _=new ResizeObserver(b);_.observe(y),vt(()=>_.disconnect())}),(()=>{var y=S3(),b=y.firstChild,_=e.setPromptDockRef;return typeof _=="function"?Lt(_,y):e.setPromptDockRef=y,l(b,s(E,{get when(){return e.state.questionRequest()},keyed:!0,children:$=>(()=>{var D=ko();return l(D,s(Fk,{request:$,get onSubmit(){return e.onResponseSubmit}})),D})()}),null),l(b,s(E,{get when(){return e.state.permissionRequest()},keyed:!0,children:$=>(()=>{var D=ko();return l(D,s(_k,{request:$,get responding(){return e.state.permissionResponding()},onDecide:L=>{e.onResponseSubmit(),e.state.decide(L)}})),D})()}),null),l(b,s(E,{get when(){return!e.state.blocked()},get children(){return s(E,{get when(){return t.ready()},get fallback(){return[s(E,{get when(){return k()},keyed:!0,children:$=>(()=>{var D=wu();return l(D,s(pu,{get items(){return $.items},get restoring(){return $.restoring},get disabled(){return $.disabled},get onRestore(){return $.onRestore}})),D})()}),(()=>{var $=T3();return l($,()=>i()||n.t("prompt.loading")),$})()]},get children(){return[s(E,{get when(){return h()},get children(){var $=_3(),D=$.firstChild;return Lt(L=>c("body",L),D),l(D,s($3,{get sessionID(){return r.params.id},get todos(){return e.state.todos()},get collapseLabel(){return n.t("session.todo.collapse")},get expandLabel(){return n.t("session.todo.expand")},get dockProgress(){return w()}})),G(L=>{var V=w()<.98,K=`${C()*w()}px`;return V!==L.e&&$.classList.toggle("pointer-events-none",L.e=V),K!==L.t&&Je($,"max-height",L.t=K),L},{e:void 0,t:void 0}),$}}),s(E,{get when(){return k()},keyed:!0,children:$=>(()=>{var D=ko();return l(D,s(pu,{get items(){return $.items},get restoring(){return $.restoring},get disabled(){return $.disabled},get onRestore(){return $.onRestore}})),G(L=>Je(D,"margin-top",`${-36*w()}px`)),D})()}),s(E,{get when(){return e.changes},keyed:!0,children:$=>(()=>{var D=wu();return l(D,s(Xk,{get files(){return $.files},get rejecting(){return $.rejecting},get onAccept(){return $.onAccept},get onReject(){return $.onReject},get onReview(){return $.onReview}})),D})()}),(()=>{var $=ko();return Tt($,{"relative z-10":!0}),l($,s(E,{get when(){return e.followup?.items.length},get children(){return s(qk,{get items(){return e.followup.items},get sending(){return e.followup.sending},get onSend(){return e.followup.onSend},get onEdit(){return e.followup.onEdit}})}}),null),l($,s(pk,{ref(D){var L=e.inputRef;typeof L=="function"?L(D):e.inputRef=D},get newSessionWorktree(){return e.newSessionWorktree},get onNewSessionWorktreeReset(){return e.onNewSessionWorktreeReset},get edit(){return e.followup?.edit},get onEditLoaded(){return e.followup?.onEditLoaded},get shouldQueue(){return e.followup?.queue},get onQueue(){return e.followup?.onQueue},get onAbort(){return e.followup?.onAbort},get onSubmit(){return e.onSubmit}}),null),l($,s(E,{get when(){return e.fresh},get children(){var D=C3();return l(D,s(Oe,{each:yu,children:L=>(()=>{var V=A3();return V.$$click=()=>{t.set([{type:"text",content:L.prompt,start:0,end:L.prompt.length}],L.prompt.length)},l(V,()=>L.label),G(K=>{var I=L.description,U={"px-3 py-1.5 rounded-full border text-12-medium transition-colors":!0,"bg-surface-raised-base border-border-strong-base text-text-strong":a()?.id===L.id,"border-border-weaker-base text-text-weak hover:text-text-strong hover:border-border-strong-base":a()?.id!==L.id};return I!==K.e&&ue(V,"title",K.e=I),K.t=Tt(V,U,K.t),K},{e:void 0,t:void 0}),V})()})),D}}),null),G(D=>Je($,"margin-top",`${-v()}px`)),$})()]}})}}),null),G($=>{var D={"shrink-0 w-full flex flex-col justify-center items-center bg-background-stronger pointer-events-none rounded-b-xl!":!0,"mb-auto":e.fresh},L={"w-full px-3 pb-3 pointer-events-auto":!0,"md:max-w-200 md:mx-auto 2xl:max-w-[1000px]":e.centered};return $.e=Tt(y,D,$.e),$.t=Tt(b,L,$.t),$},{e:void 0,t:void 0}),y})()}Kt(["click"]);const M3=e=>e.count===0?"hide":e.live?e.done?"close":"open":"clear",$u={type:"idle"};function E3(e){const t=ig(),n=zn(),r=br(),i=eo(),o=hn(),a=fa(),d=T(()=>Fv(r.data.session,r.data.question,t.id)),c=T(()=>Rv(r.data.session,r.data.permission,t.id,I=>!a.autoResponds(I,n.directory))),u=T(()=>t.id?!!c()||!!d():!1),[g,f]=St({on:!1,live:void 0,todos:void 0}),m=()=>{const I=t.id;if(!I){f({on:!1,live:void 0,todos:void 0});return}const U=h3(I);if(!U){f({on:!1,live:void 0,todos:void 0});return}f({on:!0,live:U.live,todos:U.todos?.map(Y=>({...Y}))})};Mn(()=>{if(!kc())return;m(),$e(Pt(()=>t.id,m,{defer:!0}));const I=U=>{U.detail?.sessionID===t.id&&m()};window.addEventListener(vu,I),vt(()=>window.removeEventListener(vu,I))});const p=T(()=>{if(g.on&&g.todos!==void 0)return g.todos;const I=t.id;return I?i.data.session_todo[I]??[]:[]}),w=T(()=>p().length>0&&p().every(I=>I.status==="completed"||I.status==="cancelled")),h=T(()=>{const I=t.id;return I?r.data.session_status[I]??$u:$u}),k=T(()=>h().type!=="idle"),v=T(()=>g.on&&g.live!==void 0?g.live:k()||u()),[C,y]=St({responding:void 0,dock:p().length>0&&v(),closing:!1,opening:!1}),b=T(()=>{const I=c();return I?C.responding===I.id:!1}),_=I=>{const U=c();U&&C.responding!==U.id&&(y("responding",U.id),n.client.permission.respond({sessionID:U.sessionID,permissionID:U.id,response:I}).catch(Y=>{const S=Y instanceof Error?Y.message:String(Y);nt({title:o.t("common.requestFailed"),description:S})}).finally(()=>{y("responding",Y=>Y===U.id?void 0:Y)}))};let $,D;const L=()=>400,V=()=>{$&&window.clearTimeout($),$=window.setTimeout(()=>{y({dock:!1,closing:!1}),$=void 0},L())},K=()=>{if(g.on&&g.todos!==void 0){f("todos",[]);return}const I=t.id;I&&(i.todo.set(I,[]),r.set("todo",I,[]))};return $e(Pt(()=>[p().length,w(),v()],([I,U,Y])=>{D&&cancelAnimationFrame(D),D=void 0;const S=M3({count:I,done:U,live:Y});if(S==="hide"){$&&window.clearTimeout($),$=void 0,y({dock:!1,closing:!1,opening:!1});return}if(S==="clear"){$&&window.clearTimeout($),$=void 0,K();return}if(S==="open"){$&&window.clearTimeout($),$=void 0;const M=!C.dock||C.closing;if(y({dock:!0,closing:!1}),M){y("opening",!0),D=requestAnimationFrame(()=>{y("opening",!1),D=void 0});return}y("opening",!1);return}y({dock:!0,opening:!1,closing:!0}),$||V()})),vt(()=>{$&&window.clearTimeout($)}),vt(()=>{D&&cancelAnimationFrame(D)}),{blocked:u,questionRequest:d,permissionRequest:c,permissionResponding:b,decide:_,todos:p,dock:()=>C.dock,closing:()=>C.closing,opening:()=>C.opening}}function I3({onlyFirst:e=!1}={}){const i="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(i,e?void 0:"g")}const L3=I3();function P3(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(L3,"")}var F3=x("<span data-slot=text-shimmer-char><span data-slot=text-shimmer-char-base aria-hidden=true></span><span data-slot=text-shimmer-char-shimmer aria-hidden=true>");const tr=e=>{const t=T(()=>e.text??""),n=T(()=>e.active??!0),r=T(()=>e.offset??0),[i,o]=ke(n()),a=220;let d;return $e(()=>{if(d&&(clearTimeout(d),d=void 0),n()){o(!0);return}d=setTimeout(()=>{d=void 0,o(!1)},a)}),vt(()=>{d&&clearTimeout(d)}),s(Or,{get component(){return e.as??"span"},"data-component":"text-shimmer",get"data-active"(){return n()?"true":"false"},get class(){return e.class},get"aria-label"(){return t()},get style(){return{"--text-shimmer-swap":`${a}ms`,"--text-shimmer-index":`${r()}`}},get children(){var c=F3(),u=c.firstChild,g=u.nextSibling;return l(u,t),l(g,t),G(()=>ue(g,"data-run",i()?"true":"false")),c}})};var R3=x("<div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><div data-slot=basic-tool-tool-info>"),z3=x("<div data-slot=collapsible-content data-animated>"),O3=x("<span data-slot=basic-tool-tool-subtitle>"),N3=x("<span data-slot=basic-tool-tool-action>"),B3=x("<div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),q3=x("<span data-slot=basic-tool-tool-arg>");const j3=e=>typeof e=="object"&&e!==null&&"title"in e&&(typeof Node>"u"||!(e instanceof Node)),ku={type:"spring",visualDuration:.35,bounce:0};function Yn(e){const[t,n]=St({open:e.defaultOpen??!1,ready:e.defaultOpen??!1}),r=()=>t.open,i=()=>t.ready,o=()=>e.status==="pending"||e.status==="running";let a;const d=()=>{a!==void 0&&(cancelAnimationFrame(a),a=void 0)};vt(d),$e(()=>{e.forceOpen&&n("open",!0)}),$e(Pt(r,m=>{if(e.defer){if(!m){d(),n("ready",!1);return}d(),a=requestAnimationFrame(()=>{a=void 0,r()&&n("ready",!0)})}},{defer:!0}));let c,u;const g=r();return $e(Pt(r,m=>{!e.animated||!c||(u?.stop(),m?(c.style.overflow="hidden",u=ia(c,{height:"auto"},ku),u.finished.then(()=>{!c||!r()||(c.style.overflow="visible",c.style.height="auto")})):(c.style.overflow="hidden",u=ia(c,{height:"0px"},ku)))},{defer:!0})),vt(()=>{u?.stop()}),s(Fn,{get open(){return r()},onOpenChange:m=>{o()||e.locked&&!m||n("open",m)},class:"tool-collapsible",get children(){return[s(Fn.Trigger,{get children(){var m=R3(),p=m.firstChild,w=p.firstChild;return l(w,s(Dn,{get children(){return[s(ot,{get when(){return Te(()=>!!j3(e.trigger))()&&e.trigger},children:h=>(()=>{var k=B3(),v=k.firstChild,C=v.firstChild;return l(C,s(tr,{get text(){return h().title},get active(){return o()}})),l(v,s(E,{get when(){return!o()},get children(){return[s(E,{get when(){return h().subtitle},get children(){var y=O3();return y.$$click=b=>{e.onSubtitleClick&&(b.stopPropagation(),e.onSubtitleClick())},l(y,()=>h().subtitle),G(b=>Tt(y,{[h().subtitleClass??""]:!!h().subtitleClass,clickable:!!e.onSubtitleClick},b)),y}}),s(E,{get when(){return h().args?.length},get children(){return s(Oe,{get each(){return h().args},children:y=>(()=>{var b=q3();return l(b,y),G(_=>Tt(b,{[h().argsClass??""]:!!h().argsClass},_)),b})()})}})]}}),null),l(k,s(E,{get when(){return Te(()=>!o())()&&h().action},get children(){var y=N3();return l(y,()=>h().action),y}}),null),G(y=>Tt(C,{[h().titleClass??""]:!!h().titleClass},y)),k})()}),s(ot,{when:!0,get children(){return e.trigger}})]}})),l(m,s(E,{get when(){return Te(()=>!!(e.children&&!e.hideDetails&&!e.locked))()&&!o()},get children(){return s(Fn.Arrow,{})}}),null),m}}),s(E,{get when(){return Te(()=>!!(e.animated&&e.children))()&&!e.hideDetails},get children(){var m=z3(),p=c;return typeof p=="function"?Lt(p,m):c=m,Je(m,"height",g?"auto":"0px"),Je(m,"overflow",g?"visible":"hidden"),l(m,()=>e.children),m}}),s(E,{get when(){return Te(()=>!!(!e.animated&&e.children))()&&!e.hideDetails},get children(){return s(Fn.Content,{get children(){return s(E,{get when(){return!e.defer||i()},get children(){return e.children}})}})}})]}})}function V3(e){return["description","query","url","filePath","path","pattern","name"].map(n=>e?.[n]).find(n=>typeof n=="string"&&n.length>0)}function H3(e){if(!e)return[];const t=new Set(["description","query","url","filePath","path","pattern","name"]);return Object.entries(e).filter(([n])=>!t.has(n)).flatMap(([n,r])=>typeof r=="string"?[`${n}=${r}`]:typeof r=="number"?[`${n}=${r}`]:typeof r=="boolean"?[`${n}=${r}`]:[]).slice(0,3)}function U3(e){const t=xn();return s(Yn,{icon:"mcp",get status(){return e.status},get trigger(){return{title:t.t("ui.basicTool.called",{tool:e.tool}),subtitle:V3(e.input),args:H3(e.input)}},get hideDetails(){return e.hideDetails}})}Kt(["click"]);var Wh=x("<div>");function W3(e,t){return t?e?typeof e=="string"?`${e};--card-accent:${t};`:{...e,"--card-accent":t}:{"--card-accent":t}:e}function wa(e){const[t,n]=rn(e,["variant","style","class","classList"]),r=()=>t.variant??"normal",i=()=>{const o=r();if(o==="error")return"var(--icon-critical-base)";if(o==="warning")return"var(--icon-warning-active)";if(o==="success")return"var(--icon-success-active)";if(o==="info")return"var(--icon-info-active)"};return(()=>{var o=Wh();return Nr(o,bt(n,{"data-component":"card",get"data-variant"(){return r()},get style(){return W3(t.style,i())},get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}),!1,!0),l(o,()=>e.children),o})()}function K3(e){const[t,n]=rn(e,["class","classList","children"]);return(()=>{var r=Wh();return Nr(r,bt(n,{"data-slot":"card-description",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}),!1,!0),l(r,()=>t.children),r})()}var G3=x('<a data-slot=basic-tool-tool-subtitle class="clickable subagent-link">'),Y3=x("<div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><span data-slot=basic-tool-tool-indicator data-component=tool-error-card-icon></span><div data-slot=basic-tool-tool-info><div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),X3=x("<div data-slot=tool-error-card-copy>"),Z3=x("<div data-slot=tool-error-card-content>"),Q3=x("<span data-slot=basic-tool-tool-subtitle>");function J3(e){const t=xn(),[n,r]=St({open:e.defaultOpen??!1,copied:!1}),i=()=>n.open,o=()=>n.copied,[a,d]=rn(e,["tool","error","defaultOpen","subtitle","href"]),c=T(()=>{const h={read:"ui.tool.read",list:"ui.tool.list",glob:"ui.tool.glob",grep:"ui.tool.grep",task:"ui.tool.task",webfetch:"ui.tool.webfetch",websearch:"ui.tool.websearch",codesearch:"ui.tool.codesearch",bash:"ui.tool.shell",apply_patch:"ui.tool.patch",question:"ui.tool.questions"}[a.tool];return h?h.includes(".")?t.t(h):h:a.tool}),u=T(()=>a.error.replace(/^Error:\s*/,"").trim()),g=T(()=>{const w=u(),h=`${a.tool} `;return w.startsWith(h)?w.slice(h.length):w}),f=T(()=>{if(a.subtitle)return a.subtitle;const w=g().split(": ");if(w.length<=1)return t.t("ui.toolErrorCard.failed");const h=(w[0]??"").trim();return h&&h[0]?h[0].toUpperCase()+h.slice(1):t.t("ui.toolErrorCard.failed")}),m=T(()=>{const w=g().split(": ");return w.length<=1?u():w.slice(1).join(": ").trim()||u()}),p=async()=>{const w=u();w&&(await navigator.clipboard.writeText(w),r("copied",!0),setTimeout(()=>r("copied",!1),2e3))};return s(wa,bt(d,{"data-kind":"tool-error-card",get"data-open"(){return i()?"true":"false"},variant:"error",get children(){return s(Fn,{class:"tool-collapsible",get"data-open"(){return i()?"true":"false"},get open(){return i()},onOpenChange:w=>r("open",w),get children(){return[s(Fn.Trigger,{get children(){var w=Y3(),h=w.firstChild,k=h.firstChild,v=k.nextSibling,C=v.firstChild,y=C.firstChild,b=y.firstChild;return l(k,s(Ue,{name:"circle-ban-sign",size:"small",style:{"stroke-width":1.5}})),l(b,c),l(y,s(E,{get when(){return Te(()=>!!a.href)()&&a.subtitle},get fallback(){return(()=>{var _=Q3();return l(_,f),_})()},get children(){var _=G3();return _.$$click=$=>$.stopPropagation(),l(_,f),G(()=>ue(_,"href",a.href)),_}}),null),l(w,s(Fn.Arrow,{}),null),w}}),s(Fn.Content,{get children(){var w=Z3();return l(w,s(E,{get when(){return i()},get children(){var h=X3();return l(h,s(Nn,{get value(){return Te(()=>!!o())()?t.t("ui.message.copied"):t.t("ui.toolErrorCard.copyError")},placement:"top",gutter:4,get children(){return s(Ot,{get icon(){return o()?"check":"copy"},size:"normal",variant:"ghost",onMouseDown:k=>k.preventDefault(),onClick:k=>{k.stopPropagation(),p()},get"aria-label"(){return Te(()=>!!o())()?t.t("ui.message.copied"):t.t("ui.toolErrorCard.copyError")}})}})),h}}),null),l(w,s(E,{get when(){return m()},children:h=>s(K3,{get children(){return h()}})}),null),w}})]}})}}))}Kt(["click"]);var e_=x("<span data-component=tool-count-label><span data-slot=tool-count-label-before></span><span data-slot=tool-count-label-word><span data-slot=tool-count-label-stem></span><span data-slot=tool-count-label-suffix><span data-slot=tool-count-label-suffix-inner>");function _u(e){const t=/{{\s*count\s*}}/.exec(e);return t?t.index===void 0?{before:"",after:e}:{before:e.slice(0,t.index),after:e.slice(t.index+t[0].length)}:{before:"",after:e}}function t_(e,t){const n=Array.from(e),r=Array.from(t);let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return{stem:n.slice(0,i).join(""),one:n.slice(i).join(""),other:r.slice(i).join("")}}function n_(e){const t=T(()=>_u(e.one)),n=T(()=>_u(e.other)),r=T(()=>Math.round(e.count)===1),i=T(()=>r()?t():n()),o=T(()=>t_(t().after,n().after)),a=T(()=>t().before===n().before&&(t().after.startsWith(n().after)||n().after.startsWith(t().after))),d=T(()=>a()?t().before:i().before),c=T(()=>a()?o().stem:i().after),u=T(()=>a()?r()?o().one:o().other:""),g=T(()=>a()&&u().length>0);return(()=>{var f=e_(),m=f.firstChild,p=m.nextSibling,w=p.firstChild,h=w.nextSibling,k=h.firstChild;return l(m,d),l(f,s(Pl,{get value(){return e.count}}),p),l(w,c),l(k,u),G(v=>{var C=e.class,y=g()?"true":"false";return C!==v.e&&Ht(f,v.e=C),y!==v.t&&ue(h,"data-active",v.t=y),v},{e:void 0,t:void 0}),f})()}var r_=x("<span data-component=tool-count-summary><span data-slot=tool-count-summary-empty><span data-slot=tool-count-summary-empty-inner>"),i_=x("<span data-slot=tool-count-summary-prefix>,"),s_=x("<span data-slot=tool-count-summary-item><span data-slot=tool-count-summary-item-inner>");function o_(e){const t=T(()=>e.items.filter(i=>i.count>0)),n=T(()=>e.fallback??""),r=T(()=>t().length===0&&n().length>0);return(()=>{var i=r_(),o=i.firstChild,a=o.firstChild;return l(a,n),l(i,s(bi,{get each(){return e.items},children:(d,c)=>{const u=T(()=>d().count>0),g=T(()=>{for(let f=c-1;f>=0;f--)if(e.items[f].count>0)return!0;return!1});return[(()=>{var f=i_();return G(()=>ue(f,"data-active",u()&&g()?"true":"false")),f})(),(()=>{var f=s_(),m=f.firstChild;return l(m,s(n_,{get one(){return d().one},get other(){return d().other},get count(){return Math.max(0,Math.round(d().count))}})),G(()=>ue(f,"data-active",u()?"true":"false")),f})()]}}),null),G(d=>{var c=e.class,u=r()?"true":"false";return c!==d.e&&Ht(i,d.e=c),u!==d.t&&ue(o,"data-active",d.t=u),d},{e:void 0,t:void 0}),i})()}var a_=x("<span data-slot=tool-status-suffix><span data-slot=tool-status-prefix></span><span data-slot=tool-status-tail><span data-slot=tool-status-active></span><span data-slot=tool-status-done>"),l_=x("<span data-component=tool-status-title>"),c_=x("<span data-slot=tool-status-swap><span data-slot=tool-status-active></span><span data-slot=tool-status-done>");function d_(e,t){const n=Array.from(e),r=Array.from(t);let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return{prefix:n.slice(0,i).join(""),active:n.slice(i).join(""),done:r.slice(i).join("")}}function u_(e){if(!e)return 0;const t=document.createRange();return t.selectNodeContents(e),Math.ceil(t.getBoundingClientRect().width)}function f_(e){const t=T(()=>d_(e.activeText,e.doneText)),n=T(()=>(e.split??!0)&&t().prefix.length>=2&&t().active.length>0&&t().done.length>0),r=T(()=>Array.from(t().prefix).length),i=T(()=>n()?t().active:e.activeText),o=T(()=>n()?t().done:e.doneText),[a,d]=St({width:"auto",ready:!1}),c=()=>a.width,u=()=>a.ready;let g,f,m,p;const w=()=>{const v=e.active?g:f,C=u_(v);C>0&&d("width",`${C}px`)},h=()=>{if(typeof requestAnimationFrame!="function"){w();return}m!==void 0&&cancelAnimationFrame(m),m=requestAnimationFrame(()=>{m=void 0,w()})},k=()=>{if(typeof requestAnimationFrame!="function"){d("ready",!0);return}p!==void 0&&cancelAnimationFrame(p),p=requestAnimationFrame(()=>{p=void 0,d("ready",!0)})};return $e(Pt([()=>e.active,i,o,n],()=>h())),Mn(()=>{w();const v=typeof document<"u"?document.fonts:void 0;if(!v){k();return}v.ready.finally(()=>{w(),k()})}),vt(()=>{m!==void 0&&cancelAnimationFrame(m),p!==void 0&&cancelAnimationFrame(p)}),(()=>{var v=l_();return l(v,s(E,{get when(){return n()},get fallback(){return(()=>{var C=c_(),y=C.firstChild,b=y.nextSibling,_=g;typeof _=="function"?Lt(_,y):g=y,l(y,s(tr,{get text(){return i()},get active(){return e.active},offset:0}));var $=f;return typeof $=="function"?Lt($,b):f=b,l(b,s(tr,{get text(){return o()},active:!1,offset:0})),G(D=>Je(C,"width",c())),C})()},get children(){var C=a_(),y=C.firstChild,b=y.nextSibling,_=b.firstChild,$=_.nextSibling;l(y,s(tr,{get text(){return t().prefix},get active(){return e.active},offset:0}));var D=g;typeof D=="function"?Lt(D,_):g=_,l(_,s(tr,{get text(){return i()},get active(){return e.active},get offset(){return r()}}));var L=f;return typeof L=="function"?Lt(L,$):f=$,l($,s(tr,{get text(){return o()},active:!1,get offset(){return r()}})),G(V=>Je(b,"width",c())),C}})),G(C=>{var y=e.active?"true":"false",b=u()?"true":"false",_=n()?"suffix":"swap",$=e.class,D=e.active?e.activeText:e.doneText;return y!==C.e&&ue(v,"data-active",C.e=y),b!==C.t&&ue(v,"data-ready",C.t=b),_!==C.a&&ue(v,"data-mode",C.a=_),$!==C.o&&Ht(v,C.o=$),D!==C.i&&ue(v,"aria-label",C.i=D),C},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),v})()}function Kh(e){return e.url.startsWith("data:")||e.url.startsWith("/file/media/")}function g_(e){return Kh(e)?!1:e.source?.text?.start!==void 0&&e.source?.text?.end!==void 0}function m_(e){return e.mime.startsWith("image/")?"image":"file"}var h_=x("<span data-component=shell-submessage><span data-slot=shell-submessage-width><span data-slot=basic-tool-tool-subtitle><span data-slot=shell-submessage-value>"),p_=x("<div data-component=diagnostics>"),v_=x("<div data-slot=diagnostic><span data-slot=diagnostic-label></span><span data-slot=diagnostic-location>[<!>:<!>]</span><span data-slot=diagnostic-message>"),b_=x("<div data-component=exa-tool-output><div data-slot=exa-tool-links>"),x_=x('<a data-slot=exa-tool-link target=_blank rel="noopener noreferrer">'),y_=x('<div data-component=context-tool-group-trigger><span data-slot=context-tool-group-title class="min-w-0 flex items-center gap-2 text-14-medium text-text-strong"><span data-slot=context-tool-group-label class=shrink-0></span><span data-slot=context-tool-group-summary class="min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-normal text-text-base">'),w_=x("<div data-component=context-tool-group-list>"),$_=x("<div data-component=context-synthesis>"),Gh=x("<span data-slot=basic-tool-tool-subtitle>"),k_=x("<div data-slot=context-tool-output-preview>"),__=x("<div data-slot=context-tool-output-info><span data-slot=context-tool-output-count>"),C_=x("<div data-slot=context-tool-group-item><div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><div data-slot=basic-tool-tool-info><div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),S_=x("<span data-slot=basic-tool-tool-arg>"),T_=x("<span data-slot=context-tool-output-line>"),A_=x("<div data-slot=context-synthesis-item><span data-slot=context-synthesis-text>"),D_=x("<div data-slot=user-message-attachments>"),M_=x("<div data-slot=user-message-body><div data-slot=user-message-text>"),E_=x('<span data-slot=user-message-meta class="text-12-regular text-text-weak cursor-default">'),I_=x('<span data-slot=user-message-meta-sep class="text-12-regular text-text-weak cursor-default"> · '),L_=x('<span data-slot=user-message-meta-tail class="text-12-regular text-text-weak cursor-default">'),P_=x("<span data-slot=user-message-meta-wrap>"),F_=x("<div data-slot=user-message-copy-wrapper>"),R_=x("<div data-component=user-message>"),z_=x("<img data-slot=user-message-attachment-image>"),O_=x("<div data-slot=user-message-attachment>"),N_=x("<div data-slot=user-message-attachment-file><span data-slot=user-message-attachment-name>"),B_=x("<span>"),Yh=x("<span data-slot=apply-patch-directory>"),Xh=x("<div data-slot=apply-patch-trigger-content><div data-slot=apply-patch-file-info><div data-slot=apply-patch-file-name-container><span data-slot=apply-patch-filename></span></div></div><div data-slot=apply-patch-trigger-actions>"),q_=x("<div data-slot=trellis-tool-pills>"),j_=x("<div data-component=tool-trigger><div data-slot=basic-tool-tool-trigger-content><span data-slot=basic-tool-tool-indicator data-component=trellis-tool-icon></span><div data-slot=basic-tool-tool-info><div data-slot=basic-tool-tool-info-structured data-scope=trellis-tool><div data-slot=basic-tool-tool-info-main data-scope=trellis-tool><span data-slot=basic-tool-tool-title>"),V_=x("<div data-slot=trellis-tool-content><div data-component=tool-output data-scrollable>"),H_=x("<span data-slot=trellis-tool-pill>"),U_=x("<div data-component=tool-part-wrapper>"),W_=x('<div style=width:100%;display:flex;justify-content:flex-end><span class="text-13-regular text-text-weak cursor-default">'),K_=x('<div data-component=compaction-part><div data-slot=compaction-part-divider><span data-slot=compaction-part-line></span><span data-slot=compaction-part-label class="text-12-regular text-text-weak"></span><span data-slot=compaction-part-line>'),G_=x('<span data-slot=text-part-meta class="text-12-regular text-text-weak cursor-default">'),Y_=x("<div data-slot=text-part-copy-wrapper>"),X_=x("<div data-component=text-part><div data-slot=text-part-body>"),Z_=x("<div data-component=reasoning-part>"),Q_=x("<div data-component=tool-loaded-file><span> "),_c=x("<div data-component=tool-output data-scrollable>"),J_=x('<a data-slot=basic-tool-tool-subtitle class="clickable subagent-link"target=_blank rel="noopener noreferrer">'),eC=x("<div data-component=tool-action>"),Zh=x("<div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title>"),tC=x('<a data-slot=basic-tool-tool-subtitle class="clickable subagent-link">'),Qh=x('<div data-slot=basic-tool-tool-info-structured><div data-slot=basic-tool-tool-info-main><span data-slot=basic-tool-tool-title class="capitalize agent-title">'),nC=x("<div data-component=bash-output><div data-slot=bash-copy></div><div data-slot=bash-scroll data-scrollable><pre data-slot=bash-pre><code>"),rC=x("<div data-component=edit-content>"),iC=x("<div data-component=edit-tool>"),Cc=x("<span data-slot=message-part-title-filename>"),Sc=x("<div data-slot=message-part-path><span data-slot=message-part-directory>"),Jh=x("<div data-component=edit-trigger><div data-slot=message-part-title-area><div data-slot=message-part-title><span data-slot=message-part-title-text></span></div></div><div data-slot=message-part-actions>"),sC=x("<div data-slot=memory-card-preview>"),oC=x("<div data-component=memory-card>"),aC=x("<div data-component=write-content>"),lC=x("<div data-component=write-tool>"),cC=x("<div data-component=write-trigger><div data-slot=message-part-title-area><div data-slot=message-part-title><span data-slot=message-part-title-text></span></div></div><div data-slot=message-part-actions>"),Cu=x("<div data-component=apply-patch-file-diff>"),Su=x("<div data-component=apply-patch-tool>"),Tu=x("<span data-slot=apply-patch-change data-type=added>"),Au=x("<span data-slot=apply-patch-change data-type=removed>"),Du=x("<span data-slot=apply-patch-change data-type=modified>"),dC=x("<div data-component=todos>"),uC=x("<span data-slot=message-part-todo-content>"),fC=x("<div data-component=question-answers>"),gC=x("<div data-slot=question-answer-item><div data-slot=question-text></div><div data-slot=answer-text>");function ep(){try{return hg()}catch{return{pathname:""}}}function mC(e){let t,n;return Mn(()=>{e.animate&&requestAnimationFrame(()=>{t&&ia(t,{width:"auto"},{type:"spring",visualDuration:.25,bounce:0}),n&&ia(n,{opacity:1,filter:"blur(0px)"},{duration:.32,ease:[.16,1,.3,1]})})}),(()=>{var r=h_(),i=r.firstChild,o=i.firstChild,a=o.firstChild,d=t;typeof d=="function"?Lt(d,i):t=i;var c=n;return typeof c=="function"?Lt(c,a):n=a,l(a,()=>e.text),G(u=>{var g=e.animate?"0px":void 0,f=e.animate?{opacity:0,filter:"blur(2px)"}:void 0;return g!==u.e&&Je(i,"width",u.e=g),u.t=Pn(a,f,u.t),u},{e:void 0,t:void 0}),r})()}function tp(e,t){return!e||!t?[]:(e[t]??[]).filter(r=>r.severity===1).slice(0,3)}function np(e){const t=xn();return s(E,{get when(){return e.diagnostics.length>0},get children(){var n=p_();return l(n,s(Oe,{get each(){return e.diagnostics},children:r=>(()=>{var i=v_(),o=i.firstChild,a=o.nextSibling,d=a.firstChild,c=d.nextSibling,u=c.nextSibling,g=u.nextSibling;g.nextSibling;var f=a.nextSibling;return l(o,()=>t.t("ui.messagePart.diagnostic.error")),l(a,()=>r.range.start.line+1,c),l(a,()=>r.range.start.character+1,g),l(f,()=>r.message),i})()})),n}})}const qi={},Mu=24,hC=/[\s.,!?;:)\]]/;function pC(e){return e<=12?2:e<=48?4:e<=96?8:Math.min(24,Math.ceil(e/8))}function vC(e,t){const n=Math.min(e.length,t+pC(e.length-t)),r=Math.min(e.length,n+8);for(let i=n;i<r;i++)if(hC.test(e[i]??""))return i+1;return n}function rp(e,t){const[n,r]=ke(e());let i=e(),o;const a=()=>{o&&(clearTimeout(o),o=void 0)},d=u=>{i=u,r(u)},c=()=>{o=void 0;const u=e();if(!t?.()){d(u);return}if(!u.startsWith(i)||u.length<=i.length){d(u);return}const g=vC(u,i.length);d(u.slice(0,g)),g<u.length&&(o=setTimeout(c,Mu))};return $e(()=>{const u=e();if(!t?.()){a(),d(u);return}if(!u.startsWith(i)||u.length<i.length){a(),d(u);return}u.length===i.length||o||(o=setTimeout(c,Mu))}),vt(()=>{a()}),n}function ip(e,t){if(!e)return"";if(!t||t==="/"||t==="\\")return e;if(e===t)return"";const n=t.includes("\\")?"\\":"/",r=t.endsWith(n)?t:t+n;return e.startsWith(r)?e.slice(t.length):e}function zr(e){const t=xi();return ip(ls(e),t.directory)}function sp(e,t){return t?e.t("ui.tool.agent",{type:t}):e.t("ui.tool.agent.default")}function op(e,t={}){const n=xn();switch(e){case"read":return{icon:"glasses",title:n.t("ui.tool.read"),subtitle:t.filePath?Sn(t.filePath):void 0};case"list":return{icon:"bullet-list",title:n.t("ui.tool.list"),subtitle:t.path?Sn(t.path):void 0};case"glob":return{icon:"magnifying-glass-menu",title:n.t("ui.tool.glob"),subtitle:t.pattern};case"grep":return{icon:"magnifying-glass-menu",title:n.t("ui.tool.grep"),subtitle:t.pattern};case"webfetch":return{icon:"window-cursor",title:n.t("ui.tool.webfetch"),subtitle:t.url};case"websearch":return{icon:"window-cursor",title:n.t("ui.tool.websearch"),subtitle:t.query};case"codesearch":return{icon:"code",title:n.t("ui.tool.codesearch"),subtitle:t.query};case"task":{const r=typeof t.subagent_type=="string"&&t.subagent_type?t.subagent_type[0].toUpperCase()+t.subagent_type.slice(1):void 0;return{icon:"task",title:sp(n,r),subtitle:t.description}}case"bash":return{icon:"console",title:n.t("ui.tool.shell"),subtitle:t.description};case"edit":return{icon:"code-lines",title:n.t("ui.messagePart.title.edit"),subtitle:t.filePath?Sn(t.filePath):void 0};case"write":return{icon:"code-lines",title:n.t("ui.messagePart.title.write"),subtitle:t.filePath?Sn(t.filePath):void 0};case"apply_patch":return{icon:"code-lines",title:n.t("ui.tool.patch"),subtitle:t.files?.length?`${t.files.length} ${n.t(t.files.length>1?"ui.common.file.other":"ui.common.file.one")}`:void 0};case"todowrite":return{icon:"checklist",title:n.t("ui.tool.todos")};case"question":return{icon:"bubble-5",title:n.t("ui.tool.questions")};case"skill":return{icon:"brain",title:t.name||n.t("ui.tool.skill")};default:return{icon:"mcp",title:e}}}function bC(e){if(!e)return[];const t=new Set;return[...e.matchAll(/https?:\/\/[^\s<>"'`)\]]+/g)].map(n=>n[0].replace(/[),.;:!?]+$/g,"")).filter(n=>t.has(n)?!1:(t.add(n),!0))}function ap(e,t,n){if(!e)return;const r=n?.(e);if(r)return r;const i=t.indexOf("/session");if(i!==-1)return`${t.slice(0,i)}/session/${e}`}const xC=new Set(["read","glob","grep","list"]),yC=new Set(["todowrite"]);function Eu(e,t){return Array.isArray(e)?e:t}function lp(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function Iu(e,t){return e.messageID===t.messageID&&e.partID===t.partID}function wC(e,t){return e===t?!0:e.key!==t.key||e.type!==t.type?!1:e.type==="part"?t.type!=="part"?!1:Iu(e.ref,t.ref):t.type!=="context"||e.refs.length!==t.refs.length?!1:e.refs.every((n,r)=>Iu(n,t.refs[r]))}function cp(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,r)=>wC(n,t[r]))}function dp(e){const t=[];let n=-1;const r=i=>{if(n<0)return;const o=e[n],a=e[i];if(!o||!a){n=-1;return}t.push({key:`context:${o.part.id}`,type:"context",refs:e.slice(n,i+1).map(d=>({messageID:d.messageID,partID:d.part.id}))}),n=-1};return e.forEach((i,o)=>{if(Tc(i.part)){n<0&&(n=o);return}r(o-1),t.push({key:`part:${i.messageID}:${i.part.id}`,type:"part",ref:{messageID:i.messageID,partID:i.part.id}})}),r(e.length-1),t}function Fl(e){return new Map(e.map(t=>[t.id,t]))}function up(e,t=!0){return e.type==="tool"?yC.has(e.tool)?!1:e.tool==="question"?e.state.status!=="pending"&&e.state.status!=="running":!0:e.type==="text"?!!e.text?.trim():e.type==="reasoning"?t&&!!e.text?.trim():!!qi[e.type]}function $C(e,t=!1,n=!1){if(e==="bash")return t;if(e==="edit"||e==="write"||e==="apply_patch")return n}function kC(e,t=!1,n=!1){if(e.type==="tool")return $C(e.tool,t,n)}function _C(e){const t=xi(),n=[],r=[],i=T(()=>Fl(e.messages)),o=T(()=>new Map(e.messages.map(c=>[c.id,Fl(Eu(t.store.part?.[c.id],n))]))),a=T(()=>dp(e.messages.flatMap(c=>Eu(t.store.part?.[c.id],n).filter(u=>up(u,e.showReasoningSummaries??!0)).map(u=>({messageID:c.id,part:u})))),[],{equals:cp}),d=T(()=>a().at(-1)?.key);return s(bi,{get each(){return a()},children:c=>{const u=T(()=>c().type);return s(Dn,{get children(){return[s(ot,{get when(){return u()==="context"},get children(){return(()=>{const g=T(()=>{const m=c();return m.type!=="context"?r:m.refs.map(p=>o().get(p.messageID)?.get(p.partID)).filter(p=>!!p&&Tc(p))},r,{equals:lp}),f=T(()=>e.working&&d()===c().key);return s(E,{get when(){return g().length>0},get children(){return s(gp,{get parts(){return g()},get busy(){return f()}})}})})()}}),s(ot,{get when(){return u()==="part"},get children(){return(()=>{const g=T(()=>{const m=c();if(m.type==="part")return i().get(m.ref.messageID)}),f=T(()=>{const m=c();if(m.type==="part")return o().get(m.ref.messageID)?.get(m.ref.partID)});return s(E,{get when(){return g()},get children(){return s(E,{get when(){return f()},get children(){return s(mp,{get part(){return f()},get message(){return g()},get showAssistantCopyPartID(){return e.showAssistantCopyPartID},get turnDurationMs(){return e.turnDurationMs},get defaultOpen(){return kC(f(),e.shellToolDefaultOpen,e.editToolDefaultOpen)},get onLinkClick(){return e.onLinkClick},get fileFetch(){return e.fileFetch}})}})}})})()}})]}})}})}function Tc(e){return e.type==="tool"&&xC.has(e.tool)}function CC(e){const t=op(e.tool,e.state.input??{});if(t.subtitle)return t.subtitle;if(e.state.status==="error")return e.state.error;if((e.state.status==="running"||e.state.status==="completed")&&e.state.title)return e.state.title;const n=e.state.input?.description;if(typeof n=="string")return n}function SC(e,t){const n=e.state.input??{},r=typeof n.path=="string"?n.path:"/",i=typeof n.filePath=="string"?n.filePath:void 0,o=typeof n.pattern=="string"?n.pattern:void 0,a=typeof n.include=="string"?n.include:void 0,d=typeof n.offset=="number"?n.offset:void 0,c=typeof n.limit=="number"?n.limit:void 0;switch(e.tool){case"read":{const u=[];return d!==void 0&&u.push("offset="+d),c!==void 0&&u.push("limit="+c),{title:t.t("ui.tool.read"),subtitle:i?Sn(i):"",args:u}}case"list":return{title:t.t("ui.tool.list"),subtitle:zr(r)};case"glob":return{title:t.t("ui.tool.glob"),subtitle:zr(r),args:o?["pattern="+o]:[]};case"grep":{const u=[];return o&&u.push("pattern="+o),a&&u.push("include="+a),{title:t.t("ui.tool.grep"),subtitle:zr(r),args:u}}default:{const u=op(e.tool,n);return{title:u.title,subtitle:u.subtitle||CC(e),args:[]}}}}function TC(e){const t=e.filter(i=>i.tool==="read").length,n=e.filter(i=>i.tool==="glob"||i.tool==="grep").length,r=e.filter(i=>i.tool==="list").length;return{read:t,search:n,list:r}}function AC(e){if(e.state.status!=="completed")return;const t=e.state.output;if(!t?.trim())return;const n=t.split(`
19
+ `).filter(r=>r.trim());switch(e.tool){case"read":return{count:`${n.length} lines`,items:[]};case"grep":return{count:`${n.length} matches`,items:n.slice(0,3)};case"glob":return{count:`${n.length} files`,items:n.slice(0,5)};case"list":return{count:`${n.length} entries`,items:n.slice(0,5)};default:return}}function DC(e){const t=[],n=e.filter(o=>o.tool==="read"&&o.state.status==="completed");if(n.length>0){const o=n.map(d=>Sn(d.state.input?.filePath??"")).filter(d=>d).slice(0,4),a=n.length>4?` +${n.length-4} more`:"";t.push({icon:"glasses",text:`Read ${o.join(", ")}${a}`})}const r=e.filter(o=>o.tool==="grep"&&o.state.status==="completed");for(const o of r){const d=o.state.output?.split(`
20
+ `).filter(u=>u.trim()).length??0,c=o.state.input?.pattern??"";c&&t.push({icon:"magnifying-glass-menu",text:`${d} matches for “${c}”`})}const i=e.filter(o=>o.tool==="glob"&&o.state.status==="completed");for(const o of i){const d=o.state.output?.split(`
21
+ `).filter(u=>u.trim()).length??0,c=o.state.input?.pattern??"";c&&t.push({icon:"magnifying-glass-menu",text:`${d} files matching “${c}”`})}return t}function fp(e){const t=T(()=>bC(e.output));return s(E,{get when(){return t().length>0},get children(){var n=b_(),r=n.firstChild;return l(r,s(Oe,{get each(){return t()},children:i=>(()=>{var o=x_();return o.$$click=a=>a.stopPropagation(),ue(o,"href",i),l(o,i),o})()})),n}})}function MC(e){return s(Dn,{get children(){return[s(ot,{get when(){return Te(()=>e.message.role==="user")()&&e.message},children:t=>s(IC,{get message(){return t()},get parts(){return e.parts},get actions(){return e.actions}})}),s(ot,{get when(){return Te(()=>e.message.role==="assistant")()&&e.message},children:t=>s(EC,{get message(){return t()},get parts(){return e.parts},get showAssistantCopyPartID(){return e.showAssistantCopyPartID},get showReasoningSummaries(){return e.showReasoningSummaries}})})]}})}function EC(e){const t=[],n=T(()=>Fl(e.parts)),r=T(()=>dp(e.parts.filter(i=>up(i,e.showReasoningSummaries??!0)).map(i=>({messageID:e.message.id,part:i}))),[],{equals:cp});return s(bi,{get each(){return r()},children:i=>{const o=T(()=>i().type);return s(Dn,{get children(){return[s(ot,{get when(){return o()==="context"},get children(){return(()=>{const a=T(()=>{const d=i();return d.type!=="context"?t:d.refs.map(c=>n().get(c.partID)).filter(c=>!!c&&Tc(c))},t,{equals:lp});return s(E,{get when(){return a().length>0},get children(){return s(gp,{get parts(){return a()}})}})})()}}),s(ot,{get when(){return o()==="part"},get children(){return(()=>{const a=T(()=>{const d=i();if(d.type==="part")return n().get(d.ref.partID)});return s(E,{get when(){return a()},get children(){return s(mp,{get part(){return a()},get message(){return e.message},get showAssistantCopyPartID(){return e.showAssistantCopyPartID}})}})})()}})]}})}})}function gp(e){const t=xn(),[n,r]=ke(!1),i=T(()=>!!e.busy||e.parts.some(c=>c.state.status==="pending"||c.state.status==="running")),o=T(()=>TC(e.parts)),a=T(()=>!e.busy&&e.parts.every(c=>c.state.status==="completed"||c.state.status==="error")),d=T(()=>a()?DC(e.parts):[]);return[s(Fn,{get open(){return n()},onOpenChange:r,variant:"ghost",class:"tool-collapsible",get children(){return[s(Fn.Trigger,{get children(){var c=y_(),u=c.firstChild,g=u.firstChild,f=g.nextSibling;return l(g,s(f_,{get active(){return i()},get activeText(){return t.t("ui.sessionTurn.status.gatheringContext")},get doneText(){return t.t("ui.sessionTurn.status.gatheredContext")},split:!1})),l(f,s(o_,{get items(){return[{key:"read",count:o().read,one:t.t("ui.messagePart.context.read.one"),other:t.t("ui.messagePart.context.read.other")},{key:"search",count:o().search,one:t.t("ui.messagePart.context.search.one"),other:t.t("ui.messagePart.context.search.other")},{key:"list",count:o().list,one:t.t("ui.messagePart.context.list.one"),other:t.t("ui.messagePart.context.list.other")}]},fallback:""})),l(c,s(Fn.Arrow,{}),null),c}}),s(Fn.Content,{get children(){var c=w_();return l(c,s(bi,{get each(){return e.parts},children:u=>{const g=T(()=>SC(u(),t)),f=T(()=>u().state.status==="pending"||u().state.status==="running"),m=T(()=>AC(u()));return(()=>{var p=C_(),w=p.firstChild,h=w.firstChild,k=h.firstChild,v=k.firstChild,C=v.firstChild,y=C.firstChild;return l(y,s(tr,{get text(){return g().title},get active(){return f()}})),l(C,s(E,{get when(){return Te(()=>!f())()&&g().subtitle},get children(){var b=Gh();return l(b,()=>g().subtitle),b}}),null),l(C,s(E,{get when(){return Te(()=>!f())()&&g().args?.length},get children(){return s(Oe,{get each(){return g().args},children:b=>(()=>{var _=S_();return l(_,b),_})()})}}),null),l(p,s(E,{get when(){return Te(()=>!f())()&&m()},get children(){var b=__(),_=b.firstChild;return l(_,()=>m().count),l(b,s(E,{get when(){return m().items.length>0},get children(){var $=k_();return l($,s(Oe,{get each(){return m().items},children:D=>(()=>{var L=T_();return l(L,D),L})()})),$}}),null),b}}),null),p})()}})),c}})]}}),s(E,{get when(){return d().length>0},get children(){var c=$_();return l(c,s(Oe,{get each(){return d()},children:u=>(()=>{var g=A_(),f=g.firstChild;return l(g,s(Ue,{get name(){return u.icon},size:"small"}),f),l(f,()=>u.text),g})()})),c}})]}function IC(e){const t=xi(),n=dr(),r=xn(),[i,o]=St({copied:!1,busy:!1}),a=()=>i.copied,d=()=>i.busy,c=T(()=>e.parts?.find($=>$.type==="text"&&!$.synthetic)),u=T(()=>c()?.text||""),g=T(()=>e.parts?.filter($=>$.type==="file")??[]),f=T(()=>g().filter(Kh)),m=T(()=>g().filter(g_)),p=T(()=>e.parts?.filter($=>$.type==="agent")??[]),w=T(()=>{const $=e.message.model?.providerID,D=e.message.model?.modelID;return!$||!D?"":t.store.provider?.all?.find(V=>V.id===$)?.models?.[D]?.name??D}),h=T(()=>new Intl.DateTimeFormat(r.locale(),{timeStyle:"short"})),k=T(()=>{const $=e.message.time?.created;return typeof $!="number"?"":h().format($)}),v=T(()=>{const $=e.message.agent;return[$?$[0]?.toUpperCase()+$.slice(1):"",w()].filter(L=>!!L).join(" · ")}),C=k,y=($,D)=>{n.show(()=>s(Lh,{src:$,alt:D}))},b=async()=>{const $=u();$&&(await navigator.clipboard.writeText($),o("copied",!0),setTimeout(()=>o("copied",!1),2e3))},_=()=>{const $=e.actions?.revert;!$||d()||(o("busy",!0),Promise.resolve().then(()=>$({sessionID:e.message.sessionID,messageID:e.message.id})).finally(()=>o("busy",!1)))};return(()=>{var $=R_();return l($,s(E,{get when(){return f().length>0},get children(){var D=D_();return l(D,s(Oe,{get each(){return f()},children:L=>{const V=m_(L),K=L.filename??r.t("ui.message.attachment.alt");return(()=>{var I=O_();return I.$$click=()=>{V==="image"&&y(L.url,K)},ue(I,"data-type",V),ue(I,"data-clickable",V==="image"?"true":void 0),ue(I,"title",V==="file"?K:void 0),l(I,s(E,{when:V==="image",get fallback(){return(()=>{var U=N_(),Y=U.firstChild;return l(U,s(cr,{node:{path:K,type:"file"}}),Y),l(Y,K),U})()},get children(){var U=z_();return ue(U,"alt",K),G(()=>ue(U,"src",t.mediaUrl&&L.url.startsWith("/")?new URL(L.url,t.mediaUrl).toString():L.url)),U}})),I})()}})),D}}),null),l($,s(E,{get when(){return u()},get children(){return[(()=>{var D=M_(),L=D.firstChild;return l(L,s(LC,{get text(){return u()},get references(){return m()},get agents(){return p()}})),D})(),(()=>{var D=F_();return l(D,s(E,{get when(){return v()||C()},get children(){var L=P_();return l(L,s(E,{get when(){return v()},get children(){var V=E_();return l(V,v),V}}),null),l(L,s(E,{get when(){return Te(()=>!!v())()&&C()},get children(){return I_()}}),null),l(L,s(E,{get when(){return C()},get children(){var V=L_();return l(V,C),V}}),null),L}}),null),l(D,s(E,{get when(){return e.actions?.revert},get children(){return s(Nn,{get value(){return r.t("ui.message.revertMessage")},placement:"top",gutter:4,get children(){return s(Ot,{icon:"reset",size:"normal",variant:"ghost",get disabled(){return!!d()},onMouseDown:L=>L.preventDefault(),onClick:L=>{L.stopPropagation(),_()},get"aria-label"(){return r.t("ui.message.revertMessage")}})}})}}),null),l(D,s(Nn,{get value(){return Te(()=>!!a())()?r.t("ui.message.copied"):r.t("ui.message.copyMessage")},placement:"top",gutter:4,get children(){return s(Ot,{get icon(){return a()?"check":"copy"},size:"normal",variant:"ghost",onMouseDown:L=>L.preventDefault(),onClick:L=>{L.stopPropagation(),b()},get"aria-label"(){return Te(()=>!!a())()?r.t("ui.message.copied"):r.t("ui.message.copyMessage")}})}}),null),D})()]}}),null),$})()}function LC(e){const t=T(()=>{const n=e.text,r=[...e.references.filter(a=>a.source?.text?.start!==void 0&&a.source?.text?.end!==void 0).map(a=>({start:a.source.text.start,end:a.source.text.end,type:"file"})),...e.agents.filter(a=>a.source?.start!==void 0&&a.source?.end!==void 0).map(a=>({start:a.source.start,end:a.source.end,type:"agent"}))].sort((a,d)=>a.start-d.start),i=[];let o=0;for(const a of r)a.start<o||(a.start>o&&i.push({text:n.slice(o,a.start)}),i.push({text:n.slice(a.start,a.end),type:a.type}),o=a.end);return o<n.length&&i.push({text:n.slice(o)}),i});return s(Oe,{get each(){return t()},children:n=>(()=>{var r=B_();return l(r,()=>n.text),G(()=>ue(r,"data-highlight",n.type)),r})()})}function mp(e){const t=T(()=>qi[e.part.type]);return s(E,{get when(){return t()},get children(){return s(Or,{get component(){return t()},get part(){return e.part},get message(){return e.message},get hideDetails(){return e.hideDetails},get defaultOpen(){return e.defaultOpen},get showAssistantCopyPartID(){return e.showAssistantCopyPartID},get turnDurationMs(){return e.turnDurationMs},get onLinkClick(){return e.onLinkClick},get fileFetch(){return e.fileFetch}})}})}const hp={};function PC(e){return hp[e.name]=e,e}function FC(e){return hp[e]?.render}const rr={register:PC,render:FC};function Ac(e){const t=T(()=>e.path||"tool-file");return s(Bn,{multiple:!0,"data-scope":"apply-patch",style:{"--sticky-accordion-offset":"40px"},get defaultValue(){return[t()]},get children(){return s(Bn.Item,{get value(){return t()},get children(){return[s(oo,{get children(){return s(Bn.Trigger,{get children(){var n=Xh(),r=n.firstChild,i=r.firstChild,o=i.firstChild,a=r.nextSibling;return l(r,s(cr,{get node(){return{path:e.path,type:"file"}}}),i),l(i,s(E,{get when(){return e.path.includes("/")},get children(){var d=Yh();return l(d,()=>`‪${zr(e.path)}‬`),d}}),o),l(o,()=>Sn(e.path)),l(a,()=>e.actions,null),l(a,s(Ue,{name:"chevron-grabber-vertical",size:"small"}),null),n}})}}),s(Bn.Content,{get children(){return e.children}})]}})}})}function ir(e,t=28){return e.length<=t?e:`${e.slice(0,t-1)}…`}function An(e){if(typeof e=="string")return e.trim();if(typeof e=="number"||typeof e=="boolean")return String(e);if(e===null)return"null"}function bn(e,t="meta"){return{label:e,tone:t}}function _o(e,t="attr"){if(!e)return[];if(Array.isArray(e))return e.flatMap(n=>{const r=An(n);return r?[bn(ir(r),t)]:[]});if(typeof e!="object"){const n=An(e);return n?[bn(ir(n),t)]:[]}return Object.entries(e).flatMap(([n,r])=>{const i=An(r);return i?[bn(`${n} ${ir(i)}`,t)]:[]})}function Ss(e){const t=[];return typeof e.id=="string"&&e.id&&t.push(bn(e.id,"result")),typeof e.count=="number"&&t.push(bn(`${e.count} results`,"result")),typeof e.nodes=="number"&&t.push(bn(`${e.nodes} nodes`,"result")),typeof e.edges=="number"&&t.push(bn(`${e.edges} edges`,"result")),typeof e.facts=="number"&&t.push(bn(`${e.facts} facts`,"result")),typeof e.links=="number"&&t.push(bn(`${e.links} links`,"result")),typeof e.asserted=="number"&&t.push(bn(`${e.asserted} asserted`,"result")),typeof e.retracted=="number"&&t.push(bn(`${e.retracted} retracted`,"result")),typeof e.unlinked=="number"&&t.push(bn(`${e.unlinked} removed`,"result")),typeof e.truncated=="boolean"&&e.truncated&&t.push(bn("truncated","meta")),t}function RC(e,t,n){if(e==="trellis_store_mutate"){const i=An(t.action)??"mutated",o=An(t.id),a=An(t.type),d=An(t.entity),c=An(t.attribute),u=An(t.value),g=An(t.source),f=An(t.relation),m=An(t.target);return{title:i==="define"?`Created ${o??"entity"}`:i==="update"?`Updated ${o??"entity"}`:i==="delete"?`Deleted ${o??"entity"}`:i==="assert"?`Asserted ${d??"entity"}${c?`.${c}`:""}`:i==="retract"?`Retracted ${d??"entity"}${c?`.${c}`:""}`:i==="link"?`Linked ${g??"entity"} to ${m??"entity"}`:i==="unlink"?`Unlinked ${g??"entity"} from ${m??"entity"}`:"Updated the Trellis store",list:[bn(i,"action"),...o?[bn(`id ${ir(o)}`)]:[],...a?[bn(`type ${ir(a)}`)]:[],...c?[bn(`attr ${ir(c)}`,"attr")]:[],...u?[bn(`value ${ir(u)}`,"attr")]:[],...f?[bn(`relation ${ir(f)}`,"attr")]:[],..._o(t.attrs,"attr"),...Ss(n)]}}if(e==="trellis_store_query"){const i=An(t.mode)??"query",o=An(t.id),a=An(t.type),d=An(t.attribute),c=An(t.value),u=An(t.depth),g=An(t.limit);return{title:i==="entities"?`Browsed ${a?`${a} `:""}entities`:i==="entity"?`Inspected ${o??"entity"}`:i==="facts"?"Queried facts":i==="links"?"Queried links":i==="graph"?`Mapped neighbors for ${o??"entity"}`:i==="types"?"Listed entity types":"Queried the Trellis store",list:[bn(i,"action"),...o?[bn(`id ${ir(o)}`)]:[],...a?[bn(`type ${ir(a)}`)]:[],...d?[bn(`attr ${ir(d)}`,"attr")]:[],...c?[bn(`value ${ir(c)}`,"attr")]:[],...u?[bn(`depth ${u}`,"meta")]:[],...g?[bn(`limit ${g}`,"meta")]:[],...Ss(n)]}}if(e==="trellis_store_schema"){const i=An(t.mode)??"schema",o=An(t.type);return{title:i==="stats"?"Inspected store stats":i==="catalog"?"Browsed the attribute catalog":i==="attributes"?`Viewed attributes for ${o??"type"}`:"Inspected the store schema",list:[bn(i,"action"),...o?[bn(`type ${ir(o)}`)]:[],...Ss(n)]}}if(e==="trellis_issue"){const i=An(t.title),o=An(t.priority),a=[...o?[bn(o,"action")]:[],..._o(t.labels,"meta"),...Array.isArray(t.criteria)&&t.criteria.length?[bn(`${t.criteria.length} criteria`,"result")]:[],...Ss(n)];return{title:i?`Created issue ${ir(i,56)}`:"Created a Trellis issue",list:a}}const r=Object.entries(t).flatMap(([i,o])=>{if(Array.isArray(o))return _o(o,"meta");if(o&&typeof o=="object")return _o(o,"attr");const a=An(o);return a?[bn(`${i} ${ir(a)}`)]:[]});return{title:`Ran ${e.replace(/^trellis_/,"").replaceAll("_"," ")}`,list:[...r,...Ss(n)]}}function zC(e){const[t,n]=ke(e.defaultOpen??!1),r=T(()=>e.status==="pending"||e.status==="running"),i=T(()=>e.output?.trim()??""),o=T(()=>!e.hideDetails&&!!i()),a=T(()=>RC(e.tool,e.input,e.metadata)),d=T(()=>{const c=a().list;return c.length<=8?c:[...c.slice(0,8),bn(`+${c.length-8}`,"meta")]});return $e(()=>{e.forceOpen&&o()&&n(!0)}),s(wa,{"data-kind":"trellis-tool-card",get"data-open"(){return t()?"true":"false"},style:{"--card-accent":"var(--icon-interactive-base)"},get children(){return s(Fn,{class:"tool-collapsible",get"data-open"(){return t()?"true":"false"},get open(){return t()},onOpenChange:c=>{o()&&(e.locked&&!c||n(c))},get children(){return[s(Fn.Trigger,{get children(){var c=j_(),u=c.firstChild,g=u.firstChild,f=g.nextSibling,m=f.firstChild,p=m.firstChild,w=p.firstChild;return l(g,s(Ue,{name:"providers",size:"small"})),l(w,s(tr,{get text(){return a().title},get active(){return r()}})),l(m,s(E,{get when(){return Te(()=>!r())()&&d().length},get children(){var h=q_();return l(h,s(Oe,{get each(){return d()},children:k=>(()=>{var v=H_();return l(v,()=>k.label),G(()=>ue(v,"data-tone",k.tone)),v})()})),h}}),null),l(c,s(E,{get when(){return o()},get children(){return s(Fn.Arrow,{})}}),null),c}}),s(E,{get when(){return o()},get children(){return s(Fn.Content,{get children(){var c=V_(),u=c.firstChild;return l(u,s(zi,{get text(){return i()}})),c}})}})]}})}})}qi.tool=function(t){const n=xi(),r=xn(),i=ep(),o=()=>t.part;if(o().tool==="todowrite")return null;const a=T(()=>{const p=o().state.input;return p&&typeof p=="object"?p:{}}),d=T(()=>{const p=o().state.metadata;return{...o().metadata??{},...p??{}}}),c=T(()=>{const p=d().sessionId;return typeof p=="string"&&p?p:void 0}),u=T(()=>o().tool==="question"&&(o().state.status==="pending"||o().state.status==="running")),g=T(()=>{if(o().tool==="task")return ap(c(),i.pathname,n.sessionHref)}),f=T(()=>{if(o().tool!=="task")return;const p=a().description;return typeof p=="string"&&p?p:c()}),m=T(()=>rr.render(o().tool)??(o().tool.startsWith("trellis_")?zC:U3));return s(E,{get when(){return!u()},get children(){var p=U_();return l(p,s(Dn,{get children(){return[s(ot,{get when(){return Te(()=>o().state.status==="error")()&&o().state.error},children:w=>{const h=w().replace("Error: ","");return o().tool==="question"&&h.includes("dismissed this question")?(()=>{var k=W_(),v=k.firstChild;return l(v,()=>r.t("ui.messagePart.questions.dismissed")),k})():s(J3,{get tool(){return o().tool},get error(){return w()},get defaultOpen(){return t.defaultOpen},get subtitle(){return f()},get href(){return g()}})}}),s(ot,{when:!0,get children(){return s(Or,{get component(){return m()},get input(){return a()},get tool(){return o().tool},get metadata(){return d()},get output(){return o().state.output},get status(){return o().state.status},get hideDetails(){return t.hideDetails},get defaultOpen(){return t.defaultOpen}})}})]}})),p}})};function pp(e){return(()=>{var t=K_(),n=t.firstChild,r=n.firstChild,i=r.nextSibling;return l(i,()=>e.label),t})()}qi.compaction=function(){const t=xn();return s(pp,{get label(){return t.t("ui.messagePart.compaction")}})};qi.text=function(t){const n=xi(),r=xn(),i=T(()=>new Intl.NumberFormat(r.locale())),o=()=>t.part,a=T(()=>t.message.role==="assistant"&&t.message.error?.name==="MessageAbortedError"),d=T(()=>{if(t.message.role!=="assistant")return"";const C=t.message;return n.store.provider?.all?.find(b=>b.id===C.providerID)?.models?.[C.modelID]?.name??C.modelID}),c=T(()=>{if(t.message.role!=="assistant")return"";const C=t.message,y=C.time.completed,b=typeof t.turnDurationMs=="number"?t.turnDurationMs:typeof y=="number"?y-C.time.created:-1;if(!(b>=0))return"";const _=Math.round(b/1e3);if(_<60)return r.t("ui.message.duration.seconds",{count:i().format(_)});const $=Math.floor(_/60),D=_%60;return r.t("ui.message.duration.minutesSeconds",{minutes:i().format($),seconds:i().format(D)})}),u=T(()=>{if(t.message.role!=="assistant")return"";const C=t.message.agent;return[C?C[0]?.toUpperCase()+C.slice(1):"",d(),c(),a()?r.t("ui.message.interrupted"):""].filter(b=>!!b).join(" · ")}),g=T(()=>t.message.role==="assistant"&&typeof t.message.time.completed!="number"),f=()=>(o().text??"").trim(),m=rp(f,g),p=T(()=>(n.store.part?.[t.message.id]??[]).filter(y=>y?.type==="text"&&!!y.text?.trim()).at(-1)?.id===o().id),w=T(()=>t.message.role!=="assistant"?p():t.showAssistantCopyPartID===null?!1:typeof t.showAssistantCopyPartID=="string"?t.showAssistantCopyPartID===o().id:p()),[h,k]=ke(!1),v=async()=>{const C=f();C&&(await navigator.clipboard.writeText(C),k(!0),setTimeout(()=>k(!1),2e3))};return s(E,{get when(){return m()},get children(){var C=X_(),y=C.firstChild;return l(y,s(zi,{get text(){return m()},get cacheKey(){return o().id},get streaming(){return g()},get onLinkClick(){return t.onLinkClick},get fileFetch(){return t.fileFetch}})),l(C,s(E,{get when(){return w()},get children(){var b=Y_();return l(b,s(Nn,{get value(){return Te(()=>!!h())()?r.t("ui.message.copied"):r.t("ui.message.copyResponse")},placement:"top",gutter:4,get children(){return s(Ot,{get icon(){return h()?"check":"copy"},size:"normal",variant:"ghost",onMouseDown:_=>_.preventDefault(),onClick:v,get"aria-label"(){return Te(()=>!!h())()?r.t("ui.message.copied"):r.t("ui.message.copyResponse")}})}}),null),l(b,s(E,{get when(){return u()},get children(){var _=G_();return l(_,u),_}}),null),G(()=>ue(b,"data-interrupted",a()?"":void 0)),b}}),null),C}})};qi.reasoning=function(t){const n=()=>t.part,r=T(()=>t.message.role==="assistant"&&typeof t.message.time.completed!="number"),o=rp(()=>n().text.trim(),r);return s(E,{get when(){return o()},get children(){var a=Z_();return l(a,s(zi,{get text(){return o()},get cacheKey(){return n().id},get streaming(){return r()},get onLinkClick(){return t.onLinkClick},get fileFetch(){return t.fileFetch}})),a}})};rr.register({name:"read",render(e){const t=xi(),n=xn(),r=[];e.input.offset&&r.push("offset="+e.input.offset),e.input.limit&&r.push("limit="+e.input.limit);const i=T(()=>{if(e.status!=="completed")return[];const o=e.metadata.loaded;return!o||!Array.isArray(o)?[]:o.filter(a=>typeof a=="string")});return[s(Yn,bt(e,{icon:"glasses",get trigger(){return{title:n.t("ui.tool.read"),subtitle:e.input.filePath?Sn(e.input.filePath):"",args:r}}})),s(Oe,{get each(){return i()},children:o=>(()=>{var a=Q_(),d=a.firstChild,c=d.firstChild;return l(a,s(Ue,{name:"enter",size:"small"}),d),l(d,()=>n.t("ui.tool.loaded"),c),l(d,()=>ip(o,t.directory),null),a})()})]}});rr.register({name:"list",render(e){const t=xn();return s(Yn,bt(e,{icon:"bullet-list",get trigger(){return{title:t.t("ui.tool.list"),subtitle:zr(e.input.path||"/")}},get children(){return s(E,{get when(){return e.output},get children(){var n=_c();return l(n,s(zi,{get text(){return e.output}})),n}})}}))}});rr.register({name:"glob",render(e){const t=xn();return s(Yn,bt(e,{icon:"magnifying-glass-menu",get trigger(){return{title:t.t("ui.tool.glob"),subtitle:zr(e.input.path||"/"),args:e.input.pattern?["pattern="+e.input.pattern]:[]}},get children(){return s(E,{get when(){return e.output},get children(){var n=_c();return l(n,s(zi,{get text(){return e.output}})),n}})}}))}});rr.register({name:"grep",render(e){const t=xn(),n=[];return e.input.pattern&&n.push("pattern="+e.input.pattern),e.input.include&&n.push("include="+e.input.include),s(Yn,bt(e,{icon:"magnifying-glass-menu",get trigger(){return{title:t.t("ui.tool.grep"),subtitle:zr(e.input.path||"/"),args:n}},get children(){return s(E,{get when(){return e.output},get children(){var r=_c();return l(r,s(zi,{get text(){return e.output}})),r}})}}))}});rr.register({name:"webfetch",render(e){const t=xn(),n=T(()=>e.status==="pending"||e.status==="running"),r=T(()=>{const i=e.input.url;return typeof i!="string"?"":i});return s(Yn,bt(e,{hideDetails:!0,icon:"window-cursor",get trigger(){return(()=>{var i=Zh(),o=i.firstChild,a=o.firstChild;return l(a,s(tr,{get text(){return t.t("ui.tool.webfetch")},get active(){return n()}})),l(o,s(E,{get when(){return Te(()=>!n())()&&r()},get children(){var d=J_();return d.$$click=c=>c.stopPropagation(),l(d,r),G(()=>ue(d,"href",r())),d}}),null),l(i,s(E,{get when(){return Te(()=>!n())()&&r()},get children(){var d=eC();return l(d,s(Ue,{name:"square-arrow-top-right",size:"small"})),d}}),null),i})()}}))}});rr.register({name:"websearch",render(e){const t=xn(),n=T(()=>{const r=e.input.query;return typeof r!="string"?"":r});return s(Yn,bt(e,{icon:"window-cursor",get trigger(){return{title:t.t("ui.tool.websearch"),subtitle:n(),subtitleClass:"exa-tool-query"}},get children(){return s(fp,{get output(){return e.output}})}}))}});rr.register({name:"codesearch",render(e){const t=xn(),n=T(()=>{const r=e.input.query;return typeof r!="string"?"":r});return s(Yn,bt(e,{icon:"code",get trigger(){return{title:t.t("ui.tool.codesearch"),subtitle:n(),subtitleClass:"exa-tool-query"}},get children(){return s(fp,{get output(){return e.output}})}}))}});rr.register({name:"task",render(e){const t=xi(),n=xn(),r=ep(),i=()=>e.metadata.sessionId,o=T(()=>{const m=e.input.subagent_type;if(!(typeof m!="string"||!m))return m[0].toUpperCase()+m.slice(1)}),a=T(()=>sp(n,o())),d=T(()=>{const m=e.input.description;return typeof m=="string"&&m?m:i()}),c=T(()=>e.status==="pending"||e.status==="running"),u=T(()=>ap(i(),r.pathname,t.sessionHref)),g=()=>s(tr,{get text(){return a()},get active(){return c()}}),f=()=>(()=>{var m=Qh(),p=m.firstChild,w=p.firstChild;return l(w,g),l(p,s(E,{get when(){return d()},get children(){return s(Dn,{get children(){return[s(ot,{get when(){return u()},get children(){var h=tC();return h.$$click=k=>k.stopPropagation(),l(h,d),G(()=>ue(h,"href",u())),h}}),s(ot,{when:!0,get children(){var h=Gh();return l(h,d),h}})]}})}}),null),m})();return s(Yn,{icon:"task",get status(){return e.status},get trigger(){return f()},hideDetails:!0})}});rr.register({name:"bash",render(e){const t=xn(),n=()=>e.status==="pending"||e.status==="running",r=n(),i=T(()=>{const c=e.input.command??e.metadata.command??"",u=P3(e.output||e.metadata.output||"");return`$ ${c}${u?`
22
+
23
+ `+u:""}`}),[o,a]=ke(!1),d=async()=>{const c=i();c&&(await navigator.clipboard.writeText(c),a(!0),setTimeout(()=>a(!1),2e3))};return s(Yn,bt(e,{icon:"console",get trigger(){return(()=>{var c=Zh(),u=c.firstChild,g=u.firstChild;return l(g,s(tr,{get text(){return t.t("ui.tool.shell")},get active(){return n()}})),l(u,s(E,{get when(){return Te(()=>!n())()&&e.input.description},get children(){return s(mC,{get text(){return e.input.description},animate:r})}}),null),c})()},get children(){var c=nC(),u=c.firstChild,g=u.nextSibling,f=g.firstChild,m=f.firstChild;return l(u,s(Nn,{get value(){return Te(()=>!!o())()?t.t("ui.message.copied"):t.t("ui.message.copy")},placement:"top",gutter:4,get children(){return s(Ot,{get icon(){return o()?"check":"copy"},size:"small",variant:"secondary",onMouseDown:p=>p.preventDefault(),onClick:d,get"aria-label"(){return Te(()=>!!o())()?t.t("ui.message.copied"):t.t("ui.message.copy")}})}})),l(m,i),c}}))}});rr.register({name:"edit",render(e){const t=xn(),n=cs(),r=T(()=>tp(e.metadata.diagnostics,e.input.filePath)),i=T(()=>e.metadata?.filediff?.file||e.input.filePath||""),o=()=>Sn(e.input.filePath??""),a=()=>e.status==="pending"||e.status==="running";return(()=>{var d=iC();return l(d,s(Yn,bt(e,{icon:"code-lines",defer:!0,get trigger(){return(()=>{var c=Jh(),u=c.firstChild,g=u.firstChild,f=g.firstChild,m=u.nextSibling;return l(f,s(tr,{get text(){return t.t("ui.messagePart.title.edit")},get active(){return a()}})),l(g,s(E,{get when(){return!a()},get children(){var p=Cc();return l(p,o),p}}),null),l(u,s(E,{get when(){return Te(()=>!a())()&&e.input.filePath?.includes("/")},get children(){var p=Sc(),w=p.firstChild;return l(w,()=>zr(e.input.filePath)),p}}),null),l(m,s(E,{get when(){return Te(()=>!a())()&&e.metadata.filediff},get children(){return s(Vr,{get changes(){return e.metadata.filediff}})}})),c})()},get children(){return[s(E,{get when(){return i()},get children(){return s(Ac,{get path(){return i()},get actions(){return s(E,{get when(){return Te(()=>!a())()&&e.metadata.filediff},get children(){return s(Vr,{get changes(){return e.metadata.filediff}})}})},get children(){var c=rC();return l(c,s(Or,{component:n,mode:"diff",get before(){return{name:e.metadata?.filediff?.file||e.input.filePath,contents:e.metadata?.filediff?.before||e.input.oldString}},get after(){return{name:e.metadata?.filediff?.file||e.input.filePath,contents:e.metadata?.filediff?.after||e.input.newString}}})),c}})}}),s(np,{get diagnostics(){return r()}})]}}))),d})()}});rr.register({name:"write",render(e){const t=xn(),n=cs(),r=T(()=>tp(e.metadata.diagnostics,e.input.filePath)),i=T(()=>e.input.filePath||""),o=()=>Sn(e.input.filePath??""),a=()=>e.status==="pending"||e.status==="running",d=T(()=>{const u=e.input.filePath??"";return u.includes("/memory/")||u.includes("/.claude/")}),c=T(()=>d()?(e.input.content??"").split(`
24
+ `).slice(0,10).join(`
25
+ `):"");return s(E,{get when(){return d()},get fallback(){return(()=>{var u=lC();return l(u,s(Yn,bt(e,{icon:"code-lines",defer:!0,get trigger(){return(()=>{var g=cC(),f=g.firstChild,m=f.firstChild,p=m.firstChild;return l(p,s(tr,{get text(){return t.t("ui.messagePart.title.write")},get active(){return a()}})),l(m,s(E,{get when(){return!a()},get children(){var w=Cc();return l(w,o),w}}),null),l(f,s(E,{get when(){return Te(()=>!a())()&&e.input.filePath?.includes("/")},get children(){var w=Sc(),h=w.firstChild;return l(h,()=>zr(e.input.filePath)),w}}),null),g})()},get children(){return[s(E,{get when(){return Te(()=>!!e.input.content)()&&i()},get children(){return s(Ac,{get path(){return i()},get children(){var g=aC();return l(g,s(Or,{component:n,mode:"text",get file(){return{name:e.input.filePath,contents:e.input.content,cacheKey:da(e.input.content)}},overflow:"scroll"})),g}})}}),s(np,{get diagnostics(){return r()}})]}}))),u})()},get children(){var u=oC();return l(u,s(Yn,bt(e,{icon:"brain",get trigger(){return{title:a()?"Saving memory…":"Memory saved",subtitle:o()}},get children(){return s(E,{get when(){return Te(()=>!a())()&&c()},get children(){var g=sC();return l(g,c),g}})}}))),u}})}});rr.register({name:"apply_patch",render(e){const t=xn(),n=cs(),r=T(()=>e.metadata.files??[]),i=T(()=>e.status==="pending"||e.status==="running"),o=T(()=>{const g=r();if(g.length===1)return g[0]}),[a,d]=ke([]);let c=!1;$e(()=>{const g=r();g.length!==0&&(c||(c=!0,d(g.filter(f=>f.type!=="delete").map(f=>f.filePath))))});const u=T(()=>{const g=r().length;return g===0?"":`${g} ${t.t(g>1?"ui.common.file.other":"ui.common.file.one")}`});return s(E,{get when(){return o()},get fallback(){return(()=>{var g=Su();return l(g,s(Yn,bt(e,{icon:"code-lines",defer:!0,get trigger(){return{title:t.t("ui.tool.patch"),subtitle:u()}},get children(){return s(E,{get when(){return r().length>0},get children(){return s(Bn,{multiple:!0,"data-scope":"apply-patch",style:{"--sticky-accordion-offset":"40px"},get value(){return a()},onChange:f=>d(Array.isArray(f)?f:f?[f]:[]),get children(){return s(Oe,{get each(){return r()},children:f=>{const m=T(()=>a().includes(f.filePath)),[p,w]=ke(!1);return $e(()=>{if(!m()){w(!1);return}requestAnimationFrame(()=>{m()&&w(!0)})}),s(Bn.Item,{get value(){return f.filePath},get"data-type"(){return f.type},get children(){return[s(oo,{get children(){return s(Bn.Trigger,{get children(){var h=Xh(),k=h.firstChild,v=k.firstChild,C=v.firstChild,y=k.nextSibling;return l(k,s(cr,{get node(){return{path:f.relativePath,type:"file"}}}),v),l(v,s(E,{get when(){return f.relativePath.includes("/")},get children(){var b=Yh();return l(b,()=>`‪${zr(f.relativePath)}‬`),b}}),C),l(C,()=>Sn(f.relativePath)),l(y,s(Dn,{get children(){return[s(ot,{get when(){return f.type==="add"},get children(){var b=Tu();return l(b,()=>t.t("ui.patch.action.created")),b}}),s(ot,{get when(){return f.type==="delete"},get children(){var b=Au();return l(b,()=>t.t("ui.patch.action.deleted")),b}}),s(ot,{get when(){return f.type==="move"},get children(){var b=Du();return l(b,()=>t.t("ui.patch.action.moved")),b}}),s(ot,{when:!0,get children(){return s(Vr,{get changes(){return{additions:f.additions,deletions:f.deletions}}})}})]}}),null),l(y,s(Ue,{name:"chevron-grabber-vertical",size:"small"}),null),h}})}}),s(Bn.Content,{get children(){return s(E,{get when(){return p()},get children(){var h=Cu();return l(h,s(Or,{component:n,mode:"diff",get before(){return{name:f.filePath,contents:f.before}},get after(){return{name:f.movePath??f.filePath,contents:f.after}}})),h}})}})]}})}})}})}})}}))),g})()},get children(){var g=Su();return l(g,s(Yn,bt(e,{icon:"code-lines",defer:!0,get trigger(){return(()=>{var f=Jh(),m=f.firstChild,p=m.firstChild,w=p.firstChild,h=m.nextSibling;return l(w,s(tr,{get text(){return t.t("ui.tool.patch")},get active(){return i()}})),l(p,s(E,{get when(){return!i()},get children(){var k=Cc();return l(k,()=>Sn(o().relativePath)),k}}),null),l(m,s(E,{get when(){return Te(()=>!i())()&&o().relativePath.includes("/")},get children(){var k=Sc(),v=k.firstChild;return l(v,()=>zr(o().relativePath)),k}}),null),l(h,s(E,{get when(){return!i()},get children(){return s(Vr,{get changes(){return{additions:o().additions,deletions:o().deletions}}})}})),f})()},get children(){return s(Ac,{get path(){return o().relativePath},get actions(){return s(Dn,{get children(){return[s(ot,{get when(){return o().type==="add"},get children(){var f=Tu();return l(f,()=>t.t("ui.patch.action.created")),f}}),s(ot,{get when(){return o().type==="delete"},get children(){var f=Au();return l(f,()=>t.t("ui.patch.action.deleted")),f}}),s(ot,{get when(){return o().type==="move"},get children(){var f=Du();return l(f,()=>t.t("ui.patch.action.moved")),f}}),s(ot,{when:!0,get children(){return s(Vr,{get changes(){return{additions:o().additions,deletions:o().deletions}}})}})]}})},get children(){var f=Cu();return l(f,s(Or,{component:n,mode:"diff",get before(){return{name:o().filePath,contents:o().before}},get after(){return{name:o().movePath??o().filePath,contents:o().after}}})),f}})}}))),g}})}});rr.register({name:"todowrite",render(e){const t=xn(),n=T(()=>{const i=e.metadata?.todos;if(Array.isArray(i))return i;const o=e.input.todos;return Array.isArray(o)?o:[]}),r=T(()=>{const i=n();return i.length===0?"":`${i.filter(o=>o.status==="completed").length}/${i.length}`});return s(Yn,bt(e,{defaultOpen:!0,icon:"checklist",get trigger(){return{title:t.t("ui.tool.todos"),subtitle:r()}},get children(){return s(E,{get when(){return n().length},get children(){var i=dC();return l(i,s(Oe,{get each(){return n()},children:o=>s(Vh,{readOnly:!0,get checked(){return o.status==="completed"},get children(){var a=uC();return l(a,()=>o.content),G(()=>ue(a,"data-completed",o.status==="completed"?"completed":void 0)),a}})})),i}})}}))}});rr.register({name:"question",render(e){const t=xn(),n=T(()=>e.input.questions??[]),r=T(()=>e.metadata.answers??[]),i=T(()=>r().length>0),o=T(()=>{const a=n().length;return a===0?"":i()?t.t("ui.question.subtitle.answered",{count:a}):`${a} ${t.t(a>1?"ui.common.question.other":"ui.common.question.one")}`});return s(Yn,bt(e,{get defaultOpen(){return i()},icon:"bubble-5",get trigger(){return{title:t.t("ui.tool.questions"),subtitle:o()}},get children(){return s(E,{get when(){return i()},get children(){var a=fC();return l(a,s(Oe,{get each(){return n()},children:(d,c)=>{const u=()=>r()[c()]??[];return(()=>{var g=gC(),f=g.firstChild,m=f.nextSibling;return l(f,()=>d.question),l(m,()=>u().join(", ")||t.t("ui.question.answer.none")),g})()}})),a}})}}))}});rr.register({name:"skill",render(e){const t=xn(),n=T(()=>e.input.name||t.t("ui.tool.skill")),r=T(()=>e.status==="pending"||e.status==="running"),i=()=>s(tr,{get text(){return n()},get active(){return r()}}),o=()=>(()=>{var a=Qh(),d=a.firstChild,c=d.firstChild;return l(c,i),a})();return s(Yn,{icon:"brain",get status(){return e.status},get trigger(){return o()},hideDetails:!0})}});Kt(["click"]);var OC=x('<div data-slot=session-turn-retry-message class="cursor-help truncate">'),NC=x('<div class="flex items-start gap-2"><div class=min-w-0>'),BC=x("<div data-slot=session-turn-retry>"),qC=x("<div data-slot=session-turn-retry-message>"),jC=x("<div data-slot=session-turn-retry-info>");function VC(e){const t=xn(),n=T(()=>{if(e.status.type==="retry")return e.status}),[r,i]=ke(0);$e(Pt(n,c=>{if(!c)return;const u=()=>{const f=n()?.next;f&&i(Math.round((f-Date.now())/1e3))};u();const g=setInterval(u,1e3);vt(()=>clearInterval(g))}));const o=T(()=>{const c=n();return c?c.message.includes("exceeded your current quota")&&c.message.includes("gemini")?t.t("ui.sessionTurn.retry.geminiHot"):c.message.length>80?c.message.slice(0,80)+"...":c.message:""}),a=T(()=>{const c=n();return c?c.message.length>80:!1}),d=T(()=>{const c=n();if(!c)return"";const u=Math.max(0,r()),g=u>0?t.t("ui.sessionTurn.retry.inSeconds",{seconds:u}):"",m=[t.t("ui.sessionTurn.retry.retrying"),g].filter(Boolean).join(" ");return m?t.t("ui.sessionTurn.retry.attemptLine",{line:m,attempt:c.attempt}):t.t("ui.sessionTurn.retry.attempt",{attempt:c.attempt})});return s(E,{get when(){return Te(()=>!!n())()&&(e.show??!0)},get children(){var c=BC();return l(c,s(wa,{variant:"error",class:"error-card",get children(){var u=NC(),g=u.firstChild;return l(u,s(Ti,{class:"size-4 mt-0.5"}),g),l(g,s(E,{get when(){return a()},get fallback(){return(()=>{var f=qC();return l(f,o),f})()},get children(){return s(Nn,{get value(){return n()?.message??""},placement:"top",get children(){var f=OC();return l(f,o),f}})}}),null),l(g,s(E,{get when(){return d()},children:f=>(()=>{var m=jC();return l(m,f),m})()}),null),u}})),c}})}var HC=x("<div data-slot=session-turn-compaction>"),UC=x("<div data-slot=session-turn-assistant-content>"),WC=x("<div data-slot=session-turn-thinking>"),KC=x("<div data-component=session-turn-diffs-trigger><div data-slot=session-turn-diffs-title><span data-slot=session-turn-diffs-label></span><span data-slot=session-turn-diffs-count> </span><div data-slot=session-turn-diffs-meta>"),GC=x("<div data-component=session-turn-diffs-content>"),YC=x("<div data-slot=session-turn-diffs>"),XC=x("<div data-slot=session-turn-message-container><div data-slot=session-turn-message-content aria-live=off>"),ZC=x("<div data-component=session-turn><div data-slot=session-turn-content><div>"),QC=x("<span data-slot=session-turn-diff-directory>"),JC=x("<div data-slot=session-turn-diff-trigger><span data-slot=session-turn-diff-path><span data-slot=session-turn-diff-filename></span></span><div data-slot=session-turn-diff-meta><span data-slot=session-turn-diff-changes></span><span data-slot=session-turn-diff-chevron>"),e5=x("<div data-slot=session-turn-diff-view data-scrollable>");function Lu(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Pu(e){const t=e.replace(/^Error:\s*/,"").trim(),n=c=>{try{return JSON.parse(c)}catch{return}},r=c=>{const u=n(c);return typeof u!="string"?u:n(u.trim())};let i=r(t);if(i===void 0){const c=t.indexOf("{"),u=t.lastIndexOf("}");c!==-1&&u>c&&(i=r(t.slice(c,u+1)))}if(!Lu(i))return e;const o=Lu(i.error)?i.error:void 0;if(o){const c=typeof o.type=="string"?o.type:void 0,u=typeof o.message=="string"?o.message:void 0;if(c&&u)return`${c}: ${u}`;if(u)return u;if(c)return c;const g=typeof o.code=="string"?o.code:void 0;if(g)return g}const a=typeof i.message=="string"?i.message:void 0;if(a)return a;const d=typeof i.error=="string"?i.error:void 0;return d||e}function t5(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function Co(e,t){return Array.isArray(e)?e:t}const n5=new Set(["todowrite"]);function r5(e,t){if(e.type==="tool")return n5.has(e.tool)||e.tool==="question"&&(e.state.status==="pending"||e.state.status==="running")?void 0:"visible";if(e.type==="text")return e.text?.trim()?"visible":void 0;if(e.type==="reasoning")return t&&e.text?.trim()?"visible":void 0;if(qi[e.type])return"visible"}function So(e){return e.replace(/`([^`]+)`/g,"$1").replace(/\[([^\]]+)\]\([^\)]+\)/g,"$1").replace(/[*_~]+/g,"").trim()}function i5(e){const t=e.replace(/\r\n?/g,`
26
+ `),n=t.match(/<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>/i);if(n?.[1]){const a=So(n[1].replace(/<[^>]+>/g," "));if(a)return a}const r=t.match(/^\s{0,3}#{1,6}[ \t]+(.+?)(?:[ \t]+#+[ \t]*)?$/m);if(r?.[1]){const a=So(r[1]);if(a)return a}const i=t.match(/^([^\n]+)\n(?:=+|-+)\s*$/m);if(i?.[1]){const a=So(i[1]);if(a)return a}const o=t.match(/^\s*(?:\*\*|__)(.+?)(?:\*\*|__)\s*$/m);if(o?.[1]){const a=So(o[1]);if(a)return a}}function s5(e){const t=xi(),n=xn(),r=cs(),i=[],o=[],a=[],d=[],c={type:"idle"},u=T(()=>e.messages??Co(t.store.message?.[e.sessionID],i)),g=T(()=>{const q=u()??i,Q=Uo.search(q,e.messageID,J=>J.id),j=Q.found?Q.index:q.findIndex(J=>J.id===e.messageID);if(j<0)return-1;const H=q[j];return!H||H.role!=="user"?-1:j}),f=T(()=>{const q=g();if(q<0)return;const j=(u()??i)[q];if(!(!j||j.role!=="user"))return j}),m=T(()=>typeof e.active=="boolean"?void 0:(u()??i).findLast(Q=>Q.role==="assistant"&&typeof Q.time.completed!="number")),p=T(()=>{const q=m();if(!q?.parentID)return;const Q=u()??i,j=Uo.search(Q,q.parentID,J=>J.id),H=j.found?Q[j.index]:Q.find(J=>J.id===q.parentID);if(!(!H||H.role!=="user"))return H}),w=T(()=>{if(typeof e.active=="boolean")return e.active;const q=f(),Q=p();return!q||!Q?!1:Q.id===q.id}),h=T(()=>{const q=f();return q?Co(t.store.part?.[q.id],o):o}),k=T(()=>h().find(q=>q.type==="compaction")),v=T(()=>{const q=f()?.summary?.diffs;if(!q?.length)return d;const Q=new Set;return q.reduceRight((j,H)=>(Q.has(H.file)||(Q.add(H.file),j.push(H)),j),[]).reverse()}),C=T(()=>v().length),[y,b]=St({open:!1,expanded:[]}),_=()=>y.open,$=()=>y.expanded;$e(Pt(_,(q,Q)=>{!q&&Q&&b("expanded",[])},{defer:!0}));const D=T(()=>{const q=f();if(!q)return a;const Q=u()??i,j=g();if(j<0)return a;const H=[];for(let J=j+1;J<Q.length;J++){const le=Q[J];if(le){if(le.role==="user")break;le.role==="assistant"&&le.parentID===q.id&&H.push(le)}}return H},a,{equals:t5}),L=T(()=>D().some(q=>q.error?.name==="MessageAbortedError")),V=T(()=>k()?n.t("ui.messagePart.compaction"):L()?n.t("ui.message.interrupted"):""),K=T(()=>D().find(q=>q.error&&q.error.name!=="MessageAbortedError")?.error),I=T(()=>{const q=D();for(let Q=q.length-1;Q>=0;Q--){const j=q[Q];if(!j)continue;const H=Co(t.store.part?.[j.id],o);for(let J=H.length-1;J>=0;J--){const le=H[J];if(!(!le||le.type!=="text"||!le.text?.trim()))return le.id}}}),U=T(()=>{const q=K()?.data?.message;return typeof q=="string"?Pu(q):q==null?"":Pu(String(q))}),Y=T(()=>e.status!==void 0?e.status:typeof e.active=="boolean"&&!e.active?c:t.store.session_status[e.sessionID]??c),S=T(()=>Y().type!=="idle"&&w()),M=T(()=>e.showReasoningSummaries??!0),A=T(()=>S()?null:I()??null),F=T(()=>{const q=f()?.time.created;if(typeof q!="number")return;const Q=D().reduce((j,H)=>{const J=H.time.completed;return typeof J!="number"?j:j===void 0?J:Math.max(j,J)},void 0);if(typeof Q=="number"&&!(Q<q))return Q-q}),N=T(()=>{let q=0,Q,j;const H=M();for(const J of D())for(const le of Co(t.store.part?.[J.id],o))if(r5(le,H)==="visible"&&(q++,Q=le.type==="text"?"text":"other"),le.type==="reasoning"&&le.text){const de=i5(le.text);de&&(j=de)}return{visible:q,tail:Q,reason:j}}),X=T(()=>N().visible);T(()=>N().tail);const B=T(()=>N().reason),O=T(()=>{const q=S(),Q=!!K(),j=Y().type,H=M(),J=X();return!q||Q||j==="retry"?!1:H?J===0:!0}),z=Gg({working:S,onUserInteracted:e.onUserInteracted,overflowAnchor:"dynamic"});return(()=>{var q=ZC(),Q=q.firstChild,j=Q.firstChild;Rt(Q,"scroll",z.handleScroll);var H=z.scrollRef;return typeof H=="function"?Lt(H,Q):z.scrollRef=Q,Rt(j,"click",z.handleInteraction,!0),l(j,s(E,{get when(){return f()},get children(){var J=XC(),le=J.firstChild,de=z.contentRef;return typeof de=="function"?Lt(de,J):z.contentRef=J,l(le,s(MC,{get message(){return f()},get parts(){return h()},get actions(){return e.actions},get onLinkClick(){return e.onLinkClick},get fileFetch(){return e.fileFetch}})),l(J,s(E,{get when(){return V()},get children(){var Re=HC();return l(Re,s(pp,{get label(){return V()}})),Re}}),null),l(J,s(E,{get when(){return D().length>0},get children(){var Re=UC();return l(Re,s(_C,{get messages(){return D()},get showAssistantCopyPartID(){return A()},get turnDurationMs(){return F()},get working(){return S()},get showReasoningSummaries(){return M()},get shellToolDefaultOpen(){return e.shellToolDefaultOpen},get editToolDefaultOpen(){return e.editToolDefaultOpen},get onLinkClick(){return e.onLinkClick},get fileFetch(){return e.fileFetch}})),G(()=>ue(Re,"aria-hidden",S())),Re}}),null),l(J,s(E,{get when(){return O()},get children(){var Re=WC();return l(Re,s(tr,{get text(){return n.t("ui.sessionTurn.status.thinking")}}),null),l(Re,s(E,{get when(){return!M()},get children(){return s(Hh,{get text(){return B()},class:"session-turn-thinking-heading",travel:25,duration:700})}}),null),Re}}),null),l(J,s(VC,{get status(){return Y()},get show(){return w()}}),null),l(J,s(E,{get when(){return Te(()=>C()>0)()&&!S()},get children(){var Re=YC();return l(Re,s(Fn,{get open(){return _()},onOpenChange:Ve=>b("open",Ve),variant:"ghost",get children(){return[s(Fn.Trigger,{get children(){var Ve=KC(),Z=Ve.firstChild,ne=Z.firstChild,re=ne.nextSibling,ie=re.firstChild,be=re.nextSibling;return l(ne,()=>n.t("ui.sessionReview.change.modified")),l(re,C,ie),l(re,()=>n.t(C()===1?"ui.common.file.one":"ui.common.file.other"),null),l(be,s(Vr,{get changes(){return v()},variant:"bars"}),null),l(be,s(Fn.Arrow,{}),null),Ve}}),s(Fn.Content,{get children(){return s(E,{get when(){return _()},get children(){var Ve=GC();return l(Ve,s(Bn,{multiple:!0,style:{"--sticky-accordion-offset":"40px"},get value(){return $()},onChange:Z=>b("expanded",Array.isArray(Z)?Z:Z?[Z]:[]),get children(){return s(Oe,{get each(){return v()},children:Z=>{const ne=T(()=>$().includes(Z.file)),[re,ie]=ke(!1);return $e(Pt(ne,be=>{if(!be){ie(!1);return}requestAnimationFrame(()=>{ne()&&ie(!0)})},{defer:!0})),s(Bn.Item,{get value(){return Z.file},get children(){return[s(oo,{get children(){return s(Bn.Trigger,{get children(){var be=JC(),Fe=be.firstChild,ee=Fe.firstChild,_e=Fe.nextSibling,xe=_e.firstChild,ye=xe.nextSibling;return l(Fe,s(E,{get when(){return Z.file.includes("/")},get children(){var Le=QC();return l(Le,()=>`‪${ls(Z.file)}‬`),Le}}),ee),l(ee,()=>Sn(Z.file)),l(xe,s(Vr,{changes:Z})),l(ye,s(Ue,{name:"chevron-down",size:"small"})),be}})}}),s(Bn.Content,{get children(){return s(E,{get when(){return re()},get children(){var be=e5();return l(be,s(Or,{component:r,mode:"diff",get before(){return{name:Z.file,contents:Z.before}},get after(){return{name:Z.file,contents:Z.after}}})),be}})}})]}})}})}})),Ve}})}})]}})),Re}}),null),l(J,s(E,{get when(){return K()},get children(){return s(wa,{variant:"error",class:"error-card",get children(){return U()}})}}),null),G(Re=>{var Ve=f().id,Z=e.classes?.container;return Ve!==Re.e&&ue(J,"data-message",Re.e=Ve),Z!==Re.t&&Ht(J,Re.t=Z),Re},{e:void 0,t:void 0}),J}}),null),l(j,()=>e.children,null),G(J=>{var le=e.classes?.root,de=e.classes?.content;return le!==J.e&&Ht(q,J.e=le),de!==J.t&&Ht(Q,J.t=de),J},{e:void 0,t:void 0}),q})()}Kt(["click"]);const o5=e=>e.deltaMode===1?e.deltaY*40:e.deltaMode===2?e.deltaY*e.rootHeight:e.deltaY,a5=e=>{const t=e.scrollHeight-e.clientHeight;if(t<=1)return!0;if(!e.delta)return!1;if(e.delta<0)return e.scrollTop+e.delta<=0;const n=t-e.scrollTop;return e.delta>n};var l5=x("<svg><circle cx=8 cy=8 data-slot=progress-circle-background></circle><circle cx=8 cy=8 data-slot=progress-circle-progress>");function c5(e){const[t,n]=rn(e,["percentage","size","strokeWidth","class","classList"]),r=()=>t.size||16,i=()=>t.strokeWidth||3,a=16/2,d=()=>a-i()/2,c=T(()=>2*Math.PI*d()),u=T(()=>{const f=Math.max(0,Math.min(100,t.percentage||0))/100;return c()*(1-f)});return(()=>{var g=l5(),f=g.firstChild,m=f.nextSibling;return Nr(g,bt(n,{get width(){return r()},get height(){return r()},viewBox:"0 0 16 16",fill:"none","data-component":"progress-circle",get classList(){return{...t.classList??{},[t.class??""]:!!t.class}}}),!0,!0),G(p=>{var w=d(),h=i(),k=d(),v=i(),C=c().toString(),y=u();return w!==p.e&&ue(f,"r",p.e=w),h!==p.t&&ue(f,"stroke-width",p.t=h),k!==p.a&&ue(m,"r",p.a=k),v!==p.o&&ue(m,"stroke-width",p.o=v),C!==p.i&&ue(m,"stroke-dasharray",p.i=C),y!==p.n&&ue(m,"stroke-dashoffset",p.n=y),p},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),g})()}var d5=x('<div class="flex items-center justify-center">'),u5=x('<div><div class="flex items-center gap-2"><span class=text-text-invert-strong></span><span class=text-text-invert-base>'),f5=x('<div class="flex items-center gap-2"><span class=text-text-invert-strong></span><span class=text-text-invert-base>'),g5=x('<div class="flex items-center gap-2"><span class=text-text-invert-strong>%</span><span class=text-text-invert-base>');function m5(e){e.view.reviewPanel.opened()||e.view.reviewPanel.open(),e.layout.fileTree.opened()&&e.layout.fileTree.tab()!=="all"&&e.layout.fileTree.setTab("all"),e.tabs.open("context"),e.tabs.setActive("context")}function vp(e){const t=br(),n=yr(),r=Hr(),i=hn(),o=Vl(),{params:a,tabs:d,view:c}=Ur(),u=T(()=>e.variant??"button"),g=fs({tabs:d,pathFromTab:n.pathFromTab,normalizeTab:y=>y.startsWith("file://")?n.tab(y):y}),f=T(()=>a.id?t.data.message[a.id]??[]:[]),m=T(()=>new Intl.NumberFormat(i.intl(),{style:"currency",currency:"USD"})),p=T(()=>eg(f(),o.all())),w=T(()=>p().context),h=T(()=>m().format(p().totalCost)),k=()=>{if(a.id){if(g.activeTab()==="context"){d().close("context");return}m5({view:c(),layout:r,tabs:d()})}},v=()=>(()=>{var y=d5();return l(y,s(c5,{size:16,strokeWidth:2,get percentage(){return w()?.usage??0}})),y})(),C=()=>(()=>{var y=u5(),b=y.firstChild,_=b.firstChild,$=_.nextSibling;return l(y,s(E,{get when(){return w()},children:D=>[(()=>{var L=f5(),V=L.firstChild,K=V.nextSibling;return l(V,()=>D().total.toLocaleString(i.intl())),l(K,()=>i.t("context.usage.tokens")),L})(),(()=>{var L=g5(),V=L.firstChild,K=V.firstChild,I=V.nextSibling;return l(V,()=>D().usage??0,K),l(I,()=>i.t("context.usage.usage")),L})()]}),b),l(_,h),l($,()=>i.t("context.usage.cost")),y})();return s(E,{get when(){return a.id},get children(){return s(Nn,{get value(){return C()},get placement(){return e.placement??"top"},get children(){return s(Dn,{get children(){return[s(ot,{get when(){return u()==="indicator"},get children(){return v()}}),s(ot,{when:!0,get children(){return s(kt,{type:"button",variant:"ghost",class:"size-6",onClick:k,get"aria-label"(){return i.t("context.usage.view")},get children(){return v()}})}})]}})}})}})}const h5=(e,t,n)=>{const r=n(e,t);return vt(()=>clearInterval(r))};function p5(e,t){const{debounceMs:n=16,maxStaleMs:r=5e3,onStale:i}=t??{},[o,a]=ke(e),[d,c]=ke(Date.now());let u,g;const f=p=>{g&&clearTimeout(g),u&&clearTimeout(u),g=setTimeout(()=>{a(()=>p),c(Date.now()),u=setTimeout(()=>{Date.now()-d()>r&&i?.(p)},r)},n)},m=p=>{g&&clearTimeout(g),u&&clearTimeout(u),a(()=>p),c(Date.now())};return vt(()=>{g&&clearTimeout(g),u&&clearTimeout(u)}),[o,f,m]}function v5(e,t){const{maxRetries:n=3,retryDelay:r=1e3,onError:i}=t??{},[o,a]=ke({status:"ok",retryCount:0}),d=async u=>{try{const g=await u();return a({status:"ok",retryCount:0}),g}catch(g){const f=g instanceof Error?g:new Error(String(g)),m=o();return m.retryCount<n?(a({status:"retrying",error:f,retryCount:m.retryCount+1}),i?.(f,m.retryCount+1),await new Promise(p=>setTimeout(p,r)),d(u)):(a({status:"error",error:f,retryCount:0}),i?.(f,0),e)}};return[o,d,()=>{a({status:"ok",retryCount:0})}]}function b5(e){const[t,n]=ke(e),[r,i]=ke(0),o=new Set;return{state:t,version:r,update:(c,u)=>{if(!o.has(c)){o.add(c);try{n(g=>u(g)),i(g=>g+1)}finally{o.delete(c)}}},updateAsync:async(c,u)=>{if(!o.has(c)){o.add(c);try{const g=await u(t());n(()=>g),i(f=>f+1)}finally{o.delete(c)}}},isPending:c=>o.has(c)}}var x5=x('<div class="flex min-w-0 items-center gap-2 whitespace-nowrap"><span class="text-12-medium text-text-weak truncate">'),y5=x('<div class="flex flex-col gap-4 pl-6 pr-2.5 pb-3"><div class="flex flex-col gap-1"><span class="text-14-regular text-text-strong"></span></div><div class="flex justify-end gap-2">'),w5=x('<div data-session-title><div class="h-12 w-full flex items-center justify-between gap-2"><div class="flex items-center gap-1 min-w-0 flex-1 pr-3">'),$5=x('<div class="w-full flex justify-center">'),k5=x('<div class="w-full px-4 md:px-5 py-4"><div class="flex items-center gap-2 max-w-[82%]">'),_5=x('<div class="min-w-0 w-full"><div role=log data-slot=session-turn-list class="flex flex-col items-start justify-start pb-16 transition-[margin]">'),C5=x('<div class="relative w-full h-full min-w-0"><div class="absolute left-1/2 -translate-x-1/2 bottom-6 z-[60] pointer-events-none transition-all duration-200 ease-out"><button class="pointer-events-auto size-8 flex items-center justify-center rounded-full bg-background-base border border-border-base shadow-sm text-text-base hover:bg-background-stronger transition-colors">'),S5=x('<div class="relative h-full overflow-hidden">'),T5=x('<div class="flex flex-col gap-2"><div class="grid grid-cols-2 gap-2">'),A5=x('<div class="flex flex-col p-3"><div class="flex flex-col gap-1"><div class="text-13-medium text-text-strong"></div><div class="text-12-regular text-text-weak"></div></div><div class="mt-3 flex flex-col gap-2">'),D5=x('<div class="shrink-0 flex items-center gap-3">'),M5=x('<div class="w-full px-4 md:px-5 pb-2"><div class="ml-auto max-w-[82%] overflow-x-auto no-scrollbar"><div class="flex w-max min-w-full justify-end gap-2">'),E5=x("<div>"),I5=x('<div class="shrink-0 max-w-[260px] rounded-[6px] border border-border-weak-base bg-background-stronger px-2.5 py-2"><div class="flex items-center gap-1.5 min-w-0 text-11-medium text-text-strong"><span class=truncate></span></div><div class="pt-1 text-12-regular text-text-strong whitespace-pre-wrap break-words">'),L5=x('<span class="shrink-0 text-text-weak">');const Ga=[],Fu={type:"idle"},Ru=["Accomplishing","Actioning","Actualizing","Baking","Booping","Brewing","Calculating","Cerebrating","Channelling","Churning","Clauding","Coalescing","Cogitating","Combobulating","Computing","Concocting","Conjuring","Considering","Contemplating","Cooking","Crafting","Creating","Crunching","Deciphering","Deliberating","Determining","Discombobulating","Divining","Doing","Effecting","Elucidating","Elevating","Emanating","Emerging","Enchanting","Envisioning","Evaluating","Examining","Expanding","Exploring","Finagling","Flibbertigibbeting","Forging","Forming","Frolicking","Generating","Germinating","Gestating","Hatching","Herding","Honking","Hustling","Ideating","Imagining","Incubating","Inferring","Inspecting","Intertwining","Intuiting","Inventing","Investigating","Jiving","Juggling","Manifesting","Marinating","Meandering","Meditating","Moseying","Mulling","Mustering","Musing","Noodling","Observing","Orchestrating","Percolating","Perusing","Philosophising","Pondering","Pontificating","Processing","Puttering","Puzzling","Rearranging","Reticulating","Ruminating","Scheming","Schlepping","Shimmying","Shucking","Simmering","Smooshing","Spelunking","Spinning","Stewing","Stretching","Sussing","Swirling","Synthesizing","Thinking","Tinkering","Transforming","Transmuting","Twirling","Unfurling","Unravelling","Unspooling","Vibing","Wandering","Weaving","Whirring","Wibbling","Wizarding","Wobbling","Wondering","Wrangling","Working"];function P5(e){const[t,n]=ke(0),[r,i]=ke(0),o=["",".","..","..."];return $e(()=>{const a=setInterval(()=>{n(c=>(c+1)%Ru.length)},1400),d=setInterval(()=>{i(c=>(c+1)%o.length)},400);vt(()=>{clearInterval(a),clearInterval(d)})}),(()=>{var a=x5(),d=a.firstChild;return l(a,s(Ti,{class:"size-3",get style(){return{color:e.color}}}),d),l(d,()=>Ru[t()],null),l(d,()=>o[r()],null),G(c=>Je(a,"color",e.color)),a})()}const F5=e=>e.flatMap(t=>{if(t.type!=="text"||!t.synthetic)return[];const n=C1(t.metadata)??T1(t.text);return n?[{path:n.path,comment:n.comment,selection:n.selection?{startLine:n.selection.startLine,endLine:n.selection.endLine}:void 0}]:[]}),R5=(e,t)=>{const r=(t instanceof Element?t:void 0)?.closest("[data-scrollable]");return!r||r===e||!(r instanceof HTMLElement)?e:r},zu=e=>{const t=R5(e.root,e.target);if(t===e.root){e.onMarkScrollGesture(e.root);return}a5({delta:e.delta,scrollTop:t.scrollTop,scrollHeight:t.scrollHeight,clientHeight:t.clientHeight})&&e.onMarkScrollGesture(e.root)};function z5(e){const[t,n]=St({activeSession:"",completedSession:"",count:0}),r=T(()=>{const c=e.messages().length;if(e.turnStart()<=0||t.completedSession===e.sessionKey())return c;const u=Math.min(c,e.config.init);return t.count<=u?u:t.count>=c?c:t.count}),i=T(()=>{const c=e.messages(),u=r();return u>=c.length?c:c.slice(Math.max(0,c.length-u))});let o;const a=()=>{o!==void 0&&(cancelAnimationFrame(o),o=void 0)};$e(Pt(()=>[e.sessionKey(),e.turnStart()>0,e.messages().length],([c,u,g])=>{if(a(),!(u&&g>e.config.init&&t.completedSession!==c&&t.activeSession!==c)){n({activeSession:"",count:g});return}let m=Math.min(g,e.config.init);n({activeSession:c,count:m});const p=()=>{if(e.sessionKey()!==c){o=void 0;return}const w=e.messages().length;if(m=Math.min(w,m+e.config.batch),n("count",m),m>=w){n({completedSession:c,activeSession:""}),o=void 0;return}o=requestAnimationFrame(p)};o=requestAnimationFrame(p)}));const d=T(()=>{const c=e.sessionKey();return t.activeSession===c&&t.completedSession!==c});return vt(a),{messages:i,isStaging:d}}function O5(e){let t;const n=Ri(),r=pg(),i=zn(),o=br(),a=Hl(),d=dr(),c=hn(),{params:u,sessionKey:g}=fg(),f=aa(),m=yr(),p=Hr(),w=(ee,_e)=>{if(rg(ee)){_e.preventDefault();return}if(ee.startsWith("wiki://")){_e.preventDefault();const tt=ee.replace("wiki://","").split("/"),ge=tt[0],qe=decodeURIComponent(tt.slice(1).join("/"));n(ge==="issue"?`/trellis?issue=${encodeURIComponent(qe)}`:`/trellis?entity=${encodeURIComponent(`${ge}:${qe}`)}`);return}_e.preventDefault();const xe=ee.replace(/^(\.\/|\/)/,"");if(!xe)return;const ye=m.tab(xe);m.load(xe);const Le=p.tabs(`${u.dir}${u.id?"/"+u.id:""}`);Le.open(ye),Le.setActive(ye)},h=async ee=>{const _e=ee.replace(/^(\.\/)/,"");if(_e)return await m.load(_e),m.text(_e)},k=T(()=>e.renderedUserMessages.map(ee=>ee.id)),v=T(()=>u.id),C=b5(Ga),y=T(()=>{const ee=v();if(!ee)return Ga;const xe=(o.data.message[ee]??Ga).sort((ye,Le)=>{const tt=ye.time?.created??0,ge=Le.time?.created??0;return tt-ge});return(xe.length!==C.state().length||xe.some((ye,Le)=>ye.id!==C.state()[Le]?.id))&&C.update("session-messages",()=>xe),C.state()}),b=T(()=>y().findLast(ee=>ee.role==="assistant"&&typeof ee.time.completed!="number")),_=T(()=>{const ee=v();return ee?o.data.session_status[ee]??Fu:Fu}),$=T(()=>!!b()||_().type!=="idle"),D=T(()=>Qf(y(),o.data.agent)),[L,V,K]=p5(!0,{debounceMs:50,maxStaleMs:1e3,onStale:()=>{console.warn("Timeout state went stale, forcing update"),K(!0)}}),I=T(ee=>$()?"showing":L()?"hidden":"hiding");$e(()=>{I()==="hiding"&&(V(!1),h5(()=>V(!0),260,setTimeout))});const U=T(()=>{const ee=b()?.parentID;if(ee){const xe=y(),ye=Uo.search(xe,ee,tt=>tt.id),Le=ye.found?xe[ye.index]:xe.find(tt=>tt.id===ee);if(Le&&Le.role==="user")return Le.id}if(_().type!=="idle"){const xe=y();for(let ye=xe.length-1;ye>=0;ye--)if(xe[ye].role==="user")return xe[ye].id}}),Y=T(()=>{const ee=v();if(ee)return o.session.get(ee)}),S=T(()=>Y()?.title),M=T(()=>Y()?.share?.url),A=T(()=>o.data.config.share!=="disabled"),F=T(()=>Y()?.parentID),N=T(()=>!!(S()||F())),B=z5({sessionKey:g,turnStart:()=>e.turnStart,messages:()=>e.renderedUserMessages,config:{init:1,batch:3}}),[O,z]=St({draft:"",editing:!1,menuOpen:!1,pendingRename:!1,pendingShare:!1});v5(null,{maxRetries:2,retryDelay:500,onError:(ee,_e)=>{console.error(`Session operation failed (attempt ${_e}):`,ee)}});const[q,Q]=St({open:!1,dismiss:null});let j;const H=()=>{const ee=M();ee&&f.openLink(ee)},J=ee=>{if(ee&&typeof ee=="object"&&"data"in ee){const _e=ee.data;if(_e?.message)return _e.message}return ee instanceof Error?ee.message:c.t("common.requestFailed")},le=Yr(()=>({mutationFn:ee=>r.client.session.share({sessionID:ee,directory:i.directory}),onError:ee=>{console.error("Failed to share session",ee)}})),de=Yr(()=>({mutationFn:ee=>r.client.session.unshare({sessionID:ee,directory:i.directory}),onError:ee=>{console.error("Failed to unshare session",ee)}}));Yr(()=>({mutationFn:ee=>i.client.session.update({sessionID:ee.id,title:ee.title}),onSuccess:(ee,_e)=>{o.set(Rs(xe=>{const ye=xe.session.findIndex(Le=>Le.id===_e.id);ye!==-1&&(xe.session[ye].title=_e.title)})),z("editing",!1)},onError:ee=>{nt({title:c.t("common.requestFailed"),description:J(ee)})}}));const Re=()=>{const ee=v();!ee||le.isPending||A()&&le.mutate(ee)},Ve=()=>{const ee=v();!ee||de.isPending||A()&&de.mutate(ee)};$e(Pt(g,()=>z({draft:"",editing:!1,menuOpen:!1,pendingRename:!1,pendingShare:!1}),{defer:!0}));const Z=()=>{v()&&(z({editing:!0,draft:S()??""}),requestAnimationFrame(()=>{}))},ne=(ee,_e,xe)=>{if(u.id===ee){if(_e){n(`/${u.dir}/session/${_e}`);return}if(xe){n(`/${u.dir}/session/${xe}`);return}n(`/${u.dir}/session`)}},re=async ee=>{const _e=o.session.get(ee);if(!_e)return;const xe=o.data.session??[],ye=xe.findIndex(tt=>tt.id===ee),Le=ye===-1?void 0:xe[ye+1]??xe[ye-1];await i.client.session.update({sessionID:ee,time:{archived:Date.now()}}).then(()=>{o.set(Rs(tt=>{const ge=tt.session.findIndex(qe=>qe.id===ee);ge!==-1&&tt.session.splice(ge,1)})),ne(ee,_e.parentID,Le?.id)}).catch(tt=>{nt({title:c.t("common.requestFailed"),description:J(tt)})})},ie=async ee=>{const _e=o.session.get(ee);if(!_e)return!1;const xe=(o.data.session??[]).filter(ge=>!ge.parentID&&!ge.time?.archived),ye=xe.findIndex(ge=>ge.id===ee),Le=ye===-1?void 0:xe[ye+1]??xe[ye-1];return await i.client.session.delete({sessionID:ee}).then(ge=>ge.data).catch(ge=>(nt({title:c.t("session.delete.failed.title"),description:J(ge)}),!1))?(o.set(Rs(ge=>{const qe=new Set([ee]),we=new Map;for(const Ne of ge.session){const Ee=Ne.parentID;if(!Ee)continue;const rt=we.get(Ee);if(rt){rt.push(Ne.id);continue}we.set(Ee,[Ne.id])}const He=[ee];for(;He.length;){const Ne=He.pop();if(!Ne)continue;const Ee=we.get(Ne);if(Ee)for(const rt of Ee)qe.has(rt)||(qe.add(rt),He.push(rt))}ge.session=ge.session.filter(Ne=>!qe.has(Ne.id))})),ne(ee,_e.parentID,Le?.id),!0):!1},be=()=>{const ee=F();ee&&n(`/${u.dir}/session/${ee}`)};function Fe(ee){const _e=T(()=>o.session.get(ee.sessionID)?.title??c.t("command.session.new")),xe=async()=>{await ie(ee.sessionID),d.close()};return s(no,{get title(){return c.t("session.delete.title")},fit:!0,get children(){var ye=y5(),Le=ye.firstChild,tt=Le.firstChild,ge=Le.nextSibling;return l(tt,()=>c.t("session.delete.confirm",{name:_e()})),l(ge,s(kt,{variant:"ghost",size:"large",onClick:()=>d.close(),get children(){return c.t("common.cancel")}}),null),l(ge,s(kt,{variant:"primary",size:"large",onClick:xe,get children(){return c.t("session.delete.button")}}),null),ye}})}return s(E,{get when(){return!e.mobileChanges},get fallback(){return(()=>{var ee=S5();return l(ee,()=>e.mobileFallback),ee})()},get children(){var ee=C5(),_e=ee.firstChild,xe=_e.firstChild;return Rt(xe,"click",e.onResumeScroll,!0),l(xe,s(Ue,{name:"arrow-down-to-line"})),l(ee,s(ba,{get viewportRef(){return e.setScrollRef},onWheel:ye=>{const Le=ye.currentTarget,tt=o5({deltaY:ye.deltaY,deltaMode:ye.deltaMode,rootHeight:Le.clientHeight});tt&&zu({root:Le,target:ye.target,delta:tt,onMarkScrollGesture:e.onMarkScrollGesture})},onTouchStart:ye=>{t=ye.touches[0]?.clientY},onTouchMove:ye=>{const Le=ye.touches[0]?.clientY,tt=t;if(t=Le,Le===void 0||tt===void 0)return;const ge=tt-Le;if(!ge)return;const qe=ye.currentTarget;zu({root:qe,target:ye.target,delta:ge,onMarkScrollGesture:e.onMarkScrollGesture})},onTouchEnd:()=>{t=void 0},onTouchCancel:()=>{t=void 0},onPointerDown:ye=>{ye.target===ye.currentTarget&&e.onMarkScrollGesture(ye.currentTarget)},onScroll:ye=>{e.onScheduleScrollState(ye.currentTarget),e.onTurnBackfillScroll(),e.hasScrollGesture()&&(e.onUserScroll(),e.onAutoScrollHandleScroll(),e.onMarkScrollGesture(ye.currentTarget))},get onClick(){return e.onAutoScrollInteraction},class:"relative min-w-0 w-full h-full",get style(){return{"--session-title-height":N()?"40px":"0px","--sticky-accordion-top":N()?"48px":"0px"}},get children(){var ye=_5(),Le=ye.firstChild,tt=e.setContentRef;return typeof tt=="function"?Lt(tt,ye):e.setContentRef=ye,l(ye,s(E,{get when(){return N()},get children(){var ge=w5(),qe=ge.firstChild,we=qe.firstChild;return l(we,s(E,{get when(){return F()},get children(){return s(Ot,{tabIndex:-1,icon:"arrow-left",variant:"ghost",onClick:be,get"aria-label"(){return c.t("common.goBack")}})}})),l(qe,s(E,{get when(){return v()},children:He=>(()=>{var Ne=D5();return l(Ne,s(vp,{placement:"bottom"}),null),l(Ne,s(Ye,{gutter:4,placement:"bottom-end",get open(){return O.menuOpen},onOpenChange:Ee=>{z("menuOpen",Ee)},get children(){return[s(Ye.Trigger,{as:Ot,icon:"dot-grid",variant:"ghost",class:"size-6 rounded-md data-[expanded]:bg-surface-base-active",get classList(){return{"bg-surface-base-active":q.open||O.pendingShare}},get"aria-label"(){return c.t("common.moreOptions")},get"aria-expanded"(){return O.menuOpen||q.open||O.pendingShare},ref:Ee=>{j=Ee}}),s(Ye.Portal,{get children(){return s(Ye.Content,{style:{"min-width":"104px"},onCloseAutoFocus:Ee=>{if(O.pendingRename){Ee.preventDefault(),z("pendingRename",!1),Z();return}O.pendingShare&&(Ee.preventDefault(),requestAnimationFrame(()=>{Q({open:!0,dismiss:null}),z("pendingShare",!1)}))},get children(){return[s(Ye.Item,{onSelect:()=>{z("pendingRename",!0),z("menuOpen",!1)},get children(){return s(Ye.ItemLabel,{get children(){return c.t("common.rename")}})}}),s(E,{get when(){return A()},get children(){return s(Ye.Item,{onSelect:()=>{z({pendingShare:!0,menuOpen:!1})},get children(){return s(Ye.ItemLabel,{get children(){return c.t("session.share.action.share")}})}})}}),s(Ye.Item,{onSelect:()=>void re(He()),get children(){return s(Ye.ItemLabel,{get children(){return c.t("common.archive")}})}}),s(Ye.Separator,{}),s(Ye.Item,{onSelect:()=>d.show(()=>s(Fe,{get sessionID(){return He()}})),get children(){return s(Ye.ItemLabel,{get children(){return c.t("common.delete")}})}})]}})}})]}}),null),l(Ne,s(ci,{get open(){return q.open},anchorRef:()=>j,placement:"bottom-end",gutter:4,modal:!1,onOpenChange:Ee=>{Ee&&Q("dismiss",null),Q("open",Ee)},get children(){return s(ci.Portal,{get children(){return s(ci.Content,{"data-component":"popover-content",style:{"min-width":"320px"},onEscapeKeyDown:Ee=>{Q({dismiss:"escape",open:!1}),Ee.preventDefault(),Ee.stopPropagation()},onPointerDownOutside:()=>{Q({dismiss:"outside",open:!1})},onFocusOutside:()=>{Q({dismiss:"outside",open:!1})},onCloseAutoFocus:Ee=>{q.dismiss==="outside"&&Ee.preventDefault(),Q("dismiss",null)},get children(){var Ee=A5(),rt=Ee.firstChild,ct=rt.firstChild,zt=ct.nextSibling,xt=rt.nextSibling;return l(ct,()=>c.t("session.share.popover.title")),l(zt,(()=>{var st=Te(()=>!!M());return()=>st()?c.t("session.share.popover.description.shared"):c.t("session.share.popover.description.unshared")})()),l(xt,s(E,{get when(){return M()},get fallback(){return s(kt,{size:"large",variant:"primary",class:"w-full",onClick:Re,get disabled(){return le.isPending},get children(){return Te(()=>!!le.isPending)()?c.t("session.share.action.publishing"):c.t("session.share.action.publish")}})},get children(){var st=T5(),gt=st.firstChild;return l(st,s(Kl,{get value(){return M()??""},readOnly:!0,copyable:!0,copyKind:"link",tabIndex:-1,class:"w-full"}),gt),l(gt,s(kt,{size:"large",variant:"secondary",class:"w-full shadow-none border border-border-weak-base",onClick:Ve,get disabled(){return de.isPending},get children(){return Te(()=>!!de.isPending)()?c.t("session.share.action.unpublishing"):c.t("session.share.action.unpublish")}}),null),l(gt,s(kt,{size:"large",variant:"primary",class:"w-full",onClick:H,get disabled(){return de.isPending},get children(){return c.t("session.share.action.view")}}),null),st}})),Ee}})}})}}),null),Ne})()}),null),G(He=>Tt(ge,{"sticky top-0 z-30 bg-[linear-gradient(to_bottom,var(--background-stronger)_48px,transparent)]":!0,"w-full":!0,"pb-4":!0,"pl-2 pr-3 md:pl-4 md:pr-3":!0,"md:max-w-200 md:mx-auto 2xl:max-w-[1000px]":e.centered},He)),ge}}),Le),l(Le,s(E,{get when(){return e.turnStart>0||e.historyMore},get children(){var ge=$5();return l(ge,s(kt,{variant:"ghost",size:"large",class:"text-12-medium opacity-50",get disabled(){return e.historyLoading},get onClick(){return e.onLoadEarlier},get children(){return Te(()=>!!e.historyLoading)()?c.t("session.messages.loadingEarlier"):c.t("session.messages.loadEarlier")}})),ge}}),null),l(Le,s(Oe,{get each(){return k()},children:ge=>{const qe=T(()=>U()===ge),we=T(()=>o.data.part[ge]??[]),He=T(()=>F5(we()),[],{equals:(Ee,rt)=>Ee.length===rt.length&&Ee.every((ct,zt)=>ct.path===rt[zt].path&&ct.comment===rt[zt].comment&&ct.selection?.startLine===rt[zt].selection?.startLine&&ct.selection?.endLine===rt[zt].selection?.endLine)}),Ne=T(()=>He().length);return(()=>{var Ee=E5();return Lt(rt=>{requestAnimationFrame(()=>vg(rt,{opacity:[0,1],y:[16,0]},{type:"spring",stiffness:400,damping:30}))},Ee),ue(Ee,"data-message-id",ge),l(Ee,s(E,{get when(){return Ne()>0},get children(){var rt=M5(),ct=rt.firstChild,zt=ct.firstChild;return l(zt,s(bi,{get each(){return He()},children:xt=>{const st=T(()=>xt());return s(E,{get when(){return st()},children:gt=>(()=>{var $n=I5(),Ce=$n.firstChild,Dt=Ce.firstChild,lt=Ce.nextSibling;return l(Ce,s(cr,{get node(){return{path:gt().path,type:"file"}},class:"size-3.5 shrink-0"}),Dt),l(Dt,()=>Sn(gt().path)),l(Ce,s(E,{get when(){return gt().selection},children:At=>(()=>{var wt=L5();return l(wt,(()=>{var It=Te(()=>At().startLine===At().endLine);return()=>It()?`:${At().startLine}`:`:${At().startLine}-${At().endLine}`})()),wt})()}),null),l(lt,()=>gt().comment),$n})()})}})),rt}}),null),l(Ee,s(s5,{get sessionID(){return v()??""},messageID:ge,get messages(){return y()},get actions(){return e.actions},get active(){return qe()},get status(){return Te(()=>!!qe())()?_():void 0},get showReasoningSummaries(){return a.general.showReasoningSummaries()},get shellToolDefaultOpen(){return a.general.shellToolPartsExpanded()},get editToolDefaultOpen(){return a.general.editToolPartsExpanded()},onLinkClick:w,fileFetch:h,classes:{root:"min-w-0 w-full relative",content:"flex flex-col justify-between !overflow-visible",container:"w-full px-4 md:px-5"}}),null),G(rt=>{var ct=e.anchor(ge),zt={"min-w-0 w-full max-w-full":!0,"md:max-w-200 2xl:max-w-[1000px]":e.centered};return ct!==rt.e&&ue(Ee,"id",rt.e=ct),rt.t=Tt(Ee,zt,rt.t),rt},{e:void 0,t:void 0}),Ee})()}}),null),l(Le,s(E,{get when(){return I()!=="hidden"},get children(){var ge=k5(),qe=ge.firstChild;return l(qe,s(P5,{get color(){return D()??"var(--icon-interactive-base)"}})),G(we=>Tt(ge,{"opacity-100 translate-y-0 transition-all duration-200 ease-out":I()==="showing","opacity-0 translate-y-2 transition-all duration-200 ease-out pointer-events-none":I()==="hiding"},we)),ge}}),null),G(ge=>Tt(Le,{"w-full":!0,"md:max-w-200 md:mx-auto 2xl:max-w-[1000px]":e.centered,"mt-0.5":e.centered,"mt-0":!e.centered},ge)),ye}}),null),G(ye=>Tt(_e,{"opacity-100 translate-y-0 scale-100":e.scroll.overflow&&!e.scroll.bottom&&!B.isStaging(),"opacity-0 translate-y-2 scale-95 pointer-events-none":!e.scroll.overflow||e.scroll.bottom||B.isStaging()},ye)),ee}})}Kt(["click"]);var N5={};jl(N5,{Description:()=>ma,ErrorMessage:()=>ga,Item:()=>yp,ItemControl:()=>Dc,ItemDescription:()=>Mc,ItemIndicator:()=>Ec,ItemInput:()=>wp,ItemLabel:()=>Ic,Label:()=>Lc,RadioGroup:()=>ka,Root:()=>$p,useRadioGroupContext:()=>$a});var bp=as();function $a(){const e=os(bp);if(e===void 0)throw new Error("[kobalte]: `useRadioGroupContext` must be used within a `RadioGroup` component");return e}var xp=as();function xs(){const e=os(xp);if(e===void 0)throw new Error("[kobalte]: `useRadioGroupItemContext` must be used within a `RadioGroup.Item` component");return e}function yp(e){const t=ro(),n=$a(),r=`${t.generateId("item")}-${to()}`,i=ur({id:r},e),[o,a]=rn(i,["value","disabled","onPointerDown"]),[d,c]=ke(),[u,g]=ke(),[f,m]=ke(),[p,w]=ke(),[h,k]=ke(!1),v=T(()=>n.isDefaultValue(o.value)),C=T(()=>n.isSelectedValue(o.value)),y=T(()=>o.disabled||t.isDisabled()||!1),b=D=>{vr(D,o.onPointerDown),h()&&D.preventDefault()},_=T(()=>({...t.dataset(),"data-disabled":y()?"":void 0,"data-checked":C()?"":void 0})),$={value:()=>o.value,dataset:_,isDefault:v,isSelected:C,isDisabled:y,inputId:d,labelId:u,descriptionId:f,inputRef:p,select:()=>n.setSelectedValue(o.value),generateId:ca(()=>a.id),registerInput:Fs(c),registerLabel:Fs(g),registerDescription:Fs(m),setIsFocused:k,setInputRef:w};return s(xp.Provider,{value:$,get children(){return s(xr,bt({as:"div",role:"group",onPointerDown:b},_,a))}})}function Dc(e){const t=xs(),n=ur({id:t.generateId("control")},e),[r,i]=rn(n,["onClick","onKeyDown"]);return s(xr,bt({as:"div",onClick:d=>{vr(d,r.onClick),t.select(),t.inputRef()?.focus()},onKeyDown:d=>{vr(d,r.onKeyDown),d.key===ug.Space&&(t.select(),t.inputRef()?.focus())}},()=>t.dataset(),i))}function Mc(e){const t=xs(),n=ur({id:t.generateId("description")},e);return $e(()=>vt(t.registerDescription(n.id))),s(xr,bt({as:"div"},()=>t.dataset(),n))}function Ec(e){const t=xs(),n=ur({id:t.generateId("indicator")},e),[r,i]=rn(n,["ref","forceMount"]),[o,a]=ke(),{present:d}=dg({show:()=>r.forceMount||t.isSelected(),element:()=>o()??null});return s(E,{get when(){return d()},get children(){return s(xr,bt({as:"div",ref(c){var u=Br(a,r.ref);typeof u=="function"&&u(c)}},()=>t.dataset(),i))}})}function wp(e){const t=ro(),n=$a(),r=xs(),i=ur({id:r.generateId("input")},e),[o,a]=rn(i,["ref","style","aria-labelledby","aria-describedby","onChange","onFocus","onBlur"]),d=()=>[o["aria-labelledby"],r.labelId(),o["aria-labelledby"]!=null&&a["aria-label"]!=null?a.id:void 0].filter(Boolean).join(" ")||void 0,c=()=>[o["aria-describedby"],r.descriptionId(),n.ariaDescribedBy()].filter(Boolean).join(" ")||void 0,[u,g]=ke(!1),f=w=>{if(vr(w,o.onChange),w.stopPropagation(),!u()){n.setSelectedValue(r.value());const h=w.target;h.checked=r.isSelected()}g(!1)},m=w=>{vr(w,o.onFocus),r.setIsFocused(!0)},p=w=>{vr(w,o.onBlur),r.setIsFocused(!1)};return $e(Pt([()=>r.isSelected(),()=>r.value()],w=>{if(!w[0]&&w[1]===r.value())return;g(!0);const h=r.inputRef();h?.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),h?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},{defer:!0})),$e(()=>vt(r.registerInput(a.id))),s(xr,bt({as:"input",ref(w){var h=Br(r.setInputRef,o.ref);typeof h=="function"&&h(w)},type:"radio",get name(){return t.name()},get value(){return r.value()},get checked(){return r.isSelected()},get required(){return t.isRequired()},get disabled(){return r.isDisabled()},get readonly(){return t.isReadOnly()},get style(){return la({...cg},o.style)},get"aria-labelledby"(){return d()},get"aria-describedby"(){return c()},onChange:f,onFocus:m,onBlur:p},()=>r.dataset(),a))}function Ic(e){const t=xs(),n=ur({id:t.generateId("label")},e);return $e(()=>vt(t.registerLabel(n.id))),s(xr,bt({as:"label",get for(){return t.inputId()}},()=>t.dataset(),n))}function Lc(e){return s(lg,bt({as:"span"},e))}function $p(e){let t;const n=`radiogroup-${to()}`,r=ur({id:n,orientation:"vertical"},e),[i,o,a]=rn(r,["ref","value","defaultValue","onChange","orientation","aria-labelledby","aria-describedby"],sg),[d,c]=zv({value:()=>i.value,defaultValue:()=>i.defaultValue,onChange:k=>i.onChange?.(k)}),{formControlContext:u}=og(o);Wl(()=>t,()=>c(i.defaultValue??""));const g=()=>u.getAriaLabelledBy(Wo(o.id),a["aria-label"],i["aria-labelledby"]),f=()=>u.getAriaDescribedBy(i["aria-describedby"]),m=k=>k===e.defaultValue,p=k=>k===d(),h={ariaDescribedBy:f,isDefaultValue:m,isSelectedValue:p,setSelectedValue:k=>{if(!(u.isReadOnly()||u.isDisabled())&&(c(k),t))for(const v of t.querySelectorAll("[type='radio']")){const C=v;C.checked=p(C.value)}}};return s(ag.Provider,{value:u,get children(){return s(bp.Provider,{value:h,get children(){return s(xr,bt({as:"div",ref(k){var v=Br(C=>t=C,i.ref);typeof v=="function"&&v(k)},role:"radiogroup",get id(){return Wo(o.id)},get"aria-invalid"(){return u.validationState()==="invalid"||void 0},get"aria-required"(){return u.isRequired()||void 0},get"aria-disabled"(){return u.isDisabled()||void 0},get"aria-readonly"(){return u.isReadOnly()||void 0},get"aria-orientation"(){return i.orientation},get"aria-labelledby"(){return g()},get"aria-describedby"(){return f()}},()=>u.dataset(),a))}})}})}var ka=Object.assign($p,{Description:ma,ErrorMessage:ga,Item:yp,ItemControl:Dc,ItemDescription:Mc,ItemIndicator:Ec,ItemInput:wp,ItemLabel:Ic,Label:Lc}),kp=as();function _p(){const e=os(kp);if(e===void 0)throw new Error("[kobalte]: `useSegmentedControlContext` must be used within a `SegmentedControl` component");return e}function B5(e){const t=_p(),[n,r]=rn(e,["style"]),[i,o]=ke(),[a,d]=ke(!1),c=()=>{const g=t.selectedItem();if(!g){o(void 0);return}o({width:`${g.offsetWidth}px`,height:`${g.offsetHeight}px`,transform:u(g),"transition-duration":a()?"0ms":void 0})},u=g=>{const f=getComputedStyle(g.parentElement),m=g.offsetLeft-Number.parseFloat(f.paddingLeft),p=g.offsetTop-Number.parseFloat(f.paddingTop);return`translate(${m}px, ${p}px)`};return $e(Pt(t.selectedItem,()=>{d(!i()),c(),d(!1)})),Zo(t.root,()=>{Wn(()=>{d(!0),c(),d(!1)})}),s(xr,bt({as:"div",role:"presentation",get style(){return la(i(),n.style)},get"data-resizing"(){return a()},get"data-orientation"(){return t.orientation()}},r))}var q5=e=>{const t=$a(),n=_p(),[r,i]=rn(e,["ref"]),[o,a]=ke();return $e(()=>{const d=o();d&&t.isSelectedValue(e.value)&&n.setSelectedItem(d)}),s(ka.Item,bt({ref(d){var c=Br(a,r.ref);typeof c=="function"&&c(d)}},i))},j5=e=>{const t=xs(),[n,r]=rn(e,["ref"]),[i,o]=ke();return Wl(i,()=>{requestAnimationFrame(()=>{t.isDefault()&&t.select()})}),s(ka.ItemInput,bt({ref(a){var d=Br(o,n.ref);typeof d=="function"&&d(a)}},r))},V5=e=>{const t=bt({defaultValue:e.value,orientation:"horizontal"},e),[n,r]=rn(t,["ref"]),[i,o]=ke(),[a,d]=ke(),c={value:()=>r.value,defaultValue:()=>r.defaultValue,orientation:()=>r.orientation,root:i,selectedItem:a,setSelectedItem:d};return $e(()=>{c.value()||d(void 0)}),s(kp.Provider,{value:c,get children(){return s(ka,bt({ref(u){var g=Br(o,n.ref);typeof g=="function"&&g(u)}},r))}})},Ts=Object.assign(V5,{Description:ma,ErrorMessage:ga,Indicator:B5,Item:q5,ItemControl:Dc,ItemDescription:Mc,ItemIndicator:Ec,ItemInput:j5,ItemLabel:Ic,Label:Lc}),H5=x("<div role=presentation data-slot=radio-group-wrapper><div role=presentation data-slot=radio-group-items>"),U5=x("<span data-slot=radio-group-item-control>");function W5(e){const[t,n]=rn(e,["class","classList","options","current","defaultValue","value","label","onSelect","size","fill","pad"]),r=a=>t.value?t.value(a):String(a),i=a=>t.label?t.label(a):String(a),o=a=>t.options.find(d=>r(d)===a);return s(Ts,bt(n,{"data-component":"radio-group",get"data-size"(){return t.size??"medium"},get"data-fill"(){return t.fill?"":void 0},get"data-pad"(){return t.pad??"normal"},get classList(){return{...t.classList??{},[t.class??""]:!!t.class}},get value(){return Te(()=>!!t.current)()?r(t.current):void 0},get defaultValue(){return Te(()=>!!t.defaultValue)()?r(t.defaultValue):void 0},onChange:a=>t.onSelect?.(o(a)),get children(){var a=H5(),d=a.firstChild;return l(a,s(Ts.Indicator,{"data-slot":"radio-group-indicator"}),d),l(d,s(Oe,{get each(){return t.options},children:c=>s(Ts.Item,{get value(){return r(c)},"data-slot":"radio-group-item",get"data-value"(){return r(c)},get children(){return[s(Ts.ItemInput,{"data-slot":"radio-group-item-input"}),s(Ts.ItemLabel,{"data-slot":"radio-group-item-label",get children(){var u=U5();return l(u,()=>i(c)),u}})]}})})),a}}))}function K5(e){if(typeof document>"u")return;const t=document.createElement("button");t.type="button",t.ariaLabel=e.label,t.textContent="+",t.style.width="20px",t.style.height="20px",t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.border="none",t.style.borderRadius="var(--radius-md)",t.style.background="var(--icon-interactive-base)",t.style.color="var(--white)",t.style.boxShadow="var(--shadow-xs)",t.style.fontSize="14px",t.style.lineHeight="1",t.style.cursor="pointer",t.style.position="relative",t.style.left="30px",t.style.top="calc((var(--diffs-line-height, 24px) - 20px) / 2)";let n;const r=()=>{const a=e.getHoveredLine();a&&(n=a)},i=()=>{t.isConnected&&(r(),requestAnimationFrame(i))},o=()=>{const a=e.getHoveredLine()??n;a&&e.onSelect(a)};return requestAnimationFrame(i),t.addEventListener("mouseenter",r),t.addEventListener("mousemove",r),t.addEventListener("pointerdown",a=>{a.preventDefault(),a.stopPropagation(),r()}),t.addEventListener("mousedown",a=>{a.preventDefault(),a.stopPropagation(),r()}),t.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),o()}),t}var G5=x('<svg><path d="M16.25 3.75H3.75V16.25L6.875 14.4643H16.25V3.75Z"stroke=currentColor stroke-linecap=square></svg>',!1,!0,!1),Y5=x('<svg data-slot=line-comment-icon viewBox="0 0 20 20"fill=none aria-hidden=true>'),X5=x('<svg><path d="M10 5.41699V10.0003M10 10.0003V14.5837M10 10.0003H5.4165M10 10.0003H14.5832"stroke=currentColor stroke-linecap=square></svg>',!1,!0,!1),Z5=x("<div data-slot=line-comment-popover data-inline-body>"),Q5=x("<div data-component=line-comment data-prevent-autofocus>"),J5=x("<button type=button data-slot=line-comment-button>"),e4=x("<div data-slot=line-comment-popover>"),t4=x("<div data-slot=line-comment-tools>"),n4=x("<div data-slot=line-comment-content><div data-slot=line-comment-head><div data-slot=line-comment-text></div></div><div data-slot=line-comment-label>"),r4=x("<div data-slot=line-comment-editor><textarea data-slot=line-comment-textarea></textarea><div data-slot=line-comment-actions><div data-slot=line-comment-editor-label>"),i4=x("<button type=button data-slot=line-comment-action data-variant=ghost>"),s4=x("<button type=button data-slot=line-comment-action data-variant=primary>");Ov();function o4(e){return(()=>{var t=Y5();return l(t,s(E,{get when(){return e.icon==="comment"},get fallback(){return X5()},get children(){return G5()}})),t})()}const Cp=e=>{const t=()=>!e.inline&&e.top===void 0,n=()=>e.variant??"default",r=()=>e.icon??"comment",i=()=>e.inline&&e.hideButton;return(()=>{var o=Q5();return l(o,s(E,{get when(){return i()},get fallback(){return[(()=>{var a=J5();return Rt(a,"mouseenter",e.onMouseEnter),Rt(a,"click",e.onClick),Rt(a,"mouseup",d=>d.stopPropagation()),Rt(a,"mousedown",d=>d.stopPropagation()),l(a,s(E,{get when(){return e.inline},get fallback(){return s(Ue,{get name(){return r()==="plus"?"plus-small":"comment"},size:"small"})},get children(){return s(o4,{get icon(){return r()}})}})),G(()=>ue(a,"aria-label",e.buttonLabel)),a})(),s(E,{get when(){return e.open},get children(){var a=e4();return Rt(a,"focusout",e.onPopoverFocusOut),Rt(a,"mousedown",d=>d.stopPropagation()),l(a,()=>e.children),G(d=>Tt(a,{[e.popoverClass??""]:!!e.popoverClass},d)),a}})]},get children(){var a=Z5();return Rt(a,"focusout",e.onPopoverFocusOut),Rt(a,"mouseenter",e.onMouseEnter),Rt(a,"click",e.onClick),Rt(a,"mousedown",d=>d.stopPropagation()),l(a,()=>e.children),G(d=>Tt(a,{[e.popoverClass??""]:!!e.popoverClass},d)),a}})),G(a=>{var d=n(),c=e.id,u=e.open?"":void 0,g=e.inline?"":void 0,f={[e.class??""]:!!e.class},m=e.inline?void 0:{top:`${e.top??0}px`,opacity:t()?0:1,"pointer-events":t()?"none":"auto"};return d!==a.e&&ue(o,"data-variant",a.e=d),c!==a.t&&ue(o,"data-comment-id",a.t=c),u!==a.a&&ue(o,"data-open",a.a=u),g!==a.o&&ue(o,"data-inline",a.o=g),a.i=Tt(o,f,a.i),a.n=Pn(o,m,a.n),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),o})()},a4=e=>{const t=xn(),[n,r]=rn(e,["comment","selection","actions"]);return s(Cp,bt(r,{variant:"default",get hideButton(){return e.inline},get children(){var i=n4(),o=i.firstChild,a=o.firstChild,d=o.nextSibling;return l(a,()=>n.comment),l(o,s(E,{get when(){return n.actions},get children(){var c=t4();return l(c,()=>n.actions),c}}),null),l(d,()=>t.t("ui.lineComment.label.prefix"),null),l(d,()=>n.selection,null),l(d,()=>t.t("ui.lineComment.label.suffix"),null),i}}))},Ou=e=>{const t=xn(),[n,r]=rn(e,["value","selection","onInput","onCancel","onSubmit","placeholder","rows","autofocus","cancelLabel","submitLabel"]),i={textarea:void 0},[o,a]=ke(n.value),d=()=>i.textarea?.focus(),c=f=>{f.preventDefault(),f.stopPropagation()},u=f=>m=>{m.stopPropagation(),f()};$e(()=>{a(n.value)});const g=()=>{const f=o().trim();f&&n.onSubmit(f)};return Mn(()=>{n.autofocus!==!1&&requestAnimationFrame(d)}),s(Cp,bt(r,{open:!0,variant:"editor",get hideButton(){return e.inline},onClick:()=>d(),get children(){var f=r4(),m=f.firstChild,p=m.nextSibling,w=p.firstChild;return Rt(m,"keydown",h=>{const k=h;if(!(k.isComposing||k.keyCode===229)){if(k.stopPropagation(),h.key==="Escape"){k.preventDefault(),h.currentTarget.blur(),n.onCancel();return}h.key==="Enter"&&(h.shiftKey||(k.preventDefault(),g()))}}),Rt(m,"input",h=>{const k=h.currentTarget.value;a(k),n.onInput(k)}),Lt(h=>{i.textarea=h},m),l(w,()=>t.t("ui.lineComment.editorLabel.prefix"),null),l(w,()=>n.selection,null),l(w,()=>t.t("ui.lineComment.editorLabel.suffix"),null),l(p,s(E,{get when(){return!e.inline},get fallback(){return[(()=>{var h=i4();return Rt(h,"click",u(n.onCancel)),Rt(h,"mousedown",c),l(h,()=>n.cancelLabel??t.t("ui.common.cancel")),h})(),(()=>{var h=s4();return Rt(h,"click",u(g)),Rt(h,"mousedown",c),l(h,()=>n.submitLabel??t.t("ui.lineComment.submit")),G(()=>h.disabled=o().trim().length===0),h})()]},get children(){return[s(kt,{size:"small",variant:"ghost",get onClick(){return n.onCancel},get children(){return n.cancelLabel??t.t("ui.common.cancel")}}),s(kt,{size:"small",variant:"primary",get disabled(){return o().trim().length===0},onClick:g,get children(){return n.submitLabel??t.t("ui.lineComment.submit")}})]}}),null),G(h=>{var k=n.rows??3,v=n.placeholder??t.t("ui.lineComment.placeholder");return k!==h.e&&ue(m,"rows",h.e=k),v!==h.t&&ue(m,"placeholder",h.t=v),h},{e:void 0,t:void 0}),G(()=>m.value=o()),f}}))};function l4(e){const t=new Map,n=a=>{if(typeof document>"u")return;const d=document.createElement("div");d.setAttribute("data-prevent-autofocus","");const[c,u]=ke(a),g=Nv(()=>{const m=c();if(m.kind==="comment"){const w=T(()=>{const h=c();return h.kind!=="comment"?e.renderComment(m.comment):e.renderComment(h.comment)});return s(E,{get when(){return w().editor},get fallback(){return s(a4,{inline:!0,get id(){return w().id},get open(){return w().open},get comment(){return w().comment},get selection(){return w().selection},get actions(){return w().actions},get onClick(){return w().onClick},get onMouseEnter(){return w().onMouseEnter}})},get children(){return s(Ou,{inline:!0,get id(){return w().id},get value(){return w().editor.value},get selection(){return w().editor.selection},get onInput(){return w().editor.onInput},get onCancel(){return w().editor.onCancel},get onSubmit(){return w().editor.onSubmit},get onPopoverFocusOut(){return w().editor.onPopoverFocusOut},get cancelLabel(){return w().editor.cancelLabel},get submitLabel(){return w().editor.submitLabel}})}})}const p=T(()=>{const w=c();return w.kind!=="draft"?e.renderDraft(m.range):e.renderDraft(w.range)});return s(Ou,{inline:!0,get value(){return p().value},get selection(){return p().selection},get onInput(){return p().onInput},get onCancel(){return p().onCancel},get onSubmit(){return p().onSubmit},get onPopoverFocusOut(){return p().onPopoverFocusOut}})},d),f={host:d,dispose:g,setMeta:u};return t.set(a.key,f),f};return{render:a=>{const d=a.metadata,c=t.get(d.key)??n(d);if(c)return c.setMeta(d),c.host},reconcile:a=>{const d=new Set(a.map(c=>c.metadata.key));for(const[c,u]of t)d.has(c)||(u.dispose(),t.delete(c))},cleanup:()=>{for(const[,a]of t)a.dispose();t.clear()}}}function c4(e){const[t,n]=St({draft:"",editing:null}),r=()=>t.draft,i=y=>n("draft",y),o=()=>t.editing,a=y=>n("editing",typeof y=="function"?()=>y:y),d=y=>y?rs(y):null,c=y=>{const b=d(y);return e.setSelected(b),e.syncSelected?.(d(b)),b},u=y=>{const b=d(y);return e.setCommenting(b),b},g=()=>{e.setOpened(null)},f=()=>{i(""),a(null),u(null)},m=()=>{i(""),a(null),e.setOpened(null),e.setSelected(null),e.setCommenting(null)},p=(y,b,_)=>{_?.cancelDraft&&f(),e.setOpened(y),c(b)},w=(y,b,_)=>{_?.cancelDraft&&f();const $=e.opened()===y?null:y;e.setOpened($),c(b)},h=y=>{const b=d(y);i(""),a(null),g(),c(b),u(b)},k=(y,b,_)=>{g(),c(b),e.setCommenting(null),a(y),i(_)},v=y=>{const b=d(y);if(b){if(e.hoverSelected){e.hoverSelected(b);return}c(b)}},C=y=>{g(),c(y),f()};return $e(()=>{e.commenting(),i("")}),{draft:r,setDraft:i,editing:o,opened:e.opened,selected:e.selected,commenting:e.commenting,isOpen:y=>e.opened()===y,isEditing:y=>o()===y,closeComment:g,openComment:p,toggleComment:w,openDraft:h,openEditor:k,hoverComment:v,cancelDraft:f,finishSelection:C,select:c,reset:m}}function Sp(e){const t=xn(),n=c4(e.state),r="getSide"in e?Nu({comments:e.comments,getCommentId:u=>u.id,getCommentSelection:u=>u.selection,draftRange:n.commenting,draftKey:e.draftKey,getSide:e.getSide}):Nu({comments:e.comments,getCommentId:u=>u.id,getCommentSelection:u=>u.selection,draftRange:n.commenting,draftKey:e.draftKey}),{renderAnnotation:i}=d4({annotations:r,renderComment:u=>{const g=()=>n.openEditor(u.id,u.selection,u.comment),f=()=>{n.reset(),e.onDelete?.(u)};return{id:u.id,get open(){return n.isOpen(u.id)||n.isEditing(u.id)},comment:u.comment,selection:Da(u.selection,t.t),get actions(){return e.renderCommentActions?.(u,{edit:g,remove:f})},get editor(){return n.isEditing(u.id)?{get value(){return n.draft()},selection:Da(u.selection,t.t),onInput:n.setDraft,onCancel:n.cancelDraft,onSubmit:m=>{e.onUpdate?.({id:u.id,comment:m,selection:rs(u.selection)}),n.cancelDraft()},submitLabel:e.editSubmitLabel}:void 0},onMouseEnter:()=>n.hoverComment(u.selection),onClick:()=>{n.isEditing(u.id)||n.toggleComment(u.id,u.selection,{cancelDraft:e.cancelDraftOnCommentToggle})}}},renderDraft:u=>({get value(){return n.draft()},selection:Da(u,t.t),onInput:n.setDraft,onCancel:n.cancelDraft,onSubmit:g=>{e.onSubmit({comment:g,selection:rs(u)}),n.cancelDraft()},onPopoverFocusOut:e.onDraftPopoverFocusOut})}),o=u4({label:e.label,getSelectedRange:()=>n.opened()?null:e.getHoverSelectedRange?.()??n.selected(),onOpenDraft:n.openDraft});return{note:n,annotations:r,renderAnnotation:i,renderHoverUtility:o,onLineSelected:u=>{if(!u){n.select(null),n.cancelDraft();return}n.select(u)},onLineSelectionEnd:u=>{if(!u){e.clearSelectionOnSelectionEndNull&&n.select(null),n.cancelDraft();return}n.finishSelection(u)},onLineNumberSelectionEnd:u=>{u&&n.openDraft(u)}}}function Nu(e){const t=n=>Math.max(n.start,n.end);return"getSide"in e?T(()=>{const n=e.comments().map(i=>{const o=e.getCommentSelection(i);return{side:e.getSide(o),lineNumber:t(o),metadata:{kind:"comment",key:`comment:${e.getCommentId(i)}`,comment:i}}}),r=e.draftRange();return r?[...n,{side:e.getSide(r),lineNumber:t(r),metadata:{kind:"draft",key:`draft:${e.draftKey()}`,range:r}}]:n}):T(()=>{const n=e.comments().map(o=>{const a=e.getCommentSelection(o);return{lineNumber:t(a),metadata:{kind:"comment",key:`comment:${e.getCommentId(o)}`,comment:o}}}),r=e.draftRange();if(!r)return n;const i={lineNumber:t(r),metadata:{kind:"draft",key:`draft:${e.draftKey()}`,range:r}};return[...n,i]})}function d4(e){const t=l4({renderComment:e.renderComment,renderDraft:e.renderDraft});return $e(()=>{t.reconcile(e.annotations())}),vt(()=>{t.cleanup()}),{renderAnnotation:t.render}}function u4(e){return t=>K5({label:e.label,getHoveredLine:t,onSelect:n=>{const r=e.getSelectedRange();if(r&&Bv(r,n.lineNumber,n.side)){e.onOpenDraft(rs(r));return}const i={start:n.lineNumber,end:n.lineNumber};n.side&&(i.side=n.side),e.onOpenDraft(i)}})}var f4=x("<div>"),g4=x("<div class=h-4 aria-hidden=true>"),m4=x("<div class=pb-6>"),h4=x("<div data-slot=session-review-container>"),p4=x("<div data-component=session-review><div data-slot=session-review-header><div data-slot=session-review-title></div><div data-slot=session-review-actions>"),v4=x("<span data-slot=session-review-directory>"),b4=x("<button data-slot=session-review-view-button type=button>"),x4=x("<div data-slot=session-review-change-group data-type=added><span data-slot=session-review-change data-type=added>"),y4=x("<span data-slot=session-review-change data-type=removed>"),w4=x("<span data-slot=session-review-change data-type=modified>"),$4=x("<div data-slot=session-review-trigger-content><div data-slot=session-review-file-info><div data-slot=session-review-file-name-container><span data-slot=session-review-filename></span></div></div><div data-slot=session-review-trigger-actions><span data-slot=session-review-diff-chevron>"),k4=x("<div data-slot=session-review-large-diff><div data-slot=session-review-large-diff-title></div><div data-slot=session-review-large-diff-meta></div><div data-slot=session-review-large-diff-actions>"),_4=x("<div data-slot=session-review-diff-wrapper>");const Bu=500;function C4(e){return(()=>{var t=f4();return t.$$click=n=>n.stopPropagation(),t.$$mousedown=n=>n.stopPropagation(),l(t,s(Ye,{gutter:4,placement:"bottom-end",get children(){return[s(Ye.Trigger,{as:Ot,icon:"dot-grid",variant:"ghost",size:"small",class:"size-6 rounded-md",get"aria-label"(){return e.labels.moreLabel}}),s(Ye.Portal,{get children(){return s(Ye.Content,{get children(){return[s(Ye.Item,{get onSelect(){return e.onEdit},get children(){return s(Ye.ItemLabel,{get children(){return e.labels.editLabel}})}}),s(Ye.Item,{get onSelect(){return e.onDelete},get children(){return s(Ye.ItemLabel,{get children(){return e.labels.deleteLabel}})}})]}})}})]}})),t})()}function S4(e){const t=da(e);if(t)return`session-review-diff-${t}`}const T4=e=>{let t,n=0;const r=24,i=xn(),o=cs(),[a,d]=St({open:[],force:{},selection:null,commenting:null,opened:null,count:r,loader:void 0}),c=new Map,u=()=>a.selection,g=()=>a.commenting,f=()=>a.opened,m=()=>e.open??a.open,p=T(()=>e.diffs.map(S=>S.file)),w=T(()=>new Map(e.diffs.map(S=>[S.file,S]))),h=T(()=>{const S=new Map;for(const M of e.comments??[]){const A=S.get(M.file);if(A){A.push(M);continue}S.set(M.file,[M])}return S}),k=T(()=>p().slice(0,a.count)),v=T(()=>new Map(p().map((S,M)=>[S,M]))),C=T(()=>new Set(m())),y=()=>e.diffStyle??(e.split?"split":"unified"),b=()=>p().length>0,_=()=>a.count<p().length,$=S=>{const M=v().get(S);M!==void 0&&(M<a.count||d("count",Math.min(p().length,M+r)))},D=()=>{_()&&d("count",Math.min(p().length,a.count+r))},L=S=>{const M=e.onScroll;typeof M=="function"&&M(S);const A=S.currentTarget;_()&&(A.scrollTop+A.clientHeight<A.scrollHeight-600||D())},V=S=>{e.onOpenChange?.(S),e.open===void 0&&d("open",S)},K=()=>{const S=m().length>0?[]:p();V(S)},I=()=>i.t("ui.sessionReview.openFile"),U=S=>S.endSide??S.side??"additions",Y=(S,M)=>{const F=U(M)==="deletions"?S.before:S.after;if(!(typeof F!="string"||F.length===0))return ha(F,M)};return $e(()=>{const S=e.focusedComment;S&&kr(()=>{$(S.file),n++;const M=n;d("opened",S);const A=(e.comments??[]).find(X=>X.file===S.file&&X.id===S.id);A&&d("selection",{file:A.file,range:rs(A.selection)});const F=m();F.includes(S.file)||V([...F,S.file]);const N=X=>{if(M!==n)return;const B=t;if(!B)return;const O=c.get(S.file),z=O?.querySelector(`[data-comment-id="${S.id}"]`),q=z instanceof HTMLElement&&z.style.pointerEvents!=="none"&&z.style.opacity!=="0",Q=q?z:O;if(!Q){if(X>=120)return;requestAnimationFrame(()=>N(X+1));return}const j=B.getBoundingClientRect(),H=Q.getBoundingClientRect(),J=H.top-j.top,le=B.scrollTop+J-j.height/2+H.height/2;B.scrollTop=Math.max(0,le),!q&&(X>=120||requestAnimationFrame(()=>N(X+1)))};requestAnimationFrame(()=>N(0)),requestAnimationFrame(()=>e.onFocusedCommentChange?.(null))})}),$e(()=>{const S=t,M=a.loader;if(!S||!M||!_()||typeof IntersectionObserver>"u")return;const A=new IntersectionObserver(F=>{F.some(N=>N.isIntersecting)&&D()},{root:S,rootMargin:"800px 0px",threshold:0});A.observe(M),vt(()=>A.disconnect())}),$e(()=>{e.focusedFile&&$(e.focusedFile)}),(()=>{var S=p4(),M=S.firstChild,A=M.firstChild,F=A.nextSibling;return l(A,(()=>{var N=Te(()=>e.title===void 0);return()=>N()?i.t("ui.sessionReview.title"):e.title})()),l(F,s(E,{get when(){return Te(()=>!!b())()&&e.onDiffStyleChange},get children(){return s(W5,{options:["unified","split"],get current(){return y()},size:"small",value:N=>N,label:N=>i.t(N==="unified"?"ui.sessionReview.diffStyle.unified":"ui.sessionReview.diffStyle.split"),onSelect:N=>N&&e.onDiffStyleChange?.(N)})}}),null),l(F,s(E,{get when(){return b()},get children(){return s(kt,{size:"small",icon:"chevron-grabber-vertical",class:"w-[106px] justify-start",onClick:K,get children(){return s(Dn,{get children(){return[s(ot,{get when(){return m().length>0},get children(){return i.t("ui.sessionReview.collapseAll")}}),s(ot,{when:!0,get children(){return i.t("ui.sessionReview.expandAll")}})]}})}})}}),null),l(F,()=>e.actions,null),l(S,s(ba,{"data-slot":"session-review-scroll",viewportRef:N=>{t=N,d("loader",void 0),e.scrollRef?.(N)},onScroll:L,get classList(){return{[e.classes?.root??""]:!!e.classes?.root}},get children(){var N=h4();return l(N,s(E,{get when(){return b()},get fallback(){return e.empty},get children(){var X=m4();return l(X,s(Bn,{multiple:!0,get value(){return m()},onChange:V,get children(){return[s(Oe,{get each(){return k()},children:B=>{const O=T(()=>w().get(B)),z=()=>C().has(B),q=()=>!!a.force[B],Q=T(()=>h().get(B)??[]),j=T(()=>Q().map(ee=>ee.selection)),H=()=>typeof O().before=="string"?O().before:"",J=()=>typeof O().after=="string"?O().after:"",le=()=>O().additions+O().deletions,de=T(()=>qv(B)),Re=T(()=>!z()||q()||de()?!1:le()>Bu),Ve=()=>O().status==="added"||H().length===0&&J().length>0,Z=()=>O().status==="deleted"||J().length===0&&H().length>0,ne=T(()=>{const ee=u();return!ee||ee.file!==B?null:ee.range}),re=T(()=>{const ee=g();return!ee||ee.file!==B?null:ee.range}),ie=Sp({comments:Q,label:i.t("ui.lineComment.submit"),draftKey:()=>B,state:{opened:()=>{const ee=f();return!ee||ee.file!==B?null:ee.id},setOpened:ee=>d("opened",ee?{file:B,id:ee}:null),selected:ne,setSelected:ee=>d("selection",ee?{file:B,range:ee}:null),commenting:re,setCommenting:ee=>d("commenting",ee?{file:B,range:ee}:null)},getSide:U,clearSelectionOnSelectionEndNull:!1,onSubmit:({comment:ee,selection:_e})=>{e.onLineComment?.({file:B,selection:_e,comment:ee,preview:Y(O(),_e)})},onUpdate:({id:ee,comment:_e,selection:xe})=>{e.onLineCommentUpdate?.({id:ee,file:B,selection:xe,comment:_e,preview:Y(O(),xe)})},onDelete:ee=>{e.onLineCommentDelete?.({id:ee.id,file:B})},editSubmitLabel:e.lineCommentActions?.saveLabel,renderCommentActions:e.lineCommentActions?(ee,_e)=>s(C4,{get labels(){return e.lineCommentActions},get onEdit(){return _e.edit},get onDelete(){return _e.remove}}):void 0});vt(()=>{c.delete(B)});const be=ee=>{e.onLineComment&&ie.onLineSelected(ee)},Fe=ee=>{e.onLineComment&&ie.onLineSelectionEnd(ee)};return s(Bn.Item,{value:B,get id(){return S4(B)},"data-file":B,"data-slot":"session-review-accordion-item",get"data-selected"(){return e.focusedFile===B?"":void 0},get children(){return[s(oo,{get children(){return s(Bn.Trigger,{get children(){var ee=$4(),_e=ee.firstChild,xe=_e.firstChild,ye=xe.firstChild,Le=_e.nextSibling,tt=Le.firstChild;return l(_e,s(cr,{node:{path:B,type:"file"}}),xe),l(xe,s(E,{get when(){return B.includes("/")},get children(){var ge=v4();return l(ge,()=>`‪${ls(B)}‬`),ge}}),ye),l(ye,()=>Sn(B)),l(xe,s(E,{get when(){return e.onViewFile},get children(){return s(Nn,{get value(){return I()},placement:"top",gutter:4,get children(){var ge=b4();return ge.$$click=qe=>{qe.stopPropagation(),e.onViewFile?.(B)},l(ge,s(Ue,{name:"open-file",size:"small"})),G(()=>ue(ge,"aria-label",I())),ge}})}}),null),l(Le,s(Dn,{get children(){return[s(ot,{get when(){return Ve()},get children(){var ge=x4(),qe=ge.firstChild;return l(qe,()=>i.t("ui.sessionReview.change.added")),l(ge,s(Vr,{get changes(){return O()}}),null),ge}}),s(ot,{get when(){return Z()},get children(){var ge=y4();return l(ge,()=>i.t("ui.sessionReview.change.removed")),ge}}),s(ot,{get when(){return!!de()},get children(){var ge=w4();return l(ge,()=>i.t("ui.sessionReview.change.modified")),ge}}),s(ot,{when:!0,get children(){return s(Vr,{get changes(){return O()}})}})]}}),tt),l(tt,s(Ue,{name:"chevron-down",size:"small"})),ee}})}}),s(Bn.Content,{"data-slot":"session-review-accordion-content",get children(){var ee=_4();return Lt(_e=>{c.set(B,_e)},ee),l(ee,s(E,{get when(){return z()},get children(){return s(Dn,{get children(){return[s(ot,{get when(){return Re()},get children(){var _e=k4(),xe=_e.firstChild,ye=xe.nextSibling,Le=ye.nextSibling;return l(xe,()=>i.t("ui.sessionReview.largeDiff.title")),l(ye,()=>i.t("ui.sessionReview.largeDiff.meta",{limit:Bu.toLocaleString(),current:le().toLocaleString()})),l(Le,s(kt,{size:"normal",variant:"secondary",onClick:()=>d("force",B,!0),get children(){return i.t("ui.sessionReview.largeDiff.renderAnyway")}})),_e}}),s(ot,{when:!0,get children(){return s(Or,{component:o,mode:"diff",get preloadedDiff(){return O().preloaded},get diffStyle(){return y()},onRendered:()=>{e.onDiffRendered?.()},get enableLineSelection(){return e.onLineComment!=null},get enableHoverUtility(){return e.onLineComment!=null},onLineSelected:be,onLineSelectionEnd:Fe,get onLineNumberSelectionEnd(){return ie.onLineNumberSelectionEnd},get annotations(){return ie.annotations()},get renderAnnotation(){return ie.renderAnnotation},get renderHoverUtility(){return Te(()=>!!e.onLineComment)()?ie.renderHoverUtility:void 0},get selectedLines(){return ne()},get commentedLines(){return j()},get before(){return{name:B,contents:typeof O().before=="string"?O().before:""}},get after(){return{name:B,contents:typeof O().after=="string"?O().after:""}},get media(){return{mode:"auto",path:B,before:O().before,after:O().after,readFile:e.readFile}}})}})]}})}})),ee}})]}})}}),s(E,{get when(){return _()},get children(){var B=g4();return Lt(O=>{d("loader",O)},B),B}})]}})),X}})),G(()=>Ht(N,e.classes?.container)),N}}),null),G(N=>{var X=e.class,B=e.classList,O=e.classes?.header;return X!==N.e&&Ht(S,N.e=X),N.t=Tt(S,B,N.t),O!==N.a&&Ht(M,N.a=O),N},{e:void 0,t:void 0,a:void 0}),S})()};Kt(["mousedown","click"]);function A4(e){let t,n,r=!1,i;const o=zn(),a=Hr(),d=async m=>o.client.file.read({path:m}).then(p=>p.data).catch(p=>{console.debug("[session-review] failed to read file",{path:m,error:p})}),c=()=>{r=!0,n!==void 0&&(cancelAnimationFrame(n),n=void 0)},u=()=>{n=void 0;const m=t;if(!m||!a.ready()||r||m.clientHeight===0||m.clientWidth===0)return;const p=e.view().scroll("review");if(!p||p.x===0&&p.y===0)return;const w=Math.max(0,m.scrollHeight-m.clientHeight),h=Math.max(0,m.scrollWidth-m.clientWidth),k=Math.min(p.y,w),v=Math.min(p.x,h);m.scrollTop===k&&m.scrollLeft===v||(m.scrollTop!==k&&(m.scrollTop=k),m.scrollLeft!==v&&(m.scrollLeft=v),i={x:m.scrollLeft,y:m.scrollTop})},g=()=>{r||n!==void 0||(n=requestAnimationFrame(u))},f=m=>{const p=m.currentTarget,w=i;if(w&&p.scrollTop===w.y&&p.scrollLeft===w.x){i=void 0;return}i=void 0,c(),a.ready()&&(p.clientHeight===0||p.clientWidth===0||e.view().setScroll("review",{x:p.scrollLeft,y:p.scrollTop}))};return $e(()=>{e.diffs().length,e.diffStyle,a.ready()&&g()}),vt(()=>{n!==void 0&&cancelAnimationFrame(n),t&&(t.removeEventListener("wheel",c,{capture:!0}),t.removeEventListener("mousewheel",c,{capture:!0}),t.removeEventListener("pointerdown",c,{capture:!0}),t.removeEventListener("touchstart",c,{capture:!0}),t.removeEventListener("keydown",c,{capture:!0}))}),s(T4,{get title(){return e.title},get empty(){return e.empty},scrollRef:m=>{t=m,m.addEventListener("wheel",c,{passive:!0,capture:!0}),m.addEventListener("mousewheel",c,{passive:!0,capture:!0}),m.addEventListener("pointerdown",c,{passive:!0,capture:!0}),m.addEventListener("touchstart",c,{passive:!0,capture:!0}),m.addEventListener("keydown",c,{passive:!0,capture:!0}),e.onScrollRef?.(m),g()},onScroll:f,onDiffRendered:g,get open(){return e.view().review.open()},get onOpenChange(){return e.view().review.setOpen},get classes(){return{root:e.classes?.root??"pr-3",header:e.classes?.header??"px-3",container:e.classes?.container??"pl-3"}},get diffs(){return e.diffs()},get diffStyle(){return e.diffStyle},get onDiffStyleChange(){return e.onDiffStyleChange},get onViewFile(){return e.onViewFile},get focusedFile(){return e.focusedFile},readFile:d,get onLineComment(){return e.onLineComment},get onLineCommentUpdate(){return e.onLineCommentUpdate},get onLineCommentDelete(){return e.onLineCommentDelete},get lineCommentActions(){return e.lineCommentActions},get comments(){return e.comments},get focusedComment(){return e.focusedComment},get onFocusedCommentChange(){return e.onFocusedCommentChange}})}const D4=(e,t)=>{e.session.restore(t)},M4=e=>{const t=e.lastIndexOf(".");return t<=0?{base:e,ext:""}:{base:e.slice(0,t),ext:e.slice(t)}};function qu(e,t){if(!t.has(e))return e;const{base:n,ext:r}=M4(e);for(let i=1;i<1e4;i++){const o=`${n} (${i})${r}`;if(!t.has(o))return o}return`${n} (${Date.now()})${r}`}function E4(e,t){const n=e.replace(/^\/+|\/+$/g,""),r=t.replace(/^\/+|\/+$/g,"");return n===""?r!=="":n===r?!0:r.startsWith(n+"/")}const I4=e=>new Promise((t,n)=>{const r=e.createReader?.();if(!r)return t([]);const i=[],o=()=>{r.readEntries(a=>{if(a.length===0)return t(i);i.push(...a),o()},a=>n(a))};o()}),L4=e=>new Promise(t=>{if(!e.file)return t(void 0);e.file(n=>t(n),()=>t(void 0))});async function*Tp(e,t){if(e.isFile){const i=await L4(e);if(!i)return;yield{relPath:t?`${t}/${e.name}`:e.name,file:i};return}if(!e.isDirectory)return;const n=t?`${t}/${e.name}`:e.name,r=await I4(e);for(const i of r)yield*Tp(i,n)}async function*P4(e){for(let t=0;t<e.length;t++){const n=e[t];if(!n||n.kind!=="file")continue;const r=n.webkitGetAsEntry?.()??n.getAsEntry?.()??null;if(r){yield*Tp(r,"");continue}const i=n.getAsFile?.();i&&(yield{relPath:i.name,file:i})}}const Ya=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)},ju=e=>{const t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)},Ap=e=>{const t=e.indexOf("/");return t===-1?e:e.slice(0,t)},F4=(e,t)=>{const n=Ap(e),r=t.get(n);return!r||r===n?e:r+e.slice(n.length)};function R4(){const e=yr(),t=zn(),[n,r]=ke(),i=async(g,f,m,p)=>{const w=Ap(g.relPath);if(!m.has(w)){const L=qu(w,p);m.set(w,L),p.add(L)}const h=F4(g.relPath,m),k=Ya(h),v=f?k?`${f}/${k}`:f:k,C=ju(h),y=new URL("/file/upload",t.url);t.directory&&y.searchParams.set("directory",t.directory);const b=new FormData;b.append("path",v),b.append("name",C),b.append("file",g.file,C);const _=await t.fetch(y,{method:"POST",body:b});if(!_.ok)throw new Error(await _.text().catch(()=>`HTTP ${_.status}`));const $=_.headers.get("content-type")??"";if(!$.includes("application/json"))throw new Error(`upload route missing on server (got ${$||"no content-type"})`);const D=await _.json().catch(()=>null);if(!D||typeof D.path!="string")throw new Error("upload route returned an unexpected payload")},o=async(g,f)=>{const m=new Set(e.tree.children(g).map(C=>C.name)),p=new Map;let w=0,h=0;const k=(()=>{if("length"in f&&f.length>0&&"kind"in f[0])return P4(f);const C=f;return(async function*(){for(let y=0;y<C.length;y++){const b=C.item(y);b&&(yield{relPath:b.name,file:b})}})()})();for await(const C of k)try{await i(C,g,p,m),w++}catch(y){console.error("[file-tree-drop] upload failed",C.relPath,y),h++}w>0&&await e.tree.refresh(g);const v=g?`/${g}`:"workspace root";h===0&&w>0?nt({variant:"success",title:`Added ${w} file${w===1?"":"s"} to ${v}`}):w>0?nt({variant:"default",title:`Added ${w} file${w===1?"":"s"}, ${h} failed`}):h>0&&nt({variant:"error",title:"Upload failed"})},a=async(g,f)=>{if(!g||Ya(g)===f)return;if(E4(g,f)){nt({variant:"error",title:"Cannot move a folder into itself"});return}const m=new Set(e.tree.children(f).map(h=>h.name)),p=qu(ju(g),m),w=f?`${f}/${p}`:p;try{await t.client.file.rename({from:g,to:w}),await Promise.all([e.tree.refresh(Ya(g)),e.tree.refresh(f)])}catch(h){const k=h instanceof Error?h.message:String(h);nt({variant:"error",title:"Move failed",description:k})}};return{hovered:n,setHovered:r,handleDragOver:(g,f)=>{const m=f.dataTransfer?.types;if(!m)return;const p=m.includes("Files"),w=m.includes("text/plain");!p&&!w||(f.preventDefault(),f.stopPropagation(),f.dataTransfer&&(f.dataTransfer.dropEffect=p?"copy":"move"),n()!==g&&r(g))},handleDragLeave:g=>{const f=g.relatedTarget;if(f instanceof Node){const m=g.currentTarget?.closest('[data-component="filetree-root"]');if(m&&m.contains(f))return}r(void 0)},handleDrop:async(g,f)=>{f.preventDefault(),f.stopPropagation(),r(void 0);const m=f.dataTransfer;if(!m)return;const p=(()=>{try{return m.getData("text/plain")}catch{return""}})();if(p?.startsWith("file:")){const w=p.slice(5);await a(w,g);return}if(m.items&&m.items.length>0){await o(g,m.items);return}m.files&&m.files.length>0&&await o(g,m.files)}}}var z4=x("<span>"),O4=x('<span class="shrink-0 w-4 text-center text-12-medium">'),N4=x('<div class="shrink-0 size-1.5 mr-1.5 rounded-full">'),B4=x("<div data-component=filetree>"),q4=x('<div class="size-4 flex items-center justify-center text-icon-weak">'),j4=x("<div>"),V4=x('<div class="w-5 shrink-0">'),H4=x('<span class="filetree-iconpair size-4">'),U4=x('<div class="px-2 py-1 text-12-regular text-text-weak">...');const W4=128;function K4(e){return`file://${dl(e)}`}function G4(e){return!(e.level!==0||e.dir?.loaded||e.dir?.loading)}function Y4(e){return e.level!==0?[]:e.filter?[...e.filter.dirs].filter(t=>!e.expanded(t)):[]}const X4=e=>e==="add"?"A":e==="del"?"D":"M",Rl=e=>e==="add"?"color: var(--icon-diff-add-base)":e==="del"?"color: var(--icon-diff-delete-base)":"color: var(--icon-diff-modified-base)",Z4=e=>e==="add"?"background-color: var(--icon-diff-add-base)":e==="del"?"background-color: var(--icon-diff-delete-base)":"background-color: var(--icon-diff-modified-base)",Dp=(e,t,n)=>{const r=t?.get(e.path);if(r&&n?.has(e.path))return r},Q4=e=>{const t=e.querySelector('[data-component="file-icon"]')??e.querySelector("svg"),n=e.querySelector("span");if(!t||!n)return;const r=document.createElement("div");return r.className="flex items-center gap-x-2 px-2 py-1 bg-surface-raised-base rounded-md border border-border-base text-12-regular text-text-strong",r.style.position="absolute",r.style.top="-1000px",r.innerHTML=t.outerHTML+n.outerHTML,r},J4=e=>{const t=Q4(e.currentTarget);t&&(document.body.appendChild(t),e.dataTransfer?.setDragImage(t,0,12),setTimeout(()=>document.body.removeChild(t),0))},Vu=e=>{const[t,n]=rn(e,["node","level","active","nodeClass","draggable","kinds","marks","as","children","class","classList","dropHovered"]),r=()=>Dp(t.node,t.kinds,t.marks),i=()=>!!r()&&!t.node.ignored,o=()=>{const a=r();if(a)return Rl(a)};return s(Or,bt({get component(){return t.as??"div"},get"data-file-path"(){return Te(()=>t.node.type==="file")()?t.node.path:void 0},get classList(){return{"w-full min-w-0 h-6 flex items-center justify-start gap-x-1.5 rounded-md px-1.5 py-0 text-left hover:bg-surface-raised-base-hover active:bg-surface-base-active transition-colors cursor-pointer":!0,"bg-surface-base-active":t.node.path===t.active,"opacity-60":t.node.name.startsWith("."),"ring-1 ring-border-strong-base/70 bg-surface-base-active/60":!!t.dropHovered,...t.classList??{},[t.class??""]:!!t.class,[t.nodeClass??""]:!!t.nodeClass}},get style(){return`padding-left: ${Math.max(0,8+t.level*22-(t.node.type==="file"?20:4))}px`},get draggable(){return t.draggable},onDragStart:a=>{t.draggable&&(a.dataTransfer?.setData("text/plain",`file:${t.node.path}`),a.dataTransfer?.setData("text/uri-list",K4(t.node.path)),a.dataTransfer&&(a.dataTransfer.effectAllowed="copy"),J4(a))}},n,{get children(){return[Te(()=>t.children),(()=>{var a=z4();return l(a,()=>t.node.name),G(d=>{var c={"flex-1 min-w-0 text-12-medium whitespace-nowrap truncate":!0,"text-text-weaker":t.node.ignored||e.isEmpty,"text-text-weak":!t.node.ignored&&!i()&&!e.isEmpty},u=i()?o():void 0;return d.e=Tt(a,c,d.e),d.t=Pn(a,u,d.t),d},{e:void 0,t:void 0}),a})(),Te(()=>(()=>{const a=r();return a?t.node.type==="file"?(()=>{var d=O4();return l(d,()=>X4(a)),G(c=>Pn(d,Rl(a),c)),d})():(()=>{var d=N4();return G(c=>Pn(d,Z4(a),c)),d})():null})())]}}))};function Mp(e){const t=yr(),n=e.level??0,r=()=>e.draggable??!0;let i,o;const a=n===0?e._drop??R4():e._drop,d=v=>{const C=v.lastIndexOf("/");return C===-1?"":v.slice(0,C)},c=v=>t.normalize(v).replace(/[\\/]+$/,"").replaceAll("\\","/"),u=e._chain?[...e._chain,c(e.path)]:[c(e.path)],g=T(()=>{if(e._filter)return e._filter;const v=e.allowed;if(!v)return;const C=new Set(v),y=new Set;for(const b of v){const $=b.split("/").slice(0,-1);for(const[D]of $.entries()){const L=$.slice(0,D+1).join("/");L&&y.add(L)}}return{files:C,dirs:y}}),f=T(()=>{if(e._marks)return e._marks;const v=new Set;for(const C of e.modified??[])v.add(C);for(const C of e.kinds?.keys()??[])v.add(C);if(v.size!==0)return v}),m=T(()=>e._kinds?e._kinds:e.kinds),p=T(()=>{if(e._deeps)return e._deeps;const v=new Map,C=e.path;if(!(t.tree.state(C)?.expanded??!1))return v;const y=new Set,b=[],_=($,D)=>{const L=c($);if(y.has(L))return;y.add(L);const V=t.tree.children($).filter(K=>K.type==="directory"&&(t.tree.state(K.path)?.expanded??!1)).map(K=>K.path);b.push({dir:$,lvl:D,i:0,kids:V,max:D})};for(_(C,n-1);b.length>0;){const $=b[b.length-1];if($.i<$.kids.length){const L=$.kids[$.i];$.i++,_(L,$.lvl+1);continue}v.set($.dir,$.max),b.pop();const D=b[b.length-1];D&&(D.max=Math.max(D.max,$.max))}return v});$e(()=>{const v=g(),C=Y4({level:n,filter:v,expanded:y=>kr(()=>t.tree.state(y)?.expanded)??!1});for(const y of C)t.tree.expand(y)}),$e(Pt(()=>e.path,v=>{const C=kr(()=>t.tree.state(v));G4({level:n,dir:C})&&t.tree.list(v)},{defer:!1})),$e(Pt(()=>{const v=e.active;if(n!==0||!v)return"";const C=v.split("/").slice(0,-1),y=C.at(-1)??"",b=C.map((_,$)=>{const D=C.slice(0,$+1).join("/"),L=t.tree.state(D);return`${D}:${L?.expanded?1:0}:${L?.loaded?1:0}:${L?.loading?1:0}`});return[v,y,t.tree.children(y).length,...b].join("|")},()=>{const v=e.active;if(n!==0||!v)return;const C=v.split("/").slice(0,-1);for(const[y]of C.entries()){const b=C.slice(0,y+1).join("/");b&&t.tree.expand(b)}typeof window>"u"||(o!==void 0&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=void 0;const y=i?.querySelectorAll("[data-file-path]"),b=Array.from(y??[]).find(_=>_.getAttribute("data-file-path")===v);b instanceof HTMLElement&&b.scrollIntoView({block:"nearest",behavior:"smooth"})}))},{defer:!0})),vt(()=>{o!==void 0&&cancelAnimationFrame(o)});const w=T(()=>{const v=t.tree.children(e.path),C=g();if(!C)return v;const y=D=>{const L=D.lastIndexOf("/");return L===-1?"":D.slice(0,L)},b=D=>{const L=D.lastIndexOf("/");return L===-1?D:D.slice(L+1)},_=v.filter(D=>D.type==="file"?C.files.has(D.path):C.dirs.has(D.path)),$=new Set(_.map(D=>D.path));for(const D of C.dirs)y(D)===e.path&&($.has(D)||(_.push({name:b(D),path:D,absolute:D,type:"directory",ignored:!1}),$.add(D)));for(const D of C.files)y(D)===e.path&&($.has(D)||(_.push({name:b(D),path:D,absolute:D,type:"file",ignored:!1}),$.add(D)));return _.sort((D,L)=>D.type!==L.type?D.type==="directory"?-1:1:D.name.localeCompare(L.name)),_}),h=n===0,k=()=>h&&a?.hovered()==="";return(()=>{var v=B4();Rt(v,"drop",h&&a?y=>a.handleDrop("",y):void 0),Rt(v,"dragleave",h&&a?a.handleDragLeave:void 0),Rt(v,"dragover",h&&a?y=>a.handleDragOver("",y):void 0);var C=i;return typeof C=="function"?Lt(C,v):i=v,ue(v,"data-filetree-root",h?"true":void 0),l(v,s(Oe,{get each(){return w()},children:y=>{const b=()=>t.tree.state(y.path)?.expanded??!1,_=()=>p().get(y.path)??-1,$=()=>Dp(y,m(),f()),D=()=>!!$()&&!y.ignored,L=y.type==="directory"?y.path:d(y.path),V=()=>a?.hovered()===L,K=a?U=>a.handleDragOver(L,U):void 0,I=a?U=>a.handleDrop(L,U):void 0;return s(Dn,{get children(){return[s(ot,{get when(){return y.type==="directory"},get children(){return s(Fn,{variant:"ghost",class:"w-full","data-scope":"filetree",forceMount:!1,get open(){return b()},onOpenChange:U=>{if(!U){const Y=e.active;if(Y&&Y.startsWith(y.path+"/"))return}U?t.tree.expand(y.path):t.tree.collapse(y.path)},get children(){return[s(Fn.Trigger,{get children(){return s(Vu,{node:y,level:n,get active(){return e.active},get nodeClass(){return e.nodeClass},get draggable(){return r()},get kinds(){return m()},get marks(){return f()},get isEmpty(){return t.tree.children(y.path).length===0},get dropHovered(){return V()},onDragOver:K,onDrop:I,onContextMenu:U=>{e.onNodeContextMenu&&(U.preventDefault(),U.stopPropagation(),e.onNodeContextMenu(y,U))},get children(){return[(()=>{var U=q4();return l(U,s(Ue,{get name(){return b()?"chevron-down":"chevron-right"},size:"small"})),U})(),s(Ue,{get name(){return b()?"folder-open":"folder"},size:"small",class:"text-icon-weak"})]}})}}),s(Fn.Content,{class:"relative pt-0.5",get children(){return[(()=>{var U=j4();return G(Y=>{var S={"absolute top-0 bottom-0 w-px pointer-events-none bg-border-weak-base opacity-0 transition-opacity duration-150 ease-out motion-reduce:transition-none":!0,"group-hover/filetree:opacity-100":b()&&_()===n,"group-hover/filetree:opacity-50":!(b()&&_()===n)},M=`left: ${Math.max(0,8+n*22-4)+8}px`;return Y.e=Tt(U,S,Y.e),Y.t=Pn(U,M,Y.t),Y},{e:void 0,t:void 0}),U})(),s(E,{get when(){return n<W4&&!u.includes(c(y.path))},get fallback(){return U4()},get children(){return s(Mp,{get path(){return y.path},level:n+1,get allowed(){return e.allowed},get modified(){return e.modified},get kinds(){return e.kinds},get active(){return e.active},get draggable(){return e.draggable},get onFileClick(){return e.onFileClick},get onNodeContextMenu(){return e.onNodeContextMenu},get _filter(){return g()},get _marks(){return f()},get _deeps(){return p()},get _kinds(){return m()},_chain:u,_drop:a})}})]}})]}})}}),s(ot,{get when(){return y.type==="file"},get children(){return s(Vu,{node:y,level:n,get active(){return e.active},get nodeClass(){return e.nodeClass},get draggable(){return r()},get kinds(){return m()},get marks(){return f()},as:"button",type:"button",get dropHovered(){return V()},onDragOver:K,onDrop:I,onClick:()=>e.onFileClick?.(y),onContextMenu:U=>{e.onNodeContextMenu&&(U.preventDefault(),U.stopPropagation(),e.onNodeContextMenu(y,U))},get children(){return[V4(),s(Dn,{get children(){return[s(ot,{get when(){return y.ignored},get children(){return s(cr,{node:y,class:"size-4 filetree-icon filetree-icon--mono",style:"color: var(--icon-weak-base)",mono:!0})}}),s(ot,{get when(){return D()},get children(){return s(cr,{node:y,class:"size-4 filetree-icon filetree-icon--mono",get style(){return Rl($())},mono:!0})}}),s(ot,{get when(){return!y.ignored},get children(){var U=H4();return l(U,s(cr,{node:y,class:"size-4 filetree-icon filetree-icon--color opacity-0 group-hover/filetree:opacity-100"}),null),l(U,s(cr,{node:y,class:"size-4 filetree-icon filetree-icon--mono group-hover/filetree:opacity-0",mono:!0}),null),U}})]}})]}})}})]}})}})),G(y=>{var b=`flex flex-col gap-0.5 ${h?"min-h-full":""} ${e.class??""}`,_={"ring-1 ring-inset ring-border-strong-base/60 rounded-md":k()};return b!==y.e&&Ht(v,y.e=b),y.t=Tt(v,_,y.t),y},{e:void 0,t:void 0}),v})()}var eS=x('<div class="text-12-regular text-text-weak truncate">/'),tS=x('<form class="flex flex-col gap-4 p-6 pt-0"><div class="flex justify-end gap-2">');function zl(e){const t=dr(),n=zn(),r=yr(),i=hn(),o=()=>(e.baseDir??"").replace(/^\/+|\/+$/g,""),[a,d]=ke(""),[c,u]=ke(!1),[g,f]=ke(),m=()=>{const k=a().trim().replace(/^\/+|\/+$/g,"");return k?o()?`${o()}/${k}`:k:""},p=e.kind==="file"?i.t("session.fileTree.newFile"):i.t("session.fileTree.newFolder");async function w(k){if(k.preventDefault(),c())return;const v=m();if(!v){f(i.t("dialog.newEntry.error.empty"));return}if(v.split("/").some(C=>!C||C==="."||C==="..")){f(i.t("dialog.newEntry.error.invalid"));return}u(!0),f(void 0);try{if(e.kind==="file")await n.client.file.write({fileWriteInput:{path:v,content:"",format:!1}});else{const y=`${n.directory.replace(/\/+$/,"")}/${v}`;await n.client.global.mkdir({path:y})}const C=o();await r.tree.refresh(C),C&&r.tree.expand(C),e.onCreated?.(v,e.kind),t.close()}catch(C){const y=C instanceof Error?C.message:String(C);f(y),nt({variant:"error",title:p,description:y})}finally{u(!1)}}const h=e.kind==="file"?i.t("dialog.newEntry.placeholder.file"):i.t("dialog.newEntry.placeholder.folder");return s(no,{title:p,class:"w-full max-w-[440px] mx-auto",get children(){var k=tS(),v=k.firstChild;return k.addEventListener("submit",w),l(k,s(E,{get when(){return o()},get children(){var C=eS(),y=C.firstChild;return l(C,o,y),C}}),v),l(k,s(Kl,{autofocus:!0,type:"text",get label(){return i.t("dialog.newEntry.name")},placeholder:h,get value(){return a()},onChange:C=>{d(C),f(void 0)},get error(){return g()},get validationState(){return g()?"invalid":void 0}}),v),l(v,s(kt,{type:"button",variant:"ghost",size:"large",onClick:()=>t.close(),get children(){return i.t("common.cancel")}}),null),l(v,s(kt,{type:"submit",variant:"primary",size:"large",get disabled(){return c()||!a().trim()},get children(){return Te(()=>!!c())()?i.t("common.saving"):i.t("common.create")}}),null),k}})}const Hu=Object.freeze(Object.defineProperty({__proto__:null,DialogNewFileEntry:zl},Symbol.toStringTag,{value:"Module"}));var nS=x('<form class="flex flex-col gap-4 p-6 pt-0"><div class="text-12-regular text-text-weak truncate"></div><div class="flex justify-end gap-2">');function rS(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function iS(e){const t=dr(),n=zn(),r=yr(),i=hn(),[o,a]=ke(Sn(e.path)),[d,c]=ke(!1),[u,g]=ke(),f=rS(e.path),m=()=>{const w=o().trim().replace(/^\/+|\/+$/g,"");return w?f?`${f}/${w}`:w:""};async function p(w){if(w.preventDefault(),d())return;const h=m();if(!h){g(i.t("dialog.newEntry.error.empty"));return}if(h.split("/").some(k=>!k||k==="."||k==="..")){g(i.t("dialog.newEntry.error.invalid"));return}if(h===e.path){t.close();return}c(!0),g(void 0);try{const k=new URLSearchParams({directory:n.directory}).toString(),v=await n.fetch(`${n.url}/file/rename?${k}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:e.path,to:h})});if(!v.ok){const C=await v.json().catch(()=>({}));throw new Error(C?.error??`Rename failed (${v.status})`)}await r.tree.refresh(f),f&&r.tree.expand(f),t.close()}catch(k){const v=k instanceof Error?k.message:String(k);g(v),nt({variant:"error",title:i.t("session.fileTree.contextMenu.rename"),description:v})}finally{c(!1)}}return s(no,{get title(){return i.t("session.fileTree.contextMenu.rename")},class:"w-full max-w-[440px] mx-auto",get children(){var w=nS(),h=w.firstChild,k=h.nextSibling;return w.addEventListener("submit",p),l(h,f?`${f}/`:""),l(w,s(Kl,{autofocus:!0,type:"text",get label(){return i.t("dialog.newEntry.name")},get value(){return o()},onChange:v=>{a(v),g(void 0)},get error(){return u()},get validationState(){return u()?"invalid":void 0}}),k),l(k,s(kt,{type:"button",variant:"ghost",size:"large",onClick:()=>t.close(),get children(){return i.t("common.cancel")}}),null),l(k,s(kt,{type:"submit",variant:"primary",size:"large",get disabled(){return d()||!o().trim()},get children(){return Te(()=>!!d())()?i.t("common.saving"):i.t("common.rename")}}),null),w}})}var sS=x('<div class="my-1 h-px bg-border-weaker-base">'),Uu=x('<button type=button class="w-full px-3 py-1.5 text-left text-12-medium hover:bg-surface-raised-base-hover">'),oS=x('<button type=button class="w-full px-3 py-1.5 text-left text-12-medium hover:bg-surface-raised-base-hover text-text-destructive">Delete'),aS=x('<div id=file-tree-ctx-menu role=menu class="fixed z-[9999] min-w-[180px] rounded-md border border-border-base bg-surface-raised-base shadow-lg py-1 text-text-strong"><button type=button class="w-full px-3 py-1.5 text-left text-12-medium hover:bg-surface-raised-base-hover"></button><button type=button class="w-full px-3 py-1.5 text-left text-12-medium hover:bg-surface-raised-base-hover">');function Wu(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function lS(e){const t=dr(),n=hn(),r=zn(),i=yr(),[o,a]=ke(!1),[d,c]=ke({x:0,y:0}),[u,g]=ke({kind:"root",path:"",baseDir:""});function f(){a(!1)}function m(b,_){g(_),c({x:b.clientX,y:b.clientY}),a(!0)}function p(b,_){m(_,{kind:b.type==="directory"?"dir":"file",path:b.path,baseDir:b.type==="directory"?b.path:Wu(b.path)})}function w(b){m(b,{kind:"root",path:"",baseDir:""})}function h(b){f(),t.show(()=>s(zl,{kind:"file",baseDir:b,onCreated:(_,$)=>{$==="file"&&e?.onFileCreated?.(_)}}))}function k(b){f(),t.show(()=>s(zl,{kind:"folder",baseDir:b}))}function v(b,_){f(),t.show(()=>s(iS,{path:b,kind:_}))}async function C(b){f();try{await navigator.clipboard.writeText(b),nt({variant:"success",title:n.t("session.fileTree.contextMenu.copyPath.done")})}catch{nt({variant:"error",title:n.t("session.fileTree.contextMenu.copyPath.failed")})}}async function y(b,_="file"){if(f(),!!confirm(`Are you sure you want to delete "${b}"? This action cannot be undone.`))try{await r.client.file.delete({path:b});const D=Wu(b);await i.tree.refresh(D),e?.onFileDeleted?.(b,_),nt({variant:"success",title:"Deleted successfully"})}catch(D){const L=D instanceof Error?D.message:typeof D=="string"?D:JSON.stringify(D);nt({variant:"error",title:"Failed to delete",description:L})}}return{open:o,pos:d,target:u,close:f,showNode:p,showRoot:w,newFile:h,newFolder:k,rename:v,copyPath:C,deleteFile:y}}function cS(e){const t=hn(),n=i=>{const o=document.getElementById("file-tree-ctx-menu");o&&i.target instanceof Node&&o.contains(i.target)||e.ctrl.close()},r=i=>{i.key==="Escape"&&e.ctrl.close()};return typeof window<"u"&&(window.addEventListener("mousedown",n,!0),window.addEventListener("keydown",r),vt(()=>{window.removeEventListener("mousedown",n,!0),window.removeEventListener("keydown",r)})),s(E,{get when(){return e.ctrl.open()},get children(){return s(qo,{get children(){var i=aS(),o=i.firstChild,a=o.nextSibling;return o.$$click=()=>e.ctrl.newFile(e.ctrl.target().baseDir),l(o,()=>t.t("session.fileTree.newFile")),a.$$click=()=>e.ctrl.newFolder(e.ctrl.target().baseDir),l(a,()=>t.t("session.fileTree.newFolder")),l(i,s(E,{get when(){return e.ctrl.target().kind!=="root"},get children(){return[sS(),(()=>{var d=Uu();return d.$$click=()=>{const c=e.ctrl.target();c.kind!=="root"&&e.ctrl.rename(c.path,c.kind==="dir"?"dir":"file")},l(d,()=>t.t("session.fileTree.contextMenu.rename")),d})(),(()=>{var d=Uu();return d.$$click=()=>e.ctrl.copyPath(e.ctrl.target().path),l(d,()=>t.t("session.fileTree.contextMenu.copyPath")),d})(),(()=>{var d=oS();return d.$$click=()=>{const c=e.ctrl.target();c.kind!=="root"&&e.ctrl.deleteFile(c.path,c.kind)},d})()]}}),null),G(d=>{var c=`${e.ctrl.pos().x}px`,u=`${e.ctrl.pos().y}px`;return c!==d.e&&Je(i,"left",d.e=c),u!==d.t&&Je(i,"top",d.t=u),d},{e:void 0,t:void 0}),i}})}})}Kt(["click"]);Kt(["input","keydown","click"]);var dS=x("<span class=preview-console-count>"),uS=x("<button class=preview-console-toggle>"),fS=x("<div class=preview-console-empty>No console output"),gS=x('<div class=preview-console><div class=preview-console-header><span class=preview-console-title>Console</span><div class=flex-1></div><button class=preview-console-clear title="Clear console"></button></div><div class=preview-console-entries><div>'),mS=x("<div class=preview-console-entry><span class=preview-console-badge></span><span class=preview-console-time></span><span class=preview-console-msg>");function hS(e){let t;$e(()=>{e.logs.length,t?.scrollIntoView({behavior:"smooth"})});const n=o=>o==="error"?"var(--color-red-500)":o==="warn"?"var(--color-yellow-500)":o==="info"?"var(--color-blue-500)":o==="debug"?"var(--text-weaker)":"var(--text-base)",r=o=>o==="error"?"ERR":o==="warn"?"WRN":o==="info"?"INF":o==="debug"?"DBG":"LOG",i=o=>{const a=new Date(o);return`${a.getHours().toString().padStart(2,"0")}:${a.getMinutes().toString().padStart(2,"0")}:${a.getSeconds().toString().padStart(2,"0")}.${a.getMilliseconds().toString().padStart(3,"0")}`};return(()=>{var o=gS(),a=o.firstChild,d=a.firstChild,c=d.firstChild,u=d.nextSibling,g=u.nextSibling,f=a.nextSibling,m=f.firstChild;l(d,s(bg,{class:"size-3"}),c),l(a,s(E,{get when(){return e.logs.length>0},get children(){var w=dS();return l(w,()=>e.logs.length),w}}),u),l(a,s(E,{get when(){return e.onToggle},get children(){var w=uS();return Rt(w,"click",e.onToggle,!0),l(w,s(E,{get when(){return e.collapsed},get fallback(){return s(Vv,{class:"size-3"})},get children(){return s(jv,{class:"size-3"})}})),G(()=>ue(w,"title",e.collapsed?"Expand console":"Collapse console")),w}}),g),Rt(g,"click",e.onClear,!0),l(g,s(zs,{class:"size-3"})),l(f,s(E,{get when(){return e.logs.length===0},get children(){return fS()}}),m),l(f,s(Oe,{get each(){return e.logs},children:w=>(()=>{var h=mS(),k=h.firstChild,v=k.nextSibling,C=v.nextSibling;return l(k,()=>r(w.level)),l(v,()=>i(w.timestamp)),l(C,()=>w.args.join(" ")),G(y=>{var b=n(w.level),_=n(w.level);return b!==y.e&&Je(h,"color",y.e=b),_!==y.t&&Je(k,"color",y.t=_),y},{e:void 0,t:void 0}),h})()}),m);var p=t;return typeof p=="function"?Lt(p,m):t=m,G(()=>o.classList.toggle("preview-console--collapsed",!!e.collapsed)),o})()}Kt(["click"]);var pS=x('<div class="preview-viewport-toggle shrink-0"><button title="Mobile (375px)"></button><button title="Tablet (768px)"></button><button title=Desktop>'),vS=x('<span class="preview-console-badge-count absolute -top-1 -right-1">'),bS=x('<button class="size-8 shrink-0 rounded-md border border-border-weaker-base flex items-center justify-center text-text-weak hover:text-text-base hover:bg-surface-raised-base/40 relative"title="Toggle console">'),xS=x('<div class="h-full min-h-0 flex flex-col bg-background-base"><div class="shrink-0 flex items-center gap-2 px-3 pt-3 pb-2 border-b border-border-weaker-base"><div class="flex items-center gap-2 min-w-0 flex-1 overflow-x-auto"></div></div><div class="shrink-0 flex items-center gap-2 px-3 py-2 border-b border-border-weaker-base bg-surface-raised-base/20"><button class="size-8 shrink-0 rounded-md border border-border-weaker-base flex items-center justify-center text-text-weak hover:text-text-base hover:bg-surface-raised-base/40 disabled:opacity-40 disabled:cursor-not-allowed"title=Back></button><button class="size-8 shrink-0 rounded-md border border-border-weaker-base flex items-center justify-center text-text-weak hover:text-text-base hover:bg-surface-raised-base/40 disabled:opacity-40 disabled:cursor-not-allowed"title=Forward></button><button class="size-8 shrink-0 rounded-md border border-border-weaker-base flex items-center justify-center text-text-weak hover:text-text-base hover:bg-surface-raised-base/40"title=Refresh></button><div class="min-w-0 flex-1 h-9 rounded-lg border border-border-weaker-base bg-background-base flex items-center gap-2 px-3"><input class="flex-1 bg-transparent outline-none text-13-regular text-text-base placeholder:text-text-weaker"placeholder="Enter a URL"></div></div><div id=browser-content class="flex-1 min-h-0 overflow-hidden bg-surface-raised-base/20 flex flex-col">'),yS=x('<button class="shrink-0 h-8 max-w-52 px-3 rounded-lg border flex items-center gap-2 transition-colors"><span class="truncate text-12-regular"></span><span class="size-5 shrink-0 rounded-md flex items-center justify-center text-text-weaker hover:text-text-base hover:bg-surface-raised-base/60">×'),wS=x('<div class="h-full flex items-center justify-center text-13-regular text-text-weaker">No tab selected'),$S=x('<div class="h-full flex flex-col items-center justify-center gap-3 text-center text-text-weaker px-6"><div class="text-14-medium text-text-strong">Open a page</div><div class="text-13-regular max-w-md">Enter a URL in the location bar above. Some websites may block embedded browsing and need to be opened in a separate tab.'),kS=x('<div class="preview-web-wrap flex-1 flex flex-col min-h-0"><div><iframe class="preview-web-frame flex-1 w-full h-full border-none"sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-downloads"allow="accelerometer; gyroscope; magnetometer; clipboard-read; clipboard-write; display-capture">');const _S=500,Wi=(e,t="")=>{const n=Os(t);return{id:e,input:n,title:pa(n),name:void 0,url:n,stack:n?[n]:[],idx:n?0:-1}},Pc=e=>{const t=Array.isArray(e.stack)?e.stack.filter(r=>typeof r=="string"&&r.length>0):e.url?[e.url]:[],n=t.length?typeof e.idx=="number"?Math.min(Math.max(e.idx,0),t.length-1):t.length-1:-1;return{list:t,idx:n}},To=(e,t,n)=>{const r=Os(t),i=Pc(e),o=i.list.slice(0,i.idx+1);return o[o.length-1]!==r&&o.push(r),{...e,input:r,title:n??e.name??pa(r),name:n??e.name,url:r,stack:o,idx:o.length-1}},Ku=(e,t)=>{const n=Pc(e),r=n.list[t]??"";return{...e,input:r,title:e.name??pa(r),url:r,stack:n.list,idx:t}},CS=e=>e==="mobile"?"preview-web--mobile":e==="tablet"?"preview-web--tablet":"preview-web--desktop";function SS(){const e=zn(),t=Hv(),[n,r]=Xr(Zr.workspace(e.directory,"browser"),St({active:"1",next:2,tabs:[Wi("1")]})),i=T(()=>n.tabs.find(I=>I.id===n.active)??n.tabs[0]),o=T(()=>i()?.id),a=T(()=>i()?.url),[d,c]=Xr(Zr.global("preview-viewport",["preview-viewport.v1"]),St({mode:"desktop"})),[u,g]=St({show:!1,logs:[],next:0}),f=T(()=>{const I=i();return I?Pc(I):{list:[],idx:-1}}),m=T(()=>{const I=a();return I}),p=I=>{if(I.data?.source!=="oc-console")return;const U=I.data,Y={id:u.next,level:typeof U.level=="string"?U.level:"log",args:Array.isArray(U.args)?U.args.map(String):[],timestamp:typeof U.timestamp=="number"?U.timestamp:Date.now(),url:typeof U.url=="string"?U.url:i()?.url,name:i()?.name};t.console.capture({level:Y.level,args:Y.args,timestamp:Y.timestamp,url:Y.url,name:Y.name}),g("logs",S=>S.length>=_S?[...S.slice(1),Y]:[...S,Y]),g("next",u.next+1)};window.addEventListener("message",p),vt(()=>window.removeEventListener("message",p)),$e(Pt(o,()=>{g("logs",[]),g("next",0)})),$e(()=>{if(n.tabs.length>0){n.tabs.some(U=>U.id===n.active)||r("active",n.tabs[0].id);return}const I=`${n.next}`;Wn(()=>{r("next",n.next+1),r("tabs",[Wi(I)]),r("active",I)})}),$e(Pt(()=>t.target()?.id,()=>{const I=t.target(),U=Os(I?.url??"");if(!U)return;const Y=n.tabs.find(S=>I?.name&&S.name===I.name||S.url===U);if(!Y){const S=`${n.next}`;Wn(()=>{r("next",n.next+1),r("tabs",M=>[...M,To({...Wi(S),title:I?.name??"New Tab"},U,I?.name)]),r("active",S)});return}Wn(()=>{r("active",Y.id),r("tabs",S=>S.map(M=>M.id===Y.id?To(M,U,I?.name):M))})}));const w=(I="",U)=>{const Y=`${n.next}`,S=Os(I);Wn(()=>{r("next",n.next+1),r("tabs",M=>[...M,S?To({...Wi(Y,I),title:pa(S)},S,U):Wi(Y)]),r("active",Y)})},h=I=>{r("active",I)},k=(I,U)=>{r("tabs",Y=>Y.map(S=>S.id===I?{...S,input:U,title:U.trim()?S.title:"New Tab"}:S))},v=I=>{const U=n.tabs.find(S=>S.id===I);if(!U)return;const Y=Os(U.input);Y&&r("tabs",S=>S.map(M=>M.id===I?To(M,Y):M))},C=I=>{const U=n.tabs.findIndex(S=>S.id===I);if(U===-1)return;if(n.tabs.length===1){r("tabs",[Wi(I)]);return}const Y=n.tabs[U-1]??n.tabs[U+1];Wn(()=>{r("tabs",S=>S.filter(M=>M.id!==I)),n.active===I&&Y&&r("active",Y.id)})},y=()=>{const I=i();if(!I?.url)return;r("tabs",Y=>Y.map(S=>S.id===I.id?{...S,url:`${I.url}`}:S));const U=document.getElementById(`browser-frame-${I.id}`);U&&(U.src=m()??I.url)},b=()=>{const I=i(),U=f();!I||U.idx<1||r("tabs",Y=>Y.map(S=>S.id===I.id?Ku(S,U.idx-1):S))},_=()=>{const I=i(),U=f();!I||U.idx<0||U.idx>=U.list.length-1||r("tabs",Y=>Y.map(S=>S.id===I.id?Ku(S,U.idx+1):S))},[$,D]=St({hasFocus:!1}),L=I=>{D("hasFocus",!0);try{document.getElementById(`browser-frame-${I}`)?.contentWindow?.focus()}catch{}},V=I=>{if(!$.hasFocus)return;const Y=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," ","Tab","Enter","Backspace","Escape"].includes(I.key);if(!(Y&&I.key==="Enter"&&document.activeElement?.tagName==="INPUT"))try{const S=i();if(!S){Y&&I.preventDefault();return}const M=document.getElementById(`browser-frame-${S.id}`),A=M?.contentWindow;if(!A){Y&&I.preventDefault();return}document.activeElement!==M&&M.focus();const F=A.document;if(!F){Y&&I.preventDefault();return}const N=new KeyboardEvent(I.type,{key:I.key,code:I.code,keyCode:I.keyCode,which:I.which,bubbles:!0,cancelable:!0,ctrlKey:I.ctrlKey,shiftKey:I.shiftKey,altKey:I.altKey,metaKey:I.metaKey});F.dispatchEvent(N),Y&&I.preventDefault()}catch{Y&&I.preventDefault()}},K=I=>{document.getElementById("browser-content")?.contains(I.target)?D("hasFocus",!0):document.activeElement?.tagName!=="IFRAME"&&D("hasFocus",!1)};return vt(()=>{window.removeEventListener("keydown",V,!0),window.removeEventListener("mousedown",K)}),$e(()=>{window.addEventListener("keydown",V,!0),window.addEventListener("mousedown",K)}),(()=>{var I=xS(),U=I.firstChild,Y=U.firstChild,S=U.nextSibling,M=S.firstChild,A=M.nextSibling,F=A.nextSibling,N=F.nextSibling,X=N.firstChild,B=S.nextSibling;return l(Y,s(Oe,{get each(){return n.tabs},children:O=>(()=>{var z=yS(),q=z.firstChild,Q=q.nextSibling;return z.$$click=()=>h(O.id),l(z,s(ki,{class:"size-3.5 shrink-0"}),q),l(q,()=>O.title),Q.$$click=j=>{j.stopPropagation(),C(O.id)},G(j=>Tt(z,{"border-border-weak-base bg-surface-raised-base text-text-strong":n.active===O.id,"border-border-weaker-base bg-background-base text-text-weak hover:text-text-base hover:bg-surface-raised-base/40":n.active!==O.id},j)),z})()})),l(U,s(Ot,{icon:"plus-small",variant:"ghost",class:"!rounded-md shrink-0",onClick:()=>w(),"aria-label":"New tab"}),null),M.$$click=b,l(M,s(Uv,{class:"size-4"})),A.$$click=_,l(A,s(Wv,{class:"size-4"})),F.$$click=y,l(F,s(xg,{class:"size-4"})),l(N,s(ki,{class:"size-4 shrink-0 text-text-weaker"}),X),X.$$keydown=O=>{if(O.key!=="Enter")return;const z=o();z&&v(z)},X.$$input=O=>{const z=o();z&&k(z,O.currentTarget.value)},ue(X,"spellcheck",!1),l(S,s(kt,{variant:"secondary",size:"small",class:"shrink-0",onClick:()=>{const O=o();O&&v(O)},children:"Go"}),null),l(S,s(E,{get when(){return a()},get children(){return[(()=>{var O=pS(),z=O.firstChild,q=z.nextSibling,Q=q.nextSibling;return z.$$click=()=>c("mode","mobile"),l(z,s(Kv,{class:"size-3.5"})),q.$$click=()=>c("mode","tablet"),l(q,s(Gv,{class:"size-3.5"})),Q.$$click=()=>c("mode","desktop"),l(Q,s(Yv,{class:"size-3.5"})),G(j=>{var H=`preview-viewport-btn ${d.mode==="mobile"?"preview-viewport-btn--active":""}`,J=`preview-viewport-btn ${d.mode==="tablet"?"preview-viewport-btn--active":""}`,le=`preview-viewport-btn ${d.mode==="desktop"?"preview-viewport-btn--active":""}`;return H!==j.e&&Ht(z,j.e=H),J!==j.t&&Ht(q,j.t=J),le!==j.a&&Ht(Q,j.a=le),j},{e:void 0,t:void 0,a:void 0}),O})(),(()=>{var O=bS();return O.$$click=()=>g("show",!u.show),l(O,s(bg,{class:"size-4"}),null),l(O,s(E,{get when(){return u.logs.length>0},get children(){var z=vS();return l(z,()=>u.logs.length),z}}),null),G(()=>O.classList.toggle("preview-action-btn--active",!!u.show)),O})()]}}),null),l(B,s(E,{get when(){return i()},get fallback(){return wS()},children:O=>s(E,{get when(){return m()},get fallback(){return(()=>{var z=$S(),q=z.firstChild;return l(z,s(ki,{class:"size-10 opacity-20"}),q),z})()},children:z=>(()=>{var q=kS(),Q=q.firstChild,j=Q.firstChild;return Q.$$click=()=>L(O().id),j.addEventListener("load",()=>L(O().id)),l(q,s(hS,{get logs(){return u.logs},onClear:()=>g("logs",[]),get collapsed(){return!u.show},onToggle:()=>g("show",!u.show)}),null),G(H=>{var J=`preview-web ${CS(d.mode)} flex-1 flex flex-col min-h-0`,le=!!$.hasFocus,de=`browser-frame-${O().id}`,Re=z();return J!==H.e&&Ht(Q,H.e=J),le!==H.t&&Q.classList.toggle("preview-web--focused",H.t=le),de!==H.a&&ue(j,"id",H.a=de),Re!==H.o&&ue(j,"src",H.o=Re),H},{e:void 0,t:void 0,a:void 0,o:void 0}),q})()})})),G(O=>{var z=f().idx<1,q=f().idx<0||f().idx>=f().list.length-1;return z!==O.e&&(M.disabled=O.e=z),q!==O.t&&(A.disabled=O.t=q),O},{e:void 0,t:void 0}),G(()=>X.value=i()?.input??""),I})()}Kt(["click","input","keydown"]);const Me=(e,t,n="text",r=!1)=>({key:e,label:t,type:n,required:r}),Xi=(e,t)=>{const n=t.map(a=>a.key==="color"?{...a,type:"color",required:!0,default:a.default??Ai(e)}:a.key==="icon"?{...a,type:"select",required:!0,default:a.default??Di(e),options:a.options??Ko}:a),r=new Set(n.map(a=>a.key)),i=[{...Me("color","Color","color",!0),default:Ai(e)},{...Me("icon","Icon","select",!0),default:Di(e),options:Ko},Me("body","Body")].filter(a=>!r.has(a.key)),o=n.findIndex(a=>a.key==="type");return o<0?[...i,...n]:[...n.slice(0,o+1),...i,...n.slice(o+1)]},Ep={issue:[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("status","Status","select"),Me("priority","Priority","select"),Me("assignee","Assignee"),Me("branch","Branch"),Me("criteriaCount","Criteria Count","number"),Me("criteriaPassed","Criteria Passed","number"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],agent:[Me("type","Type","text",!0),Me("name","Name"),Me("model","Model"),Me("provider","Provider"),Me("status","Status")],project:[Me("type","Type","text",!0),Me("name","Name"),Me("path","Path"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],memory:[Me("type","Type","text",!0),Me("title","Title"),Me("content","Content"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],mcp:[Me("type","Type","text",!0),Me("name","Name"),Me("status","Status"),Me("command","Command")],sprite:[Me("type","Type","text",!0),Me("name","Name"),Me("github","GitHub"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],workunit:[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("body","Body"),Me("status","Status","select"),Me("priority","Priority","select"),Me("phase","Phase"),Me("context","Context"),Me("assignee","Assignee"),Me("branch","Branch"),Me("criteriaCount","Criteria Count","number"),Me("criteriaPassed","Criteria Passed","number"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],cycle:[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("status","Status","select"),Me("horizon","Horizon"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],epic:[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("status","Status","select"),Me("targetDate","Target Date","date"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],roadmap:[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("status","Status","select"),Me("horizon","Horizon"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],suggestion:[Me("type","Type","text",!0),Me("title","Title"),Me("description","Description"),Me("priority","Priority","select"),Me("dismissed","Dismissed","boolean"),Me("createdAt","Created At","date")],file:[Me("type","Type","text",!0),Me("path","Path","text",!0),Me("language","Language"),Me("size","Size","number"),Me("contentHash","Content Hash"),Me("modifiedAt","Modified At","date"),Me("lastModified","Last Modified","date")],directory:[Me("type","Type","text",!0),Me("path","Path","text",!0)],op:[Me("type","Type","text",!0),Me("kind","Kind"),Me("time","Time","date"),Me("summary","Summary")],branch:[Me("type","Type","text",!0),Me("name","Name","text",!0),Me("current","Current","boolean"),Me("createdAt","Created At","date"),Me("createdBy","Created By")],decision:[Me("type","Type","text",!0),Me("title","Title"),Me("status","Status"),Me("context","Context"),Me("toolName","Tool Name"),Me("toolInput","Tool Input"),Me("outputSummary","Output Summary"),Me("createdAt","Created At","date"),Me("createdBy","Created By")],session:[Me("type","Type","text",!0),Me("title","Title"),Me("createdAt","Created At","date"),Me("updatedAt","Updated At","date")],typeschema:[Me("type","Type","text",!0),Me("label","Label"),Me("props","Props")]},TS=Object.keys(Ep),AS={phase:Xi("phase",[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("description","Description"),Me("context","Context")]),risk:Xi("risk",[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("description","Description"),Me("context","Context")]),mitigationstrategy:Xi("mitigationstrategy",[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("description","Description"),Me("context","Context")]),checkpoint:Xi("checkpoint",[Me("type","Type","text",!0),Me("trigger","Trigger"),Me("atOpHash","At Op Hash"),Me("createdAt","Created At","date")]),acceptancecriteria:Xi("acceptancecriteria",[Me("type","Type","text",!0),Me("title","Title","text",!0),Me("description","Description"),Me("context","Context")])},DS=["branch:","checkpoint:","decision:","dir:","file:","issue:","mcp:","session:","sprite:"],MS=new Set(["Branch","Checkpoint","Decision","DirectoryNode","FileNode","Issue","Session","Sprite","TypeSchema"]);function Fc(e){return MS.has(e.type)?!1:!DS.some(t=>e.id.startsWith(t))}function vi(e){return e.trim().toLowerCase()}function Cr(e){const t=e.trim();return t==="DirectoryNode"?"directory":t==="FileNode"?"file":t==="MilestoneEpic"?"epic":vi(t)}function Ei(e,t){return Cr(e)===vi(t)}function ES(e){const t=e.trim();return t==="Branch"?"branch":t==="Decision"?"decision":t==="DirectoryNode"?"directory":t==="FileNode"?"file":t==="Issue"?"issue":t==="MilestoneEpic"?"epic":t==="Roadmap"?"roadmap":t==="Session"?"session":t==="Sprite"?"sprite":t==="WorkUnit"?"workunit":t}function Gu(e){return Ep[vi(e)]}function Yu(e){return AS[vi(e)]}function Xu(e,t){return Xi(e,t)}function IS(e,t){const n={};for(const r of e)Fc(r)&&(n[Cr(r.type)]=[]);for(const[r,i]of Object.entries(t))n[r]=i;return n}const[Zu,Qu]=ke(),Ju={pending:Zu,request(e){Qu(e)},clear(){Zu()!==void 0&&Qu(void 0)}};var Ip=x("<div>"),LS=x("<section>"),PS=x("<div class=route-sidebar-meta>"),FS=x("<div class=route-sidebar-head><div class=route-sidebar-title>"),RS=x("<div class=route-sidebar-foot>"),zS=x("<aside><div class=route-sidebar-body>"),OS=x("<nav>"),NS=x("<span class=route-nav-icon>"),BS=x("<span class=route-nav-badge>"),qS=x("<button><span class=route-nav-label>"),jS=x("<div class=route-header-meta>"),VS=x("<div class=route-header-search>"),HS=x("<div class=route-header-actions>"),US=x("<header><div class=route-header-main><h2 class=route-header-title>"),WS=x("<div class=route-empty-icon>"),KS=x("<div class=route-empty-desc>"),GS=x("<div class=route-empty-action>"),YS=x("<div><div class=route-empty-copy><div class=route-empty-title>"),XS=x("<div class=route-detail-actions>"),ZS=x("<div class=route-detail-head><div class=route-detail-title>"),QS=x("<aside><div class=route-detail-body>");function Jr(...e){return e.filter(Boolean).join(" ")}function Rc(e){return(()=>{var t=Ip();return l(t,()=>e.children),G(()=>Ht(t,Jr("route-view",e.class))),t})()}function zc(e){return(()=>{var t=LS();return l(t,()=>e.children),G(()=>Ht(t,Jr("route-panel",e.compact&&"route-panel--compact",e.class))),t})()}function JS(e){return(()=>{var t=zS(),n=t.firstChild;return l(t,s(E,{get when(){return e.title||e.meta},get children(){var r=FS(),i=r.firstChild;return l(i,()=>e.title),l(r,s(E,{get when(){return e.meta},get children(){var o=PS();return l(o,()=>e.meta),o}}),null),r}}),n),l(n,()=>e.children),l(t,s(E,{get when(){return e.footer},get children(){var r=RS();return l(r,()=>e.footer),r}}),null),G(r=>{var i=Jr("route-sidebar",e.compact&&"route-sidebar--compact",e.class),o=`${e.width??208}px`;return i!==r.e&&Ht(t,r.e=i),o!==r.t&&Je(t,"--route-sidebar-width",r.t=o),r},{e:void 0,t:void 0}),t})()}function Lp(e){return(()=>{var t=OS();return l(t,s(Oe,{get each(){return e.items},children:(n,r)=>(()=>{var i=qS(),o=i.firstChild;return i.$$click=()=>e.onSelect(n.id),l(i,s(E,{get when(){return n.icon},get children(){var a=NS();return l(a,()=>n.icon),a}}),o),l(o,()=>n.label),l(i,s(E,{get when(){return n.badge},get children(){var a=BS();return l(a,()=>n.badge),a}}),null),G(a=>{var d=Jr("route-nav-item",e.variant==="tabs"&&"route-nav-item--tab",e.active===n.id&&"route-nav-item--active"),c=e.stagger?`${r()*45}ms`:void 0,u=!!e.stagger,g=n.disabled,f=e.active===n.id;return d!==a.e&&Ht(i,a.e=d),c!==a.t&&Je(i,"animation-delay",a.t=c),u!==a.a&&i.classList.toggle("route-motion-item",a.a=u),g!==a.o&&(i.disabled=a.o=g),f!==a.i&&ue(i,"aria-pressed",a.i=f),a},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()})),G(()=>Ht(t,Jr("route-nav",e.variant==="tabs"&&"route-nav--tabs"))),t})()}function Oc(e){return(()=>{var t=US(),n=t.firstChild,r=n.firstChild;return l(r,()=>e.title),l(n,s(E,{get when(){return e.meta},get children(){var i=jS();return l(i,()=>e.meta),i}}),null),l(t,s(E,{get when(){return e.search},get children(){var i=VS();return l(i,()=>e.search),i}}),null),l(t,s(E,{get when(){return e.actions},get children(){var i=HS();return l(i,()=>e.actions),i}}),null),G(()=>Ht(t,Jr("route-header",e.class))),t})()}function Nc(e){return(()=>{var t=Ip();return l(t,()=>e.children),G(()=>Ht(t,Jr("route-content route-motion-section",e.padded&&"route-content--padded",e.narrow&&"route-content--narrow",e.scroll===!1&&"route-content--clip",e.class))),t})()}function Pp(e){return(()=>{var t=YS(),n=t.firstChild,r=n.firstChild;return l(t,s(E,{get when(){return e.icon},get children(){var i=WS();return l(i,()=>e.icon),i}}),n),l(r,()=>e.title),l(n,s(E,{get when(){return e.description},get children(){var i=KS();return l(i,()=>e.description),i}}),null),l(t,s(E,{get when(){return e.action},get children(){var i=GS();return l(i,()=>e.action),i}}),null),G(()=>Ht(t,Jr("route-empty route-motion-pop",e.class))),t})()}function e6(e){const t=()=>typeof e.width=="number"?`${e.width}px`:e.width;return(()=>{var n=QS(),r=n.firstChild;return l(n,s(E,{get when(){return e.title||e.actions},get children(){var i=ZS(),o=i.firstChild;return l(o,()=>e.title),l(i,s(E,{get when(){return e.actions},get children(){var a=XS();return l(a,()=>e.actions),a}}),null),i}}),r),l(r,()=>e.children),G(i=>{var o=Jr("route-detail",e.side==="left"&&"route-detail--left",e.side==="bottom"&&"route-detail--bottom",e.flush&&"route-detail--flush",e.class),a=t();return o!==i.e&&Ht(n,i.e=o),a!==i.t&&Je(n,"--route-detail-width",i.t=a),i},{e:void 0,t:void 0}),n})()}Kt(["click"]);function Bc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem("trellis_nav_v2")==="true"}catch{return!1}}const qc=1,t6="trellis.graph.layout:v1:",Fp=e=>t6+e;function n6(e){if(!(typeof localStorage>"u"))try{const t=localStorage.getItem(Fp(e));if(!t)return;const n=JSON.parse(t);return n?.v!==qc||!n.positions||typeof n.positions!="object"?void 0:n}catch{return}}function ef(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(Fp(e),JSON.stringify({...t,v:qc}))}catch{}}function r6(e,t=800){let n,r;return{save:a=>{r=a,n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,r&&(ef(e,r),r=void 0)},t)},flush:()=>{n&&(clearTimeout(n),n=void 0),r&&(ef(e,r),r=void 0)}}}function Rp(e,t){const n={};for(const r of e)typeof r.x=="number"&&typeof r.y=="number"&&isFinite(r.x)&&isFinite(r.y)&&(n[r.id]={x:r.x,y:r.y});return{v:qc,zoom:t,positions:n}}function zp(e,t){if(!t)return 0;let n=0;for(const r of e){const i=t.positions[r.id];i&&(r.x=i.x,r.y=i.y,r.vx=0,r.vy=0,n++)}return n}const Ol={light:2e3,heavy:15e3},Ii={dist:1.5,charge:1.5,collide:1,decay:1};function jr(e){return Ni(e.type,e.status,e.color)}function Op(e){return yg(e.type,e.icon)}function _r(e){return e.type==="issue"?15:e.type==="project"?13:e.type==="sprite"?12:e.type==="roadmap"?11:e.type==="epic"?10:e.type==="cycle"?8:e.type==="suggestion"?6:e.type==="directory"?8:e.type==="op"?4:e.type==="file"?e.size?Math.min(18,6+Math.max(0,Math.log2(e.size/512))*1.5):6:7}const i6=140;function s6(e,t,n){const r=i6/Math.min(1,e.k);return{left:(-e.x-r)/e.k,top:(-e.y-r)/e.k,right:(t-e.x+r)/e.k,bottom:(n-e.y+r)/e.k}}function tf(e,t){const n=e.x??0,r=e.y??0;return n>=t.left&&n<=t.right&&r>=t.top&&r<=t.bottom}function Ao(e,t){const n=e.source,r=e.target,i=n.x??0,o=n.y??0,a=r.x??0,d=r.y??0;return Math.max(i,a)>=t.left&&Math.min(i,a)<=t.right&&Math.max(o,d)>=t.top&&Math.min(o,d)<=t.bottom}function o6(e,t){const n=new Map;for(const a of e)n.set(a.id,a);const r=new Map;for(const a of e)r.set(a.id,new Set);for(const a of t){const d=typeof a.source=="string"?a.source:a.source.id,c=typeof a.target=="string"?a.target:a.target.id;r.get(d)?.add(c),r.get(c)?.add(d)}const i=new Map;return{byId:n,adjacency:r,getClosure:a=>{const d=i.get(a);if(d)return d;const c=r.get(a)??new Set,u=new Set([a,...c]);return i.set(a,u),u}}}class a6{cell;buckets=new Map;constructor(t=40){this.cell=t}key(t,n){return t*100003+n}rebuild(t){this.buckets.clear();const n=this.cell;for(const r of t){const i=Math.floor((r.x??0)/n),o=Math.floor((r.y??0)/n),a=this.key(i,o),d=this.buckets.get(a);d?d.push(r):this.buckets.set(a,[r])}}find(t,n,r,i){const o=this.cell,a=Math.max(1,Math.ceil(r/o)),d=Math.floor(t/o),c=Math.floor(n/o);let u=null,g=1/0;for(let f=-a;f<=a;f++)for(let m=-a;m<=a;m++){const p=this.buckets.get(this.key(d+f,c+m));if(p)for(const w of p){const h=(w.x??0)-t,k=(w.y??0)-n,v=h*h+k*k,C=i(w);v<=C*C&&v<g&&(g=v,u=w)}}return u}}class l6{constructor(t){this.dpr=t}cache=new Map;entity(t,n,r,i=2.25,o){const a=o?yg(t,o):nd[t]??nd.entity;if(!a)return null;const d=`${t}|${o??""}|${n}|${r}|${i}|${this.dpr}`,c=this.cache.get(d);if(c)return c;const u=Math.max(4,Math.round(r*this.dpr)),g=document.createElement("canvas");g.width=u,g.height=u;const f=g.getContext("2d");if(!f)return null;const m=u/24;return f.setTransform(m,0,0,m,0,0),f.lineCap="round",f.lineJoin="round",f.strokeStyle=n,f.lineWidth=i,c6(f,a),this.cache.set(d,g),g}clear(){this.cache.clear()}}function c6(e,t){const n=/<(path|circle|rect|line)\b([^/>]*)\/>/g;let r;for(;r=n.exec(t);){const i=r[1],o=d6(r[2]);if(i==="path"&&o.d)try{e.stroke(new Path2D(o.d))}catch{}else if(i==="circle"){const a=Er(o.cx),d=Er(o.cy),c=Er(o.r);c>0&&(e.beginPath(),e.arc(a,d,c,0,Math.PI*2),e.stroke())}else if(i==="rect"){const a=Er(o.x),d=Er(o.y),c=Er(o.width),u=Er(o.height);c>0&&u>0&&e.strokeRect(a,d,c,u)}else if(i==="line"){const a=Er(o.x1),d=Er(o.y1),c=Er(o.x2),u=Er(o.y2);e.beginPath(),e.moveTo(a,d),e.lineTo(c,u),e.stroke()}}}function d6(e){const t={},n=/(\w+)\s*=\s*"([^"]*)"/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}function Er(e){if(!e)return 0;const t=Number(e);return Number.isFinite(t)?t:0}function u6(e){const t=e.appendChild(document.createElement("div"));t.setAttribute("class","graph-tooltip"),t.style.cssText="position:absolute;pointer-events:none;z-index:20;display:none;padding:0;border-radius:8px;font-size:11px;line-height:1.4;background:color-mix(in srgb, var(--surface-raised-base) 85%, transparent);backdrop-filter:blur(4px);border:1px solid var(--border-base);color:var(--text-strong);box-shadow:0 6px 20px rgba(0,0,0,.35);width:max-content;max-width:min(480px,90vw);opacity:0;transform:translateY(2px);transition:opacity 80ms ease-out,transform 80ms ease-out;";let n=null;const r=(i,o)=>{const a=t.offsetWidth,d=t.offsetHeight;let c=i.x-a/2,u=i.y-i.r-d-10;u<4&&(u=i.y+i.r+10),c<4&&(c=4),c+a>o.w-4&&(c=o.w-a-4),t.style.left=c+"px",t.style.top=u+"px"};return{show(i,o,a){t.innerHTML=i,n!==null&&(clearTimeout(n),n=null),t.style.display="block",r(o,a),requestAnimationFrame(()=>{t.style.opacity="1",t.style.transform="translateY(0)"})},reposition:r,hide(){t.style.opacity="0",t.style.transform="translateY(4px)",n=setTimeout(()=>{t.style.display="none",n=null},140)},destroy(){n!==null&&(clearTimeout(n),n=null),t.remove()}}}function Do(e){return e.replace(/[&<>"']/g,t=>{switch(t){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";default:return"&#39;"}})}function f6(e){const t=jr(e),n=Do(e.type.replace(/_/g," ")),r=Do(e.label),i=e.status?`<div style="color:var(--text-weaker);margin-top:1px">Status: ${Do(e.status.replace(/_/g," "))}</div>`:"",o=e.priority?`<div style="color:var(--text-weaker)">Priority: ${Do(e.priority)}</div>`:"";return`<div style="padding:10px 24px 10px 12px"><div style="display:flex;align-items:center;gap:6px;margin-bottom:2px"><span style="width:8px;height:8px;border-radius:50%;background:${t};flex-shrink:0"></span><span style="font-weight:600;text-transform:capitalize">${n}</span></div><div style="color:var(--text-weak);white-space:nowrap">${r}</div>`+i+o+"</div>"}function nf(e,t,n,r,i=Ii){const o=e.parentElement;if(!o)throw new Error("graph-canvas: svgEl must be in a container");const a=()=>e.clientWidth||o.clientWidth||800,d=()=>e.clientHeight||o.clientHeight||600,c=window.devicePixelRatio||1,u=t.length>Ol.heavy,g=zp(t,r.layout?.load()),f=g>0&&g>=Math.floor(t.length*.6),m=a()/2,p=d()/2,w=Math.min(a(),d())*.3;for(const ce of t)if(ce.x==null||ce.y==null||Number.isNaN(ce.x)||Number.isNaN(ce.y)){const Se=Math.random()*Math.PI*2,Xe=Math.random()*w;ce.x=m+Math.cos(Se)*Xe,ce.y=p+Math.sin(Se)*Xe}const h=document.createElement("canvas");h.className="graph-canvas",h.setAttribute("tabindex","0"),h.style.cssText="position:absolute;inset:0;width:100%;height:100%;touch-action:none;outline:none;",o.insertBefore(h,e);const k=h.getContext("2d",{alpha:!0});if(!k)throw new Error("graph-canvas: 2D context unavailable");const v=k,C={pointerEvents:e.style.pointerEvents,position:e.style.position,inset:e.style.inset,zIndex:e.style.zIndex};e.style.pointerEvents="none",e.style.position="absolute",e.style.inset="0",e.style.zIndex="2",h.style.zIndex="1";const y=ar(e);y.selectAll("*").remove();const b=document.createElementNS("http://www.w3.org/2000/svg","style");b.textContent="@keyframes edgeFlow{to{stroke-dashoffset:-16}}.edge-flow{animation:edgeFlow 0.5s linear infinite}",e.prepend(b);const _=y.append("g");function $(){const ce=a(),Se=d();h.width=Math.floor(ce*c),h.height=Math.floor(Se*c),h.style.width=ce+"px",h.style.height=Se+"px"}$();let D=a(),L=d();const V=new ResizeObserver(()=>{const ce=a(),Se=d();if((ce!==D||Se!==L)&&D>0&&L>0){const Xe=(ce-D)/2,et=(Se-L)/2,qt=sr.translate(M.x+Xe,M.y+et).scale(M.k);M=qt,ar(h).call(st.transform,qt)}D=ce,L=Se,$(),Gt(),ht()});V.observe(o);const{byId:K,adjacency:I,getClosure:U}=o6(t,n),Y=new l6(c),S=new a6(40);let M=sr;const A=r.layout?.load();A?.zoom&&(M=sr.translate(A.zoom.x,A.zoom.y).scale(A.zoom.k));let F=null,N=null,X=!1,B=null,O=null,z=0,q;const Q=new Set(t.filter(ce=>ce.fresh).map(ce=>ce.id)),j=Date.now();let H=0,J=0,le=0,de=!0,Re=0,Ve=0,Z=0,ne=null,re=null;const ie=.18,be=.35,Fe=1,ee=0,_e=.05,xe=12,ye=r.layout?{save:r.layout.save,flush:r.layout.flush}:{save:()=>{},flush:()=>{}},Le=()=>{ye.save(Rp(t,{x:M.x,y:M.y,k:M.k}))},tt=n.map(ce=>({source:ce.source,target:ce.target,type:ce.type})),ge=t.length,qe=ge>2200?45:ge>1200?60:90,we=ge>2200?-90:ge>1200?-130:-250,He=ge>2200?11:ge>1200?15:22,Ne=ge>2200?.09:ge>1200?.07:.05;let Ee={...i};const rt=()=>qe*Ee.dist,ct=()=>we*Ee.charge,zt=()=>He*Ee.collide,xt=()=>Ne*Ee.decay;if(q=Ug(t).force("link",Hg(tt).id(ce=>ce.id).distance(rt())).force("charge",Wg().strength(ct())).force("collide",Vg(zt())).alphaDecay(xt()),f||q.force("center",qg(a()/2,d()/2)),f&&q.alpha(.15).alphaTarget(0),q.on("tick",()=>{Gt()}),q.on("end",()=>{S.rebuild(t),Le()}),u){let ce=function(){for(let tn=0;tn<8&&et<Se;tn++)Xe.tick(),et++;et<Se?requestAnimationFrame(ce):(Xe.stop(),S.rebuild(t),Le())};const Se=f?30:Math.min(300,Math.max(60,Math.floor(t.length/120))),Xe=q;Xe.alpha(f?.15:1),Xe.stop(),requestAnimationFrame(()=>{Cn(),vn()});let et=0;requestAnimationFrame(ce)}else S.rebuild(t);const st=Kg().scaleExtent([_e,4]).extent(()=>[[0,0],[a(),d()]]).filter(ce=>ce.type==="wheel"?ce.ctrlKey||ce.metaKey:ce.type==="mousedown"&&ce.button===0&&At(ce)?!1:ce.button===0||ce.button===1).on("zoom",ce=>{M=ce.transform,Gt(),ht(),Le()}),gt=ar(h);gt.call(st),h.addEventListener("wheel",ce=>{ce.ctrlKey||ce.metaKey||(ce.preventDefault(),gt.call(st.translateBy,-ce.deltaX/M.k,-ce.deltaY/M.k))},{passive:!1}),h.addEventListener("mousedown",ce=>{ce.button===1&&(ce.preventDefault(),h.style.cursor="grabbing")}),h.addEventListener("mouseup",ce=>{ce.button===1&&!X&&(h.style.cursor="default")});const $n=ce=>{if(!(ce instanceof HTMLElement))return!1;if(ce.isContentEditable)return!0;const Se=ce.tagName;return Se==="INPUT"||Se==="TEXTAREA"||Se==="SELECT"},Ce=ce=>{ce.code!=="Space"||X||$n(ce.target)||(ce.preventDefault(),X=!0,h.style.cursor="grab",st.scaleExtent([M.k,M.k]))},Dt=ce=>{ce.code==="Space"&&X&&(ce.preventDefault(),X=!1,h.style.cursor="default",st.scaleExtent([_e,4]))};window.addEventListener("keydown",Ce),window.addEventListener("keyup",Dt),h.focus();function lt(ce){const Se=h.getBoundingClientRect();return{x:(ce.clientX-Se.left-M.x)/M.k,y:(ce.clientY-Se.top-M.y)/M.k}}function At(ce){const Se=lt(ce);return S.find(Se.x,Se.y,Math.max(8,xe/M.k),wt)}function wt(ce){return Math.max(_r(ce),xe/M.k)}const It=2.1;let W=1,oe=1,me=null;function he(){le=0;const ce=oe-W;if(Math.abs(ce)<.005){W=oe,oe===1&&(me=null),Gt();return}W+=ce*.28,Gt(),le=requestAnimationFrame(he)}function Ie(ce){ce?(me=ce,oe=It):oe=1,le||(le=requestAnimationFrame(he))}const Ae=90,De=1.75,Ke=t.length>Ol.light;function yt(ce){if(me===ce.id)return W;if(Ke||B===null||O===null)return 1;const Se=(ce.x??0)-B,Xe=(ce.y??0)-O,et=Se*Se+Xe*Xe,qt=Ae*Ae;if(et>=qt)return 1;const tn=1-Math.sqrt(et)/Ae,jn=tn*tn*(3-2*tn);return 1+(De-1)*jn}const Nt=u6(o);function Ft(ce){if(F!==ce){if(F=ce,ce){const Se=K.get(ce);Se&&(Nt.show(f6(Se),{x:(Se.x??0)*M.k+M.x,y:(Se.y??0)*M.k+M.y,r:_r(Se)*M.k},{w:a(),h:d()}),Ie(ce))}else Nt.hide(),Ie(null);Gt()}}h.addEventListener("mousemove",ut),h.addEventListener("mouseleave",()=>{B=null,O=null,F&&Ft(null),Gt()});let kn=null;h.addEventListener("mousedown",ce=>{if(ce.button!==0)return;kn={x:ce.clientX,y:ce.clientY};const Se=At(ce);Se&&(ce.preventDefault(),ce.stopPropagation(),N=Se,q&&!u&&!ce.active&&q.alphaTarget(.3).restart(),Se.fx=Se.x,Se.fy=Se.y)});const Yt=ce=>{if(!N)return;const Se=lt(ce);N.fx=Se.x,N.fy=Se.y,u&&(N.x=Se.x,N.y=Se.y),Gt()},an=()=>{kn&&(kn=null),N&&(q&&!u&&q.alphaTarget(0),N.fx=null,N.fy=null,S.rebuild(t),Le(),N=null)};window.addEventListener("mousemove",Yt),window.addEventListener("mouseup",an),h.addEventListener("click",ce=>{if(kn){const Xe=ce.clientX-kn.x,et=ce.clientY-kn.y;if(kn=null,Xe*Xe+et*et>9)return}const Se=At(ce);Se?r.onSelect(Se):r.onDeselect()});const En=window.matchMedia("(max-width: 767px)").matches,dn=En?96:180,Xt=En?64:120,sn=En?4:6,_n=o.appendChild(document.createElement("canvas"));_n.width=dn*c,_n.height=Xt*c,_n.setAttribute("class","graph-minimap"),_n.style.cssText=`position:absolute;left:12px;bottom:12px;z-index:15;width:${dn}px;height:${Xt}px;background:color-mix(in srgb, var(--background-base) 88%, transparent);border:1px solid var(--border-base);border-radius:6px;box-shadow:0 2px 10px rgba(0,0,0,.35);cursor:pointer;`;const fn=_n.getContext("2d");fn.scale(c,c);const Hn=new Map;function Xn(ce){const Se=Hn.get(ce.type);if(Se)return Se;const Xe=jr(ce);return Hn.set(ce.type,Xe),Xe}function On(){let ce=1/0,Se=1/0,Xe=-1/0,et=-1/0;for(const Ln of t){const mt=Ln.x??0,jt=Ln.y??0;mt<ce&&(ce=mt),jt<Se&&(Se=jt),mt>Xe&&(Xe=mt),jt>et&&(et=jt)}const qt=a(),tn=d(),jn=-M.x/M.k,wn=-M.y/M.k,un=(qt-M.x)/M.k,Un=(tn-M.y)/M.k;ce=Math.min(ce,jn),Se=Math.min(Se,wn),Xe=Math.max(Xe,un),et=Math.max(et,Un),Number.isFinite(ce)||(ce=0,Se=0,Xe=qt,et=tn);const Zn=Xe-ce||1,Qn=et-Se||1,In=Math.min((dn-sn*2)/Zn,(Xt-sn*2)/Qn);return{minX:ce,minY:Se,maxX:Xe,maxY:et,scale:In}}function je(ce,Se,Xe){return[sn+(ce-Xe.minX)*Xe.scale,sn+(Se-Xe.minY)*Xe.scale]}function ht(){vn()}function vn(){J||(J=requestAnimationFrame(()=>{J=0,fn.clearRect(0,0,dn,Xt);const ce=On();fn.globalAlpha=.7;const Se=new Map;for(const Ln of t){const mt=Xn(Ln),jt=Se.get(mt);jt?jt.push(Ln):Se.set(mt,[Ln])}for(const[Ln,mt]of Se){fn.fillStyle=Ln;for(const jt of mt){const[Ze,nn]=je(jt.x??0,jt.y??0,ce);fn.fillRect(Ze-.75,nn-.75,1.5,1.5)}}fn.globalAlpha=1;const Xe=a(),et=d(),qt=-M.x/M.k,tn=-M.y/M.k,jn=Xe/M.k,wn=et/M.k,[un,Un]=je(qt,tn,ce),Zn=jn*ce.scale,Qn=wn*ce.scale;fn.fillStyle="rgba(0,0,0,0.45)";const In=new Path2D;In.rect(0,0,dn,Xt),In.rect(un,Un,Zn,Qn),fn.fill(In,"evenodd"),fn.strokeStyle="rgba(255,255,255,0.9)",fn.lineWidth=1,fn.strokeRect(un+.5,Un+.5,Zn-1,Qn-1)}))}function ln(ce){const Se=_n.getBoundingClientRect(),Xe=ce.clientX-Se.left,et=ce.clientY-Se.top;if(Xe<0||et<0||Xe>dn||et>Xt)return null;const qt=On();return[(Xe-sn)/qt.scale+qt.minX,(et-sn)/qt.scale+qt.minY]}function cn(ce,Se){const Xe=M.k,et=a()/2-ce*Xe,qt=d()/2-Se*Xe;gt.call(st.transform,sr.translate(et,qt).scale(Xe))}let Jt=!1;const en=ce=>{ce.preventDefault(),Jt=!0;const Se=ln(ce);Se&&cn(Se[0],Se[1])},Ut=ce=>{if(!Jt)return;const Se=ln(ce);Se&&cn(Se[0],Se[1])},gn=()=>{Jt=!1};_n.addEventListener("mousedown",en),window.addEventListener("mousemove",Ut),window.addEventListener("mouseup",gn),de=!0,Re=M.k,Ve=M.x,Z=M.y,ne=null,re=null;function Gt(){de=!0,Zt()}function Zt(){z||(z=requestAnimationFrame(()=>{z=0,de&&(Cn(),de=!1),ht()}))}let te=0,pe=null,We=null;function ut(ce){te||(pe=ce.clientX,We=ce.clientY,te=requestAnimationFrame(()=>{te=0,pe!==null&&We!==null&&(at(pe,We),pe=null,We=null)}))}function at(ce,Se){const Xe=h.getBoundingClientRect(),et={x:(ce-Xe.left-M.x)/M.k,y:(Se-Xe.top-M.y)/M.k};if(B=et.x,O=et.y,!N){if(M.k<ee)F&&Ft(null);else{const qt=S.find(et.x,et.y,Math.max(8,xe/M.k),wt);Ft(qt?.id??null)}Ke||Gt()}}function Mt(){H=0,!(Date.now()-j>=5600)&&(Gt(),H=requestAnimationFrame(Mt))}const Be=new Map;function ft(ce){const Se=ce.type+"|"+(ce.status??"")+"|"+(ce.color??""),Xe=Be.get(Se);if(Xe)return Xe;const et=jr(ce);return Be.set(Se,et),et}let Vt=null,Bt="";function pn(ce){const Se=`${M.k.toFixed(2)}_${M.x.toFixed(0)}_${M.y.toFixed(0)}`;if(Vt&&Bt===Se)return Vt;const Xe=new Map;for(const et of t){if(!tf(et,ce))continue;const qt=ft(et),tn=Xe.get(qt);tn?tn.push(et):Xe.set(qt,[et])}return Vt=Xe,Bt=Se,Xe}function Cn(){const ce=a(),Se=d(),Xe=r.getSelectedId(),et=F??Xe;if(!(M.k!==Re||M.x!==Ve||M.y!==Z)&&!(F!==ne)&&!(et!==re)&&!u){if(F){const mt=K.get(F);mt&&Nt.reposition({x:(mt.x??0)*M.k+M.x,y:(mt.y??0)*M.k+M.y,r:_r(mt)*M.k},{w:ce,h:Se})}return}Re=M.k,Ve=M.x,Z=M.y,ne=F,re=et,v.setTransform(1,0,0,1,0,0),v.clearRect(0,0,h.width,h.height),v.setTransform(c*M.k,0,0,c*M.k,c*M.x,c*M.y);const wn=s6(M,ce,Se),un=F&&Xe&&Xe!==F?Xe:null,Un=et?U(et):null,Zn=un?U(un):null;v.lineWidth=1/M.k,v.strokeStyle=sf("--text-weak");const Qn=(mt,jt)=>mt==="imports"?[3/jt,3/jt]:mt==="links"?[1/jt,4/jt]:[];v.setLineDash([]),v.globalAlpha=ie,v.beginPath();for(const mt of tt){const jt=mt.type;if(jt==="imports"||jt==="links"||!Ao(mt,wn)||se(mt,et,un))continue;const Ze=mt.source,nn=mt.target;v.moveTo(Ze.x??0,Ze.y??0),v.lineTo(nn.x??0,nn.y??0)}v.stroke(),v.setLineDash([3/M.k,3/M.k]),v.beginPath();for(const mt of tt){if(mt.type!=="imports"||!Ao(mt,wn)||se(mt,et,un))continue;const jt=mt.source,Ze=mt.target;v.moveTo(jt.x??0,jt.y??0),v.lineTo(Ze.x??0,Ze.y??0)}v.stroke(),v.setLineDash([1/M.k,4/M.k]),v.beginPath();for(const mt of tt){if(mt.type!=="links"||!Ao(mt,wn)||se(mt,et,un))continue;const jt=mt.source,Ze=mt.target;v.moveTo(jt.x??0,jt.y??0),v.lineTo(Ze.x??0,Ze.y??0)}if(v.stroke(),et){v.setLineDash([]);const mt=K.get(et),jt=mt?ft(mt):sf("--border-base"),Ze=un?K.get(un):null,nn=Ze?ft(Ze):null;for(const Tn of tt){const Jn=R(Tn,et,un);if(Jn===0||!Ao(Tn,wn))continue;const wr=Tn.source,$r=Tn.target;v.globalAlpha=Jn===1?.9:.45,v.lineWidth=(Jn===1?2:1.5)/M.k,v.strokeStyle=Jn===1?jt:nn??jt,v.setLineDash(Qn(Tn.type,M.k)),v.beginPath(),v.moveTo(wr.x??0,wr.y??0),v.lineTo($r.x??0,$r.y??0),v.stroke()}}v.setLineDash([]),v.globalAlpha=1,v.lineWidth=1.5/M.k;const In=pn(wn),Ln=4/M.k;for(const[mt,jt]of In){v.strokeStyle=mt,v.fillStyle=mt;for(const Ze of jt){const nn=Ze.x??0,Tn=Ze.y??0,Jn=_r(Ze),wr=yt(Ze),$r=Math.max(Jn*wr,Ln),er=Un?.has(Ze.id)||Zn?.has(Ze.id);v.beginPath(),v.arc(nn,Tn,$r,0,Math.PI*2),v.globalAlpha=er?.5:et?.1:.2,v.fill(),v.globalAlpha=er?1:et?.35:be,v.stroke()}}if(Q.size>0){const mt=Math.min(1,(Date.now()-j)/5500),jt=(1-mt)*(1-mt);if(jt>0){v.save(),v.fillStyle="rgba(34,197,94,0.18)",v.strokeStyle="#22c55e",v.lineWidth=3/M.k,v.shadowColor="#22c55e",v.shadowBlur=18/M.k,v.globalAlpha=jt;for(const Ze of t){if(!Q.has(Ze.id)||!tf(Ze,wn))continue;const nn=(_r(Ze)+6)*(1+2.4*jt);v.beginPath(),v.arc(Ze.x??0,Ze.y??0,nn,0,Math.PI*2),v.fill(),v.stroke()}v.restore()}}if(v.globalAlpha=1,mn(et,un),F){const mt=K.get(F);mt&&Nt.reposition({x:(mt.x??0)*M.k+M.x,y:(mt.y??0)*M.k+M.y,r:_r(mt)*M.k},{w:ce,h:Se})}}function R(ce,Se,Xe){const et=ce.source.id,qt=ce.target.id;return Se&&(et===Se||qt===Se)?1:Xe&&(et===Xe||qt===Xe)?2:0}function se(ce,Se,Xe){return R(ce,Se,Xe)!==0}const fe=_.append("g").attr("class","overlay-edges"),Pe=_.append("g").attr("class","overlay-nodes");let dt=null,Qe=null,pt=0,Wt="";function mn(ce,Se){if(_.attr("transform",`translate(${M.x},${M.y}) scale(${M.k})`),!ce){if(dt===null)return;fe.selectAll("*").remove(),Pe.selectAll("*").remove(),dt=null,Qe=null;return}const Xe=K.get(ce);if(!Xe){fe.selectAll("*").remove(),Pe.selectAll("*").remove(),dt=null,Qe=null;return}const et=new Set(U(ce));if(Se)for(const Ze of U(Se))et.add(Ze);et.size>80&&(et.clear(),et.add(ce),Se&&et.add(Se));const tn=Array.from(et).sort().join(",");if(!(Math.abs(M.k-pt)>.01)&&ce===dt&&Se===Qe&&tn===Wt){const Ze=[];for(const nn of et){const Tn=K.get(nn);Tn&&Ze.push(Tn)}Pe.selectAll("g.overlay-node").data(Ze,nn=>nn.id).attr("transform",nn=>`translate(${nn.x??0},${nn.y??0})`),fe.selectAll("line").attr("x1",nn=>nn.source.x??0).attr("y1",nn=>nn.source.y??0).attr("x2",nn=>nn.target.x??0).attr("y2",nn=>nn.target.y??0);return}dt=ce,Qe=Se,pt=M.k,Wt=tn;const wn=[];for(const Ze of et){const nn=K.get(Ze);nn&&wn.push(nn)}const un=tt.filter(Ze=>{const nn=Ze.source.id,Tn=Ze.target.id;return et.has(nn)&&et.has(Tn)}),Un=ft(Xe),Zn=M.k>=Fe,Qn=fe.selectAll("line").data(un,Ze=>Ze.source.id+"→"+Ze.target.id);Qn.exit().remove(),Qn.enter().append("line").attr("stroke-linecap","round").attr("stroke-width",2).attr("stroke-opacity",.9).merge(Qn).attr("x1",Ze=>Ze.source.x??0).attr("y1",Ze=>Ze.source.y??0).attr("x2",Ze=>Ze.target.x??0).attr("y2",Ze=>Ze.target.y??0).attr("stroke",Un).attr("stroke-dasharray",Ze=>Zn?"4 4":Ze.type==="imports"?"3,3":Ze.type==="links"?"1,4":"none").classed("edge-flow",Ze=>Zn&&Ze.source&&Ze.source.id===ce);const Ln=Pe.selectAll("g.overlay-node").data(wn,Ze=>Ze.id);Ln.exit().remove();const mt=Ln.enter().append("g").attr("class","overlay-node");mt.append("circle").attr("class","ring").attr("fill","transparent").attr("stroke-width",1.5),mt.append("g").attr("class","icon-slot"),mt.append("text").attr("class","label").attr("text-anchor","middle").attr("font-size","10px").attr("fill","var(--text-weak)").attr("pointer-events","none").attr("dy","2.2em");const jt=mt.merge(Ln);jt.attr("transform",Ze=>`translate(${Ze.x??0},${Ze.y??0})`).style("cursor","pointer"),jt.select("circle.ring").attr("r",Ze=>_r(Ze)+(Ze.type==="file"||Ze.type==="directory"?4:0)).attr("stroke",Ze=>ft(Ze)).attr("stroke-opacity",Ze=>Ze.id===ce?1:.7),jt.select("text.label").text(Ze=>Ze.label).attr("x",0).attr("y",0),jt.each(function(Ze){const Tn=ar(this).select("g.icon-slot");if(Tn.attr("data-for")===Ze.id)return;Tn.selectAll("*").remove(),Tn.attr("data-for",Ze.id);const wr=_r(Ze);if(Ze.type==="file"||Ze.type==="directory"){const $r=Ze.id.startsWith("file:")?Ze.id.slice(5):Ze.id.startsWith("dir:")?Ze.id.slice(4):Ze.id,er=wg($r,Ze.type,!1),Mr=Math.max(wr*1.8,14);Tn.append("svg").attr("viewBox","0 0 32 32").attr("width",Mr).attr("height",Mr).attr("x",-Mr/2).attr("y",-Mr/2).attr("pointer-events","none").append("use").attr("href",`${$g}#${er}`)}else{const $r=Op(Ze);if(!$r)return;const er=Math.max(wr*1.05,9);Tn.append("svg").attr("viewBox",kg).attr("width",er).attr("height",er).attr("x",-er/2).attr("y",-er/2).attr("fill","none").attr("stroke",ft(Ze)).attr("stroke-width",2.25).attr("stroke-linecap","round").attr("stroke-linejoin","round").html($r)}})}function $t(){const ce=()=>{if(t.length===0)return;let Se=1/0,Xe=-1/0,et=1/0,qt=-1/0;const tn=a(),jn=d();for(const mt of t){const jt=mt.x??tn/2,Ze=mt.y??jn/2;Se=Math.min(Se,jt),Xe=Math.max(Xe,jt),et=Math.min(et,Ze),qt=Math.max(qt,Ze)}const wn=120,un=Xe-Se+wn*2,Un=qt-et+wn*2,Zn=Math.max(_e,Math.min(tn/un,jn/Un,2)),Qn=(Se+Xe)/2,In=(et+qt)/2,Ln=sr.translate(tn/2-Qn*Zn,jn/2-In*Zn).scale(Zn);gt.transition().duration(550).ease(mt=>mt<.5?4*mt*mt*mt:1-Math.pow(-2*mt+2,3)/2).call(st.transform,Ln)};t.some(Se=>Se.x==null||Se.y==null)?requestAnimationFrame(ce):ce()}function Qt(ce){if(!ce){Gt();return}const Se=K.get(ce);if(!Se)return;const Xe=()=>{const et=I.get(ce)??new Set,qt=[Se,...Array.from(et).map(gr=>K.get(gr)).filter(gr=>!!gr)];let tn=1/0,jn=-1/0,wn=1/0,un=-1/0;for(const gr of qt){const co=gr.x??a()/2,uo=gr.y??d()/2;tn=Math.min(tn,co),jn=Math.max(jn,co),wn=Math.min(wn,uo),un=Math.max(un,uo)}const Un=80,Zn=jn-tn+Un*2,Qn=un-wn+Un*2,In=r.inset?.()??420,Ln=a(),mt=d(),jt=Ln-In,Ze=mt,nn=jt/Zn,Tn=Ze/Qn,Jn=Math.min(nn,Tn,2),wr=(tn+jn)/2,$r=(wn+un)/2,er=(Ln-In)/2,Mr=mt/2,Sa=sr.translate(er-wr*Jn,Mr-$r*Jn).scale(Jn);gt.transition().duration(900).ease(gr=>gr<.5?4*gr*gr*gr:1-Math.pow(-2*gr+2,3)/2).call(st.transform,Sa)};Se.x==null||Se.y==null?requestAnimationFrame(Xe):Xe()}function _t(ce){const Se=a(),Xe=d(),et=Math.max(0,Math.min(ce,Se)),qt=M.k,tn=((Se-et)/2-M.x)/qt,jn=(Xe/2-M.y)/qt,wn=sr.translate(Se/2-tn*qt,Xe/2-jn*qt).scale(qt);gt.transition().duration(560).ease(un=>un<.5?4*un*un*un:1-Math.pow(-2*un+2,3)/2).call(st.transform,wn)}function qn(ce){ce&&!K.has(ce)||Ft(ce)}Zt(),Q.size>0&&(H=requestAnimationFrame(Mt)),ht();function yn(){z&&cancelAnimationFrame(z),H&&cancelAnimationFrame(H),le&&cancelAnimationFrame(le),J&&cancelAnimationFrame(J),q?.stop(),Le(),ye.flush(),Nt.destroy(),V.disconnect(),_n.removeEventListener("mousedown",en),window.removeEventListener("mousemove",Ut),window.removeEventListener("mouseup",gn),window.removeEventListener("mousemove",Yt),window.removeEventListener("mouseup",an),window.removeEventListener("keydown",Ce),window.removeEventListener("keyup",Dt),_n.remove(),h.remove(),e.style.pointerEvents=C.pointerEvents,e.style.position=C.position,e.style.inset=C.inset,e.style.zIndex=C.zIndex,y.selectAll("*").remove(),Y.clear()}return{stop:yn,focus:Qt,fit:$t,recenter:_t,setHoveredId:qn,setPhysics:ce=>{Ee={...ce};const Se=q.force("link");Se&&Se.distance(rt());const Xe=q.force("charge");Xe&&Xe.strength(ct());const et=q.force("collide");et&&et.radius(zt()),q.alphaDecay(xt()),u||q.alpha(.3).restart()}}}const rf=new Map;function sf(e){const t=rf.get(e);if(t)return t;const n=getComputedStyle(document.documentElement).getPropertyValue(e).trim()||"#888888";return rf.set(e,n),n}var g6=x('<div class="grid grid-cols-1 gap-2 md:grid-cols-2 xl:grid-cols-4">'),m6=x('<div class="flex h-full items-center justify-center gap-2 text-12-regular text-text-weak"><span>'),h6=x('<div class="flex h-full items-center justify-center text-12-regular text-text-weak">'),p6=x('<div class="flex h-full flex-col items-center justify-center gap-3 px-6 text-center"><div class="text-13-medium text-text-strong">No README found in the project root.</div><div class="max-w-sm text-12-regular text-text-weaker">Create one explicitly to add rich project context to Home.'),v6=x('<div class="min-h-0 flex-1 overflow-hidden rounded-xl border border-border-weaker-base bg-background-base">'),b6=x('<div class="min-h-0 flex-1 overflow-y-auto"><div class="grid gap-1">'),x6=x('<div class="h-full min-h-0 overflow-y-auto bg-background-base"><div class="mx-auto flex max-w-[1400px] flex-col gap-4 p-4"><section class="rounded-2xl border border-border-weaker-base bg-gradient-to-br from-surface-raised-base/90 to-background-base p-5 shadow-sm"><div class="flex flex-col gap-5 xl:flex-row xl:items-start xl:justify-between"><div class="flex min-w-0 items-start gap-5"><button type=button class="relative size-24 shrink-0 overflow-hidden rounded-3xl border border-border-base/60 flex items-center justify-center text-32-semibold text-text-strong transition-colors hover:border-border-strong"title="Upload project logo"><span class="absolute inset-0 flex items-center justify-center bg-background-base/70 opacity-0 transition-opacity hover:opacity-100"></span></button><input type=file accept=image/* class=hidden><div class="min-w-0 flex-1"><div class="flex min-w-0 flex-wrap items-center gap-3"><h1 class="min-w-0 truncate text-[42px] font-semibold leading-none tracking-tight text-text-strong"></h1></div><div class="mt-4 flex flex-wrap items-center gap-2 text-11-regular text-text-weaker"><span></span></div></div></div><div class="grid shrink-0 grid-cols-2 gap-2 sm:grid-cols-4 xl:w-[520px]"></div></div></section><div class="grid grid-cols-12 gap-4"><div class="col-span-12 grid grid-cols-12 items-start gap-4">'),y6=x('<img alt class="size-full object-cover">'),w6=x('<span class="shrink-0 rounded-full bg-surface-raised-base px-2 py-0.5 text-11-regular text-text-weaker">branch: '),$6=x("<span>last activity "),k6=x('<div class="px-1 text-10-medium text-text-weaker">+<!> more'),_6=x('<div class="min-h-[220px] rounded-xl border border-border-weaker-base bg-background-base/50 p-2"><div class="mb-2 flex items-center justify-between gap-2 px-1"><div class="truncate text-11-semibold uppercase tracking-wide text-text-weak"></div><div class="rounded-full bg-surface-raised-base px-2 py-0.5 text-10-medium text-text-weaker"></div></div><div class="grid gap-2">'),C6=x('<div class="px-1 py-6 text-center text-11-regular text-text-weaker">No cards'),S6=x('<button class="rounded-lg border border-border-weaker-base bg-surface-raised-base/45 p-2 text-left transition-colors hover:border-border-base hover:bg-surface-raised-base"><div class="mb-2 flex items-center gap-2"><span></span></div><div class="line-clamp-2 text-12-medium leading-4 text-text-strong">'),T6=x('<div class="px-6 py-4 text-text-weak">'),A6=x('<div class="text-12-regular text-text-weaker">No recent Trellis operations yet.'),D6=x('<div class="flex items-center gap-3 rounded-lg border border-transparent px-2 py-2 hover:bg-surface-raised-base/40"><div class="min-w-0 flex-1 truncate text-12-regular text-text-base"></div><div class="shrink-0 text-11-mono text-text-weaker"></div><div class="shrink-0 text-11-regular text-text-weaker">'),M6=x('<section><div class="mb-3 flex items-center gap-2"><h2 class="text-13-semibold text-text-strong">'),E6=x('<div class="rounded-xl border border-border-weaker-base bg-background-base/70 p-3"><div class="text-10-medium uppercase tracking-wide text-text-weaker"></div><div class="mt-1 text-20-semibold text-text-strong">'),I6=x('<div class="mt-1 truncate text-11-regular text-text-weaker">');const L6=[{id:"backlog",label:"Backlog",tone:"var(--text-weak)"},{id:"queue",label:"Queue",tone:"var(--text-weak)"},{id:"in_progress",label:"In Progress",tone:"var(--text-weak)"},{id:"paused",label:"Paused",tone:"var(--text-weak)"},{id:"closed",label:"Closed",tone:"var(--text-weak)"}],P6={backlog:"backlog",in_progress:"in_progress",done:"closed"};function of(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function F6(){const e=yr(),t=hn(),n=zn(),r=pg(),i=eo(),o=br(),a=Gl(),d=io(),{tabs:c}=Ur();let u;const[g,f]=St({ready:!1,path:void 0,creating:!1,uploading:!1,logo:void 0}),m=T(()=>o.project?.name||Sn(n.directory)||"Project"),p=T(()=>o.project?.icon?.override||o.project?.icon?.url||g.logo),w=T(()=>o.project?.icon?.color||"var(--surface-info-base)"),h=T(()=>a?.issues??[]),k=T(()=>a?.workUnits??[]),v=T(()=>a?.stats),C=T(()=>[...h().filter(A=>A.status!=="closed").map(A=>({kind:"issue",id:A.id,title:A.title,status:A.status,priority:A.priority})),...k().filter(A=>A.status!=="done").map(A=>({kind:"workunit",id:A.id,title:A.title,status:A.status,priority:A.priority}))]),y=T(()=>L6.filter(A=>A.id!=="closed").map(A=>({...A,items:[...h().filter(F=>F.status===A.id).map(F=>({kind:"issue",id:F.id,title:F.title,status:F.status,priority:F.priority})),...k().filter(F=>P6[F.status]===A.id).map(F=>({kind:"workunit",id:F.id,title:F.title,status:F.status,priority:F.priority}))]}))),b=T(()=>a?[...a.ops].reverse():[]),_=A=>(f("path",A),f("ready",!0),e.load(A).then(()=>{e.setMode(A,"rich")})),$=()=>{g.creating||(f("creating",!0),n.client.file.write({fileWriteInput:{path:"README.md",content:`# ${m()}
27
+
28
+ Welcome to ${m()}.
29
+
30
+ ## Getting started
31
+
32
+ Start by describing what this project is for and what you're building.
33
+ `,format:!0}}).then(()=>e.tree.refresh("")).then(()=>_("README.md")).finally(()=>f("creating",!1)))},D=async A=>{if(A.type.startsWith("image/")&&!g.uploading){f("uploading",!0);try{const F=await lf(A,512),N=await N6(await lf(A,64)),X=await O6(F);await Promise.all([n.client.file.write({fileWriteInput:{path:"favicon.png",content:af(F),encoding:"base64",mimeType:"image/png",format:!1}}),n.client.file.write({fileWriteInput:{path:"favicon.ico",content:af(N),encoding:"base64",mimeType:"image/x-icon",format:!1}})]);const B=o.project,O={color:B?.icon?.color||"pink",override:X};B?.id&&B.id!=="global"&&await r.client.project.update({projectID:B.id,directory:B.worktree,name:B.name??"",icon:O,commands:{start:B.commands?.start??""}}),i.project.meta(n.directory,{icon:O}),i.project.icon(n.directory,X),f("logo",X),await e.tree.refresh(""),nt({variant:"success",title:"Project logo updated"})}catch(F){nt({variant:"error",title:"Logo upload failed",description:F instanceof Error?F.message:String(F)})}finally{f("uploading",!1),u&&(u.value="")}}};Mn(()=>{a?.fetchOps(400),a?.fetchStoreEntities(),e.tree.list("").then(()=>{const A=e.tree.children("").find(N=>{if(N.type!=="file")return!1;const X=N.path.split("/").pop()??N.path;return/^readme(?:\.(md|markdown|mdx|note))?$/i.test(X)}),F=e.tree.children("").find(N=>N.type!=="file"?!1:/^favicon\.(png|ico)$/i.test(N.path.split("/").pop()??N.path));if(!o.project?.icon?.override&&!o.project?.icon?.url&&F&&f("logo",Ns(n.url,F.path,n.directory)),!A){f("ready",!0);return}return _(A.path)}).catch(()=>f("ready",!0))});const L=T(()=>g.path),V=T(()=>{const A=L();if(A)return e.get(A)}),K=T(()=>{const A=L();return A?e.text(A)??"":""}),I=T(()=>{const A=V()?.content;return A?.type==="text"&&A.encoding!=="base64"}),U=T(()=>{if(!L())return;const A=K().split(/\r\n|\r|\n/).reduce((F,N)=>F+Math.max(1,Math.ceil(N.length/92)),0);return Math.max(120,A*24+96)}),Y=T(()=>{const A=U();return A?{height:`${A}px`}:{"aspect-ratio":"1 / 1"}}),S=T(()=>{const A=U();return A?{"max-height":`${A}px`}:{"aspect-ratio":"1 / 1"}}),M=()=>{const A=L();A&&e.save(A)};return(()=>{var A=x6(),F=A.firstChild,N=F.firstChild,X=N.firstChild,B=X.firstChild,O=B.firstChild,z=O.firstChild,q=O.nextSibling,Q=q.nextSibling,j=Q.firstChild,H=j.firstChild,J=j.nextSibling,le=J.firstChild,de=B.nextSibling,Re=N.nextSibling,Ve=Re.firstChild;return O.$$click=()=>u?.click(),l(O,s(E,{get when(){return p()},get fallback(){return m().slice(0,1).toUpperCase()},children:Z=>(()=>{var ne=y6();return G(()=>ue(ne,"src",Z())),ne})()}),z),l(z,s(E,{get when(){return g.uploading},get fallback(){return s(Ue,{name:"cloud-upload",size:"large",class:"text-icon-strong"})},get children(){return s(Ti,{})}})),q.addEventListener("change",Z=>{const ne=Z.currentTarget.files?.[0];ne&&D(ne)}),Lt(Z=>{u=Z},q),l(H,m),l(j,s(E,{get when(){return v()?.branch},children:Z=>(()=>{var ne=w6();return ne.firstChild,l(ne,Z,null),ne})()}),null),l(le,()=>n.directory),l(J,s(E,{get when(){return a?.latestOp()},children:Z=>(()=>{var ne=$6();return ne.firstChild,l(ne,()=>of(Z().timestamp),null),ne})()}),null),l(de,s(Mo,{label:"Entities",get value(){return a?.storeEntities.length??0},hint:"store catalog"}),null),l(de,s(Mo,{label:"Active issues",get value(){return v()?.activeIssues??C().filter(Z=>Z.kind==="issue").length},get hint(){return`${v()?.issueCount??h().length} total issues`}}),null),l(de,s(Mo,{label:"Graph nodes",get value(){return v()?.nodeCount??0},get hint(){return`${v()?.edgeCount??0} edges`}}),null),l(de,s(Mo,{label:"Tracked files",get value(){return v()?.trackedFiles??0},get hint(){return`${v()?.totalOps??0} ops`}}),null),l(Re,s(Xa,{title:"Work Board",get icon(){return s(Ue,{name:"checklist",size:"small",class:"text-icon-weak"})},class:"col-span-12",get children(){var Z=g6();return l(Z,s(Oe,{get each(){return y()},children:ne=>(()=>{var re=_6(),ie=re.firstChild,be=ie.firstChild,Fe=be.nextSibling,ee=ie.nextSibling;return l(be,()=>ne.label),l(Fe,()=>ne.items.length),l(ee,s(Oe,{get each(){return ne.items.slice(0,4)},get fallback(){return C6()},children:_e=>(()=>{var xe=S6(),ye=xe.firstChild,Le=ye.firstChild,tt=ye.nextSibling;return xe.$$click=()=>d.push(_e.id,_e.kind),l(ye,s(Gn,{get type(){return _e.kind},size:14,class:"shrink-0"}),Le),l(Le,()=>_e.priority),l(tt,()=>_e.title),G(()=>Ht(Le,`rounded-full px-1.5 py-0.5 text-9-medium uppercase ${R6(_e.priority)}`)),xe})()}),null),l(ee,s(E,{get when(){return ne.items.length>4},get children(){var _e=k6(),xe=_e.firstChild,ye=xe.nextSibling;return ye.nextSibling,l(_e,()=>ne.items.length-4,ye),_e}}),null),re})()})),Z}}),Ve),l(Ve,s(Xa,{title:"README.md",get icon(){return s(Ue,{name:"file-text",size:"small",class:"text-icon-weak"})},get class(){return`col-span-12 self-start ${L()?"xl:col-span-8":"xl:col-span-6"}`},get children(){var Z=v6();return l(Z,s(Dn,{get children(){return[s(ot,{get when(){return!g.ready},get children(){var ne=m6(),re=ne.firstChild;return l(ne,s(Ti,{}),re),l(re,()=>t.t("common.loading"),null),l(re,()=>t.t("common.loading.ellipsis"),null),ne}}),s(ot,{get when(){return Te(()=>!!(L()&&V()?.loaded))()&&I()},get children(){return s(_g,{get path(){return L()},get state(){return V()},get value(){return K()},active:!0,onChange:ne=>e.setDraft(L(),ne),onSave:M,onMode:ne=>e.setMode(L(),ne),mention:{search:ne=>Cg({query:ne,file:e,sync:o,trellis:a}),fetch:async(ne,re)=>{if(re==="file")return await e.load(ne),e.text(ne)},navigate:ne=>{if(ne.type!=="file")return;const re=e.tab(ne.id);c().all().includes(re)||c().open(re),c().setActive(re),e.load(ne.id)},onCreate:async ne=>{try{await n.client.file.write({fileWriteInput:{path:ne,content:"",format:!1}});const re=ne.includes("/")?ne.slice(0,ne.lastIndexOf("/")):"";return await e.tree.refresh(re),re&&e.tree.expand(re),nt({variant:"success",title:`Created ${ne}`}),ne}catch(re){const ie=re instanceof Error?re.message:String(re);nt({variant:"error",title:"Create failed",description:ie});return}}}})}}),s(ot,{get when(){return Te(()=>!!L())()&&V()?.loading},get children(){var ne=h6();return l(ne,()=>t.t("common.loading"),null),l(ne,()=>t.t("common.loading.ellipsis"),null),ne}}),s(ot,{get when(){return V()?.error},children:ne=>(()=>{var re=T6();return l(re,ne),re})()}),s(ot,{get when(){return g.ready},get children(){var ne=p6(),re=ne.firstChild;return re.nextSibling,l(ne,s(kt,{size:"small",variant:"secondary",onClick:$,get disabled(){return g.creating},get children(){return g.creating?"Creating...":"Create README"}}),null),ne}})]}})),G(ne=>Pn(Z,Y(),ne)),Z}}),null),l(Ve,s(Xa,{title:"Recent Activity",get icon(){return s(Ue,{name:"history",size:"small",class:"text-icon-weak"})},get class(){return`col-span-12 min-h-0 self-start overflow-hidden ${L()?"xl:col-span-4":"xl:col-span-6"}`},get style(){return S()},get children(){var Z=b6(),ne=Z.firstChild;return l(ne,s(Oe,{get each(){return b()},get fallback(){return A6()},children:re=>(()=>{var ie=D6(),be=ie.firstChild,Fe=be.nextSibling,ee=Fe.nextSibling;return l(ie,s(Sg,{get kind(){return re.kind}}),be),l(be,()=>B6(re)),l(Fe,()=>re.hash.slice(0,7)),l(ee,()=>of(re.timestamp)),G(_e=>{var xe={"border-text-accent/30 bg-surface-raised-base/70":re.kind==="vcs:decisionRecord"},ye=re.kind==="vcs:decisionRecord"?z6():void 0;return _e.e=Tt(ie,xe,_e.e),_e.t=Pn(ie,ye,_e.t),_e},{e:void 0,t:void 0}),ie})()})),Z}}),null),G(Z=>{var ne=w(),re=g.uploading;return ne!==Z.e&&Je(O,"background",Z.e=ne),re!==Z.t&&(O.disabled=Z.t=re),Z},{e:void 0,t:void 0}),A})()}function Xa(e){return(()=>{var t=M6(),n=t.firstChild,r=n.firstChild;return l(n,()=>e.icon,r),l(r,()=>e.title),l(t,()=>e.children,null),G(i=>{var o=`flex flex-col rounded-2xl border border-border-weaker-base bg-surface-raised-base/45 p-4 ${e.class??""}`,a=e.style;return o!==i.e&&Ht(t,i.e=o),i.t=Pn(t,a,i.t),i},{e:void 0,t:void 0}),t})()}function Mo(e){return(()=>{var t=E6(),n=t.firstChild,r=n.nextSibling;return l(n,()=>e.label),l(r,()=>e.value),l(t,s(E,{get when(){return e.hint},children:i=>(()=>{var o=I6();return l(o,i),o})()}),null),t})()}function R6(e){return e==="critical"?"bg-danger-base/15 text-danger-base":e==="high"?"bg-warning-base/15 text-warning-base":e==="low"?"bg-surface-raised-base text-text-weaker":"bg-text-info/10 text-text-info"}function z6(){return{"border-left":"3px solid var(--text-accent)","background-image":"linear-gradient(90deg, color-mix(in srgb, var(--text-accent) 12%, transparent), transparent 55%)"}}function af(e){const t=new Uint8Array(e),n=32768;return btoa(Array.from({length:Math.ceil(t.length/n)},(r,i)=>String.fromCharCode(...t.subarray(i*n,i*n+n))).join(""))}function O6(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error??new Error("Unable to read image")),r.readAsDataURL(new Blob([e],{type:"image/png"}))})}function lf(e,t){return new Promise((n,r)=>{const i=URL.createObjectURL(e),o=new Image;o.onload=()=>{const a=document.createElement("canvas"),d=a.getContext("2d");if(!d){URL.revokeObjectURL(i),r(new Error("Unable to render image"));return}const c=Math.max(t/o.naturalWidth,t/o.naturalHeight),u=o.naturalWidth*c,g=o.naturalHeight*c;a.width=t,a.height=t,d.clearRect(0,0,t,t),d.drawImage(o,(t-u)/2,(t-g)/2,u,g),a.toBlob(f=>{if(URL.revokeObjectURL(i),!f){r(new Error("Unable to encode image"));return}f.arrayBuffer().then(n,r)},"image/png")},o.onerror=()=>{URL.revokeObjectURL(i),r(new Error("Unable to load image"))},o.src=i})}function N6(e){const t=new Uint8Array(e),n=new ArrayBuffer(22+t.length),r=new DataView(n);return r.setUint16(0,0,!0),r.setUint16(2,1,!0),r.setUint16(4,1,!0),r.setUint8(6,64),r.setUint8(7,64),r.setUint8(8,0),r.setUint8(9,0),r.setUint16(10,1,!0),r.setUint16(12,32,!0),r.setUint32(14,t.length,!0),r.setUint32(18,22,!0),new Uint8Array(n,22).set(t),n}function B6(e){return e.milestoneMessage?e.milestoneMessage:e.filePath?`${e.kind} — ${e.filePath.split("/").pop()}`:e.branchName?`${e.kind} — ${e.branchName}`:e.kind}Kt(["click"]);var q6=x('<div class="flex-1 min-h-0 overflow-x-auto overflow-y-hidden"><div class="h-full flex gap-4 p-4">'),j6=x('<div class="flex-1 min-h-0 flex flex-col overflow-hidden">'),V6=x('<div class="size-full min-h-0 flex flex-col bg-background-base overflow-hidden"><div class="shrink-0 px-6 py-4 border-b border-border-weaker-base flex items-center gap-3"><div class="flex items-center gap-2 min-w-0"><div class="text-14-medium text-text-strong">Trellis Board</div><div class="text-12-regular text-text-weak"> issues · <!> work units</div></div><div class=flex-1>'),cf=x('<div class="flex-1 flex items-center justify-center text-12-regular text-text-weak">'),df=x('<button class="flex items-center justify-center size-6 rounded-md hover:bg-surface-raised-base transition-colors">'),H6=x('<div class="mt-1 p-2 rounded-md bg-surface-raised-base border border-border-base flex flex-col gap-2"><div class="flex items-center gap-2"><div class=flex-1>'),U6=x('<section><div><div></div><div class="text-12-medium uppercase tracking-wide text-text-strong"></div><div class=flex-1></div></div><div class="flex-1 min-h-0 overflow-y-auto p-2 flex flex-col gap-2">'),W6=x('<div class="px-2 py-4 text-12-regular text-text-weak text-center">No items'),K6=x('<div class="rounded-md border border-dashed border-border-info/40 bg-surface-raised-base/40 px-3 py-2 flex flex-col gap-1.5"><div class="flex items-center gap-2"><span class="rounded-full bg-surface-raised-base/60 px-2 py-0.5 text-10-medium text-text-info">plan</span><span class="text-10-medium uppercase text-text-weak/70"></span></div><div class="text-13-medium text-text-strong/90 leading-5">'),G6=x('<div class="flex flex-wrap gap-1">'),Y6=x('<div class="w-12 h-1 rounded-full overflow-hidden bg-surface-raised-base/50"><div class="h-full rounded-full">'),X6=x("<div class=text-text-weak/90>/<!> AC"),Z6=x('<div class="rounded-md border px-3 py-2 flex flex-col gap-2 transition-all cursor-pointer backdrop-blur-sm"><div class="flex items-start gap-2"><div class="text-12-medium text-text-info/80 shrink-0 font-mono"></div><div class="text-10-medium uppercase rounded px-1.5 py-0.5 bg-surface-raised-base/60 text-text-weak/90 shrink-0"></div><div class=flex-1></div><button type=button title="Start implementation session"class="flex items-center justify-center size-6 -mr-1 rounded-md text-icon-weak hover:text-text-info hover:bg-surface-raised-base transition-colors disabled:opacity-50 disabled:pointer-events-none"></button></div><div class="text-13-medium text-text-strong/95 leading-5"></div><div class="flex items-center gap-2 text-11-regular text-text-weak/80"><div class=flex-1>'),Q6=x('<div class="text-11-regular text-text-weak truncate max-w-24">'),J6=x('<div class="text-12-regular text-text-weak/80 line-clamp-2">'),eT=x('<span class="rounded-full bg-surface-raised-base/60 px-2 py-0.5 text-10-medium text-text-weak/90">'),tT=x("<div class=text-text-weak/90>"),_a=x('<div class="flex flex-col">'),nT=x('<div class="flex flex-col h-full overflow-hidden"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"></div><div class="flex-1 overflow-auto">'),rT=x('<div class="flex flex-col items-center gap-2 py-8 text-text-weak"><div class=text-12-regular>No ops recorded yet'),iT=x('<div class="text-11-mono text-text-weak truncate">'),sT=x('<div class="text-11-mono text-text-info truncate">'),oT=x('<div class="text-11-regular text-text-base italic truncate">'),aT=x('<div class="flex items-start gap-3 px-3 py-2 border-b border-border-weaker-base hover:bg-surface-raised-base/50 transition-colors"><div class="flex-1 min-w-0"></div><div class="shrink-0 text-11-regular text-text-weaker whitespace-nowrap">'),lT=x('<div class="flex-1 overflow-auto">'),cT=x('<div class="flex flex-col h-full overflow-hidden"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"><div class="text-12-medium text-text-weak flex-1">Decision Traces'),dT=x('<div class="flex flex-col items-center gap-2 py-8 text-text-weak"><div class=text-12-regular>No decisions recorded yet'),uT=x('<div class="text-11-regular text-text-weak truncate">session: '),fT=x('<div class="text-11-regular text-text-weaker truncate">'),gT=x('<button class="flex items-start gap-3 px-3 py-2 border-b border-border-weaker-base hover:bg-surface-raised-base/50 transition-colors text-left w-full"><div class="mt-0.5 shrink-0"></div><div class="flex-1 min-w-0"><div class="text-12-medium text-text-strong"></div></div><div class="shrink-0 text-11-regular text-text-weaker whitespace-nowrap">'),mT=x('<div class="flex flex-col gap-1"><div class="text-10-medium uppercase tracking-wide text-text-weak">Session</div><div class="text-12-regular text-text-base">'),hT=x('<div class="flex flex-col gap-1"><div class="text-10-medium uppercase tracking-wide text-text-weak">Input</div><pre class="text-11-mono text-text-base p-2 rounded bg-background-base border border-border-base overflow-x-auto max-h-48">'),pT=x('<div class="flex flex-col gap-1"><div class="text-10-medium uppercase tracking-wide text-text-weak">Output</div><pre class="text-11-mono text-text-base p-2 rounded bg-background-base border border-border-base overflow-x-auto max-h-48">'),vT=x('<div class="flex flex-col gap-1"><div class="text-10-medium uppercase tracking-wide text-text-weak">Related Entities</div><div class="flex flex-wrap gap-1">'),bT=x('<div class="flex flex-col gap-1"><div class="text-10-medium uppercase tracking-wide text-text-weak">Metadata</div><pre class="text-11-mono text-text-base p-2 rounded bg-background-base border border-border-base overflow-x-auto max-h-32">'),xT=x('<div class="flex-1 overflow-auto flex flex-col"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"><div class="text-12-medium text-text-strong"></div><div class=flex-1></div><div class="text-11-regular text-text-weaker"></div></div><div class="p-3 flex flex-col gap-3">'),yT=x('<span class="text-11-mono px-1.5 py-0.5 rounded bg-surface-raised-base text-text-info">'),Np=x('<div class="px-3 py-2 border-b border-border-weaker-base flex items-center gap-2">'),wT=x('<div class="flex flex-col h-full overflow-hidden"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"><div class="text-12-medium text-text-weak flex-1">Branches</div></div><div class="flex-1 overflow-auto">'),$T=x('<div class="px-3 py-8 text-center text-12-regular text-text-weaker">No branches'),kT=x('<span class="text-10-medium uppercase text-text-success">current'),_T=x('<button class="flex items-center gap-3 px-3 py-2 border-b border-border-weaker-base hover:bg-surface-raised-base/50 transition-colors w-full text-left"><div class="flex-1 min-w-0"><div>'),CT=x('<div class="flex flex-col h-full overflow-hidden"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"><div class="text-12-medium text-text-weak flex-1">Milestones</div></div><div class="flex-1 overflow-auto">'),ST=x('<div class="px-3 py-8 text-center text-12-regular text-text-weaker">No milestones'),TT=x("<span>"),AT=x("<span> files"),DT=x('<div class="px-3 py-2 border-b border-border-weaker-base flex items-start gap-3"><div class="mt-0.5 shrink-0"></div><div class="flex-1 min-w-0 flex flex-col gap-1"><div class="text-12-medium text-text-strong"></div><div class="flex items-center gap-2 text-11-regular text-text-weaker">'),MT=x('<div class="shrink-0 overflow-hidden relative"style="transition:width 420ms cubic-bezier(0.16, 1, 0.3, 1)"><div class="flex h-full absolute top-0 left-0 bottom-0"style="will-change:opacity;transition:opacity 220ms ease-out"><div class=relative>'),ET=x('<div class="absolute inset-0 flex flex-col items-center justify-center gap-2 pointer-events-none"><span class="text-12-regular text-text-weak">Loading graph'),IT=x('<div class="absolute inset-0 flex items-center justify-center pointer-events-none"><div class="max-w-sm px-6 py-4 text-center pointer-events-auto"><div class="text-13-medium text-text-weak mb-1">Error loading graph</div><div class="text-11-regular text-text-weaker mb-3"></div><button class="px-3 py-1 text-11-medium bg-surface-raised-base border border-border-base rounded hover:bg-surface-raised-hover transition-colors">Retry'),LT=x('<div class="absolute inset-0 flex items-center justify-center pointer-events-none"><div class="max-w-sm px-6 py-4 text-center pointer-events-auto"><div class="text-13-medium text-text-weak mb-1">No graph data</div><div class="text-11-regular text-text-weaker">Either this project has no tracked entities yet, or the backend is missing the trellis routes.'),PT=x('<div class="flex w-full h-full bg-background-base overflow-hidden"><div class="relative flex-1 h-full overflow-hidden"><svg class="w-full h-full"style=touch-action:none>'),FT=x("<div class=py-1>"),RT=x('<div class="absolute z-20 rounded-md border border-border-base shadow-lg pointer-events-auto"style="bottom:144px;left:12px;width:180px;background:color-mix(in srgb, var(--background-base) 88%, transparent)"><div class="flex items-center justify-between gap-2 px-2 py-1.5 border-b border-border-weaker-base"><button class="flex items-center gap-1.5 text-10-medium uppercase tracking-wide text-text-weaker hover:text-text-base transition-colors">Physics</button><button class="text-10-medium uppercase tracking-wide text-text-weaker hover:text-text-base transition-colors"title="Reset all physics multipliers to 1×">Reset'),zT=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-colors"title="Include dotfiles and gitignored paths (e.g. node_modules)"><span class="flex-1 truncate">Hidden files</span><span class="size-1.5 shrink-0 rounded-full transition-colors">'),OT=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-colors"title="Derive edges from imports, requires, and @import statements"><span class="flex-1 truncate">Import edges</span><span class="size-1.5 shrink-0 rounded-full transition-colors">'),NT=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-colors"title="Derive edges from markdown links ([text](file)) and wiki-links ([[file]])"><span class="flex-1 truncate">Link edges</span><span class="size-1.5 shrink-0 rounded-full transition-colors">'),BT=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-colors"title="Include recent causal-stream ops (capped at 100)"><span class="flex-1 truncate">Ops</span><span class="size-1.5 shrink-0 rounded-full transition-colors">'),qT=x('<aside class="shrink-0 border-r border-border-weaker-base bg-surface-raised-base/00 px-2 py-3 flex flex-col gap-1 overflow-y-auto">'),jT=x('<div class="px-2.5 py-1.5 text-11-regular text-text-weaker italic">No custom entities'),VT=x('<div class="px-2 pb-1 flex items-center justify-between"><button class="flex items-center gap-1.5 text-10-medium uppercase tracking-wide text-text-weaker hover:text-text-base transition-colors"><span>'),HT=x('<button class="text-10-medium uppercase tracking-wide text-text-weaker hover:text-text-base transition-colors">'),UT=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-all group"><span class="flex-1 truncate capitalize"></span><span class="text-11-regular text-text-weaker tabular-nums group-hover:text-text-weak transition-colors"></span><span class="size-1.5 shrink-0 rounded-full transition-colors">'),WT=x('<div class="px-2.5 py-1"><div class="flex items-center justify-between text-12-medium text-text-weak"><span></span><span class="text-10-regular tabular-nums text-text-weaker">×</span></div><input type=range min=0.25 max=4 step=0.05 class="w-full h-1 mt-1 accent-text-strong">'),KT=x('<div class="absolute left-0 top-0 bottom-0 z-30">'),GT=x('<div class="absolute top-0 right-0 bottom-0 h-full p-4 rounded pointer-events-none"><div class="relative z-20 bg-background-base flex flex-col rounded-lg border border-border-base/50 h-full overflow-hidden"style="will-change:transform, opacity;transition:transform 560ms cubic-bezier(0.16, 1, 0.3, 1), opacity 240ms ease-out">'),YT=x('<div class="shrink-0 flex flex-col gap-0.5 px-3 py-2.5 border-b border-border-base/50"><div class="flex items-center gap-1"><div class="flex items-center gap-0 shrink-0"></div><span class="flex-1 min-w-0 text-12-medium text-text-strong truncate"></span></div><div class=pl-0><span class="text-9-regular text-text-weaker/75 font-mono truncate block">'),XT=x('<div class="flex flex-col h-full overflow-hidden"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"><div class="flex-1 text-center text-12-medium text-text-strong"> </div></div><div class="flex-1 min-h-0 flex flex-col overflow-hidden px-3 pt-2 pb-1"><div class="shrink-0 grid grid-cols-7 gap-px mb-1"></div><div class="flex-1 min-h-0 grid grid-cols-7 gap-px"style=grid-auto-rows:1fr></div><div class="shrink-0 pt-1.5 flex items-center gap-3 flex-wrap text-10-regular text-text-weaker"><div class="flex items-center gap-1"><div class="w-1.5 h-1.5 rounded-full"></div>Critical</div><div class="flex items-center gap-1"><div class="w-1.5 h-1.5 rounded-full"></div>High</div><div class="flex items-center gap-1"><div class="w-1.5 h-1.5 rounded-full"></div>Medium</div><div class="flex items-center gap-1"><div class="w-1.5 h-1.5 rounded-full"></div>Low</div><div class="flex items-center gap-1"><div class="w-1.5 h-1.5 rounded-sm bg-text-interactive-base"></div>Milestone</div><div class="flex items-center gap-1"><div class="w-1.5 h-1.5 rounded-sm"></div>WorkUnit'),ZT=x('<div class="text-center text-10-medium text-text-weaker py-0.5">'),QT=x('<div class="text-10-medium mb-0.5 w-4 h-4 flex items-center justify-center rounded-full">'),JT=x('<div class="flex flex-wrap gap-px">'),e9=x('<div class="p-1 rounded-md overflow-hidden">'),t9=x('<div class="w-1.5 h-1.5 shrink-0">'),n9=x('<div class="w-1.5 h-1.5 rounded-sm shrink-0 bg-text-interactive-base">'),r9=x('<div class="flex flex-col h-full overflow-hidden"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"><div class="text-12-medium text-text-weak flex-1">Proactive Suggestions</div></div><div class="flex-1 overflow-auto">'),i9=x('<div class="flex flex-col items-center gap-2 py-8 text-text-weak"><div class=text-12-regular>No suggestions right now'),s9=x('<div class="flex items-start gap-3 px-3 py-3 border-b border-border-weaker-base"><div class="mt-0.5 shrink-0"></div><div class="flex-1 min-w-0"><div class="text-12-medium text-text-strong"></div><div class="text-11-regular text-text-weak mt-0.5">Rule: '),o9=x('<div class="flex flex-col h-full overflow-hidden"><div class="shrink-0 px-3 py-2 border-b border-border-weaker-base flex items-center gap-2"><div class="text-12-medium text-text-weak flex-1">Plan History</div></div><div class="flex-1 overflow-auto">'),a9=x('<div class="flex flex-col items-center gap-2 py-8 text-text-weak"><div class=text-12-regular>No plans yet'),l9=x('<div class="text-12-regular text-text-weak mb-1">'),c9=x('<div class="text-12-regular text-text-danger mt-1">Rejected: '),d9=x('<div class="px-3 pb-3 flex flex-col gap-1.5">'),u9=x('<div class="border-b border-border-weaker-base"><button class="w-full flex items-center gap-3 px-3 py-2 hover:bg-surface-raised-base/50 transition-colors text-left"><span></span><div class="flex-1 min-w-0"><div class="text-12-medium text-text-strong truncate"></div></div><span class="text-11-regular text-text-weaker"> ops</span><span class="text-11-regular text-text-weaker">'),f9=x("<span class=text-text-weak>"),g9=x('<span class="text-text-weaker truncate flex-1">'),m9=x('<div class="flex items-center gap-2 px-2 py-1 rounded-md bg-background-base/50 text-12-regular"><span class="text-text-info font-mono">'),h9=x('<div class="flex flex-col h-full overflow-y-auto px-4 py-4 gap-6"><div class="flex flex-col gap-2"><div class="text-11-medium uppercase tracking-wide text-text-weaker">Weekly Throughput</div><div class="flex items-end gap-1 h-24"></div><div class="flex items-center gap-4 text-10-regular text-text-weaker"><div class="flex items-center gap-1"><div class="w-2 h-2 rounded-sm bg-text-info/60"></div>Created</div><div class="flex items-center gap-1"><div class="w-2 h-2 rounded-sm bg-text-success/60"></div>Closed</div></div></div><div class="flex flex-col gap-2"><div class="text-11-medium uppercase tracking-wide text-text-weaker">By Priority</div><div class="flex flex-col gap-1.5"></div></div><div class="flex flex-col gap-2"><div class="text-11-medium uppercase tracking-wide text-text-weaker">By Status</div><div class="flex flex-col gap-1.5">'),p9=x('<div class="flex-1 flex flex-col items-center gap-0.5"><div class="w-full flex gap-px justify-center"style=height:80px><div class="w-2 rounded-t bg-text-info/60 self-end transition-all"></div><div class="w-2 rounded-t bg-text-success/60 self-end transition-all"></div></div><div class="text-[9px] text-text-weaker">'),v9=x('<div class="flex items-center gap-2"><div class="w-16 text-11-regular text-text-weak capitalize"></div><div class="flex-1 h-2 rounded-full bg-surface-raised-base/50 overflow-hidden"><div></div></div><div class="w-6 text-right text-11-medium text-text-base">'),b9=x('<div class="flex items-center gap-2"><div class="w-20 text-11-regular text-text-weak capitalize"></div><div class="flex-1 h-2 rounded-full bg-surface-raised-base/50 overflow-hidden"><div></div></div><div class="w-6 text-right text-11-medium text-text-base">'),x9=x('<div class="flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden">');const y9=[{id:"backlog",label:"Backlog",tone:"var(--text-weak)"},{id:"queue",label:"Queue",tone:"var(--text-weak)"},{id:"in_progress",label:"In Progress",tone:"var(--text-weak)"},{id:"paused",label:"Paused",tone:"var(--text-weak)"},{id:"closed",label:"Closed",tone:"var(--text-weak)"}],w9={pending:"backlog",in_progress:"in_progress",completed:"closed"},uf={backlog:"backlog",in_progress:"in_progress",done:"closed"},$9={backlog:"backlog",in_progress:"in_progress",closed:"done"};function fi(e){return`${e.kind}:${e.item.id}`}function Bp(e){return e.kind==="issue"?e.item.labels:e.item.tags}function Nl(e){return e.kind==="issue"?e.item.description:e.item.cycle||e.item.specPath}function k9(e){return e.kind==="issue"?e.item.branch:void 0}function _9(e){const t=e.item,n=e.kind==="issue"?"Trellis issue":"Trellis WorkUnit",r=Bp(e),i=(t.criteria??[]).map(a=>{const d=a.status?` [${a.status}]`:"",c=a.command?`
34
+ command: ${a.command}`:"";return`- ${a.description??a.id}${d}${c}`}).join(`
35
+ `),o=[`ID: ${t.id}`,`Title: ${t.title}`,`Status: ${t.status}`,`Priority: ${t.priority}`,r.length?`Tags: ${r.join(", ")}`:void 0,"branch"in t&&t.branch?`Branch: ${t.branch}`:void 0,"cycle"in t&&t.cycle?`Cycle: ${t.cycle}`:void 0,"specPath"in t&&t.specPath?`Spec: ${t.specPath}`:void 0,t.assignee?`Assignee: ${t.assignee}`:void 0,Nl(e)?`Details: ${Nl(e)}`:void 0,t.criteriaCount?`Acceptance: ${t.criteriaPassed}/${t.criteriaCount}`:void 0].filter(a=>!!a);return`Begin implementing this ${n}.
36
+
37
+ ${o.join(`
38
+ `)}
39
+
40
+ ${i?`Acceptance criteria:
41
+ ${i}
42
+
43
+ `:""}Inspect the codebase, make the required changes, validate them, and summarize the result.`}function C9(e){const t=Ar(),n=io(),r=hn(),i=Pi(),o=Ri(),a=zn(),d=br(),c=T(()=>t.issues),u=T(()=>t.workUnits),g=T(()=>[...c().map(I=>({kind:"issue",item:I,col:I.status})),...u().map(I=>({kind:"workunit",item:I,col:uf[I.status]}))]),[f,m]=ke(),[p,w]=ke(),[h,k]=ke(null),[v,C]=ke(""),[y,b]=ke("medium"),[_,$]=St({id:void 0}),D=I=>{m(fi(I)),n.push(I.item.id,I.kind)},L=I=>{w(void 0);const U=I.draggable?.id,Y=I.droppable?.id;if(!U||!Y)return;const S=c().find(F=>fi({kind:"issue",item:F,col:F.status})===U);if(S){if(S.status===Y)return;const F=S.status;if(Y==="in_progress"&&F==="paused"){t.resumeIssue(S.id);return}if(Y==="in_progress"){t.startIssue(S.id);return}if(Y==="paused"&&F==="in_progress"){t.pauseIssue(S.id,"Paused via kanban board");return}if(Y==="closed"){t.closeIssue(S.id,!0);return}if(F==="closed"){(async()=>(await t.reopenIssue(S.id),Y!=="queue"&&await t.updateIssueStatus(S.id,Y)))();return}if(Y==="queue"&&F==="backlog"){t.triageIssue(S.id);return}t.updateIssueStatus(S.id,Y);return}const M=u().find(F=>fi({kind:"workunit",item:F,col:uf[F.status]})===U),A=Y?$9[Y]:void 0;!M||!A||M.status===A||t.updateWorkUnit(M.id,{status:A})},V=async I=>{const U=v().trim();U&&(await t.createIssue({title:U,priority:y()}),Wn(()=>{k(null),C(""),b("medium")}))},K=async I=>{if(_.id)return;const U=i.model.current(),Y=i.agent.current(),S=i.model.variant.current();if(!U||!Y){nt({variant:"error",title:r.t("prompt.toast.modelAgentRequired.title"),description:r.t("prompt.toast.modelAgentRequired.description")});return}$("id",fi(I));try{const M=await a.client.session.create().then(A=>A.data??void 0).catch(A=>{nt({variant:"error",title:r.t("prompt.toast.sessionCreateFailed.title"),description:Qr(A,r.t)})});if(!M)return;d.set("session",A=>A.some(F=>F.id===M.id)?A:[...A,M].sort((F,N)=>F.id<N.id?-1:F.id>N.id?1:0)),i.session.promote(a.directory,M.id),o(`/${Ps(a.directory)}/session/${M.id}`),await a.client.session.promptAsync({sessionID:M.id,agent:Y.name,model:{modelID:U.id,providerID:U.provider.id},variant:S,parts:[{type:"text",text:_9(I)}]}).catch(A=>{nt({variant:"error",title:r.t("prompt.toast.promptSendFailed.title"),description:Qr(A,r.t)})})}finally{$("id",void 0)}};return(()=>{var I=V6(),U=I.firstChild,Y=U.firstChild,S=Y.firstChild,M=S.nextSibling,A=M.firstChild,F=A.nextSibling;return F.nextSibling,Y.nextSibling,l(Y,s(Ue,{name:"checklist",size:"small"}),S),l(M,()=>c().length,A),l(M,()=>u().length,F),l(U,s(kt,{size:"small",variant:"ghost",onClick:()=>void t.refresh(),children:"Refresh"}),null),l(I,s(E,{get when(){return t.ready},get fallback(){return(()=>{var N=cf();return l(N,()=>r.t("common.loading"),null),l(N,()=>r.t("common.loading.ellipsis"),null),N})()},get children(){return s(E,{get when(){return!t.error},get fallback(){return(()=>{var N=cf();return l(N,()=>t.error),N})()},get children(){var N=j6();return l(N,s(Hs,{onDragEnd:L,get children(){return[s(Us,{}),(()=>{var X=q6(),B=X.firstChild;return l(B,s(Oe,{each:y9,children:O=>s(S9,{get id(){return O.id},get label(){return O.label},get tone(){return O.tone},get entries(){return g().filter(z=>z.col===O.id)},get planSteps(){return(e.todos??[]).filter(z=>w9[z.status]===O.id)},onSelect:D,get selected(){return f()},get draggingId(){return p()},setDraggingId:w,get creating(){return h()===O.id},onStartCreate:()=>k(O.id),onCancelCreate:()=>{Wn(()=>{k(null),C(""),b("medium")})},get newTitle(){return v()},onTitleChange:C,get newPriority(){return y()},onPriorityChange:b,onSubmit:()=>V(O.id),onPlay:K,get playing(){return _.id}})})),X})()]}})),N}})}}),null),I})()}function S9(e){const t=T(()=>D9(e.entries)),n=Xv(e.id),r=()=>"bg-surface-raised-base/80",i=()=>{switch(e.id){case"backlog":return"folder";case"queue":return"dash";case"in_progress":return"arrow-right";case"paused":return"stop";case"closed":return"check-small";default:return"folder"}},o=()=>"bg-surface-raised-base/40",a=()=>"bg-background-base text-text-weak border border-border-base/50";return(()=>{var d=U6(),c=d.firstChild,u=c.firstChild,g=u.nextSibling;g.nextSibling;var f=c.nextSibling,m=n.ref;return typeof m=="function"?Lt(m,d):n.ref=d,l(c,s(Ue,{get name(){return i()},size:"small",class:"text-text-weak"}),u),l(u,()=>t().length),l(g,()=>e.label),l(c,s(E,{get when(){return!e.creating},get fallback(){return(()=>{var p=df();return Rt(p,"click",e.onCancelCreate,!0),l(p,s(Ue,{name:"close-small",size:"small",class:"text-text-weak"})),p})()},get children(){var p=df();return Rt(p,"click",e.onStartCreate,!0),l(p,s(Ue,{name:"plus-small",size:"small",class:"text-text-weak"})),p}}),null),l(f,s(E,{get when(){return t().length>0||(e.planSteps??[]).length>0},get fallback(){return W6()},get children(){return[s(Oe,{get each(){return e.planSteps??[]},children:p=>s(T9,{step:p})}),s(Oe,{get each(){return t()},children:p=>s(A9,{entry:p,onClick:()=>e.onSelect(p),get selected(){return e.selected===fi(p)},get isDragging(){return e.draggingId===fi(p)},get setDraggingId(){return e.setDraggingId},get draggingId(){return e.draggingId},onPlay:()=>e.onPlay(p),get playing(){return e.playing===fi(p)},get disabled(){return!!e.playing}})})]}}),null),l(f,s(E,{get when(){return e.creating},get children(){var p=H6(),w=p.firstChild,h=w.firstChild;return l(p,s(va,{placeholder:"Issue title...",get value(){return e.newTitle},onInput:k=>e.onTitleChange(k.target.value),onKeyDown:k=>k.key==="Enter"&&e.onSubmit(),class:"w-full",autofocus:!0}),w),l(w,s(Qo,{get current(){return e.newPriority},onSelect:k=>k&&e.onPriorityChange(k),options:["low","medium","high","critical"],label:k=>k.charAt(0).toUpperCase()+k.slice(1),class:"w-24",size:"small"}),h),l(w,s(Ot,{icon:"check-small",variant:"ghost",get onClick(){return e.onSubmit},get disabled(){return!e.newTitle.trim()}}),null),l(w,s(Ot,{icon:"close-small",variant:"ghost",get onClick(){return e.onCancelCreate}}),null),p}}),null),G(p=>{var w=`h-full w-72 flex-shrink-0 flex flex-col rounded-xl border border-border-base/50 ${o()}`,h={"ring-2 ring-border-strong-base bg-surface-raised-base/60":n.isActiveDroppable},k=`shrink-0 px-3 py-2 flex rounded-t-xl items-center gap-2 ${r()}`,v=`rounded-full px-2 py-0.5 text-11-medium ${a()}`;return w!==p.e&&Ht(d,p.e=w),p.t=Tt(d,h,p.t),k!==p.a&&Ht(c,p.a=k),v!==p.o&&Ht(u,p.o=v),p},{e:void 0,t:void 0,a:void 0,o:void 0}),d})()}function T9(e){const t=()=>e.step.status==="completed"?"check-small":e.step.status==="in_progress"?"arrow-right":"dash";return(()=>{var n=K6(),r=n.firstChild,i=r.firstChild,o=i.nextSibling,a=r.nextSibling;return l(r,s(Ue,{get name(){return t()},size:"small",class:"mt-0.5 shrink-0 text-icon-info"}),i),l(o,()=>e.step.priority),l(a,()=>e.step.content),n})()}function A9(e){const t=()=>e.entry.item,n=T(()=>fi(e.entry)),r=T(()=>Bp(e.entry)),i=T(()=>Nl(e.entry)),o=T(()=>k9(e.entry)),a=r0(n()),d=T(()=>t().criteriaCount===0?0:Math.round(t().criteriaPassed/t().criteriaCount*100)),c=T(()=>Math.round(d()/100*120)),u=T(()=>t().criteriaCount>0);return(()=>{var g=Z6(),f=g.firstChild,m=f.firstChild,p=m.nextSibling,w=p.nextSibling,h=w.nextSibling,k=f.nextSibling,v=k.nextSibling,C=v.firstChild;g.$$mouseup=()=>e.setDraggingId(void 0),g.$$mousedown=()=>e.setDraggingId(n()),Rt(g,"click",e.onClick,!0);var y=a.ref;return typeof y=="function"?Lt(y,g):a.ref=g,l(f,s(Gn,{get type(){return e.entry.kind},size:12,class:"mt-0.5"}),m),l(m,()=>t().id),l(p,()=>t().priority),l(f,s(E,{get when(){return o()},children:b=>(()=>{var _=Q6();return l(_,b),_})()}),h),h.$$click=b=>{b.stopPropagation(),e.onPlay()},h.$$mouseup=b=>b.stopPropagation(),h.$$mousedown=b=>b.stopPropagation(),l(h,s(E,{get when(){return e.playing},get fallback(){return s(Ue,{name:"play",size:"small"})},get children(){return s(Ti,{class:"size-3"})}})),l(k,()=>t().title),l(g,s(E,{get when(){return i()},children:b=>(()=>{var _=J6();return l(_,b),_})()}),v),l(g,s(E,{get when(){return r().length>0},get children(){var b=G6();return l(b,s(Oe,{get each(){return r()},children:_=>(()=>{var $=eT();return l($,_),$})()})),b}}),v),l(v,s(E,{get when(){return u()},get children(){return[(()=>{var b=Y6(),_=b.firstChild;return G($=>{var D=`${d()}%`,L=`hsl(${c()}, 70%, 45%)`;return D!==$.e&&Je(_,"width",$.e=D),L!==$.t&&Je(_,"background",$.t=L),$},{e:void 0,t:void 0}),b})(),(()=>{var b=X6(),_=b.firstChild,$=_.nextSibling;return $.nextSibling,l(b,()=>t().criteriaPassed,_),l(b,()=>t().criteriaCount,$),b})()]}}),C),l(v,s(E,{get when(){return t().assignee},children:b=>(()=>{var _=tT();return l(_,b),_})()}),null),G(b=>{var _={"border-border-strong-base bg-surface-raised-base/90 shadow-sm":e.selected,"border-border-base/50 bg-background-base/70 hover:bg-background-base/80 hover:border-border-strong-base/70":!e.selected,"opacity-40 scale-95 shadow-none":e.isDragging||a.isActiveDraggable,"opacity-60 scale-98 shadow-sm":e.draggingId===n()&&!a.isActiveDraggable,"cursor-grab hover:scale-[1.02] hover:shadow-sm":!a.isActiveDraggable&&!e.isDragging,"cursor-grabbing":a.isActiveDraggable},$=e.disabled,D=`Start implementation session for ${t().id}`;return b.e=Tt(g,_,b.e),$!==b.t&&(h.disabled=b.t=$),D!==b.a&&ue(h,"aria-label",b.a=D),b},{e:void 0,t:void 0,a:void 0}),g})()}function D9(e){return e.slice().sort((t,n)=>n.item.createdAt.localeCompare(t.item.createdAt))}function Zs(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function M9(){const e=Ar(),[t,n]=ke(50),[r,i]=ke("");Mn(()=>{e.fetchOps(t())});const o=()=>void e.fetchOps(t(),r()||void 0),a=T(()=>e.ops.slice().reverse());return(()=>{var d=nT(),c=d.firstChild,u=c.nextSibling;return l(c,s(va,{placeholder:"Filter by file...",get value(){return r()},onInput:g=>i(g.target.value),onKeyDown:g=>g.key==="Enter"&&o(),class:"flex-1"}),null),l(c,s(kt,{size:"small",variant:"ghost",onClick:o,children:"Refresh"}),null),l(u,s(E,{get when(){return a().length>0},get fallback(){return rT()},get children(){var g=_a();return l(g,s(Oe,{get each(){return a()},children:f=>(()=>{var m=aT(),p=m.firstChild,w=p.nextSibling;return l(m,s(Sg,{get kind(){return f.kind},class:"mt-0.5 shrink-0 min-w-0"}),p),l(p,s(E,{get when(){return f.filePath},get children(){var h=iT();return l(h,()=>f.filePath),h}}),null),l(p,s(E,{get when(){return f.branchName},get children(){var h=sT();return l(h,()=>f.branchName),h}}),null),l(p,s(E,{get when(){return f.milestoneMessage},get children(){var h=oT();return l(h,()=>f.milestoneMessage),h}}),null),l(w,()=>Zs(f.timestamp)),m})()})),g}})),d})()}function E9(){const e=Ar(),[t,n]=ke(),[r,i]=ke(50);Mn(()=>{e.fetchDecisions({limit:r()})});const o=()=>void e.fetchDecisions({limit:r()}),a=T(()=>e.decisions.slice().reverse());return(()=>{var d=cT(),c=d.firstChild;return c.firstChild,l(c,s(kt,{size:"small",variant:"ghost",onClick:o,children:"Refresh"}),null),l(d,s(E,{get when(){return!t()},get children(){var u=lT();return l(u,s(E,{get when(){return a().length>0},get fallback(){return dT()},get children(){var g=_a();return l(g,s(Oe,{get each(){return a()},children:f=>(()=>{var m=gT(),p=m.firstChild,w=p.nextSibling,h=w.firstChild,k=w.nextSibling;return m.$$click=()=>n(f),l(p,s(Gn,{type:"decision",size:16})),l(h,()=>f.toolName),l(w,s(E,{get when(){return f.context},get children(){var v=uT();return v.firstChild,l(v,()=>f.context,null),v}}),null),l(w,s(E,{get when(){return f.outputSummary},get children(){var v=fT();return l(v,()=>f.outputSummary),v}}),null),l(k,()=>Zs(f.timestamp)),G(v=>Pn(m,Y9(),v)),m})()})),g}})),u}}),null),l(d,s(E,{get when(){return t()},children:u=>(()=>{var g=xT(),f=g.firstChild,m=f.firstChild,p=m.nextSibling,w=p.nextSibling,h=f.nextSibling;return l(f,s(Ot,{icon:"arrow-left",variant:"ghost",onClick:()=>n(void 0)}),m),l(m,()=>u().toolName),l(w,()=>Zs(u().timestamp)),l(h,s(E,{get when(){return u().context},get children(){var k=mT(),v=k.firstChild,C=v.nextSibling;return l(C,()=>u().context),k}}),null),l(h,s(E,{get when(){return u().input},get children(){var k=hT(),v=k.firstChild,C=v.nextSibling;return l(C,()=>JSON.stringify(u().input,null,2)),k}}),null),l(h,s(E,{get when(){return u().outputSummary},get children(){var k=pT(),v=k.firstChild,C=v.nextSibling;return l(C,()=>u().outputSummary),k}}),null),l(h,s(E,{get when(){return Te(()=>!!u().relatedEntities)()&&u().relatedEntities.length>0},get children(){var k=vT(),v=k.firstChild,C=v.nextSibling;return l(C,s(Oe,{get each(){return u().relatedEntities},children:y=>(()=>{var b=yT();return l(b,y),b})()})),k}}),null),l(h,s(E,{get when(){return Te(()=>!!u().custom)()&&Object.keys(u().custom).length>0},get children(){var k=bT(),v=k.firstChild,C=v.nextSibling;return l(C,()=>JSON.stringify(u().custom,null,2)),k}}),null),g})()}),null),d})()}function I9(){const e=Ar(),[t,n]=ke([]),[r,i]=ke(!1),[o,a]=ke(""),[d,c]=ke(!1),u=async()=>n(await e.fetchBranches());Mn(u);const g=async()=>{const p=o().trim();if(p){c(!0);try{await e.createBranch(p),a(""),i(!1),await u()}finally{c(!1)}}},f=async p=>{c(!0);try{await e.switchBranch(p),await u(),await e.refresh()}finally{c(!1)}},m=async p=>{c(!0);try{await e.deleteBranch(p),await u()}finally{c(!1)}};return(()=>{var p=wT(),w=p.firstChild;w.firstChild;var h=w.nextSibling;return l(w,s(kt,{size:"small",variant:"ghost",onClick:()=>i(!0),get disabled(){return r()},children:"New"}),null),l(w,s(kt,{size:"small",variant:"ghost",onClick:u,children:"Refresh"}),null),l(p,s(E,{get when(){return r()},get children(){var k=Np();return l(k,s(va,{placeholder:"Branch name...",get value(){return o()},onInput:v=>a(v.target.value),onKeyDown:v=>v.key==="Enter"&&g(),class:"flex-1",autofocus:!0}),null),l(k,s(Ot,{icon:"check-small",variant:"ghost",onClick:g,get disabled(){return!o().trim()||d()}}),null),l(k,s(Ot,{icon:"close-small",variant:"ghost",onClick:()=>i(!1)}),null),k}}),h),l(h,s(E,{get when(){return t().length>0},get fallback(){return $T()},get children(){return s(Oe,{get each(){return t()},children:k=>(()=>{var v=_T(),C=v.firstChild,y=C.firstChild;return v.$$click=()=>!k.isCurrent&&f(k.name),l(v,s(E,{get when(){return!k.isCurrent},get fallback(){return s(Ue,{name:"check-small",size:"small",class:"text-icon-success"})},get children(){return s(Gn,{type:"branch",size:16})}}),C),l(y,()=>k.name),l(v,s(E,{get when(){return k.isCurrent},get children(){return kT()}}),null),l(v,s(E,{get when(){return!k.isCurrent},get children(){return s(Ot,{icon:"close-small",variant:"ghost",size:"small",onClick:b=>{b.stopPropagation(),m(k.name)},get disabled(){return d()}})}}),null),G(b=>{var _=d(),$=`text-12-medium ${k.isCurrent?"text-text-strong":"text-text-base"}`;return _!==b.e&&(v.disabled=b.e=_),$!==b.t&&Ht(y,b.t=$),b},{e:void 0,t:void 0}),v})()})}})),p})()}function L9(){const e=Ar(),[t,n]=ke([]),[r,i]=ke(!1),[o,a]=ke(""),[d,c]=ke(!1),u=async()=>n(await e.fetchMilestones());Mn(u);const g=async()=>{const f=o().trim();if(f){c(!0);try{await e.createMilestone(f),a(""),i(!1),await u()}finally{c(!1)}}};return(()=>{var f=CT(),m=f.firstChild;m.firstChild;var p=m.nextSibling;return l(m,s(kt,{size:"small",variant:"ghost",onClick:()=>i(!0),get disabled(){return r()},children:"New"}),null),l(m,s(kt,{size:"small",variant:"ghost",onClick:u,children:"Refresh"}),null),l(f,s(E,{get when(){return r()},get children(){var w=Np();return l(w,s(va,{placeholder:"Milestone message...",get value(){return o()},onInput:h=>a(h.target.value),onKeyDown:h=>h.key==="Enter"&&g(),class:"flex-1",autofocus:!0}),null),l(w,s(Ot,{icon:"check-small",variant:"ghost",onClick:g,get disabled(){return!o().trim()||d()}}),null),l(w,s(Ot,{icon:"close-small",variant:"ghost",onClick:()=>i(!1)}),null),w}}),p),l(p,s(E,{get when(){return t().length>0},get fallback(){return ST()},get children(){return s(Oe,{get each(){return t()},children:w=>(()=>{var h=DT(),k=h.firstChild,v=k.nextSibling,C=v.firstChild,y=C.nextSibling;return l(k,s(Gn,{type:"milestone",size:16})),l(C,()=>w.message??w.id),l(y,s(E,{get when(){return w.createdAt},get children(){var b=TT();return l(b,()=>Zs(w.createdAt)),b}}),null),l(y,s(E,{get when(){return w.affectedFiles.length>0},get children(){var b=AT(),_=b.firstChild;return l(b,()=>w.affectedFiles.length,_),b}}),null),h})()})}})),f})()}const P9={contains:["1","*"],assigns:["1","1"],blocks:["1","1"],remembers:["1","*"],tracks:["1","*"],parent:["1","*"],imports:["*","*"],links:["*","*"]};function ff(e,t,n,r,i){const a=Math.cos(i),d=Math.sin(i),c=-d,u=a;if(t==="1")e.append("line").attr("x1",n+c*6).attr("y1",r+u*6).attr("x2",n-c*6).attr("y2",r-u*6).attr("stroke","var(--text-weaker)").attr("stroke-width",1.2);else if(t==="*")for(const g of[-1,0,1])e.append("line").attr("x1",n).attr("y1",r).attr("x2",n+a*6*1.2+c*6*g*.7).attr("y2",r+d*6*1.2+u*6*g*.7).attr("stroke","var(--text-weaker)").attr("stroke-width",1.2);else if(t==="0..1")e.append("circle").attr("cx",n+a*6).attr("cy",r+d*6).attr("r",3).attr("fill","none").attr("stroke","var(--text-weaker)").attr("stroke-width",1.2),e.append("line").attr("x1",n+c*6).attr("y1",r+u*6).attr("x2",n-c*6).attr("y2",r-u*6).attr("stroke","var(--text-weaker)").attr("stroke-width",1.2);else if(t==="1..*"){e.append("line").attr("x1",n+c*6).attr("y1",r+u*6).attr("x2",n-c*6).attr("y2",r-u*6).attr("stroke","var(--text-weaker)").attr("stroke-width",1.2);const g={x:n+a*6,y:r+d*6};for(const f of[-1,0,1])e.append("line").attr("x1",g.x).attr("y1",g.y).attr("x2",g.x+a*6*.8+c*6*f*.7).attr("y2",g.y+d*6*.8+u*6*f*.7).attr("stroke","var(--text-weaker)").attr("stroke-width",1.2)}}const Qs=["issue","agent","project","memory","mcp","sprite","workunit","cycle","epic","roadmap","suggestion","file","directory","op"],Zi={label:900,edge:250,card:150,icon:2e4,dense:1500,pad:140},qp="trellis:graph-physics";function F9(){try{const e=localStorage.getItem(qp);if(!e)return Ii;const t=JSON.parse(e);return{dist:Eo(t.dist??1.5),charge:Eo(t.charge??1.5),collide:Eo(t.collide??1),decay:Eo(t.decay??1)}}catch{return Ii}}function R9(e){try{localStorage.setItem(qp,JSON.stringify(e))}catch{}}function Eo(e){return Number.isFinite(e)?Math.max(.25,Math.min(4,e)):1}function z9(e){return{label:e<=Zi.label,edge:e<=Zi.edge,card:e<=Zi.card,icon:e<=Zi.icon,dense:e>=Zi.dense,dist:e>2200?45:e>1200?60:90,charge:e>2200?-90:e>1200?-130:-250,collide:e>2200?11:e>1200?15:22,decay:e>2200?.09:e>1200?.07:.05,link:e>2200?.2:e>1200?.3:.5}}function gf(e,t,n){const r=Zi.pad/Math.min(1,e.k);return{left:(-e.x-r)/e.k,top:(-e.y-r)/e.k,right:(t-e.x+r)/e.k,bottom:(n-e.y+r)/e.k}}function Za(e,t){const n=e.x??0,r=e.y??0;return n>=t.left&&n<=t.right&&r>=t.top&&r<=t.bottom}function mf(e,t){const n=e.source,r=e.target,i=n.x??0,o=n.y??0,a=r.x??0,d=r.y??0;return Math.max(i,a)>=t.left&&Math.min(i,a)<=t.right&&Math.max(o,d)>=t.top&&Math.min(o,d)<=t.bottom}function hf(e={}){const t=Ar(),n=zn(),r=`graph-sidebar-widths-${n.directory}`,i=()=>{try{const ge=localStorage.getItem(r);return ge?JSON.parse(ge):null}catch{return null}},[o,a]=ke(i()?.left??224),[d,c]=ke(i()?.right??360);$e(()=>{localStorage.setItem(r,JSON.stringify({left:o(),right:d()}))});const u=()=>typeof window>"u"?720:Math.max(320,Math.min(720,Math.floor(window.innerWidth*.5))),g=()=>{const ge=u();d()>ge&&c(ge)};Mn(()=>{typeof window>"u"||(g(),window.addEventListener("resize",g),vt(()=>window.removeEventListener("resize",g)))});const[f,m]=ke(!0),[p,w]=ke(!0),[h,k]=ke(!0),[v,C]=ke(!1),y=()=>e.options?.includeHidden??f(),b=()=>e.options?.includeImports??p(),_=()=>e.options?.includeLinks??h(),$=()=>e.options?.includeOps??v(),D=(ge,qe)=>{if(e.options&&e.onOptionsChange){e.onOptionsChange({...e.options,[ge]:qe});return}ge==="includeHidden"&&m(qe),ge==="includeImports"&&w(qe),ge==="includeLinks"&&k(qe),ge==="includeOps"&&C(qe)},[L,V]=ke(F9()),[K,I]=ke(void 0),[U,Y]=ke(!1),[S,M]=ke(null);let A=null,F=0,N=null;const X=async()=>{if(rd.data){I(rd.data),Y(!1),Zv();return}const ge=++F;A&&(A.abort(),A=null),Y(!0),M(null),A=new AbortController;const qe=await t.fetchGraph({includeHidden:y(),includeImports:b(),includeLinks:_(),includeOps:$()}).catch(we=>(ge===F&&!A?.signal.aborted&&(M(we instanceof Error?we.message:"Failed to load graph"),I(void 0)),null));qe&&ge===F&&!A?.signal.aborted&&(I(qe),M(null)),ge===F&&(Y(!1),A=null)};$e(()=>{t.revision,y(),b(),_(),$(),e.revision,N&&clearTimeout(N),N=setTimeout(()=>{N=null,X()},150)}),vt(()=>{N&&(clearTimeout(N),N=null),A&&(A.abort(),A=null)});const B=()=>K(),O=e.scopedTypes?new Set(e.scopedTypes):new Set(["issue","agent","project","memory","mcp","sprite","workunit","cycle","epic","roadmap","suggestion","file","directory","op"]),[z,q]=ke(O),Q=new Set(e.scopedTypes??Qs),j=T(()=>new Set(e.highlightIds??[])),[H,J]=ke(null),[le,de]=St({back:[],forward:[]});let Re,Ve;const Z=ge=>{const qe=B();return qe?qe.nodes.find(we=>we.id===ge)??null:null},ne=ge=>{const qe=Z(ge);if(!qe)return;const we=H()?.id;we!==ge&&Wn(()=>{we&&de("back",He=>[...He,we]),de("forward",[]),J(qe)})},re=()=>{const ge=le.back;if(ge.length===0)return;const qe=ge[ge.length-1],we=Z(qe);if(!we){de("back",Ne=>Ne.slice(0,-1)),re();return}const He=H()?.id;Wn(()=>{de("back",Ne=>Ne.slice(0,-1)),He&&de("forward",Ne=>[...Ne,He]),J(we)})},ie=()=>{const ge=le.forward;if(ge.length===0)return;const qe=ge[ge.length-1],we=Z(qe);if(!we){de("forward",Ne=>Ne.slice(0,-1)),ie();return}const He=H()?.id;Wn(()=>{de("forward",Ne=>Ne.slice(0,-1)),He&&de("back",Ne=>[...Ne,He]),J(we)})},be=T(()=>{const ge=B();if(!ge)return{};const qe={};for(const we of ge.nodes)qe[we.type]=(qe[we.type]??0)+1;return qe}),Fe=T(()=>{const ge=be();return[...new Set([...Qs,...Object.keys(ge)])].sort((qe,we)=>(ge[we]??0)-(ge[qe]??0))});$e(()=>{const ge=e.scopedTypes;ge&&(q(new Set(ge)),Wn(()=>{J(null),de({back:[],forward:[]})}))}),$e(()=>{if(e.scopedTypes)return;const ge=Fe().filter(qe=>!Q.has(qe));ge.length!==0&&(ge.forEach(qe=>Q.add(qe)),q(qe=>new Set([...qe,...ge])))});let ee=null;$e(()=>{const ge=B();if(!ge||!Re)return;ee&&cancelAnimationFrame(ee);const qe=e.themes,we=j(),He=z();ee=requestAnimationFrame(()=>{ee=null;const Ee=ge.nodes.filter(xt=>He.has(xt.type)).map(xt=>{const st=qe?.[xt.type]??qe?.[xt.type.toLowerCase()];return st?{...xt,color:st.color,icon:st.icon,fresh:we.has(xt.id)}:{...xt,fresh:we.has(xt.id)}}),rt=new Set(Ee.map(xt=>xt.id)),ct=ge.edges.filter(xt=>rt.has(xt.source)&&rt.has(xt.target)).map(xt=>({...xt})),zt=r6(n.directory);Ve=V9(Re,Ee,ct,{onSelect:xt=>{ne(xt.id)},onDeselect:()=>{Wn(()=>{J(null),de({back:[],forward:[]})})},getSelectedId:()=>H()?.id??null,inset:()=>H()?d()+32:0,layout:{load:()=>n6(n.directory),save:zt.save,flush:zt.flush}},kr(L)),e.scopedTypes&&requestAnimationFrame(()=>Ve?.fit())}),vt(()=>{ee&&(cancelAnimationFrame(ee),ee=null),Ve?.stop(),Ve=void 0})}),$e(()=>{const ge=L();R9(ge),Ve?.setPhysics(ge)}),$e(()=>{const ge=H()?.id??null,qe=Ve;qe&&requestAnimationFrame(()=>qe.focus(ge))}),$e(()=>{const ge=Ju.pending();if(!ge||!B())return;const we=Z(ge);we&&(z().has(we.type)||q(He=>new Set([...He,we.type])),ne(ge),Ju.clear())});const _e=T(()=>Fe().length>0&&Fe().every(ge=>z().has(ge))),xe=()=>{q(()=>_e()?new Set:new Set(Fe()))},ye=()=>H()!==null,Le=4,tt=()=>o()+Le;return(()=>{var ge=PT(),qe=ge.firstChild,we=qe.firstChild;l(ge,s(E,{get when(){return!e.hideSidebar},get children(){var Ne=MT(),Ee=Ne.firstChild,rt=Ee.firstChild;return l(Ee,s(N9,{get width(){return o()},get types(){return Fe()},get counts(){return be()},get active(){return z()},get allActive(){return _e()},get includeHidden(){return y()},get includeImports(){return b()},get includeLinks(){return _()},get includeOps(){return $()},onToggle:ct=>q(zt=>{const xt=new Set(zt);return xt.has(ct)?xt.delete(ct):xt.add(ct),xt}),onToggleAll:xe,onToggleHidden:()=>D("includeHidden",!y()),onToggleImports:()=>D("includeImports",!b()),onToggleLinks:()=>D("includeLinks",!_()),onToggleOps:()=>D("includeOps",!$()),get physics(){return L()},onPhysicsChange:ct=>V(ct),onPhysicsReset:()=>V(Ii),get themes(){return e.themes}}),rt),rt.$$pointerdown=ct=>ct.stopPropagation(),l(rt,s(so,{direction:"horizontal",get size(){return o()},min:180,max:400,onResize:ct=>a(ct)})),G(ct=>{var zt=ye()?"0px":`${tt()}px`,xt=ye(),st=`${tt()}px`,gt=ye()?0:1,$n=ye()||void 0;return zt!==ct.e&&Je(Ne,"width",ct.e=zt),xt!==ct.t&&ue(Ne,"aria-hidden",ct.t=xt),st!==ct.a&&Je(Ee,"width",ct.a=st),gt!==ct.o&&Je(Ee,"opacity",ct.o=gt),$n!==ct.i&&(rt.inert=ct.i=$n),ct},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),Ne}}),qe),l(qe,s(E,{get when(){return Te(()=>!U())()&&B()},get children(){return s(O9,{get physics(){return L()},onPhysicsChange:V,onPhysicsReset:()=>V(Ii)})}}),we);var He=Re;return typeof He=="function"?Lt(He,we):Re=we,l(qe,s(E,{get when(){return U()},get children(){var Ne=ET(),Ee=Ne.firstChild;return l(Ne,s(Ti,{}),Ee),Ne}}),null),l(qe,s(E,{get when(){return S()},get children(){var Ne=IT(),Ee=Ne.firstChild,rt=Ee.firstChild,ct=rt.nextSibling,zt=ct.nextSibling;return l(ct,S),zt.$$click=()=>X(),Ne}}),null),l(qe,s(E,{get when(){return Te(()=>!U()&&!S())()&&B()?.nodes.length===0},get children(){return LT()}}),null),l(qe,s(j9,{get width(){return d()},get maxWidth(){return u()},onResize:Ne=>c(Math.min(Ne,u())),get node(){return H()},get canBack(){return le.back.length>0},get canForward(){return le.forward.length>0},onBack:re,onForward:ie,onClose:()=>{const Ne=d()+32;Wn(()=>{J(null),de({back:[],forward:[]})}),Ve?.recenter(Ne),Ve?.focus(null)},onNavigate:Ne=>ne(Ne),onHover:Ne=>Ve?.setHoveredId(Ne)}),null),ge})()}function O9(e){const[t,n]=ke(!1);return(()=>{var r=RT(),i=r.firstChild,o=i.firstChild,a=o.firstChild,d=o.nextSibling;return o.$$click=()=>n(c=>!c),l(o,s(Ue,{name:"chevron-right",size:"small",class:"text-icon-weak transition-transform",get style(){return{transform:t()?"rotate(90deg)":"rotate(0deg)"}}}),a),Rt(d,"click",e.onPhysicsReset,!0),l(r,s(E,{get when(){return t()},get children(){var c=FT();return l(c,s(Io,{label:"Distance",get value(){return e.physics.dist},onInput:u=>e.onPhysicsChange({...e.physics,dist:u})}),null),l(c,s(Io,{label:"Repulsion",get value(){return e.physics.charge},onInput:u=>e.onPhysicsChange({...e.physics,charge:u})}),null),l(c,s(Io,{label:"Collision",get value(){return e.physics.collide},onInput:u=>e.onPhysicsChange({...e.physics,collide:u})}),null),l(c,s(Io,{label:"Decay",get value(){return e.physics.decay},onInput:u=>e.onPhysicsChange({...e.physics,decay:u})}),null),c}}),null),G(()=>ue(o,"aria-expanded",t())),r})()}function N9(e){const t=new Set(Qs),n=()=>e.types.filter(d=>t.has(d)),r=()=>e.types.filter(d=>!t.has(d)),[i,o]=ke(B9()),a=d=>{o(c=>{const u={...c,[d]:!c[d]};return q9(u),u})};return(()=>{var d=qT();return l(d,s(Ja,{label:"System entities",get open(){return i().system},onToggle:()=>a("system"),get rightAction(){return{label:e.allActive?"None":"All",onClick:e.onToggleAll}}}),null),l(d,s(E,{get when(){return i().system},get children(){return s(Oe,{get each(){return n()},children:c=>s(pf,{type:c,get active(){return e.active.has(c)},get count(){return e.counts[c]??0},onClick:()=>e.onToggle(c),get theme(){return e.themes?.[c]??e.themes?.[c.toLowerCase()]}})})}}),null),l(d,s(Ja,{label:"Custom entities",get open(){return i().custom},onToggle:()=>a("custom"),topBorder:!0}),null),l(d,s(E,{get when(){return i().custom},get children(){return s(E,{get when(){return r().length>0},get fallback(){return jT()},get children(){return s(Oe,{get each(){return r()},children:c=>s(pf,{type:c,get active(){return e.active.has(c)},get count(){return e.counts[c]??0},onClick:()=>e.onToggle(c)})})}})}}),null),l(d,s(Ja,{label:"Options",get open(){return i().options},onToggle:()=>a("options"),topBorder:!0}),null),l(d,s(E,{get when(){return i().options},get children(){return[(()=>{var c=zT(),u=c.firstChild,g=u.nextSibling;return Rt(c,"click",e.onToggleHidden,!0),l(c,s(Ue,{name:"eye",size:"small",class:"text-icon-weak"}),u),G(f=>{var m={"text-text-strong bg-surface-base/0":e.includeHidden,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.includeHidden},p=e.includeHidden,w=!!e.includeHidden,h=!e.includeHidden;return f.e=Tt(c,m,f.e),p!==f.t&&ue(c,"aria-pressed",f.t=p),w!==f.a&&g.classList.toggle("bg-text-strong",f.a=w),h!==f.o&&g.classList.toggle("bg-border-base",f.o=h),f},{e:void 0,t:void 0,a:void 0,o:void 0}),c})(),(()=>{var c=OT(),u=c.firstChild,g=u.nextSibling;return Rt(c,"click",e.onToggleImports,!0),l(c,s(Ue,{name:"link",size:"small",class:"text-icon-weak"}),u),G(f=>{var m={"text-text-strong bg-surface-raised-base/0":e.includeImports,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.includeImports},p=e.includeImports,w=!!e.includeImports,h=!e.includeImports;return f.e=Tt(c,m,f.e),p!==f.t&&ue(c,"aria-pressed",f.t=p),w!==f.a&&g.classList.toggle("bg-text-strong",f.a=w),h!==f.o&&g.classList.toggle("bg-border-base",f.o=h),f},{e:void 0,t:void 0,a:void 0,o:void 0}),c})(),(()=>{var c=NT(),u=c.firstChild,g=u.nextSibling;return Rt(c,"click",e.onToggleLinks,!0),l(c,s(Ue,{name:"file-text",size:"small",class:"text-icon-weak"}),u),G(f=>{var m={"text-text-strong bg-surface-raised-base/0":e.includeLinks,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.includeLinks},p=e.includeLinks,w=!!e.includeLinks,h=!e.includeLinks;return f.e=Tt(c,m,f.e),p!==f.t&&ue(c,"aria-pressed",f.t=p),w!==f.a&&g.classList.toggle("bg-text-strong",f.a=w),h!==f.o&&g.classList.toggle("bg-border-base",f.o=h),f},{e:void 0,t:void 0,a:void 0,o:void 0}),c})(),(()=>{var c=BT(),u=c.firstChild,g=u.nextSibling;return Rt(c,"click",e.onToggleOps,!0),l(c,s(Gn,{type:"op",size:14,get color(){return Te(()=>!!e.includeOps)()?Tg.op:"var(--text-weaker)"}}),u),G(f=>{var m={"text-text-strong bg-surface-raised-base/0":e.includeOps,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.includeOps},p=e.includeOps,w=!!e.includeOps,h=!e.includeOps;return f.e=Tt(c,m,f.e),p!==f.t&&ue(c,"aria-pressed",f.t=p),w!==f.a&&g.classList.toggle("bg-text-strong",f.a=w),h!==f.o&&g.classList.toggle("bg-border-base",f.o=h),f},{e:void 0,t:void 0,a:void 0,o:void 0}),c})()]}}),null),G(c=>Je(d,"width",`${e.width}px`)),d})()}const jp="trellis:sidebar-sections",Qa={physics:!0,system:!0,custom:!0,options:!0};function B9(){try{const e=localStorage.getItem(jp);if(!e)return Qa;const t=JSON.parse(e);return{...Qa,...t}}catch{return Qa}}function q9(e){try{localStorage.setItem(jp,JSON.stringify(e))}catch{}}function Ja(e){return(()=>{var t=VT(),n=t.firstChild,r=n.firstChild;return Rt(n,"click",e.onToggle,!0),l(n,s(Ue,{name:"chevron-right",size:"small",class:"text-icon-weak transition-transform",get style(){return{transform:e.open?"rotate(90deg)":"rotate(0deg)"}}}),r),l(r,()=>e.label),l(t,s(E,{get when(){return e.rightAction},children:i=>(()=>{var o=HT();return o.$$click=a=>{a.stopPropagation(),i().onClick()},l(o,()=>i().label),G(()=>ue(o,"title",i().title)),o})()}),null),G(i=>{var o={"mt-3 pt-2 border-t border-border-weaker-base":!!e.topBorder},a=e.open;return i.e=Tt(t,o,i.e),a!==i.t&&ue(n,"aria-expanded",i.t=a),i},{e:void 0,t:void 0}),t})()}function pf(e){const t=()=>e.theme?.color??Ni(e.type),n=()=>e.theme?.icon;return(()=>{var r=UT(),i=r.firstChild,o=i.nextSibling,a=o.nextSibling;return Rt(r,"click",e.onClick,!0),l(r,s(Gn,{get type(){return e.type},size:14,get color(){return t()},get icon(){return n()}}),i),l(i,()=>e.theme?.label||e.type.replace(/_/g," ")),l(o,()=>e.count),G(d=>{var c={"text-text-strong bg-surface-raised-base/50":e.active,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.active},u=e.active,g=!!e.active,f=!e.active;return d.e=Tt(r,c,d.e),u!==d.t&&ue(r,"aria-pressed",d.t=u),g!==d.a&&a.classList.toggle("bg-text-strong",d.a=g),f!==d.o&&a.classList.toggle("bg-border-base",d.o=f),d},{e:void 0,t:void 0,a:void 0,o:void 0}),r})()}function Io(e){return(()=>{var t=WT(),n=t.firstChild,r=n.firstChild,i=r.nextSibling,o=i.firstChild,a=n.nextSibling;return l(r,()=>e.label),l(i,()=>e.value.toFixed(2),o),a.$$input=d=>e.onInput(Number(d.currentTarget.value)),G(()=>a.value=e.value),t})()}function j9(e){const[n,r]=ke(e.node);let i;return $e(()=>{const o=e.node;if(i&&(clearTimeout(i),i=void 0),o){r(o);return}i=setTimeout(()=>{e.node||r(null)},560)}),vt(()=>{i&&clearTimeout(i)}),(()=>{var o=GT(),a=o.firstChild;return l(a,s(E,{get when(){return n()},get children(){var d=KT();return d.$$pointerdown=c=>c.stopPropagation(),l(d,s(so,{direction:"horizontal",edge:"start",get size(){return e.width},min:300,get max(){return e.maxWidth},get onResize(){return e.onResize}})),d}}),null),l(a,s(E,{get when(){return n()},children:d=>s(Qv,{get navigate(){return e.onNavigate},get children(){return s(Jv,{get onHover(){return e.onHover},get children(){return[(()=>{var c=YT(),u=c.firstChild,g=u.firstChild,f=g.nextSibling,m=u.nextSibling,p=m.firstChild;return l(g,s(Ot,{icon:"arrow-left",variant:"ghost",get onClick(){return e.onBack},get disabled(){return!e.canBack},title:"Back"}),null),l(g,s(Ot,{icon:"arrow-right",variant:"ghost",get onClick(){return e.onForward},get disabled(){return!e.canForward},title:"Forward"}),null),l(u,s(Gn,{get type(){return d().type},size:14,class:"shrink-0"}),f),l(f,()=>d().label),l(u,s(Ot,{icon:"close-small",variant:"ghost",get onClick(){return e.onClose}}),null),l(p,()=>d().id),G(w=>{var h=d().label,k=d().id;return h!==w.e&&ue(f,"title",w.e=h),k!==w.t&&ue(p,"title",w.t=k),w},{e:void 0,t:void 0}),c})(),Te(()=>(()=>{const c=Bc(),u=d().type==="file"||d().type==="directory";return s(e0,{get id(){return d().id},get type(){return d().type},get status(){return d().status},get priority(){return d().priority},initialTab:c?"overview":u?"preview":"details",get items(){return c?t0:u?void 0:n0.filter(g=>g.id!=="preview")}})})())]}})}})}),null),G(d=>{var c=`${e.width}px`,u=e.node?"translateX(0)":"translateX(110%)",g=e.node?1:0,f=e.node?"auto":"none";return c!==d.e&&Je(a,"width",d.e=c),u!==d.t&&Je(a,"transform",d.t=u),g!==d.a&&Je(a,"opacity",d.a=g),f!==d.o&&Je(a,"pointer-events",d.o=f),d},{e:void 0,t:void 0,a:void 0,o:void 0}),o})()}function V9(e,t,n,r,i=Ii){const o=typeof location<"u"?new URLSearchParams(location.search).get("renderer"):null;return o==="canvas"?nf(e,t,n,r,i):o==="svg"||t.length<=Ol.light?vf(e,t,n,r,i):nf(e,t,n,r,i)}function vf(e,t,n,r,i=Ii){const o=e.clientWidth||800,a=e.clientHeight||600,d=z9(t.length),c=t.length>1500,u=r.layout?.load(),g=zp(t,u),f=g>0&&g>=Math.floor(t.length*.6),m=ar(e);m.selectAll("*").remove();const p=document.createElementNS("http://www.w3.org/2000/svg","style");p.textContent="@keyframes edgeFlow{to{stroke-dashoffset:-16}}.edge-flow{animation:edgeFlow 0.5s linear infinite}@keyframes nodeBirth{0%{opacity:1;transform:scale(3.4);filter:drop-shadow(0 0 18px #22c55e)}100%{opacity:0;transform:scale(1);filter:drop-shadow(0 0 0 transparent)}}.node-birth{animation:nodeBirth 5.5s ease-out forwards;transform-box:fill-box;transform-origin:center;pointer-events:none}",e.prepend(p);const w=1,h=0,k=.05,v=12,C=m.append("g");let y=u?.zoom?sr.translate(u.zoom.x,u.zoom.y).scale(u.zoom.k):sr,b=0,_=0,$,D=0;const L=550;f||(C.style("opacity","0").style("transition",`opacity ${L}ms ease-out`),requestAnimationFrame(()=>{C.style("opacity","1"),setTimeout(()=>C.style("transition",null),L+50)}));const V=()=>{r.layout&&r.layout.save(Rp(t,{x:y.x,y:y.y,k:y.k}))};let K=!1,I=null;const U=new Map;for(const te of t)U.set(te.id,te);const Y=new Map;for(const te of t)Y.set(te.id,new Set);for(const te of n){const pe=Y.get(te.source),We=Y.get(te.target);pe&&pe.add(te.target),We&&We.add(te.source)}const S=new Map;for(const[te,pe]of Y)S.set(te,new Set([te,...pe]));let M=null;const A=e.parentElement,F=A.appendChild(document.createElement("div"));F.setAttribute("class","graph-tooltip"),F.style.cssText="position:absolute;pointer-events:none;z-index:20;display:none;padding:0;border-radius:8px;font-size:11px;line-height:1.4;background:color-mix(in srgb, var(--surface-raised-base) 85%, transparent);backdrop-filter:blur(4px);border:1px solid var(--border-base);color:var(--text-strong);box-shadow:0 6px 20px rgba(0,0,0,.35);width:max-content;max-width:min(480px,90vw);opacity:0;transform:translateY(2px);transition:opacity 80ms ease-out,transform 80ms ease-out;";const N=window.matchMedia("(max-width: 767px)").matches,X=N?96:180,B=N?64:120,O=N?4:6,z=A.appendChild(document.createElement("canvas")),q=window.devicePixelRatio||1;z.width=X*q,z.height=B*q,z.setAttribute("class","graph-minimap"),z.style.cssText=`position:absolute;left:12px;bottom:12px;z-index:15;width:${X}px;height:${B}px;background:color-mix(in srgb, var(--background-base) 88%, transparent);border:1px solid var(--border-base);border-radius:6px;box-shadow:0 2px 10px rgba(0,0,0,.35);cursor:pointer;`;const Q=z.getContext("2d");Q.scale(q,q);function j(){let te=1/0,pe=1/0,We=-1/0,ut=-1/0;for(const Cn of t){const R=Cn.x??0,se=Cn.y??0;R<te&&(te=R),se<pe&&(pe=se),R>We&&(We=R),se>ut&&(ut=se)}const at=-y.x/y.k,Mt=-y.y/y.k,Be=(o-y.x)/y.k,ft=(a-y.y)/y.k;te=Math.min(te,at),pe=Math.min(pe,Mt),We=Math.max(We,Be),ut=Math.max(ut,ft),Number.isFinite(te)||(te=0,pe=0,We=o,ut=a);const Vt=We-te||1,Bt=ut-pe||1,pn=Math.min((X-O*2)/Vt,(B-O*2)/Bt);return{minX:te,minY:pe,maxX:We,maxY:ut,scale:pn}}function H(te,pe,We){return[O+(te-We.minX)*We.scale,O+(pe-We.minY)*We.scale]}const J=new Map;function le(te){const pe=J.get(te.type);if(pe)return pe;const We=jr(te);return J.set(te.type,We),We}let de=0;function Re(){de||(de=requestAnimationFrame(()=>{de=0,Q.clearRect(0,0,X,B);const te=j();Q.globalAlpha=.7;const pe=new Map;for(const Cn of t){const R=le(Cn),se=pe.get(R);se?se.push(Cn):pe.set(R,[Cn])}for(const[Cn,R]of pe){Q.fillStyle=Cn;for(const se of R){const[fe,Pe]=H(se.x??0,se.y??0,te);Q.fillRect(fe-.75,Pe-.75,1.5,1.5)}}Q.globalAlpha=1;const We=-y.x/y.k,ut=-y.y/y.k,at=o/y.k,Mt=a/y.k,[Be,ft]=H(We,ut,te),Vt=at*te.scale,Bt=Mt*te.scale;Q.fillStyle="rgba(0,0,0,0.45)";const pn=new Path2D;pn.rect(0,0,X,B),pn.rect(Be,ft,Vt,Bt),Q.fill(pn,"evenodd"),Q.strokeStyle="rgba(255,255,255,0.9)",Q.lineWidth=1,Q.strokeRect(Be+.5,ft+.5,Vt-1,Bt-1)}))}function Ve(te){const pe=z.getBoundingClientRect(),We=te.clientX-pe.left,ut=te.clientY-pe.top;if(We<0||ut<0||We>X||ut>B)return null;const at=j(),Mt=(We-O)/at.scale+at.minX,Be=(ut-O)/at.scale+at.minY;return[Mt,Be]}function Z(te,pe){const We=y.k,ut=o/2-te*We,at=a/2-pe*We;m.call(Fe.transform,sr.translate(ut,at).scale(We))}let ne=!1;const re=te=>{te.preventDefault(),ne=!0;const pe=Ve(te);pe&&Z(pe[0],pe[1])},ie=te=>{if(!ne)return;const pe=Ve(te);pe&&Z(pe[0],pe[1])},be=()=>{ne=!1};z.addEventListener("mousedown",re),window.addEventListener("mousemove",ie),window.addEventListener("mouseup",be);const Fe=Kg().scaleExtent([k,4]).extent(()=>[[0,0],[e.clientWidth||o,e.clientHeight||a]]).filter(te=>te.type==="wheel"?te.ctrlKey||te.metaKey:te.button===0||te.button===1).on("zoom",te=>{y=te.transform,C.attr("transform",String(te.transform)),Ut(),Re(),V()});m.call(Fe),e.addEventListener("wheel",te=>{te.ctrlKey||te.metaKey||(te.preventDefault(),m.call(Fe.translateBy,-te.deltaX/y.k,-te.deltaY/y.k))},{passive:!1}),e.addEventListener("mousedown",te=>{te.button===1&&(te.preventDefault(),e.style.cursor="grabbing")}),e.addEventListener("mouseup",te=>{te.button===1&&!K&&(e.style.cursor="default")});const ee=te=>{if(!(te instanceof HTMLElement))return!1;if(te.isContentEditable)return!0;const pe=te.tagName;return pe==="INPUT"||pe==="TEXTAREA"||pe==="SELECT"},_e=te=>{te.code!=="Space"||K||ee(te.target)||(te.preventDefault(),K=!0,e.style.cursor="grab",Fe.scaleExtent([y.k,y.k]))},xe=te=>{te.code==="Space"&&K&&(te.preventDefault(),K=!1,e.style.cursor="default",Fe.scaleExtent([k,4]))};window.addEventListener("keydown",_e),window.addEventListener("keyup",xe),e.setAttribute("tabindex","0"),e.style.outline="none",e.focus(),m.on("click",te=>{te.target===e&&r.onDeselect()});const ye=n.map(te=>({...te}));let Le={...i};const tt=()=>d.dist*Le.dist,ge=()=>d.charge*Le.charge,qe=()=>d.collide*Le.collide,we=()=>d.decay*Le.decay,He=Ug(t).force("link",Hg(ye).id(te=>te.id).distance(tt())).force("charge",Wg().strength(ge())).force("collide",Vg(qe())).alphaDecay(we());f||He.force("center",qg(o/2,a/2)),f&&He.alpha(.15).alphaTarget(0);const Ne=!c,Ee=Ne?"stroke 110ms ease-out, stroke-opacity 110ms ease-out, stroke-width 110ms ease-out, opacity 110ms ease-out":"none",rt=.18,ct=C.append("g").attr("class","links").selectAll("line").data(ye).join("line").attr("stroke","var(--text-weak)").attr("stroke-width",1).attr("stroke-opacity",rt).attr("stroke-linecap","round").attr("stroke-dasharray",te=>te.type==="imports"?"3,3":te.type==="links"?"1,4":"none").style("transition",Ee),xt=C.append("g").attr("class","edge-labels").selectAll("text").data(d.edge?ye:[]).join("text").text(te=>te.type).attr("font-size","9px").attr("font-weight","500").attr("fill","var(--text-base)").attr("stroke","var(--background-base)").attr("stroke-width",3).attr("stroke-linejoin","round").attr("paint-order","stroke").attr("text-anchor","middle").attr("pointer-events","none").attr("dy","0.35em").style("opacity",.35).style("transition",Ee),st=C.append("g").attr("class","cardinality");function gt(te){const pe=_r(te)+(te.type==="file"||te.type==="directory"?4:0);return Math.max(pe,v/y.k)}function $n(te){const pe=_r(te)+(te.type==="file"||te.type==="directory"?4:0);return Math.max(pe,4/y.k)}const Ce=C.append("g").attr("class","nodes").selectAll("g").data(t).join("g").style("cursor","pointer").on("click",(te,pe)=>{te.stopPropagation(),r.onSelect(pe)}).on("mouseenter",(te,pe)=>{y.k<h||(I=pe.id,je(),vn(pe),Yt(pe.id))}).on("mouseleave",()=>{I!==null&&(I=null,je(),cn(),Yt(null))}),Dt=Ce.append("circle").attr("class","node-hit").attr("r",gt).attr("fill","transparent"),lt=.35;Ce.append("circle").attr("class","node-ring").attr("r",$n).attr("fill",te=>jr(te)).attr("fill-opacity",.2).attr("stroke",te=>jr(te)).attr("stroke-width",1.5).attr("stroke-opacity",lt).style("transition",Ee),Ce.filter(te=>!!te.fresh).append("circle").attr("class","node-birth").attr("r",te=>_r(te)+6).attr("fill","rgba(34,197,94,0.18)").attr("stroke","#22c55e").attr("stroke-width",3),d.icon&&Ce.each(function(te){const pe=_r(te),We=ar(this);if(te.type==="file"||te.type==="directory"){const Mt=te.id.startsWith("file:")?te.id.slice(5):te.id.startsWith("dir:")?te.id.slice(4):te.id,Be=wg(Mt,te.type,!1),ft=Math.max(pe*1.8,14);We.append("svg").attr("viewBox","0 0 32 32").attr("width",ft).attr("height",ft).attr("x",-ft/2).attr("y",-ft/2).attr("pointer-events","none").append("use").attr("href",`${$g}#${Be}`);return}const ut=Op(te);if(!ut)return;const at=Math.max(pe*1.05,9);We.append("svg").attr("viewBox",kg).attr("width",at).attr("height",at).attr("x",-at/2).attr("y",-at/2).attr("fill","none").attr("stroke",jr(te)).attr("stroke-width",2.25).attr("stroke-linecap","round").attr("stroke-linejoin","round").attr("pointer-events","none").html(ut)});const At=C.append("g").attr("class","labels").selectAll("text").data(d.label?t:[]).join("text").text(te=>te.label).attr("font-size","10px").attr("fill","var(--text-weak)").attr("text-anchor","middle").attr("pointer-events","none").attr("dy","2.2em");let wt=null,It=null;const W=120,oe=.15,me=90,he=1.75,Ie=t.length>4e3;let Ae=0;const De=2.1;let Ke=1,yt=1,Nt=null,Ft=0;function kn(){Ft=0;const te=yt-Ke;if(Math.abs(te)<.005){Ke=yt,yt===1&&(Nt=null),En();return}Ke+=te*.28,En(),Ft=requestAnimationFrame(kn)}function Yt(te){te?(Nt=te,yt=De):yt=1,Ft||(Ft=requestAnimationFrame(kn))}function an(te){if(Nt===te.id)return Ke;if(wt===null||It===null)return 1;const pe=(te.x??0)-wt,We=(te.y??0)-It,ut=pe*pe+We*We,at=me*me;if(ut>=at)return 1;const Mt=1-Math.sqrt(ut)/me,Be=Mt*Mt*(3-2*Mt);return 1+(he-1)*Be}function En(){Ce.attr("transform",te=>{const pe=te.x??0,We=te.y??0,ut=Ie&&Nt!==te.id?1:an(te);return ut===1?`translate(${pe},${We})`:`translate(${pe},${We}) scale(${ut})`})}function dn(){Ae||Ie&&Nt===null||(Ae=requestAnimationFrame(()=>{Ae=0,En()}))}e.addEventListener("mousemove",te=>{const pe=e.getBoundingClientRect();wt=(te.clientX-pe.left-y.x)/y.k,It=(te.clientY-pe.top-y.y)/y.k,dn()}),e.addEventListener("mouseleave",()=>{wt=null,It=null,dn()});const Xt=t.length>4e3,sn=W,_n=new Map,fn=(te,pe)=>Math.floor(te/sn)*100003+Math.floor(pe/sn),Hn=()=>{_n.clear();for(const te of t){const pe=fn(te.x??0,te.y??0),We=_n.get(pe);We?We.push(te):_n.set(pe,[te])}};let Xn=0;Xt||He.force("magnetic",te=>{if(wt===null||It===null)return;Xn++%(te>.02?1:3)===0&&Hn();const pe=wt,We=It,ut=Math.floor(pe/sn),at=Math.floor(We/sn),Mt=W*W;for(let Be=-1;Be<=1;Be++)for(let ft=-1;ft<=1;ft++){const Vt=_n.get((ut+Be)*100003+(at+ft));if(Vt)for(const Bt of Vt){const pn=Bt.x??0,Cn=Bt.y??0,R=pe-pn,se=We-Cn,fe=R*R+se*se;if(fe>=Mt||fe<25)continue;const dt=(1-Math.sqrt(fe)/W)*oe*te;Bt.vx=(Bt.vx??0)+R*dt,Bt.vy=(Bt.vy??0)+se*dt}}});const On=F0().on("start",(te,pe)=>{te.active||He.alphaTarget(.3).restart(),pe.fx=pe.x,pe.fy=pe.y}).on("drag",(te,pe)=>{pe.fx=te.x,pe.fy=te.y}).on("end",(te,pe)=>{te.active||He.alphaTarget(0),pe.fx=null,pe.fy=null,V()});Ce.call(On);function je(){const te=r.getSelectedId(),pe=I??te,We=I&&te&&te!==I?te:null,ut=Ce,at=ct,Mt=xt,Be=At,ft=st;if(pe===null){ut.style("opacity",null),Ce.select(".node-ring").attr("stroke-opacity",lt).attr("fill-opacity",.2),at.classed("edge-flow",!1).attr("stroke","var(--text-weak)").attr("stroke-width",1).attr("stroke-opacity",rt).attr("stroke-dasharray",Qe=>Qe.type==="imports"?"3,3":Qe.type==="links"?"1,4":"none"),Mt.style("opacity",.35),Be.style("opacity",null),ft.style("opacity",null);return}const Vt=gf(y,o,a),Bt=S.get(pe)??new Set([pe]),pn=We?S.get(We)??new Set([We]):null,Cn=U.get(pe),R=Cn?jr(Cn):"var(--border-base)",se=We?U.get(We):null,fe=se?jr(se):null;ut.style("opacity",Qe=>Za(Qe,Vt)?Bt.has(Qe.id)?1:pn&&pn.has(Qe.id)?.55:.35:null),Ce.select(".node-ring").attr("stroke-opacity",Qe=>Bt.has(Qe.id)?1:pn&&pn.has(Qe.id)?.7:lt).attr("fill-opacity",Qe=>Bt.has(Qe.id)?.5:pn&&pn.has(Qe.id)?.3:.1);const Pe=Qe=>{const pt=Qe.source.id,Wt=Qe.target.id;return pt===pe||Wt===pe?1:We&&(pt===We||Wt===We)?2:0},dt=Ne&&y.k>=w;at.classed("edge-flow",Qe=>dt&&Pe(Qe)===1).attr("stroke",Qe=>{const pt=Pe(Qe);return pt===1?R:pt===2&&fe?fe:"var(--border-base)"}).attr("stroke-width",Qe=>{const pt=Pe(Qe);return pt===1?2:pt===2?1.5:.5}).attr("stroke-opacity",Qe=>{const pt=Pe(Qe);return pt===1?.9:pt===2?.45:.25}).attr("stroke-dasharray",Qe=>{const pt=Pe(Qe);return dt&&pt===1?"4 4":Qe.type==="imports"?"3,3":Qe.type==="links"?"1,4":"none"}),Mt.style("opacity",Qe=>{const pt=Pe(Qe);return pt===1?1:pt===2?.5:.25}),Be.style("opacity",Qe=>Bt.has(Qe.id)?1:pn&&pn.has(Qe.id)?.5:.25),ft.style("opacity",.25)}function ht(te){return`<div style="padding:10px 24px 10px 12px"><div style="display:flex;align-items:center;gap:6px;margin-bottom:2px"><span style="width:8px;height:8px;border-radius:50%;background:${jr(te)};flex-shrink:0"></span><span style="font-weight:600;text-transform:capitalize">${te.type.replace(/_/g," ")}</span></div><div style="color:var(--text-weak);white-space:nowrap">${te.label}</div>`+(te.status?`<div style="color:var(--text-weaker);margin-top:1px">Status: ${te.status.replace(/_/g," ")}</div>`:"")+(te.priority?`<div style="color:var(--text-weaker)">Priority: ${te.priority}</div>`:"")+"</div>"}function vn(te){F.innerHTML=ht(te),M!==null&&(clearTimeout(M),M=null),F.style.display="block",ln(te),requestAnimationFrame(()=>{F.style.opacity="1",F.style.transform="translateY(0)"})}function ln(te){const pe=e.getBoundingClientRect(),We=(te.x??0)*y.k+y.x,ut=(te.y??0)*y.k+y.y,at=_r(te)*y.k,Mt=F.offsetWidth,Be=F.offsetHeight;let ft=We-Mt/2,Vt=ut-at-Be-10;Vt<4&&(Vt=ut+at+10),ft<4&&(ft=4),ft+Mt>pe.width-4&&(ft=pe.width-Mt-4),F.style.left=ft+"px",F.style.top=Vt+"px"}function cn(){F.style.opacity="0",F.style.transform="translateY(4px)",M=setTimeout(()=>{F.style.display="none",M=null},140)}function Jt(){const te=gf(y,o,a);if(Ce.style("display",pe=>Za(pe,te)?null:"none"),d.label&&At.style("display",pe=>Za(pe,te)?null:"none"),ct.style("display",pe=>mf(pe,te)?null:"none"),d.edge&&xt.style("display",pe=>mf(pe,te)?null:"none"),Dt.attr("r",gt),Ce.select(".node-ring").attr("r",$n),d.label&&I===null){const pe=Math.min(1,Math.max(.2,(y.k-k)/1.5));At.style("opacity",pe)}if(I!==null&&y.k<h){I=null,je(),cn(),Yt(null);return}if(I!==null){const pe=U.get(I);pe&&ln(pe),je()}}const en=c?180:0;function Ut(){if(b||$)return;const te=performance.now(),pe=en?Math.max(0,en-(te-D)):0,We=()=>{b=0,$=void 0,D=performance.now(),Jt()};pe>0?$=setTimeout(()=>{$=void 0,b=requestAnimationFrame(We)},pe):b=requestAnimationFrame(We)}He.on("end",()=>V()),He.on("tick",()=>{if(_++,!(c&&_&1)){if(ct.attr("x1",te=>te.source.x??0).attr("y1",te=>te.source.y??0).attr("x2",te=>te.target.x??0).attr("y2",te=>te.target.y??0),d.edge&&xt.attr("x",te=>(te.source.x+te.target.x)/2).attr("y",te=>(te.source.y+te.target.y)/2),d.card){st.selectAll("*").remove();for(const te of ye){const pe=te.source,We=te.target,ut=pe.x??0,at=pe.y??0,Mt=We.x??0,Be=We.y??0,ft=Mt-ut,Vt=Be-at,Bt=Math.sqrt(ft*ft+Vt*Vt);if(Bt<1)continue;const pn=Math.atan2(Vt,ft),Cn=te.type,[R,se]=P9[Cn]??["1","*"],fe=14;ff(st,R,ut+ft/Bt*fe,at+Vt/Bt*fe,pn),ff(st,se,Mt-ft/Bt*fe,Be-Vt/Bt*fe,pn+Math.PI)}}En(),d.label&&At.attr("x",te=>te.x??0).attr("y",te=>te.y??0),(_&7)===0&&Ut(),(_&3)===0&&Re()}}),Ut(),Re();function gn(){const te=()=>{if(t.length===0)return;let pe=1/0,We=-1/0,ut=1/0,at=-1/0;for(const R of t){const se=R.x??o/2,fe=R.y??a/2;pe=Math.min(pe,se),We=Math.max(We,se),ut=Math.min(ut,fe),at=Math.max(at,fe)}const Mt=120,Be=We-pe+Mt*2,ft=at-ut+Mt*2,Vt=Math.max(k,Math.min(o/Be,a/ft,2)),Bt=(pe+We)/2,pn=(ut+at)/2,Cn=sr.translate(o/2-Bt*Vt,a/2-pn*Vt).scale(Vt);m.transition().duration(550).ease(R=>R<.5?4*R*R*R:1-Math.pow(-2*R+2,3)/2).call(Fe.transform,Cn)};t.some(pe=>pe.x==null||pe.y==null)?requestAnimationFrame(te):te()}function Gt(te){const pe=Math.max(0,Math.min(te,o)),We=y.k,ut=((o-pe)/2-y.x)/We,at=(a/2-y.y)/We,Mt=sr.translate(o/2-ut*We,a/2-at*We).scale(We);m.transition().duration(560).ease(Be=>Be<.5?4*Be*Be*Be:1-Math.pow(-2*Be+2,3)/2).call(Fe.transform,Mt)}function Zt(te){if(je(),!te)return;const pe=t.find(ut=>ut.id===te);if(!pe)return;const We=()=>{const ut=Y.get(te)??new Set,at=[pe,...Array.from(ut).map(_t=>t.find(qn=>qn.id===_t)).filter(Boolean)];let Mt=1/0,Be=-1/0,ft=1/0,Vt=-1/0;for(const _t of at){const qn=_t.x??o/2,yn=_t.y??a/2;Mt=Math.min(Mt,qn),Be=Math.max(Be,qn),ft=Math.min(ft,yn),Vt=Math.max(Vt,yn)}const Bt=80,pn=Be-Mt+Bt*2,Cn=Vt-ft+Bt*2,R=r.inset?.()??420,se=o-R,fe=a,Pe=se/pn,dt=fe/Cn,Qe=Math.min(Pe,dt,2),pt=(Mt+Be)/2,Wt=(ft+Vt)/2,mn=(o-R)/2,$t=a/2,Qt=sr.translate(mn-pt*Qe,$t-Wt*Qe).scale(Qe);m.transition().duration(900).ease(_t=>_t<.5?4*_t*_t*_t:1-Math.pow(-2*_t+2,3)/2).call(Fe.transform,Qt)};pe.x==null||pe.y==null?requestAnimationFrame(We):We()}return u?.zoom&&m.call(Fe.transform,y),{stop:()=>{b&&cancelAnimationFrame(b),$&&clearTimeout($),de&&cancelAnimationFrame(de),Ae&&cancelAnimationFrame(Ae),Ft&&cancelAnimationFrame(Ft),M!==null&&clearTimeout(M),He.stop(),V(),r.layout?.flush(),F.remove(),z.removeEventListener("mousedown",re),window.removeEventListener("mousemove",ie),window.removeEventListener("mouseup",be),z.remove(),window.removeEventListener("keydown",_e),window.removeEventListener("keyup",xe)},focus:Zt,fit:gn,recenter:Gt,setHoveredId:te=>{if(!(te&&!U.has(te))){if(I=te,je(),te){const pe=U.get(te);pe&&vn(pe)}else cn();dn()}},setPhysics:te=>{Le={...te};const pe=He.force("link");pe&&pe.distance(tt());const We=He.force("charge");We&&We.strength(ge());const ut=He.force("collide");ut&&ut.radius(qe()),He.alphaDecay(we()),He.alpha(.3).restart()}}}const Ki={critical:"var(--icon-error)",high:"var(--icon-warning)",medium:"var(--icon-info)",low:"var(--text-weaker)"},H9=["January","February","March","April","May","June","July","August","September","October","November","December"];function bf(...e){return e.find(t=>t&&!Number.isNaN(new Date(t).getTime()))??new Date().toISOString()}function U9(){const e=Ar(),t=new Date,[n,r]=ke(t.getFullYear()),[i,o]=ke(t.getMonth()),[a]=Yl(()=>e.revision,()=>e.fetchMilestones(),{initialValue:[]}),d=()=>{i()===0?(r(h=>h-1),o(11)):o(h=>h-1)},c=()=>{i()===11?(r(h=>h+1),o(0)):o(h=>h+1)},u=T(()=>{const h=new Date(n(),i(),1).getDay(),k=new Date(n(),i()+1,0).getDate();return{first:h,total:k}}),g=T(()=>{const h=new Map,k=[...e.issues.map(v=>({kind:"issue",id:v.id,title:v.title,priority:v.priority,date:bf(v.createdAt)})),...e.workUnits.map(v=>({kind:"workunit",id:v.id,title:v.title,priority:v.priority,date:bf(v.createdAt,v.updatedAt)}))];for(const v of k){const C=new Date(v.date);if(C.getFullYear()!==n()||C.getMonth()!==i())continue;const y=C.getDate(),b=h.get(y)??[];b.push(v),h.set(y,b)}return h}),f=T(()=>{const h=new Map;for(const k of a.latest??[]){if(!k.createdAt)continue;const v=new Date(k.createdAt);if(v.getFullYear()!==n()||v.getMonth()!==i())continue;const C=v.getDate(),y=h.get(C)??[];y.push(k),h.set(C,y)}return h}),m=T(()=>{const{first:h,total:k}=u(),v=Array(h).fill(null);for(let C=1;C<=k;C++)v.push(C);return v}),p=new Date,w=h=>h===p.getDate()&&i()===p.getMonth()&&n()===p.getFullYear();return(()=>{var h=XT(),k=h.firstChild,v=k.firstChild,C=v.firstChild,y=k.nextSibling,b=y.firstChild,_=b.nextSibling,$=_.nextSibling,D=$.firstChild,L=D.firstChild,V=D.nextSibling,K=V.firstChild,I=V.nextSibling,U=I.firstChild,Y=I.nextSibling,S=Y.firstChild,M=Y.nextSibling,A=M.nextSibling,F=A.firstChild;return l(k,s(Ot,{icon:"chevron-left",variant:"ghost",onClick:d,"aria-label":"Previous month"}),v),l(v,()=>H9[i()],C),l(v,n,null),l(k,s(Ot,{icon:"chevron-right",variant:"ghost",onClick:c,"aria-label":"Next month"}),null),l(b,s(Oe,{each:["Su","Mo","Tu","We","Th","Fr","Sa"],children:N=>(()=>{var X=ZT();return l(X,N),X})()})),l(_,s(Oe,{get each(){return m()},children:N=>(()=>{var X=e9();return l(X,s(E,{when:N!==null,get children(){return[(()=>{var B=QT();return l(B,N),G(O=>Tt(B,{"bg-text-strong text-background-base":w(N),"text-text-weak":!w(N)},O)),B})(),(()=>{var B=JT();return l(B,s(Oe,{get each(){return g().get(N)??[]},children:O=>(()=>{var z=t9();return G(q=>{var Q=O.kind==="issue",j=O.kind==="workunit",H=Ki[O.priority]??"var(--text-weaker)",J=`${O.kind==="workunit"?"WorkUnit":"Issue"}: ${O.title}`;return Q!==q.e&&z.classList.toggle("rounded-full",q.e=Q),j!==q.t&&z.classList.toggle("rounded-sm",q.t=j),H!==q.a&&Je(z,"background",q.a=H),J!==q.o&&ue(z,"title",q.o=J),q},{e:void 0,t:void 0,a:void 0,o:void 0}),z})()}),null),l(B,s(Oe,{get each(){return f().get(N)??[]},children:O=>(()=>{var z=n9();return G(()=>ue(z,"title",O.message??O.id)),z})()}),null),B})()]}})),G(B=>{var O=N!==null&&!w(N),z=!!w(N);return O!==B.e&&X.classList.toggle("bg-surface-base",B.e=O),z!==B.t&&X.classList.toggle("bg-surface-raised-base",B.t=z),B},{e:void 0,t:void 0}),X})()})),G(N=>{var X=Ki.critical,B=Ki.high,O=Ki.medium,z=Ki.low,q=Ki.medium;return X!==N.e&&Je(L,"background",N.e=X),B!==N.t&&Je(K,"background",N.t=B),O!==N.a&&Je(U,"background",N.a=O),z!==N.o&&Je(S,"background",N.o=z),q!==N.i&&Je(F,"background",N.i=q),N},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),h})()}function W9(){const e=Ar(),t=T(()=>e.suggestions),[n,r]=ke(),i=async o=>{r(o),await e.dismissSuggestion(o),r(void 0)};return(()=>{var o=r9(),a=o.firstChild;a.firstChild;var d=a.nextSibling;return l(a,s(kt,{size:"small",variant:"ghost",onClick:()=>void e.refresh(),children:"Refresh"}),null),l(d,s(E,{get when(){return t().length>0},get fallback(){return(()=>{var c=i9(),u=c.firstChild;return l(c,s(Ue,{name:"checklist",size:"small",class:"text-icon-weak"}),u),c})()},get children(){var c=_a();return l(c,s(Oe,{get each(){return t()},children:u=>(()=>{var g=s9(),f=g.firstChild,m=f.nextSibling,p=m.firstChild,w=p.nextSibling;return w.firstChild,l(f,s(E,{get when(){return u.priority==="high"},get fallback(){return s(Ue,{name:"alert-triangle",size:"small",class:"text-icon-warning"})},get children(){return s(Ue,{name:"alert-triangle",size:"small",class:"text-icon-error"})}})),l(p,()=>u.description),l(w,()=>u.ruleId,null),l(w,s(E,{get when(){return u.entityId},get children(){return[" · ",Te(()=>u.entityId)]}}),null),l(g,s(kt,{size:"small",variant:"ghost",onClick:()=>i(u.id),get disabled(){return n()===u.id},children:"Dismiss"}),null),g})()})),c}})),o})()}function K9(){const e=Ar(),[t,n]=ke([]),[r,i]=ke();Mn(()=>{e.fetchPlans().then(n)});const o=a=>`rounded-full px-2 py-0.5 text-10-medium ${{drafting:"bg-surface-raised-base text-text-warning",submitted:"bg-surface-warning/20 text-text-warning",approved:"bg-surface-raised-base text-text-success",rejected:"bg-surface-raised-base text-text-danger"}[a]??"bg-surface-raised-base text-text-weak"}`;return(()=>{var a=o9(),d=a.firstChild;d.firstChild;var c=d.nextSibling;return l(d,s(kt,{size:"small",variant:"ghost",onClick:()=>void e.fetchPlans().then(n),children:"Refresh"}),null),l(c,s(E,{get when(){return t().length>0},get fallback(){return a9()},get children(){var u=_a();return l(u,s(Oe,{get each(){return t()},children:g=>(()=>{var f=u9(),m=f.firstChild,p=m.firstChild,w=p.nextSibling,h=w.firstChild,k=w.nextSibling,v=k.firstChild,C=k.nextSibling;return m.$$click=()=>i(r()===g.id?void 0:g.id),l(p,()=>g.status),l(h,()=>g.title),l(k,()=>g.operations.length,v),l(C,()=>Zs(g.createdAt)),l(f,s(E,{get when(){return r()===g.id},get children(){var y=d9();return l(y,s(E,{get when(){return g.description},get children(){var b=l9();return l(b,()=>g.description),b}}),null),l(y,s(Oe,{get each(){return g.operations},children:b=>(()=>{var _=m9(),$=_.firstChild;return l($,()=>b.kind),l(_,s(E,{get when(){return b.entityType},get children(){var D=f9();return l(D,()=>b.entityType),D}}),null),l(_,s(E,{get when(){return b.description},get children(){var D=g9();return l(D,()=>b.description),D}}),null),_})()}),null),l(y,s(E,{get when(){return g.rejectionReason},get children(){var b=c9();return b.firstChild,l(b,()=>g.rejectionReason,null),b}}),null),y}}),null),G(()=>Ht(p,o(g.status))),f})()})),u}})),a})()}function G9(){const e=Ar(),t=T(()=>{const d=new Map,c=Date.now();for(let u=7;u>=0;u--){const g=new Date(c-u*7*864e5),f=`W${Math.ceil(g.getDate()/7)}`;d.set(f,{created:0,closed:0})}for(const u of e.issues){if(!u.createdAt)continue;const g=new Date(u.createdAt),f=Math.floor((c-g.getTime())/(7*864e5));if(f>7||f<0)continue;const m=`W${Math.ceil(g.getDate()/7)}`,p=d.get(m);p&&p.created++,u.status==="closed"&&p&&p.closed++}return[...d.entries()].map(([u,g])=>({label:u,...g}))}),n=T(()=>{let d=1;for(const c of t())c.created>d&&(d=c.created),c.closed>d&&(d=c.closed);return d}),r=T(()=>{const d={};for(const c of e.issues)d[c.priority]=(d[c.priority]??0)+1;return Object.entries(d).sort((c,u)=>u[1]-c[1])}),i=T(()=>{const d={};for(const c of e.issues)d[c.status]=(d[c.status]??0)+1;return Object.entries(d).sort((c,u)=>u[1]-c[1])}),o=d=>d==="closed"?"bg-text-success/70":d==="in_progress"?"bg-text-warning/70":d==="queue"?"bg-text-info/70":d==="paused"?"bg-[#bc8cff]/70":"bg-text-weak/40",a=d=>d==="critical"?"bg-text-error/70":d==="high"?"bg-text-warning/70":d==="medium"?"bg-text-info/70":"bg-text-weak/40";return(()=>{var d=h9(),c=d.firstChild,u=c.firstChild,g=u.nextSibling,f=c.nextSibling,m=f.firstChild,p=m.nextSibling,w=f.nextSibling,h=w.firstChild,k=h.nextSibling;return l(g,s(Oe,{get each(){return t()},children:v=>(()=>{var C=p9(),y=C.firstChild,b=y.firstChild,_=b.nextSibling,$=y.nextSibling;return l($,()=>v.label),G(D=>{var L=`${v.created/n()*100}%`,V=`Created: ${v.created}`,K=`${v.closed/n()*100}%`,I=`Closed: ${v.closed}`;return L!==D.e&&Je(b,"height",D.e=L),V!==D.t&&ue(b,"title",D.t=V),K!==D.a&&Je(_,"height",D.a=K),I!==D.o&&ue(_,"title",D.o=I),D},{e:void 0,t:void 0,a:void 0,o:void 0}),C})()})),l(p,s(Oe,{get each(){return r()},children:([v,C])=>{const y=()=>e.issues.length>0?C/e.issues.length*100:0;return(()=>{var b=v9(),_=b.firstChild,$=_.nextSibling,D=$.firstChild,L=$.nextSibling;return l(_,v),l(L,C),G(V=>{var K=`h-full rounded-full ${a(v)}`,I=`${y()}%`;return K!==V.e&&Ht(D,V.e=K),I!==V.t&&Je(D,"width",V.t=I),V},{e:void 0,t:void 0}),b})()}})),l(k,s(Oe,{get each(){return i()},children:([v,C])=>{const y=()=>e.issues.length>0?C/e.issues.length*100:0;return(()=>{var b=b9(),_=b.firstChild,$=_.nextSibling,D=$.firstChild,L=$.nextSibling;return l(_,()=>v.replace("_"," ")),l(L,C),G(V=>{var K=`h-full rounded-full ${o(v)}`,I=`${y()}%`;return K!==V.e&&Ht(D,V.e=K),I!==V.t&&Je(D,"width",V.t=I),V},{e:void 0,t:void 0}),b})()}})),d})()}function Y9(){return{"border-left":"3px solid var(--text-accent)","background-image":"linear-gradient(90deg, color-mix(in srgb, var(--text-accent) 12%, transparent), transparent 55%)"}}function X9(e){const t=Ar(),[n,r]=ke("board"),i=T(()=>t.suggestions.length),o=T(()=>[{id:"board",label:"Board",icon:"checklist"},{id:"milestones",label:"Milestones",icon:"flag"},{id:"calendar",label:"Calendar",icon:"calendar"},{id:"suggestions",label:"Suggestions",icon:"lightbulb",badge:i()},{id:"plans",label:"Plans",icon:"scroll"},{id:"insights",label:"Insights",icon:"line-chart"}]),a=T(()=>o().find(d=>d.id===n()));return s(Rc,{get children(){return s(zc,{get children(){return[s(JS,{title:"Plan",get meta(){return t.issues.length},width:224,get children(){return s(Lp,{get items(){return o().map(d=>({id:d.id,label:d.label,icon:s(Ue,{get name(){return d.icon},size:"small",class:"text-icon-weak"}),badge:d.badge&&d.badge>0?d.badge:void 0}))},get active(){return n()},onSelect:d=>r(d),stagger:!0})}}),(()=>{var d=x9();return l(d,s(Oc,{get title(){return a()?.label??"Plan"},get meta(){return`${t.issues.length} issues · ${t.milestones.length} milestones`}}),null),l(d,s(Nc,{scroll:!1,get children(){return[s(E,{get when(){return n()==="board"},get children(){return s(C9,{get todos(){return e.todos}})}}),s(E,{get when(){return n()==="milestones"},get children(){return s(L9,{})}}),s(E,{get when(){return n()==="calendar"},get children(){return s(U9,{})}}),s(E,{get when(){return n()==="suggestions"},get children(){return s(W9,{})}}),s(E,{get when(){return n()==="plans"},get children(){return s(K9,{})}}),s(E,{get when(){return n()==="insights"},get children(){return s(G9,{})}})]}}),null),d})()]}})}})}function Z9(){return s(Up,{})}Kt(["click","mousedown","mouseup","pointerdown","input"]);var Q9=x('<aside class="shrink-0 border-b border-border-weaker-base bg-background-base"><div class="flex gap-1 overflow-x-auto no-scrollbar px-1.5 py-1.5"><button class="flex h-8 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-left text-11-medium transition-colors"><span>All</span><span class="rounded-full bg-surface-raised-base px-1.5 py-[1px] text-10-regular tabular-nums text-text-weaker"></span></button></div><div class="flex gap-1 overflow-x-auto no-scrollbar px-1.5 pb-1.5"><button class="flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-10-medium transition-colors">Hide empty'),J9=x('<button class="flex h-7 shrink-0 items-center gap-1 rounded-full px-2 text-10-medium transition-colors">'),e8=x('<aside class="shrink-0 border-r border-border-weaker-base px-2 py-3 flex flex-col gap-1 overflow-y-auto"><button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-colors"><span class="truncate flex-1">All</span><span class="px-1.5 py-[1px] rounded-full text-10-regular tabular-nums bg-surface-raised-base text-text-weaker"></span></button><div class="mx-1 my-1 border-t border-border-weaker-base">'),t8=x('<div class="px-2.5 py-1.5 text-11-regular text-text-weaker italic">No custom entities'),n8=x('<span class="text-10-regular tabular-nums text-text-weaker">'),r8=x('<div class="px-2 pb-1 flex items-center justify-between"><button class="flex items-center gap-1.5 text-10-medium uppercase tracking-wide text-text-weaker hover:text-text-base transition-colors"><span>'),i8=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-colors"><span class="truncate capitalize flex-1"></span><span class="px-1.5 py-[1px] rounded-full text-10-regular tabular-nums">'),s8=x('<button class="flex h-8 max-w-36 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-left text-11-medium transition-colors"><span class="min-w-0 truncate capitalize"></span><span class="shrink-0 rounded-full px-1.5 py-[1px] text-10-regular tabular-nums">'),o8=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-colors"><span class="flex-1 truncate"></span><span class="size-1.5 shrink-0 rounded-full transition-colors">');const Vp="trellis:database-sidebar-sections",Hp="trellis:database-sidebar-hide-empty",el={system:!0,custom:!0,options:!0};function a8(){try{const e=localStorage.getItem(Vp);return e?{...el,...JSON.parse(e)}:el}catch{return el}}function l8(e){try{localStorage.setItem(Vp,JSON.stringify(e))}catch{}}function c8(){try{return localStorage.getItem(Hp)==="true"}catch{return!1}}function xf(e){try{localStorage.setItem(Hp,String(e))}catch{}}function d8(e){const t=new Set(e.systemTypes),[n,r]=ke(c8()),i=p=>!n()||(e.counts[p]??0)>0||e.selectedType===p,o=()=>e.types.filter(p=>t.has(p)&&i(p)),a=()=>e.types.filter(p=>!t.has(p)&&i(p)),d=p=>e.theme?.(p)??{label:p,color:Ni(p),icon:p},[c,u]=ke(a8()),g=p=>{u(w=>{const h={...w,[p]:!w[p]};return l8(h),h})},f=p=>{e.selectedType===p?e.onSelectType(null):e.onSelectType(p)},m=T(()=>e.types.filter(i));return e.mobile?(()=>{var p=Q9(),w=p.firstChild,h=w.firstChild,k=h.firstChild,v=k.nextSibling,C=w.nextSibling,y=C.firstChild,b=y.firstChild;return h.$$click=()=>e.onSelectType(null),l(h,s(Ue,{name:"git-branch",size:"small",class:"text-icon-weak"}),k),l(v,()=>e.total??0),l(w,s(Oe,{get each(){return m()},children:_=>s(u8,{type:_,get count(){return e.counts[_]??0},get active(){return e.selectedType===_},get theme(){return d(_)},onClick:()=>f(_)})}),null),y.$$click=()=>{r(_=>(xf(!_),!_))},l(y,s(Ue,{name:"eye-off",size:"small",class:"text-icon-weak"}),b),l(C,s(E,{get when(){return Te(()=>!!e.options)()&&e.onToggleOption},get children(){return s(Oe,{each:["hidden","imports","links","ops"],children:_=>(()=>{var $=J9();return $.$$click=()=>e.onToggleOption(_),l($,_),G(D=>{var L={"text-text-strong bg-surface-raised-base":!!e.options[_],"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.options[_]},V=!!e.options[_];return D.e=Tt($,L,D.e),V!==D.t&&ue($,"aria-pressed",D.t=V),D},{e:void 0,t:void 0}),$})()})}}),null),G(_=>{var $={"text-text-strong bg-surface-raised-base":e.selectedType===null,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":e.selectedType!==null},D=e.selectedType===null,L={"text-text-strong bg-surface-raised-base":n(),"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!n()},V=n();return _.e=Tt(h,$,_.e),D!==_.t&&ue(h,"aria-pressed",_.t=D),_.a=Tt(y,L,_.a),V!==_.o&&ue(y,"aria-pressed",_.o=V),_},{e:void 0,t:void 0,a:void 0,o:void 0}),p})():(()=>{var p=e8(),w=p.firstChild,h=w.firstChild,k=h.nextSibling;return w.nextSibling,w.$$click=()=>e.onSelectType(null),l(w,s(Ue,{name:"git-branch",size:"small",class:"text-icon-weak"}),h),l(k,()=>e.total??0),l(p,s(Lo,{label:"System entities",get right(){return Te(()=>e.types.length>0)()?`${o().length}`:void 0},get open(){return c().system},onToggle:()=>g("system")}),null),l(p,s(E,{get when(){return c().system},get children(){return s(Oe,{get each(){return o()},children:v=>s(yf,{type:v,get count(){return e.counts[v]??0},get active(){return e.selectedType===v},get theme(){return d(v)},onClick:()=>f(v)})})}}),null),l(p,s(Lo,{label:"Custom entities",get right(){return Te(()=>a().length>0)()?`${a().length}`:"none"},get open(){return c().custom},onToggle:()=>g("custom"),topBorder:!0}),null),l(p,s(E,{get when(){return c().custom},get children(){return s(E,{get when(){return a().length>0},get fallback(){return t8()},get children(){return s(Oe,{get each(){return a()},children:v=>s(yf,{type:v,get count(){return e.counts[v]??0},get active(){return e.selectedType===v},get theme(){return d(v)},onClick:()=>f(v)})})}})}}),null),l(p,s(E,{get when(){return Te(()=>!!e.options)()&&e.onToggleOption},get children(){return s(Lo,{label:"Options",get open(){return c().options},onToggle:()=>g("options"),topBorder:!0})}}),null),l(p,s(E,{get when(){return!e.options||!e.onToggleOption},get children(){return s(Lo,{label:"Options",get open(){return c().options},onToggle:()=>g("options"),topBorder:!0})}}),null),l(p,s(E,{get when(){return c().options},get children(){return[s(As,{get icon(){return s(Ue,{name:"eye-off",size:"small",class:"text-icon-weak"})},label:"Hide empty entities",get active(){return n()},onClick:()=>{r(v=>(xf(!v),!v))},title:"Hide entity types with no records"}),s(E,{get when(){return Te(()=>!!e.options)()&&e.onToggleOption},get children(){return[s(As,{get icon(){return s(Ue,{name:"eye",size:"small",class:"text-icon-weak"})},label:"Hidden files",get active(){return e.options.hidden},onClick:()=>e.onToggleOption("hidden"),title:"Include dotfiles and gitignored paths"}),s(As,{get icon(){return s(Ue,{name:"link",size:"small",class:"text-icon-weak"})},label:"Import edges",get active(){return e.options.imports},onClick:()=>e.onToggleOption("imports"),title:"Edges from imports / requires / @import"}),s(As,{get icon(){return s(Ue,{name:"file-text",size:"small",class:"text-icon-weak"})},label:"Link edges",get active(){return e.options.links},onClick:()=>e.onToggleOption("links"),title:"Edges from markdown and wiki-links"}),s(As,{get icon(){return s(Gn,{type:"op",size:14,get color(){return Te(()=>!!e.options.ops)()?Tg.op:"var(--text-weaker)"}})},label:"Ops",get active(){return e.options.ops},onClick:()=>e.onToggleOption("ops"),title:"Include recent causal-stream ops"})]}})]}}),null),G(v=>{var C=`${e.width}px`,y={"text-text-strong bg-surface-raised-base":e.selectedType===null,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":e.selectedType!==null},b=e.selectedType===null;return C!==v.e&&Je(p,"width",v.e=C),v.t=Tt(w,y,v.t),b!==v.a&&ue(w,"aria-pressed",v.a=b),v},{e:void 0,t:void 0,a:void 0}),p})()}function Lo(e){return(()=>{var t=r8(),n=t.firstChild,r=n.firstChild;return Rt(n,"click",e.onToggle,!0),l(n,s(Ue,{name:"chevron-right",size:"small",class:"text-icon-weak transition-transform",get style(){return{transform:e.open?"rotate(90deg)":"rotate(0deg)"}}}),r),l(r,()=>e.label),l(t,s(E,{get when(){return e.right},get children(){var i=n8();return l(i,()=>e.right),i}}),null),G(i=>{var o={"mt-3 pt-2 border-t border-border-weaker-base":!!e.topBorder},a=e.open;return i.e=Tt(t,o,i.e),a!==i.t&&ue(n,"aria-expanded",i.t=a),i},{e:void 0,t:void 0}),t})()}function yf(e){const t=()=>e.theme.color;return(()=>{var n=i8(),r=n.firstChild,i=r.nextSibling;return Rt(n,"click",e.onClick,!0),l(n,s(Gn,{get type(){return e.type},size:14,get color(){return Te(()=>!!e.active)()?t():"var(--text-weaker)"},get icon(){return e.theme.icon}}),r),l(r,()=>e.theme.label),l(i,()=>e.count),G(o=>{var a={"text-text-strong bg-surface-raised-base":e.active,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.active},d=e.active,c=e.active?{"background-color":`color-mix(in oklab, ${t()} 18%, transparent)`,color:`color-mix(in oklab, ${t()} 90%, var(--text-base))`}:{"background-color":"var(--surface-raised-base)",color:"var(--text-weaker)"};return o.e=Tt(n,a,o.e),d!==o.t&&ue(n,"aria-pressed",o.t=d),o.a=Pn(i,c,o.a),o},{e:void 0,t:void 0,a:void 0}),n})()}function u8(e){const t=()=>e.theme.color;return(()=>{var n=s8(),r=n.firstChild,i=r.nextSibling;return Rt(n,"click",e.onClick,!0),l(n,s(Gn,{get type(){return e.type},size:14,get color(){return Te(()=>!!e.active)()?t():"var(--text-weaker)"},get icon(){return e.theme.icon}}),r),l(r,()=>e.theme.label),l(i,()=>e.count),G(o=>{var a={"text-text-strong bg-surface-raised-base":e.active,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.active},d=e.active,c=e.active?{"background-color":`color-mix(in oklab, ${t()} 18%, transparent)`,color:`color-mix(in oklab, ${t()} 90%, var(--text-base))`}:{"background-color":"var(--surface-raised-base)",color:"var(--text-weaker)"};return o.e=Tt(n,a,o.e),d!==o.t&&ue(n,"aria-pressed",o.t=d),o.a=Pn(i,c,o.a),o},{e:void 0,t:void 0,a:void 0}),n})()}function As(e){return(()=>{var t=o8(),n=t.firstChild,r=n.nextSibling;return Rt(t,"click",e.onClick,!0),l(t,()=>e.icon,n),l(n,()=>e.label),G(i=>{var o={"text-text-strong":e.active,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.active},a=e.active,d=e.title,c=!!e.active,u=!e.active;return i.e=Tt(t,o,i.e),a!==i.t&&ue(t,"aria-pressed",i.t=a),d!==i.a&&ue(t,"title",i.a=d),c!==i.o&&r.classList.toggle("bg-text-strong",i.o=c),u!==i.i&&r.classList.toggle("bg-border-base",i.i=u),i},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})()}Kt(["click"]);var f8=x('<div class="db-json-view shiki-json-view">'),g8=x("<pre class=db-json-view>");function jc(e){const t=ng(),[n]=Yl(()=>({code:e.code,mode:t.mode()}),async({code:r,mode:i})=>i0(r,{lang:"json",theme:i==="dark"?"github-dark":"github-light"}));return s(E,{get when(){return n()},get fallback(){return(()=>{var r=g8();return l(r,()=>e.code),r})()},get children(){var r=f8();return G(()=>r.innerHTML=n()),r}})}var m8=x('<button class="text-text-weaker hover:text-text-base"title=Clear>'),h8=x('<div class="h-full overflow-y-auto"><div class=relative>'),p8=x('<div class="flex flex-col h-full min-h-0"><div class="shrink-0 flex flex-col gap-1.5 border-b border-border-weaker-base px-2 py-1.5 sm:flex-row sm:items-center sm:gap-2 sm:px-3 sm:py-2"><div class="flex w-full items-center gap-1.5 rounded-md bg-surface-raised-base/40 px-2 py-0.5 sm:flex-1 sm:min-w-0 sm:py-1"><input type=text class="flex-1 min-w-0 bg-transparent border-0 outline-0 text-11-regular text-text-base placeholder:text-text-weaker sm:text-12-regular"placeholder="Filter… key:value"></div><div class="shrink-0 flex items-center gap-0.5 self-start rounded-md bg-surface-raised-base/40 p-0.5"></div></div><div class="flex-1 min-h-0 overflow-hidden">'),v8=x('<button class="flex items-center gap-1 rounded px-1.5 py-0.5 text-10-medium transition-colors sm:px-2 sm:py-1 sm:text-11-medium">'),b8=x('<div class="h-full flex items-center justify-center text-12-regular text-text-weaker">No records'),x8=x('<button class="absolute left-3 right-3 flex items-center gap-2 px-2.5 py-2 rounded-md text-left text-12-regular text-text-weak hover:text-text-base hover:bg-surface-raised-base/40 transition-colors"style=height:32px><span class="font-mono text-text-base truncate flex-1"></span><span class="px-1.5 py-[1px] rounded-full text-10-regular tabular-nums shrink-0"style=background-color:var(--surface-raised-base)>');function y8(e){const t=e.trim();if(!t)return{};const n=t.match(/^([a-zA-Z_][\w-]*)\s*[:=]\s*(.+)$/);return n?{attribute:n[1],value:n[2].trim()}:{value:t}}const w8=[{id:"list",label:"List",icon:"list"},{id:"json",label:"JSON-LD",icon:"braces"}],Po=40,wf=8;function $8(e){const t=Dr(),n=io(),[r,i]=ke("list"),[o,a]=ke(""),[d,c]=ke({top:0,height:0});let u;const g=T(()=>e.type?t.entities.filter(C=>Ei(C.type,e.type)):t.entities),f=T(()=>{const C=new Map;for(const y of t.facts){const b=C.get(y.e);b?b.push(y):C.set(y.e,[y])}return C}),m=T(()=>{const C=y8(o()),y=g();if(!C.value&&!C.attribute)return y;const b=C.value?.toLowerCase();if(!C.attribute&&b)return y.filter($=>$.id.toLowerCase().includes(b)||Cr($.type).includes(b)||(f().get($.id)??[]).some(D=>D.a.toLowerCase().includes(b)||String(D.v).toLowerCase().includes(b)));const _=C.attribute?.toLowerCase();return y.filter($=>(f().get($.id)??[]).some(D=>(!_||D.a.toLowerCase().includes(_))&&(!b||String(D.v).toLowerCase().includes(b))))}),p=T(()=>{const C=m().length,y=d(),b=y.height||600,_=Math.max(0,Math.floor(y.top/Po)-wf),$=Math.min(C,Math.ceil((y.top+b)/Po)+wf);return{start:_,end:$}}),w=T(()=>m().slice(p().start,p().end)),h=C=>e.theme?.(C)??{label:C,color:Ni(C),icon:C},k=T(()=>JSON.stringify({"@context":{"@vocab":"https://trellis.local/store#"},"@graph":m().map(C=>{const y={"@id":C.id,"@type":C.type};for(const b of f().get(C.id)??[]){const _=y[b.a];_===void 0?y[b.a]=b.v:y[b.a]=Array.isArray(_)?[..._,b.v]:[_,b.v]}return y})},null,2)),v=C=>c({top:C.scrollTop,height:C.clientHeight});return $e(()=>{o(),e.type,requestAnimationFrame(()=>{u&&(u.scrollTop=0,v(u))})}),(()=>{var C=p8(),y=C.firstChild,b=y.firstChild,_=b.firstChild,$=b.nextSibling,D=y.nextSibling;return l(b,s(Ue,{name:"search",size:"small",class:"text-icon-weak shrink-0"}),_),_.$$input=L=>a(L.currentTarget.value),l(b,s(E,{get when(){return o()},get children(){var L=m8();return L.$$click=()=>a(""),l(L,s(Ue,{name:"x",size:"small"})),L}}),null),l($,s(Oe,{each:w8,children:L=>(()=>{var V=v8();return V.$$click=()=>i(L.id),l(V,s(Ue,{get name(){return L.icon},size:"small"}),null),l(V,()=>L.label,null),G(K=>{var I={"bg-surface-raised-base text-text-strong":r()===L.id,"text-text-weak hover:text-text-base":r()!==L.id},U=r()===L.id;return K.e=Tt(V,I,K.e),U!==K.t&&ue(V,"aria-pressed",K.t=U),K},{e:void 0,t:void 0}),V})()})),l(D,s(Dn,{get children(){return[s(ot,{get when(){return r()==="json"},get children(){return s(jc,{get code(){return k()}})}}),s(ot,{get when(){return r()==="list"},get children(){return s(E,{get when(){return m().length>0},get fallback(){return(()=>{var L=b8();return L.firstChild,l(L,(()=>{var V=Te(()=>!!e.type);return()=>V()?` of type ${e.type}`:""})(),null),L})()},get children(){var L=h8(),V=L.firstChild;return L.addEventListener("scroll",K=>v(K.currentTarget)),Lt(K=>{u=K,requestAnimationFrame(()=>v(K))},L),l(V,s(Oe,{get each(){return w()},children:(K,I)=>{const U=h(K.type);return(()=>{var Y=x8(),S=Y.firstChild,M=S.nextSibling;return Y.$$click=()=>{t.select(K.id),n.push(K.id,K.type)},l(Y,s(Gn,{get type(){return K.type},size:14,class:"shrink-0",get color(){return U.color},get icon(){return U.icon}}),S),l(S,()=>K.id),l(M,()=>U.label),G(A=>{var F=`${(p().start+I())*Po+4}px`,N=U.color;return F!==A.e&&Je(Y,"top",A.e=F),N!==A.t&&Je(M,"color",A.t=N),A},{e:void 0,t:void 0}),Y})()}})),G(K=>Je(V,"height",`${m().length*Po}px`)),L}})}})]}})),G(()=>_.value=o()),C})()}Kt(["input","click"]);var k8=x('<div class="h-full w-full overflow-hidden bg-background-base"><svg class="h-full min-h-[560px] w-full cursor-grab active:cursor-grabbing"viewBox="0 0 1000 700"preserveAspectRatio="xMinYMin meet"style=touch-action:none><defs><pattern id=links-erd-dots width=16 height=16 patternUnits=userSpaceOnUse><circle cx=1 cy=1 r=1 fill=var(--text-weaker) opacity=0.35></circle></pattern></defs><g><rect x=-2000 y=-2000 fill=url(#links-erd-dots)>'),_8=x('<div class="h-full flex items-center justify-center text-12-regular text-text-weaker">No relationships to render'),C8=x("<svg><g><path></path><circle r=3></circle><circle r=3></svg>",!1,!0,!1),S8=x('<svg><g><rect width=224 rx=8></rect><rect width=224 height=44 rx=8 fill=var(--surface-raised-base)></rect><path d="M 0 44 H 224"stroke=var(--border-weaker-base)></path><text x=14 y=26 fill=var(--text-strong) font-size=12 font-family="ui-monospace, monospace"></text><text x=206 y=26 text-anchor=middle fill=var(--text-weaker) font-size=16>⋮</svg>',!1,!0,!1),T8=x('<svg><g><path d="M 12 24 H 212"stroke=var(--border-weaker-base) stroke-dasharray="3 3"></path><text x=14 y=16 fill=var(--text-base) font-size=11 font-family="ui-monospace, monospace"></text><text x=210 y=16 text-anchor=end fill=var(--text-weaker) font-size=10 font-family="ui-monospace, monospace"></svg>',!1,!0,!1);const Fo=224,ii=44,Ro=24,$f=72,kf=52,zo=64,tl=7;function A8(e){const t=Dr(),[n,r]=ke({x:0,y:0,k:1});let i,o,a;const d=()=>e.type==="all",c=T(()=>{const j=new Map;for(const H of e.links){const J=e.typeOf(H.e1),le=e.typeOf(H.e2),de=`${J}|${H.a}|${le}`,Re=j.get(de);Re?Re.count++:j.set(de,{key:de,source:J,target:le,relation:H.a,count:1})}return Array.from(j.values()).sort((H,J)=>J.count-H.count)}),u=j=>e.theme?.(j)??{label:j,color:Ni(j),icon:j},g=T(()=>new Map(t.entities.map(j=>[j.id,j.type]))),f=T(()=>[...new Set(c().flatMap(j=>[j.source,j.target]))].filter(j=>d()||j===e.type).sort()),m=T(()=>{const j=new Map;for(const H of f()){const J=new Set(t.entities.filter(de=>de.type===H).map(de=>de.id)),le=new Map;for(const de of t.facts)!J.has(de.e)||le.has(de.a)||le.set(de.a,{name:de.a,value:typeof de.v,kind:"fact"});for(const de of t.links){const Re=g().get(de.e1),Ve=g().get(de.e2);Re===H&&!le.has(de.a)&&le.set(de.a,{name:de.a,value:Ve??"entity",kind:"link"})}j.set(H,[...le.values()].slice(0,tl))}return j}),p=T(()=>f().map((j,H)=>({type:j,x:zo+H%3*(Fo+$f),y:zo+Math.floor(H/3)*(ii+Ro*tl+kf),fields:m().get(j)??[]}))),w=T(()=>new Map(p().map(j=>[j.type,j]))),h=T(()=>({w:zo*2+Math.min(p().length,3)*Fo+Math.max(Math.min(p().length,3)-1,0)*$f,h:zo*2+Math.max(Math.ceil(p().length/3),1)*(ii+Ro*tl)+Math.max(Math.ceil(p().length/3)-1,0)*kf})),k=()=>c().length,v=(j,H)=>{const J=j.x+Fo,le=j.y+ii+12,de=H.x,Re=H.y+ii+12,Ve=J+(de-J)/2;return`M ${J} ${le} H ${Ve} V ${Re} H ${de}`},C=j=>d()||j.source===e.type||j.target===e.type,y=j=>ii+Math.max(j.fields.length,1)*Ro,b=j=>`/${u(j).label}`,_=j=>j.length>22?`${j.slice(0,19)}…`:j,$=j=>j.length>12?`${j.slice(0,9)}…`:j,D=j=>j.kind==="link"?" (FK)":"",L=(j,H)=>(H()===0||j.name==="id",""),V=j=>j.fields.length>0?j.fields:[{name:"id",value:"entity",kind:"fact"}],K={fill:"none",stroke:"var(--border-base)","stroke-width":1.5},I={fill:"var(--surface-raised-base)",stroke:"var(--border-base)","stroke-width":1},U={fill:"var(--background-base)",stroke:"var(--border-strong)","stroke-width":1.5},Y=j=>Math.min(2.5,Math.max(.45,j)),S=(j,H)=>{const J=a?.getScreenCTM()?.inverse();if(!a||!J)return{x:j,y:H};const le=a.createSVGPoint();le.x=j,le.y=H;const de=le.matrixTransform(J);return{x:de.x,y:de.y}},M=(j,H,J)=>{const le=Y(J),de=n(),Re=le/de.k;r({x:j-(j-de.x)*Re,y:H-(H-de.y)*Re,k:le})},A=j=>{if(j.preventDefault(),j.ctrlKey||j.metaKey){const H=S(j.clientX,j.clientY);M(H.x,H.y,n().k*Math.exp(-j.deltaY*.01));return}r(H=>({...H,x:H.x-(j.shiftKey?j.deltaY:j.deltaX),y:H.y-(j.shiftKey?0:j.deltaY)}))},F=j=>{j.pointerType!=="touch"&&(i={x:j.clientX,y:j.clientY},a?.setPointerCapture(j.pointerId))},N=j=>{if(!i)return;const H=i;i={x:j.clientX,y:j.clientY},r(J=>({...J,x:J.x+j.clientX-H.x,y:J.y+j.clientY-H.y}))},X=()=>{i=void 0},B=(j,H)=>Math.hypot(j.clientX-H.clientX,j.clientY-H.clientY),O=(j,H)=>({x:(j.clientX+H.clientX)/2,y:(j.clientY+H.clientY)/2}),z=j=>{if(j.touches.length!==2)return;j.preventDefault();const H=O(j.touches[0],j.touches[1]);o={...S(H.x,H.y),d:B(j.touches[0],j.touches[1]),k:n().k}},q=j=>{if(j.touches.length===1&&!o){j.preventDefault();const le=i??{x:j.touches[0].clientX,y:j.touches[0].clientY};i={x:j.touches[0].clientX,y:j.touches[0].clientY},r(de=>({...de,x:de.x+j.touches[0].clientX-le.x,y:de.y+j.touches[0].clientY-le.y}));return}if(j.touches.length!==2||!o)return;j.preventDefault();const H=O(j.touches[0],j.touches[1]),J=S(H.x,H.y);r(le=>({...le,x:le.x+J.x-o.x,y:le.y+J.y-o.y})),M(J.x,J.y,o.k*(B(j.touches[0],j.touches[1])/o.d)),o={...o,x:J.x,y:J.y}},Q=()=>{i=void 0,o=void 0};return s(E,{get when(){return k()>0},get fallback(){return _8()},get children(){var j=k8(),H=j.firstChild,J=H.firstChild,le=J.nextSibling,de=le.firstChild;H.addEventListener("touchcancel",Q),H.$$touchend=Q,H.$$touchmove=q,H.$$touchstart=z,H.addEventListener("pointercancel",X),H.$$pointerup=X,H.$$pointermove=N,H.$$pointerdown=F,H.addEventListener("wheel",A);var Re=a;return typeof Re=="function"?Lt(Re,H):a=H,l(le,s(Oe,{get each(){return c().filter(C)},children:Ve=>{const Z=w().get(Ve.source),ne=w().get(Ve.target);return!Z||!ne?null:(()=>{var re=C8(),ie=re.firstChild,be=ie.nextSibling,Fe=be.nextSibling;return Pn(ie,K),G(ee=>{var _e=v(Z,ne),xe=Z.x+Fo,ye=Z.y+ii+12,Le=U,tt=ne.x,ge=ne.y+ii+12,qe=U;return _e!==ee.e&&ue(ie,"d",ee.e=_e),xe!==ee.t&&ue(be,"cx",ee.t=xe),ye!==ee.a&&ue(be,"cy",ee.a=ye),ee.o=Pn(be,Le,ee.o),tt!==ee.i&&ue(Fe,"cx",ee.i=tt),ge!==ee.n&&ue(Fe,"cy",ee.n=ge),ee.s=Pn(Fe,qe,ee.s),ee},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),re})()}}),null),l(le,s(Oe,{get each(){return p()},children:Ve=>(()=>{var Z=S8(),ne=Z.firstChild,re=ne.nextSibling,ie=re.nextSibling,be=ie.nextSibling;return be.nextSibling,Pn(ne,I),l(be,()=>b(Ve.type)),l(Z,s(Oe,{get each(){return V(Ve)},children:(Fe,ee)=>(()=>{var _e=T8(),xe=_e.firstChild,ye=xe.nextSibling,Le=ye.nextSibling;return l(ye,()=>_(Fe.name),null),l(ye,()=>D(Fe),null),l(ye,()=>L(Fe,ee),null),l(Le,()=>$(Fe.value)),G(()=>ue(_e,"transform",`translate(0 ${ii+ee()*Ro})`)),_e})()}),null),G(Fe=>{var ee=`translate(${Ve.x} ${Ve.y})`,_e=y(Ve);return ee!==Fe.e&&ue(Z,"transform",Fe.e=ee),_e!==Fe.t&&ue(ne,"height",Fe.t=_e),Fe},{e:void 0,t:void 0}),Z})()}),null),G(Ve=>{var Z=`translate(${n().x} ${n().y}) scale(${n().k})`,ne=h().w+4e3,re=h().h+4e3;return Z!==Ve.e&&ue(le,"transform",Ve.e=Z),ne!==Ve.t&&ue(de,"width",Ve.t=ne),re!==Ve.a&&ue(de,"height",Ve.a=re),Ve},{e:void 0,t:void 0,a:void 0}),j}})}Kt(["pointerdown","pointermove","pointerup","touchstart","touchmove","touchend"]);var D8=x('<button class="text-text-weaker hover:text-text-base"title=Clear>'),M8=x('<div class="h-full overflow-y-auto"><div class="sticky top-0 z-10 hidden grid-cols-[minmax(12rem,1.25fr)_minmax(10rem,0.75fr)_minmax(12rem,1.25fr)] bg-background-base text-text-weaker text-10-medium uppercase tracking-wide sm:grid"><div class="px-4 py-3 font-medium">Source</div><div class="px-4 py-3 font-medium">Relation</div><div class="px-4 py-3 font-medium">Target</div></div><div class="relative text-12-regular">'),E8=x('<div class="flex flex-col h-full min-h-0"><div class="shrink-0 flex flex-col gap-1.5 border-b border-border-weaker-base px-2 py-1.5 sm:flex-row sm:items-center sm:gap-2 sm:px-3 sm:py-2"><div class="flex w-full items-center gap-1.5 rounded-md bg-surface-raised-base/40 px-2 py-0.5 sm:flex-1 sm:min-w-0 sm:py-1"><input type=text class="flex-1 min-w-0 bg-transparent border-0 outline-0 text-11-regular text-text-base placeholder:text-text-weaker sm:text-12-regular"placeholder="Filter… source: target: relation:"></div><div class="shrink-0 flex items-center gap-0.5 self-start rounded-md bg-surface-raised-base/40 p-0.5"></div></div><div class="flex-1 min-h-0 overflow-hidden">'),I8=x('<button class="flex items-center gap-1 rounded px-1.5 py-0.5 text-10-medium transition-colors sm:px-2 sm:py-1 sm:text-11-medium">'),L8=x('<div class="h-full flex items-center justify-center text-12-regular text-text-weaker">No relationships'),P8=x('<div class="absolute left-2 right-2 flex flex-col justify-center gap-1 rounded-lg border border-border-weaker-base/50 px-3 py-2 hover:bg-surface-raised-base/30 sm:left-0 sm:right-0 sm:grid sm:grid-cols-[minmax(12rem,1.25fr)_minmax(10rem,0.75fr)_minmax(12rem,1.25fr)] sm:rounded-none sm:border-x-0 sm:border-b-0 sm:px-0 sm:py-0"><div class="font-mono min-w-0 sm:px-4 sm:py-2.5"><button class="text-text-base hover:underline truncate block max-w-full"></button></div><div class="text-text-weak truncate sm:px-4 sm:py-2.5"></div><div class="font-mono min-w-0 sm:px-4 sm:py-2.5"><button class="text-text-base hover:underline truncate block max-w-full">');const F8=[{id:"erd",label:"ERD",icon:"network"},{id:"list",label:"List",icon:"list"},{id:"json",label:"JSON-LD",icon:"braces"}],R8=48,_f=10;function z8(e){const t=Dr(),n=io(),r=ds("(max-width: 639px)"),[i,o]=ke("erd"),[a,d]=ke(""),[c,u]=ke({top:0,height:0});let g;const f=T(()=>r()?88:R8),m=T(()=>new Map(t.entities.map(_=>[_.id,_.type]))),p=_=>Cr(m().get(_)??"unknown"),w=T(()=>e.type?t.links.filter(_=>Ei(m().get(_.e1)??"unknown",e.type)||Ei(m().get(_.e2)??"unknown",e.type)):t.links),h=_=>e.theme?.(_)??{label:_,color:Ni(_),icon:_},k=T(()=>{const _=w(),$=a().trim().toLowerCase();if(!$)return _;if($.startsWith("source:")){const D=$.slice(7).trim();return _.filter(L=>L.e1.toLowerCase().includes(D))}if($.startsWith("target:")){const D=$.slice(7).trim();return _.filter(L=>L.e2.toLowerCase().includes(D))}if($.startsWith("relation:")){const D=$.slice(9).trim();return _.filter(L=>L.a.toLowerCase().includes(D))}return _.filter(D=>D.a.toLowerCase().includes($)||D.e1.toLowerCase().includes($)||D.e2.toLowerCase().includes($))}),v=T(()=>{const _=k().length,$=c(),D=$.height||600,L=Math.max(0,Math.floor($.top/f())-_f),V=Math.min(_,Math.ceil(($.top+D)/f())+_f);return{start:L,end:V}}),C=T(()=>k().slice(v().start,v().end)),y=T(()=>JSON.stringify({"@context":{"@vocab":"https://trellis.local/store#"},"@graph":k().map(_=>({"@id":`${_.e1}#${_.a}#${_.e2}`,"@type":"Relationship",source:_.e1,sourceType:p(_.e1),relation:_.a,target:_.e2,targetType:p(_.e2)}))},null,2)),b=_=>u({top:_.scrollTop,height:_.clientHeight});return $e(()=>{a(),e.type,requestAnimationFrame(()=>{g&&(g.scrollTop=0,b(g))})}),(()=>{var _=E8(),$=_.firstChild,D=$.firstChild,L=D.firstChild,V=D.nextSibling,K=$.nextSibling;return l(D,s(Ue,{name:"search",size:"small",class:"text-icon-weak shrink-0"}),L),L.$$input=I=>d(I.currentTarget.value),l(D,s(E,{get when(){return a()},get children(){var I=D8();return I.$$click=()=>d(""),l(I,s(Ue,{name:"x",size:"small"})),I}}),null),l(V,s(Oe,{each:F8,children:I=>(()=>{var U=I8();return U.$$click=()=>o(I.id),l(U,s(Ue,{get name(){return I.icon},size:"small"}),null),l(U,()=>I.label,null),G(Y=>{var S={"bg-surface-raised-base text-text-strong":i()===I.id,"text-text-weak hover:text-text-base":i()!==I.id},M=i()===I.id;return Y.e=Tt(U,S,Y.e),M!==Y.t&&ue(U,"aria-pressed",Y.t=M),Y},{e:void 0,t:void 0}),U})()})),l(K,s(Dn,{get children(){return[s(ot,{get when(){return i()==="list"},get children(){return s(E,{get when(){return k().length>0},get fallback(){return(()=>{var I=L8();return I.firstChild,l(I,(()=>{var U=Te(()=>!!e.type);return()=>U()?` involve ${e.type}`:""})(),null),I})()},get children(){var I=M8(),U=I.firstChild,Y=U.nextSibling;return I.addEventListener("scroll",S=>b(S.currentTarget)),Lt(S=>{g=S,requestAnimationFrame(()=>b(S))},I),l(Y,s(Oe,{get each(){return C()},children:(S,M)=>(()=>{var A=P8(),F=A.firstChild,N=F.firstChild,X=F.nextSibling,B=X.nextSibling,O=B.firstChild;return N.$$click=()=>n.push(S.e1,p(S.e1)),l(N,()=>S.e1),l(X,()=>S.a),O.$$click=()=>n.push(S.e2,p(S.e2)),l(O,()=>S.e2),G(z=>{var q=`${(v().start+M())*f()}px`,Q=`${f()}px`,j=h(p(S.e1)).color,H=h(p(S.e2)).color;return q!==z.e&&Je(A,"top",z.e=q),Q!==z.t&&Je(A,"height",z.t=Q),j!==z.a&&Je(N,"color",z.a=j),H!==z.o&&Je(O,"color",z.o=H),z},{e:void 0,t:void 0,a:void 0,o:void 0}),A})()})),G(S=>Je(Y,"height",`${k().length*f()}px`)),I}})}}),s(ot,{get when(){return i()==="json"},get children(){return s(jc,{get code(){return y()}})}}),s(ot,{get when(){return i()==="erd"},get children(){return s(A8,{get type(){return e.type??"all"},get links(){return k()},typeOf:p,theme:h})}})]}})),G(()=>L.value=a()),_})()}Kt(["input","click"]);var O8=x('<button class="text-text-weaker hover:text-text-base"title=Clear>'),N8=x('<div class="h-full overflow-y-auto"><div class="sticky top-0 z-10 hidden grid-cols-[minmax(12rem,1.25fr)_minmax(10rem,0.75fr)_minmax(16rem,1.5fr)] bg-background-base text-text-weaker text-10-medium uppercase tracking-wide sm:grid"><div class="px-3 py-2 font-medium">Entity</div><div class="px-3 py-2 font-medium">Attribute</div><div class="px-3 py-2 font-medium">Value</div></div><div class="relative text-12-regular">'),B8=x('<div class="flex flex-col h-full min-h-0"><div class="shrink-0 flex flex-col gap-1.5 border-b border-border-weaker-base px-2 py-1.5 sm:flex-row sm:items-center sm:gap-2 sm:px-3 sm:py-2"><div class="flex w-full items-center gap-1.5 rounded-md bg-surface-raised-base/40 px-2 py-0.5 sm:flex-1 sm:min-w-0 sm:py-1"><input type=text class="flex-1 min-w-0 bg-transparent border-0 outline-0 text-11-regular text-text-base placeholder:text-text-weaker sm:text-12-regular"placeholder="Filter… entity: attr: value:"></div><div class="shrink-0 flex items-center gap-0.5 self-start rounded-md bg-surface-raised-base/40 p-0.5"></div></div><div class="flex-1 min-h-0 overflow-hidden">'),q8=x('<button class="flex items-center gap-1 rounded px-1.5 py-0.5 text-10-medium transition-colors sm:px-2 sm:py-1 sm:text-11-medium">'),j8=x('<div class="h-full flex items-center justify-center text-12-regular text-text-weaker">No facts'),V8=x('<div class="absolute left-2 right-2 flex flex-col justify-center gap-1 rounded-lg border border-border-weaker-base/50 px-3 py-2 hover:bg-surface-raised-base/30 sm:left-0 sm:right-0 sm:grid sm:grid-cols-[minmax(12rem,1.25fr)_minmax(10rem,0.75fr)_minmax(16rem,1.5fr)] sm:rounded-none sm:border-x-0 sm:border-b-0 sm:px-0 sm:py-0"><div class="font-mono min-w-0 sm:px-3 sm:py-1.5"><button class="text-text-base hover:underline truncate block max-w-full"></button></div><div class="text-text-weak font-mono truncate sm:px-3 sm:py-1.5"></div><div class="text-text-base font-mono truncate sm:px-3 sm:py-1.5">');const H8=[{id:"table",label:"Table",icon:"table"},{id:"json",label:"JSON-LD",icon:"braces"}],U8=34,Cf=10;function W8(e){const t=Dr(),n=io(),r=ds("(max-width: 639px)"),[i,o]=ke("table"),[a,d]=ke(""),[c,u]=ke({top:0,height:0});let g;const f=T(()=>r()?78:U8),m=T(()=>new Map(t.entities.map(_=>[_.id,_.type]))),p=_=>Cr(m().get(_)??"unknown"),w=T(()=>e.type?t.facts.filter(_=>Ei(m().get(_.e)??"unknown",e.type)):t.facts),h=T(()=>{const _=a().trim().toLowerCase();if(!_)return w();if(_.startsWith("entity:")){const $=_.slice(7).trim();return w().filter(D=>D.e.toLowerCase().includes($))}if(_.startsWith("attr:")){const $=_.slice(5).trim();return w().filter(D=>D.a.toLowerCase().includes($))}if(_.startsWith("value:")){const $=_.slice(6).trim();return w().filter(D=>String(D.v).toLowerCase().includes($))}return w().filter($=>$.e.toLowerCase().includes(_)||$.a.toLowerCase().includes(_)||String($.v).toLowerCase().includes(_))}),k=T(()=>{const _=h().length,$=c(),D=$.height||600,L=Math.max(0,Math.floor($.top/f())-Cf),V=Math.min(_,Math.ceil(($.top+D)/f())+Cf);return{start:L,end:V}}),v=T(()=>h().slice(k().start,k().end)),C=_=>e.theme?.(_)??{label:_,color:Ni(_),icon:_},y=T(()=>JSON.stringify({"@context":{"@vocab":"https://trellis.local/store#"},"@graph":h().map(_=>({"@id":_.e,"@type":p(_.e),[_.a]:_.v}))},null,2)),b=_=>u({top:_.scrollTop,height:_.clientHeight});return $e(()=>{a(),e.type,requestAnimationFrame(()=>{g&&(g.scrollTop=0,b(g))})}),(()=>{var _=B8(),$=_.firstChild,D=$.firstChild,L=D.firstChild,V=D.nextSibling,K=$.nextSibling;return l(D,s(Ue,{name:"search",size:"small",class:"text-icon-weak shrink-0"}),L),L.$$input=I=>d(I.currentTarget.value),l(D,s(E,{get when(){return a()},get children(){var I=O8();return I.$$click=()=>d(""),l(I,s(Ue,{name:"x",size:"small"})),I}}),null),l(V,s(Oe,{each:H8,children:I=>(()=>{var U=q8();return U.$$click=()=>o(I.id),l(U,s(Ue,{get name(){return I.icon},size:"small"}),null),l(U,()=>I.label,null),G(Y=>{var S={"bg-surface-raised-base text-text-strong":i()===I.id,"text-text-weak hover:text-text-base":i()!==I.id},M=i()===I.id;return Y.e=Tt(U,S,Y.e),M!==Y.t&&ue(U,"aria-pressed",Y.t=M),Y},{e:void 0,t:void 0}),U})()})),l(K,s(Dn,{get children(){return[s(ot,{get when(){return i()==="json"},get children(){return s(jc,{get code(){return y()}})}}),s(ot,{get when(){return i()==="table"},get children(){return s(E,{get when(){return h().length>0},get fallback(){return(()=>{var I=j8();return I.firstChild,l(I,(()=>{var U=Te(()=>!!e.type);return()=>U()?` for ${e.type}`:""})(),null),I})()},get children(){var I=N8(),U=I.firstChild,Y=U.nextSibling;return I.addEventListener("scroll",S=>b(S.currentTarget)),Lt(S=>{g=S,requestAnimationFrame(()=>b(S))},I),l(Y,s(Oe,{get each(){return v()},children:(S,M)=>(()=>{var A=V8(),F=A.firstChild,N=F.firstChild,X=F.nextSibling,B=X.nextSibling;return N.$$click=()=>n.push(S.e,p(S.e)),l(N,()=>S.e),l(X,()=>S.a),l(B,()=>String(S.v)),G(O=>{var z=`${(k().start+M())*f()}px`,q=`${f()}px`,Q=C(p(S.e)).color;return z!==O.e&&Je(A,"top",O.e=z),q!==O.t&&Je(A,"height",O.t=q),Q!==O.a&&Je(N,"color",O.a=Q),O},{e:void 0,t:void 0,a:void 0}),A})()})),G(S=>Je(Y,"height",`${h().length*f()}px`)),I}})}})]}})),G(()=>L.value=a()),_})()}Kt(["input","click"]);var K8=x('<div class="flex-1 flex items-center justify-center text-12-regular text-text-weaker">Loading store…'),G8=x('<div class="flex-1 min-h-0 flex flex-col">'),Y8=x('<div class="flex-1 min-w-0 min-h-0 flex flex-col">'),X8=x('<span class="flex items-center gap-2"><span class=capitalize></span><span class="text-text-weaker tabular-nums">'),Z8=x('<span class="flex items-center justify-between gap-3"><span>All entities</span><span class="text-10-regular text-text-weaker tabular-nums">'),Q8=x('<span class="flex items-center justify-between gap-3"><span class="flex min-w-0 items-center gap-2"><span class="truncate capitalize"></span></span><span class="text-10-regular text-text-weaker tabular-nums">'),J8=x('<span class="flex items-center justify-between gap-3"><span class=capitalize></span><span class="size-1.5 rounded-full">'),eA=x('<div class="h-full flex items-center justify-center text-12-regular text-text-weaker">Select an entity type to configure'),tA=x('<span class="text-11-medium text-text-weaker">Read-only'),nA=x("<span class=db-create-error style=font-size:0.75rem>Delete?"),rA=x('<button class="db-action-btn db-action-btn--danger">Yes'),iA=x("<button class=db-action-btn>No"),sA=x("<button class=db-action-btn>Add Property"),oA=x('<button class="db-action-btn db-action-btn--primary">'),aA=x('<div class=db-schema-editor><div class=db-detail-header><span class=db-detail-id></span><div class=db-detail-header-actions></div></div><div class=db-detail-scroll><div class=db-schema-prop-list><div class=db-schema-meta><div class=db-schema-meta-card><span class=db-field-label>Color</span><div class=db-color-wrap><input type=color class=db-color-input><span class=db-color-hex></span></div></div><div class=db-schema-meta-card><span class=db-field-label>Icon</span><button class=db-icon-pick><span class=truncate></span></button></div><label class="db-schema-meta-card db-schema-meta-card--wide"><span class=db-field-label>Entity description</span><textarea class="db-field-input db-schema-desc"placeholder="Describe what this entity type represents…"></textarea></label></div></div><div class=db-schema-editor-footer>'),lA=x('<button class=db-detail-close title="Delete type">'),cA=x("<span class=db-schema-lock title=Read-only>"),dA=x('<div class=db-schema-prop-row><span class=db-schema-type-icon></span><input class="db-field-input db-field-input--sm"placeholder=key><input class="db-field-input db-field-input--sm"placeholder=label><select class="db-select db-select--sm"></select><label class=db-schema-required><input type=checkbox class=db-checkbox>Req'),uA=x("<option>"),fA=x("<button class=db-detail-close>"),gA=x('<div class=db-schema-options-row><span class=db-field-label> options</span><input class=db-field-input placeholder="comma-separated options">'),mA=x('<div class=db-schema-options-row><span class=db-field-label> formula</span><input class=db-field-input placeholder="{level} * {strength}">'),hA=x('<div class=db-icon-dialog-backdrop><div class=db-icon-dialog><div class=db-icon-dialog-header><div class="text-13-medium text-text-strong">Choose icon</div><button class=db-detail-close title=Close></button></div><div class=db-icon-search><input class=db-field-input placeholder="Search icons…"></div><div class=db-icon-grid>'),pA=x("<button class=db-icon-option><span>");const vA=["text","number","boolean","date","email","url","color","select","multiselect","file","formula"],bA={text:"type",number:"hash",boolean:"toggle-left",date:"calendar",email:"mail",url:"link",color:"palette",select:"list",multiselect:"list-checks",file:"file",formula:"sigma",rich_text:"file-text",reference:"link",image:"image",video:"video",audio:"music"};function xA(e){if(typeof e!="string")return[];try{return JSON.parse(e)}catch{return[]}}function yA(e){return e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,t=>t.toUpperCase())}function wA(e){return typeof e.v=="boolean"?"boolean":typeof e.v=="number"?"number":/email/i.test(e.a)&&typeof e.v=="string"&&e.v.includes("@")?"email":/url|uri|link/i.test(e.a)&&typeof e.v=="string"&&/^https?:\/\//.test(e.v)?"url":/(date|at)$/i.test(e.a)&&typeof e.v=="string"&&!Number.isNaN(new Date(e.v).getTime())?"date":"text"}function Oo(e){return typeof e=="string"?e:void 0}function Sf(e,t){return e.find(n=>n.key===t)?.default}function Tf(e,t,n){return{label:n?.label||e,color:n?.color||Sf(t,"color")||Ai(e),icon:n?.icon||Sf(t,"icon")||Di(e),description:n?.description}}function $A(){const e=Dr(),t=ds("(max-width: 767px)"),[n,r]=ke(null),[i,o]=ke("graph"),[a,d]=ke({hidden:!0,imports:!0,links:!0,ops:!1}),c=T(()=>[{id:"graph",label:"Graph",icon:"git-branch"},{id:"records",label:"Records",icon:"table"},...n()?[{id:"configure",label:"Configure",icon:"sliders"}]:[],{id:"facts",label:"Facts",icon:"list"},{id:"relationships",label:"Relationships",icon:"network"},{id:"history",label:"History",icon:"history"},{id:"decisions",label:"Decisions",icon:"brain"},{id:"branches",label:"Branches",icon:"branch"}]),u=T(()=>({includeHidden:a().hidden,includeImports:a().imports,includeLinks:a().links,includeOps:a().ops})),g=S=>d(M=>({...M,[S]:!M[S]})),f=S=>{r(S),o("graph")},[m,p]=St({}),[w,h]=St({}),[k,v]=St({}),C=()=>{const S=new Map;for(const F of e.facts){const N=S.get(F.e);N?N.push(F):S.set(F.e,[F])}const M=e.entities.filter(F=>F.type==="TypeSchema").map(F=>{const N=S.get(F.id)??[],X=N.find(q=>q.a==="props"),B=xA(X?.v),O=vi(F.id.replace(/^schema:/,"")),z={label:Oo(N.find(q=>q.a==="label")?.v)||O,description:Oo(N.find(q=>q.a==="description")?.v),color:Oo(N.find(q=>q.a==="color")?.v),icon:Oo(N.find(q=>q.a==="icon")?.v)};return[O,B,z]});p(gi(Object.fromEntries(M.map(F=>[F[0],F[1]]))));const A=Object.fromEntries(M.map(F=>[F[0],F[2]]));h(gi(A)),v(gi(A))},y=T(()=>IS(e.entities,m));$e(()=>{e.revision,e.ready&&C()});const b=T(()=>{const S={};for(const M of e.entities){const A=Cr(M.type);S[A]=(S[A]??0)+1}return S}),_=T(()=>{const S=new Set(Qs);for(const M of Object.keys(y()))S.add(M);for(const M of e.entities)Fc(M)&&S.add(Cr(M.type));return Array.from(S).sort()}),$=T(()=>{const S=new Set;for(const M of e.entities)M.type==="TypeSchema"&&S.add(vi(M.id.replace(/^schema:/,"")));return S}),D=T(()=>{const S=new Map;for(const F of e.entities)S.set(F.id,Cr(F.type));const M=new Set,A={};for(const F of e.facts){const N=S.get(F.e);if(!N)continue;const X=`${N}:${F.a}`;M.has(X)||(M.add(X),A[N]=[...A[N]??[],{key:F.a,label:yA(F.a),type:wA(F),required:F.a==="type"}])}return A}),L=T(()=>{const S=n();if(!S)return[];const M=Gu(S);if(M)return M;const A=$().has(S)?m[S]??D()[S]??[]:D()[S]??Yu(S)??y()[S]??[];return Xu(S,A)}),V=T(()=>!!(n()&&Gu(n()))),K=T(()=>{const S={};for(const M of _()){const A=Xu(M,m[M]??Yu(M)??D()[M]??y()[M]??[]);S[M]=Tf(M,A,w[M])}return S}),I=S=>K()[Cr(S)]??Tf(Cr(S),[]),U=async(S,M)=>{const A=n();if(!A)return;const F=k[A],N=[{e:`schema:${A}`,a:"props",v:JSON.stringify(m[A]??[])},...F?.label?[{e:`schema:${A}`,a:"label",v:F.label}]:[],...F?.description?[{e:`schema:${A}`,a:"description",v:F.description}]:[],...F?.color?[{e:`schema:${A}`,a:"color",v:F.color}]:[],...F?.icon?[{e:`schema:${A}`,a:"icon",v:F.icon}]:[]],X=[{e:`schema:${A}`,a:"type",v:"TypeSchema"},{e:`schema:${A}`,a:"label",v:A},{e:`schema:${A}`,a:"props",v:JSON.stringify(S)},{e:`schema:${A}`,a:"color",v:M.color},{e:`schema:${A}`,a:"icon",v:M.icon},...M.description?[{e:`schema:${A}`,a:"description",v:M.description}]:[]];if(!$().has(A)){await e.assert(X),C();return}await e.retract(N),await e.assert(X),C()},Y=async()=>{const S=n();if(!S||!$().has(S)){r(null);return}const M=`schema:${S}`;await e.retract([{e:M,a:"type",v:"TypeSchema"},{e:M,a:"label",v:S},{e:M,a:"props",v:JSON.stringify(m[S]??[])},...w[S]?.description?[{e:M,a:"description",v:w[S].description}]:[],...w[S]?.color?[{e:M,a:"color",v:w[S].color}]:[],...w[S]?.icon?[{e:M,a:"icon",v:w[S].icon}]:[]]),C(),r(null)};return s(Rc,{get children(){return s(zc,{get compact(){return t()},get children(){return[s(E,{get when(){return!(t()&&i()==="graph")},get children(){return s(d8,{width:224,get mobile(){return t()},get types(){return _()},get counts(){return b()},systemTypes:Qs,get selectedType(){return n()},onSelectType:f,theme:I,get options(){return Te(()=>!!n())()?void 0:a()},get onToggleOption(){return n()?void 0:g},get total(){return e.entities.length}})}}),(()=>{var S=Y8();return l(S,s(Oc,{get title(){return s(E,{get when(){return n()},fallback:"All",children:M=>(()=>{var A=X8(),F=A.firstChild,N=F.nextSibling;return l(A,s(Gn,{get type(){return M()},size:14,get color(){return I(M()).color},get icon(){return I(M()).icon}}),F),l(F,()=>I(M()).label),l(N,()=>b()[M()]??0),A})()})},get meta(){return s(E,{get when(){return e.stats},children:M=>`${e.entities.length} entities · ${M().totalFacts} facts · ${M().totalLinks} links`})},get actions(){return s(E,{get when(){return Te(()=>!!t())()&&i()==="graph"},get children(){return s(Ye,{placement:"bottom-end",gutter:4,modal:!1,get children(){return[s(Ye.Trigger,{class:"flex h-7 items-center gap-1 rounded-md border border-border-base/50 bg-surface-raised-base/50 px-2 text-10-medium text-text-base","aria-label":"Graph filters",get children(){return[s(Ue,{name:"sliders",size:"small"}),"Graph"]}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"max-h-[70vh] min-w-[220px] overflow-y-auto",get children(){return[s(Ye.Item,{onSelect:()=>f(null),get children(){return s(Ye.ItemLabel,{get children(){var M=Z8(),A=M.firstChild,F=A.nextSibling;return l(F,()=>e.entities.length),M}})}}),s(Ye.Separator,{}),s(Oe,{get each(){return _()},children:M=>s(Ye.Item,{onSelect:()=>f(M),get children(){return s(Ye.ItemLabel,{get children(){var A=Q8(),F=A.firstChild,N=F.firstChild,X=F.nextSibling;return l(F,s(Gn,{type:M,size:14,get color(){return I(M).color},get icon(){return I(M).icon}}),N),l(N,()=>I(M).label),l(X,()=>b()[M]??0),A}})}})}),s(E,{get when(){return!n()},get children(){return[s(Ye.Separator,{}),s(Oe,{each:["hidden","imports","links","ops"],children:M=>s(Ye.Item,{onSelect:()=>g(M),get children(){return s(Ye.ItemLabel,{get children(){var A=J8(),F=A.firstChild,N=F.nextSibling;return l(F,M),G(X=>{var B=!!a()[M],O=!a()[M];return B!==X.e&&N.classList.toggle("bg-text-strong",X.e=B),O!==X.t&&N.classList.toggle("bg-border-base",X.t=O),X},{e:void 0,t:void 0}),A}})}})})]}})]}})}})]}})}})}}),null),l(S,s(E,{get when(){return!e.ready},get children(){return K8()}}),null),l(S,s(E,{get when(){return e.ready},get children(){var M=G8();return l(M,s(Lp,{variant:"tabs",get items(){return c().map(A=>({id:A.id,label:A.label,icon:s(Ue,{get name(){return A.icon},size:"small"})}))},get active(){return i()},onSelect:A=>o(A)}),null),l(M,s(Nc,{scroll:!1,get children(){return s(Dn,{get children(){return[s(ot,{get when(){return i()==="records"},get children(){return s($8,{get type(){return n()??void 0},theme:I})}}),s(ot,{get when(){return i()==="configure"},get children(){return s(E,{get when(){return n()},get fallback(){return eA()},children:A=>s(kA,{get name(){return A()},get defs(){return L()},get meta(){return I(A())},get defined(){return $().has(A())},get readonly(){return V()},onSave:U,onDraft:F=>h(A(),F),onDelete:Y})})}}),s(ot,{get when(){return i()==="graph"},get children(){return s(E,{get when(){return n()},get fallback(){return s(hf,{hideSidebar:!0,get options(){return u()},get themes(){return K()},get revision(){return e.revision},get highlightIds(){return e.fresh},onOptionsChange:A=>d({hidden:A.includeHidden,imports:A.includeImports,links:A.includeLinks,ops:A.includeOps})})},children:A=>s(hf,{hideSidebar:!0,get themes(){return K()},get revision(){return e.revision},get highlightIds(){return e.fresh},get scopedTypes(){return[...new Set(e.entities.filter(F=>Cr(F.type)===A()).map(F=>ES(F.type)))]}})})}}),s(ot,{get when(){return i()==="facts"},get children(){return s(W8,{get type(){return n()??void 0},theme:I})}}),s(ot,{get when(){return i()==="relationships"},get children(){return s(z8,{get type(){return n()??void 0},theme:I})}}),s(ot,{get when(){return i()==="history"},get children(){return s(M9,{})}}),s(ot,{get when(){return i()==="decisions"},get children(){return s(E9,{})}}),s(ot,{get when(){return i()==="branches"},get children(){return s(I9,{})}})]}})}}),null),M}}),null),S})()]}})}})}function Up(){return s(Xl,{get children(){return s($A,{})}})}function kA(e){const[t,n]=St([]),[r,i]=St({label:"",color:"#000000",icon:"thing"}),[o,a]=ke(!1),[d,c]=ke(!1),[u,g]=ke(!1);$e(()=>{n(gi(e.defs.map(v=>({...v}))))}),$e(()=>{i(gi({...e.meta}))});const f=T(()=>t.map((v,C)=>({row:v,idx:C})).filter(v=>v.row.key!=="color"&&v.row.key!=="icon")),m=()=>n(t.length,{key:"",label:"",type:"text"}),p=v=>n(C=>C.filter((y,b)=>b!==v)),w=(v,C)=>{const y=t.findIndex(b=>b.key===v);y>=0&&n(y,"default",C)},h=v=>{const C={...r,...v};i(gi(C)),e.onDraft?.(C),v.color&&w("color",v.color),v.icon&&w("icon",v.icon)},k=async()=>{if(!e.readonly){a(!0);try{await e.onSave(t.filter(v=>v.key.trim()),r)}finally{a(!1)}}};return(()=>{var v=aA(),C=v.firstChild,y=C.firstChild,b=y.nextSibling,_=C.nextSibling,$=_.firstChild,D=$.firstChild,L=D.firstChild,V=L.firstChild,K=V.nextSibling,I=K.firstChild,U=I.nextSibling,Y=L.nextSibling,S=Y.firstChild,M=S.nextSibling,A=M.firstChild,F=Y.nextSibling,N=F.firstChild,X=N.nextSibling,B=$.nextSibling;return l(y,()=>e.name),l(b,s(E,{get when(){return e.readonly},get children(){return tA()}}),null),l(b,s(E,{get when(){return Te(()=>!!e.defined)()&&!e.readonly},get children(){return s(E,{get when(){return d()},get fallback(){return(()=>{var O=lA();return O.$$click=()=>c(!0),l(O,s(Ue,{name:"trash-2",size:"small"})),O})()},get children(){return[nA(),(()=>{var O=rA();return O.$$click=()=>{a(!0),e.onDelete()},G(()=>O.disabled=o()),O})(),(()=>{var O=iA();return O.$$click=()=>c(!1),O})()]}})}}),null),I.$$input=O=>h({color:O.currentTarget.value}),l(U,()=>r.color||"#000000"),M.$$click=()=>g(!0),l(M,s(Gn,{get type(){return e.name},get color(){return r.color},get icon(){return r.icon},size:16}),A),l(A,()=>r.icon),l(M,s(Ue,{name:"chevron-down",size:"small"}),null),X.$$input=O=>h({description:O.currentTarget.value}),l($,s(Oe,{get each(){return f()},children:O=>(()=>{var z=dA(),q=z.firstChild,Q=q.nextSibling,j=Q.nextSibling,H=j.nextSibling,J=H.nextSibling,le=J.firstChild;return l(q,s(Ue,{get name(){return bA[O.row.type]},size:"small"})),Q.$$input=de=>n(O.idx,"key",de.currentTarget.value),j.$$input=de=>n(O.idx,"label",de.currentTarget.value),H.addEventListener("change",de=>n(O.idx,"type",de.currentTarget.value)),l(H,s(Oe,{each:vA,children:de=>(()=>{var Re=uA();return Re.value=de,l(Re,de),Re})()})),le.addEventListener("change",de=>n(O.idx,"required",de.currentTarget.checked)),l(z,s(E,{get when(){return e.readonly},get fallback(){return(()=>{var de=fA();return de.$$click=()=>p(O.idx),l(de,s(Ue,{name:"x",size:"small"})),de})()},get children(){var de=cA();return l(de,s(Ue,{name:"lock",size:"small"})),de}}),null),G(de=>{var Re=!!e.readonly,Ve=O.row.type,Z=e.readonly,ne=e.readonly,re=e.readonly,ie=e.readonly;return Re!==de.e&&z.classList.toggle("db-schema-prop-row--readonly",de.e=Re),Ve!==de.t&&ue(q,"title",de.t=Ve),Z!==de.a&&(Q.disabled=de.a=Z),ne!==de.o&&(j.disabled=de.o=ne),re!==de.i&&(H.disabled=de.i=re),ie!==de.n&&(le.disabled=de.n=ie),de},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),G(()=>Q.value=O.row.key),G(()=>j.value=O.row.label),G(()=>H.value=O.row.type),G(()=>le.checked=O.row.required??!1),z})()}),null),l($,s(Oe,{get each(){return f()},children:O=>s(E,{get when(){return O.row.type==="select"||O.row.type==="multiselect"},get children(){var z=gA(),q=z.firstChild,Q=q.firstChild,j=q.nextSibling;return l(q,()=>O.row.key||"?",Q),j.$$input=H=>n(O.idx,"options",H.currentTarget.value.split(",").map(J=>J.trim()).filter(Boolean)),G(()=>j.disabled=e.readonly),G(()=>j.value=(O.row.options??[]).join(", ")),z}})}),null),l($,s(Oe,{get each(){return f()},children:O=>s(E,{get when(){return O.row.type==="formula"},get children(){var z=mA(),q=z.firstChild,Q=q.firstChild,j=q.nextSibling;return l(q,()=>O.row.key||"?",Q),j.$$input=H=>n(O.idx,"formula",H.currentTarget.value),G(()=>j.disabled=e.readonly),G(()=>j.value=O.row.formula??""),z}})}),null),l(B,s(E,{get when(){return!e.readonly},get children(){return[(()=>{var O=sA(),z=O.firstChild;return O.$$click=m,l(O,s(Ue,{name:"plus",size:"small"}),z),O})(),(()=>{var O=oA();return O.$$click=()=>void k(),l(O,()=>o()?"Saving…":"Save"),G(()=>O.disabled=o()),O})()]}})),l(v,s(_A,{get open(){return u()},get value(){return r.icon},get color(){return r.color},get type(){return e.name},onClose:()=>g(!1),onSelect:O=>{h({icon:O}),g(!1)}}),null),G(O=>{var z=e.readonly,q=e.readonly,Q=e.readonly;return z!==O.e&&(I.disabled=O.e=z),q!==O.t&&(M.disabled=O.t=q),Q!==O.a&&(X.disabled=O.a=Q),O},{e:void 0,t:void 0,a:void 0}),G(()=>I.value=r.color||"#000000"),G(()=>X.value=r.description??""),v})()}function _A(e){const[t,n]=ke(""),r=T(()=>{const i=t().trim().toLowerCase();return i?Ko.filter(o=>o.includes(i)):Ko});return s(E,{get when(){return e.open},get children(){var i=hA(),o=i.firstChild,a=o.firstChild,d=a.firstChild,c=d.nextSibling,u=a.nextSibling,g=u.firstChild,f=u.nextSibling;return Rt(i,"click",e.onClose,!0),o.$$click=m=>m.stopPropagation(),Rt(c,"click",e.onClose,!0),l(c,s(Ue,{name:"x",size:"small"})),l(u,s(Ue,{name:"search",size:"small",class:"text-icon-weak"}),g),g.$$input=m=>n(m.currentTarget.value),l(f,s(Oe,{get each(){return r()},children:m=>(()=>{var p=pA(),w=p.firstChild;return p.$$click=()=>e.onSelect(m),ue(p,"title",m),l(p,s(Gn,{get type(){return e.type},icon:m,get color(){return e.color},size:18}),w),l(w,m),G(()=>p.classList.toggle("db-icon-option--active",e.value===m)),p})()})),G(()=>g.value=t()),i}})}Kt(["click","input"]);function Ca(e){const t=T(()=>{const r=new Map;for(const i of e.facts){const o=r.get(i.e);o?o.push(i):r.set(i.e,[i])}return r}),n=T(()=>{const r=new Map;for(const i of e.entities){if(!Fc(i))continue;const o=Cr(i.type),a=r.get(o);a?a.push(i):r.set(o,[i])}return r});return{facts:t,entities:r=>n().get(vi(r))??[]}}var CA=x('<div class="flex flex-col items-center justify-center gap-4 py-8"><div class=relative><div class="size-8 rounded-full border-2 border-surface-raised-base/20 border-t-border-base border-t-solid animate-spin"></div><div class="absolute inset-0 flex items-center justify-center"><div class="size-3 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 animate-pulse"></div></div></div><div class="flex flex-col items-center gap-1"><span class="text-12-medium text-text-base"></span><div class="flex gap-1"><div class="w-1 h-1 rounded-full bg-text-weaker/40 animate-pulse"style=animation-delay:0ms></div><div class="w-1 h-1 rounded-full bg-text-weaker/40 animate-pulse"style=animation-delay:150ms></div><div class="w-1 h-1 rounded-full bg-text-weaker/40 animate-pulse"style=animation-delay:300ms>'),SA=x('<div class="shrink-0 px-3 h-10 border-b border-border-weaker-base flex items-center"><span class="text-12-medium text-text-strong">Collections</span><span class="ml-auto text-10-regular tabular-nums text-text-weaker">'),TA=x('<button class="text-text-weaker hover:text-text-base"title=Clear>'),AA=x('<div class="shrink-0 px-2 py-2 border-b border-border-weaker-base"><div class="flex items-center gap-1.5 px-2 py-1 rounded-md bg-surface-raised-base/0"><input type=text class="flex-1 min-w-0 bg-transparent border-0 outline-0 text-12-regular text-text-base placeholder:text-text-weaker"placeholder="Filter collections…">'),DA=x('<div class="flex-1 min-h-0 overflow-y-auto px-2 py-2 flex flex-col gap-0.5">'),MA=x('<input type=text autofocus class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1 text-12-regular text-text-base outline-0 focus:border-border-base"placeholder=collection_name>'),EA=x('<div class="shrink-0 border-t border-border-weaker-base p-2">'),IA=x('<aside class="flex flex-col bg-background-strong border-r border-border-weaker-base">'),LA=x('<div class="flex-1 flex flex-col"><div class="shrink-0 px-3 h-10 border-b border-border-weaker-base flex items-center"><span class="text-12-medium text-text-strong">Collections</span><span class="ml-auto size-3 rounded-full bg-blue-500/60 animate-pulse"></span></div><div class="flex-1 min-h-0 flex flex-col">'),PA=x('<div class="px-2.5 py-3 text-11-regular text-text-weaker italic text-center">'),FA=x('<button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-12-medium text-text-weak hover:text-text-base hover:bg-surface-raised-base/40 transition-colors"><span>New collection'),RA=x('<div class="group relative"><button class="w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md text-left text-12-medium transition-all duration-700"><span class="truncate capitalize flex-1"></span><span class="px-1.5 py-[1px] rounded-full text-10-regular tabular-nums transition-opacity group-hover:opacity-0"></span></button><button class="pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-text-weaker hover:text-red-400 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus:pointer-events-auto focus:opacity-100"title="Delete collection">');const Af=new Set([...TS,"checkpoint","criterion","designcomponent","designtoken","field"]);function zA(e){return(()=>{var t=CA(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,o=i.nextSibling,a=o.firstChild,d=a.nextSibling;return d.nextSibling,l(i,()=>e.label),t})()}function Df(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase()).trim()}function Vc(e){const t=Dr(),n=e??Ca(t);return T(()=>{const r={},i={};for(const d of t.entities){const c=Cr(d.type);r[c]=(r[c]??0)+1,i[c]||(i[c]=d.type)}const o=(d,c)=>n.facts().get(d)?.find(u=>u.a===c)?.v,a=new Map;for(const d of t.entities){if(d.type!=="TypeSchema")continue;const c=d.id,u=c.replace(/^schema:/,""),g=vi(u);if(Af.has(g))continue;const f=o(c,"label"),m=typeof f=="string"&&f?f:Df(u),p=o(c,"color"),w=o(c,"icon"),h=o(c,"description"),k={label:m,color:typeof p=="string"?p:Ai(g),icon:typeof w=="string"?w:Di(g),description:typeof h=="string"?h:void 0};a.set(g,{key:g,schemaId:c,label:m,canonicalType:i[g]??u,theme:k,count:r[g]??0,inferred:!1})}for(const[d,c]of Object.entries(r)){if(Af.has(d)||a.has(d))continue;const u=i[d],g=Df(u);a.set(d,{key:d,schemaId:`schema:${d}`,label:g,canonicalType:u,theme:{label:g,color:Ai(d),icon:Di(d)},count:c,inferred:!0})}return Array.from(a.values()).sort((d,c)=>d.label.localeCompare(c.label))})}function OA(e){const t=e.collections??Vc(e.cache),n=Dr(),[r,i]=ke(""),o=T(()=>{const m=r().trim().toLowerCase();return m?t().filter(p=>p.key.toLowerCase().includes(m)||p.label.toLowerCase().includes(m)):t()}),[a,d]=ke(!1),[c,u]=ke(""),g=async()=>{const m=c().trim();if(!m){d(!1);return}await e.onCreate(m),u(""),d(!1)},f=()=>{u(""),d(!1)};return(()=>{var m=IA();return l(m,s(E,{get when(){return n.ready},get fallback(){return(()=>{var p=LA(),w=p.firstChild,h=w.nextSibling;return l(h,s(zA,{label:"Loading store…"})),p})()},get children(){return[(()=>{var p=SA(),w=p.firstChild,h=w.nextSibling;return l(h,()=>o().length),p})(),(()=>{var p=AA(),w=p.firstChild,h=w.firstChild;return l(w,s(Ue,{name:"search",size:"small",class:"text-icon-weak shrink-0"}),h),h.$$input=k=>i(k.currentTarget.value),l(w,s(E,{get when(){return r()},get children(){var k=TA();return k.$$click=()=>i(""),l(k,s(Ue,{name:"x",size:"small"})),k}}),null),G(()=>h.value=r()),p})(),(()=>{var p=DA();return l(p,s(E,{get when(){return o().length>0},get fallback(){return(()=>{var w=PA();return l(w,s(E,{get when(){return r()},fallback:"No collections yet",children:"No matches"})),w})()},get children(){return s(Oe,{get each(){return o()},children:w=>s(NA,{collection:w,get active(){return e.selected===w.key},get fresh(){return n.fresh.includes(w.schemaId)},onClick:()=>e.onSelect(e.selected===w.key?null:w.key),onDelete:()=>void e.onDelete(w.key)})})}})),p})(),(()=>{var p=EA();return l(p,s(E,{get when(){return a()},get fallback(){return(()=>{var w=FA(),h=w.firstChild;return w.$$click=()=>d(!0),l(w,s(Ue,{name:"plus",size:"small",class:"text-icon-weak"}),h),w})()},get children(){var w=MA();return w.addEventListener("blur",f),w.$$keydown=h=>{h.key==="Enter"&&g(),h.key==="Escape"&&f()},w.$$input=h=>u(h.currentTarget.value),G(()=>w.value=c()),w}})),p})()]}})),G(p=>{var w={"w-full max-h-48 border-r-0 border-b":e.compact},h=e.compact?"100%":`${e.width}px`;return p.e=Tt(m,w,p.e),h!==p.t&&Je(m,"width",p.t=h),p},{e:void 0,t:void 0}),m})()}function NA(e){const t=()=>e.collection.theme.color;return(()=>{var n=RA(),r=n.firstChild,i=r.firstChild,o=i.nextSibling,a=r.nextSibling;return Rt(r,"click",e.onClick,!0),l(r,s(Gn,{get type(){return e.collection.key},size:14,get color(){return Te(()=>!!e.active)()?t():"var(--text-weaker)"},get icon(){return e.collection.theme.icon}}),i),l(i,()=>e.collection.label),l(r,s(E,{get when(){return e.collection.inferred},get children(){return s(s0,{class:"size-3 shrink-0 text-text-weaker",classList:{"group-hover:opacity-0 transition-opacity":!0}})}}),o),l(o,()=>e.collection.count),a.$$click=d=>{d.stopPropagation(),e.onDelete()},l(a,s(Mi,{class:"size-3.5"})),G(d=>{var c={"text-text-strong bg-surface-raised-base":e.active,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/30":!e.active&&!e.fresh,"ring-1 ring-emerald-500/40 bg-emerald-500/5":e.fresh},u=e.active,g=e.active?{"background-color":`color-mix(in oklab, ${t()} 18%, transparent)`,color:`color-mix(in oklab, ${t()} 90%, var(--text-base))`}:{"background-color":"var(--surface-raised-base)",color:"var(--text-weaker)"};return d.e=Tt(r,c,d.e),u!==d.t&&ue(r,"aria-pressed",d.t=u),d.a=Pn(o,g,d.a),d},{e:void 0,t:void 0,a:void 0}),n})()}Kt(["input","click","keydown"]);const BA=new Set(["+","-","*","/","(",")"]);function Mf(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string"||e.trim()==="")return;const t=Number(e);return Number.isFinite(t)?t:void 0}function qA(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(/\s/.test(r)){n++;continue}if(BA.has(r)){t.push(r),n++;continue}if(/\d|\./.test(r)){let i=n+1;for(;i<e.length&&/\d|\./.test(e[i]);)i++;const o=Number(e.slice(n,i));if(!Number.isFinite(o))return;t.push(o),n=i;continue}return}return t}function jA(e){let t=0;const n=()=>e[t],r=()=>e[t++],i=()=>{const c=r();if(typeof c=="number")return c;if(c==="+")return i();if(c==="-"){const u=i();return u===void 0?void 0:-u}if(c==="("){const u=a();return r()!==")"?void 0:u}},o=()=>{let c=i();for(;n()==="*"||n()==="/";){const u=r(),g=i();if(c===void 0||g===void 0)return;c=u==="*"?c*g:c/g}return c},a=()=>{let c=o();for(;n()==="+"||n()==="-";){const u=r(),g=o();if(c===void 0||g===void 0)return;c=u==="+"?c+g:c-g}return c},d=a();if(!(t!==e.length||d===void 0||!Number.isFinite(d)))return d}function Js(e,t){const n=e.replace(/\{([^{}]+)\}/g,(o,a)=>{const d=Mf(t[a.trim()]);return d===void 0?o:String(d)});if(n.includes("{")||n.includes("}"))return;const r=n.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\b/g,(o,a)=>{const d=Mf(t[a]);return d===void 0?o:String(d)});if(r.includes("{")||r.includes("}"))return;const i=qA(r);return i?jA(i):void 0}const VA=["title","name","label","description"],HA=/^[a-z][a-z0-9_]*:[a-z0-9-]+/i;function UA(e){if(typeof e!="string")return!1;const t=e.split(",")[0]?.trim();return!!t&&HA.test(t)}function WA(e){return typeof e!="string"||!e.trim()?[]:e.split(",").map(t=>t.trim()).filter(Boolean)}function Ef(e){return e.join(", ")}function oa(e,t){const n=t.get(e)??[];for(const r of VA){const i=n.find(o=>o.a===r);if(i&&typeof i.v=="string"&&i.v.trim())return i.v}return e.includes(":")?e.split(":").slice(1).join(":"):e}function KA(e,t,n,r){const i=new Map;for(const o of e){const a=t.get(o);if(a?.type==="reference"){i.set(o,{key:o,label:a.label??o,type:"reference",target:a.target});continue}if(a?.type&&a.type!=="text")continue;r.some(c=>UA(n(c.id,o)))&&i.set(o,{key:o,label:a?.label??o,type:"reference",target:a?.target})}return i}function GA(e,t,n){return n.some(r=>{const i=t(r.id,e);return typeof i=="string"&&i.includes(",")})}var YA=x('<button role=switch class="relative inline-flex h-4 w-7 shrink-0 rounded-full transition-colors"><span class="absolute top-0.5 h-3 w-3 rounded-full bg-white shadow-sm transition-transform">'),XA=x('<div class="truncate pr-3 text-11-regular text-text-weaker">'),ZA=x('<input class="mr-3 min-w-0 w-full rounded border border-transparent bg-transparent px-1.5 py-1 text-11-regular text-text-base outline-0 transition-colors placeholder:text-text-weaker hover:border-border-weaker-base hover:bg-surface-raised-base/30 focus:border-border-base focus:bg-surface-raised-base">'),If=x("<span class=truncate>"),QA=x('<div class="flex min-w-0 items-center gap-1 truncate pr-3 text-11-regular italic text-text-weak">'),JA=x('<span class="truncate text-red-400">!'),e7=x("<span class=text-text-weaker>—"),Lf=x('<span class="flex items-center justify-between gap-3"><span class=text-text-weaker>—'),t7=x('<div class="flex min-w-0 flex-wrap items-center gap-1 pr-1">'),n7=x('<button type=button class="shrink-0 rounded p-0.5 opacity-60 hover:opacity-100"title=Remove>'),r7=x('<span class="inline-flex max-w-[9rem] items-center gap-1 rounded px-1.5 py-[1px] text-9-regular tracking-wide"><span class=truncate>'),i7=x('<span class="flex items-center justify-between gap-3 min-w-0"><span class="inline-flex max-w-full items-center gap-1 rounded px-1.5 py-[1px] text-9-regular tracking-wide"><span class=truncate>'),s7=x('<div class="flex min-w-0 items-center pr-1">'),o7=x('<span class="flex items-center justify-between gap-3"><span class="rounded px-1.5 py-[1px] text-9-regular uppercase tracking-wide">'),a7=x('<button class="text-text-weaker hover:text-text-base"title=Clear>'),l7=x('<div class="px-2 text-10-regular text-red-400">'),c7=x("<span>Add property"),Pf=x('<textarea rows=2 class="rounded border border-border-base bg-surface-raised-base px-2 py-1 font-mono text-11-regular text-text-base outline-0"placeholder="points * 2">'),d7=x('<div class="text-10-regular text-red-400">'),u7=x('<div class="flex flex-col gap-2"><div class="text-10-medium uppercase tracking-wide text-text-weaker">New property</div><input type=text autofocus class="rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"placeholder="name (e.g. category)"><select class="rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"><option value=text>Text</option><option value=longtext>Long text</option><option value=number>Number</option><option value=date>Date</option><option value=boolean>Boolean</option><option value=formula>Formula</option></select><button type=button class="self-end rounded-md bg-text-strong px-2.5 py-1 text-11-medium text-background-base disabled:opacity-50">Add'),f7=x('<div class="shrink-0 border-b border-border-weaker-base bg-surface-raised-base/20 px-3 py-1.5"><div class="flex flex-wrap items-center gap-1.5"><button class="ml-1 text-10-regular text-text-weaker hover:text-text-base">Clear all'),g7=x("<div class=relative>"),m7=x('<div class="sticky bottom-0 z-10 border-t border-border-weaker-base bg-background-base/95 backdrop-blur"><button class="flex h-10 w-full items-center px-5 text-left text-11-medium text-text-weaker transition-colors hover:bg-surface-raised-base/0 hover:text-text-base"><span class="sticky left-5 flex items-center gap-2"><span>New entry'),h7=x('<div class="shrink-0 border-t border-border-weaker-base px-3 py-2"><div class="flex flex-wrap items-center gap-1.5 rounded-md border border-border-weaker-base bg-surface-raised-base/30 px-2 py-1.5"><span class="mr-1 text-11-medium text-text-base"> selected</span><button class="flex items-center gap-1 rounded px-2 py-1 text-11-medium text-emerald-400 hover:bg-emerald-500/10"><span>Publish</span></button><button class="flex items-center gap-1 rounded px-2 py-1 text-11-medium text-text-weak hover:bg-surface-raised-base/60 hover:text-text-base"><span>Draft</span></button><button class="flex items-center gap-1 rounded px-2 py-1 text-11-medium text-zinc-300 hover:bg-zinc-500/10"><span>Archive</span></button><button class="flex items-center gap-1 rounded px-2 py-1 text-11-medium text-red-400 hover:bg-red-500/10"><span>Delete</span></button><button class="ml-auto rounded px-2 py-1 text-11-regular text-text-weaker hover:text-text-base">Clear'),p7=x('<div class="flex h-full min-h-0 flex-col overflow-hidden"><div class="shrink-0 border-b border-border-weaker-base px-3 py-1.5"><div class="flex flex-col gap-2"><div class="flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between"><div class="flex min-w-0 flex-1 flex-col gap-1"><div class="flex min-w-0 items-center gap-1.5 rounded-md bg-surface-raised-base/0 px-2 py-1"><input type=text><button role=switch class="flex items-center gap-1 rounded px-1.5 py-0.5 text-9-medium uppercase tracking-wide text-text-weaker transition-colors hover:text-text-base"><span>EQL</span><span class="relative inline-flex h-4 w-7 rounded-full transition-colors"><span class="absolute top-0.5 h-3 w-3 rounded-full shadow-sm transition-transform"></span></span></button></div></div><div class="flex shrink-0 items-center gap-2"></div></div></div></div><div class="min-h-0 flex-1 overflow-auto"><div class=min-w-full><div class="sticky top-0 z-10 grid h-9 items-center border-b border-border-weaker-base bg-background-base/95 px-2 text-10-medium uppercase tracking-wide text-text-weaker backdrop-blur"><div class="flex items-center justify-center sticky left-0 z-20 bg-background-base/95 backdrop-blur"><input type=checkbox class="size-3.5 accent-text-strong"title="Select all rows"></div><div class="flex min-w-0 items-center gap-1 pl-2 pr-7"><span>ID</span></div><div class="flex items-center justify-center text-text-weaker"title=Row>#</div><button class="flex items-center gap-1 hover:text-text-base transition-colors">Entry</button><button class="flex items-center gap-1 hover:text-text-base transition-colors">Status</button><div class="sticky right-0 z-20 flex h-full items-center justify-center border-l border-border-weaker-base bg-background-base/95 shadow-[-12px_0_16px_-18px_rgba(0,0,0,0.8)]"title=Open>'),v7=x('<span class="flex items-center gap-1 rounded-md bg-blue-500/10 px-2 py-0.5 text-11-regular text-blue-300"><span class=text-text-weaker>:</span><span class=font-medium></span><button class=hover:text-text-base title="Remove filter">'),b7=x('<textarea rows=3 class="rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"placeholder="One option per line">'),x7=x('<div class="flex flex-col gap-2"><div class="text-10-medium uppercase tracking-wide text-text-weaker">Edit property</div><input type=text class="rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"placeholder="Display label"><select class="rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"><option value=text>Text</option><option value=longtext>Long text</option><option value=number>Number</option><option value=date>Date</option><option value=boolean>Boolean</option><option value=select>Select</option><option value=reference>Reference</option><option value=formula>Formula</option></select><div class="flex items-center justify-between gap-2 pt-1"><button type=button class="flex items-center gap-1 rounded px-2 py-1 text-11-medium text-red-400 hover:bg-red-500/10"title="Delete column"><span>Delete</span></button><button type=button class="rounded-md bg-text-strong px-2.5 py-1 text-11-medium text-background-base"title="Save (⌘/Ctrl+Enter)">Save'),y7=x('<div class="flex min-w-0 items-center gap-1"><button class="flex min-w-0 items-center gap-1 truncate hover:text-text-base transition-colors"><span class=truncate>'),w7=x('<div class="flex flex-col gap-1.5"><div class="text-10-medium uppercase tracking-wide text-text-weaker">Range</div><div class="flex items-center gap-1"><input type=number step=any class="w-full rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"placeholder=min><span class=text-text-weaker>–</span><input type=number step=any class="w-full rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"placeholder=max></div><button class="self-end text-10-regular text-text-weaker hover:text-text-base">Clear'),$7=x('<div class="flex flex-col gap-1.5"><div class="text-10-medium uppercase tracking-wide text-text-weaker">Contains</div><input type=text class="rounded border border-border-base bg-surface-raised-base px-2 py-1 text-11-regular text-text-base outline-0"placeholder=search…><button class="self-end text-10-regular text-text-weaker hover:text-text-base">Clear'),k7=x('<div class="flex flex-col gap-1"><div class="px-1 pb-1 text-10-medium uppercase tracking-wide text-text-weaker">Match any</div><button class="mt-1 self-end text-10-regular text-text-weaker hover:text-text-base">Clear'),_7=x('<label class="flex cursor-pointer items-center gap-2 rounded px-1 py-0.5 text-11-regular text-text-base hover:bg-surface-raised-base/40"><input type=checkbox class="size-3.5 accent-text-strong"><span>'),C7=x('<button class="rounded-md bg-surface-raised-base px-3 py-1.5 text-12-medium text-text-base hover:bg-surface-raised-base/80">New entry'),S7=x('<span class="shrink-0 px-1.5 py-0.5 rounded text-9-medium bg-emerald-500/20 text-emerald-400 uppercase tracking-wider animate-fade-out">New'),T7=x('<span class="flex items-center gap-2"><span>Duplicate'),A7=x('<span class="flex items-center gap-2 text-red-400"><span>Delete'),D7=x('<div class="group absolute left-0 right-0 px-2 border-b border-border-weaker-base/20"style=height:42px><div class="grid h-full w-full items-center rounded-md border border-transparent px-2 text-left transition-all duration-700"><div class="flex items-center justify-center sticky left-0 z-20 bg-background-base/95 backdrop-blur"><input type=checkbox class="size-3.5 accent-text-strong"></div><div class="flex min-w-0 items-center gap-1 pl-2 pr-1"><span class="min-w-0 flex-1 truncate font-mono text-10-regular text-text-weaker"></span><button class="flex size-5 shrink-0 items-center justify-center rounded text-icon-weak opacity-0 transition-opacity hover:bg-surface-raised-base/70 hover:text-text-base group-hover:opacity-100 focus:opacity-100"title="Copy ID"></button></div><div class="flex items-center justify-center font-mono text-10-regular text-text-weaker"></div><div class="flex min-w-0 items-center gap-2 pr-3"><div class="min-w-0 flex-1 flex items-center gap-2"></div></div><div></div><div class="sticky right-0 z-[2] flex h-full items-center justify-center gap-0.5 border-l border-border-weaker-base bg-background-base/95 px-1 shadow-[-12px_0_16px_-18px_rgba(0,0,0,0.8)]"><button class="flex size-6 items-center justify-center rounded-md text-icon-weak transition-colors hover:bg-surface-raised-base/70 hover:text-text-base">'),M7=x('<span class="flex items-center justify-between gap-3"><span>'),E7=x("<div>");const Gi=["title","name","label","description"],yi=42,Ff=10,hr=e=>({bg:`rgba(${e}, 0.24)`,text:`rgb(${e})`,ring:`rgba(${e}, 0.34)`}),Ds=e=>({"background-color":e.bg,color:e.text,"box-shadow":`inset 0 0 0 1px ${e.ring}`}),nl=hr("167, 139, 250"),Rf=[hr("96, 165, 250"),hr("167, 139, 250"),hr("244, 114, 182"),hr("34, 211, 238"),hr("251, 146, 60"),hr("232, 121, 249")];function I7(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function zf(e){const t=e.toLowerCase();return/^(easy|low|beginner|simple)$/.test(t)?hr("52, 211, 153"):/^(medium|med|mid|moderate)$/.test(t)?hr("251, 191, 36"):/^(hard|expert|advanced|high)$/.test(t)?hr("248, 113, 113"):/^(draft)$/.test(t)?hr("251, 191, 36"):/^(active|live|published|on)$/.test(t)?hr("52, 211, 153"):/^(archived|inactive|off)$/.test(t)?hr("212, 212, 216"):Rf[I7(t)%Rf.length]}function L7(e,t){const n={};for(const r of Object.keys(t)){const i=t[r];(i===void 0||typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&(n[r]=i)}return{ok:!0,value:Js(e,n)}}function P7(e){const t=e.trim();if(!t)return{ok:!0,clauses:[]};const r=t.replace(/^\s*find\s+\?[a-zA-Z_]+\s+where\s+/i,"").split(/\s+and\s+/i).map(o=>o.trim()).filter(Boolean),i=[];for(const o of r){const a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*(<=|>=|!=|=|<|>|contains|~)\s*(.+)$/i);if(!a)return{ok:!1,error:`Invalid clause: ${o}`};const d=a[2].toLowerCase(),c=a[3].trim();if(/^[<>=!~]/.test(c))return{ok:!1,error:`Invalid value: ${c}`};let u;c==="true"||c==="false"?u=c==="true":c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'")?u=c.slice(1,-1):/^-?\d+(\.\d+)?$/.test(c)?u=Number(c):u=c,i.push({attr:a[1],op:d,val:u})}return{ok:!0,clauses:i}}const Of=/^\d{4}-\d{2}-\d{2}$/,F7=60,No=new Set(["slug","id","lastEdited","createdAt","updatedAt"]),R7=[{id:"draft",label:"Draft"},{id:"published",label:"Live"},{id:"archived",label:"Archived"}],Nf={draft:0,published:1,archived:2};function Ms(e){return e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,t=>t.toUpperCase())}function Bo(e,t){return e.replace(`${t}:`,"")}function Vs(e){return e==null||e===""?"—":typeof e=="boolean"?e?"Yes":"No":typeof e=="number"?e.toLocaleString():String(e)}function z7(e,t){if(t==="number"){const n=Number(e);return e.trim()===""||!Number.isFinite(n)?void 0:n}return e.trim()===""?void 0:e}function Bf(e,t){const n=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):Number.NaN,r=typeof t=="number"?t:typeof t=="string"&&t.trim()?Number(t):Number.NaN;return Number.isFinite(n)&&Number.isFinite(r)?n-r:Vs(e).localeCompare(Vs(t),void 0,{numeric:!0,sensitivity:"base"})}function O7(e){const t=Dr(),n=e.cache??Ca(t),[r,i]=St({query:"",filter:"all",top:0,height:0,picked:{},last:"",edit:null,draft:"",pending:{},sort:{key:null,dir:"asc"},cellChanges:{},filters:{},extraCols:[],colTypeHints:{},colFormulas:{},addPropDraft:{name:"",type:"text",expr:""},editColDraft:{label:"",type:"text",options:"",expr:""},queryMode:"text",eqlsActive:null,eqlsError:""});let o,a=0;const d=new Map,c=W=>n.facts().get(W)??[],u=(W,oe)=>c(W).find(me=>me.a===oe),g=(W,oe)=>`${W}\0${oe}`,f=(W,oe)=>{const me=r.pending[g(W,oe)];return me?me.value:u(W,oe)?.v},m=W=>{const oe=f(W,"cms_status");return oe==="published"?"published":oe==="archived"?"archived":"draft"},p=T(()=>{const oe=(n.facts().get(e.collection.schemaId)??[]).find(me=>me.a==="props");if(!oe||typeof oe.v!="string")return[];try{const me=JSON.parse(oe.v);return Array.isArray(me)?me.filter(he=>!!he&&typeof he.key=="string"):[]}catch{return[]}}),w=T(()=>{const W=p();if(W.length===0)return new Set(Gi);const oe=new Set(W.map(Ie=>Ie.key)),me=new Set(Gi);let he=null;for(const Ie of Gi)oe.has(Ie)&&(he===null?he=Ie:me.delete(Ie));return me}),h=W=>{const oe=w();for(const me of Gi){if(!oe.has(me))continue;const he=f(W,me);if(typeof he=="string"&&he.trim())return{value:he,empty:!1,key:me}}return{value:Bo(W,e.collection.key),empty:!0,key:"name"}},k=(W,oe)=>Vs(f(W.id,oe)),v=T(()=>n.entities(e.collection.key)),C=T(()=>{const W=p(),oe=w();if(W.length>0){const Ae=W.map(Ke=>Ke.key).filter(Ke=>!oe.has(Ke)&&Ke!=="type"&&Ke!=="cms_status"&&Ke!=="id"),De=r.extraCols.filter(Ke=>!Ae.includes(Ke));return[...Ae,...De]}const me=new Map;for(const Ae of v())for(const De of c(Ae.id))De.a==="type"||De.a==="cms_status"||oe.has(De.a)||me.set(De.a,(me.get(De.a)??0)+1);const he=Array.from(me.entries()).sort((Ae,De)=>De[1]-Ae[1]||Ae[0].localeCompare(De[0])).slice(0,e.compact?3:6).map(([Ae])=>Ae),Ie=r.extraCols.filter(Ae=>!he.includes(Ae));return[...he,...Ie]}),y=T(()=>new Map(p().map(W=>[W.key,W]))),b=T(()=>KA(C(),y(),f,v())),_=W=>W?.formula??W?.expr,$=T(()=>p().map(W=>{const oe=_(W);return W.type==="formula"&&oe?{key:W.key,expr:oe}:void 0}).filter(W=>!!W)),D=W=>{if(typeof W=="string"||typeof W=="number"||typeof W=="boolean")return W},L=W=>{const oe={};for(const Ie of c(W))oe[Ie.a]=D(Ie.v);const me=`${W}\0`;for(const Ie of Object.keys(r.pending))Ie.startsWith(me)&&(oe[Ie.slice(me.length)]=r.pending[Ie]?.value);const he=$();for(let Ie=0;Ie<he.length;Ie++)for(const Ae of he)oe[Ae.key]=Js(Ae.expr,oe);return oe},V=W=>{if(W){if(W==="number")return"number";if(W==="date")return"date";if(W==="rich_text"||W==="longtext")return"longtext";if(W==="text"||W==="email"||W==="url"||W==="color")return"text"}},K=(W,oe)=>Js(oe,L(W)),I=T(()=>{const W=new Map,oe=y();for(const me of C()){if(b().has(me))continue;const he=oe.get(me);if(he&&(he.type==="select"||he.type==="multiselect")&&Array.isArray(he.options)&&he.options.length>0){W.set(me,[...he.options]);continue}if(he&&he.type&&he.type!=="text")continue;const Ie=[];for(const Ke of v()){const yt=f(Ke.id,me);typeof yt=="string"&&yt.trim()&&Ie.push(yt.trim())}const Ae=[...new Set(Ie)].sort();!Ie.every(Ke=>Number.isFinite(Number(Ke)))&&Ae.length>=2&&Ae.length<=30&&Ie.length/Ae.length>=1.5&&W.set(me,Ae)}return W}),U=T(()=>{const W=new Map,oe=I(),me=y();for(const he of C()){if(oe.has(he))continue;const Ie=r.colFormulas[he];if(Ie){for(const Yt of v()){const an=K(Yt.id,Ie);if(!(an==null||an==="")){if(typeof an=="number"){W.set(he,"number");break}if(typeof an=="string"&&Of.test(an)){W.set(he,"date");break}W.set(he,"text");break}}W.has(he)||W.set(he,"text");continue}const Ae=V(me.get(he)?.type),De=[];let Ke=0;for(const Yt of v()){const an=f(Yt.id,he);if(!(an==null||an==="")){if(typeof an=="boolean"){Ke++;continue}De.push(an)}}const yt=r.colTypeHints[he];if(Ke>0&&De.length===0){Ae?W.set(he,Ae):yt&&yt!=="boolean"&&W.set(he,yt);continue}if(!De.length){Ae?W.set(he,Ae):W.set(he,yt&&yt!=="boolean"?yt:"text");continue}if(Ae){W.set(he,Ae);continue}if(De.every(Yt=>typeof Yt=="number"||typeof Yt=="string"&&Yt.trim()!==""&&Number.isFinite(Number(Yt)))){W.set(he,"number");continue}if(De.every(Yt=>typeof Yt=="string"&&Of.test(Yt))){W.set(he,"date");continue}const kn=De.some(Yt=>typeof Yt=="string"&&Yt.length>F7);W.set(he,kn?"longtext":"text")}return W}),Y=W=>U().get(W)??"text",S=W=>{const oe=y().get(W)?.label;return oe&&oe.trim()?oe:Ms(W)},M=(W,oe)=>{const me={};for(const he of Object.keys(r.filters)){const Ie=r.filters[he];he!==W&&Ie&&(me[he]=Ie)}oe&&(me[W]=oe),i("filters",gi(me))},A=()=>i("filters",gi({})),F=/^[a-zA-Z][a-zA-Z0-9_]*$/,N=T(()=>{const W=r.addPropDraft.name.trim();return W?F.test(W)?W==="type"||W==="cms_status"||W==="id"||No.has(W)||Gi.includes(W)?"Reserved name":C().includes(W)?"Already exists":"":"Letters, digits, _ only":""}),X=(W,oe)=>{const me=f(W.id,oe.attr);if(oe.op==="contains"||oe.op==="~")return String(me??"").toLowerCase().includes(String(oe.val).toLowerCase());if(oe.op==="=")return String(me??"")===String(oe.val);if(oe.op==="!=")return String(me??"")!==String(oe.val);const he=typeof me=="number"?me:typeof me=="string"&&me.trim()!==""?Number(me):Number.NaN,Ie=typeof oe.val=="number"?oe.val:typeof oe.val=="string"?Number(oe.val):Number.NaN;return!Number.isFinite(he)||!Number.isFinite(Ie)?!1:oe.op==="<"?he<Ie:oe.op==="<="?he<=Ie:oe.op===">"?he>Ie:oe.op===">="?he>=Ie:!1},B=W=>{const oe=P7(W);oe.ok?i({eqlsActive:oe.clauses,eqlsError:""}):i("eqlsError",oe.error)},O=async W=>{const oe=e.collection.schemaId,me=[],he=[];(n.facts().get(oe)??[]).some(De=>De.a==="type"&&De.v==="TypeSchema")||(he.push({e:oe,a:"type",v:"TypeSchema"}),he.push({e:oe,a:"label",v:e.collection.label}),he.push({e:oe,a:"cms",v:!0}));const Ae=(n.facts().get(oe)??[]).find(De=>De.a==="props");return Ae&&me.push(Ae),he.push({e:oe,a:"props",v:JSON.stringify(W)}),me.length>0&&await t.retract(me),t.assert(he)},z=async(W,oe)=>{const he=[...p()],Ie=he.findIndex(yt=>yt.key===W),Ae=Ie>=0?he[Ie]:{},De={key:W,label:oe.label??Ae.label??Ms(W),type:oe.type??Ae.type};oe.expr===null||(oe.expr!==void 0?De.formula=oe.expr:_(Ae)&&(De.type??Ae.type)==="formula"&&(De.formula=_(Ae))),oe.options===null||(oe.options!==void 0?De.options=oe.options:Ae.options&&(De.type==="select"||De.type==="multiselect")&&(De.options=Ae.options)),Ie>=0?he[Ie]=De:he.push(De);const Ke=await O(he);return Ke||nt({variant:"error",title:"Failed to save field"}),Ke},q=async W=>{const oe=p().filter(he=>he.key!==W),me=await O(oe);return me||nt({variant:"error",title:"Failed to delete field"}),me},Q=W=>{const oe=y().get(W),me=r.colFormulas[W],he=me?"formula":oe?.type??r.colTypeHints[W]??Y(W);i("editColDraft",{label:oe?.label??Ms(W),type:String(he),options:(oe?.options??[]).join(`
44
+ `),expr:me??_(oe)??""})},j=async W=>{const oe=r.editColDraft,me=oe.type,he=oe.label.trim()||Ms(W),Ie={type:me,label:he};Ie.expr=me==="formula"?oe.expr.trim()||"0":null,Ie.options=me==="select"||me==="multiselect"?oe.options.split(`
45
+ `).map(De=>De.trim()).filter(Boolean):null,await z(W,Ie)&&(me==="formula"?(i("colFormulas",W,Ie.expr??"0"),i("colTypeHints",De=>{const Ke={...De};return delete Ke[W],Ke})):(i("colFormulas",De=>{const Ke={...De};return delete Ke[W],Ke}),(me==="boolean"||me==="text"||me==="longtext"||me==="number"||me==="date")&&i("colTypeHints",W,me)),M(W,void 0))},H=async W=>{!window.confirm(`Delete column "${S(W)}"? Existing row data is preserved.`)||!await q(W)||(i("extraCols",me=>me.filter(he=>he!==W)),i("colFormulas",me=>{const he={...me};return delete he[W],he}),i("colTypeHints",me=>{const he={...me};return delete he[W],he}),M(W,void 0),r.sort.key===W&&i("sort",{key:null,dir:"asc"}))},J=async()=>{const W=r.addPropDraft.name.trim();if(!W||N())return;i("extraCols",me=>[...me,W]);const oe=r.addPropDraft.type;if(oe==="formula"){const me=r.addPropDraft.expr.trim()||"0";i("colFormulas",W,me),z(W,{type:"formula",expr:me})}else i("colTypeHints",W,oe),z(W,{type:oe});i("addPropDraft",{name:"",type:"text",expr:""})};$e(()=>{const W=p(),oe=[],me={},he={};for(const Ie of W){const Ae=_(Ie);Ie.type==="formula"&&Ae?(oe.push(Ie.key),he[Ie.key]=Ae):Ie.type&&Ie.type!=="formula"&&(oe.push(Ie.key),me[Ie.key]=Ie.type)}i({extraCols:oe,colTypeHints:me,colFormulas:he})});const le=W=>{for(const oe of Object.keys(r.filters)){const me=r.filters[oe];if(!me)continue;const he=r.colFormulas[oe],Ie=he?K(W.id,he):f(W.id,oe);if(me.kind==="enum"){if(me.values.length===0)continue;if(!me.values.includes(String(Ie??"")))return!1}else if(me.kind==="range"){const Ae=typeof Ie=="number"?Ie:typeof Ie=="string"&&Ie.trim()!==""?Number(Ie):Number.NaN;if(me.min!==void 0&&(!Number.isFinite(Ae)||Ae<me.min)||me.max!==void 0&&(!Number.isFinite(Ae)||Ae>me.max))return!1}else if(me.kind==="contains"){const Ae=me.text.trim().toLowerCase();if(!Ae)continue;if(typeof Ie!="string"||!Ie.toLowerCase().includes(Ae))return!1}}return!0},de=T(()=>{const W=r.filter==="all"?v():v().filter(Ae=>m(Ae.id)===r.filter);let oe;if(r.queryMode==="eqls"){const Ae=r.eqlsActive??[];oe=Ae.length===0?W:W.filter(De=>Ae.every(Ke=>X(De,Ke)))}else{const Ae=r.query.trim().toLowerCase();oe=Ae?W.filter(De=>De.id.toLowerCase().includes(Ae)||c(De.id).some(Ke=>String(Ke.v).toLowerCase().includes(Ae))):W}const me=Object.keys(r.filters).length===0?oe:oe.filter(le),{key:he,dir:Ie}=r.sort;return he?[...me].sort((Ae,De)=>{const Ke=r.colFormulas[he],yt=he==="_status"?Nf[m(Ae.id)]-Nf[m(De.id)]:he==="_entry"?h(Ae.id).value.localeCompare(h(De.id).value,void 0,{numeric:!0,sensitivity:"base"}):Ke?Bf(K(Ae.id,Ke),K(De.id,Ke)):Bf(f(Ae.id,he),f(De.id,he));return Ie==="asc"?yt:-yt}):me}),Re=T(()=>de().filter(W=>r.picked[W.id])),Ve=T(()=>Re().map(W=>W.id)),Z=T(()=>de().length>0&&de().every(W=>r.picked[W.id])),ne=T(()=>{const W=r.height||600;return{start:Math.max(0,Math.floor(r.top/yi)-Ff),end:Math.min(de().length,Math.ceil((r.top+W)/yi)+Ff)}}),re=T(()=>de().slice(ne().start,ne().end)),ie=W=>{const oe=de().slice(0,80).map(Ie=>W==="_entry"?h(Ie.id).value:W==="_id"?Bo(Ie.id,e.collection.key):k(Ie,W)),me=W==="_entry"?"Entry":W==="_id"?"ID":Ms(W),he=Math.max(me.length,...oe.map(Ie=>Ie.length));return Math.min(320,Math.max(140,he*7+48))},be=T(()=>{const W=C(),oe=W.findIndex(he=>he==="slug"),me=[];for(let he=0;he<W.length;he++)W[he]!=="slug"&&me.push(W[he]);if(oe>=0){const he=me.findIndex(Ie=>!["title","name","label","description"].includes(Ie));he>=0&&me.splice(he,0,"slug")}return me}),Fe=T(()=>be().map(W=>ie(W))),ee=T(()=>Math.max(220,ie("_entry"))),_e=T(()=>204+ee()+92+Fe().reduce((W,oe)=>W+oe,0)+72),xe=T(()=>`36px 128px 40px ${ee()}px 92px ${Fe().map(W=>`${W}px`).join(" ")} 72px`),ye=W=>i({top:W.scrollTop,height:W.clientHeight}),Le=()=>i({picked:{},last:""}),tt=W=>i({picked:W?Object.fromEntries(de().map(oe=>[oe.id,!0])):{},last:""}),ge=(W,oe,me)=>{const he=de().map(De=>De.id),Ie=he.indexOf(r.last),Ae=he.indexOf(W);if(me&&Ie>=0&&Ae>=0)for(const De of he.slice(Math.min(Ie,Ae),Math.max(Ie,Ae)+1))i("picked",De,oe);else i("picked",W,oe);i("last",W)},qe=()=>i({edit:null,draft:""}),we=W=>i("sort",oe=>({key:oe.key===W&&oe.dir==="desc"?null:W,dir:oe.key===W&&oe.dir==="asc"?"desc":"asc"})),He=(W,oe)=>{r.pending[W]?.seq===oe&&i("pending",me=>{const he={...me};return delete he[W],he})},Ne=async(W,oe,me)=>{const he=u(W,oe);if(!he&&me===void 0||he?.v===me)return!0;const Ie=`${W}\0${oe}`;let Ae=null;if(he){if(me===void 0||me===""?Ae="delete":Ae="update",!await t.retract([he]))return nt({variant:"error",title:`Failed to update "${oe}"`}),!1}else me!==void 0&&me!==""&&(Ae="add");if(me!==void 0&&me!==""){const De=new Date().toISOString();if(!await t.assert([{e:W,a:oe,v:me},{e:W,a:"lastEdited",v:De}]))return nt({variant:"error",title:`Failed to save "${oe}"`}),!1}return Ae&&(i("cellChanges",Ie,{type:Ae,ts:Date.now()}),setTimeout(()=>{i("cellChanges",De=>{const Ke={...De};return delete Ke[Ie],Ke})},3e3)),!0},Ee=(W,oe,me)=>{const he=g(W,oe),Ie=++a;i("pending",he,{value:me,seq:Ie});const Ae=(d.get(he)??Promise.resolve(!0)).then(()=>Ne(W,oe,me)).then(De=>(De&&qe(),De)).finally(()=>{He(he,Ie),d.get(he)===Ae&&d.delete(he)});return d.set(he,Ae),Ae},rt=(W,oe)=>{if(No.has(oe)||r.colFormulas[oe]||b().has(oe))return;const me=f(W,oe);typeof me!="boolean"&&(I().has(oe)||i({edit:{id:W,key:oe},draft:me==null?"":String(me)}))},ct=(W,oe)=>{const me=oe==="_entry"?h(W).key:oe;rt(W,me)},zt=W=>{const oe=["_entry"],me=I();for(const he of C())No.has(he)||r.colFormulas[he]||b().has(he)||me.has(he)||typeof f(W,he)!="boolean"&&oe.push(he);return oe},xt=W=>Gi.includes(W)?"_entry":W,st=W=>{if(!o)return;const oe=W*yi;oe<r.top?o.scrollTop=oe:oe+yi>r.top+r.height&&(o.scrollTop=oe-r.height+yi)},gt=()=>{requestAnimationFrame(()=>{const W=o?.querySelector("input[type='text'], input[type='number'], input[type='date'], textarea");W&&document.activeElement!==W&&W.focus()})},$n=(W,oe,me)=>{const he=xt(oe);if(me==="down"){const Ke=de(),yt=Ke.findIndex(Ft=>Ft.id===W);if(yt<0)return;const Nt=Ke[yt+1];if(!Nt||!zt(Nt.id).includes(he))return;st(yt+1),requestAnimationFrame(()=>{ct(Nt.id,he),gt()});return}const Ie=zt(W),Ae=Ie.indexOf(he);if(Ae<0)return;const De=Ie[me==="next"?Ae+1:Ae-1];De&&(ct(W,De),gt())},Ce=W=>r.sort.key!==W?null:r.sort.dir==="asc"?" ↑":" ↓",Dt=async(W,oe)=>{r.edit?.id!==W||r.edit.key!==oe||await Ee(W,oe,z7(r.draft,Y(oe)))},lt=async W=>{const oe=Ve();if(oe.length===0)return;const me=oe.flatMap(De=>{const Ke=u(De,"cms_status");return Ke?[Ke]:[]});if(me.length>0&&!await t.retract(me)){nt({variant:"error",title:"Failed to update selected entries"});return}const he=new Date().toISOString();if(!await t.assert(oe.flatMap(De=>[{e:De,a:"cms_status",v:W},{e:De,a:"lastEdited",v:he}]))){nt({variant:"error",title:"Failed to update selected entries"});return}const Ae=W==="published"?"published":W==="archived"?"archived":"moved to drafts";nt({variant:"success",title:`${oe.length} ${Ae}`}),Le()},At=async()=>{const W=Ve();if(W.length===0||!window.confirm(`Delete ${W.length} selected ${W.length===1?"entry":"entries"}?`))return;const oe=W.flatMap(he=>c(he));if(oe.length===0)return;if(!await t.retract(oe)){nt({variant:"error",title:"Failed to delete selected entries"});return}e.selected&&W.includes(e.selected)&&e.onSelect(null),nt({variant:"success",title:`Deleted ${W.length} ${W.length===1?"entry":"entries"}`}),Le()},wt=W=>{navigator.clipboard&&navigator.clipboard.writeText(W).then(()=>nt({variant:"success",title:"Copied ID"}))},It=(W,oe,me,he)=>{const Ie=()=>r.edit?.id===W&&r.edit.key===oe,Ae=()=>f(W,oe);return s(Dn,{get children(){return[s(ot,{get when(){return r.colFormulas[oe]},children:De=>{const Ke=T(()=>L(W)),yt=T(()=>L7(De(),Ke()));return(()=>{var Nt=QA();return l(Nt,s(d0,{class:"size-3 shrink-0 text-icon-weak"}),null),l(Nt,s(E,{get when(){return yt().ok},get fallback(){return(()=>{var Ft=JA();return G(()=>ue(Ft,"title",yt().error)),Ft})()},get children(){var Ft=If();return l(Ft,()=>Vs(yt().value)),Ft}}),null),G(()=>ue(Nt,"title",`Formula: ${De()}`)),Nt})()}}),s(ot,{get when(){return typeof Ae()=="boolean"||void 0},get children(){var De=YA(),Ke=De.firstChild;return De.$$click=yt=>{yt.stopPropagation(),Ee(W,oe,!Ae())},G(yt=>{var Nt=Ae()===!0,Ft={"bg-blue-500":Ae()===!0,"bg-surface-raised-base/80 ring-1 ring-inset ring-border-base/50":Ae()!==!0},kn=`Toggle ${S(oe)}`,Yt=Ae()===!0,an=Ae()!==!0;return Nt!==yt.e&&ue(De,"aria-checked",yt.e=Nt),yt.t=Tt(De,Ft,yt.t),kn!==yt.a&&ue(De,"title",yt.a=kn),Yt!==yt.o&&Ke.classList.toggle("translate-x-3.5",yt.o=Yt),an!==yt.i&&Ke.classList.toggle("translate-x-0.5",yt.i=an),yt},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),De}}),s(ot,{get when(){return b().get(oe)},children:De=>{const Ke=()=>{const dn=De().target;if(dn)return dn;const Xt=Nt()[0];if(Xt?.includes(":"))return Xt.split(":")[0]},yt=()=>GA(oe,f,v()),Nt=()=>WA(Ae()),Ft=()=>n.facts(),kn=()=>{const dn=Ke();return(dn?t.entities.filter(sn=>Ei(sn.type,dn)):t.entities).slice(0,40)},Yt=dn=>{if(yt()){const Xt=Nt();if(Xt.includes(dn))return;Ee(W,oe,Ef([...Xt,dn]));return}Ee(W,oe,dn)},an=dn=>{const Xt=Nt().filter(sn=>sn!==dn);Ee(W,oe,Xt.length===0?void 0:Ef(Xt))},En=()=>void Ee(W,oe,void 0);return(()=>{var dn=t7();return l(dn,s(Oe,{get each(){return Nt()},children:Xt=>(()=>{var sn=r7(),_n=sn.firstChild;return ue(sn,"title",Xt),l(sn,s(jo,{class:"size-3 shrink-0 opacity-80"}),_n),l(_n,()=>oa(Xt,Ft())),l(sn,s(E,{get when(){return yt()},get children(){var fn=n7();return fn.$$click=Hn=>{Hn.stopPropagation(),an(Xt)},l(fn,s(Mi,{class:"size-2.5"})),fn}}),null),G(fn=>Pn(sn,Ds(nl),fn)),sn})()}),null),l(dn,s(Ye,{placement:"bottom-start",gutter:2,modal:!1,get children(){return[s(Ye.Trigger,{class:"inline-flex items-center gap-0.5 rounded px-1.5 py-[1px] text-9-regular tracking-wide transition-opacity hover:opacity-80",get style(){return Ds(nl)},onClick:Xt=>Xt.stopPropagation(),get title(){return`Edit ${S(oe)}`},get children(){return[s(E,{get when(){return Nt().length===0},get children(){return[s(jo,{class:"size-3 shrink-0 opacity-80"}),e7()]}}),s(Ue,{name:"chevron-down",size:"small",class:"opacity-60"})]}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"min-w-[180px] max-h-64 overflow-y-auto",get children(){return[s(E,{get when(){return!yt()},get children(){return s(Ye.Item,{onSelect:En,get children(){return s(Ye.ItemLabel,{get children(){var Xt=Lf();return Xt.firstChild,l(Xt,s(E,{get when(){return Nt().length===0},get children(){return s(Ue,{name:"check",size:"small",class:"text-text-base"})}}),null),Xt}})}})}}),s(Oe,{get each(){return kn()},children:Xt=>{const sn=()=>Nt().includes(Xt.id);return s(Ye.Item,{onSelect:()=>Yt(Xt.id),get children(){return s(Ye.ItemLabel,{get children(){var _n=i7(),fn=_n.firstChild,Hn=fn.firstChild;return l(fn,s(jo,{class:"size-3 shrink-0 opacity-80"}),Hn),l(Hn,()=>oa(Xt.id,Ft())),l(_n,s(E,{get when(){return sn()},get children(){return s(Ue,{name:"check",size:"small",class:"text-text-base shrink-0"})}}),null),G(Xn=>Pn(fn,Ds(nl),Xn)),_n}})}})}})]}})}})]}}),null),dn})()}}),s(ot,{get when(){return I().get(oe)},children:De=>{const Ke=()=>Ae()===void 0||Ae()===null||Ae()===""?"":String(Ae()),yt=()=>Ke()?zf(Ke()):hr("113, 113, 122");return(()=>{var Nt=s7();return l(Nt,s(Ye,{placement:"bottom-start",gutter:2,modal:!1,get children(){return[s(Ye.Trigger,{class:"flex items-center gap-0.5 rounded px-1.5 py-[1px] text-9-regular uppercase tracking-wide transition-opacity hover:opacity-80",get style(){return Ds(yt())},onClick:Ft=>Ft.stopPropagation(),get title(){return`Edit ${S(oe)}`},get children(){return[(()=>{var Ft=If();return l(Ft,()=>Ke()||"—"),Ft})(),s(Ue,{name:"chevron-down",size:"small",class:"opacity-60"})]}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"min-w-[140px]",get children(){return[s(Ye.Item,{onSelect:()=>void Ee(W,oe,void 0),get children(){return s(Ye.ItemLabel,{get children(){var Ft=Lf();return Ft.firstChild,l(Ft,s(E,{get when(){return!Ke()},get children(){return s(Ue,{name:"check",size:"small",class:"text-text-base"})}}),null),Ft}})}}),s(Oe,{get each(){return De()},children:Ft=>{const kn=zf(Ft);return s(Ye.Item,{onSelect:()=>void Ee(W,oe,Ft),get children(){return s(Ye.ItemLabel,{get children(){var Yt=o7(),an=Yt.firstChild;return l(an,Ft),l(Yt,s(E,{get when(){return Ke()===Ft},get children(){return s(Ue,{name:"check",size:"small",class:"text-text-base"})}}),null),G(En=>Pn(an,Ds(kn),En)),Yt}})}})}})]}})}})]}})),Nt})()}}),s(ot,{get when(){return No.has(oe)},get children(){var De=XA();return l(De,()=>me?.()??Vs(Ae())),G(()=>ue(De,"title",`${S(oe)} is read-only`)),De}}),s(ot,{when:!0,get children(){var De=ZA();return De.$$keydown=Ke=>{if(Ke.key==="Tab"){Ke.preventDefault();const yt=Ke.shiftKey?"prev":"next";Dt(W,oe).then(()=>$n(W,oe,yt));return}if(Ke.key==="Enter"){Ke.preventDefault(),Dt(W,oe).then(()=>$n(W,oe,"down"));return}Ke.key==="Escape"&&qe()},De.addEventListener("blur",()=>void Dt(W,oe)),De.$$input=Ke=>i("draft",Ke.currentTarget.value),De.$$click=Ke=>Ke.stopPropagation(),De.addEventListener("focus",()=>{if(Ie())return;const Ke=Ae();i({edit:{id:W,key:oe},draft:Ke==null?"":String(Ke)})}),G(Ke=>{var yt=Y(oe)==="number"?"number":Y(oe)==="date"?"date":"text",Nt=Y(oe)==="number"?"any":void 0,Ft={"italic text-text-weaker":he?.()&&!Ie()},kn=he?.()?me?.()??"":"—";return yt!==Ke.e&&ue(De,"type",Ke.e=yt),Nt!==Ke.t&&ue(De,"step",Ke.t=Nt),Ke.a=Tt(De,Ft,Ke.a),kn!==Ke.o&&ue(De,"placeholder",Ke.o=kn),Ke},{e:void 0,t:void 0,a:void 0,o:void 0}),G(()=>De.value=Ie()?r.draft:Ae()===void 0||Ae()===null?"":String(Ae())),De}})]}})};return $e(()=>{r.query,r.filter,e.collection.key,Le(),requestAnimationFrame(()=>{o&&(o.scrollTop=0,ye(o))})}),(()=>{var W=p7(),oe=W.firstChild,me=oe.firstChild,he=me.firstChild,Ie=he.firstChild,Ae=Ie.firstChild,De=Ae.firstChild,Ke=De.nextSibling,yt=Ke.firstChild,Nt=yt.nextSibling,Ft=Nt.firstChild,kn=Ie.nextSibling,Yt=oe.nextSibling,an=Yt.firstChild,En=an.firstChild,dn=En.firstChild,Xt=dn.firstChild,sn=dn.nextSibling,_n=sn.firstChild,fn=sn.nextSibling,Hn=fn.nextSibling;Hn.firstChild;var Xn=Hn.nextSibling;Xn.firstChild;var On=Xn.nextSibling;return l(Ae,s(Ue,{name:"search",size:"small",class:"shrink-0 text-icon-weak"}),De),De.$$input=je=>{const ht=je.currentTarget.value;i("query",ht),r.queryMode==="eqls"&&B(ht)},Ke.$$click=()=>{const je=r.queryMode==="eqls"?"text":"eqls";i("queryMode",je),je==="eqls"?B(r.query):i({eqlsActive:null,eqlsError:""})},l(Ae,s(E,{get when(){return r.query},get children(){var je=a7();return je.$$click=()=>{i("query",""),r.queryMode==="eqls"&&i({eqlsActive:[],eqlsError:""})},l(je,s(Ue,{name:"x",size:"small"})),je}}),null),l(Ie,s(E,{get when(){return Te(()=>r.queryMode==="eqls")()&&r.eqlsError},get children(){var je=l7();return l(je,()=>r.eqlsError),je}}),null),l(kn,s(Ye,{placement:"bottom-end",gutter:4,modal:!1,get children(){return[s(Ye.Trigger,{class:"flex items-center gap-1 rounded-md border border-border-weaker-base bg-surface-raised-base/40 px-2 py-1 text-11-medium text-text-weak hover:text-text-base",title:"Add property",get children(){return[s(es,{class:"size-3.5"}),c7()]}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"min-w-[240px] p-2",get children(){var je=u7(),ht=je.firstChild,vn=ht.nextSibling,ln=vn.nextSibling,cn=ln.nextSibling;return je.$$keydown=Jt=>{Jt.key==="Enter"&&!N()&&r.addPropDraft.name.trim()&&(Jt.preventDefault(),J())},vn.$$input=Jt=>i("addPropDraft","name",Jt.currentTarget.value),ln.addEventListener("change",Jt=>i("addPropDraft","type",Jt.currentTarget.value)),l(je,s(E,{get when(){return r.addPropDraft.type==="formula"},get children(){var Jt=Pf();return Jt.$$input=en=>i("addPropDraft","expr",en.currentTarget.value),G(()=>Jt.value=r.addPropDraft.expr),Jt}}),cn),l(je,s(E,{get when(){return N()},get children(){var Jt=d7();return l(Jt,N),Jt}}),cn),cn.$$click=J,G(()=>cn.disabled=!r.addPropDraft.name.trim()||!!N()),G(()=>vn.value=r.addPropDraft.name),G(()=>ln.value=r.addPropDraft.type),je}})}})]}})),l(W,s(E,{get when(){return Object.keys(r.filters).length>0},get children(){var je=f7(),ht=je.firstChild,vn=ht.firstChild;return l(ht,s(Oe,{get each(){return Object.keys(r.filters)},children:ln=>{const cn=()=>r.filters[ln],Jt=()=>{const en=cn();if(!en)return"";if(en.kind==="enum")return en.values.join(", ");if(en.kind==="range"){const Ut=en.min!==void 0?String(en.min):"*",gn=en.max!==void 0?String(en.max):"*";return`${Ut}…${gn}`}return en.kind==="contains"?`"${en.text}"`:""};return(()=>{var en=v7(),Ut=en.firstChild,gn=Ut.firstChild,Gt=Ut.nextSibling,Zt=Gt.nextSibling;return l(Ut,()=>S(ln),gn),l(Gt,Jt),Zt.$$click=()=>M(ln,void 0),l(Zt,s(Mi,{class:"size-3"})),en})()}}),vn),vn.$$click=A,je}}),Yt),Yt.addEventListener("scroll",je=>ye(je.currentTarget)),Lt(je=>{o=je,requestAnimationFrame(()=>ye(je))},Yt),Xt.addEventListener("change",je=>tt(je.currentTarget.checked)),l(sn,s(Ue,{name:"fingerprint",size:"small",class:"shrink-0 text-icon-weak"}),_n),Hn.$$click=()=>we("_entry"),l(Hn,()=>Ce("_entry"),null),Xn.$$click=()=>we("_status"),l(Xn,()=>Ce("_status"),null),l(En,s(Oe,{get each(){return be()},children:je=>{const ht=()=>Y(je),vn=()=>I().get(je),ln=()=>!!r.filters[je];return(()=>{var cn=y7(),Jt=cn.firstChild,en=Jt.firstChild;return Jt.$$click=()=>we(je),l(en,()=>S(je)),l(Jt,()=>Ce(je),null),l(cn,s(Ye,{placement:"bottom-end",gutter:4,modal:!1,get children(){return[s(Ye.Trigger,{class:"flex size-4 shrink-0 items-center justify-center rounded text-icon-weak hover:text-text-base",get classList(){return{"text-blue-400":ln()}},onClick:Ut=>Ut.stopPropagation(),get title(){return`Filter ${S(je)}`},get children(){return s(o0,{class:"size-3"})}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"min-w-[200px] p-2",get children(){return s(E,{get when(){return vn()},get fallback(){return s(E,{get when(){return ht()==="number"},get fallback(){return(()=>{var Ut=$7(),gn=Ut.firstChild,Gt=gn.nextSibling,Zt=Gt.nextSibling;return Gt.$$input=te=>{const pe=te.currentTarget.value;M(je,pe?{kind:"contains",text:pe}:void 0)},Zt.$$click=()=>M(je,void 0),G(()=>Gt.value=r.filters[je]?.kind==="contains"?r.filters[je].text:""),Ut})()},get children(){var Ut=w7(),gn=Ut.firstChild,Gt=gn.nextSibling,Zt=Gt.firstChild,te=Zt.nextSibling,pe=te.nextSibling,We=Gt.nextSibling;return Zt.$$input=ut=>{const at=ut.currentTarget.value===""?void 0:Number(ut.currentTarget.value),Mt=r.filters[je],Be=Mt?.kind==="range"?Mt.max:void 0;M(je,at===void 0&&Be===void 0?void 0:{kind:"range",min:at,max:Be})},pe.$$input=ut=>{const at=ut.currentTarget.value===""?void 0:Number(ut.currentTarget.value),Mt=r.filters[je],Be=Mt?.kind==="range"?Mt.min:void 0;M(je,Be===void 0&&at===void 0?void 0:{kind:"range",min:Be,max:at})},We.$$click=()=>M(je,void 0),G(()=>Zt.value=r.filters[je]?.kind==="range"?r.filters[je].min??"":""),G(()=>pe.value=r.filters[je]?.kind==="range"?r.filters[je].max??"":""),Ut}})},children:Ut=>(()=>{var gn=k7(),Gt=gn.firstChild,Zt=Gt.nextSibling;return l(gn,s(Oe,{get each(){return Ut()},children:te=>{const pe=()=>{const We=r.filters[je];return We?.kind==="enum"&&We.values.includes(te)};return(()=>{var We=_7(),ut=We.firstChild,at=ut.nextSibling;return ut.addEventListener("change",Mt=>{const Be=r.filters[je],ft=Be?.kind==="enum"?[...Be.values]:[];if(Mt.currentTarget.checked)ft.push(te);else{const Vt=ft.indexOf(te);Vt>=0&&ft.splice(Vt,1)}M(je,ft.length===0?void 0:{kind:"enum",values:ft})}),l(at,te),G(()=>ut.checked=pe()),We})()}}),Zt),Zt.$$click=()=>M(je,void 0),gn})()})}})}})]}}),null),l(cn,s(Ye,{placement:"bottom-end",gutter:4,modal:!1,get children(){return[s(Ye.Trigger,{class:"flex size-4 shrink-0 items-center justify-center rounded text-icon-weak hover:text-text-base",onClick:Ut=>{Ut.stopPropagation(),Q(je)},get title(){return`Edit ${S(je)}`},get children(){return s(a0,{class:"size-3"})}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"min-w-[240px] p-2",get children(){var Ut=x7(),gn=Ut.firstChild,Gt=gn.nextSibling,Zt=Gt.nextSibling,te=Zt.nextSibling,pe=te.firstChild,We=pe.firstChild,ut=pe.nextSibling;return Ut.$$keydown=at=>{at.key==="Enter"&&(at.metaKey||at.ctrlKey)&&(at.preventDefault(),j(je))},Gt.$$input=at=>i("editColDraft","label",at.currentTarget.value),Zt.addEventListener("change",at=>i("editColDraft","type",at.currentTarget.value)),l(Ut,s(E,{get when(){return r.editColDraft.type==="select"},get children(){var at=b7();return at.$$input=Mt=>i("editColDraft","options",Mt.currentTarget.value),G(()=>at.value=r.editColDraft.options),at}}),te),l(Ut,s(E,{get when(){return r.editColDraft.type==="formula"},get children(){var at=Pf();return at.$$input=Mt=>i("editColDraft","expr",Mt.currentTarget.value),G(()=>at.value=r.editColDraft.expr),at}}),te),pe.$$click=()=>void H(je),l(pe,s(zs,{class:"size-3.5"}),We),ut.$$click=()=>void j(je),G(()=>Gt.value=r.editColDraft.label),G(()=>Zt.value=r.editColDraft.type),Ut}})}})]}}),null),cn})()}}),On),l(On,s(id,{class:"size-3.5 text-icon-weak"})),l(an,s(E,{get when(){return de().length>0},get fallback(){return s(Pp,{get icon(){return s(es,{class:"size-5"})},get title(){return r.query?"No matching entries":"No entries yet"},get description(){return r.query?"Try a different search or status filter.":"Create the first row in this collection."},get action(){return(()=>{var je=C7();return je.$$click=()=>void e.onCreate(),je})()}})},get children(){var je=g7();return l(je,s(Oe,{get each(){return re()},children:(ht,vn)=>{const ln=T(()=>h(ht.id));return(()=>{var cn=D7(),Jt=cn.firstChild,en=Jt.firstChild,Ut=en.firstChild,gn=en.nextSibling,Gt=gn.firstChild,Zt=Gt.nextSibling,te=gn.nextSibling,pe=te.nextSibling,We=pe.firstChild,ut=pe.nextSibling,at=ut.nextSibling,Mt=at.firstChild;return Ut.$$click=Be=>{Be.stopPropagation(),ge(ht.id,Be.currentTarget.checked,Be.shiftKey)},l(Gt,()=>Bo(ht.id,e.collection.key)),Zt.$$click=Be=>{Be.stopPropagation(),wt(ht.id)},l(Zt,s(sd,{class:"size-3"})),l(te,()=>ne().start+vn()+1),l(pe,s(Gn,{get type(){return e.collection.key},size:14,get color(){return e.collection.theme.color},get icon(){return e.collection.theme.icon}}),We),l(We,()=>It(ht.id,ln().key,()=>ln().empty?"Untitled":ln().value,()=>ln().empty),null),l(We,s(E,{get when(){return t.fresh.includes(ht.id)},get children(){return S7()}}),null),l(ut,s(Ye,{placement:"bottom-start",gutter:2,modal:!1,get children(){return[s(Ye.Trigger,{class:"flex items-center gap-0.5 rounded px-1.5 py-[1px] text-9-regular uppercase tracking-wide hover:opacity-80 transition-opacity",get classList(){return{"bg-amber-500/15 text-amber-400":m(ht.id)==="draft","bg-emerald-500/15 text-emerald-400":m(ht.id)==="published","bg-zinc-500/20 text-zinc-300":m(ht.id)==="archived"}},onClick:Be=>Be.stopPropagation(),title:"Change status",get children(){return[Te(()=>Te(()=>m(ht.id)==="draft")()?"Draft":m(ht.id)==="published"?"Live":"Archived"),s(Ue,{name:"chevron-down",size:"small",class:"opacity-60"})]}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"min-w-[120px]",get children(){return s(Oe,{each:R7,children:Be=>s(Ye.Item,{onSelect:()=>void Ee(ht.id,"cms_status",Be.id),get children(){return s(Ye.ItemLabel,{get children(){var ft=M7(),Vt=ft.firstChild;return l(Vt,()=>Be.label),l(ft,s(E,{get when(){return m(ht.id)===Be.id},get children(){return s(Ue,{name:"check",size:"small",class:"text-text-base"})}}),null),ft}})}})})}})}})]}})),l(Jt,s(Oe,{get each(){return be()},children:Be=>{const ft=()=>r.cellChanges[`${ht.id}\0${Be}`],Vt=()=>{const Bt=ft();return Bt?Bt.type==="add"?"animate-cell-add":Bt.type==="update"?"animate-cell-update":Bt.type==="delete"?"animate-cell-delete":"":""};return(()=>{var Bt=E7();return l(Bt,()=>It(ht.id,Be,()=>k(ht,Be))),G(()=>Ht(Bt,`min-w-0 rounded ${Vt()}`)),Bt})()}}),at),Mt.$$click=Be=>{Be.stopPropagation(),e.onSelect(e.selected===ht.id?null:ht.id)},l(Mt,s(id,{class:"size-3.5"})),l(at,s(Ye,{placement:"bottom-end",gutter:4,modal:!1,get children(){return[s(Ye.Trigger,{class:"flex size-6 items-center justify-center rounded-md text-icon-weak transition-colors hover:bg-surface-raised-base/70 hover:text-text-base",onClick:Be=>Be.stopPropagation(),title:"Row actions",get children(){return s(l0,{class:"size-3.5"})}}),s(Ye.Portal,{get children(){return s(Ye.Content,{class:"min-w-[140px]",get children(){return[s(E,{get when(){return e.onDuplicate},get children(){return s(Ye.Item,{onSelect:()=>void e.onDuplicate?.(ht.id),get children(){return s(Ye.ItemLabel,{get children(){var Be=T7(),ft=Be.firstChild;return l(Be,s(sd,{class:"size-3.5 text-icon-weak"}),ft),Be}})}})}}),s(Ye.Item,{onSelect:()=>{e.onDelete(ht.id),i("picked",ht.id,!1)},get children(){return s(Ye.ItemLabel,{get children(){var Be=A7(),ft=Be.firstChild;return l(Be,s(zs,{class:"size-3.5"}),ft),Be}})}})]}})}})]}}),null),G(Be=>{var ft=`${(ne().start+vn())*yi}px`,Vt={"bg-surface-raised-base text-text-strong":e.selected===ht.id,"bg-surface-raised-base/60":r.picked[ht.id]&&e.selected!==ht.id,"hover:bg-surface-raised-base/40":e.selected!==ht.id&&!t.fresh.includes(ht.id)&&!r.picked[ht.id],"bg-emerald-500/15 animate-fresh-highlight":t.fresh.includes(ht.id)},Bt=xe(),pn=`Select ${ln().empty?Bo(ht.id,e.collection.key):ln().value}`,Cn={"text-text-weaker italic":ln().empty,"text-text-base":!ln().empty},R=e.selected===ht.id,se=!!(r.picked[ht.id]&&e.selected!==ht.id),fe={"bg-surface-raised-base text-text-base":e.selected===ht.id},Pe=e.selected===ht.id?"Close sidebar":"Open in sidebar";return ft!==Be.e&&Je(cn,"top",Be.e=ft),Be.t=Tt(Jt,Vt,Be.t),Bt!==Be.a&&Je(Jt,"grid-template-columns",Be.a=Bt),pn!==Be.o&&ue(Ut,"title",Be.o=pn),Be.i=Tt(We,Cn,Be.i),R!==Be.n&&at.classList.toggle("bg-surface-raised-base",Be.n=R),se!==Be.s&&at.classList.toggle("bg-surface-raised-base/95",Be.s=se),Be.h=Tt(Mt,fe,Be.h),Pe!==Be.r&&ue(Mt,"title",Be.r=Pe),Be},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),G(()=>Ut.checked=!!r.picked[ht.id]),cn})()}})),G(ht=>Je(je,"height",`${de().length*yi}px`)),je}}),null),l(an,s(E,{get when(){return de().length>0},get children(){var je=m7(),ht=je.firstChild,vn=ht.firstChild,ln=vn.firstChild;return ht.$$click=()=>void e.onCreate(),l(vn,s(es,{class:"size-3.5"}),ln),je}}),null),l(W,s(E,{get when(){return Ve().length>0},get children(){var je=h7(),ht=je.firstChild,vn=ht.firstChild,ln=vn.firstChild,cn=vn.nextSibling,Jt=cn.firstChild,en=cn.nextSibling,Ut=en.firstChild,gn=en.nextSibling,Gt=gn.firstChild,Zt=gn.nextSibling,te=Zt.firstChild,pe=Zt.nextSibling;return l(vn,()=>Ve().length,ln),cn.$$click=()=>void lt("published"),l(cn,s(ki,{class:"size-3.5"}),Jt),en.$$click=()=>void lt("draft"),l(en,s(Ag,{class:"size-3.5"}),Ut),gn.$$click=()=>void lt("archived"),l(gn,s(c0,{class:"size-3.5"}),Gt),Zt.$$click=()=>void At(),l(Zt,s(zs,{class:"size-3.5"}),te),pe.$$click=Le,je}}),null),G(je=>{var ht=r.queryMode==="eqls"?"min-w-0 flex-1 border-0 bg-transparent font-mono text-12-regular text-text-base outline-0 placeholder:text-text-weaker":"min-w-0 flex-1 border-0 bg-transparent text-12-regular text-text-base outline-0 placeholder:text-text-weaker",vn=r.queryMode==="eqls"?'find ?e where points >= 200 and difficulty = "easy"':`Search ${e.collection.label}…`,ln=r.queryMode==="eqls",cn=r.queryMode==="eqls"?"Switch to text search":"Switch to EQL-S query mode",Jt=r.queryMode==="eqls"?"rgb(34, 211, 238)":"rgb(63, 63, 70)",en=r.queryMode==="eqls"?"inset 0 0 0 1px rgba(207, 250, 254, 0.8)":"inset 0 0 0 1px rgba(212, 212, 216, 0.75)",Ut=r.queryMode==="eqls"?"rgb(9, 9, 11)":"rgb(255, 255, 255)",gn=r.queryMode==="eqls"?"translateX(14px)":"translateX(2px)",Gt=`${_e()}px`,Zt=xe();return ht!==je.e&&Ht(De,je.e=ht),vn!==je.t&&ue(De,"placeholder",je.t=vn),ln!==je.a&&ue(Ke,"aria-checked",je.a=ln),cn!==je.o&&ue(Ke,"title",je.o=cn),Jt!==je.i&&Je(Nt,"background-color",je.i=Jt),en!==je.n&&Je(Nt,"box-shadow",je.n=en),Ut!==je.s&&Je(Ft,"background-color",je.s=Ut),gn!==je.h&&Je(Ft,"transform",je.h=gn),Gt!==je.r&&Je(an,"width",je.r=Gt),Zt!==je.d&&Je(En,"grid-template-columns",je.d=Zt),je},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),G(()=>De.value=r.query),G(()=>Xt.checked=Z()),W})()}Kt(["click","input","keydown"]);var N7=x("<span class=text-red-500 title=Required>*"),B7=x('<label class="flex flex-col gap-1.5"><span class="text-11-medium text-text-weak flex items-center gap-1"><span class=capitalize></span><span class="ml-auto text-10-regular text-text-weaker font-mono">'),q7=x('<input class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50">'),j7=x('<input type=number class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50">'),V7=x('<div class="flex items-center gap-2 px-2 py-1.5 rounded border border-border-weaker-base bg-surface-raised-base/40"><input type=checkbox class="size-3.5 accent-text-strong"><span class="text-12-regular text-text-weak">'),H7=x('<span class="text-10-regular text-text-weaker">Repeats '),U7=x('<div class="flex flex-col gap-1"><input type=date class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50">'),W7=x('<select class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50 appearance-none cursor-pointer"><option value>— none —'),K7=x("<option>"),G7=x('<div class="flex items-center gap-2"><input type=color class="size-8 rounded border border-border-weaker-base bg-transparent cursor-pointer disabled:opacity-50"><input type=text class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50 font-mono">'),Y7=x('<div class="bg-surface-raised-base/40 border border-border-weaker-base rounded px-3 py-2 min-h-[120px] focus-within:border-border-base">'),X7=x('<span class="ml-auto text-10-regular text-text-weaker font-mono truncate">'),Z7=x('<div class="flex items-center gap-2 px-2 py-1.5 rounded border border-border-weaker-base bg-surface-raised-base/30"><span class="text-10-medium text-text-weaker font-mono">ƒ</span><span class="text-12-regular text-text-base font-mono">'),Q7=x('<div class="flex items-center gap-2"><button type=button class="flex flex-1 items-center gap-2 rounded border px-2 py-1.5 text-left text-12-regular disabled:opacity-50"style="background-color:rgba(167, 139, 250, 0.24);border-color:rgba(167, 139, 250, 0.34);color:rgb(167, 139, 250);box-shadow:inset 0 0 0 1px rgba(167, 139, 250, 0.2)"><span class=truncate></span></button><button type=button class="px-2 py-1.5 text-text-weaker hover:text-text-base"title=Clear>'),J7=x('<div class="border border-border-weaker-base rounded bg-background-base mt-1 overflow-hidden"><input autofocus type=text class="w-full bg-transparent border-0 border-b border-border-weaker-base outline-0 px-2 py-1.5 text-12-regular"><div class="max-h-48 overflow-y-auto">'),eD=x('<button type=button class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50 text-left text-text-weaker hover:text-text-weak transition-colors">'),tD=x('<div class="px-2 py-2 text-11-regular text-text-weaker italic text-center">No results'),nD=x('<button type=button class="w-full text-left px-2 py-1.5 text-12-regular hover:bg-surface-raised-base/40 flex items-center gap-2"><span class="truncate flex-1"></span><span class="text-10-regular text-text-weaker font-mono shrink-0">'),rD=x('<button type=button class="px-2 py-1.5 text-text-weaker hover:text-text-base"title=Clear>'),iD=x('<div class="rounded border border-border-weaker-base overflow-hidden bg-surface-raised-base/30 p-2 flex items-center justify-center"><img class="max-h-32 max-w-full object-contain">'),sD=x('<video controls class="rounded border border-border-weaker-base max-h-40 bg-black">'),oD=x("<audio controls preload=metadata class=w-full>"),aD=x('<div class="flex flex-col gap-2"><div class="flex items-center gap-2"><div class="flex-1 relative"><input type=text class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50 pl-8 font-mono"placeholder=assets/file.png></div><button type=button class="px-2 py-1.5 rounded border border-border-weaker-base text-11-medium text-text-weak hover:text-text-base hover:bg-surface-raised-base/40 disabled:opacity-50">Browse'),lD=x('<input type=text class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base disabled:opacity-50">'),cD=x('<span class="text-10-regular text-text-weaker">Field type "<!>" not yet supported — falling back to text input');function qr(e){return(()=>{var t=B7(),n=t.firstChild,r=n.firstChild,i=r.nextSibling;return l(r,()=>e.def.label),l(n,s(E,{get when(){return e.def.required},get children(){return N7()}}),i),l(i,()=>e.def.type),l(t,()=>e.children,null),t})()}function dD(e){const t=()=>e.def.type==="email"?"email":e.def.type==="url"?"url":"text",n=()=>{const r=e.value();return typeof r=="string"?r:""};return s(qr,{get def(){return e.def},get children(){var r=q7();return r.$$input=i=>e.onChange(i.currentTarget.value||void 0),G(i=>{var o=t(),a=e.def.default,d=e.disabled;return o!==i.e&&ue(r,"type",i.e=o),a!==i.t&&ue(r,"placeholder",i.t=a),d!==i.a&&(r.disabled=i.a=d),i},{e:void 0,t:void 0,a:void 0}),G(()=>r.value=n()),r}})}function uD(e){const t=()=>{const n=e.value();return typeof n=="number"?n:""};return s(qr,{get def(){return e.def},get children(){var n=j7();return n.$$input=r=>{const i=r.currentTarget.value;if(i==="")return e.onChange(void 0);const o=Number(i);Number.isFinite(o)&&e.onChange(o)},G(r=>{var i=e.def.min,o=e.def.max,a=e.def.step,d=e.def.default,c=e.disabled;return i!==r.e&&ue(n,"min",r.e=i),o!==r.t&&ue(n,"max",r.t=o),a!==r.a&&ue(n,"step",r.a=a),d!==r.o&&ue(n,"placeholder",r.o=d),c!==r.i&&(n.disabled=r.i=c),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),G(()=>n.value=t()),n}})}function fD(e){return s(qr,{get def(){return e.def},get children(){var t=V7(),n=t.firstChild,r=n.nextSibling;return n.addEventListener("change",i=>e.onChange(i.currentTarget.checked)),l(r,()=>e.value()?"True":"False"),G(()=>n.disabled=e.disabled),G(()=>n.checked=!!e.value()),t}})}function gD(e){const t=()=>{const r=e.value();return typeof r=="string"?r:""},n=()=>{const r=t();if(!r)return"";const i=new Date(r);return Number.isNaN(i.getTime())?"":i.toISOString().slice(0,10)};return s(qr,{get def(){return e.def},get children(){var r=U7(),i=r.firstChild;return i.$$input=o=>{const a=o.currentTarget.value;if(!a)return e.onChange(void 0);e.onChange(new Date(a).toISOString())},l(r,s(E,{get when(){return Te(()=>!!e.def.repeat)()&&e.def.repeat!=="none"},get children(){var o=H7();return o.firstChild,l(o,()=>e.def.repeat,null),o}}),null),G(()=>i.disabled=e.disabled),G(()=>i.value=n()),r}})}function mD(e){const t=()=>e.def.options??[],n=()=>{const r=e.value();return typeof r=="string"?r:""};return s(qr,{get def(){return e.def},get children(){var r=W7();return r.firstChild,r.addEventListener("change",i=>e.onChange(i.currentTarget.value||void 0)),l(r,s(Oe,{get each(){return t()},children:i=>(()=>{var o=K7();return o.value=i,l(o,i),o})()}),null),G(()=>r.disabled=e.disabled),G(()=>r.value=n()),r}})}function hD(e){const t=()=>{const r=e.value();return typeof r=="string"?r:""},n=()=>{const r=e.value();return typeof r=="string"&&/^#[0-9a-fA-F]{6}$/.test(r)?r:typeof e.def.default=="string"&&/^#[0-9a-fA-F]{6}$/.test(e.def.default)?e.def.default:"#888888"};return s(qr,{get def(){return e.def},get children(){var r=G7(),i=r.firstChild,o=i.nextSibling;return i.$$input=a=>e.onChange(a.currentTarget.value),o.$$input=a=>e.onChange(a.currentTarget.value||void 0),G(a=>{var d=e.disabled,c=n(),u=e.disabled;return d!==a.e&&(i.disabled=a.e=d),c!==a.t&&ue(o,"placeholder",a.t=c),u!==a.a&&(o.disabled=a.a=u),a},{e:void 0,t:void 0,a:void 0}),G(()=>i.value=n()),G(()=>o.value=t()),r}})}function pD(e){const t=()=>{const n=e.value();return typeof n=="string"?n:""};return s(qr,{get def(){return e.def},get children(){var n=Y7();return l(n,s(u0,{get path(){return`cms:${e.def.key}`},get value(){return t()},active:!0,onChange:r=>e.onChange(r||void 0)})),n}})}function vD(e){const t=T(()=>{const n=Js(e.def.formula??"",e.values?.()??{});return n===void 0?"—":String(n)});return s(qr,{get def(){return e.def},get children(){var n=Z7(),r=n.firstChild,i=r.nextSibling;return l(i,t),l(n,s(E,{get when(){return e.def.formula},get children(){var o=X7();return l(o,()=>e.def.formula),o}}),null),n}})}function bD(e){const t=Dr(),[n,r]=ke(!1),[i,o]=ke(""),a=()=>e.def.target,d=()=>{const f=e.value();return typeof f=="string"?f:""},c=T(()=>{const f=new Map;for(const m of t.facts){const p=f.get(m.e);p?p.push(m):f.set(m.e,[m])}return f}),u=T(()=>{const f=a(),m=f?t.entities.filter(h=>Ei(h.type,f)):t.entities,p=i().trim().toLowerCase();return(p?m.filter(h=>h.id.toLowerCase().includes(p)?!0:(c().get(h.id)??[]).some(v=>(v.a==="title"||v.a==="name"||v.a==="label"||v.a==="description")&&String(v.v).toLowerCase().includes(p))):m).slice(0,20)}),g=f=>{e.onChange(f),r(!1),o("")};return s(qr,{get def(){return e.def},get children(){return[s(E,{get when(){return d()},get fallback(){return(()=>{var f=eD();return f.$$click=()=>r(!0),l(f,(()=>{var m=Te(()=>!!a());return()=>m()?`Pick a ${a()}…`:"Pick an entity…"})()),G(()=>f.disabled=e.disabled),f})()},get children(){var f=Q7(),m=f.firstChild,p=m.firstChild,w=m.nextSibling;return m.$$click=()=>r(!0),l(m,s(jo,{class:"size-3.5 shrink-0 opacity-80"}),p),l(p,()=>oa(d(),c())),w.$$click=()=>e.onChange(void 0),l(w,s(Mi,{class:"size-3.5"})),G(h=>{var k=e.disabled,v=e.disabled;return k!==h.e&&(m.disabled=h.e=k),v!==h.t&&(w.disabled=h.t=v),h},{e:void 0,t:void 0}),f}}),s(E,{get when(){return n()},get children(){var f=J7(),m=f.firstChild,p=m.nextSibling;return m.addEventListener("blur",()=>setTimeout(()=>r(!1),150)),m.$$keydown=w=>{w.key==="Escape"&&r(!1)},m.$$input=w=>o(w.currentTarget.value),l(p,s(E,{get when(){return u().length>0},get fallback(){return tD()},get children(){return s(Oe,{get each(){return u()},children:w=>(()=>{var h=nD(),k=h.firstChild,v=k.nextSibling;return h.$$mousedown=()=>g(w.id),l(k,()=>oa(w.id,c())),l(v,()=>w.id),h})()})}})),G(()=>ue(m,"placeholder",a()?`Search ${a()}…`:"Search entities…")),G(()=>m.value=i()),f}})]}})}function xD(e){const t=dr(),n=zn(),r=()=>{const a=e.value();return typeof a=="string"?a:""},i=()=>{const a=r();return a?Ns(n.url,a,n.directory):""},o=()=>{Kn(()=>import("./dialog-select-file-B_o52Q2X.js"),__vite__mapDeps([14,1,2,5,11,12,8,13])).then(a=>{t.show(()=>s(a.DialogSelectFile,{mode:"files",onSelectFile:d=>e.onChange(d)}))})};return s(qr,{get def(){return e.def},get children(){var a=aD(),d=a.firstChild,c=d.firstChild,u=c.firstChild,g=c.nextSibling;return u.$$input=f=>e.onChange(f.currentTarget.value||void 0),l(c,s(cr,{get node(){return{path:r()||e.def.key,type:"file"}},class:"absolute left-2 top-1/2 -translate-y-1/2 size-3.5"}),null),g.$$click=o,l(d,s(E,{get when(){return r()},get children(){var f=rD();return f.$$click=()=>e.onChange(void 0),l(f,s(Mi,{class:"size-3.5"})),G(()=>f.disabled=e.disabled),f}}),null),l(a,s(E,{get when(){return Te(()=>e.def.type==="image")()&&i()},get children(){var f=iD(),m=f.firstChild;return m.addEventListener("error",p=>{p.currentTarget.style.display="none"}),G(p=>{var w=i(),h=e.def.label;return w!==p.e&&ue(m,"src",p.e=w),h!==p.t&&ue(m,"alt",p.t=h),p},{e:void 0,t:void 0}),f}}),null),l(a,s(E,{get when(){return Te(()=>e.def.type==="video")()&&i()},get children(){var f=sD();return G(()=>ue(f,"src",i())),f}}),null),l(a,s(E,{get when(){return Te(()=>e.def.type==="audio")()&&i()},get children(){var f=oD();return G(()=>ue(f,"src",i())),f}}),null),G(f=>{var m=e.disabled,p=e.disabled;return m!==f.e&&(u.disabled=f.e=m),p!==f.t&&(g.disabled=f.t=p),f},{e:void 0,t:void 0}),G(()=>u.value=r()),a}})}function yD(e){return s(qr,{get def(){return e.def},get children(){return[(()=>{var t=lD();return t.$$input=n=>e.onChange(n.currentTarget.value||void 0),G(()=>t.disabled=e.disabled),G(()=>t.value=e.value()===void 0?"":String(e.value())),t})(),(()=>{var t=cD(),n=t.firstChild,r=n.nextSibling;return r.nextSibling,l(t,()=>e.def.type,r),t})()]}})}function wD(e){switch(e.def.type){case"text":case"email":case"url":return s(dD,e);case"number":return s(uD,e);case"boolean":return s(fD,e);case"date":return s(gD,e);case"select":return s(mD,e);case"color":return s(hD,e);case"rich_text":return s(pD,e);case"reference":return s(bD,e);case"file":case"image":case"video":case"audio":return s(xD,e);case"formula":return s(vD,e);default:return s(yD,e)}}Kt(["input","click","keydown","mousedown"]);var $D=x('<span class="shrink-0 px-1.5 py-[1px] rounded text-9-regular uppercase tracking-wide bg-amber-500/15 text-amber-400">Draft'),kD=x('<span class="shrink-0 px-1.5 py-[1px] rounded text-9-regular uppercase tracking-wide bg-emerald-500/15 text-emerald-400">Live'),_D=x('<div class="flex flex-col gap-1 max-w-48"><span class="text-11-medium text-text-weak">Target</span><select class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base appearance-none cursor-pointer"><option value>— any —'),CD=x('<div class="flex flex-col gap-1"><span class="text-11-medium text-text-weak">Options</span><input type=text class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base"placeholder="Draft, Published, Archived">'),SD=x('<div class="grid grid-cols-3 gap-2"><div class="flex flex-col gap-1"><span class="text-11-medium text-text-weak">Min</span><input type=number class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base"></div><div class="flex flex-col gap-1"><span class="text-11-medium text-text-weak">Max</span><input type=number class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base"></div><div class="flex flex-col gap-1"><span class="text-11-medium text-text-weak">Step</span><input type=number class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base">'),TD=x('<div class="flex flex-col gap-1 max-w-48"><span class="text-11-medium text-text-weak">Repeat</span><select class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base appearance-none cursor-pointer">'),AD=x('<div class="flex flex-col gap-1"><span class="text-11-medium text-text-weak">Formula</span><input type=text class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base font-mono"placeholder="{price} * {quantity}">'),DD=x('<div class="flex flex-col gap-2"><div class="flex items-end gap-2 flex-wrap"><div class="flex-1 min-w-40 flex flex-col gap-1"><span class="text-11-medium text-text-weak">Field name</span><input autofocus type=text class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base"placeholder=title></div><div class="flex flex-col gap-1 w-32"><span class="text-11-medium text-text-weak">Type</span><select class="w-full bg-surface-raised-base/40 border border-border-weaker-base rounded px-2 py-1.5 text-12-regular text-text-base outline-0 focus:border-border-base appearance-none cursor-pointer"></select></div><label class="h-[30px] flex items-center gap-1.5 px-2 rounded border border-border-weaker-base text-11-medium text-text-weak"><input type=checkbox class="size-3.5 accent-text-strong"><span>Required</span></label><button class="px-3 py-1.5 rounded-md text-12-medium bg-surface-raised-base hover:bg-surface-raised-base/80 transition-colors">Add</button><button class="px-2 py-1.5 text-12-regular text-text-weaker hover:text-text-base">Cancel'),MD=x('<div class="flex-1 min-h-0 flex flex-col overflow-hidden"><div class="shrink-0 px-4 h-10 border-b border-border-weaker-base flex items-center gap-2"><span class="text-12-medium text-text-strong">Entry</span><span class="text-11-regular text-text-weaker font-mono truncate"></span><div class="ml-auto flex items-center gap-1"><button class="flex items-center gap-1 px-2 py-1 rounded-md text-11-medium transition-colors"><span></span></button><button class="flex items-center gap-1 px-2 py-1 rounded-md text-11-medium text-text-weaker hover:text-red-400 hover:bg-red-500/10 transition-colors"title="Delete entry"><span>Delete</span></button></div></div><div class="flex-1 min-h-0 overflow-y-auto"><div class="max-w-2xl mx-auto px-6 py-6 flex flex-col gap-5"><div class="border-t border-border-weaker-base pt-4">'),ED=x('<div class="text-12-regular text-text-weaker italic text-center py-4">No fields yet — add one below to start editing this entry.'),ID=x('<button class="absolute top-0 right-0 text-text-weaker hover:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity"title="Remove field from schema">'),LD=x('<div class="group relative flex flex-col gap-1">'),PD=x('<button class="flex items-center gap-1.5 px-2 py-1.5 rounded-md text-12-medium text-text-weak hover:text-text-base hover:bg-surface-raised-base/40 transition-colors"><span>Add field'),rl=x("<option>");const FD=["text","rich_text","number","boolean","date","email","url","color","select","file","reference","image","video","audio","formula"],RD=["none","daily","weekly","monthly","yearly"],qf={key:"",type:"text",target:"",formula:"",options:"",min:"",max:"",step:"",repeat:"none",required:!1},Wp=[{key:"name",label:"Name",type:"text",required:!0},{key:"slug",label:"Slug",type:"text",required:!0}];function zD(e){return e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,t=>t.toUpperCase())}const jf=e=>e==null||e==="",Ho=e=>Wp.some(t=>t.key===e),il=e=>{const t=Number(e);return e.trim()===""||!Number.isFinite(t)?void 0:t};function Vf(e){return typeof e!="string"?"":e.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function sl(e){const t=new Map(e.map(n=>[n.key,n]));return[...Wp.map(n=>({...t.get(n.key),...n})),...e.filter(n=>!Ho(n.key))]}function OD(e){const t=Dr(),n=e.cache??Ca(t),r=()=>n.facts().get(e.collection.schemaId)??[],i=()=>n.facts().get(e.entryId)??[],o=T(()=>n.entities(e.collection.key)),a=T(()=>{const A=r().find(F=>F.a==="props");return A&&typeof A.v=="string"?A.v:"[]"}),d=T(()=>{try{return JSON.parse(a())}catch{return[]}}),c=T(()=>{const A=new Map;for(const F of o())for(const N of n.facts().get(F.id)??[]){if(N.a==="type"||N.a==="cms_status"||A.has(N.a))continue;let X="text";const B=N.v;typeof B=="boolean"?X="boolean":typeof B=="number"?X="number":typeof B=="string"&&(/^https?:\/\//.test(B)?X="url":/email/i.test(N.a)&&B.includes("@")?X="email":/(date|at)$/i.test(N.a)&&!Number.isNaN(new Date(B).getTime())&&(X="date")),A.set(N.a,{key:N.a,label:N.a.replace(/[_-]+/g," ").replace(/\b\w/g,O=>O.toUpperCase()),type:X})}return Array.from(A.values())}),u=T(()=>{const A=d();return A.length>0?sl(A):e.collection.inferred?sl(c()):sl([])}),[g,f]=St({}),m=new Map,p=A=>A in g?g[A]:i().find(N=>N.a===A)?.v,w=async(A,F,N)=>{const X=(n.facts().get(A)??[]).find(B=>B.a===F);if(X&&!await t.retract([X])){nt({variant:"error",title:`Failed to update "${F}"`});return}if(!jf(N)&&!await t.assert([{e:A,a:F,v:N}])){nt({variant:"error",title:`Failed to save "${F}"`});return}f(Rs(B=>{delete B[F]}))},h=(A,F,N)=>{const X=m.get(F);X&&clearTimeout(X);const B=setTimeout(()=>{w(A,F,N),m.delete(F)},400);m.set(F,B)},k=(A,F)=>{const N=e.entryId;if(A==="name"){const X=p("name"),B=p("slug"),O=Vf(F);(jf(B)||B===Vf(X))&&(f("slug",O||void 0),h(N,"slug",O||void 0))}f(A,F),h(N,A,F)};vt(()=>{const A=e.entryId;for(const[F,N]of m){clearTimeout(N);const X=g[F];w(A,F,X)}m.clear()});const v=(A,F,N,X)=>{const B=[{e:A,a:"type",v:"Field"},{e:A,a:"collection",v:F},{e:A,a:"key",v:N.key},{e:A,a:"label",v:N.label},{e:A,a:"kind",v:N.type},{e:A,a:"order",v:X}];return N.required&&B.push({e:A,a:"required",v:!0}),N.default&&B.push({e:A,a:"default",v:N.default}),N.options&&B.push({e:A,a:"options",v:JSON.stringify(N.options)}),N.formula&&B.push({e:A,a:"formula",v:N.formula}),N.target&&B.push({e:A,a:"target",v:N.target}),N.min!==void 0&&B.push({e:A,a:"min",v:N.min}),N.max!==void 0&&B.push({e:A,a:"max",v:N.max}),N.step!==void 0&&B.push({e:A,a:"step",v:N.step}),N.repeat&&N.repeat!=="none"&&B.push({e:A,a:"repeat",v:N.repeat}),B},C=async A=>{const F=e.collection.schemaId,N=e.collection.key,X=d(),B=new Set(A.map(H=>H.key)),O=[],z=[];r().some(H=>H.a==="type"&&H.v==="TypeSchema")||(z.push({e:F,a:"type",v:"TypeSchema"}),z.push({e:F,a:"label",v:e.collection.label}),z.push({e:F,a:"cms",v:!0}));const Q=r().find(H=>H.a==="props");Q&&O.push(Q),z.push({e:F,a:"props",v:JSON.stringify(A)});for(const H of X){if(B.has(H.key))continue;const J=`field:${N}.${H.key}`;O.push(...n.facts().get(J)??[])}for(const[H,J]of A.entries()){const le=`field:${N}.${J.key}`;O.push(...n.facts().get(le)??[]),z.push(...v(le,F,J,H))}return O.length>0&&!await t.retract(O)?(nt({variant:"error",title:"Failed to update schema"}),!1):await t.assert(z)?!0:(nt({variant:"error",title:"Failed to update schema"}),!1)},y=e.collections??Vc(e.cache),[b,_]=ke(!1),[$,D]=St({...qf}),L=T(()=>y().filter(A=>A.key!==e.collection.key)),V=()=>D({...qf}),K=async()=>{const A=$.key.trim();if(!A){_(!1);return}if(u().some(X=>X.key===A)){V(),_(!1);return}if(Ho(A)){V(),_(!1);return}const F={key:A,label:zD(A),type:$.type},N=$.options.split(",").map(X=>X.trim()).filter(Boolean);$.required&&(F.required=!0),$.type==="reference"&&$.target&&(F.target=$.target),$.type==="formula"&&(F.formula=$.formula.trim()),$.type==="select"&&N.length>0&&(F.options=N),$.type==="number"&&(F.min=il($.min),F.max=il($.max),F.step=il($.step)),$.type==="date"&&$.repeat!=="none"&&(F.repeat=$.repeat),await C([...u(),F]),V(),_(!1)},I=async A=>{Ho(A)||await C(u().filter(F=>F.key!==A))},U=async()=>{const A=i();A.length>0&&await t.retract(A),e.onDelete()},Y=T(()=>i().find(F=>F.a==="cms_status")?.v==="published"?"published":"draft"),S=async()=>{const A=Y()==="published"?"draft":"published",F=i().find(X=>X.a==="cms_status");if(F&&!await t.retract([F])){nt({variant:"error",title:"Failed to update status"});return}if(!await t.assert([{e:e.entryId,a:"cms_status",v:A}])){nt({variant:"error",title:"Failed to update status"});return}nt({variant:"success",title:A==="published"?"Published":"Moved to drafts"})},M=T(()=>{const A=Object.fromEntries(u().map(N=>[N.key,p(N.key)])),F=u().filter(N=>N.type==="formula"&&N.formula?.trim());for(let N=0;N<F.length;N++)for(const X of F)A[X.key]=Js(X.formula??"",A);return A});return(()=>{var A=MD(),F=A.firstChild,N=F.firstChild,X=N.nextSibling,B=X.nextSibling,O=B.firstChild,z=O.firstChild,q=O.nextSibling,Q=q.firstChild,j=F.nextSibling,H=j.firstChild,J=H.firstChild;return l(X,()=>e.entryId),l(F,s(E,{get when(){return Y()==="draft"},get children(){return $D()}}),B),l(F,s(E,{get when(){return Y()==="published"},get children(){return kD()}}),B),O.$$click=()=>void S(),l(O,s(E,{get when(){return Y()==="draft"},get fallback(){return s(Ag,{class:"size-3.5"})},get children(){return s(ki,{class:"size-3.5"})}}),z),l(z,()=>Y()==="draft"?"Publish":"Unpublish"),q.$$click=()=>void U(),l(q,s(zs,{class:"size-3.5"}),Q),l(H,s(E,{get when(){return u().length>0},get fallback(){return ED()},get children(){return s(Oe,{get each(){return u()},children:le=>(()=>{var de=LD();return l(de,s(wD,{def:le,value:()=>le.type==="formula"?M()[le.key]:p(le.key),values:M,onChange:Re=>k(le.key,Re)}),null),l(de,s(E,{get when(){return!Ho(le.key)},get children(){var Re=ID();return Re.$$click=()=>void I(le.key),l(Re,s(Mi,{class:"size-3.5"})),Re}}),null),de})()})}}),J),l(J,s(E,{get when(){return b()},get fallback(){return(()=>{var le=PD(),de=le.firstChild;return le.$$click=()=>_(!0),l(le,s(es,{class:"size-3.5"}),de),le})()},get children(){var le=DD(),de=le.firstChild,Re=de.firstChild,Ve=Re.firstChild,Z=Ve.nextSibling,ne=Re.nextSibling,re=ne.firstChild,ie=re.nextSibling,be=ne.nextSibling,Fe=be.firstChild,ee=be.nextSibling,_e=ee.nextSibling;return Z.$$keydown=xe=>{xe.key==="Enter"&&K(),xe.key==="Escape"&&(V(),_(!1))},Z.$$input=xe=>D("key",xe.currentTarget.value),ie.addEventListener("change",xe=>D("type",xe.currentTarget.value)),l(ie,s(Oe,{each:FD,children:xe=>(()=>{var ye=rl();return ye.value=xe,l(ye,xe),ye})()})),Fe.addEventListener("change",xe=>D("required",xe.currentTarget.checked)),ee.$$click=()=>void K(),_e.$$click=()=>{V(),_(!1)},l(le,s(E,{get when(){return $.type==="reference"},get children(){var xe=_D(),ye=xe.firstChild,Le=ye.nextSibling;return Le.firstChild,Le.addEventListener("change",tt=>D("target",tt.currentTarget.value)),l(Le,s(Oe,{get each(){return L()},children:tt=>(()=>{var ge=rl();return l(ge,()=>tt.label),G(()=>ge.value=tt.key),ge})()}),null),G(()=>Le.value=$.target),xe}}),null),l(le,s(E,{get when(){return $.type==="select"},get children(){var xe=CD(),ye=xe.firstChild,Le=ye.nextSibling;return Le.$$input=tt=>D("options",tt.currentTarget.value),G(()=>Le.value=$.options),xe}}),null),l(le,s(E,{get when(){return $.type==="number"},get children(){var xe=SD(),ye=xe.firstChild,Le=ye.firstChild,tt=Le.nextSibling,ge=ye.nextSibling,qe=ge.firstChild,we=qe.nextSibling,He=ge.nextSibling,Ne=He.firstChild,Ee=Ne.nextSibling;return tt.$$input=rt=>D("min",rt.currentTarget.value),we.$$input=rt=>D("max",rt.currentTarget.value),Ee.$$input=rt=>D("step",rt.currentTarget.value),G(()=>tt.value=$.min),G(()=>we.value=$.max),G(()=>Ee.value=$.step),xe}}),null),l(le,s(E,{get when(){return $.type==="date"},get children(){var xe=TD(),ye=xe.firstChild,Le=ye.nextSibling;return Le.addEventListener("change",tt=>D("repeat",tt.currentTarget.value)),l(Le,s(Oe,{each:RD,children:tt=>(()=>{var ge=rl();return ge.value=tt,l(ge,tt),ge})()})),G(()=>Le.value=$.repeat),xe}}),null),l(le,s(E,{get when(){return $.type==="formula"},get children(){var xe=AD(),ye=xe.firstChild,Le=ye.nextSibling;return Le.$$input=tt=>D("formula",tt.currentTarget.value),G(()=>Le.value=$.formula),xe}}),null),G(()=>Z.value=$.key),G(()=>ie.value=$.type),G(()=>Fe.checked=$.required),le}})),G(le=>{var de={"text-text-weak hover:text-text-base hover:bg-surface-raised-base/40":Y()==="published","text-emerald-400 hover:text-emerald-300 hover:bg-emerald-500/10":Y()==="draft"},Re=Y()==="published"?"Move back to drafts":"Publish entry";return le.e=Tt(O,de,le.e),Re!==le.t&&ue(O,"title",le.t=Re),le},{e:void 0,t:void 0}),A})()}Kt(["click","input","keydown"]);var ND=x('<div class="flex flex-col items-center justify-center gap-4 py-12"><div class=relative><div class="size-12 rounded-full border-2 border-surface-raised-base/20 border-t-border-base border-t-solid animate-spin"></div><div class="absolute inset-0 flex items-center justify-center"><div class="size-4 rounded-full bg-gradient-to-br from-emerald-500 to-blue-600 animate-pulse"></div></div></div><div class="flex flex-col items-center gap-2"><span class="text-13-medium text-text-base"></span><div class="flex gap-1.5"><div class="w-1.5 h-1.5 rounded-full bg-text-weaker/40 animate-pulse"style=animation-delay:0ms></div><div class="w-1.5 h-1.5 rounded-full bg-text-weaker/40 animate-pulse"style=animation-delay:150ms></div><div class="w-1.5 h-1.5 rounded-full bg-text-weaker/40 animate-pulse"style=animation-delay:300ms>'),BD=x('<div class="shrink-0 flex items-center gap-2 border-b border-border-weaker-base px-4 py-2.5"><div class="size-2.5 rounded-full bg-blue-500/60 animate-pulse"></div><span class="text-12-regular text-text-weaker">'),qD=x('<div class="flex h-full min-h-0 flex-col overflow-hidden"><div class="shrink-0 border-b border-border-weaker-base px-3 py-2"><div class="flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between"><div class="flex min-w-0 flex-1 items-center gap-1.5 rounded-md bg-surface-raised-base/40 px-2 py-1.5"><div class="size-3.5 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="flex-1 h-3 rounded bg-surface-raised-base/30 animate-pulse"></div></div><div class="flex shrink-0 items-center gap-2"><div class="w-16 h-6 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="w-16 h-6 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="w-16 h-6 rounded bg-surface-raised-base/40 animate-pulse"></div></div></div></div><div class="min-h-0 flex-1 overflow-auto"><div class=min-w-[720px]><div class="sticky top-0 z-10 grid h-9 items-center border-b border-border-weaker-base bg-background-base/95 px-3 backdrop-blur"style="grid-template-columns:36px minmax(220px, 1.8fr) 92px minmax(140px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr) 92px"><div class="flex items-center justify-center"><div class="size-3.5 rounded bg-surface-raised-base/40 animate-pulse"></div></div><div class="h-3 w-12 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="h-3 w-12 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="h-3 w-16 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="h-3 w-20 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="h-3 w-16 rounded bg-surface-raised-base/40 animate-pulse"></div><div class="h-3 w-8 rounded bg-surface-raised-base/40 animate-pulse"></div></div><div class=relative style=height:340px>'),jD=x('<div class="absolute left-0 right-0 px-2 border-b border-border-weaker-base/20"style=height:42px><div class="grid h-full w-full items-center px-2"style="grid-template-columns:36px minmax(220px, 1.8fr) 92px minmax(140px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr) 92px"><div class="flex items-center justify-center"><div class="size-3.5 rounded bg-surface-raised-base/30 animate-pulse"></div></div><div class="flex items-center gap-2"><div class="size-3.5 rounded bg-surface-raised-base/30 animate-pulse"></div><div class="flex-1 h-3 rounded bg-surface-raised-base/20 animate-pulse"></div></div><div class="w-12 h-4 rounded bg-surface-raised-base/30 animate-pulse"></div><div class="h-3 w-20 rounded bg-surface-raised-base/20 animate-pulse"></div><div class="h-3 w-16 rounded bg-surface-raised-base/20 animate-pulse"></div><div class="h-3 w-24 rounded bg-surface-raised-base/20 animate-pulse"></div><div class="h-3 w-12 rounded bg-surface-raised-base/20 animate-pulse">'),VD=x('<div class="flex min-w-0 flex-1 flex-col">'),HD=x('<div class="flex flex-1 items-center justify-center">'),UD=x('<div class="flex items-center gap-0.5 opacity-50"><div class="size-1 rounded-full bg-text-weaker animate-pulse"></div><div class="size-1 rounded-full bg-text-weaker animate-pulse"style=animation-delay:150ms></div><div class="size-1 rounded-full bg-text-weaker animate-pulse"style=animation-delay:300ms>'),WD=x('<button class="flex items-center gap-1.5 rounded-md bg-surface-raised-base px-2.5 py-1.5 text-12-medium text-text-base hover:bg-surface-raised-base/80"><span>New entry'),KD=x('<button class="text-text-weaker hover:text-text-base"title=Close>'),GD=x('<div class="flex h-full items-center justify-center text-12-regular text-text-weaker">Loading entry…');function YD(e){return(()=>{var t=ND(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,o=i.nextSibling,a=o.firstChild,d=a.nextSibling;return d.nextSibling,l(i,()=>e.label),t})()}function XD(e){return(()=>{var t=qD(),n=t.firstChild,r=n.nextSibling,i=r.firstChild,o=i.firstChild,a=o.nextSibling;return l(t,s(E,{get when(){return e.label},get children(){var d=BD(),c=d.firstChild,u=c.nextSibling;return l(u,()=>e.label),d}}),n),l(a,s(Oe,{get each(){return Array.from({length:8})},children:(d,c)=>(()=>{var u=jD();return u.firstChild,G(g=>Je(u,"top",`${c()*42}px`)),u})()})),t})()}function Hf(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(36).slice(2,10)}function ZD(){const e=Dr(),t=Ca(e),n=Vc(t),[r,i]=ke(null),[o,a]=ke(null),[d,c]=ke(null),[u,g]=ke(null),f=ds("(max-width: 1023px)");$e(()=>{const b=r();if(c(null),g(null),a(null),!b)return;const _=requestAnimationFrame(()=>{r()===b&&a(b)});vt(()=>cancelAnimationFrame(_))}),$e(()=>{const b=d();if(g(null),!b)return;const _=requestAnimationFrame(()=>{d()===b&&g(b)});vt(()=>cancelAnimationFrame(_))}),$e(()=>{const b=_=>{const $=_.detail;$&&($.collection&&i($.collection),$.entry&&c($.entry))};window.addEventListener("cms-navigate",b),vt(()=>window.removeEventListener("cms-navigate",b))});const m=(b,_)=>b===_?!0:!b||!_?!1:b.key===_.key&&b.label===_.label&&b.count===_.count,p=T(()=>{const b=r();return b?n().find(_=>_.key===b)??null:null},null,{equals:m}),w=T(()=>{const b=o();return b?n().find(_=>_.key===b)??null:null},null,{equals:m}),h=async b=>{const _=b.trim().toLowerCase().replace(/\s+/g,"_");if(!_)return;const $=`schema:${_}`;if(!await e.assert([{e:$,a:"type",v:"TypeSchema"},{e:$,a:"label",v:_},{e:$,a:"props",v:"[]"},{e:$,a:"color",v:Ai(_)},{e:$,a:"icon",v:Di(_)},{e:$,a:"cms",v:!0}])){nt({variant:"error",title:`Failed to create collection "${_}"`});return}i(_)},k=async()=>{const b=p();if(!b)return;const _=`${b.key}:${Hf()}`,$=new Date().toISOString();if(!await e.assert([{e:_,a:"type",v:b.canonicalType},{e:_,a:"cms_status",v:"draft"},{e:_,a:"createdAt",v:$},{e:_,a:"createdBy",v:"user"},{e:_,a:"lastEdited",v:$}])){nt({variant:"error",title:"Failed to create entry"});return}c(_)},v=async b=>{const _=e.entities.filter(K=>Ei(K.type,b)),$=_.length>0?`Delete collection "${b}" and ${_.length} ${_.length===1?"entry":"entries"}?`:`Delete collection "${b}"?`;if(!window.confirm($))return;const D=`schema:${b}`,L=`field:${b}.`,V=e.facts.filter(K=>K.e===D||K.e.startsWith(L)||_.some(I=>K.e===I.id));if(V.length>0&&!await e.retract(V)){nt({variant:"error",title:`Failed to delete collection "${b}"`});return}r()===b&&i(null)},C=async b=>{const _=e.facts.filter($=>$.e===b);if(_.length>0&&!await e.retract(_)){nt({variant:"error",title:"Failed to delete entry"});return}d()===b&&c(null)},y=async b=>{const _=p();if(!_)return;const $=`${_.key}:${Hf()}`,D=new Date().toISOString(),L=e.facts.filter(I=>I.e===b&&I.a!=="lastEdited");if(L.length===0)return;const V=L.map(I=>(I.a==="name"||I.a==="title")&&typeof I.v=="string"?{e:$,a:I.a,v:`${I.v} (Copy)`}:{e:$,a:I.a,v:I.v});if(V.push({e:$,a:"lastEdited",v:D}),!await e.assert(V)){nt({variant:"error",title:"Failed to duplicate entry"});return}c($)};return s(Rc,{get children(){return s(zc,{get compact(){return f()},get children(){return[s(OA,{width:224,get compact(){return f()},cache:t,collections:n,get selected(){return r()},onSelect:i,onCreate:h,onDelete:v}),(()=>{var b=VD();return l(b,s(E,{get when(){return e.ready},get fallback(){return s(XD,{label:"Loading store…"})},get children(){return s(E,{get when(){return p()},keyed:!0,get fallback(){return s(Pp,{get icon(){return s(Dg,{class:"size-8"})},title:"Select a collection",description:"Pick a collection from the sidebar, or create a new one to get started."})},children:_=>s(E,{get when(){return w()},keyed:!0,get fallback(){return(()=>{var $=HD();return l($,s(YD,{get label(){return`Loading ${_.label}…`}})),$})()},children:$=>[s(Oc,{get title(){return $.label},get meta(){return`${$.count} entries`},get actions(){return[s(E,{get when(){return e.loading},get children(){var D=UD(),L=D.firstChild,V=L.nextSibling;return V.nextSibling,D}}),(()=>{var D=WD(),L=D.firstChild;return D.$$click=()=>void k(),l(D,s(es,{class:"size-3.5"}),L),D})()]}}),s(Nc,{scroll:!1,get children(){return s(O7,{get compact(){return f()},cache:t,collection:$,get selected(){return d()},onSelect:c,onCreate:k,onDelete:C,onDuplicate:y})}})]})})}})),b})(),s(E,{get when(){return w()},keyed:!0,children:b=>s(E,{get when(){return d()},get children(){return s(e6,{get side(){return f()?"bottom":"right"},width:440,flush:!0,title:"Entry",get actions(){return(()=>{var _=KD();return _.$$click=()=>c(null),l(_,s(Mi,{class:"size-3.5"})),_})()},get children(){return s(E,{get when(){return u()},keyed:!0,get fallback(){return GD()},children:_=>s(OD,{entryId:_,collection:b,cache:t,collections:n,onDelete:()=>c(null)})})}})}})})]}})}})}function QD(){return s(Xl,{get children(){return s(ZD,{})}})}Kt(["click"]);var JD=x('<form class="flex flex-col gap-4 p-6 pt-0"><textarea autofocus rows=4 placeholder="A cute turtle riding a snowboard down a snowy slope..."class="w-full bg-surface-raised-base border border-border-weaker-base rounded-md px-3 py-2 text-13-regular resize-none focus:ring-1 focus:ring-primary-base"></textarea><div class="flex justify-end gap-2">'),eM=x('<div class="text-12-regular text-text-destructive">');function tM(e){const t=dr(),[n,r]=ke(""),[i,o]=ke(!1),[a,d]=ke();async function c(u){u.preventDefault();const g=n().trim();if(!(!g||i())){o(!0),d(void 0);try{await e.onGenerate(g),t.close()}catch(f){d(f instanceof Error?f.message:String(f))}finally{o(!1)}}}return s(no,{title:"Generate image asset",description:"Describe the image you want. It will be saved to .trellis/media.",class:"w-full max-w-[480px] mx-auto",get children(){var u=JD(),g=u.firstChild,f=g.nextSibling;return u.addEventListener("submit",c),g.$$input=m=>{r(m.currentTarget.value),d(void 0)},l(u,(()=>{var m=Te(()=>!!a());return()=>m()?(()=>{var p=eM();return l(p,a),p})():null})(),f),l(f,s(kt,{type:"button",variant:"ghost",size:"large",onClick:()=>t.close(),children:"Cancel"}),null),l(f,s(kt,{type:"submit",variant:"primary",size:"large",get disabled(){return i()||!n().trim()},get children(){return i()?"Generating...":"Generate"}}),null),G(()=>g.value=n()),u}})}Kt(["input"]);var nM=x("<img>"),rM=x('<div class="flex flex-col items-center gap-2 text-text-weaker px-3 text-center"><span class="text-10-medium uppercase tracking-wider break-all">'),iM=x('<div class="flex flex-col items-center gap-2 text-text-weaker group-hover:scale-110 transition-transform duration-300 px-2 text-center"><span class="text-10-medium uppercase tracking-wider">'),sM=x('<div class=relative><input type=text placeholder="Search assets..."class="h-7 pl-8 pr-3 bg-surface-raised-base border-none rounded-md text-12-regular w-48 focus:ring-1 focus:ring-primary-base transition-all">'),oM=x("<div class=asset-grid>"),aM=x('<div class="flex flex-col gap-2 p-6">'),lM=x('<div class=design-panel><input type=file class=hidden><div class=design-sidebar><div class="h-10 flex items-center px-3 border-b border-border-weaker-base shrink-0"><span class="text-xs font-medium text-text-weak opacity-80 uppercase tracking-wider">Design</span></div><div class="design-sidebar-items flex-1 overflow-y-auto p-2 flex flex-col gap-0.5"></div></div><div class=design-content><div class=design-header><div class="flex items-center gap-4"><h2 class="text-12-medium text-text-strong uppercase tracking-wide"></h2></div><div class="flex items-center gap-2"></div></div><div class="flex-1 overflow-y-auto"><div class="section-content-enter max-w-5xl mx-auto w-full">'),cM=x('<button class="stagger-item design-section-btn">'),dM=x('<div class="py-20 flex flex-col items-center justify-center gap-4 animate-in fade-in zoom-in-95 duration-300"><div class="size-16 rounded-full bg-surface-raised-base flex items-center justify-center text-text-weaker"></div><div class=text-center><div class="text-16-medium text-text-base mb-1">No <!> yet</div><div class="text-14-regular text-text-weaker max-w-[320px]">'),uM=x('<div class="stagger-item asset-card group"><div class=asset-preview></div><div class=asset-info><div class="text-12-medium text-text-base truncate mb-0.5"></div><div class="text-10-regular text-text-weaker flex items-center justify-between"><span></span><span>'),fM=x('<div class="text-10-regular text-text-weaker truncate mb-1">'),gM=x('<div class="stagger-item flex items-center justify-between p-3 bg-surface-raised-base rounded-lg border border-border-weaker-base hover:border-border-base transition-all group"><div class="flex items-center gap-3"><div class="size-8 rounded bg-background-base flex items-center justify-center text-text-weak border border-border-weaker-base"></div><div><div class="text-13-medium text-text-base"></div><div class="text-11-regular text-text-weaker">'),mM=x('<div><label class="text-11-medium text-text-weaker uppercase mb-1.5 block">Palette</label><div class="flex flex-wrap gap-1.5">'),hM=x('<div><label class="text-11-medium text-text-weaker uppercase mb-1.5 block">Tone</label><div class="text-12-regular text-text-base break-words">'),pM=x('<div><label class="text-11-medium text-text-weaker uppercase mb-1.5 block">Tags</label><div class="text-12-regular text-text-base break-words">'),vM=x('<div><label class="text-11-medium text-text-weaker uppercase mb-1.5 block">Transcript</label><textarea rows=3 readonly class="w-full bg-surface-raised-base border border-border-weaker-base rounded px-2 py-1.5 text-12-regular resize-none">'),bM=x('<div class=detail-sidebar><div class="h-12 flex items-center justify-between px-4 border-b border-border-weaker-base shrink-0"><span class="text-13-semibold text-text-base">Asset Details</span></div><div class="flex-1 overflow-y-auto p-4 flex flex-col gap-6"><div class="aspect-square rounded-lg bg-background-base border border-border-weaker-base flex items-center justify-center overflow-hidden shrink-0"></div><div class="flex flex-col gap-4"><div><label class="text-11-medium text-text-weaker uppercase mb-1.5 block">File Name</label><div class="text-13-regular text-text-base break-all"></div></div><div><label class="text-11-medium text-text-weaker uppercase mb-1.5 block">Title</label><input type=text placeholder="Add a title..."class="w-full bg-surface-raised-base border border-border-weaker-base rounded px-2 py-1.5 text-13-regular"></div><div><label class="text-11-medium text-text-weaker uppercase mb-1.5 block">Alt Text</label><textarea rows=2 placeholder="Describe for accessibility..."class="w-full bg-surface-raised-base border border-border-weaker-base rounded px-2 py-1.5 text-13-regular resize-none"></textarea></div><div><div class="flex items-center justify-between mb-1.5"><label class="text-11-medium text-text-weaker uppercase">Description</label></div><textarea rows=4 placeholder="Semantic description for agents and CMS..."class="w-full bg-surface-raised-base border border-border-weaker-base rounded px-2 py-1.5 text-12-regular resize-none"></textarea></div><div class="grid grid-cols-2 gap-4 pt-2 border-t border-border-weaker-base"><div><label class="text-11-medium text-text-weaker uppercase mb-1 block">Size</label><div class="text-12-regular text-text-base"></div></div><div><label class="text-11-medium text-text-weaker uppercase mb-1 block">Type</label><div class="text-12-regular text-text-base uppercase"></div></div></div></div></div><div class="p-4 border-t border-border-weaker-base flex flex-col gap-2">'),xM=x('<audio controls class="w-full px-4">'),yM=x('<div class="flex flex-col items-center gap-2 text-text-weaker p-4"><span class="text-12-medium uppercase tracking-wider">'),wM=x('<div class="flex items-center gap-1.5 border border-border-weaker-base bg-surface-raised-base rounded px-1.5 py-1 min-w-0"><span class="text-11-regular text-text-base font-mono truncate">'),$M=x('<span class="size-4 shrink-0 rounded-sm border border-border-weaker-base">');const Ir=e=>e==="assets"||e==="models"||e==="audio",Uf=(e,t)=>e==="assets"?t.category==="image"||t.category==="video":e==="models"?t.category==="model3d"||t.category==="texture":t.category==="audio",kM=e=>e==="assets"?"image/*,video/*":e==="models"?".glb,.gltf,.obj,.fbx,.usdz,.stl,.ply,.dae,.blend,.usd,.abc,.hdr,.exr,.ktx,.ktx2,.dds,.tga,.psd":"audio/*",_M=e=>{const t=e.toLowerCase();return["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"].includes(t)?"image":["glb","gltf","obj","fbx","usdz","stl","ply","dae","blend","usd","abc"].includes(t)?"model3d":["hdr","exr","ktx","ktx2","dds","tga","psd"].includes(t)?"texture":["mp4","m4v","mov","webm","ogv","avi","mkv"].includes(t)?"video":["mp3","wav","ogg","flac","aac","m4a","opus"].includes(t)?"audio":"other"};function Kp(e){const[t,n]=ke(!0);return s(E,{get when(){return t()},get fallback(){return(()=>{var r=rM(),i=r.firstChild;return l(r,s(Mg,{class:"size-8"}),i),l(i,()=>e.name),r})()},get children(){var r=nM();return r.addEventListener("error",()=>n(!1)),r.addEventListener("load",i=>{i.currentTarget.naturalWidth===0&&n(!1)}),G(i=>{var o=e.src,a=e.name,d=e.class;return o!==i.e&&ue(r,"src",i.e=o),a!==i.t&&ue(r,"alt",i.t=a),d!==i.a&&Ht(r,i.a=d),i},{e:void 0,t:void 0,a:void 0}),r}})}function CM(e){return s(E,{get when(){return e.asset.category==="image"},get fallback(){return(()=>{var t=iM(),n=t.firstChild;return l(t,s(E,{get when(){return e.asset.category==="video"},get fallback(){return s(E,{get when(){return e.asset.category==="audio"},get fallback(){return s(E,{get when(){return e.asset.category==="model3d"||e.asset.category==="texture"},get fallback(){return s(Lg,{class:"size-8"})},get children(){return s(ul,{class:"size-8"})}})},get children(){return s(Eg,{class:"size-8"})}})},get children(){return s(Ig,{class:"size-8"})}}),n),l(n,()=>e.asset.ext),t})()},get children(){return s(Kp,{get src(){return e.raw(e.asset.path)},get name(){return e.asset.name},class:"size-full object-contain group-hover:scale-110 transition-transform duration-500 ease-out"})}})}function SM(){const e=zn(),t=dr(),n=Dr(),[r,i]=ke("assets"),[o,a]=ke(""),[d,c]=ke([]),u=async()=>{const z=await e.fetch(`${e.url}/file/media/list?directory=${encodeURIComponent(e.directory)}`);return z.ok?await z.json():[]},[g,{refetch:f}]=Yl(u);$e(()=>{const z=e.event.listen(q=>{if(q.details.type!=="file.watcher.updated")return;const Q=q.details.properties;Q.file?.replace(/^\/+/,"")?.includes(".trellis/media")&&(Q.event==="add"||Q.event==="change"||Q.event==="unlink")&&f()});vt(z)});const m=T(()=>{const z=g()??[];return[...d().filter(Q=>!z.some(j=>j.path===Q.path)),...z]}),[p,w]=ke(null),[h,k]=ke(!1),[v,C]=ke(!1),y=T(()=>n.entities.filter(z=>z.type==="DesignComponent")),b=T(()=>n.entities.filter(z=>z.type==="DesignToken")),_=()=>{const z=o().toLowerCase();if(Ir(r())){const q=m().filter(Q=>Uf(r(),Q));return z?q.filter(Q=>Q.name.toLowerCase().includes(z)||Q.path.toLowerCase().includes(z)||Q.title?.toLowerCase().includes(z)||Q.description?.toLowerCase().includes(z)||Q.tone?.toLowerCase().includes(z)||Q.tags?.some(j=>j.toLowerCase().includes(z))):q}if(r()==="components"){const q=y();return z?q.filter(Q=>n.facts.find(H=>H.e===Q.id&&H.a==="label")?.v?.toLowerCase().includes(z)):q}if(r()==="tokens"){const q=b();return z?q.filter(Q=>n.facts.find(H=>H.e===Q.id&&H.a==="label")?.v?.toLowerCase().includes(z)):q}return[]},$=[{id:"assets",label:"Assets",icon:Mg,description:"Images, icons, and visual media."},{id:"models",label:"Models",icon:ul,description:"3D models, meshes, and texture maps."},{id:"audio",label:"Audio",icon:Eg,description:"Sound effects, music, and voice clips."},{id:"components",label:"Components",icon:od,description:"Reusable UI components and elements."},{id:"patterns",label:"Patterns",icon:f0,description:"Common layouts and interaction patterns."},{id:"tokens",label:"Tokens",icon:ad,description:"Design tokens like colors, typography, and spacing."},{id:"bindings",label:"CMS Bindings",icon:Dg,description:"Map CMS fields to component properties."}],D=z=>{if(!z)return"0 B";const q=1024,Q=["B","KB","MB","GB"],j=Math.floor(Math.log(z)/Math.log(q));return parseFloat((z/Math.pow(q,j)).toFixed(1))+" "+Q[j]},L=z=>`${e.url}/file/raw?path=${encodeURIComponent(z)}&directory=${encodeURIComponent(e.directory)}`,V=z=>z.title?.trim()||z.name,K=z=>z.description?.trim()||z.alt?.trim()||z.tone?.trim(),I=z=>/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(z.trim())?z.trim():void 0,U=(z,q)=>{c(j=>j.map(H=>H.path===z?{...H,...q}:H));const Q=p();Q?.path===z&&w({...Q,...q})},Y=async(z,q=!1)=>{const Q=await e.fetch(`${e.url}/file/media/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:z.path,force:q})});if(!Q.ok)return;const j=await Q.json();!j.description&&!j.tone&&!j.tags?.length&&!j.palette?.length||(U(z.path,j),await f())},S=async()=>{if(Ir(r())){O?.click();return}const z=window.prompt(`Enter ${r().slice(0,-1)} name:`);if(!z)return;const q=`design:${r()}:${Date.now()}`,Q=r()==="components"?"DesignComponent":"DesignToken";await n.assert([{e:q,a:"type",v:Q},{e:q,a:"label",v:z},{e:q,a:"createdAt",v:new Date().toISOString()}])?nt({title:`${r().slice(0,-1)} added`}):nt({variant:"error",title:"Failed to add item"})},M=async z=>{if(!confirm("Delete this item?"))return;const q=n.facts.filter(j=>j.e===z);await n.retract(q)&&nt({title:"Item deleted"})},A=async z=>{const q=z.target;if(!q.files?.length)return;const Q=q.files[0],j=new FormData;j.append("file",Q),j.append("path",".trellis/media");try{const H=await e.fetch(`${e.url}/file/upload?directory=${encodeURIComponent(e.directory)}`,{method:"POST",body:j});if(H.ok){const J=await H.json(),le=J.path.split(".").pop()?.toLowerCase()??"bin",de={path:J.path,name:J.path.split("/").pop()??Q.name,ext:le,category:_M(le),size:J.size};c(Re=>[de,...Re]),w(de),nt({title:"Asset uploaded"}),await f(),Y(de).catch(()=>{})}else{const J=await H.json();nt({variant:"error",title:"Upload failed",description:J.error})}}catch(H){nt({variant:"error",title:"Upload failed",description:String(H)})}finally{q.value=""}},F=async z=>{const q=p();if(q){k(!0);try{(await e.fetch(`${e.url}/file/media/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:q.path,...z})})).ok?(nt({title:"Metadata updated"}),U(q.path,z),await f()):nt({variant:"error",title:"Update failed"})}catch(Q){nt({variant:"error",title:"Update failed",description:String(Q)})}finally{k(!1)}}},N=async()=>{const z=p();if(z){k(!0);try{await Y(z,!0),nt({title:"Metadata generated"})}catch{nt({variant:"error",title:"Generation failed"})}finally{k(!1)}}},X=async z=>{C(!0);try{const q=await e.fetch(`${e.url}/file/media/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:z,provider:"auto",size:"1024x1024",output_format:"png"})});if(!q.ok){const j=await q.json().catch(()=>({error:"Generation failed"}));throw new Error(j.error??"Generation failed")}const Q=await q.json();c(j=>[Q,...j]),i("assets"),w(Q),nt({title:"Image asset generated",description:Q.name}),await f()}finally{C(!1)}},B=()=>{t.show(()=>s(tM,{onGenerate:X}))};let O;return $e(()=>{const z=r();!Ir(z)||!O||(O.accept=kM(z))}),(()=>{var z=lM(),q=z.firstChild,Q=q.nextSibling,j=Q.firstChild,H=j.nextSibling,J=Q.nextSibling,le=J.firstChild,de=le.firstChild,Re=de.firstChild,Ve=de.nextSibling,Z=le.nextSibling,ne=Z.firstChild;q.addEventListener("change",A);var re=O;return typeof re=="function"?Lt(re,q):O=q,l(H,s(Oe,{each:$,children:(ie,be)=>(()=>{var Fe=cM();return Fe.$$click=()=>{i(ie.id),w(null)},l(Fe,s(ie.icon,{class:"size-4 opacity-70"}),null),l(Fe,()=>ie.label,null),G(ee=>{var _e=`${be()*50}ms`,xe=r()===ie.id;return _e!==ee.e&&Je(Fe,"animation-delay",ee.e=_e),xe!==ee.t&&Fe.classList.toggle("active",ee.t=xe),ee},{e:void 0,t:void 0}),Fe})()})),l(Re,()=>$.find(ie=>ie.id===r())?.label),l(de,s(E,{get when(){return Ir(r())},get children(){var ie=sM(),be=ie.firstChild;return l(ie,s(g0,{class:"absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-text-weaker"}),be),be.$$input=Fe=>a(Fe.currentTarget.value),G(()=>be.value=o()),ie}}),null),l(Ve,s(E,{get when(){return Ir(r())},get children(){return s(kt,{size:"small",variant:"secondary",onClick:()=>f(),children:"Refresh"})}}),null),l(Ve,s(E,{get when(){return r()==="assets"},get children(){return s(kt,{size:"small",variant:"secondary",onClick:B,get disabled(){return v()},get children(){return[s(Zl,{class:"size-3.5 mr-1.5"}),Te(()=>v()?"Generating...":"Generate")]}})}}),null),l(Ve,s(kt,{size:"small",variant:"primary",onClick:S,get children(){return[s(es,{class:"size-3.5 mr-1.5"}),"Add ",Te(()=>Te(()=>!!Ir(r()))()?"Asset":r().slice(0,-1))]}}),null),l(ne,s(E,{get when(){return Te(()=>!!Ir(r()))()&&_().length>0||r()==="components"&&y().length>0||r()==="tokens"&&b().length>0},get fallback(){return(()=>{var ie=dM(),be=ie.firstChild,Fe=be.nextSibling,ee=Fe.firstChild,_e=ee.firstChild,xe=_e.nextSibling;xe.nextSibling;var ye=ee.nextSibling;return l(be,()=>{const Le=$.find(tt=>tt.id===r())?.icon;return s(Le,{class:"size-8"})}),l(ee,r,xe),l(ye,()=>r()==="assets"&&"Images and visual media in .trellis/media will appear here.",null),l(ye,()=>r()==="models"&&"Upload GLB, GLTF, OBJ, HDR, and other 3D or texture files.",null),l(ye,()=>r()==="audio"&&"Upload MP3, WAV, and other audio files for your project.",null),l(ye,()=>r()==="components"&&"Components defined in your project will appear here.",null),l(ye,()=>r()==="patterns"&&"Patterns help you build consistent layouts quickly.",null),l(ye,()=>r()==="tokens"&&"Centralize your styling with theme-aware tokens.",null),l(ye,()=>r()==="bindings"&&"Link your data to your design visually.",null),l(ie,s(E,{get when(){return Ir(r())||r()==="components"||r()==="tokens"},get children(){return s(kt,{variant:"secondary",class:"mt-2",onClick:S,get children(){return["Add your first ",Te(()=>Te(()=>!!Ir(r()))()?"asset":r().slice(0,-1))]}})}}),null),ie})()},get children(){return[s(E,{get when(){return Ir(r())},get children(){var ie=oM();return l(ie,s(Oe,{get each(){return _()},children:(be,Fe)=>(()=>{var ee=uM(),_e=ee.firstChild,xe=_e.nextSibling,ye=xe.firstChild,Le=ye.nextSibling,tt=Le.firstChild,ge=tt.nextSibling;return ee.$$click=()=>w(be),l(_e,s(CM,{asset:be,raw:L})),l(ye,()=>V(be)),l(xe,s(E,{get when(){return K(be)},children:qe=>(()=>{var we=fM();return l(we,qe),G(()=>ue(we,"title",qe())),we})()}),Le),l(tt,()=>be.ext.toUpperCase()),l(ge,()=>D(be.size)),G(qe=>{var we=`${Fe()*30}ms`,He=p()?.path===be.path,Ne=V(be);return we!==qe.e&&Je(ee,"animation-delay",qe.e=we),He!==qe.t&&ee.classList.toggle("selected",qe.t=He),Ne!==qe.a&&ue(ye,"title",qe.a=Ne),qe},{e:void 0,t:void 0,a:void 0}),ee})()})),ie}}),s(E,{get when(){return r()==="components"||r()==="tokens"},get children(){var ie=aM();return l(ie,s(Oe,{get each(){return _()},children:(be,Fe)=>(()=>{var ee=gM(),_e=ee.firstChild,xe=_e.firstChild,ye=xe.nextSibling,Le=ye.firstChild,tt=Le.nextSibling;return l(xe,s(E,{get when(){return r()==="components"},get fallback(){return s(ad,{class:"size-4"})},get children(){return s(od,{class:"size-4"})}})),l(Le,()=>n.facts.find(ge=>ge.e===be.id&&ge.a==="label")?.v),l(tt,()=>be.id),l(ee,s(Ot,{icon:"trash-2",variant:"ghost",size:"small",class:"opacity-0 group-hover:opacity-100 transition-opacity text-text-destructive",onClick:()=>M(be.id)}),null),G(ge=>Je(ee,"animation-delay",`${Fe()*20}ms`)),ee})()})),ie}})]}})),l(z,s(E,{get when(){return p()},children:ie=>s(E,{get when(){return Te(()=>!!Ir(r()))()&&Uf(r(),ie())},get children(){var be=bM(),Fe=be.firstChild;Fe.firstChild;var ee=Fe.nextSibling,_e=ee.firstChild,xe=_e.nextSibling,ye=xe.firstChild,Le=ye.firstChild,tt=Le.nextSibling,ge=ye.nextSibling,qe=ge.firstChild,we=qe.nextSibling,He=ge.nextSibling,Ne=He.firstChild,Ee=Ne.nextSibling,rt=He.nextSibling,ct=rt.firstChild;ct.firstChild;var zt=ct.nextSibling,xt=rt.nextSibling,st=xt.firstChild,gt=st.firstChild,$n=gt.nextSibling,Ce=st.nextSibling,Dt=Ce.firstChild,lt=Dt.nextSibling,At=ee.nextSibling;return l(Fe,s(Ot,{icon:"plus",variant:"ghost",size:"small",class:"rotate-45",onClick:()=>w(null)}),null),l(_e,s(E,{get when(){return ie().category==="image"},get fallback(){return s(E,{get when(){return ie().category==="audio"},get fallback(){return(()=>{var wt=yM(),It=wt.firstChild;return l(wt,s(E,{get when(){return ie().category==="model3d"||ie().category==="texture"},get fallback(){return s(E,{get when(){return ie().category==="video"},get fallback(){return s(Lg,{class:"size-12"})},get children(){return s(Ig,{class:"size-12"})}})},get children(){return s(ul,{class:"size-12"})}}),It),l(It,()=>ie().ext),wt})()},get children(){var wt=xM();return G(()=>ue(wt,"src",L(ie().path))),wt}})},get children(){return s(Kp,{get src(){return L(ie().path)},get name(){return ie().name},class:"size-full object-contain"})}})),l(tt,()=>ie().name),we.addEventListener("blur",wt=>F({title:wt.currentTarget.value})),Ee.addEventListener("blur",wt=>F({alt:wt.currentTarget.value})),l(ct,s(Ot,{icon:"palette",variant:"ghost",size:"small",onClick:N,get disabled(){return h()}}),null),zt.addEventListener("blur",wt=>F({description:wt.currentTarget.value})),l(xe,s(E,{get when(){return ie().palette?.length},get children(){var wt=mM(),It=wt.firstChild,W=It.nextSibling;return l(W,s(Oe,{get each(){return ie().palette},children:oe=>(()=>{var me=wM(),he=me.firstChild;return l(me,s(E,{get when(){return I(oe)},children:Ie=>(()=>{var Ae=$M();return G(De=>Je(Ae,"background-color",Ie())),Ae})()}),he),l(he,oe),me})()})),wt}}),xt),l(xe,s(E,{get when(){return ie().tone},get children(){var wt=hM(),It=wt.firstChild,W=It.nextSibling;return l(W,()=>ie().tone),wt}}),xt),l(xe,s(E,{get when(){return ie().tags?.length},get children(){var wt=pM(),It=wt.firstChild,W=It.nextSibling;return l(W,()=>ie().tags?.join(", ")),wt}}),xt),l(xe,s(E,{get when(){return ie().transcript},get children(){var wt=vM(),It=wt.firstChild,W=It.nextSibling;return G(()=>W.value=ie().transcript||""),wt}}),xt),l($n,()=>D(ie().size)),l(lt,()=>ie().ext),l(At,s(kt,{variant:"secondary",class:"w-full text-text-destructive hover:bg-red-500/10",onClick:async()=>{confirm("Delete this asset?")&&(await e.fetch(`${e.url}/file/delete?directory=${encodeURIComponent(e.directory)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ie().path})}),w(null),c(wt=>wt.filter(It=>It.path!==ie().path)),await f())},children:"Delete Asset"})),G(()=>we.value=ie().title||""),G(()=>Ee.value=ie().alt||""),G(()=>zt.value=ie().description||""),be}})}),null),z})()}function TM(){return s(Xl,{get children(){return s(SM,{})}})}Kt(["input","click"]);const AM=e=>{if(!(e.scrollWidth<=e.prevScrollWidth)){if(!e.prevContextOpen&&e.contextOpen)return 0;if(!(e.scrollWidth<=e.clientWidth))return e.scrollWidth-e.clientWidth}},DM=e=>{let t,n=e.el.scrollWidth,r=e.contextOpen();const i=()=>{const c=e.el.scrollWidth,u=e.el.clientWidth,g=e.contextOpen(),f=AM({prevScrollWidth:n,scrollWidth:c,clientWidth:u,prevContextOpen:r,contextOpen:g});f!==void 0&&e.el.scrollTo({left:f,behavior:"smooth"}),n=c,r=g},o=()=>{t!==void 0&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{t=void 0,i()})},a=c=>{Math.abs(c.deltaY)<=Math.abs(c.deltaX)||(e.el.scrollLeft+=c.deltaY>0?50:-50,c.preventDefault())};e.el.addEventListener("wheel",a,{passive:!1});const d=new MutationObserver(o);return d.observe(e.el,{childList:!0}),()=>{e.el.removeEventListener("wheel",a),d.disconnect(),t!==void 0&&cancelAnimationFrame(t)}};var MM=x("<div>"),EM=x('<div class="relative overflow-hidden pb-0 h-full">'),IM=x('<div class="h-full min-h-0 flex items-center justify-center bg-black"><video controls class="max-h-full max-w-full">'),LM=x('<div class="h-full min-h-0 flex items-center justify-center bg-background-stronger px-6"><audio controls preload=metadata class="w-full max-w-xl">'),PM=x('<div class="h-full min-h-0 flex items-center justify-center bg-background-stronger overflow-auto p-4"><img class="max-h-full max-w-full object-contain">'),ol=x('<div class="px-6 py-4 text-text-weak">...'),FM=x('<div class="px-6 py-4 text-text-weak">');const RM=e=>!!e&&/\.(mp4|m4v|webm|ogv|mov|mkv|avi|flv|wmv|3gp|3g2)$/i.test(e),zM=e=>!!e&&/\.(png|jpe?g|gif|webp|svg|ico|bmp|avif|apng|jxl)$/i.test(e),OM=e=>!!e&&/\.(mp3|wav|ogg|oga|opus|flac|aac|m4a|weba|wma|aif|aiff|mid|midi)$/i.test(e),NM=e=>!!e&&/\.(xlsx?|xlsm)$/i.test(e),BM=e=>!!e&&/\.(obj|mtl|gltf|glb|bin|dds)$/i.test(e),qM=Pg(()=>Kn(()=>import("./xlsx-editor-CQjlqJzW.js"),__vite__mapDeps([15,1,2,16]))),jM=Pg(()=>Kn(()=>import("./model-viewer-DXWYp1q7.js"),__vite__mapDeps([17,1,2])));function VM(e){return(()=>{var t=MM();return t.$$click=n=>n.stopPropagation(),t.$$mousedown=n=>n.stopPropagation(),l(t,s(Ye,{gutter:4,placement:"bottom-end",get children(){return[s(Ye.Trigger,{as:Ot,icon:"dot-grid",variant:"ghost",size:"small",class:"size-6 rounded-md",get"aria-label"(){return e.moreLabel}}),s(Ye.Portal,{get children(){return s(Ye.Content,{get children(){return[s(Ye.Item,{get onSelect(){return e.onEdit},get children(){return s(Ye.ItemLabel,{get children(){return e.editLabel}})}}),s(Ye.Item,{get onSelect(){return e.onDelete},get children(){return s(Ye.ItemLabel,{get children(){return e.deleteLabel}})}})]}})}})]}})),t})()}function HM(e){const t=yr(),n=zn(),r=Ul(),i=hn(),o=Oi(),a=br(),d=Gl(),c=cs(),{sessionKey:u,tabs:g,view:f}=Ur(),m=fs({tabs:g,pathFromTab:t.pathFromTab,normalizeTab:Z=>Z.startsWith("file://")?t.tab(Z):Z}).activeFileTab;let p,w,h,k,v=[],C=null;const y={register:Z=>{C=Z}},b=T(()=>t.pathFromTab(e.tab)),_=T(()=>{const Z=b();if(Z)return t.get(Z)}),$=T(()=>_()?.content?.content??""),D=T(()=>{const Z=b();return Z?t.text(Z)??"":""}),L=T(()=>m0($())),V=T(()=>{const Z=_()?.content;return Z?.type==="text"&&Z.encoding!=="base64"}),K=T(()=>{const Z=b();return Z?t.ready()?t.selectedLines(Z)??null:gg(u())?.files[Z]??null:null}),I=(Z,ne)=>ha(Z,{start:ne.startLine,end:ne.endLine}),U=Z=>{const ne=is(Z.selection),re=Z.preview??(()=>{if(Z.file===b())return I($(),ne);const be=t.get(Z.file)?.content?.content;if(be)return I(be,ne)})(),ie=r.add({file:Z.file,selection:Z.selection,comment:Z.comment});o.context.add({type:"file",path:Z.file,selection:ne,comment:Z.comment,commentID:ie.id,commentOrigin:Z.origin,preview:re})},Y=Z=>{r.update(Z.file,Z.id,Z.comment);const ne=Z.file===b()?I($(),is(Z.selection)):void 0;o.context.updateComment(Z.file,Z.id,{comment:Z.comment,...ne?{preview:ne}:{}})},S=Z=>{r.remove(Z.file,Z.id),o.context.removeComment(Z.file,Z.id)},M=T(()=>{const Z=b();return Z?r.list(Z):[]}),A=T(()=>M().map(Z=>Z.selection)),[F,N]=St({openedComment:null,commenting:null,selected:null}),X=Z=>{const ne=b();ne&&t.setSelectedLines(ne,Z?rs(Z):null)},B=()=>F.selected??K(),O=Sp({comments:M,label:i.t("ui.lineComment.submit"),draftKey:()=>b()??e.tab,state:{opened:()=>F.openedComment,setOpened:Z=>N("openedComment",Z),selected:()=>F.selected,setSelected:Z=>N("selected",Z),commenting:()=>F.commenting,setCommenting:Z=>N("commenting",Z),syncSelected:X,hoverSelected:X},getHoverSelectedRange:B,cancelDraftOnCommentToggle:!0,clearSelectionOnSelectionEndNull:!0,onSubmit:({comment:Z,selection:ne})=>{const re=b();re&&U({file:re,selection:ne,comment:Z,origin:"file"})},onUpdate:({id:Z,comment:ne,selection:re})=>{const ie=b();ie&&Y({id:Z,file:ie,selection:re,comment:ne})},onDelete:Z=>{const ne=b();ne&&S({id:Z.id,file:ne})},editSubmitLabel:i.t("common.save"),renderCommentActions:(Z,ne)=>s(VM,{get moreLabel(){return i.t("common.moreOptions")},get editLabel(){return i.t("common.edit")},get deleteLabel(){return i.t("common.delete")},get onEdit(){return ne.edit},get onDelete(){return ne.remove}})});$e(()=>{if(typeof window>"u")return;const Z=ne=>{m()===e.tab&&(!(ne.metaKey||ne.ctrlKey)||ne.altKey||ne.shiftKey||ne.key.toLowerCase()==="f"&&(ne.preventDefault(),ne.stopPropagation(),C?.focus()))};window.addEventListener("keydown",Z,{capture:!0}),vt(()=>window.removeEventListener("keydown",Z,{capture:!0}))}),$e(Pt(b,()=>{O.note.reset()},{defer:!0})),$e(()=>{const Z=r.focus(),ne=b();if(!Z||!ne||Z.file!==ne||m()!==e.tab)return;const re=M().find(ie=>ie.id===Z.id);re&&(O.note.openComment(re.id,re.selection,{cancelDraft:!0}),requestAnimationFrame(()=>r.clearFocus()))});const z=()=>{const Z=p;if(!Z)return[];const ne=Z.querySelector("diffs-container");if(!(ne instanceof HTMLElement))return[];const re=ne.shadowRoot;return re?Array.from(re.querySelectorAll("[data-code]")).filter(ie=>ie instanceof HTMLElement&&ie.clientWidth>0):[]},q=Z=>{k=Z,w===void 0&&(w=requestAnimationFrame(()=>{w=void 0;const ne=k;k=void 0,ne&&f().setScroll(e.tab,ne)}))},Q=Z=>{const ne=p;if(!ne)return;const re=Z.currentTarget;re instanceof HTMLElement&&q({x:re.scrollLeft,y:ne.scrollTop})},j=()=>{const Z=z();if(!(Z.length===v.length&&Z.every((ne,re)=>ne===v[re]))){for(const ne of v)ne.removeEventListener("scroll",Q);v=Z;for(const ne of v)ne.addEventListener("scroll",Q)}},H=()=>{const Z=p;if(!Z)return;const ne=f().scroll(e.tab);if(ne){if(j(),v.length>0)for(const re of v)re.scrollLeft!==ne.x&&(re.scrollLeft=ne.x);Z.scrollTop!==ne.y&&(Z.scrollTop=ne.y),!(v.length>0)&&Z.scrollLeft!==ne.x&&(Z.scrollLeft=ne.x)}},J=()=>{h===void 0&&(h=requestAnimationFrame(()=>{h=void 0,H()}))},le=Z=>{v.length===0&&j(),q({x:v[0]?.scrollLeft??Z.currentTarget.scrollLeft,y:Z.currentTarget.scrollTop})};let de={loaded:!1,ready:!1,active:!1};$e(()=>{const Z=!!_()?.loaded,ne=t.ready(),re=m()===e.tab,ie=Z&&!de.loaded||ne&&!de.ready||re&&Z&&!de.active;de={loaded:Z,ready:ne,active:re},ie&&J()}),vt(()=>{for(const Z of v)Z.removeEventListener("scroll",Q);w!==void 0&&cancelAnimationFrame(w),h!==void 0&&cancelAnimationFrame(h)});const Re=Z=>(()=>{var ne=EM();return l(ne,s(Or,{component:c,mode:"text",get file(){return{name:b()??"",contents:Z,cacheKey:L()}},enableLineSelection:!0,enableHoverUtility:!0,get selectedLines(){return B()},get commentedLines(){return A()},onRendered:()=>{J()},get annotations(){return O.annotations()},get renderAnnotation(){return O.renderAnnotation},get renderHoverUtility(){return O.renderHoverUtility},onLineSelected:re=>{O.onLineSelected(re)},get onLineNumberSelectionEnd(){return O.onLineNumberSelectionEnd},onLineSelectionEnd:re=>{O.onLineSelectionEnd(re)},search:y,class:"select-text",get media(){return{mode:"auto",path:b(),current:_()?.content,readFile:re=>n.client.file.read({path:re}).then(ie=>ie.data).catch(()=>{}),onLoad:J,onError:re=>{re.kind==="svg"&&nt({variant:"error",title:i.t("toast.file.loadFailed.title")})}}}})),ne})(),Ve=()=>{const Z=b();Z&&t.save(Z).catch(ne=>{nt({variant:"error",title:i.t("common.requestFailed"),description:Qr(ne,i.t)})})};return s(pr.Content,{get value(){return e.tab},class:"mt-0 relative h-full",get children(){return s(Dn,{get children(){return[s(ot,{get when(){return Te(()=>!!(_()?.loaded&&NM(b())))()&&b()},children:Z=>s(ld,{get fallback(){return(()=>{var ne=ol(),re=ne.firstChild;return l(ne,()=>i.t("common.loading"),re),ne})()},get children(){return s(qM,{get path(){return Z()},get active(){return m()===e.tab}})}})}),s(ot,{get when(){return Te(()=>!!(_()?.loaded&&BM(b())))()&&b()},children:Z=>s(ld,{get fallback(){return(()=>{var ne=ol(),re=ne.firstChild;return l(ne,()=>i.t("common.loading"),re),ne})()},get children(){return s(jM,{get path(){return Z()},get active(){return m()===e.tab}})}})}),s(ot,{get when(){return Te(()=>!!(_()?.loaded&&V()))()&&b()},children:Z=>s(_g,{get path(){return Z()},get state(){return _()},get value(){return D()},get active(){return m()===e.tab},onChange:ne=>t.setDraft(Z(),ne),onSave:Ve,onMode:ne=>t.setMode(Z(),ne),mention:{search:ne=>Cg({query:ne,file:t,sync:a,trellis:d}),fetch:async(ne,re)=>{if(re==="file")return await t.load(ne),t.text(ne)},navigate:ne=>{if(ne.type==="file"){const re=t.tab(ne.id);t.load(ne.id),g().open(re),g().setActive(re)}},onCreate:async ne=>{try{await n.client.file.write({fileWriteInput:{path:ne,content:"",format:!1}});const re=ne.includes("/")?ne.slice(0,ne.lastIndexOf("/")):"";return await t.tree.refresh(re),re&&t.tree.expand(re),nt({variant:"success",title:`Created ${ne}`}),ne}catch(re){const ie=re instanceof Error?re.message:String(re);nt({variant:"error",title:"Create failed",description:ie});return}},onCreateEntity:async ne=>{try{const re=ne.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),ie=`${ne.type.toLowerCase()}:${re}`,be=n.directory,Fe=n.url,ee=await n.fetch(`${Fe}/trellis/store/assert?directory=${encodeURIComponent(be)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({facts:[{e:ie,a:"type",v:ne.type},{e:ie,a:"name",v:ne.name},{e:ie,a:"color",v:Ai(ne.type)},{e:ie,a:"icon",v:Di(ne.type)}]})});if(!ee.ok)throw new Error(`Store assert failed: ${ee.status}`);return window.dispatchEvent(new CustomEvent("trellis-store-changed",{detail:{quiet:!0}})),nt({variant:"success",title:`Created ${ne.type}: ${ne.name}`}),ie}catch(re){const ie=re instanceof Error?re.message:String(re);nt({variant:"error",title:"Entity create failed",description:ie});return}}}})}),s(ot,{get when(){return Te(()=>!!_()?.loaded)()&&RM(b())},get children(){var Z=IM(),ne=Z.firstChild;return G(()=>ue(ne,"src",Ns(n.url,b(),n.directory))),Z}}),s(ot,{get when(){return Te(()=>!!_()?.loaded)()&&OM(b())},get children(){var Z=LM(),ne=Z.firstChild;return G(()=>ue(ne,"src",Ns(n.url,b(),n.directory))),Z}}),s(ot,{get when(){return Te(()=>!!_()?.loaded)()&&zM(b())},get children(){var Z=PM(),ne=Z.firstChild;return G(re=>{var ie=Ns(n.url,b(),n.directory),be=b();return ie!==re.e&&ue(ne,"src",re.e=ie),be!==re.t&&ue(ne,"alt",re.t=be),re},{e:void 0,t:void 0}),Z}}),s(ot,{get when(){return _()?.loaded},get children(){return s(ba,{class:"h-full",viewportRef:Z=>{p=Z,H()},onScroll:le,get children(){return Re($())}})}}),s(ot,{get when(){return _()?.loading},get children(){var Z=ol(),ne=Z.firstChild;return l(Z,()=>i.t("common.loading"),ne),Z}}),s(ot,{get when(){return _()?.error},children:Z=>(()=>{var ne=FM();return l(ne,Z),ne})()})]}})}})}Kt(["mousedown","click"]);var UM=x('<svg viewBox="0 0 800 800"fill=none xmlns=http://www.w3.org/2000/svg><path d="M373.362 226.643C388.087 211.919 411.96 211.919 426.684 226.643L573.37 373.324C588.094 388.047 588.094 411.92 573.37 426.644L426.684 573.324C411.96 588.048 388.087 588.048 373.362 573.324L226.677 426.644C211.952 411.92 211.952 388.047 226.677 373.324L373.362 226.643Z"fill=currentColor></path><path d="M586.658 513.282C594.02 505.921 605.956 505.921 613.318 513.282L686.659 586.621C694.021 593.983 694.021 605.919 686.659 613.28L613.318 686.619C605.956 693.981 594.02 693.981 586.658 686.619L513.317 613.28C505.955 605.919 505.955 593.983 513.317 586.621L586.658 513.282Z"fill=currentColor></path><path d="M286.501 586.454C293.957 593.909 293.957 605.997 286.501 613.453L213.5 686.452C206.044 693.907 193.956 693.907 186.5 686.452L113.499 613.453C106.043 605.997 106.043 593.909 113.499 586.454L186.5 513.455C193.956 506 206.044 506 213.5 513.455L286.501 586.454Z"fill=currentColor></path><path d="M406.524 93.4982C402.934 97.088 397.113 97.088 393.523 93.4982L356.523 56.499C352.933 52.9092 352.933 47.089 356.523 43.4992L393.523 6.50002C397.113 2.91025 402.934 2.91025 406.524 6.50003L443.524 43.4992C447.114 47.089 447.114 52.9092 443.524 56.499L406.524 93.4982Z"fill=currentColor></path><path d="M186.502 113.498C193.958 106.042 206.046 106.042 213.502 113.498L286.503 186.496C293.959 193.952 293.959 206.04 286.503 213.496L213.502 286.494C206.046 293.95 193.958 293.95 186.502 286.494L113.501 213.496C106.045 206.04 106.045 193.952 113.501 186.496L186.502 113.498Z"fill=currentColor></path><path d="M686.499 186.483C693.955 193.939 693.955 206.027 686.499 213.482L613.498 286.481C606.042 293.937 593.954 293.937 586.498 286.481L513.497 213.482C506.041 206.027 506.041 193.939 513.497 186.483L586.498 113.484C593.954 106.029 606.042 106.029 613.498 113.484L686.499 186.483Z"fill=currentColor></path><path d="M356.689 756.666C353.007 752.985 353.007 747.017 356.689 743.336L393.359 706.667C397.04 702.986 403.008 702.986 406.689 706.667L443.359 743.336C447.041 747.017 447.041 752.985 443.359 756.666L406.689 793.335C403.008 797.016 397.04 797.016 393.359 793.335L356.689 756.666Z"fill=currentColor>'),WM=x('<span class="absolute -top-0.5 -right-0.5 min-w-[14px] h-[14px] flex items-center justify-center text-[9px] font-bold rounded-full px-1"style="background:rgb(239, 68, 68);color:white">'),KM=x('<button class="flex h-9 min-w-12 items-center justify-center gap-0.5 rounded-md px-1.5 transition-colors [&amp;_svg]:size-4 md:size-9 md:min-w-0 md:px-0 md:[&amp;_svg]:size-[18px]"><span class="text-[9px] font-medium leading-none md:hidden">'),GM=x("<div class=relative>"),YM=x('<div class="h-full flex flex-col"><div class="h-6 shrink-0"aria-hidden></div><div class="flex-1 pb-64 flex items-center justify-center text-center"><div class="text-12-regular text-text-weak">'),XM=x('<div class="shrink-0 hidden md:flex md:flex-col items-center gap-0.5 overflow-x-auto no-scrollbar border-b border-border-base/30 pb-1.5 md:w-12 md:border-b-0 md:gap-2 md:py-2 md:pb-2">'),si=x('<div class="flex-1 min-h-0 overflow-hidden contain-strict animate-in fade-in slide-in-from-right-4 duration-200">'),Es=x('<button class="flex items-center justify-center size-5 sm:size-6 rounded-md text-icon-weaker hover:text-icon-weak hover:bg-surface-raised-base/30 transition-colors">'),ZM=x("<div>"),QM=x('<div class="flex items-center gap-2"><div>'),JM=x('<div class="flex items-center gap-2.5 px-2">'),eE=x("<div class=flex-1 aria-hidden>"),tE=x('<div class="bg-background-stronger h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3">'),nE=x('<div class="shrink-0 flex items-center border-b border-border-weaker-base"><div id=file-explorer-toggle class="flex items-center px-0 h-fit shrink-0 rotate-180 ml-3 mr-3">'),rE=x('<div class="relative flex-1 min-h-0 overflow-hidden"><div class="h-full flex flex-col items-center justify-center text-center gap-6"><div class="text-14-regular text-text-weak max-w-56">'),iE=x('<div class="relative pt-2 flex-1 min-h-0 overflow-hidden">'),sE=x('<div class="flex h-full w-full min-w-0 flex-col md:flex-row overflow-hidden gap-1.5 p-1.5 rounded-[14px] border border-border-base/50 bg-surface-raised-base/25 md:gap-2 md:p-2 md:rounded-[16px]"><aside id=review-panel class="relative min-w-0 min-h-0 flex-1 flex overflow-hidden bg-background-base rounded-xl border border-border-weaker-base! active:border-[#ff0000]"><div class="size-full min-w-0 h-full bg-surface-raised-base/40 flex flex-col"><div><div id=file-tree-panel class="relative min-w-0 h-full shrink-0 overflow-hidden"><div class="h-full flex flex-col overflow-hidden group/filetree border-r border-border-base/30"><div class="shrink-0 flex items-center justify-between gap-0.5 px-2 sm:px-3 h-10 sm:h-12 border-b border-border-weaker-base"><span class="text-xs sm:text-sm font-medium text-text-weak pl-1 sm:pl-1.5 opacity-80 truncate">Explorer</span><div class="flex gap-0.5 sm:gap-1 flex-shrink-0"></div></div><div class="flex-1 overflow-auto px-3 py-0"data-scope=filetree></div></div></div><div class="relative min-w-0 h-full flex-1 overflow-hidden ">'),oE=x("<div data-component=tabs-drag-preview>");const aE=e=>(()=>{var t=UM();return G(n=>Tt(t,{[e.class??""]:!!e.class},n)),t})(),Gp=[{id:"home",label:"Home",tab:"home",icon:()=>s(h0,{class:"size-[18px]"})},{id:"graph",label:"Graph",tab:"graph",icon:()=>s(p0,{class:"size-[18px]"})},{id:"plan",label:"Plan",tab:"plan",icon:()=>s(Fg,{class:"size-[18px]"})},{id:"browser",label:"Browser",tab:"browser",icon:()=>s(ki,{class:"size-[18px]"})},{id:"code",label:"Code",tab:"code",icon:()=>s(Rg,{class:"size-[18px]"})},{id:"review",label:"Review",tab:"review",icon:()=>s(v0,{class:"size-[18px]"})},{id:"explore",label:"Explore",tab:"explore",icon:()=>s(zg,{class:"size-[18px]"})},{id:"cms",label:"CMS",tab:"cms",icon:()=>s(Og,{class:"size-[18px]"})},{id:"design",label:"Design",tab:"design",icon:()=>s(Zl,{class:"size-[18px]"})}],Yp=[{id:"explore",label:"Explore",tab:"explore",icon:()=>s(zg,{class:"size-[18px]"})},{id:"plan",label:"Plan",tab:"plan",icon:()=>s(Fg,{class:"size-[18px]"})},{id:"code",label:"Code",tab:"code",icon:()=>s(Rg,{class:"size-[18px]"})},{id:"cms",label:"CMS",tab:"cms",icon:()=>s(Og,{class:"size-[18px]"})},{id:"design",label:"Design",tab:"design",icon:()=>s(Zl,{class:"size-[18px]"})}];function lE(e){const t=ua(e.item.id);return(()=>{var n=GM(),r=t.ref;return typeof r=="function"?Lt(r,n):t.ref=n,l(n,s(Nn,{placement:"right",get value(){return e.item.label},get children(){var i=KM(),o=i.firstChild;return Nr(i,bt({get classList(){return{"bg-surface-raised-base text-text-strong":e.active,"text-text-weak hover:text-text-base hover:bg-surface-raised-base/50":!e.active}},get onClick(){return e.onClick},get"aria-label"(){return e.item.label}},()=>t.dragActivators),!1,!0),l(i,()=>e.item.icon(),o),l(o,()=>e.item.label),l(i,s(E,{get when(){return Te(()=>!!(e.item.id==="review"&&e.reviewCount))()&&e.reviewCount>0},get children(){var a=WM();return l(a,(()=>{var d=Te(()=>e.reviewCount>9);return()=>d()?"9+":e.reviewCount})()),a}}),null),i}})),G(()=>n.classList.toggle("opacity-50",!!t.isActiveDraggable)),n})()}function cE(e){const t=Hr(),n=br(),r=yr(),i=hn(),o=Li(),a=dr(),d=lS({onFileCreated:we=>U(r.tab(we)),onFileDeleted:(we,He)=>{const Ne=g().all();for(const Ee of Ne){const rt=r.pathFromTab(Ee);if(!rt)continue;(He==="dir"?rt===we||rt.startsWith(we+"/"):rt===we)&&g().close(Ee)}}}),{params:c,sessionKey:u,tabs:g,view:f}=Ur(),m=ds("(min-width: 768px)"),p=T(()=>m()&&f().reviewPanel.opened()),w=T(()=>m()&&t.fileTree.opened()),h=T(()=>!m()||p()||w()),k=T(()=>m()),v=T(()=>h()?"calc(100%)":"0px"),C=T(()=>c.id?n.session.get(c.id):void 0),y=T(()=>c.id?n.data.session_diff[c.id]??[]:[]),b=T(()=>Math.max(C()?.summary?.files??0,y().length)),_=T(()=>b()>0),$=T(()=>y().map(we=>we.file)),D=T(()=>{const we=(Ee,rt)=>Ee?Ee===rt?Ee:"mix":rt,He=Ee=>Ee.replaceAll("\\\\","/").replace(/\/+$/,""),Ne=new Map;for(const Ee of y()){const rt=He(Ee.file),ct=Ee.status==="added"?"add":Ee.status==="deleted"?"del":"mix";Ne.set(rt,ct);const zt=rt.split("/");for(const[xt]of zt.slice(0,-1).entries()){const st=zt.slice(0,xt+1).join("/");st&&Ne.set(st,we(Ne.get(st),ct))}}return Ne}),L=we=>(()=>{var He=YM(),Ne=He.firstChild,Ee=Ne.nextSibling,rt=Ee.firstChild;return l(rt,we),He})(),V=T(()=>r.tree.state("")?.loaded?r.tree.children("").length===0:!1),K=we=>we.startsWith("file://")?r.tab(we):we,I=()=>{f().reviewPanel.opened()||f().reviewPanel.open()},U=Fx({normalizeTab:K,openTab:g().open,pathFromTab:r.pathFromTab,loadFile:r.load,openReviewPanel:I,setActive:g().setActive}),Y=we=>{const He=we.path,Ne=r.tab(He);if(J.clickTimeout!==void 0&&(clearTimeout(J.clickTimeout),le("clickTimeout",void 0),J.pendingFile===He)){U(Ne),le("pendingFile",void 0);return}le("pendingFile",He),le("clickTimeout",window.setTimeout(()=>{const Ee=N();Ee&&Ee!=="context"&&Ee!=="empty"&&g().close(Ee),U(Ne),le("clickTimeout",void 0),le("pendingFile",void 0)},300))},S=fs({tabs:g,pathFromTab:r.pathFromTab,normalizeTab:K,review:k,hasReview:_}),M=S.contextOpen,A=S.openedTabs,F=S.activeTab;S.activeTopTab;const N=S.activeFileTab,X=T(()=>{const we=N();if(we)return r.pathFromTab(we)}),[B,O]=ql(),z=T(()=>{const we=B.view;return we==="home"?"home":we==="graph"?"graph":we==="plan"?"plan":we==="preview"||we==="browser"?"browser":we==="code"?"code":we==="data"?"graph":we==="explore"?"explore":we==="review"?"review":we==="cms"?"cms":we==="design"?"design":"home"}),q=()=>z();T(()=>q()==="code"?q():"graph");const Q=T(()=>w()&&z()==="code"?`${t.fileTree.width()}px`:"0px"),j=()=>t.fileTree.tab(),H=()=>{j()==="changes"&&t.fileTree.setTab("all")},[J,le]=St({activeDraggable:void 0,clickTimeout:void 0,pendingFile:void 0}),de=we=>we instanceof HTMLElement?!!(we.isContentEditable||we.closest("[contenteditable='true']")||we.closest("input, textarea, select")):!1,Re=we=>{if(!de(we.target)&&(we.metaKey||we.ctrlKey)&&we.key==="Delete"){const He=X();He&&(we.preventDefault(),d.deleteFile(He));return}};Mn(()=>window.addEventListener("keydown",Re)),vt(()=>window.removeEventListener("keydown",Re));const Ve=Bc(),Z=Ve?Yp:Gp,ne=()=>Z.map(we=>we.id),[re,ie,,be]=Xr(Zr.global(Ve?"session.rail.order.v2":"session.rail.order",[Ve?"rail.order.v2":"rail.order.v1"]),St({order:ne()})),Fe=T(()=>{const we=re.order.filter(Ne=>Z.some(Ee=>Ee.id===Ne)),He=Z.filter(Ne=>!we.includes(Ne.id)).map(Ne=>Ne.id);return He.includes("home")?["home",...we,...He.filter(Ne=>Ne!=="home")]:[...we,...He]}),ee=T(()=>Fe().map(He=>Z.find(Ne=>Ne.id===He)).filter(He=>!!He)),_e=T(()=>ee().filter(we=>m()||we.id!=="review")),xe=we=>{const He=Xo(we);He&&le("activeDraggable",He)},ye=we=>{const{draggable:He,droppable:Ne}=we;if(!He||!Ne)return;const Ee=Fe(),rt=Ee.indexOf(He.id.toString()),ct=Ee.indexOf(Ne.id.toString());rt===-1||ct===-1||rt===ct||ie("order",Rs(zt=>{const[xt]=zt.splice(rt,1);zt.splice(ct,0,xt)}))},Le=()=>{le("activeDraggable",void 0)},tt=we=>{const He=Xo(we);He&&le("activeDraggable",He)},ge=we=>{const{draggable:He,droppable:Ne}=we;if(!He||!Ne)return;const Ee=g().all(),rt=om(Ee,He.id.toString(),Ne.id.toString());rt!==void 0&&g().move(He.id.toString(),rt)},qe=()=>{le("activeDraggable",void 0)};return $e(()=>{r.ready()&&mg(u(),{files:g().all().reduce((we,He)=>{const Ne=r.pathFromTab(He);if(!Ne)return we;const Ee=r.selectedLines(Ne);return we[Ne]=Ee&&typeof Ee=="object"&&"start"in Ee&&"end"in Ee?Ee:null,we},{})})}),s($0,{get children(){var we=sE(),He=we.firstChild,Ne=He.firstChild,Ee=Ne.firstChild,rt=Ee.firstChild,ct=rt.firstChild,zt=ct.firstChild,xt=zt.firstChild,st=xt.nextSibling,gt=zt.nextSibling,$n=rt.nextSibling;return l(we,s(Hs,{onDragStart:xe,onDragEnd:Le,onDragOver:ye,collisionDetector:Go,get children(){return[s(Us,{}),s(b0,{}),(()=>{var Ce=XM();return l(Ce,s(Yo,{get ids(){return _e().map(Dt=>Dt.id)},get children(){return s(Oe,{get each(){return _e()},children:Dt=>{const lt=Dt.id==="code";return s(lE,{item:Dt,get active(){return z()===Dt.tab},onClick:()=>{if(O({view:Dt.tab}),lt){const wt=A()[0];wt?g().setActive(wt):M()?g().setActive("context"):g().setActive("empty")}},get reviewCount(){return Te(()=>Dt.id==="review")()?b():void 0}})}})}})),Ce})()]}}),He),l(Ne,s(E,{get when(){return z()==="home"},get children(){var Ce=si();return l(Ce,()=>e.homePanel()),Ce}}),Ee),l(Ne,s(E,{get when(){return z()==="plan"},get children(){var Ce=si();return l(Ce,()=>e.planPanel()),Ce}}),Ee),l(Ne,s(E,{get when(){return z()==="explore"},get children(){var Ce=si();return l(Ce,()=>e.explorePanel()),Ce}}),Ee),l(Ne,s(E,{get when(){return z()==="graph"},get children(){var Ce=si();return l(Ce,s(Up,{})),Ce}}),Ee),l(Ne,s(E,{get when(){return z()==="cms"},get children(){var Ce=si();return l(Ce,s(QD,{})),Ce}}),Ee),l(Ne,s(E,{get when(){return z()==="design"},get children(){var Ce=si();return l(Ce,s(TM,{})),Ce}}),Ee),l(Ne,s(E,{get when(){return z()==="browser"},get children(){var Ce=si();return l(Ce,s(SS,{})),Ce}}),Ee),l(Ne,s(E,{get when(){return Te(()=>z()==="review")()&&k()},get children(){var Ce=si();return l(Ce,()=>e.reviewPanel()),Ce}}),Ee),l(st,s(Nn,{get value(){return i.t("session.fileTree.newFile")},placement:"bottom",gutter:6,get children(){var Ce=Es();return Ce.$$click=()=>{Kn(()=>Promise.resolve().then(()=>Hu),void 0).then(Dt=>{a.show(()=>s(Dt.DialogNewFileEntry,{kind:"file",baseDir:"",onCreated:lt=>U(r.tab(lt))}))})},l(Ce,s(cd,{class:"size-3 sm:size-3.5 opacity-70"})),G(()=>ue(Ce,"aria-label",i.t("session.fileTree.newFile"))),Ce}}),null),l(st,s(Nn,{get value(){return i.t("session.fileTree.newFolder")},placement:"bottom",gutter:6,get children(){var Ce=Es();return Ce.$$click=()=>{Kn(()=>Promise.resolve().then(()=>Hu),void 0).then(Dt=>{a.show(()=>s(Dt.DialogNewFileEntry,{kind:"folder",baseDir:""}))})},l(Ce,s(x0,{class:"size-3 sm:size-3.5 opacity-70"})),G(()=>ue(Ce,"aria-label",i.t("session.fileTree.newFolder"))),Ce}}),null),l(st,s(Nn,{get value(){return i.t("session.fileTree.expandAll")},placement:"bottom",gutter:6,get children(){var Ce=Es();return Ce.$$click=()=>{const Dt=lt=>{for(const At of r.tree.children(lt))At.type==="directory"&&(r.tree.expand(At.path),Dt(At.path))};Dt("")},l(Ce,s(y0,{class:"size-3 sm:size-3.5 opacity-70"})),G(()=>ue(Ce,"aria-label",i.t("session.fileTree.expandAll"))),Ce}}),null),l(st,s(Nn,{get value(){return i.t("session.fileTree.collapseAll")},placement:"bottom",gutter:6,get children(){var Ce=Es();return Ce.$$click=()=>{const Dt=lt=>{for(const At of r.tree.children(lt))At.type==="directory"&&(Dt(At.path),r.tree.collapse(At.path))};Dt("")},l(Ce,s(w0,{class:"size-3 sm:size-3.5 opacity-70"})),G(()=>ue(Ce,"aria-label",i.t("session.fileTree.collapseAll"))),Ce}}),null),l(st,s(Nn,{get value(){return i.t("session.fileTree.refresh")},placement:"bottom",gutter:6,get children(){var Ce=Es();return Ce.$$click=()=>r.tree.refresh(""),l(Ce,s(xg,{class:"size-3 sm:size-3.5 opacity-70"})),G(()=>ue(Ce,"aria-label",i.t("session.fileTree.refresh"))),Ce}}),null),gt.$$contextmenu=Ce=>{Ce.preventDefault(),d.showRoot(Ce)},l(gt,s(Dn,{get children(){return[s(ot,{get when(){return V()},get children(){return L(i.t("session.files.empty"))}}),s(ot,{when:!0,get children(){return s(Mp,{path:"",class:"pt-3",get active(){return X()},get modified(){return $()},get kinds(){return D()},onFileClick:Y,onNodeContextMenu:(Ce,Dt)=>d.showNode(Ce,Dt)})}})]}})),l(ct,s(cS,{ctrl:d}),null),l(rt,s(E,{get when(){return w()},get children(){var Ce=ZM();return Ce.$$pointerdown=()=>e.size.start(),l(Ce,s(so,{direction:"horizontal",get size(){return t.fileTree.width()},min:200,max:480,onResize:Dt=>{e.size.touch(),t.fileTree.resize(Dt)}})),Ce}}),null),l($n,s(Hs,{onDragStart:tt,onDragEnd:qe,onDragOver:ge,collisionDetector:Go,get children(){return[s(Us,{}),s(Ql,{}),s(pr,{get value(){return F()},onChange:U,class:"h-full flex flex-col",get children(){return[(()=>{var Ce=nE(),Dt=Ce.firstChild;return Dt.$$click=lt=>lt.stopPropagation(),Dt.$$mousedown=lt=>lt.stopPropagation(),l(Dt,s(or,{get title(){return i.t("command.fileTree.toggle")},get keybind(){return o.keybind("fileTree.toggle")},get children(){return s(Ot,{get icon(){return t.fileTree.opened()?"file-tree-active":"file-tree"},variant:"ghost",class:"!rounded-md size-6 rotate-180",get classList(){return{"text-icon-strong":t.fileTree.opened(),"text-icon-weak":!t.fileTree.opened()}},onClick:lt=>{lt.stopPropagation(),t.fileTree.toggle()},get"aria-label"(){return i.t("command.fileTree.toggle")},get"aria-expanded"(){return t.fileTree.opened()},"aria-controls":"file-tree-panel"})}})),l(Ce,s(pr.List,{class:"px-0! gap-4 w-full",ref:lt=>{const At=DM({el:lt,contextOpen:M});vt(At)},get children(){return[s(E,{get when(){return M()},get children(){var lt=JM();return l(lt,s(pr.Trigger,{value:"context",get closeButton(){return s(or,{get title(){return i.t("common.closeTab")},get keybind(){return o.keybind("tab.close")},placement:"bottom",gutter:10,get children(){return s(Ot,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:()=>g().close("context"),get"aria-label"(){return i.t("common.closeTab")}})}})},hideCloseButton:!0,onMiddleClick:()=>g().close("context"),get children(){var At=QM(),wt=At.firstChild;return l(At,s(vp,{variant:"indicator"}),wt),l(wt,()=>i.t("session.tab.context")),At}})),lt}}),s(Yo,{get ids(){return A()},get children(){return s(Oe,{get each(){return A()},children:lt=>s(Mx,{tab:lt,get onTabClose(){return g().close}})})}}),eE(),(()=>{var lt=tE();return l(lt,s(or,{get title(){return i.t("command.file.open")},get keybind(){return o.keybind("file.open")},class:"flex items-center",get children(){return s(Ot,{icon:"plus-small",variant:"ghost",iconSize:"large",class:"!rounded-md",onClick:()=>{Kn(()=>import("./dialog-select-file-B_o52Q2X.js"),__vite__mapDeps([14,1,2,5,11,12,8,13])).then(At=>{a.show(()=>s(At.DialogSelectFile,{mode:"files",onOpenFile:H}))})},get"aria-label"(){return i.t("command.file.open")}})}})),lt})()]}}),null),Ce})(),s(pr.Content,{value:"empty",class:"flex flex-col flex-1 min-h-0 overflow-hidden contain-strict",get children(){return s(E,{get when(){return F()==="empty"},get children(){var Ce=rE(),Dt=Ce.firstChild,lt=Dt.firstChild;return l(Dt,s(aE,{class:"w-14 opacity-10"}),lt),l(lt,()=>i.t("session.files.selectToOpen")),l(Dt,s(kt,{variant:"secondary",size:"small",onClick:()=>{o.trigger("file.new")},get children(){return[s(cd,{class:"size-4 mr-2"}),Te(()=>i.t("command.file.new"))]}}),null),Ce}})}}),s(E,{get when(){return M()},get children(){return s(pr.Content,{value:"context",class:"flex flex-col flex-1 min-h-0 overflow-hidden contain-strict",get children(){return s(E,{get when(){return F()==="context"},get children(){var Ce=iE();return l(Ce,s(Cx,{})),Ce}})}})}}),s(E,{get when(){return N()},keyed:!0,children:Ce=>s(HM,{tab:Ce})})]}}),s(Jl,{get children(){return s(E,{get when(){return J.activeDraggable},keyed:!0,children:Ce=>{const Dt=r.pathFromTab(Ce);return(()=>{var lt=oE();return l(lt,s(E,{when:Dt,children:At=>s(sm,{active:!0,get path(){return At()}})})),lt})()}})}})]}})),G(Ce=>{var Dt=i.t("session.panel.reviewAndFiles"),lt=!h(),At=!h(),wt={"pointer-events-none":!h(),"transition-[width] duration-[240ms] ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width] motion-reduce:transition-none":!e.size.active()&&!e.reviewSnap},It=v(),W=`flex-1 min-h-0 flex overflow-hidden ${z()!=="code"?"hidden":""}`,oe=!w(),me=!w(),he={"pointer-events-none":!w(),"transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width] motion-reduce:transition-none":!e.size.active()},Ie=Q();return Dt!==Ce.e&&ue(He,"aria-label",Ce.e=Dt),lt!==Ce.t&&ue(He,"aria-hidden",Ce.t=lt),At!==Ce.a&&(He.inert=Ce.a=At),Ce.o=Tt(He,wt,Ce.o),It!==Ce.i&&Je(He,"width",Ce.i=It),W!==Ce.n&&Ht(Ee,Ce.n=W),oe!==Ce.s&&ue(rt,"aria-hidden",Ce.s=oe),me!==Ce.h&&(rt.inert=Ce.h=me),Ce.r=Tt(rt,he,Ce.r),Ie!==Ce.d&&Je(rt,"width",Ce.d=Ie),Ce},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),we}})}Kt(["click","contextmenu","pointerdown","mousedown"]);const Wf=e=>{const t=e.title??"",n=e.titleNumber??0,r=Number.isFinite(n)&&n>0&&tg(t,n);return t&&!r?t:n>0?e.t("terminal.title.numbered",{number:n}):t||e.t("terminal.title")};var dE=x('<div class="h-full flex items-center px-3 gap-1.5 text-text-base text-[12px]"><span> Terminals'),uE=x('<span class="text-text-weak text-[12px] pl-2 pr-1">New terminal'),fE=x('<div class="h-full flex items-center justify-center">'),gE=x('<div class="flex-1 min-w-0 flex items-center px-2"><span class="text-12-regular text-text-weak truncate">'),mE=x('<div class="flex-1 min-h-0 relative p-3">'),hE=x('<div class="rounded-xl flex flex-col"><div id=terminal-tab-bar class="shrink-0 flex items-center bg-background-stronger border border-border-weak-base overflow-hidden"></div><div id=terminal-panel role=region class="relative w-full overflow-hidden bg-background-stronger rounded-b-xl"><div class="absolute flex flex-col"><div class="hidden md:block">'),pE=x('<div class="h-10 flex items-center gap-2 px-2 flex-1 overflow-hidden pointer-events-none"><div class=flex-1></div><div class="text-text-weak pr-2">'),vE=x('<div class="px-2 py-1 rounded-md bg-surface-base text-14-regular text-text-weak truncate max-w-40">'),bE=x('<div class="relative p-1 h-10 flex items-center bg-background-stronger text-14-regular">'),xE=x('<div class="flex-1 flex items-center justify-center text-text-weak">'),Kf=x('<div class="absolute inset-0">');function Gf(e={}){const t=[120,240],n=Hr(),r=Fi(),i=hn(),o=Li(),{params:a,view:d}=Ur(),c=T(()=>d().terminal.opened()),u=am(),g=T(()=>n.terminal.height()),f=()=>d().terminal.close();let m;const[p,w]=St({autoCreated:!1,activeDraggable:void 0,view:typeof window>"u"?1e3:window.visualViewport?.height??window.innerHeight}),h=()=>p.view*.6,k=()=>e.fullscreen?p.view:Math.min(g(),h());Mn(()=>{if(typeof window>"u")return;const L=()=>w("view",window.visualViewport?.height??window.innerHeight),V=window.visualViewport;L(),window.addEventListener("resize",L),V?.addEventListener("resize",L),vt(()=>{window.removeEventListener("resize",L),V?.removeEventListener("resize",L)})}),$e(()=>{if(!c()){w("autoCreated",!1);return}!r.ready()||r.all().length!==0||p.autoCreated||(r.new(),w("autoCreated",!0))}),$e(Pt(()=>r.all().length,(L,V)=>{V===void 0||V<=0||L!==0||c()&&f()}));const v=L=>{const V=cm(L);V.focus(t.length+1),Qi(L);const K=requestAnimationFrame(()=>{V.step(),c()&&r.active()===L&&Qi(L)}),I=t.map(U=>window.setTimeout(()=>{V.step(),c()&&r.active()===L&&Qi(L)},U));return()=>{V.focus(0),cancelAnimationFrame(K);for(const U of I)clearTimeout(U)}};$e(Pt(()=>[c(),r.active()],([L,V])=>{if(!L||!V)return;const K=v(V);vt(K)})),$e(()=>{if(c())return;const L=document.activeElement;L instanceof HTMLElement&&m?.contains(L)&&L.blur()}),$e(()=>{const L=a.dir;L&&r.ready()&&(i.locale(),k0(L,r.all().map(V=>Wf({title:V.title,titleNumber:V.titleNumber,t:i.t}))))});const C=T(()=>{const L=a.dir;return L?_0(L)??[]:[]}),y=r.all,b=T(()=>y().map(L=>L.id)),_=L=>{const V=Xo(L);V&&w("activeDraggable",V)},$=L=>{const{draggable:V,droppable:K}=L;if(!V||!K)return;const I=r.all(),U=I.findIndex(S=>S.id===V.id.toString()),Y=I.findIndex(S=>S.id===K.id.toString());U!==-1&&Y!==-1&&U!==Y&&r.move(V.id.toString(),Y)},D=()=>{w("activeDraggable",void 0);const L=r.active();L&&requestAnimationFrame(()=>{r.active()===L&&Qi(L)})};return s(E,{get when(){return c()},get children(){var L=hE(),V=L.firstChild,K=V.nextSibling,I=K.firstChild,U=I.firstChild;l(V,s(E,{get when(){return r.ready()},get fallback(){return(()=>{var S=pE(),M=S.firstChild,A=M.nextSibling;return l(S,s(Oe,{get each(){return C()},children:F=>(()=>{var N=vE();return l(N,F),N})()}),M),l(A,()=>i.t("common.loading"),null),l(A,()=>i.t("common.loading.ellipsis"),null),S})()},get children(){return s(Hs,{onDragStart:_,onDragEnd:D,onDragOver:$,collisionDetector:Go,get children(){return[s(Us,{}),s(Ql,{}),s(pr,{get value(){return r.active()},onChange:S=>r.open(S),class:"!h-10 flex-1 min-w-0",get children(){return s(pr.List,{class:"h-10 px-0! gap-0!",get children(){return[s(E,{get when(){return r.paneTree()},get fallback(){return s(Yo,{get ids(){return b()},get children(){return s(Oe,{get each(){return y()},children:S=>s(Nx,{terminal:S,onClose:f})})}})},get children(){var S=dE(),M=S.firstChild,A=M.firstChild;return l(S,s(Ue,{name:"square-split-horizontal",class:"w-4 h-4 shrink-0"}),M),l(M,()=>y().length,A),S}}),(()=>{var S=fE();return l(S,s(E,{get when(){return r.all().length===0},get children(){return uE()}}),null),l(S,s(or,{get title(){return i.t("command.terminal.new")},get keybind(){return o.keybind("terminal.new")},class:"flex items-center",get children(){return s(Ot,{icon:"plus-small",variant:"ghost",iconSize:"large",get onClick(){return r.new},get"aria-label"(){return i.t("command.terminal.new")}})}}),null),S})()]}})}}),s(Jl,{get children(){return s(E,{get when(){return p.activeDraggable},keyed:!0,children:S=>s(E,{get when(){return y().find(M=>M.id===S)},children:M=>(()=>{var A=bE();return l(A,()=>Wf({title:M().title,titleNumber:M().titleNumber,t:i.t})),A})()})})}})]}})}}),null),l(V,s(E,{get when(){return $d()},get children(){var S=gE(),M=S.firstChild;return l(M,$d),S}}),null),l(V,s(or,{get title(){return i.t("command.terminal.split.horizontal")},get keybind(){return o.keybind("terminal.split.horizontal")},placement:"top",class:"flex items-center shrink-0",get children(){return s(Ot,{icon:"terminal-split",variant:"ghost",onClick:()=>{const S=r.focusedPane()??r.active();S&&(d().terminal.open(),r.split(S,"h"))},get"aria-label"(){return i.t("command.terminal.split.horizontal")}})}}),null),l(V,s(or,{get title(){return i.t("command.terminal.toggle")},get keybind(){return o.keybind("terminal.toggle")},placement:"top",class:"flex items-center shrink-0 px-2 mr-2",get children(){return s(Ot,{get icon(){return c()?"chevron-down":"chevron-up"},variant:"ghost",onClick:()=>d().terminal.toggle(),get"aria-label"(){return i.t("command.terminal.toggle")},get"aria-expanded"(){return c()},"aria-controls":"terminal-panel"})}}),null);var Y=m;return typeof Y=="function"?Lt(Y,K):m=K,U.$$pointerdown=()=>u.start(),l(U,s(so,{direction:"vertical",get size(){return k()},min:100,get max(){return h()},collapseThreshold:50,onResize:S=>{u.touch(),n.terminal.resize(S)},onCollapse:f})),l(I,s(E,{get when(){return r.ready()},get fallback(){return(()=>{var S=xE();return l(S,()=>i.t("terminal.loading")),S})()},get children(){var S=mE();return l(S,s(E,{get when(){return r.paneTree()},get fallback(){return s(E,{get when(){return r.active()},keyed:!0,children:M=>{const A=r.bind();return s(E,{get when(){return y().find(F=>F.id===M)},children:F=>(()=>{var N=Kf();return ue(N,"id",`terminal-wrapper-${M}`),l(N,s(dm,{get pty(){return F()},get autoFocus(){return c()},clearOnConnect:!0,onConnect:()=>A.trim(M),get onCleanup(){return A.update},onConnectError:()=>A.clone(M)})),N})()})}})},children:M=>{const A=r.bind();return(()=>{var F=Kf();return l(F,s(hl,{get node(){return M()},get opened(){return c()},clearOnConnect:!0,onConnect:N=>A.trim(N),get onCleanup(){return A.update},onConnectError:N=>A.clone(N)})),F})()}})),S}}),null),G(S=>{var M={"h-full min-h-0 pt-0":e.fullscreen,"pt-3":!e.fullscreen},A=!c(),F=!!c(),N=i.t("terminal.title"),X=!c(),B=!c(),O={"border-x border-b border-border-weak-base":c(),"flex-1 min-h-0":e.fullscreen,"shrink-0":!e.fullscreen,"transition-[height] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[height] motion-reduce:transition-none":!u.active()&&!e.fullscreen},z=e.fullscreen?"auto":c()?`${k()}px`:"0px",q={"inset-0":e.fullscreen,"inset-x-0 top-0":!e.fullscreen,"pointer-events-none":!c()},Q=e.fullscreen?"100%":`${k()}px`;return S.e=Tt(L,M,S.e),A!==S.t&&V.classList.toggle("rounded-xl",S.t=A),F!==S.a&&V.classList.toggle("rounded-t-xl",S.a=F),N!==S.o&&ue(K,"aria-label",S.o=N),X!==S.i&&ue(K,"aria-hidden",S.i=X),B!==S.n&&(K.inert=S.n=B),S.s=Tt(K,O,S.s),z!==S.h&&Je(K,"height",S.h=z),S.r=Tt(I,q,S.r),Q!==S.d&&Je(I,"height",S.d=Q),S},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),L}})}Kt(["pointerdown"]);function yE(e){const t=e.indexOf("?");if(t===-1)return;const n=new URLSearchParams(e.slice(t+1)),r=Number(n.get("start")),i=Number(n.get("end"));if(!(!Number.isFinite(r)||!Number.isFinite(i)))return{startLine:r,endLine:i,startChar:0,endChar:0}}function wE(e){return e.filter(n=>n.type==="text").filter(n=>!n.synthetic&&!n.ignored).reduce((n,r)=>!n||r.text.length>n.text.length?r:n,void 0)}function Xp(e,t){const r=wE(e)?.text??"",i=t?.directory,o=t?.attachmentName??"attachment",a=h=>{if(!i)return h;const k=i.endsWith("/")?i:i+"/";if(h.startsWith(k))return h.slice(k.length);if(h.startsWith(i)){const v=h.slice(i.length);return v.startsWith("/")?v.slice(1):v}return h},d=[],c=[];for(const h of e){if(h.type==="file"){const k=h,v=k.source?.text;if(v){const C=v.value,y=v.start,b=v.end;let _=C;C.startsWith("@")&&(_=C.slice(1)),!C.startsWith("@")&&k.source&&"path"in k.source&&(_=k.source.path),d.push({type:"file",start:y,end:b,value:C,path:a(_),selection:yE(k.url)});continue}k.url.startsWith("data:")&&c.push({type:"image",id:k.id,filename:k.filename??o,mime:k.mime,dataUrl:k.url})}if(h.type==="agent"){const k=h,v=k.source;if(!v)continue;d.push({type:"agent",start:v.start,end:v.end,value:v.value,name:k.name})}}d.sort((h,k)=>h.start!==k.start?h.start-k.start:h.end-k.end);const u=[];let g=0,f=0;const m=h=>{h&&(u.push({type:"text",content:h,start:g,end:g+h.length}),g+=h.length)},p=h=>{const k=h.value,v={type:"file",path:h.path,content:k,start:g,end:g+k.length,selection:h.selection};u.push(v),g+=k.length},w=h=>{const k=h.value,v={type:"agent",name:h.name,content:k,start:g,end:g+k.length};u.push(v),g+=k.length};for(const h of d){if(h.start<0||h.end<h.start)continue;const k=h.value;if(!k)continue;const v=h.end>r.length||h.start<f||r.slice(h.start,h.end)!==k,C=v?r.indexOf(k,f):h.start;if(C===-1)continue;const y=v?C+k.length:h.end;m(r.slice(f,C)),h.type==="file"&&p(h),h.type==="agent"&&w(h),f=y}return m(r.slice(f)),u.length===0&&u.push({type:"text",content:"",start:0,end:0}),c.length===0?u:[...u,...c]}const Lr=e=>t=>({...t,category:e}),$E=e=>{const t=Li(),n=dr(),r=yr(),i=hn(),o=Pi(),a=fa(),d=Oi(),c=zn(),u=br(),g=Fi(),f=Hr(),{params:m,tabs:p,view:w}=Ur(),h=()=>{const re=m.id;if(re)return u.session.get(re)},k=()=>{const re=m.id;return re?Math.max(h()?.summary?.files??0,(u.data.session_diff[re]??[]).length)>0:!1},v=re=>re.startsWith("file://")?r.tab(re):re,C=fs({tabs:p,pathFromTab:r.pathFromTab,normalizeTab:v,review:e.review,hasReview:k}),y=C.openedTabs,b=C.activeFileTab,_=C.closableTab,$={type:"idle"},D=()=>u.data.session_status[m.id??""]??$,L=()=>{const re=m.id;return re?u.data.message[re]??[]:[]},V=()=>L().filter(re=>re.role==="user"),K=()=>{const re=h()?.revert?.messageID;return re?V().filter(ie=>ie.id<re):V()},I=()=>{f.fileTree.tab()==="changes"&&f.fileTree.setTab("all")},U=(re,ie)=>{const be=r.text(re);if(be)return ha(be,{start:ie.startLine,end:ie.endLine})},Y=()=>{const re=b();if(re)return r.pathFromTab(re)},S=re=>{const ie=b();if(!ie)return;const be=y(),Fe=be.indexOf(ie);if(Fe===-1)return;const ee=be[Fe+re];ee&&p().setActive(ee)},M=async re=>{if(!re)return!1;try{return await r.save(re)?(vo(i.t("common.save")),!0):!1}catch(ie){return nt({variant:"error",title:i.t("common.requestFailed"),description:Qr(ie,i.t)}),!1}},A=async()=>{try{return await r.saveAll()?(vo(i.t("command.file.saveAll")),!0):!1}catch(re){return nt({variant:"error",title:i.t("common.requestFailed"),description:Qr(re,i.t)}),!1}},F=(re,ie)=>{const be=U(re,ie);d.context.add({type:"file",path:re,selection:ie,preview:be})},N=()=>{const re=b();if(!re)return!1;const ie=r.pathFromTab(re);return ie?r.selectedLines(ie)!=null:!1},X=e.navigateMessageByOffset,B=e.setActiveMessage,O=e.focusInput,z=Lr(i.t("command.category.session")),q=Lr(i.t("command.category.file")),Q=Lr(i.t("command.category.context")),j=Lr(i.t("command.category.view")),H=Lr(i.t("command.category.editor")),J=Lr(i.t("command.category.terminal")),le=Lr(i.t("command.category.model")),de=Lr(i.t("command.category.mcp")),Re=Lr(i.t("command.category.agent")),Ve=Lr(i.t("command.category.permissions")),Z=Lr(i.t("command.category.ai")),ne=()=>{const re=m.id;return re?a.isAutoAccepting(re,c.directory):a.isAutoAcceptingDirectory(c.directory)};t.register("session",()=>{const re=u.data.config.share==="disabled"?[]:[z({id:"session.share",title:h()?.share?.url?i.t("session.share.copy.copyLink"):i.t("command.session.share"),description:h()?.share?.url?i.t("toast.session.share.success.description"):i.t("command.session.share.description"),slash:"share",disabled:!m.id,onSelect:async()=>{if(!m.id)return;const ie=_e=>{const xe=typeof document>"u"?void 0:document.body;if(xe){const Le=document.createElement("textarea");Le.value=_e,Le.setAttribute("readonly",""),Le.style.position="fixed",Le.style.opacity="0",Le.style.pointerEvents="none",xe.appendChild(Le),Le.select();const tt=document.execCommand("copy");if(xe.removeChild(Le),tt)return Promise.resolve(!0)}const ye=typeof navigator>"u"?void 0:navigator.clipboard;return ye?.writeText?ye.writeText(_e).then(()=>!0,()=>!1):Promise.resolve(!1)},be=async(_e,xe)=>{if(!await ie(_e)){nt({title:i.t("toast.session.share.copyFailed.title"),variant:"error"});return}vo(xe?i.t("session.share.copy.copied"):i.t("toast.session.share.success.title"))},Fe=h()?.share?.url;if(Fe){await be(Fe,!0);return}const ee=await c.client.session.share({sessionID:m.id}).then(_e=>_e.data?.share?.url).catch(()=>{});if(!ee){nt({title:i.t("toast.session.share.failed.title"),description:i.t("toast.session.share.failed.description"),variant:"error"});return}await be(ee,!1)}}),z({id:"session.unshare",title:i.t("command.session.unshare"),description:i.t("command.session.unshare.description"),slash:"unshare",disabled:!m.id||!h()?.share?.url,onSelect:async()=>{m.id&&await c.client.session.unshare({sessionID:m.id}).then(()=>nt({title:i.t("toast.session.unshare.success.title"),description:i.t("toast.session.unshare.success.description"),variant:"success"})).catch(()=>nt({title:i.t("toast.session.unshare.failed.title"),description:i.t("toast.session.unshare.failed.description"),variant:"error"}))}})];return[z({id:"session.new",title:i.t("command.session.new"),keybind:"mod+shift+s",slash:"new",onSelect:e.createSession}),q({id:"file.open",title:i.t("command.file.open"),description:i.t("palette.search.placeholder"),keybind:"alt+space,mod+p",slash:"open",onSelect:()=>{Kn(()=>import("./dialog-select-file-B_o52Q2X.js"),__vite__mapDeps([14,1,2,5,11,12,8,13])).then(ie=>{n.show(()=>s(ie.DialogSelectFile,{onOpenFile:I}))})}}),q({id:"tab.close",title:i.t("command.tab.close"),keybind:"mod+w,alt+x,ctrl+x",disabled:!_(),onSelect:()=>{const ie=_();ie&&p().close(ie)}}),q({id:"tab.previous",title:"Previous tab",keybind:"alt+arrowleft",disabled:!b(),onSelect:()=>{S(-1)}}),q({id:"tab.next",title:"Next tab",keybind:"alt+arrowright",disabled:!b(),onSelect:()=>{S(1)}}),q({id:"file.save",title:i.t("command.file.save"),keybind:"mod+s",disabled:!Y(),onSelect:()=>void M(Y())}),q({id:"file.saveAll",title:i.t("command.file.saveAll"),keybind:"mod+shift+s",onSelect:()=>void A()}),q({id:"file.new",title:i.t("command.file.new"),keybind:"mod+n",onSelect:()=>{}}),q({id:"folder.new",title:i.t("command.folder.new"),keybind:"mod+alt+n",onSelect:()=>{}}),H({id:"editor.format",title:i.t("command.editor.format"),keybind:"alt+f",onSelect:()=>{}}),H({id:"editor.quickFix",title:i.t("command.editor.quickFix"),keybind:"alt+q",onSelect:()=>{}}),H({id:"editor.find",title:i.t("command.editor.find"),keybind:"mod+f",onSelect:()=>{}}),H({id:"editor.replace",title:i.t("command.editor.replace"),keybind:"mod+alt+f",onSelect:()=>{}}),H({id:"editor.gotoLine",title:i.t("command.editor.gotoLine"),keybind:"mod+g",onSelect:()=>{}}),H({id:"editor.foldAll",title:i.t("command.editor.foldAll"),keybind:"mod+shift+j",onSelect:()=>{}}),H({id:"editor.unfoldAll",title:i.t("command.editor.unfoldAll"),keybind:"mod+shift+h",onSelect:()=>{}}),H({id:"editor.selectToBracket",title:i.t("command.editor.selectToBracket"),keybind:"alt+shift+]",onSelect:()=>{}}),H({id:"editor.smartSelect.expand",title:i.t("command.editor.smartSelect.expand"),keybind:"mod+shift+arrowright",onSelect:()=>{}}),H({id:"editor.smartSelect.shrink",title:i.t("command.editor.smartSelect.shrink"),keybind:"mod+shift+arrowleft",onSelect:()=>{}}),H({id:"editor.commentLine",title:i.t("command.editor.commentLine"),keybind:"mod+/",onSelect:()=>{}}),H({id:"editor.deleteLines",title:i.t("command.editor.deleteLines"),keybind:"mod+shift+k",onSelect:()=>{}}),H({id:"editor.copyFilePath",title:i.t("command.editor.copyFilePath"),keybind:"mod+shift+c",onSelect:()=>{const ie=b();if(!ie)return;const be=r.pathFromTab(ie);be&&(navigator.clipboard.writeText(be),vo(`${i.t("session.header.open.copyPath")}: ${be}`))}}),Z({id:"ai.quickChat",title:i.t("command.ai.quickChat"),keybind:"alt+`",onSelect:()=>{}}),Z({id:"ai.sidePane",title:i.t("command.ai.sidePane"),keybind:"shift+alt+l",onSelect:()=>f.session.toggle()}),Z({id:"ai.insertSelection",title:i.t("command.ai.insertSelection"),keybind:"mod+alt+l",onSelect:()=>{if(!N())return;const ie=b();if(!ie)return;const be=r.pathFromTab(ie);if(!be)return;const Fe=r.selectedLines(be);Fe&&F(be,is(Fe))}}),Z({id:"ai.toggleModel",title:i.t("command.ai.toggleModel"),keybind:"mod+alt+/",onSelect:()=>{}}),Z({id:"ai.openSettings",title:i.t("command.ai.openSettings"),keybind:"mod+alt+,",onSelect:()=>{Kn(()=>import("./dialog-settings-ChnTBHFF.js"),__vite__mapDeps([18,1,2,11,12,5,6,9,8,7])).then(ie=>{n.show(()=>s(ie.DialogSettings,{tab:"models"}))})}}),Z({id:"ai.openGlobalRules",title:i.t("command.ai.openGlobalRules"),keybind:"mod+alt+,",onSelect:()=>{}}),Z({id:"ai.toggleModelSelector",title:i.t("command.ai.toggleModelSelector"),keybind:"alt+'",onSelect:()=>{}}),Z({id:"ai.switchToNextModel",title:i.t("command.ai.switchToNextModel"),keybind:"mod+alt+/",onSelect:()=>{}}),Z({id:"ai.openMcpMarketplace",title:i.t("command.ai.openMcpMarketplace"),keybind:"ctrl+m",onSelect:()=>{}}),Z({id:"ai.cascadeView",title:i.t("command.ai.cascadeView"),keybind:"mod+alt+space",onSelect:()=>{}}),q({id:"file.findInFiles",title:i.t("command.file.findInFiles"),keybind:"mod+shift+f",onSelect:()=>{}}),q({id:"tab.moveLeft",title:i.t("command.tab.moveLeft"),keybind:"mod+alt+arrowleft,alt+,",onSelect:()=>{const ie=p().active();if(!ie)return;const Fe=p().all().indexOf(ie);Fe>0&&p().move(ie,Fe-1)}}),q({id:"tab.moveRight",title:i.t("command.tab.moveRight"),keybind:"mod+alt+arrowright,alt+.",onSelect:()=>{const ie=p().active();if(!ie)return;const be=p().all(),Fe=be.indexOf(ie);Fe<be.length-1&&p().move(ie,Fe+1)}}),Q({id:"context.addSelection",title:i.t("command.context.addSelection"),description:i.t("command.context.addSelection.description"),keybind:"mod+shift+l",disabled:!N(),onSelect:()=>{const ie=b();if(!ie)return;const be=r.pathFromTab(ie);if(!be)return;const Fe=r.selectedLines(be);if(!Fe){nt({title:i.t("toast.context.noLineSelection.title"),description:i.t("toast.context.noLineSelection.description")});return}F(be,is(Fe))}}),j({id:"terminal.toggle",title:i.t("command.terminal.toggle"),keybind:"ctrl+`,ctrl+i",slash:"terminal",onSelect:()=>w().terminal.toggle()}),j({id:"review.toggle",title:i.t("command.review.toggle"),keybind:"mod+shift+r",onSelect:()=>w().reviewPanel.toggle()}),j({id:"fileTree.toggle",title:i.t("command.fileTree.toggle"),keybind:"mod+\\",onSelect:()=>f.fileTree.toggle()}),j({id:"input.focus",title:i.t("command.input.focus"),keybind:"ctrl+l",onSelect:O}),J({id:"terminal.new",title:i.t("command.terminal.new"),description:i.t("command.terminal.new.description"),keybind:"ctrl+alt+t",onSelect:()=>{g.all().length>0&&g.new(),w().terminal.open()}}),J({id:"terminal.split.horizontal",title:i.t("command.terminal.split.horizontal"),keybind:"mod+/",onSelect:()=>{const ie=g.focusedPane()??g.active();ie&&(w().terminal.open(),g.split(ie,"h"))}}),J({id:"terminal.split.vertical",title:i.t("command.terminal.split.vertical"),keybind:"ctrl+alt+-",onSelect:()=>{const ie=g.focusedPane()??g.active();ie&&(w().terminal.open(),g.split(ie,"v"))}}),J({id:"terminal.pane.close",title:i.t("command.terminal.pane.close"),keybind:"ctrl+alt+w",onSelect:()=>{const ie=g.focusedPane()??g.active();if(!ie)return;g.paneTree()&&g.unsplit(ie)}}),z({id:"message.previous",title:i.t("command.message.previous"),description:i.t("command.message.previous.description"),keybind:"mod+alt+[",disabled:!m.id,onSelect:()=>X(-1)}),z({id:"message.next",title:i.t("command.message.next"),description:i.t("command.message.next.description"),keybind:"mod+alt+]",disabled:!m.id,onSelect:()=>X(1)}),le({id:"model.choose",title:i.t("command.model.choose"),description:i.t("command.model.choose.description"),keybind:"mod+'",slash:"model",onSelect:()=>{Kn(()=>Promise.resolve().then(()=>h$),void 0).then(ie=>{n.show(()=>s(ie.DialogSelectModel,{get model(){return o.model}}))})}}),de({id:"mcp.toggle",title:i.t("command.mcp.toggle"),description:i.t("command.mcp.toggle.description"),keybind:"mod+;",slash:"mcp",onSelect:()=>{Kn(()=>import("./dialog-select-mcp-u2kkqhGU.js"),__vite__mapDeps([19,1,2,5,6])).then(ie=>{n.show(()=>s(ie.DialogSelectMcp,{}))})}}),Re({id:"agent.cycle",title:i.t("command.agent.cycle"),description:i.t("command.agent.cycle.description"),keybind:"mod+.",slash:"agent",onSelect:()=>o.agent.move(1)}),Re({id:"agent.cycle.reverse",title:i.t("command.agent.cycle.reverse"),description:i.t("command.agent.cycle.reverse.description"),keybind:"shift+mod+.",onSelect:()=>o.agent.move(-1)}),le({id:"model.variant.cycle",title:i.t("command.model.variant.cycle"),description:i.t("command.model.variant.cycle.description"),keybind:"shift+mod+d",onSelect:()=>o.model.variant.cycle()}),Ve({id:"permissions.autoaccept",title:ne()?i.t("command.permissions.autoaccept.disable"):i.t("command.permissions.autoaccept.enable"),keybind:"mod+shift+a",disabled:!1,onSelect:()=>{const ie=m.id;ie?a.toggleAutoAccept(ie,c.directory):a.toggleAutoAcceptDirectory(c.directory);const be=ie?a.isAutoAccepting(ie,c.directory):a.isAutoAcceptingDirectory(c.directory);nt({title:be?i.t("toast.permissions.autoaccept.on.title"):i.t("toast.permissions.autoaccept.off.title"),description:be?i.t("toast.permissions.autoaccept.on.description"):i.t("toast.permissions.autoaccept.off.description")})}}),z({id:"session.undo",title:i.t("command.session.undo"),description:i.t("command.session.undo.description"),slash:"undo",disabled:!m.id||K().length===0,onSelect:async()=>{const ie=m.id;if(!ie)return;D().type!=="idle"&&await c.client.session.abort({sessionID:ie}).catch(()=>{});const be=h()?.revert?.messageID,Fe=Is(V(),xe=>!be||xe.id<be);if(!Fe)return;await c.client.session.revert({sessionID:ie,messageID:Fe.id});const ee=u.data.part[Fe.id];if(ee){const xe=Xp(ee,{directory:c.directory});d.set(xe)}const _e=Is(V(),xe=>xe.id<Fe.id);B(_e)}}),z({id:"session.redo",title:i.t("command.session.redo"),description:i.t("command.session.redo.description"),slash:"redo",disabled:!m.id||!h()?.revert?.messageID,onSelect:async()=>{const ie=m.id;if(!ie)return;const be=h()?.revert?.messageID;if(!be)return;const Fe=V().find(_e=>_e.id>be);if(!Fe){await c.client.session.unrevert({sessionID:ie}),d.reset();const _e=Is(V(),xe=>xe.id>=be);B(_e);return}await c.client.session.revert({sessionID:ie,messageID:Fe.id});const ee=Is(V(),_e=>_e.id<Fe.id);B(ee)}}),z({id:"session.compact",title:i.t("command.session.compact"),description:i.t("command.session.compact.description"),slash:"compact",disabled:!m.id||K().length===0,onSelect:async()=>{const ie=m.id;if(!ie)return;const be=o.model.current();if(!be){nt({title:i.t("toast.model.none.title"),description:i.t("toast.model.none.description")});return}await c.client.session.summarize({sessionID:ie,modelID:be.id,providerID:be.provider.id})}}),z({id:"session.fork",title:i.t("command.session.fork"),description:i.t("command.session.fork.description"),slash:"fork",disabled:!m.id||K().length===0,onSelect:()=>{Kn(()=>import("./dialog-fork-BAqzkh_T.js"),__vite__mapDeps([20,1,2,5,11,12,8,13])).then(ie=>{n.show(()=>s(ie.DialogFork,{}))})}}),...re]})},al=e=>{const n=(e.startsWith("#")?e.slice(1):e).match(/^message-(.+)$/);if(n)return n[1]},kE=e=>{const t=T(()=>e.visibleUserMessages()),n=T(()=>new Map(t().map(v=>[v.id,v]))),r=T(()=>new Map(t().map((v,C)=>[v.id,C])));let i="",o=!1;const a=hg(),d=Ri(),c=new Set,u=v=>{const C=requestAnimationFrame(()=>{c.delete(C),v()});c.add(C)},g=()=>{for(const v of c)cancelAnimationFrame(v);c.clear()},f=()=>{g(),e.consumePendingMessage(e.sessionKey()),e.pendingMessage()&&e.setPendingMessage(void 0),a.hash&&(o=!0,d(a.pathname+a.search,{replace:!0}))},m=v=>{const C=`#${e.anchor(v)}`;a.hash!==C&&(o=!1,d(a.pathname+a.search+C,{replace:!0}))},p=(v,C)=>{const y=e.scroller();if(!y)return!1;const b=v.getBoundingClientRect(),_=y.getBoundingClientRect(),$=y.querySelector("[data-session-title]"),D=$ instanceof HTMLElement?$.offsetHeight:0,L=Math.max(0,b.top-_.top+y.scrollTop-D);return y.scrollTo({top:L,behavior:C}),!0},w=(v,C,y=4)=>{const b=document.getElementById(e.anchor(v));return b?p(b,C):(y<=0||u(()=>{w(v,C,y-1)}),!1)},h=(v,C="smooth")=>{g(),e.currentMessageId()!==v.id&&e.setActiveMessage(v);const y=r().get(v.id)??-1;if(y!==-1&&y<e.turnStart()){e.setTurnStart(y),u(()=>{w(v.id,C)}),m(v.id);return}if(w(v.id,C)){m(v.id);return}m(v.id)},k=v=>{const C=a.hash.slice(1);if(!C){e.autoScroll.forceScrollToBottom();const $=e.scroller();$&&e.scheduleScrollState($);return}const y=al(C);if(y){e.autoScroll.pause();const $=n().get(y);if($){h($,v);return}return}const b=document.getElementById(C);if(b){e.autoScroll.pause(),p(b,v);return}e.autoScroll.forceScrollToBottom();const _=e.scroller();_&&e.scheduleScrollState(_)};return $e(()=>{a.hash||(o=!1),!(!e.sessionID()||!e.messagesReady())&&(g(),u(()=>k("auto")))}),$e(()=>{if(!e.sessionID()||!e.messagesReady())return;t(),e.turnStart();let v=e.pendingMessage();if(!v){const b=e.sessionKey();if(i!==b){i=b;const _=e.consumePendingMessage(b);_&&(e.setPendingMessage(_),v=_)}}if(!v&&!o&&(v=al(a.hash)),!v)return;const C=e.pendingMessage()===v,y=n().get(v);y&&(C&&e.setPendingMessage(void 0),!(e.currentMessageId()===v&&!C)&&(e.autoScroll.pause(),g(),u(()=>h(y,"auto"))))}),$e(()=>{const v=e.sessionID();if(!v||!e.messagesReady())return;t();let C=e.pendingMessage();!C&&!o&&(C=al(a.hash)),C&&(n().has(C)||!e.historyMore()||e.historyLoading()||e.loadMore(v))}),Mn(()=>{typeof window<"u"&&"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual")}),vt(g),{clearMessageHash:f,scrollToMessage:h,applyHash:k}};var _E=x('<div class="h-full pb-64 -mt-4 flex flex-col items-center justify-center text-center gap-6"><div class="text-14-regular text-text-weak max-w-56">'),CE=x("<div>"),SE=x('<div><div class="flex flex-col gap-3"><div class="text-14-medium text-text-strong"></div><div class="text-14-regular text-text-base max-w-md"style=line-height:var(--line-height-normal)>'),TE=x('<div><div class="text-14-regular text-text-weak max-w-56">'),AE=x('<div class="flex flex-col h-full overflow-hidden bg-background-stronger contain-strict"><div class="relative pt-2 flex-1 min-h-0 overflow-hidden">'),DE=x('<div class="flex-1 h-full flex items-center justify-center text-text-weaker text-12-regular">Deployment info coming soon'),Yf=x('<span class="max-w-[160px] truncate">'),ME=x('<div class="h-full flex items-center">'),EE=x('<div class="flex-1 min-w-0 min-h-0 flex flex-col">'),IE=x('<div class="flex-1 min-w-0 min-h-0">'),LE=x('<div class="absolute right-2 top-2 z-20">'),PE=x('<div class="absolute left-0 top-0 bottom-0 z-10 -translate-x-1/2">'),FE=x('<div class="flex items-center px-2 h-full bg-transparent rounded-t-xl">'),RE=x("<div><div id=chat-panel><div>"),zE=x('<nav aria-label="Mobile session navigation"class="pointer-events-none absolute inset-x-0 bottom-0 z-40 flex justify-center px-4 pb-[calc(env(safe-area-inset-bottom)+0.75rem)]"><div class="pointer-events-auto flex items-center justify-center gap-1 overflow-x-auto no-scrollbar rounded-full border border-border-base/60 bg-background-base/85 p-1 shadow-[0_12px_36px_rgba(0,0,0,0.28)] backdrop-blur-md">'),OE=x('<div class="relative bg-transparent size-full overflow-hidden flex flex-col"><div class="flex-1 min-h-0 flex flex-col md:flex-row bg-transparent pb-[72px] md:pb-0">'),NE=x('<div data-component=tabs-drag-preview class="h-full flex items-center">'),BE=x('<button class="flex size-10 shrink-0 items-center justify-center rounded-full transition-colors">'),qE=x('<div class="mx-4 mb-2 px-3 py-1.5 rounded-lg border border-border-warning/40 bg-surface-warning/10 flex items-center gap-2"><div class="size-2 rounded-full bg-text-warning animate-pulse"></div><span class="text-12-medium text-text-warning">Plan Mode Active</span><div class=flex-1>'),jE=x('<div class="px-4 pb-3 flex flex-col gap-1.5 border-t border-border-warning/20 pt-2">'),VE=x('<div class="px-4 pb-3 flex items-center gap-2 border-t border-border-warning/20 pt-2"><input type=text placeholder="Rejection reason (optional)..."class="flex-1 px-2 py-1 rounded-md bg-background-base border border-border-base text-13-regular text-text-base placeholder:text-text-weaker outline-none focus:border-border-strong-base">'),HE=x('<div class="mx-4 mb-2 rounded-xl border border-border-warning/50 bg-surface-warning/5 overflow-hidden"><div class="px-4 py-3 flex items-center gap-3"><div class="flex-1 min-w-0"><div class="text-13-medium text-text-strong"></div><div class="text-11-regular text-text-weak"> operation'),UE=x("<span class=text-text-weak>"),WE=x('<span class="text-text-weak font-mono">'),KE=x('<span class="text-text-weaker truncate flex-1">'),GE=x('<div class="flex items-center gap-2 px-2 py-1 rounded-md bg-background-base/50 text-12-regular"><span class="text-text-info font-mono">');const Bl=[],Xf=[];function YE(e){const[d,c]=St({turnID:void 0,turnStart:0,prefetchUntil:0,prefetchNoGrowth:0}),u=C=>C>10?C-10:0,g=T(()=>{const C=e.sessionID(),y=e.visibleUserMessages().length;return!C||y<=0?0:d.turnID!==C?u(y):d.turnStart<=0?0:d.turnStart>=y?u(y):d.turnStart}),f=C=>{const y=e.sessionID(),b=C>0?C:0;if(!y){c({turnID:void 0,turnStart:b});return}c({turnID:y,turnStart:b})},m=T(()=>{const C=e.visibleUserMessages(),y=g();return y<=0?C:C.slice(y)},Bl,{equals:_i}),p=C=>{const y=e.scroller();if(!y){C();return}const b=y.scrollTop,_=y.scrollHeight;C(),requestAnimationFrame(()=>{const $=y.scrollHeight-_;$&&(y.scrollTop=b+$)})},w=()=>{const C=g();if(C<=0)return;const y=C-8,b=y>0?y:0;p(()=>f(b))},h=async()=>{const C=e.sessionID();if(!C)return;const y=g(),b=e.visibleUserMessages().length;let _=e.loaded();if(y>0&&f(0),!e.historyMore()||e.historyLoading())return;let $=b,D=0;for(;;){if(await e.loadMore(C),e.sessionID()!==C)return;$=e.visibleUserMessages().length;const K=e.loaded(),I=K-_;if(D+=I,_=K,$>b||I<=0||!e.historyMore())break}if(D<=0||(d.prefetchNoGrowth&&c("prefetchNoGrowth",0),$-b<=0)||g()!==0)return;const V=Math.min($,b+8);f(Math.max(0,$-V))},k=async C=>{const y=e.sessionID();if(!y||!e.historyMore()||e.historyLoading())return;if(C?.prefetch){const S=Date.now();if(d.prefetchUntil>S||d.prefetchNoGrowth>=2)return;c("prefetchUntil",S+400)}const b=g(),_=e.visibleUserMessages().length,$=b<=0?_:m().length;let D=e.loaded(),L=0,V=0;for(;;){if(await e.loadMore(y),e.sessionID()!==y)return;const S=e.loaded(),M=S-D;if(L+=M,D=S,V=e.visibleUserMessages().length-_,V>0||M<=0||C?.prefetch||!e.historyMore())break}const K=e.visibleUserMessages().length;if(C?.prefetch?c("prefetchNoGrowth",L>0?0:d.prefetchNoGrowth+1):L>0&&d.prefetchNoGrowth&&c("prefetchNoGrowth",0),L<=0||V<=0)return;if(C?.prefetch){const S=g();p(()=>f(S+V));return}if(g()!==b)return;const I=m().length,U=Math.max($,I),Y=Math.min(K,U+8);p(()=>f(Math.max(0,K-Y)))},v=()=>{if(!e.userScrolled())return;const C=e.scroller();if(!C||C.scrollTop>=200)return;const y=g();if(y>0){y<=16&&k({prefetch:!0}),w();return}k()};return $e(Pt(e.sessionID,()=>{c({prefetchUntil:0,prefetchNoGrowth:0})},{defer:!0})),$e(Pt(()=>[e.sessionID(),e.messagesReady()],([C,y])=>{!C||!y||f(u(e.visibleUserMessages().length))},{defer:!0})),{turnStart:g,setTurnStart:f,renderedUserMessages:m,loadAndReveal:h,onScrollerScroll:v}}function XE(){const e=eo(),t=Hr(),n=Pi(),r=yr(),i=br(),o=dr(),a=hn(),d=zn(),c=Hl(),u=Oi(),g=Ul(),f=Fi();Li();const m=Ri(),[p,w]=ql(),{params:h,sessionKey:k,tabs:v,view:C}=Ur(),y=T(()=>n.agent.current()?.name==="plan"),b=P=>{const ae=new URLSearchParams;p.view&&ae.set("view",p.view);const ve=ae.toString();return`/${h.dir}/session/${P}${ve?`?${ve}`:""}`};$e(Pt(()=>y(),(P,ae)=>{P&&!ae&&v().setActive("plan")},{defer:!0})),$e(()=>{kr(()=>u.ready())&&(u.ready(),kr(()=>{if(h.id||!u.ready())return;const P=p.prompt;P&&(u.set([{type:"text",content:P,start:0,end:P.length}],P.length),w({...p,prompt:void 0}))}))});const[_,$]=St({pendingMessage:void 0,reviewSnap:!1,scrollGesture:0,scroll:{overflow:!1,bottom:!0}}),D=E3(),L=T(()=>h.dir??""),V=T(()=>t.tabs(L)),[K,I]=St({creating:!1,activeDraggable:void 0}),[U,Y,,S]=Xr(Zr.global("session-order",["session-order.v1"]),St({})),[M,A,,F]=Xr(Zr.global("session-open",["session-open.v1"]),St({})),N=T(()=>h.dir??"");$e(()=>{const P=N();P&&S()&&F()&&M[P]===void 0&&A(P,U[P]??(h.id?[h.id]:[]))}),$e(Pt(()=>h.id,(P,ae)=>{if(!P||ae)return;const ve=t.handoff.tabs();if(!ve)return;if(Date.now()-ve.at>6e4){t.handoff.clearTabs();return}if(ve.id!==P||(t.handoff.clearTabs(),ve.dir!==(h.dir??"")))return;const ze=V().tabs();if(ze.all.length===0&&!ze.active)return;const it=v().tabs();if(it.all.length>0||it.active)return;const Ge=ie(ze.all),Et=ze.active?re(ze.active):void 0;v().setAll(Ge),v().setActive(Et&&Ge.includes(Et)?Et:Ge[0]),V().setAll([]),V().setActive(void 0)},{defer:!0}));const X=T(()=>(i.data.session??[]).filter(P=>!P.time?.archived&&!P.parentID).sort((P,ae)=>(ae.time.updated??ae.time.created)-(P.time.updated??P.time.created))),B=T(()=>{const P=U[N()],ae=X(),ve=new Map(ae.map(Ge=>[Ge.id,Ge])),ze=P?.length?[...P.flatMap(Ge=>{const Et=ve.get(Ge);return Et?(ve.delete(Ge),[Et]):[]}),...ve.values()]:ae,it=new Set(M[N()]??[]);return h.id&&it.add(h.id),it.size===0?[]:ze.filter(Ge=>it.has(Ge.id))}),O=(P,ae)=>{if(!S()||!F())return;const ve=N();ve&&(Y(ve,ze=>{const it=ze??[];return!ae&&it.includes(P)?it:[P,...it.filter(Ge=>Ge!==P)]}),A(ve,ze=>{const it=ze??[];return it.includes(P)?it:[...it,P]}))},z=(P,ae)=>{if(!S())return;const ve=N();if(!ve)return;const ze=B().map(Et=>Et.id),it=ze.indexOf(P);if(it===-1||it===ae)return;const Ge=ze.slice();Ge.splice(ae,0,Ge.splice(it,1)[0]),Y(ve,Ge)},q=P=>{if(!F())return;const ae=N();if(!ae)return;const ve=B().map(Et=>Et.id),ze=ve.indexOf(P),it=ve.filter(Et=>Et!==P);if(A(ae,Et=>(Et??[]).filter(on=>on!==P)),h.id!==P)return;const Ge=it[ze-1]??it[ze];if(Ge){m(`/${ae}/session/${Ge}`);return}n.session.reset(),u.reset(),m(`/${ae}/session`)},Q=P=>{const ae=Xo(P);ae&&I("activeDraggable",ae)},j=P=>{const{draggable:ae,droppable:ve}=P;if(!ae||!ve)return;const ze=om(B().map(it=>it.id),ae.id.toString(),ve.id.toString());ze!==void 0&&z(ae.id.toString(),ze)},H=()=>{I("activeDraggable",void 0)};$e(Pt(()=>h.id,P=>{P&&O(P)},{defer:!0}));const J=ds("(min-width: 768px)"),le=am();let de;$e(()=>{const P=de;if(!P)return;const ae=t.session.opened();J()&&ae&&requestAnimationFrame(()=>{vg(P,{opacity:[0,1],x:[20,0]},{type:"spring",stiffness:400,damping:30})})});const Re=T(()=>J()&&C().reviewPanel.opened()),Ve=T(()=>J()&&t.fileTree.opened()),Z=T(()=>J()&&!!h.dir&&t.session.fullscreen(h.dir)()),ne=T(()=>J()&&(Z()||!Re()));function re(P){return P.startsWith("file://")?r.tab(P):P}function ie(P){const ae=new Set,ve=[];for(const ze of P){const it=re(ze);ae.has(it)||(ae.add(it),ve.push(it))}return ve}const be=()=>{C().reviewPanel.opened()||C().reviewPanel.open()},Fe=T(()=>h.id?i.session.get(h.id):void 0),ee=T(()=>h.id?i.data.session_diff[h.id]??[]:[]),_e=T(()=>Math.max(Fe()?.summary?.files??0,ee().length)),xe=T(()=>_e()>0),ye=T(()=>J()),Le=fs({tabs:v,pathFromTab:r.pathFromTab,normalizeTab:re,review:ye,hasReview:xe}),tt=Le.contextOpen,ge=Le.openedTabs,qe=Le.activeTab,we=Le.activeFileTab,Ne=Bc()?Yp:Gp,rt=["home","explore","plan","browser","code","cms","design"].map(P=>Ne.find(ae=>ae.id===P)).filter(P=>!!P),ct=T(()=>Fe()?.revert?.messageID),zt=T(()=>h.id?i.data.message[h.id]??[]:[]),xt=T(()=>{const P=h.id;return P?i.data.message[P]!==void 0:!0}),st=T(()=>{const P=h.id;return P?i.session.history.more(P):!1}),gt=T(()=>{const P=h.id;return P?i.session.history.loading(P):!1}),$n=T(()=>zt().filter(P=>P.role==="user"),Bl,{equals:_i}),Ce=T(()=>{const P=ct();return P?$n().filter(ae=>ae.id<P):$n()},Bl,{equals:_i}),Dt=T(()=>Ce().at(-1));$e(Pt(()=>[k(),xt()],([P,ae])=>{},{defer:!0})),$e(()=>{const P=we();if(!P)return;const ae=r.pathFromTab(P);ae&&r.load(ae)}),$e(()=>{}),$e(()=>{const P=d.event.listen(ae=>{if(ae.name!=="ui.navigate")return;const ve=ae.details.properties;ve.sessionID&&(ve.sessionID,h.id)});vt(P)}),$e(()=>{const P=ae=>{ae.detail?.url&&w({...p,view:"browser"})};window.addEventListener(dd,P),vt(()=>window.removeEventListener(dd,P))}),$e(Pt(()=>Dt()?.id,()=>{const P=Dt();P&&D4(n,P)})),$e(Pt(()=>[k(),J()?Ve()||Re()&&qe()==="review":lt.mobileTab==="changes"],([P,ae])=>{if(Ae!==void 0&&cancelAnimationFrame(Ae),De!==void 0&&window.clearTimeout(De),Ae=void 0,De=void 0,!ae)return;const ve=h.id;ve&&kr(()=>i.data.session_diff[ve]!==void 0)&&(Ae=requestAnimationFrame(()=>{Ae=void 0,De=window.setTimeout(()=>{De=void 0,k()===P&&i.session.diff(ve,{force:!0})},0)}))},{defer:!0}));const[lt,At]=St({messageId:void 0,mobileTab:"session",changes:"session",newSessionWorktree:"main",deferRender:!1});$e(Pt(()=>[J(),p.view],([P,ae])=>{P||!ae||At("mobileTab","studio")}));const[wt,It]=Xr(Zr.workspace(d.directory,"followup",["followup.v1"]),St({items:{},failed:{},paused:{},edit:{}}));ud(P=>{const ae=k();return ae!==P&&(At("deferRender",!0),requestAnimationFrame(()=>{setTimeout(()=>At("deferRender",!1),0)})),ae},k());let W,oe,me,he,Ie,Ae,De;ud(P=>{const ae=Re();return P===void 0||P===ae||(W!==void 0&&cancelAnimationFrame(W),$("reviewSnap",!0),W=requestAnimationFrame(()=>{W=void 0,$("reviewSnap",!1)})),ae},Re());const Ke=T(()=>Dt()?.summary?.diffs??[]),yt=T(()=>lt.changes==="session"?ee():Ke()),Nt=T(()=>{if(lt.newSessionWorktree==="create")return"create";const P=i.project;return P&&d.directory!==P.worktree?d.directory:"main"}),Ft=P=>{vn=ht,At("messageId",P?.id)},kn=P=>`message-${P}`,Yt=()=>{const P=On;if(!P)return lt.messageId;const ae=P.getBoundingClientRect(),ve=ae.top+100,ze=[...P.querySelectorAll("[data-message-id]")].map(on=>{const Wr=on.dataset.messageId;if(!Wr)return;const ei=on.getBoundingClientRect();return{id:Wr,top:ei.top,bottom:ei.bottom}}).filter(on=>!!on),it=ze.filter(on=>on.bottom>ae.top&&on.top<ae.bottom),Ge=it.find(on=>on.top<=ve&&on.bottom>=ve);if(Ge)return Ge.id;const Et=[...it].sort((on,Wr)=>{const ei=Math.abs(on.top-ve),ys=Math.abs(Wr.top-ve);return ei!==ys?ei-ys:on.top-Wr.top})[0];return Et?Et.id:ze.filter(on=>on.top<=ve).at(-1)?.id??ze[0]?.id??lt.messageId};function an(P){const ae=Ce();if(ae.length===0)return;const ve=lt.messageId&&vn===ht?lt.messageId:Yt(),ze=ve?ae.findIndex(Et=>Et.id===ve):ae.length,Ge=(ze===-1?ae.length:ze)+P;if(!(Ge<0||Ge>ae.length)){if(Ge===ae.length){un();return}Xe.pause(),cv(ae[Ge],"auto")}}const En=T(()=>{const P=h.id;return!P||!xe()?!0:i.data.session_diff[P]!==void 0}),dn=T(()=>{const P=i.project;return P&&!P.vcs?"session.review.noVcs":i.data.config.snapshot===!1?"session.review.noSnapshot":"session.review.empty"});function Xt(P){const ae=e.data.project;i.set("project",P.id);const ve=ae.findIndex(it=>it.id===P.id);if(ve>=0){e.set("project",ae.map((it,Ge)=>Ge===ve?{...it,...P}:it));return}const ze=ae.findIndex(it=>it.id>P.id);if(ze>=0){e.set("project",[...ae.slice(0,ze),P,...ae.slice(ze)]);return}e.set("project",[...ae,P])}const sn=Yr(()=>({mutationFn:()=>d.client.project.initGit(),onSuccess:P=>{P.data&&Xt(P.data)},onError:P=>{nt({variant:"error",title:a.t("common.requestFailed"),description:Qr(P,a.t)})}}));function _n(){sn.isPending||sn.mutate()}let fn,Hn,Xn=0,On,je,ht=0,vn=0;const ln=250,cn=P=>{const ae=On;if(!ae)return;const ze=(P instanceof Element?P:void 0)?.closest("[data-scrollable]");ze&&ze!==ae||$("scrollGesture",Date.now())},Jt=()=>Date.now()-_.scrollGesture<ln;$e(Pt([()=>d.directory,()=>h.id],([,P])=>{if(oe!==void 0&&cancelAnimationFrame(oe),me!==void 0&&window.clearTimeout(me),oe=void 0,me=void 0,!P)return;const ve=kr(()=>i.data.message[P]!==void 0)?(()=>{const ze=C0(d.directory,P);return ze?Date.now()-ze.at>S0:!0})():!1;kr(()=>{i.session.sync(P)}),oe=requestAnimationFrame(()=>{oe=void 0,me=window.setTimeout(()=>{me=void 0,h.id===P&&kr(()=>{ve&&i.session.sync(P,{force:!0})})},0)})})),$e(Pt(()=>{const P=h.id;return[d.directory,P,P?i.data.session_status[P]?.type??"idle":"idle",P?D.blocked():!1]},([P,ae,ve,ze])=>{if(he!==void 0&&cancelAnimationFrame(he),Ie!==void 0&&window.clearTimeout(Ie),he=void 0,Ie=void 0,!ae||ve==="idle"&&!ze)return;const it=kr(()=>i.data.todo[ae]!==void 0||e.data.session_todo[ae]!==void 0);he=requestAnimationFrame(()=>{he=void 0,Ie=window.setTimeout(()=>{Ie=void 0,!(d.directory!==P||h.id!==ae)&&kr(()=>{i.session.todo(ae,it?{force:!0}:void 0)})},0)})},{defer:!0})),$e(Pt(()=>Ce().at(-1)?.id,(P,ae)=>{P&&ae&&P>ae&&At("messageId",void 0)},{defer:!0})),$e(Pt(k,()=>{At("messageId",void 0),At("changes","session"),$("pendingMessage",void 0)},{defer:!0})),$e(Pt(()=>h.dir,P=>{P&&At("newSessionWorktree","main")},{defer:!0}));const en=(P,ae)=>{const ve=r.get(P)?.content?.content;if(ve)return ha(ve,{start:ae.startLine,end:ae.endLine})},Ut=P=>{const ae=is(P.selection),ve=P.preview??en(P.file,ae),ze=g.add({file:P.file,selection:P.selection,comment:P.comment});u.context.add({type:"file",path:P.file,selection:ae,comment:P.comment,commentID:ze.id,commentOrigin:P.origin,preview:ve})},gn=P=>{g.update(P.file,P.id,P.comment),u.context.updateComment(P.file,P.id,{comment:P.comment,...P.preview?{preview:P.preview}:{}})},Gt=P=>{g.remove(P.file,P.id),u.context.removeComment(P.file,P.id)},Zt=T(()=>({moreLabel:a.t("common.moreOptions"),editLabel:a.t("common.edit"),deleteLabel:a.t("common.delete"),saveLabel:a.t("common.save")})),te=P=>P instanceof HTMLElement?/^(INPUT|TEXTAREA|SELECT|BUTTON)$/.test(P.tagName)||P.isContentEditable:!1,pe=()=>{let P=document.activeElement;for(;P instanceof HTMLElement&&P.shadowRoot?.activeElement;)P=P.shadowRoot.activeElement;return P instanceof HTMLElement?P:void 0},We=P=>{const ae=P.composedPath(),ve=ae.find(Ge=>Ge instanceof HTMLElement),ze=pe();if(!(ae.some(Ge=>Ge instanceof HTMLElement&&Ge.closest("[data-prevent-autofocus]")!==null)||te(ve))){if(ze){const Ge=ze.closest("[data-prevent-autofocus]"),Et=te(ze);if(Ge||Et)return}if(!o.active){if(ze===fn){P.key==="Escape"&&fn?.blur();return}if(C().terminal.opened()){const Ge=f.active();if(Ge&&Lx(P)&&Qi(Ge))return}if(P.key==="PageUp"||P.key==="PageDown"||P.key==="Home"||P.key==="End"){cn();return}if(P.key.length===1&&P.key!=="Unidentified"&&!(P.ctrlKey||P.metaKey)){if(D.blocked())return;fn?.focus()}}}},ut=T(()=>!J()&&lt.mobileTab==="changes"),at=()=>t.fileTree.tab(),Mt=P=>t.fileTree.setTab(P),[Be,ft]=St({reviewScroll:void 0,pendingDiff:void 0,activeDiff:void 0});$e(Pt(k,()=>{ft({reviewScroll:void 0,pendingDiff:void 0,activeDiff:void 0})},{defer:!0}));const Vt=()=>{at()==="changes"&&Mt("all")},Bt=()=>fn?.focus(),pn=Px({showAllFiles:Vt,tabForPath:r.tab,openTab:v().open,setActive:v().setActive,loadFile:r.load}),R=[...["session","turn"]],se=()=>xe()?s(Qo,{options:R,get current(){return lt.changes},label:P=>P==="session"?a.t("ui.sessionReview.title"):a.t("ui.sessionReview.title.lastTurn"),onSelect:P=>P&&At("changes",P),variant:"ghost",size:"small",valueClass:"text-14-medium"}):null,fe=()=>(()=>{var P=_E(),ae=P.firstChild;return l(ae,()=>a.t("session.review.noChanges")),P})(),Pe=P=>lt.changes==="turn"?fe():xe()&&!En()?(()=>{var ae=CE();return l(ae,()=>a.t("session.review.loadingChanges")),G(()=>Ht(ae,P.loadingClass)),ae})():dn()==="session.review.noVcs"?(()=>{var ae=SE(),ve=ae.firstChild,ze=ve.firstChild,it=ze.nextSibling;return l(ze,()=>a.t("session.review.noVcs.createGit.title")),l(it,()=>a.t("session.review.noVcs.createGit.description")),l(ae,s(kt,{size:"large",get disabled(){return sn.isPending},onClick:_n,get children(){return Te(()=>!!sn.isPending)()?a.t("session.review.noVcs.createGit.actionLoading"):a.t("session.review.noVcs.createGit.action")}}),null),G(()=>Ht(ae,P.emptyClass)),ae})():(()=>{var ae=TE(),ve=ae.firstChild;return l(ve,()=>a.t(dn())),G(()=>Ht(ae,P.emptyClass)),ae})(),dt=P=>s(E,{get when(){return!lt.deferRender},get children(){return s(A4,{get title(){return se()},get empty(){return Pe(P)},diffs:yt,view:C,get diffStyle(){return P.diffStyle},get onDiffStyleChange(){return P.onDiffStyleChange},onScrollRef:ae=>ft("reviewScroll",ae),get focusedFile(){return Be.activeDiff},onLineComment:ae=>Ut({...ae,origin:"review"}),onLineCommentUpdate:gn,onLineCommentDelete:Gt,get lineCommentActions(){return Zt()},get comments(){return g.all()},get focusedComment(){return g.focus()},get onFocusedCommentChange(){return g.setFocus},onViewFile:pn,get classes(){return P.classes}})}}),Qe=()=>(()=>{var P=AE(),ae=P.firstChild;return l(ae,()=>dt({diffStyle:t.review.diffStyle(),onDiffStyleChange:t.review.setDiffStyle,loadingClass:"px-6 py-4 text-text-weak",emptyClass:"h-full pb-64 -mt-4 flex flex-col items-center justify-center text-center gap-6"})),P})(),pt=T(()=>h.id?i.data.todo[h.id]:void 0);$e(()=>{y()&&h.id&&i.session.todo(h.id)});const Wt=()=>s(F6,{}),mn=()=>s(X9,{get todos(){return pt()}}),$t=()=>s(Z9,{}),Qt=()=>DE();$e(Pt(we,P=>{P&&at()==="changes"&&Vt()},{defer:!0}));const _t=P=>{const ae=da(P);if(ae)return`session-review-diff-${ae}`},qn=P=>{const ae=Be.reviewScroll;if(!ae)return;const ve=_t(P);if(!ve)return;const ze=document.getElementById(ve);if(!(ze instanceof HTMLElement)||!ae.contains(ze))return;const it=ze.getBoundingClientRect(),Ge=ae.getBoundingClientRect();return it.top-Ge.top+ae.scrollTop},yn=P=>{const ae=Be.reviewScroll;if(!ae)return!1;const ve=qn(P);return ve===void 0?!1:(C().setScroll("review",{x:ae.scrollLeft,y:ve}),ae.scrollTo({top:ve,behavior:"auto"}),!0)},ce=P=>{be(),C().review.openPath(P),ft({activeDiff:P,pendingDiff:P})};$e(()=>{const P=Be.pendingDiff;if(!P||!Be.reviewScroll||!En())return;const ae=ve=>{if(Be.pendingDiff!==P)return;if(ve>60){ft("pendingDiff",void 0);return}const ze=Be.reviewScroll;if(!ze){requestAnimationFrame(()=>ae(ve+1));return}if(!yn(P)){requestAnimationFrame(()=>ae(ve+1));return}const it=qn(P);if(it===void 0){requestAnimationFrame(()=>ae(ve+1));return}if(Math.abs(ze.scrollTop-it)<=1){ft("pendingDiff",void 0);return}requestAnimationFrame(()=>ae(ve+1))};requestAnimationFrame(()=>ae(0))}),$e(()=>{const P=h.id;!P||!(J()?Ve()||Re()&&qe()==="review":lt.mobileTab==="changes")||i.data.session_diff[P]===void 0&&i.status!=="loading"&&i.session.diff(P)}),$e(Pt(()=>[k(),J()?Ve()||Re()&&qe()==="review":lt.mobileTab==="changes"],([P,ae])=>{if(Ae!==void 0&&cancelAnimationFrame(Ae),De!==void 0&&window.clearTimeout(De),Ae=void 0,De=void 0,!ae)return;const ve=h.id;ve&&kr(()=>i.data.session_diff[ve]!==void 0)&&(Ae=requestAnimationFrame(()=>{Ae=void 0,De=window.setTimeout(()=>{De=void 0,k()===P&&i.session.diff(ve,{force:!0})},0)}))},{defer:!0}));let Se;$e(()=>{const P=d.directory;if(!J()||!t.fileTree.opened()||i.status==="loading")return;at();const ae=Se!==P;Se=P,ae?r.tree.refresh(""):r.tree.list("")}),$e(Pt(()=>d.directory,()=>{const P=we();if(!P)return;const ae=r.pathFromTab(P);ae&&r.load(ae,{force:!0})},{defer:!0}));const Xe=Gg({working:()=>!0,overflowAnchor:"dynamic"});let et,qt,tn;const jn=P=>{const ae=P.scrollHeight-P.clientHeight,ve=ae>1,ze=!ve||P.scrollTop>=ae-2;_.scroll.overflow===ve&&_.scroll.bottom===ze||$("scroll",{overflow:ve,bottom:ze})},wn=P=>{qt=P,et===void 0&&(et=requestAnimationFrame(()=>{et=void 0;const ae=qt;qt=void 0,ae&&jn(ae)}))},un=()=>{At("messageId",void 0),Xe.forceScrollToBottom(),Yc();const P=On;P&&wn(P)};$e(Pt(Xe.userScrolled,P=>{P||(At("messageId",void 0),Yc())},{defer:!0}));let Un=()=>{};const Zn=P=>{On=P,Xe.scrollRef(P),P&&(wn(P),Un())},Qn=()=>{ht+=1};Zo(()=>je,()=>{const P=On;P&&wn(P),Un()});const In=YE({sessionID:()=>h.id,messagesReady:xt,loaded:()=>zt().length,visibleUserMessages:Ce,historyMore:st,historyLoading:gt,loadMore:P=>i.session.history.loadMore(P),userScrolled:Xe.userScrolled,scroller:()=>On});Un=()=>{tn===void 0&&(tn=requestAnimationFrame(()=>{if(tn=void 0,!h.id||!xt()||Xe.userScrolled()||gt())return;const P=On;P&&(P.scrollHeight>P.clientHeight+1||In.turnStart()<=0&&!st()||In.loadAndReveal())}))},$e(Pt(()=>[h.id,xt(),In.turnStart(),st(),gt(),Xe.userScrolled(),Ce().length],([P,ae,ve,ze,it,Ge])=>{!P||!ae||it||Ge||ve<=0&&!ze||Un()},{defer:!0}));const Ln=P=>Xp(i.data.part[P]??[],{directory:d.directory,attachmentName:a.t("common.attachment")}),mt=P=>{const ae=Ln(P).map(ve=>ve.type==="image"?`[image:${ve.filename}]`:ve.content).join("").replace(/\s+/g," ").trim();return ae||`[${a.t("common.attachment")}]`},jt=P=>{nt({variant:"error",title:a.t("common.requestFailed"),description:Qr(P,a.t)})},Ze=P=>i.set("session",ae=>{const ve=ae.findIndex(it=>it.id===P.id);if(ve<0)return[...ae,P].sort((it,Ge)=>it.id<Ge.id?-1:it.id>Ge.id?1:0);const ze=ae.slice();return ze[ve]=P,ze}),nn=(P,ae)=>{const ve=h.dir;K.creating||!ve||(I("creating",!0),d.client.session.create().then(ze=>ze.data??void 0).then(ze=>{ze&&h.dir===ve&&(Ze(ze),O(ze.id,!0),n.session.promote(d.directory,ze.id),m(b(ze.id),P?{replace:!0}:void 0))}).catch(ze=>{nt({variant:"error",title:a.t("prompt.toast.sessionCreateFailed.title"),description:Qr(ze,a.t)})}).finally(()=>{I("creating",!1),ae?.()}))};$E({navigateMessageByOffset:an,setActiveMessage:Ft,focusInput:Bt,createSession:nn,review:ye});const Tn=(P,ae)=>i.set("session",ve=>{const ze=ve.findIndex(Ge=>Ge.id===P);if(ze<0)return ve;const it=ve.slice();return it[ze]={...it[ze],revert:ae},it}),Jn=P=>(i.data.session_status[P]??{type:"idle"}).type!=="idle"?!0:(i.data.message[P]??[]).some(ae=>ae.role==="assistant"&&typeof ae.time.completed!="number"),wr=T(()=>{const P=h.id;return P?wt.items[P]??Xf:Xf}),$r=T(()=>{const P=h.id;if(P)return wt.edit[P]}),er=Yr(()=>({mutationFn:async P=>{const ae=(wt.items[P.sessionID]??[]).find(ze=>ze.id===P.id);!ae||(P.manual&&It("paused",P.sessionID,void 0),It("failed",P.sessionID,void 0),!await ym({client:d.client,sync:i,globalSync:e,draft:ae,optimisticBusy:ae.sessionDirectory===d.directory}).catch(ze=>(It("failed",P.sessionID,P.id),jt(ze),!1)))||(It("items",P.sessionID,ze=>(ze??[]).filter(it=>it.id!==P.id)),P.manual&&un())}})),Mr=P=>er.isPending&&er.variables?.sessionID===P,Sa=T(()=>{const P=h.id;if(P&&Mr(P))return er.variables?.id}),gr=T(()=>{const P=h.id;return P?c.general.followup()==="queue"&&Jn(P)&&!D.blocked():!1}),co=P=>{const ae=P.prompt.map(ve=>ve.type==="image"?`[image:${ve.filename}]`:ve.type==="file"?`[file:${ve.path}]`:ve.type==="agent"?`@${ve.name}`:ve.content).join("").split(/\r?\n/).map(ve=>ve.trim()).find(ve=>!!ve);return ae||`[${a.t("common.attachment")}]`},uo=P=>{It("items",P.sessionID,ae=>[...ae??[],{id:mr.ascending("message"),...P}]),It("failed",P.sessionID,void 0),It("paused",P.sessionID,void 0)},Zp=T(()=>wr().map(P=>({id:P.id,text:co(P)}))),Hc=(P,ae,ve)=>!(wt.items[P]??[]).find(it=>it.id===ae)||Mr(P)?Promise.resolve():er.mutateAsync({sessionID:P,id:ae,manual:ve?.manual}),Qp=P=>{const ae=h.id;if(!ae||Mr(ae))return;const ve=wr().find(ze=>ze.id===P);ve&&(It("items",ae,ze=>(ze??[]).filter(it=>it.id!==P)),It("failed",ae,ze=>ze===P?void 0:ze),It("edit",ae,{id:ve.id,prompt:ve.prompt,context:ve.context}))},Jp=()=>{const P=h.id;P&&It("edit",P,void 0)},Ta=P=>Jn(P)?d.client.session.abort({sessionID:P}).catch(()=>{}):Promise.resolve(),Uc=Yr(()=>({mutationFn:async P=>{const ae=u.current().slice(),ve=Fe()?.revert,ze=Ln(P.messageID);Wn(()=>{Tn(P.sessionID,{messageID:P.messageID}),u.set(ze)}),await Ta(P.sessionID).then(()=>d.client.session.revert(P)).then(it=>{it.data&&Ze(it.data)}).catch(it=>{Wn(()=>{Tn(P.sessionID,ve),u.set(ae)}),jt(it)})}})),fo=Yr(()=>({mutationFn:async P=>{const ae=h.id;if(!ae)return;const ve=$n().find(Et=>Et.id>P),ze=u.current().slice(),it=Fe()?.revert;Wn(()=>{if(Tn(ae,ve?{messageID:ve.id}:void 0),ve){u.set(Ln(ve.id));return}u.reset()}),await(ve?Ta(ae).then(()=>d.client.session.revert({sessionID:ae,messageID:ve.id})):Ta(ae).then(()=>d.client.session.unrevert({sessionID:ae}))).then(Et=>{Et.data&&Ze(Et.data)}).catch(Et=>{Wn(()=>{Tn(ae,it),u.set(ze)}),jt(Et)})}})),go=T(()=>Uc.isPending||fo.isPending),ev=T(()=>fo.isPending?fo.variables:void 0),Wc=P=>{if(!go())return Uc.mutateAsync(P)},tv=P=>{if(!(!h.id||go()))return fo.mutateAsync(P)},Kc=T(()=>{const P=ct();return P?$n().filter(ae=>ae.id>=P).map(ae=>({id:ae.id,text:mt(ae.id)})):[]}),nv={revert:Wc},[rv,iv]=ke(void 0),Gc=T(()=>{const P=h.id;return P?Jn(P)?[]:Ke():[]}),sv=T(()=>{if(Gc().length===0)return!1;const ae=Dt();return ae?rv()!==ae.id:!1}),ov=()=>{const P=Dt()?.id;P&&iv(P)},av=()=>{const P=h.id;if(!P)return;const ae=Dt()?.id;ae&&Wc({sessionID:P,messageID:ae})},lv=()=>{w({...p,view:"review"})};$e(()=>{const P=h.id;if(!P)return;const ae=wr()[0];ae&&(Mr(P)||wt.failed[P]!==ae.id&&(wt.paused[P]||D.blocked()||Jn(P)||Hc(P,ae.id)))}),Zo(()=>Hn,({height:P})=>{const ae=Math.ceil(P);if(ae===Xn)return;const ve=On,ze=ae-Xn,it=ve?!Xe.userScrolled()||ve.scrollHeight-ve.clientHeight-ve.scrollTop<10+Math.max(0,ze):!1;Xn=ae,it&&Xe.forceScrollToBottom(),ve&&wn(ve),Un()});const{clearMessageHash:Yc,scrollToMessage:cv}=kE({sessionKey:k,sessionID:()=>h.id,messagesReady:xt,visibleUserMessages:Ce,historyMore:st,historyLoading:gt,loadMore:P=>i.session.history.loadMore(P),turnStart:In.turnStart,currentMessageId:()=>lt.messageId,pendingMessage:()=>_.pendingMessage,setPendingMessage:P=>$("pendingMessage",P),setActiveMessage:Ft,setTurnStart:In.setTurnStart,autoScroll:Xe,scroller:()=>On,anchor:kn,scheduleScrollState:wn,consumePendingMessage:t.pendingMessage.consume});$e(Pt(()=>h.id,P=>{P||requestAnimationFrame(()=>fn?.focus())})),Mn(()=>{document.addEventListener("keydown",We)}),vt(()=>{document.removeEventListener("keydown",We),W!==void 0&&cancelAnimationFrame(W),oe!==void 0&&cancelAnimationFrame(oe),me!==void 0&&window.clearTimeout(me),he!==void 0&&cancelAnimationFrame(he),Ie!==void 0&&window.clearTimeout(Ie),Ae!==void 0&&cancelAnimationFrame(Ae),De!==void 0&&window.clearTimeout(De),et!==void 0&&cancelAnimationFrame(et),tn!==void 0&&cancelAnimationFrame(tn)}),$e(()=>{const P=p.new,ae=h.dir;if(P!=="1"||K.creating||!ae)return;const ve={...p,new:void 0};nn(!0,()=>{h.dir!==ae||p.new!=="1"||w(ve)})});function Xc(P){return(()=>{var ae=Yf();return l(ae,()=>P.session.title||P.session.id.slice(0,8)),ae})()}function dv(P){const ae=ua(P.session.id);return(()=>{var ve=ME();return Lt(ae,ve,()=>!0),l(ve,s(pr.Trigger,{get value(){return P.session.id},get closeButton(){return s(Nn,{placement:"bottom",get value(){return a.t("common.closeTab")},get children(){return s(Ot,{icon:"close-small",variant:"ghost",class:"h-5 w-5",onClick:ze=>{ze.stopPropagation(),q(P.session.id)},get"aria-label"(){return a.t("common.closeTab")}})}})},hideCloseButton:!0,onMiddleClick:()=>q(P.session.id),get children(){return s(Xc,{get session(){return P.session}})}})),G(()=>ve.classList.toggle("opacity-0",!!ae.isActiveDraggable)),ve})()}return(()=>{var P=OE(),ae=P.firstChild;return l(P,s(Jb,{}),ae),l(ae,s(E,{get when(){return Te(()=>!Z())()&&(J()||lt.mobileTab==="studio")},get children(){var ve=EE();return l(ve,s(cE,{reviewPanel:Qe,homePanel:Wt,planPanel:mn,explorePanel:$t,shipPanel:Qt,get activeDiff(){return Be.activeDiff},focusReviewDiff:ce,get reviewSnap(){return _.reviewSnap},size:le}),null),l(ve,s(Gf,{}),null),ve}}),null),l(ae,s(E,{get when(){return Te(()=>!J())()&&lt.mobileTab==="terminal"},get children(){var ve=IE();return l(ve,s(Gf,{fullscreen:!0})),ve}}),null),l(ae,s(E,{get when(){return Te(()=>!!J())()?t.session.opened()||Z():lt.mobileTab==="session"||lt.mobileTab==="changes"},get children(){var ve=RE(),ze=ve.firstChild,it=ze.firstChild;return Lt(Ge=>{de=Ge},ve),Tt(ze,{"@container relative shrink-0 flex flex-col h-full min-h-0 bg-background-stronger rounded-xl border border-border-weaker-base":!0}),l(ze,s(E,{get when(){return Te(()=>!!J())()&&h.dir},get children(){var Ge=LE();return l(Ge,s(Nn,{get value(){return Z()?"Exit fullscreen":"Fullscreen"},placement:"bottom",get children(){return s(Ot,{get icon(){return Z()?"collapse":"expand"},variant:"ghost",class:"!rounded-md",onClick:()=>t.session.toggleFullscreen(h.dir),get"aria-label"(){return Z()?"Exit fullscreen":"Fullscreen"}})}})),Ge}}),it),l(ze,s(E,{get when(){return Te(()=>!!J())()&&!Z()},get children(){var Ge=PE();return Ge.$$pointerdown=()=>le.start(),l(Ge,s(so,{direction:"horizontal",edge:"start",get size(){return t.session.width()},min:320,get max(){return typeof window>"u"?800:window.innerWidth*.6},onResize:Et=>{le.touch(),t.session.resize(Et)}})),Ge}}),it),l(ze,s(E,{get when(){return Te(()=>!!J())()&&(B().length>0||!h.id)},get children(){return s(Hs,{onDragStart:Q,onDragEnd:H,onDragOver:j,collisionDetector:Go,get children(){return[s(Us,{}),s(Ql,{}),s(pr,{class:"h-auto bg-red-500",get value(){return h.id??"new"},onChange:Ge=>m(Ge==="new"?`/${h.dir}/session`:`/${h.dir}/session/${Ge}`),variant:"normal",get children(){return s(pr.List,{get children(){return[s(Yo,{get ids(){return B().map(Ge=>Ge.id)},get children(){return s(Oe,{get each(){return B()},children:Ge=>s(dv,{session:Ge})})}}),s(E,{get when(){return!h.id},get children(){return s(pr.Trigger,{value:"new",get children(){var Ge=Yf();return l(Ge,()=>a.t("command.session.new")),Ge}})}}),(()=>{var Ge=FE();return Ge.$$click=Et=>{Et.stopPropagation()},Ge.$$mousedown=Et=>{Et.stopPropagation()},l(Ge,s(Ot,{icon:"plus-small",variant:"ghost",iconSize:"large",class:"!rounded-md",get disabled(){return K.creating},onClick:Et=>{if(Et.stopPropagation(),!h.id){n.session.reset(),u.reset(),nn(!0);return}nn()},get"aria-label"(){return a.t("command.session.new")}})),Ge})()]}})}}),s(Jl,{get children(){return s(E,{get when(){return K.activeDraggable},keyed:!0,children:Ge=>s(E,{get when(){return B().find(Et=>Et.id===Ge)},keyed:!0,children:Et=>(()=>{var on=NE();return l(on,s(Xc,{session:Et})),on})()})})}})]}})}}),it),l(it,s(Dn,{get children(){return[s(ot,{get when(){return h.id},get children(){return s(E,{get when(){return xt()},get children(){return s(O5,{get mobileChanges(){return ut()},get mobileFallback(){return dt({diffStyle:"unified",classes:{root:"pb-8",header:"px-4",container:"px-4"},loadingClass:"px-4 py-4 text-text-weak",emptyClass:"h-full pb-64 -mt-4 flex flex-col items-center justify-center text-center gap-6"})},actions:nv,get scroll(){return _.scroll},onResumeScroll:un,setScrollRef:Zn,onScheduleScrollState:wn,get onAutoScrollHandleScroll(){return Xe.handleScroll},onMarkScrollGesture:cn,hasScrollGesture:Jt,onUserScroll:Qn,get onTurnBackfillScroll(){return In.onScrollerScroll},get onAutoScrollInteraction(){return Xe.handleInteraction},get centered(){return ne()},setContentRef:Ge=>{je=Ge,Xe.contentRef(Ge);const Et=On;Et&&wn(Et)},get turnStart(){return In.turnStart()},get historyMore(){return st()},get historyLoading(){return gt()},onLoadEarlier:()=>{In.loadAndReveal()},get renderedUserMessages(){return In.renderedUserMessages()},anchor:kn})}})}}),s(ot,{when:!0,get children(){return s(Gx,{get worktree(){return Nt()},compact:!0})}})]}})),l(ze,s(ZE,{}),null),l(ze,s(D3,{state:D,get ready(){return Te(()=>!lt.deferRender)()&&xt()},get centered(){return ne()},inputRef:Ge=>{fn=Ge},get newSessionWorktree(){return Nt()},onNewSessionWorktreeReset:()=>At("newSessionWorktree","main"),onSubmit:()=>{g.clear(),un()},onResponseSubmit:un,get followup(){return Te(()=>!!h.id)()?{queue:gr,items:Zp(),sending:Sa(),edit:$r(),onQueue:uo,onAbort:()=>{const Ge=h.id;Ge&&It("paused",Ge,!0)},onSend:Ge=>{Hc(h.id,Ge,{manual:!0})},onEdit:Qp,onEditLoaded:Jp}:void 0},get revert(){return Te(()=>Kc().length>0)()?{items:Kc(),restoring:ev(),disabled:go(),onRestore:tv}:void 0},get changes(){return Te(()=>!!sv())()?{files:Gc(),rejecting:go(),onAccept:ov,onReject:av,onReview:lv}:void 0},setPromptDockRef:Ge=>{Hn=Ge},get fresh(){return!h.id}}),null),G(Ge=>{var Et={"rounded-xl":!0,"border-l border-border-weaker-base":J(),"ml-3":J()&&!Z(),"flex-1 min-w-0 min-h-0":!J()||Z()},on=J()&&!Z()?`${t.session.width()}px`:"100%",Wr={"min-h-0 overflow-hidden":!0,"flex-1":!!h.id,"shrink-0 mt-auto":!h.id};return Ge.e=Tt(ve,Et,Ge.e),on!==Ge.t&&Je(ze,"width",Ge.t=on),Ge.a=Tt(it,Wr,Ge.a),Ge},{e:void 0,t:void 0,a:void 0}),ve}}),null),l(P,s(E,{get when(){return!J()},get children(){var ve=zE(),ze=ve.firstChild;return l(ze,s(Oe,{each:rt,children:it=>{const Ge=()=>{const Et=p.view;return(Et==="preview"?"browser":Et==="data"?"graph":Et??"home")===it.tab};return(()=>{var Et=BE();return Et.$$click=()=>{if(At("mobileTab","studio"),w({view:it.tab}),it.tab==="code"){const on=ge()[0];on?v().setActive(on):tt()?v().setActive("context"):v().setActive("empty")}},l(Et,()=>it.icon()),G(on=>{var Wr={"bg-surface-raised-base text-text-strong":Ge(),"text-text-weak hover:text-text-base":!Ge()},ei=it.label,ys=Ge(),Zc=it.label;return on.e=Tt(Et,Wr,on.e),ei!==on.t&&ue(Et,"aria-label",on.t=ei),ys!==on.a&&ue(Et,"aria-pressed",on.a=ys),Zc!==on.o&&ue(Et,"title",on.o=Zc),on},{e:void 0,t:void 0,a:void 0,o:void 0}),Et})()}})),ve}}),null),P})()}function ZE(){const e=Gl(),[t,n]=ke(!1),[r,i]=ke(!1),[o,a]=ke(""),[d,c]=ke(!1),u=T(()=>e?.pendingPlan),g=T(()=>e?.planMode??!1),f=async()=>{c(!0),await e?.approvePlan(),c(!1),nt({title:"Plan approved",variant:"success"})},m=async()=>{c(!0),await e?.rejectPlan(o()||void 0),c(!1),i(!1),a(""),nt({title:"Plan rejected",variant:"default"})},p=async()=>{c(!0),await e?.cancelPlan(),c(!1)};return[s(E,{get when(){return Te(()=>!!g())()&&!u()},get children(){var w=qE(),h=w.firstChild,k=h.nextSibling;return k.nextSibling,l(w,s(kt,{size:"small",variant:"ghost",onClick:p,get disabled(){return d()},children:"Cancel"}),null),w}}),s(E,{get when(){return u()?.status==="submitted"},children:w=>{const h=()=>u();return(()=>{var k=HE(),v=k.firstChild,C=v.firstChild,y=C.firstChild,b=y.nextSibling,_=b.firstChild;return l(v,s(Ue,{name:"alert-triangle",size:"small",class:"text-text-warning shrink-0"}),C),l(y,()=>h().title),l(b,()=>h().operations.length,_),l(b,()=>h().operations.length!==1?"s":"",null),l(b,(()=>{var $=Te(()=>!!h().submittedAt);return()=>$()?` • submitted ${QE(h().submittedAt)}`:""})(),null),l(v,s(kt,{size:"small",variant:"ghost",onClick:()=>n(!t()),get children(){return t()?"Hide":"Details"}}),null),l(v,s(kt,{size:"small",variant:"ghost",onClick:f,get disabled(){return d()},children:"Approve"}),null),l(v,s(kt,{size:"small",variant:"ghost",onClick:()=>i(!0),get disabled(){return d()},children:"Reject"}),null),l(k,s(E,{get when(){return t()},get children(){var $=jE();return l($,s(Oe,{get each(){return h().operations},children:D=>(()=>{var L=GE(),V=L.firstChild;return l(V,()=>D.kind),l(L,s(E,{get when(){return D.entityType},get children(){var K=UE();return l(K,()=>D.entityType),K}}),null),l(L,s(E,{get when(){return D.entityId},get children(){var K=WE();return l(K,()=>D.entityId),K}}),null),l(L,s(E,{get when(){return D.description},get children(){var K=KE();return l(K,()=>D.description),K}}),null),L})()})),$}}),null),l(k,s(E,{get when(){return r()},get children(){var $=VE(),D=$.firstChild;return D.$$keydown=L=>L.key==="Enter"&&m(),D.$$input=L=>a(L.currentTarget.value),l($,s(kt,{size:"small",variant:"ghost",onClick:m,get disabled(){return d()},children:"Confirm"}),null),l($,s(Ot,{icon:"close-small",variant:"ghost",onClick:()=>i(!1)}),null),G(()=>D.value=o()),$}}),null),k})()}})]}function QE(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}Kt(["pointerdown","mousedown","click","input","keydown"]);const sI=Object.freeze(Object.defineProperty({__proto__:null,default:XE},Symbol.toStringTag,{value:"Module"}));export{u$ as M,fs as c,Xp as e,sI as s};