bloby-bot 0.49.3 → 0.49.4

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-CeNcsRuK.js","assets/jsx-runtime-C0W9Wf2W.js","assets/angular-html-olSuI25H.js","assets/html-CzX0w7K_.js","assets/css-zY4NE9yA.js","assets/javascript-CzjRtS1s.js","assets/angular-ts-BJPoZ_vo.js","assets/scss-Efq7Dmbs.js","assets/apl-CyVuPSCb.js","assets/json-CdFmZMJc.js","assets/xml-BlDEvPia.js","assets/java-BqKEu7zh.js","assets/astro-CKc3-gwH.js","assets/postcss-BTQso3H9.js","assets/tsx-DrzBggF8.js","assets/typescript-COZIw7xM.js","assets/blade-DMAsVBaV.js","assets/html-derivative-D-XvNBA6.js","assets/sql-CB6kO6Km.js","assets/bsl-B1qbqNES.js","assets/sdbl-BmWYR-pI.js","assets/c-BvB8CVo8.js","assets/cairo-BDj8wWhy.js","assets/python-CKg5r0C3.js","assets/cobol-hBjMZW-R.js","assets/coffee-B4OtR3w-.js","assets/cpp-BblbpnyR.js","assets/glsl-CEMf-THb.js","assets/regexp-CvWG4lI-.js","assets/crystal-x3k4USY-.js","assets/shellscript-BbEstezf.js","assets/edge-B-9TrlZC.js","assets/elixir-CXCzbj1r.js","assets/elm-BdRiwmde.js","assets/erb-C9tvRzx3.js","assets/ruby-CXP5_4kq.js","assets/graphql-dBCd2Czl.js","assets/jsx-BL6Wh6Qw.js","assets/haml-Ck5pVAEG.js","assets/lua-B4ezzssg.js","assets/yaml-iUXljnLs.js","assets/erlang-Bc4hQuqa.js","assets/markdown-BaI9LyM4.js","assets/fortran-fixed-form-B02FOYI-.js","assets/fortran-free-form-BPTf0lbT.js","assets/fsharp-DhdR18vN.js","assets/gdresource-DgnrMPIx.js","assets/gdscript-CsadCSaZ.js","assets/gdshader-PfnN_8tR.js","assets/git-commit-DGJi7qBD.js","assets/diff-CdkWtnkL.js","assets/git-rebase-HwDSB2qJ.js","assets/glimmer-js-B6LF_BMd.js","assets/glimmer-ts-Cn42BUKe.js","assets/hack-DDEqRjBe.js","assets/handlebars-g9Qe0ao2.js","assets/http-qlhghEti.js","assets/hurl-CHIKfBKk.js","assets/csv-DNUpVBxl.js","assets/hxml-adC65L_J.js","assets/haxe-DfXTCEOz.js","assets/jinja-BHZt0_Dn.js","assets/jison-TqJYWKkW.js","assets/julia-CW07fy07.js","assets/r-CGji9_vM.js","assets/just-DBcWo9WY.js","assets/perl-DqDX-7VG.js","assets/latex-D6lXiPTF.js","assets/tex-CdJ24HJj.js","assets/liquid-DhYYAQ41.js","assets/marko-xtrIBdcL.js","assets/less-C95PyOu0.js","assets/mdc-DyZVNnwP.js","assets/nextflow-JEyYUlIq.js","assets/nextflow-groovy-wvmJO4hi.js","assets/nginx-CGgm1VOJ.js","assets/nim-Br7S817Z.js","assets/php-DYSqNNGJ.js","assets/pug-Bob3gNio.js","assets/qml-CsMafcqN.js","assets/razor-B4PzhaZX.js","assets/csharp-BDKQY1K9.js","assets/rst-BXuz-2b8.js","assets/cmake-D5rSbMir.js","assets/sas-Cov9PzAD.js","assets/shaderlab-DZ3Lsiak.js","assets/hlsl-DpuYn7pp.js","assets/shellsession-BHLVblBB.js","assets/soy-e0u3-wIA.js","assets/sparql-B9c85a_o.js","assets/turtle-CqNXyJWZ.js","assets/stata-B1mLEMrz.js","assets/surrealql-BTKo2XFY.js","assets/svelte-B7URZ-wm.js","assets/templ-DVRYIgGq.js","assets/go-DLnOLj8q.js","assets/ts-tags-CCSbelDn.js","assets/twig-Dn4ruiVl.js","assets/vue-D19cWHwY.js","assets/vue-html-_j-KC7Cs.js","assets/vue-vine-BC03MN6c.js","assets/stylus-sKwvsUaC.js","assets/xsl-DR-zOeBm.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-DGw6RxGl.js","assets/jsx-runtime-C0W9Wf2W.js","assets/angular-html-olSuI25H.js","assets/html-CzX0w7K_.js","assets/css-zY4NE9yA.js","assets/javascript-CzjRtS1s.js","assets/angular-ts-BJPoZ_vo.js","assets/scss-Efq7Dmbs.js","assets/apl-CyVuPSCb.js","assets/json-CdFmZMJc.js","assets/xml-BlDEvPia.js","assets/java-BqKEu7zh.js","assets/astro-CKc3-gwH.js","assets/postcss-BTQso3H9.js","assets/tsx-DrzBggF8.js","assets/typescript-COZIw7xM.js","assets/blade-DMAsVBaV.js","assets/html-derivative-D-XvNBA6.js","assets/sql-CB6kO6Km.js","assets/bsl-B1qbqNES.js","assets/sdbl-BmWYR-pI.js","assets/c-BvB8CVo8.js","assets/cairo-BDj8wWhy.js","assets/python-CKg5r0C3.js","assets/cobol-hBjMZW-R.js","assets/coffee-B4OtR3w-.js","assets/cpp-BblbpnyR.js","assets/glsl-CEMf-THb.js","assets/regexp-CvWG4lI-.js","assets/crystal-x3k4USY-.js","assets/shellscript-BbEstezf.js","assets/edge-B-9TrlZC.js","assets/elixir-CXCzbj1r.js","assets/elm-BdRiwmde.js","assets/erb-C9tvRzx3.js","assets/ruby-CXP5_4kq.js","assets/graphql-dBCd2Czl.js","assets/jsx-BL6Wh6Qw.js","assets/haml-Ck5pVAEG.js","assets/lua-B4ezzssg.js","assets/yaml-iUXljnLs.js","assets/erlang-Bc4hQuqa.js","assets/markdown-BaI9LyM4.js","assets/fortran-fixed-form-B02FOYI-.js","assets/fortran-free-form-BPTf0lbT.js","assets/fsharp-DhdR18vN.js","assets/gdresource-DgnrMPIx.js","assets/gdscript-CsadCSaZ.js","assets/gdshader-PfnN_8tR.js","assets/git-commit-DGJi7qBD.js","assets/diff-CdkWtnkL.js","assets/git-rebase-HwDSB2qJ.js","assets/glimmer-js-B6LF_BMd.js","assets/glimmer-ts-Cn42BUKe.js","assets/hack-DDEqRjBe.js","assets/handlebars-g9Qe0ao2.js","assets/http-qlhghEti.js","assets/hurl-CHIKfBKk.js","assets/csv-DNUpVBxl.js","assets/hxml-adC65L_J.js","assets/haxe-DfXTCEOz.js","assets/jinja-BHZt0_Dn.js","assets/jison-TqJYWKkW.js","assets/julia-CW07fy07.js","assets/r-CGji9_vM.js","assets/just-DBcWo9WY.js","assets/perl-DqDX-7VG.js","assets/latex-D6lXiPTF.js","assets/tex-CdJ24HJj.js","assets/liquid-DhYYAQ41.js","assets/marko-xtrIBdcL.js","assets/less-C95PyOu0.js","assets/mdc-DyZVNnwP.js","assets/nextflow-JEyYUlIq.js","assets/nextflow-groovy-wvmJO4hi.js","assets/nginx-CGgm1VOJ.js","assets/nim-Br7S817Z.js","assets/php-DYSqNNGJ.js","assets/pug-Bob3gNio.js","assets/qml-CsMafcqN.js","assets/razor-B4PzhaZX.js","assets/csharp-BDKQY1K9.js","assets/rst-BXuz-2b8.js","assets/cmake-D5rSbMir.js","assets/sas-Cov9PzAD.js","assets/shaderlab-DZ3Lsiak.js","assets/hlsl-DpuYn7pp.js","assets/shellsession-BHLVblBB.js","assets/soy-e0u3-wIA.js","assets/sparql-B9c85a_o.js","assets/turtle-CqNXyJWZ.js","assets/stata-B1mLEMrz.js","assets/surrealql-BTKo2XFY.js","assets/svelte-B7URZ-wm.js","assets/templ-DVRYIgGq.js","assets/go-DLnOLj8q.js","assets/ts-tags-CCSbelDn.js","assets/twig-Dn4ruiVl.js","assets/vue-D19cWHwY.js","assets/vue-html-_j-KC7Cs.js","assets/vue-vine-BC03MN6c.js","assets/stylus-sKwvsUaC.js","assets/xsl-DR-zOeBm.js"])))=>i.map(i=>d[i]);
2
2
  import{c as e,i as t,n,o as r,r as i,t as a}from"./jsx-runtime-C0W9Wf2W.js";import{a as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./globals-DNO3ilRx.js";var x=p(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),S=p(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),C=p(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),w=p(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),T=p(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),E=p(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ee=p(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),D=p(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),te=p(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ne=p(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),re=p(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),O=p(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),ie=p(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),ae=p(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),oe=p(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),k=p(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),se=p(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),ce=p(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),le=p(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),ue=p(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),A=p(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),de=p(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),fe=p(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),pe=p(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),j=e(i(),1),me=e(u(),1),he=class e{ws=null;handlers=new Map;statusHandlers=new Set;reconnectTimer=null;heartbeatTimer=null;url;queue=[];intentionalClose=!1;reconnectDelay=1e3;static MAX_RECONNECT_DELAY=8e3;tokenGetter=null;constructor(e,t){let n=location.protocol===`https:`?`wss:`:`ws:`,r=location.host;this.url=e??`${n}//${r}/ws`,this.tokenGetter=t??null}connect(){this.intentionalClose=!1;let t=this.url;if(this.tokenGetter){let e=this.tokenGetter();if(e){let n=t.includes(`?`)?`&`:`?`;t=`${t}${n}token=${e}`}}this.ws=new WebSocket(t),this.ws.onopen=()=>{this.reconnectDelay=1e3,this.notifyStatus(!0),this.flushQueue(),this.startHeartbeat()},this.ws.onmessage=e=>{if(e.data===`pong`)return;let t=JSON.parse(e.data);this.handlers.get(t.type)?.forEach(e=>e(t.data))},this.ws.onclose=()=>{this.stopHeartbeat(),this.notifyStatus(!1),this.intentionalClose||(this.reconnectTimer=setTimeout(()=>{this.reconnectDelay=Math.min(this.reconnectDelay*2,e.MAX_RECONNECT_DELAY),this.connect()},this.reconnectDelay))},this.ws.onerror=()=>this.ws?.close()}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.stopHeartbeat(),this.ws?.close(),this.ws=null}on(e,t){return this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t),()=>this.handlers.get(e)?.delete(t)}onStatus(e){return this.statusHandlers.add(e),()=>this.statusHandlers.delete(e)}send(e,t){let n={type:e,data:t};this.ws?.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(n)):this.queue.push(n)}get connected(){return this.ws?.readyState===WebSocket.OPEN}flushQueue(){for(;this.queue.length>0&&this.ws?.readyState===WebSocket.OPEN;){let e=this.queue.shift();this.ws.send(JSON.stringify(e))}}notifyStatus(e){this.statusHandlers.forEach(t=>t(e))}startHeartbeat(){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send(`ping`)},25e3)}stopHeartbeat(){this.heartbeatTimer&&=(clearInterval(this.heartbeatTimer),null)}},ge=`bloby_token`,_e=null;function ve(){return localStorage.getItem(ge)}function ye(e){localStorage.setItem(ge,e)}function be(){localStorage.removeItem(ge)}function xe(e){_e=e}async function Se(e,t={}){let n=ve(),r=new Headers(t.headers);n&&r.set(`Authorization`,`Bearer ${n}`);let i=await fetch(e,{...t,headers:r});return i.status===401&&n&&(be(),_e?.()),i}function Ce(e,t,n=!0){let[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)([]),[p,m]=(0,j.useState)(!1),h=(0,j.useRef)(!1),g=(0,j.useRef)(null),_=(0,j.useRef)(!1),v=(0,j.useRef)(!1),y=(0,j.useRef)(``),b=(0,j.useRef)(0),x=(0,j.useRef)(null),S=(0,j.useRef)(null),C=(0,j.useRef)(new URLSearchParams(location.search).has(`ext`));(0,j.useEffect)(()=>{g.current=a},[a]),(0,j.useEffect)(()=>{_.current=s},[s]),(0,j.useEffect)(()=>{if(!C.current)return;function e(e){e.data?.type===`bloby:page-context`&&(S.current=e.data.context,console.log(`[blobyChat] Extension page context:`,e.data.context?.url))}return window.addEventListener(`message`,e),window.parent?.postMessage({type:`bloby:request-context`},`*`),()=>window.removeEventListener(`message`,e)},[]);let w=(0,j.useCallback)(e=>{let t;e.audio_data&&(t=e.audio_data.startsWith(`data:`)?e.audio_data:e.audio_data.includes(`/`)?`/api/files/${e.audio_data}`:`data:audio/webm;base64,${e.audio_data}`);let n;if(e.attachments)try{n=JSON.parse(e.attachments)}catch{}return{id:e.id,role:e.role,content:e.content,timestamp:e.created_at,audioData:t,hasAttachments:!!(n&&n.length>0),attachments:n}},[]),T=(0,j.useCallback)(async()=>{try{let e=await Se(`/api/context/current`).then(e=>e.json());if(!e.conversationId)return;o(e.conversationId);let t=await Se(`/api/conversations/${e.conversationId}/messages?limit=200`);if(!t.ok)return;let n=await t.json();if(!n?.length)return;i(n.filter(e=>e.role===`user`||e.role===`assistant`).map(w)),m(n.length>=200)}catch{}},[w]),E=(0,j.useCallback)(async()=>{if(!(v.current||!g.current)){v.current=!0;try{let e=r[0]?.id;if(!e)return;let t=await Se(`/api/conversations/${g.current}/messages?before=${e}&limit=100`);if(!t.ok)return;let n=await t.json();if(!n?.length){m(!1);return}let a=n.filter(e=>e.role===`user`||e.role===`assistant`).map(w);i(e=>[...a,...e]),n.length<100&&m(!1)}catch{}finally{v.current=!1}}},[r,w]);(0,j.useEffect)(()=>{!n||h.current||(h.current=!0,T())},[n,T]),(0,j.useEffect)(()=>{n&&t&&t>0&&T()},[n,t,T]),(0,j.useEffect)(()=>{if(!n||!t||t===0||!s)return;let e=setInterval(()=>{if(!_.current){clearInterval(e);return}T()},3e3);return()=>clearInterval(e)},[n,t,s,T]),(0,j.useEffect)(()=>{if(!e)return;console.log(`[blobyChat] ──── WS HANDLERS REGISTERED ────`);let t=[e.on(`bot:typing`,()=>{console.log(`[blobyChat] bot:typing → streaming=true`),c(!0),f([])}),e.on(`bot:token`,e=>{c(!0),u(t=>{let n=t+e.token;return y.current=n,n})}),e.on(`bot:tool`,e=>{let t=y.current;t&&(console.log(`[blobyChat] bot:tool (${e.name}) — committing ${t.length} chars as bubble`),b.current+=t.length,i(e=>[...e,{id:`tool-`+Date.now(),role:`assistant`,content:t,timestamp:new Date().toISOString()}]),u(``),y.current=``),f(t=>t.find(t=>t.name===e.name&&t.status===`running`)?t:[...t,{name:e.name,status:`running`}])}),e.on(`bot:response`,e=>{if(g.current&&e.conversationId!==g.current)return;o(e.conversationId);let t=e.content||``;b.current>0?(t=t.slice(b.current).replace(/^\n+/,``),b.current=0,console.log(`[blobyChat] bot:response — stripped partial, remaining:`,t.slice(0,60))):console.log(`[blobyChat] bot:response — new bubble`),t.trim()&&i(n=>[...n,{id:e.messageId||Date.now().toString(),role:`assistant`,content:t,timestamp:new Date().toISOString()}]),u(``),y.current=``,f([])}),e.on(`bot:task-created`,()=>{let e=y.current;e&&(console.log(`[blobyChat] bot:task-created — committing stream, showing dots`),b.current+=e.length,i(t=>[...t,{id:`pre-task-`+Date.now(),role:`assistant`,content:e,timestamp:new Date().toISOString()}]),u(``),y.current=``)}),e.on(`bot:idle`,()=>{console.log(`[blobyChat] bot:idle → streaming=false`),c(!1)}),e.on(`bot:error`,e=>{console.log(`[blobyChat] bot:error`),u(``),y.current=``,c(!1),f([]),i(t=>[...t,{id:Date.now().toString(),role:`assistant`,content:`Error: ${e.error}`,timestamp:new Date().toISOString()}])}),e.on(`chat:sync`,e=>{g.current&&e.conversationId!==g.current||i(t=>[...t,{id:Date.now().toString(),role:e.message.role,content:e.message.content,timestamp:e.message.timestamp,hasAttachments:!!e.message.attachments?.length,attachments:e.message.attachments}])}),e.on(`chat:conversation-created`,e=>{o(e.conversationId)}),e.on(`chat:state`,e=>{e.streaming&&(c(!0),e.conversationId&&o(e.conversationId),e.buffer&&u(e.buffer))}),e.on(`chat:cleared`,()=>{i([]),o(null),u(``),c(!1),f([]),h.current=!1})];return()=>t.forEach(e=>e())},[e]);let ee=(0,j.useCallback)(e=>{let t=`pending-audio-`+Date.now();x.current=t,i(n=>[...n,{id:t,role:`user`,content:``,timestamp:new Date().toISOString(),audioData:e.startsWith(`data:`)?e:`data:audio/webm;base64,${e}`,transcribing:!0}])},[]);return{messages:r,streaming:s,streamBuffer:l,conversationId:a,tools:d,hasMore:p,loadOlder:E,sendMessage:(0,j.useCallback)((t,n,r)=>{if(!e||!t.trim()&&(!n||n.length===0)&&!r)return;let o=y.current;o&&(console.log(`[blobyChat] Committing partial —`,o.length,`chars`),b.current+=o.length,i(e=>[...e,{id:`partial-`+Date.now(),role:`assistant`,content:o,timestamp:new Date().toISOString()}]),u(``),y.current=``);let s=x.current;if(r&&s)x.current=null,i(e=>e.map(e=>e.id===s?{...e,content:t,transcribing:!1,hasAttachments:!!(n&&n.length>0)}:e));else{let e={id:Date.now().toString(),role:`user`,content:t,timestamp:new Date().toISOString(),hasAttachments:!!(n&&n.length>0),audioData:r?r.startsWith(`data:`)?r:`data:audio/webm;base64,${r}`:void 0};i(t=>[...t,e])}let c=t;if(C.current&&S.current){let e=S.current,n=[`[Page: ${e.url}`];e.title&&(n[0]+=` | ${e.title}`),e.productName&&(n[0]+=` | ${e.productName}`),e.price&&(n[0]+=` | ${e.currency||`$`}${e.price}`),n[0]+=`]`,e.selection&&n.push(`[Selected: ${e.selection}]`),e.hasForms&&n.push(`[Page has ${e.formCount} form(s)]`),c=n.join(`
3
3
  `)+`
4
4
  `+t,window.parent?.postMessage({type:`bloby:request-context`},`*`)}let l={conversationId:a,content:c};r&&(l.audioData=r.includes(`,`)?r.split(`,`)[1]:r),n?.length&&(l.attachments=n.map(e=>{let t=e.preview.match(/^data:([^;]+);base64,(.+)$/);return{type:e.type,name:e.name,mediaType:t?.[1]||`application/octet-stream`,data:t?.[2]||``}})),e.send(`user:message`,l)},[e,a]),addPendingAudio:ee,stopStreaming:(0,j.useCallback)(()=>{e&&(e.send(`user:stop`,{conversationId:a}),c(!1),u(``),y.current=``,b.current=0,f([]))},[e,a]),clearContext:(0,j.useCallback)(()=>{e&&e.send(`user:clear-context`,{}),i([]),o(null),u(``),y.current=``,b.current=0,c(!1),f([]),h.current=!1},[e])}}var M=a(),we=`bloby_login_totp`;function Te({onLogin:e,totpEnabled:t}){let[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(``),[s,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(`password`),[p,h]=(0,j.useState)(``),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(!0),[C,w]=(0,j.useState)(!1),T=(0,j.useRef)(null);(0,j.useEffect)(()=>{try{let e=sessionStorage.getItem(we);if(!e)return;let t=JSON.parse(e);t.pendingToken&&t.expiresAt>Date.now()?(b(t.pendingToken),f(`totp`)):sessionStorage.removeItem(we)}catch{}},[]),(0,j.useEffect)(()=>{d===`totp`&&setTimeout(()=>T.current?.focus(),100)},[d]);function E(e){try{sessionStorage.setItem(we,JSON.stringify({pendingToken:e,expiresAt:Date.now()+4.5*60*1e3}))}catch{}}function ee(){try{sessionStorage.removeItem(we)}catch{}}let D=async()=>{if(!(!n.trim()||s)){u(!0),a(``);try{let t=btoa(`admin:${n}`),r=await fetch(`/api/portal/login`,{headers:{Authorization:`Basic ${t}`},credentials:`include`}),i=await r.json();r.ok&&i.token?(ee(),e(i.token)):r.ok&&i.requiresTOTP?(b(i.pendingToken),E(i.pendingToken),f(`totp`),a(``)):a(i.error||`Invalid password`)}catch{a(`Could not reach server`)}finally{u(!1)}}},te=async()=>{if(!(!p.trim()||s)){u(!0),a(``);try{let t=await fetch(`/api/portal/login/totp?pending=${encodeURIComponent(y)}&code=${encodeURIComponent(p)}&trust=${x?`1`:`0`}`,{credentials:`include`}),n=await t.json();t.ok&&n.token?(ee(),e(n.token)):a(n.error||`Invalid code`)}catch{a(`Could not reach server`)}finally{u(!1)}}},ne=e=>{e.key===`Enter`&&(d===`password`?D():te())},re=()=>{f(`password`),a(``),h(``),w(!1),ee()},O=`w-full bg-white/[0.05] border border-white/[0.08] text-white rounded-xl px-4 py-3 text-base outline-none input-glow placeholder:text-white/20 transition-all`;return(0,M.jsx)(`div`,{className:`flex flex-col items-center justify-center h-dvh px-6`,children:(0,M.jsx)(`div`,{className:`w-full max-w-[320px] flex flex-col items-center`,children:(0,M.jsx)(_,{mode:`wait`,children:d===`password`?(0,M.jsxs)(m.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:`w-full flex flex-col items-center`,children:[(0,M.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-white/[0.04] border border-white/[0.08] flex items-center justify-center mb-5`,children:(0,M.jsx)(ie,{className:`h-6 w-6 text-white/40`})}),(0,M.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:`Welcome back`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[13px] mb-6`,children:`Enter your password to continue.`}),i&&(0,M.jsx)(`div`,{className:`w-full bg-red-500/8 border border-red-500/15 rounded-xl px-4 py-2.5 mb-4`,children:(0,M.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:i})}),(0,M.jsx)(`input`,{type:`password`,value:n,onChange:e=>r(e.target.value),onKeyDown:ne,placeholder:`Password`,autoFocus:!0,autoComplete:`current-password`,className:O}),(0,M.jsx)(`button`,{onClick:D,disabled:!n.trim()||s,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:s?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(v,{className:`h-4 w-4 animate-spin`}),`Signing in...`]}):(0,M.jsxs)(M.Fragment,{children:[`Sign In`,(0,M.jsx)(l,{className:`h-4 w-4`})]})})]},`password`):(0,M.jsxs)(m.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.2},className:`w-full flex flex-col items-center`,children:[(0,M.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-[#AF27E3]/10 border border-[#AF27E3]/20 flex items-center justify-center mb-5`,children:(0,M.jsx)(o,{className:`h-6 w-6 text-[#AF27E3]`})}),(0,M.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:C?`Recovery code`:`Enter your 2FA code`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[13px] mb-6`,children:C?`Enter one of your recovery codes.`:`Open your authenticator app and enter the 6-digit code.`}),i&&(0,M.jsx)(`div`,{className:`w-full bg-red-500/8 border border-red-500/15 rounded-xl px-4 py-2.5 mb-4`,children:(0,M.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:i})}),(0,M.jsx)(`input`,{ref:T,type:`text`,inputMode:C?`text`:`numeric`,autoComplete:`one-time-code`,maxLength:C?20:6,value:p,onChange:e=>{h(C?e.target.value:e.target.value.replace(/\D/g,``)),a(``)},onKeyDown:ne,placeholder:C?`Recovery code`:`000000`,autoFocus:!0,className:O+(C?``:` tracking-[0.3em] text-center font-mono`)}),(0,M.jsxs)(`label`,{className:`flex items-center gap-2.5 mt-4 w-full cursor-pointer`,children:[(0,M.jsx)(`div`,{onClick:()=>S(e=>!e),className:`w-5 h-5 rounded-md border flex items-center justify-center transition-all ${x?`bg-[#AF27E3] border-[#AF27E3]`:`bg-white/[0.04] border-white/[0.12]`}`,children:x&&(0,M.jsx)(c,{className:`h-3.5 w-3.5 text-white`})}),(0,M.jsx)(`span`,{className:`text-[13px] text-white/50`,children:`Trust this device for 90 days`})]}),(0,M.jsx)(`button`,{onClick:te,disabled:!p.trim()||s,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:s?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(v,{className:`h-4 w-4 animate-spin`}),`Verifying...`]}):(0,M.jsxs)(M.Fragment,{children:[`Verify`,(0,M.jsx)(l,{className:`h-4 w-4`})]})}),(0,M.jsxs)(`div`,{className:`flex items-center gap-4 mt-4`,children:[(0,M.jsxs)(`button`,{onClick:re,className:`text-[12px] text-white/30 hover:text-white/50 flex items-center gap-1 transition-colors`,children:[(0,M.jsx)(g,{className:`h-3 w-3`}),`Back`]}),(0,M.jsx)(`button`,{onClick:()=>{w(e=>!e),h(``),a(``)},className:`text-[12px] text-white/30 hover:text-white/50 transition-colors`,children:C?`Use authenticator code`:`Use a recovery code`})]})]},`totp`)})})})}var Ee=(function(e){if(e==null)return je;if(typeof e==`function`)return Ae(e);if(typeof e==`object`)return Array.isArray(e)?De(e):Oe(e);if(typeof e==`string`)return ke(e);throw Error(`Expected function, string, or object as test`)});function De(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ee(e[n]);return Ae(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Oe(e){let t=e;return Ae(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function ke(e){return Ae(t);function t(t){return t&&t.type===e}}function Ae(e){return t;function t(t,n,r){return!!(Me(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function je(){return!0}function Me(e){return typeof e==`object`&&!!e&&`type`in e}function Ne(e){return e}var Pe=[],Fe=`skip`;function Ie(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Ee(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+Ne(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=Pe,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Le(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function Le(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Pe:[e]}function Re(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),Ie(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var ze={indicator:`indicator`,textOnly:`text-only`,remove:`remove`};function Be({defaultOrigin:e=``,allowedLinkPrefixes:t=[],allowedImagePrefixes:n=[],allowDataImages:r=!1,allowedProtocols:i=[],blockedImageClass:a=`inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm`,blockedLinkClass:o=`text-gray-500`,linkBlockPolicy:s=ze.indicator,imageBlockPolicy:c=ze.indicator}){let l=t.length&&!t.every(e=>e===`*`),u=n.length&&!n.every(e=>e===`*`);if(!e&&(l||u))throw Error(`defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided`);return l=>{let u=Xe(e,t,n,r,i,a,o,s,c);Ke(l),Re(l,u)}}function Ve(e,t){if(typeof e!=`string`)return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))try{return new URL(e,`http://example.com`)}catch{return null}return null}}function He(e){return typeof e==`string`?e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`):!1}var Ue=new Set([`https:`,`http:`,`irc:`,`ircs:`,`mailto:`,`xmpp:`,`blob:`]),We=new Set([`javascript:`,`data:`,`file:`,`vbscript:`]);function Ge(e,t,n,r=!1,i=!1,a=[]){if(!e)return null;if(typeof e==`string`&&e.startsWith(`#`)&&!i)try{if(new URL(e,`http://example.com`).hash===e)return e}catch{}if(typeof e==`string`&&e.startsWith(`data:`))return i&&r&&e.startsWith(`data:image/`)?e:null;if(typeof e==`string`&&e.startsWith(`blob:`)){try{if(new URL(e).protocol===`blob:`&&e.length>5){let t=e.substring(5);if(t&&t.length>0&&t!==`invalid`)return e}}catch{return null}return null}let o=Ve(e,n);if(!o||We.has(o.protocol)||!(Ue.has(o.protocol)||a.includes(o.protocol)||a.includes(`*`)))return null;if(o.protocol===`mailto:`||!o.protocol.match(/^https?:$/))return o.href;let s=He(e);return o&&t.some(e=>{let t=Ve(e,n);return!t||t.origin!==o.origin?!1:o.href.startsWith(t.href)})?s?o.pathname+o.search+o.hash:o.href:t.includes(`*`)?o.protocol!==`https:`&&o.protocol!==`http:`?null:s?o.pathname+o.search+o.hash:o.href:null}function Ke(e){if(`children`in e&&Array.isArray(e.children)){e.children=e.children.filter(e=>e!=null);for(let t of e.children)Ke(t)}}var qe=Symbol(`node-seen`);function Je(e,t,n){return t===ze.remove?{type:`remove`}:t===ze.textOnly?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[...e.children]}}:{type:`replace`,element:{type:`element`,tagName:`span`,properties:{title:`Blocked URL: `+String(e.properties.href),class:n},children:[...e.children,{type:`text`,value:` [blocked]`}]}}}function Ye(e,t,n){if(t===ze.remove)return{type:`remove`};if(t===ze.textOnly){let t=String(e.properties.alt||``);return t?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[{type:`text`,value:t}]}}:{type:`remove`}}return{type:`replace`,element:{type:`element`,tagName:`span`,properties:{class:n},children:[{type:`text`,value:`[Image blocked: `+String(e.properties.alt||`No description`)+`]`}]}}}var Xe=(e,t,n,r,i,a,o,s,c)=>{let l=(u,d,f)=>{if(u.type!==`element`||u[qe])return!0;if(u.tagName===`a`){let n=Ge(u.properties.href,t,e,!1,!1,i);if(n===null){if(u[qe]=!0,Re(u,l),f&&typeof d==`number`){let e=Je(u,s,o);if(e.type===`remove`)return f.children.splice(d,1),[Fe,d];f.children[d]=e.element}return Fe}else return u.properties.href=n,u.properties.target=`_blank`,u.properties.rel=`noopener noreferrer`,!0}if(u.tagName===`img`){let t=Ge(u.properties.src,n,e,r,!0,i);if(t===null){if(u[qe]=!0,Re(u,l),f&&typeof d==`number`){let e=Ye(u,c,a);if(e.type===`remove`)return f.children.splice(d,1),[Fe,d];f.children[d]=e.element}return Fe}else return u.properties.src=t,!0}return!0};return l},Ze=typeof self==`object`?self:globalThis,Qe=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new Ze[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new Ze[a](o),i)};return r},$e=e=>Qe(new Map,e)(0),et=``,{toString:tt}={},{keys:nt}=Object,rt=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=tt.call(e).slice(8,-1);switch(n){case`Array`:return[1,et];case`Object`:return[2,et];case`Date`:return[3,et];case`RegExp`:return[4,et];case`Map`:return[5,et];case`Set`:return[6,et];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},it=([e,t])=>e===0&&(t===`function`||t===`symbol`),at=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=rt(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of nt(r))(e||!it(rt(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(it(rt(n))||it(rt(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!it(rt(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},ot=(e,{json:t,lossy:n}={})=>{let r=[];return at(!(t||n),!!t,new Map,r)(e),r},st=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?$e(ot(e,t)):structuredClone(e):(e,t)=>$e(ot(e,t)),ct=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ct.prototype.normal={},ct.prototype.property={},ct.prototype.space=void 0;function lt(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ct(n,r,t)}function ut(e){return e.toLowerCase()}var dt=class{constructor(e,t){this.attribute=t,this.property=e}};dt.prototype.attribute=``,dt.prototype.booleanish=!1,dt.prototype.boolean=!1,dt.prototype.commaOrSpaceSeparated=!1,dt.prototype.commaSeparated=!1,dt.prototype.defined=!1,dt.prototype.mustUseProperty=!1,dt.prototype.number=!1,dt.prototype.overloadedBoolean=!1,dt.prototype.property=``,dt.prototype.spaceSeparated=!1,dt.prototype.space=void 0;var ft=r({boolean:()=>N,booleanish:()=>mt,commaOrSpaceSeparated:()=>vt,commaSeparated:()=>_t,number:()=>P,overloadedBoolean:()=>ht,spaceSeparated:()=>gt}),pt=0,N=yt(),mt=yt(),ht=yt(),P=yt(),gt=yt(),_t=yt(),vt=yt();function yt(){return 2**++pt}var bt=Object.keys(ft),xt=class extends dt{constructor(e,t,n,r){let i=-1;if(super(e,t),St(this,`space`,r),typeof n==`number`)for(;++i<bt.length;){let e=bt[i];St(this,bt[i],(n&ft[e])===ft[e])}}};xt.prototype.defined=!0;function St(e,t,n){n&&(e[t]=n)}function Ct(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new xt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ut(r)]=r,n[ut(a.attribute)]=r}return new ct(t,n,e.space)}var wt=Ct({properties:{ariaActiveDescendant:null,ariaAtomic:mt,ariaAutoComplete:null,ariaBusy:mt,ariaChecked:mt,ariaColCount:P,ariaColIndex:P,ariaColSpan:P,ariaControls:gt,ariaCurrent:null,ariaDescribedBy:gt,ariaDetails:null,ariaDisabled:mt,ariaDropEffect:gt,ariaErrorMessage:null,ariaExpanded:mt,ariaFlowTo:gt,ariaGrabbed:mt,ariaHasPopup:null,ariaHidden:mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gt,ariaLevel:P,ariaLive:null,ariaModal:mt,ariaMultiLine:mt,ariaMultiSelectable:mt,ariaOrientation:null,ariaOwns:gt,ariaPlaceholder:null,ariaPosInSet:P,ariaPressed:mt,ariaReadOnly:mt,ariaRelevant:null,ariaRequired:mt,ariaRoleDescription:gt,ariaRowCount:P,ariaRowIndex:P,ariaRowSpan:P,ariaSelected:mt,ariaSetSize:P,ariaSort:null,ariaValueMax:P,ariaValueMin:P,ariaValueNow:P,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Tt(e,t){return t in e?e[t]:t}function Et(e,t){return Tt(e,t.toLowerCase())}var Dt=Ct({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:_t,acceptCharset:gt,accessKey:gt,action:null,allow:null,allowFullScreen:N,allowPaymentRequest:N,allowUserMedia:N,alt:null,as:null,async:N,autoCapitalize:null,autoComplete:gt,autoFocus:N,autoPlay:N,blocking:gt,capture:null,charSet:null,checked:N,cite:null,className:gt,cols:P,colSpan:null,content:null,contentEditable:mt,controls:N,controlsList:gt,coords:P|_t,crossOrigin:null,data:null,dateTime:null,decoding:null,default:N,defer:N,dir:null,dirName:null,disabled:N,download:ht,draggable:mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:N,formTarget:null,headers:gt,height:P,hidden:ht,high:P,href:null,hrefLang:null,htmlFor:gt,httpEquiv:gt,id:null,imageSizes:null,imageSrcSet:null,inert:N,inputMode:null,integrity:null,is:null,isMap:N,itemId:null,itemProp:gt,itemRef:gt,itemScope:N,itemType:gt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:N,low:P,manifest:null,max:null,maxLength:P,media:null,method:null,min:null,minLength:P,multiple:N,muted:N,name:null,nonce:null,noModule:N,noValidate:N,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:N,optimum:P,pattern:null,ping:gt,placeholder:null,playsInline:N,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:N,referrerPolicy:null,rel:gt,required:N,reversed:N,rows:P,rowSpan:P,sandbox:gt,scope:null,scoped:N,seamless:N,selected:N,shadowRootClonable:N,shadowRootDelegatesFocus:N,shadowRootMode:null,shape:null,size:P,sizes:null,slot:null,span:P,spellCheck:mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:P,step:null,style:null,tabIndex:P,target:null,title:null,translate:null,type:null,typeMustMatch:N,useMap:null,value:mt,width:P,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gt,axis:null,background:null,bgColor:null,border:P,borderColor:null,bottomMargin:P,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:N,declare:N,event:null,face:null,frame:null,frameBorder:null,hSpace:P,leftMargin:P,link:null,longDesc:null,lowSrc:null,marginHeight:P,marginWidth:P,noResize:N,noHref:N,noShade:N,noWrap:N,object:null,profile:null,prompt:null,rev:null,rightMargin:P,rules:null,scheme:null,scrolling:mt,standby:null,summary:null,text:null,topMargin:P,valueType:null,version:null,vAlign:null,vLink:null,vSpace:P,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:N,disableRemotePlayback:N,prefix:null,property:null,results:P,security:null,unselectable:null},space:`html`,transform:Et}),Ot=Ct({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:vt,accentHeight:P,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:P,amplitude:P,arabicForm:null,ascent:P,attributeName:null,attributeType:null,azimuth:P,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:P,by:null,calcMode:null,capHeight:P,className:gt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:P,diffuseConstant:P,direction:null,display:null,dur:null,divisor:P,dominantBaseline:null,download:N,dx:null,dy:null,edgeMode:null,editable:null,elevation:P,enableBackground:null,end:null,event:null,exponent:P,externalResourcesRequired:null,fill:null,fillOpacity:P,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_t,g2:_t,glyphName:_t,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:P,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:P,horizOriginX:P,horizOriginY:P,id:null,ideographic:P,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:P,k:P,k1:P,k2:P,k3:P,k4:P,kernelMatrix:vt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:P,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:P,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:P,overlineThickness:P,paintOrder:null,panose1:null,path:null,pathLength:P,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:P,pointsAtY:P,pointsAtZ:P,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vt,rev:vt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vt,requiredFeatures:vt,requiredFonts:vt,requiredFormats:vt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:P,specularExponent:P,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:P,strikethroughThickness:P,string:null,stroke:null,strokeDashArray:vt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:P,strokeOpacity:P,strokeWidth:null,style:null,surfaceScale:P,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vt,tabIndex:P,tableValues:null,target:null,targetX:P,targetY:P,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:P,underlineThickness:P,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:P,values:null,vAlphabetic:P,vMathematical:P,vectorEffect:null,vHanging:P,vIdeographic:P,version:null,vertAdvY:P,vertOriginX:P,vertOriginY:P,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:P,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Tt}),kt=Ct({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),At=Ct({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Et}),jt=Ct({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Mt={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Nt=/[A-Z]/g,Pt=/-[a-z]/g,Ft=/^data[-\w.:]+$/i;function It(e,t){let n=ut(t),r=t,i=dt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Ft.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Pt,Rt);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Pt.test(e)){let n=e.replace(Nt,Lt);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=xt}return new i(r,t)}function Lt(e){return`-`+e.toLowerCase()}function Rt(e){return e.charAt(1).toUpperCase()}var zt=lt([wt,Dt,kt,At,jt],`html`),Bt=lt([wt,Ot,kt,At,jt],`svg`);function Vt(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function Ht(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Ut=/[#.]/g;function Wt(e,t){let n=e||``,r={},i=0,a,o;for(;i<n.length;){Ut.lastIndex=i;let e=Ut.exec(n),t=n.slice(i,e?e.index:n.length);t&&(a?a===`#`?r.id=t:Array.isArray(r.className)?r.className.push(t):r.className=[t]:o=t,i+=t.length),e&&(a=e[0],i++)}return{type:`element`,tagName:o||t||`div`,properties:r,children:[]}}function Gt(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Kt(e){return e.join(` `).trim()}function qt(e,t,n){let r=n?$t(n):void 0;function i(n,i,...a){let o;if(n==null){o={type:`root`,children:[]};let e=i;a.unshift(e)}else{o=Wt(n,t);let s=o.tagName.toLowerCase(),c=r?r.get(s):void 0;if(o.tagName=c||s,Jt(i))a.unshift(i);else for(let[t,n]of Object.entries(i))Yt(e,o.properties,t,n)}for(let e of a)Xt(o.children,e);return o.type===`element`&&o.tagName===`template`&&(o.content={type:`root`,children:o.children},o.children=[]),o}return i}function Jt(e){if(typeof e!=`object`||!e||Array.isArray(e))return!0;if(typeof e.type!=`string`)return!1;let t=e,n=Object.keys(e);for(let e of n){let n=t[e];if(n&&typeof n==`object`){if(!Array.isArray(n))return!0;let e=n;for(let t of e)if(typeof t!=`number`&&typeof t!=`string`)return!0}}return!!(`children`in e&&Array.isArray(e.children))}function Yt(e,t,n,r){let i=It(e,n),a;if(r!=null){if(typeof r==`number`){if(Number.isNaN(r))return;a=r}else a=typeof r==`boolean`?r:typeof r==`string`?i.spaceSeparated?Gt(r):i.commaSeparated?Vt(r):i.commaOrSpaceSeparated?Gt(Vt(r).join(` `)):Zt(i,i.property,r):Array.isArray(r)?[...r]:i.property===`style`?Qt(r):String(r);if(Array.isArray(a)){let e=[];for(let t of a)e.push(Zt(i,i.property,t));a=e}i.property===`className`&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}function Xt(e,t){if(t!=null)if(typeof t==`number`||typeof t==`string`)e.push({type:`text`,value:String(t)});else if(Array.isArray(t))for(let n of t)Xt(e,n);else if(typeof t==`object`&&`type`in t)t.type===`root`?Xt(e,t.children):e.push(t);else throw Error("Expected node, nodes, or string, got `"+t+"`")}function Zt(e,t,n){if(typeof n==`string`){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===``||ut(n)===ut(t)))return!0}return n}function Qt(e){let t=[];for(let[n,r]of Object.entries(e))t.push([n,r].join(`: `));return t.join(`; `)}function $t(e){let t=new Map;for(let n of e)t.set(n.toLowerCase(),n);return t}var en=`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.solidColor.textArea.textPath`.split(`.`),tn=qt(zt,`div`),nn=qt(Bt,`g`,en);function rn(e){let t=String(e),n=[];return{toOffset:i,toPoint:r};function r(e){if(typeof e==`number`&&e>-1&&e<=t.length){let r=0;for(;;){let i=n[r];if(i===void 0){let e=an(t,n[r-1]);i=e===-1?t.length+1:e+1,n[r]=i}if(i>e)return{line:r+1,column:e-(r>0?n[r-1]:0)+1,offset:e};r++}}}function i(e){if(e&&typeof e.line==`number`&&typeof e.column==`number`&&!Number.isNaN(e.line)&&!Number.isNaN(e.column)){for(;n.length<e.line;){let e=n[n.length-1],r=an(t,e),i=r===-1?t.length+1:r+1;if(e===i)break;n.push(i)}let r=(e.line>1?n[e.line-2]:0)+e.column-1;if(r<n[e.line-1])return r}}}function an(e,t){let n=e.indexOf(`\r`,t),r=e.indexOf(`
@@ -111,14 +111,14 @@ ${e}</tr>
111
111
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${fb(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=pb(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+fb(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=pb(e);if(i===null)return fb(n);e=i;let a=`<img src="${e}" alt="${fb(n)}"`;return t&&(a+=` title="${fb(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:fb(e.text)}},Cb=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},wb=class e{options;renderer;textRenderer;constructor(e){this.options=e||ey,this.options.renderer=this.options.renderer||new Sb,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Cb}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Tb=class{options;block;constructor(e){this.options=e||ey}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?xb.lex:xb.lexInline}provideParser(){return this.block?wb.parse:wb.parseInline}},Eb=new class{defaults=$v();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=wb;Renderer=Sb;TextRenderer=Cb;Lexer=xb;Tokenizer=bb;Hooks=Tb;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Sb(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new bb(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Tb;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Tb.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Tb.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return xb.lex(e,t??this.defaults)}parser(e,t){return wb.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(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 t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?xb.lex:xb.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?wb.parse:wb.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?xb.lex:xb.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?wb.parse:wb.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
112
112
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+fb(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Db(e,t){return Eb.parse(e,t)}Db.options=Db.setOptions=function(e){return Eb.setOptions(e),Db.defaults=Eb.defaults,ty(Db.defaults),Db},Db.getDefaults=$v,Db.defaults=ey,Db.use=function(...e){return Eb.use(...e),Db.defaults=Eb.defaults,ty(Db.defaults),Db},Db.walkTokens=function(e,t){return Eb.walkTokens(e,t)},Db.parseInline=Eb.parseInline,Db.Parser=wb,Db.parser=wb.parse,Db.Renderer=Sb,Db.TextRenderer=Cb,Db.Lexer=xb,Db.lexer=xb.lex,Db.Tokenizer=bb,Db.Hooks=Tb,Db.parse=Db,Db.options,Db.setOptions,Db.use,Db.walkTokens,Db.parseInline,wb.parse,xb.lex;var Ob=`modulepreload`,kb=function(e){return`/bloby/`+e},Ab={},Z=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=kb(t,n),t in Ab)return;Ab[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Ob,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},jb=300,Mb=`300px`,Nb=500;function Pb(e={}){let{immediate:t=!1,debounceDelay:n=jb,rootMargin:r=Mb,idleTimeout:i=Nb}=e,[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)(null),u=(0,j.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),d=(0,j.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),f=(0,j.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,j.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null)},u=e=>{l.current=d(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=d(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},p=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?p(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&f(l.current),h.disconnect()}},[t,n,r,i,f,d]),{shouldRender:a,containerRef:s}}var Fb=/\s/,Ib=/^\s+$/,Lb=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),Rb=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,zb=e=>e.some(e=>Rb(e)&&Lb.has(e.tagName)),Bb=e=>{let t=[],n=``,r=!1;for(let i of e){let e=Fb.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},Vb=e=>{let t=[],n=``;for(let r of e)Fb.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},Hb=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},Ub=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(zb(t))return Fe;let o=a,s=o.children.indexOf(e);if(s===-1)return;let c=e.value;if(!c.trim()){i.count+=c.length;return}let l=n.sep===`char`?Vb(c):Bb(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,Ib.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return Hb(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},Wb=0;function Gb(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40},n={prevContentLength:0,lastRenderCharCount:0},r=Wb++,i=()=>e=>{let r={count:0,newIndex:0};Ie(e,`text`,(e,i)=>Ub(e,i,t,n,r)),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,`name`,{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.prevContentLength=e},getLastRenderCharCount(){let e=n.lastRenderCharCount;return n.lastRenderCharCount=0,e}}}Gb();var Kb=(0,j.createContext)(!1),qb=()=>(0,j.useContext)(Kb),Jb=(...e)=>Kh(Cm(e)),Yb=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},Xb=e=>e?(...t)=>Yb(e,Kh(Cm(t))):Jb,Zb=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},Qb=(0,j.createContext)(Jb),Q=()=>(0,j.useContext)(Qb),$b=Jb(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),ex=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},tx=(0,j.memo)(({children:e,result:t,language:n,className:r,startLine:i,lineNumbers:a=!0,...o})=>{let s=Q(),c=(0,j.useMemo)(()=>s($b),[s]),l=(0,j.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,ex(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,M.jsx)(`div`,{className:s(r,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,...o,children:(0,M.jsx)(`pre`,{className:s(r,`bg-[var(--sdm-bg,inherit]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]`),style:l,children:(0,M.jsx)(`code`,{className:a?s(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((e,t)=>(0,M.jsx)(`span`,{className:a?c:void 0,children:e.length===0||e.length===1&&e[0].content===``?`
113
113
  `:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,M.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),nx=({className:e,language:t,style:n,isIncomplete:r,...i})=>(0,M.jsx)(`div`,{className:Q()(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i}),rx=(0,j.createContext)({code:``}),ix=()=>(0,j.useContext)(rx),ax=({language:e})=>{let t=Q();return(0,M.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,M.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},ox=e=>{let t=e.length;for(;t>0&&e[t-1]===`
114
- `;)t--;return e.slice(0,t)},sx=(0,j.lazy)(()=>Z(()=>import(`./highlighted-body-OFNGDK62-CeNcsRuK.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),cx=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=Q(),l=(0,j.useMemo)(()=>ox(e),[e]),u=(0,j.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
114
+ `;)t--;return e.slice(0,t)},sx=(0,j.lazy)(()=>Z(()=>import(`./highlighted-body-OFNGDK62-DGw6RxGl.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),cx=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=Q(),l=(0,j.useMemo)(()=>ox(e),[e]),u=(0,j.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
115
115
  `).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,M.jsx)(rx.Provider,{value:{code:e},children:(0,M.jsxs)(nx,{isIncomplete:i,language:t,children:[(0,M.jsx)(ax,{language:t}),r?(0,M.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,M.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(tx,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,M.jsx)(sx,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},lx={CheckIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,M.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,M.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},ux=(0,j.createContext)(lx),dx=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>e[n]===t[n]):!1},fx=({icons:e,children:t})=>{let n=(0,j.useRef)(e),r=(0,j.useRef)(e?{...lx,...e}:lx);dx(n.current,e)||(n.current=e,r.current=e?{...lx,...e}:lx);let i=r.current;return(0,M.jsx)(ux.Provider,{value:i,children:t})},px=()=>(0,j.useContext)(ux),mx={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},hx=(0,j.createContext)(mx),gx=()=>(0,j.useContext)(hx),_x=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=Q(),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(0),{code:d}=ix(),{isAnimating:f}=(0,j.useContext)(CC),p=gx(),m=a??d,h=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(m),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,j.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let g=px(),_=c?g.CheckIcon:g.CopyIcon;return(0,M.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:f,onClick:h,title:p.copyCode,type:`button`,...o,children:r??(0,M.jsx)(_,{size:14})})},vx={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},yx=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=Q(),{code:c}=ix(),{isAnimating:l}=(0,j.useContext)(CC),u=gx(),d=px(),f=a??c,p=`file.${n&&n in vx?vx[n]:`txt`}`,m=()=>{try{Zb(p,f,`text/plain`),e?.()}catch(e){t?.(e)}};return(0,M.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:m,title:u.downloadFile,type:`button`,...o,children:r??(0,M.jsx)(d.DownloadIcon,{size:14})})},bx=()=>{let{Loader2Icon:e}=px(),t=Q();return(0,M.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,M.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,M.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,M.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},xx=/\.[^/.]+$/,Sx=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=px(),c=Q(),l=(0,j.useRef)(null),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=gx(),h=o.width!=null||o.height!=null,g=(u||h)&&!f,_=f&&!h;(0,j.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;d(t),p(!t)}},[]);let v=(0,j.useCallback)(e=>{d(!0),p(!1),i?.(e)},[i]),y=(0,j.useCallback)(e=>{d(!1),p(!0),a?.(e)},[a]),b=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(xx,``)}.${i}`}Zb(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,M.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,M.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,_&&`hidden`,t),"data-streamdown":`image`,onError:y,onLoad:v,ref:l,src:n,...o}),_&&(0,M.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:m.imageNotAvailable}),(0,M.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),g&&(0,M.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:b,title:m.downloadImage,type:`button`,children:(0,M.jsx)(s,{size:14})})]}):null},Cx=0,wx=()=>{Cx+=1,Cx===1&&(document.body.style.overflow=`hidden`)},Tx=()=>{Cx=Math.max(0,Cx-1),Cx===0&&(document.body.style.overflow=``)},Ex=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=px(),c=Q(),[l,u]=(0,j.useState)(!1),d=gx(),f=(0,j.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),p=(0,j.useCallback)(()=>{r(),n()},[r,n]);return(0,j.useEffect)(()=>{if(t){wx();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Tx()}}},[t,n]),t?(0,M.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,M.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,M.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:d.close,type:`button`,children:(0,M.jsx)(s,{size:16})}),(0,M.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,M.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,M.jsx)(o,{size:20}),(0,M.jsx)(`span`,{children:d.openExternalLink})]}),(0,M.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,M.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,M.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,M.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:f,type:`button`,children:l?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(i,{size:14}),(0,M.jsx)(`span`,{children:d.copied})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(a,{size:14}),(0,M.jsx)(`span`,{children:d.copyLink})]})}),(0,M.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:p,type:`button`,children:[(0,M.jsx)(o,{size:14}),(0,M.jsx)(`span`,{children:d.openLink})]})]})]})}):null},Dx=(0,j.createContext)(null),Ox=()=>(0,j.useContext)(Dx),kx=()=>Ox()?.code??null,Ax=()=>Ox()?.mermaid??null,jx=e=>{var t;let n=Ox();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},Mx=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),Nx=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=Q(),[s,c]=(0,j.useState)(!1),l=(0,j.useRef)(null),{isAnimating:u}=(0,j.useContext)(CC),d=px(),f=Ax(),p=gx(),m=async t=>{try{if(t===`mmd`){Zb(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!f){a?.(Error(`Mermaid plugin not available`));return}let n=f.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){Zb(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){Zb(`diagram.png`,await Mx(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,M.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,M.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:p.downloadDiagram,type:`button`,children:t??(0,M.jsx)(d.DownloadIcon,{size:14})}),s?(0,M.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`svg`),title:p.downloadDiagramAsSvg,type:`button`,children:p.mermaidFormatSvg}),(0,M.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`png`),title:p.downloadDiagramAsPng,type:`button`,children:p.mermaidFormatPng}),(0,M.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`mmd`),title:p.downloadDiagramAsMmd,type:`button`,children:p.mermaidFormatMmd})]}):null]})},Px=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=px(),c=Q(),[l,u]=(0,j.useState)(!1),{isAnimating:d,controls:f}=(0,j.useContext)(CC),p=gx(),m=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0?!0:e.panZoom!==!1})(),h=()=>{u(!l)};return(0,j.useEffect)(()=>{if(l){wx();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Tx()}}},[l]),(0,j.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:d,onClick:h,title:p.viewFullscreen,type:`button`,...a,children:(0,M.jsx)(o,{size:14})}),l?(0,Qv.createPortal)((0,M.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:h,onKeyDown:e=>{e.key===`Escape`&&h()},role:`button`,tabIndex:0,children:[(0,M.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:h,title:p.exitFullscreen,type:`button`,children:(0,M.jsx)(s,{size:20})}),(0,M.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,M.jsx)(DC,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})},Fx=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},Ix=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
