@claude-sessions/web 0.4.3-beta.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/client/_app/immutable/chunks/{BoyMWhtU.js → BD8bPhzS.js} +1 -1
- package/build/client/_app/immutable/chunks/BD8bPhzS.js.br +0 -0
- package/build/client/_app/immutable/chunks/BD8bPhzS.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Bqa8LetD.js +93 -0
- package/build/client/_app/immutable/chunks/Bqa8LetD.js.br +0 -0
- package/build/client/_app/immutable/chunks/Bqa8LetD.js.gz +0 -0
- package/build/client/_app/immutable/chunks/YC0ra1sn.js +1 -0
- package/build/client/_app/immutable/chunks/YC0ra1sn.js.br +0 -0
- package/build/client/_app/immutable/chunks/YC0ra1sn.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.C6QNWdSe.js → app.mxEiaq_i.js} +2 -2
- package/build/client/_app/immutable/entry/app.mxEiaq_i.js.br +0 -0
- package/build/client/_app/immutable/entry/app.mxEiaq_i.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.DluUgWU4.js +1 -0
- package/build/client/_app/immutable/entry/start.DluUgWU4.js.br +2 -0
- package/build/client/_app/immutable/entry/start.DluUgWU4.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{0.CdzU0U_T.js → 0.kClcR1E1.js} +1 -1
- package/build/client/_app/immutable/nodes/0.kClcR1E1.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.kClcR1E1.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{1.CiSjgLcJ.js → 1.DJyyQX5X.js} +1 -1
- package/build/client/_app/immutable/nodes/1.DJyyQX5X.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.DJyyQX5X.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.BCmqimtm.js → 2.BmK5jcJA.js} +1 -1
- package/build/client/_app/immutable/nodes/2.BmK5jcJA.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.BmK5jcJA.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{3.DfBVw2a7.js → 3.i6zo7SKu.js} +1 -1
- package/build/client/_app/immutable/nodes/3.i6zo7SKu.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.i6zo7SKu.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/server/chunks/{0-Ry9ZGsia.js → 0-B0--GvEh.js} +3 -3
- package/build/server/chunks/{0-Ry9ZGsia.js.map → 0-B0--GvEh.js.map} +1 -1
- package/build/server/chunks/{1-CHv4nfaK.js → 1-CwbA0HCh.js} +2 -2
- package/build/server/chunks/{1-CHv4nfaK.js.map → 1-CwbA0HCh.js.map} +1 -1
- package/build/server/chunks/{2-JM3QevKG.js → 2-DmZZoG0F.js} +3 -3
- package/build/server/chunks/{2-JM3QevKG.js.map → 2-DmZZoG0F.js.map} +1 -1
- package/build/server/chunks/{3-5eBXBic1.js → 3-z6nvxRIj.js} +3 -3
- package/build/server/chunks/{3-5eBXBic1.js.map → 3-z6nvxRIj.js.map} +1 -1
- package/build/server/chunks/{InputModal-CbpiMXy3.js → InputModal-Dqb_HPxu.js} +2 -2
- package/build/server/chunks/{InputModal-CbpiMXy3.js.map → InputModal-Dqb_HPxu.js.map} +1 -1
- package/build/server/chunks/{Toast-pmKOv8z-.js → Toast-BuxKn4OL.js} +3 -3
- package/build/server/chunks/{Toast-pmKOv8z-.js.map → Toast-BuxKn4OL.js.map} +1 -1
- package/build/server/chunks/{_layout.svelte-COzxmxGG.js → _layout.svelte-CO9il4J1.js} +4 -4
- package/build/server/chunks/{_layout.svelte-COzxmxGG.js.map → _layout.svelte-CO9il4J1.js.map} +1 -1
- package/build/server/chunks/{_page.svelte-BHR7zfE6.js → _page.svelte-BURcBZhI.js} +60 -9
- package/build/server/chunks/_page.svelte-BURcBZhI.js.map +1 -0
- package/build/server/chunks/{_page.svelte-BF108V74.js → _page.svelte-KMNOBaI5.js} +5 -5
- package/build/server/chunks/{_page.svelte-BF108V74.js.map → _page.svelte-KMNOBaI5.js.map} +1 -1
- package/build/server/chunks/{_server.ts-LvR6hcmL.js → _server.ts--WKYHexr.js} +2 -2
- package/build/server/chunks/{_server.ts-LvR6hcmL.js.map → _server.ts--WKYHexr.js.map} +1 -1
- package/build/server/chunks/{_server.ts-Cg8je7HW.js → _server.ts-BMvMFfTo.js} +3 -3
- package/build/server/chunks/_server.ts-BMvMFfTo.js.map +1 -0
- package/build/server/chunks/{_server.ts-B77l9WP7.js → _server.ts-BZ9qxvjI.js} +2 -2
- package/build/server/chunks/{_server.ts-B77l9WP7.js.map → _server.ts-BZ9qxvjI.js.map} +1 -1
- package/build/server/chunks/{_server.ts-AWtzEUzT.js → _server.ts-BgYGjL60.js} +2 -2
- package/build/server/chunks/{_server.ts-AWtzEUzT.js.map → _server.ts-BgYGjL60.js.map} +1 -1
- package/build/server/chunks/{_server.ts-KwQ8Un-9.js → _server.ts-BqSzMQFJ.js} +2 -2
- package/build/server/chunks/{_server.ts-KwQ8Un-9.js.map → _server.ts-BqSzMQFJ.js.map} +1 -1
- package/build/server/chunks/{_server.ts-CAiKbsWv.js → _server.ts-Bz_U7WSA.js} +2 -2
- package/build/server/chunks/{_server.ts-CAiKbsWv.js.map → _server.ts-Bz_U7WSA.js.map} +1 -1
- package/build/server/chunks/{_server.ts-DEkoGqtY.js → _server.ts-BzbbjRy6.js} +2 -2
- package/build/server/chunks/{_server.ts-DEkoGqtY.js.map → _server.ts-BzbbjRy6.js.map} +1 -1
- package/build/server/chunks/{_server.ts-yZS2qQ2R.js → _server.ts-C549UKsT.js} +2 -2
- package/build/server/chunks/{_server.ts-yZS2qQ2R.js.map → _server.ts-C549UKsT.js.map} +1 -1
- package/build/server/chunks/{_server.ts-D9uHkuTT.js → _server.ts-C8FzjlS8.js} +2 -2
- package/build/server/chunks/{_server.ts-D9uHkuTT.js.map → _server.ts-C8FzjlS8.js.map} +1 -1
- package/build/server/chunks/{_server.ts-D9yStkjt.js → _server.ts-C8oHPILh.js} +2 -2
- package/build/server/chunks/{_server.ts-D9yStkjt.js.map → _server.ts-C8oHPILh.js.map} +1 -1
- package/build/server/chunks/{_server.ts-Dy2tuoXi.js → _server.ts-CcVTjWAT.js} +2 -2
- package/build/server/chunks/{_server.ts-Dy2tuoXi.js.map → _server.ts-CcVTjWAT.js.map} +1 -1
- package/build/server/chunks/{_server.ts-Cb5P-FeJ.js → _server.ts-Ceoc-TLt.js} +3 -3
- package/build/server/chunks/{_server.ts-Cb5P-FeJ.js.map → _server.ts-Ceoc-TLt.js.map} +1 -1
- package/build/server/chunks/{_server.ts-_gq66mYS.js → _server.ts-CkTWQ_px.js} +2 -2
- package/build/server/chunks/{_server.ts-_gq66mYS.js.map → _server.ts-CkTWQ_px.js.map} +1 -1
- package/build/server/chunks/{_server.ts-CwCXHiDk.js → _server.ts-D470eKHA.js} +3 -3
- package/build/server/chunks/{_server.ts-CwCXHiDk.js.map → _server.ts-D470eKHA.js.map} +1 -1
- package/build/server/chunks/{_server.ts-Biv_eRMr.js → _server.ts-Dx9cf97O.js} +2 -2
- package/build/server/chunks/{_server.ts-Biv_eRMr.js.map → _server.ts-Dx9cf97O.js.map} +1 -1
- package/build/server/chunks/{_server.ts-BrPvXBu1.js → _server.ts-j3BwZNd1.js} +2 -2
- package/build/server/chunks/{_server.ts-BrPvXBu1.js.map → _server.ts-j3BwZNd1.js.map} +1 -1
- package/build/server/chunks/{index-BEaiIYry.js → index-D4ev3Ona.js} +2 -2
- package/build/server/chunks/{index-BEaiIYry.js.map → index-D4ev3Ona.js.map} +1 -1
- package/build/server/chunks/{index3-CdoX5rbd.js → index3-D3k_xGNn.js} +40 -25
- package/build/server/chunks/index3-D3k_xGNn.js.map +1 -0
- package/build/server/chunks/{session-DEugS4qN.js → session-dCkSvtk_.js} +2 -2
- package/build/server/chunks/{session-DEugS4qN.js.map → session-dCkSvtk_.js.map} +1 -1
- package/build/server/index.js +2 -2
- package/build/server/index.js.map +1 -1
- package/build/server/manifest.js +21 -21
- package/build/server/manifest.js.map +1 -1
- package/package.json +2 -2
- package/build/client/_app/immutable/chunks/B6WQA_fV.js +0 -93
- package/build/client/_app/immutable/chunks/B6WQA_fV.js.br +0 -0
- package/build/client/_app/immutable/chunks/B6WQA_fV.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BoyMWhtU.js.br +0 -0
- package/build/client/_app/immutable/chunks/BoyMWhtU.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DjgxI-jO.js +0 -1
- package/build/client/_app/immutable/chunks/DjgxI-jO.js.br +0 -0
- package/build/client/_app/immutable/chunks/DjgxI-jO.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.C6QNWdSe.js.br +0 -0
- package/build/client/_app/immutable/entry/app.C6QNWdSe.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.CXvUo7_K.js +0 -1
- package/build/client/_app/immutable/entry/start.CXvUo7_K.js.br +0 -2
- package/build/client/_app/immutable/entry/start.CXvUo7_K.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.CdzU0U_T.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.CdzU0U_T.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.CiSjgLcJ.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.CiSjgLcJ.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.BCmqimtm.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.BCmqimtm.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.DfBVw2a7.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.DfBVw2a7.js.gz +0 -0
- package/build/server/chunks/_page.svelte-BHR7zfE6.js.map +0 -1
- package/build/server/chunks/_server.ts-Cg8je7HW.js.map +0 -1
- package/build/server/chunks/index3-CdoX5rbd.js.map +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import{i as Pg,b as jg,d as lr,n as Lg,g as $g,c as te,a as _,f as C,s as M,e as Kr,t as jt}from"./DOXVKi87.js";import{aR as Qa,aS as Hu,aT as Dg,l as Xe,P as Ku,aU as Ug,k as Xa,aV as yl,S as Wu,v as go,T as ra,q as $r,V as ec,av as ms,ai as Io,Y as na,aW as Bg,ak as qg,aX as zg,aY as Vg,af as Hg,aZ as Ju,j as Li,m as Kg,g as l,a7 as Wg,R as Jg,w as ro,C as Gg,aP as Yg,I as bn,a_ as Cr,M as ws,O as Zg,aN as tc,a$ as Qg,b0 as Xg,b1 as ep,J as Gu,L as Yu,b2 as $i,n as tp,aM as rp,K as To,b3 as Zu,b4 as np,Q as sp,b5 as Qu,x as Xu,a0 as op,b6 as ip,b7 as ap,b8 as cp,b9 as lp,ba as up,bb as fp,bc as hp,bd as dp,be as gp,bf as ef,ag as tf,A as rf,U as nf,bg as pp,bh as mp,bi as vp,_ as _p,p as Yt,f as G,c as Zt,d as m,r as g,e as w,t as U,s as Qe,a as Ro,u as xn,b as K,h as V,aw as kn,bj as sf,bk as bp}from"./YXuXYbOb.js";import{B as of,p as Me,i as N,b as rc,r as yp,a as xp,s as kp}from"./B-Z9hXPk.js";const Sp=[];function wp(t,e=!1,r=!1){return po(t,new Map,"",Sp,null,r)}function po(t,e,r,n,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(Qa(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]=po(u,e,r,n,null,o))}return c}if(Hu(t)===Dg){c={},e.set(t,c),s!==null&&e.set(s,c);for(var f in t)c[f]=po(t[f],e,r,n,null,o);return c}if(t instanceof Date)return structuredClone(t);if(typeof t.toJSON=="function"&&!o)return po(t.toJSON(),e,r,n,t)}if(t instanceof EventTarget)return t;try{return structuredClone(t)}catch{return t}}const xl=0,Di=1;function sa(t,e,r,n,s){Xe&&Ku();var o=Ug(),i=Ju,c=o?Io(i):na(i,!1,!1),a=o?Io(i):na(i,!1,!1),u=new of(t);Xa(()=>{var f=e(),d=!1;let h=Xe&&yl(f)===(t.data===Wu);if(h&&(go(ra()),$r(!1)),yl(f)){var v=Bg(),p=!1;const S=b=>{if(!d){p=!0,v(!1),qg.ensure(),Xe&&$r(!1);try{b()}finally{zg(),Vg||Hg()}}};f.then(b=>{S(()=>{ms(c,b),u.ensure(Di,n&&(k=>n(k,c)))})},b=>{S(()=>{if(ms(a,b),u.ensure(Di,s&&(k=>s(k,a))),!s)throw a.v})}),Xe?u.ensure(xl,r):ec(()=>{p||S(()=>{u.ensure(xl,r)})})}else ms(c,f),u.ensure(Di,n&&(S=>n(S,c)));return h&&$r(!0),()=>{d=!0}})}function wt(t,e){return e}function Ip(t,e,r){for(var n=[],s=e.length,o,i=e.length,c=0;c<s;c++){let d=e[c];Yu(d,()=>{if(o){if(o.pending.delete(d),o.done.add(d),o.pending.size===0){var h=t.outrogroups;oa(tc(o.done)),h.delete(o),h.size===0&&(t.outrogroups=null)}}else i-=1},!1)}if(i===0){var a=n.length===0&&r!==null;if(a){var u=r,f=u.parentNode;rp(f),f.append(u),t.items.clear()}oa(e,!a)}else o={pending:new Set(e),done:new Set},(t.outrogroups??=new Set).add(o)}function oa(t,e=!0){for(var r=0;r<t.length;r++)To(t[r],e)}var kl;function bt(t,e,r,n,s,o=null){var i=t,c=new Map,a=(e&Zu)!==0;if(a){var u=t;i=Xe?go(Kg(u)):u.appendChild(Li())}Xe&&Ku();var f=null,d=Wg(()=>{var k=r();return Qa(k)?k:k==null?[]:tc(k)}),h,v=!0;function p(){b.fallback=f,Tp(b,h,i,e,n),f!==null&&(h.length===0?(f.f&Cr)===0?Gu(f):(f.f^=Cr,ds(f,null,i)):Yu(f,()=>{f=null}))}var S=Xa(()=>{h=l(d);var k=h.length;let F=!1;if(Xe){var B=Jg(i)===Wu;B!==(k===0)&&(i=ra(),go(i),$r(!1),F=!0)}for(var R=new Set,L=bn,O=Zg(),I=0;I<k;I+=1){Xe&&ro.nodeType===Gg&&ro.data===Yg&&(i=ro,F=!0,$r(!1));var x=h[I],A=n(x,I),E=v?null:c.get(A);E?(E.v&&ms(E.v,x),E.i&&ms(E.i,I),O&&L.skipped_effects.delete(E.e)):(E=Rp(c,v?i:kl??=Li(),x,A,I,s,e,r),v||(E.e.f|=Cr),c.set(A,E)),R.add(A)}if(k===0&&o&&!f&&(v?f=ws(()=>o(i)):(f=ws(()=>o(kl??=Li())),f.f|=Cr)),Xe&&k>0&&go(ra()),!v)if(O){for(const[D,oe]of c)R.has(D)||L.skipped_effects.add(oe.e);L.oncommit(p),L.ondiscard(()=>{})}else p();F&&$r(!0),l(d)}),b={effect:S,items:c,outrogroups:null,fallback:f};v=!1,Xe&&(i=ro)}function Tp(t,e,r,n,s){var o=(n&np)!==0,i=e.length,c=t.items,a=t.effect.first,u,f=null,d,h=[],v=[],p,S,b,k;if(o)for(k=0;k<i;k+=1)p=e[k],S=s(p,k),b=c.get(S).e,(b.f&Cr)===0&&(b.nodes?.a?.measure(),(d??=new Set).add(b));for(k=0;k<i;k+=1){if(p=e[k],S=s(p,k),b=c.get(S).e,t.outrogroups!==null)for(const E of t.outrogroups)E.pending.delete(b),E.done.delete(b);if((b.f&Cr)!==0)if(b.f^=Cr,b===a)ds(b,null,r);else{var F=f?f.next:a;b===t.effect.last&&(t.effect.last=b.prev),b.prev&&(b.prev.next=b.next),b.next&&(b.next.prev=b.prev),Fr(t,f,b),Fr(t,b,F),ds(b,F,r),f=b,h=[],v=[],a=f.next;continue}if((b.f&$i)!==0&&(Gu(b),o&&(b.nodes?.a?.unfix(),(d??=new Set).delete(b))),b!==a){if(u!==void 0&&u.has(b)){if(h.length<v.length){var B=v[0],R;f=B.prev;var L=h[0],O=h[h.length-1];for(R=0;R<h.length;R+=1)ds(h[R],B,r);for(R=0;R<v.length;R+=1)u.delete(v[R]);Fr(t,L.prev,O.next),Fr(t,f,L),Fr(t,O,B),a=B,f=O,k-=1,h=[],v=[]}else u.delete(b),ds(b,a,r),Fr(t,b.prev,b.next),Fr(t,b,f===null?t.effect.first:f.next),Fr(t,f,b),f=b;continue}for(h=[],v=[];a!==null&&a!==b;)(u??=new Set).add(a),v.push(a),a=a.next;if(a===null)continue}(b.f&Cr)===0&&h.push(b),f=b,a=b.next}if(t.outrogroups!==null){for(const E of t.outrogroups)E.pending.size===0&&(oa(tc(E.done)),t.outrogroups?.delete(E));t.outrogroups.size===0&&(t.outrogroups=null)}if(a!==null||u!==void 0){var I=[];if(u!==void 0)for(b of u)(b.f&$i)===0&&I.push(b);for(;a!==null;)(a.f&$i)===0&&a!==t.fallback&&I.push(a),a=a.next;var x=I.length;if(x>0){var A=(n&Zu)!==0&&i===0?r:null;if(o){for(k=0;k<x;k+=1)I[k].nodes?.a?.measure();for(k=0;k<x;k+=1)I[k].nodes?.a?.fix()}Ip(t,I,A)}}o&&ec(()=>{if(d!==void 0)for(b of d)b.nodes?.a?.apply()})}function Rp(t,e,r,n,s,o,i,c){var a=(i&Qg)!==0?(i&Xg)===0?na(r,!1,!1):Io(r):null,u=(i&ep)!==0?Io(s):null;return{v:a,i:u,e:ws(()=>(o(e,a??r,u??s,c),()=>{t.delete(n)}))}}function ds(t,e,r){if(t.nodes)for(var n=t.nodes.start,s=t.nodes.end,o=e&&(e.f&Cr)===0?e.nodes.start:r;n!==null;){var i=tp(n);if(o.before(n),n===s)return;n=i}}function Fr(t,e,r){e===null?t.effect.first=r:e.next=r,r===null?t.effect.last=e:r.prev=e}function Cp(t,e,...r){var n=new of(t);Xa(()=>{const s=e()??null;n.ensure(s,s&&(o=>s(o,...r)))},sp)}function Ep(t,e){var r=void 0,n;Qu(()=>{r!==(r=e())&&(n&&(To(n),n=null),r&&(n=ws(()=>{Xu(()=>r(t))})))})}function af(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(r=af(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function Op(){for(var t,e,r=0,n="",s=arguments.length;r<s;r++)(t=arguments[r])&&(e=af(t))&&(n&&(n+=" "),n+=e);return n}function Is(t){return typeof t=="object"?Op(t):t??""}const Sl=[...`
|
|
2
|
+
\r\f \v\uFEFF`];function Mp(t,e,r){var n=t==null?"":""+t;if(e&&(n=n?n+" "+e:e),r){for(var s in r)if(r[s])n=n?n+" "+s:s;else if(n.length)for(var o=s.length,i=0;(i=n.indexOf(s,i))>=0;){var c=i+o;(i===0||Sl.includes(n[i-1]))&&(c===n.length||Sl.includes(n[c]))?n=(i===0?"":n.substring(0,i))+n.substring(c+1):i=c}}return n===""?null:n}function wl(t,e=!1){var r=e?" !important;":";",n="";for(var s in t){var o=t[s];o!=null&&o!==""&&(n+=" "+s+": "+o+r)}return n}function Ui(t){return t[0]!=="-"||t[1]!=="-"?t.toLowerCase():t}function Ap(t,e){if(e){var r="",n,s;if(Array.isArray(e)?(n=e[0],s=e[1]):n=e,t){t=String(t).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var o=!1,i=0,c=!1,a=[];n&&a.push(...Object.keys(n).map(Ui)),s&&a.push(...Object.keys(s).map(Ui));var u=0,f=-1;const S=t.length;for(var d=0;d<S;d++){var h=t[d];if(c?h==="/"&&t[d-1]==="*"&&(c=!1):o?o===h&&(o=!1):h==="/"&&t[d+1]==="*"?c=!0:h==='"'||h==="'"?o=h:h==="("?i++:h===")"&&i--,!c&&o===!1&&i===0){if(h===":"&&f===-1)f=d;else if(h===";"||d===S-1){if(f!==-1){var v=Ui(t.substring(u,f).trim());if(!a.includes(v)){h!==";"&&d++;var p=t.substring(u,d).trim();r+=" "+p+";"}}u=d+1,f=-1}}}}return n&&(r+=wl(n)),s&&(r+=wl(s,!0)),r=r.trim(),r===""?null:r}return t==null?null:String(t)}function Te(t,e,r,n,s,o){var i=t.__className;if(Xe||i!==r||i===void 0){var c=Mp(r,n,o);(!Xe||c!==t.getAttribute("class"))&&(c==null?t.removeAttribute("class"):e?t.className=c:t.setAttribute("class",c)),t.__className=r}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 Bi(t,e={},r,n){for(var s in r){var o=r[s];e[s]!==o&&(r[s]==null?t.style.removeProperty(s):t.style.setProperty(s,o,n))}}function cf(t,e,r,n){var s=t.__style;if(Xe||s!==e){var o=Ap(e,n);(!Xe||o!==t.getAttribute("style"))&&(o==null?t.removeAttribute("style"):t.style.cssText=o),t.__style=e}else n&&(Array.isArray(n)?(Bi(t,r?.[0],n[0]),Bi(t,r?.[1],n[1],"important")):Bi(t,r,n));return n}function Co(t,e,r=!1){if(t.multiple){if(e==null)return;if(!Qa(e))return ip();for(var n of t.options)n.selected=e.includes(Il(n));return}for(n of t.options){var s=Il(n);if(ap(s,e)){n.selected=!0;return}}(!r||e!==void 0)&&(t.selectedIndex=-1)}function lf(t){var e=new MutationObserver(()=>{Co(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),op(()=>{e.disconnect()})}function Il(t){return"__value"in t?t.__value:t.value}const no=Symbol("class"),ss=Symbol("style"),uf=Symbol("is custom element"),ff=Symbol("is html");function hf(t){if(Xe){var e=!1,r=()=>{if(!e){if(e=!0,t.hasAttribute("value")){var n=t.value;ye(t,"value",null),t.value=n}if(t.hasAttribute("checked")){var s=t.checked;ye(t,"checked",null),t.checked=s}}};t.__on_r=r,ec(r),lp()}}function VT(t,e){var r=nc(t);r.value===(r.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!=="PROGRESS")||(t.value=e??"")}function Np(t,e){e?t.hasAttribute("selected")||t.setAttribute("selected",""):t.removeAttribute("selected")}function ye(t,e,r,n){var s=nc(t);Xe&&(s[e]=t.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&t.nodeName==="LINK")||s[e]!==(s[e]=r)&&(e==="loading"&&(t[up]=r),r==null?t.removeAttribute(e):typeof r!="string"&&df(t).includes(e)?t[e]=r:t.setAttribute(e,r))}function Fp(t,e,r,n,s=!1,o=!1){if(Xe&&s&&t.tagName==="INPUT"){var i=t,c=i.type==="checkbox"?"defaultChecked":"defaultValue";c in r||hf(i)}var a=nc(t),u=a[uf],f=!a[ff];let d=Xe&&u;d&&$r(!1);var h=e||{},v=t.tagName==="OPTION";for(var p in e)p in r||(r[p]=null);r.class?r.class=Is(r.class):r.class=null,r[ss]&&(r.style??=null);var S=df(t);for(const O in r){let I=r[O];if(v&&O==="value"&&I==null){t.value=t.__value="",h[O]=I;continue}if(O==="class"){var b=t.namespaceURI==="http://www.w3.org/1999/xhtml";Te(t,b,I,n,e?.[no],r[no]),h[O]=I,h[no]=r[no];continue}if(O==="style"){cf(t,I,e?.[ss],r[ss]),h[O]=I,h[ss]=r[ss];continue}var k=h[O];if(!(I===k&&!(I===void 0&&t.hasAttribute(O)))){h[O]=I;var F=O[0]+O[1];if(F!=="$$")if(F==="on"){const x={},A="$$"+O;let E=O.slice(2);var B=$g(E);if(Pg(E)&&(E=E.slice(0,-7),x.capture=!0),!B&&k){if(I!=null)continue;t.removeEventListener(E,h[A],x),h[A]=null}if(I!=null)if(B)t[`__${E}`]=I,lr([E]);else{let D=function(oe){h[O].call(this,oe)};h[A]=jg(E,t,D,x)}else B&&(t[`__${E}`]=void 0)}else if(O==="style")ye(t,O,I);else if(O==="autofocus")gp(t,!!I);else if(!u&&(O==="__value"||O==="value"&&I!=null))t.value=t.__value=I;else if(O==="selected"&&v)Np(t,I);else{var R=O;f||(R=Lg(R));var L=R==="defaultValue"||R==="defaultChecked";if(I==null&&!u&&!L)if(a[O]=null,R==="value"||R==="checked"){let x=t;const A=e===void 0;if(R==="value"){let E=x.defaultValue;x.removeAttribute(R),x.defaultValue=E,x.value=x.__value=A?E:null}else{let E=x.defaultChecked;x.removeAttribute(R),x.defaultChecked=E,x.checked=A?E:!1}}else t.removeAttribute(O);else L||S.includes(R)&&(u||typeof I!="string")?(t[R]=I,R in a&&(a[R]=Ju)):typeof I!="function"&&ye(t,R,I)}}}return d&&$r(!0),h}function Pp(t,e,r=[],n=[],s=[],o,i=!1,c=!1){hp(s,r,n,a=>{var u=void 0,f={},d=t.nodeName==="SELECT",h=!1;if(Qu(()=>{var p=e(...a.map(l)),S=Fp(t,u,p,o,i,c);h&&d&&"value"in p&&Co(t,p.value);for(let k of Object.getOwnPropertySymbols(f))p[k]||To(f[k]);for(let k of Object.getOwnPropertySymbols(p)){var b=p[k];k.description===dp&&(!u||b!==u[k])&&(f[k]&&To(f[k]),f[k]=ws(()=>Ep(t,()=>b))),S[k]=b}u=S}),d){var v=t;Xu(()=>{Co(v,u.value,!0),lf(v)})}h=!0})}function nc(t){return t.__attributes??={[uf]:t.nodeName.includes("-"),[ff]:t.namespaceURI===cp}}var Tl=new Map;function df(t){var e=t.getAttribute("is")||t.nodeName,r=Tl.get(e);if(r)return r;Tl.set(e,r=[]);for(var n,s=t,o=Element.prototype;o!==s;){n=fp(s);for(var i in n)n[i].set&&r.push(i);s=Hu(s)}return r}function jp(t,e,r=e){var n=new WeakSet;ef(t,"input",async s=>{var o=s?t.defaultValue:t.value;if(o=qi(t)?zi(o):o,r(o),bn!==null&&n.add(bn),await tf(),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))}}}),(Xe&&t.defaultValue!==t.value||rf(e)==null&&t.value)&&(r(qi(t)?zi(t.value):t.value),bn!==null&&n.add(bn)),nf(()=>{var s=e();if(t===document.activeElement){var o=pp??bn;if(n.has(o))return}qi(t)&&s===zi(t.value)||t.type==="date"&&!s&&!t.value||s!==t.value&&(t.value=s??"")})}function HT(t,e,r=e){ef(t,"change",n=>{var s=n?t.defaultChecked:t.checked;r(s)}),(Xe&&t.defaultChecked!==t.checked||rf(e)==null)&&r(t.checked),nf(()=>{var n=e();t.checked=!!n})}function qi(t){var e=t.type;return e==="number"||e==="range"}function zi(t){return t===""?null:+t}const ei="/api",_r=async t=>{const e=await fetch(`${ei}${t}`);if(!e.ok)throw new Error(await e.text());return e.json()},br=async(t,e)=>{const r=await fetch(`${ei}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(await r.text());return r.json()},gf=async t=>{const e=await fetch(`${ei}${t}`,{method:"DELETE"});if(!e.ok)throw new Error(await e.text());return e.json()},Lp=async(t,e)=>{const r=await fetch(`${ei}${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(await r.text());return r.json()},KT=()=>_r("/projects"),WT=t=>_r(`/sessions?project=${encodeURIComponent(t)}`),JT=(t,e)=>_r(`/session?project=${encodeURIComponent(t)}&id=${encodeURIComponent(e)}`),GT=(t,e)=>gf(`/session?project=${encodeURIComponent(t)}&id=${encodeURIComponent(e)}`),YT=(t,e,r)=>br("/session/rename",{project:t,id:e,title:r}),Rl=(t,e,r,n)=>gf(`/message?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}&uuid=${encodeURIComponent(r)}${n?`&targetType=${n}`:""}`),$p=(t,e,r,n)=>br(`/message?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}`,{message:r,index:n}),ZT=(t,e,r,n)=>Lp(`/message?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}&uuid=${encodeURIComponent(r)}`,{customTitle:n}),QT=t=>_r("/cleanup"),XT=t=>br("/cleanup",t),eR=()=>_r("/version"),tR=()=>br("/shutdown",{}),Dp=(t,e)=>br("/open-file",{sessionId:t,backupFileName:e}),sc=t=>br("/open-file",{filePath:t}),rR=(t,e,r)=>br("/session/split",{project:t,sessionId:e,messageUuid:r}),nR=(t,e,r)=>br("/session/move",{sourceProject:t,sessionId:e,targetProject:r}),ia=async t=>{try{return(await _r(`/file-exists?path=${encodeURIComponent(t)}`)).exists}catch{return!1}},sR=(t,e)=>{const r=new URLSearchParams({q:t});return e?.project&&r.set("project",e.project),e?.searchContent&&r.set("content","true"),_r(`/search?${r}`)},oR=(t,e)=>{const r=new URLSearchParams({project:t});return e?.field&&r.set("sortField",e.field),e?.order&&r.set("sortOrder",e.order),_r(`/project/expand?${r.toString()}`)},iR=(t,e)=>_r(`/session/tree-data?project=${encodeURIComponent(t)}&id=${encodeURIComponent(e)}`),Up=(t,e,r)=>_r(`/agent/messages?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}&agent=${encodeURIComponent(r)}`),aR=(t,e)=>br("/session/resume",{projectName:t,sessionId:e}),Bp=(t,e)=>br(`/session/repair-chain?project=${encodeURIComponent(t)}&session=${encodeURIComponent(e)}`,{}),qp={},pf=Object.freeze(Object.defineProperty({__proto__:null,default:qp},Symbol.toStringTag,{value:"Module"})),zp=t=>typeof t=="function",y=function(t,e){if(typeof t=="function")return function(){return t(arguments)?e.apply(this,arguments):r=>e(r,...arguments)};switch(t){case 0:case 1:throw new RangeError(`Invalid arity ${t}`);case 2:return function(r,n){return arguments.length>=2?e(r,n):function(s){return e(s,r)}};case 3:return function(r,n,s){return arguments.length>=3?e(r,n,s):function(o){return e(o,r,n)}};case 4:return function(r,n,s,o){return arguments.length>=4?e(r,n,s,o):function(i){return e(i,r,n,s)}};case 5:return function(r,n,s,o,i){return arguments.length>=5?e(r,n,s,o,i):function(c){return e(c,r,n,s,o)}};default:return function(){if(arguments.length>=t)return e.apply(this,arguments);const r=arguments;return function(n){return e(n,...r)}}}},De=t=>t,ti=t=>()=>t,Cl=ti(!0),aa=ti(!1),mf=ti(void 0),Vp=mf;function T(t,e,r,n,s,o,i,c,a){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return r(e(t));case 4:return n(r(e(t)));case 5:return s(n(r(e(t))));case 6:return o(s(n(r(e(t)))));case 7:return i(o(s(n(r(e(t))))));case 8:return c(i(o(s(n(r(e(t)))))));case 9:return a(c(i(o(s(n(r(e(t))))))));default:{let u=arguments[0];for(let f=1;f<arguments.length;f++)u=arguments[f](u);return u}}}const oc=t=>(e,r)=>e===r||t(e,r),Hp=y(2,(t,e)=>oc((r,n)=>t(e(r),e(n)))),Kp=t=>oc((e,r)=>{if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(!t(e[n],r[n]))return!1;return!0}),El="effect/GlobalValue";let os;const be=(t,e)=>(os||(globalThis[El]??=new Map,os=globalThis[El]),os.has(t)||os.set(t,e()),os.get(t)),Wp=t=>typeof t=="string",ca=t=>typeof t=="number",Jp=t=>typeof t=="bigint",ri=zp,Gp=t=>typeof t=="object"&&t!==null,ni=t=>Gp(t)||ri(t),le=y(2,(t,e)=>ni(t)&&e in t),vf=y(2,(t,e)=>le(t,"_tag")&&t._tag===e),pn=t=>t==null,_f=t=>typeof t=="string"||le(t,Symbol.iterator),Yp=t=>le(t,"then")&&ri(t.then),si=t=>`BUG: ${t} - please report an issue at https://github.com/Effect-TS/effect/issues`;let bf=class yf{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 yf(this.self)}};const Zp=335903614,Qp=4150755663,Xp=1481765933,em=1284865837,tm=9007199254740992,rm=134217728;class nm{_state;constructor(e,r,n,s){return pn(r)&&pn(e)?(r=Math.random()*4294967295>>>0,e=0):pn(r)&&(r=e,e=0),pn(s)&&pn(n)?(s=this._state?this._state[3]:Qp,n=this._state?this._state[2]:Zp):pn(s)&&(s=n,n=0),this._state=new Int32Array([0,0,n>>>0,((s||0)|1)>>>0]),this._next(),Ol(this._state,this._state[0],this._state[1],e>>>0,r>>>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,r=(this._next()&134217727)*1;return(e*rm+r)/tm}_next(){const e=this._state[0]>>>0,r=this._state[1]>>>0;sm(this._state,e,r,Xp,em),Ol(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let n=e>>>18,s=(r>>>18|e<<14)>>>0;n=(n^e)>>>0,s=(s^r)>>>0;const o=(s>>>27|n<<5)>>>0,i=e>>>27,c=(-i>>>0&31)>>>0;return(o>>>i|o<<c)>>>0}}function sm(t,e,r,n,s){let o=(r>>>16)*(s&65535)>>>0,i=(r&65535)*(s>>>16)>>>0,c=(r&65535)*(s&65535)>>>0,a=(r>>>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(r,n)>>>0,a=a+Math.imul(e,s)>>>0,t[0]=a,t[1]=c}function Ol(t,e,r,n,s){let o=e+n>>>0;const i=r+s>>>0;i>>>0<r>>>0&&(o=o+1|0),t[0]=o,t[1]=i}const la=Symbol.for("effect/Utils/YieldWrap");class Ls{#e;constructor(e){this.#e=e}[la](){return this.#e}}function om(t){if(typeof t=="object"&&t!==null&&la in t)return t[la]();throw new Error(si("yieldWrapGet"))}const Wt=be("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0})),xf={effect_internal_function:t=>t()},im={effect_internal_function:t=>t()},am=xf.effect_internal_function(()=>new Error().stack)?.includes("effect_internal_function")===!0,Ct=am?xf.effect_internal_function:im.effect_internal_function,Vi=be(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),ie=Symbol.for("effect/Hash"),H=t=>{if(Wt.enabled===!0)return 0;switch(typeof t){case"number":return ac(t);case"bigint":return Ke(t.toString(10));case"boolean":return Ke(String(t));case"symbol":return Ke(String(t));case"string":return Ke(t);case"undefined":return Ke("undefined");case"function":case"object":return t===null?Ke("null"):t instanceof Date?Number.isNaN(t.getTime())?Ke("Invalid Date"):H(t.toISOString()):t instanceof URL?H(t.href):cm(t)?t[ie]():ic(t);default:throw new Error(`BUG: unhandled typeof ${typeof t} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},ic=t=>(Vi.has(t)||Vi.set(t,ac(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),Vi.get(t)),me=t=>e=>e*53^t,oi=t=>t&3221225471|t>>>1&1073741824,cm=t=>le(t,ie),ac=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 oi(e)},Ke=t=>{let e=5381,r=t.length;for(;r;)e=e*33^t.charCodeAt(--r);return oi(e)},lm=(t,e)=>{let r=12289;for(let n=0;n<e.length;n++)r^=T(Ke(e[n]),me(H(t[e[n]])));return oi(r)},kf=t=>lm(t,Object.keys(t)),$s=t=>{let e=6151;for(let r=0;r<t.length;r++)e=T(e,me(H(t[r])));return oi(e)},He=function(){if(arguments.length===1){const r=arguments[0];return function(n){return Object.defineProperty(r,ie,{value(){return n},enumerable:!1}),n}}const t=arguments[0],e=arguments[1];return Object.defineProperty(t,ie,{value(){return e},enumerable:!1}),e},se=Symbol.for("effect/Equal");function ae(){return arguments.length===1?t=>Eo(t,arguments[0]):Eo(arguments[0],arguments[1])}function Eo(t,e){if(t===e)return!0;const r=typeof t;if(r!==typeof e)return!1;if(r==="object"||r==="function"){if(t!==null&&e!==null){if(Oo(t)&&Oo(e))return H(t)===H(e)&&t[se](e)?!0:Wt.enabled&&Wt.tester?Wt.tester(t,e):!1;if(t instanceof Date&&e instanceof Date){const n=t.getTime(),s=e.getTime();return n===s||Number.isNaN(n)&&Number.isNaN(s)}else if(t instanceof URL&&e instanceof URL)return t.href===e.href}if(Wt.enabled){if(Array.isArray(t)&&Array.isArray(e))return t.length===e.length&&t.every((n,s)=>Eo(n,e[s]));if(Object.getPrototypeOf(t)===Object.prototype&&Object.getPrototypeOf(t)===Object.prototype){const n=Object.keys(t),s=Object.keys(e);if(n.length===s.length){for(const o of n)if(!(o in e&&Eo(t[o],e[o])))return Wt.tester?Wt.tester(t,e):!1;return!0}}return Wt.tester?Wt.tester(t,e):!1}}return Wt.enabled&&Wt.tester?Wt.tester(t,e):!1}const Oo=t=>le(t,se),cc=()=>ae,We=Symbol.for("nodejs.util.inspect.custom"),ot=t=>{try{if(le(t,"toJSON")&&ri(t.toJSON)&&t.toJSON.length===0)return t.toJSON();if(Array.isArray(t))return t.map(ot)}catch{return{}}return fm(t)},dt=t=>JSON.stringify(t,null,2),Cn=(t,e=2)=>{if(typeof t=="string")return t;try{return typeof t=="object"?Sf(t,e):String(t)}catch{return String(t)}},Sf=(t,e)=>{let r=[];const n=JSON.stringify(t,(s,o)=>typeof o=="object"&&o!==null?r.includes(o)?void 0:r.push(o)&&(Yr.fiberRefs!==void 0&&wf(o)?o[lc](Yr.fiberRefs):o):o,e);return r=void 0,n},lc=Symbol.for("effect/Inspectable/Redactable"),wf=t=>typeof t=="object"&&t!==null&&lc in t,Yr=be("effect/Inspectable/redactableState",()=>({fiberRefs:void 0})),um=(t,e)=>{const r=Yr.fiberRefs;Yr.fiberRefs=t;try{return e()}finally{Yr.fiberRefs=r}},fm=t=>wf(t)&&Yr.fiberRefs!==void 0?t[lc](Yr.fiberRefs):t,ne=(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 r=t;for(let n=0,s=e.length;n<s;n++)r=e[n](r);return r}}},vs="Async",ii="Commit",or="Failure",Hi="OnFailure",Mo="OnSuccess",Ao="OnSuccessAndFailure",ir="Success",If="Sync",hm="Tag",Ds="UpdateRuntimeFlags",No="While",_s="Iterator",Tf="WithRuntime",mo="Yield",uc="RevertFlags";let dm="3.19.14";const fc=()=>dm,gm=Symbol.for("effect/Effect"),pm=Symbol.for("effect/Stream"),mm=Symbol.for("effect/Sink"),vm=Symbol.for("effect/Channel"),En={_R:t=>t,_E:t=>t,_A:t=>t,_V:fc()},_m={_A:t=>t,_In:t=>t,_L:t=>t,_E:t=>t,_R:t=>t},bm={_Env:t=>t,_InErr:t=>t,_InElem:t=>t,_InDone:t=>t,_OutErr:t=>t,_OutElem:t=>t,_OutDone:t=>t},Us={[gm]:En,[pm]:En,[mm]:_m,[vm]:bm,[se](t){return this===t},[ie](){return He(this,ic(this))},[Symbol.iterator](){return new bf(new Ls(this))},pipe(){return ne(this,arguments)}},hc={[ie](){return He(this,kf(this))},[se](t){const e=Object.keys(this),r=Object.keys(t);if(e.length!==r.length)return!1;for(const n of e)if(!(n in t&&ae(this[n],t[n])))return!1;return!0}},Bs={...Us,_op:ii},ym={...Bs,...hc},xm=(function(){function t(){}return t.prototype=Bs,t})(),Rf=Symbol.for("effect/Option"),Cf={...Us,[Rf]:{_A:t=>t},[We](){return this.toJSON()},toString(){return dt(this.toJSON())}},km=Object.assign(Object.create(Cf),{_tag:"Some",_op:"Some",[se](t){return Ef(t)&&Mf(t)&&ae(this.value,t.value)},[ie](){return He(this,me(H(this._tag))(H(this.value)))},toJSON(){return{_id:"Option",_tag:this._tag,value:ot(this.value)}}}),Sm=H("None"),wm=Object.assign(Object.create(Cf),{_tag:"None",_op:"None",[se](t){return Ef(t)&&Of(t)},[ie](){return Sm},toJSON(){return{_id:"Option",_tag:this._tag}}}),Ef=t=>le(t,Rf),Of=t=>t._tag==="None",Mf=t=>t._tag==="Some",Af=Object.create(wm),ua=t=>{const e=Object.create(km);return e.value=t,e},Nf=Symbol.for("effect/Either"),Ff={...Us,[Nf]:{_R:t=>t},[We](){return this.toJSON()},toString(){return dt(this.toJSON())}},Im=Object.assign(Object.create(Ff),{_tag:"Right",_op:"Right",[se](t){return Pf(t)&&Lf(t)&&ae(this.right,t.right)},[ie](){return me(H(this._tag))(H(this.right))},toJSON(){return{_id:"Either",_tag:this._tag,right:ot(this.right)}}}),Tm=Object.assign(Object.create(Ff),{_tag:"Left",_op:"Left",[se](t){return Pf(t)&&jf(t)&&ae(this.left,t.left)},[ie](){return me(H(this._tag))(H(this.left))},toJSON(){return{_id:"Either",_tag:this._tag,left:ot(this.left)}}}),Pf=t=>le(t,Nf),jf=t=>t._tag==="Left",Lf=t=>t._tag==="Right",Rm=t=>{const e=Object.create(Tm);return e.left=t,e},Cm=t=>{const e=Object.create(Im);return e.right=t,e},Er=Cm,On=Rm,gs=jf,so=Lf,Em=y(2,(t,{onLeft:e,onRight:r})=>gs(t)?e(t.left):r(t.right)),Om=Em({onLeft:De,onRight:De}),$f=t=>t.length>0,Df=t=>(e,r)=>e===r?0:t(e,r),Mm=Df((t,e)=>t<e?-1:1),Am=y(2,(t,e)=>Df((r,n)=>t(e(r),e(n)))),Nm=t=>y(2,(e,r)=>t(e,r)===1),re=()=>Af,pe=ua,Mt=Of,mr=Mf,un=y(2,(t,{onNone:e,onSome:r})=>Mt(t)?e():r(t.value)),en=y(2,(t,e)=>Mt(t)?e():t.value),Fm=y(2,(t,e)=>Mt(t)?pe(e()):t),dc=t=>t==null?re():pe(t),Vr=en(mf),Pm=y(2,(t,e)=>Mt(t)?re():pe(e(t.value))),jm=y(2,(t,e)=>Mt(t)?re():e(t.value)),Lm=t=>y(2,(e,r)=>Mt(e)?!1:t(e.value,r)),$m=cc(),Dm=Lm($m),Um=(...t)=>t,gc=t=>new Array(t),Bm=y(2,(t,e)=>{const r=Math.max(1,Math.floor(t)),n=new Array(r);for(let s=0;s<r;s++)n[s]=e(s);return n}),et=t=>Array.isArray(t)?t:Array.from(t),qm=t=>Array.isArray(t)?t:[t],Fo=y(2,(t,e)=>[e,...t]),zm=y(2,(t,e)=>[...t,e]),Uf=y(2,(t,e)=>et(t).concat(et(e))),Vm=t=>t.length===0,Hm=Vm,Km=$f,Ut=$f,Bf=(t,e)=>t<0||t>=e.length,Wm=(t,e)=>Math.floor(Math.min(Math.max(0,t),e.length)),Jm=y(2,(t,e)=>{const r=Math.floor(e);return Bf(r,t)?re():pe(t[r])}),qf=y(2,(t,e)=>{const r=Math.floor(e);if(Bf(r,t))throw new Error(`Index ${r} out of bounds`);return t[r]}),bs=Jm(0),Lt=qf(0),Gm=t=>Ut(t)?pe(zf(t)):re(),zf=t=>t[t.length-1],Mn=t=>t.slice(1),Ym=(t,e)=>{let r=0;for(const n of t){if(!e(n,r))break;r++}return r},Zm=y(2,(t,e)=>tv(t,Ym(t,e))),Qm=y(2,(t,e)=>{const r=et(t);return r.slice(Wm(e,r),r.length)}),Ml=t=>Array.from(t).reverse(),Po=y(2,(t,e)=>{const r=Array.from(t);return r.sort(e),r}),Al=y(2,(t,e)=>Xm(t,e,Um)),Xm=y(3,(t,e,r)=>{const n=et(t),s=et(e);if(Ut(n)&&Ut(s)){const o=[r(Lt(n),Lt(s))],i=Math.min(n.length,s.length);for(let c=1;c<i;c++)o[c]=r(n[c],s[c]);return o}return[]}),ev=cc(),tv=y(2,(t,e)=>{const r=Array.from(t),n=Math.floor(e);return Ut(r)?n>=1?rv(r,n):[[],r]:[r,[]]}),rv=y(2,(t,e)=>{const r=Math.max(1,Math.floor(e));return r>=t.length?[nv(t),[]]:[Fo(t.slice(1,r),Lt(t)),t.slice(r)]}),nv=t=>t.slice(),sv=y(3,(t,e,r)=>{const n=et(t),s=et(e);return Ut(n)?Ut(s)?Hf(r)(Uf(n,s)):n:s}),vo=y(2,(t,e)=>sv(t,e,ev)),An=()=>[],er=t=>[t],Sn=y(2,(t,e)=>t.map(e)),ov=y(2,(t,e)=>{if(Hm(t))return[];const r=[];for(let n=0;n<t.length;n++){const s=e(t[n],n);for(let o=0;o<s.length;o++)r.push(s[o])}return r}),iv=ov(De),Vf=y(3,(t,e,r)=>et(t).reduce((n,s,o)=>r(n,s,o),e)),Nl=(t,e)=>{const r=[];let n=t,s;for(;mr(s=e(n));){const[o,i]=s.value;r.push(o),n=i}return r},pc=Kp,Hf=y(2,(t,e)=>{const r=et(t);if(Ut(r)){const n=[Lt(r)],s=Mn(r);for(const o of s)n.every(i=>!e(o,i))&&n.push(o);return n}return[]}),av=t=>Hf(t,cc()),Gn=y(2,(t,e)=>et(t).join(e)),Ts=Mm,cv=t=>t.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&"),lv=Symbol.for("effect/Context/Tag"),jo=Symbol.for("effect/Context/Reference"),uv="effect/STM",fv=Symbol.for(uv),Kf={...Us,_op:"Tag",[fv]:En,[lv]:{_Service:t=>t,_Identifier:t=>t},toString(){return dt(this.toJSON())},toJSON(){return{_id:"Tag",key:this.key,stack:this.stack}},[We](){return this.toJSON()},of(t){return t},context(t){return Jf(this,t)}},hv={...Kf,[jo]:jo},dv=t=>{const e=Error.stackTraceLimit;Error.stackTraceLimit=2;const r=new Error;Error.stackTraceLimit=e;const n=Object.create(Kf);return Object.defineProperty(n,"stack",{get(){return r.stack}}),n.key=t,n},gv=()=>(t,e)=>{const r=Error.stackTraceLimit;Error.stackTraceLimit=2;const n=new Error;Error.stackTraceLimit=r;function s(){}return Object.setPrototypeOf(s,hv),s.key=t,s.defaultValue=e.defaultValue,Object.defineProperty(s,"stack",{get(){return n.stack}}),s},Wf=Symbol.for("effect/Context"),pv={[Wf]:{_Services:t=>t},[se](t){if(vv(t)&&this.unsafeMap.size===t.unsafeMap.size){for(const e of this.unsafeMap.keys())if(!t.unsafeMap.has(e)||!ae(this.unsafeMap.get(e),t.unsafeMap.get(e)))return!1;return!0}return!1},[ie](){return He(this,ac(this.unsafeMap.size))},pipe(){return ne(this,arguments)},toString(){return dt(this.toJSON())},toJSON(){return{_id:"Context",services:Array.from(this.unsafeMap).map(ot)}},[We](){return this.toJSON()}},Nn=t=>{const e=Object.create(pv);return e.unsafeMap=t,e},mv=t=>{const e=new Error(`Service not found${t.key?`: ${String(t.key)}`:""}`);if(t.stack){const r=t.stack.split(`
|
|
3
|
+
`);if(r.length>2){const n=r[2].match(/at (.*)/);n&&(e.message=e.message+` (defined at ${n[1]})`)}}if(e.stack){const r=e.stack.split(`
|
|
4
|
+
`);r.splice(1,3),e.stack=r.join(`
|
|
5
|
+
`)}return e},vv=t=>le(t,Wf),_v=t=>le(t,jo),bv=Nn(new Map),yv=()=>bv,Jf=(t,e)=>Nn(new Map([[t.key,e]])),xv=y(3,(t,e,r)=>{const n=new Map(t.unsafeMap);return n.set(e.key,r),Nn(n)}),Ki=be("effect/Context/defaultValueCache",()=>new Map),mc=t=>{if(Ki.has(t.key))return Ki.get(t.key);const e=t.defaultValue();return Ki.set(t.key,e),e},kv=(t,e)=>t.unsafeMap.has(e.key)?t.unsafeMap.get(e.key):mc(e),Gf=y(2,(t,e)=>{if(!t.unsafeMap.has(e.key)){if(jo in e)return mc(e);throw mv(e)}return t.unsafeMap.get(e.key)}),Sv=Gf,wv=y(2,(t,e)=>t.unsafeMap.has(e.key)?ua(t.unsafeMap.get(e.key)):_v(e)?ua(mc(e)):Af),Iv=y(2,(t,e)=>{const r=new Map(t.unsafeMap);for(const[n,s]of e.unsafeMap)r.set(n,s);return Nn(r)}),fn=dv,Yf=yv,Tv=Jf,is=xv,Zf=Sv,Qf=Gf,qs=wv,Xf=Iv,eh=gv,th=Symbol.for("effect/Chunk");function Rv(t,e,r,n,s){for(let o=e;o<Math.min(t.length,e+s);o++)r[n+o-e]=t[o];return r}const rh=[],Cv=t=>oc((e,r)=>e.length===r.length&&Zr(e).every((n,s)=>t(n,wn(r,s)))),Ev=Cv(ae),Ov={[th]:{_A:t=>t},toString(){return dt(this.toJSON())},toJSON(){return{_id:"Chunk",values:Zr(this).map(ot)}},[We](){return this.toJSON()},[se](t){return nh(t)&&Ev(this,t)},[ie](){return He(this,$s(Zr(this)))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return rh[Symbol.iterator]();default:return Zr(this)[Symbol.iterator]()}},pipe(){return ne(this,arguments)}},rt=t=>{const e=Object.create(Ov);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=pr,e.right=pr;break}case"ISingleton":{e.length=1,e.depth=0,e.left=pr,e.right=pr;break}case"ISlice":{e.length=t.length,e.depth=t.chunk.depth+1,e.left=pr,e.right=pr;break}}return e},nh=t=>le(t,th),pr=rt({_tag:"IEmpty"}),Ar=()=>pr,Wi=(...t)=>Nv(t),Bt=t=>rt({_tag:"ISingleton",a:t}),sh=t=>nh(t)?t:ai(et(t)),fa=(t,e,r)=>{switch(t.backing._tag){case"IArray":{Rv(t.backing.array,0,e,r,t.length);break}case"IConcat":{fa(t.left,e,r),fa(t.right,e,r+t.left.length);break}case"ISingleton":{e[r]=t.backing.a;break}case"ISlice":{let n=0,s=r;for(;n<t.length;)e[s]=wn(t,n),n+=1,s+=1;break}}},Mv=t=>{switch(t.backing._tag){case"IEmpty":return rh;case"IArray":return t.backing.array;default:{const e=new Array(t.length);return fa(t,e,0),t.backing={_tag:"IArray",array:e},t.left=pr,t.right=pr,t.depth=0,e}}},Zr=Mv,Av=t=>{switch(t.backing._tag){case"IEmpty":case"ISingleton":return t;case"IArray":return rt({_tag:"IArray",array:Ml(t.backing.array)});case"IConcat":return rt({_tag:"IConcat",left:Fn(t.backing.right),right:Fn(t.backing.left)});case"ISlice":return ai(Ml(Zr(t)))}},Fn=Av,ai=t=>t.length===0?Ar():t.length===1?Bt(t[0]):rt({_tag:"IArray",array:t}),Nv=t=>ai(t),wn=y(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?wn(t.left,e):wn(t.right,e-t.left.length);case"ISlice":return wn(t.backing.chunk,e+t.backing.offset)}}),Fv=y(2,(t,e)=>nr(t,Bt(e))),ar=y(2,(t,e)=>nr(Bt(e),t)),ha=y(2,(t,e)=>{if(e<=0)return t;if(e>=t.length)return pr;switch(t.backing._tag){case"ISlice":return rt({_tag:"ISlice",chunk:t.backing.chunk,offset:t.backing.offset+e,length:t.backing.length-e});case"IConcat":return e>t.left.length?ha(t.right,e-t.left.length):rt({_tag:"IConcat",left:ha(t.left,e),right:t.right});default:return rt({_tag:"ISlice",chunk:t,offset:e,length:t.length-e})}}),nr=y(2,(t,e)=>{if(t.backing._tag==="IEmpty")return e;if(e.backing._tag==="IEmpty")return t;const r=e.depth-t.depth;if(Math.abs(r)<=1)return rt({_tag:"IConcat",left:t,right:e});if(r<-1)if(t.left.depth>=t.right.depth){const n=nr(t.right,e);return rt({_tag:"IConcat",left:t.left,right:n})}else{const n=nr(t.right.right,e);if(n.depth===t.depth-3){const s=rt({_tag:"IConcat",left:t.right.left,right:n});return rt({_tag:"IConcat",left:t.left,right:s})}else{const s=rt({_tag:"IConcat",left:t.left,right:t.right.left});return rt({_tag:"IConcat",left:s,right:n})}}else if(e.right.depth>=e.left.depth){const n=nr(t,e.left);return rt({_tag:"IConcat",left:n,right:e.right})}else{const n=nr(t,e.left.left);if(n.depth===e.depth-3){const s=rt({_tag:"IConcat",left:n,right:e.left.right});return rt({_tag:"IConcat",left:s,right:e.right})}else{const s=rt({_tag:"IConcat",left:e.left.right,right:e.right});return rt({_tag:"IConcat",left:n,right:s})}}}),Pv=t=>t.length===0,Pn=t=>t.length>0,oh=t=>wn(t,0),jn=oh,Wr=t=>ha(t,1),da=Symbol.for("effect/Duration"),ih=BigInt(0),Fl=BigInt(24),oo=BigInt(60),ga=BigInt(1e3),Pl=BigInt(1e6),jl=BigInt(1e9),jv=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Nr=t=>{if(ah(t))return t;if(ca(t))return pa(t);if(Jp(t))return Ji(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])?ch:t[0]===1/0||t[1]===1/0?Uv:Ji(BigInt(Math.round(t[0]*1e9))+BigInt(Math.round(t[1])));if(Wp(t)){const e=jv.exec(t);if(e){const[r,n,s]=e,o=Number(n);switch(s){case"nano":case"nanos":return Ji(BigInt(n));case"micro":case"micros":return Bv(BigInt(n));case"milli":case"millis":return pa(o);case"second":case"seconds":return qv(o);case"minute":case"minutes":return zv(o);case"hour":case"hours":return Vv(o);case"day":case"days":return Hv(o);case"week":case"weeks":return Kv(o)}}}throw new Error("Invalid DurationInput")},Ll={_tag:"Millis",millis:0},Lv={_tag:"Infinity"},$v={[da]:da,[ie](){return He(this,kf(this.value))},[se](t){return ah(t)&&Xv(this,t)},toString(){return`Duration(${t_(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:Jv(this)};case"Infinity":return{_id:"Duration",_tag:"Infinity"}}},[We](){return this.toJSON()},pipe(){return ne(this,arguments)}},yr=t=>{const e=Object.create($v);return ca(t)?isNaN(t)||t<=0?e.value=Ll:Number.isFinite(t)?Number.isInteger(t)?e.value={_tag:"Millis",millis:t}:e.value={_tag:"Nanos",nanos:BigInt(Math.round(t*1e6))}:e.value=Lv:t<=ih?e.value=Ll:e.value={_tag:"Nanos",nanos:t},e},ah=t=>le(t,da),Dv=t=>{switch(t.value._tag){case"Millis":return t.value.millis===0;case"Nanos":return t.value.nanos===ih;case"Infinity":return!1}},ch=yr(0),Uv=yr(1/0),Ji=t=>yr(t),Bv=t=>yr(t*ga),pa=t=>yr(t),qv=t=>yr(t*1e3),zv=t=>yr(t*6e4),Vv=t=>yr(t*36e5),Hv=t=>yr(t*864e5),Kv=t=>yr(t*6048e5),ma=t=>Gv(t,{onMillis:e=>e,onNanos:e=>Number(e)/1e6}),Wv=t=>{const e=Nr(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))}},Jv=t=>{const e=Nr(t);switch(e.value._tag){case"Infinity":return[1/0,0];case"Nanos":return[Number(e.value.nanos/jl),Number(e.value.nanos%jl)];case"Millis":return[Math.floor(e.value.millis/1e3),Math.round(e.value.millis%1e3*1e6)]}},Gv=y(2,(t,e)=>{const r=Nr(t);switch(r.value._tag){case"Nanos":return e.onNanos(r.value.nanos);case"Infinity":return e.onMillis(1/0);case"Millis":return e.onMillis(r.value.millis)}}),vc=y(3,(t,e,r)=>{const n=Nr(t),s=Nr(e);if(n.value._tag==="Infinity"||s.value._tag==="Infinity")return r.onMillis(ma(n),ma(s));if(n.value._tag==="Nanos"||s.value._tag==="Nanos"){const o=n.value._tag==="Nanos"?n.value.nanos:BigInt(Math.round(n.value.millis*1e6)),i=s.value._tag==="Nanos"?s.value.nanos:BigInt(Math.round(s.value.millis*1e6));return r.onNanos(o,i)}return r.onMillis(n.value.millis,s.value.millis)}),Yv=(t,e)=>vc(t,e,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n}),Zv=y(2,(t,e)=>vc(t,e,{onMillis:(r,n)=>r<=n,onNanos:(r,n)=>r<=n})),Qv=y(2,(t,e)=>vc(t,e,{onMillis:(r,n)=>r>=n,onNanos:(r,n)=>r>=n})),Xv=y(2,(t,e)=>Yv(Nr(t),Nr(e))),e_=t=>{const e=Nr(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 r=Wv(e),n=r/Pl,s=n/ga,o=s/oo,i=o/oo,c=i/Fl;return{days:Number(c),hours:Number(i%Fl),minutes:Number(o%oo),seconds:Number(s%oo),millis:Number(n%ga),nanos:Number(r%Pl)}},t_=t=>{const e=Nr(t);if(e.value._tag==="Infinity")return"Infinity";if(Dv(e))return"0";const r=e_(e),n=[];return r.days!==0&&n.push(`${r.days}d`),r.hours!==0&&n.push(`${r.hours}h`),r.minutes!==0&&n.push(`${r.minutes}m`),r.seconds!==0&&n.push(`${r.seconds}s`),r.millis!==0&&n.push(`${r.millis}ms`),r.nanos!==0&&n.push(`${r.nanos}ns`),n.join(" ")},tn=5,_c=Math.pow(2,tn),r_=_c-1,n_=_c/2,s_=_c/4;function o_(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 Ln(t,e){return e>>>t&r_}function yn(t){return 1<<t}function lh(t,e){return o_(t&e-1)}const i_=(t,e)=>({value:t,previous:e});function In(t,e,r,n){let s=n;if(!t){const o=n.length;s=new Array(o);for(let i=0;i<o;++i)s[i]=n[i]}return s[e]=r,s}function uh(t,e,r){const n=r.length-1;let s=0,o=0,i=r;if(t)s=o=e;else for(i=new Array(n);s<e;)i[o++]=r[s++];for(++s;s<=n;)i[o++]=r[s++];return t&&(i.length=n),i}function a_(t,e,r,n){const s=n.length;if(t){let a=s;for(;a>=e;)n[a--]=n[a];return n[e]=r,n}let o=0,i=0;const c=new Array(s+1);for(;o<e;)c[i++]=n[o++];for(c[e]=r;o<s;)c[++i]=n[o++];return c}class Dr{_tag="EmptyNode";modify(e,r,n,s,o,i){const c=n(re());return Mt(c)?new Dr:(++i.value,new Qr(e,s,o,c))}}function sr(t){return vf(t,"EmptyNode")}function c_(t){return sr(t)||t._tag==="LeafNode"||t._tag==="CollisionNode"}function ci(t,e){return sr(t)?!1:e===t.edit}class Qr{edit;hash;key;value;_tag="LeafNode";constructor(e,r,n,s){this.edit=e,this.hash=r,this.key=n,this.value=s}modify(e,r,n,s,o,i){if(ae(o,this.key)){const a=n(this.value);return a===this.value?this:Mt(a)?(--i.value,new Dr):ci(this,e)?(this.value=a,this):new Qr(e,s,o,a)}const c=n(re());return Mt(c)?this:(++i.value,fh(e,r,this.hash,this,s,new Qr(e,s,o,c)))}}class bc{edit;hash;children;_tag="CollisionNode";constructor(e,r,n){this.edit=e,this.hash=r,this.children=n}modify(e,r,n,s,o,i){if(s===this.hash){const a=ci(this,e),u=this.updateCollisionList(a,e,this.hash,this.children,n,o,i);return u===this.children?this:u.length>1?new bc(e,this.hash,u):u[0]}const c=n(re());return Mt(c)?this:(++i.value,fh(e,r,this.hash,this,s,new Qr(e,s,o,c)))}updateCollisionList(e,r,n,s,o,i,c){const a=s.length;for(let f=0;f<a;++f){const d=s[f];if("key"in d&&ae(i,d.key)){const h=d.value,v=o(h);return v===h?s:Mt(v)?(--c.value,uh(e,f,s)):In(e,f,new Qr(r,n,i,v),s)}}const u=o(re());return Mt(u)?s:(++c.value,In(e,a,new Qr(r,n,i,u),s))}}class $n{edit;mask;children;_tag="IndexedNode";constructor(e,r,n){this.edit=e,this.mask=r,this.children=n}modify(e,r,n,s,o,i){const c=this.mask,a=this.children,u=Ln(r,s),f=yn(u),d=lh(c,f),h=c&f,v=ci(this,e);if(!h){const F=new Dr().modify(e,r+tn,n,s,o,i);return F?a.length>=n_?u_(e,u,F,c,a):new $n(e,c|f,a_(v,d,F,a)):this}const p=a[d],S=p.modify(e,r+tn,n,s,o,i);if(p===S)return this;let b=c,k;if(sr(S)){if(b&=~f,!b)return new Dr;if(a.length<=2&&c_(a[d^1]))return a[d^1];k=uh(v,d,a)}else k=In(v,d,S,a);return v?(this.mask=b,this.children=k,this):new $n(e,b,k)}}class yc{edit;size;children;_tag="ArrayNode";constructor(e,r,n){this.edit=e,this.size=r,this.children=n}modify(e,r,n,s,o,i){let c=this.size;const a=this.children,u=Ln(r,s),f=a[u],d=(f||new Dr).modify(e,r+tn,n,s,o,i);if(f===d)return this;const h=ci(this,e);let v;if(sr(f)&&!sr(d))++c,v=In(h,u,d,a);else if(!sr(f)&&sr(d)){if(--c,c<=s_)return l_(e,c,u,a);v=In(h,u,new Dr,a)}else v=In(h,u,d,a);return h?(this.size=c,this.children=v,this):new yc(e,c,v)}}function l_(t,e,r,n){const s=new Array(e-1);let o=0,i=0;for(let c=0,a=n.length;c<a;++c)if(c!==r){const u=n[c];u&&!sr(u)&&(s[o++]=u,i|=1<<c)}return new $n(t,i,s)}function u_(t,e,r,n,s){const o=[];let i=n,c=0;for(let a=0;i;++a)i&1&&(o[a]=s[c++]),i>>>=1;return o[e]=r,new yc(t,c+1,o)}function f_(t,e,r,n,s,o){if(r===s)return new bc(t,r,[o,n]);const i=Ln(e,r),c=Ln(e,s);if(i===c)return a=>new $n(t,yn(i)|yn(c),[a]);{const a=i<c?[n,o]:[o,n];return new $n(t,yn(i)|yn(c),a)}}function fh(t,e,r,n,s,o){let i,c=e;for(;;){const a=f_(t,c,r,n,s,o);if(typeof a=="function")i=i_(a,i),c=c+tn;else{let u=a;for(;i!=null;)u=i.value(u),i=i.previous;return u}}}const hh="effect/HashMap",va=Symbol.for(hh),h_={[va]:va,[Symbol.iterator](){return new li(this,(t,e)=>[t,e])},[ie](){let t=H(hh);for(const e of this)t^=T(H(e[0]),me(H(e[1])));return He(this,t)},[se](t){if(p_(t)){if(t._size!==this._size)return!1;for(const e of this){const r=T(t,kc(e[0],H(e[0])));if(Mt(r))return!1;if(!ae(e[1],r.value))return!1}return!0}return!1},toString(){return dt(this.toJSON())},toJSON(){return{_id:"HashMap",values:Array.from(this).map(ot)}},[We](){return this.toJSON()},pipe(){return ne(this,arguments)}},xc=(t,e,r,n)=>{const s=Object.create(h_);return s._editable=t,s._edit=e,s._root=r,s._size=n,s};class li{map;f;v;constructor(e,r){this.map=e,this.f=r,this.v=dh(this.map._root,this.f,void 0)}next(){if(Mt(this.v))return{done:!0,value:void 0};const e=this.v.value;return this.v=Lo(e.cont),{done:!1,value:e.value}}[Symbol.iterator](){return new li(this.map,this.f)}}const Lo=t=>t?gh(t[0],t[1],t[2],t[3],t[4]):re(),dh=(t,e,r=void 0)=>{switch(t._tag){case"LeafNode":return mr(t.value)?pe({value:e(t.key,t.value.value),cont:r}):Lo(r);case"CollisionNode":case"ArrayNode":case"IndexedNode":{const n=t.children;return gh(n.length,n,0,e,r)}default:return Lo(r)}},gh=(t,e,r,n,s)=>{for(;r<t;){const o=e[r++];if(o&&!sr(o))return dh(o,n,[t,e,r,n,s])}return Lo(s)},d_=xc(!1,0,new Dr,0),ui=()=>d_,g_=t=>{const e=mh(ui());for(const r of t)Rs(e,r[0],r[1]);return y_(e)},p_=t=>le(t,va),m_=t=>t&&sr(t._root),v_=y(2,(t,e)=>kc(t,e,H(e))),kc=y(3,(t,e,r)=>{let n=t._root,s=0;for(;;)switch(n._tag){case"LeafNode":return ae(e,n.key)?n.value:re();case"CollisionNode":{if(r===n.hash){const o=n.children;for(let i=0,c=o.length;i<c;++i){const a=o[i];if("key"in a&&ae(e,a.key))return a.value}}return re()}case"IndexedNode":{const o=Ln(s,r),i=yn(o);if(n.mask&i){n=n.children[lh(n.mask,i)],s+=tn;break}return re()}case"ArrayNode":{if(n=n.children[Ln(s,r)],n){s+=tn;break}return re()}default:return re()}}),__=y(2,(t,e)=>mr(kc(t,e,H(e)))),Rs=y(3,(t,e,r)=>Sc(t,e,()=>pe(r))),b_=y(3,(t,e,r)=>t._editable?(t._root=e,t._size=r,t):e===t._root?t:xc(t._editable,t._edit,e,r)),ph=t=>new li(t,e=>e),_a=t=>t._size,mh=t=>xc(!0,t._edit+1,t._root,t._size),y_=t=>(t._editable=!1,t),Sc=y(3,(t,e,r)=>x_(t,e,H(e),r)),x_=y(4,(t,e,r,n)=>{const s={value:t._size},o=t._root.modify(t._editable?t._edit:NaN,0,n,r,e,s);return T(t,b_(o,s.value))}),$l=y(2,(t,e)=>Sc(t,e,re)),k_=y(2,(t,e)=>fi(t,ui(),(r,n,s)=>Rs(r,s,e(n,s)))),S_=y(2,(t,e)=>fi(t,void 0,(r,n,s)=>e(n,s))),fi=y(3,(t,e,r)=>{const n=t._root;if(n._tag==="LeafNode")return mr(n.value)?r(e,n.value.value,n.key):e;if(n._tag==="EmptyNode")return e;const s=[n.children];let o;for(;o=s.pop();)for(let i=0,c=o.length;i<c;){const a=o[i++];a&&!sr(a)&&(a._tag==="LeafNode"?mr(a.value)&&(e=r(e,a.value.value,a.key)):s.push(a.children))}return e}),vh="effect/HashSet",ba=Symbol.for(vh),w_={[ba]:ba,[Symbol.iterator](){return ph(this._keyMap)},[ie](){return He(this,me(H(this._keyMap))(H(vh)))},[se](t){return I_(t)?_a(this._keyMap)===_a(t._keyMap)&&ae(this._keyMap,t._keyMap):!1},toString(){return dt(this.toJSON())},toJSON(){return{_id:"HashSet",values:Array.from(this).map(ot)}},[We](){return this.toJSON()},pipe(){return ne(this,arguments)}},hi=t=>{const e=Object.create(w_);return e._keyMap=t,e},I_=t=>le(t,ba),T_=hi(ui()),di=()=>T_,R_=t=>{const e=wc(di());for(const r of t)Cs(e,r);return Ic(e)},C_=(...t)=>{const e=wc(di());for(const r of t)Cs(e,r);return Ic(e)},E_=y(2,(t,e)=>__(t._keyMap,e)),O_=t=>_a(t._keyMap),wc=t=>hi(mh(t._keyMap)),Ic=t=>(t._keyMap._editable=!1,t),_h=y(2,(t,e)=>{const r=wc(t);return e(r),Ic(r)}),Cs=y(2,(t,e)=>t._keyMap._editable?(Rs(e,!0)(t._keyMap),t):hi(Rs(e,!0)(t._keyMap))),bh=y(2,(t,e)=>t._keyMap._editable?($l(e)(t._keyMap),t):hi($l(e)(t._keyMap))),M_=y(2,(t,e)=>_h(t,r=>{for(const n of e)bh(r,n)})),A_=y(2,(t,e)=>_h(di(),r=>{N_(t,n=>Cs(r,n));for(const n of e)Cs(r,n)})),N_=y(2,(t,e)=>S_(t._keyMap,(r,n)=>e(n))),F_=y(3,(t,e,r)=>fi(t._keyMap,e,(n,s,o)=>r(n,o))),rn=di,P_=R_,Tc=C_,j_=E_,yh=O_,ys=Cs,xh=bh,Dl=M_,Es=A_,$o=F_,Ul=Symbol.for("effect/MutableRef"),L_={[Ul]:Ul,toString(){return dt(this.toJSON())},toJSON(){return{_id:"MutableRef",current:ot(this.current)}},[We](){return this.toJSON()},pipe(){return ne(this,arguments)}},kh=t=>{const e=Object.create(L_);return e.current=t,e},gi=t=>t.current,Sh=y(2,(t,e)=>(t.current=e,t)),Rc="effect/FiberId",Os=Symbol.for(Rc),Do="None",ya="Runtime",$_="Composite",D_=Ke(`${Rc}-${Do}`);let U_=class{[Os]=Os;_tag=Do;id=-1;startTimeMillis=-1;[ie](){return D_}[se](e){return wh(e)&&e._tag===Do}toString(){return dt(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag}}[We](){return this.toJSON()}};class B_{id;startTimeMillis;[Os]=Os;_tag=ya;constructor(e,r){this.id=e,this.startTimeMillis=r}[ie](){return He(this,Ke(`${Rc}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[se](e){return wh(e)&&e._tag===ya&&this.id===e.id&&this.startTimeMillis===e.startTimeMillis}toString(){return dt(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[We](){return this.toJSON()}}const q_=new U_,wh=t=>le(t,Os),xa=t=>{switch(t._tag){case Do:return rn();case ya:return Tc(t.id);case $_:return T(xa(t.left),Es(xa(t.right)))}},Bl=be(Symbol.for("effect/Fiber/Id/_fiberCounter"),()=>kh(0)),Ih=t=>Array.from(xa(t)).map(r=>`#${r}`).join(","),z_=()=>{const t=gi(Bl);return T(Bl,Sh(t+1)),new B_(t,Date.now())},Dn=q_,V_=Ih,H_=z_,Cc=ui,K_=g_,W_=m_,Th=v_,Rh=Rs,Ch=ph,J_=Sc,G_=k_,Eh=fi,Ms=Symbol.for("effect/List"),ka=t=>et(t),Y_=t=>Hp(pc(t),ka),Z_=Y_(ae),Q_={[Ms]:Ms,_tag:"Cons",toString(){return dt(this.toJSON())},toJSON(){return{_id:"List",_tag:"Cons",values:ka(this).map(ot)}},[We](){return this.toJSON()},[se](t){return Mh(t)&&this._tag===t._tag&&Z_(this,t)},[ie](){return He(this,$s(ka(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 r=e.head;return e=e.tail,{done:t,value:r}},return(r){return t||(t=!0),{done:!0,value:r}}}},pipe(){return ne(this,arguments)}},Uo=(t,e)=>{const r=Object.create(Q_);return r.head=t,r.tail=e,r},X_=Ke("Nil"),eb={[Ms]:Ms,_tag:"Nil",toString(){return dt(this.toJSON())},toJSON(){return{_id:"List",_tag:"Nil"}},[We](){return this.toJSON()},[ie](){return X_},[se](t){return Mh(t)&&this._tag===t._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return ne(this,arguments)}},Oh=Object.create(eb),Mh=t=>le(t,Ms),Or=t=>t._tag==="Nil",tb=t=>t._tag==="Cons",rb=()=>Oh,nn=(t,e)=>Uo(t,e),Un=rb,Ec=t=>Uo(t,Oh),nb=y(2,(t,e)=>ob(e,t)),sb=y(2,(t,e)=>nn(e,t)),ob=y(2,(t,e)=>{if(Or(t))return e;if(Or(e))return t;{const r=Uo(e.head,t);let n=r,s=e.tail;for(;!Or(s);){const o=Uo(s.head,t);n.tail=o,n=o,s=s.tail}return r}}),ib=y(3,(t,e,r)=>{let n=e,s=t;for(;!Or(s);)n=r(n,s.head),s=s.tail;return n}),ab=t=>{let e=Un(),r=t;for(;!Or(r);)e=sb(e,r.head),r=r.tail;return e},Oc=(function(){function t(e){e&&Object.assign(this,e)}return t.prototype=hc,t})(),cb=Symbol.for("effect/DifferContextPatch");function ql(t){return t}const zs={...Oc.prototype,[cb]:{_Value:ql,_Patch:ql}},lb=Object.assign(Object.create(zs),{_tag:"Empty"}),ub=Object.create(lb),Ah=()=>ub,fb=Object.assign(Object.create(zs),{_tag:"AndThen"}),hb=(t,e)=>{const r=Object.create(fb);return r.first=t,r.second=e,r},db=Object.assign(Object.create(zs),{_tag:"AddService"}),gb=(t,e)=>{const r=Object.create(db);return r.key=t,r.service=e,r},pb=Object.assign(Object.create(zs),{_tag:"RemoveService"}),mb=t=>{const e=Object.create(pb);return e.key=t,e},vb=Object.assign(Object.create(zs),{_tag:"UpdateService"}),_b=(t,e)=>{const r=Object.create(vb);return r.key=t,r.update=e,r},bb=(t,e)=>{const r=new Map(t.unsafeMap);let n=Ah();for(const[s,o]of e.unsafeMap.entries())if(r.has(s)){const i=r.get(s);r.delete(s),ae(i,o)||(n=_o(_b(s,()=>o))(n))}else r.delete(s),n=_o(gb(s,o))(n);for(const[s]of r.entries())n=_o(mb(s))(n);return n},_o=y(2,(t,e)=>hb(t,e)),yb=y(2,(t,e)=>{if(t._tag==="Empty")return e;let r=!1,n=Bt(t);const s=new Map(e.unsafeMap);for(;Pn(n);){const i=jn(n),c=Wr(n);switch(i._tag){case"Empty":{n=c;break}case"AddService":{s.set(i.key,i.service),n=c;break}case"AndThen":{n=ar(ar(c,i.second),i.first);break}case"RemoveService":{s.delete(i.key),n=c;break}case"UpdateService":{s.set(i.key,i.update(s.get(i.key))),r=!0,n=c;break}}}if(!r)return Nn(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 Nn(o)}),xb=Symbol.for("effect/DifferHashSetPatch");function Gi(t){return t}const pi={...Oc.prototype,[xb]:{_Value:Gi,_Key:Gi,_Patch:Gi}},kb=Object.assign(Object.create(pi),{_tag:"Empty"}),Sb=Object.create(kb),Nh=()=>Sb,wb=Object.assign(Object.create(pi),{_tag:"AndThen"}),Ib=(t,e)=>{const r=Object.create(wb);return r.first=t,r.second=e,r},Tb=Object.assign(Object.create(pi),{_tag:"Add"}),Rb=t=>{const e=Object.create(Tb);return e.value=t,e},Cb=Object.assign(Object.create(pi),{_tag:"Remove"}),Eb=t=>{const e=Object.create(Cb);return e.value=t,e},Ob=(t,e)=>{const[r,n]=$o([t,Nh()],([s,o],i)=>j_(i)(s)?[xh(i)(s),o]:[s,Sa(Rb(i))(o)])(e);return $o(n,(s,o)=>Sa(Eb(o))(s))(r)},Sa=y(2,(t,e)=>Ib(t,e)),Mb=y(2,(t,e)=>{if(t._tag==="Empty")return e;let r=e,n=Bt(t);for(;Pn(n);){const s=jn(n),o=Wr(n);switch(s._tag){case"Empty":{n=o;break}case"AndThen":{n=ar(s.first)(ar(s.second)(o));break}case"Add":{r=ys(s.value)(r),n=o;break}case"Remove":r=xh(s.value)(r),n=o}}return r}),Ab=Symbol.for("effect/DifferReadonlyArrayPatch");function zl(t){return t}const Vs={...Oc.prototype,[Ab]:{_Value:zl,_Patch:zl}},Nb=Object.assign(Object.create(Vs),{_tag:"Empty"}),Fb=Object.create(Nb),Fh=()=>Fb,Pb=Object.assign(Object.create(Vs),{_tag:"AndThen"}),jb=(t,e)=>{const r=Object.create(Pb);return r.first=t,r.second=e,r},Lb=Object.assign(Object.create(Vs),{_tag:"Append"}),$b=t=>{const e=Object.create(Lb);return e.values=t,e},Db=Object.assign(Object.create(Vs),{_tag:"Slice"}),Ub=(t,e)=>{const r=Object.create(Db);return r.from=t,r.until=e,r},Bb=Object.assign(Object.create(Vs),{_tag:"Update"}),qb=(t,e)=>{const r=Object.create(Bb);return r.index=t,r.patch=e,r},zb=t=>{let e=0,r=Fh();for(;e<t.oldValue.length&&e<t.newValue.length;){const n=t.oldValue[e],s=t.newValue[e],o=t.differ.diff(n,s);ae(o,t.differ.empty)||(r=bo(r,qb(e,o))),e=e+1}return e<t.oldValue.length&&(r=bo(r,Ub(0,e))),e<t.newValue.length&&(r=bo(r,$b(Qm(e)(t.newValue)))),r},bo=y(2,(t,e)=>jb(t,e)),Vb=y(3,(t,e,r)=>{if(t._tag==="Empty")return e;let n=e.slice(),s=er(t);for(;Km(s);){const o=Lt(s),i=Mn(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)n.push(c);s=i;break}case"Slice":{n=n.slice(o.from,o.until),s=i;break}case"Update":{n[o.index]=r.patch(o.patch,n[o.index]),s=i;break}}}return n}),Hb=Symbol.for("effect/Differ"),Kb={[Hb]:{_P:De,_V:De},pipe(){return ne(this,arguments)}},Yn=t=>{const e=Object.create(Kb);return e.empty=t.empty,e.diff=t.diff,e.combine=t.combine,e.patch=t.patch,e},Wb=()=>Yn({empty:Ah(),combine:(t,e)=>_o(e)(t),diff:(t,e)=>bb(t,e),patch:(t,e)=>yb(e)(t)}),Jb=()=>Yn({empty:Nh(),combine:(t,e)=>Sa(e)(t),diff:(t,e)=>Ob(t,e),patch:(t,e)=>Mb(e)(t)}),Gb=t=>Yn({empty:Fh(),combine:(e,r)=>bo(e,r),diff:(e,r)=>zb({oldValue:e,newValue:r,differ:t}),patch:(e,r)=>Vb(e,r,t)}),Ph=()=>Yb((t,e)=>e),Yb=t=>Yn({empty:De,combine:(e,r)=>e===De?r:r===De?e:n=>r(e(n)),diff:(e,r)=>ae(e,r)?De:ti(r),patch:(e,r)=>t(r,e(r))}),As=255,jh=8,wa=t=>t&As,Ia=t=>t>>jh&As,Hs=(t,e)=>(t&As)+((e&t&As)<<jh),Zb=Hs(0,0),Qb=t=>Hs(t,t),Xb=t=>Hs(t,0),ey=y(2,(t,e)=>Hs(wa(t)&~e,Ia(t))),ty=y(2,(t,e)=>t|e),ry=t=>~t>>>0&As,ny=0,Ks=1,sy=2,oy=4,Ta=16,iy=32,ay=t=>mi(t,iy),cy=y(2,(t,e)=>t|e),Pr=t=>Lh(t)&&!fy(t),Lh=t=>mi(t,Ks),mi=y(2,(t,e)=>(t&e)!==0),ly=(...t)=>t.reduce((e,r)=>e|r,0),uy=ly(ny),Vl=t=>mi(t,oy),fy=t=>mi(t,Ta),yo=y(2,(t,e)=>Hs(t^e,e)),xo=y(2,(t,e)=>t&(ry(wa(e))|Ia(e))|wa(e)&Ia(e)),Hl=Yn({empty:Zb,diff:(t,e)=>yo(t,e),combine:(t,e)=>ty(e)(t),patch:(t,e)=>xo(e,t)}),hy=Qb,$h=Xb,Kl=ey,Dh=(t,e)=>({_tag:"Par",left:t,right:e}),io=(t,e)=>({_tag:"Seq",left:t,right:e}),dy=t=>{let e=Ec(t),r=Un();for(;;){const[n,s]=ib(e,[Uh(),Un()],([o,i],c)=>{const[a,u]=gy(c);return[by(o,a),nb(i,u)]});if(r=py(r,n),Or(s))return ab(r);e=s}throw new Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues")},gy=t=>{let e=t,r=Uh(),n=Un(),s=Un();for(;;)switch(e._tag){case"Empty":{if(Or(n))return[r,s];e=n.head,n=n.tail;break}case"Par":{n=nn(e.right,n),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=Dh(io(c,i),io(a,i));break}case"Seq":{const c=o.left,a=o.right;e=io(c,io(a,i));break}case"Single":{e=o,s=nn(i,s);break}}break}case"Single":{if(r=_y(r,e),Or(n))return[r,s];e=n.head,n=n.tail;break}}throw new Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues")},py=(t,e)=>{if(Or(t))return Ec(Yi(e));if(yy(e))return t;const r=Ty(t.head),n=xy(e);return r.length===1&&n.length===1&&ae(r[0],n[0])?nn(Iy(t.head,Yi(e)),t.tail):nn(Yi(e),t)},my=Symbol.for("effect/RequestBlock/RequestBlockParallel"),vy={_R:t=>t};class Mc{map;[my]=vy;constructor(e){this.map=e}}const Uh=()=>new Mc(Cc()),_y=(t,e)=>new Mc(J_(t.map,e.dataSource,r=>Fm(Pm(r,Fv(e.blockedRequest)),()=>Bt(e.blockedRequest)))),by=(t,e)=>new Mc(Eh(t.map,e.map,(r,n,s)=>Rh(r,s,un(Th(r,s),{onNone:()=>n,onSome:o=>nr(n,o)})))),yy=t=>W_(t.map),xy=t=>Array.from(Ch(t.map)),Yi=t=>wy(G_(t.map,e=>Bt(e))),ky=Symbol.for("effect/RequestBlock/RequestBlockSequential"),Sy={_R:t=>t};class Bh{map;[ky]=Sy;constructor(e){this.map=e}}const wy=t=>new Bh(t),Iy=(t,e)=>new Bh(Eh(e.map,t.map,(r,n,s)=>Rh(r,s,un(Th(r,s),{onNone:()=>Ar(),onSome:o=>nr(o,n)})))),Ty=t=>Array.from(Ch(t.map)),Ry=t=>Array.from(t.map),Ws="Die",sn="Empty",Zn="Fail",Qn="Interrupt",Bn="Parallel",qn="Sequential",qh="effect/Cause",zh=Symbol.for(qh),Cy={_E:t=>t},Xn={[zh]:Cy,[ie](){return T(H(qh),me(H(By(this))),He(this))},[se](t){return Ey(t)&&Uy(this,t)},pipe(){return ne(this,arguments)},toJSON(){switch(this._tag){case"Empty":return{_id:"Cause",_tag:this._tag};case"Die":return{_id:"Cause",_tag:this._tag,defect:ot(this.defect)};case"Interrupt":return{_id:"Cause",_tag:this._tag,fiberId:this.fiberId.toJSON()};case"Fail":return{_id:"Cause",_tag:this._tag,failure:ot(this.error)};case"Sequential":case"Parallel":return{_id:"Cause",_tag:this._tag,left:ot(this.left),right:ot(this.right)}}},toString(){return _i(this)},[We](){return this.toJSON()}},zn=(()=>{const t=Object.create(Xn);return t._tag=sn,t})(),Ra=t=>{const e=Object.create(Xn);return e._tag=Zn,e.error=t,e},Mr=t=>{const e=Object.create(Xn);return e._tag=Ws,e.defect=t,e},jr=t=>{const e=Object.create(Xn);return e._tag=Qn,e.fiberId=t,e},vi=(t,e)=>{const r=Object.create(Xn);return r._tag=Bn,r.left=t,r.right=e,r},Gt=(t,e)=>{const r=Object.create(Xn);return r._tag=qn,r.left=t,r.right=e,r},Ey=t=>le(t,zh),Oy=t=>t._tag===sn,My=t=>t._tag===sn?!0:Vn(t,!0,(e,r)=>{switch(r._tag){case sn:return pe(e);case Ws:case Zn:case Qn:return pe(!1);default:return re()}}),Ay=t=>mr($y(t)),Ac=t=>Nc(void 0,zy)(t),Ny=t=>Fn(Vn(t,Ar(),(e,r)=>r._tag===Zn?pe(T(e,ar(r.error))):re())),Fy=t=>Fn(Vn(t,Ar(),(e,r)=>r._tag===Ws?pe(T(e,ar(r.defect))):re())),Py=t=>Vn(t,rn(),(e,r)=>r._tag===Qn?pe(T(e,ys(r.fiberId))):re()),jy=t=>Vh(t,e=>e._tag===Zn?pe(e.error):re()),Ly=t=>{const e=jy(t);switch(e._tag){case"None":return Er(t);case"Some":return On(e.value)}},$y=t=>Vh(t,e=>e._tag===Qn?pe(e.fiberId):re()),Wl=t=>Hh(t,{onEmpty:zn,onFail:()=>zn,onDie:Mr,onInterrupt:jr,onSequential:Gt,onParallel:vi}),Dy=t=>Hh(t,{onEmpty:zn,onFail:Mr,onDie:Mr,onInterrupt:jr,onSequential:Gt,onParallel:vi}),Uy=(t,e)=>{let r=Bt(t),n=Bt(e);for(;Pn(r)&&Pn(n);){const[s,o]=T(jn(r),Vn([rn(),Ar()],([a,u],f)=>{const[d,h]=Ca(f);return pe([T(a,Es(d)),T(u,nr(h))])})),[i,c]=T(jn(n),Vn([rn(),Ar()],([a,u],f)=>{const[d,h]=Ca(f);return pe([T(a,Es(d)),T(u,nr(h))])}));if(!ae(s,i))return!1;r=o,n=c}return!0},By=t=>qy(Bt(t),Ar()),qy=(t,e)=>{for(;;){const[r,n]=T(t,Vf([rn(),Ar()],([o,i],c)=>{const[a,u]=Ca(c);return[T(o,Es(a)),T(i,nr(u))]})),s=yh(r)>0?T(e,ar(r)):e;if(Pv(n))return Fn(s);t=n,e=s}throw new Error(si("Cause.flattenCauseLoop"))},Vh=y(2,(t,e)=>{const r=[t];for(;r.length>0;){const n=r.pop(),s=e(n);switch(s._tag){case"None":{switch(n._tag){case qn:case Bn:{r.push(n.right),r.push(n.left);break}}break}case"Some":return s}}return re()}),Ca=t=>{let e=t;const r=[];let n=rn(),s=Ar();for(;e!==void 0;)switch(e._tag){case sn:{if(r.length===0)return[n,s];e=r.pop();break}case Zn:{if(n=ys(n,Wi(e._tag,e.error)),r.length===0)return[n,s];e=r.pop();break}case Ws:{if(n=ys(n,Wi(e._tag,e.defect)),r.length===0)return[n,s];e=r.pop();break}case Qn:{if(n=ys(n,Wi(e._tag,e.fiberId)),r.length===0)return[n,s];e=r.pop();break}case qn:{switch(e.left._tag){case sn:{e=e.right;break}case qn:{e=Gt(e.left.left,Gt(e.left.right,e.right));break}case Bn:{e=vi(Gt(e.left.left,e.right),Gt(e.left.right,e.right));break}default:{s=ar(s,e.right),e=e.left;break}}break}case Bn:{r.push(e.right),e=e.left;break}}throw new Error(si("Cause.evaluateCauseLoop"))},zy={emptyCase:Cl,failCase:aa,dieCase:aa,interruptCase:Cl,sequentialCase:(t,e,r)=>e&&r,parallelCase:(t,e,r)=>e&&r},Jl="SequentialCase",Gl="ParallelCase",Hh=y(2,(t,{onDie:e,onEmpty:r,onFail:n,onInterrupt:s,onParallel:o,onSequential:i})=>Nc(t,void 0,{emptyCase:()=>r,failCase:(c,a)=>n(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)})),Vn=y(3,(t,e,r)=>{let n=e,s=t;const o=[];for(;s!==void 0;){const i=r(n,s);switch(n=mr(i)?i.value:n,s._tag){case qn:{o.push(s.right),s=s.left;break}case Bn:{o.push(s.right),s=s.left;break}default:{s=void 0;break}}s===void 0&&o.length>0&&(s=o.pop())}return n}),Nc=y(3,(t,e,r)=>{const n=[t],s=[];for(;n.length>0;){const i=n.pop();switch(i._tag){case sn:{s.push(Er(r.emptyCase(e)));break}case Zn:{s.push(Er(r.failCase(e,i.error)));break}case Ws:{s.push(Er(r.dieCase(e,i.defect)));break}case Qn:{s.push(Er(r.interruptCase(e,i.fiberId)));break}case qn:{n.push(i.right),n.push(i.left),s.push(On({_tag:Jl}));break}case Bn:{n.push(i.right),n.push(i.left),s.push(On({_tag:Gl}));break}}}const o=[];for(;s.length>0;){const i=s.pop();switch(i._tag){case"Left":{switch(i.left._tag){case Jl:{const c=o.pop(),a=o.pop(),u=r.sequentialCase(e,c,a);o.push(u);break}case Gl:{const c=o.pop(),a=o.pop(),u=r.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()}),_i=(t,e)=>Ac(t)?"All fibers interrupted without errors.":Jy(t).map(function(r){return e?.renderErrorCause!==!0||r.cause===void 0?r.stack:`${r.stack} {
|
|
6
|
+
${Kh(r.cause," ")}
|
|
7
|
+
}`}).join(`
|
|
8
|
+
`),Kh=(t,e)=>{const r=t.stack.split(`
|
|
9
|
+
`);let n=`${e}[cause]: ${r[0]}`;for(let s=1,o=r.length;s<o;s++)n+=`
|
|
10
|
+
${e}${r[s]}`;return t.cause&&(n+=` {
|
|
11
|
+
${Kh(t.cause,`${e} `)}
|
|
12
|
+
${e}}`),n};class Bo extends globalThis.Error{span=void 0;constructor(e){const r=typeof e=="object"&&e!==null,n=Error.stackTraceLimit;Error.stackTraceLimit=1,super(Vy(e),r&&"cause"in e&&typeof e.cause<"u"?{cause:new Bo(e.cause)}:void 0),this.message===""&&(this.message="An error has occurred"),Error.stackTraceLimit=n,this.name=e instanceof Error?e.name:"Error",r&&(Hn in e&&(this.span=e[Hn]),Object.keys(e).forEach(s=>{s in this||(this[s]=e[s])})),this.stack=Wy(`${this.name}: ${this.message}`,e instanceof Error&&e.stack?e.stack:"",this.span)}}const Vy=t=>{if(typeof t=="string")return t;if(typeof t=="object"&&t!==null&&t instanceof Error)return t.message;try{if(le(t,"toString")&&ri(t.toString)&&t.toString!==Object.prototype.toString&&t.toString!==globalThis.Array.prototype.toString)return t.toString()}catch{}return Sf(t)},Hy=/\((.*)\)/g,Ky=be("effect/Tracer/spanToTrace",()=>new WeakMap),Wy=(t,e,r)=>{const n=[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;n.push(s[o].replace(/at .*effect_instruction_i.*\((.*)\)/,"at $1").replace(/EffectPrimitive\.\w+/,"<anonymous>"))}if(r){let o=r,i=0;for(;o&&o._tag==="Span"&&i<10;){const c=Ky.get(o);if(typeof c=="function"){const a=c();if(typeof a=="string"){const u=a.matchAll(Hy);let f=!1;for(const[,d]of u)f=!0,n.push(` at ${o.name} (${d})`);f||n.push(` at ${o.name} (${a.replace(/^at /,"")})`)}else n.push(` at ${o.name}`)}else n.push(` at ${o.name}`);o=Vr(o.parent),i++}}return n.join(`
|
|
15
|
+
`)},Hn=Symbol.for("effect/SpanAnnotation"),Jy=t=>Nc(t,void 0,{emptyCase:()=>[],dieCase:(e,r)=>[new Bo(r)],failCase:(e,r)=>[new Bo(r)],interruptCase:()=>[],parallelCase:(e,r,n)=>[...r,...n],sequentialCase:(e,r,n)=>[...r,...n]}),bi="Pending",Wh="Done",Gy="effect/Deferred",Yy=Symbol.for(Gy),Zy={_E:t=>t,_A:t=>t},Qy=t=>({_tag:bi,joiners:t}),Xy=t=>({_tag:Wh,effect:t});class Js{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 Js(this.self)}}const Jh=(t,e)=>{const r=new gt("Blocked");return r.effect_instruction_i0=t,r.effect_instruction_i1=e,r},e0=t=>{const e=new gt("RunBlocked");return e.effect_instruction_i0=t,e},Kn=Symbol.for("effect/Effect");class t0{patch;op;_op=uc;constructor(e,r){this.patch=e,this.op=r}}class gt{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Kn]=En;constructor(e){this._op=e}[se](e){return this===e}[ie](){return He(this,ic(this))}pipe(){return ne(this,arguments)}toJSON(){return{_id:"Effect",_op:this._op,effect_instruction_i0:ot(this.effect_instruction_i0),effect_instruction_i1:ot(this.effect_instruction_i1),effect_instruction_i2:ot(this.effect_instruction_i2)}}toString(){return dt(this.toJSON())}[We](){return this.toJSON()}[Symbol.iterator](){return new Js(new Ls(this))}}class Gh{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Kn]=En;constructor(e){this._op=e,this._tag=e}[se](e){return Ii(e)&&e._op==="Failure"&&ae(this.effect_instruction_i0,e.effect_instruction_i0)}[ie](){return T(Ke(this._tag),me(H(this.effect_instruction_i0)),He(this))}get cause(){return this.effect_instruction_i0}pipe(){return ne(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,cause:this.cause.toJSON()}}toString(){return dt(this.toJSON())}[We](){return this.toJSON()}[Symbol.iterator](){return new Js(new Ls(this))}}class Yh{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Kn]=En;constructor(e){this._op=e,this._tag=e}[se](e){return Ii(e)&&e._op==="Success"&&ae(this.effect_instruction_i0,e.effect_instruction_i0)}[ie](){return T(Ke(this._tag),me(H(this.effect_instruction_i0)),He(this))}get value(){return this.effect_instruction_i0}pipe(){return ne(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,value:ot(this.value)}}toString(){return dt(this.toJSON())}[We](){return this.toJSON()}[Symbol.iterator](){return new Js(new Ls(this))}}const Fc=t=>le(t,Kn),qt=t=>{const e=new gt(Tf);return e.effect_instruction_i0=t,e},r0=y(3,(t,e,r)=>ki(n=>X(t,s=>X(Xh(nt(()=>n(e(s)))),o=>nt(()=>r(s,o)).pipe(Wn({onFailure:i=>{switch(o._tag){case or:return cr(Gt(o.effect_instruction_i0,i));case ir:return cr(i)}},onSuccess:()=>o})))))),Gs=y(2,(t,e)=>X(t,()=>Ae(e))),yi=t=>Gs(t,void 0),Zh=function(){const t=new gt(ii);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(si("you're not supposed to end up here"))}return t},qo=(t,e=Dn)=>{const r=new gt(vs);let n;return r.effect_instruction_i0=s=>{n=t(s)},r.effect_instruction_i1=e,sd(r,s=>Fc(n)?n:vr)},n0=(t,e=Dn)=>nt(()=>qo(t,e)),on=(t,e=Dn)=>Zh(t,function(){let r,n;function s(a){r?r(a):n===void 0&&(n=a)}const o=new gt(vs);o.effect_instruction_i0=a=>{r=a,n&&a(n)},o.effect_instruction_i1=e;let i,c;return this.effect_instruction_i0.length!==1?(c=new AbortController,i=Ct(()=>this.effect_instruction_i0(s,c.signal))):i=Ct(()=>this.effect_instruction_i0(s)),i||c?sd(o,a=>(c&&c.abort(),i??vr)):o}),Yl=y(2,(t,e)=>jc(t,{onFailure:e,onSuccess:Ae})),Zl=Symbol.for("effect/OriginalAnnotation"),Qh=(t,e)=>mr(e)?new Proxy(t,{has(r,n){return n===Hn||n===Zl||n in r},get(r,n){return n===Hn?e.value:n===Zl?t:r[n]}}):t,Ql=t=>ni(t)&&!(Hn in t)?qt(e=>cr(Mr(Qh(t,_d(e))))):cr(Mr(t)),s0=t=>o0(()=>Mr(new $0(t))),Ns=t=>jc(t,{onFailure:e=>Ae(On(e)),onSuccess:e=>Ae(Er(e))}),Xh=t=>l0(t,{onFailure:ze,onSuccess:ht}),_t=t=>ni(t)&&!(Hn in t)?qt(e=>cr(Ra(Qh(t,_d(e))))):cr(Ra(t)),Pc=t=>X(Q(t),_t),cr=t=>{const e=new Gh(or);return e.effect_instruction_i0=t,e},o0=t=>X(Q(t),cr),i0=qt(t=>Ae(t.id())),a0=t=>qt(e=>t(e.id())),X=y(2,(t,e)=>{const r=new gt(Mo);return r.effect_instruction_i0=t,r.effect_instruction_i1=e,r}),c0=t=>{const e=new gt("OnStep");return e.effect_instruction_i0=t,e},ed=t=>X(t,De),l0=y(2,(t,e)=>Wn(t,{onFailure:r=>Ae(e.onFailure(r)),onSuccess:r=>Ae(e.onSuccess(r))})),Wn=y(2,(t,e)=>{const r=new gt(Ao);return r.effect_instruction_i0=t,r.effect_instruction_i1=e.onFailure,r.effect_instruction_i2=e.onSuccess,r}),jc=y(2,(t,e)=>Wn(t,{onFailure:r=>{if(Fy(r).length>0)return cr(Dy(r));const s=Ny(r);return s.length>0?e.onFailure(oh(s)):cr(r)},onSuccess:e.onSuccess})),Lr=y(2,(t,e)=>nt(()=>{const r=et(t),n=gc(r.length);let s=0;return Gs($c({while:()=>s<r.length,body:()=>e(r[s],s),step:o=>{n[s++]=o}}),n)})),xi=y(2,(t,e)=>nt(()=>{const r=et(t);let n=0;return $c({while:()=>n<r.length,body:()=>e(r[n],n),step:()=>{n++}})})),td=t=>{const e=new gt(Ds);return e.effect_instruction_i0=hy(Ks),e.effect_instruction_i1=()=>t,e},Et=y(2,(t,e)=>X(t,r=>Q(()=>e(r)))),rd=y(2,(t,e)=>jc(t,{onFailure:r=>Pc(()=>e.onFailure(r)),onSuccess:r=>Q(()=>e.onSuccess(r))})),Lc=y(2,(t,e)=>Wn(t,{onFailure:r=>{const n=Ly(r);switch(n._tag){case"Left":return Pc(()=>e(n.left));case"Right":return cr(n.right)}},onSuccess:Ae})),nd=y(2,(t,e)=>ki(r=>Wn(r(t),{onFailure:n=>{const s=ze(n);return Wn(e(s),{onFailure:o=>ze(Gt(n,o)),onSuccess:()=>s})},onSuccess:n=>{const s=ht(n);return Uc(e(s),s)}}))),sd=y(2,(t,e)=>nd(t,pd({onFailure:r=>Ac(r)?yi(e(Py(r))):vr,onSuccess:()=>vr}))),Ae=t=>{const e=new Yh(ir);return e.effect_instruction_i0=t,e},nt=t=>{const e=new gt(ii);return e.commit=t,e},Q=t=>{const e=new gt(If);return e.effect_instruction_i0=t,e},u0=y(t=>t.length===3||t.length===2&&!(ni(t[1])&&"onlyEffect"in t[1]),(t,e)=>X(t,r=>{const n=typeof e=="function"?e(r):e;return Fc(n)?Gs(n,r):Yp(n)?qo(s=>{n.then(o=>s(Ae(r)),o=>s(_t(new gd(o,"An unknown error occurred in Effect.tap"))))}):Ae(r)})),f0=t=>qt(e=>{const r=e.getFiberRef(Oa),n=T(r,en(()=>e.scope()));return t(Si(Oa,pe(n)))}),od=t=>{const e=new gt(Ds);return e.effect_instruction_i0=$h(Ks),e.effect_instruction_i1=()=>t,e},ki=t=>Zh(t,function(){const e=new gt(Ds);return e.effect_instruction_i0=$h(Ks),e.effect_instruction_i1=r=>Lh(r)?Ct(()=>this.effect_instruction_i0(td)):Ct(()=>this.effect_instruction_i0(od)),e}),vr=Ae(void 0),h0=t=>{const e=new gt(Ds);return e.effect_instruction_i0=t,e.effect_instruction_i1=void 0,e},$c=t=>{const e=new gt(No);return e.effect_instruction_i0=t.while,e.effect_instruction_i1=t.body,e.effect_instruction_i2=t.step,e},d0=t=>nt(()=>{const e=new gt(_s);return e.effect_instruction_i0=t(),e}),g0=function(){const t=arguments.length===1?arguments[0]:arguments[1].bind(arguments[0]);return d0(()=>t(T))},Dc=t=>{const e=new gt(mo);return typeof t?.priority<"u"?N0(e,t.priority):e},id=y(2,(t,e)=>X(t,r=>Et(e,n=>[r,n]))),ad=y(2,(t,e)=>X(t,r=>Gs(e,r))),Uc=y(2,(t,e)=>X(t,()=>e)),p0=t=>X(i0,e=>T(t,m0(e))),m0=y(2,(t,e)=>X(t.interruptAsFork(e),()=>t.await)),v0={_tag:"All",syslog:0,label:"ALL",ordinal:Number.MIN_SAFE_INTEGER,pipe(){return ne(this,arguments)}},_0={_tag:"Fatal",syslog:2,label:"FATAL",ordinal:5e4,pipe(){return ne(this,arguments)}},b0={_tag:"Error",syslog:3,label:"ERROR",ordinal:4e4,pipe(){return ne(this,arguments)}},cd={_tag:"Warning",syslog:4,label:"WARN",ordinal:3e4,pipe(){return ne(this,arguments)}},ld={_tag:"Info",syslog:6,label:"INFO",ordinal:2e4,pipe(){return ne(this,arguments)}},ud={_tag:"Debug",syslog:7,label:"DEBUG",ordinal:1e4,pipe(){return ne(this,arguments)}},y0={_tag:"Trace",syslog:7,label:"TRACE",ordinal:0,pipe(){return ne(this,arguments)}},x0={_tag:"None",syslog:7,label:"OFF",ordinal:Number.MAX_SAFE_INTEGER,pipe(){return ne(this,arguments)}},k0="effect/FiberRef",S0=Symbol.for(k0),w0={_A:t=>t},Bc=t=>qt(e=>ht(e.getFiberRef(t))),qc=y(2,(t,e)=>X(Bc(t),e)),Xl=y(2,(t,e)=>I0(t,()=>[void 0,e])),I0=y(2,(t,e)=>qt(r=>{const[n,s]=e(r.getFiberRef(t));return r.setFiberRef(t,s),Ae(n)})),Si=y(3,(t,e,r)=>r0(ad(Bc(e),Xl(e,r)),()=>t,n=>Xl(e,n))),$t=(t,e)=>es(t,{differ:Ph(),fork:e?.fork??De,join:e?.join}),T0=t=>{const e=Jb();return es(t,{differ:e,fork:e.empty})},R0=t=>{const e=Gb(Ph());return es(t,{differ:e,fork:e.empty})},fd=t=>{const e=Wb();return es(t,{differ:e,fork:e.empty})},es=(t,e)=>({...Bs,[S0]:w0,initial:t,commit(){return Bc(this)},diff:(n,s)=>e.differ.diff(n,s),combine:(n,s)=>e.differ.combine(n,s),patch:n=>s=>e.differ.patch(n,s),fork:e.fork,join:e.join??((n,s)=>s)}),C0=t=>es(t,{differ:Hl,fork:Hl.empty}),wi=be(Symbol.for("effect/FiberRef/currentContext"),()=>fd(Yf())),zc=be(Symbol.for("effect/FiberRef/currentSchedulingPriority"),()=>$t(0)),E0=be(Symbol.for("effect/FiberRef/currentMaxOpsBeforeYield"),()=>$t(2048)),O0=be(Symbol.for("effect/FiberRef/currentLogAnnotation"),()=>$t(Cc())),M0=be(Symbol.for("effect/FiberRef/currentLogLevel"),()=>$t(ld)),A0=be(Symbol.for("effect/FiberRef/currentLogSpan"),()=>$t(Un())),N0=y(2,(t,e)=>Si(t,zc,e)),F0=be(Symbol.for("effect/FiberRef/currentConcurrency"),()=>$t("unbounded")),P0=be(Symbol.for("effect/FiberRef/currentRequestBatching"),()=>$t(!0)),j0=be(Symbol.for("effect/FiberRef/currentUnhandledErrorLogLevel"),()=>$t(pe(ud))),L0=be(Symbol.for("effect/FiberRef/versionMismatchErrorLogLevel"),()=>$t(pe(cd))),Ea=be(Symbol.for("effect/FiberRef/currentMetricLabels"),()=>R0(An())),Oa=be(Symbol.for("effect/FiberRef/currentForkScopeOverride"),()=>$t(re(),{fork:()=>re(),join:(t,e)=>t})),ao=be(Symbol.for("effect/FiberRef/currentInterruptedCause"),()=>$t(zn,{fork:()=>zn,join:(t,e)=>t})),Vc=(t,e)=>t.fork(e),hd=(function(){class t extends globalThis.Error{commit(){return _t(this)}toJSON(){const r={...this};return this.message&&(r.message=this.message),this.cause&&(r.cause=this.cause),r}[We](){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?_i(Ra(this),{renderErrorCause:!0}):this}}return Object.assign(t.prototype,ym),t})(),dd=(t,e)=>{class r extends hd{_tag=e}return Object.assign(r.prototype,t),r.prototype.name=e,r},eu=Symbol.for("effect/Cause/errors/RuntimeException"),$0=dd({[eu]:eu},"RuntimeException"),D0=Symbol.for("effect/Cause/errors/InterruptedException"),U0=t=>le(t,D0),tu=Symbol.for("effect/Cause/errors/NoSuchElement"),B0=dd({[tu]:tu},"NoSuchElementException"),ru=Symbol.for("effect/Cause/errors/UnknownException"),gd=(function(){class t extends hd{_tag="UnknownException";error;constructor(r,n){super(n??"An unknown error occurred",{cause:r}),this.error=r}}return Object.assign(t.prototype,{[ru]:ru,name:"UnknownException"}),t})(),Ii=t=>Fc(t)&&"_tag"in t&&(t._tag==="Success"||t._tag==="Failure"),nu=(t,e)=>V0(t,e?.parallel?vi:Gt),ze=t=>{const e=new Gh(or);return e.effect_instruction_i0=t,e},q0=t=>ze(jr(t)),Zi=y(2,(t,e)=>{switch(t._tag){case or:return ze(t.effect_instruction_i0);case ir:return ht(e(t.effect_instruction_i0))}}),pd=y(2,(t,{onFailure:e,onSuccess:r})=>{switch(t._tag){case or:return e(t.effect_instruction_i0);case ir:return r(t.effect_instruction_i0)}}),ht=t=>{const e=new Yh(ir);return e.effect_instruction_i0=t,e},Jr=ht(void 0),z0=y(3,(t,e,{onFailure:r,onSuccess:n})=>{switch(t._tag){case or:switch(e._tag){case ir:return ze(t.effect_instruction_i0);case or:return ze(r(t.effect_instruction_i0,e.effect_instruction_i0))}case ir:switch(e._tag){case ir:return ht(n(t.effect_instruction_i0,e.effect_instruction_i0));case or:return ze(e.effect_instruction_i0)}}}),V0=(t,e)=>{const r=sh(t);return Pn(r)?T(Wr(r),Vf(T(jn(r),Zi(Bt)),(n,s)=>T(n,z0(s,{onSuccess:(o,i)=>T(o,ar(i)),onFailure:e}))),Zi(Fn),Zi(n=>Zr(n)),pe):re()},H0=t=>({...Bs,[Yy]:Zy,state:kh(Qy([])),commit(){return md(this)},blockingOn:t}),md=t=>n0(e=>{const r=gi(t.state);switch(r._tag){case Wh:return e(r.effect);case bi:return r.joiners.push(e),K0(t,e)}},t.blockingOn),vd=(t,e)=>{const r=gi(t.state);if(r._tag===bi){Sh(t.state,Xy(e));for(let n=0,s=r.joiners.length;n<s;n++)r.joiners[n](e)}},K0=(t,e)=>Q(()=>{const r=gi(t.state);if(r._tag===bi){const n=r.joiners.indexOf(e);n>=0&&r.joiners.splice(n,1)}}),W0=qt(t=>ht(t.currentContext)),J0=()=>W0,Ys=t=>X(J0(),t),G0=y(2,(t,e)=>Si(wi,e)(t)),Y0=y(2,(t,e)=>Ys(r=>G0(t,e(r)))),_d=t=>{const e=t.currentSpan;return e!==void 0&&e._tag==="Span"?pe(e):re()},su=Symbol.for("effect/MutableHashMap"),Z0={[su]:su,[Symbol.iterator](){return new Hc(this)},toString(){return dt(this.toJSON())},toJSON(){return{_id:"MutableHashMap",values:Array.from(this).map(ot)}},[We](){return this.toJSON()},pipe(){return ne(this,arguments)}};class Hc{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 Q0(this.self.buckets.values()),this.next()):e}[Symbol.iterator](){return new Hc(this.self)}}class Q0{backing;constructor(e){this.backing=e}currentBucket;next(){if(this.currentBucket===void 0){const r=this.backing.next();if(r.done)return r;this.currentBucket=r.value[Symbol.iterator]()}const e=this.currentBucket.next();return e.done?(this.currentBucket=void 0,this.next()):e}}const X0=()=>{const t=Object.create(Z0);return t.referential=new Map,t.buckets=new Map,t.bucketsSize=0,t},Hr=y(2,(t,e)=>{if(Oo(e)===!1)return t.referential.has(e)?pe(t.referential.get(e)):re();const r=e[ie](),n=t.buckets.get(r);return n===void 0?re():ex(t,n,e)}),ex=(t,e,r,n=!1)=>{for(let s=0,o=e.length;s<o;s++)if(r[se](e[s][0])){const i=e[s][1];return n&&(e.splice(s,1),t.bucketsSize--),pe(i)}return re()},as=y(2,(t,e)=>mr(Hr(t,e))),cs=y(3,(t,e,r)=>{if(Oo(e)===!1)return t.referential.set(e,r),t;const n=e[ie](),s=t.buckets.get(n);return s===void 0?(t.buckets.set(n,[[e,r]]),t.bucketsSize++,t):(tx(t,s,e),s.push([e,r]),t.bucketsSize++,t)}),tx=(t,e,r)=>{for(let n=0,s=e.length;n<s;n++)if(r[se](e[n][0])){e.splice(n,1),t.bucketsSize--;return}},rx="effect/Clock",ou=Symbol.for(rx),Kc=fn("effect/Clock"),nx=2**31-1,iu={unsafeSchedule(t,e){const r=ma(e);if(r>nx)return aa;let n=!1;const s=setTimeout(()=>{n=!0,t()},r);return()=>(clearTimeout(s),!n)}},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)))})(),sx=(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 ox{[ou]=ou;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return sx()}currentTimeMillis=Q(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=Q(()=>this.unsafeCurrentTimeNanos());scheduler(){return Ae(iu)}sleep(e){return on(r=>{const n=iu.unsafeSchedule(()=>r(vr),e);return yi(Q(n))})}}const ix=()=>new ox,bd="And",yd="Or",xd="InvalidData",kd="MissingData",Sd="SourceUnavailable",wd="Unsupported",ax="effect/ConfigError",cu=Symbol.for(ax),ts={_tag:"ConfigError",[cu]:cu},Id=(t,e)=>{const r=Object.create(ts);return r._op=bd,r.left=t,r.right=e,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},Td=(t,e)=>{const r=Object.create(ts);return r._op=yd,r.left=t,r.right=e,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},cx=(t,e,r={pathDelim:"."})=>{const n=Object.create(ts);return n._op=xd,n.path=t,n.message=e,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Invalid data at ${T(this.path,Gn(r.pathDelim))}: "${this.message}")`}}),n},an=(t,e,r={pathDelim:"."})=>{const n=Object.create(ts);return n._op=kd,n.path=t,n.message=e,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Missing data at ${T(this.path,Gn(r.pathDelim))}: "${this.message}")`}}),n},lx=(t,e,r,n={pathDelim:"."})=>{const s=Object.create(ts);return s._op=Sd,s.path=t,s.message=e,s.cause=r,Object.defineProperty(s,"toString",{enumerable:!1,value(){return`(Source unavailable at ${T(this.path,Gn(n.pathDelim))}: "${this.message}")`}}),s},ux=(t,e,r={pathDelim:"."})=>{const n=Object.create(ts);return n._op=wd,n.path=t,n.message=e,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${T(this.path,Gn(r.pathDelim))}: "${this.message}")`}}),n},Gr=y(2,(t,e)=>{switch(t._op){case bd:return Id(Gr(t.left,e),Gr(t.right,e));case yd:return Td(Gr(t.left,e),Gr(t.right,e));case xd:return cx([...e,...t.path],t.message);case kd:return an([...e,...t.path],t.message);case Sd:return lx([...e,...t.path],t.message,t.cause);case wd:return ux([...e,...t.path],t.message)}}),fx={_tag:"Empty"},Qi=y(2,(t,e)=>{let r=Ec(e),n=t;for(;tb(r);){const s=r.head;switch(s._tag){case"Empty":{r=r.tail;break}case"AndThen":{r=nn(s.first,nn(s.second,r.tail));break}case"MapName":{n=Sn(n,s.f),r=r.tail;break}case"Nested":{n=Fo(n,s.name),r=r.tail;break}case"Unnested":{if(T(bs(n),Dm(s.name)))n=Mn(n),r=r.tail;else return On(an(n,`Expected ${s.name} to be in path in ConfigProvider#unnested`));break}}}return Er(n)}),hx="Constant",dx="Fail",gx="Fallback",px="Described",mx="Lazy",vx="MapOrFail",_x="Nested",bx="Primitive",yx="Sequence",xx="HashMap",kx="ZipWith";var lu={};const zo=(t,e)=>[...t,...e],Sx="effect/ConfigProvider",uu=Symbol.for(Sx),wx=fn("effect/ConfigProvider"),Ix="effect/ConfigProviderFlat",fu=Symbol.for(Ix),Tx=t=>({[uu]:uu,pipe(){return ne(this,arguments)},...t}),Rx=t=>({[fu]:fu,patch:t.patch,load:(e,r,n=!0)=>t.load(e,r,n),enumerateChildren:t.enumerateChildren}),Cx=t=>Tx({load:e=>X(Jt(t,An(),e,!1),r=>un(bs(r),{onNone:()=>_t(an(An(),`Expected a single value having structure: ${e}`)),onSome:Ae})),flattened:t}),Ex=t=>{const{pathDelim:e,seqDelim:r}=Object.assign({},{pathDelim:"_",seqDelim:","},t),n=a=>T(a,Gn(e)),s=a=>a.split(e),o=()=>typeof process<"u"&&"env"in process&&typeof lu=="object"?lu:{};return Cx(Rx({load:(a,u,f=!0)=>{const d=n(a),h=o(),v=d in h?pe(h[d]):re();return T(v,Lc(()=>an(a,`Expected ${d} to exist in the process context`)),X(p=>Fx(p,a,u,r,f)))},enumerateChildren:a=>Q(()=>{const u=o(),h=Object.keys(u).map(v=>s(v.toUpperCase())).filter(v=>{for(let p=0;p<a.length;p++){const S=T(a,qf(p)),b=v[p];if(b===void 0||S!==b)return!1}return!0}).flatMap(v=>v.slice(a.length,a.length+1));return P_(h)}),patch:fx}))},Ox=(t,e,r,n)=>{const s=Nl(r.length,a=>a>=n.length?re():pe([t(a),a+1])),o=Nl(n.length,a=>a>=r.length?re():pe([e(a),a+1])),i=zo(r,s),c=zo(n,o);return[i,c]},Mx=(t,e)=>{let r=e;if(r._tag==="Nested"){const n=t.slice();for(;r._tag==="Nested";)n.push(r.name),r=r.config;return n}return t},Jt=(t,e,r,n)=>{const s=r;switch(s._tag){case hx:return Ae(er(s.value));case px:return nt(()=>Jt(t,e,s.config,n));case dx:return _t(an(e,s.message));case gx:return T(nt(()=>Jt(t,e,s.first,n)),Yl(o=>s.condition(o)?T(Jt(t,e,s.second,n),Yl(i=>_t(Td(o,i)))):_t(o)));case mx:return nt(()=>Jt(t,e,s.config(),n));case vx:return nt(()=>T(Jt(t,e,s.original,n),X(Lr(o=>T(s.mapOrFail(o),Lc(Gr(Mx(e,s.original))))))));case _x:return nt(()=>Jt(t,zo(e,er(s.name)),s.config,n));case bx:return T(Qi(e,t.patch),X(o=>T(t.load(o,s,n),X(i=>{if(i.length===0){const c=T(Gm(o),en(()=>"<n/a>"));return _t(an([],`Expected ${s.description} with name ${c}`))}return Ae(i)}))));case yx:return T(Qi(e,t.patch),X(o=>T(t.enumerateChildren(o),X(jx),X(i=>i.length===0?nt(()=>Et(Jt(t,e,s.config,!0),er)):T(Lr(i,c=>Jt(t,zm(e,`[${c}]`),s.config,!0)),Et(c=>{const a=iv(c);return a.length===0?er(An()):er(a)}))))));case xx:return nt(()=>T(Qi(e,t.patch),X(o=>T(t.enumerateChildren(o),X(i=>T(i,Lr(c=>Jt(t,zo(o,er(c)),s.valueConfig,n)),Et(c=>c.length===0?er(Cc()):T(Px(c),Sn(a=>K_(Al(et(i),a)))))))))));case kx:return nt(()=>T(Jt(t,e,s.left,n),Ns,X(o=>T(Jt(t,e,s.right,n),Ns,X(i=>{if(gs(o)&&gs(i))return _t(Id(o.left,i.left));if(gs(o)&&so(i))return _t(o.left);if(so(o)&&gs(i))return _t(i.left);if(so(o)&&so(i)){const c=T(e,Gn(".")),a=Ax(e,c),[u,f]=Ox(a,a,T(o.right,Sn(Er)),T(i.right,Sn(Er)));return T(u,Al(f),Lr(([d,h])=>T(id(d,h),Et(([v,p])=>s.zip(v,p)))))}throw new Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues")})))))}},Ax=(t,e)=>r=>On(an(t,`The element at index ${r} in a sequence at path "${e}" was missing`)),Nx=(t,e)=>t.split(new RegExp(`\\s*${cv(e)}\\s*`)),Fx=(t,e,r,n,s)=>s?T(Nx(t,n),Lr(o=>r.parse(o.trim())),Lc(Gr(e))):T(r.parse(t),rd({onFailure:Gr(e),onSuccess:er})),Px=t=>Object.keys(t[0]).map(e=>t.map(r=>r[e])),jx=t=>T(Lr(t,$x),rd({onFailure:()=>An(),onSuccess:Po(Ts)}),Ns,Et(Om)),Lx=/^(\[(\d+)\])$/,$x=t=>{const e=t.match(Lx);if(e!==null){const r=e[2];return T(r!==void 0&&r.length>0?pe(r):re(),jm(Dx))}return re()},Dx=t=>{const e=Number.parseInt(t);return Number.isNaN(e)?re():pe(e)},hu=Symbol.for("effect/Console"),Rd=fn("effect/Console"),Ux={[hu]:hu,assert(t,...e){return Q(()=>{console.assert(t,...e)})},clear:Q(()=>{console.clear()}),count(t){return Q(()=>{console.count(t)})},countReset(t){return Q(()=>{console.countReset(t)})},debug(...t){return Q(()=>{console.debug(...t)})},dir(t,e){return Q(()=>{console.dir(t,e)})},dirxml(...t){return Q(()=>{console.dirxml(...t)})},error(...t){return Q(()=>{console.error(...t)})},group(t){return t?.collapsed?Q(()=>console.groupCollapsed(t?.label)):Q(()=>console.group(t?.label))},groupEnd:Q(()=>{console.groupEnd()}),info(...t){return Q(()=>{console.info(...t)})},log(...t){return Q(()=>{console.log(...t)})},table(t,e){return Q(()=>{console.table(t,e)})},time(t){return Q(()=>console.time(t))},timeEnd(t){return Q(()=>console.timeEnd(t))},timeLog(t,...e){return Q(()=>{console.timeLog(t,...e)})},trace(...t){return Q(()=>{console.trace(...t)})},warn(...t){return Q(()=>{console.warn(...t)})},unsafe:console},Bx="effect/Random",du=Symbol.for(Bx),qx=fn("effect/Random");class zx{seed;[du]=du;PRNG;constructor(e){this.seed=e,this.PRNG=new nm(e)}get next(){return Q(()=>this.PRNG.number())}get nextBoolean(){return Et(this.next,e=>e>.5)}get nextInt(){return Q(()=>this.PRNG.integer(Number.MAX_SAFE_INTEGER))}nextRange(e,r){return Et(this.next,n=>(r-e)*n+e)}nextIntBetween(e,r){return Q(()=>this.PRNG.integer(r-e)+e)}shuffle(e){return Vx(e,r=>this.nextIntBetween(0,r))}}const Vx=(t,e)=>nt(()=>T(Q(()=>Array.from(t)),X(r=>{const n=[];for(let s=r.length;s>=2;s=s-1)n.push(s);return T(n,xi(s=>T(e(s),Et(o=>Hx(r,s-1,o)))),Gs(sh(r)))}))),Hx=(t,e,r)=>{const n=t[e];return t[e]=t[r],t[r]=n,t},Kx=t=>new zx(H(t)),gu=Symbol.for("effect/Tracer"),Wx=t=>({[gu]:gu,...t}),Cd=fn("effect/Tracer"),Ed=fn("effect/ParentSpan"),pu=(function(){const t="abcdef0123456789",e=t.length;return function(r){let n="";for(let s=0;s<r;s++)n+=t.charAt(Math.floor(Math.random()*e));return n}})();class Jx{name;parent;context;startTime;kind;_tag="Span";spanId;traceId="native";sampled=!0;status;attributes;events=[];links;constructor(e,r,n,s,o,i){this.name=e,this.parent=r,this.context=n,this.startTime=o,this.kind=i,this.status={_tag:"Started",startTime:o},this.attributes=new Map,this.traceId=r._tag==="Some"?r.value.traceId:pu(32),this.spanId=pu(16),this.links=Array.from(s)}end(e,r){this.status={_tag:"Ended",endTime:e,exit:r,startTime:this.status.startTime}}attribute(e,r){this.attributes.set(e,r)}event(e,r,n){this.events.push([e,r,n??{}])}addLinks(e){this.links.push(...e)}}const Gx=Wx({span:(t,e,r,n,s,o)=>new Jx(t,e,r,n,s,o),context:t=>t()}),Yx=T(Yf(),is(Kc,ix()),is(Rd,Ux),is(qx,Kx(Math.random())),is(wx,Ex()),is(Cd,Gx)),Vo=be(Symbol.for("effect/DefaultServices/currentServices"),()=>fd(Yx)),mu=Symbol.for("effect/FiberRefs");class Fs{locals;[mu]=mu;constructor(e){this.locals=e}pipe(){return ne(this,arguments)}}const Zx=(t,e,r,n=!1)=>{const s=t;let o=e,i=r,c=n,a;for(;a===void 0;)if(Ut(o)&&Ut(i)){const u=Lt(o)[0],f=Mn(o),d=Lt(i)[0],h=Lt(i)[1],v=Mn(i);u.startTimeMillis<d.startTimeMillis?(i=v,c=!0):u.startTimeMillis>d.startTimeMillis?o=f:u.id<d.id?(i=v,c=!0):u.id>d.id?o=f:a=[h,c]}else a=[s.initial,!0];return a},Qx=y(3,(t,e,r)=>{const n=new Map(t.locals);return r.locals.forEach((s,o)=>{const i=s[0][1];if(!s[0][0][se](e)){if(!n.has(o)){if(ae(i,o.initial))return;n.set(o,[[e,o.join(o.initial,i)]]);return}const c=n.get(o),[a,u]=Zx(o,c,s);if(u){const f=o.diff(a,i),d=c[0][1],h=o.join(d,o.patch(f)(d));if(!ae(d,h)){let v;const p=c[0][0];p[se](e)?v=[[p,h],...c.slice(1)]:v=[[e,h],...c],n.set(o,v)}}}}),new Fs(n)}),Xx=y(2,(t,e)=>{const r=new Map;return ek(t,r,e),new Fs(r)}),ek=(t,e,r)=>{t.locals.forEach((n,s)=>{const o=n[0][1],i=s.patch(s.fork)(o);ae(o,i)?e.set(s,n):e.set(s,[[r,i],...n])})},Od=y(2,(t,e)=>{const r=new Map(t.locals);return r.delete(e),new Fs(r)}),tk=y(2,(t,e)=>t.locals.has(e)?pe(Lt(t.locals.get(e))[1]):re()),Ps=y(2,(t,e)=>T(tk(t,e),en(()=>e.initial))),Ma=y(2,(t,{fiberId:e,fiberRef:r,value:n})=>{if(t.locals.size===0)return new Fs(new Map([[r,[[e,n]]]]));const s=new Map(t.locals);return rk(s,e,r,n),new Fs(s)}),rk=(t,e,r,n)=>{const s=t.get(r)??[];let o;if(Ut(s)){const[i,c]=Lt(s);if(i[se](e)){if(ae(c,n))return;o=[[e,n],...s.slice(1)]}else o=[[e,n],...s]}else o=[[e,n]];t.set(r,o)},nk=Ps,sk=v0,ok=_0,ik=b0,ak=cd,ck=ld,lk=ud,uk=y0,fk=x0,hk=T(Ts,Am(t=>t.ordinal)),dk=Nm(hk),gk=t=>{switch(t){case"All":return sk;case"Debug":return lk;case"Error":return ik;case"Fatal":return ok;case"Info":return ck;case"Trace":return uk;case"None":return fk;case"Warning":return ak}},Md=t=>t.replace(/[\s="]/g,"_"),pk=t=>e=>`${Md(e.label)}=${t-e.startTime}ms`,mk=Us,vk=xm;class _k extends vk{}const Ad="Empty",Nd="Add",Fd="Remove",Pd="Update",jd="AndThen",bk={_tag:Ad},yk=(t,e)=>{const r=new Map(t.locals);let n=bk;for(const[s,o]of e.locals.entries()){const i=Lt(o)[1],c=r.get(s);if(c!==void 0){const a=Lt(c)[1];ae(a,i)||(n=Xi({_tag:Pd,fiberRef:s,patch:s.diff(a,i)})(n))}else n=Xi({_tag:Nd,fiberRef:s,value:i})(n);r.delete(s)}for(const[s]of r.entries())n=Xi({_tag:Fd,fiberRef:s})(n);return n},Xi=y(2,(t,e)=>({_tag:jd,first:t,second:e})),xk=y(3,(t,e,r)=>{let n=r,s=er(t);for(;Ut(s);){const o=Lt(s),i=Mn(s);switch(o._tag){case Ad:{s=i;break}case Nd:{n=Ma(n,{fiberId:e,fiberRef:o.fiberRef,value:o.value}),s=i;break}case Fd:{n=Od(n,o.fiberRef),s=i;break}case Pd:{const c=Ps(n,o.fiberRef);n=Ma(n,{fiberId:e,fiberRef:o.fiberRef,value:o.fiberRef.patch(o.patch)(c)}),s=i;break}case jd:{s=Fo(o.first)(Fo(o.second)(i));break}}}return n}),Ld="effect/MetricLabel",Aa=Symbol.for(Ld);class kk{key;value;[Aa]=Aa;_hash;constructor(e,r){this.key=e,this.value=r,this._hash=Ke(Ld+this.key+this.value)}[ie](){return this._hash}[se](e){return wk(e)&&this.key===e.key&&this.value===e.value}pipe(){return ne(this,arguments)}}const Sk=(t,e)=>new kk(t,e),wk=t=>le(t,Aa),Ik=t=>{let e,r;typeof t=="function"?e=t:(e=t.try,r=t.catch);const n=s=>r?Pc(()=>r(s)):_t(new gd(s,"An unknown error occurred in Effect.tryPromise"));return e.length>=1?on((s,o)=>{try{e(o).then(i=>s(Ae(i)),i=>s(n(i)))}catch(i){s(n(i))}}):on(s=>{try{e().then(o=>s(Ae(o)),o=>s(n(o)))}catch(o){s(n(o))}})},Tk="Sequential",Rk="Parallel",Ck="ParallelN",Ek={_tag:Tk},Ok={_tag:Rk},Mk=t=>({_tag:Ck,parallelism:t}),Na=Ek,Fa=Ok,Pa=Mk,Ak=yk,Nk=xk,Ti="effect/FiberStatus",cn=Symbol.for(Ti),Ho="Done",vu="Running",_u="Suspended",Fk=Ke(`${Ti}-${Ho}`);class Pk{[cn]=cn;_tag=Ho;[ie](){return Fk}[se](e){return Wc(e)&&e._tag===Ho}}class jk{runtimeFlags;[cn]=cn;_tag=vu;constructor(e){this.runtimeFlags=e}[ie](){return T(H(Ti),me(H(this._tag)),me(H(this.runtimeFlags)),He(this))}[se](e){return Wc(e)&&e._tag===vu&&this.runtimeFlags===e.runtimeFlags}}class Lk{runtimeFlags;blockingOn;[cn]=cn;_tag=_u;constructor(e,r){this.runtimeFlags=e,this.blockingOn=r}[ie](){return T(H(Ti),me(H(this._tag)),me(H(this.runtimeFlags)),me(H(this.blockingOn)),He(this))}[se](e){return Wc(e)&&e._tag===_u&&this.runtimeFlags===e.runtimeFlags&&ae(this.blockingOn,e.blockingOn)}}const $k=new Pk,Dk=t=>new jk(t),Uk=(t,e)=>new Lk(t,e),Wc=t=>le(t,cn),Bk=t=>t._tag===Ho,qk=$k,$d=Dk,zk=Uk,Vk=Bk,Hk=Symbol.for("effect/Micro"),Ko=Symbol.for("effect/Micro/MicroExit"),bu=Symbol.for("effect/Micro/MicroCause"),Kk={_E:De};class Dd extends globalThis.Error{_tag;traces;[bu];constructor(e,r,n){const s=`MicroCause.${e}`;let o,i,c;if(r instanceof globalThis.Error){o=`(${s}) ${r.name}`,i=r.message;const a=i.split(`
|
|
19
|
+
`).length;c=r.stack?`(${s}) ${r.stack.split(`
|
|
20
|
+
`).slice(0,a+3).join(`
|
|
21
|
+
`)}`:`${o}: ${i}`}else o=s,i=Cn(r,0),c=`${o}: ${i}`;n.length>0&&(c+=`
|
|
22
|
+
${n.join(`
|
|
23
|
+
`)}`),super(i),this._tag=e,this.traces=n,this[bu]=Kk,this.name=o,this.stack=c}pipe(){return ne(this,arguments)}toString(){return this.stack}[We](){return this.stack}}class Wk extends Dd{defect;constructor(e,r=[]){super("Die",e,r),this.defect=e}}const Jk=(t,e=[])=>new Wk(t,e);class Gk extends Dd{constructor(e=[]){super("Interrupt","interrupted",e)}}const Yk=(t=[])=>new Gk(t),Zk=t=>t._tag==="Interrupt",yu=Symbol.for("effect/Micro/MicroFiber"),Qk={_A:De,_E:De};class Xk{context;interruptible;[yu];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(e,r=!0){this.context=e,this.interruptible=r,this[yu]=Qk}getRef(e){return kv(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Vp):(this._observers.push(e),()=>{const r=this._observers.indexOf(e);r>=0&&this._observers.splice(r,1)})}_interrupted=!1;unsafeInterrupt(){this._exit||(this._interrupted=!0,this.interruptible&&this.evaluate(Qc))}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 r=this.runLoop(e);if(r===co)return;const n=xu.interruptChildren&&xu.interruptChildren(this);if(n!==void 0)return this.evaluate(Jo(n,()=>r));this._exit=r;for(let s=0;s<this._observers.length;s++)this._observers[s](r);this._observers.length=0}runLoop(e){let r=!1,n=e;this.currentOpCount=0;try{for(;;){if(this.currentOpCount++,!r&&this.getRef(Xc).shouldYield(this)){r=!0;const s=n;n=Jo(s1,()=>s)}if(n=n[ja](this),n===co){const s=this._yielded;return Ko in s?(this._yielded=void 0,s):co}}}catch(s){return le(n,ja)?La(s):La(`MicroFiber.runLoop: Not a valid effect: ${String(n)}`)}}getCont(e){for(;;){const r=this._stack.pop();if(!r)return;const n=r[Wo]&&r[Wo](this);if(n)return{[e]:n};if(r[e])return r}}_yielded=void 0;yieldWith(e){return this._yielded=e,co}children(){return this._children??=new Set}}const xu=be("effect/Micro/fiberMiddleware",()=>({interruptChildren:void 0})),Ud=Symbol.for("effect/Micro/identifier"),st=Symbol.for("effect/Micro/args"),ja=Symbol.for("effect/Micro/evaluate"),Jn=Symbol.for("effect/Micro/successCont"),Tn=Symbol.for("effect/Micro/failureCont"),Wo=Symbol.for("effect/Micro/ensureCont"),co=Symbol.for("effect/Micro/Yield"),e1={_A:De,_E:De,_R:De},t1={...mk,_op:"Micro",[Hk]:e1,pipe(){return ne(this,arguments)},[Symbol.iterator](){return new bf(new Ls(this))},toJSON(){return{_id:"Micro",op:this[Ud],...st in this?{args:this[st]}:void 0}},toString(){return dt(this)},[We](){return dt(this)}};function r1(t){return La("Micro.evaluate: Not implemented")}const Ri=t=>({...t1,[Ud]:t.op,[ja]:t.eval??r1,[Jn]:t.contA,[Tn]:t.contE,[Wo]:t.ensure}),Jc=t=>{const e=Ri(t);return function(){const r=Object.create(e);return r[st]=t.single===!1?arguments:arguments[0],r}},Bd=t=>{const e={...Ri(t),[Ko]:Ko,_tag:t.op,get[t.prop](){return this[st]},toJSON(){return{_id:"MicroExit",_tag:t.op,[t.prop]:this[st]}},[se](r){return a1(r)&&r._tag===t.op&&ae(this[st],r[st])},[ie](){return He(this,me(Ke(t.op))(H(this[st])))}};return function(r){const n=Object.create(e);return n[st]=r,n[Jn]=void 0,n[Tn]=void 0,n[Wo]=void 0,n}},Gc=Bd({op:"Success",prop:"value",eval(t){const e=t.getCont(Jn);return e?e[Jn](this[st],t):t.yieldWith(this)}}),qd=Bd({op:"Failure",prop:"cause",eval(t){let e=t.getCont(Tn);for(;Zk(this[st])&&e&&t.interruptible;)e=t.getCont(Tn);return e?e[Tn](this[st],t):t.yieldWith(this)}}),n1=Jc({op:"Yield",eval(t){let e=!1;return t.getRef(Xc).scheduleTask(()=>{e||t.evaluate(c1)},this[st]??0),t.yieldWith(()=>{e=!0})}}),s1=n1(0),o1=Gc(void 0),Yc=Jc({op:"WithMicroFiber",eval(t){return this[st](t)}}),Jo=y(2,(t,e)=>{const r=Object.create(i1);return r[st]=t,r[Jn]=e,r}),i1=Ri({op:"OnSuccess",eval(t){return t._stack.push(this),this[st]}}),a1=t=>le(t,Ko),zd=Gc,Zc=qd,Qc=Zc(Yk()),La=t=>Zc(Jk(t)),c1=zd(void 0),l1="setImmediate"in globalThis?globalThis.setImmediate:t=>setTimeout(t,0);class Vd{tasks=[];running=!1;scheduleTask(e,r){this.tasks.push(e),this.running||(this.running=!0,l1(this.afterScheduled))}afterScheduled=()=>{this.running=!1,this.runTasks()};runTasks(){const e=this.tasks;this.tasks=[];for(let r=0,n=e.length;r<n;r++)e[r]()}shouldYield(e){return e.currentOpCount>=e.getRef(h1)}flush(){for(;this.tasks.length>0;)this.runTasks()}}const u1=y(2,(t,e)=>Yc(r=>{const n=r.context;return r.context=e(n),p1(t,()=>(r.context=n,o1))})),f1=y(2,(t,e)=>u1(t,Xf(e)));class h1 extends eh()("effect/Micro/currentMaxOpsBeforeYield",{defaultValue:()=>2048}){}class Xc extends eh()("effect/Micro/currentScheduler",{defaultValue:()=>new Vd}){}const d1=y(2,(t,e)=>{const r=Object.create(g1);return r[st]=t,r[Jn]=e.onSuccess,r[Tn]=e.onFailure,r}),g1=Ri({op:"OnSuccessAndFailure",eval(t){return t._stack.push(this),this[st]}}),p1=y(2,(t,e)=>v1(r=>d1(r(t),{onFailure:n=>Jo(e(Zc(n)),()=>qd(n)),onSuccess:n=>Jo(e(zd(n)),()=>Gc(n))}))),Hd=Jc({op:"SetInterruptible",ensure(t){if(t.interruptible=this[st],t._interrupted&&t.interruptible)return()=>Qc}}),m1=t=>Yc(e=>e.interruptible?t:(e.interruptible=!0,e._stack.push(Hd(!1)),e._interrupted?Qc:t)),v1=t=>Yc(e=>e.interruptible?(e.interruptible=!1,e._stack.push(Hd(!0)),t(m1)):t(De)),_1=(t,e)=>{const r=new Xk(Xc.context(new Vd));return r.evaluate(t),r};class b1{buckets=[];scheduleTask(e,r){const n=this.buckets.length;let s,o=0;for(;o<n&&this.buckets[o][0]<=r;o++)s=this.buckets[o];s&&s[0]===r?s[1].push(e):o===n?this.buckets.push([r,[e]]):this.buckets.splice(o,0,[r,[e]])}}class y1{maxNextTickBeforeTimer;running=!1;tasks=new b1;constructor(e){this.maxNextTickBeforeTimer=e}starveInternal(e){const r=this.tasks.buckets;this.tasks.buckets=[];for(const[n,s]of r)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(E0)?e.getFiberRef(zc):!1}scheduleTask(e,r){this.tasks.scheduleTask(e,r),this.running||(this.running=!0,this.starve())}}const x1=be(Symbol.for("effect/Scheduler/defaultScheduler"),()=>new y1(2048)),k1=be(Symbol.for("effect/FiberRef/currentScheduler"),()=>$t(x1)),Kd=be(Symbol.for("effect/FiberRef/currentRequestMap"),()=>$t(new Map)),ku=(t,e,r,n)=>{switch(t){case void 0:return e();case"unbounded":return r();case"inherit":return qc(F0,s=>s==="unbounded"?r():s>1?n(s):e());default:return t>1?n(t):e()}},el="InterruptSignal",tl="Stateful",rl="Resume",nl="YieldNow",ea=t=>({_tag:el,cause:t}),ko=t=>({_tag:tl,onFiber:t}),mn=t=>({_tag:rl,effect:t}),S1=()=>({_tag:nl}),w1="effect/FiberScope",Go=Symbol.for(w1);class I1{[Go]=Go;fiberId=Dn;roots=new Set;add(e,r){this.roots.add(r),r.addObserver(()=>{this.roots.delete(r)})}}class T1{fiberId;parent;[Go]=Go;constructor(e,r){this.fiberId=e,this.parent=r}add(e,r){this.parent.tell(ko(n=>{n.addChild(r),r.addObserver(()=>{n.removeChild(r)})}))}}const R1=t=>new T1(t.id(),t),Wd=be(Symbol.for("effect/FiberScope/Global"),()=>new I1),C1="effect/Fiber",E1=Symbol.for(C1),O1={_E:t=>t,_A:t=>t},M1="effect/Fiber",A1=Symbol.for(M1),Jd=t=>ad(ed(t.await),t.inheritAll);({...Bs});const zr="effect/FiberCurrent",N1="effect/Logger",F1=Symbol.for(N1),P1={_Message:t=>t,_Output:t=>t},sl=t=>({[F1]:P1,log:t,pipe(){return ne(this,arguments)}}),j1=/^[^\s"=]*$/,L1=(t,e)=>({annotations:r,cause:n,date:s,fiberId:o,logLevel:i,message:c,spans:a})=>{const u=p=>p.match(j1)?p:t(p),f=(p,S)=>`${Md(p)}=${u(S)}`,d=(p,S)=>" "+f(p,S);let h=f("timestamp",s.toISOString());h+=d("level",i.label),h+=d("fiber",Ih(o));const v=qm(c);for(let p=0;p<v.length;p++)h+=d("message",Cn(v[p],e));Oy(n)||(h+=d("cause",_i(n,{renderErrorCause:!0})));for(const p of a)h+=" "+pk(s.getTime())(p);for(const[p,S]of r)h+=d(p,Cn(S,e));return h},$1=t=>`"${t.replace(/\\([\s\S])|(")/g,"\\$1$2")}"`,D1=sl(L1($1)),U1=typeof process=="object"&&process!==null&&typeof process.stdout=="object"&&process.stdout!==null;U1&&process.stdout.isTTY;const Gd="effect/MetricBoundaries",$a=Symbol.for(Gd);class B1{values;[$a]=$a;constructor(e){this.values=e,this._hash=T(Ke(Gd),me($s(this.values)))}_hash;[ie](){return this._hash}[se](e){return q1(e)&&ae(this.values,e.values)}pipe(){return ne(this,arguments)}}const q1=t=>le(t,$a),z1=t=>{const e=T(t,Uf(Bt(Number.POSITIVE_INFINITY)),av);return new B1(e)},V1=t=>T(Bm(t.count-1,e=>t.start*Math.pow(t.factor,e)),ai,z1),H1="effect/MetricKeyType",Yd=Symbol.for(H1),Zd="effect/MetricKeyType/Counter",Da=Symbol.for(Zd),K1="effect/MetricKeyType/Frequency",W1=Symbol.for(K1),J1="effect/MetricKeyType/Gauge",G1=Symbol.for(J1),Qd="effect/MetricKeyType/Histogram",Ua=Symbol.for(Qd),Y1="effect/MetricKeyType/Summary",Z1=Symbol.for(Y1),Xd={_In:t=>t,_Out:t=>t};class Q1{incremental;bigint;[Yd]=Xd;[Da]=Da;constructor(e,r){this.incremental=e,this.bigint=r,this._hash=Ke(Zd)}_hash;[ie](){return this._hash}[se](e){return eg(e)}pipe(){return ne(this,arguments)}}class X1{boundaries;[Yd]=Xd;[Ua]=Ua;constructor(e){this.boundaries=e,this._hash=T(Ke(Qd),me(H(this.boundaries)))}_hash;[ie](){return this._hash}[se](e){return tg(e)&&ae(this.boundaries,e.boundaries)}pipe(){return ne(this,arguments)}}const eS=t=>new Q1(t?.incremental??!1,t?.bigint??!1),tS=t=>new X1(t),eg=t=>le(t,Da),rS=t=>le(t,W1),nS=t=>le(t,G1),tg=t=>le(t,Ua),sS=t=>le(t,Z1),oS="effect/MetricKey",rg=Symbol.for(oS),iS={_Type:t=>t},aS=pc(ae);class ol{name;keyType;description;tags;[rg]=iS;constructor(e,r,n,s=[]){this.name=e,this.keyType=r,this.description=n,this.tags=s,this._hash=T(Ke(this.name+this.description),me(H(this.keyType)),me($s(this.tags)))}_hash;[ie](){return this._hash}[se](e){return cS(e)&&this.name===e.name&&ae(this.keyType,e.keyType)&&ae(this.description,e.description)&&aS(this.tags,e.tags)}pipe(){return ne(this,arguments)}}const cS=t=>le(t,rg),lS=(t,e)=>new ol(t,eS(e),dc(e?.description)),uS=(t,e,r)=>new ol(t,tS(e),dc(r)),fS=y(2,(t,e)=>e.length===0?t:new ol(t.name,t.keyType,t.description,vo(t.tags,e))),hS="effect/MetricState",Zs=Symbol.for(hS),ng="effect/MetricState/Counter",Ba=Symbol.for(ng),sg="effect/MetricState/Frequency",qa=Symbol.for(sg),og="effect/MetricState/Gauge",za=Symbol.for(og),ig="effect/MetricState/Histogram",Va=Symbol.for(ig),ag="effect/MetricState/Summary",Ha=Symbol.for(ag),Qs={_A:t=>t};class dS{count;[Zs]=Qs;[Ba]=Ba;constructor(e){this.count=e}[ie](){return T(H(ng),me(H(this.count)),He(this))}[se](e){return wS(e)&&this.count===e.count}pipe(){return ne(this,arguments)}}const gS=pc(ae);class pS{occurrences;[Zs]=Qs;[qa]=qa;constructor(e){this.occurrences=e}_hash;[ie](){return T(Ke(sg),me($s(et(this.occurrences.entries()))),He(this))}[se](e){return IS(e)&&gS(et(this.occurrences.entries()),et(e.occurrences.entries()))}pipe(){return ne(this,arguments)}}class mS{value;[Zs]=Qs;[za]=za;constructor(e){this.value=e}[ie](){return T(H(og),me(H(this.value)),He(this))}[se](e){return TS(e)&&this.value===e.value}pipe(){return ne(this,arguments)}}class vS{buckets;count;min;max;sum;[Zs]=Qs;[Va]=Va;constructor(e,r,n,s,o){this.buckets=e,this.count=r,this.min=n,this.max=s,this.sum=o}[ie](){return T(H(ig),me(H(this.buckets)),me(H(this.count)),me(H(this.min)),me(H(this.max)),me(H(this.sum)),He(this))}[se](e){return RS(e)&&ae(this.buckets,e.buckets)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return ne(this,arguments)}}class _S{error;quantiles;count;min;max;sum;[Zs]=Qs;[Ha]=Ha;constructor(e,r,n,s,o,i){this.error=e,this.quantiles=r,this.count=n,this.min=s,this.max=o,this.sum=i}[ie](){return T(H(ag),me(H(this.error)),me(H(this.quantiles)),me(H(this.count)),me(H(this.min)),me(H(this.max)),me(H(this.sum)),He(this))}[se](e){return CS(e)&&this.error===e.error&&ae(this.quantiles,e.quantiles)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return ne(this,arguments)}}const bS=t=>new dS(t),yS=t=>new pS(t),xS=t=>new mS(t),kS=t=>new vS(t.buckets,t.count,t.min,t.max,t.sum),SS=t=>new _S(t.error,t.quantiles,t.count,t.min,t.max,t.sum),wS=t=>le(t,Ba),IS=t=>le(t,qa),TS=t=>le(t,za),RS=t=>le(t,Va),CS=t=>le(t,Ha),ES="effect/MetricHook",OS=Symbol.for(ES),MS={_In:t=>t,_Out:t=>t},Xs=t=>({[OS]:MS,pipe(){return ne(this,arguments)},...t}),Su=BigInt(0),AS=t=>{let e=t.keyType.bigint?Su:0;const r=t.keyType.incremental?t.keyType.bigint?s=>s>=Su:s=>s>=0:s=>!0,n=s=>{r(s)&&(e=e+s)};return Xs({get:()=>bS(e),update:n,modify:n})},NS=t=>{const e=new Map;for(const n of t.keyType.preregisteredWords)e.set(n,0);const r=n=>{const s=e.get(n)??0;e.set(n,s+1)};return Xs({get:()=>yS(e),update:r,modify:r})},FS=(t,e)=>{let r=e;return Xs({get:()=>xS(r),update:n=>{r=n},modify:n=>{r=r+n}})},PS=t=>{const e=t.keyType.boundaries.values,r=e.length,n=new Uint32Array(r+1),s=new Float64Array(r);let o=0,i=0,c=Number.MAX_VALUE,a=Number.MIN_VALUE;T(e,Po(Ts),Sn((d,h)=>{s[h]=d}));const u=d=>{let h=0,v=r;for(;h!==v;){const p=Math.floor(h+(v-h)/2),S=s[p];d<=S?v=p:h=p,v===h+1&&(d<=s[h]?v=h:h=v)}n[h]=n[h]+1,o=o+1,i=i+d,d<c&&(c=d),d>a&&(a=d)},f=()=>{const d=gc(r);let h=0;for(let v=0;v<r;v++){const p=s[v],S=n[v];h=h+S,d[v]=[p,h]}return d};return Xs({get:()=>kS({buckets:f(),count:o,min:c,max:a,sum:i}),update:u,modify:u})},jS=t=>{const{error:e,maxAge:r,maxSize:n,quantiles:s}=t.keyType,o=T(s,Po(Ts)),i=gc(n);let c=0,a=0,u=0,f=0,d=0;const h=p=>{const S=[];let b=0;for(;b!==n-1;){const k=i[b];if(k!=null){const[F,B]=k,R=pa(p-F);Qv(R,ch)&&Zv(R,r)&&S.push(B)}b=b+1}return LS(e,o,Po(S,Ts))},v=(p,S)=>{if(n>0){c=c+1;const b=c%n;i[b]=[S,p]}f=a===0?p:Math.min(f,p),d=a===0?p:Math.max(d,p),a=a+1,u=u+p};return Xs({get:()=>SS({error:e,quantiles:h(Date.now()),count:a,min:f,max:d,sum:u}),update:([p,S])=>v(p,S),modify:([p,S])=>v(p,S)})},LS=(t,e,r)=>{const n=r.length;if(!Ut(e))return An();const s=e[0],o=e.slice(1),i=wu(t,n,re(),0,s,r),c=er(i);return o.forEach(a=>{c.push(wu(t,n,i.value,i.consumed,a,i.rest))}),Sn(c,a=>[a.quantile,a.value])},wu=(t,e,r,n,s,o)=>{let i=t,c=e,a=r,u=n,f=s,d=o,h=t,v=e,p=r,S=n,b=s,k=o;for(;;){if(!Ut(d))return{quantile:f,value:re(),consumed:u,rest:[]};if(f===1)return{quantile:f,value:pe(zf(d)),consumed:u+d.length,rest:[]};const F=Lt(d),B=Zm(d,x=>x===F),R=f*c,L=i/2*R,O=u+B[0].length,I=Math.abs(O-R);if(O<R-L){h=i,v=c,p=bs(d),S=O,b=f,k=B[1],i=h,c=v,a=p,u=S,f=b,d=k;continue}if(O>R+L){const x=Mt(a)?pe(F):a;return{quantile:f,value:x,consumed:u,rest:d}}switch(a._tag){case"None":{h=i,v=c,p=bs(d),S=O,b=f,k=B[1],i=h,c=v,a=p,u=S,f=b,d=k;continue}case"Some":{const x=Math.abs(R-a.value);if(I<x){h=i,v=c,p=bs(d),S=O,b=f,k=B[1],i=h,c=v,a=p,u=S,f=b,d=k;continue}return{quantile:f,value:pe(a.value),consumed:u,rest:d}}}}throw new Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues")},$S="effect/MetricPair",DS=Symbol.for($S),US={_Type:t=>t},BS=(t,e)=>({[DS]:US,metricKey:t,metricState:e,pipe(){return ne(this,arguments)}}),qS="effect/MetricRegistry",Iu=Symbol.for(qS);class zS{[Iu]=Iu;map=X0();snapshot(){const e=[];for(const[r,n]of this.map)e.push(BS(r,n.get()));return e}get(e){const r=T(this.map,Hr(e),Vr);if(r==null){if(eg(e.keyType))return this.getCounter(e);if(nS(e.keyType))return this.getGauge(e);if(rS(e.keyType))return this.getFrequency(e);if(tg(e.keyType))return this.getHistogram(e);if(sS(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 r}getCounter(e){let r=T(this.map,Hr(e),Vr);if(r==null){const n=AS(e);T(this.map,as(e))||T(this.map,cs(e,n)),r=n}return r}getFrequency(e){let r=T(this.map,Hr(e),Vr);if(r==null){const n=NS(e);T(this.map,as(e))||T(this.map,cs(e,n)),r=n}return r}getGauge(e){let r=T(this.map,Hr(e),Vr);if(r==null){const n=FS(e,e.keyType.bigint?BigInt(0):0);T(this.map,as(e))||T(this.map,cs(e,n)),r=n}return r}getHistogram(e){let r=T(this.map,Hr(e),Vr);if(r==null){const n=PS(e);T(this.map,as(e))||T(this.map,cs(e,n)),r=n}return r}getSummary(e){let r=T(this.map,Hr(e),Vr);if(r==null){const n=jS(e);T(this.map,as(e))||T(this.map,cs(e,n)),r=n}return r}}const VS=()=>new zS,HS="effect/Metric",KS=Symbol.for(HS),WS={_Type:t=>t,_In:t=>t,_Out:t=>t},Tu=be(Symbol.for("effect/Metric/globalMetricRegistry"),()=>VS()),cg=function(t,e,r,n){const s=Object.assign(o=>u0(o,i=>ZS(s,i)),{[KS]:WS,keyType:t,unsafeUpdate:e,unsafeValue:r,unsafeModify:n,register(){return this.unsafeValue([]),this},pipe(){return ne(this,arguments)}});return s},Ci=(t,e)=>lg(lS(t,e)),lg=t=>{let e;const r=new WeakMap,n=s=>{if(s.length===0)return e!==void 0||(e=Tu.get(t)),e;let o=r.get(s);return o!==void 0||(o=Tu.get(fS(t,s)),r.set(s,o)),o};return cg(t.keyType,(s,o)=>n(o).update(s),s=>n(s).get(),(s,o)=>n(o).modify(s))},JS=(t,e,r)=>lg(uS(t,e,r)),GS=y(3,(t,e,r)=>YS(t,[Sk(e,r)])),YS=y(2,(t,e)=>cg(t.keyType,(r,n)=>t.unsafeUpdate(r,vo(e,n)),r=>t.unsafeValue(vo(e,r)),(r,n)=>t.unsafeModify(r,vo(e,n)))),ZS=y(2,(t,e)=>qc(Ea,r=>Q(()=>t.unsafeUpdate(e,r))));({...hc});const QS=y(2,(t,e)=>qc(Kd,r=>Q(()=>{if(r.has(t)){const n=r.get(t);n.state.completed||(n.state.completed=!0,vd(n.result,e))}}))),XS="effect/Supervisor",Ei=Symbol.for(XS),il={_T:t=>t};class Oi{underlying;value0;[Ei]=il;constructor(e,r){this.underlying=e,this.value0=r}get value(){return this.value0}onStart(e,r,n,s){this.underlying.onStart(e,r,n,s)}onEnd(e,r){this.underlying.onEnd(e,r)}onEffect(e,r){this.underlying.onEffect(e,r)}onSuspend(e){this.underlying.onSuspend(e)}onResume(e){this.underlying.onResume(e)}map(e){return new Oi(this,T(this.value,Et(e)))}zip(e){return new Mi(this,e)}}class Mi{left;right;_tag="Zip";[Ei]=il;constructor(e,r){this.left=e,this.right=r}get value(){return id(this.left.value,this.right.value)}onStart(e,r,n,s){this.left.onStart(e,r,n,s),this.right.onStart(e,r,n,s)}onEnd(e,r){this.left.onEnd(e,r),this.right.onEnd(e,r)}onEffect(e,r){this.left.onEffect(e,r),this.right.onEffect(e,r)}onSuspend(e){this.left.onSuspend(e),this.right.onSuspend(e)}onResume(e){this.left.onResume(e),this.right.onResume(e)}map(e){return new Oi(this,T(this.value,Et(e)))}zip(e){return new Mi(this,e)}}const ug=t=>le(t,Ei)&&vf(t,"Zip");class ew{effect;[Ei]=il;constructor(e){this.effect=e}get value(){return this.effect}onStart(e,r,n,s){}onEnd(e,r){}onEffect(e,r){}onSuspend(e){}onResume(e){}map(e){return new Oi(this,T(this.value,Et(e)))}zip(e){return new Mi(this,e)}onRun(e,r){return e()}}const tw=t=>new ew(t),al=be("effect/Supervisor/none",()=>tw(vr)),rw=Yn,fg="Empty",hg="AddSupervisor",dg="RemoveSupervisor",gg="AndThen",xs={_tag:fg},So=(t,e)=>({_tag:gg,first:t,second:e}),nw=(t,e)=>sw(e,Bt(t)),sw=(t,e)=>{let r=t,n=e;for(;Pn(n);){const s=jn(n);switch(s._tag){case fg:{n=Wr(n);break}case hg:{r=r.zip(s.supervisor),n=Wr(n);break}case dg:{r=Ka(r,s.supervisor),n=Wr(n);break}case gg:{n=ar(s.first)(ar(s.second)(Wr(n)));break}}}return r},Ka=(t,e)=>ae(t,e)?al:ug(t)?Ka(t.left,e).zip(Ka(t.right,e)):t,Yo=t=>ae(t,al)?rn():ug(t)?T(Yo(t.left),Es(Yo(t.right))):Tc(t),ow=(t,e)=>{if(ae(t,e))return xs;const r=Yo(t),n=Yo(e),s=T(n,Dl(r),$o(xs,(i,c)=>So(i,{_tag:hg,supervisor:c}))),o=T(r,Dl(n),$o(xs,(i,c)=>So(i,{_tag:dg,supervisor:c})));return So(s,o)},iw=rw({empty:xs,patch:nw,combine:So,diff:ow}),aw=Ci("effect_fiber_started",{incremental:!0}),Ru=Ci("effect_fiber_active"),cw=Ci("effect_fiber_successes",{incremental:!0}),lw=Ci("effect_fiber_failures",{incremental:!0}),uw=GS(JS("effect_fiber_lifetimes",V1({start:.5,factor:2,count:35})),"time_unit","milliseconds"),ls="Continue",fw="Done",Cu="Yield",hw={_E:t=>t,_A:t=>t},lo=t=>{throw new Error(`BUG: FiberRuntime - ${Cn(t)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},Ir=Symbol.for("effect/internal/fiberRuntime/YieldedOp"),Tr=be("effect/internal/fiberRuntime/yieldedOpChannel",()=>({currentOp:null})),us={[Mo]:(t,e,r)=>Ct(()=>e.effect_instruction_i1(r)),OnStep:(t,e,r)=>ht(ht(r)),[Ao]:(t,e,r)=>Ct(()=>e.effect_instruction_i2(r)),[uc]:(t,e,r)=>(t.patchRuntimeFlags(t.currentRuntimeFlags,e.patch),Pr(t.currentRuntimeFlags)&&t.isInterrupted()?ze(t.getInterruptedCause()):ht(r)),[No]:(t,e,r)=>(Ct(()=>e.effect_instruction_i2(r)),Ct(()=>e.effect_instruction_i0())?(t.pushStack(e),Ct(()=>e.effect_instruction_i1())):vr),[_s]:(t,e,r)=>{for(;;){const n=Ct(()=>e.effect_instruction_i0.next(r));if(n.done)return ht(n.value);const s=om(n.value);if(Ii(s)){if(s._tag==="Failure")return s}else return t.pushStack(e),s;r=s.value}}},dw={[el]:(t,e,r,n)=>(t.processNewInterruptSignal(n.cause),Pr(e)?ze(n.cause):r),[rl]:(t,e,r,n)=>{throw new Error("It is illegal to have multiple concurrent run loops in a single fiber")},[tl]:(t,e,r,n)=>(n.onFiber(t,$d(e)),r),[nl]:(t,e,r,n)=>X(Dc(),()=>r)},gw=t=>xi(dy(t),e=>Xr(Ry(e),([r,n])=>{const s=new Map,o=[];for(const c of n){o.push(Zr(c));for(const a of c)s.set(a.request,a)}const i=o.flat();return Si(Aw(r.runAll(o),i,()=>i.forEach(c=>{c.listeners.interrupted=!0})),Kd,s)},!1,!1)),pw=fc();class mw extends _k{[E1]=O1;[A1]=hw;_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,r,n){if(super(),this.currentRuntimeFlags=n,this._fiberId=e,this._fiberRefs=r,Vl(n)){const s=this.getFiberRef(Ea);aw.unsafeUpdate(1,s),Ru.unsafeUpdate(1,s)}this.refreshRefCache()}commit(){return Jd(this)}id(){return this._fiberId}resume(e){this.tell(mn(e))}get status(){return this.ask((e,r)=>r)}get runtimeFlags(){return this.ask((e,r)=>Vk(r)?e.currentRuntimeFlags:r.runtimeFlags)}scope(){return R1(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(ao)}fiberRefs(){return this.ask(e=>e.getFiberRefs())}ask(e){return nt(()=>{const r=H0(this._fiberId);return this.tell(ko((n,s)=>{vd(r,Q(()=>e(n,s)))})),md(r)})}tell(e){this._queue.push(e),this._running||(this._running=!0,this.drainQueueLaterOnExecutor())}get await(){return on(e=>{const r=n=>e(Ae(n));return this.tell(ko((n,s)=>{n._exitValue!==null?r(this._exitValue):n.addObserver(r)})),Q(()=>this.tell(ko((n,s)=>{n.removeObserver(r)})))},this.id())}get inheritAll(){return qt((e,r)=>{const n=e.id(),s=e.getFiberRefs(),o=r.runtimeFlags,i=this.getFiberRefs(),c=Qx(s,n,i);e.setFiberRefs(c);const a=e.getFiberRef(Nu),u=T(yo(o,a),Kl(Ks),Kl(Ta));return h0(u)})}get poll(){return Q(()=>dc(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(e){return Q(()=>this.tell(ea(jr(e))))}unsafeInterruptAsFork(e){this.tell(ea(jr(e)))}addObserver(e){this._exitValue!==null?e(this._exitValue):this._observers.push(e)}removeObserver(e){this._observers=this._observers.filter(r=>r!==e)}getFiberRefs(){return this.setFiberRef(Nu,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(e){this._fiberRefs=Od(this._fiberRefs,e)}getFiberRef(e){return this._fiberRefs.locals.has(e)?this._fiberRefs.locals.get(e)[0][1]:e.initial}setFiberRef(e,r){this._fiberRefs=Ma(this._fiberRefs,{fiberId:this._fiberId,fiberRef:e,value:r}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(Vo),this.currentTracer=this.currentDefaultServices.unsafeMap.get(Cd.key),this.currentSupervisor=this.getFiberRef(Mw),this.currentScheduler=this.getFiberRef(k1),this.currentContext=this.getFiberRef(wi),this.currentSpan=this.currentContext.unsafeMap.get(Ed.key)}setFiberRefs(e){this._fiberRefs=e,this.refreshRefCache()}addChild(e){this.getChildren().add(e)}removeChild(e){this.getChildren().delete(e)}transferChildren(e){const r=this._children;if(this._children=null,r!==null&&r.size>0)for(const n of r)n._exitValue===null&&e.add(this.currentRuntimeFlags,n)}drainQueueOnCurrentThread(){let e=!0;for(;e;){let r=ls;const n=globalThis[zr];globalThis[zr]=this;try{for(;r===ls;)r=this._queue.length===0?fw:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[zr]=n}this._queue.length>0&&!this._running?(this._running=!0,r===Cu?(this.drainQueueLaterOnExecutor(),e=!1):e=!0):e=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(zc))}drainQueueWhileRunning(e,r){let n=r;for(;this._queue.length>0;){const s=this._queue.splice(0,1)[0];n=dw[s._tag](this,e,n,s)}return n}isInterrupted(){return!My(this.getFiberRef(ao))}addInterruptedCause(e){const r=this.getFiberRef(ao);this.setFiberRef(ao,Gt(r,e))}processNewInterruptSignal(e){this.addInterruptedCause(e),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let e=!1;for(const r of this._children)r.tell(ea(jr(this.id()))),e=!0;return e}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){const e=this._children.values();this._children=null;let r=!1;return $c({while:()=>!r,body:()=>{const s=e.next();return s.done?Q(()=>{r=!0}):yi(s.value.await)},step:()=>{}})}return null}reportExitValue(e){if(Vl(this.currentRuntimeFlags)){const r=this.getFiberRef(Ea),n=this.id().startTimeMillis,s=Date.now();switch(uw.unsafeUpdate(s-n,r),Ru.unsafeUpdate(-1,r),e._tag){case ir:{cw.unsafeUpdate(1,r);break}case or:{lw.unsafeUpdate(1,r);break}}}if(e._tag==="Failure"){const r=this.getFiberRef(j0);!Ac(e.cause)&&r._tag==="Some"&&this.log("Fiber terminated with an unhandled error",e.cause,r)}}setExitValue(e){this._exitValue=e,this.reportExitValue(e);for(let r=this._observers.length-1;r>=0;r--)this._observers[r](e);this._observers=[]}getLoggers(){return this.getFiberRef(xw)}log(e,r,n){const s=mr(n)?n.value:this.getFiberRef(M0),o=this.getFiberRef(vw);if(dk(o,s))return;const i=this.getFiberRef(A0),c=this.getFiberRef(O0),a=this.getLoggers(),u=this.getFiberRefs();if(yh(a)>0){const f=Zf(this.getFiberRef(Vo),Kc),d=new Date(f.unsafeCurrentTimeMillis());um(u,()=>{for(const h of a)h.log({fiberId:this.id(),logLevel:s,message:e,cause:r,context:u,spans:i,annotations:c,date:d})})}}evaluateMessageWhileSuspended(e){switch(e._tag){case nl:return Cu;case el:return this.processNewInterruptSignal(e.cause),this._asyncInterruptor!==null&&(this._asyncInterruptor(ze(e.cause)),this._asyncInterruptor=null),ls;case rl:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(e.effect),ls;case tl:return e.onFiber(this,this._exitValue!==null?qk:zk(this.currentRuntimeFlags,this._asyncBlockingOn)),ls;default:return lo(e)}}evaluateEffect(e){this.currentSupervisor.onResume(this);try{let r=Pr(this.currentRuntimeFlags)&&this.isInterrupted()?ze(this.getInterruptedCause()):e;for(;r!==null;){const n=r,s=this.runLoop(n);if(s===Ir){const o=Tr.currentOp;Tr.currentOp=null,o._op===mo?ay(this.currentRuntimeFlags)?(this.tell(S1()),this.tell(mn(Jr)),r=null):r=Jr:o._op===vs&&(r=null)}else{this.currentRuntimeFlags=T(this.currentRuntimeFlags,cy(Ta));const o=this.interruptAllChildren();o!==null?r=X(o,()=>s):(this._queue.length===0?this.setExitValue(s):this.tell(mn(s)),r=null)}}}finally{this.currentSupervisor.onSuspend(this)}}start(e){if(this._running)this.tell(mn(e));else{this._running=!0;const r=globalThis[zr];globalThis[zr]=this;try{this.evaluateEffect(e)}finally{this._running=!1,globalThis[zr]=r,this._queue.length>0&&this.drainQueueLaterOnExecutor()}}}startFork(e){this.tell(mn(e))}patchRuntimeFlags(e,r){const n=xo(e,r);return globalThis[zr]=this,this.currentRuntimeFlags=n,n}initiateAsync(e,r){let n=!1;const s=o=>{n||(n=!0,this.tell(mn(o)))};Pr(e)&&(this._asyncInterruptor=s);try{r(s)}catch(o){s(cr(Mr(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!==Hi)return e;e=this.popStack()}}getNextFailCont(){let e=this.popStack();for(;e;){if(e._op!==Mo&&e._op!==No&&e._op!==_s)return e;e=this.popStack()}}[hm](e){return Q(()=>Qf(this.currentContext,e))}Left(e){return _t(e.left)}None(e){return _t(new B0)}Right(e){return ht(e.right)}Some(e){return ht(e.value)}Micro(e){return qo(r=>{let n=r;const s=_1(f1(e,this.currentContext));return s.addObserver(o=>{if(o._tag==="Success")return n(ht(o.value));switch(o.cause._tag){case"Interrupt":return n(ze(jr(Dn)));case"Fail":return n(_t(o.cause.error));case"Die":return n(Ql(o.cause.defect))}}),qo(o=>{n=i=>{o(vr)},s.unsafeInterrupt()})})}[If](e){const r=Ct(()=>e.effect_instruction_i0()),n=this.getNextSuccessCont();return n!==void 0?(n._op in us||lo(n),us[n._op](this,n,r)):(Tr.currentOp=ht(r),Ir)}[ir](e){const r=e,n=this.getNextSuccessCont();return n!==void 0?(n._op in us||lo(n),us[n._op](this,n,r.effect_instruction_i0)):(Tr.currentOp=r,Ir)}[or](e){const r=e.effect_instruction_i0,n=this.getNextFailCont();if(n!==void 0)switch(n._op){case Hi:case Ao:return Pr(this.currentRuntimeFlags)&&this.isInterrupted()?ze(Wl(r)):Ct(()=>n.effect_instruction_i1(r));case"OnStep":return Pr(this.currentRuntimeFlags)&&this.isInterrupted()?ze(Wl(r)):ht(ze(r));case uc:return this.patchRuntimeFlags(this.currentRuntimeFlags,n.patch),Pr(this.currentRuntimeFlags)&&this.isInterrupted()?ze(Gt(r,this.getInterruptedCause())):ze(r);default:lo(n)}else return Tr.currentOp=ze(r),Ir}[Tf](e){return Ct(()=>e.effect_instruction_i0(this,$d(this.currentRuntimeFlags)))}Blocked(e){const r=this.getFiberRefs(),n=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=Ak(o.refs,r),a=yo(o.flags,n);return ht(Jh(e.effect_instruction_i0,qt(u=>{for(;s.length>0;)u.pushStack(s.pop());return u.setFiberRefs(Nk(u.id(),u.getFiberRefs())(c)),u.currentRuntimeFlags=xo(a)(u.currentRuntimeFlags),e.effect_instruction_i1})))}return ki(s=>X(pg(e0(e.effect_instruction_i0)),()=>s(e.effect_instruction_i1)))}RunBlocked(e){return gw(e.effect_instruction_i0)}[Ds](e){const r=e.effect_instruction_i0,n=this.currentRuntimeFlags,s=xo(n,r);if(Pr(s)&&this.isInterrupted())return ze(this.getInterruptedCause());if(this.patchRuntimeFlags(this.currentRuntimeFlags,r),e.effect_instruction_i1){const o=yo(s,n);return this.pushStack(new t0(o,e)),Ct(()=>e.effect_instruction_i1(n))}else return Jr}[Mo](e){return this.pushStack(e),e.effect_instruction_i0}OnStep(e){return this.pushStack(e),e.effect_instruction_i0}[Hi](e){return this.pushStack(e),e.effect_instruction_i0}[Ao](e){return this.pushStack(e),e.effect_instruction_i0}[vs](e){return this._asyncBlockingOn=e.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,e.effect_instruction_i0),Tr.currentOp=e,Ir}[mo](e){return this._isYielding=!1,Tr.currentOp=e,Ir}[No](e){const r=e.effect_instruction_i0,n=e.effect_instruction_i1;return r()?(this.pushStack(e),n()):Jr}[_s](e){return us[_s](this,e,void 0)}[ii](e){return Ct(()=>e.commit())}runLoop(e){let r=e;for(this.currentOpCount=0;;){if((this.currentRuntimeFlags&sy)!==0&&this.currentSupervisor.onEffect(this,r),this._queue.length>0&&(r=this.drainQueueWhileRunning(this.currentRuntimeFlags,r)),!this._isYielding){this.currentOpCount+=1;const n=this.currentScheduler.shouldYield(this);if(n!==!1){this._isYielding=!0,this.currentOpCount=0;const s=r;r=X(Dc({priority:n}),()=>s)}}try{if(r=this.currentTracer.context(()=>{if(pw!==r[Kn]._V){const n=this.getFiberRef(L0);if(n._tag==="Some"){const s=r[Kn]._V;this.log(`Executing an Effect versioned ${s} with a Runtime of version ${fc()}, 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`,zn,n)}}return this[r._op](r)},this),r===Ir){const n=Tr.currentOp;return n._op===mo||n._op===vs?Ir:(Tr.currentOp=null,n._op===ir||n._op===or?n:ze(Mr(n)))}}catch(n){r!==Ir&&!le(r,"_op")||!(r._op in this)?r=s0(`Not a valid effect: ${Cn(r)}`):U0(n)?r=ze(Gt(Mr(n),jr(Dn))):r=Ql(n)}}}run=()=>{this.drainQueueOnCurrentThread()}}const vw=be("effect/FiberRef/currentMinimumLogLevel",()=>$t(gk("Info"))),_w=t=>sl(e=>{const r=nk(e.context,Vo);Zf(r,Rd).unsafe.log(t.log(e))}),bw=be(Symbol.for("effect/Logger/defaultLogger"),()=>_w(D1)),yw=be(Symbol.for("effect/Logger/tracerLogger"),()=>sl(({annotations:t,cause:e,context:r,fiberId:n,logLevel:s,message:o})=>{const i=qs(Ps(r,wi),Ed);if(i._tag==="None"||i.value._tag==="ExternalSpan")return;const c=Qf(Ps(r,Vo),Kc),a={};for(const[u,f]of t)a[u]=f;a["effect.fiberId"]=V_(n),a["effect.logLevel"]=s.label,e!==null&&e._tag!=="Empty"&&(a["effect.cause"]=_i(e,{renderErrorCause:!0})),i.value.event(Cn(Array.isArray(o)&&o.length===1?o[0]:o),c.unsafeCurrentTimeNanos(),a)})),xw=be(Symbol.for("effect/FiberRef/currentLoggers"),()=>T0(Tc(bw,yw))),kw=t=>{if(Array.isArray(t)||_f(t))return[t,re()];const e=Object.keys(t),r=e.length;return[e.map(n=>t[n]),pe(n=>{const s={};for(let o=0;o<r;o++)s[e[o]]=n[o];return s})]},Sw=(t,e,r)=>{const n=[];for(const s of t)n.push(Ns(s));return X(js(n,De,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),s=>{const o=re(),i=s.length,c=new Array(i),a=new Array(i);let u=!1;for(let f=0;f<i;f++){const d=s[f];d._tag==="Left"?(c[f]=pe(d.left),u=!0):(a[f]=d.right,c[f]=o)}return u?e._tag==="Some"?_t(e.value(c)):_t(c):r?.discard?vr:e._tag==="Some"?Ae(e.value(a)):Ae(a)})},ww=(t,e,r)=>{const n=[];for(const s of t)n.push(Ns(s));return r?.discard?js(n,De,{concurrency:r?.concurrency,batching:r?.batching,discard:!0,concurrentFinalizers:r?.concurrentFinalizers}):Et(js(n,De,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),s=>e._tag==="Some"?e.value(s):s)},Iw=(t,e)=>{const[r,n]=kw(t);return e?.mode==="validate"?Sw(r,n,e):e?.mode==="either"?ww(r,n,e):e?.discard!==!0&&n._tag==="Some"?Et(js(r,De,e),n.value):js(r,De,e)},js=y(t=>_f(t[0]),(t,e,r)=>qt(n=>{const s=r?.batching===!0||r?.batching==="inherit"&&n.getFiberRef(P0);return r?.discard?ku(r.concurrency,()=>vn(Na,r?.concurrentFinalizers)(o=>s?Xr(t,(i,c)=>o(e(i,c)),!0,!1,1):xi(t,(i,c)=>o(e(i,c)))),()=>vn(Fa,r?.concurrentFinalizers)(o=>Xr(t,(i,c)=>o(e(i,c)),s,!1)),o=>vn(Pa(o),r?.concurrentFinalizers)(i=>Xr(t,(c,a)=>i(e(c,a)),s,!1,o))):ku(r?.concurrency,()=>vn(Na,r?.concurrentFinalizers)(o=>s?Eu(t,1,(i,c)=>o(e(i,c)),!0):Lr(t,(i,c)=>o(e(i,c)))),()=>vn(Fa,r?.concurrentFinalizers)(o=>Tw(t,(i,c)=>o(e(i,c)),s)),o=>vn(Pa(o),r?.concurrentFinalizers)(i=>Eu(t,o,(c,a)=>i(e(c,a)),s)))})),Tw=(t,e,r)=>nt(()=>{const n=et(t),s=new Array(n.length);return Uc(Xr(n,(i,c)=>X(e(i,c),a=>Q(()=>s[c]=a)),r,!1),Ae(s))}),Xr=(t,e,r,n,s)=>ki(o=>f0(i=>qt(c=>{let a=Array.from(t).reverse(),u=a.length;if(u===0)return vr;let f=0,d=!1;const h=s?Math.min(a.length,s):a.length,v=new Set,p=new Array,S=()=>v.forEach(x=>{x.currentScheduler.scheduleTask(()=>{x.unsafeInterruptAsFork(c.id())},0)}),b=new Array,k=new Array,F=new Array,B=()=>{const x=p.filter(({exit:A})=>A._tag==="Failure").sort((A,E)=>A.index<E.index?-1:A.index===E.index?0:1).map(({exit:A})=>A);return x.length===0&&x.push(Jr),x},R=(x,A=!1)=>{const E=od(i(x)),D=Cw(E,c,c.currentRuntimeFlags,Wd);return c.currentScheduler.scheduleTask(()=>{A&&D.unsafeInterruptAsFork(c.id()),D.resume(E)},0),D},L=()=>{n||(u-=a.length,a=[]),d=!0,S()},O=r?c0:Xh,I=R(on(x=>{const A=(D,oe)=>{D._op==="Blocked"?F.push(D):(p.push({index:oe,exit:D}),D._op==="Failure"&&!d&&L())},E=()=>{if(a.length>0){const D=a.pop();let oe=f++;const ue=()=>{const j=a.pop();return oe=f++,X(Dc(),()=>X(O(o(e(j,oe))),z))},z=j=>a.length>0&&(A(j,oe),a.length>0)?ue():Ae(j),q=X(O(o(e(D,oe))),z),P=R(q);b.push(P),v.add(P),d&&P.currentScheduler.scheduleTask(()=>{P.unsafeInterruptAsFork(c.id())},0),P.addObserver(j=>{let Je;if(j._op==="Failure"?Je=j:Je=j.effect_instruction_i0,k.push(P),v.delete(P),A(Je,oe),p.length===u)x(Ae(en(nu(B(),{parallel:!0}),()=>Jr)));else if(F.length+p.length===u){const tt=B(),je=F.map(Ne=>Ne.effect_instruction_i0).reduce(Dh);x(Ae(Jh(je,Xr([en(nu(tt,{parallel:!0}),()=>Jr),...F.map(Ne=>Ne.effect_instruction_i1)],Ne=>Ne,r,!0,s))))}else E()})}};for(let D=0;D<h;D++)E()}));return yi(nd(ed(o(Jd(I))),pd({onFailure:x=>{L();const A=F.length+1,E=Math.min(typeof s=="number"?s:F.length,F.length),D=Array.from(F);return on(oe=>{let ue=0,z=0;const q=(j,Je)=>tt=>{ue++,ue===A&&oe(ht(ze(x))),D.length>0&&Je&&P()},P=()=>{R(D.pop(),!0).addObserver(q(z,!0)),z++};I.addObserver(q(z,!1)),z++;for(let j=0;j<E;j++)P()})},onSuccess:()=>Lr(k,x=>x.inheritAll)})))}))),Eu=(t,e,r,n)=>nt(()=>{const s=et(t),o=new Array(s.length);return Uc(Xr(s,(c,a)=>Et(r(c,a),u=>o[a]=u),n,!1,e),Ae(o))}),pg=t=>Ew(t,Wd),Rw=(t,e,r,n=null)=>{const s=mg(t,e,r,n);return s.resume(t),s},Cw=(t,e,r,n=null)=>mg(t,e,r,n),mg=(t,e,r,n=null)=>{const s=H_(),o=e.getFiberRefs(),i=Xx(o,s),c=new mw(s,i,r),a=Ps(i,wi),u=c.currentSupervisor;return u.onStart(a,t,pe(e),c),c.addObserver(d=>u.onEnd(d,c)),(n!==null?n:T(e.getFiberRef(Oa),en(()=>e.scope()))).add(r,c),c},Ew=(t,e)=>qt((r,n)=>Ae(Rw(t,r,n.runtimeFlags,e))),Ou=t=>Ys(e=>un(qs(e,eo),{onNone:()=>t,onSome:r=>{switch(r.strategy._tag){case"Parallel":return t;case"Sequential":case"ParallelN":return X(Vc(r,Fa),n=>cl(t,n))}}})),Mu=t=>e=>Ys(r=>un(qs(r,eo),{onNone:()=>e,onSome:n=>n.strategy._tag==="ParallelN"&&n.strategy.parallelism===t?e:X(Vc(n,Pa(t)),s=>cl(e,s))})),vn=(t,e)=>r=>Ys(n=>un(qs(n,eo),{onNone:()=>r(De),onSome:s=>{if(e===!0){const o=t._tag==="Parallel"?Ou:t._tag==="Sequential"?Au:Mu(t.parallelism);switch(s.strategy._tag){case"Parallel":return o(r(Ou));case"Sequential":return o(r(Au));case"ParallelN":return o(r(Mu(s.strategy.parallelism)))}}else return r(De)}})),Au=t=>Ys(e=>un(qs(e,eo),{onNone:()=>t,onSome:r=>{switch(r.strategy._tag){case"Sequential":return t;case"Parallel":case"ParallelN":return X(Vc(r,Na),n=>cl(t,n))}}})),eo=fn("effect/Scope"),cl=y(2,(t,e)=>Y0(t,Xf(Tv(eo,e)))),Ow=t=>es(t,{differ:iw,fork:xs}),Nu=C0(uy),Mw=Ow(al),Aw=(t,e,r)=>a0(n=>X(X(pg(td(t)),s=>on(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"&&Ii(u.result.state.current.effect)&&u.result.state.current.effect._tag==="Failure"&&Ay(u.result.state.current.effect.cause)))&&(a.forEach(u=>u()),r?.(),o(p0(s)))};s.addObserver(u=>{a.forEach(f=>f()),o(u)});const a=e.map((u,f)=>{const d=h=>{i[f]=h,c()};return u.listeners.addObserver(d),()=>u.listeners.removeObserver(d)});return c(),Q(()=>{a.forEach(u=>u())})})),()=>nt(()=>{const s=e.flatMap(o=>o.state.completed?[]:[o]);return xi(s,o=>QS(o.request,q0(n)))}))),Nw=Iw,Fu=g0,ta=Ik;var Fw={},Pw={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)},uo=Pw,jw=t=>({debug:(e,...r)=>uo.debug(`[${t}] ${e}`,...r),info:(e,...r)=>uo.info(`[${t}] ${e}`,...r),warn:(e,...r)=>uo.warn(`[${t}] ${e}`,...r),error:(e,...r)=>uo.error(`[${t}] ${e}`,...r)}),Wa=t=>{const e=t?.match(/<command-name>([^<]+)<\/command-name>/)?.[1]??"",r=t?.match(/<command-message>([^<]+)<\/command-message>/)?.[1]??"",n=t?.match(/<command-args>([^<]+)<\/command-args>/)?.[1]?.trim()??"";return{name:e,message:r,args:n}},vg=(t,e,r,n=60,s="Untitled")=>{if(t)return t;if(e)return e.length>n?e.slice(0,n-3)+"...":e;if(r&&r!=="Untitled"){if(r.includes("<command-name>")){const{name:o,args:i}=Wa(r);if(o)return i?`${o} ${i}`:o}return r}return s},Lw=(t,e)=>{if(!e)return t;const r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`${r}(?=[/\\\\]|$)`,"g");return t.replace(n,"~")},$w=(t,e,r)=>{try{return JSON.parse(t)}catch{return null}},_g=jw("paths"),bg=()=>Fw.CLAUDE_SESSIONS_DIR||(void 0)((void 0)(),".claude","projects"),Dw=(t,e)=>{const r=t.split(`
|
|
24
|
+
`).filter(n=>n.trim());for(let n=0;n<r.length;n++){const s=$w(r[n]);if(s?.cwd)return s.cwd}return null},Uw=t=>t.endsWith(".jsonl")&&!t.startsWith("agent-"),Pu=(t,e)=>{const r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/");return r===n?"~":r.startsWith(n+"/")?"~"+r.slice(n.length):t},Bw=t=>{const e=t.match(/^([A-Za-z])--/);if(e){const r=e[1],n=t.slice(3);return r+":\\"+n.replace(/--/g,"\\.").replace(/-/g,"\\")}return t.replace(/^-/,"/").replace(/--/g,"/.").replace(/-/g,"/")},yg=t=>{const e=n=>[...n].map(s=>s.charCodeAt(0)<=127?s:"-").join(""),r=t.match(/^([A-Za-z]):[/\\]/);if(r){const n=r[1].toLowerCase(),s=t.slice(3);return n+"--"+e(s).replace(/[/\\]\./g,"--").replace(/[/\\]/g,"-").replace(/\./g,"-")}return e(t).replace(/^\//g,"-").replace(/\/\./g,"--").replace(/\//g,"-").replace(/\./g,"-")},qw=(t,e=pf,r=_g)=>{const n=(void 0)(t);try{const s=e.readFileSync(t,"utf-8"),o=Dw(s);return o===null?null:o}catch(s){return r.warn(`tryGetCwdFromFile: ${n} -> read error: ${s}`),null}},zw=(t,e=bg(),r=pf,n=_g)=>{const s=(void 0)(e,t);try{const o=r.readdirSync(s).filter(Uw),i=[];for(const a of o){const u=qw((void 0)(s,a),r,n);u!==null&&i.push(u)}const c=i.find(a=>yg(a)===t);return c||(i.length>0?n.warn(`getRealPathFromSession: ${t} -> no match, cwds found: ${i.join(", ")}`):n.warn(`getRealPathFromSession: ${t} -> no valid cwd in any session`),null)}catch{return null}},Vw=t=>{const e=(void 0)(),r=zw(t);if(r)return Pu(r,e);const n=Bw(t);return Pu(n,e)},Hw=(t,e={})=>{const{currentProjectName:r,homeDir:n,filterEmpty:s=!0}=e,o=s?t.filter(c=>c.sessionCount>0):t,i=n?yg(n):null;return o.sort((c,a)=>{if(r){if(c.name===r)return-1;if(a.name===r)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)})};Fu(function*(){const t=bg();if(!(yield*ta(()=>(void 0)(t).then(()=>!0).catch(()=>!1))))return[];const r=yield*ta(()=>(void 0)(t,{withFileTypes:!0}));return yield*Nw(r.filter(s=>s.isDirectory()&&!s.name.startsWith(".")).map(s=>Fu(function*(){const o=(void 0)(t,s.name),c=(yield*ta(()=>(void 0)(o))).filter(a=>a.endsWith(".jsonl")&&!a.startsWith("agent-"));return{name:s.name,displayName:Vw(s.name),path:o,sessionCount:c.length}})),{concurrency:10})});function Kw(t){const e=[],r=new Set;for(const s of t)s.uuid&&r.add(s.uuid);let n=!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(!n){if(n=!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}r.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 Ww(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(n.type==="progress"){const s=n,o=s.hookEvent??s.data?.hookEvent,i=s.hookName??s.data?.hookName;(o==="Stop"||i==="SessionStart:resume")&&e.push({type:"unwanted_progress",line:r+1,hookEvent:o,hookName:i})}}return{valid:e.length===0,errors:e}}function Jw(t,e){const r=new Map;for(const s of e)s.uuid&&s.type!=="file-history-snapshot"&&r.set(s.uuid,s.parentUuid);const n=s=>{let o=s;for(;o&&r.has(o);)o=r.get(o);return o};for(const s of t)s.parentUuid&&r.has(s.parentUuid)&&(s.parentUuid=n(s.parentUuid))}function ju(t,e,r){let n=-1;if(r==="file-history-snapshot"?n=t.findIndex(f=>f.type==="file-history-snapshot"&&f.messageId===e):r==="summary"?n=t.findIndex(f=>f.leafUuid===e):(n=t.findIndex(f=>f.uuid===e),n===-1&&(n=t.findIndex(f=>f.leafUuid===e)),n===-1&&(n=t.findIndex(f=>f.type==="file-history-snapshot"&&f.messageId===e))),n===-1)return{deleted:null,alsoDeleted:[]};const s=t[n],o=[];if(s.type==="assistant"){const f=s.message?.content;if(Array.isArray(f))for(const d of f)d.type==="tool_use"&&d.id&&o.push(d.id)}const i=[];if(o.length>0)for(let f=0;f<t.length;f++){const d=t[f];if(d.type==="user"){const h=d.message?.content;if(Array.isArray(h)){for(const v of h)if(v.type==="tool_result"&&v.tool_use_id&&o.includes(v.tool_use_id)){i.push(f);break}}}}const c=[n,...i].sort((f,d)=>d-f),a=c.map(f=>t[f]),u=i.map(f=>t[f]);Jw(t,a);for(const f of c)t.splice(f,1);return{deleted:s,alsoDeleted:u}}const ll=vp({version:"",homeDir:"",currentProjectName:""}),ul=(t,e)=>{const r=e??_p(ll).homeDir;return r?Lw(t,r):t.replace(/(?:\/Users\/[^/\s]+|C:\\Users\\[^\\\s]+)(?=[/\\]|(?=\s|$|[)"'\]}>,:;]))/g,"~")};mp(ll,t=>e=>ul(e,t.homeDir));var Gw=C('<div class="fixed inset-0 bg-black/50 flex items-center justify-center z-50" role="dialog" aria-modal="true"><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 lR(t,e){Yt(e,!0);let r=Me(e,"confirmText",3,"Confirm"),n=Me(e,"cancelText",3,"Cancel"),s=Me(e,"variant",3,"default");const o=u=>{u.key==="Escape"&&e.onCancel(),u.key==="Enter"&&e.onConfirm()};var i=te(),c=G(i);{var a=u=>{var f=Gw();f.__click=L=>L.target===L.currentTarget&&e.onCancel(),f.__keydown=o;var d=m(f),h=m(d),v=m(h,!0);g(h);var p=w(h,2),S=m(p,!0);g(p);var b=w(p,2),k=m(b);k.__click=function(...L){e.onCancel?.apply(this,L)};var F=m(k,!0);g(k);var B=w(k,2);B.__click=function(...L){e.onConfirm?.apply(this,L)};var R=m(B,!0);g(B),g(b),g(d),g(f),U(()=>{M(v,e.title),M(S,e.message),M(F,n()),Te(B,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"}`),M(R,r())}),_(u,f)};N(c,u=>{e.show&&u(a)})}_(t,i),Zt()}lr(["click","keydown"]);var Yw=C('<label class="block text-sm text-gh-text-secondary mb-2"> </label>'),Zw=C('<div class="fixed inset-0 bg-black/50 flex items-center justify-center z-50" role="dialog" aria-modal="true"><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 uR(t,e){Yt(e,!0);let r=Me(e,"label",3,""),n=Me(e,"placeholder",3,""),s=Me(e,"initialValue",3,""),o=Me(e,"confirmText",3,"Save"),i=Me(e,"cancelText",3,"Cancel"),c=Qe(Ro(s())),a=Qe(void 0);xn(()=>{e.show&&(K(c,s()),tf().then(()=>{l(a)?.focus(),l(a)?.select()}))});const u=()=>{e.onConfirm(l(c).trim())},f=p=>{p.key==="Escape"&&e.onCancel(),p.key==="Enter"&&u()};var d=te(),h=G(d);{var v=p=>{var S=Zw();S.__click=D=>D.target===D.currentTarget&&e.onCancel(),S.__keydown=f;var b=m(S),k=m(b),F=m(k,!0);g(k);var B=w(k,2);{var R=D=>{var oe=Yw(),ue=m(oe,!0);g(oe),U(()=>M(ue,r())),_(D,oe)};N(B,D=>{r()&&D(R)})}var L=w(B,2);hf(L),rc(L,D=>K(a,D),()=>l(a));var O=w(L,2),I=m(O);I.__click=function(...D){e.onCancel?.apply(this,D)};var x=m(I,!0);g(I);var A=w(I,2);A.__click=u;var E=m(A,!0);g(A),g(O),g(b),g(S),U(()=>{M(F,e.title),ye(L,"placeholder",n()),M(x,i()),M(E,o())}),jp(L,()=>l(c),D=>K(c,D)),_(p,S)};N(h,p=>{e.show&&p(v)})}_(t,d),Zt()}lr(["click","keydown"]);function fl(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var hn=fl();function xg(t){hn=t}var ks={exec:()=>null};function _e(t,e=""){let r=typeof t=="string"?t:t.source,n={replace:(s,o)=>{let i=typeof o=="string"?o:o.source;return i=i.replace(Ot.caret,"$1"),r=r.replace(s,i),n},getRegex:()=>new RegExp(r,e)};return n}var Qw=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ot={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,listReplaceTabs:/^\t+/,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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,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")},Xw=/^(?:[ \t]*(?:\n|$))+/,e2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,t2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,to=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,r2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hl=/(?:[*+-]|\d{1,9}[.)])/,kg=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Sg=_e(kg).replace(/bull/g,hl).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(),n2=_e(kg).replace(/bull/g,hl).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(),dl=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,s2=/^[^\n]+/,gl=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,o2=_e(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),i2=_e(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,hl).getRegex(),Ai="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",pl=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,a2=_e("^ {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",pl).replace("tag",Ai).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),wg=_e(dl).replace("hr",to).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ai).getRegex(),c2=_e(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",wg).getRegex(),ml={blockquote:c2,code:e2,def:o2,fences:t2,heading:r2,hr:to,html:a2,lheading:Sg,list:i2,newline:Xw,paragraph:wg,table:ks,text:s2},Lu=_e("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",to).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ai).getRegex(),l2={...ml,lheading:n2,table:Lu,paragraph:_e(dl).replace("hr",to).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Lu).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ai).getRegex()},u2={...ml,html:_e(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pl).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:ks,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_e(dl).replace("hr",to).replace("heading",` *#{1,6} *[^
|
|
25
|
+
]`).replace("lheading",Sg).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},f2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,h2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ig=/^( {2,}|\\)\n(?!\s*$)/,d2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ni=/[\p{P}\p{S}]/u,vl=/[\s\p{P}\p{S}]/u,Tg=/[^\s\p{P}\p{S}]/u,g2=_e(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,vl).getRegex(),Rg=/(?!~)[\p{P}\p{S}]/u,p2=/(?!~)[\s\p{P}\p{S}]/u,m2=/(?:[^\s\p{P}\p{S}]|~)/u,v2=_e(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Qw?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cg=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,_2=_e(Cg,"u").replace(/punct/g,Ni).getRegex(),b2=_e(Cg,"u").replace(/punct/g,Rg).getRegex(),Eg="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",y2=_e(Eg,"gu").replace(/notPunctSpace/g,Tg).replace(/punctSpace/g,vl).replace(/punct/g,Ni).getRegex(),x2=_e(Eg,"gu").replace(/notPunctSpace/g,m2).replace(/punctSpace/g,p2).replace(/punct/g,Rg).getRegex(),k2=_e("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Tg).replace(/punctSpace/g,vl).replace(/punct/g,Ni).getRegex(),S2=_e(/\\(punct)/,"gu").replace(/punct/g,Ni).getRegex(),w2=_e(/^<(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(),I2=_e(pl).replace("(?:-->|$)","-->").getRegex(),T2=_e("^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",I2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Zo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,R2=_e(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Zo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Og=_e(/^!?\[(label)\]\[(ref)\]/).replace("label",Zo).replace("ref",gl).getRegex(),Mg=_e(/^!?\[(ref)\](?:\[\])?/).replace("ref",gl).getRegex(),C2=_e("reflink|nolink(?!\\()","g").replace("reflink",Og).replace("nolink",Mg).getRegex(),$u=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_l={_backpedal:ks,anyPunctuation:S2,autolink:w2,blockSkip:v2,br:Ig,code:h2,del:ks,emStrongLDelim:_2,emStrongRDelimAst:y2,emStrongRDelimUnd:k2,escape:f2,link:R2,nolink:Mg,punctuation:g2,reflink:Og,reflinkSearch:C2,tag:T2,text:d2,url:ks},E2={..._l,link:_e(/^!?\[(label)\]\((.*?)\)/).replace("label",Zo).getRegex(),reflink:_e(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Zo).getRegex()},Ja={..._l,emStrongRDelimAst:x2,emStrongLDelim:b2,url:_e(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",$u).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:_e(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",$u).getRegex()},O2={...Ja,br:_e(Ig).replace("{2,}","*").getRegex(),text:_e(Ja.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},fo={normal:ml,gfm:l2,pedantic:u2},fs={normal:_l,gfm:Ja,breaks:O2,pedantic:E2},M2={"&":"&","<":"<",">":">",'"':""","'":"'"},Du=t=>M2[t];function Rr(t,e){if(e){if(Ot.escapeTest.test(t))return t.replace(Ot.escapeReplace,Du)}else if(Ot.escapeTestNoEncode.test(t))return t.replace(Ot.escapeReplaceNoEncode,Du);return t}function Uu(t){try{t=encodeURI(t).replace(Ot.percentDecode,"%")}catch{return null}return t}function Bu(t,e){let r=t.replace(Ot.findPipe,(o,i,c)=>{let a=!1,u=i;for(;--u>=0&&c[u]==="\\";)a=!a;return a?"|":" |"}),n=r.split(Ot.splitPipe),s=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(Ot.slashPipe,"|");return n}function hs(t,e,r){let n=t.length;if(n===0)return"";let s=0;for(;s<n&&t.charAt(n-s-1)===e;)s++;return t.slice(0,n-s)}function A2(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let n=0;n<t.length;n++)if(t[n]==="\\")n++;else if(t[n]===e[0])r++;else if(t[n]===e[1]&&(r--,r<0))return n;return r>0?-2:-1}function qu(t,e,r,n,s){let o=e.href,i=e.title||null,c=t[1].replace(s.other.outputLinkReplace,"$1");n.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:r,href:o,title:i,text:c,tokens:n.inlineTokens(c)};return n.state.inLink=!1,a}function N2(t,e,r){let n=t.match(r.other.indentCodeCompensation);if(n===null)return e;let s=n[1];return e.split(`
|
|
26
|
+
`).map(o=>{let i=o.match(r.other.beginningSpace);if(i===null)return o;let[c]=i;return c.length>=s.length?o.slice(s.length):o}).join(`
|
|
27
|
+
`)}var Qo=class{options;rules;lexer;constructor(t){this.options=t||hn}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 r=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?r:hs(r,`
|
|
28
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let r=e[0],n=N2(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let n=hs(r,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(r=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:hs(e[0],`
|
|
29
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let r=hs(e[0],`
|
|
30
|
+
`).split(`
|
|
31
|
+
`),n="",s="",o=[];for(;r.length>0;){let i=!1,c=[],a;for(a=0;a<r.length;a++)if(this.rules.other.blockquoteStart.test(r[a]))c.push(r[a]),i=!0;else if(!i)c.push(r[a]);else break;r=r.slice(a);let u=c.join(`
|
|
32
|
+
`),f=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
33
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
34
|
+
${u}`:u,s=s?`${s}
|
|
35
|
+
${f}`:f;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,o,!0),this.lexer.state.top=d,r.length===0)break;let h=o.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let v=h,p=v.raw+`
|
|
36
|
+
`+r.join(`
|
|
37
|
+
`),S=this.blockquote(p);o[o.length-1]=S,n=n.substring(0,n.length-v.raw.length)+S.raw,s=s.substring(0,s.length-v.text.length)+S.text;break}else if(h?.type==="list"){let v=h,p=v.raw+`
|
|
38
|
+
`+r.join(`
|
|
39
|
+
`),S=this.list(p);o[o.length-1]=S,n=n.substring(0,n.length-h.raw.length)+S.raw,s=s.substring(0,s.length-v.raw.length)+S.raw,r=p.substring(o.at(-1).raw.length).split(`
|
|
40
|
+
`);continue}}return{type:"blockquote",raw:n,tokens:o,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),n=r.length>1,s={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:!1,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let o=this.rules.other.listItemRegex(r),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 d=e[2].split(`
|
|
41
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,S=>" ".repeat(3*S.length)),h=t.split(`
|
|
42
|
+
`,1)[0],v=!d.trim(),p=0;if(this.options.pedantic?(p=2,f=d.trimStart()):v?p=e[1].length+1:(p=e[2].search(this.rules.other.nonSpaceChar),p=p>4?1:p,f=d.slice(p),p+=e[1].length),v&&this.rules.other.blankLine.test(h)&&(u+=h+`
|
|
43
|
+
`,t=t.substring(h.length+1),a=!0),!a){let S=this.rules.other.nextBulletRegex(p),b=this.rules.other.hrRegex(p),k=this.rules.other.fencesBeginRegex(p),F=this.rules.other.headingBeginRegex(p),B=this.rules.other.htmlBeginRegex(p);for(;t;){let R=t.split(`
|
|
44
|
+
`,1)[0],L;if(h=R,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),L=h):L=h.replace(this.rules.other.tabCharGlobal," "),k.test(h)||F.test(h)||B.test(h)||S.test(h)||b.test(h))break;if(L.search(this.rules.other.nonSpaceChar)>=p||!h.trim())f+=`
|
|
45
|
+
`+L.slice(p);else{if(v||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(d)||F.test(d)||b.test(d))break;f+=`
|
|
46
|
+
`+h}!v&&!h.trim()&&(v=!0),u+=R+`
|
|
47
|
+
`,t=t.substring(R.length+1),d=L.slice(p)}}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(d=>d.type==="space"),f=u.length>0&&u.some(d=>this.rules.other.anyLine.test(d.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 r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=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:r,raw:e[0],href:n,title:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=Bu(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
48
|
+
`):[],o={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===n.length){for(let i of n)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<r.length;i++)o.header.push({text:r[i],tokens:this.lexer.inline(r[i]),header:!0,align:o.align[i]});for(let i of s)o.rows.push(Bu(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 r=e[1].charAt(e[1].length-1)===`
|
|
49
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}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 r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let o=hs(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{let o=A2(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 n=e[2],s="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(n);o&&(n=o[1],s=o[3])}else s=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?n=n.slice(1):n=n.slice(1,-1)),qu(e,{href:n&&n.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 r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let n=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[n.toLowerCase()];if(!s){let o=r[0].charAt(0);return{type:"text",raw:o,text:o}}return qu(r,s,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let n=this.rules.inline.emStrongLDelim.exec(t);if(!(!n||n[3]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[2])||!r||this.rules.inline.punctuation.exec(r))){let s=[...n[0]].length-1,o,i,c=s,a=0,u=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+s);(n=u.exec(e))!=null;){if(o=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!o)continue;if(i=[...o].length,n[3]||n[4]){c+=i;continue}else if((n[5]||n[6])&&s%3&&!((s+i)%3)){a+=i;continue}if(c-=i,c>0)continue;i=Math.min(i,i+c+a);let f=[...n[0]][0].length,d=t.slice(0,s+n.index+f+i);if(Math.min(s,i)%2){let v=d.slice(1,-1);return{type:"em",raw:d,text:v,tokens:this.lexer.inlineTokens(v)}}let h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(r),s=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return n&&s&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){let e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let r,n;return e[2]==="@"?(r=e[1],n="mailto:"+r):(r=e[1],n=r),{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let r,n;if(e[2]==="@")r=e[0],n="mailto:"+r;else{let s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==e[0]);r=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},tr=class Ga{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||hn,this.options.tokenizer=this.options.tokenizer||new Qo,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 r={other:Ot,block:fo.normal,inline:fs.normal};this.options.pedantic?(r.block=fo.pedantic,r.inline=fs.pedantic):this.options.gfm&&(r.block=fo.gfm,this.options.breaks?r.inline=fs.breaks:r.inline=fs.gfm),this.tokenizer.rules=r}static get rules(){return{block:fo,inline:fs}}static lex(e,r){return new Ga(r).lex(e)}static lexInline(e,r){return new Ga(r).inlineTokens(e)}lex(e){e=e.replace(Ot.carriageReturn,`
|
|
50
|
+
`),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],n=!1){for(this.options.pedantic&&(e=e.replace(Ot.tabCharGlobal," ").replace(Ot.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(i=>(s=i.call({lexer:this},e,r))?(e=e.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let i=r.at(-1);s.raw.length===1&&i!==void 0?i.raw+=`
|
|
51
|
+
`:r.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
52
|
+
`)?"":`
|
|
53
|
+
`)+s.raw,i.text+=`
|
|
54
|
+
`+s.text,this.inlineQueue.at(-1).src=i.text):r.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let i=r.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
55
|
+
`)?"":`
|
|
56
|
+
`)+s.raw,i.text+=`
|
|
57
|
+
`+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},r.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),r.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=r.at(-1);n&&i?.type==="paragraph"?(i.raw+=(i.raw.endsWith(`
|
|
58
|
+
`)?"":`
|
|
59
|
+
`)+s.raw,i.text+=`
|
|
60
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.push(s),n=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=r.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
61
|
+
`)?"":`
|
|
62
|
+
`)+s.raw,i.text+=`
|
|
63
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):r.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,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let n=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(n))!=null;)a.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,s.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)o=s[2]?s[2].length:0,n=n.slice(0,s.index+o)+"["+"a".repeat(s[0].length-o-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;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,r))?(e=e.substring(a.raw.length),r.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let f=r.at(-1);a.type==="text"&&f?.type==="text"?(f.raw+=a.raw,f.text+=a.text):r.push(a);continue}if(a=this.tokenizer.emStrong(e,n,c)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.del(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),r.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),r.push(a);continue}let u=e;if(this.options.extensions?.startInline){let f=1/0,d=e.slice(1),h;this.options.extensions.startInline.forEach(v=>{h=v.call({lexer:this},d),typeof h=="number"&&h>=0&&(f=Math.min(f,h))}),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=r.at(-1);f?.type==="text"?(f.raw+=a.raw,f.text+=a.text):r.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 r}},Xo=class{options;parser;constructor(t){this.options=t||hn}space(t){return""}code({text:t,lang:e,escaped:r}){let n=(e||"").match(Ot.notSpaceStart)?.[0],s=t.replace(Ot.endingNewline,"")+`
|
|
64
|
+
`;return n?'<pre><code class="language-'+Rr(n)+'">'+(r?s:Rr(s,!0))+`</code></pre>
|
|
65
|
+
`:"<pre><code>"+(r?s:Rr(s,!0))+`</code></pre>
|
|
66
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
67
|
+
${this.parser.parse(t)}</blockquote>
|
|
68
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
69
|
+
`}hr(t){return`<hr>
|
|
70
|
+
`}list(t){let e=t.ordered,r=t.start,n="";for(let i=0;i<t.items.length;i++){let c=t.items[i];n+=this.listitem(c)}let s=e?"ol":"ul",o=e&&r!==1?' start="'+r+'"':"";return"<"+s+o+`>
|
|
71
|
+
`+n+"</"+s+`>
|
|
72
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
73
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
74
|
+
`}table(t){let e="",r="";for(let s=0;s<t.header.length;s++)r+=this.tablecell(t.header[s]);e+=this.tablerow({text:r});let n="";for(let s=0;s<t.rows.length;s++){let o=t.rows[s];r="";for(let i=0;i<o.length;i++)r+=this.tablecell(o[i]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
|
75
|
+
<thead>
|
|
76
|
+
`+e+`</thead>
|
|
77
|
+
`+n+`</table>
|
|
78
|
+
`}tablerow({text:t}){return`<tr>
|
|
79
|
+
${t}</tr>
|
|
80
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>
|
|
81
|
+
`}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>${Rr(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let n=this.parser.parseInline(r),s=Uu(t);if(s===null)return n;t=s;let o='<a href="'+t+'"';return e&&(o+=' title="'+Rr(e)+'"'),o+=">"+n+"</a>",o}image({href:t,title:e,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let s=Uu(t);if(s===null)return Rr(r);t=s;let o=`<img src="${t}" alt="${r}"`;return e&&(o+=` title="${Rr(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Rr(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}},rr=class Ya{options;renderer;textRenderer;constructor(e){this.options=e||hn,this.options.renderer=this.options.renderer||new Xo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new bl}static parse(e,r){return new Ya(r).parse(e)}static parseInline(e,r){return new Ya(r).parseInline(e)}parse(e){let r="";for(let n=0;n<e.length;n++){let s=e[n];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)){r+=c||"";continue}}let o=s;switch(o.type){case"space":{r+=this.renderer.space(o);break}case"hr":{r+=this.renderer.hr(o);break}case"heading":{r+=this.renderer.heading(o);break}case"code":{r+=this.renderer.code(o);break}case"table":{r+=this.renderer.table(o);break}case"blockquote":{r+=this.renderer.blockquote(o);break}case"list":{r+=this.renderer.list(o);break}case"checkbox":{r+=this.renderer.checkbox(o);break}case"html":{r+=this.renderer.html(o);break}case"def":{r+=this.renderer.def(o);break}case"paragraph":{r+=this.renderer.paragraph(o);break}case"text":{r+=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 r}parseInline(e,r=this.renderer){let n="";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)){n+=c||"";continue}}let i=o;switch(i.type){case"escape":{n+=r.text(i);break}case"html":{n+=r.html(i);break}case"link":{n+=r.link(i);break}case"image":{n+=r.image(i);break}case"checkbox":{n+=r.checkbox(i);break}case"strong":{n+=r.strong(i);break}case"em":{n+=r.em(i);break}case"codespan":{n+=r.codespan(i);break}case"br":{n+=r.br(i);break}case"del":{n+=r.del(i);break}case"text":{n+=r.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 n}},ps=class{options;block;constructor(t){this.options=t||hn}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?tr.lex:tr.lexInline}provideParser(){return this.block?rr.parse:rr.parseInline}},F2=class{defaults=fl();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=rr;Renderer=Xo;TextRenderer=bl;Lexer=tr;Tokenizer=Qo;Hooks=ps;constructor(...t){this.use(...t)}walkTokens(t,e){let r=[];for(let n of t)switch(r=r.concat(e.call(this,n)),n.type){case"table":{let s=n;for(let o of s.header)r=r.concat(this.walkTokens(o.tokens,e));for(let o of s.rows)for(let i of o)r=r.concat(this.walkTokens(i.tokens,e));break}case"list":{let s=n;r=r.concat(this.walkTokens(s.items,e));break}default:{let s=n;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(o=>{let i=s[o].flat(1/0);r=r.concat(this.walkTokens(i,e))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let n={...r};if(n.async=this.defaults.async||n.async||!1,r.extensions&&(r.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)}),n.extensions=e),r.renderer){let s=this.defaults.renderer||new Xo(this.defaults);for(let o in r.renderer){if(!(o in s))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let i=o,c=r.renderer[i],a=s[i];s[i]=(...u)=>{let f=c.apply(s,u);return f===!1&&(f=a.apply(s,u)),f||""}}n.renderer=s}if(r.tokenizer){let s=this.defaults.tokenizer||new Qo(this.defaults);for(let o in r.tokenizer){if(!(o in s))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let i=o,c=r.tokenizer[i],a=s[i];s[i]=(...u)=>{let f=c.apply(s,u);return f===!1&&(f=a.apply(s,u)),f}}n.tokenizer=s}if(r.hooks){let s=this.defaults.hooks||new ps;for(let o in r.hooks){if(!(o in s))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let i=o,c=r.hooks[i],a=s[i];ps.passThroughHooks.has(o)?s[i]=u=>{if(this.defaults.async&&ps.passThroughHooksRespectAsync.has(o))return(async()=>{let d=await c.call(s,u);return a.call(s,d)})();let f=c.call(s,u);return a.call(s,f)}:s[i]=(...u)=>{if(this.defaults.async)return(async()=>{let d=await c.apply(s,u);return d===!1&&(d=await a.apply(s,u)),d})();let f=c.apply(s,u);return f===!1&&(f=a.apply(s,u)),f}}n.hooks=s}if(r.walkTokens){let s=this.defaults.walkTokens,o=r.walkTokens;n.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,...n}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return tr.lex(t,e??this.defaults)}parser(t,e){return rr.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let n={...r},s={...this.defaults,...n},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&n.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?tr.lex:tr.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?rr.parse:rr.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?tr.lex:tr.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?rr.parse:rr.parseInline)(i,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(i){return o(i)}}}onError(t,e){return r=>{if(r.message+=`
|
|
82
|
+
Please report this to https://github.com/markedjs/marked.`,t){let n="<p>An error occurred:</p><pre>"+Rr(r.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(r);throw r}}},ln=new F2;function Re(t,e){return ln.parse(t,e)}Re.options=Re.setOptions=function(t){return ln.setOptions(t),Re.defaults=ln.defaults,xg(Re.defaults),Re};Re.getDefaults=fl;Re.defaults=hn;Re.use=function(...t){return ln.use(...t),Re.defaults=ln.defaults,xg(Re.defaults),Re};Re.walkTokens=function(t,e){return ln.walkTokens(t,e)};Re.parseInline=ln.parseInline;Re.Parser=rr;Re.parser=rr.parse;Re.Renderer=Xo;Re.TextRenderer=bl;Re.Lexer=tr;Re.lexer=tr.lex;Re.Tokenizer=Qo;Re.Hooks=ps;Re.parse=Re;Re.options;Re.setOptions;Re.use;Re.walkTokens;Re.parseInline;rr.parse;tr.lex;Re.setOptions({breaks:!0,gfm:!0});const _n=t=>t?new Date(t).toLocaleString():"-",P2=(t,e)=>t.length>e?t.slice(0,e)+"...":t,j2=t=>ul(t),wo=t=>ul(t),Ss=t=>typeof t=="string"?t:Array.isArray(t)?t.map(Ss).join(""):t.type==="text"?t.text??"":t.type==="thinking"?"":t.type==="tool_result"?t.content?Ss(t.content):"0":t.content?Ss(t.content):"",zu=t=>{let e="";if(t.summary)e=t.summary;else if(t.content)e=Ss(t.content);else{const r=t.message;r?.content&&(e=Ss(r.content))}return wo(e)},L2=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"}},$2=t=>{const e=t;if(e?.subtype!=="turn_duration")return null;const r=e.durationMs??0,n=Math.round(r/1e3),s=Math.floor(n/60),o=n%60,i=s>0?`${s}m ${o}s`:`${o}s`;return{durationMs:r,durationFormatted:i}},D2=t=>{const e=t;if(e?.type!=="progress")return null;const r=e.data;return r?{type:r.type??"unknown",hookEvent:r.hookEvent,hookName:r.hookName,command:r.command}:null},U2=t=>{const e=[],r=/<(ide_[^>]+)>([\s\S]*?)<\/\1>/g;let n=0,s;for(;(s=r.exec(t))!==null;){if(s.index>n){const o=t.slice(n,s.index).trim();o&&e.push({type:"text",content:o})}e.push({type:"ide_tag",tag:s[1],content:s[2].trim()}),n=r.lastIndex}if(n<t.length){const o=t.slice(n).trim();o&&e.push({type:"text",content:o})}return e};var B2=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"><code> </code></pre>'),q2=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"> </pre>'),z2=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>'),V2=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),H2=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>'),K2=C('<div class="relative"><!> <!></div>'),W2=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"><code> </code></pre>'),J2=C('<pre class="whitespace-pre-wrap font-mono text-xs text-gh-text-secondary overflow-x-auto"> </pre>');function ho(t,e){Yt(e,!0);let r=Me(e,"maxLines",3,10),n=Qe(!1),s=Qe(!1);const o=V(()=>e.content.split(`
|
|
83
|
+
`)),i=V(()=>l(o).length>r()),c=V(()=>l(i)&&!l(n)?l(o).slice(0,r()).join(`
|
|
84
|
+
`):e.content);var a=te(),u=G(a);{var f=h=>{var v=K2(),p=m(v);{var S=R=>{var L=B2(),O=m(L),I=m(O,!0);g(O),g(L),U(()=>{Te(O,1,`language-${e.lang??""}`),M(I,l(c))}),_(R,L)},b=R=>{var L=q2(),O=m(L,!0);g(L),U(()=>M(O,l(c))),_(R,L)};N(p,R=>{e.lang?R(S):R(b,!1)})}var k=w(p,2);{var F=R=>{var L=V2(),O=w(G(L),2);{var I=x=>{var A=z2();A.__click=()=>K(n,!0);var E=m(A);g(A),U(()=>M(E,`Click to expand (${l(o).length-r()} more lines)`)),_(x,A)};N(O,x=>{l(s)&&x(I)})}_(R,L)},B=R=>{var L=H2();L.__click=()=>K(n,!1),_(R,L)};N(k,R=>{l(n)?R(B,!1):R(F)})}g(v),Kr("mouseenter",v,()=>K(s,!0)),Kr("mouseleave",v,()=>K(s,!1)),_(h,v)},d=h=>{var v=te(),p=G(v);{var S=k=>{var F=W2(),B=m(F),R=m(B,!0);g(B),g(F),U(()=>{Te(B,1,`language-${e.lang??""}`),M(R,e.content)}),_(k,F)},b=k=>{var F=J2(),B=m(F,!0);g(F),U(()=>M(B,e.content)),_(k,F)};N(p,k=>{e.lang?k(S):k(b,!1)},!0)}_(h,v)};N(u,h=>{l(i)?h(f):h(d,!1)})}_(t,a),Zt()}lr(["click"]);var G2=C('<button class="font-mono hover:underline cursor-pointer bg-transparent border-none text-blue-400 p-0"> </button>'),Y2=C('<span class="font-mono opacity-60"> </span>'),Z2=C('<span class="font-mono"> </span>'),Q2=C('<span class="opacity-60"> </span>'),X2=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>'),eI=C('<button class="font-mono hover:underline cursor-pointer bg-transparent border-none text-purple-400 p-0"> </button>'),tI=C('<span class="font-mono opacity-60"> </span>'),rI=C('<span class="font-mono"> </span>'),nI=C('<span class="font-mono"> </span>'),sI=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>'),oI=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 iI(t,e){Yt(e,!0);const r=V(()=>{const u=e.content.match(/(?:opened the file |selected.*from )(\/[^\s]+)/);return u?u[1]:e.content.trim().startsWith("/")?e.content.trim().split(`
|
|
85
|
+
`)[0].split(" ")[0]:null}),n=V(()=>{const u=e.content.match(/lines? (\d+)(?:\s*to\s*(\d+))?/);return u?u[2]?`L${u[1]}-${u[2]}`:`L${u[1]}`:null}),s=async()=>{l(r)&&await sc(l(r))};var o=te(),i=G(o);{var c=u=>{var f=X2(),d=w(m(f),2);{var h=p=>{var S=te(),b=G(S);sa(b,()=>ia(l(r)),k=>{var F=Z2(),B=m(F,!0);g(F),U(R=>M(B,R),[()=>l(r).split("/").pop()]),_(k,F)},(k,F)=>{var B=te(),R=G(B);{var L=I=>{var x=G2();x.__click=s;var A=m(x);g(x),U(E=>{ye(x,"title",l(r)),M(A,`${E??""}${l(n)?`:${l(n)}`:""}`)},[()=>l(r).split("/").pop()]),_(I,x)},O=I=>{var x=Y2(),A=m(x,!0);g(x),U(E=>{ye(x,"title",l(r)),M(A,E)},[()=>l(r).split("/").pop()]),_(I,x)};N(R,I=>{l(F)?I(L):I(O,!1)})}_(k,B)}),_(p,S)},v=p=>{var S=Q2(),b=m(S,!0);g(S),U(()=>M(b,e.content)),_(p,S)};N(d,p=>{l(r)?p(h):p(v,!1)})}g(f),_(u,f)},a=u=>{var f=te(),d=G(f);{var h=p=>{var S=sI(),b=m(S),k=w(m(b),2);{var F=R=>{var L=te(),O=G(L);sa(O,()=>ia(l(r)),I=>{var x=rI(),A=m(x);g(x),U(E=>M(A,`${E??""}${l(n)?`:${l(n)}`:""}`),[()=>l(r).split("/").pop()]),_(I,x)},(I,x)=>{var A=te(),E=G(A);{var D=ue=>{var z=eI();z.__click=s;var q=m(z);g(z),U(P=>{ye(z,"title",l(r)),M(q,`${P??""}${l(n)?`:${l(n)}`:""}`)},[()=>l(r).split("/").pop()]),_(ue,z)},oe=ue=>{var z=tI(),q=m(z);g(z),U(P=>{ye(z,"title",l(r)),M(q,`${P??""}${l(n)?`:${l(n)}`:""}`)},[()=>l(r).split("/").pop()]),_(ue,z)};N(E,ue=>{l(x)?ue(D):ue(oe,!1)})}_(I,A)}),_(R,L)},B=R=>{var L=nI(),O=m(L,!0);g(L),U(I=>M(O,I),[()=>e.content.split(`
|
|
86
|
+
`)[0].slice(0,60)]),_(R,L)};N(k,R=>{l(r)?R(F):R(B,!1)})}g(b),g(S),_(p,S)},v=p=>{var S=oI(),b=w(m(S),2),k=m(b);g(b);var F=w(b,2),B=m(F);g(F),g(S),U(R=>{M(k,`<${e.tag??""}>`),M(B,`${R??""}${e.content.length>50?"...":""}`)},[()=>e.content.slice(0,50)]),_(p,S)};N(d,p=>{e.tag==="ide_selection"?p(h):p(v,!1)},!0)}_(u,f)};N(i,u=>{e.tag==="ide_opened_file"?u(c):u(a,!1)})}_(t,o),Zt()}lr(["click"]);var aI=C('<li><span class="flex-shrink-0"> </span> <span> </span></li>'),cI=C('<ul class="space-y-1.5 mt-1"></ul>');function lI(t,e){const r=o=>{switch(o){case"completed":return"✅";case"in_progress":return"🔄";case"pending":return"⬜"}},n=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=cI();bt(s,21,()=>e.todos,wt,(o,i)=>{var c=aI(),a=m(c),u=m(a,!0);g(a);var f=w(a,2),d=m(f,!0);g(f),g(c),U((h,v)=>{Te(c,1,`flex items-start gap-2 text-sm ${h??""}`),M(u,v),Te(f,1,Is(l(i).status==="completed"?"line-through opacity-70":"")),M(d,l(i).status==="in_progress"?l(i).activeForm:l(i).content)},[()=>n(l(i).status),()=>r(l(i).status)]),_(o,c)}),g(s),_(t,s)}var uI=C('<span class="tooltip svelte-1yfjzin"> </span>'),fI=C("<button><!></button> <!>",1);function Rn(t,e){let r=Me(e,"position",3,"bottom"),n=Me(e,"class",3,""),s=yp(e,["$$slots","$$events","$$legacy","title","children","position","class"]),o=Qe(null),i=Qe(!1),c=Qe("");const a=()=>{if(!l(o))return;const b=l(o).getBoundingClientRect(),k=b.left+b.width/2;r()==="top"?K(c,`left: ${k}px; bottom: ${window.innerHeight-b.top+8}px;`):K(c,`left: ${k}px; top: ${b.bottom+8}px;`)},u=()=>{a(),K(i,!0)},f=()=>{K(i,!1)};var d=fI(),h=G(d);Pp(h,()=>({class:`tooltip-btn ${n()??""}`,onmouseenter:u,onmouseleave:f,...s}),void 0,void 0,void 0,"svelte-1yfjzin");var v=m(h);Cp(v,()=>e.children),g(h),rc(h,b=>K(o,b),()=>l(o));var p=w(h,2);{var S=b=>{var k=uI(),F=m(k,!0);g(k),U(()=>{cf(k,l(c)),M(F,e.title)}),_(b,k)};N(p,b=>{l(i)&&b(S)})}_(t,d)}var hI=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>'),dI=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>'),gI=C('<span class="font-mono"> </span>'),pI=C('<div class="mt-1 text-xs text-gh-text-secondary"></div>'),mI=C("<p> </p>"),vI=C('<div class="mt-1 text-xs text-red-400"></div>'),_I=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>'),bI=C('<button class="text-gh-accent hover:underline cursor-pointer bg-transparent border-none p-0" title="Open backup in VS Code"> </button>'),yI=C('<span class="text-gh-text-secondary"> </span>'),xI=C('<li class="font-mono text-xs truncate"><!></li>'),kI=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>'),SI=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>'),wI=C('<p class="mt-1 text-sm text-gh-text-secondary"> </p>'),II=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>'),TI=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>'),RI=C('<span class="mt-1 text-sm text-gh-text-secondary font-mono"> </span>'),CI=C('<span class="mt-1 text-sm text-gh-text-secondary font-mono"> </span>'),EI=C('<p class="mt-1 text-sm text-gh-text-secondary"> </p>'),OI=C("<!> <!>",1),MI=C(" <!>",1),AI=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>'),NI=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>'),FI=C('<div class="message-content text-sm"></div>'),PI=C('<span class="font-semibold text-purple-400"> </span>'),jI=C('<p class="whitespace-pre-wrap"> </p>'),LI=C('<div class="message-content text-sm"><!></div>'),$I=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 DI(t,e){Yt(e,!0);const r=q=>{var P=te(),j=G(P);{var Je=tt=>{Rn(tt,{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:(je,Ne)=>{kn();var zt=jt("✂️");_(je,zt)},$$slots:{default:!0}})};N(j,tt=>{e.onSplit&&!s()&&e.msg.uuid&&tt(Je)})}_(q,P)},n=q=>{Rn(q,{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:(P,j)=>{kn();var Je=jt("🗑️");_(P,Je)},$$slots:{default:!0}})};let s=Me(e,"isFirst",3,!1);const o=V(()=>e.msg.uuid??""),i=V(()=>e.msg.type==="assistant"),c=V(()=>e.msg.type==="custom-title"),a=V(()=>e.msg.type==="file-history-snapshot"),u=V(()=>e.msg.type==="human"||e.msg.type==="user"),f=V(()=>e.msg.type==="system"&&e.msg.subtype==="local_command"),d=V(()=>e.msg.type==="queue-operation"),h=V(()=>{if(e.msg.type!=="user")return!1;const q=e.msg.message;return Array.isArray(q?.content)?q.content[0]?.type==="tool_result":!1}),v=V(()=>{if(!l(a))return null;const q=e.msg.snapshot,P=q?.trackedFileBackups??{};return{files:Object.entries(P),timestamp:q?.timestamp}}),p=V(()=>{if(l(f)){const q=typeof e.msg.content=="string"?e.msg.content:"";return Wa(q)}if(l(u)){const q=e.msg.message,P=typeof q?.content=="string"?q.content:"";if(P.includes("<command-name>"))return Wa(P)}return null}),S=V(()=>l(p)!==null&&!l(f)),b=V(()=>L2(e.msg)),k=V(()=>$2(e.msg)),F=V(()=>D2(e.msg)),B=["Read","Write","Edit"],R=V(()=>{if(!l(i))return null;const q=e.msg.message;if(!Array.isArray(q?.content))return null;const P=q.content.find(j=>typeof j=="object"&&j!==null&&j.type==="tool_use");return P?{name:P.name,input:P.input,filePath:B.includes(P.name)?P.input.file_path:null}:null}),L=V(()=>{if(!l(i))return[];const q=e.msg.message;return Array.isArray(q?.content)?q.content.filter(P=>typeof P=="object"&&P!==null&&P.type==="thinking"):[]}),O=V(()=>e.msg.customTitle??""),I=V(()=>e.msg.uuid||e.msg.messageId||""),x=V(()=>{if(l(d))return!1;if(l(a)||l(f)||l(c)||l(R)||zu(e.msg).trim().length>0)return!0;if(e.msg.type==="user"||e.msg.type==="human"){const P=l(h)?"Tool result":"User message";console.warn(`${P} without content:`,wp(e.msg))}return!1}),A=V(()=>l(x)||l(L).length>0),E=V(()=>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 D=te(),oe=G(D);{var ue=q=>{},z=q=>{var P=te(),j=G(P);{var Je=je=>{var Ne=hI(),zt=m(Ne),yt=m(zt),Ur=m(yt);g(yt);var it=w(yt,2),At=m(it);r(At);var ur=w(At,2);n(ur),g(it),g(zt),g(Ne),U(()=>{ye(Ne,"data-msg-id",l(o)),M(Ur,`🔄 ${l(F).hookName??l(F).type??""}`)}),_(je,Ne)},tt=je=>{var Ne=te(),zt=G(Ne);{var yt=it=>{var At=dI(),ur=m(At),xr=m(ur),It=m(xr);g(xr);var pt=w(xr,2),$=m(pt);r($);var J=w($,2);n(J),g(pt),g(ur),g(At),U(()=>{ye(At,"data-msg-id",l(o)),M(It,`⏱️ ${l(k).durationFormatted??""}`)}),_(it,At)},Ur=it=>{var At=te(),ur=G(At);{var xr=pt=>{var $=_I(),J=m($),fe=m(J),Fe=m(fe);g(fe);var Ce=w(fe,2),he=m(Ce),ce=m(he,!0);g(he);var de=w(he,2);r(de);var Ge=w(de,2);n(Ge),g(Ce),g(J);var xe=w(J,2);{var Z=ee=>{var ke=pI();bt(ke,21,()=>l(b).hookInfos,wt,(ge,Pe)=>{var Se=gI(),Be=m(Se,!0);g(Se),U(()=>M(Be,l(Pe).command)),_(ge,Se)}),g(ke),_(ee,ke)};N(xe,ee=>{l(b).hookInfos.length>0&&ee(Z)})}var Ue=w(xe,2);{var at=ee=>{var ke=vI();bt(ke,21,()=>l(b).hookErrors,wt,(ge,Pe)=>{var Se=mI(),Be=m(Se,!0);g(Se),U(()=>M(Be,l(Pe))),_(ge,Se)}),g(ke),_(ee,ke)};N(Ue,ee=>{l(b).hookErrors.length>0&&ee(at)})}g($),U(ee=>{ye($,"data-msg-id",l(o)),M(Fe,`🪝 Hook (${l(b).hookCount??""})`),M(ce,ee)},[()=>_n(e.msg.timestamp)]),_(pt,$)},It=pt=>{var $=te(),J=G($);{var fe=Ce=>{var he=kI(),ce=m(he),de=m(ce),Ge=m(de);g(de);var xe=w(de,2),Z=m(xe),Ue=m(Z,!0);g(Z);var at=w(Z,2);r(at);var ee=w(at,2);n(ee),g(xe),g(ce);var ke=w(ce,2);bt(ke,21,()=>l(v).files,wt,(ge,Pe)=>{var Se=V(()=>sf(l(Pe),2));let Be=()=>l(Se)[0],Ee=()=>l(Se)[1];const qe=V(()=>!!(Ee().backupFileName&&e.sessionId));var ct=xI(),Ye=m(ct);{var lt=$e=>{var ve=bI();ve.__click=()=>Dp(e.sessionId,Ee().backupFileName);var Ze=m(ve,!0);g(ve),U(Nt=>M(Ze,Nt),[()=>wo(Be())]),_($e,ve)},Le=$e=>{var ve=yI(),Ze=m(ve,!0);g(ve),U(Nt=>M(Ze,Nt),[()=>wo(Be())]),_($e,ve)};N(Ye,$e=>{l(qe)?$e(lt):$e(Le,!1)})}g(ct),U($e=>ye(ct,"title",$e),[()=>wo(Be())]),_(ge,ct)}),g(ke),g(he),U(ge=>{ye(he,"data-msg-id",l(o)),ye(he,"title",`messageId: ${l(I)??""}`),M(Ge,`📁 File Backups (${l(v).files.length??""})`),M(Ue,ge)},[()=>_n(l(v).timestamp)]),_(Ce,he)},Fe=Ce=>{var he=te(),ce=G(he);{var de=xe=>{var Z=SI(),Ue=m(Z),at=m(Ue),ee=m(at,!0);g(at);var ke=w(at,2),ge=m(ke),Pe=m(ge,!0);g(ge);var Se=w(ge,2);r(Se);var Be=w(Se,2);n(Be),g(ke),g(Ue),g(Z),U(Ee=>{ye(Z,"data-msg-id",l(o)),M(ee,l(p).name||"Command"),M(Pe,Ee)},[()=>_n(e.msg.timestamp)]),_(xe,Z)},Ge=xe=>{var Z=te(),Ue=G(Z);{var at=ke=>{var ge=II(),Pe=m(ge),Se=m(Pe),Be=m(Se);g(Se);var Ee=w(Se,2),qe=m(Ee),ct=m(qe,!0);g(qe);var Ye=w(qe,2);r(Ye);var lt=w(Ye,2);n(lt),g(Ee),g(Pe);var Le=w(Pe,2);{var $e=ve=>{var Ze=wI(),Nt=m(Ze,!0);g(Ze),U(()=>M(Nt,l(p).message)),_(ve,Ze)};N(Le,ve=>{l(p).message&&l(p).message!==l(p).name?.slice(1)&&ve($e)})}g(ge),U(ve=>{ye(ge,"data-msg-id",l(o)),M(Be,`⚡ ${(l(p).name||"Command")??""}`),M(ct,ve)},[()=>_n(e.msg.timestamp)]),_(ke,ge)},ee=ke=>{var ge=te(),Pe=G(ge);{var Se=Ee=>{var qe=AI(),ct=m(qe),Ye=m(ct),lt=m(Ye);g(Ye);var Le=w(Ye,2),$e=m(Le),ve=m($e,!0);g($e);var Ze=w($e,2);r(Ze);var Nt=w(Ze,2);n(Nt),g(Le),g(ct);var fr=w(ct,2);{var Br=xt=>{var Vt=te(),kr=G(Vt);sa(kr,()=>ia(l(R).filePath),hr=>{var Qt=CI(),kt=m(Qt,!0);g(Qt),U(Tt=>M(kt,Tt),[()=>l(R).filePath.split("/").pop()]),_(hr,Qt)},(hr,Qt)=>{var kt=te(),Tt=G(kt);{var Ht=Oe=>{var we=TI();we.__click=()=>sc(l(R).filePath);var St=m(we,!0);g(we),U(Ve=>{ye(we,"title",l(R).filePath),M(St,Ve)},[()=>l(R).filePath.split("/").pop()]),_(Oe,we)},dr=Oe=>{var we=RI(),St=m(we,!0);g(we),U(Ve=>{ye(we,"title",l(R).filePath),M(St,Ve)},[()=>l(R).filePath.split("/").pop()]),_(Oe,we)};N(Tt,Oe=>{l(Qt)?Oe(Ht):Oe(dr,!1)})}_(hr,kt)}),_(xt,Vt)},Ft=xt=>{var Vt=te(),kr=G(Vt);{var hr=kt=>{var Tt=OI(),Ht=G(Tt);{var dr=we=>{var St=EI(),Ve=m(St,!0);g(St),U(()=>M(Ve,l(R).input.description)),_(we,St)};N(Ht,we=>{l(R).input.description&&we(dr)})}var Oe=w(Ht,2);{let we=V(()=>String(l(R).input.command));ho(Oe,{get content(){return l(we)},lang:"sh",maxLines:3})}_(kt,Tt)},Qt=kt=>{const Tt=V(()=>{const{path:Ve,...W}=l(R).input;return{_path:Ve,input:W}}),Ht=V(()=>Object.keys(l(Tt).input));var dr=te(),Oe=G(dr);{var we=Ve=>{const W=V(()=>l(Ht)[0]),Y=V(()=>l(Tt).input[l(W)]);var Ie=MI(),ut=G(Ie),gr=w(ut);{var qr=ft=>{lI(ft,{get todos(){return l(Y)}})},dn=ft=>{{let gn=V(()=>`${l(W)} = ${JSON.stringify(l(Y),null,2)}`);ho(ft,{get content(){return l(gn)},lang:"js",maxLines:1})}};N(gr,ft=>{l(W)==="todos"&&Array.isArray(l(Y))?ft(qr):ft(dn,!1)})}U(ft=>M(ut,`${ft??""} `),[()=>(console.info(`${l(W)} =`,l(Y)),"")]),_(Ve,Ie)},St=Ve=>{{let W=V(()=>JSON.stringify(l(Tt).input,null,2));ho(Ve,{get content(){return l(W)},lang:"json",maxLines:6})}};N(Oe,Ve=>{l(Ht).length===1?Ve(we):Ve(St,!1)})}_(kt,dr)};N(kr,kt=>{l(R).input.command?kt(hr):kt(Qt,!1)},!0)}_(xt,Vt)};N(fr,xt=>{l(R).filePath?xt(Br):xt(Ft,!1)})}g(qe),U(xt=>{ye(qe,"data-msg-id",l(o)),M(lt,`🔧 ${l(R).name??""}`),M(ve,xt)},[()=>_n(e.msg.timestamp)]),_(Ee,qe)},Be=Ee=>{var qe=te(),ct=G(qe);{var Ye=lt=>{var Le=$I(),$e=m(Le),ve=m($e),Ze=m(ve,!0);g(ve);var Nt=w(ve,2),fr=m(Nt),Br=m(fr,!0);g(fr);var Ft=w(fr,2),xt=m(Ft,!0);g(Ft);var Vt=w(Ft,2);{var kr=Oe=>{Rn(Oe,{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:(we,St)=>{kn();var Ve=jt("✏️");_(we,Ve)},$$slots:{default:!0}})};N(Vt,Oe=>{l(c)&&e.onEditTitle&&Oe(kr)})}var hr=w(Vt,2);r(hr);var Qt=w(hr,2);n(Qt),g(Nt),g($e);var kt=w($e,2);{var Tt=Oe=>{var we=FI();bt(we,21,()=>l(L),wt,(St,Ve,W)=>{var Y=NI(),Ie=m(Y),ut=m(Ie);g(Ie);var gr=w(Ie,2),qr=m(gr,!0);g(gr),g(Y),U(()=>{M(ut,`💭 Thinking ${l(L).length>1?`(${W+1}/${l(L).length})`:""}`),M(qr,l(Ve).thinking)}),_(St,Y)}),g(we),_(Oe,we)};N(kt,Oe=>{l(L).length>0&&Oe(Tt)})}var Ht=w(kt,2);{var dr=Oe=>{var we=LI(),St=m(we);{var Ve=Y=>{var Ie=PI(),ut=m(Ie,!0);g(Ie),U(()=>M(ut,l(O))),_(Y,Ie)},W=Y=>{const Ie=V(()=>zu(e.msg)),ut=V(()=>U2(l(Ie)));var gr=te(),qr=G(gr);bt(qr,17,()=>l(ut),wt,(dn,ft)=>{var gn=te(),Fi=G(gn);{var mt=Rt=>{iI(Rt,{get tag(){return l(ft).tag},get content(){return l(ft).content}})},Pt=Rt=>{const Sr=V(()=>l(ft).content.split(`
|
|
87
|
+
`));var vt=te(),Kt=G(vt);{var Dt=Xt=>{ho(Xt,{get content(){return l(ft).content},maxLines:10})},wr=Xt=>{var rs=jI(),Pi=m(rs,!0);g(rs),U(()=>M(Pi,l(ft).content)),_(Xt,rs)};N(Kt,Xt=>{l(Sr).length>10?Xt(Dt):Xt(wr,!1)})}_(Rt,vt)};N(Fi,Rt=>{l(ft).type==="ide_tag"&&l(ft).tag?Rt(mt):Rt(Pt,!1)})}_(dn,gn)}),_(Y,gr)};N(St,Y=>{l(c)?Y(Ve):Y(W,!1)})}g(we),_(Oe,we)};N(Ht,Oe=>{l(x)&&Oe(dr)})}g(Le),U(Oe=>{ye(Le,"data-msg-id",l(o)),Te(Le,1,`p-4 rounded-lg group relative ${l(E)??""} flex flex-col ${l(A)?"gap-2":""}`),M(Ze,l(h)?"OUT":e.msg.type),M(Br,Oe),M(xt,l(I))},[()=>_n(e.msg.timestamp)]),_(lt,Le)};N(ct,lt=>{l(A)&<(Ye)},!0)}_(Ee,qe)};N(Pe,Ee=>{l(R)?Ee(Se):Ee(Be,!1)},!0)}_(ke,ge)};N(Ue,ke=>{l(f)&&l(p)?ke(at):ke(ee,!1)},!0)}_(xe,Z)};N(ce,xe=>{l(S)&&l(p)?xe(de):xe(Ge,!1)},!0)}_(Ce,he)};N(J,Ce=>{l(a)&&l(v)?Ce(fe):Ce(Fe,!1)},!0)}_(pt,$)};N(ur,pt=>{l(b)?pt(xr):pt(It,!1)},!0)}_(it,At)};N(zt,it=>{l(k)?it(yt):it(Ur,!1)},!0)}_(je,Ne)};N(j,je=>{l(F)?je(Je):je(tt,!1)},!0)}_(q,P)};N(oe,q=>{l(d)?q(ue):q(z,!1)})}_(t,D),Zt()}lr(["click"]);var UI=C("<section><div></div></section>");function Vu(t,e){Yt(e,!0);let r=Me(e,"enableScroll",3,!0),n=Me(e,"fullWidth",3,!1);const s=V(()=>e.messages.findIndex(c=>c.type==="user"||c.type==="assistant"||c.type==="human"));var o=UI(),i=m(o);bt(i,23,()=>e.messages,(c,a)=>c.uuid??`idx-${a}`,(c,a,u)=>{{let f=V(()=>l(u)===0||l(u)===l(s));DI(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}})}}),g(i),g(o),U(()=>{Te(o,1,`bg-gh-bg-secondary overflow-hidden flex flex-col ${n()?"":"border border-gh-border rounded-lg"}`),Te(i,1,`${r()?"overflow-y-auto":""} flex-1 p-4 flex flex-col gap-4`)}),_(t,o),Zt()}var BI=C(' <span class="text-gh-text-secondary"> </span>',1),qI=C('<span><span class="text-gh-accent"> </span><!></span>'),zI=C("<span> </span>");function Za(t,e){Yt(e,!0);let r=Me(e,"class",3,"");const n=V(()=>()=>{if(!e.title.startsWith("/"))return null;const a=e.title.indexOf(" ");return a===-1?{command:e.title,args:""}:{command:e.title.slice(0,a),args:e.title.slice(a+1)}});var s=te(),o=G(s);{var i=a=>{var u=qI(),f=m(u),d=m(f,!0);g(f);var h=w(f);{var v=p=>{var S=BI(),b=G(S,!0);b.nodeValue=" ";var k=w(b),F=m(k,!0);g(k),U(B=>M(F,B),[()=>l(n)().args]),_(p,S)};N(h,p=>{l(n)().args&&p(v)})}g(u),U(p=>{Te(u,1,Is(r())),M(d,p)},[()=>l(n)().command]),_(a,u)},c=a=>{var u=zI(),f=m(u,!0);g(u),U(()=>{Te(u,1,Is(r())),M(f,e.title)}),_(a,u)};N(o,a=>{l(n)()?a(i):a(c,!1)})}_(t,s),Zt()}var VI=C("<option> </option>"),HI=C('<li class="py-2 px-8 text-gh-text-secondary text-sm">Loading...</li>'),KI=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>'),WI=C('<span class="w-5 ml-1"></span>'),JI=C('<span class="flex items-center gap-0.5"><span>🤖</span><span> </span></span>'),GI=C('<span class="flex items-center gap-0.5"><span>📋</span><span> </span></span>'),YI=C('<span class="pl-6 text-[10px] text-gh-text-secondary/70"> </span>'),ZI=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>'),QI=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>'),XI=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>'),eT=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>'),tT=C('<ul class="bg-gh-bg-secondary/50 border-t border-gh-border-subtle text-xs"><!> <!> <!> <!></ul>'),rT=C('<li draggable="true"><div class="flex items-center"><!> <button class="flex-1 min-w-0 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> <div><span class="flex-1 min-w-0 pl-7 pr-2 text-xs text-gh-text-secondary italic overflow-hidden text-ellipsis whitespace-nowrap"><!></span> <div class="flex-shrink-0 flex gap-0.5 pr-2 pointer-events-auto"><!> <!> <!></div></div></div> <!></li>'),nT=C('<ul class="bg-gh-bg"><!></ul>'),sT=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>'),oT=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 fR(t,e){Yt(e,!0);const r=()=>kp(ll,"$appConfig",n),[n,s]=xp(),o={summary:"Summary Time",modified:"Modified",created:"Created",updated:"Last Message",messageCount:"Messages",title:"Title"},i=P=>{const j=P.target;e.onSortChange?.(j.value,e.sortOrder)},c=()=>{e.onSortChange?.(e.sortField,e.sortOrder==="asc"?"desc":"asc")},a=(P,j)=>e.projectSessionData.get(P)?.get(j),u=P=>{const j=a(P.projectName,P.id);return vg(j?.customTitle,j?.currentSummary,P.title)},f=P=>{const j=a(P.projectName,P.id);return j?.customTitle&&j?.currentSummary?j.currentSummary:j?.currentSummary&&P.title&&P.title!=="Untitled"?P.title:j?.currentSummary?j.currentSummary:P.title??"No summary available"},d=P=>{const j=a(P.projectName,P.id),Je=j?.todos?j.todos.sessionTodos.length+j.todos.agentTodos.reduce((tt,je)=>tt+je.todos.length,0):0;return{agents:j?.agents.length??0,todos:Je,summaries:j?.summaries.length??0}},h=V(()=>Hw(e.projects,{currentProjectName:r().currentProjectName,homeDir:r().homeDir}));let v=Qe(Ro(e.selectedSession?new Set([e.selectedSession.id]):new Set));const p=(P,j)=>{P.stopPropagation(),l(v).has(j)?l(v).delete(j):l(v).add(j),K(v,new Set(l(v)),!0)};let S=Qe(null),b=Qe(null);const k=(P,j)=>{P.dataTransfer&&(K(S,j,!0),P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("text/plain",JSON.stringify({id:j.id,project:j.projectName})))},F=()=>{K(S,null),K(b,null)},B=(P,j)=>{!l(S)||l(S).projectName===j||(P.preventDefault(),P.dataTransfer&&(P.dataTransfer.dropEffect="move"),K(b,j,!0))},R=()=>{K(b,null)},L=(P,j)=>{P.preventDefault(),K(b,null),!(!l(S)||l(S).projectName===j)&&(e.onMoveSession?.(l(S),j),K(S,null))};var O=oT(),I=m(O),x=m(I),A=m(x);g(x);var E=w(x,2),D=w(m(E),2);D.__change=i,bt(D,21,()=>Object.entries(o),wt,(P,j)=>{var Je=V(()=>sf(l(j),2));let tt=()=>l(Je)[0],je=()=>l(Je)[1];var Ne=VI(),zt=m(Ne,!0);g(Ne);var yt={};U(()=>{M(zt,je()),yt!==(yt=tt())&&(Ne.value=(Ne.__value=tt())??"")}),_(P,Ne)}),g(D);var oe;lf(D);var ue=w(D,2);ue.__click=c;var z=m(ue,!0);g(ue),g(E),g(I);var q=w(I,2);bt(q,21,()=>l(h),wt,(P,j)=>{const Je=V(()=>l(b)===l(j).name);var tt=sT(),je=m(tt);je.__click=()=>e.onToggleProject(l(j).name);var Ne=m(je),zt=m(Ne,!0);g(Ne);var yt=w(Ne,2),Ur=m(yt,!0);g(yt);var it=w(yt,2),At=m(it,!0);g(it),g(je);var ur=w(je,2);{var xr=It=>{var pt=nT(),$=m(pt);{var J=Fe=>{var Ce=HI();_(Fe,Ce)},fe=Fe=>{var Ce=te(),he=G(Ce);bt(he,17,()=>e.projectSessions.get(l(j).name)??[],wt,(ce,de)=>{const Ge=V(()=>e.selectedSession?.id===l(de).id),xe=V(()=>l(S)?.id===l(de).id),Z=V(()=>d(l(de))),Ue=V(()=>u(l(de))),at=V(()=>f(l(de))),ee=V(()=>a(l(de).projectName,l(de).id)),ke=V(()=>!l(ee)?.customTitle&&!l(ee)?.currentSummary),ge=V(()=>l(v).has(l(de).id)),Pe=V(()=>l(Z).summaries>0||l(Z).agents>0||l(Z).todos>0);var Se=rT(),Be=m(Se),Ee=m(Be);{var qe=W=>{var Y=KI();Y.__click=ut=>p(ut,l(de).id);var Ie=m(Y,!0);g(Y),U(()=>{ye(Y,"title",l(ge)?"Collapse":"Expand"),M(Ie,l(ge)?"▼":"▶")}),_(W,Y)},ct=W=>{var Y=WI();_(W,Y)};N(Ee,W=>{l(Pe)?W(qe):W(ct,!1)})}var Ye=w(Ee,2);Ye.__click=()=>e.onSelectSession(l(de));var lt=m(Ye),Le=m(lt);Za(Le,{get title(){return l(Ue)}}),g(lt);var $e=w(lt,2),ve=m($e),Ze=w(m(ve)),Nt=m(Ze,!0);g(Ze),g(ve);var fr=w(ve,2);{var Br=W=>{var Y=JI(),Ie=w(m(Y)),ut=m(Ie,!0);g(Ie),g(Y),U(()=>{ye(Y,"title",`${l(Z).agents??""} agent(s)`),M(ut,l(Z).agents)}),_(W,Y)};N(fr,W=>{l(Z).agents>0&&W(Br)})}var Ft=w(fr,2);{var xt=W=>{var Y=GI(),Ie=w(m(Y)),ut=m(Ie,!0);g(Ie),g(Y),U(()=>{ye(Y,"title",`${l(Z).todos??""} todo(s)`),M(ut,l(Z).todos)}),_(W,Y)};N(Ft,W=>{l(Z).todos>0&&W(xt)})}g($e),g(Ye);var Vt=w(Ye,2),kr=m(Vt),hr=m(kr);{var Qt=W=>{var Y=jt();U(Ie=>M(Y,Ie),[()=>l(ee).currentSummary.length>50?l(ee).currentSummary.slice(0,47)+"...":l(ee).currentSummary]),_(W,Y)},kt=W=>{Za(W,{get title(){return l(Ue)}})};N(hr,W=>{l(ee)?.currentSummary?W(Qt):W(kt,!1)})}g(kr);var Tt=w(kr,2),Ht=m(Tt);{var dr=W=>{Rn(W,{class:"p-1 rounded hover:bg-gh-green/20 text-xs",onclick:Y=>e.onResumeSession(Y,l(de)),title:"Resume session",children:(Y,Ie)=>{kn();var ut=jt("▶️");_(Y,ut)},$$slots:{default:!0}})};N(Ht,W=>{e.onResumeSession&&W(dr)})}var Oe=w(Ht,2);Rn(Oe,{class:"p-1 rounded hover:bg-gh-border text-xs",onclick:W=>e.onRenameSession(W,l(de)),title:"Rename",children:(W,Y)=>{kn();var Ie=jt("✏️");_(W,Ie)},$$slots:{default:!0}});var we=w(Oe,2);Rn(we,{class:"p-1 rounded hover:bg-gh-red/20 text-xs",onclick:W=>e.onDeleteSession(W,l(de)),title:"Delete",children:(W,Y)=>{kn();var Ie=jt("🗑️");_(W,Ie)},$$slots:{default:!0}}),g(Tt),g(Vt),g(Be);var St=w(Be,2);{var Ve=W=>{var Y=tT(),Ie=m(Y);{var ut=mt=>{var Pt=te(),Rt=G(Pt);bt(Rt,17,()=>l(ee).summaries,wt,(Sr,vt,Kt)=>{var Dt=ZI();Te(Dt,1,`py-1.5 px-4 pl-8 hover:bg-gh-border-subtle/50 flex flex-col gap-0.5 ${Kt===0?"text-gh-text":"text-gh-text-secondary"}`);var wr=m(Dt),Xt=w(m(wr),2),rs=m(Xt,!0);g(Xt),g(wr);var Pi=w(wr,2);{var Ag=ns=>{var ji=YI(),Ng=m(ji,!0);g(ji),U(Fg=>M(Ng,Fg),[()=>new Date(l(vt).timestamp).toLocaleString()]),_(ns,ji)};N(Pi,ns=>{l(vt).timestamp&&ns(Ag)})}g(Dt),U(ns=>{ye(Dt,"title",l(vt).summary),M(rs,ns)},[()=>l(vt).summary.length>100?l(vt).summary.slice(0,97)+"...":l(vt).summary]),_(Sr,Dt)}),_(mt,Pt)};N(Ie,mt=>{l(ee)?.summaries&&l(ee).summaries.length>0&&mt(ut)})}var gr=w(Ie,2);{var qr=mt=>{var Pt=QI(),Rt=w(m(Pt),2),Sr=m(Rt);g(Rt),g(Pt),U(()=>M(Sr,`Session Todos (${l(ee).todos.sessionTodos.length??""})`)),_(mt,Pt)};N(gr,mt=>{l(ee)?.todos?.sessionTodos&&l(ee).todos.sessionTodos.length>0&&mt(qr)})}var dn=w(gr,2);{var ft=mt=>{var Pt=te(),Rt=G(Pt);bt(Rt,17,()=>l(ee).todos.agentTodos,wt,(Sr,vt)=>{var Kt=XI(),Dt=w(m(Kt),2),wr=m(Dt);g(Dt),g(Kt),U(()=>M(wr,`Agent Todos (${l(vt).todos.length??""})`)),_(Sr,Kt)}),_(mt,Pt)};N(dn,mt=>{l(ee)?.todos?.agentTodos&&mt(ft)})}var gn=w(dn,2);{var Fi=mt=>{var Pt=te(),Rt=G(Pt);bt(Rt,17,()=>l(ee).agents,wt,(Sr,vt)=>{var Kt=eT(),Dt=w(m(Kt),2),wr=m(Dt);g(Dt),g(Kt),U(Xt=>{ye(Kt,"title",l(vt).name??l(vt).id),M(wr,`${Xt??""} (${l(vt).messageCount??""} msgs)`)},[()=>l(vt).name??l(vt).id.slice(0,12)+"..."]),_(Sr,Kt)}),_(mt,Pt)};N(gn,mt=>{l(ee)?.agents&&l(ee).agents.length>0&&mt(Fi)})}g(Y),_(W,Y)};N(St,W=>{l(ge)&&l(Pe)&&W(Ve)})}g(Se),U(()=>{Te(Se,1,`relative border-t border-gh-border-subtle group ${l(Ge)?"bg-gh-accent/20 border-l-3 border-l-gh-accent":""} ${l(xe)?"opacity-50":""}`),ye(Ye,"title",l(at)),Te(lt,1,`flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${l(ke)?"italic text-gh-text-secondary":""}`),ye(ve,"title",`${l(de).messageCount??""} messages`),M(Nt,l(de).messageCount),Te(Vt,1,`absolute left-0 right-0 top-0 h-8 flex items-center opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none ${l(Ge)?"bg-gradient-to-r from-[color-mix(in_srgb,var(--color-gh-accent)_20%,var(--color-gh-bg))] via-[color-mix(in_srgb,var(--color-gh-accent)_20%,var(--color-gh-bg))] to-[color-mix(in_srgb,var(--color-gh-accent)_20%,var(--color-gh-bg))]":"bg-gradient-to-r from-gh-bg via-gh-bg to-gh-bg"}`)}),Kr("dragstart",Se,W=>k(W,l(de))),Kr("dragend",Se,F),_(ce,Se)}),_(Fe,Ce)};N($,Fe=>{e.loadingProject===l(j).name?Fe(J):Fe(fe,!1)})}g(pt),_(It,pt)};N(ur,It=>{e.expandedProjects.has(l(j).name)&&It(xr)})}g(tt),U((It,pt,$)=>{Te(je,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 ${It??""} ${l(Je)?"bg-gh-green/20 ring-2 ring-gh-green ring-inset":""}`),M(zt,pt),ye(yt,"title",l(j).displayName),M(Ur,$),M(At,l(j).sessionCount)},[()=>e.expandedProjects.has(l(j).name)?"bg-gh-accent/10":"",()=>e.expandedProjects.has(l(j).name)?"▼":"▶",()=>j2(l(j).displayName)]),Kr("dragover",je,It=>B(It,l(j).name)),Kr("dragleave",je,R),Kr("drop",je,It=>L(It,l(j).name)),_(P,tt)}),g(q),g(O),U(()=>{M(A,`Projects (${l(h).length??""})`),oe!==(oe=e.sortField)&&(D.value=(D.__value=e.sortField)??"",Co(D,e.sortField)),ye(ue,"title",e.sortOrder==="desc"?"Descending (newest first)":"Ascending (oldest first)"),M(z,e.sortOrder==="desc"?"↓":"↑")}),_(t,O),Zt(),s()}lr(["change","click"]);var iT=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>'),aT=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 cT(t,e){Yt(e,!0);let r=Me(e,"class",3,"");const n=x=>{if(x.type!=="user"||!x.uuid)return!1;const A=x.toolUseResult;if(A){if(typeof A=="object")return"answers"in A;if(typeof A=="string"){const D="The user provided the following reason for the rejection:",oe=A.indexOf(D);if(oe!==-1)return A.slice(oe+D.length).trim().length>0}return!1}const E=x.message?.content??x.content;if(!E)return!1;if(typeof E=="string")return E.trim().length>0;if(!Array.isArray(E))return!1;for(const D of E)if(D.type==="text"&&D.text?.trim())return!0;return!1};let s=null,o=null;const i=()=>{if(s===null||o!==e.messages){s=[];for(let x=0;x<e.messages.length;x++)n(e.messages[x])&&s.push(x);o=e.messages}return s};let c=-1,a=null;const u=()=>{if(a!==e.messages){c=-1;for(let x=e.messages.length-1;x>=0;x--)if(e.messages[x].isCompactSummary){c=x;break}a=e.messages}},f=()=>(u(),c),d=()=>(u(),c>=0);let h=Qe(!1);xn(()=>{e.messages.length,K(h,d(),!0)});let v=Qe(0);const p=()=>{if(!e.scrollContainer)return 0;const x=e.scrollContainer.getBoundingClientRect(),A=e.scrollContainer.querySelectorAll("[data-msg-id]");for(let E=0;E<A.length;E++){const D=A[E];if(D.getBoundingClientRect().top>=x.top-50){const ue=D.getAttribute("data-msg-id"),z=e.messages.findIndex(q=>(q.uuid??`idx-${e.messages.indexOf(q)}`)===ue);return z>=0?z:E}}return 0},S=x=>{if(!e.scrollContainer||x<0||x>=e.messages.length)return;const A=e.messages[x].uuid??`idx-${x}`,E=e.scrollContainer.querySelector(`[data-msg-id="${A}"]`);E&&(E.scrollIntoView({behavior:"smooth",block:"start"}),K(v,x,!0))},b=()=>{e.scrollContainer?.scrollTo({top:0,behavior:"smooth"}),K(v,0)},k=()=>{e.scrollContainer&&(e.scrollContainer.scrollTo({top:e.scrollContainer.scrollHeight+1e4,behavior:"smooth"}),K(v,e.messages.length-1))},F=()=>{const x=f();x>=0&&S(x)},B=()=>{const x=p(),A=i();for(let E=A.length-1;E>=0;E--)if(A[E]<x){S(A[E]);return}b()},R=()=>{const x=p(),A=i();for(const E of A)if(E>x){S(E);return}k()};var L=te(),O=G(L);{var I=x=>{var A=aT(),E=m(A);Te(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"),E.__click=b;var D=w(E,2);Te(D,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"),D.__click=B;var oe=w(D,2);{var ue=P=>{var j=iT();Te(j,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"),j.__click=F,_(P,j)};N(oe,P=>{l(h)&&P(ue)})}var z=w(oe,2);Te(z,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"),z.__click=R;var q=w(z,2);Te(q,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"),q.__click=k,g(A),U(()=>Te(A,1,`flex gap-0.5 ${r()??""}`,"svelte-12kovyu")),_(x,A)};N(O,x=>{e.messages.length>0&&x(I)})}_(t,L),Zt()}lr(["click"]);var lT=C('<span class="animate-spin">⟳</span>'),uT=C(`<button class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700
|
|
88
|
+
hover:bg-red-900/50 transition-colors flex items-center gap-1"><!> <!></button>`),fT=C('<span class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700"> </span>'),hT=C('<span class="text-gh-text-secondary"> </span>'),dT=C('<li class="text-red-400"><span class="text-gh-text-secondary"> </span> <!></li>'),gT=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>'),pT=C(`<div class="relative group"><!> <div class="absolute left-0 top-full mt-1 z-50 hidden group-hover:block
|
|
89
|
+
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>`),mT=C('<span class="animate-spin">⟳</span>'),vT=C(`<button class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700
|
|
90
|
+
hover:bg-red-900/50 transition-colors flex items-center gap-1"><!> <!></button>`),_T=C('<span class="text-xs px-2 py-0.5 rounded bg-red-900/30 text-red-400 border border-red-700"> </span>'),bT=C('<li class="text-red-400"><span class="text-gh-text-secondary"> </span> </li>'),yT=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>'),xT=C(`<div class="relative group"><!> <div class="absolute left-0 top-full mt-1 z-50 hidden group-hover:block
|
|
91
|
+
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>`),kT=C("<!> <!>",1);function ST(t,e){Yt(e,!0);let r=Me(e,"chainErrors",19,()=>[]),n=Me(e,"progressErrors",19,()=>[]),s=Me(e,"isRepairing",3,!1);const o=V(()=>r().filter(v=>v.type==="broken_chain"||v.type==="orphan_parent")),i=V(()=>l(o).length>0),c=V(()=>n().length>0);var a=kT(),u=G(a);{var f=v=>{var p=pT(),S=m(p);{var b=O=>{var I=uT();I.__click=function(...z){e.onRepair?.apply(this,z)};var x=m(I);{var A=z=>{var q=lT();_(z,q)},E=z=>{var q=jt("⚠️");_(z,q)};N(x,z=>{s()?z(A):z(E,!1)})}var D=w(x),oe=w(D);{var ue=z=>{var q=jt("- Repair");_(z,q)};N(oe,z=>{s()||z(ue)})}g(I),U(()=>{I.disabled=s(),M(D,` ${l(o).length??""} chain error${l(o).length>1?"s":""} `)}),_(O,I)},k=O=>{var I=fT(),x=m(I);g(I),U(()=>M(x,`⚠️ ${l(o).length??""} chain error${l(o).length>1?"s":""}`)),_(O,I)};N(S,O=>{e.onRepair?O(b):O(k,!1)})}var F=w(S,2),B=w(m(F),2);bt(B,21,()=>l(o),wt,(O,I)=>{var x=dT(),A=m(x),E=m(A);g(A);var D=w(A),oe=w(D);{var ue=z=>{var q=hT(),P=m(q);g(q),U(j=>M(P,`→ ${j??""}...`),[()=>l(I).parentUuid.slice(0,8)]),_(z,q)};N(oe,z=>{l(I).type==="orphan_parent"&&l(I).parentUuid&&z(ue)})}g(x),U(()=>{M(E,`L${l(I).line??""}:`),M(D,` ${l(I).type==="broken_chain"?"Broken chain (null parentUuid)":"Orphan parent"} `)}),_(O,x)}),g(B);var R=w(B,2);{var L=O=>{var I=gT();_(O,I)};N(R,O=>{e.onRepair&&O(L)})}g(F),g(p),_(v,p)};N(u,v=>{l(i)&&v(f)})}var d=w(u,2);{var h=v=>{var p=xT(),S=m(p);{var b=O=>{var I=vT();I.__click=function(...z){e.onRepairProgress?.apply(this,z)};var x=m(I);{var A=z=>{var q=mT();_(z,q)},E=z=>{var q=jt("⚠️");_(z,q)};N(x,z=>{s()?z(A):z(E,!1)})}var D=w(x),oe=w(D);{var ue=z=>{var q=jt("- Remove");_(z,q)};N(oe,z=>{s()||z(ue)})}g(I),U(()=>{I.disabled=s(),M(D,` ${n().length??""} progress `)}),_(O,I)},k=O=>{var I=_T(),x=m(I);g(I),U(()=>M(x,`⚠️ ${n().length??""} progress`)),_(O,I)};N(S,O=>{e.onRepairProgress?O(b):O(k,!1)})}var F=w(S,2),B=w(m(F),2);bt(B,21,n,wt,(O,I)=>{var x=bT(),A=m(x),E=m(A);g(A);var D=w(A);g(x),U(()=>{M(E,`L${l(I).line??""}:`),M(D,` ${(l(I).hookName||l(I).hookEvent||"unknown")??""}`)}),_(O,x)}),g(B);var R=w(B,2);{var L=O=>{var I=yT();_(O,I)};N(R,O=>{e.onRepairProgress&&O(L)})}g(F),g(p),_(v,p)};N(d,v=>{l(c)&&v(h)})}_(t,a),Zt()}lr(["click"]);var wT=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>'),IT=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
|
|
92
|
+
hover:underline cursor-pointer bg-transparent border-none p-0 text-left" title="Open session file in VSCode"> </button> <!></div>`,1),TT=C('<h2 class="text-base font-semibold">Messages</h2>'),RT=C('<button>🤖 <span class="hidden md:inline"> </span><span class="md:hidden"> </span> </button>'),CT=C("<button> </button>"),ET=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>'),OT=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">Select a session to view</div>'),MT=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">No messages</div>'),AT=C('<div class="text-gh-text-secondary text-center py-8">No todos</div>'),NT=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>'),FT=C('<ul class="space-y-2"></ul>'),PT=C('<div class="p-4"><!></div>'),jT=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">Loading agent messages...</div>'),LT=C('<div class="flex items-center justify-center h-full text-gh-text-secondary">No messages</div>'),$T=C(`<div class="fixed bottom-4 left-1/2 -translate-x-1/2 bg-neutral-500/20 border border-neutral-600
|
|
93
|
+
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>`),DT=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 hR(t,e){Yt(e,!0);let r=Me(e,"todos",19,()=>[]),n=Me(e,"agents",19,()=>[]),s=Me(e,"enableScroll",3,!0),o=Me(e,"externalScrollContainer",3,null),i=Me(e,"fullWidth",3,!1);const c=V(()=>vg(e.customTitle,e.currentSummary,e.session?.title,50)),a=V(()=>Kw(e.messages)),u=V(()=>Ww(e.messages));let f=Qe(!1);const d=async()=>{if(!(!e.session||l(f))){K(f,!0);try{const $=await Bp(e.session.projectName,e.session.id);$.success&&$.repairCount>0&&await L()}catch($){console.error("Failed to repair chain:",$)}finally{K(f,!1)}}},h=async()=>{if(!(!e.session||l(f))){K(f,!0);try{for(const $ of l(u).errors){const J=e.messages[$.line-1];J?.uuid&&await Rl(e.session.projectName,e.session.id,J.uuid)}await L()}catch($){console.error("Failed to remove progress messages:",$)}finally{K(f,!1)}}};let v=Qe("messages"),p=Qe(Ro([])),S=Qe(!1),b=Qe(Ro([])),k=Qe(0),F=Qe(null),B=Promise.resolve();xn(()=>{if(l(k)<=0)return;const $=setInterval(()=>{K(k,Math.max(0,l(k)-1),!0),l(k)===0&&K(b,[],!0)},1e3);return()=>clearInterval($)}),xn(()=>{e.session?.id,K(v,"messages"),K(p,[],!0)});const R=V(()=>l(v).startsWith("agent:")?l(v).slice(6):null);xn(()=>{l(R)&&e.session&&(K(S,!0),Up(e.session.projectName,e.session.id,l(R)).then($=>{K(p,$,!0)}).catch($=>{console.error("Failed to load agent messages:",$),K(p,[],!0)}).finally(()=>{K(S,!1)}))});const L=async()=>{e.onRefresh&&await e.onRefresh()},O=async()=>{if(l(F)&&clearTimeout(l(F)),!e.session||l(b).length===0)return;await B;const $=[...l(b)].reverse();for(const J of $)try{if(await $p(e.session.projectName,J.sessionId,J.msg,J.index),J.isAgent){const fe=[...l(p)];fe.splice(J.index,0,J.msg),K(p,fe,!0)}else{const fe=[...e.messages];fe.splice(J.index,0,J.msg),e.onMessagesChange?.(fe)}}catch(fe){console.error("Failed to restore message:",fe)}K(b,[],!0),K(k,0),K(F,null),await L()},I=async($,J)=>{if(!e.session)return;const fe=$.uuid||$.messageId||$.leafUuid;if(!fe)return;const Fe=$.type==="file-history-snapshot"?"file-history-snapshot":$.type==="summary"?"summary":void 0,Ce=J&&l(R)?l(R):e.session.id;let he;if(J){if(he=l(p).findIndex(ce=>(ce.uuid||ce.messageId||ce.leafUuid)===fe),he===-1)return}else if(he=e.messages.findIndex(ce=>(ce.uuid||ce.messageId||ce.leafUuid)===fe),he===-1)return;if(J){const ce=[...l(p)];ju(ce,fe,Fe),K(p,ce,!0)}else{const ce=[...e.messages];ju(ce,fe,Fe),e.onMessagesChange?.(ce)}K(b,[...l(b),{msg:$,index:he,isAgent:J,sessionId:Ce}],!0),l(F)&&clearTimeout(l(F)),K(k,10),K(F,setTimeout(()=>{K(b,[],!0),K(k,0),K(F,null)},1e4),!0),B=B.then(async()=>{try{await Rl(e.session.projectName,Ce,fe,Fe)}catch(ce){console.error("Failed to delete message:",ce)}}),e.onDeleteMessage?.($)},x=$=>{I($,!0)},A=$=>{I($,!1)},E=async()=>{if(!e.session)return;const $=`~/.claude/projects/${e.session.projectName}/${e.session.id}.jsonl`;try{await sc($)}catch(J){console.error("Failed to open file:",J)}};let D=Qe(void 0);const oe=V(()=>o()??l(D));var ue=DT(),z=m(ue),q=m(z);{var P=$=>{var J=wT();U(()=>ye(J,"href",e.backUrl)),_($,J)};N(q,$=>{e.backUrl&&$(P)})}var j=w(q,2),Je=m(j);{var tt=$=>{var J=IT(),fe=G(J),Fe=m(fe);{let Ge=V(()=>P2(l(c),50));Za(Fe,{get title(){return l(Ge)}})}g(fe);var Ce=w(fe,2),he=m(Ce);he.__click=E;var ce=m(he,!0);g(he);var de=w(he,2);ST(de,{get chainErrors(){return l(a).errors},get progressErrors(){return l(u).errors},get isRepairing(){return l(f)},onRepair:d,onRepairProgress:h}),g(Ce),U(()=>M(ce,e.session.id)),_($,J)},je=$=>{var J=TT();_($,J)};N(Je,$=>{e.session?$(tt):$(je,!1)})}g(j);var Ne=w(j,2);{var zt=$=>{cT($,{get messages(){return e.messages},get scrollContainer(){return l(oe)}})};N(Ne,$=>{l(v)!=="todos"&&$(zt)})}g(z);var yt=w(z,2);{var Ur=$=>{var J=ET(),fe=m(J),Fe=m(fe);Fe.__click=()=>K(v,"messages");var Ce=m(Fe);g(Fe);var he=w(Fe,2);bt(he,17,n,wt,(Ge,xe)=>{var Z=RT();Z.__click=()=>K(v,`agent:${l(xe).id}`);var Ue=w(m(Z)),at=m(Ue,!0);g(Ue);var ee=w(Ue),ke=m(ee,!0);g(ee);var ge=w(ee);g(Z),U(Pe=>{Te(Z,1,`px-4 py-2 text-sm font-medium transition-colors whitespace-nowrap ${l(v)===`agent:${l(xe).id}`?"text-gh-accent border-b-2 border-gh-accent":"text-gh-text-secondary hover:text-gh-text hover:bg-gh-border-subtle"}`),M(at,l(xe).id),M(ke,Pe),M(ge,` (${l(xe).messageCount??""})`)},[()=>l(xe).id.replace("agent-","")]),_(Ge,Z)}),g(fe);var ce=w(fe,2);{var de=Ge=>{var xe=CT();xe.__click=()=>K(v,"todos");var Z=m(xe);g(xe),U(()=>{Te(xe,1,`px-4 py-2 text-sm font-medium transition-colors whitespace-nowrap ${l(v)==="todos"?"text-gh-accent border-b-2 border-gh-accent":"text-gh-text-secondary hover:text-gh-text hover:bg-gh-border-subtle"}`),M(Z,`✅ Todos (${r().length??""})`)}),_(Ge,xe)};N(ce,Ge=>{r().length>0&&Ge(de)})}g(J),U(()=>{Te(Fe,1,`px-4 py-2 text-sm font-medium transition-colors whitespace-nowrap ${l(v)==="messages"?"text-gh-accent border-b-2 border-gh-accent":"text-gh-text-secondary hover:text-gh-text hover:bg-gh-border-subtle"}`),M(Ce,`💬 Messages (${e.messages.length??""})`)}),_($,J)};N(yt,$=>{e.session&&$(Ur)})}var it=w(yt,2),At=m(it);{var ur=$=>{var J=OT();_($,J)},xr=$=>{var J=te(),fe=G(J);{var Fe=he=>{var ce=te(),de=G(ce);{var Ge=Z=>{var Ue=MT();_(Z,Ue)},xe=Z=>{Vu(Z,{get sessionId(){return e.session.id},get messages(){return e.messages},onDeleteMessage:A,get onEditTitle(){return e.onEditTitle},get onSplitSession(){return e.onSplitSession},enableScroll:!1,fullWidth:!0})};N(de,Z=>{e.messages.length===0?Z(Ge):Z(xe,!1)})}_(he,ce)},Ce=he=>{var ce=te(),de=G(ce);{var Ge=Z=>{var Ue=PT(),at=m(Ue);{var ee=ge=>{var Pe=AT();_(ge,Pe)},ke=ge=>{var Pe=FT();bt(Pe,21,r,wt,(Se,Be)=>{var Ee=NT(),qe=m(Ee),ct=m(qe);{var Ye=ve=>{var Ze=jt("✅");_(ve,Ze)},lt=ve=>{var Ze=te(),Nt=G(Ze);{var fr=Ft=>{var xt=jt("🔄");_(Ft,xt)},Br=Ft=>{var xt=jt("⬜");_(Ft,xt)};N(Nt,Ft=>{l(Be).status==="in_progress"?Ft(fr):Ft(Br,!1)},!0)}_(ve,Ze)};N(ct,ve=>{l(Be).status==="completed"?ve(Ye):ve(lt,!1)})}g(qe);var Le=w(qe,2),$e=m(Le,!0);g(Le),g(Ee),U(()=>{Te(Le,1,Is(l(Be).status==="completed"?"text-gh-text-secondary line-through":"")),M($e,l(Be).content)}),_(Se,Ee)}),g(Pe),_(ge,Pe)};N(at,ge=>{r().length===0?ge(ee):ge(ke,!1)})}g(Ue),_(Z,Ue)},xe=Z=>{var Ue=te(),at=G(Ue);{var ee=ke=>{var ge=te(),Pe=G(ge);{var Se=Ee=>{var qe=jT();_(Ee,qe)},Be=Ee=>{var qe=te(),ct=G(qe);{var Ye=Le=>{var $e=LT();_(Le,$e)},lt=Le=>{Vu(Le,{get sessionId(){return e.session.id},get messages(){return l(p)},onDeleteMessage:x,enableScroll:!1,fullWidth:!0})};N(ct,Le=>{l(p).length===0?Le(Ye):Le(lt,!1)},!0)}_(Ee,qe)};N(Pe,Ee=>{l(S)?Ee(Se):Ee(Be,!1)})}_(ke,ge)};N(at,ke=>{l(R)&&ke(ee)},!0)}_(Z,Ue)};N(de,Z=>{l(v)==="todos"?Z(Ge):Z(xe,!1)},!0)}_(he,ce)};N(fe,he=>{l(v)==="messages"?he(Fe):he(Ce,!1)},!0)}_($,J)};N(At,$=>{e.session?$(xr,!1):$(ur)})}g(it),rc(it,$=>K(D,$),()=>l(D));var It=w(it,2);{var pt=$=>{var J=$T(),fe=m(J),Fe=m(fe,!0);g(fe);var Ce=w(fe,2),he=m(Ce);g(Ce);var ce=w(Ce,2);ce.__click=O;var de=w(ce,2);de.__click=()=>{l(F)&&clearTimeout(l(F)),K(b,[],!0),K(k,0)},g(J),U(()=>{M(Fe,l(b).length===1?"Message deleted":`${l(b).length} messages deleted`),M(he,`${l(k)??""}s`)}),_($,J)};N(It,$=>{l(b).length>0&&$(pt)})}g(ue),U(()=>{Te(ue,1,`bg-gh-bg-secondary overflow-hidden flex flex-col h-full ${i()?"":"border border-gh-border rounded-lg"}`),Te(it,1,`flex-1 ${s()?"overflow-y-auto":""}`)}),_(t,ue),Zt()}lr(["click"]);var UT=C('<div><span> </span> <button class="text-white/70 hover:text-white transition-colors" title="Dismiss">✕</button></div>');function dR(t,e){Yt(e,!0);let r=Me(e,"message",15),n=Me(e,"variant",3,"success"),s=Me(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"};xn(()=>{r()&&(o&&clearTimeout(o),o=setTimeout(()=>r(null),s()))}),bp(()=>{o&&clearTimeout(o)});var c=te(),a=G(c);{var u=f=>{var d=UT(),h=m(d),v=m(h,!0);g(h);var p=w(h,2);p.__click=()=>r(null),g(d),U(()=>{Te(d,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[n()]??""}`,"svelte-1cpok13"),M(v,r())}),_(f,d)};N(a,f=>{r()&&f(u)})}_(t,c),Zt()}lr(["click"]);export{bt as A,wt as B,lR as C,uR as I,fR as P,hR as S,dR as T,ll as a,vg as b,iR as c,ju as d,oR as e,Rl as f,JT as g,GT as h,YT as i,WT as j,Cp as k,KT as l,nR as m,sR as n,eR as o,QT as p,tR as q,aR as r,rR as s,hf as t,ZT as u,ye as v,VT as w,Te as x,HT as y,XT as z};
|