@claude-sessions/web 0.4.7-beta.1 → 0.4.7

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 (120) hide show
  1. package/build/client/_app/immutable/chunks/{Dw50LpzA.js → 6j6qgi5m.js} +1 -1
  2. package/build/client/_app/immutable/chunks/6j6qgi5m.js.br +0 -0
  3. package/build/client/_app/immutable/chunks/6j6qgi5m.js.gz +0 -0
  4. package/build/client/_app/immutable/chunks/BkKWBf8s.js +1 -0
  5. package/build/client/_app/immutable/chunks/BkKWBf8s.js.br +0 -0
  6. package/build/client/_app/immutable/chunks/BkKWBf8s.js.gz +0 -0
  7. package/build/client/_app/immutable/chunks/CursEjUX.js +1 -0
  8. package/build/client/_app/immutable/chunks/CursEjUX.js.br +0 -0
  9. package/build/client/_app/immutable/chunks/CursEjUX.js.gz +0 -0
  10. package/build/client/_app/immutable/chunks/{B8g5xi4b.js → D1duoKAw.js} +1 -1
  11. package/build/client/_app/immutable/chunks/D1duoKAw.js.br +0 -0
  12. package/build/client/_app/immutable/chunks/D1duoKAw.js.gz +0 -0
  13. package/build/client/_app/immutable/chunks/DB1q-JFC.js +1 -0
  14. package/build/client/_app/immutable/chunks/DB1q-JFC.js.br +0 -0
  15. package/build/client/_app/immutable/chunks/DB1q-JFC.js.gz +0 -0
  16. package/build/client/_app/immutable/chunks/{BWaY6ujL.js → HCtei06b.js} +1 -1
  17. package/build/client/_app/immutable/chunks/HCtei06b.js.br +0 -0
  18. package/build/client/_app/immutable/chunks/HCtei06b.js.gz +0 -0
  19. package/build/client/_app/immutable/chunks/WK3b3g7j.js +2 -0
  20. package/build/client/_app/immutable/chunks/WK3b3g7j.js.br +0 -0
  21. package/build/client/_app/immutable/chunks/WK3b3g7j.js.gz +0 -0
  22. package/build/client/_app/immutable/chunks/_v9tgGMR.js +100 -0
  23. package/build/client/_app/immutable/chunks/_v9tgGMR.js.br +0 -0
  24. package/build/client/_app/immutable/chunks/_v9tgGMR.js.gz +0 -0
  25. package/build/client/_app/immutable/entry/{app.CTjFL720.js → app.8EIXmrxu.js} +2 -2
  26. package/build/client/_app/immutable/entry/app.8EIXmrxu.js.br +0 -0
  27. package/build/client/_app/immutable/entry/app.8EIXmrxu.js.gz +0 -0
  28. package/build/client/_app/immutable/entry/start.B1RcmDxV.js +1 -0
  29. package/build/client/_app/immutable/entry/start.B1RcmDxV.js.br +0 -0
  30. package/build/client/_app/immutable/entry/start.B1RcmDxV.js.gz +0 -0
  31. package/build/client/_app/immutable/nodes/{0.DbsRMSGz.js → 0.C3-EWlLD.js} +1 -1
  32. package/build/client/_app/immutable/nodes/0.C3-EWlLD.js.br +0 -0
  33. package/build/client/_app/immutable/nodes/0.C3-EWlLD.js.gz +0 -0
  34. package/build/client/_app/immutable/nodes/{1.CzCkEGH-.js → 1.LTLF-xkJ.js} +1 -1
  35. package/build/client/_app/immutable/nodes/1.LTLF-xkJ.js.br +0 -0
  36. package/build/client/_app/immutable/nodes/1.LTLF-xkJ.js.gz +0 -0
  37. package/build/client/_app/immutable/nodes/{2.BRrV1M8V.js → 2.JKvSvrXU.js} +1 -1
  38. package/build/client/_app/immutable/nodes/2.JKvSvrXU.js.br +0 -0
  39. package/build/client/_app/immutable/nodes/2.JKvSvrXU.js.gz +0 -0
  40. package/build/client/_app/immutable/nodes/{3.CThHCmon.js → 3.QvG7KcU-.js} +1 -1
  41. package/build/client/_app/immutable/nodes/3.QvG7KcU-.js.br +0 -0
  42. package/build/client/_app/immutable/nodes/3.QvG7KcU-.js.gz +0 -0
  43. package/build/client/_app/version.json +1 -1
  44. package/build/client/_app/version.json.br +0 -0
  45. package/build/client/_app/version.json.gz +0 -0
  46. package/build/server/chunks/{0-B-m2U1BP.js → 0-Bmmq9ZM6.js} +3 -3
  47. package/build/server/chunks/{0-B-m2U1BP.js.map → 0-Bmmq9ZM6.js.map} +1 -1
  48. package/build/server/chunks/1-QC3Sx1LV.js +9 -0
  49. package/build/server/chunks/{1-BxbzQf60.js.map → 1-QC3Sx1LV.js.map} +1 -1
  50. package/build/server/chunks/2-Dw5NPnTj.js +9 -0
  51. package/build/server/chunks/{2-B1OQIXg9.js.map → 2-Dw5NPnTj.js.map} +1 -1
  52. package/build/server/chunks/3-BcDPYoSg.js +9 -0
  53. package/build/server/chunks/{3-QNnRFpXn.js.map → 3-BcDPYoSg.js.map} +1 -1
  54. package/build/server/chunks/{InputModal-B2QW71Rc.js → InputModal-Cp5WgcYP.js} +2 -2
  55. package/build/server/chunks/{InputModal-B2QW71Rc.js.map → InputModal-Cp5WgcYP.js.map} +1 -1
  56. package/build/server/chunks/{Toast-C0Uluww6.js → Toast-AVuTocXd.js} +2 -2
  57. package/build/server/chunks/{Toast-C0Uluww6.js.map → Toast-AVuTocXd.js.map} +1 -1
  58. package/build/server/chunks/{_layout.svelte-rcGJkEsi.js → _layout.svelte-DaSyc-mf.js} +5 -5
  59. package/build/server/chunks/{_layout.svelte-rcGJkEsi.js.map → _layout.svelte-DaSyc-mf.js.map} +1 -1
  60. package/build/server/chunks/{_page.svelte-BBAp4Vom.js → _page.svelte-D0jFzJtD.js} +12 -5
  61. package/build/server/chunks/_page.svelte-D0jFzJtD.js.map +1 -0
  62. package/build/server/chunks/{_page.svelte-JEzT1D1F.js → _page.svelte-D3EVHdvH.js} +5 -5
  63. package/build/server/chunks/{_page.svelte-JEzT1D1F.js.map → _page.svelte-D3EVHdvH.js.map} +1 -1
  64. package/build/server/chunks/{_server.ts-L0d7krv-.js → _server.ts-DousfQCX.js} +2 -2
  65. package/build/server/chunks/_server.ts-DousfQCX.js.map +1 -0
  66. package/build/server/chunks/{client-CJUAsTTN.js → client-C63uMw4h.js} +4 -3
  67. package/build/server/chunks/client-C63uMw4h.js.map +1 -0
  68. package/build/server/chunks/{error.svelte-CYLEgCzL.js → error.svelte-7ySp2asi.js} +4 -4
  69. package/build/server/chunks/{error.svelte-CYLEgCzL.js.map → error.svelte-7ySp2asi.js.map} +1 -1
  70. package/build/server/chunks/index-CoD1IJuy.js.map +1 -1
  71. package/build/server/chunks/{index-CUeePJRv.js → index-Dqbd-Nxp.js} +256 -235
  72. package/build/server/chunks/index-Dqbd-Nxp.js.map +1 -0
  73. package/build/server/chunks/{index3-BKokHvI9.js → index3-vPlrIIie.js} +3 -3
  74. package/build/server/chunks/{index3-BKokHvI9.js.map → index3-vPlrIIie.js.map} +1 -1
  75. package/build/server/index.js +99 -13
  76. package/build/server/index.js.map +1 -1
  77. package/build/server/manifest.js +6 -6
  78. package/build/server/manifest.js.map +1 -1
  79. package/package.json +23 -20
  80. package/build/client/_app/immutable/chunks/B8g5xi4b.js.br +0 -0
  81. package/build/client/_app/immutable/chunks/B8g5xi4b.js.gz +0 -0
  82. package/build/client/_app/immutable/chunks/BWaY6ujL.js.br +0 -0
  83. package/build/client/_app/immutable/chunks/BWaY6ujL.js.gz +0 -0
  84. package/build/client/_app/immutable/chunks/BfRp2rnv.js +0 -100
  85. package/build/client/_app/immutable/chunks/BfRp2rnv.js.br +0 -0
  86. package/build/client/_app/immutable/chunks/BfRp2rnv.js.gz +0 -0
  87. package/build/client/_app/immutable/chunks/CG99hqDQ.js +0 -2
  88. package/build/client/_app/immutable/chunks/CG99hqDQ.js.br +0 -0
  89. package/build/client/_app/immutable/chunks/CG99hqDQ.js.gz +0 -0
  90. package/build/client/_app/immutable/chunks/CfsdC4sQ.js +0 -1
  91. package/build/client/_app/immutable/chunks/CfsdC4sQ.js.br +0 -0
  92. package/build/client/_app/immutable/chunks/CfsdC4sQ.js.gz +0 -0
  93. package/build/client/_app/immutable/chunks/DWa7QuMS.js +0 -1
  94. package/build/client/_app/immutable/chunks/DWa7QuMS.js.br +0 -0
  95. package/build/client/_app/immutable/chunks/DWa7QuMS.js.gz +0 -0
  96. package/build/client/_app/immutable/chunks/DjDr02vs.js +0 -1
  97. package/build/client/_app/immutable/chunks/DjDr02vs.js.br +0 -0
  98. package/build/client/_app/immutable/chunks/DjDr02vs.js.gz +0 -0
  99. package/build/client/_app/immutable/chunks/Dw50LpzA.js.br +0 -0
  100. package/build/client/_app/immutable/chunks/Dw50LpzA.js.gz +0 -0
  101. package/build/client/_app/immutable/entry/app.CTjFL720.js.br +0 -0
  102. package/build/client/_app/immutable/entry/app.CTjFL720.js.gz +0 -0
  103. package/build/client/_app/immutable/entry/start.Chk6JwCE.js +0 -1
  104. package/build/client/_app/immutable/entry/start.Chk6JwCE.js.br +0 -0
  105. package/build/client/_app/immutable/entry/start.Chk6JwCE.js.gz +0 -0
  106. package/build/client/_app/immutable/nodes/0.DbsRMSGz.js.br +0 -0
  107. package/build/client/_app/immutable/nodes/0.DbsRMSGz.js.gz +0 -0
  108. package/build/client/_app/immutable/nodes/1.CzCkEGH-.js.br +0 -2
  109. package/build/client/_app/immutable/nodes/1.CzCkEGH-.js.gz +0 -0
  110. package/build/client/_app/immutable/nodes/2.BRrV1M8V.js.br +0 -0
  111. package/build/client/_app/immutable/nodes/2.BRrV1M8V.js.gz +0 -0
  112. package/build/client/_app/immutable/nodes/3.CThHCmon.js.br +0 -0
  113. package/build/client/_app/immutable/nodes/3.CThHCmon.js.gz +0 -0
  114. package/build/server/chunks/1-BxbzQf60.js +0 -9
  115. package/build/server/chunks/2-B1OQIXg9.js +0 -9
  116. package/build/server/chunks/3-QNnRFpXn.js +0 -9
  117. package/build/server/chunks/_page.svelte-BBAp4Vom.js.map +0 -1
  118. package/build/server/chunks/_server.ts-L0d7krv-.js.map +0 -1
  119. package/build/server/chunks/client-CJUAsTTN.js.map +0 -1
  120. package/build/server/chunks/index-CUeePJRv.js.map +0 -1
@@ -1,100 +0,0 @@
1
- import{i as Ep,b as ve,d as $t,j as Op,n as Ap,k as Mp,g as Fe,a as y,f as C,s as N,e as vn,t as Rt}from"./CG99hqDQ.js";import{aW as bc,aX as wf,aY as Np,l as Ye,Y as Tf,aZ as Pp,k as _c,V as Dn,a_ as zl,ap as Cf,v as _o,a0 as _a,q as On,an as yc,aB as ps,al as Oo,M as ya,a$ as Fp,ay as Lp,b0 as jp,b1 as Dp,ai as $p,b2 as Rf,j as ea,m as Bp,g as l,aa as Up,_ as qp,w as io,C as zp,aU as Vp,b3 as rn,U as ks,b4 as Hp,X as Wp,aT as xc,b5 as Kp,b6 as Gp,b7 as Jp,a9 as Yp,R as If,T as Ef,b8 as ta,n as Zp,b9 as Qp,aR as Xp,W as em,S as Ao,ba as Of,bb as tm,Z as nm,bc as Af,K as Mf,P as rm,bd as sm,be as om,bf as im,bg as am,bh as Fs,bi as cm,bj as lm,bk as um,bl as fm,bm as hm,bn as Nf,aj as Pf,z as Ff,a1 as Lf,J as dm,I as gm,O as pm,p as Mt,f as Te,c as Nt,d as b,r as m,e as T,t as B,u as zn,b as J,s as De,h as H,aC as hr,bo as jf,a as xa,bp as mm}from"./DWa7QuMS.js";import{B as Df,p as Ae,i as q,b as ai,r as vm,a as bm,s as _m}from"./B8g5xi4b.js";import{b as ym}from"./DjDr02vs.js";const xm=[];function km(t,e=!1,n=!1){return yo(t,new Map,"",xm,null,n)}function yo(t,e,n,r,s=null,o=!1){if(typeof t=="object"&&t!==null){var i=e.get(t);if(i!==void 0)return i;if(t instanceof Map)return new Map(t);if(t instanceof Set)return new Set(t);if(bc(t)){var c=Array(t.length);e.set(t,c),s!==null&&e.set(s,c);for(var a=0;a<t.length;a+=1){var u=t[a];a in t&&(c[a]=yo(u,e,n,r,null,o))}return c}if(wf(t)===Np){c={},e.set(t,c),s!==null&&e.set(s,c);for(var f of Object.keys(t))c[f]=yo(t[f],e,n,r,null,o);return c}if(t instanceof Date)return structuredClone(t);if(typeof t.toJSON=="function"&&!o)return yo(t.toJSON(),e,n,r,t)}if(t instanceof EventTarget)return t;try{return structuredClone(t)}catch{return t}}const Vl=0,Hl=1,Sm=2;function ka(t,e,n,r,s){Ye&&Tf();var o=Pp(),i=Rf,c=o?Oo(i):ya(i,!1,!1),a=o?Oo(i):ya(i,!1,!1),u=new Df(t);_c(()=>{var f=Dn;f.deactivate();var h=e();f.activate();var d=!1;let p=Ye&&zl(h)===(t.data===Cf);if(p&&(_o(_a()),On(!1)),zl(h)){var g=Fp(),x=!1;const v=_=>{if(!d){x=!0,g(!1),Lp.ensure(),Ye&&On(!1);try{_()}finally{jp(!1),Dp||$p()}}};h.then(_=>{v(()=>{ps(c,_),u.ensure(Hl,r&&(O=>r(O,c)))})},_=>{v(()=>{if(ps(a,_),u.ensure(Sm,s&&(O=>s(O,a))),!s)throw a.v})}),Ye?u.ensure(Vl,n):yc(()=>{x||v(()=>{u.ensure(Vl,n)})})}else ps(c,h),u.ensure(Hl,r&&(v=>r(v,c)));return p&&On(!0),()=>{d=!0}})}function _t(t,e){return e}function wm(t,e,n){for(var r=[],s=e.length,o,i=e.length,c=0;c<s;c++){let h=e[c];Ef(h,()=>{if(o){if(o.pending.delete(h),o.done.add(h),o.pending.size===0){var d=t.outrogroups;Sa(t,xc(o.done)),d.delete(o),d.size===0&&(t.outrogroups=null)}}else i-=1},!1)}if(i===0){var a=r.length===0&&n!==null;if(a){var u=n,f=u.parentNode;Xp(f),f.append(u),t.items.clear()}Sa(t,e,!a)}else o={pending:new Set(e),done:new Set},(t.outrogroups??=new Set).add(o)}function Sa(t,e,n=!0){var r;if(t.pending.size>0){r=new Set;for(const i of t.pending.values())for(const c of i)r.add(t.items.get(c).e)}for(var s=0;s<e.length;s++){var o=e[s];if(r?.has(o)){o.f|=rn;const i=document.createDocumentFragment();em(o,i)}else Ao(e[s],n)}}var Wl;function dt(t,e,n,r,s,o=null){var i=t,c=new Map,a=(e&Of)!==0;if(a){var u=t;i=Ye?_o(Bp(u)):u.appendChild(ea())}Ye&&Tf();var f=null,h=Up(()=>{var P=n();return bc(P)?P:P==null?[]:xc(P)}),d,p=new Map,g=!0;function x(P){(O.effect.f&Yp)===0&&(O.pending.delete(P),O.fallback=f,Tm(O,d,i,e,r),f!==null&&(d.length===0?(f.f&rn)===0?If(f):(f.f^=rn,hs(f,null,i)):Ef(f,()=>{f=null})))}function v(P){O.pending.delete(P)}var _=_c(()=>{d=l(h);var P=d.length;let R=!1;if(Ye){var D=qp(i)===Cf;D!==(P===0)&&(i=_a(),_o(i),On(!1),R=!0)}for(var w=new Set,A=Dn,S=Wp(),M=0;M<P;M+=1){Ye&&io.nodeType===zp&&io.data===Vp&&(i=io,R=!0,On(!1));var E=d[M],$=r(E,M),Q=g?null:c.get($);Q?(Q.v&&ps(Q.v,E),Q.i&&ps(Q.i,M),S&&A.unskip_effect(Q.e)):(Q=Cm(c,g?i:Wl??=ea(),E,$,M,s,e,n),g||(Q.e.f|=rn),c.set($,Q)),w.add($)}if(P===0&&o&&!f&&(g?f=ks(()=>o(i)):(f=ks(()=>o(Wl??=ea())),f.f|=rn)),P>w.size&&Hp(),Ye&&P>0&&_o(_a()),!g)if(p.set(A,w),S){for(const[pe,W]of c)w.has(pe)||A.skip_effect(W.e);A.oncommit(x),A.ondiscard(v)}else x(A);R&&On(!0),l(h)}),O={effect:_,items:c,pending:p,outrogroups:null,fallback:f};g=!1,Ye&&(i=io)}function ns(t){for(;t!==null&&(t.f&Qp)===0;)t=t.next;return t}function Tm(t,e,n,r,s){var o=(r&tm)!==0,i=e.length,c=t.items,a=ns(t.effect.first),u,f=null,h,d=[],p=[],g,x,v,_;if(o)for(_=0;_<i;_+=1)g=e[_],x=s(g,_),v=c.get(x).e,(v.f&rn)===0&&(v.nodes?.a?.measure(),(h??=new Set).add(v));for(_=0;_<i;_+=1){if(g=e[_],x=s(g,_),v=c.get(x).e,t.outrogroups!==null)for(const E of t.outrogroups)E.pending.delete(v),E.done.delete(v);if((v.f&rn)!==0)if(v.f^=rn,v===a)hs(v,null,n);else{var O=f?f.next:a;v===t.effect.last&&(t.effect.last=v.prev),v.prev&&(v.prev.next=v.next),v.next&&(v.next.prev=v.prev),Tn(t,f,v),Tn(t,v,O),hs(v,O,n),f=v,d=[],p=[],a=ns(f.next);continue}if((v.f&ta)!==0&&(If(v),o&&(v.nodes?.a?.unfix(),(h??=new Set).delete(v))),v!==a){if(u!==void 0&&u.has(v)){if(d.length<p.length){var P=p[0],R;f=P.prev;var D=d[0],w=d[d.length-1];for(R=0;R<d.length;R+=1)hs(d[R],P,n);for(R=0;R<p.length;R+=1)u.delete(p[R]);Tn(t,D.prev,w.next),Tn(t,f,D),Tn(t,w,P),a=P,f=w,_-=1,d=[],p=[]}else u.delete(v),hs(v,a,n),Tn(t,v.prev,v.next),Tn(t,v,f===null?t.effect.first:f.next),Tn(t,f,v),f=v;continue}for(d=[],p=[];a!==null&&a!==v;)(u??=new Set).add(a),p.push(a),a=ns(a.next);if(a===null)continue}(v.f&rn)===0&&d.push(v),f=v,a=ns(v.next)}if(t.outrogroups!==null){for(const E of t.outrogroups)E.pending.size===0&&(Sa(t,xc(E.done)),t.outrogroups?.delete(E));t.outrogroups.size===0&&(t.outrogroups=null)}if(a!==null||u!==void 0){var A=[];if(u!==void 0)for(v of u)(v.f&ta)===0&&A.push(v);for(;a!==null;)(a.f&ta)===0&&a!==t.fallback&&A.push(a),a=ns(a.next);var S=A.length;if(S>0){var M=(r&Of)!==0&&i===0?n:null;if(o){for(_=0;_<S;_+=1)A[_].nodes?.a?.measure();for(_=0;_<S;_+=1)A[_].nodes?.a?.fix()}wm(t,A,M)}}o&&yc(()=>{if(h!==void 0)for(v of h)v.nodes?.a?.apply()})}function Cm(t,e,n,r,s,o,i,c){var a=(i&Kp)!==0?(i&Gp)===0?ya(n,!1,!1):Oo(n):null,u=(i&Jp)!==0?Oo(s):null;return{v:a,i:u,e:ks(()=>(o(e,a??n,u??s,c),()=>{t.delete(r)}))}}function hs(t,e,n){if(t.nodes)for(var r=t.nodes.start,s=t.nodes.end,o=e&&(e.f&rn)===0?e.nodes.start:n;r!==null;){var i=Zp(r);if(o.before(r),r===s)return;r=i}}function Tn(t,e,n){e===null?t.effect.first=n:e.next=n,n===null?t.effect.last=e:n.prev=e}function $f(t,e,...n){var r=new Df(t);_c(()=>{const s=e()??null;r.ensure(s,s&&(o=>s(o,...n)))},nm)}function Rm(t,e){var n=void 0,r;Af(()=>{n!==(n=e())&&(r&&(Ao(r),r=null),n&&(r=ks(()=>{Mf(()=>n(t))})))})}function Bf(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=Bf(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Im(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=Bf(t))&&(r&&(r+=" "),r+=e);return r}function yr(t){return typeof t=="object"?Im(t):t??""}const Kl=[...`
2
- \r\f \v\uFEFF`];function Em(t,e,n){var r=t==null?"":""+t;if(e&&(r=r?r+" "+e:e),n){for(var s of Object.keys(n))if(n[s])r=r?r+" "+s:s;else if(r.length)for(var o=s.length,i=0;(i=r.indexOf(s,i))>=0;){var c=i+o;(i===0||Kl.includes(r[i-1]))&&(c===r.length||Kl.includes(r[c]))?r=(i===0?"":r.substring(0,i))+r.substring(c+1):i=c}}return r===""?null:r}function Gl(t,e=!1){var n=e?" !important;":";",r="";for(var s of Object.keys(t)){var o=t[s];o!=null&&o!==""&&(r+=" "+s+": "+o+n)}return r}function na(t){return t[0]!=="-"||t[1]!=="-"?t.toLowerCase():t}function Om(t,e){if(e){var n="",r,s;if(Array.isArray(e)?(r=e[0],s=e[1]):r=e,t){t=String(t).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var o=!1,i=0,c=!1,a=[];r&&a.push(...Object.keys(r).map(na)),s&&a.push(...Object.keys(s).map(na));var u=0,f=-1;const x=t.length;for(var h=0;h<x;h++){var d=t[h];if(c?d==="/"&&t[h-1]==="*"&&(c=!1):o?o===d&&(o=!1):d==="/"&&t[h+1]==="*"?c=!0:d==='"'||d==="'"?o=d:d==="("?i++:d===")"&&i--,!c&&o===!1&&i===0){if(d===":"&&f===-1)f=h;else if(d===";"||h===x-1){if(f!==-1){var p=na(t.substring(u,f).trim());if(!a.includes(p)){d!==";"&&h++;var g=t.substring(u,h).trim();n+=" "+g+";"}}u=h+1,f=-1}}}}return r&&(n+=Gl(r)),s&&(n+=Gl(s,!0)),n=n.trim(),n===""?null:n}return t==null?null:String(t)}function Ie(t,e,n,r,s,o){var i=t.__className;if(Ye||i!==n||i===void 0){var c=Em(n,r,o);(!Ye||c!==t.getAttribute("class"))&&(c==null?t.removeAttribute("class"):e?t.className=c:t.setAttribute("class",c)),t.__className=n}else if(o&&s!==o)for(var a in o){var u=!!o[a];(s==null||u!==!!s[a])&&t.classList.toggle(a,u)}return o}function ra(t,e={},n,r){for(var s in n){var o=n[s];e[s]!==o&&(n[s]==null?t.style.removeProperty(s):t.style.setProperty(s,o,r))}}function Uf(t,e,n,r){var s=t.__style;if(Ye||s!==e){var o=Om(e,r);(!Ye||o!==t.getAttribute("style"))&&(o==null?t.removeAttribute("style"):t.style.cssText=o),t.__style=e}else r&&(Array.isArray(r)?(ra(t,n?.[0],r[0]),ra(t,n?.[1],r[1],"important")):ra(t,n,r));return r}function Mo(t,e,n=!1){if(t.multiple){if(e==null)return;if(!bc(e))return sm();for(var r of t.options)r.selected=e.includes(Jl(r));return}for(r of t.options){var s=Jl(r);if(om(s,e)){r.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function qf(t){var e=new MutationObserver(()=>{Mo(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),rm(()=>{e.disconnect()})}function Jl(t){return"__value"in t?t.__value:t.value}const ao=Symbol("class"),rs=Symbol("style"),zf=Symbol("is custom element"),Vf=Symbol("is html"),Am=Fs?"link":"LINK",Mm=Fs?"input":"INPUT",Nm=Fs?"option":"OPTION",Pm=Fs?"select":"SELECT",Fm=Fs?"progress":"PROGRESS";function Hf(t){if(Ye){var e=!1,n=()=>{if(!e){if(e=!0,t.hasAttribute("value")){var r=t.value;Me(t,"value",null),t.value=r}if(t.hasAttribute("checked")){var s=t.checked;Me(t,"checked",null),t.checked=s}}};t.__on_r=n,yc(n),am()}}function aE(t,e){var n=kc(t);n.value===(n.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==Fm)||(t.value=e??"")}function Lm(t,e){e?t.hasAttribute("selected")||t.setAttribute("selected",""):t.removeAttribute("selected")}function Me(t,e,n,r){var s=kc(t);Ye&&(s[e]=t.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&t.nodeName===Am)||s[e]!==(s[e]=n)&&(e==="loading"&&(t[cm]=n),n==null?t.removeAttribute(e):typeof n!="string"&&Wf(t).includes(e)?t[e]=n:t.setAttribute(e,n))}function jm(t,e,n,r,s=!1,o=!1){if(Ye&&s&&t.nodeName===Mm){var i=t,c=i.type==="checkbox"?"defaultChecked":"defaultValue";c in n||Hf(i)}var a=kc(t),u=a[zf],f=!a[Vf];let h=Ye&&u;h&&On(!1);var d=e||{},p=t.nodeName===Nm;for(var g in e)g in n||(n[g]=null);n.class?n.class=yr(n.class):n.class=null,n[rs]&&(n.style??=null);var x=Wf(t);for(const w in n){let A=n[w];if(p&&w==="value"&&A==null){t.value=t.__value="",d[w]=A;continue}if(w==="class"){var v=t.namespaceURI==="http://www.w3.org/1999/xhtml";Ie(t,v,A,r,e?.[ao],n[ao]),d[w]=A,d[ao]=n[ao];continue}if(w==="style"){Uf(t,A,e?.[rs],n[rs]),d[w]=A,d[rs]=n[rs];continue}var _=d[w];if(!(A===_&&!(A===void 0&&t.hasAttribute(w)))){d[w]=A;var O=w[0]+w[1];if(O!=="$$")if(O==="on"){const S={},M="$$"+w;let E=w.slice(2);var P=Mp(E);if(Ep(E)&&(E=E.slice(0,-7),S.capture=!0),!P&&_){if(A!=null)continue;t.removeEventListener(E,d[M],S),d[M]=null}if(P)ve(E,t,A),$t([E]);else if(A!=null){let $=function(Q){d[w].call(this,Q)};d[M]=Op(E,t,$,S)}}else if(w==="style")Me(t,w,A);else if(w==="autofocus")hm(t,!!A);else if(!u&&(w==="__value"||w==="value"&&A!=null))t.value=t.__value=A;else if(w==="selected"&&p)Lm(t,A);else{var R=w;f||(R=Ap(R));var D=R==="defaultValue"||R==="defaultChecked";if(A==null&&!u&&!D)if(a[w]=null,R==="value"||R==="checked"){let S=t;const M=e===void 0;if(R==="value"){let E=S.defaultValue;S.removeAttribute(R),S.defaultValue=E,S.value=S.__value=M?E:null}else{let E=S.defaultChecked;S.removeAttribute(R),S.defaultChecked=E,S.checked=M?E:!1}}else t.removeAttribute(w);else D||x.includes(R)&&(u||typeof A!="string")?(t[R]=A,R in a&&(a[R]=Rf)):typeof A!="function"&&Me(t,R,A)}}}return h&&On(!0),d}function Dm(t,e,n=[],r=[],s=[],o,i=!1,c=!1){um(s,n,r,a=>{var u=void 0,f={},h=t.nodeName===Pm,d=!1;if(Af(()=>{var g=e(...a.map(l)),x=jm(t,u,g,o,i,c);d&&h&&"value"in g&&Mo(t,g.value);for(let _ of Object.getOwnPropertySymbols(f))g[_]||Ao(f[_]);for(let _ of Object.getOwnPropertySymbols(g)){var v=g[_];_.description===fm&&(!u||v!==u[_])&&(f[_]&&Ao(f[_]),f[_]=ks(()=>Rm(t,()=>v))),x[_]=v}u=x}),h){var p=t;Mf(()=>{Mo(p,u.value,!0),qf(p)})}d=!0})}function kc(t){return t.__attributes??={[zf]:t.nodeName.includes("-"),[Vf]:t.namespaceURI===im}}var Yl=new Map;function Wf(t){var e=t.getAttribute("is")||t.nodeName,n=Yl.get(e);if(n)return n;Yl.set(e,n=[]);for(var r,s=t,o=Element.prototype;o!==s;){r=lm(s);for(var i in r)r[i].set&&n.push(i);s=wf(s)}return n}function $m(t,e,n=e){var r=new WeakSet;Nf(t,"input",async s=>{var o=s?t.defaultValue:t.value;if(o=sa(t)?oa(o):o,n(o),Dn!==null&&r.add(Dn),await Pf(),o!==(o=e())){var i=t.selectionStart,c=t.selectionEnd,a=t.value.length;if(t.value=o??"",c!==null){var u=t.value.length;i===c&&c===a&&u>a?(t.selectionStart=u,t.selectionEnd=u):(t.selectionStart=i,t.selectionEnd=Math.min(c,u))}}}),(Ye&&t.defaultValue!==t.value||Ff(e)==null&&t.value)&&(n(sa(t)?oa(t.value):t.value),Dn!==null&&r.add(Dn)),Lf(()=>{var s=e();if(t===document.activeElement){var o=Dn;if(r.has(o))return}sa(t)&&s===oa(t.value)||t.type==="date"&&!s&&!t.value||s!==t.value&&(t.value=s??"")})}function cE(t,e,n=e){Nf(t,"change",r=>{var s=r?t.defaultChecked:t.checked;n(s)}),(Ye&&t.defaultChecked!==t.checked||Ff(e)==null)&&n(t.checked),Lf(()=>{var r=e();t.checked=!!r})}function sa(t){var e=t.type;return e==="number"||e==="range"}function oa(t){return t===""?null:+t}const ci=`${ym}/api`,ln=async t=>{const e=await fetch(`${ci}${t}`);if(!e.ok)throw new Error(await e.text());return e.json()},un=async(t,e)=>{const n=await fetch(`${ci}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()},Kf=async t=>{const e=await fetch(`${ci}${t}`,{method:"DELETE"});if(!e.ok)throw new Error(await e.text());return e.json()},Bm=async(t,e)=>{const n=await fetch(`${ci}${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()},lE=()=>ln("/projects"),uE=t=>ln(`/sessions?project=${encodeURIComponent(t)}`),fE=(t,e)=>ln(`/session?project=${encodeURIComponent(t)}&id=${encodeURIComponent(e)}`),hE=(t,e)=>Kf(`/session?project=${encodeURIComponent(t)}&id=${encodeURIComponent(e)}`),dE=(t,e,n)=>un("/session/rename",{project:t,id:e,title:n}),Zl=(t,e,n,r)=>Kf(`/message?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}&uuid=${encodeURIComponent(n)}${r?`&targetType=${r}`:""}`),Um=(t,e,n,r)=>un(`/message?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}`,{message:n,index:r}),gE=(t,e,n,r)=>Bm(`/message?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}&uuid=${encodeURIComponent(n)}`,{customTitle:r}),pE=t=>ln("/cleanup"),mE=t=>un("/cleanup",t),vE=()=>ln("/version"),bE=()=>un("/shutdown",{}),qm=(t,e)=>un("/open-file",{sessionId:t,backupFileName:e}),Sc=t=>un("/open-file",{filePath:t}),_E=(t,e,n)=>un("/session/split",{project:t,sessionId:e,messageUuid:n}),yE=(t,e,n)=>un("/session/move",{sourceProject:t,sessionId:e,targetProject:n}),wa=async t=>{try{return(await ln(`/file-exists?path=${encodeURIComponent(t)}`)).exists}catch{return!1}},xE=(t,e)=>{const n=new URLSearchParams({q:t});return e?.project&&n.set("project",e.project),e?.searchContent&&n.set("content","true"),ln(`/search?${n}`)},kE=(t,e)=>{const n=new URLSearchParams({project:t});return e?.field&&n.set("sortField",e.field),e?.order&&n.set("sortOrder",e.order),ln(`/project/expand?${n.toString()}`)},SE=(t,e)=>ln(`/session/tree-data?project=${encodeURIComponent(t)}&id=${encodeURIComponent(e)}`),zm=(t,e,n)=>ln(`/agent/messages?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}&agent=${encodeURIComponent(n)}`),wE=(t,e)=>un("/session/resume",{projectName:t,sessionId:e}),Vm=(t,e)=>un(`/session/repair-chain?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}`,{}),Hm={},wc=Object.freeze(Object.defineProperty({__proto__:null,default:Hm},Symbol.toStringTag,{value:"Module"})),Wm=t=>typeof t=="function",k=function(t,e){if(typeof t=="function")return function(){return t(arguments)?e.apply(this,arguments):n=>e(n,...arguments)};switch(t){case 0:case 1:throw new RangeError(`Invalid arity ${t}`);case 2:return function(n,r){return arguments.length>=2?e(n,r):function(s){return e(s,n)}};case 3:return function(n,r,s){return arguments.length>=3?e(n,r,s):function(o){return e(o,n,r)}};case 4:return function(n,r,s,o){return arguments.length>=4?e(n,r,s,o):function(i){return e(i,n,r,s)}};case 5:return function(n,r,s,o,i){return arguments.length>=5?e(n,r,s,o,i):function(c){return e(c,n,r,s,o)}};default:return function(){if(arguments.length>=t)return e.apply(this,arguments);const n=arguments;return function(r){return e(r,...n)}}}},Le=t=>t,li=t=>()=>t,Ql=li(!0),Ta=li(!1),Gf=li(void 0),Km=Gf;function I(t,e,n,r,s,o,i,c,a){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return n(e(t));case 4:return r(n(e(t)));case 5:return s(r(n(e(t))));case 6:return o(s(r(n(e(t)))));case 7:return i(o(s(r(n(e(t))))));case 8:return c(i(o(s(r(n(e(t)))))));case 9:return a(c(i(o(s(r(n(e(t))))))));default:{let u=arguments[0];for(let f=1;f<arguments.length;f++)u=arguments[f](u);return u}}}const Tc=t=>(e,n)=>e===n||t(e,n),Gm=k(2,(t,e)=>Tc((n,r)=>t(e(n),e(r)))),Jm=t=>Tc((e,n)=>{if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r]))return!1;return!0}),Xl="effect/GlobalValue";let ss;const Ce=(t,e)=>(ss||(globalThis[Xl]??=new Map,ss=globalThis[Xl]),ss.has(t)||ss.set(t,e()),ss.get(t)),Ym=t=>typeof t=="string",Ca=t=>typeof t=="number",Zm=t=>typeof t=="bigint",ui=Wm,Qm=t=>typeof t=="object"&&t!==null,fi=t=>Qm(t)||ui(t),me=k(2,(t,e)=>fi(t)&&e in t),Jf=k(2,(t,e)=>me(t,"_tag")&&t._tag===e),ar=t=>t==null,Yf=t=>typeof t=="string"||me(t,Symbol.iterator),Xm=t=>me(t,"then")&&ui(t.then),hi=t=>`BUG: ${t} - please report an issue at https://github.com/Effect-TS/effect/issues`;let Zf=class Qf{self;called=!1;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(e){return{value:e,done:!0}}throw(e){throw e}[Symbol.iterator](){return new Qf(this.self)}};const ev=335903614,tv=4150755663,nv=1481765933,rv=1284865837,sv=9007199254740992,ov=134217728;class iv{_state;constructor(e,n,r,s){return ar(n)&&ar(e)?(n=Math.random()*4294967295>>>0,e=0):ar(n)&&(n=e,e=0),ar(s)&&ar(r)?(s=this._state?this._state[3]:tv,r=this._state?this._state[2]:ev):ar(s)&&(s=r,r=0),this._state=new Int32Array([0,0,r>>>0,((s||0)|1)>>>0]),this._next(),eu(this._state,this._state[0],this._state[1],e>>>0,n>>>0),this._next(),this}getState(){return[this._state[0],this._state[1],this._state[2],this._state[3]]}setState(e){this._state[0]=e[0],this._state[1]=e[1],this._state[2]=e[2],this._state[3]=e[3]|1}integer(e){return Math.round(this.number()*Number.MAX_SAFE_INTEGER)%e}number(){const e=(this._next()&67108863)*1,n=(this._next()&134217727)*1;return(e*ov+n)/sv}_next(){const e=this._state[0]>>>0,n=this._state[1]>>>0;av(this._state,e,n,nv,rv),eu(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let r=e>>>18,s=(n>>>18|e<<14)>>>0;r=(r^e)>>>0,s=(s^n)>>>0;const o=(s>>>27|r<<5)>>>0,i=e>>>27,c=(-i>>>0&31)>>>0;return(o>>>i|o<<c)>>>0}}function av(t,e,n,r,s){let o=(n>>>16)*(s&65535)>>>0,i=(n&65535)*(s>>>16)>>>0,c=(n&65535)*(s&65535)>>>0,a=(n>>>16)*(s>>>16)+((i>>>16)+(o>>>16))>>>0;i=i<<16>>>0,c=c+i>>>0,c>>>0<i>>>0&&(a=a+1>>>0),o=o<<16>>>0,c=c+o>>>0,c>>>0<o>>>0&&(a=a+1>>>0),a=a+Math.imul(n,r)>>>0,a=a+Math.imul(e,s)>>>0,t[0]=a,t[1]=c}function eu(t,e,n,r,s){let o=e+r>>>0;const i=n+s>>>0;i>>>0<n>>>0&&(o=o+1|0),t[0]=o,t[1]=i}const Ra=Symbol.for("effect/Utils/YieldWrap");class Ls{#e;constructor(e){this.#e=e}[Ra](){return this.#e}}function cv(t){if(typeof t=="object"&&t!==null&&Ra in t)return t[Ra]();throw new Error(hi("yieldWrapGet"))}const Lt=Ce("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0})),Xf={effect_internal_function:t=>t()},lv={effect_internal_function:t=>t()},uv=Xf.effect_internal_function(()=>new Error().stack)?.includes("effect_internal_function")===!0,bt=uv?Xf.effect_internal_function:lv.effect_internal_function,ia=Ce(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),de=Symbol.for("effect/Hash"),Z=t=>{if(Lt.enabled===!0)return 0;switch(typeof t){case"number":return Rc(t);case"bigint":return Ge(t.toString(10));case"boolean":return Ge(String(t));case"symbol":return Ge(String(t));case"string":return Ge(t);case"undefined":return Ge("undefined");case"function":case"object":return t===null?Ge("null"):t instanceof Date?Number.isNaN(t.getTime())?Ge("Invalid Date"):Z(t.toISOString()):t instanceof URL?Z(t.href):fv(t)?t[de]():Cc(t);default:throw new Error(`BUG: unhandled typeof ${typeof t} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Cc=t=>(ia.has(t)||ia.set(t,Rc(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),ia.get(t)),Se=t=>e=>e*53^t,di=t=>t&3221225471|t>>>1&1073741824,fv=t=>me(t,de),Rc=t=>{if(t!==t||t===1/0)return 0;let e=t|0;for(e!==t&&(e^=t*4294967295);t>4294967295;)e^=t/=4294967295;return di(e)},Ge=t=>{let e=5381,n=t.length;for(;n;)e=e*33^t.charCodeAt(--n);return di(e)},hv=(t,e)=>{let n=12289;for(let r=0;r<e.length;r++)n^=I(Ge(e[r]),Se(Z(t[e[r]])));return di(n)},eh=t=>hv(t,Object.keys(t)),js=t=>{let e=6151;for(let n=0;n<t.length;n++)e=I(e,Se(Z(t[n])));return di(e)},ze=function(){if(arguments.length===1){const n=arguments[0];return function(r){return Object.defineProperty(n,de,{value(){return r},enumerable:!1}),r}}const t=arguments[0],e=arguments[1];return Object.defineProperty(t,de,{value(){return e},enumerable:!1}),e},he=Symbol.for("effect/Equal");function ge(){return arguments.length===1?t=>No(t,arguments[0]):No(arguments[0],arguments[1])}function No(t,e){if(t===e)return!0;const n=typeof t;if(n!==typeof e)return!1;if(n==="object"||n==="function"){if(t!==null&&e!==null){if(Po(t)&&Po(e))return Z(t)===Z(e)&&t[he](e)?!0:Lt.enabled&&Lt.tester?Lt.tester(t,e):!1;if(t instanceof Date&&e instanceof Date){const r=t.getTime(),s=e.getTime();return r===s||Number.isNaN(r)&&Number.isNaN(s)}else if(t instanceof URL&&e instanceof URL)return t.href===e.href}if(Lt.enabled){if(Array.isArray(t)&&Array.isArray(e))return t.length===e.length&&t.every((r,s)=>No(r,e[s]));if(Object.getPrototypeOf(t)===Object.prototype&&Object.getPrototypeOf(e)===Object.prototype){const r=Object.keys(t),s=Object.keys(e);if(r.length===s.length){for(const o of r)if(!(o in e&&No(t[o],e[o])))return Lt.tester?Lt.tester(t,e):!1;return!0}}return Lt.tester?Lt.tester(t,e):!1}}return Lt.enabled&&Lt.tester?Lt.tester(t,e):!1}const Po=t=>me(t,he),Ic=()=>ge,Je=Symbol.for("nodejs.util.inspect.custom"),st=t=>{try{if(me(t,"toJSON")&&ui(t.toJSON)&&t.toJSON.length===0)return t.toJSON();if(Array.isArray(t))return t.map(st)}catch{return{}}return gv(t)},ct=t=>JSON.stringify(t,null,2),xr=(t,e=2)=>{if(typeof t=="string")return t;try{return typeof t=="object"?th(t,e):String(t)}catch{return String(t)}},th=(t,e)=>{let n=[];const r=JSON.stringify(t,(s,o)=>typeof o=="object"&&o!==null?n.includes(o)?void 0:n.push(o)&&(Vn.fiberRefs!==void 0&&nh(o)?o[Ec](Vn.fiberRefs):o):o,e);return n=void 0,r},Ec=Symbol.for("effect/Inspectable/Redactable"),nh=t=>typeof t=="object"&&t!==null&&Ec in t,Vn=Ce("effect/Inspectable/redactableState",()=>({fiberRefs:void 0})),dv=(t,e)=>{const n=Vn.fiberRefs;Vn.fiberRefs=t;try{return e()}finally{Vn.fiberRefs=n}},gv=t=>nh(t)&&Vn.fiberRefs!==void 0?t[Ec](Vn.fiberRefs):t,le=(t,e)=>{switch(e.length){case 0:return t;case 1:return e[0](t);case 2:return e[1](e[0](t));case 3:return e[2](e[1](e[0](t)));case 4:return e[3](e[2](e[1](e[0](t))));case 5:return e[4](e[3](e[2](e[1](e[0](t)))));case 6:return e[5](e[4](e[3](e[2](e[1](e[0](t))))));case 7:return e[6](e[5](e[4](e[3](e[2](e[1](e[0](t)))))));case 8:return e[7](e[6](e[5](e[4](e[3](e[2](e[1](e[0](t))))))));case 9:return e[8](e[7](e[6](e[5](e[4](e[3](e[2](e[1](e[0](t)))))))));default:{let n=t;for(let r=0,s=e.length;r<s;r++)n=e[r](n);return n}}},ms="Async",gi="Commit",Wt="Failure",aa="OnFailure",Fo="OnSuccess",Lo="OnSuccessAndFailure",Kt="Success",rh="Sync",pv="Tag",Ds="UpdateRuntimeFlags",jo="While",vs="Iterator",sh="WithRuntime",xo="Yield",Oc="RevertFlags";let mv="3.19.19";const Ac=()=>mv,vv=Symbol.for("effect/Effect"),bv=Symbol.for("effect/Stream"),_v=Symbol.for("effect/Sink"),yv=Symbol.for("effect/Channel"),kr={_R:t=>t,_E:t=>t,_A:t=>t,_V:Ac()},xv={_A:t=>t,_In:t=>t,_L:t=>t,_E:t=>t,_R:t=>t},kv={_Env:t=>t,_InErr:t=>t,_InElem:t=>t,_InDone:t=>t,_OutErr:t=>t,_OutElem:t=>t,_OutDone:t=>t},$s={[vv]:kr,[bv]:kr,[_v]:xv,[yv]:kv,[he](t){return this===t},[de](){return ze(this,Cc(this))},[Symbol.iterator](){return new Zf(new Ls(this))},pipe(){return le(this,arguments)}},Mc={[de](){return ze(this,eh(this))},[he](t){const e=Object.keys(this),n=Object.keys(t);if(e.length!==n.length)return!1;for(const r of e)if(!(r in t&&ge(this[r],t[r])))return!1;return!0}},Bs={...$s,_op:gi},Sv={...Bs,...Mc},wv=(function(){function t(){}return t.prototype=Bs,t})(),oh=Symbol.for("effect/Option"),ih={...$s,[oh]:{_A:t=>t},[Je](){return this.toJSON()},toString(){return ct(this.toJSON())}},Tv=Object.assign(Object.create(ih),{_tag:"Some",_op:"Some",[he](t){return ah(t)&&lh(t)&&ge(this.value,t.value)},[de](){return ze(this,Se(Z(this._tag))(Z(this.value)))},toJSON(){return{_id:"Option",_tag:this._tag,value:st(this.value)}}}),Cv=Z("None"),Rv=Object.assign(Object.create(ih),{_tag:"None",_op:"None",[he](t){return ah(t)&&ch(t)},[de](){return Cv},toJSON(){return{_id:"Option",_tag:this._tag}}}),ah=t=>me(t,oh),ch=t=>t._tag==="None",lh=t=>t._tag==="Some",uh=Object.create(Rv),Ia=t=>{const e=Object.create(Tv);return e.value=t,e},fh=Symbol.for("effect/Either"),hh={...$s,[fh]:{_R:t=>t},[Je](){return this.toJSON()},toString(){return ct(this.toJSON())}},Iv=Object.assign(Object.create(hh),{_tag:"Right",_op:"Right",[he](t){return dh(t)&&ph(t)&&ge(this.right,t.right)},[de](){return Se(Z(this._tag))(Z(this.right))},toJSON(){return{_id:"Either",_tag:this._tag,right:st(this.right)}}}),Ev=Object.assign(Object.create(hh),{_tag:"Left",_op:"Left",[he](t){return dh(t)&&gh(t)&&ge(this.left,t.left)},[de](){return Se(Z(this._tag))(Z(this.left))},toJSON(){return{_id:"Either",_tag:this._tag,left:st(this.left)}}}),dh=t=>me(t,fh),gh=t=>t._tag==="Left",ph=t=>t._tag==="Right",Ov=t=>{const e=Object.create(Ev);return e.left=t,e},Av=t=>{const e=Object.create(Iv);return e.right=t,e},bn=Av,Sr=Ov,ds=gh,co=ph,Mv=k(2,(t,{onLeft:e,onRight:n})=>ds(t)?e(t.left):n(t.right)),Nv=Mv({onLeft:Le,onRight:Le}),mh=t=>t.length>0,vh=t=>(e,n)=>e===n?0:t(e,n),Pv=vh((t,e)=>t<e?-1:1),Fv=k(2,(t,e)=>vh((n,r)=>t(e(n),e(r)))),Lv=t=>k(2,(e,n)=>t(e,n)===1),ce=()=>uh,ye=Ia,kt=ch,on=lh,sr=k(2,(t,{onNone:e,onSome:n})=>kt(t)?e():n(t.value)),Gn=k(2,(t,e)=>kt(t)?e():t.value),jv=k(2,(t,e)=>kt(t)?ye(e()):t),Nc=t=>t==null?ce():ye(t),Ln=Gn(Gf),Dv=k(2,(t,e)=>kt(t)?ce():ye(e(t.value))),$v=k(2,(t,e)=>kt(t)?ce():e(t.value)),Bv=t=>k(2,(e,n)=>kt(e)?!1:t(e.value,n)),Uv=Ic(),qv=Bv(Uv),zv=(...t)=>t,Pc=t=>new Array(t),Vv=k(2,(t,e)=>{const n=Math.max(1,Math.floor(t)),r=new Array(n);for(let s=0;s<n;s++)r[s]=e(s);return r}),Ze=t=>Array.isArray(t)?t:Array.from(t),Hv=t=>Array.isArray(t)?t:[t],Do=k(2,(t,e)=>[e,...t]),Wv=k(2,(t,e)=>[...t,e]),bh=k(2,(t,e)=>Ze(t).concat(Ze(e))),Kv=t=>t.length===0,Gv=Kv,Jv=mh,Et=mh,_h=(t,e)=>t<0||t>=e.length,Yv=(t,e)=>Math.floor(Math.min(Math.max(0,t),e.length)),Zv=k(2,(t,e)=>{const n=Math.floor(e);return _h(n,t)?ce():ye(t[n])}),yh=k(2,(t,e)=>{const n=Math.floor(e);if(_h(n,t))throw new Error(`Index ${n} out of bounds`);return t[n]}),bs=Zv(0),Tt=yh(0),Qv=t=>Et(t)?ye(xh(t)):ce(),xh=t=>t[t.length-1],wr=t=>t.slice(1),Xv=(t,e)=>{let n=0;for(const r of t){if(!e(r,n))break;n++}return n},eb=k(2,(t,e)=>sb(t,Xv(t,e))),tb=k(2,(t,e)=>{const n=Ze(t);return n.slice(Yv(e,n),n.length)}),tu=t=>Array.from(t).reverse(),$o=k(2,(t,e)=>{const n=Array.from(t);return n.sort(e),n}),nu=k(2,(t,e)=>nb(t,e,zv)),nb=k(3,(t,e,n)=>{const r=Ze(t),s=Ze(e);if(Et(r)&&Et(s)){const o=[n(Tt(r),Tt(s))],i=Math.min(r.length,s.length);for(let c=1;c<i;c++)o[c]=n(r[c],s[c]);return o}return[]}),rb=Ic(),sb=k(2,(t,e)=>{const n=Array.from(t),r=Math.floor(e);return Et(n)?r>=1?ob(n,r):[[],n]:[n,[]]}),ob=k(2,(t,e)=>{const n=Math.max(1,Math.floor(e));return n>=t.length?[ib(t),[]]:[Do(t.slice(1,n),Tt(t)),t.slice(n)]}),ib=t=>t.slice(),ab=k(3,(t,e,n)=>{const r=Ze(t),s=Ze(e);return Et(r)?Et(s)?Sh(n)(bh(r,s)):r:s}),ko=k(2,(t,e)=>ab(t,e,rb)),Tr=()=>[],Ut=t=>[t],dr=k(2,(t,e)=>t.map(e)),cb=k(2,(t,e)=>{if(Gv(t))return[];const n=[];for(let r=0;r<t.length;r++){const s=e(t[r],r);for(let o=0;o<s.length;o++)n.push(s[o])}return n}),lb=cb(Le),kh=k(3,(t,e,n)=>Ze(t).reduce((r,s,o)=>n(r,s,o),e)),ru=(t,e)=>{const n=[];let r=t,s;for(;on(s=e(r));){const[o,i]=s.value;n.push(o),r=i}return n},Fc=Jm,Sh=k(2,(t,e)=>{const n=Ze(t);if(Et(n)){const r=[Tt(n)],s=wr(n);for(const o of s)r.every(i=>!e(o,i))&&r.push(o);return r}return[]}),ub=t=>Sh(t,Ic()),zr=k(2,(t,e)=>Ze(t).join(e)),Ss=Pv,fb=t=>t.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&"),hb=Symbol.for("effect/Context/Tag"),Bo=Symbol.for("effect/Context/Reference"),db="effect/STM",gb=Symbol.for(db),wh={...$s,_op:"Tag",[gb]:kr,[hb]:{_Service:t=>t,_Identifier:t=>t},toString(){return ct(this.toJSON())},toJSON(){return{_id:"Tag",key:this.key,stack:this.stack}},[Je](){return this.toJSON()},of(t){return t},context(t){return Ch(this,t)}},pb={...wh,[Bo]:Bo},mb=t=>{const e=Error.stackTraceLimit;Error.stackTraceLimit=2;const n=new Error;Error.stackTraceLimit=e;const r=Object.create(wh);return Object.defineProperty(r,"stack",{get(){return n.stack}}),r.key=t,r},vb=()=>(t,e)=>{const n=Error.stackTraceLimit;Error.stackTraceLimit=2;const r=new Error;Error.stackTraceLimit=n;function s(){}return Object.setPrototypeOf(s,pb),s.key=t,s.defaultValue=e.defaultValue,Object.defineProperty(s,"stack",{get(){return r.stack}}),s},Th=Symbol.for("effect/Context"),bb={[Th]:{_Services:t=>t},[he](t){if(yb(t)&&this.unsafeMap.size===t.unsafeMap.size){for(const e of this.unsafeMap.keys())if(!t.unsafeMap.has(e)||!ge(this.unsafeMap.get(e),t.unsafeMap.get(e)))return!1;return!0}return!1},[de](){return ze(this,Rc(this.unsafeMap.size))},pipe(){return le(this,arguments)},toString(){return ct(this.toJSON())},toJSON(){return{_id:"Context",services:Array.from(this.unsafeMap).map(st)}},[Je](){return this.toJSON()}},Cr=t=>{const e=Object.create(bb);return e.unsafeMap=t,e},_b=t=>{const e=new Error(`Service not found${t.key?`: ${String(t.key)}`:""}`);if(t.stack){const n=t.stack.split(`
3
- `);if(n.length>2){const r=n[2].match(/at (.*)/);r&&(e.message=e.message+` (defined at ${r[1]})`)}}if(e.stack){const n=e.stack.split(`
4
- `);n.splice(1,3),e.stack=n.join(`
5
- `)}return e},yb=t=>me(t,Th),xb=t=>me(t,Bo),kb=Cr(new Map),Sb=()=>kb,Ch=(t,e)=>Cr(new Map([[t.key,e]])),wb=k(3,(t,e,n)=>{const r=new Map(t.unsafeMap);return r.set(e.key,n),Cr(r)}),ca=Ce("effect/Context/defaultValueCache",()=>new Map),Lc=t=>{if(ca.has(t.key))return ca.get(t.key);const e=t.defaultValue();return ca.set(t.key,e),e},Tb=(t,e)=>t.unsafeMap.has(e.key)?t.unsafeMap.get(e.key):Lc(e),Rh=k(2,(t,e)=>{if(!t.unsafeMap.has(e.key)){if(Bo in e)return Lc(e);throw _b(e)}return t.unsafeMap.get(e.key)}),Cb=Rh,Rb=k(2,(t,e)=>t.unsafeMap.has(e.key)?Ia(t.unsafeMap.get(e.key)):xb(e)?Ia(Lc(e)):uh),Ib=k(2,(t,e)=>{const n=new Map(t.unsafeMap);for(const[r,s]of e.unsafeMap)n.set(r,s);return Cr(n)}),or=mb,Ih=Sb,Eb=Ch,os=wb,Eh=Cb,Oh=Rh,Us=Rb,Ah=Ib,Mh=vb,Nh=Symbol.for("effect/Chunk");function Ob(t,e,n,r,s){for(let o=e;o<Math.min(t.length,e+s);o++)n[r+o-e]=t[o];return n}const Ph=[],Ab=t=>Tc((e,n)=>e.length===n.length&&Hn(e).every((r,s)=>t(r,gr(n,s)))),Mb=Ab(ge),Nb={[Nh]:{_A:t=>t},toString(){return ct(this.toJSON())},toJSON(){return{_id:"Chunk",values:Hn(this).map(st)}},[Je](){return this.toJSON()},[he](t){return Fh(t)&&Mb(this,t)},[de](){return ze(this,js(Hn(this)))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return Ph[Symbol.iterator]();default:return Hn(this)[Symbol.iterator]()}},pipe(){return le(this,arguments)}},tt=t=>{const e=Object.create(Nb);switch(e.backing=t,t._tag){case"IEmpty":{e.length=0,e.depth=0,e.left=e,e.right=e;break}case"IConcat":{e.length=t.left.length+t.right.length,e.depth=1+Math.max(t.left.depth,t.right.depth),e.left=t.left,e.right=t.right;break}case"IArray":{e.length=t.array.length,e.depth=0,e.left=nn,e.right=nn;break}case"ISingleton":{e.length=1,e.depth=0,e.left=nn,e.right=nn;break}case"ISlice":{e.length=t.length,e.depth=t.chunk.depth+1,e.left=nn,e.right=nn;break}}return e},Fh=t=>me(t,Nh),nn=tt({_tag:"IEmpty"}),xn=()=>nn,la=(...t)=>Lb(t),Ot=t=>tt({_tag:"ISingleton",a:t}),Lh=t=>Fh(t)?t:pi(Ze(t)),Ea=(t,e,n)=>{switch(t.backing._tag){case"IArray":{Ob(t.backing.array,0,e,n,t.length);break}case"IConcat":{Ea(t.left,e,n),Ea(t.right,e,n+t.left.length);break}case"ISingleton":{e[n]=t.backing.a;break}case"ISlice":{let r=0,s=n;for(;r<t.length;)e[s]=gr(t,r),r+=1,s+=1;break}}},Pb=t=>{switch(t.backing._tag){case"IEmpty":return Ph;case"IArray":return t.backing.array;default:{const e=new Array(t.length);return Ea(t,e,0),t.backing={_tag:"IArray",array:e},t.left=nn,t.right=nn,t.depth=0,e}}},Hn=Pb,Fb=t=>{switch(t.backing._tag){case"IEmpty":case"ISingleton":return t;case"IArray":return tt({_tag:"IArray",array:tu(t.backing.array)});case"IConcat":return tt({_tag:"IConcat",left:Rr(t.backing.right),right:Rr(t.backing.left)});case"ISlice":return pi(tu(Hn(t)))}},Rr=Fb,pi=t=>t.length===0?xn():t.length===1?Ot(t[0]):tt({_tag:"IArray",array:t}),Lb=t=>pi(t),gr=k(2,(t,e)=>{switch(t.backing._tag){case"IEmpty":throw new Error("Index out of bounds");case"ISingleton":{if(e!==0)throw new Error("Index out of bounds");return t.backing.a}case"IArray":{if(e>=t.length||e<0)throw new Error("Index out of bounds");return t.backing.array[e]}case"IConcat":return e<t.left.length?gr(t.left,e):gr(t.right,e-t.left.length);case"ISlice":return gr(t.backing.chunk,e+t.backing.offset)}}),jb=k(2,(t,e)=>Vt(t,Ot(e))),Gt=k(2,(t,e)=>Vt(Ot(e),t)),Oa=k(2,(t,e)=>{if(e<=0)return t;if(e>=t.length)return nn;switch(t.backing._tag){case"ISlice":return tt({_tag:"ISlice",chunk:t.backing.chunk,offset:t.backing.offset+e,length:t.backing.length-e});case"IConcat":return e>t.left.length?Oa(t.right,e-t.left.length):tt({_tag:"IConcat",left:Oa(t.left,e),right:t.right});default:return tt({_tag:"ISlice",chunk:t,offset:e,length:t.length-e})}}),Vt=k(2,(t,e)=>{if(t.backing._tag==="IEmpty")return e;if(e.backing._tag==="IEmpty")return t;const n=e.depth-t.depth;if(Math.abs(n)<=1)return tt({_tag:"IConcat",left:t,right:e});if(n<-1)if(t.left.depth>=t.right.depth){const r=Vt(t.right,e);return tt({_tag:"IConcat",left:t.left,right:r})}else{const r=Vt(t.right.right,e);if(r.depth===t.depth-3){const s=tt({_tag:"IConcat",left:t.right.left,right:r});return tt({_tag:"IConcat",left:t.left,right:s})}else{const s=tt({_tag:"IConcat",left:t.left,right:t.right.left});return tt({_tag:"IConcat",left:s,right:r})}}else if(e.right.depth>=e.left.depth){const r=Vt(t,e.left);return tt({_tag:"IConcat",left:r,right:e.right})}else{const r=Vt(t,e.left.left);if(r.depth===e.depth-3){const s=tt({_tag:"IConcat",left:r,right:e.left.right});return tt({_tag:"IConcat",left:s,right:e.right})}else{const s=tt({_tag:"IConcat",left:e.left.right,right:e.right});return tt({_tag:"IConcat",left:r,right:s})}}}),Db=t=>t.length===0,Ir=t=>t.length>0,jh=t=>gr(t,0),Er=jh,Bn=t=>Oa(t,1),Aa=Symbol.for("effect/Duration"),Dh=BigInt(0),su=BigInt(24),lo=BigInt(60),Ma=BigInt(1e3),ou=BigInt(1e6),iu=BigInt(1e9),$b=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,kn=t=>{if($h(t))return t;if(Ca(t))return Na(t);if(Zm(t))return ua(t);if(Array.isArray(t)&&t.length===2&&t.every(Ca))return t[0]===-1/0||t[1]===-1/0||Number.isNaN(t[0])||Number.isNaN(t[1])?Bh:t[0]===1/0||t[1]===1/0?zb:ua(BigInt(Math.round(t[0]*1e9))+BigInt(Math.round(t[1])));if(Ym(t)){const e=$b.exec(t);if(e){const[n,r,s]=e,o=Number(r);switch(s){case"nano":case"nanos":return ua(BigInt(r));case"micro":case"micros":return Vb(BigInt(r));case"milli":case"millis":return Na(o);case"second":case"seconds":return Hb(o);case"minute":case"minutes":return Wb(o);case"hour":case"hours":return Kb(o);case"day":case"days":return Gb(o);case"week":case"weeks":return Jb(o)}}}throw new Error("Invalid DurationInput")},au={_tag:"Millis",millis:0},Bb={_tag:"Infinity"},Ub={[Aa]:Aa,[de](){return ze(this,eh(this.value))},[he](t){return $h(t)&&n_(this,t)},toString(){return`Duration(${s_(this)})`},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",hrtime:Zb(this)};case"Infinity":return{_id:"Duration",_tag:"Infinity"}}},[Je](){return this.toJSON()},pipe(){return le(this,arguments)}},fn=t=>{const e=Object.create(Ub);return Ca(t)?isNaN(t)||t<=0?e.value=au:Number.isFinite(t)?Number.isInteger(t)?e.value={_tag:"Millis",millis:t}:e.value={_tag:"Nanos",nanos:BigInt(Math.round(t*1e6))}:e.value=Bb:t<=Dh?e.value=au:e.value={_tag:"Nanos",nanos:t},e},$h=t=>me(t,Aa),qb=t=>{switch(t.value._tag){case"Millis":return t.value.millis===0;case"Nanos":return t.value.nanos===Dh;case"Infinity":return!1}},Bh=fn(0),zb=fn(1/0),ua=t=>fn(t),Vb=t=>fn(t*Ma),Na=t=>fn(t),Hb=t=>fn(t*1e3),Wb=t=>fn(t*6e4),Kb=t=>fn(t*36e5),Gb=t=>fn(t*864e5),Jb=t=>fn(t*6048e5),Pa=t=>Qb(t,{onMillis:e=>e,onNanos:e=>Number(e)/1e6}),Yb=t=>{const e=kn(t);switch(e.value._tag){case"Infinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return e.value.nanos;case"Millis":return BigInt(Math.round(e.value.millis*1e6))}},Zb=t=>{const e=kn(t);switch(e.value._tag){case"Infinity":return[1/0,0];case"Nanos":return[Number(e.value.nanos/iu),Number(e.value.nanos%iu)];case"Millis":return[Math.floor(e.value.millis/1e3),Math.round(e.value.millis%1e3*1e6)]}},Qb=k(2,(t,e)=>{const n=kn(t);switch(n.value._tag){case"Nanos":return e.onNanos(n.value.nanos);case"Infinity":return e.onMillis(1/0);case"Millis":return e.onMillis(n.value.millis)}}),jc=k(3,(t,e,n)=>{const r=kn(t),s=kn(e);if(r.value._tag==="Infinity"||s.value._tag==="Infinity")return n.onMillis(Pa(r),Pa(s));if(r.value._tag==="Nanos"||s.value._tag==="Nanos"){const o=r.value._tag==="Nanos"?r.value.nanos:BigInt(Math.round(r.value.millis*1e6)),i=s.value._tag==="Nanos"?s.value.nanos:BigInt(Math.round(s.value.millis*1e6));return n.onNanos(o,i)}return n.onMillis(r.value.millis,s.value.millis)}),Xb=(t,e)=>jc(t,e,{onMillis:(n,r)=>n===r,onNanos:(n,r)=>n===r}),e_=k(2,(t,e)=>jc(t,e,{onMillis:(n,r)=>n<=r,onNanos:(n,r)=>n<=r})),t_=k(2,(t,e)=>jc(t,e,{onMillis:(n,r)=>n>=r,onNanos:(n,r)=>n>=r})),n_=k(2,(t,e)=>Xb(kn(t),kn(e))),r_=t=>{const e=kn(t);if(e.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};const n=Yb(e),r=n/ou,s=r/Ma,o=s/lo,i=o/lo,c=i/su;return{days:Number(c),hours:Number(i%su),minutes:Number(o%lo),seconds:Number(s%lo),millis:Number(r%Ma),nanos:Number(n%ou)}},s_=t=>{const e=kn(t);if(e.value._tag==="Infinity")return"Infinity";if(qb(e))return"0";const n=r_(e),r=[];return n.days!==0&&r.push(`${n.days}d`),n.hours!==0&&r.push(`${n.hours}h`),n.minutes!==0&&r.push(`${n.minutes}m`),n.seconds!==0&&r.push(`${n.seconds}s`),n.millis!==0&&r.push(`${n.millis}ms`),n.nanos!==0&&r.push(`${n.nanos}ns`),r.join(" ")},Jn=5,Dc=Math.pow(2,Jn),o_=Dc-1,i_=Dc/2,a_=Dc/4;function c_(t){return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,t&127}function Or(t,e){return e>>>t&o_}function fr(t){return 1<<t}function Uh(t,e){return c_(t&e-1)}const l_=(t,e)=>({value:t,previous:e});function pr(t,e,n,r){let s=r;if(!t){const o=r.length;s=new Array(o);for(let i=0;i<o;++i)s[i]=r[i]}return s[e]=n,s}function qh(t,e,n){const r=n.length-1;let s=0,o=0,i=n;if(t)s=o=e;else for(i=new Array(r);s<e;)i[o++]=n[s++];for(++s;s<=r;)i[o++]=n[s++];return t&&(i.length=r),i}function u_(t,e,n,r){const s=r.length;if(t){let a=s;for(;a>=e;)r[a--]=r[a];return r[e]=n,r}let o=0,i=0;const c=new Array(s+1);for(;o<e;)c[i++]=r[o++];for(c[e]=n;o<s;)c[++i]=r[o++];return c}class An{_tag="EmptyNode";modify(e,n,r,s,o,i){const c=r(ce());return kt(c)?new An:(++i.value,new Wn(e,s,o,c))}}function Ht(t){return Jf(t,"EmptyNode")}function f_(t){return Ht(t)||t._tag==="LeafNode"||t._tag==="CollisionNode"}function mi(t,e){return Ht(t)?!1:e===t.edit}class Wn{edit;hash;key;value;_tag="LeafNode";constructor(e,n,r,s){this.edit=e,this.hash=n,this.key=r,this.value=s}modify(e,n,r,s,o,i){if(ge(o,this.key)){const a=r(this.value);return a===this.value?this:kt(a)?(--i.value,new An):mi(this,e)?(this.value=a,this):new Wn(e,s,o,a)}const c=r(ce());return kt(c)?this:(++i.value,zh(e,n,this.hash,this,s,new Wn(e,s,o,c)))}}class $c{edit;hash;children;_tag="CollisionNode";constructor(e,n,r){this.edit=e,this.hash=n,this.children=r}modify(e,n,r,s,o,i){if(s===this.hash){const a=mi(this,e),u=this.updateCollisionList(a,e,this.hash,this.children,r,o,i);return u===this.children?this:u.length>1?new $c(e,this.hash,u):u[0]}const c=r(ce());return kt(c)?this:(++i.value,zh(e,n,this.hash,this,s,new Wn(e,s,o,c)))}updateCollisionList(e,n,r,s,o,i,c){const a=s.length;for(let f=0;f<a;++f){const h=s[f];if("key"in h&&ge(i,h.key)){const d=h.value,p=o(d);return p===d?s:kt(p)?(--c.value,qh(e,f,s)):pr(e,f,new Wn(n,r,i,p),s)}}const u=o(ce());return kt(u)?s:(++c.value,pr(e,a,new Wn(n,r,i,u),s))}}class Ar{edit;mask;children;_tag="IndexedNode";constructor(e,n,r){this.edit=e,this.mask=n,this.children=r}modify(e,n,r,s,o,i){const c=this.mask,a=this.children,u=Or(n,s),f=fr(u),h=Uh(c,f),d=c&f,p=mi(this,e);if(!d){const O=new An().modify(e,n+Jn,r,s,o,i);return O?a.length>=i_?d_(e,u,O,c,a):new Ar(e,c|f,u_(p,h,O,a)):this}const g=a[h],x=g.modify(e,n+Jn,r,s,o,i);if(g===x)return this;let v=c,_;if(Ht(x)){if(v&=~f,!v)return new An;if(a.length<=2&&f_(a[h^1]))return a[h^1];_=qh(p,h,a)}else _=pr(p,h,x,a);return p?(this.mask=v,this.children=_,this):new Ar(e,v,_)}}class Bc{edit;size;children;_tag="ArrayNode";constructor(e,n,r){this.edit=e,this.size=n,this.children=r}modify(e,n,r,s,o,i){let c=this.size;const a=this.children,u=Or(n,s),f=a[u],h=(f||new An).modify(e,n+Jn,r,s,o,i);if(f===h)return this;const d=mi(this,e);let p;if(Ht(f)&&!Ht(h))++c,p=pr(d,u,h,a);else if(!Ht(f)&&Ht(h)){if(--c,c<=a_)return h_(e,c,u,a);p=pr(d,u,new An,a)}else p=pr(d,u,h,a);return d?(this.size=c,this.children=p,this):new Bc(e,c,p)}}function h_(t,e,n,r){const s=new Array(e-1);let o=0,i=0;for(let c=0,a=r.length;c<a;++c)if(c!==n){const u=r[c];u&&!Ht(u)&&(s[o++]=u,i|=1<<c)}return new Ar(t,i,s)}function d_(t,e,n,r,s){const o=[];let i=r,c=0;for(let a=0;i;++a)i&1&&(o[a]=s[c++]),i>>>=1;return o[e]=n,new Bc(t,c+1,o)}function g_(t,e,n,r,s,o){if(n===s)return new $c(t,n,[o,r]);const i=Or(e,n),c=Or(e,s);if(i===c)return a=>new Ar(t,fr(i)|fr(c),[a]);{const a=i<c?[r,o]:[o,r];return new Ar(t,fr(i)|fr(c),a)}}function zh(t,e,n,r,s,o){let i,c=e;for(;;){const a=g_(t,c,n,r,s,o);if(typeof a=="function")i=l_(a,i),c=c+Jn;else{let u=a;for(;i!=null;)u=i.value(u),i=i.previous;return u}}}const Vh="effect/HashMap",Fa=Symbol.for(Vh),p_={[Fa]:Fa,[Symbol.iterator](){return new vi(this,(t,e)=>[t,e])},[de](){let t=Z(Vh);for(const e of this)t^=I(Z(e[0]),Se(Z(e[1])));return ze(this,t)},[he](t){if(b_(t)){if(t._size!==this._size)return!1;for(const e of this){const n=I(t,qc(e[0],Z(e[0])));if(kt(n))return!1;if(!ge(e[1],n.value))return!1}return!0}return!1},toString(){return ct(this.toJSON())},toJSON(){return{_id:"HashMap",values:Array.from(this).map(st)}},[Je](){return this.toJSON()},pipe(){return le(this,arguments)}},Uc=(t,e,n,r)=>{const s=Object.create(p_);return s._editable=t,s._edit=e,s._root=n,s._size=r,s};class vi{map;f;v;constructor(e,n){this.map=e,this.f=n,this.v=Hh(this.map._root,this.f,void 0)}next(){if(kt(this.v))return{done:!0,value:void 0};const e=this.v.value;return this.v=Uo(e.cont),{done:!1,value:e.value}}[Symbol.iterator](){return new vi(this.map,this.f)}}const Uo=t=>t?Wh(t[0],t[1],t[2],t[3],t[4]):ce(),Hh=(t,e,n=void 0)=>{switch(t._tag){case"LeafNode":return on(t.value)?ye({value:e(t.key,t.value.value),cont:n}):Uo(n);case"CollisionNode":case"ArrayNode":case"IndexedNode":{const r=t.children;return Wh(r.length,r,0,e,n)}default:return Uo(n)}},Wh=(t,e,n,r,s)=>{for(;n<t;){const o=e[n++];if(o&&!Ht(o))return Hh(o,r,[t,e,n,r,s])}return Uo(s)},m_=Uc(!1,0,new An,0),bi=()=>m_,v_=t=>{const e=Gh(bi());for(const n of t)ws(e,n[0],n[1]);return S_(e)},b_=t=>me(t,Fa),__=t=>t&&Ht(t._root),y_=k(2,(t,e)=>qc(t,e,Z(e))),qc=k(3,(t,e,n)=>{let r=t._root,s=0;for(;;)switch(r._tag){case"LeafNode":return ge(e,r.key)?r.value:ce();case"CollisionNode":{if(n===r.hash){const o=r.children;for(let i=0,c=o.length;i<c;++i){const a=o[i];if("key"in a&&ge(e,a.key))return a.value}}return ce()}case"IndexedNode":{const o=Or(s,n),i=fr(o);if(r.mask&i){r=r.children[Uh(r.mask,i)],s+=Jn;break}return ce()}case"ArrayNode":{if(r=r.children[Or(s,n)],r){s+=Jn;break}return ce()}default:return ce()}}),x_=k(2,(t,e)=>on(qc(t,e,Z(e)))),ws=k(3,(t,e,n)=>zc(t,e,()=>ye(n))),k_=k(3,(t,e,n)=>t._editable?(t._root=e,t._size=n,t):e===t._root?t:Uc(t._editable,t._edit,e,n)),Kh=t=>new vi(t,e=>e),La=t=>t._size,Gh=t=>Uc(!0,t._edit+1,t._root,t._size),S_=t=>(t._editable=!1,t),zc=k(3,(t,e,n)=>w_(t,e,Z(e),n)),w_=k(4,(t,e,n,r)=>{const s={value:t._size},o=t._root.modify(t._editable?t._edit:NaN,0,r,n,e,s);return I(t,k_(o,s.value))}),cu=k(2,(t,e)=>zc(t,e,ce)),T_=k(2,(t,e)=>_i(t,bi(),(n,r,s)=>ws(n,s,e(r,s)))),C_=k(2,(t,e)=>_i(t,void 0,(n,r,s)=>e(r,s))),_i=k(3,(t,e,n)=>{const r=t._root;if(r._tag==="LeafNode")return on(r.value)?n(e,r.value.value,r.key):e;if(r._tag==="EmptyNode")return e;const s=[r.children];let o;for(;o=s.pop();)for(let i=0,c=o.length;i<c;){const a=o[i++];a&&!Ht(a)&&(a._tag==="LeafNode"?on(a.value)&&(e=n(e,a.value.value,a.key)):s.push(a.children))}return e}),Jh="effect/HashSet",ja=Symbol.for(Jh),R_={[ja]:ja,[Symbol.iterator](){return Kh(this._keyMap)},[de](){return ze(this,Se(Z(this._keyMap))(Z(Jh)))},[he](t){return I_(t)?La(this._keyMap)===La(t._keyMap)&&ge(this._keyMap,t._keyMap):!1},toString(){return ct(this.toJSON())},toJSON(){return{_id:"HashSet",values:Array.from(this).map(st)}},[Je](){return this.toJSON()},pipe(){return le(this,arguments)}},yi=t=>{const e=Object.create(R_);return e._keyMap=t,e},I_=t=>me(t,ja),E_=yi(bi()),xi=()=>E_,O_=t=>{const e=Vc(xi());for(const n of t)Ts(e,n);return Hc(e)},A_=(...t)=>{const e=Vc(xi());for(const n of t)Ts(e,n);return Hc(e)},M_=k(2,(t,e)=>x_(t._keyMap,e)),N_=t=>La(t._keyMap),Vc=t=>yi(Gh(t._keyMap)),Hc=t=>(t._keyMap._editable=!1,t),Yh=k(2,(t,e)=>{const n=Vc(t);return e(n),Hc(n)}),Ts=k(2,(t,e)=>t._keyMap._editable?(ws(e,!0)(t._keyMap),t):yi(ws(e,!0)(t._keyMap))),Zh=k(2,(t,e)=>t._keyMap._editable?(cu(e)(t._keyMap),t):yi(cu(e)(t._keyMap))),P_=k(2,(t,e)=>Yh(t,n=>{for(const r of e)Zh(n,r)})),F_=k(2,(t,e)=>Yh(xi(),n=>{L_(t,r=>Ts(n,r));for(const r of e)Ts(n,r)})),L_=k(2,(t,e)=>C_(t._keyMap,(n,r)=>e(r))),j_=k(3,(t,e,n)=>_i(t._keyMap,e,(r,s,o)=>n(r,o))),Yn=xi,D_=O_,Wc=A_,$_=M_,Qh=N_,_s=Ts,Xh=Zh,lu=P_,Cs=F_,qo=j_,uu=Symbol.for("effect/MutableRef"),B_={[uu]:uu,toString(){return ct(this.toJSON())},toJSON(){return{_id:"MutableRef",current:st(this.current)}},[Je](){return this.toJSON()},pipe(){return le(this,arguments)}},ed=t=>{const e=Object.create(B_);return e.current=t,e},ki=t=>t.current,td=k(2,(t,e)=>(t.current=e,t)),Kc="effect/FiberId",Rs=Symbol.for(Kc),zo="None",Da="Runtime",U_="Composite",q_=Ge(`${Kc}-${zo}`);let z_=class{[Rs]=Rs;_tag=zo;id=-1;startTimeMillis=-1;[de](){return q_}[he](e){return nd(e)&&e._tag===zo}toString(){return ct(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag}}[Je](){return this.toJSON()}};class V_{id;startTimeMillis;[Rs]=Rs;_tag=Da;constructor(e,n){this.id=e,this.startTimeMillis=n}[de](){return ze(this,Ge(`${Kc}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[he](e){return nd(e)&&e._tag===Da&&this.id===e.id&&this.startTimeMillis===e.startTimeMillis}toString(){return ct(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[Je](){return this.toJSON()}}const H_=new z_,nd=t=>me(t,Rs),$a=t=>{switch(t._tag){case zo:return Yn();case Da:return Wc(t.id);case U_:return I($a(t.left),Cs($a(t.right)))}},fu=Ce(Symbol.for("effect/Fiber/Id/_fiberCounter"),()=>ed(0)),rd=t=>Array.from($a(t)).map(n=>`#${n}`).join(","),W_=()=>{const t=ki(fu);return I(fu,td(t+1)),new V_(t,Date.now())},Mr=H_,K_=rd,G_=W_,Gc=bi,J_=v_,Y_=__,sd=y_,od=ws,id=Kh,Z_=zc,Q_=T_,ad=_i,Is=Symbol.for("effect/List"),Ba=t=>Ze(t),X_=t=>Gm(Fc(t),Ba),ey=X_(ge),ty={[Is]:Is,_tag:"Cons",toString(){return ct(this.toJSON())},toJSON(){return{_id:"List",_tag:"Cons",values:Ba(this).map(st)}},[Je](){return this.toJSON()},[he](t){return ld(t)&&this._tag===t._tag&&ey(this,t)},[de](){return ze(this,js(Ba(this)))},[Symbol.iterator](){let t=!1,e=this;return{next(){if(t)return this.return();if(e._tag==="Nil")return t=!0,this.return();const n=e.head;return e=e.tail,{done:t,value:n}},return(n){return t||(t=!0),{done:!0,value:n}}}},pipe(){return le(this,arguments)}},Vo=(t,e)=>{const n=Object.create(ty);return n.head=t,n.tail=e,n},ny=Ge("Nil"),ry={[Is]:Is,_tag:"Nil",toString(){return ct(this.toJSON())},toJSON(){return{_id:"List",_tag:"Nil"}},[Je](){return this.toJSON()},[de](){return ny},[he](t){return ld(t)&&this._tag===t._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return le(this,arguments)}},cd=Object.create(ry),ld=t=>me(t,Is),_n=t=>t._tag==="Nil",sy=t=>t._tag==="Cons",oy=()=>cd,Zn=(t,e)=>Vo(t,e),Nr=oy,Jc=t=>Vo(t,cd),iy=k(2,(t,e)=>cy(e,t)),ay=k(2,(t,e)=>Zn(e,t)),cy=k(2,(t,e)=>{if(_n(t))return e;if(_n(e))return t;{const n=Vo(e.head,t);let r=n,s=e.tail;for(;!_n(s);){const o=Vo(s.head,t);r.tail=o,r=o,s=s.tail}return n}}),ly=k(3,(t,e,n)=>{let r=e,s=t;for(;!_n(s);)r=n(r,s.head),s=s.tail;return r}),uy=t=>{let e=Nr(),n=t;for(;!_n(n);)e=ay(e,n.head),n=n.tail;return e},Yc=(function(){function t(e){e&&Object.assign(this,e)}return t.prototype=Mc,t})(),fy=Symbol.for("effect/DifferContextPatch");function hu(t){return t}const qs={...Yc.prototype,[fy]:{_Value:hu,_Patch:hu}},hy=Object.assign(Object.create(qs),{_tag:"Empty"}),dy=Object.create(hy),ud=()=>dy,gy=Object.assign(Object.create(qs),{_tag:"AndThen"}),py=(t,e)=>{const n=Object.create(gy);return n.first=t,n.second=e,n},my=Object.assign(Object.create(qs),{_tag:"AddService"}),vy=(t,e)=>{const n=Object.create(my);return n.key=t,n.service=e,n},by=Object.assign(Object.create(qs),{_tag:"RemoveService"}),_y=t=>{const e=Object.create(by);return e.key=t,e},yy=Object.assign(Object.create(qs),{_tag:"UpdateService"}),xy=(t,e)=>{const n=Object.create(yy);return n.key=t,n.update=e,n},ky=(t,e)=>{const n=new Map(t.unsafeMap);let r=ud();for(const[s,o]of e.unsafeMap.entries())if(n.has(s)){const i=n.get(s);n.delete(s),ge(i,o)||(r=So(xy(s,()=>o))(r))}else n.delete(s),r=So(vy(s,o))(r);for(const[s]of n.entries())r=So(_y(s))(r);return r},So=k(2,(t,e)=>py(t,e)),Sy=k(2,(t,e)=>{if(t._tag==="Empty")return e;let n=!1,r=Ot(t);const s=new Map(e.unsafeMap);for(;Ir(r);){const i=Er(r),c=Bn(r);switch(i._tag){case"Empty":{r=c;break}case"AddService":{s.set(i.key,i.service),r=c;break}case"AndThen":{r=Gt(Gt(c,i.second),i.first);break}case"RemoveService":{s.delete(i.key),r=c;break}case"UpdateService":{s.set(i.key,i.update(s.get(i.key))),n=!0,r=c;break}}}if(!n)return Cr(s);const o=new Map;for(const[i]of e.unsafeMap)s.has(i)&&(o.set(i,s.get(i)),s.delete(i));for(const[i,c]of s)o.set(i,c);return Cr(o)}),wy=Symbol.for("effect/DifferHashSetPatch");function fa(t){return t}const Si={...Yc.prototype,[wy]:{_Value:fa,_Key:fa,_Patch:fa}},Ty=Object.assign(Object.create(Si),{_tag:"Empty"}),Cy=Object.create(Ty),fd=()=>Cy,Ry=Object.assign(Object.create(Si),{_tag:"AndThen"}),Iy=(t,e)=>{const n=Object.create(Ry);return n.first=t,n.second=e,n},Ey=Object.assign(Object.create(Si),{_tag:"Add"}),Oy=t=>{const e=Object.create(Ey);return e.value=t,e},Ay=Object.assign(Object.create(Si),{_tag:"Remove"}),My=t=>{const e=Object.create(Ay);return e.value=t,e},Ny=(t,e)=>{const[n,r]=qo([t,fd()],([s,o],i)=>$_(i)(s)?[Xh(i)(s),o]:[s,Ua(Oy(i))(o)])(e);return qo(r,(s,o)=>Ua(My(o))(s))(n)},Ua=k(2,(t,e)=>Iy(t,e)),Py=k(2,(t,e)=>{if(t._tag==="Empty")return e;let n=e,r=Ot(t);for(;Ir(r);){const s=Er(r),o=Bn(r);switch(s._tag){case"Empty":{r=o;break}case"AndThen":{r=Gt(s.first)(Gt(s.second)(o));break}case"Add":{n=_s(s.value)(n),r=o;break}case"Remove":n=Xh(s.value)(n),r=o}}return n}),Fy=Symbol.for("effect/DifferReadonlyArrayPatch");function du(t){return t}const zs={...Yc.prototype,[Fy]:{_Value:du,_Patch:du}},Ly=Object.assign(Object.create(zs),{_tag:"Empty"}),jy=Object.create(Ly),hd=()=>jy,Dy=Object.assign(Object.create(zs),{_tag:"AndThen"}),$y=(t,e)=>{const n=Object.create(Dy);return n.first=t,n.second=e,n},By=Object.assign(Object.create(zs),{_tag:"Append"}),Uy=t=>{const e=Object.create(By);return e.values=t,e},qy=Object.assign(Object.create(zs),{_tag:"Slice"}),zy=(t,e)=>{const n=Object.create(qy);return n.from=t,n.until=e,n},Vy=Object.assign(Object.create(zs),{_tag:"Update"}),Hy=(t,e)=>{const n=Object.create(Vy);return n.index=t,n.patch=e,n},Wy=t=>{let e=0,n=hd();for(;e<t.oldValue.length&&e<t.newValue.length;){const r=t.oldValue[e],s=t.newValue[e],o=t.differ.diff(r,s);ge(o,t.differ.empty)||(n=wo(n,Hy(e,o))),e=e+1}return e<t.oldValue.length&&(n=wo(n,zy(0,e))),e<t.newValue.length&&(n=wo(n,Uy(tb(e)(t.newValue)))),n},wo=k(2,(t,e)=>$y(t,e)),Ky=k(3,(t,e,n)=>{if(t._tag==="Empty")return e;let r=e.slice(),s=Ut(t);for(;Jv(s);){const o=Tt(s),i=wr(s);switch(o._tag){case"Empty":{s=i;break}case"AndThen":{i.unshift(o.first,o.second),s=i;break}case"Append":{for(const c of o.values)r.push(c);s=i;break}case"Slice":{r=r.slice(o.from,o.until),s=i;break}case"Update":{r[o.index]=n.patch(o.patch,r[o.index]),s=i;break}}}return r}),Gy=Symbol.for("effect/Differ"),Jy={[Gy]:{_P:Le,_V:Le},pipe(){return le(this,arguments)}},Vr=t=>{const e=Object.create(Jy);return e.empty=t.empty,e.diff=t.diff,e.combine=t.combine,e.patch=t.patch,e},Yy=()=>Vr({empty:ud(),combine:(t,e)=>So(e)(t),diff:(t,e)=>ky(t,e),patch:(t,e)=>Sy(e)(t)}),Zy=()=>Vr({empty:fd(),combine:(t,e)=>Ua(e)(t),diff:(t,e)=>Ny(t,e),patch:(t,e)=>Py(e)(t)}),Qy=t=>Vr({empty:hd(),combine:(e,n)=>wo(e,n),diff:(e,n)=>Wy({oldValue:e,newValue:n,differ:t}),patch:(e,n)=>Ky(e,n,t)}),dd=()=>Xy((t,e)=>e),Xy=t=>Vr({empty:Le,combine:(e,n)=>e===Le?n:n===Le?e:r=>n(e(r)),diff:(e,n)=>ge(e,n)?Le:li(n),patch:(e,n)=>t(n,e(n))}),Es=255,gd=8,qa=t=>t&Es,za=t=>t>>gd&Es,Vs=(t,e)=>(t&Es)+((e&t&Es)<<gd),ex=Vs(0,0),tx=t=>Vs(t,t),nx=t=>Vs(t,0),rx=k(2,(t,e)=>Vs(qa(t)&~e,za(t))),sx=k(2,(t,e)=>t|e),ox=t=>~t>>>0&Es,ix=0,Hs=1,ax=2,cx=4,Va=16,lx=32,ux=t=>wi(t,lx),fx=k(2,(t,e)=>t|e),Cn=t=>pd(t)&&!gx(t),pd=t=>wi(t,Hs),wi=k(2,(t,e)=>(t&e)!==0),hx=(...t)=>t.reduce((e,n)=>e|n,0),dx=hx(ix),gu=t=>wi(t,cx),gx=t=>wi(t,Va),To=k(2,(t,e)=>Vs(t^e,e)),Co=k(2,(t,e)=>t&(ox(qa(e))|za(e))|qa(e)&za(e)),pu=Vr({empty:ex,diff:(t,e)=>To(t,e),combine:(t,e)=>sx(e)(t),patch:(t,e)=>Co(e,t)}),px=tx,md=nx,mu=rx,vd=(t,e)=>({_tag:"Par",left:t,right:e}),uo=(t,e)=>({_tag:"Seq",left:t,right:e}),mx=t=>{let e=Jc(t),n=Nr();for(;;){const[r,s]=ly(e,[bd(),Nr()],([o,i],c)=>{const[a,u]=vx(c);return[kx(o,a),iy(i,u)]});if(n=bx(n,r),_n(s))return uy(n);e=s}throw new Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues")},vx=t=>{let e=t,n=bd(),r=Nr(),s=Nr();for(;;)switch(e._tag){case"Empty":{if(_n(r))return[n,s];e=r.head,r=r.tail;break}case"Par":{r=Zn(e.right,r),e=e.left;break}case"Seq":{const o=e.left,i=e.right;switch(o._tag){case"Empty":{e=i;break}case"Par":{const c=o.left,a=o.right;e=vd(uo(c,i),uo(a,i));break}case"Seq":{const c=o.left,a=o.right;e=uo(c,uo(a,i));break}case"Single":{e=o,s=Zn(i,s);break}}break}case"Single":{if(n=xx(n,e),_n(r))return[n,s];e=r.head,r=r.tail;break}}throw new Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues")},bx=(t,e)=>{if(_n(t))return Jc(ha(e));if(Sx(e))return t;const n=Ex(t.head),r=wx(e);return n.length===1&&r.length===1&&ge(n[0],r[0])?Zn(Ix(t.head,ha(e)),t.tail):Zn(ha(e),t)},_x=Symbol.for("effect/RequestBlock/RequestBlockParallel"),yx={_R:t=>t};class Zc{map;[_x]=yx;constructor(e){this.map=e}}const bd=()=>new Zc(Gc()),xx=(t,e)=>new Zc(Z_(t.map,e.dataSource,n=>jv(Dv(n,jb(e.blockedRequest)),()=>Ot(e.blockedRequest)))),kx=(t,e)=>new Zc(ad(t.map,e.map,(n,r,s)=>od(n,s,sr(sd(n,s),{onNone:()=>r,onSome:o=>Vt(r,o)})))),Sx=t=>Y_(t.map),wx=t=>Array.from(id(t.map)),ha=t=>Rx(Q_(t.map,e=>Ot(e))),Tx=Symbol.for("effect/RequestBlock/RequestBlockSequential"),Cx={_R:t=>t};class _d{map;[Tx]=Cx;constructor(e){this.map=e}}const Rx=t=>new _d(t),Ix=(t,e)=>new _d(ad(e.map,t.map,(n,r,s)=>od(n,s,sr(sd(n,s),{onNone:()=>xn(),onSome:o=>Vt(o,r)})))),Ex=t=>Array.from(id(t.map)),Ox=t=>Array.from(t.map),Ws="Die",Qn="Empty",Hr="Fail",Wr="Interrupt",Pr="Parallel",Fr="Sequential",yd="effect/Cause",xd=Symbol.for(yd),Ax={_E:t=>t},Kr={[xd]:Ax,[de](){return I(Z(yd),Se(Z(Vx(this))),ze(this))},[he](t){return Mx(t)&&zx(this,t)},pipe(){return le(this,arguments)},toJSON(){switch(this._tag){case"Empty":return{_id:"Cause",_tag:this._tag};case"Die":return{_id:"Cause",_tag:this._tag,defect:st(this.defect)};case"Interrupt":return{_id:"Cause",_tag:this._tag,fiberId:this.fiberId.toJSON()};case"Fail":return{_id:"Cause",_tag:this._tag,failure:st(this.error)};case"Sequential":case"Parallel":return{_id:"Cause",_tag:this._tag,left:st(this.left),right:st(this.right)}}},toString(){return Ci(this)},[Je](){return this.toJSON()}},Lr=(()=>{const t=Object.create(Kr);return t._tag=Qn,t})(),Ha=t=>{const e=Object.create(Kr);return e._tag=Hr,e.error=t,e},yn=t=>{const e=Object.create(Kr);return e._tag=Ws,e.defect=t,e},Rn=t=>{const e=Object.create(Kr);return e._tag=Wr,e.fiberId=t,e},Ti=(t,e)=>{const n=Object.create(Kr);return n._tag=Pr,n.left=t,n.right=e,n},Dt=(t,e)=>{const n=Object.create(Kr);return n._tag=Fr,n.left=t,n.right=e,n},Mx=t=>me(t,xd),Nx=t=>t._tag===Qn,Px=t=>t._tag===Qn?!0:jr(t,!0,(e,n)=>{switch(n._tag){case Qn:return ye(e);case Ws:case Hr:case Wr:return ye(!1);default:return ce()}}),Fx=t=>on(Ux(t)),Qc=t=>Xc(void 0,Wx)(t),Lx=t=>Rr(jr(t,xn(),(e,n)=>n._tag===Hr?ye(I(e,Gt(n.error))):ce())),jx=t=>Rr(jr(t,xn(),(e,n)=>n._tag===Ws?ye(I(e,Gt(n.defect))):ce())),Dx=t=>jr(t,Yn(),(e,n)=>n._tag===Wr?ye(I(e,_s(n.fiberId))):ce()),$x=t=>kd(t,e=>e._tag===Hr?ye(e.error):ce()),Bx=t=>{const e=$x(t);switch(e._tag){case"None":return bn(t);case"Some":return Sr(e.value)}},Ux=t=>kd(t,e=>e._tag===Wr?ye(e.fiberId):ce()),vu=t=>Sd(t,{onEmpty:Lr,onFail:()=>Lr,onDie:yn,onInterrupt:Rn,onSequential:Dt,onParallel:Ti}),qx=t=>Sd(t,{onEmpty:Lr,onFail:yn,onDie:yn,onInterrupt:Rn,onSequential:Dt,onParallel:Ti}),zx=(t,e)=>{let n=Ot(t),r=Ot(e);for(;Ir(n)&&Ir(r);){const[s,o]=I(Er(n),jr([Yn(),xn()],([a,u],f)=>{const[h,d]=Wa(f);return ye([I(a,Cs(h)),I(u,Vt(d))])})),[i,c]=I(Er(r),jr([Yn(),xn()],([a,u],f)=>{const[h,d]=Wa(f);return ye([I(a,Cs(h)),I(u,Vt(d))])}));if(!ge(s,i))return!1;n=o,r=c}return!0},Vx=t=>Hx(Ot(t),xn()),Hx=(t,e)=>{for(;;){const[n,r]=I(t,kh([Yn(),xn()],([o,i],c)=>{const[a,u]=Wa(c);return[I(o,Cs(a)),I(i,Vt(u))]})),s=Qh(n)>0?I(e,Gt(n)):e;if(Db(r))return Rr(s);t=r,e=s}throw new Error(hi("Cause.flattenCauseLoop"))},kd=k(2,(t,e)=>{const n=[t];for(;n.length>0;){const r=n.pop(),s=e(r);switch(s._tag){case"None":{switch(r._tag){case Fr:case Pr:{n.push(r.right),n.push(r.left);break}}break}case"Some":return s}}return ce()}),Wa=t=>{let e=t;const n=[];let r=Yn(),s=xn();for(;e!==void 0;)switch(e._tag){case Qn:{if(n.length===0)return[r,s];e=n.pop();break}case Hr:{if(r=_s(r,la(e._tag,e.error)),n.length===0)return[r,s];e=n.pop();break}case Ws:{if(r=_s(r,la(e._tag,e.defect)),n.length===0)return[r,s];e=n.pop();break}case Wr:{if(r=_s(r,la(e._tag,e.fiberId)),n.length===0)return[r,s];e=n.pop();break}case Fr:{switch(e.left._tag){case Qn:{e=e.right;break}case Fr:{e=Dt(e.left.left,Dt(e.left.right,e.right));break}case Pr:{e=Ti(Dt(e.left.left,e.right),Dt(e.left.right,e.right));break}default:{s=Gt(s,e.right),e=e.left;break}}break}case Pr:{n.push(e.right),e=e.left;break}}throw new Error(hi("Cause.evaluateCauseLoop"))},Wx={emptyCase:Ql,failCase:Ta,dieCase:Ta,interruptCase:Ql,sequentialCase:(t,e,n)=>e&&n,parallelCase:(t,e,n)=>e&&n},bu="SequentialCase",_u="ParallelCase",Sd=k(2,(t,{onDie:e,onEmpty:n,onFail:r,onInterrupt:s,onParallel:o,onSequential:i})=>Xc(t,void 0,{emptyCase:()=>n,failCase:(c,a)=>r(a),dieCase:(c,a)=>e(a),interruptCase:(c,a)=>s(a),sequentialCase:(c,a,u)=>i(a,u),parallelCase:(c,a,u)=>o(a,u)})),jr=k(3,(t,e,n)=>{let r=e,s=t;const o=[];for(;s!==void 0;){const i=n(r,s);switch(r=on(i)?i.value:r,s._tag){case Fr:{o.push(s.right),s=s.left;break}case Pr:{o.push(s.right),s=s.left;break}default:{s=void 0;break}}s===void 0&&o.length>0&&(s=o.pop())}return r}),Xc=k(3,(t,e,n)=>{const r=[t],s=[];for(;r.length>0;){const i=r.pop();switch(i._tag){case Qn:{s.push(bn(n.emptyCase(e)));break}case Hr:{s.push(bn(n.failCase(e,i.error)));break}case Ws:{s.push(bn(n.dieCase(e,i.defect)));break}case Wr:{s.push(bn(n.interruptCase(e,i.fiberId)));break}case Fr:{r.push(i.right),r.push(i.left),s.push(Sr({_tag:bu}));break}case Pr:{r.push(i.right),r.push(i.left),s.push(Sr({_tag:_u}));break}}}const o=[];for(;s.length>0;){const i=s.pop();switch(i._tag){case"Left":{switch(i.left._tag){case bu:{const c=o.pop(),a=o.pop(),u=n.sequentialCase(e,c,a);o.push(u);break}case _u:{const c=o.pop(),a=o.pop(),u=n.parallelCase(e,c,a);o.push(u);break}}break}case"Right":{o.push(i.right);break}}}if(o.length===0)throw new Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return o.pop()}),Ci=(t,e)=>Qc(t)?"All fibers interrupted without errors.":Zx(t).map(function(n){return e?.renderErrorCause!==!0||n.cause===void 0?n.stack:`${n.stack} {
6
- ${wd(n.cause," ")}
7
- }`}).join(`
8
- `),wd=(t,e)=>{const n=t.stack.split(`
9
- `);let r=`${e}[cause]: ${n[0]}`;for(let s=1,o=n.length;s<o;s++)r+=`
10
- ${e}${n[s]}`;return t.cause&&(r+=` {
11
- ${wd(t.cause,`${e} `)}
12
- ${e}}`),r};class Ho extends globalThis.Error{span=void 0;constructor(e){const n=typeof e=="object"&&e!==null,r=Error.stackTraceLimit;Error.stackTraceLimit=1,super(Kx(e),n&&"cause"in e&&typeof e.cause<"u"?{cause:new Ho(e.cause)}:void 0),this.message===""&&(this.message="An error has occurred"),Error.stackTraceLimit=r,this.name=e instanceof Error?e.name:"Error",n&&(Dr in e&&(this.span=e[Dr]),Object.keys(e).forEach(s=>{s in this||(this[s]=e[s])})),this.stack=Yx(`${this.name}: ${this.message}`,e instanceof Error&&e.stack?e.stack:"",this.span)}}const Kx=t=>{if(typeof t=="string")return t;if(typeof t=="object"&&t!==null&&t instanceof Error)return t.message;try{if(me(t,"toString")&&ui(t.toString)&&t.toString!==Object.prototype.toString&&t.toString!==globalThis.Array.prototype.toString)return t.toString()}catch{}return th(t)},Gx=/\((.*)\)/g,Jx=Ce("effect/Tracer/spanToTrace",()=>new WeakMap),Yx=(t,e,n)=>{const r=[t],s=e.startsWith(t)?e.slice(t.length).split(`
13
- `):e.split(`
14
- `);for(let o=1;o<s.length;o++){if(s[o].includes(" at new BaseEffectError")||s[o].includes(" at new YieldableError")){o++;continue}if(s[o].includes("Generator.next")||s[o].includes("effect_internal_function"))break;r.push(s[o].replace(/at .*effect_instruction_i.*\((.*)\)/,"at $1").replace(/EffectPrimitive\.\w+/,"<anonymous>"))}if(n){let o=n,i=0;for(;o&&o._tag==="Span"&&i<10;){const c=Jx.get(o);if(typeof c=="function"){const a=c();if(typeof a=="string"){const u=a.matchAll(Gx);let f=!1;for(const[,h]of u)f=!0,r.push(` at ${o.name} (${h})`);f||r.push(` at ${o.name} (${a.replace(/^at /,"")})`)}else r.push(` at ${o.name}`)}else r.push(` at ${o.name}`);o=Ln(o.parent),i++}}return r.join(`
15
- `)},Dr=Symbol.for("effect/SpanAnnotation"),Zx=t=>Xc(t,void 0,{emptyCase:()=>[],dieCase:(e,n)=>[new Ho(n)],failCase:(e,n)=>[new Ho(n)],interruptCase:()=>[],parallelCase:(e,n,r)=>[...n,...r],sequentialCase:(e,n,r)=>[...n,...r]}),Ri="Pending",Td="Done",Qx="effect/Deferred",Xx=Symbol.for(Qx),e0={_E:t=>t,_A:t=>t},t0=t=>({_tag:Ri,joiners:t}),n0=t=>({_tag:Td,effect:t});class Ks{self;called=!1;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(e){return{value:e,done:!0}}throw(e){throw e}[Symbol.iterator](){return new Ks(this.self)}}const Cd=(t,e)=>{const n=new lt("Blocked");return n.effect_instruction_i0=t,n.effect_instruction_i1=e,n},r0=t=>{const e=new lt("RunBlocked");return e.effect_instruction_i0=t,e},$r=Symbol.for("effect/Effect");class s0{patch;op;_op=Oc;constructor(e,n){this.patch=e,this.op=n}}class lt{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[$r]=kr;constructor(e){this._op=e}[he](e){return this===e}[de](){return ze(this,Cc(this))}pipe(){return le(this,arguments)}toJSON(){return{_id:"Effect",_op:this._op,effect_instruction_i0:st(this.effect_instruction_i0),effect_instruction_i1:st(this.effect_instruction_i1),effect_instruction_i2:st(this.effect_instruction_i2)}}toString(){return ct(this.toJSON())}[Je](){return this.toJSON()}[Symbol.iterator](){return new Ks(new Ls(this))}}class Rd{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[$r]=kr;constructor(e){this._op=e,this._tag=e}[he](e){return Ni(e)&&e._op==="Failure"&&ge(this.effect_instruction_i0,e.effect_instruction_i0)}[de](){return I(Ge(this._tag),Se(Z(this.effect_instruction_i0)),ze(this))}get cause(){return this.effect_instruction_i0}pipe(){return le(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,cause:this.cause.toJSON()}}toString(){return ct(this.toJSON())}[Je](){return this.toJSON()}[Symbol.iterator](){return new Ks(new Ls(this))}}class Id{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[$r]=kr;constructor(e){this._op=e,this._tag=e}[he](e){return Ni(e)&&e._op==="Success"&&ge(this.effect_instruction_i0,e.effect_instruction_i0)}[de](){return I(Ge(this._tag),Se(Z(this.effect_instruction_i0)),ze(this))}get value(){return this.effect_instruction_i0}pipe(){return le(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,value:st(this.value)}}toString(){return ct(this.toJSON())}[Je](){return this.toJSON()}[Symbol.iterator](){return new Ks(new Ls(this))}}const el=t=>me(t,$r),At=t=>{const e=new lt(sh);return e.effect_instruction_i0=t,e},o0=k(3,(t,e,n)=>Oi(r=>oe(t,s=>oe(Ad(nt(()=>r(e(s)))),o=>nt(()=>n(s,o)).pipe(Br({onFailure:i=>{switch(o._tag){case Wt:return Jt(Dt(o.effect_instruction_i0,i));case Kt:return Jt(i)}},onSuccess:()=>o})))))),Gs=k(2,(t,e)=>oe(t,()=>Ne(e))),Ii=t=>Gs(t,void 0),Ed=function(){const t=new lt(gi);switch(arguments.length){case 2:{t.effect_instruction_i0=arguments[0],t.commit=arguments[1];break}case 3:{t.effect_instruction_i0=arguments[0],t.effect_instruction_i1=arguments[1],t.commit=arguments[2];break}case 4:{t.effect_instruction_i0=arguments[0],t.effect_instruction_i1=arguments[1],t.effect_instruction_i2=arguments[2],t.commit=arguments[3];break}default:throw new Error(hi("you're not supposed to end up here"))}return t},Wo=(t,e=Mr)=>{const n=new lt(ms);let r;return n.effect_instruction_i0=s=>{r=t(s)},n.effect_instruction_i1=e,Ld(n,s=>el(r)?r:an)},i0=(t,e=Mr)=>nt(()=>Wo(t,e)),Xn=(t,e=Mr)=>Ed(t,function(){let n,r;function s(a){n?n(a):r===void 0&&(r=a)}const o=new lt(ms);o.effect_instruction_i0=a=>{n=a,r&&a(r)},o.effect_instruction_i1=e;let i,c;return this.effect_instruction_i0.length!==1?(c=new AbortController,i=bt(()=>this.effect_instruction_i0(s,c.signal))):i=bt(()=>this.effect_instruction_i0(s)),i||c?Ld(o,a=>(c&&c.abort(),i??an)):o}),yu=k(2,(t,e)=>nl(t,{onFailure:e,onSuccess:Ne})),xu=Symbol.for("effect/OriginalAnnotation"),Od=(t,e)=>on(e)?new Proxy(t,{has(n,r){return r===Dr||r===xu||r in n},get(n,r){return r===Dr?e.value:r===xu?t:n[r]}}):t,ku=t=>fi(t)&&!(Dr in t)?At(e=>Jt(yn(Od(t,Yd(e))))):Jt(yn(t)),a0=t=>c0(()=>yn(new U0(t))),Os=t=>nl(t,{onFailure:e=>Ne(Sr(e)),onSuccess:e=>Ne(bn(e))}),Ad=t=>h0(t,{onFailure:Be,onSuccess:at}),ht=t=>fi(t)&&!(Dr in t)?At(e=>Jt(Ha(Od(t,Yd(e))))):Jt(Ha(t)),tl=t=>oe(se(t),ht),Jt=t=>{const e=new Rd(Wt);return e.effect_instruction_i0=t,e},c0=t=>oe(se(t),Jt),l0=At(t=>Ne(t.id())),u0=t=>At(e=>t(e.id())),oe=k(2,(t,e)=>{const n=new lt(Fo);return n.effect_instruction_i0=t,n.effect_instruction_i1=e,n}),f0=t=>{const e=new lt("OnStep");return e.effect_instruction_i0=t,e},Md=t=>oe(t,Le),h0=k(2,(t,e)=>Br(t,{onFailure:n=>Ne(e.onFailure(n)),onSuccess:n=>Ne(e.onSuccess(n))})),Br=k(2,(t,e)=>{const n=new lt(Lo);return n.effect_instruction_i0=t,n.effect_instruction_i1=e.onFailure,n.effect_instruction_i2=e.onSuccess,n}),nl=k(2,(t,e)=>Br(t,{onFailure:n=>{if(jx(n).length>0)return Jt(qx(n));const s=Lx(n);return s.length>0?e.onFailure(jh(s)):Jt(n)},onSuccess:e.onSuccess})),In=k(2,(t,e)=>nt(()=>{const n=Ze(t),r=Pc(n.length);let s=0;return Gs(sl({while:()=>s<n.length,body:()=>e(n[s],s),step:o=>{r[s++]=o}}),r)})),Ei=k(2,(t,e)=>nt(()=>{const n=Ze(t);let r=0;return sl({while:()=>r<n.length,body:()=>e(n[r],r),step:()=>{r++}})})),Nd=t=>{const e=new lt(Ds);return e.effect_instruction_i0=px(Hs),e.effect_instruction_i1=()=>t,e},yt=k(2,(t,e)=>oe(t,n=>se(()=>e(n)))),Pd=k(2,(t,e)=>nl(t,{onFailure:n=>tl(()=>e.onFailure(n)),onSuccess:n=>se(()=>e.onSuccess(n))})),rl=k(2,(t,e)=>Br(t,{onFailure:n=>{const r=Bx(n);switch(r._tag){case"Left":return tl(()=>e(r.left));case"Right":return Jt(r.right)}},onSuccess:Ne})),Fd=k(2,(t,e)=>Oi(n=>Br(n(t),{onFailure:r=>{const s=Be(r);return Br(e(s),{onFailure:o=>Be(Dt(r,o)),onSuccess:()=>s})},onSuccess:r=>{const s=at(r);return il(e(s),s)}}))),Ld=k(2,(t,e)=>Fd(t,Kd({onFailure:n=>Qc(n)?Ii(e(Dx(n))):an,onSuccess:()=>an}))),Ne=t=>{const e=new Id(Kt);return e.effect_instruction_i0=t,e},nt=t=>{const e=new lt(gi);return e.commit=t,e},se=t=>{const e=new lt(rh);return e.effect_instruction_i0=t,e},d0=k(t=>t.length===3||t.length===2&&!(fi(t[1])&&"onlyEffect"in t[1]),(t,e)=>oe(t,n=>{const r=typeof e=="function"?e(n):e;return el(r)?Gs(r,n):Xm(r)?Wo(s=>{r.then(o=>s(Ne(n)),o=>s(ht(new Wd(o,"An unknown error occurred in Effect.tap"))))}):Ne(n)})),g0=t=>At(e=>{const n=e.getFiberRef(Ga),r=I(n,Gn(()=>e.scope()));return t(Ai(Ga,ye(r)))}),jd=t=>{const e=new lt(Ds);return e.effect_instruction_i0=md(Hs),e.effect_instruction_i1=()=>t,e},Oi=t=>Ed(t,function(){const e=new lt(Ds);return e.effect_instruction_i0=md(Hs),e.effect_instruction_i1=n=>pd(n)?bt(()=>this.effect_instruction_i0(Nd)):bt(()=>this.effect_instruction_i0(jd)),e}),an=Ne(void 0),p0=t=>{const e=new lt(Ds);return e.effect_instruction_i0=t,e.effect_instruction_i1=void 0,e},sl=t=>{const e=new lt(jo);return e.effect_instruction_i0=t.while,e.effect_instruction_i1=t.body,e.effect_instruction_i2=t.step,e},m0=t=>nt(()=>{const e=new lt(vs);return e.effect_instruction_i0=t(),e}),v0=function(){const t=arguments.length===1?arguments[0]:arguments[1].bind(arguments[0]);return m0(()=>t(I))},ol=t=>{const e=new lt(xo);return typeof t?.priority<"u"?L0(e,t.priority):e},Dd=k(2,(t,e)=>oe(t,n=>yt(e,r=>[n,r]))),$d=k(2,(t,e)=>oe(t,n=>Gs(e,n))),il=k(2,(t,e)=>oe(t,()=>e)),b0=t=>oe(l0,e=>I(t,_0(e))),_0=k(2,(t,e)=>oe(t.interruptAsFork(e),()=>t.await)),y0={_tag:"All",syslog:0,label:"ALL",ordinal:Number.MIN_SAFE_INTEGER,pipe(){return le(this,arguments)}},x0={_tag:"Fatal",syslog:2,label:"FATAL",ordinal:5e4,pipe(){return le(this,arguments)}},k0={_tag:"Error",syslog:3,label:"ERROR",ordinal:4e4,pipe(){return le(this,arguments)}},Bd={_tag:"Warning",syslog:4,label:"WARN",ordinal:3e4,pipe(){return le(this,arguments)}},Ud={_tag:"Info",syslog:6,label:"INFO",ordinal:2e4,pipe(){return le(this,arguments)}},qd={_tag:"Debug",syslog:7,label:"DEBUG",ordinal:1e4,pipe(){return le(this,arguments)}},S0={_tag:"Trace",syslog:7,label:"TRACE",ordinal:0,pipe(){return le(this,arguments)}},w0={_tag:"None",syslog:7,label:"OFF",ordinal:Number.MAX_SAFE_INTEGER,pipe(){return le(this,arguments)}},T0="effect/FiberRef",C0=Symbol.for(T0),R0={_A:t=>t},al=t=>At(e=>at(e.getFiberRef(t))),cl=k(2,(t,e)=>oe(al(t),e)),Su=k(2,(t,e)=>I0(t,()=>[void 0,e])),I0=k(2,(t,e)=>At(n=>{const[r,s]=e(n.getFiberRef(t));return n.setFiberRef(t,s),Ne(r)})),Ai=k(3,(t,e,n)=>o0($d(al(e),Su(e,n)),()=>t,r=>Su(e,r))),Ct=(t,e)=>Gr(t,{differ:dd(),fork:e?.fork??Le,join:e?.join}),E0=t=>{const e=Zy();return Gr(t,{differ:e,fork:e.empty})},O0=t=>{const e=Qy(dd());return Gr(t,{differ:e,fork:e.empty})},zd=t=>{const e=Yy();return Gr(t,{differ:e,fork:e.empty})},Gr=(t,e)=>({...Bs,[C0]:R0,initial:t,commit(){return al(this)},diff:(r,s)=>e.differ.diff(r,s),combine:(r,s)=>e.differ.combine(r,s),patch:r=>s=>e.differ.patch(r,s),fork:e.fork,join:e.join??((r,s)=>s)}),A0=t=>Gr(t,{differ:pu,fork:pu.empty}),Mi=Ce(Symbol.for("effect/FiberRef/currentContext"),()=>zd(Ih())),ll=Ce(Symbol.for("effect/FiberRef/currentSchedulingPriority"),()=>Ct(0)),M0=Ce(Symbol.for("effect/FiberRef/currentMaxOpsBeforeYield"),()=>Ct(2048)),N0=Ce(Symbol.for("effect/FiberRef/currentLogAnnotation"),()=>Ct(Gc())),P0=Ce(Symbol.for("effect/FiberRef/currentLogLevel"),()=>Ct(Ud)),F0=Ce(Symbol.for("effect/FiberRef/currentLogSpan"),()=>Ct(Nr())),L0=k(2,(t,e)=>Ai(t,ll,e)),j0=Ce(Symbol.for("effect/FiberRef/currentConcurrency"),()=>Ct("unbounded")),D0=Ce(Symbol.for("effect/FiberRef/currentRequestBatching"),()=>Ct(!0)),$0=Ce(Symbol.for("effect/FiberRef/currentUnhandledErrorLogLevel"),()=>Ct(ye(qd))),B0=Ce(Symbol.for("effect/FiberRef/versionMismatchErrorLogLevel"),()=>Ct(ye(Bd))),Ka=Ce(Symbol.for("effect/FiberRef/currentMetricLabels"),()=>O0(Tr())),Ga=Ce(Symbol.for("effect/FiberRef/currentForkScopeOverride"),()=>Ct(ce(),{fork:()=>ce(),join:(t,e)=>t})),fo=Ce(Symbol.for("effect/FiberRef/currentInterruptedCause"),()=>Ct(Lr,{fork:()=>Lr,join:(t,e)=>t})),ul=(t,e)=>t.fork(e),Vd=(function(){class t extends globalThis.Error{commit(){return ht(this)}toJSON(){const n={...this};return this.message&&(n.message=this.message),this.cause&&(n.cause=this.cause),n}[Je](){return this.toString!==globalThis.Error.prototype.toString?this.stack?`${this.toString()}
16
- ${this.stack.split(`
17
- `).slice(1).join(`
18
- `)}`:this.toString():"Bun"in globalThis?Ci(Ha(this),{renderErrorCause:!0}):this}}return Object.assign(t.prototype,Sv),t})(),Hd=(t,e)=>{class n extends Vd{_tag=e}return Object.assign(n.prototype,t),n.prototype.name=e,n},wu=Symbol.for("effect/Cause/errors/RuntimeException"),U0=Hd({[wu]:wu},"RuntimeException"),q0=Symbol.for("effect/Cause/errors/InterruptedException"),z0=t=>me(t,q0),Tu=Symbol.for("effect/Cause/errors/NoSuchElement"),V0=Hd({[Tu]:Tu},"NoSuchElementException"),Cu=Symbol.for("effect/Cause/errors/UnknownException"),Wd=(function(){class t extends Vd{_tag="UnknownException";error;constructor(n,r){super(r??"An unknown error occurred",{cause:n}),this.error=n}}return Object.assign(t.prototype,{[Cu]:Cu,name:"UnknownException"}),t})(),Ni=t=>el(t)&&"_tag"in t&&(t._tag==="Success"||t._tag==="Failure"),Ru=(t,e)=>K0(t,e?.parallel?Ti:Dt),Be=t=>{const e=new Rd(Wt);return e.effect_instruction_i0=t,e},H0=t=>Be(Rn(t)),da=k(2,(t,e)=>{switch(t._tag){case Wt:return Be(t.effect_instruction_i0);case Kt:return at(e(t.effect_instruction_i0))}}),Kd=k(2,(t,{onFailure:e,onSuccess:n})=>{switch(t._tag){case Wt:return e(t.effect_instruction_i0);case Kt:return n(t.effect_instruction_i0)}}),at=t=>{const e=new Id(Kt);return e.effect_instruction_i0=t,e},Un=at(void 0),W0=k(3,(t,e,{onFailure:n,onSuccess:r})=>{switch(t._tag){case Wt:switch(e._tag){case Kt:return Be(t.effect_instruction_i0);case Wt:return Be(n(t.effect_instruction_i0,e.effect_instruction_i0))}case Kt:switch(e._tag){case Kt:return at(r(t.effect_instruction_i0,e.effect_instruction_i0));case Wt:return Be(e.effect_instruction_i0)}}}),K0=(t,e)=>{const n=Lh(t);return Ir(n)?I(Bn(n),kh(I(Er(n),da(Ot)),(r,s)=>I(r,W0(s,{onSuccess:(o,i)=>I(o,Gt(i)),onFailure:e}))),da(Rr),da(r=>Hn(r)),ye):ce()},G0=t=>({...Bs,[Xx]:e0,state:ed(t0([])),commit(){return Gd(this)},blockingOn:t}),Gd=t=>i0(e=>{const n=ki(t.state);switch(n._tag){case Td:return e(n.effect);case Ri:return n.joiners.push(e),J0(t,e)}},t.blockingOn),Jd=(t,e)=>{const n=ki(t.state);if(n._tag===Ri){td(t.state,n0(e));for(let r=0,s=n.joiners.length;r<s;r++)n.joiners[r](e)}},J0=(t,e)=>se(()=>{const n=ki(t.state);if(n._tag===Ri){const r=n.joiners.indexOf(e);r>=0&&n.joiners.splice(r,1)}}),Y0=At(t=>at(t.currentContext)),Z0=()=>Y0,Js=t=>oe(Z0(),t),Q0=k(2,(t,e)=>Ai(Mi,e)(t)),X0=k(2,(t,e)=>Js(n=>Q0(t,e(n)))),Yd=t=>{const e=t.currentSpan;return e!==void 0&&e._tag==="Span"?ye(e):ce()},Iu=Symbol.for("effect/MutableHashMap"),ek={[Iu]:Iu,[Symbol.iterator](){return new fl(this)},toString(){return ct(this.toJSON())},toJSON(){return{_id:"MutableHashMap",values:Array.from(this).map(st)}},[Je](){return this.toJSON()},pipe(){return le(this,arguments)}};class fl{self;referentialIterator;bucketIterator;constructor(e){this.self=e,this.referentialIterator=e.referential[Symbol.iterator]()}next(){if(this.bucketIterator!==void 0)return this.bucketIterator.next();const e=this.referentialIterator.next();return e.done?(this.bucketIterator=new tk(this.self.buckets.values()),this.next()):e}[Symbol.iterator](){return new fl(this.self)}}class tk{backing;constructor(e){this.backing=e}currentBucket;next(){if(this.currentBucket===void 0){const n=this.backing.next();if(n.done)return n;this.currentBucket=n.value[Symbol.iterator]()}const e=this.currentBucket.next();return e.done?(this.currentBucket=void 0,this.next()):e}}const nk=()=>{const t=Object.create(ek);return t.referential=new Map,t.buckets=new Map,t.bucketsSize=0,t},jn=k(2,(t,e)=>{if(Po(e)===!1)return t.referential.has(e)?ye(t.referential.get(e)):ce();const n=e[de](),r=t.buckets.get(n);return r===void 0?ce():rk(t,r,e)}),rk=(t,e,n,r=!1)=>{for(let s=0,o=e.length;s<o;s++)if(n[he](e[s][0])){const i=e[s][1];return r&&(e.splice(s,1),t.bucketsSize--),ye(i)}return ce()},is=k(2,(t,e)=>on(jn(t,e))),as=k(3,(t,e,n)=>{if(Po(e)===!1)return t.referential.set(e,n),t;const r=e[de](),s=t.buckets.get(r);return s===void 0?(t.buckets.set(r,[[e,n]]),t.bucketsSize++,t):(sk(t,s,e),s.push([e,n]),t.bucketsSize++,t)}),sk=(t,e,n)=>{for(let r=0,s=e.length;r<s;r++)if(n[he](e[r][0])){e.splice(r,1),t.bucketsSize--;return}},ok="effect/Clock",Eu=Symbol.for(ok),hl=or("effect/Clock"),ik=2**31-1,Ou={unsafeSchedule(t,e){const n=Pa(e);if(n>ik)return Ta;let r=!1;const s=setTimeout(()=>{r=!0,t()},n);return()=>(clearTimeout(s),!r)}},Au=(function(){const t=BigInt(1e6);if(typeof performance>"u"||typeof performance.now!="function")return()=>BigInt(Date.now())*t;let e;return()=>(e===void 0&&(e=BigInt(Date.now())*t-BigInt(Math.round(performance.now()*1e6))),e+BigInt(Math.round(performance.now()*1e6)))})(),ak=(function(){const t=typeof process=="object"&&"hrtime"in process&&typeof process.hrtime.bigint=="function"?process.hrtime:void 0;if(!t)return Au;const e=Au()-t.bigint();return()=>e+t.bigint()})();class ck{[Eu]=Eu;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return ak()}currentTimeMillis=se(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=se(()=>this.unsafeCurrentTimeNanos());scheduler(){return Ne(Ou)}sleep(e){return Xn(n=>{const r=Ou.unsafeSchedule(()=>n(an),e);return Ii(se(r))})}}const lk=()=>new ck,Zd="And",Qd="Or",Xd="InvalidData",eg="MissingData",tg="SourceUnavailable",ng="Unsupported",uk="effect/ConfigError",Mu=Symbol.for(uk),Jr={_tag:"ConfigError",[Mu]:Mu},rg=(t,e)=>{const n=Object.create(Jr);return n._op=Zd,n.left=t,n.right=e,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(n,"message",{enumerable:!1,get(){return this.toString()}}),n},sg=(t,e)=>{const n=Object.create(Jr);return n._op=Qd,n.left=t,n.right=e,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(n,"message",{enumerable:!1,get(){return this.toString()}}),n},fk=(t,e,n={pathDelim:"."})=>{const r=Object.create(Jr);return r._op=Xd,r.path=t,r.message=e,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Invalid data at ${I(this.path,zr(n.pathDelim))}: "${this.message}")`}}),r},er=(t,e,n={pathDelim:"."})=>{const r=Object.create(Jr);return r._op=eg,r.path=t,r.message=e,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Missing data at ${I(this.path,zr(n.pathDelim))}: "${this.message}")`}}),r},hk=(t,e,n,r={pathDelim:"."})=>{const s=Object.create(Jr);return s._op=tg,s.path=t,s.message=e,s.cause=n,Object.defineProperty(s,"toString",{enumerable:!1,value(){return`(Source unavailable at ${I(this.path,zr(r.pathDelim))}: "${this.message}")`}}),s},dk=(t,e,n={pathDelim:"."})=>{const r=Object.create(Jr);return r._op=ng,r.path=t,r.message=e,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${I(this.path,zr(n.pathDelim))}: "${this.message}")`}}),r},qn=k(2,(t,e)=>{switch(t._op){case Zd:return rg(qn(t.left,e),qn(t.right,e));case Qd:return sg(qn(t.left,e),qn(t.right,e));case Xd:return fk([...e,...t.path],t.message);case eg:return er([...e,...t.path],t.message);case tg:return hk([...e,...t.path],t.message,t.cause);case ng:return dk([...e,...t.path],t.message)}}),gk={_tag:"Empty"},ga=k(2,(t,e)=>{let n=Jc(e),r=t;for(;sy(n);){const s=n.head;switch(s._tag){case"Empty":{n=n.tail;break}case"AndThen":{n=Zn(s.first,Zn(s.second,n.tail));break}case"MapName":{r=dr(r,s.f),n=n.tail;break}case"Nested":{r=Do(r,s.name),n=n.tail;break}case"Unnested":{if(I(bs(r),qv(s.name)))r=wr(r),n=n.tail;else return Sr(er(r,`Expected ${s.name} to be in path in ConfigProvider#unnested`));break}}}return bn(r)}),pk="Constant",mk="Fail",vk="Fallback",bk="Described",_k="Lazy",yk="MapOrFail",xk="Nested",kk="Primitive",Sk="Sequence",wk="HashMap",Tk="ZipWith";var Nu={};const Ko=(t,e)=>[...t,...e],Ck="effect/ConfigProvider",Pu=Symbol.for(Ck),Rk=or("effect/ConfigProvider"),Ik="effect/ConfigProviderFlat",Fu=Symbol.for(Ik),Ek=t=>({[Pu]:Pu,pipe(){return le(this,arguments)},...t}),Ok=t=>({[Fu]:Fu,patch:t.patch,load:(e,n,r=!0)=>t.load(e,n,r),enumerateChildren:t.enumerateChildren}),Ak=t=>Ek({load:e=>oe(jt(t,Tr(),e,!1),n=>sr(bs(n),{onNone:()=>ht(er(Tr(),`Expected a single value having structure: ${e}`)),onSome:Ne})),flattened:t}),Mk=t=>{const{pathDelim:e,seqDelim:n}=Object.assign({},{pathDelim:"_",seqDelim:","},t),r=a=>I(a,zr(e)),s=a=>a.split(e),o=()=>typeof process<"u"&&"env"in process&&typeof Nu=="object"?Nu:{};return Ak(Ok({load:(a,u,f=!0)=>{const h=r(a),d=o(),p=h in d?ye(d[h]):ce();return I(p,rl(()=>er(a,`Expected ${h} to exist in the process context`)),oe(g=>jk(g,a,u,n,f)))},enumerateChildren:a=>se(()=>{const u=o(),d=Object.keys(u).map(p=>s(p.toUpperCase())).filter(p=>{for(let g=0;g<a.length;g++){const x=I(a,yh(g)),v=p[g];if(v===void 0||x!==v)return!1}return!0}).flatMap(p=>p.slice(a.length,a.length+1));return D_(d)}),patch:gk}))},Nk=(t,e,n,r)=>{const s=ru(n.length,a=>a>=r.length?ce():ye([t(a),a+1])),o=ru(r.length,a=>a>=n.length?ce():ye([e(a),a+1])),i=Ko(n,s),c=Ko(r,o);return[i,c]},Pk=(t,e)=>{let n=e;if(n._tag==="Nested"){const r=t.slice();for(;n._tag==="Nested";)r.push(n.name),n=n.config;return r}return t},jt=(t,e,n,r)=>{const s=n;switch(s._tag){case pk:return Ne(Ut(s.value));case bk:return nt(()=>jt(t,e,s.config,r));case mk:return ht(er(e,s.message));case vk:return I(nt(()=>jt(t,e,s.first,r)),yu(o=>s.condition(o)?I(jt(t,e,s.second,r),yu(i=>ht(sg(o,i)))):ht(o)));case _k:return nt(()=>jt(t,e,s.config(),r));case yk:return nt(()=>I(jt(t,e,s.original,r),oe(In(o=>I(s.mapOrFail(o),rl(qn(Pk(e,s.original))))))));case xk:return nt(()=>jt(t,Ko(e,Ut(s.name)),s.config,r));case kk:return I(ga(e,t.patch),oe(o=>I(t.load(o,s,r),oe(i=>{if(i.length===0){const c=I(Qv(o),Gn(()=>"<n/a>"));return ht(er([],`Expected ${s.description} with name ${c}`))}return Ne(i)}))));case Sk:return I(ga(e,t.patch),oe(o=>I(t.enumerateChildren(o),oe($k),oe(i=>i.length===0?nt(()=>yt(jt(t,e,s.config,!0),Ut)):I(In(i,c=>jt(t,Wv(e,`[${c}]`),s.config,!0)),yt(c=>{const a=lb(c);return a.length===0?Ut(Tr()):Ut(a)}))))));case wk:return nt(()=>I(ga(e,t.patch),oe(o=>I(t.enumerateChildren(o),oe(i=>I(i,In(c=>jt(t,Ko(o,Ut(c)),s.valueConfig,r)),yt(c=>c.length===0?Ut(Gc()):I(Dk(c),dr(a=>J_(nu(Ze(i),a)))))))))));case Tk:return nt(()=>I(jt(t,e,s.left,r),Os,oe(o=>I(jt(t,e,s.right,r),Os,oe(i=>{if(ds(o)&&ds(i))return ht(rg(o.left,i.left));if(ds(o)&&co(i))return ht(o.left);if(co(o)&&ds(i))return ht(i.left);if(co(o)&&co(i)){const c=I(e,zr(".")),a=Fk(e,c),[u,f]=Nk(a,a,I(o.right,dr(bn)),I(i.right,dr(bn)));return I(u,nu(f),In(([h,d])=>I(Dd(h,d),yt(([p,g])=>s.zip(p,g)))))}throw new Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues")})))))}},Fk=(t,e)=>n=>Sr(er(t,`The element at index ${n} in a sequence at path "${e}" was missing`)),Lk=(t,e)=>t.split(new RegExp(`\\s*${fb(e)}\\s*`)),jk=(t,e,n,r,s)=>s?I(Lk(t,r),In(o=>n.parse(o.trim())),rl(qn(e))):I(n.parse(t),Pd({onFailure:qn(e),onSuccess:Ut})),Dk=t=>Object.keys(t[0]).map(e=>t.map(n=>n[e])),$k=t=>I(In(t,Uk),Pd({onFailure:()=>Tr(),onSuccess:$o(Ss)}),Os,yt(Nv)),Bk=/^(\[(\d+)\])$/,Uk=t=>{const e=t.match(Bk);if(e!==null){const n=e[2];return I(n!==void 0&&n.length>0?ye(n):ce(),$v(qk))}return ce()},qk=t=>{const e=Number.parseInt(t);return Number.isNaN(e)?ce():ye(e)},Lu=Symbol.for("effect/Console"),og=or("effect/Console"),zk={[Lu]:Lu,assert(t,...e){return se(()=>{console.assert(t,...e)})},clear:se(()=>{console.clear()}),count(t){return se(()=>{console.count(t)})},countReset(t){return se(()=>{console.countReset(t)})},debug(...t){return se(()=>{console.debug(...t)})},dir(t,e){return se(()=>{console.dir(t,e)})},dirxml(...t){return se(()=>{console.dirxml(...t)})},error(...t){return se(()=>{console.error(...t)})},group(t){return t?.collapsed?se(()=>console.groupCollapsed(t?.label)):se(()=>console.group(t?.label))},groupEnd:se(()=>{console.groupEnd()}),info(...t){return se(()=>{console.info(...t)})},log(...t){return se(()=>{console.log(...t)})},table(t,e){return se(()=>{console.table(t,e)})},time(t){return se(()=>console.time(t))},timeEnd(t){return se(()=>console.timeEnd(t))},timeLog(t,...e){return se(()=>{console.timeLog(t,...e)})},trace(...t){return se(()=>{console.trace(...t)})},warn(...t){return se(()=>{console.warn(...t)})},unsafe:console},Vk="effect/Random",ju=Symbol.for(Vk),Hk=or("effect/Random");class Wk{seed;[ju]=ju;PRNG;constructor(e){this.seed=e,this.PRNG=new iv(e)}get next(){return se(()=>this.PRNG.number())}get nextBoolean(){return yt(this.next,e=>e>.5)}get nextInt(){return se(()=>this.PRNG.integer(Number.MAX_SAFE_INTEGER))}nextRange(e,n){return yt(this.next,r=>(n-e)*r+e)}nextIntBetween(e,n){return se(()=>this.PRNG.integer(n-e)+e)}shuffle(e){return Kk(e,n=>this.nextIntBetween(0,n))}}const Kk=(t,e)=>nt(()=>I(se(()=>Array.from(t)),oe(n=>{const r=[];for(let s=n.length;s>=2;s=s-1)r.push(s);return I(r,Ei(s=>I(e(s),yt(o=>Gk(n,s-1,o)))),Gs(Lh(n)))}))),Gk=(t,e,n)=>{const r=t[e];return t[e]=t[n],t[n]=r,t},Jk=t=>new Wk(Z(t)),Du=Symbol.for("effect/Tracer"),Yk=t=>({[Du]:Du,...t}),ig=or("effect/Tracer"),ag=or("effect/ParentSpan"),$u=(function(){const t="abcdef0123456789",e=t.length;return function(n){let r="";for(let s=0;s<n;s++)r+=t.charAt(Math.floor(Math.random()*e));return r}})();class Zk{name;parent;context;startTime;kind;_tag="Span";spanId;traceId="native";sampled=!0;status;attributes;events=[];links;constructor(e,n,r,s,o,i){this.name=e,this.parent=n,this.context=r,this.startTime=o,this.kind=i,this.status={_tag:"Started",startTime:o},this.attributes=new Map,this.traceId=n._tag==="Some"?n.value.traceId:$u(32),this.spanId=$u(16),this.links=Array.from(s)}end(e,n){this.status={_tag:"Ended",endTime:e,exit:n,startTime:this.status.startTime}}attribute(e,n){this.attributes.set(e,n)}event(e,n,r){this.events.push([e,n,r??{}])}addLinks(e){this.links.push(...e)}}const Qk=Yk({span:(t,e,n,r,s,o)=>new Zk(t,e,n,r,s,o),context:t=>t()}),Xk=I(Ih(),os(hl,lk()),os(og,zk),os(Hk,Jk(Math.random())),os(Rk,Mk()),os(ig,Qk)),Go=Ce(Symbol.for("effect/DefaultServices/currentServices"),()=>zd(Xk)),Bu=Symbol.for("effect/FiberRefs");class As{locals;[Bu]=Bu;constructor(e){this.locals=e}pipe(){return le(this,arguments)}}const e1=(t,e,n,r=!1)=>{const s=t;let o=e,i=n,c=r,a;for(;a===void 0;)if(Et(o)&&Et(i)){const u=Tt(o)[0],f=wr(o),h=Tt(i)[0],d=Tt(i)[1],p=wr(i);u.startTimeMillis<h.startTimeMillis?(i=p,c=!0):u.startTimeMillis>h.startTimeMillis?o=f:u.id<h.id?(i=p,c=!0):u.id>h.id?o=f:a=[d,c]}else a=[s.initial,!0];return a},t1=k(3,(t,e,n)=>{const r=new Map(t.locals);return n.locals.forEach((s,o)=>{const i=s[0][1];if(!s[0][0][he](e)){if(!r.has(o)){if(ge(i,o.initial))return;r.set(o,[[e,o.join(o.initial,i)]]);return}const c=r.get(o),[a,u]=e1(o,c,s);if(u){const f=o.diff(a,i),h=c[0][1],d=o.join(h,o.patch(f)(h));if(!ge(h,d)){let p;const g=c[0][0];g[he](e)?p=[[g,d],...c.slice(1)]:p=[[e,d],...c],r.set(o,p)}}}}),new As(r)}),n1=k(2,(t,e)=>{const n=new Map;return r1(t,n,e),new As(n)}),r1=(t,e,n)=>{t.locals.forEach((r,s)=>{const o=r[0][1],i=s.patch(s.fork)(o);ge(o,i)?e.set(s,r):e.set(s,[[n,i],...r])})},cg=k(2,(t,e)=>{const n=new Map(t.locals);return n.delete(e),new As(n)}),s1=k(2,(t,e)=>t.locals.has(e)?ye(Tt(t.locals.get(e))[1]):ce()),Ms=k(2,(t,e)=>I(s1(t,e),Gn(()=>e.initial))),Ja=k(2,(t,{fiberId:e,fiberRef:n,value:r})=>{if(t.locals.size===0)return new As(new Map([[n,[[e,r]]]]));const s=new Map(t.locals);return o1(s,e,n,r),new As(s)}),o1=(t,e,n,r)=>{const s=t.get(n)??[];let o;if(Et(s)){const[i,c]=Tt(s);if(i[he](e)){if(ge(c,r))return;o=[[e,r],...s.slice(1)]}else o=[[e,r],...s]}else o=[[e,r]];t.set(n,o)},i1=Ms,a1=y0,c1=x0,l1=k0,u1=Bd,f1=Ud,h1=qd,d1=S0,g1=w0,p1=I(Ss,Fv(t=>t.ordinal)),m1=Lv(p1),v1=t=>{switch(t){case"All":return a1;case"Debug":return h1;case"Error":return l1;case"Fatal":return c1;case"Info":return f1;case"Trace":return d1;case"None":return g1;case"Warning":return u1}},lg=t=>t.replace(/[\s="]/g,"_"),b1=t=>e=>`${lg(e.label)}=${t-e.startTime}ms`,_1=$s,y1=wv;class x1 extends y1{}const ug="Empty",fg="Add",hg="Remove",dg="Update",gg="AndThen",k1={_tag:ug},S1=(t,e)=>{const n=new Map(t.locals);let r=k1;for(const[s,o]of e.locals.entries()){const i=Tt(o)[1],c=n.get(s);if(c!==void 0){const a=Tt(c)[1];ge(a,i)||(r=pa({_tag:dg,fiberRef:s,patch:s.diff(a,i)})(r))}else r=pa({_tag:fg,fiberRef:s,value:i})(r);n.delete(s)}for(const[s]of n.entries())r=pa({_tag:hg,fiberRef:s})(r);return r},pa=k(2,(t,e)=>({_tag:gg,first:t,second:e})),w1=k(3,(t,e,n)=>{let r=n,s=Ut(t);for(;Et(s);){const o=Tt(s),i=wr(s);switch(o._tag){case ug:{s=i;break}case fg:{r=Ja(r,{fiberId:e,fiberRef:o.fiberRef,value:o.value}),s=i;break}case hg:{r=cg(r,o.fiberRef),s=i;break}case dg:{const c=Ms(r,o.fiberRef);r=Ja(r,{fiberId:e,fiberRef:o.fiberRef,value:o.fiberRef.patch(o.patch)(c)}),s=i;break}case gg:{s=Do(o.first)(Do(o.second)(i));break}}}return r}),pg="effect/MetricLabel",Ya=Symbol.for(pg);class T1{key;value;[Ya]=Ya;_hash;constructor(e,n){this.key=e,this.value=n,this._hash=Ge(pg+this.key+this.value)}[de](){return this._hash}[he](e){return R1(e)&&this.key===e.key&&this.value===e.value}pipe(){return le(this,arguments)}}const C1=(t,e)=>new T1(t,e),R1=t=>me(t,Ya),I1=t=>{let e,n;typeof t=="function"?e=t:(e=t.try,n=t.catch);const r=s=>n?tl(()=>n(s)):ht(new Wd(s,"An unknown error occurred in Effect.tryPromise"));return e.length>=1?Xn((s,o)=>{try{e(o).then(i=>s(Ne(i)),i=>s(r(i)))}catch(i){s(r(i))}}):Xn(s=>{try{e().then(o=>s(Ne(o)),o=>s(r(o)))}catch(o){s(r(o))}})},E1="Sequential",O1="Parallel",A1="ParallelN",M1={_tag:E1},N1={_tag:O1},P1=t=>({_tag:A1,parallelism:t}),Za=M1,Qa=N1,Xa=P1,F1=S1,L1=w1,Pi="effect/FiberStatus",tr=Symbol.for(Pi),Jo="Done",Uu="Running",qu="Suspended",j1=Ge(`${Pi}-${Jo}`);class D1{[tr]=tr;_tag=Jo;[de](){return j1}[he](e){return dl(e)&&e._tag===Jo}}class $1{runtimeFlags;[tr]=tr;_tag=Uu;constructor(e){this.runtimeFlags=e}[de](){return I(Z(Pi),Se(Z(this._tag)),Se(Z(this.runtimeFlags)),ze(this))}[he](e){return dl(e)&&e._tag===Uu&&this.runtimeFlags===e.runtimeFlags}}class B1{runtimeFlags;blockingOn;[tr]=tr;_tag=qu;constructor(e,n){this.runtimeFlags=e,this.blockingOn=n}[de](){return I(Z(Pi),Se(Z(this._tag)),Se(Z(this.runtimeFlags)),Se(Z(this.blockingOn)),ze(this))}[he](e){return dl(e)&&e._tag===qu&&this.runtimeFlags===e.runtimeFlags&&ge(this.blockingOn,e.blockingOn)}}const U1=new D1,q1=t=>new $1(t),z1=(t,e)=>new B1(t,e),dl=t=>me(t,tr),V1=t=>t._tag===Jo,H1=U1,mg=q1,W1=z1,K1=V1,G1=Symbol.for("effect/Micro"),Yo=Symbol.for("effect/Micro/MicroExit"),zu=Symbol.for("effect/Micro/MicroCause"),J1={_E:Le};class vg extends globalThis.Error{_tag;traces;[zu];constructor(e,n,r){const s=`MicroCause.${e}`;let o,i,c;if(n instanceof globalThis.Error){o=`(${s}) ${n.name}`,i=n.message;const a=i.split(`
19
- `).length;c=n.stack?`(${s}) ${n.stack.split(`
20
- `).slice(0,a+3).join(`
21
- `)}`:`${o}: ${i}`}else o=s,i=xr(n,0),c=`${o}: ${i}`;r.length>0&&(c+=`
22
- ${r.join(`
23
- `)}`),super(i),this._tag=e,this.traces=r,this[zu]=J1,this.name=o,this.stack=c}pipe(){return le(this,arguments)}toString(){return this.stack}[Je](){return this.stack}}class Y1 extends vg{defect;constructor(e,n=[]){super("Die",e,n),this.defect=e}}const Z1=(t,e=[])=>new Y1(t,e);class Q1 extends vg{constructor(e=[]){super("Interrupt","interrupted",e)}}const X1=(t=[])=>new Q1(t),eS=t=>t._tag==="Interrupt",Vu=Symbol.for("effect/Micro/MicroFiber"),tS={_A:Le,_E:Le};class nS{context;interruptible;[Vu];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(e,n=!0){this.context=e,this.interruptible=n,this[Vu]=tS}getRef(e){return Tb(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Km):(this._observers.push(e),()=>{const n=this._observers.indexOf(e);n>=0&&this._observers.splice(n,1)})}_interrupted=!1;unsafeInterrupt(){this._exit||(this._interrupted=!0,this.interruptible&&this.evaluate(bl))}unsafePoll(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){const s=this._yielded;this._yielded=void 0,s()}const n=this.runLoop(e);if(n===ho)return;const r=Hu.interruptChildren&&Hu.interruptChildren(this);if(r!==void 0)return this.evaluate(Qo(r,()=>n));this._exit=n;for(let s=0;s<this._observers.length;s++)this._observers[s](n);this._observers.length=0}runLoop(e){let n=!1,r=e;this.currentOpCount=0;try{for(;;){if(this.currentOpCount++,!n&&this.getRef(_l).shouldYield(this)){n=!0;const s=r;r=Qo(aS,()=>s)}if(r=r[ec](this),r===ho){const s=this._yielded;return Yo in s?(this._yielded=void 0,s):ho}}}catch(s){return me(r,ec)?tc(s):tc(`MicroFiber.runLoop: Not a valid effect: ${String(r)}`)}}getCont(e){for(;;){const n=this._stack.pop();if(!n)return;const r=n[Zo]&&n[Zo](this);if(r)return{[e]:r};if(n[e])return n}}_yielded=void 0;yieldWith(e){return this._yielded=e,ho}children(){return this._children??=new Set}}const Hu=Ce("effect/Micro/fiberMiddleware",()=>({interruptChildren:void 0})),bg=Symbol.for("effect/Micro/identifier"),rt=Symbol.for("effect/Micro/args"),ec=Symbol.for("effect/Micro/evaluate"),Ur=Symbol.for("effect/Micro/successCont"),mr=Symbol.for("effect/Micro/failureCont"),Zo=Symbol.for("effect/Micro/ensureCont"),ho=Symbol.for("effect/Micro/Yield"),rS={_A:Le,_E:Le,_R:Le},sS={..._1,_op:"Micro",[G1]:rS,pipe(){return le(this,arguments)},[Symbol.iterator](){return new Zf(new Ls(this))},toJSON(){return{_id:"Micro",op:this[bg],...rt in this?{args:this[rt]}:void 0}},toString(){return ct(this)},[Je](){return ct(this)}};function oS(t){return tc("Micro.evaluate: Not implemented")}const Fi=t=>({...sS,[bg]:t.op,[ec]:t.eval??oS,[Ur]:t.contA,[mr]:t.contE,[Zo]:t.ensure}),gl=t=>{const e=Fi(t);return function(){const n=Object.create(e);return n[rt]=t.single===!1?arguments:arguments[0],n}},_g=t=>{const e={...Fi(t),[Yo]:Yo,_tag:t.op,get[t.prop](){return this[rt]},toJSON(){return{_id:"MicroExit",_tag:t.op,[t.prop]:this[rt]}},[he](n){return uS(n)&&n._tag===t.op&&ge(this[rt],n[rt])},[de](){return ze(this,Se(Ge(t.op))(Z(this[rt])))}};return function(n){const r=Object.create(e);return r[rt]=n,r[Ur]=void 0,r[mr]=void 0,r[Zo]=void 0,r}},pl=_g({op:"Success",prop:"value",eval(t){const e=t.getCont(Ur);return e?e[Ur](this[rt],t):t.yieldWith(this)}}),yg=_g({op:"Failure",prop:"cause",eval(t){let e=t.getCont(mr);for(;eS(this[rt])&&e&&t.interruptible;)e=t.getCont(mr);return e?e[mr](this[rt],t):t.yieldWith(this)}}),iS=gl({op:"Yield",eval(t){let e=!1;return t.getRef(_l).scheduleTask(()=>{e||t.evaluate(fS)},this[rt]??0),t.yieldWith(()=>{e=!0})}}),aS=iS(0),cS=pl(void 0),ml=gl({op:"WithMicroFiber",eval(t){return this[rt](t)}}),Qo=k(2,(t,e)=>{const n=Object.create(lS);return n[rt]=t,n[Ur]=e,n}),lS=Fi({op:"OnSuccess",eval(t){return t._stack.push(this),this[rt]}}),uS=t=>me(t,Yo),xg=pl,vl=yg,bl=vl(X1()),tc=t=>vl(Z1(t)),fS=xg(void 0),hS="setImmediate"in globalThis?globalThis.setImmediate:t=>setTimeout(t,0);class kg{tasks=[];running=!1;scheduleTask(e,n){this.tasks.push(e),this.running||(this.running=!0,hS(this.afterScheduled))}afterScheduled=()=>{this.running=!1,this.runTasks()};runTasks(){const e=this.tasks;this.tasks=[];for(let n=0,r=e.length;n<r;n++)e[n]()}shouldYield(e){return e.currentOpCount>=e.getRef(pS)}flush(){for(;this.tasks.length>0;)this.runTasks()}}const dS=k(2,(t,e)=>ml(n=>{const r=n.context;return n.context=e(r),bS(t,()=>(n.context=r,cS))})),gS=k(2,(t,e)=>dS(t,Ah(e)));class pS extends Mh()("effect/Micro/currentMaxOpsBeforeYield",{defaultValue:()=>2048}){}class _l extends Mh()("effect/Micro/currentScheduler",{defaultValue:()=>new kg}){}const mS=k(2,(t,e)=>{const n=Object.create(vS);return n[rt]=t,n[Ur]=e.onSuccess,n[mr]=e.onFailure,n}),vS=Fi({op:"OnSuccessAndFailure",eval(t){return t._stack.push(this),this[rt]}}),bS=k(2,(t,e)=>yS(n=>mS(n(t),{onFailure:r=>Qo(e(vl(r)),()=>yg(r)),onSuccess:r=>Qo(e(xg(r)),()=>pl(r))}))),Sg=gl({op:"SetInterruptible",ensure(t){if(t.interruptible=this[rt],t._interrupted&&t.interruptible)return()=>bl}}),_S=t=>ml(e=>e.interruptible?t:(e.interruptible=!0,e._stack.push(Sg(!1)),e._interrupted?bl:t)),yS=t=>ml(e=>e.interruptible?(e.interruptible=!1,e._stack.push(Sg(!0)),t(_S)):t(Le)),xS=(t,e)=>{const n=new nS(_l.context(new kg));return n.evaluate(t),n};class kS{buckets=[];scheduleTask(e,n){const r=this.buckets.length;let s,o=0;for(;o<r&&this.buckets[o][0]<=n;o++)s=this.buckets[o];s&&s[0]===n?s[1].push(e):o===r?this.buckets.push([n,[e]]):this.buckets.splice(o,0,[n,[e]])}}class SS{maxNextTickBeforeTimer;running=!1;tasks=new kS;constructor(e){this.maxNextTickBeforeTimer=e}starveInternal(e){const n=this.tasks.buckets;this.tasks.buckets=[];for(const[r,s]of n)for(let o=0;o<s.length;o++)s[o]();this.tasks.buckets.length===0?this.running=!1:this.starve(e)}starve(e=0){e>=this.maxNextTickBeforeTimer?setTimeout(()=>this.starveInternal(0),0):Promise.resolve(void 0).then(()=>this.starveInternal(e+1))}shouldYield(e){return e.currentOpCount>e.getFiberRef(M0)?e.getFiberRef(ll):!1}scheduleTask(e,n){this.tasks.scheduleTask(e,n),this.running||(this.running=!0,this.starve())}}const wS=Ce(Symbol.for("effect/Scheduler/defaultScheduler"),()=>new SS(2048)),TS=Ce(Symbol.for("effect/FiberRef/currentScheduler"),()=>Ct(wS)),wg=Ce(Symbol.for("effect/FiberRef/currentRequestMap"),()=>Ct(new Map)),Wu=(t,e,n,r)=>{switch(t){case void 0:return e();case"unbounded":return n();case"inherit":return cl(j0,s=>s==="unbounded"?n():s>1?r(s):e());default:return t>1?r(t):e()}},yl="InterruptSignal",xl="Stateful",kl="Resume",Sl="YieldNow",ma=t=>({_tag:yl,cause:t}),Ro=t=>({_tag:xl,onFiber:t}),cr=t=>({_tag:kl,effect:t}),CS=()=>({_tag:Sl}),RS="effect/FiberScope",Xo=Symbol.for(RS);class IS{[Xo]=Xo;fiberId=Mr;roots=new Set;add(e,n){this.roots.add(n),n.addObserver(()=>{this.roots.delete(n)})}}class ES{fiberId;parent;[Xo]=Xo;constructor(e,n){this.fiberId=e,this.parent=n}add(e,n){this.parent.tell(Ro(r=>{r.addChild(n),n.addObserver(()=>{r.removeChild(n)})}))}}const OS=t=>new ES(t.id(),t),Tg=Ce(Symbol.for("effect/FiberScope/Global"),()=>new IS),AS="effect/Fiber",MS=Symbol.for(AS),NS={_E:t=>t,_A:t=>t},PS="effect/Fiber",FS=Symbol.for(PS),Cg=t=>$d(Md(t.await),t.inheritAll);({...Bs});const Pn="effect/FiberCurrent",LS="effect/Logger",jS=Symbol.for(LS),DS={_Message:t=>t,_Output:t=>t},wl=t=>({[jS]:DS,log:t,pipe(){return le(this,arguments)}}),$S=/^[^\s"=]*$/,BS=(t,e)=>({annotations:n,cause:r,date:s,fiberId:o,logLevel:i,message:c,spans:a})=>{const u=g=>g.match($S)?g:t(g),f=(g,x)=>`${lg(g)}=${u(x)}`,h=(g,x)=>" "+f(g,x);let d=f("timestamp",s.toISOString());d+=h("level",i.label),d+=h("fiber",rd(o));const p=Hv(c);for(let g=0;g<p.length;g++)d+=h("message",xr(p[g],e));Nx(r)||(d+=h("cause",Ci(r,{renderErrorCause:!0})));for(const g of a)d+=" "+b1(s.getTime())(g);for(const[g,x]of n)d+=h(g,xr(x,e));return d},US=t=>`"${t.replace(/\\([\s\S])|(")/g,"\\$1$2")}"`,qS=wl(BS(US)),zS=typeof process=="object"&&process!==null&&typeof process.stdout=="object"&&process.stdout!==null;zS&&process.stdout.isTTY;const Rg="effect/MetricBoundaries",nc=Symbol.for(Rg);class VS{values;[nc]=nc;constructor(e){this.values=e,this._hash=I(Ge(Rg),Se(js(this.values)))}_hash;[de](){return this._hash}[he](e){return HS(e)&&ge(this.values,e.values)}pipe(){return le(this,arguments)}}const HS=t=>me(t,nc),WS=t=>{const e=I(t,bh(Ot(Number.POSITIVE_INFINITY)),ub);return new VS(e)},KS=t=>I(Vv(t.count-1,e=>t.start*Math.pow(t.factor,e)),pi,WS),GS="effect/MetricKeyType",Ig=Symbol.for(GS),Eg="effect/MetricKeyType/Counter",rc=Symbol.for(Eg),JS="effect/MetricKeyType/Frequency",YS=Symbol.for(JS),ZS="effect/MetricKeyType/Gauge",QS=Symbol.for(ZS),Og="effect/MetricKeyType/Histogram",sc=Symbol.for(Og),XS="effect/MetricKeyType/Summary",ew=Symbol.for(XS),Ag={_In:t=>t,_Out:t=>t};class tw{incremental;bigint;[Ig]=Ag;[rc]=rc;constructor(e,n){this.incremental=e,this.bigint=n,this._hash=Ge(Eg)}_hash;[de](){return this._hash}[he](e){return Mg(e)}pipe(){return le(this,arguments)}}class nw{boundaries;[Ig]=Ag;[sc]=sc;constructor(e){this.boundaries=e,this._hash=I(Ge(Og),Se(Z(this.boundaries)))}_hash;[de](){return this._hash}[he](e){return Ng(e)&&ge(this.boundaries,e.boundaries)}pipe(){return le(this,arguments)}}const rw=t=>new tw(t?.incremental??!1,t?.bigint??!1),sw=t=>new nw(t),Mg=t=>me(t,rc),ow=t=>me(t,YS),iw=t=>me(t,QS),Ng=t=>me(t,sc),aw=t=>me(t,ew),cw="effect/MetricKey",Pg=Symbol.for(cw),lw={_Type:t=>t},uw=Fc(ge);class Tl{name;keyType;description;tags;[Pg]=lw;constructor(e,n,r,s=[]){this.name=e,this.keyType=n,this.description=r,this.tags=s,this._hash=I(Ge(this.name+this.description),Se(Z(this.keyType)),Se(js(this.tags)))}_hash;[de](){return this._hash}[he](e){return fw(e)&&this.name===e.name&&ge(this.keyType,e.keyType)&&ge(this.description,e.description)&&uw(this.tags,e.tags)}pipe(){return le(this,arguments)}}const fw=t=>me(t,Pg),hw=(t,e)=>new Tl(t,rw(e),Nc(e?.description)),dw=(t,e,n)=>new Tl(t,sw(e),Nc(n)),gw=k(2,(t,e)=>e.length===0?t:new Tl(t.name,t.keyType,t.description,ko(t.tags,e))),pw="effect/MetricState",Ys=Symbol.for(pw),Fg="effect/MetricState/Counter",oc=Symbol.for(Fg),Lg="effect/MetricState/Frequency",ic=Symbol.for(Lg),jg="effect/MetricState/Gauge",ac=Symbol.for(jg),Dg="effect/MetricState/Histogram",cc=Symbol.for(Dg),$g="effect/MetricState/Summary",lc=Symbol.for($g),Zs={_A:t=>t};class mw{count;[Ys]=Zs;[oc]=oc;constructor(e){this.count=e}[de](){return I(Z(Fg),Se(Z(this.count)),ze(this))}[he](e){return Rw(e)&&this.count===e.count}pipe(){return le(this,arguments)}}const vw=Fc(ge);class bw{occurrences;[Ys]=Zs;[ic]=ic;constructor(e){this.occurrences=e}_hash;[de](){return I(Ge(Lg),Se(js(Ze(this.occurrences.entries()))),ze(this))}[he](e){return Iw(e)&&vw(Ze(this.occurrences.entries()),Ze(e.occurrences.entries()))}pipe(){return le(this,arguments)}}class _w{value;[Ys]=Zs;[ac]=ac;constructor(e){this.value=e}[de](){return I(Z(jg),Se(Z(this.value)),ze(this))}[he](e){return Ew(e)&&this.value===e.value}pipe(){return le(this,arguments)}}class yw{buckets;count;min;max;sum;[Ys]=Zs;[cc]=cc;constructor(e,n,r,s,o){this.buckets=e,this.count=n,this.min=r,this.max=s,this.sum=o}[de](){return I(Z(Dg),Se(Z(this.buckets)),Se(Z(this.count)),Se(Z(this.min)),Se(Z(this.max)),Se(Z(this.sum)),ze(this))}[he](e){return Ow(e)&&ge(this.buckets,e.buckets)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return le(this,arguments)}}class xw{error;quantiles;count;min;max;sum;[Ys]=Zs;[lc]=lc;constructor(e,n,r,s,o,i){this.error=e,this.quantiles=n,this.count=r,this.min=s,this.max=o,this.sum=i}[de](){return I(Z($g),Se(Z(this.error)),Se(Z(this.quantiles)),Se(Z(this.count)),Se(Z(this.min)),Se(Z(this.max)),Se(Z(this.sum)),ze(this))}[he](e){return Aw(e)&&this.error===e.error&&ge(this.quantiles,e.quantiles)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return le(this,arguments)}}const kw=t=>new mw(t),Sw=t=>new bw(t),ww=t=>new _w(t),Tw=t=>new yw(t.buckets,t.count,t.min,t.max,t.sum),Cw=t=>new xw(t.error,t.quantiles,t.count,t.min,t.max,t.sum),Rw=t=>me(t,oc),Iw=t=>me(t,ic),Ew=t=>me(t,ac),Ow=t=>me(t,cc),Aw=t=>me(t,lc),Mw="effect/MetricHook",Nw=Symbol.for(Mw),Pw={_In:t=>t,_Out:t=>t},Qs=t=>({[Nw]:Pw,pipe(){return le(this,arguments)},...t}),Ku=BigInt(0),Fw=t=>{let e=t.keyType.bigint?Ku:0;const n=t.keyType.incremental?t.keyType.bigint?s=>s>=Ku:s=>s>=0:s=>!0,r=s=>{n(s)&&(e=e+s)};return Qs({get:()=>kw(e),update:r,modify:r})},Lw=t=>{const e=new Map;for(const r of t.keyType.preregisteredWords)e.set(r,0);const n=r=>{const s=e.get(r)??0;e.set(r,s+1)};return Qs({get:()=>Sw(e),update:n,modify:n})},jw=(t,e)=>{let n=e;return Qs({get:()=>ww(n),update:r=>{n=r},modify:r=>{n=n+r}})},Dw=t=>{const e=t.keyType.boundaries.values,n=e.length,r=new Uint32Array(n+1),s=new Float64Array(n);let o=0,i=0,c=Number.MAX_VALUE,a=Number.MIN_VALUE;I(e,$o(Ss),dr((h,d)=>{s[d]=h}));const u=h=>{let d=0,p=n;for(;d!==p;){const g=Math.floor(d+(p-d)/2),x=s[g];h<=x?p=g:d=g,p===d+1&&(h<=s[d]?p=d:d=p)}r[d]=r[d]+1,o=o+1,i=i+h,h<c&&(c=h),h>a&&(a=h)},f=()=>{const h=Pc(n);let d=0;for(let p=0;p<n;p++){const g=s[p],x=r[p];d=d+x,h[p]=[g,d]}return h};return Qs({get:()=>Tw({buckets:f(),count:o,min:c,max:a,sum:i}),update:u,modify:u})},$w=t=>{const{error:e,maxAge:n,maxSize:r,quantiles:s}=t.keyType,o=I(s,$o(Ss)),i=Pc(r);let c=0,a=0,u=0,f=0,h=0;const d=g=>{const x=[];let v=0;for(;v!==r-1;){const _=i[v];if(_!=null){const[O,P]=_,R=Na(g-O);t_(R,Bh)&&e_(R,n)&&x.push(P)}v=v+1}return Bw(e,o,$o(x,Ss))},p=(g,x)=>{if(r>0){c=c+1;const v=c%r;i[v]=[x,g]}f=a===0?g:Math.min(f,g),h=a===0?g:Math.max(h,g),a=a+1,u=u+g};return Qs({get:()=>Cw({error:e,quantiles:d(Date.now()),count:a,min:f,max:h,sum:u}),update:([g,x])=>p(g,x),modify:([g,x])=>p(g,x)})},Bw=(t,e,n)=>{const r=n.length;if(!Et(e))return Tr();const s=e[0],o=e.slice(1),i=Gu(t,r,ce(),0,s,n),c=Ut(i);return o.forEach(a=>{c.push(Gu(t,r,i.value,i.consumed,a,i.rest))}),dr(c,a=>[a.quantile,a.value])},Gu=(t,e,n,r,s,o)=>{let i=t,c=e,a=n,u=r,f=s,h=o,d=t,p=e,g=n,x=r,v=s,_=o;for(;;){if(!Et(h))return{quantile:f,value:ce(),consumed:u,rest:[]};if(f===1)return{quantile:f,value:ye(xh(h)),consumed:u+h.length,rest:[]};const O=Tt(h),P=eb(h,S=>S===O),R=f*c,D=i/2*R,w=u+P[0].length,A=Math.abs(w-R);if(w<R-D){d=i,p=c,g=bs(h),x=w,v=f,_=P[1],i=d,c=p,a=g,u=x,f=v,h=_;continue}if(w>R+D){const S=kt(a)?ye(O):a;return{quantile:f,value:S,consumed:u,rest:h}}switch(a._tag){case"None":{d=i,p=c,g=bs(h),x=w,v=f,_=P[1],i=d,c=p,a=g,u=x,f=v,h=_;continue}case"Some":{const S=Math.abs(R-a.value);if(A<S){d=i,p=c,g=bs(h),x=w,v=f,_=P[1],i=d,c=p,a=g,u=x,f=v,h=_;continue}return{quantile:f,value:ye(a.value),consumed:u,rest:h}}}}throw new Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues")},Uw="effect/MetricPair",qw=Symbol.for(Uw),zw={_Type:t=>t},Vw=(t,e)=>({[qw]:zw,metricKey:t,metricState:e,pipe(){return le(this,arguments)}}),Hw="effect/MetricRegistry",Ju=Symbol.for(Hw);class Ww{[Ju]=Ju;map=nk();snapshot(){const e=[];for(const[n,r]of this.map)e.push(Vw(n,r.get()));return e}get(e){const n=I(this.map,jn(e),Ln);if(n==null){if(Mg(e.keyType))return this.getCounter(e);if(iw(e.keyType))return this.getGauge(e);if(ow(e.keyType))return this.getFrequency(e);if(Ng(e.keyType))return this.getHistogram(e);if(aw(e.keyType))return this.getSummary(e);throw new Error("BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues")}else return n}getCounter(e){let n=I(this.map,jn(e),Ln);if(n==null){const r=Fw(e);I(this.map,is(e))||I(this.map,as(e,r)),n=r}return n}getFrequency(e){let n=I(this.map,jn(e),Ln);if(n==null){const r=Lw(e);I(this.map,is(e))||I(this.map,as(e,r)),n=r}return n}getGauge(e){let n=I(this.map,jn(e),Ln);if(n==null){const r=jw(e,e.keyType.bigint?BigInt(0):0);I(this.map,is(e))||I(this.map,as(e,r)),n=r}return n}getHistogram(e){let n=I(this.map,jn(e),Ln);if(n==null){const r=Dw(e);I(this.map,is(e))||I(this.map,as(e,r)),n=r}return n}getSummary(e){let n=I(this.map,jn(e),Ln);if(n==null){const r=$w(e);I(this.map,is(e))||I(this.map,as(e,r)),n=r}return n}}const Kw=()=>new Ww,Gw="effect/Metric",Jw=Symbol.for(Gw),Yw={_Type:t=>t,_In:t=>t,_Out:t=>t},Yu=Ce(Symbol.for("effect/Metric/globalMetricRegistry"),()=>Kw()),Bg=function(t,e,n,r){const s=Object.assign(o=>d0(o,i=>e2(s,i)),{[Jw]:Yw,keyType:t,unsafeUpdate:e,unsafeValue:n,unsafeModify:r,register(){return this.unsafeValue([]),this},pipe(){return le(this,arguments)}});return s},Li=(t,e)=>Ug(hw(t,e)),Ug=t=>{let e;const n=new WeakMap,r=s=>{if(s.length===0)return e!==void 0||(e=Yu.get(t)),e;let o=n.get(s);return o!==void 0||(o=Yu.get(gw(t,s)),n.set(s,o)),o};return Bg(t.keyType,(s,o)=>r(o).update(s),s=>r(s).get(),(s,o)=>r(o).modify(s))},Zw=(t,e,n)=>Ug(dw(t,e,n)),Qw=k(3,(t,e,n)=>Xw(t,[C1(e,n)])),Xw=k(2,(t,e)=>Bg(t.keyType,(n,r)=>t.unsafeUpdate(n,ko(e,r)),n=>t.unsafeValue(ko(e,n)),(n,r)=>t.unsafeModify(n,ko(e,r)))),e2=k(2,(t,e)=>cl(Ka,n=>se(()=>t.unsafeUpdate(e,n))));({...Mc});const t2=k(2,(t,e)=>cl(wg,n=>se(()=>{if(n.has(t)){const r=n.get(t);r.state.completed||(r.state.completed=!0,Jd(r.result,e))}}))),n2="effect/Supervisor",ji=Symbol.for(n2),Cl={_T:t=>t};class Di{underlying;value0;[ji]=Cl;constructor(e,n){this.underlying=e,this.value0=n}get value(){return this.value0}onStart(e,n,r,s){this.underlying.onStart(e,n,r,s)}onEnd(e,n){this.underlying.onEnd(e,n)}onEffect(e,n){this.underlying.onEffect(e,n)}onSuspend(e){this.underlying.onSuspend(e)}onResume(e){this.underlying.onResume(e)}map(e){return new Di(this,I(this.value,yt(e)))}zip(e){return new $i(this,e)}}class $i{left;right;_tag="Zip";[ji]=Cl;constructor(e,n){this.left=e,this.right=n}get value(){return Dd(this.left.value,this.right.value)}onStart(e,n,r,s){this.left.onStart(e,n,r,s),this.right.onStart(e,n,r,s)}onEnd(e,n){this.left.onEnd(e,n),this.right.onEnd(e,n)}onEffect(e,n){this.left.onEffect(e,n),this.right.onEffect(e,n)}onSuspend(e){this.left.onSuspend(e),this.right.onSuspend(e)}onResume(e){this.left.onResume(e),this.right.onResume(e)}map(e){return new Di(this,I(this.value,yt(e)))}zip(e){return new $i(this,e)}}const qg=t=>me(t,ji)&&Jf(t,"Zip");class r2{effect;[ji]=Cl;constructor(e){this.effect=e}get value(){return this.effect}onStart(e,n,r,s){}onEnd(e,n){}onEffect(e,n){}onSuspend(e){}onResume(e){}map(e){return new Di(this,I(this.value,yt(e)))}zip(e){return new $i(this,e)}onRun(e,n){return e()}}const s2=t=>new r2(t),Rl=Ce("effect/Supervisor/none",()=>s2(an)),o2=Vr,zg="Empty",Vg="AddSupervisor",Hg="RemoveSupervisor",Wg="AndThen",ys={_tag:zg},Io=(t,e)=>({_tag:Wg,first:t,second:e}),i2=(t,e)=>a2(e,Ot(t)),a2=(t,e)=>{let n=t,r=e;for(;Ir(r);){const s=Er(r);switch(s._tag){case zg:{r=Bn(r);break}case Vg:{n=n.zip(s.supervisor),r=Bn(r);break}case Hg:{n=uc(n,s.supervisor),r=Bn(r);break}case Wg:{r=Gt(s.first)(Gt(s.second)(Bn(r)));break}}}return n},uc=(t,e)=>ge(t,e)?Rl:qg(t)?uc(t.left,e).zip(uc(t.right,e)):t,ei=t=>ge(t,Rl)?Yn():qg(t)?I(ei(t.left),Cs(ei(t.right))):Wc(t),c2=(t,e)=>{if(ge(t,e))return ys;const n=ei(t),r=ei(e),s=I(r,lu(n),qo(ys,(i,c)=>Io(i,{_tag:Vg,supervisor:c}))),o=I(n,lu(r),qo(ys,(i,c)=>Io(i,{_tag:Hg,supervisor:c})));return Io(s,o)},l2=o2({empty:ys,patch:i2,combine:Io,diff:c2}),u2=Li("effect_fiber_started",{incremental:!0}),Zu=Li("effect_fiber_active"),f2=Li("effect_fiber_successes",{incremental:!0}),h2=Li("effect_fiber_failures",{incremental:!0}),d2=Qw(Zw("effect_fiber_lifetimes",KS({start:.5,factor:2,count:35})),"time_unit","milliseconds"),cs="Continue",g2="Done",Qu="Yield",p2={_E:t=>t,_A:t=>t},go=t=>{throw new Error(`BUG: FiberRuntime - ${xr(t)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},pn=Symbol.for("effect/internal/fiberRuntime/YieldedOp"),mn=Ce("effect/internal/fiberRuntime/yieldedOpChannel",()=>({currentOp:null})),ls={[Fo]:(t,e,n)=>bt(()=>e.effect_instruction_i1(n)),OnStep:(t,e,n)=>at(at(n)),[Lo]:(t,e,n)=>bt(()=>e.effect_instruction_i2(n)),[Oc]:(t,e,n)=>(t.patchRuntimeFlags(t.currentRuntimeFlags,e.patch),Cn(t.currentRuntimeFlags)&&t.isInterrupted()?Be(t.getInterruptedCause()):at(n)),[jo]:(t,e,n)=>(bt(()=>e.effect_instruction_i2(n)),bt(()=>e.effect_instruction_i0())?(t.pushStack(e),bt(()=>e.effect_instruction_i1())):an),[vs]:(t,e,n)=>{for(;;){const r=bt(()=>e.effect_instruction_i0.next(n));if(r.done)return at(r.value);const s=cv(r.value);if(Ni(s)){if(s._tag==="Failure")return s}else return t.pushStack(e),s;n=s.value}}},m2={[yl]:(t,e,n,r)=>(t.processNewInterruptSignal(r.cause),Cn(e)?Be(r.cause):n),[kl]:(t,e,n,r)=>{throw new Error("It is illegal to have multiple concurrent run loops in a single fiber")},[xl]:(t,e,n,r)=>(r.onFiber(t,mg(e)),n),[Sl]:(t,e,n,r)=>oe(ol(),()=>n)},v2=t=>Ei(mx(t),e=>Kn(Ox(e),([n,r])=>{const s=new Map,o=[];for(const c of r){o.push(Hn(c));for(const a of c)s.set(a.request,a)}const i=o.flat();return Ai(F2(n.runAll(o),i,()=>i.forEach(c=>{c.listeners.interrupted=!0})),wg,s)},!1,!1)),b2=Ac();class _2 extends x1{[MS]=NS;[FS]=p2;_fiberRefs;_fiberId;_queue=new Array;_children=null;_observers=new Array;_running=!1;_stack=[];_asyncInterruptor=null;_asyncBlockingOn=null;_exitValue=null;_steps=[];_isYielding=!1;currentRuntimeFlags;currentOpCount=0;currentSupervisor;currentScheduler;currentTracer;currentSpan;currentContext;currentDefaultServices;constructor(e,n,r){if(super(),this.currentRuntimeFlags=r,this._fiberId=e,this._fiberRefs=n,gu(r)){const s=this.getFiberRef(Ka);u2.unsafeUpdate(1,s),Zu.unsafeUpdate(1,s)}this.refreshRefCache()}commit(){return Cg(this)}id(){return this._fiberId}resume(e){this.tell(cr(e))}get status(){return this.ask((e,n)=>n)}get runtimeFlags(){return this.ask((e,n)=>K1(n)?e.currentRuntimeFlags:n.runtimeFlags)}scope(){return OS(this)}get children(){return this.ask(e=>Array.from(e.getChildren()))}getChildren(){return this._children===null&&(this._children=new Set),this._children}getInterruptedCause(){return this.getFiberRef(fo)}fiberRefs(){return this.ask(e=>e.getFiberRefs())}ask(e){return nt(()=>{const n=G0(this._fiberId);return this.tell(Ro((r,s)=>{Jd(n,se(()=>e(r,s)))})),Gd(n)})}tell(e){this._queue.push(e),this._running||(this._running=!0,this.drainQueueLaterOnExecutor())}get await(){return Xn(e=>{const n=r=>e(Ne(r));if(this._exitValue!==null){n(this._exitValue);return}return this.tell(Ro((r,s)=>{r._exitValue!==null?n(this._exitValue):r.addObserver(n)})),se(()=>this.tell(Ro((r,s)=>{r.removeObserver(n)})))},this.id())}get inheritAll(){return At((e,n)=>{const r=e.id(),s=e.getFiberRefs(),o=n.runtimeFlags,i=this.getFiberRefs(),c=t1(s,r,i);e.setFiberRefs(c);const a=e.getFiberRef(rf),u=I(To(o,a),mu(Hs),mu(Va));return p0(u)})}get poll(){return se(()=>Nc(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(e){return se(()=>this.tell(ma(Rn(e))))}unsafeInterruptAsFork(e){this.tell(ma(Rn(e)))}addObserver(e){this._exitValue!==null?e(this._exitValue):this._observers.push(e)}removeObserver(e){this._observers=this._observers.filter(n=>n!==e)}getFiberRefs(){return this.setFiberRef(rf,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(e){this._fiberRefs=cg(this._fiberRefs,e)}getFiberRef(e){return this._fiberRefs.locals.has(e)?this._fiberRefs.locals.get(e)[0][1]:e.initial}setFiberRef(e,n){this._fiberRefs=Ja(this._fiberRefs,{fiberId:this._fiberId,fiberRef:e,value:n}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(Go),this.currentTracer=this.currentDefaultServices.unsafeMap.get(ig.key),this.currentSupervisor=this.getFiberRef(P2),this.currentScheduler=this.getFiberRef(TS),this.currentContext=this.getFiberRef(Mi),this.currentSpan=this.currentContext.unsafeMap.get(ag.key)}setFiberRefs(e){this._fiberRefs=e,this.refreshRefCache()}addChild(e){this.getChildren().add(e)}removeChild(e){this.getChildren().delete(e)}transferChildren(e){const n=this._children;if(this._children=null,n!==null&&n.size>0)for(const r of n)r._exitValue===null&&e.add(this.currentRuntimeFlags,r)}drainQueueOnCurrentThread(){let e=!0;for(;e;){let n=cs;const r=globalThis[Pn];globalThis[Pn]=this;try{for(;n===cs;)n=this._queue.length===0?g2:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[Pn]=r}this._queue.length>0&&!this._running?(this._running=!0,n===Qu?(this.drainQueueLaterOnExecutor(),e=!1):e=!0):e=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(ll))}drainQueueWhileRunning(e,n){let r=n;for(;this._queue.length>0;){const s=this._queue.splice(0,1)[0];r=m2[s._tag](this,e,r,s)}return r}isInterrupted(){return!Px(this.getFiberRef(fo))}addInterruptedCause(e){const n=this.getFiberRef(fo);this.setFiberRef(fo,Dt(n,e))}processNewInterruptSignal(e){this.addInterruptedCause(e),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let e=!1;for(const n of this._children)n.tell(ma(Rn(this.id()))),e=!0;return e}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){const e=this._children.values();this._children=null;let n=!1;return sl({while:()=>!n,body:()=>{const s=e.next();return s.done?se(()=>{n=!0}):Ii(s.value.await)},step:()=>{}})}return null}reportExitValue(e){if(gu(this.currentRuntimeFlags)){const n=this.getFiberRef(Ka),r=this.id().startTimeMillis,s=Date.now();switch(d2.unsafeUpdate(s-r,n),Zu.unsafeUpdate(-1,n),e._tag){case Kt:{f2.unsafeUpdate(1,n);break}case Wt:{h2.unsafeUpdate(1,n);break}}}if(e._tag==="Failure"){const n=this.getFiberRef($0);!Qc(e.cause)&&n._tag==="Some"&&this.log("Fiber terminated with an unhandled error",e.cause,n)}}setExitValue(e){this._exitValue=e,this.reportExitValue(e);for(let n=this._observers.length-1;n>=0;n--)this._observers[n](e);this._observers=[]}getLoggers(){return this.getFiberRef(w2)}log(e,n,r){const s=on(r)?r.value:this.getFiberRef(P0),o=this.getFiberRef(y2);if(m1(o,s))return;const i=this.getFiberRef(F0),c=this.getFiberRef(N0),a=this.getLoggers(),u=this.getFiberRefs();if(Qh(a)>0){const f=Eh(this.getFiberRef(Go),hl),h=new Date(f.unsafeCurrentTimeMillis());dv(u,()=>{for(const d of a)d.log({fiberId:this.id(),logLevel:s,message:e,cause:n,context:u,spans:i,annotations:c,date:h})})}}evaluateMessageWhileSuspended(e){switch(e._tag){case Sl:return Qu;case yl:return this.processNewInterruptSignal(e.cause),this._asyncInterruptor!==null&&(this._asyncInterruptor(Be(e.cause)),this._asyncInterruptor=null),cs;case kl:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(e.effect),cs;case xl:return e.onFiber(this,this._exitValue!==null?H1:W1(this.currentRuntimeFlags,this._asyncBlockingOn)),cs;default:return go(e)}}evaluateEffect(e){this.currentSupervisor.onResume(this);try{let n=Cn(this.currentRuntimeFlags)&&this.isInterrupted()?Be(this.getInterruptedCause()):e;for(;n!==null;){const r=n,s=this.runLoop(r);if(s===pn){const o=mn.currentOp;mn.currentOp=null,o._op===xo?ux(this.currentRuntimeFlags)?(this.tell(CS()),this.tell(cr(Un)),n=null):n=Un:o._op===ms&&(n=null)}else{this.currentRuntimeFlags=I(this.currentRuntimeFlags,fx(Va));const o=this.interruptAllChildren();o!==null?n=oe(o,()=>s):(this._queue.length===0?this.setExitValue(s):this.tell(cr(s)),n=null)}}}finally{this.currentSupervisor.onSuspend(this)}}start(e){if(this._running)this.tell(cr(e));else{this._running=!0;const n=globalThis[Pn];globalThis[Pn]=this;try{this.evaluateEffect(e)}finally{this._running=!1,globalThis[Pn]=n,this._queue.length>0&&this.drainQueueLaterOnExecutor()}}}startFork(e){this.tell(cr(e))}patchRuntimeFlags(e,n){const r=Co(e,n);return globalThis[Pn]=this,this.currentRuntimeFlags=r,r}initiateAsync(e,n){let r=!1;const s=o=>{r||(r=!0,this.tell(cr(o)))};Cn(e)&&(this._asyncInterruptor=s);try{n(s)}catch(o){s(Jt(yn(o)))}}pushStack(e){this._stack.push(e),e._op==="OnStep"&&this._steps.push({refs:this.getFiberRefs(),flags:this.currentRuntimeFlags})}popStack(){const e=this._stack.pop();if(e)return e._op==="OnStep"&&this._steps.pop(),e}getNextSuccessCont(){let e=this.popStack();for(;e;){if(e._op!==aa)return e;e=this.popStack()}}getNextFailCont(){let e=this.popStack();for(;e;){if(e._op!==Fo&&e._op!==jo&&e._op!==vs)return e;e=this.popStack()}}[pv](e){return se(()=>Oh(this.currentContext,e))}Left(e){return ht(e.left)}None(e){return ht(new V0)}Right(e){return at(e.right)}Some(e){return at(e.value)}Micro(e){return Wo(n=>{let r=n;const s=xS(gS(e,this.currentContext));return s.addObserver(o=>{if(o._tag==="Success")return r(at(o.value));switch(o.cause._tag){case"Interrupt":return r(Be(Rn(Mr)));case"Fail":return r(ht(o.cause.error));case"Die":return r(ku(o.cause.defect))}}),Wo(o=>{r=i=>{o(an)},s.unsafeInterrupt()})})}[rh](e){const n=bt(()=>e.effect_instruction_i0()),r=this.getNextSuccessCont();return r!==void 0?(r._op in ls||go(r),ls[r._op](this,r,n)):(mn.currentOp=at(n),pn)}[Kt](e){const n=e,r=this.getNextSuccessCont();return r!==void 0?(r._op in ls||go(r),ls[r._op](this,r,n.effect_instruction_i0)):(mn.currentOp=n,pn)}[Wt](e){const n=e.effect_instruction_i0,r=this.getNextFailCont();if(r!==void 0)switch(r._op){case aa:case Lo:return Cn(this.currentRuntimeFlags)&&this.isInterrupted()?Be(vu(n)):bt(()=>r.effect_instruction_i1(n));case"OnStep":return Cn(this.currentRuntimeFlags)&&this.isInterrupted()?Be(vu(n)):at(Be(n));case Oc:return this.patchRuntimeFlags(this.currentRuntimeFlags,r.patch),Cn(this.currentRuntimeFlags)&&this.isInterrupted()?Be(Dt(n,this.getInterruptedCause())):Be(n);default:go(r)}else return mn.currentOp=Be(n),pn}[sh](e){return bt(()=>e.effect_instruction_i0(this,mg(this.currentRuntimeFlags)))}Blocked(e){const n=this.getFiberRefs(),r=this.currentRuntimeFlags;if(this._steps.length>0){const s=[],o=this._steps[this._steps.length-1];let i=this.popStack();for(;i&&i._op!=="OnStep";)s.push(i),i=this.popStack();this.setFiberRefs(o.refs),this.currentRuntimeFlags=o.flags;const c=F1(o.refs,n),a=To(o.flags,r);return at(Cd(e.effect_instruction_i0,At(u=>{for(;s.length>0;)u.pushStack(s.pop());return u.setFiberRefs(L1(u.id(),u.getFiberRefs())(c)),u.currentRuntimeFlags=Co(a)(u.currentRuntimeFlags),e.effect_instruction_i1})))}return Oi(s=>oe(Kg(r0(e.effect_instruction_i0)),()=>s(e.effect_instruction_i1)))}RunBlocked(e){return v2(e.effect_instruction_i0)}[Ds](e){const n=e.effect_instruction_i0,r=this.currentRuntimeFlags,s=Co(r,n);if(Cn(s)&&this.isInterrupted())return Be(this.getInterruptedCause());if(this.patchRuntimeFlags(this.currentRuntimeFlags,n),e.effect_instruction_i1){const o=To(s,r);return this.pushStack(new s0(o,e)),bt(()=>e.effect_instruction_i1(r))}else return Un}[Fo](e){return this.pushStack(e),e.effect_instruction_i0}OnStep(e){return this.pushStack(e),e.effect_instruction_i0}[aa](e){return this.pushStack(e),e.effect_instruction_i0}[Lo](e){return this.pushStack(e),e.effect_instruction_i0}[ms](e){return this._asyncBlockingOn=e.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,e.effect_instruction_i0),mn.currentOp=e,pn}[xo](e){return this._isYielding=!1,mn.currentOp=e,pn}[jo](e){const n=e.effect_instruction_i0,r=e.effect_instruction_i1;return n()?(this.pushStack(e),r()):Un}[vs](e){return ls[vs](this,e,void 0)}[gi](e){return bt(()=>e.commit())}runLoop(e){let n=e;for(this.currentOpCount=0;;){if((this.currentRuntimeFlags&ax)!==0&&this.currentSupervisor.onEffect(this,n),this._queue.length>0&&(n=this.drainQueueWhileRunning(this.currentRuntimeFlags,n)),!this._isYielding){this.currentOpCount+=1;const r=this.currentScheduler.shouldYield(this);if(r!==!1){this._isYielding=!0,this.currentOpCount=0;const s=n;n=oe(ol({priority:r}),()=>s)}}try{if(n=this.currentTracer.context(()=>{if(b2!==n[$r]._V){const r=this.getFiberRef(B0);if(r._tag==="Some"){const s=n[$r]._V;this.log(`Executing an Effect versioned ${s} with a Runtime of version ${Ac()}, you may want to dedupe the effect dependencies, you can use the language service plugin to detect this at compile time: https://github.com/Effect-TS/language-service`,Lr,r)}}return this[n._op](n)},this),n===pn){const r=mn.currentOp;return r._op===xo||r._op===ms?pn:(mn.currentOp=null,r._op===Kt||r._op===Wt?r:Be(yn(r)))}}catch(r){n!==pn&&!me(n,"_op")||!(n._op in this)?n=a0(`Not a valid effect: ${xr(n)}`):z0(r)?n=Be(Dt(yn(r),Rn(Mr))):n=ku(r)}}}run=()=>{this.drainQueueOnCurrentThread()}}const y2=Ce("effect/FiberRef/currentMinimumLogLevel",()=>Ct(v1("Info"))),x2=t=>wl(e=>{const n=i1(e.context,Go);Eh(n,og).unsafe.log(t.log(e))}),k2=Ce(Symbol.for("effect/Logger/defaultLogger"),()=>x2(qS)),S2=Ce(Symbol.for("effect/Logger/tracerLogger"),()=>wl(({annotations:t,cause:e,context:n,fiberId:r,logLevel:s,message:o})=>{const i=Us(Ms(n,Mi),ag);if(i._tag==="None"||i.value._tag==="ExternalSpan")return;const c=Oh(Ms(n,Go),hl),a={};for(const[u,f]of t)a[u]=f;a["effect.fiberId"]=K_(r),a["effect.logLevel"]=s.label,e!==null&&e._tag!=="Empty"&&(a["effect.cause"]=Ci(e,{renderErrorCause:!0})),i.value.event(xr(Array.isArray(o)&&o.length===1?o[0]:o),c.unsafeCurrentTimeNanos(),a)})),w2=Ce(Symbol.for("effect/FiberRef/currentLoggers"),()=>E0(Wc(k2,S2))),T2=t=>{if(Array.isArray(t)||Yf(t))return[t,ce()];const e=Object.keys(t),n=e.length;return[e.map(r=>t[r]),ye(r=>{const s={};for(let o=0;o<n;o++)s[e[o]]=r[o];return s})]},C2=(t,e,n)=>{const r=[];for(const s of t)r.push(Os(s));return oe(Ns(r,Le,{concurrency:n?.concurrency,batching:n?.batching,concurrentFinalizers:n?.concurrentFinalizers}),s=>{const o=ce(),i=s.length,c=new Array(i),a=new Array(i);let u=!1;for(let f=0;f<i;f++){const h=s[f];h._tag==="Left"?(c[f]=ye(h.left),u=!0):(a[f]=h.right,c[f]=o)}return u?e._tag==="Some"?ht(e.value(c)):ht(c):n?.discard?an:e._tag==="Some"?Ne(e.value(a)):Ne(a)})},R2=(t,e,n)=>{const r=[];for(const s of t)r.push(Os(s));return n?.discard?Ns(r,Le,{concurrency:n?.concurrency,batching:n?.batching,discard:!0,concurrentFinalizers:n?.concurrentFinalizers}):yt(Ns(r,Le,{concurrency:n?.concurrency,batching:n?.batching,concurrentFinalizers:n?.concurrentFinalizers}),s=>e._tag==="Some"?e.value(s):s)},I2=(t,e)=>{const[n,r]=T2(t);return e?.mode==="validate"?C2(n,r,e):e?.mode==="either"?R2(n,r,e):e?.discard!==!0&&r._tag==="Some"?yt(Ns(n,Le,e),r.value):Ns(n,Le,e)},Ns=k(t=>Yf(t[0]),(t,e,n)=>At(r=>{const s=n?.batching===!0||n?.batching==="inherit"&&r.getFiberRef(D0);return n?.discard?Wu(n.concurrency,()=>lr(Za,n?.concurrentFinalizers)(o=>s?Kn(t,(i,c)=>o(e(i,c)),!0,!1,1):Ei(t,(i,c)=>o(e(i,c)))),()=>lr(Qa,n?.concurrentFinalizers)(o=>Kn(t,(i,c)=>o(e(i,c)),s,!1)),o=>lr(Xa(o),n?.concurrentFinalizers)(i=>Kn(t,(c,a)=>i(e(c,a)),s,!1,o))):Wu(n?.concurrency,()=>lr(Za,n?.concurrentFinalizers)(o=>s?Xu(t,1,(i,c)=>o(e(i,c)),!0):In(t,(i,c)=>o(e(i,c)))),()=>lr(Qa,n?.concurrentFinalizers)(o=>E2(t,(i,c)=>o(e(i,c)),s)),o=>lr(Xa(o),n?.concurrentFinalizers)(i=>Xu(t,o,(c,a)=>i(e(c,a)),s)))})),E2=(t,e,n)=>nt(()=>{const r=Ze(t),s=new Array(r.length);return il(Kn(r,(i,c)=>oe(e(i,c),a=>se(()=>s[c]=a)),n,!1),Ne(s))}),Kn=(t,e,n,r,s)=>Oi(o=>g0(i=>At(c=>{let a=Array.from(t).reverse(),u=a.length;if(u===0)return an;let f=0,h=!1;const d=s?Math.min(a.length,s):a.length,p=new Set,g=new Array,x=()=>p.forEach(S=>{S.currentScheduler.scheduleTask(()=>{S.unsafeInterruptAsFork(c.id())},0)}),v=new Array,_=new Array,O=new Array,P=()=>{const S=g.filter(({exit:M})=>M._tag==="Failure").sort((M,E)=>M.index<E.index?-1:M.index===E.index?0:1).map(({exit:M})=>M);return S.length===0&&S.push(Un),S},R=(S,M=!1)=>{const E=jd(i(S)),$=A2(E,c,c.currentRuntimeFlags,Tg);return c.currentScheduler.scheduleTask(()=>{M&&$.unsafeInterruptAsFork(c.id()),$.resume(E)},0),$},D=()=>{r||(u-=a.length,a=[]),h=!0,x()},w=n?f0:Ad,A=R(Xn(S=>{const M=($,Q)=>{$._op==="Blocked"?O.push($):(g.push({index:Q,exit:$}),$._op==="Failure"&&!h&&D())},E=()=>{if(a.length>0){const $=a.pop();let Q=f++;const pe=()=>{const _e=a.pop();return Q=f++,oe(ol(),()=>oe(w(o(e(_e,Q))),W))},W=_e=>a.length>0&&(M(_e,Q),a.length>0)?pe():Ne(_e),ue=oe(w(o(e($,Q))),W),Oe=R(ue);v.push(Oe),p.add(Oe),h&&Oe.currentScheduler.scheduleTask(()=>{Oe.unsafeInterruptAsFork(c.id())},0),Oe.addObserver(_e=>{let Y;if(_e._op==="Failure"?Y=_e:Y=_e.effect_instruction_i0,_.push(Oe),p.delete(Oe),M(Y,Q),g.length===u)S(Ne(Gn(Ru(P(),{parallel:!0}),()=>Un)));else if(O.length+g.length===u){const K=P(),Qe=O.map(Ue=>Ue.effect_instruction_i0).reduce(vd);S(Ne(Cd(Qe,Kn([Gn(Ru(K,{parallel:!0}),()=>Un),...O.map(Ue=>Ue.effect_instruction_i1)],Ue=>Ue,n,!0,s))))}else E()})}};for(let $=0;$<d;$++)E()}));return Ii(Fd(Md(o(Cg(A))),Kd({onFailure:S=>{D();const M=O.length+1,E=Math.min(typeof s=="number"?s:O.length,O.length),$=Array.from(O);return Xn(Q=>{let pe=0,W=0;const ue=(_e,Y)=>K=>{pe++,pe===M&&Q(at(Be(S))),$.length>0&&Y&&Oe()},Oe=()=>{R($.pop(),!0).addObserver(ue(W,!0)),W++};A.addObserver(ue(W,!1)),W++;for(let _e=0;_e<E;_e++)Oe()})},onSuccess:()=>In(_,S=>S.inheritAll)})))}))),Xu=(t,e,n,r)=>nt(()=>{const s=Ze(t),o=new Array(s.length);return il(Kn(s,(c,a)=>yt(n(c,a),u=>o[a]=u),r,!1,e),Ne(o))}),Kg=t=>M2(t,Tg),O2=(t,e,n,r=null)=>{const s=Gg(t,e,n,r);return s.resume(t),s},A2=(t,e,n,r=null)=>Gg(t,e,n,r),Gg=(t,e,n,r=null)=>{const s=G_(),o=e.getFiberRefs(),i=n1(o,s),c=new _2(s,i,n),a=Ms(i,Mi),u=c.currentSupervisor;return u.onStart(a,t,ye(e),c),c.addObserver(h=>u.onEnd(h,c)),(r!==null?r:I(e.getFiberRef(Ga),Gn(()=>e.scope()))).add(n,c),c},M2=(t,e)=>At((n,r)=>Ne(O2(t,n,r.runtimeFlags,e))),ef=t=>Js(e=>sr(Us(e,Xs),{onNone:()=>t,onSome:n=>{switch(n.strategy._tag){case"Parallel":return t;case"Sequential":case"ParallelN":return oe(ul(n,Qa),r=>Il(t,r))}}})),tf=t=>e=>Js(n=>sr(Us(n,Xs),{onNone:()=>e,onSome:r=>r.strategy._tag==="ParallelN"&&r.strategy.parallelism===t?e:oe(ul(r,Xa(t)),s=>Il(e,s))})),lr=(t,e)=>n=>Js(r=>sr(Us(r,Xs),{onNone:()=>n(Le),onSome:s=>{if(e===!0){const o=t._tag==="Parallel"?ef:t._tag==="Sequential"?nf:tf(t.parallelism);switch(s.strategy._tag){case"Parallel":return o(n(ef));case"Sequential":return o(n(nf));case"ParallelN":return o(n(tf(s.strategy.parallelism)))}}else return n(Le)}})),nf=t=>Js(e=>sr(Us(e,Xs),{onNone:()=>t,onSome:n=>{switch(n.strategy._tag){case"Sequential":return t;case"Parallel":case"ParallelN":return oe(ul(n,Za),r=>Il(t,r))}}})),Xs=or("effect/Scope"),Il=k(2,(t,e)=>X0(t,Ah(Eb(Xs,e)))),N2=t=>Gr(t,{differ:l2,fork:ys}),rf=A0(dx),P2=N2(Rl),F2=(t,e,n)=>u0(r=>oe(oe(Kg(Nd(t)),s=>Xn(o=>{const i=e.map(u=>u.listeners.count),c=()=>{i.every(u=>u===0)&&e.every(u=>u.result.state.current._tag==="Pending"?!0:!!(u.result.state.current._tag==="Done"&&Ni(u.result.state.current.effect)&&u.result.state.current.effect._tag==="Failure"&&Fx(u.result.state.current.effect.cause)))&&(a.forEach(u=>u()),n?.(),o(b0(s)))};s.addObserver(u=>{a.forEach(f=>f()),o(u)});const a=e.map((u,f)=>{const h=d=>{i[f]=d,c()};return u.listeners.addObserver(h),()=>u.listeners.removeObserver(h)});return c(),se(()=>{a.forEach(u=>u())})})),()=>nt(()=>{const s=e.flatMap(o=>o.state.completed?[]:[o]);return Ei(s,o=>t2(o.request,H0(r)))}))),L2=I2,sf=v0,po=I1;var j2={},D2={debug:(t,...e)=>console.debug(`[DEBUG] ${t}`,...e),info:(t,...e)=>console.info(`[INFO] ${t}`,...e),warn:(t,...e)=>console.warn(`[WARN] ${t}`,...e),error:(t,...e)=>console.error(`[ERROR] ${t}`,...e)},mo=D2,$2=t=>({debug:(e,...n)=>mo.debug(`[${t}] ${e}`,...n),info:(e,...n)=>mo.info(`[${t}] ${e}`,...n),warn:(e,...n)=>mo.warn(`[${t}] ${e}`,...n),error:(e,...n)=>mo.error(`[${t}] ${e}`,...n)}),fc=t=>{const e=t?.match(/<command-name>([^<]+)<\/command-name>/)?.[1]??"",n=t?.match(/<command-message>([^<]+)<\/command-message>/)?.[1]??"",r=t?.match(/<command-args>([^<]+)<\/command-args>/)?.[1]?.trim()??"";return{name:e,message:n,args:r}},Jg=(t,e,n,r=60,s="Untitled")=>{if(t)return t;if(e)return e.length>r?e.slice(0,r-3)+"...":e;if(n&&n!=="Untitled"){const o=n.includes(`
24
-
25
- `)?n.split(`
26
-
27
- `)[0]:n;if(o.includes("<command-name>")){const{name:i,args:c}=fc(o);if(i)return c?`${i} ${c}`:i}return o}return s},B2=(t,e)=>{if(!e)return t;const n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`${n}(?=[/\\\\]|$)`,"g");return t.replace(r,"~")},U2=(t,e,n)=>{try{return JSON.parse(t)}catch{return null}},Yg=t=>t.sessionTodos.length+t.agentTodos.reduce((e,n)=>e+n.todos.length,0),q2=t=>{const e=Yg(t.todos);return t.summaries.length>0||t.agents.length>0||e>0},z2=t=>{const{id:e,title:n,customTitle:r,currentSummary:s,createdAt:o,updatedAt:i}=t;let c;r&&s?c=s:s&&n&&n!=="Untitled"?c=n:s?c=s:c=n??"No title";const a=[`ID: ${e}`];return o&&a.push(`Created: ${new Date(o).toLocaleString()}`),i&&a.push(`Updated: ${new Date(i).toLocaleString()}`),c+=`
28
-
29
- `+a.join(`
30
- `),c},of=(t,e)=>t!==e,Zg=$2("paths"),Qg=()=>j2.CLAUDE_SESSIONS_DIR||(void 0)((void 0)(),".claude","projects"),Xg={absolutePath:/^([A-Za-z]):[/\\]/,folderName:/^([A-Za-z])--/},V2=t=>{const e=t.match(Xg.folderName);return e?{isWindows:!0,drive:e[1],rest:t.slice(3)}:{isWindows:!1}},H2=t=>Xg.absolutePath.test(t),W2=(t,e)=>{const n=t.split(`
31
- `).filter(r=>r.trim());for(let r=0;r<n.length;r++){const s=U2(n[r]);if(s?.cwd)return s.cwd}return null},K2=t=>t.endsWith(".jsonl")&&!t.startsWith("agent-"),va=(t,e)=>{const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/"),s=H2(e),o=n.toLowerCase(),i=r.toLowerCase();return(s?o===i:n===r)?"~":(s?o.startsWith(i+"/"):n.startsWith(r+"/"))?"~"+t.slice(e.length).replace(/\\/g,"/"):t.replace(/\\/g,"/")},G2=t=>{const e=V2(t);return e.isWindows?e.drive+":\\"+e.rest.replace(/--/g,"\\.").replace(/-/g,"\\"):t.replace(/^-/,"/").replace(/--/g,"/.").replace(/-/g,"/")},El=t=>t.replace(/[^a-zA-Z0-9]/g,"-"),J2=(t,e=wc,n=Zg)=>{const r=(void 0)(t);try{const s=e.readFileSync(t,"utf-8"),o=W2(s);return o===null?null:o}catch(s){return n.warn(`tryGetCwdFromFile: ${r} -> read error: ${s}`),null}},Y2=(t,e=Qg(),n=wc,r=Zg)=>{const s=(void 0)(e,t);try{const o=n.readdirSync(s).filter(K2),i=[];for(const a of o){const u=J2((void 0)(s,a),n,r);u!==null&&i.push(u)}const c=i.find(a=>El(a)===t);return c||(i.length>0&&r.warn(`getRealPathFromSession: ${t} -> no match, cwds found: ${i.join(", ")}`),null)}catch{return null}},Z2=()=>(void 0)((void 0)(),".claude.json"),Q2=async(t,e=wc)=>{try{const n=Z2(),r=await e.readFile(n,"utf-8"),s=JSON.parse(r);if(!s.projects)return null;for(const o of Object.keys(s.projects))if(El(o)===t)return o;return null}catch{return null}},X2=async t=>{const e=(void 0)(),n=await Q2(t);if(n)return va(n,e);const r=Y2(t);if(r)return va(r,e);const s=G2(t);return va(s,e)},eT=(t,e={})=>{const{currentProjectName:n,homeDir:r,filterEmpty:s=!0}=e,o=s?t.filter(c=>c.sessionCount>0):t,i=r?El(r):null;return o.sort((c,a)=>{if(n){if(c.name===n)return-1;if(a.name===n)return 1}if(i){const u=c.name.startsWith(i),f=a.name.startsWith(i);if(u&&!f)return-1;if(!u&&f)return 1}return c.displayName.localeCompare(a.displayName)})},Fn={session:{emoji:"💬"},"todos-group":{emoji:"📋"},summary:{emoji:"📝"},agent:{emoji:"🤖"}};sf(function*(){const t=Qg();if(!(yield*po(()=>(void 0)(t).then(()=>!0).catch(()=>!1))))return[];const n=yield*po(()=>(void 0)(t,{withFileTypes:!0}));return yield*L2(n.filter(s=>s.isDirectory()&&!s.name.startsWith(".")).map(s=>sf(function*(){const o=(void 0)(t,s.name),c=(yield*po(()=>(void 0)(o))).filter(u=>u.endsWith(".jsonl")&&!u.startsWith("agent-")),a=yield*po(()=>X2(s.name));return{name:s.name,displayName:a,path:o,sessionCount:c.length}})),{concurrency:10})});function tT(t){const e=[],n=new Set;for(const s of t)s.uuid&&n.add(s.uuid);let r=!1;for(let s=0;s<t.length;s++){const o=t[s];if(!(o.type==="file-history-snapshot"||o.type==="summary")&&o.uuid){if(!r){if(r=!0,o.parentUuid===void 0){e.push({type:"broken_chain",uuid:o.uuid,line:s+1,parentUuid:null});continue}continue}if(o.parentUuid===null||o.parentUuid===void 0){o.logicalParentUuid||e.push({type:"broken_chain",uuid:o.uuid,line:s+1,parentUuid:null});continue}n.has(o.parentUuid)||e.push({type:"orphan_parent",uuid:o.uuid,line:s+1,parentUuid:o.parentUuid})}}return{valid:e.length===0,errors:e}}function nT(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(r.type==="progress"){const s=r,o=s.hookEvent??s.data?.hookEvent,i=s.hookName??s.data?.hookName;o==="Stop"&&e.push({type:"unwanted_progress",line:n+1,hookEvent:o,hookName:i})}else r.type==="saved_hook_context"&&e.push({type:"unwanted_progress",line:n+1,messageType:"saved_hook_context"})}return{valid:e.length===0,errors:e}}function rT(t,e){const n=new Map;for(const s of e)s.uuid&&s.type!=="file-history-snapshot"&&n.set(s.uuid,s.parentUuid);const r=s=>{let o=s;for(;o&&n.has(o);)o=n.get(o);return o};for(const s of t)s.parentUuid&&n.has(s.parentUuid)&&(s.parentUuid=r(s.parentUuid))}function sT(t,e,n){if(n==="file-history-snapshot")return t.findIndex(s=>s.type==="file-history-snapshot"&&s.messageId===e);if(n==="summary")return t.findIndex(s=>s.leafUuid===e);let r=t.findIndex(s=>s.uuid===e);return r===-1&&(r=t.findIndex(s=>s.leafUuid===e)),r===-1&&(r=t.findIndex(s=>s.type==="file-history-snapshot"&&s.messageId===e)),r}function oT(t,e){if(t.type!=="user")return!1;const n=t.message?.content;return Array.isArray(n)?n.some(r=>r.type==="tool_result"&&r.tool_use_id&&e.includes(r.tool_use_id)):!1}function af(t,e,n){const r=sT(t,e,n);if(r===-1)return{deleted:null,alsoDeleted:[]};const s=t[r],o=[];if(s.type==="assistant"){const f=s.message?.content;if(Array.isArray(f))for(const h of f)h.type==="tool_use"&&h.id&&o.push(h.id)}const i=[];if(o.length>0)for(let f=0;f<t.length;f++)oT(t[f],o)&&i.push(f);const c=[r,...i].sort((f,h)=>h-f),a=c.map(f=>t[f]),u=i.map(f=>t[f]);rT(t,a);for(const f of c)t.splice(f,1);return{deleted:s,alsoDeleted:u}}const Ol=gm({version:"",homeDir:"",currentProjectName:""}),Al=(t,e)=>{const n=e??pm(Ol).homeDir;return n?B2(t,n):t.replace(/(?:\/Users\/[^/\s]+|C:\\Users\\[^\\\s]+)(?=[/\\]|(?=\s|$|[)"'\]}>,:;]))/g,"~")};dm(Ol,t=>e=>Al(e,t.homeDir));var iT=C('<div class="fixed inset-0 bg-black/50 flex items-center justify-center z-50" role="dialog" aria-modal="true" tabindex="-1"><div class="bg-gh-bg-secondary border border-gh-border rounded-lg p-6 w-[380px] shadow-xl text-gh-text"><h2 class="text-lg font-semibold mb-3"> </h2> <p class="text-sm text-gh-text-secondary mb-6 whitespace-pre-wrap"> </p> <div class="flex gap-2 justify-end"><button class="px-4 py-2 text-sm rounded-md border border-gh-border hover:bg-gh-border-subtle"> </button> <button> </button></div></div></div>');function CE(t,e){Mt(e,!0);let n=Ae(e,"confirmText",3,"Confirm"),r=Ae(e,"cancelText",3,"Cancel"),s=Ae(e,"variant",3,"default");const o=u=>{u.key==="Escape"&&e.onCancel(),u.key==="Enter"&&e.onConfirm()};var i=Fe(),c=Te(i);{var a=u=>{var f=iT(),h=b(f),d=b(h),p=b(d,!0);m(d);var g=T(d,2),x=b(g,!0);m(g);var v=T(g,2),_=b(v),O=b(_,!0);m(_);var P=T(_,2),R=b(P,!0);m(P),m(v),m(h),m(f),B(()=>{N(p,e.title),N(x,e.message),N(O,r()),Ie(P,1,`px-4 py-2 text-sm rounded-md ${s()==="danger"?"bg-gh-red text-white hover:bg-red-700":"bg-gh-accent text-white hover:bg-blue-700"}`),N(R,n())}),ve("click",f,D=>D.target===D.currentTarget&&e.onCancel()),ve("keydown",f,o),ve("click",_,function(...D){e.onCancel?.apply(this,D)}),ve("click",P,function(...D){e.onConfirm?.apply(this,D)}),y(u,f)};q(c,u=>{e.show&&u(a)})}y(t,i),Nt()}$t(["click","keydown"]);var aT=C('<label class="block text-sm text-gh-text-secondary mb-2"> </label>'),cT=C('<div class="fixed inset-0 bg-black/50 flex items-center justify-center z-50" role="dialog" aria-modal="true" tabindex="-1"><div class="bg-gh-bg-secondary border border-gh-border rounded-lg p-6 w-[400px] shadow-xl text-gh-text"><h2 class="text-lg font-semibold mb-4"> </h2> <!> <input type="text" class="w-full px-3 py-2 text-sm rounded-md border border-gh-border bg-gh-bg focus:outline-none focus:border-gh-accent"/> <div class="flex gap-2 justify-end mt-6"><button class="px-4 py-2 text-sm rounded-md border border-gh-border hover:bg-gh-border-subtle"> </button> <button class="px-4 py-2 text-sm rounded-md bg-gh-accent text-white hover:bg-blue-700"> </button></div></div></div>');function RE(t,e){Mt(e,!0);let n=Ae(e,"label",3,""),r=Ae(e,"placeholder",3,""),s=Ae(e,"initialValue",3,""),o=Ae(e,"confirmText",3,"Save"),i=Ae(e,"cancelText",3,"Cancel"),c=De(""),a=De(void 0);zn(()=>{e.show&&(J(c,s()),Pf().then(()=>{l(a)?.focus(),l(a)?.select()}))});const u=()=>{e.onConfirm(l(c).trim())},f=g=>{g.key==="Escape"&&e.onCancel(),g.key==="Enter"&&u()};var h=Fe(),d=Te(h);{var p=g=>{var x=cT(),v=b(x),_=b(v),O=b(_,!0);m(_);var P=T(_,2);{var R=$=>{var Q=aT(),pe=b(Q,!0);m(Q),B(()=>N(pe,n())),y($,Q)};q(P,$=>{n()&&$(R)})}var D=T(P,2);Hf(D),ai(D,$=>J(a,$),()=>l(a));var w=T(D,2),A=b(w),S=b(A,!0);m(A);var M=T(A,2),E=b(M,!0);m(M),m(w),m(v),m(x),B(()=>{N(O,e.title),Me(D,"placeholder",r()),N(S,i()),N(E,o())}),ve("click",x,$=>$.target===$.currentTarget&&e.onCancel()),ve("keydown",x,f),$m(D,()=>l(c),$=>J(c,$)),ve("click",A,function(...$){e.onCancel?.apply(this,$)}),ve("click",M,u),y(g,x)};q(d,g=>{e.show&&g(p)})}y(t,h),Nt()}$t(["click","keydown"]);function Ml(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ir=Ml();function ep(t){ir=t}var $n={exec:()=>null};function we(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,o)=>{let i=typeof o=="string"?o:o.source;return i=i.replace(xt.caret,"$1"),n=n.replace(s,i),r},getRegex:()=>new RegExp(n,e)};return r}var lT=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),xt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},uT=/^(?:[ \t]*(?:\n|$))+/,fT=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hT=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,eo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,dT=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Nl=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,tp=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,np=we(tp).replace(/bull/g,Nl).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),gT=we(tp).replace(/bull/g,Nl).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Pl=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,pT=/^[^\n]+/,Fl=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,mT=we(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Fl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),vT=we(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Nl).getRegex(),Bi="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ll=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,bT=we("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ll).replace("tag",Bi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rp=we(Pl).replace("hr",eo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Bi).getRegex(),_T=we(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",rp).getRegex(),jl={blockquote:_T,code:fT,def:mT,fences:hT,heading:dT,hr:eo,html:bT,lheading:np,list:vT,newline:uT,paragraph:rp,table:$n,text:pT},cf=we("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",eo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Bi).getRegex(),yT={...jl,lheading:gT,table:cf,paragraph:we(Pl).replace("hr",eo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",cf).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Bi).getRegex()},xT={...jl,html:we(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ll).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:$n,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:we(Pl).replace("hr",eo).replace("heading",` *#{1,6} *[^
32
- ]`).replace("lheading",np).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},kT=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ST=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,sp=/^( {2,}|\\)\n(?!\s*$)/,wT=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ui=/[\p{P}\p{S}]/u,Dl=/[\s\p{P}\p{S}]/u,op=/[^\s\p{P}\p{S}]/u,TT=we(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Dl).getRegex(),ip=/(?!~)[\p{P}\p{S}]/u,CT=/(?!~)[\s\p{P}\p{S}]/u,RT=/(?:[^\s\p{P}\p{S}]|~)/u,ap=/(?![*_])[\p{P}\p{S}]/u,IT=/(?![*_])[\s\p{P}\p{S}]/u,ET=/(?:[^\s\p{P}\p{S}]|[*_])/u,OT=we(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",lT?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),cp=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,AT=we(cp,"u").replace(/punct/g,Ui).getRegex(),MT=we(cp,"u").replace(/punct/g,ip).getRegex(),lp="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",NT=we(lp,"gu").replace(/notPunctSpace/g,op).replace(/punctSpace/g,Dl).replace(/punct/g,Ui).getRegex(),PT=we(lp,"gu").replace(/notPunctSpace/g,RT).replace(/punctSpace/g,CT).replace(/punct/g,ip).getRegex(),FT=we("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,op).replace(/punctSpace/g,Dl).replace(/punct/g,Ui).getRegex(),LT=we(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ap).getRegex(),jT="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",DT=we(jT,"gu").replace(/notPunctSpace/g,ET).replace(/punctSpace/g,IT).replace(/punct/g,ap).getRegex(),$T=we(/\\(punct)/,"gu").replace(/punct/g,Ui).getRegex(),BT=we(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),UT=we(Ll).replace("(?:-->|$)","-->").getRegex(),qT=we("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",UT).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ti=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,zT=we(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ti).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),up=we(/^!?\[(label)\]\[(ref)\]/).replace("label",ti).replace("ref",Fl).getRegex(),fp=we(/^!?\[(ref)\](?:\[\])?/).replace("ref",Fl).getRegex(),VT=we("reflink|nolink(?!\\()","g").replace("reflink",up).replace("nolink",fp).getRegex(),lf=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,$l={_backpedal:$n,anyPunctuation:$T,autolink:BT,blockSkip:OT,br:sp,code:ST,del:$n,delLDelim:$n,delRDelim:$n,emStrongLDelim:AT,emStrongRDelimAst:NT,emStrongRDelimUnd:FT,escape:kT,link:zT,nolink:fp,punctuation:TT,reflink:up,reflinkSearch:VT,tag:qT,text:wT,url:$n},HT={...$l,link:we(/^!?\[(label)\]\((.*?)\)/).replace("label",ti).getRegex(),reflink:we(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ti).getRegex()},hc={...$l,emStrongRDelimAst:PT,emStrongLDelim:MT,delLDelim:LT,delRDelim:DT,url:we(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",lf).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:we(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",lf).getRegex()},WT={...hc,br:we(sp).replace("{2,}","*").getRegex(),text:we(hc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vo={normal:jl,gfm:yT,pedantic:xT},us={normal:$l,gfm:hc,breaks:WT,pedantic:HT},KT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},uf=t=>KT[t];function tn(t,e){if(e){if(xt.escapeTest.test(t))return t.replace(xt.escapeReplace,uf)}else if(xt.escapeTestNoEncode.test(t))return t.replace(xt.escapeReplaceNoEncode,uf);return t}function ff(t){try{t=encodeURI(t).replace(xt.percentDecode,"%")}catch{return null}return t}function hf(t,e){let n=t.replace(xt.findPipe,(o,i,c)=>{let a=!1,u=i;for(;--u>=0&&c[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(xt.splitPipe),s=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;s<r.length;s++)r[s]=r[s].trim().replace(xt.slashPipe,"|");return r}function fs(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function GT(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function JT(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=s,n++;return r}function df(t,e,n,r,s){let o=e.href,i=e.title||null,c=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:i,text:c,tokens:r.inlineTokens(c)};return r.state.inLink=!1,a}function YT(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
33
- `).map(o=>{let i=o.match(n.other.beginningSpace);if(i===null)return o;let[c]=i;return c.length>=s.length?o.slice(s.length):o}).join(`
34
- `)}var ni=class{options;rules;lexer;constructor(t){this.options=t||ir}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:fs(n,`
35
- `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=YT(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=fs(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:fs(e[0],`
36
- `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=fs(e[0],`
37
- `).split(`
38
- `),r="",s="",o=[];for(;n.length>0;){let i=!1,c=[],a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))c.push(n[a]),i=!0;else if(!i)c.push(n[a]);else break;n=n.slice(a);let u=c.join(`
39
- `),f=u.replace(this.rules.other.blockquoteSetextReplace,`
40
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
41
- ${u}`:u,s=s?`${s}
42
- ${f}`:f;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,o,!0),this.lexer.state.top=h,n.length===0)break;let d=o.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let p=d,g=p.raw+`
43
- `+n.join(`
44
- `),x=this.blockquote(g);o[o.length-1]=x,r=r.substring(0,r.length-p.raw.length)+x.raw,s=s.substring(0,s.length-p.text.length)+x.text;break}else if(d?.type==="list"){let p=d,g=p.raw+`
45
- `+n.join(`
46
- `),x=this.list(g);o[o.length-1]=x,r=r.substring(0,r.length-d.raw.length)+x.raw,s=s.substring(0,s.length-p.raw.length)+x.raw,n=g.substring(o.at(-1).raw.length).split(`
47
- `);continue}}return{type:"blockquote",raw:r,tokens:o,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),i=!1;for(;t;){let a=!1,u="",f="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=JT(e[2].split(`
48
- `,1)[0],e[1].length),d=t.split(`
49
- `,1)[0],p=!h.trim(),g=0;if(this.options.pedantic?(g=2,f=h.trimStart()):p?g=e[1].length+1:(g=h.search(this.rules.other.nonSpaceChar),g=g>4?1:g,f=h.slice(g),g+=e[1].length),p&&this.rules.other.blankLine.test(d)&&(u+=d+`
50
- `,t=t.substring(d.length+1),a=!0),!a){let x=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),_=this.rules.other.fencesBeginRegex(g),O=this.rules.other.headingBeginRegex(g),P=this.rules.other.htmlBeginRegex(g),R=this.rules.other.blockquoteBeginRegex(g);for(;t;){let D=t.split(`
51
- `,1)[0],w;if(d=D,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),w=d):w=d.replace(this.rules.other.tabCharGlobal," "),_.test(d)||O.test(d)||P.test(d)||R.test(d)||x.test(d)||v.test(d))break;if(w.search(this.rules.other.nonSpaceChar)>=g||!d.trim())f+=`
52
- `+w.slice(g);else{if(p||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(h)||O.test(h)||v.test(h))break;f+=`
53
- `+d}p=!d.trim(),u+=D+`
54
- `,t=t.substring(D.length+1),h=w.slice(g)}}s.loose||(i?s.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(i=!0)),s.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(f),loose:!1,text:f,tokens:[]}),s.raw+=u}let c=s.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let a of s.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let f=this.lexer.inlineQueue.length-1;f>=0;f--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[f].src)){this.lexer.inlineQueue[f].src=this.lexer.inlineQueue[f].src.replace(this.rules.other.listReplaceTask,"");break}}let u=this.rules.other.listTaskCheckbox.exec(a.raw);if(u){let f={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};a.checked=f.checked,s.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=f.raw+a.tokens[0].raw,a.tokens[0].text=f.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(f)):a.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):a.tokens.unshift(f)}}if(!s.loose){let u=a.tokens.filter(h=>h.type==="space"),f=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));s.loose=f}}if(s.loose)for(let a of s.items){a.loose=!0;for(let u of a.tokens)u.type==="text"&&(u.type="paragraph")}return s}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=hf(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
55
- `):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let i of r)this.rules.other.tableAlignRight.test(i)?o.align.push("right"):this.rules.other.tableAlignCenter.test(i)?o.align.push("center"):this.rules.other.tableAlignLeft.test(i)?o.align.push("left"):o.align.push(null);for(let i=0;i<n.length;i++)o.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:o.align[i]});for(let i of s)o.rows.push(hf(i,o.header.length).map((c,a)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:o.align[a]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
56
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=fs(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=GT(e[2],"()");if(o===-2)return;if(o>-1){let i=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,i).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],s=o[3])}else s=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),df(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[r.toLowerCase()];if(!s){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return df(n,s,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,o,i,c=s,a=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+s);(r=u.exec(e))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(i=[...o].length,r[3]||r[4]){c+=i;continue}else if((r[5]||r[6])&&s%3&&!((s+i)%3)){a+=i;continue}if(c-=i,c>0)continue;i=Math.min(i,i+c+a);let f=[...r[0]][0].length,h=t.slice(0,s+r.index+f+i);if(Math.min(s,i)%2){let p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}let d=h.slice(2,-2);return{type:"strong",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...r[0]].length-1,o,i,c=s,a=this.rules.inline.delRDelim;for(a.lastIndex=0,e=e.slice(-1*t.length+s);(r=a.exec(e))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(i=[...o].length,i!==s))continue;if(r[3]||r[4]){c+=i;continue}if(c-=i,c>0)continue;i=Math.min(i,i+c);let u=[...r[0]][0].length,f=t.slice(0,s+r.index+u+i),h=f.slice(s,-s);return{type:"del",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},qt=class dc{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ir,this.options.tokenizer=this.options.tokenizer||new ni,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:xt,block:vo.normal,inline:us.normal};this.options.pedantic?(n.block=vo.pedantic,n.inline=us.pedantic):this.options.gfm&&(n.block=vo.gfm,this.options.breaks?n.inline=us.breaks:n.inline=us.gfm),this.tokenizer.rules=n}static get rules(){return{block:vo,inline:us}}static lex(e,n){return new dc(n).lex(e)}static lexInline(e,n){return new dc(n).inlineTokens(e)}lex(e){e=e.replace(xt.carriageReturn,`
57
- `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.options.pedantic&&(e=e.replace(xt.tabCharGlobal," ").replace(xt.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(i=>(s=i.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let i=n.at(-1);s.raw.length===1&&i!==void 0?i.raw+=`
58
- `:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let i=n.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
59
- `)?"":`
60
- `)+s.raw,i.text+=`
61
- `+s.text,this.inlineQueue.at(-1).src=i.text):n.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let i=n.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
62
- `)?"":`
63
- `)+s.raw,i.text+=`
64
- `+s.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},n.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),n.push(s);continue}let o=e;if(this.options.extensions?.startBlock){let i=1/0,c=e.slice(1),a;this.options.extensions.startBlock.forEach(u=>{a=u.call({lexer:this},c),typeof a=="number"&&a>=0&&(i=Math.min(i,a))}),i<1/0&&i>=0&&(o=e.substring(0,i+1))}if(this.state.top&&(s=this.tokenizer.paragraph(o))){let i=n.at(-1);r&&i?.type==="paragraph"?(i.raw+=(i.raw.endsWith(`
65
- `)?"":`
66
- `)+s.raw,i.text+=`
67
- `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(s),r=o.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let i=n.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(`
68
- `)?"":`
69
- `)+s.raw,i.text+=`
70
- `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(s);continue}if(e){let i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r=e,s=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)a.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)o=s[2]?s[2].length:0,r=r.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,c="";for(;e;){i||(c=""),i=!1;let a;if(this.options.extensions?.inline?.some(f=>(a=f.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let f=n.at(-1);a.type==="text"&&f?.type==="text"?(f.raw+=a.raw,f.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,r,c)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,r,c)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let u=e;if(this.options.extensions?.startInline){let f=1/0,h=e.slice(1),d;this.options.extensions.startInline.forEach(p=>{d=p.call({lexer:this},h),typeof d=="number"&&d>=0&&(f=Math.min(f,d))}),f<1/0&&f>=0&&(u=e.substring(0,f+1))}if(a=this.tokenizer.inlineText(u)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(c=a.raw.slice(-1)),i=!0;let f=n.at(-1);f?.type==="text"?(f.raw+=a.raw,f.text+=a.text):n.push(a);continue}if(e){let f="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return n}},ri=class{options;parser;constructor(t){this.options=t||ir}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(xt.notSpaceStart)?.[0],s=t.replace(xt.endingNewline,"")+`
71
- `;return r?'<pre><code class="language-'+tn(r)+'">'+(n?s:tn(s,!0))+`</code></pre>
72
- `:"<pre><code>"+(n?s:tn(s,!0))+`</code></pre>
73
- `}blockquote({tokens:t}){return`<blockquote>
74
- ${this.parser.parse(t)}</blockquote>
75
- `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
76
- `}hr(t){return`<hr>
77
- `}list(t){let e=t.ordered,n=t.start,r="";for(let i=0;i<t.items.length;i++){let c=t.items[i];r+=this.listitem(c)}let s=e?"ol":"ul",o=e&&n!==1?' start="'+n+'"':"";return"<"+s+o+`>
78
- `+r+"</"+s+`>
79
- `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
80
- `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
81
- `}table(t){let e="",n="";for(let s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let o=t.rows[s];n="";for(let i=0;i<o.length;i++)n+=this.tablecell(o[i]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
82
- <thead>
83
- `+e+`</thead>
84
- `+r+`</table>
85
- `}tablerow({text:t}){return`<tr>
86
- ${t}</tr>
87
- `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
88
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${tn(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),s=ff(t);if(s===null)return r;t=s;let o='<a href="'+t+'"';return e&&(o+=' title="'+tn(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=ff(t);if(s===null)return tn(n);t=s;let o=`<img src="${t}" alt="${tn(n)}"`;return e&&(o+=` title="${tn(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:tn(t.text)}},Bl=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},zt=class gc{options;renderer;textRenderer;constructor(e){this.options=e||ir,this.options.renderer=this.options.renderer||new ri,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Bl}static parse(e,n){return new gc(n).parse(e)}static parseInline(e,n){return new gc(n).parseInline(e)}parse(e){let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let i=s,c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){n+=c||"";continue}}let o=s;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let i='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}parseInline(e,n=this.renderer){let r="";for(let s=0;s<e.length;s++){let o=e[s];if(this.options.extensions?.renderers?.[o.type]){let c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){r+=c||"";continue}}let i=o;switch(i.type){case"escape":{r+=n.text(i);break}case"html":{r+=n.html(i);break}case"link":{r+=n.link(i);break}case"image":{r+=n.image(i);break}case"checkbox":{r+=n.checkbox(i);break}case"strong":{r+=n.strong(i);break}case"em":{r+=n.em(i);break}case"codespan":{r+=n.codespan(i);break}case"br":{r+=n.br(i);break}case"del":{r+=n.del(i);break}case"text":{r+=n.text(i);break}default:{let c='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return r}},gs=class{options;block;constructor(t){this.options=t||ir}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?qt.lex:qt.lexInline}provideParser(){return this.block?zt.parse:zt.parseInline}},ZT=class{defaults=Ml();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=zt;Renderer=ri;TextRenderer=Bl;Lexer=qt;Tokenizer=ni;Hooks=gs;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let s=r;for(let o of s.header)n=n.concat(this.walkTokens(o.tokens,e));for(let o of s.rows)for(let i of o)n=n.concat(this.walkTokens(i.tokens,e));break}case"list":{let s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{let s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(o=>{let i=s[o].flat(1/0);n=n.concat(this.walkTokens(i,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let o=e.renderers[s.name];o?e.renderers[s.name]=function(...i){let c=s.renderer.apply(this,i);return c===!1&&(c=o.apply(this,i)),c}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[s.level];o?o.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new ri(this.defaults);for(let o in n.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let i=o,c=n.renderer[i],a=s[i];s[i]=(...u)=>{let f=c.apply(s,u);return f===!1&&(f=a.apply(s,u)),f||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new ni(this.defaults);for(let o in n.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let i=o,c=n.tokenizer[i],a=s[i];s[i]=(...u)=>{let f=c.apply(s,u);return f===!1&&(f=a.apply(s,u)),f}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new gs;for(let o in n.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let i=o,c=n.hooks[i],a=s[i];gs.passThroughHooks.has(o)?s[i]=u=>{if(this.defaults.async&&gs.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await c.call(s,u);return a.call(s,h)})();let f=c.call(s,u);return a.call(s,f)}:s[i]=(...u)=>{if(this.defaults.async)return(async()=>{let h=await c.apply(s,u);return h===!1&&(h=await a.apply(s,u)),h})();let f=c.apply(s,u);return f===!1&&(f=a.apply(s,u)),f}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(i){let c=[];return c.push(o.call(this,i)),s&&(c=c.concat(s.call(this,i))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return qt.lex(t,e??this.defaults)}parser(t,e){return zt.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let i=s.hooks?await s.hooks.preprocess(e):e,c=await(s.hooks?await s.hooks.provideLexer():t?qt.lex:qt.lexInline)(i,s),a=s.hooks?await s.hooks.processAllTokens(c):c;s.walkTokens&&await Promise.all(this.walkTokens(a,s.walkTokens));let u=await(s.hooks?await s.hooks.provideParser():t?zt.parse:zt.parseInline)(a,s);return s.hooks?await s.hooks.postprocess(u):u})().catch(o);try{s.hooks&&(e=s.hooks.preprocess(e));let i=(s.hooks?s.hooks.provideLexer():t?qt.lex:qt.lexInline)(e,s);s.hooks&&(i=s.hooks.processAllTokens(i)),s.walkTokens&&this.walkTokens(i,s.walkTokens);let c=(s.hooks?s.hooks.provideParser():t?zt.parse:zt.parseInline)(i,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(i){return o(i)}}}onError(t,e){return n=>{if(n.message+=`
89
- Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+tn(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},nr=new ZT;function Ee(t,e){return nr.parse(t,e)}Ee.options=Ee.setOptions=function(t){return nr.setOptions(t),Ee.defaults=nr.defaults,ep(Ee.defaults),Ee};Ee.getDefaults=Ml;Ee.defaults=ir;Ee.use=function(...t){return nr.use(...t),Ee.defaults=nr.defaults,ep(Ee.defaults),Ee};Ee.walkTokens=function(t,e){return nr.walkTokens(t,e)};Ee.parseInline=nr.parseInline;Ee.Parser=zt;Ee.parser=zt.parse;Ee.Renderer=ri;Ee.TextRenderer=Bl;Ee.Lexer=qt;Ee.lexer=qt.lex;Ee.Tokenizer=ni;Ee.Hooks=gs;Ee.parse=Ee;Ee.options;Ee.setOptions;Ee.use;Ee.walkTokens;Ee.parseInline;zt.parse;qt.lex;Ee.setOptions({breaks:!0,gfm:!0});const ur=t=>t?new Date(t).toLocaleString():"-",QT=(t,e)=>t.length>e?t.slice(0,e)+"...":t,XT=t=>Al(t),Eo=t=>Al(t),xs=t=>typeof t=="string"?t:Array.isArray(t)?t.map(xs).join(""):t.type==="text"?t.text??"":t.type==="thinking"?"":t.type==="tool_result"?t.content?xs(t.content):"0":t.content?xs(t.content):"",gf=t=>{let e="";if(t.summary)e=t.summary;else if(t.content)e=xs(t.content);else{const n=t.message;n?.content&&(e=xs(n.content))}return Eo(e)},eC=t=>{const e=t;return e?.subtype!=="stop_hook_summary"?null:{hookCount:e.hookCount??0,hookInfos:e.hookInfos??[],hookErrors:e.hookErrors??[],preventedContinuation:e.preventedContinuation??!1,stopReason:e.stopReason??"",hasOutput:e.hasOutput??!1,level:e.level??"info"}},tC=t=>{const e=t;if(e?.subtype!=="turn_duration")return null;const n=e.durationMs??0,r=Math.round(n/1e3),s=Math.floor(r/60),o=r%60,i=s>0?`${s}m ${o}s`:`${o}s`;return{durationMs:n,durationFormatted:i}},nC=t=>{const e=t;if(e?.type!=="progress")return null;const n=e.data;return n?{type:n.type??"unknown",hookEvent:n.hookEvent,hookName:n.hookName,command:n.command}:null},rC=t=>{const e=[],n=/<(ide_[^>]+)>([\s\S]*?)<\/\1>/g;let r=0,s;for(;(s=n.exec(t))!==null;){if(s.index>r){const o=t.slice(r,s.index).trim();o&&e.push({type:"text",content:o})}e.push({type:"ide_tag",tag:s[1],content:s[2].trim()}),r=n.lastIndex}if(r<t.length){const o=t.slice(r).trim();o&&e.push({type:"text",content:o})}return e};var sC=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"><code> </code></pre>'),oC=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"> </pre>'),iC=C('<button class="absolute bottom-1 left-1/2 -translate-x-1/2 px-3 py-1 text-xs bg-gh-border hover:bg-gh-border-muted rounded-full cursor-pointer border-none text-gh-text-secondary transition-all"> </button>'),aC=C('<div class="absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-gh-canvas to-transparent pointer-events-none"></div> <!>',1),cC=C('<button class="mt-2 px-3 py-1 text-xs bg-gh-border hover:bg-gh-border-muted rounded-full cursor-pointer border-none text-gh-text-secondary">Collapse</button>'),lC=C('<div class="relative"><!> <!></div>'),uC=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"><code> </code></pre>'),fC=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"> </pre>');function bo(t,e){Mt(e,!0);let n=Ae(e,"maxLines",3,10),r=De(!1),s=De(!1);const o=H(()=>e.content.split(`
90
- `)),i=H(()=>l(o).length>n()),c=H(()=>l(i)&&!l(r)?l(o).slice(0,n()).join(`
91
- `):e.content);var a=Fe(),u=Te(a);{var f=p=>{var g=lC(),x=b(g);{var v=D=>{var w=sC(),A=b(w),S=b(A,!0);m(A),m(w),B(()=>{Ie(A,1,`language-${e.lang??""}`),N(S,l(c))}),y(D,w)},_=D=>{var w=oC(),A=b(w,!0);m(w),B(()=>N(A,l(c))),y(D,w)};q(x,D=>{e.lang?D(v):D(_,-1)})}var O=T(x,2);{var P=D=>{var w=aC(),A=T(Te(w),2);{var S=M=>{var E=iC(),$=b(E);m(E),B(()=>N($,`Click to expand (${l(o).length-n()} more lines)`)),ve("click",E,()=>J(r,!0)),y(M,E)};q(A,M=>{l(s)&&M(S)})}y(D,w)},R=D=>{var w=cC();ve("click",w,()=>J(r,!1)),y(D,w)};q(O,D=>{l(r)?D(R,-1):D(P)})}m(g),vn("mouseenter",g,()=>J(s,!0)),vn("mouseleave",g,()=>J(s,!1)),y(p,g)},h=p=>{var g=uC(),x=b(g),v=b(x,!0);m(x),m(g),B(()=>{Ie(x,1,`language-${e.lang??""}`),N(v,e.content)}),y(p,g)},d=p=>{var g=fC(),x=b(g,!0);m(g),B(()=>N(x,e.content)),y(p,g)};q(u,p=>{l(i)?p(f):e.lang?p(h,1):p(d,-1)})}y(t,a),Nt()}$t(["click"]);var hC=C('<button class="font-mono hover:underline cursor-pointer bg-transparent border-none text-blue-400 p-0"> </button>'),dC=C('<span class="font-mono opacity-60"> </span>'),gC=C('<span class="font-mono"> </span>'),pC=C('<span class="opacity-60"> </span>'),mC=C('<div class="flex items-center gap-2 text-xs text-blue-400 bg-blue-900/20 rounded px-2 py-1"><span class="opacity-60">📂</span> <!></div>'),vC=C('<button class="font-mono hover:underline cursor-pointer bg-transparent border-none text-purple-400 p-0"> </button>'),bC=C('<span class="font-mono opacity-60"> </span>'),_C=C('<span class="font-mono"> </span>'),yC=C('<span class="font-mono"> </span>'),xC=C('<div class="text-xs text-purple-400 bg-purple-900/20 rounded px-2 py-1"><div class="flex items-center gap-2"><span class="opacity-60">✂️</span> <!></div></div>'),kC=C('<div class="text-xs text-yellow-400 bg-yellow-900/20 rounded px-2 py-1"><span class="opacity-60">⚠️</span> <span class="font-mono"> </span> <span class="opacity-60 ml-1"> </span></div>');function SC(t,e){Mt(e,!0);const n=H(()=>{const f=e.content.match(/(?:opened the file |selected.*from )(\/[^\s]+)/);return f?f[1]:e.content.trim().startsWith("/")?e.content.trim().split(`
92
- `)[0].split(" ")[0]:null}),r=H(()=>{const f=e.content.match(/lines? (\d+)(?:\s*to\s*(\d+))?/);return f?f[2]?`L${f[1]}-${f[2]}`:`L${f[1]}`:null}),s=async()=>{l(n)&&await Sc(l(n))};var o=Fe(),i=Te(o);{var c=f=>{var h=mC(),d=T(b(h),2);{var p=x=>{var v=Fe(),_=Te(v);ka(_,()=>wa(l(n)),O=>{var P=gC(),R=b(P,!0);m(P),B(D=>N(R,D),[()=>l(n).split("/").pop()]),y(O,P)},(O,P)=>{var R=Fe(),D=Te(R);{var w=S=>{var M=hC(),E=b(M);m(M),B($=>{Me(M,"title",l(n)),N(E,`${$??""}${l(r)?`:${l(r)}`:""}`)},[()=>l(n).split("/").pop()]),ve("click",M,s),y(S,M)},A=S=>{var M=dC(),E=b(M,!0);m(M),B($=>{Me(M,"title",l(n)),N(E,$)},[()=>l(n).split("/").pop()]),y(S,M)};q(D,S=>{l(P)?S(w):S(A,-1)})}y(O,R)}),y(x,v)},g=x=>{var v=pC(),_=b(v,!0);m(v),B(()=>N(_,e.content)),y(x,v)};q(d,x=>{l(n)?x(p):x(g,-1)})}m(h),y(f,h)},a=f=>{var h=xC(),d=b(h),p=T(b(d),2);{var g=v=>{var _=Fe(),O=Te(_);ka(O,()=>wa(l(n)),P=>{var R=_C(),D=b(R);m(R),B(w=>N(D,`${w??""}${l(r)?`:${l(r)}`:""}`),[()=>l(n).split("/").pop()]),y(P,R)},(P,R)=>{var D=Fe(),w=Te(D);{var A=M=>{var E=vC(),$=b(E);m(E),B(Q=>{Me(E,"title",l(n)),N($,`${Q??""}${l(r)?`:${l(r)}`:""}`)},[()=>l(n).split("/").pop()]),ve("click",E,s),y(M,E)},S=M=>{var E=bC(),$=b(E);m(E),B(Q=>{Me(E,"title",l(n)),N($,`${Q??""}${l(r)?`:${l(r)}`:""}`)},[()=>l(n).split("/").pop()]),y(M,E)};q(w,M=>{l(R)?M(A):M(S,-1)})}y(P,D)}),y(v,_)},x=v=>{var _=yC(),O=b(_,!0);m(_),B(P=>N(O,P),[()=>e.content.split(`
93
- `)[0].slice(0,60)]),y(v,_)};q(p,v=>{l(n)?v(g):v(x,-1)})}m(d),m(h),y(f,h)},u=f=>{var h=kC(),d=T(b(h),2),p=b(d);m(d);var g=T(d,2),x=b(g);m(g),m(h),B(v=>{N(p,`<${e.tag??""}>`),N(x,`${v??""}${e.content.length>50?"...":""}`)},[()=>e.content.slice(0,50)]),y(f,h)};q(i,f=>{e.tag==="ide_opened_file"?f(c):e.tag==="ide_selection"?f(a,1):f(u,-1)})}y(t,o),Nt()}$t(["click"]);var wC=C('<li><span class="flex-shrink-0"> </span> <span> </span></li>'),TC=C('<ul class="space-y-1.5 mt-1"></ul>');function CC(t,e){const n=o=>{switch(o){case"completed":return"✅";case"in_progress":return"🔄";case"pending":return"⬜"}},r=o=>{switch(o){case"completed":return"text-gh-green";case"in_progress":return"text-gh-accent";case"pending":return"text-gh-text-secondary"}};var s=TC();dt(s,21,()=>e.todos,_t,(o,i)=>{var c=wC(),a=b(c),u=b(a,!0);m(a);var f=T(a,2),h=b(f,!0);m(f),m(c),B((d,p)=>{Ie(c,1,`flex items-start gap-2 text-sm ${d??""}`),N(u,p),Ie(f,1,yr(l(i).status==="completed"?"line-through opacity-70":"")),N(h,l(i).status==="in_progress"?l(i).activeForm:l(i).content)},[()=>r(l(i).status),()=>n(l(i).status)]),y(o,c)}),m(s),y(t,s)}var RC=C('<span class="tooltip svelte-1yfjzin"> </span>'),IC=C("<button><!></button> <!>",1);function vr(t,e){let n=Ae(e,"position",3,"bottom"),r=Ae(e,"class",3,""),s=vm(e,["$$slots","$$events","$$legacy","title","children","position","class"]),o=De(null),i=De(!1),c=De("");const a=()=>{if(!l(o))return;const v=l(o).getBoundingClientRect(),_=v.left+v.width/2;n()==="top"?J(c,`left: ${_}px; bottom: ${window.innerHeight-v.top+8}px;`):J(c,`left: ${_}px; top: ${v.bottom+8}px;`)},u=()=>{a(),J(i,!0)},f=()=>{J(i,!1)};var h=IC(),d=Te(h);Dm(d,()=>({class:`tooltip-btn ${r()??""}`,onmouseenter:u,onmouseleave:f,...s}),void 0,void 0,void 0,"svelte-1yfjzin");var p=b(d);$f(p,()=>e.children),m(d),ai(d,v=>J(o,v),()=>l(o));var g=T(d,2);{var x=v=>{var _=RC(),O=b(_,!0);m(_),B(()=>{Uf(_,l(c)),N(O,e.title)}),y(v,_)};q(g,v=>{l(i)&&v(x)})}y(t,h)}var EC=C('<div class="p-2 rounded-lg bg-gh-border-subtle/30 group relative"><div class="flex justify-between items-center text-xs text-gh-text-secondary/60"><span> </span> <div class="flex items-center gap-2"><!> <!></div></div></div>'),OC=C('<div class="p-2 rounded-lg bg-gh-border-subtle/50 group relative"><div class="flex justify-between items-center text-xs text-gh-text-secondary"><span class="text-gh-text-secondary/70"> </span> <div class="flex items-center gap-2"><!> <!></div></div></div>'),AC=C('<span class="font-mono"> </span>'),MC=C('<div class="mt-1 text-xs text-gh-text-secondary"></div>'),NC=C("<p> </p>"),PC=C('<div class="mt-1 text-xs text-red-400"></div>'),FC=C('<div class="p-3 rounded-lg bg-emerald-500/10 border-l-3 border-l-emerald-500 group relative"><div class="flex justify-between items-center text-xs text-gh-text-secondary"><span class="font-semibold text-emerald-400"> </span> <div class="flex items-center gap-2"><span> </span> <!> <!></div></div> <!> <!></div>'),LC=C('<button class="text-gh-accent hover:underline cursor-pointer bg-transparent border-none p-0" title="Open backup in VS Code"> </button>'),jC=C('<span class="text-gh-text-secondary"> </span>'),DC=C('<li class="font-mono text-xs truncate"><!></li>'),$C=C('<div class="p-4 rounded-lg bg-amber-500/10 border-l-3 border-l-amber-500 group relative"><div class="flex justify-between mb-2 text-xs text-gh-text-secondary"><span class="uppercase font-semibold text-amber-400"> </span> <div class="flex items-center gap-2"><span> </span> <!> <!></div></div> <ul class="space-y-1"></ul></div>'),BC=C('<div class="p-3 rounded-lg bg-gh-accent/15 border-l-3 border-l-gh-accent group relative"><div class="flex justify-between items-center text-xs text-gh-text-secondary"><span class="font-semibold text-gh-accent"> </span> <div class="flex items-center gap-2"><span> </span> <!> <!></div></div></div>'),UC=C('<p class="mt-1 text-sm text-gh-text-secondary"> </p>'),qC=C('<div class="p-3 rounded-lg bg-cyan-500/10 border-l-3 border-l-cyan-500 group relative"><div class="flex justify-between items-center text-xs text-gh-text-secondary"><span class="font-semibold text-cyan-400"> </span> <div class="flex items-center gap-2"><span> </span> <!> <!></div></div> <!></div>'),zC=C('<button class="mt-1 text-sm text-gh-accent hover:underline cursor-pointer bg-transparent border-none p-0 font-mono truncate block max-w-full text-left"> </button>'),VC=C('<span class="mt-1 text-sm text-gh-text-secondary font-mono"> </span>'),HC=C('<span class="mt-1 text-sm text-gh-text-secondary font-mono"> </span>'),WC=C('<p class="mt-1 text-sm text-gh-text-secondary"> </p>'),KC=C("<!> <!>",1),GC=C(" <!>",1),JC=C('<div class="p-3 rounded-lg bg-violet-500/10 border-l-3 border-l-violet-500 group relative"><div class="flex justify-between items-center text-xs text-gh-text-secondary"><span class="font-semibold text-violet-400"> </span> <div class="flex items-center gap-2"><span> </span> <!> <!></div></div> <!></div>'),YC=C('<details class="text-gh-text-secondary"><summary class="cursor-pointer text-xs italic hover:text-gh-text select-none"> </summary> <p class="mt-1 whitespace-pre-wrap italic opacity-70"> </p></details>'),ZC=C('<div class="message-content text-sm"></div>'),QC=C('<span class="font-semibold text-purple-400"> </span>'),XC=C('<p class="whitespace-pre-wrap"> </p>'),eR=C('<div class="message-content text-sm"><!></div>'),tR=C('<div><div class="flex justify-between text-xs text-gh-text-secondary"><span class="uppercase font-semibold"> </span> <div class="flex items-center gap-2"><span class="group-hover:hidden"> </span> <span class="hidden group-hover:inline font-mono text-gh-text-secondary/70"> </span> <!> <!> <!></div></div> <!> <!></div>');function nR(t,e){Mt(e,!0);const n=G=>{var U=Fe(),ie=Te(U);{var ee=$e=>{vr($e,{class:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-gh-accent/20 text-xs",onclick:()=>e.onSplit(e.msg),title:"Split session from this message",children:(xe,ke)=>{hr();var Ve=Rt("✂️");y(xe,Ve)},$$slots:{default:!0}})};q(ie,$e=>{e.onSplit&&!s()&&e.msg.uuid&&$e(ee)})}y(G,U)},r=G=>{vr(G,{class:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-gh-red/20 text-xs",onclick:()=>e.onDelete(e.msg),title:"Delete message",children:(U,ie)=>{hr();var ee=Rt("🗑️");y(U,ee)},$$slots:{default:!0}})};let s=Ae(e,"isFirst",3,!1);const o=H(()=>e.msg.uuid??""),i=H(()=>e.msg.type==="assistant"),c=H(()=>e.msg.type==="custom-title"),a=H(()=>e.msg.type==="file-history-snapshot"),u=H(()=>e.msg.type==="human"||e.msg.type==="user"),f=H(()=>e.msg.type==="system"&&e.msg.subtype==="local_command"),h=H(()=>e.msg.type==="queue-operation"),d=H(()=>{if(e.msg.type!=="user")return!1;const G=e.msg.message;return Array.isArray(G?.content)?G.content[0]?.type==="tool_result":!1}),p=H(()=>{if(!l(a))return null;const G=e.msg.snapshot,U=G?.trackedFileBackups??{};return{files:Object.entries(U),timestamp:G?.timestamp}}),g=H(()=>{if(l(f)){const G=typeof e.msg.content=="string"?e.msg.content:"";return fc(G)}if(l(u)){const G=e.msg.message,U=typeof G?.content=="string"?G.content:"";if(U.includes("<command-name>"))return fc(U)}return null}),x=H(()=>l(g)!==null&&!l(f)),v=H(()=>eC(e.msg)),_=H(()=>tC(e.msg)),O=H(()=>nC(e.msg)),P=["Read","Write","Edit"],R=H(()=>{if(!l(i))return null;const G=e.msg.message;if(!Array.isArray(G?.content))return null;const U=G.content.find(ie=>typeof ie=="object"&&ie!==null&&ie.type==="tool_use");return U?{name:U.name,input:U.input,filePath:P.includes(U.name)?U.input.file_path:null}:null}),D=H(()=>{if(!l(i))return[];const G=e.msg.message;return Array.isArray(G?.content)?G.content.filter(U=>typeof U=="object"&&U!==null&&U.type==="thinking"):[]}),w=H(()=>e.msg.customTitle??""),A=H(()=>e.msg.uuid||e.msg.messageId||""),S=H(()=>{if(l(h))return!1;if(l(a)||l(f)||l(c)||l(R)||gf(e.msg).trim().length>0)return!0;if(e.msg.type==="user"||e.msg.type==="human"){const U=l(d)?"Tool result":"User message";console.warn(`${U} without content:`,km(e.msg))}return!1}),M=H(()=>l(S)||l(D).length>0),E=H(()=>l(u)?"bg-gh-accent/15 border-l-3 border-l-gh-accent":l(i)?"bg-gh-green/15 border-l-3 border-l-gh-green":l(c)?"bg-purple-500/15 border-l-3 border-l-purple-500":"bg-gh-border-subtle");var $=Fe(),Q=Te($);{var pe=G=>{},W=G=>{var U=EC(),ie=b(U),ee=b(ie),$e=b(ee);m(ee);var xe=T(ee,2),ke=b(xe);n(ke);var Ve=T(ke,2);r(Ve),m(xe),m(ie),m(U),B(()=>{Me(U,"data-msg-id",l(o)),N($e,`🔄 ${l(O).hookName??l(O).type??""}`)}),y(G,U)},ue=G=>{var U=OC(),ie=b(U),ee=b(ie),$e=b(ee);m(ee);var xe=T(ee,2),ke=b(xe);n(ke);var Ve=T(ke,2);r(Ve),m(xe),m(ie),m(U),B(()=>{Me(U,"data-msg-id",l(o)),N($e,`⏱️ ${l(_).durationFormatted??""}`)}),y(G,U)},Oe=G=>{var U=FC(),ie=b(U),ee=b(ie),$e=b(ee);m(ee);var xe=T(ee,2),ke=b(xe),Ve=b(ke,!0);m(ke);var qe=T(ke,2);n(qe);var mt=T(qe,2);r(mt),m(xe),m(ie);var Pe=T(ie,2);{var Xe=j=>{var V=MC();dt(V,21,()=>l(v).hookInfos,_t,(re,ae)=>{var z=AC(),F=b(z,!0);m(z),B(()=>N(F,l(ae).command)),y(re,z)}),m(V),y(j,V)};q(Pe,j=>{l(v).hookInfos.length>0&&j(Xe)})}var gt=T(Pe,2);{var L=j=>{var V=PC();dt(V,21,()=>l(v).hookErrors,_t,(re,ae)=>{var z=NC(),F=b(z,!0);m(z),B(()=>N(F,l(ae))),y(re,z)}),m(V),y(j,V)};q(gt,j=>{l(v).hookErrors.length>0&&j(L)})}m(U),B(j=>{Me(U,"data-msg-id",l(o)),N($e,`🪝 Hook (${l(v).hookCount??""})`),N(Ve,j)},[()=>ur(e.msg.timestamp)]),y(G,U)},_e=G=>{var U=$C(),ie=b(U),ee=b(ie),$e=b(ee);m(ee);var xe=T(ee,2),ke=b(xe),Ve=b(ke,!0);m(ke);var qe=T(ke,2);n(qe);var mt=T(qe,2);r(mt),m(xe),m(ie);var Pe=T(ie,2);dt(Pe,21,()=>l(p).files,_t,(Xe,gt)=>{var L=H(()=>jf(l(gt),2));let j=()=>l(L)[0],V=()=>l(L)[1];const re=H(()=>!!(V().backupFileName&&e.sessionId));var ae=DC(),z=b(ae);{var F=te=>{var ne=LC(),fe=b(ne,!0);m(ne),B(X=>N(fe,X),[()=>Eo(j())]),ve("click",ne,()=>qm(e.sessionId,V().backupFileName)),y(te,ne)},be=te=>{var ne=jC(),fe=b(ne,!0);m(ne),B(X=>N(fe,X),[()=>Eo(j())]),y(te,ne)};q(z,te=>{l(re)?te(F):te(be,-1)})}m(ae),B(te=>Me(ae,"title",te),[()=>Eo(j())]),y(Xe,ae)}),m(Pe),m(U),B(Xe=>{Me(U,"data-msg-id",l(o)),Me(U,"title",`messageId: ${l(A)??""}`),N($e,`📁 File Backups (${l(p).files.length??""})`),N(Ve,Xe)},[()=>ur(l(p).timestamp)]),y(G,U)},Y=G=>{var U=BC(),ie=b(U),ee=b(ie),$e=b(ee,!0);m(ee);var xe=T(ee,2),ke=b(xe),Ve=b(ke,!0);m(ke);var qe=T(ke,2);n(qe);var mt=T(qe,2);r(mt),m(xe),m(ie),m(U),B(Pe=>{Me(U,"data-msg-id",l(o)),N($e,l(g).name||"Command"),N(Ve,Pe)},[()=>ur(e.msg.timestamp)]),y(G,U)},K=G=>{var U=qC(),ie=b(U),ee=b(ie),$e=b(ee);m(ee);var xe=T(ee,2),ke=b(xe),Ve=b(ke,!0);m(ke);var qe=T(ke,2);n(qe);var mt=T(qe,2);r(mt),m(xe),m(ie);var Pe=T(ie,2);{var Xe=L=>{var j=UC(),V=b(j,!0);m(j),B(()=>N(V,l(g).message)),y(L,j)},gt=H(()=>l(g).message&&l(g).message!==l(g).name?.slice(1));q(Pe,L=>{l(gt)&&L(Xe)})}m(U),B(L=>{Me(U,"data-msg-id",l(o)),N($e,`⚡ ${(l(g).name||"Command")??""}`),N(Ve,L)},[()=>ur(e.msg.timestamp)]),y(G,U)},Qe=G=>{var U=JC(),ie=b(U),ee=b(ie),$e=b(ee);m(ee);var xe=T(ee,2),ke=b(xe),Ve=b(ke,!0);m(ke);var qe=T(ke,2);n(qe);var mt=T(qe,2);r(mt),m(xe),m(ie);var Pe=T(ie,2);{var Xe=j=>{var V=Fe(),re=Te(V);ka(re,()=>wa(l(R).filePath),ae=>{var z=HC(),F=b(z,!0);m(z),B(be=>N(F,be),[()=>l(R).filePath.split("/").pop()]),y(ae,z)},(ae,z)=>{var F=Fe(),be=Te(F);{var te=fe=>{var X=zC(),ot=b(X,!0);m(X),B(He=>{Me(X,"title",l(R).filePath),N(ot,He)},[()=>l(R).filePath.split("/").pop()]),ve("click",X,()=>Sc(l(R).filePath)),y(fe,X)},ne=fe=>{var X=VC(),ot=b(X,!0);m(X),B(He=>{Me(X,"title",l(R).filePath),N(ot,He)},[()=>l(R).filePath.split("/").pop()]),y(fe,X)};q(be,fe=>{l(z)?fe(te):fe(ne,-1)})}y(ae,F)}),y(j,V)},gt=j=>{var V=KC(),re=Te(V);{var ae=F=>{var be=WC(),te=b(be,!0);m(be),B(()=>N(te,l(R).input.description)),y(F,be)};q(re,F=>{l(R).input.description&&F(ae)})}var z=T(re,2);{let F=H(()=>String(l(R).input.command));bo(z,{get content(){return l(F)},lang:"sh",maxLines:3})}y(j,V)},L=j=>{const V=H(()=>{const{path:te,...ne}=l(R).input;return{_path:te,input:ne}}),re=H(()=>Object.keys(l(V).input));var ae=Fe(),z=Te(ae);{var F=te=>{const ne=H(()=>l(re)[0]),fe=H(()=>l(V).input[l(ne)]);var X=GC(),ot=Te(X),He=T(ot);{var Pt=je=>{CC(je,{get todos(){return l(fe)}})},pt=H(()=>l(ne)==="todos"&&Array.isArray(l(fe))),ut=je=>{{let Bt=H(()=>`${l(ne)} = ${JSON.stringify(l(fe),null,2)}`);bo(je,{get content(){return l(Bt)},lang:"js",maxLines:1})}};q(He,je=>{l(pt)?je(Pt):je(ut,-1)})}B(je=>N(ot,`${je??""} `),[()=>(console.info(`${l(ne)} =`,l(fe)),"")]),y(te,X)},be=te=>{{let ne=H(()=>JSON.stringify(l(V).input,null,2));bo(te,{get content(){return l(ne)},lang:"json",maxLines:6})}};q(z,te=>{l(re).length===1?te(F):te(be,-1)})}y(j,ae)};q(Pe,j=>{l(R).filePath?j(Xe):l(R).input.command?j(gt,1):j(L,-1)})}m(U),B(j=>{Me(U,"data-msg-id",l(o)),N($e,`🔧 ${l(R).name??""}`),N(Ve,j)},[()=>ur(e.msg.timestamp)]),y(G,U)},Ue=G=>{var U=tR(),ie=b(U),ee=b(ie),$e=b(ee,!0);m(ee);var xe=T(ee,2),ke=b(xe),Ve=b(ke,!0);m(ke);var qe=T(ke,2),mt=b(qe,!0);m(qe);var Pe=T(qe,2);{var Xe=z=>{vr(z,{class:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-gh-border text-xs",onclick:()=>e.onEditTitle(e.msg),title:"Edit title",children:(F,be)=>{hr();var te=Rt("✏️");y(F,te)},$$slots:{default:!0}})};q(Pe,z=>{l(c)&&e.onEditTitle&&z(Xe)})}var gt=T(Pe,2);n(gt);var L=T(gt,2);r(L),m(xe),m(ie);var j=T(ie,2);{var V=z=>{var F=ZC();dt(F,21,()=>l(D),_t,(be,te,ne)=>{var fe=YC(),X=b(fe),ot=b(X);m(X);var He=T(X,2),Pt=b(He,!0);m(He),m(fe),B(()=>{N(ot,`💭 Thinking ${l(D).length>1?`(${ne+1}/${l(D).length})`:""}`),N(Pt,l(te).thinking)}),y(be,fe)}),m(F),y(z,F)};q(j,z=>{l(D).length>0&&z(V)})}var re=T(j,2);{var ae=z=>{var F=eR(),be=b(F);{var te=fe=>{var X=QC(),ot=b(X,!0);m(X),B(()=>N(ot,l(w))),y(fe,X)},ne=fe=>{const X=H(()=>gf(e.msg)),ot=H(()=>rC(l(X)));var He=Fe(),Pt=Te(He);dt(Pt,17,()=>l(ot),_t,(pt,ut)=>{var je=Fe(),Bt=Te(je);{var Gi=hn=>{SC(hn,{get tag(){return l(ut).tag},get content(){return l(ut).content}})},no=hn=>{const ro=H(()=>l(ut).content.split(`
94
- `));var so=Fe(),oo=Te(so);{var Ji=wn=>{bo(wn,{get content(){return l(ut).content},maxLines:10})},Yi=wn=>{var Re=XC(),We=b(Re,!0);m(Re),B(()=>N(We,l(ut).content)),y(wn,Re)};q(oo,wn=>{l(ro).length>10?wn(Ji):wn(Yi,-1)})}y(hn,so)};q(Bt,hn=>{l(ut).type==="ide_tag"&&l(ut).tag?hn(Gi):hn(no,-1)})}y(pt,je)}),y(fe,He)};q(be,fe=>{l(c)?fe(te):fe(ne,-1)})}m(F),y(z,F)};q(re,z=>{l(S)&&z(ae)})}m(U),B(z=>{Me(U,"data-msg-id",l(o)),Ie(U,1,`p-4 rounded-lg group relative ${l(E)??""} flex flex-col ${l(M)?"gap-2":""}`),N($e,l(d)?"OUT":e.msg.type),N(Ve,z),N(mt,l(A))},[()=>ur(e.msg.timestamp)]),y(G,U)};q(Q,G=>{l(h)?G(pe):l(O)?G(W,1):l(_)?G(ue,2):l(v)?G(Oe,3):l(a)&&l(p)?G(_e,4):l(x)&&l(g)?G(Y,5):l(f)&&l(g)?G(K,6):l(R)?G(Qe,7):l(M)&&G(Ue,8)})}y(t,$),Nt()}$t(["click"]);var rR=C("<section><div></div></section>");function pf(t,e){Mt(e,!0);let n=Ae(e,"enableScroll",3,!0),r=Ae(e,"fullWidth",3,!1);const s=H(()=>e.messages.findIndex(c=>c.type==="user"||c.type==="assistant"||c.type==="human"));var o=rR(),i=b(o);dt(i,23,()=>e.messages,(c,a)=>c.uuid??`idx-${a}`,(c,a,u)=>{{let f=H(()=>l(u)===0||l(u)===l(s));nR(c,{get msg(){return l(a)},get sessionId(){return e.sessionId},get isFirst(){return l(f)},get onDelete(){return e.onDeleteMessage},get onEditTitle(){return e.onEditTitle},get onSplit(){return e.onSplitSession}})}}),m(i),m(o),B(()=>{Ie(o,1,`bg-gh-bg-secondary overflow-hidden flex flex-col ${r()?"":"border border-gh-border rounded-lg"}`),Ie(i,1,`${n()?"overflow-y-auto":""} flex-1 p-4 flex flex-col gap-4`)}),y(t,o),Nt()}const pc=Math.min,br=Math.max,si=Math.round,sn=t=>({x:t,y:t}),sR={left:"right",right:"left",bottom:"top",top:"bottom"},oR={start:"end",end:"start"};function mf(t,e,n){return br(t,pc(e,n))}function qi(t,e){return typeof t=="function"?t(e):t}function rr(t){return t.split("-")[0]}function zi(t){return t.split("-")[1]}function hp(t){return t==="x"?"y":"x"}function dp(t){return t==="y"?"height":"width"}const iR=new Set(["top","bottom"]);function En(t){return iR.has(rr(t))?"y":"x"}function gp(t){return hp(En(t))}function aR(t,e,n){n===void 0&&(n=!1);const r=zi(t),s=gp(t),o=dp(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=oi(i)),[i,oi(i)]}function cR(t){const e=oi(t);return[mc(t),e,mc(e)]}function mc(t){return t.replace(/start|end/g,e=>oR[e])}const vf=["left","right"],bf=["right","left"],lR=["top","bottom"],uR=["bottom","top"];function fR(t,e,n){switch(t){case"top":case"bottom":return n?e?bf:vf:e?vf:bf;case"left":case"right":return e?lR:uR;default:return[]}}function hR(t,e,n,r){const s=zi(t);let o=fR(rr(t),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map(mc)))),o}function oi(t){return t.replace(/left|right|bottom|top/g,e=>sR[e])}function dR(t){return{top:0,right:0,bottom:0,left:0,...t}}function gR(t){return typeof t!="number"?dR(t):{top:t,right:t,bottom:t,left:t}}function ii(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function _f(t,e,n){let{reference:r,floating:s}=t;const o=En(e),i=gp(e),c=dp(i),a=rr(e),u=o==="y",f=r.x+r.width/2-s.width/2,h=r.y+r.height/2-s.height/2,d=r[c]/2-s[c]/2;let p;switch(a){case"top":p={x:f,y:r.y-s.height};break;case"bottom":p={x:f,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:h};break;case"left":p={x:r.x-s.width,y:h};break;default:p={x:r.x,y:r.y}}switch(zi(e)){case"start":p[i]-=d*(n&&u?-1:1);break;case"end":p[i]+=d*(n&&u?-1:1);break}return p}async function pR(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:i,elements:c,strategy:a}=t,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:d=!1,padding:p=0}=qi(e,t),g=gR(p),v=c[d?h==="floating"?"reference":"floating":h],_=ii(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(v)))==null||n?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:u,rootBoundary:f,strategy:a})),O=h==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,P=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),R=await(o.isElement==null?void 0:o.isElement(P))?await(o.getScale==null?void 0:o.getScale(P))||{x:1,y:1}:{x:1,y:1},D=ii(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:O,offsetParent:P,strategy:a}):O);return{top:(_.top-D.top+g.top)/R.y,bottom:(D.bottom-_.bottom+g.bottom)/R.y,left:(_.left-D.left+g.left)/R.x,right:(D.right-_.right+g.right)/R.x}}const mR=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,c=o.filter(Boolean),a=await(i.isRTL==null?void 0:i.isRTL(e));let u=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:f,y:h}=_f(u,r,a),d=r,p={},g=0;for(let v=0;v<c.length;v++){var x;const{name:_,fn:O}=c[v],{x:P,y:R,data:D,reset:w}=await O({x:f,y:h,initialPlacement:r,placement:d,strategy:s,middlewareData:p,rects:u,platform:{...i,detectOverflow:(x=i.detectOverflow)!=null?x:pR},elements:{reference:t,floating:e}});f=P??f,h=R??h,p={...p,[_]:{...p[_],...D}},w&&g<=50&&(g++,typeof w=="object"&&(w.placement&&(d=w.placement),w.rects&&(u=w.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):w.rects),{x:f,y:h}=_f(u,d,a)),v=-1)}return{x:f,y:h,placement:d,strategy:s,middlewareData:p}},vR=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:c,platform:a,elements:u}=e,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:d,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:x=!0,...v}=qi(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const _=rr(s),O=En(c),P=rr(c)===c,R=await(a.isRTL==null?void 0:a.isRTL(u.floating)),D=d||(P||!x?[oi(c)]:cR(c)),w=g!=="none";!d&&w&&D.push(...hR(c,x,g,R));const A=[c,...D],S=await a.detectOverflow(e,v),M=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(f&&M.push(S[_]),h){const W=aR(s,i,R);M.push(S[W[0]],S[W[1]])}if(E=[...E,{placement:s,overflows:M}],!M.every(W=>W<=0)){var $,Q;const W=((($=o.flip)==null?void 0:$.index)||0)+1,ue=A[W];if(ue&&(!(h==="alignment"?O!==En(ue):!1)||E.every(Y=>En(Y.placement)===O?Y.overflows[0]>0:!0)))return{data:{index:W,overflows:E},reset:{placement:ue}};let Oe=(Q=E.filter(_e=>_e.overflows[0]<=0).sort((_e,Y)=>_e.overflows[1]-Y.overflows[1])[0])==null?void 0:Q.placement;if(!Oe)switch(p){case"bestFit":{var pe;const _e=(pe=E.filter(Y=>{if(w){const K=En(Y.placement);return K===O||K==="y"}return!0}).map(Y=>[Y.placement,Y.overflows.filter(K=>K>0).reduce((K,Qe)=>K+Qe,0)]).sort((Y,K)=>Y[1]-K[1])[0])==null?void 0:pe[0];_e&&(Oe=_e);break}case"initialPlacement":Oe=c;break}if(s!==Oe)return{reset:{placement:Oe}}}return{}}}},bR=new Set(["left","top"]);async function _R(t,e){const{placement:n,platform:r,elements:s}=t,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=rr(n),c=zi(n),a=En(n)==="y",u=bR.has(i)?-1:1,f=o&&a?-1:1,h=qi(e,t);let{mainAxis:d,crossAxis:p,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return c&&typeof g=="number"&&(p=c==="end"?g*-1:g),a?{x:p*f,y:d*u}:{x:d*u,y:p*f}}const yR=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:o,placement:i,middlewareData:c}=e,a=await _R(e,t);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:o+a.y,data:{...a,placement:i}}}}},xR=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:o}=e,{mainAxis:i=!0,crossAxis:c=!1,limiter:a={fn:_=>{let{x:O,y:P}=_;return{x:O,y:P}}},...u}=qi(t,e),f={x:n,y:r},h=await o.detectOverflow(e,u),d=En(rr(s)),p=hp(d);let g=f[p],x=f[d];if(i){const _=p==="y"?"top":"left",O=p==="y"?"bottom":"right",P=g+h[_],R=g-h[O];g=mf(P,g,R)}if(c){const _=d==="y"?"top":"left",O=d==="y"?"bottom":"right",P=x+h[_],R=x-h[O];x=mf(P,x,R)}const v=a.fn({...e,[p]:g,[d]:x});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[p]:i,[d]:c}}}}}};function Vi(){return typeof window<"u"}function Yr(t){return pp(t)?(t.nodeName||"").toLowerCase():"#document"}function It(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Sn(t){var e;return(e=(pp(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function pp(t){return Vi()?t instanceof Node||t instanceof It(t).Node:!1}function Yt(t){return Vi()?t instanceof Element||t instanceof It(t).Element:!1}function cn(t){return Vi()?t instanceof HTMLElement||t instanceof It(t).HTMLElement:!1}function yf(t){return!Vi()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof It(t).ShadowRoot}const kR=new Set(["inline","contents"]);function to(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Zt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!kR.has(s)}const SR=new Set(["table","td","th"]);function wR(t){return SR.has(Yr(t))}const TR=[":popover-open",":modal"];function Hi(t){return TR.some(e=>{try{return t.matches(e)}catch{return!1}})}const CR=["transform","translate","scale","rotate","perspective"],RR=["transform","translate","scale","rotate","perspective","filter"],IR=["paint","layout","strict","content"];function Ul(t){const e=ql(),n=Yt(t)?Zt(t):t;return CR.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||RR.some(r=>(n.willChange||"").includes(r))||IR.some(r=>(n.contain||"").includes(r))}function ER(t){let e=Mn(t);for(;cn(e)&&!qr(e);){if(Ul(e))return e;if(Hi(e))return null;e=Mn(e)}return null}function ql(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const OR=new Set(["html","body","#document"]);function qr(t){return OR.has(Yr(t))}function Zt(t){return It(t).getComputedStyle(t)}function Wi(t){return Yt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Mn(t){if(Yr(t)==="html")return t;const e=t.assignedSlot||t.parentNode||yf(t)&&t.host||Sn(t);return yf(e)?e.host:e}function mp(t){const e=Mn(t);return qr(e)?t.ownerDocument?t.ownerDocument.body:t.body:cn(e)&&to(e)?e:mp(e)}function vp(t,e,n){var r;e===void 0&&(e=[]);const s=mp(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),i=It(s);return o?(vc(i),e.concat(i,i.visualViewport||[],to(s)?s:[],[])):e.concat(s,vp(s,[]))}function vc(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function bp(t){const e=Zt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=cn(t),o=s?t.offsetWidth:n,i=s?t.offsetHeight:r,c=si(n)!==o||si(r)!==i;return c&&(n=o,r=i),{width:n,height:r,$:c}}function _p(t){return Yt(t)?t:t.contextElement}function _r(t){const e=_p(t);if(!cn(e))return sn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=bp(e);let i=(o?si(n.width):n.width)/r,c=(o?si(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const AR=sn(0);function yp(t){const e=It(t);return!ql()||!e.visualViewport?AR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function MR(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==It(t)?!1:e}function Ps(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=_p(t);let i=sn(1);e&&(r?Yt(r)&&(i=_r(r)):i=_r(t));const c=MR(o,n,r)?yp(o):sn(0);let a=(s.left+c.x)/i.x,u=(s.top+c.y)/i.y,f=s.width/i.x,h=s.height/i.y;if(o){const d=It(o),p=r&&Yt(r)?It(r):r;let g=d,x=vc(g);for(;x&&r&&p!==g;){const v=_r(x),_=x.getBoundingClientRect(),O=Zt(x),P=_.left+(x.clientLeft+parseFloat(O.paddingLeft))*v.x,R=_.top+(x.clientTop+parseFloat(O.paddingTop))*v.y;a*=v.x,u*=v.y,f*=v.x,h*=v.y,a+=P,u+=R,g=It(x),x=vc(g)}}return ii({width:f,height:h,x:a,y:u})}function Ki(t,e){const n=Wi(t).scrollLeft;return e?e.left+n:Ps(Sn(t)).left+n}function xp(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Ki(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function NR(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",i=Sn(r),c=e?Hi(e.floating):!1;if(r===i||c&&o)return n;let a={scrollLeft:0,scrollTop:0},u=sn(1);const f=sn(0),h=cn(r);if((h||!h&&!o)&&((Yr(r)!=="body"||to(i))&&(a=Wi(r)),cn(r))){const p=Ps(r);u=_r(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const d=i&&!h&&!o?xp(i,a):sn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-a.scrollLeft*u.x+f.x+d.x,y:n.y*u.y-a.scrollTop*u.y+f.y+d.y}}function PR(t){return Array.from(t.getClientRects())}function FR(t){const e=Sn(t),n=Wi(t),r=t.ownerDocument.body,s=br(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=br(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Ki(t);const c=-n.scrollTop;return Zt(r).direction==="rtl"&&(i+=br(e.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:c}}const xf=25;function LR(t,e){const n=It(t),r=Sn(t),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,c=0,a=0;if(s){o=s.width,i=s.height;const f=ql();(!f||f&&e==="fixed")&&(c=s.offsetLeft,a=s.offsetTop)}const u=Ki(r);if(u<=0){const f=r.ownerDocument,h=f.body,d=getComputedStyle(h),p=f.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,g=Math.abs(r.clientWidth-h.clientWidth-p);g<=xf&&(o-=g)}else u<=xf&&(o+=u);return{width:o,height:i,x:c,y:a}}const jR=new Set(["absolute","fixed"]);function DR(t,e){const n=Ps(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=cn(t)?_r(t):sn(1),i=t.clientWidth*o.x,c=t.clientHeight*o.y,a=s*o.x,u=r*o.y;return{width:i,height:c,x:a,y:u}}function kf(t,e,n){let r;if(e==="viewport")r=LR(t,n);else if(e==="document")r=FR(Sn(t));else if(Yt(e))r=DR(e,n);else{const s=yp(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ii(r)}function kp(t,e){const n=Mn(t);return n===e||!Yt(n)||qr(n)?!1:Zt(n).position==="fixed"||kp(n,e)}function $R(t,e){const n=e.get(t);if(n)return n;let r=vp(t,[]).filter(c=>Yt(c)&&Yr(c)!=="body"),s=null;const o=Zt(t).position==="fixed";let i=o?Mn(t):t;for(;Yt(i)&&!qr(i);){const c=Zt(i),a=Ul(i);!a&&c.position==="fixed"&&(s=null),(o?!a&&!s:!a&&c.position==="static"&&!!s&&jR.has(s.position)||to(i)&&!a&&kp(t,i))?r=r.filter(f=>f!==i):s=c,i=Mn(i)}return e.set(t,r),r}function BR(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const i=[...n==="clippingAncestors"?Hi(e)?[]:$R(e,this._c):[].concat(n),r],c=i[0],a=i.reduce((u,f)=>{const h=kf(e,f,s);return u.top=br(h.top,u.top),u.right=pc(h.right,u.right),u.bottom=pc(h.bottom,u.bottom),u.left=br(h.left,u.left),u},kf(e,c,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function UR(t){const{width:e,height:n}=bp(t);return{width:e,height:n}}function qR(t,e,n){const r=cn(e),s=Sn(e),o=n==="fixed",i=Ps(t,!0,o,e);let c={scrollLeft:0,scrollTop:0};const a=sn(0);function u(){a.x=Ki(s)}if(r||!r&&!o)if((Yr(e)!=="body"||to(s))&&(c=Wi(e)),r){const p=Ps(e,!0,o,e);a.x=p.x+e.clientLeft,a.y=p.y+e.clientTop}else s&&u();o&&!r&&s&&u();const f=s&&!r&&!o?xp(s,c):sn(0),h=i.left+c.scrollLeft-a.x-f.x,d=i.top+c.scrollTop-a.y-f.y;return{x:h,y:d,width:i.width,height:i.height}}function ba(t){return Zt(t).position==="static"}function Sf(t,e){if(!cn(t)||Zt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Sn(t)===n&&(n=n.ownerDocument.body),n}function Sp(t,e){const n=It(t);if(Hi(t))return n;if(!cn(t)){let s=Mn(t);for(;s&&!qr(s);){if(Yt(s)&&!ba(s))return s;s=Mn(s)}return n}let r=Sf(t,e);for(;r&&wR(r)&&ba(r);)r=Sf(r,e);return r&&qr(r)&&ba(r)&&!Ul(r)?n:r||ER(t)||n}const zR=async function(t){const e=this.getOffsetParent||Sp,n=this.getDimensions,r=await n(t.floating);return{reference:qR(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function VR(t){return Zt(t).direction==="rtl"}const HR={convertOffsetParentRelativeRectToViewportRelativeRect:NR,getDocumentElement:Sn,getClippingRect:BR,getOffsetParent:Sp,getElementRects:zR,getClientRects:PR,getDimensions:UR,getScale:_r,isElement:Yt,isRTL:VR},WR=yR,KR=xR,GR=vR,JR=(t,e,n)=>{const r=new Map,s={platform:HR,...n},o={...s.platform,_c:r};return mR(t,e,{...s,platform:o})};var YR=C('<div class="floating-tooltip svelte-1nvlyh9"> </div>'),ZR=C('<div role="button" tabindex="-1"><!></div> <!>',1);function QR(t,e){Mt(e,!0);let n=Ae(e,"class",3,""),r=De(!1),s=De(null),o=De(0),i=De(0);const c=async()=>{if(!l(s))return;const v={getBoundingClientRect:()=>({width:0,height:0,x:l(o),y:l(i),top:l(i),left:l(o),right:l(o),bottom:l(i)})},{x:_,y:O}=await JR(v,l(s),{placement:"bottom-start",middleware:[WR(8),GR(),KR({padding:8})]});l(s).style.left=`${_}px`,l(s).style.top=`${O}px`},a=v=>{J(o,v.clientX,!0),J(i,v.clientY,!0),l(r)&&c()},u=v=>{J(o,v.clientX,!0),J(i,v.clientY,!0),J(r,!0),requestAnimationFrame(c)},f=()=>{J(r,!1)};var h=ZR(),d=Te(h),p=b(d);$f(p,()=>e.children),m(d);var g=T(d,2);{var x=v=>{var _=YR(),O=b(_,!0);m(_),ai(_,P=>J(s,P),()=>l(s)),B(()=>N(O,e.content)),y(v,_)};q(g,v=>{l(r)&&v(x)})}B(()=>Ie(d,1,yr(n()),"svelte-1nvlyh9")),vn("mouseenter",d,u),vn("mouseleave",d,f),ve("mousemove",d,a),y(t,h),Nt()}$t(["mousemove"]);var XR=C(' <span class="text-gh-text-secondary"> </span>',1),eI=C('<span><span class="text-gh-accent"> </span><!></span>'),tI=C("<span> </span>");function wp(t,e){Mt(e,!0);let n=Ae(e,"class",3,"");const r=H(()=>()=>{if(!e.title.startsWith("/"))return null;const u=e.title.indexOf(" ");return u===-1?{command:e.title,args:""}:{command:e.title.slice(0,u),args:e.title.slice(u+1)}});var s=Fe(),o=Te(s);{var i=u=>{var f=eI(),h=b(f),d=b(h,!0);m(h);var p=T(h);{var g=v=>{var _=XR(),O=Te(_,!0);O.nodeValue=" ";var P=T(O),R=b(P,!0);m(P),B(D=>N(R,D),[()=>l(r)().args]),y(v,_)},x=H(()=>l(r)().args);q(p,v=>{l(x)&&v(g)})}m(f),B(v=>{Ie(f,1,yr(n())),N(d,v)},[()=>l(r)().command]),y(u,f)},c=H(()=>l(r)()),a=u=>{var f=tI(),h=b(f,!0);m(f),B(()=>{Ie(f,1,yr(n())),N(h,e.title)}),y(u,f)};q(o,u=>{l(c)?u(i):u(a,-1)})}y(t,s),Nt()}var nI=C("<option> </option>"),rI=C('<li class="py-2 px-8 text-gh-text-secondary text-sm">Loading...</li>'),sI=C('<button class="flex-shrink-0 w-5 h-8 flex items-center justify-center bg-transparent border-none cursor-pointer text-gh-text-secondary text-xs ml-1 z-10 relative"> </button>'),oI=C('<span class="w-5 ml-1"></span>'),iI=C('<span class="flex items-center gap-0.5"><span> </span><span> </span></span>'),aI=C('<span class="flex items-center gap-0.5"><span> </span><span> </span></span>'),cI=C('<button class="w-full py-2 pr-2 bg-transparent border-none text-gh-text cursor-pointer text-left flex items-center gap-2 text-sm"><span><!></span> <span class="flex-shrink-0 flex items-center gap-2 text-xs text-gh-text-secondary"><span class="flex items-center gap-0.5"><span> </span><span> </span></span> <!> <!></span></button>'),lI=C('<span class="pl-6 text-[10px] text-gh-text-secondary/70"> </span>'),uI=C('<li><div class="flex items-start gap-2"><span class="flex-shrink-0"> </span> <span class="overflow-hidden text-ellipsis line-clamp-2"> </span></div> <!></li>'),fI=C('<li class="py-1.5 px-4 pl-8 text-gh-text-secondary hover:bg-gh-border-subtle/50 flex items-start gap-2"><span class="flex-shrink-0"> </span> <span> </span></li>'),hI=C('<li class="py-1.5 px-4 pl-8 text-gh-text-secondary hover:bg-gh-border-subtle/50 flex items-start gap-2"><span class="flex-shrink-0"> </span> <span> </span></li>'),dI=C('<li class="py-1.5 px-4 pl-8 text-gh-text-secondary hover:bg-gh-border-subtle/50 flex items-start gap-2"><span class="flex-shrink-0"> </span> <span class="overflow-hidden text-ellipsis whitespace-nowrap"> </span></li>'),gI=C('<ul class="bg-gh-bg-secondary/50 border-t border-gh-border-subtle text-xs"><!> <!> <!> <!></ul>'),pI=C('<li draggable="true"><div class="flex items-center"><!> <!> <div class="absolute right-0 top-0 h-full flex items-center gap-0.5 pr-2 opacity-0 group-hover:opacity-100 transition-opacity bg-gh-bg"><!> <!> <!></div></div> <!></li>'),mI=C('<ul class="bg-gh-bg"><!></ul>'),vI=C('<li class="border-b border-gh-border-subtle"><button><span class="text-xs w-3 text-gh-text-secondary"> </span> <span class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap"> </span> <span class="bg-gh-border px-2 py-0.5 rounded-full text-xs font-normal"> </span></button> <!></li>'),bI=C('<aside class="bg-gh-bg-secondary border border-gh-border rounded-lg overflow-hidden flex flex-col"><div class="p-4 border-b border-gh-border bg-gh-bg"><h2 class="text-base font-semibold mb-2"> </h2> <div class="flex items-center gap-2 text-sm"><span class="text-gh-text-secondary">Sort:</span> <select class="bg-gh-bg-secondary border border-gh-border rounded px-2 py-1 text-sm text-gh-text cursor-pointer hover:border-gh-accent focus:border-gh-accent focus:outline-none"></select> <button class="bg-gh-bg-secondary border border-gh-border rounded px-2 py-1 text-sm cursor-pointer hover:border-gh-accent hover:bg-gh-border-subtle"> </button></div></div> <ul class="overflow-y-auto flex-1"></ul></aside>');function IE(t,e){Mt(e,!0);const n=()=>_m(Ol,"$appConfig",r),[r,s]=bm(),o={summary:"Summary Time",modified:"Modified",created:"Created",updated:"Last Message",messageCount:"Messages",title:"Title"},i=Y=>{const K=Y.target;e.onSortChange?.(K.value,e.sortOrder)},c=()=>{e.onSortChange?.(e.sortField,e.sortOrder==="asc"?"desc":"asc")},a=(Y,K)=>e.projectSessionData.get(Y)?.get(K),u=Y=>{const K=a(Y.projectName,Y.id);return Jg(K?.customTitle,K?.currentSummary,Y.title)},f=Y=>{const K=a(Y.projectName,Y.id),Qe=K?.todos?Yg(K.todos):0;return{agents:K?.agents.length??0,todos:Qe,summaries:K?.summaries.length??0}},h=Y=>{const K=a(Y.projectName,Y.id);return K?q2(K):!1},d=new Map;zn(()=>{e.projectSessionData.size,d.clear()});const p=Y=>{const K=`${Y.projectName}:${Y.id}`;let Qe=d.get(K);if(!Qe){const Ue=a(Y.projectName,Y.id);Qe=z2({id:Y.id,title:Y.title,customTitle:Ue?.customTitle,currentSummary:Ue?.currentSummary,createdAt:Ue?.createdAt,updatedAt:Ue?.updatedAt}),d.set(K,Qe)}return Qe},g=H(()=>eT(e.projects,{currentProjectName:n().currentProjectName,homeDir:n().homeDir}));let x=De(xa(e.selectedSession?new Set([e.selectedSession.id]):new Set));const v=(Y,K)=>{Y.stopPropagation(),l(x).has(K)?l(x).delete(K):l(x).add(K),J(x,new Set(l(x)),!0)};let _=De(null),O=De(null);const P=(Y,K)=>{Y.dataTransfer&&(J(_,K,!0),Y.dataTransfer.effectAllowed="move",Y.dataTransfer.setData("text/plain",JSON.stringify({id:K.id,project:K.projectName})))},R=()=>{J(_,null),J(O,null)},D=(Y,K)=>{!l(_)||!of(l(_).projectName,K)||(Y.preventDefault(),Y.dataTransfer&&(Y.dataTransfer.dropEffect="move"),J(O,K,!0))},w=()=>{J(O,null)},A=(Y,K)=>{Y.preventDefault(),J(O,null),!(!l(_)||!of(l(_).projectName,K))&&(e.onMoveSession?.(l(_),K),J(_,null))};var S=bI(),M=b(S),E=b(M),$=b(E);m(E);var Q=T(E,2),pe=T(b(Q),2);dt(pe,21,()=>Object.entries(o),_t,(Y,K)=>{var Qe=H(()=>jf(l(K),2));let Ue=()=>l(Qe)[0],G=()=>l(Qe)[1];var U=nI(),ie=b(U,!0);m(U);var ee={};B(()=>{N(ie,G()),ee!==(ee=Ue())&&(U.value=(U.__value=Ue())??"")}),y(Y,U)}),m(pe);var W;qf(pe);var ue=T(pe,2),Oe=b(ue,!0);m(ue),m(Q),m(M);var _e=T(M,2);dt(_e,21,()=>l(g),_t,(Y,K)=>{const Qe=H(()=>l(O)===l(K).name);var Ue=vI(),G=b(Ue),U=b(G),ie=b(U,!0);m(U);var ee=T(U,2),$e=b(ee,!0);m(ee);var xe=T(ee,2),ke=b(xe,!0);m(xe),m(G);var Ve=T(G,2);{var qe=Pe=>{var Xe=mI(),gt=b(Xe);{var L=V=>{var re=rI();y(V,re)},j=V=>{var re=Fe(),ae=Te(re);dt(ae,17,()=>e.projectSessions.get(l(K).name)??[],z=>z.id,(z,F)=>{const be=H(()=>e.selectedSession?.id===l(F).id),te=H(()=>l(_)?.id===l(F).id),ne=H(()=>f(l(F))),fe=H(()=>u(l(F))),X=H(()=>a(l(F).projectName,l(F).id)),ot=H(()=>!l(X)?.customTitle&&!l(X)?.currentSummary),He=H(()=>l(x).has(l(F).id)),Pt=H(()=>h(l(F)));var pt=pI(),ut=b(pt),je=b(ut);{var Bt=Re=>{var We=sI(),Qt=b(We,!0);m(We),B(()=>{Me(We,"title",l(He)?"Collapse":"Expand"),N(Qt,l(He)?"▼":"▶")}),ve("click",We,Xt=>v(Xt,l(F).id)),y(Re,We)},Gi=Re=>{var We=oI();y(Re,We)};q(je,Re=>{l(Pt)?Re(Bt):Re(Gi,-1)})}var no=T(je,2);{let Re=H(()=>p(l(F)));QR(no,{get content(){return l(Re)},class:"flex-1 min-w-0 flex",children:(We,Qt)=>{var Xt=cI(),Nn=b(Xt),Zi=b(Nn);wp(Zi,{get title(){return l(fe)}}),m(Nn);var Zr=T(Nn,2),Qr=b(Zr),Xr=b(Qr),Qi=b(Xr,!0);m(Xr);var it=T(Xr),St=b(it,!0);m(it),m(Qr);var Ft=T(Qr,2);{var dn=Ke=>{var vt=iI(),ft=b(vt),gn=b(ft,!0);m(ft);var en=T(ft),es=b(en,!0);m(en),m(vt),B(()=>{N(gn,Fn.agent.emoji),N(es,l(ne).agents)}),y(Ke,vt)};q(Ft,Ke=>{l(ne).agents>0&&Ke(dn)})}var et=T(Ft,2);{var wt=Ke=>{var vt=aI(),ft=b(vt),gn=b(ft,!0);m(ft);var en=T(ft),es=b(en,!0);m(en),m(vt),B(()=>{N(gn,Fn["todos-group"].emoji),N(es,l(ne).todos)}),y(Ke,vt)};q(et,Ke=>{l(ne).todos>0&&Ke(wt)})}m(Zr),m(Xt),B(()=>{Ie(Nn,1,`flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${l(ot)?"italic text-gh-text-secondary":""}`),N(Qi,Fn.session.emoji),N(St,l(F).messageCount)}),ve("click",Xt,()=>e.onSelectSession(l(F))),y(We,Xt)},$$slots:{default:!0}})}var hn=T(no,2),ro=b(hn);{var so=Re=>{vr(Re,{class:"p-1 rounded hover:bg-gh-green/20 text-xs",onclick:We=>e.onResumeSession(We,l(F)),title:"Resume session",children:(We,Qt)=>{hr();var Xt=Rt("▶️");y(We,Xt)},$$slots:{default:!0}})};q(ro,Re=>{e.onResumeSession&&Re(so)})}var oo=T(ro,2);vr(oo,{class:"p-1 rounded hover:bg-gh-border text-xs",onclick:Re=>e.onRenameSession(Re,l(F)),title:"Rename",children:(Re,We)=>{hr();var Qt=Rt("✏️");y(Re,Qt)},$$slots:{default:!0}});var Ji=T(oo,2);vr(Ji,{class:"p-1 rounded hover:bg-gh-red/20 text-xs",onclick:Re=>e.onDeleteSession(Re,l(F)),title:"Delete",children:(Re,We)=>{hr();var Qt=Rt("🗑️");y(Re,Qt)},$$slots:{default:!0}}),m(hn),m(ut);var Yi=T(ut,2);{var wn=Re=>{var We=gI(),Qt=b(We);{var Xt=it=>{var St=Fe(),Ft=Te(St);dt(Ft,17,()=>l(X).summaries,_t,(dn,et,wt)=>{var Ke=uI();Ie(Ke,1,`py-1.5 px-4 pl-8 hover:bg-gh-border-subtle/50 flex flex-col gap-0.5 ${wt===0?"text-gh-text":"text-gh-text-secondary"}`);var vt=b(Ke),ft=b(vt),gn=b(ft,!0);m(ft);var en=T(ft,2),es=b(en,!0);m(en),m(vt);var Tp=T(vt,2);{var Cp=ts=>{var Xi=lI(),Rp=b(Xi,!0);m(Xi),B(Ip=>N(Rp,Ip),[()=>new Date(l(et).timestamp).toLocaleString()]),y(ts,Xi)};q(Tp,ts=>{l(et).timestamp&&ts(Cp)})}m(Ke),B(ts=>{Me(Ke,"title",l(et).summary),N(gn,Fn.summary.emoji),N(es,ts)},[()=>l(et).summary.length>100?l(et).summary.slice(0,97)+"...":l(et).summary]),y(dn,Ke)}),y(it,St)};q(Qt,it=>{l(X)?.summaries&&l(X).summaries.length>0&&it(Xt)})}var Nn=T(Qt,2);{var Zi=it=>{var St=fI(),Ft=b(St),dn=b(Ft,!0);m(Ft);var et=T(Ft,2),wt=b(et);m(et),m(St),B(()=>{N(dn,Fn["todos-group"].emoji),N(wt,`Session Todos (${l(X).todos.sessionTodos.length??""})`)}),y(it,St)};q(Nn,it=>{l(X)?.todos?.sessionTodos&&l(X).todos.sessionTodos.length>0&&it(Zi)})}var Zr=T(Nn,2);{var Qr=it=>{var St=Fe(),Ft=Te(St);dt(Ft,17,()=>l(X).todos.agentTodos,_t,(dn,et)=>{var wt=hI(),Ke=b(wt),vt=b(Ke,!0);m(Ke);var ft=T(Ke,2),gn=b(ft);m(ft),m(wt),B(()=>{N(vt,Fn["todos-group"].emoji),N(gn,`Agent Todos (${l(et).todos.length??""})`)}),y(dn,wt)}),y(it,St)};q(Zr,it=>{l(X)?.todos?.agentTodos&&it(Qr)})}var Xr=T(Zr,2);{var Qi=it=>{var St=Fe(),Ft=Te(St);dt(Ft,17,()=>l(X).agents,_t,(dn,et)=>{var wt=dI(),Ke=b(wt),vt=b(Ke,!0);m(Ke);var ft=T(Ke,2),gn=b(ft);m(ft),m(wt),B(en=>{Me(wt,"title",l(et).name??l(et).id),N(vt,Fn.agent.emoji),N(gn,`${en??""} (${l(et).messageCount??""} msgs)`)},[()=>l(et).name??l(et).id.slice(0,12)+"..."]),y(dn,wt)}),y(it,St)};q(Xr,it=>{l(X)?.agents&&l(X).agents.length>0&&it(Qi)})}m(We),y(Re,We)};q(Yi,Re=>{l(He)&&l(Pt)&&Re(wn)})}m(pt),B(()=>Ie(pt,1,`relative border-t border-gh-border-subtle group ${l(be)?"bg-gh-accent/20 border-l-3 border-l-gh-accent":""} ${l(te)?"opacity-50":""}`)),vn("dragstart",pt,Re=>P(Re,l(F))),vn("dragend",pt,R),y(z,pt)}),y(V,re)};q(gt,V=>{e.loadingProject===l(K).name?V(L):V(j,-1)})}m(Xe),y(Pe,Xe)},mt=H(()=>e.expandedProjects.has(l(K).name));q(Ve,Pe=>{l(mt)&&Pe(qe)})}m(Ue),B((Pe,Xe,gt)=>{Ie(G,1,`w-full py-3 px-4 bg-transparent border-none text-gh-text cursor-pointer text-left flex items-center gap-2 font-medium hover:bg-gh-border-subtle ${Pe??""} ${l(Qe)?"bg-gh-green/20 ring-2 ring-gh-green ring-inset":""}`),N(ie,Xe),Me(ee,"title",l(K).displayName),N($e,gt),N(ke,l(K).sessionCount)},[()=>e.expandedProjects.has(l(K).name)?"bg-gh-accent/10":"",()=>e.expandedProjects.has(l(K).name)?"▼":"▶",()=>XT(l(K).displayName)]),ve("click",G,()=>e.onToggleProject(l(K).name)),vn("dragover",G,Pe=>D(Pe,l(K).name)),vn("dragleave",G,w),vn("drop",G,Pe=>A(Pe,l(K).name)),y(Y,Ue)}),m(_e),m(S),B(()=>{N($,`Projects (${l(g).length??""})`),W!==(W=e.sortField)&&(pe.value=(pe.__value=e.sortField)??"",Mo(pe,e.sortField)),Me(ue,"title",e.sortOrder==="desc"?"Descending (newest first)":"Ascending (oldest first)"),N(Oe,e.sortOrder==="desc"?"↓":"↑")}),ve("change",pe,i),ve("click",ue,c),y(t,S),Nt(),s()}$t(["change","click"]);var _I=C('<button><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path></svg> <span class="tooltip svelte-12kovyu">Last compacted point</span></button>'),yI=C('<div><button><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 11l7-7 7 7M5 19l7-7 7 7"></path></svg> <span class="tooltip svelte-12kovyu">Top</span></button> <button><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path></svg> <span class="tooltip svelte-12kovyu">Previous user message</span></button> <!> <button><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 9l7 7 7-7"></path></svg> <span class="tooltip svelte-12kovyu">Next user message</span></button> <button><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 5l7 7 7-7M5 13l7 7 7-7"></path></svg> <span class="tooltip svelte-12kovyu">Bottom</span></button></div>');function xI(t,e){Mt(e,!0);let n=Ae(e,"class",3,"");const r=S=>{if(S.type!=="user"||!S.uuid)return!1;const M=S.toolUseResult;if(M){if(typeof M=="object")return"answers"in M;if(typeof M=="string"){const $="The user provided the following reason for the rejection:",Q=M.indexOf($);if(Q!==-1)return M.slice(Q+$.length).trim().length>0}return!1}const E=S.message?.content??S.content;if(!E)return!1;if(typeof E=="string")return E.trim().length>0;if(!Array.isArray(E))return!1;for(const $ of E)if($.type==="text"&&$.text?.trim())return!0;return!1};let s=null,o=null;const i=()=>{if(s===null||o!==e.messages){s=[];for(let S=0;S<e.messages.length;S++)r(e.messages[S])&&s.push(S);o=e.messages}return s};let c=-1,a=null;const u=()=>{if(a!==e.messages){c=-1;for(let S=e.messages.length-1;S>=0;S--)if(e.messages[S].isCompactSummary){c=S;break}a=e.messages}},f=()=>(u(),c),h=()=>(u(),c>=0);let d=De(!1);zn(()=>{e.messages.length,J(d,h(),!0)});let p=De(0);const g=()=>{if(!e.scrollContainer)return 0;const S=e.scrollContainer.getBoundingClientRect(),M=e.scrollContainer.querySelectorAll("[data-msg-id]");for(let E=0;E<M.length;E++){const $=M[E];if($.getBoundingClientRect().top>=S.top-50){const pe=$.getAttribute("data-msg-id"),W=e.messages.findIndex(ue=>(ue.uuid??`idx-${e.messages.indexOf(ue)}`)===pe);return W>=0?W:E}}return 0},x=S=>{if(!e.scrollContainer||S<0||S>=e.messages.length)return;const M=e.messages[S].uuid??`idx-${S}`,E=e.scrollContainer.querySelector(`[data-msg-id="${M}"]`);E&&(E.scrollIntoView({behavior:"smooth",block:"start"}),J(p,S,!0))},v=()=>{e.scrollContainer?.scrollTo({top:0,behavior:"smooth"}),J(p,0)},_=()=>{e.scrollContainer&&(e.scrollContainer.scrollTo({top:e.scrollContainer.scrollHeight+1e4,behavior:"smooth"}),J(p,e.messages.length-1))},O=()=>{const S=f();S>=0&&x(S)},P=()=>{const S=g(),M=i();for(let E=M.length-1;E>=0;E--)if(M[E]<S){x(M[E]);return}v()},R=()=>{const S=g(),M=i();for(const E of M)if(E>S){x(E);return}_()};var D=Fe(),w=Te(D);{var A=S=>{var M=yI(),E=b(M);Ie(E,1,"nav-btn p-1.5 text-sm rounded border border-gh-border hover:bg-gh-border-subtle text-gh-text-secondary hover:text-gh-text transition-colors bg-gh-bg svelte-12kovyu");var $=T(E,2);Ie($,1,"nav-btn p-1.5 text-sm rounded border border-gh-border hover:bg-gh-border-subtle text-gh-text-secondary hover:text-gh-text transition-colors bg-gh-bg svelte-12kovyu");var Q=T($,2);{var pe=Oe=>{var _e=_I();Ie(_e,1,"nav-btn p-1.5 text-sm rounded border border-gh-border hover:bg-gh-border-subtle text-gh-text-secondary hover:text-gh-text transition-colors bg-gh-bg svelte-12kovyu"),ve("click",_e,O),y(Oe,_e)};q(Q,Oe=>{l(d)&&Oe(pe)})}var W=T(Q,2);Ie(W,1,"nav-btn p-1.5 text-sm rounded border border-gh-border hover:bg-gh-border-subtle text-gh-text-secondary hover:text-gh-text transition-colors bg-gh-bg svelte-12kovyu");var ue=T(W,2);Ie(ue,1,"nav-btn p-1.5 text-sm rounded border border-gh-border hover:bg-gh-border-subtle text-gh-text-secondary hover:text-gh-text transition-colors bg-gh-bg svelte-12kovyu"),m(M),B(()=>Ie(M,1,`flex gap-0.5 ${n()??""}`,"svelte-12kovyu")),ve("click",E,v),ve("click",$,P),ve("click",W,R),ve("click",ue,_),y(S,M)};q(w,S=>{e.messages.length>0&&S(A)})}y(t,D),Nt()}$t(["click"]);var kI=C('<span class="animate-spin">⟳</span>'),SI=C(`<button class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700
95
- hover:bg-red-900/50 transition-colors flex items-center gap-1"><!> <!></button>`),wI=C('<span class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700"> </span>'),TI=C('<span class="text-gh-text-secondary"> </span>'),CI=C('<li class="text-red-400"><span class="text-gh-text-secondary"> </span> <!></li>'),RI=C('<div class="text-xs text-gh-text-secondary mt-2 pt-1 border-t border-gh-border">Click to auto-repair by linking to previous message</div>'),II=C(`<div class="relative group"><!> <div class="absolute left-0 top-full mt-1 z-50 hidden group-hover:block
96
- bg-gh-bg border border-gh-border rounded-lg shadow-xl p-2 min-w-[250px] max-w-[400px]"><div class="text-xs text-gh-text-secondary mb-1">Chain errors:</div> <ul class="text-xs space-y-1"></ul> <!></div></div>`),EI=C('<span class="animate-spin">⟳</span>'),OI=C(`<button class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700
97
- hover:bg-red-900/50 transition-colors flex items-center gap-1"><!> <!></button>`),AI=C('<span class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700"> </span>'),MI=C('<li class="text-red-400"><span class="text-gh-text-secondary"> </span> </li>'),NI=C('<div class="text-xs text-gh-text-secondary mt-2 pt-1 border-t border-gh-border">Click to remove all progress messages</div>'),PI=C(`<div class="relative group"><!> <div class="absolute left-0 top-full mt-1 z-50 hidden group-hover:block
98
- bg-gh-bg border border-gh-border rounded-lg shadow-xl p-2 min-w-[200px] max-w-[350px]"><div class="text-xs text-gh-text-secondary mb-1">Progress messages (should be removed):</div> <ul class="text-xs space-y-1"></ul> <!></div></div>`),FI=C("<!> <!>",1);function LI(t,e){Mt(e,!0);let n=Ae(e,"chainErrors",19,()=>[]),r=Ae(e,"progressErrors",19,()=>[]),s=Ae(e,"isRepairing",3,!1);const o=H(()=>n().filter(p=>p.type==="broken_chain"||p.type==="orphan_parent")),i=H(()=>l(o).length>0),c=H(()=>r().length>0);var a=FI(),u=Te(a);{var f=p=>{var g=II(),x=b(g);{var v=w=>{var A=SI(),S=b(A);{var M=W=>{var ue=kI();y(W,ue)},E=W=>{var ue=Rt("⚠️");y(W,ue)};q(S,W=>{s()?W(M):W(E,-1)})}var $=T(S),Q=T($);{var pe=W=>{var ue=Rt("- Repair");y(W,ue)};q(Q,W=>{s()||W(pe)})}m(A),B(()=>{A.disabled=s(),N($,` ${l(o).length??""} chain error${l(o).length>1?"s":""} `)}),ve("click",A,function(...W){e.onRepair?.apply(this,W)}),y(w,A)},_=w=>{var A=wI(),S=b(A);m(A),B(()=>N(S,`⚠️ ${l(o).length??""} chain error${l(o).length>1?"s":""}`)),y(w,A)};q(x,w=>{e.onRepair?w(v):w(_,-1)})}var O=T(x,2),P=T(b(O),2);dt(P,21,()=>l(o),_t,(w,A)=>{var S=CI(),M=b(S),E=b(M);m(M);var $=T(M),Q=T($);{var pe=W=>{var ue=TI(),Oe=b(ue);m(ue),B(_e=>N(Oe,`→ ${_e??""}...`),[()=>l(A).parentUuid.slice(0,8)]),y(W,ue)};q(Q,W=>{l(A).type==="orphan_parent"&&l(A).parentUuid&&W(pe)})}m(S),B(()=>{N(E,`L${l(A).line??""}:`),N($,` ${l(A).type==="broken_chain"?"Broken chain (null parentUuid)":"Orphan parent"} `)}),y(w,S)}),m(P);var R=T(P,2);{var D=w=>{var A=RI();y(w,A)};q(R,w=>{e.onRepair&&w(D)})}m(O),m(g),y(p,g)};q(u,p=>{l(i)&&p(f)})}var h=T(u,2);{var d=p=>{var g=PI(),x=b(g);{var v=w=>{var A=OI(),S=b(A);{var M=W=>{var ue=EI();y(W,ue)},E=W=>{var ue=Rt("⚠️");y(W,ue)};q(S,W=>{s()?W(M):W(E,-1)})}var $=T(S),Q=T($);{var pe=W=>{var ue=Rt("- Remove");y(W,ue)};q(Q,W=>{s()||W(pe)})}m(A),B(()=>{A.disabled=s(),N($,` ${r().length??""} progress `)}),ve("click",A,function(...W){e.onRepairProgress?.apply(this,W)}),y(w,A)},_=w=>{var A=AI(),S=b(A);m(A),B(()=>N(S,`⚠️ ${r().length??""} progress`)),y(w,A)};q(x,w=>{e.onRepairProgress?w(v):w(_,-1)})}var O=T(x,2),P=T(b(O),2);dt(P,21,r,_t,(w,A)=>{var S=MI(),M=b(S),E=b(M);m(M);var $=T(M);m(S),B(()=>{N(E,`L${l(A).line??""}:`),N($,` ${(l(A).hookName||l(A).hookEvent||l(A).messageType||"unknown")??""}`)}),y(w,S)}),m(P);var R=T(P,2);{var D=w=>{var A=NI();y(w,A)};q(R,w=>{e.onRepairProgress&&w(D)})}m(O),m(g),y(p,g)};q(h,p=>{l(c)&&p(d)})}y(t,a),Nt()}$t(["click"]);var jI=C('<a class="text-gh-muted hover:text-gh-fg flex-shrink-0" title="Back to project"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path></svg></a>'),DI=C(`<h2 class="text-base font-semibold"><!></h2> <div class="flex items-center gap-2 mt-1"><button class="text-xs text-gh-text-secondary font-mono hover:text-gh-accent
99
- hover:underline cursor-pointer bg-transparent border-none p-0 text-left" title="Open session file in VSCode"> </button> <!></div>`,1),$I=C('<h2 class="text-base font-semibold">Messages</h2>'),BI=C('<button class="p-1.5 rounded text-gh-text-secondary hover:text-gh-fg hover:bg-gh-border text-sm transition-colors" title="Rename session" aria-label="Rename session"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path></svg></button>'),UI=C('<button class="p-1.5 rounded text-gh-text-secondary hover:text-gh-red hover:bg-gh-red/10 text-sm transition-colors" title="Delete session" aria-label="Delete session"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg></button>'),qI=C('<div class="flex items-center gap-0.5"><!> <!></div>'),zI=C('<button>🤖 <span class="hidden md:inline"> </span><span class="md:hidden"> </span> </button>'),VI=C("<button> </button>"),HI=C('<div class="flex border-b border-gh-border bg-gh-bg overflow-x-auto"><div class="flex-1 flex justify-center"><button> </button> <!></div> <!></div>'),WI=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">Select a session to view</div>'),KI=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">No messages</div>'),GI=C('<div class="text-gh-text-secondary text-center py-8">No todos</div>'),JI=C('<li class="flex items-start gap-2 p-3 bg-gh-bg rounded border border-gh-border"><span class="flex-shrink-0"><!></span> <span> </span></li>'),YI=C('<ul class="space-y-2"></ul>'),ZI=C('<div class="p-4"><!></div>'),QI=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">Loading agent messages...</div>'),XI=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">No messages</div>'),eE=C(`<div class="fixed bottom-4 left-1/2 -translate-x-1/2 bg-neutral-500/20 border border-neutral-600
100
- rounded-lg shadow-2xl px-4 py-3 flex items-center gap-4 z-50 backdrop-blur-sm"><span class="text-sm text-white"> </span> <span class="text-xs text-gh-text-secondary tabular-nums"> </span> <button class="px-3 py-1 text-sm font-medium text-gh-accent hover:bg-gh-border-subtle rounded transition-colors">Undo</button> <button class="px-2 py-1 text-sm text-gh-text-secondary hover:text-gh-text hover:bg-gh-border-subtle rounded transition-colors" title="Dismiss (already deleted)">✕</button></div>`),tE=C('<section><div class="p-4 border-b border-gh-border bg-gh-bg flex flex-wrap justify-between items-start gap-2"><!> <div class="flex-1 min-w-[200px]"><!></div> <!> <!></div> <!> <div><!></div> <!></section>');function EE(t,e){Mt(e,!0);let n=Ae(e,"todos",19,()=>[]),r=Ae(e,"agents",19,()=>[]),s=Ae(e,"enableScroll",3,!0),o=Ae(e,"externalScrollContainer",3,null),i=Ae(e,"fullWidth",3,!1);const c=H(()=>Jg(e.customTitle,e.currentSummary,e.session?.title,50)),a=H(()=>tT(e.messages)),u=H(()=>nT(e.messages));let f=De(!1);const h=async()=>{if(!(!e.session||l(f))){J(f,!0);try{const L=await Vm(e.session.projectName,e.session.id);L.success&&L.repairCount>0&&await D()}catch(L){console.error("Failed to repair chain:",L)}finally{J(f,!1)}}},d=async()=>{if(!(!e.session||l(f))){J(f,!0);try{for(const L of l(u).errors){const j=e.messages[L.line-1];j?.uuid&&await Zl(e.session.projectName,e.session.id,j.uuid)}await D()}catch(L){console.error("Failed to remove progress messages:",L)}finally{J(f,!1)}}};let p=De("messages"),g=De(xa([])),x=De(!1),v=De(xa([])),_=De(0),O=De(null),P=Promise.resolve();zn(()=>{if(l(_)<=0)return;const L=setInterval(()=>{J(_,Math.max(0,l(_)-1),!0),l(_)===0&&J(v,[],!0)},1e3);return()=>clearInterval(L)}),zn(()=>{e.session?.id,J(p,"messages"),J(g,[],!0)});const R=H(()=>l(p).startsWith("agent:")?l(p).slice(6):null);zn(()=>{l(R)&&e.session&&(J(x,!0),zm(e.session.projectName,e.session.id,l(R)).then(L=>{J(g,L,!0)}).catch(L=>{console.error("Failed to load agent messages:",L),J(g,[],!0)}).finally(()=>{J(x,!1)}))});const D=async()=>{e.onRefresh&&await e.onRefresh()},w=async()=>{if(l(O)&&clearTimeout(l(O)),!e.session||l(v).length===0)return;await P;const L=[...l(v)].reverse();for(const j of L)try{if(await Um(e.session.projectName,j.sessionId,j.msg,j.index),j.isAgent){const V=[...l(g)];V.splice(j.index,0,j.msg),J(g,V,!0)}else{const V=[...e.messages];V.splice(j.index,0,j.msg),e.onMessagesChange?.(V)}}catch(V){console.error("Failed to restore message:",V)}J(v,[],!0),J(_,0),J(O,null),await D()},A=async(L,j)=>{if(!e.session)return;const V=L.uuid||L.messageId||L.leafUuid;if(!V)return;const re=L.type==="file-history-snapshot"?"file-history-snapshot":L.type==="summary"?"summary":void 0,ae=j&&l(R)?l(R):e.session.id;let z;if(j){if(z=l(g).findIndex(F=>(F.uuid||F.messageId||F.leafUuid)===V),z===-1)return}else if(z=e.messages.findIndex(F=>(F.uuid||F.messageId||F.leafUuid)===V),z===-1)return;if(j){const F=[...l(g)];af(F,V,re),J(g,F,!0)}else{const F=[...e.messages];af(F,V,re),e.onMessagesChange?.(F)}J(v,[...l(v),{msg:L,index:z,isAgent:j,sessionId:ae}],!0),l(O)&&clearTimeout(l(O)),J(_,10),J(O,setTimeout(()=>{J(v,[],!0),J(_,0),J(O,null)},1e4),!0),P=P.then(async()=>{try{await Zl(e.session.projectName,ae,V,re)}catch(F){console.error("Failed to delete message:",F)}}),e.onDeleteMessage?.(L)},S=L=>{A(L,!0)},M=L=>{A(L,!1)},E=async()=>{if(!e.session)return;const L=`~/.claude/projects/${e.session.projectName}/${e.session.id}.jsonl`;try{await Sc(L)}catch(j){console.error("Failed to open file:",j)}};let $=De(void 0);const Q=H(()=>o()??l($));var pe=tE(),W=b(pe),ue=b(W);{var Oe=L=>{var j=jI();B(()=>Me(j,"href",e.backUrl)),y(L,j)};q(ue,L=>{e.backUrl&&L(Oe)})}var _e=T(ue,2),Y=b(_e);{var K=L=>{var j=DI(),V=Te(j),re=b(V);{let te=H(()=>QT(l(c),50));wp(re,{get title(){return l(te)}})}m(V);var ae=T(V,2),z=b(ae),F=b(z,!0);m(z);var be=T(z,2);LI(be,{get chainErrors(){return l(a).errors},get progressErrors(){return l(u).errors},get isRepairing(){return l(f)},onRepair:h,onRepairProgress:d}),m(ae),B(()=>N(F,e.session.id)),ve("click",z,E),y(L,j)},Qe=L=>{var j=$I();y(L,j)};q(Y,L=>{e.session?L(K):L(Qe,-1)})}m(_e);var Ue=T(_e,2);{var G=L=>{xI(L,{get messages(){return e.messages},get scrollContainer(){return l(Q)}})};q(Ue,L=>{l(p)!=="todos"&&L(G)})}var U=T(Ue,2);{var ie=L=>{var j=qI(),V=b(j);{var re=F=>{var be=BI();ve("click",be,function(...te){e.onRenameSession?.apply(this,te)}),y(F,be)};q(V,F=>{e.onRenameSession&&F(re)})}var ae=T(V,2);{var z=F=>{var be=UI();ve("click",be,function(...te){e.onDeleteSession?.apply(this,te)}),y(F,be)};q(ae,F=>{e.onDeleteSession&&F(z)})}m(j),y(L,j)};q(U,L=>{e.session&&(e.onRenameSession||e.onDeleteSession)&&L(ie)})}m(W);var ee=T(W,2);{var $e=L=>{var j=HI(),V=b(j),re=b(V),ae=b(re);m(re);var z=T(re,2);dt(z,17,r,_t,(te,ne)=>{var fe=zI(),X=T(b(fe)),ot=b(X,!0);m(X);var He=T(X),Pt=b(He,!0);m(He);var pt=T(He);m(fe),B(ut=>{Ie(fe,1,`px-4 py-2 text-sm font-medium transition-colors whitespace-nowrap ${l(p)===`agent:${l(ne).id}`?"text-gh-accent border-b-2 border-gh-accent":"text-gh-text-secondary hover:text-gh-text hover:bg-gh-border-subtle"}`),N(ot,l(ne).id),N(Pt,ut),N(pt,` (${l(ne).messageCount??""})`)},[()=>l(ne).id.replace("agent-","")]),ve("click",fe,()=>J(p,`agent:${l(ne).id}`)),y(te,fe)}),m(V);var F=T(V,2);{var be=te=>{var ne=VI(),fe=b(ne);m(ne),B(()=>{Ie(ne,1,`px-4 py-2 text-sm font-medium transition-colors whitespace-nowrap ${l(p)==="todos"?"text-gh-accent border-b-2 border-gh-accent":"text-gh-text-secondary hover:text-gh-text hover:bg-gh-border-subtle"}`),N(fe,`✅ Todos (${n().length??""})`)}),ve("click",ne,()=>J(p,"todos")),y(te,ne)};q(F,te=>{n().length>0&&te(be)})}m(j),B(()=>{Ie(re,1,`px-4 py-2 text-sm font-medium transition-colors whitespace-nowrap ${l(p)==="messages"?"text-gh-accent border-b-2 border-gh-accent":"text-gh-text-secondary hover:text-gh-text hover:bg-gh-border-subtle"}`),N(ae,`💬 Messages (${e.messages.length??""})`)}),ve("click",re,()=>J(p,"messages")),y(L,j)};q(ee,L=>{e.session&&L($e)})}var xe=T(ee,2),ke=b(xe);{var Ve=L=>{var j=WI();y(L,j)},qe=L=>{var j=Fe(),V=Te(j);{var re=z=>{var F=KI();y(z,F)},ae=z=>{pf(z,{get sessionId(){return e.session.id},get messages(){return e.messages},onDeleteMessage:M,get onEditTitle(){return e.onEditTitle},get onSplitSession(){return e.onSplitSession},enableScroll:!1,fullWidth:!0})};q(V,z=>{e.messages.length===0?z(re):z(ae,-1)})}y(L,j)},mt=L=>{var j=ZI(),V=b(j);{var re=z=>{var F=GI();y(z,F)},ae=z=>{var F=YI();dt(F,21,n,_t,(be,te)=>{var ne=JI(),fe=b(ne),X=b(fe);{var ot=je=>{var Bt=Rt("✅");y(je,Bt)},He=je=>{var Bt=Rt("🔄");y(je,Bt)},Pt=je=>{var Bt=Rt("⬜");y(je,Bt)};q(X,je=>{l(te).status==="completed"?je(ot):l(te).status==="in_progress"?je(He,1):je(Pt,-1)})}m(fe);var pt=T(fe,2),ut=b(pt,!0);m(pt),m(ne),B(()=>{Ie(pt,1,yr(l(te).status==="completed"?"text-gh-text-secondary line-through":"")),N(ut,l(te).content)}),y(be,ne)}),m(F),y(z,F)};q(V,z=>{n().length===0?z(re):z(ae,-1)})}m(j),y(L,j)},Pe=L=>{var j=Fe(),V=Te(j);{var re=F=>{var be=QI();y(F,be)},ae=F=>{var be=XI();y(F,be)},z=F=>{pf(F,{get sessionId(){return e.session.id},get messages(){return l(g)},onDeleteMessage:S,enableScroll:!1,fullWidth:!0})};q(V,F=>{l(x)?F(re):l(g).length===0?F(ae,1):F(z,-1)})}y(L,j)};q(ke,L=>{e.session?l(p)==="messages"?L(qe,1):l(p)==="todos"?L(mt,2):l(R)&&L(Pe,3):L(Ve)})}m(xe),ai(xe,L=>J($,L),()=>l($));var Xe=T(xe,2);{var gt=L=>{var j=eE(),V=b(j),re=b(V,!0);m(V);var ae=T(V,2),z=b(ae);m(ae);var F=T(ae,2),be=T(F,2);m(j),B(()=>{N(re,l(v).length===1?"Message deleted":`${l(v).length} messages deleted`),N(z,`${l(_)??""}s`)}),ve("click",F,w),ve("click",be,()=>{l(O)&&clearTimeout(l(O)),J(v,[],!0),J(_,0)}),y(L,j)};q(Xe,L=>{l(v).length>0&&L(gt)})}m(pe),B(()=>{Ie(pe,1,`bg-gh-bg-secondary overflow-hidden flex flex-col h-full ${i()?"":"border border-gh-border rounded-lg"}`),Ie(xe,1,`flex-1 ${s()?"overflow-y-auto":""}`)}),y(t,pe),Nt()}$t(["click"]);var nE=C('<div><span> </span> <button class="text-white/70 hover:text-white transition-colors" title="Dismiss">✕</button></div>');function OE(t,e){Mt(e,!0);let n=Ae(e,"message",15),r=Ae(e,"variant",3,"success"),s=Ae(e,"duration",3,3e3),o=null;const i={success:"bg-gh-green/90",error:"bg-gh-red/90",info:"bg-gh-accent/90",warning:"bg-yellow-600/90"};zn(()=>{n()&&(o&&clearTimeout(o),o=setTimeout(()=>n(null),s()))}),mm(()=>{o&&clearTimeout(o)});var c=Fe(),a=Te(c);{var u=f=>{var h=nE(),d=b(h),p=b(d,!0);m(d);var g=T(d,2);m(h),B(()=>{Ie(h,1,`fixed bottom-4 left-1/2 -translate-x-1/2 text-white px-4 py-2 rounded-lg shadow-lg z-50 flex items-center gap-3 animate-fade-in ${i[r()]??""}`,"svelte-1cpok13"),N(p,n())}),ve("click",g,()=>n(null)),y(f,h)};q(a,f=>{n()&&f(u)})}y(t,c),Nt()}$t(["click"]);export{dt as A,_t as B,CE as C,RE as I,IE as P,EE as S,OE as T,Ol as a,Jg as b,SE as c,af as d,kE as e,Zl as f,fE as g,hE as h,dE as i,uE as j,$f as k,lE as l,yE as m,vE as n,Hf as o,Me as p,aE as q,wE as r,_E as s,Ie as t,gE as u,pE as v,xE as w,bE as x,cE as y,mE as z};