116
116
  `)&&(t=!0)}return t?n?`"${e.replace(/"/g,`""`)}"`:`"${e}"`:e},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(`,`),o+=1);for(let e of n)a[o]=e.map(r).join(`,`),o+=1;return a.join(`
117
117
  `)},Lx=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1;for(let n of e)if(n===` `||n===`
118
118
  `||n===`\r`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===` `?n.push(`\\t`):t===`
119
119
  `?n.push(`\\n`):t===`\r`?n.push(`\\r`):n.push(t);return n.join(``)},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(` `),o+=1);for(let e of n)a[o]=e.map(r).join(` `),o+=1;return a.join(`
120
120
  `)},Rx=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):n.push(t);return n.join(``)},zx=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0;r[i]=`| ${t.map(e=>Rx(e)).join(` | `)} |`,i+=1;let a=Array(t.length);for(let e=0;e<t.length;e+=1)a[e]=`---`;r[i]=`| ${a.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?Rx(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else r[i]=`| ${e.map(e=>Rx(e)).join(` | `)} |`,i+=1;return r.join(`
121
- `)},Bx=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=Q(),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(0),{isAnimating:f}=(0,j.useContext)(CC),p=gx(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=Fx(t),o=({csv:Ix,tsv:Lx,md:zx}[e]||zx)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=px(),g=c?h.CheckIcon:h.CopyIcon;return(0,M.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,M.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,M.jsx)(g,{height:14,width:14})}),o?(0,M.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},Vx=({children:e,className:t,onDownload:n,onError:r})=>{let i=Q(),[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),{isAnimating:c}=(0,j.useContext)(CC),l=gx(),u=px(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=Fx(t),a=e===`csv`?Ix(i):zx(i);Zb(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,M.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,M.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,M.jsx)(u.DownloadIcon,{size:14})}),a?(0,M.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},Hx=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=px(),o=Q(),[s,c]=(0,j.useState)(!1),{isAnimating:l}=(0,j.useContext)(CC),u=gx(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,j.useEffect)(()=>{if(s){wx();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Tx()}}},[s]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,M.jsx)(i,{size:14})}),s?(0,Qv.createPortal)((0,M.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,M.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,M.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,M.jsx)(Bx,{}):null,r?(0,M.jsx)(Vx,{}):null,(0,M.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,M.jsx)(a,{size:20})})]}),(0,M.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,M.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},Ux=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=Q(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,M.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,M.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,M.jsx)(Bx,{}):null,l?(0,M.jsx)(Vx,{}):null,u?(0,M.jsx)(Hx,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,M.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,M.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},Wx=/startLine=(\d+)/,Gx=/\bnoLineNumbers\b/,Kx=(0,j.lazy)(()=>Z(()=>import(`./mermaid-GHXKKRXX-DxKK2ZHj.js`).then(e=>({default:e.Mermaid})),[])),qx=/language-([^\s]+)/;function Jx(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function Yx(e,t){return e.className===t.className&&Jx(e.node,t.node)}var Xx=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,Zx=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},Qx=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},$x=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},eS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ol`,{className:Q()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>Yx(e,t));eS.displayName=`MarkdownOl`;var tS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`li`,{className:Q()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&Jx(e.node,t.node));tS.displayName=`MarkdownLi`;var nS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ul`,{className:Q()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>Yx(e,t));nS.displayName=`MarkdownUl`;var rS=(0,j.memo)(({className:e,node:t,...n})=>(0,M.jsx)(`hr`,{className:Q()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>Yx(e,t));rS.displayName=`MarkdownHr`;var iS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`span`,{className:Q()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>Yx(e,t));iS.displayName=`MarkdownStrong`;var aS=(0,j.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=Q(),{linkSafety:o}=(0,j.useContext)(CC),[s,c]=(0,j.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,j.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,j.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,j.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,M.jsx)(Ex,{...p})]}):(0,M.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>Yx(e,t)&&e.href===t.href);aS.displayName=`MarkdownA`;var oS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h1`,{className:Q()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>Yx(e,t));oS.displayName=`MarkdownH1`;var sS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h2`,{className:Q()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>Yx(e,t));sS.displayName=`MarkdownH2`;var cS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h3`,{className:Q()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>Yx(e,t));cS.displayName=`MarkdownH3`;var lS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h4`,{className:Q()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>Yx(e,t));lS.displayName=`MarkdownH4`;var uS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h5`,{className:Q()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>Yx(e,t));uS.displayName=`MarkdownH5`;var dS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h6`,{className:Q()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>Yx(e,t));dS.displayName=`MarkdownH6`;var fS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,j.useContext)(CC);return(0,M.jsx)(Ux,{className:t,showControls:Xx(i,`table`),showCopy:Zx(i,`copy`),showDownload:Zx(i,`download`),showFullscreen:Zx(i,`fullscreen`),...r,children:e})},(e,t)=>Yx(e,t));fS.displayName=`MarkdownTable`;var pS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`thead`,{className:Q()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>Yx(e,t));pS.displayName=`MarkdownThead`;var mS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tbody`,{className:Q()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>Yx(e,t));mS.displayName=`MarkdownTbody`;var hS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tr`,{className:Q()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>Yx(e,t));hS.displayName=`MarkdownTr`;var gS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`th`,{className:Q()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>Yx(e,t));gS.displayName=`MarkdownTh`;var _S=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`td`,{className:Q()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>Yx(e,t));_S.displayName=`MarkdownTd`;var vS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`blockquote`,{className:Q()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>Yx(e,t));vS.displayName=`MarkdownBlockquote`;var yS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sup`,{className:Q()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>Yx(e,t));yS.displayName=`MarkdownSup`;var bS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sub`,{className:Q()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>Yx(e,t));bS.displayName=`MarkdownSub`;var xS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,j.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,j.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,j.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,j.isValidElement)(e))return e;if(e.type===eS){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,M.jsx)(`section`,{className:t,...r,children:i}):null}return(0,M.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>Yx(e,t));xS.displayName=`MarkdownSection`;var SS=(0,j.memo)(({node:e,className:t,children:n,...r})=>{let i=Q(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,j.useContext)(CC),l=Ax(),u=qb(),d=(t?.match(qx))?.at(1)??``,f=jx(d);if(a)return(0,M.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(Wx),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&Gx.test(p))&&c!==!1,v=``;if((0,j.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(bx,{}),children:(0,M.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=Xx(s,`mermaid`),n=$x(s,`download`),r=$x(s,`copy`),a=$x(s,`fullscreen`),c=$x(s,`panZoom`),l=e&&(n||r||a);return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(bx,{}),children:(0,M.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,M.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,M.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,M.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,M.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,M.jsx)(Nx,{chart:v,config:o?.config}):null,r?(0,M.jsx)(_x,{code:v}):null,a?(0,M.jsx)(Px,{chart:v,config:o?.config}):null]})}):null,(0,M.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,M.jsx)(Kx,{chart:v,config:o?.config,showControls:c})})]})})}let y=Xx(s,`code`),b=Qx(s,`download`),x=Qx(s,`copy`);return(0,M.jsx)(cx,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,M.jsxs)(M.Fragment,{children:[b?(0,M.jsx)(yx,{code:v,language:d}):null,x?(0,M.jsx)(_x,{}):null]}):null})},(e,t)=>e.className===t.className&&Jx(e.node,t.node));SS.displayName=`MarkdownCode`;var CS=(0,j.memo)(Sx,(e,t)=>e.className===t.className&&Jx(e.node,t.node));CS.displayName=`MarkdownImg`;var wS=(0,j.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,j.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,M.jsx)(M.Fragment,{children:e})}return(0,M.jsx)(`p`,{...n,children:e})},(e,t)=>Yx(e,t));wS.displayName=`MarkdownParagraph`;var TS={ol:eS,li:tS,ul:nS,hr:rS,strong:iS,a:aS,h1:oS,h2:sS,h3:cS,h4:lS,h5:uS,h6:dS,table:fS,thead:pS,tbody:mS,tr:hS,th:gS,td:_S,blockquote:vS,code:SS,img:CS,pre:({children:e})=>(0,j.isValidElement)(e)?(0,j.cloneElement)(e,{"data-block":`true`}):e,sup:yS,sub:bS,p:wS,section:xS},ES=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,DS=/\p{L}/u;function OS(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(ES.test(e))return`rtl`;if(DS.test(e))return`ltr`}return`ltr`}var kS=/^[ \t]{0,3}(`{3,}|~{3,})/,AS=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,jS=e=>{let t=e.split(`
121
+ `)},Bx=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=Q(),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(0),{isAnimating:f}=(0,j.useContext)(CC),p=gx(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=Fx(t),o=({csv:Ix,tsv:Lx,md:zx}[e]||zx)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=px(),g=c?h.CheckIcon:h.CopyIcon;return(0,M.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,M.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,M.jsx)(g,{height:14,width:14})}),o?(0,M.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},Vx=({children:e,className:t,onDownload:n,onError:r})=>{let i=Q(),[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),{isAnimating:c}=(0,j.useContext)(CC),l=gx(),u=px(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=Fx(t),a=e===`csv`?Ix(i):zx(i);Zb(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,M.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,M.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,M.jsx)(u.DownloadIcon,{size:14})}),a?(0,M.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},Hx=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=px(),o=Q(),[s,c]=(0,j.useState)(!1),{isAnimating:l}=(0,j.useContext)(CC),u=gx(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,j.useEffect)(()=>{if(s){wx();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Tx()}}},[s]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,M.jsx)(i,{size:14})}),s?(0,Qv.createPortal)((0,M.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,M.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,M.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,M.jsx)(Bx,{}):null,r?(0,M.jsx)(Vx,{}):null,(0,M.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,M.jsx)(a,{size:20})})]}),(0,M.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,M.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},Ux=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=Q(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,M.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,M.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,M.jsx)(Bx,{}):null,l?(0,M.jsx)(Vx,{}):null,u?(0,M.jsx)(Hx,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,M.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,M.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},Wx=/startLine=(\d+)/,Gx=/\bnoLineNumbers\b/,Kx=(0,j.lazy)(()=>Z(()=>import(`./mermaid-GHXKKRXX-CmvL8Wz0.js`).then(e=>({default:e.Mermaid})),[])),qx=/language-([^\s]+)/;function Jx(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function Yx(e,t){return e.className===t.className&&Jx(e.node,t.node)}var Xx=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,Zx=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},Qx=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},$x=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},eS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ol`,{className:Q()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>Yx(e,t));eS.displayName=`MarkdownOl`;var tS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`li`,{className:Q()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&Jx(e.node,t.node));tS.displayName=`MarkdownLi`;var nS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ul`,{className:Q()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>Yx(e,t));nS.displayName=`MarkdownUl`;var rS=(0,j.memo)(({className:e,node:t,...n})=>(0,M.jsx)(`hr`,{className:Q()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>Yx(e,t));rS.displayName=`MarkdownHr`;var iS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`span`,{className:Q()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>Yx(e,t));iS.displayName=`MarkdownStrong`;var aS=(0,j.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=Q(),{linkSafety:o}=(0,j.useContext)(CC),[s,c]=(0,j.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,j.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,j.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,j.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,M.jsx)(Ex,{...p})]}):(0,M.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>Yx(e,t)&&e.href===t.href);aS.displayName=`MarkdownA`;var oS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h1`,{className:Q()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>Yx(e,t));oS.displayName=`MarkdownH1`;var sS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h2`,{className:Q()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>Yx(e,t));sS.displayName=`MarkdownH2`;var cS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h3`,{className:Q()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>Yx(e,t));cS.displayName=`MarkdownH3`;var lS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h4`,{className:Q()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>Yx(e,t));lS.displayName=`MarkdownH4`;var uS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h5`,{className:Q()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>Yx(e,t));uS.displayName=`MarkdownH5`;var dS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h6`,{className:Q()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>Yx(e,t));dS.displayName=`MarkdownH6`;var fS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,j.useContext)(CC);return(0,M.jsx)(Ux,{className:t,showControls:Xx(i,`table`),showCopy:Zx(i,`copy`),showDownload:Zx(i,`download`),showFullscreen:Zx(i,`fullscreen`),...r,children:e})},(e,t)=>Yx(e,t));fS.displayName=`MarkdownTable`;var pS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`thead`,{className:Q()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>Yx(e,t));pS.displayName=`MarkdownThead`;var mS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tbody`,{className:Q()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>Yx(e,t));mS.displayName=`MarkdownTbody`;var hS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tr`,{className:Q()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>Yx(e,t));hS.displayName=`MarkdownTr`;var gS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`th`,{className:Q()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>Yx(e,t));gS.displayName=`MarkdownTh`;var _S=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`td`,{className:Q()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>Yx(e,t));_S.displayName=`MarkdownTd`;var vS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`blockquote`,{className:Q()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>Yx(e,t));vS.displayName=`MarkdownBlockquote`;var yS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sup`,{className:Q()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>Yx(e,t));yS.displayName=`MarkdownSup`;var bS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sub`,{className:Q()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>Yx(e,t));bS.displayName=`MarkdownSub`;var xS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,j.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,j.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,j.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,j.isValidElement)(e))return e;if(e.type===eS){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,M.jsx)(`section`,{className:t,...r,children:i}):null}return(0,M.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>Yx(e,t));xS.displayName=`MarkdownSection`;var SS=(0,j.memo)(({node:e,className:t,children:n,...r})=>{let i=Q(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,j.useContext)(CC),l=Ax(),u=qb(),d=(t?.match(qx))?.at(1)??``,f=jx(d);if(a)return(0,M.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(Wx),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&Gx.test(p))&&c!==!1,v=``;if((0,j.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(bx,{}),children:(0,M.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=Xx(s,`mermaid`),n=$x(s,`download`),r=$x(s,`copy`),a=$x(s,`fullscreen`),c=$x(s,`panZoom`),l=e&&(n||r||a);return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(bx,{}),children:(0,M.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,M.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,M.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,M.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,M.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,M.jsx)(Nx,{chart:v,config:o?.config}):null,r?(0,M.jsx)(_x,{code:v}):null,a?(0,M.jsx)(Px,{chart:v,config:o?.config}):null]})}):null,(0,M.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,M.jsx)(Kx,{chart:v,config:o?.config,showControls:c})})]})})}let y=Xx(s,`code`),b=Qx(s,`download`),x=Qx(s,`copy`);return(0,M.jsx)(cx,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,M.jsxs)(M.Fragment,{children:[b?(0,M.jsx)(yx,{code:v,language:d}):null,x?(0,M.jsx)(_x,{}):null]}):null})},(e,t)=>e.className===t.className&&Jx(e.node,t.node));SS.displayName=`MarkdownCode`;var CS=(0,j.memo)(Sx,(e,t)=>e.className===t.className&&Jx(e.node,t.node));CS.displayName=`MarkdownImg`;var wS=(0,j.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,j.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,M.jsx)(M.Fragment,{children:e})}return(0,M.jsx)(`p`,{...n,children:e})},(e,t)=>Yx(e,t));wS.displayName=`MarkdownParagraph`;var TS={ol:eS,li:tS,ul:nS,hr:rS,strong:iS,a:aS,h1:oS,h2:sS,h3:cS,h4:lS,h5:uS,h6:dS,table:fS,thead:pS,tbody:mS,tr:hS,th:gS,td:_S,blockquote:vS,code:SS,img:CS,pre:({children:e})=>(0,j.isValidElement)(e)?(0,j.cloneElement)(e,{"data-block":`true`}):e,sup:yS,sub:bS,p:wS,section:xS},ES=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,DS=/\p{L}/u;function OS(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(ES.test(e))return`rtl`;if(DS.test(e))return`ltr`}return`ltr`}var kS=/^[ \t]{0,3}(`{3,}|~{3,})/,AS=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,jS=e=>{let t=e.split(`
122
122
  `),n=null,r=0;for(let e of t){let t=kS.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},MS=e=>{let t=e.split(`
123
123
  `);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&AS.test(t))return!0}return!1},NS=()=>e=>{Re(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},PS=[],FS={allowDangerousHtml:!0},IS=new WeakMap,LS=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=IS.get(e);n||(n=e.name,IS.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=IS.get(r);e||(e=r.name,IS.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},RS=e=>{let t=zS(e),n=e.children||``;return KS(t.runSync(t.parse(n),n),e)},zS=e=>{let t=LS.get(e);if(t)return t;let n=VS(e);return LS.set(e,n),n},BS=e=>e.some(e=>Array.isArray(e)?e[0]===cs:e===cs),VS=e=>{let t=e.rehypePlugins||PS,n=e.remarkPlugins||PS,r=BS(t)?n:[...n,NS],i=e.remarkRehypeOptions?{...FS,...e.remarkRehypeOptions}:FS;return Hv().use(C_).use(r).use(mv,i).use(t)},HS=e=>e,US=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},WS=(e,t)=>{for(let n in Rg)if(Object.hasOwn(Rg,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=Rg[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},GS=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},KS=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||HS;Re(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return US(c,s,a,e.value),s;if(e.type===`element`&&(WS(e,t),GS(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return gg(e,{Fragment:M.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:M.jsx,jsxs:M.jsxs,passKeys:!0,passNode:!0})},qS=/\[\^[\w-]{1,200}\](?!:)/,JS=/\[\^[\w-]{1,200}\]:/,YS=/<(\w+)[\s>]/,XS=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),ZS=new Map,QS=new Map,$S=e=>{let t=e.toLowerCase(),n=ZS.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return ZS.set(t,r),r},eC=e=>{let t=e.toLowerCase(),n=QS.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return QS.set(t,r),r},tC=(e,t)=>{if(XS.has(t.toLowerCase()))return 0;let n=e.match($S(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},nC=(e,t)=>{let n=e.match(eC(t));return n?n.length:0},rC=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},iC=e=>{let t=qS.test(e),n=JS.test(e);if(t||n)return[e];let r=xb.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=tC(t,e),o=nC(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match(YS);if(e){let n=e[1];tC(t,n)>nC(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(rC(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},aC=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>{if(!n.includes(`
124
124
 
@@ -284,7 +284,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[gA(e),e])),lj=new Map([[`s`,JA(383)],[JA(383
284
284
  \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${JA(e.codePointAt(0)-1)}${JA(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Bj(Lj(`[${e}]`),t))}else n(Bj(Rj(Lj(fj.get(u)),l),t));else if(c===`property`)cj.has(gA(u))||(e.key=`sc`);else if(c===`space`)n(zj(cA(`space`,{negate:l}),t));else if(c===`word`)n(Bj(Rj(Lj(oj),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=tA({flags:c});e.body[0].body=o(),i(Bj(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&Mk(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error($`Uses "\K" in a way that's unsupported`);let o=nA({behind:!0});o.body[0].body=a(),i(Bj(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Bj(nA({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=tA();t.body[0].body.push(e.body),e.body=Bj(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=jj(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error($`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Ij(n)&&(n=Dj(n,t),e.ref=n)}},yj={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=zj(Tj(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&QA(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=QA(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=ZA(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Tj(0):wj(o,r.groupOriginByCopy,null),l=c;if(!s){let e=Oj(Ej(o,e=>e.type===`Group`&&!!e.flags)),t=e?ZA(r.globalFlags,e):r.globalFlags;Sj(t,r.currentFlags)||(l=tA({flags:kj(t)}),l.body[0].body.push(c))}n(Bj(l,t),{traverse:!s})}},bj={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>Cj(t,e));i.length?i.length>1?n(Bj(tA({atomic:!0,body:i.reverse().map(e=>Gk({body:[qk(e.number)]}))}),t)):e.ref=i[0].number:n(Bj(nA({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=Jk();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function xj(e){yA(e,{"*"({node:e,parent:t}){e.parent=t}})}function Sj(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Cj(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=Aj(n.parent);for(let r of t){if(r===n)break;if(r===e||Mj(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function wj(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=wj(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Tj(e){let t=sA(e);return t.isRecursive=!0,t}function Ej(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Dj(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function Oj(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function kj({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Aj(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function jj(e){let t=e.find(e=>e.kind===`search_start`||Fj(e,{negate:!1})||!Nj(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=jj(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Mj(e,t){let n=Aj(e)??[];for(let e of n)if(e===t||Mj(e,t))return!0;return!1}function Nj({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function Pj(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function Fj(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Mk(e.body[0],{type:`Assertion`,kind:`search_start`})}function Ij(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Lj(e,t){let n=Fk(e,{...t,unicodePropertyMap:cj}).body;return n.length>1||n[0].body.length>1?tA({body:n}):n[0].body[0]}function Rj(e,t){return e.negate=t,e}function zj(e,t){return e.parent=t,e}function Bj(e,t){return xj(e),e.parent=t,e}function Vj(e,t){let n=rj(t),r=$A(n.target,`ES2024`),i=$A(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];yA(e,Hj,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,ej(Uj[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&QA(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Hj={"*":{enter({node:e},t){if(tM(e)){let n=t.getCurrentModI();t.pushModI(e.flags?ZA({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){tM(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Yj(JA(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Xj(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&gj.has(e.value)&&t.setHasCasedChar()}},Uj={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?$`\B`:$`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=JA(e),r=Zj(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Yj(n)){let e=sj(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);YA.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(rM)&&(o=[Yk(45),...o.filter(e=>!rM(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||YA.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=tA(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=Gk({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(YA.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=Zj(n,i),o=Zj(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Qj(Xj(e)).forEach(e=>{s.add(Array.isArray(e)?`${Zj(e[0],i)}-${Zj(e[1],i)}`:Zj(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:$`[^\n]`;if(e===`digit`)return t?$`\D`:$`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&gj.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?$`\P`:$`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?$`\W`:$`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=ZA(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${$j(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+eM(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:$`\g<${t}&R=${r}>`}},Wj=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),Gj=new Set([`-`,`\\`,`]`,`^`,`[`]),Kj=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),qj=new Map([[9,$`\t`],[10,$`\n`],[11,$`\v`],[12,$`\f`],[13,$`\r`],[8232,$`\u2028`],[8233,$`\u2029`],[65279,$`\uFEFF`]]),Jj=/^\p{Cased}$/u;function Yj(e){return Jj.test(e)}function Xj(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=JA(e);if(!Yj(t))continue;let o=sj(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function Zj(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(qj.has(e))return qj.get(e);if(e<32||e>126&&e<160||e>262143||t&&nM(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?Kj:Gj:Wj,a=JA(e);return(i.has(a)?`\\`:``)+a}function Qj(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function $j(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function eM({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function tM({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function nM(e){return e>47&&e<58}function rM({type:e,value:t}){return e===`Character`&&t===45}var iM=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=oM(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(aM(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=sM(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function aM(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function oM(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)QA(n,t,{}).transferTo=e;return n}function sM(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function cM(e,t){let n=lM(e,t);return n.options?new iM(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function lM(e,t){let n=rj(t),r=_j(Fk(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:cj}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Vj(r,n),a=HA(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=MA(FA(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}var uM=4294967295,dM=class{constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}regexps;findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=[];function a(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>e==null?{start:uM,end:uM,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{n.lastIndex=t;let o=n.exec(r);if(!o)continue;if(o.index===t)return a(e,o,0);i.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,n,r]of i)if(n.index===e)return a(t,n,r)}return null}};function fM(e,t){return cM(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function pM(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>fM(e,{target:t.target}),{createScanner(e){return new dM(e,t)},createString(e){return{content:e}}}}var mM=pM({forgiving:!0}),hM=Object.fromEntries(iO.flatMap(e=>(e.aliases??[]).map(t=>[t,e.id]))),gM=new Set(Object.keys(sO)),_M=e=>{let t=e.trim().toLowerCase();return hM[t]||(gM.has(t),t)},vM=new Map,yM=new Map,bM=new Map,xM=e=>typeof e==`string`?e:e.name??`custom`,SM=(e,t)=>`${e}-${xM(t[0])}-${xM(t[1])}`,CM=(e,t,n)=>{let r=e.slice(0,100),i=e.length>100?e.slice(-100):``;return`${t}:${n[0]}:${n[1]}:${e.length}:${r}:${i}`},wM=(e,t)=>{let n=SM(e,t);if(vM.has(n))return vM.get(n);let r=PO({themes:t,langs:[e],engine:mM});return vM.set(n,r),r};function TM(e={}){let t=e.themes??[`github-light`,`github-dark`];return{name:`shiki`,type:`code-highlighter`,supportsLanguage(e){let t=_M(e);return gM.has(t)},getSupportedLanguages(){return Array.from(gM)},getThemes(){return t},highlight({code:e,language:t,themes:n},r){let i=_M(t),a=[xM(n[0]),xM(n[1])],o=CM(e,i,a);return yM.has(o)?yM.get(o):(r&&(bM.has(o)||bM.set(o,new Set),bM.get(o).add(r)),wM(gM.has(i)?i:`text`,n).then(t=>{let n=t.getLoadedLanguages().includes(i)?i:`text`,r=t.codeToTokens(e,{lang:n,themes:{light:a[0],dark:a[1]}});yM.set(o,r);let s=bM.get(o);if(s){for(let e of s)e(r);bM.delete(o)}}).catch(e=>{console.error(`[Streamdown Code] Failed to highlight code:`,e),bM.delete(o)}),null)}}}var EM=TM();function DM(e){return!isFinite(e)||isNaN(e)?`0:00`:`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`}function OM({audioData:e}){let[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(0),[a,o]=(0,j.useState)(0),s=(0,j.useRef)(null),c=(0,j.useRef)(null);(0,j.useEffect)(()=>{let t=new Audio(e);return t.addEventListener(`durationchange`,()=>{isFinite(t.duration)&&o(t.duration)}),t.addEventListener(`timeupdate`,()=>{isFinite(t.duration)&&t.duration>0&&(i(t.currentTime/t.duration),a===0&&o(t.duration))}),t.addEventListener(`ended`,()=>{n(!1),i(0)}),t.addEventListener(`loadedmetadata`,()=>{isFinite(t.duration)||(t.currentTime=1e10,t.addEventListener(`timeupdate`,function e(){isFinite(t.duration)&&(o(t.duration),t.currentTime=0,t.removeEventListener(`timeupdate`,e))}))}),s.current=t,()=>{t.pause(),t.src=``}},[e]);let l=(0,j.useCallback)(()=>{let e=s.current;e&&(t?(e.pause(),n(!1)):(e.play(),n(!0)))},[t]),u=(0,j.useCallback)(e=>{let t=s.current,n=c.current;if(!t||!n||!isFinite(t.duration))return;let r=n.getBoundingClientRect(),a=Math.max(0,Math.min(1,(e.clientX-r.left)/r.width));t.currentTime=a*t.duration,i(a)},[]);return(0,M.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-[180px]`,children:[(0,M.jsx)(`button`,{onClick:l,className:`flex items-center justify-center h-8 w-8 shrink-0 rounded-full bg-white/20 hover:bg-white/30 transition-colors`,children:t?(0,M.jsx)(k,{className:`h-3.5 w-3.5 fill-current`}):(0,M.jsx)(se,{className:`h-3.5 w-3.5 fill-current ml-0.5`})}),(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col gap-1`,children:[(0,M.jsx)(`div`,{ref:c,onClick:u,className:`h-1 bg-white/20 rounded-full cursor-pointer relative`,children:(0,M.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-white/70 rounded-full transition-[width] duration-100`,style:{width:`${r*100}%`}})}),(0,M.jsx)(`span`,{className:`text-[10px] opacity-60 tabular-nums`,children:DM(t?r*a:a)})]})]})}function kM({group:e}){let[t,n]=(0,j.useState)({}),[r,i]=(0,j.useState)(`idle`),[a,o]=(0,j.useState)(``),s=(e,t)=>{n(n=>({...n,[e]:t}))},l=async()=>{let e=Object.entries(t).filter(([,e])=>e.trim());if(e.length!==0){i(`submitting`),o(``);try{let t=await fetch(`/api/env`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({vars:Object.fromEntries(e)})});if(!t.ok){let e=await t.json().catch(()=>({error:`Request failed`}));throw Error(e.error||`Request failed`)}i(`submitted`)}catch(e){o(e.message||`Failed to save`),i(`error`)}}},u=Object.values(t).filter(e=>e.trim()).length;return r===`submitted`?(0,M.jsx)(`div`,{className:`my-3 rounded-xl border border-emerald-500/20 bg-emerald-500/5 overflow-hidden`,children:(0,M.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-emerald-500 shrink-0`,children:(0,M.jsx)(c,{className:`w-4 h-4 text-white`,strokeWidth:3})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-emerald-400 font-medium text-sm`,children:e.title}),(0,M.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[u,` variable`,u===1?``:`s`,` saved — backend restarting`]})]})]})}):(0,M.jsxs)(`div`,{className:`my-3 rounded-xl border border-border/60 bg-card/50 overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-3 border-b border-border/40 bg-muted/30`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-7 h-7 rounded-lg bg-primary/10 shrink-0`,children:(0,M.jsx)(re,{className:`w-3.5 h-3.5 text-primary`})}),(0,M.jsx)(`span`,{className:`font-medium text-sm text-foreground`,children:e.title})]}),(0,M.jsx)(`div`,{className:`px-4 py-3 space-y-3`,children:e.fields.map(e=>(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,M.jsx)(`span`,{children:e.label}),(0,M.jsx)(`code`,{className:`text-[10px] px-1 py-0.5 rounded bg-muted text-muted-foreground/70`,children:e.name})]}),(0,M.jsx)(`input`,{type:`text`,placeholder:e.placeholder,value:t[e.name]||``,onChange:t=>s(e.name,t.target.value),disabled:r===`submitting`,className:`w-full px-3 py-2 rounded-lg text-sm bg-background border border-border/60 text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/50 disabled:opacity-50 transition-colors font-mono`,spellCheck:!1,autoComplete:`off`})]},e.name))}),r===`error`&&(0,M.jsxs)(`div`,{className:`px-4 pb-2 flex items-center gap-1.5 text-xs text-red-400`,children:[(0,M.jsx)(ee,{className:`w-3 h-3 shrink-0`}),(0,M.jsx)(`span`,{children:a})]}),(0,M.jsxs)(`div`,{className:`px-4 py-3 border-t border-border/40 bg-muted/20 flex items-center justify-between`,children:[(0,M.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60`,children:[`Values are written to `,(0,M.jsx)(`code`,{className:`text-[10px]`,children:`.env`})]}),(0,M.jsx)(`button`,{onClick:l,disabled:u===0||r===`submitting`,className:`inline-flex items-center gap-1.5 px-4 py-1.5 rounded-lg text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all`,children:r===`submitting`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(v,{className:`w-3 h-3 animate-spin`}),`Saving...`]}):`Submit`})]})]})}function AM(e){let t=e.split(`/`);return t[t.length-1]||`bloby-image`}function jM({src:e,alt:t}){let[n,r]=(0,j.useState)(!1);return n?(0,M.jsxs)(`div`,{className:`my-2 flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl border border-border/30 bg-black/10 text-muted-foreground/50 text-xs`,children:[(0,M.jsx)(ne,{className:`h-4 w-4 shrink-0`}),(0,M.jsx)(`span`,{className:`truncate`,children:t||`Image not found`})]}):(0,M.jsxs)(`div`,{className:`relative group/img my-2 rounded-xl overflow-hidden border border-border/30 bg-black/20 w-fit max-w-full`,children:[(0,M.jsx)(`img`,{src:e,alt:t||`Generated image`,className:`max-w-full max-h-80 object-contain`,loading:`lazy`,onError:()=>r(!0)}),(0,M.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1.5 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,M.jsx)(`button`,{onClick:async()=>{try{let t=await(await fetch(e)).blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=AM(e),document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{window.open(e,`_blank`)}},className:`p-1.5 rounded-lg bg-black/60 hover:bg-black/80 text-white/80 hover:text-white transition-colors backdrop-blur-sm`,title:`Download original`,children:(0,M.jsx)(D,{className:`h-4 w-4`})})}),t&&(0,M.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-muted-foreground/70 truncate`,children:t})]})}function MM(e){return e.split(`
285
285
  `).join(`
286
286
 
287
- `)}function NM(e){return e<1024?`${e} chars`:`${(e/1024).toFixed(1)} KB`}function PM({title:e,content:t}){let[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(!1);return(0,M.jsxs)(`div`,{className:`my-2 rounded-xl border border-border/30 overflow-hidden`,children:[(0,M.jsxs)(`div`,{onClick:()=>r(e=>!e),className:`flex items-center gap-2.5 px-3.5 py-2.5 bg-white/[0.03] hover:bg-white/[0.05] transition-colors cursor-pointer select-none`,children:[(0,M.jsx)(E,{className:`h-3.5 w-3.5 text-muted-foreground/50 shrink-0 transition-transform duration-200 ${n?`rotate-90`:``}`}),(0,M.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/80 truncate min-w-0`,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground/35 tabular-nums`,children:NM(t.length)}),(0,M.jsx)(`button`,{onClick:async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},className:`p-1 rounded-md hover:bg-white/[0.08] text-muted-foreground/40 hover:text-muted-foreground/70 transition-colors`,title:`Copy text`,children:i?(0,M.jsx)(c,{className:`h-3.5 w-3.5`}):(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]})]}),n&&(0,M.jsx)(`div`,{className:`border-t border-border/15 max-h-[500px] overflow-y-auto px-4 py-3 text-sm leading-relaxed prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,M.jsx)(TC,{mode:`static`,plugins:{code:EM},controls:{code:{copy:!0,download:!1}},shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,children:MM(t)})})]})}function FM(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function IM(e){let t=e.match(/^\[([^\]]+)\]\n([\s\S]*)$/);if(!t)return{tag:`Chat`,body:e};let n=t[1].split(`|`)[0].trim();return{tag:n===`PWA`?`Chat`:n,body:t[2]}}function LM({tag:e}){let t=`h-3 w-3 opacity-60`;return e===`Mac`?(0,M.jsx)(O,{className:t}):e===`WhatsApp`?(0,M.jsx)(d,{className:t}):e===`workspace`?(0,M.jsx)(ae,{className:t}):e===`Chat`?(0,M.jsx)(s,{className:t}):e===`Alexa`?(0,M.jsx)(de,{className:t}):(0,M.jsx)(s,{className:t})}function RM(e){let t=e,n=`[pair-whatsapp](/api/channels/whatsapp/qr-page)`;t.includes(n)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/whatsapp\/qr-page`?/g,n));let r=`[connect-alexa](/api/channels/alexa/pair-page)`;return t.includes(r)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/alexa\/pair-page`?/g,r)),t}function zM(e){let t=[],n=/<EnvGroup\s+title="([^"]+)">([\s\S]*?)<\/EnvGroup>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],i=[],a=/<EnvInput\s+name="([^"]+)"\s+label="([^"]+)"\s+placeholder="([^"]+)"\s*\/>/g,o;for(;(o=a.exec(n))!==null;)i.push({name:o[1],label:o[2],placeholder:o[3]});i.length>0&&t.push({start:r.index,end:r.index+r[0].length,segment:{type:`env`,group:{title:e,fields:i}}})}let i=/<BlobyImage\s+src="([^"]+)"(?:\s+alt="([^"]*)")?\s*\/>/g;for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-image`,src:r[1],alt:r[2]||``}});let a=/<BlobyText\s+title="([^"]+)">([\s\S]*?)<\/BlobyText>/g;for(;(r=a.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-text`,title:r[1],content:r[2].trim()}});t.sort((e,t)=>e.start-t.start);let o=[],s=0;for(let n of t){if(n.start>s){let t=e.slice(s,n.start).trim();t&&o.push({type:`text`,value:t})}o.push(n.segment),s=n.end}if(s<e.length){let t=e.slice(s).trim();t&&o.push({type:`text`,value:t})}return o}function BM(e){return/<EnvGroup\s+title="[^"]+">/i.test(e)||/<BlobyImage\s+src="/i.test(e)||/<BlobyText\s+title="/i.test(e)}function VM({text:e}){let[t,n]=(0,j.useState)(!1);return(0,M.jsx)(`button`,{onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},className:`absolute -top-2.5 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded-md bg-background/80 border border-border/40 shadow-sm hover:bg-muted text-muted-foreground/60 hover:text-muted-foreground`,title:`Copy message`,children:t?(0,M.jsx)(c,{className:`h-3 w-3`}):(0,M.jsx)(b,{className:`h-3 w-3`})})}function HM(e){let t=e.outerHTML,n=window.open(``,`_blank`);n&&(n.document.write(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Table</title>
287
+ `)}function NM(e){return e<1024?`${e} chars`:`${(e/1024).toFixed(1)} KB`}function PM({title:e,content:t}){let[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(!1);return(0,M.jsxs)(`div`,{className:`my-2 rounded-xl border border-border/30 overflow-hidden`,children:[(0,M.jsxs)(`div`,{onClick:()=>r(e=>!e),className:`flex items-center gap-2.5 px-3.5 py-2.5 bg-white/[0.03] hover:bg-white/[0.05] transition-colors cursor-pointer select-none`,children:[(0,M.jsx)(E,{className:`h-3.5 w-3.5 text-muted-foreground/50 shrink-0 transition-transform duration-200 ${n?`rotate-90`:``}`}),(0,M.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/80 truncate min-w-0`,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground/35 tabular-nums`,children:NM(t.length)}),(0,M.jsx)(`button`,{onClick:async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},className:`p-1 rounded-md hover:bg-white/[0.08] text-muted-foreground/40 hover:text-muted-foreground/70 transition-colors`,title:`Copy text`,children:i?(0,M.jsx)(c,{className:`h-3.5 w-3.5`}):(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]})]}),n&&(0,M.jsx)(`div`,{className:`border-t border-border/15 max-h-[500px] overflow-y-auto px-4 py-3 text-sm leading-relaxed prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,M.jsx)(TC,{mode:`static`,plugins:{code:EM},controls:{code:{copy:!0,download:!1}},shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,children:MM(t)})})]})}function FM(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function IM(e){let t=e.match(/^\[([^\]]+)\]\n([\s\S]*)$/);if(!t)return{tag:`Chat`,body:e};let n=t[1].split(`|`)[0].trim(),r=n;return n===`PWA`?r=`Chat`:n.toLowerCase()===`workspace`&&(r=`Workspace`),{tag:r,body:t[2]}}function LM({tag:e}){let t=`h-3 w-3 opacity-60`;return e===`Mac`?(0,M.jsx)(O,{className:t}):e===`WhatsApp`?(0,M.jsx)(d,{className:t}):e===`Workspace`?(0,M.jsx)(ae,{className:t}):e===`Chat`?(0,M.jsx)(s,{className:t}):e===`Alexa`?(0,M.jsx)(de,{className:t}):(0,M.jsx)(s,{className:t})}function RM(e){let t=e,n=`[pair-whatsapp](/api/channels/whatsapp/qr-page)`;t.includes(n)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/whatsapp\/qr-page`?/g,n));let r=`[connect-alexa](/api/channels/alexa/pair-page)`;return t.includes(r)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/alexa\/pair-page`?/g,r)),t}function zM(e){let t=[],n=/<EnvGroup\s+title="([^"]+)">([\s\S]*?)<\/EnvGroup>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],i=[],a=/<EnvInput\s+name="([^"]+)"\s+label="([^"]+)"\s+placeholder="([^"]+)"\s*\/>/g,o;for(;(o=a.exec(n))!==null;)i.push({name:o[1],label:o[2],placeholder:o[3]});i.length>0&&t.push({start:r.index,end:r.index+r[0].length,segment:{type:`env`,group:{title:e,fields:i}}})}let i=/<BlobyImage\s+src="([^"]+)"(?:\s+alt="([^"]*)")?\s*\/>/g;for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-image`,src:r[1],alt:r[2]||``}});let a=/<BlobyText\s+title="([^"]+)">([\s\S]*?)<\/BlobyText>/g;for(;(r=a.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-text`,title:r[1],content:r[2].trim()}});t.sort((e,t)=>e.start-t.start);let o=[],s=0;for(let n of t){if(n.start>s){let t=e.slice(s,n.start).trim();t&&o.push({type:`text`,value:t})}o.push(n.segment),s=n.end}if(s<e.length){let t=e.slice(s).trim();t&&o.push({type:`text`,value:t})}return o}function BM(e){return/<EnvGroup\s+title="[^"]+">/i.test(e)||/<BlobyImage\s+src="/i.test(e)||/<BlobyText\s+title="/i.test(e)}function VM({text:e}){let[t,n]=(0,j.useState)(!1);return(0,M.jsx)(`button`,{onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},className:`absolute -top-2.5 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded-md bg-background/80 border border-border/40 shadow-sm hover:bg-muted text-muted-foreground/60 hover:text-muted-foreground`,title:`Copy message`,children:t?(0,M.jsx)(c,{className:`h-3 w-3`}):(0,M.jsx)(b,{className:`h-3 w-3`})})}function HM(e){let t=e.outerHTML,n=window.open(``,`_blank`);n&&(n.document.write(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Table</title>
288
288
  <style>
289
289
  body{background:#1a1a1a;color:#f5f5f5;font-family:system-ui,-apple-system,sans-serif;padding:2rem;margin:0}
290
290
  table{border-collapse:collapse;width:100%}
@@ -1 +1 @@
1
- import{c as e,r as t,t as n}from"./jsx-runtime-C0W9Wf2W.js";import{n as r,r as i,t as a}from"./bloby-CnyC8k_L.js";var o=e(t(),1),s=n(),c=({code:e,language:t,raw:n,className:c,startLine:l,lineNumbers:u,...d})=>{let{shikiTheme:f}=(0,o.useContext)(i),p=r(),[m,h]=(0,o.useState)(n);return(0,o.useEffect)(()=>{if(!p){h(n);return}let r=p.highlight({code:e,language:t,themes:f},e=>{h(e)});r&&h(r)},[e,t,f,p,n]),(0,s.jsx)(a,{className:c,language:t,lineNumbers:u,result:m,startLine:l,...d})};export{c as HighlightedCodeBlockBody};
1
+ import{c as e,r as t,t as n}from"./jsx-runtime-C0W9Wf2W.js";import{n as r,r as i,t as a}from"./bloby-l8C6YuPm.js";var o=e(t(),1),s=n(),c=({code:e,language:t,raw:n,className:c,startLine:l,lineNumbers:u,...d})=>{let{shikiTheme:f}=(0,o.useContext)(i),p=r(),[m,h]=(0,o.useState)(n);return(0,o.useEffect)(()=>{if(!p){h(n);return}let r=p.highlight({code:e,language:t,themes:f},e=>{h(e)});r&&h(r)},[e,t,f,p,n]),(0,s.jsx)(a,{className:c,language:t,lineNumbers:u,result:m,startLine:l,...d})};export{c as HighlightedCodeBlockBody};
@@ -0,0 +1 @@
1
+ import{i as e}from"./bloby-l8C6YuPm.js";export{e as Mermaid};
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-content" />
6
6
  <title>Bloby Chat</title>
7
- <script type="module" crossorigin src="/bloby/assets/bloby-CnyC8k_L.js"></script>
7
+ <script type="module" crossorigin src="/bloby/assets/bloby-l8C6YuPm.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="/bloby/assets/jsx-runtime-C0W9Wf2W.js">
9
9
  <link rel="modulepreload" crossorigin href="/bloby/assets/globals-DNO3ilRx.js">
10
10
  <link rel="stylesheet" crossorigin href="/bloby/assets/globals-D60b-8LY.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bloby-bot",
3
- "version": "0.49.3",
3
+ "version": "0.49.4",
4
4
  "releaseNotes": [
5
5
  "1. Something great..",
6
6
  "2. ",
@@ -35,8 +35,10 @@ function parseChannelTag(text: string): { tag: string; body: string } {
35
35
  const m = text.match(/^\[([^\]]+)\]\n([\s\S]*)$/);
36
36
  if (!m) return { tag: 'Chat', body: text };
37
37
  const raw = m[1].split('|')[0].trim();
38
- // Normalize explicit [PWA] tag to the friendlier "Chat" label
39
- const tag = raw === 'PWA' ? 'Chat' : raw;
38
+ // Normalize labels for display: [PWA] Chat, [workspace] Workspace
39
+ let tag = raw;
40
+ if (raw === 'PWA') tag = 'Chat';
41
+ else if (raw.toLowerCase() === 'workspace') tag = 'Workspace';
40
42
  return { tag, body: m[2] };
41
43
  }
42
44
 
@@ -44,7 +46,7 @@ function ChannelIcon({ tag }: { tag: string }) {
44
46
  const cls = 'h-3 w-3 opacity-60';
45
47
  if (tag === 'Mac') return <Laptop className={cls} />;
46
48
  if (tag === 'WhatsApp') return <Smartphone className={cls} />;
47
- if (tag === 'workspace') return <Monitor className={cls} />;
49
+ if (tag === 'Workspace') return <Monitor className={cls} />;
48
50
  if (tag === 'Chat') return <Globe className={cls} />;
49
51
  if (tag === 'Alexa') return <Volume2 className={cls} />;
50
52
  return <Globe className={cls} />;
@@ -1394,9 +1394,11 @@ mint();
1394
1394
  type: f.type, name: f.name, mediaType: f.mediaType, filePath: f.relPath,
1395
1395
  })));
1396
1396
  }
1397
+ // Prepend the channel tag so the UI can show the workspace icon.
1398
+ const taggedWorkspaceContent = `[workspace]\n${content}`;
1397
1399
  try {
1398
1400
  await workerApi(`/api/conversations/${convId}/messages`, 'POST', {
1399
- role: 'user', content, meta,
1401
+ role: 'user', content: taggedWorkspaceContent, meta,
1400
1402
  });
1401
1403
  } catch (err: any) {
1402
1404
  log.warn(`[workspace-chat] DB persist error: ${err.message}`);
@@ -1407,7 +1409,14 @@ mint();
1407
1409
  // The originating workspace subscriber renders its own message optimistically.
1408
1410
  broadcastBlobyExceptSubscriber(clientId, 'chat:sync', {
1409
1411
  conversationId: convId,
1410
- message: { role: 'user', content, timestamp: new Date().toISOString() },
1412
+ message: {
1413
+ role: 'user',
1414
+ content: taggedWorkspaceContent,
1415
+ timestamp: new Date().toISOString(),
1416
+ attachments: savedFiles.length
1417
+ ? savedFiles.map((f) => ({ type: f.type, name: f.name, mediaType: f.mediaType, filePath: f.relPath }))
1418
+ : undefined,
1419
+ },
1411
1420
  });
1412
1421
 
1413
1422
  let botName = 'Bloby', humanName = 'Human';
@@ -1452,12 +1461,11 @@ mint();
1452
1461
  const waMirrorTo = ownPhone ? `${ownPhone}@s.whatsapp.net` : undefined;
1453
1462
 
1454
1463
  // Channel tag so the agent knows the message came from the dashboard workspace
1455
- // (parallel to [WhatsApp ...] and [Alexa ...] tags). DB + chat:sync use the raw
1456
- // content so user-facing UIs show what was typed.
1464
+ // (parallel to [WhatsApp ...] and [Alexa ...] tags). Already prepended above.
1457
1465
  channelManager.pushWithRouting(
1458
1466
  convId,
1459
1467
  { surface: 'workspace', waSendTo: waMirrorTo, isSelfChat: true },
1460
- `[workspace]\n${content}`,
1468
+ taggedWorkspaceContent,
1461
1469
  agentAttachments,
1462
1470
  savedFiles,
1463
1471
  );
@@ -1 +0,0 @@
1
- import{i as e}from"./bloby-CnyC8k_L.js";export{e as Mermaid};