nextclaw 0.17.2 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +375 -168
- package/package.json +11 -11
- package/resources/USAGE.md +32 -14
- package/ui-dist/assets/ChannelsList-uKmkpD25.js +8 -0
- package/ui-dist/assets/ChatPage-CslhBPfT.js +43 -0
- package/ui-dist/assets/{DocBrowser-DjcghYGO.js → DocBrowser-C7-1sXqo.js} +1 -1
- package/ui-dist/assets/DocBrowser-DQjtSsY3.js +1 -0
- package/ui-dist/assets/{DocBrowserContext-CLlq7rZQ.js → DocBrowserContext-DN5tjUoS.js} +1 -1
- package/ui-dist/assets/{LogoBadge-D_dOy5U3.js → LogoBadge-DDS1sU_U.js} +1 -1
- package/ui-dist/assets/MarketplacePage-BZQW70ti.js +1 -0
- package/ui-dist/assets/{MarketplacePage-BlIeNn3x.js → MarketplacePage-DE0QjYVv.js} +1 -1
- package/ui-dist/assets/{McpMarketplacePage-mz2_IX1O.js → McpMarketplacePage-CeLvv1xy.js} +1 -1
- package/ui-dist/assets/ModelConfig-D1JtGtQv.js +1 -0
- package/ui-dist/assets/ProviderScopedModelInput-SAJH6nkC.js +1 -0
- package/ui-dist/assets/{ProvidersList-B0RCb_Vg.js → ProvidersList-1rKi3aQT.js} +1 -1
- package/ui-dist/assets/{RemoteAccessPage-CcfQjLtx.js → RemoteAccessPage-bIAKxDky.js} +1 -1
- package/ui-dist/assets/RuntimeConfig-BTk9319O.js +1 -0
- package/ui-dist/assets/SearchConfig-EjeszXbv.js +1 -0
- package/ui-dist/assets/{SecretsConfig-DbiS3txa.js → SecretsConfig-cnAXvREZ.js} +1 -1
- package/ui-dist/assets/{SessionsConfig-CbIOcAp8.js → SessionsConfig-BIXiDaK2.js} +1 -1
- package/ui-dist/assets/{book-open-BLxSL7Dk.js → book-open-DvWqOode.js} +1 -1
- package/ui-dist/assets/chat-session-display-D4bYa0b8.js +1 -0
- package/ui-dist/assets/{chunk-JZWAC4HX-Bp0t5xoO.js → chunk-JZWAC4HX-CxfKRD7X.js} +1 -1
- package/ui-dist/assets/{config-C96FWufn.js → config-BeGwf2Ao.js} +1 -1
- package/ui-dist/assets/{createLucideIcon-B_U7Nq4F.js → createLucideIcon-C7MmdIX3.js} +1 -1
- package/ui-dist/assets/{dist-D9pHzW9z.js → dist-B6VMuIQN.js} +1 -1
- package/ui-dist/assets/{dist-BFY-GyT4.js → dist-RWNFhxvR.js} +1 -1
- package/ui-dist/assets/{external-link-BydIQTIH.js → external-link-U86Acd1t.js} +1 -1
- package/ui-dist/assets/{hash-Djdf0x1C.js → hash-D-OVfV3Z.js} +1 -1
- package/ui-dist/assets/i18n-hM3v-3YG.js +1 -0
- package/ui-dist/assets/{index-DqSv8Azv.js → index-8XNPYwJu.js} +3 -3
- package/ui-dist/assets/index-CpxuJa9o.css +1 -0
- package/ui-dist/assets/{label-Bvv4Mrea.js → label-CHJ1ATds.js} +1 -1
- package/ui-dist/assets/loader-circle-C8cpaL0w.js +1 -0
- package/ui-dist/assets/{logos-CGJJRI5_.js → logos-U1_qDA3U.js} +1 -1
- package/ui-dist/assets/{page-layout-6Nm4Cnvr.js → page-layout-Z1klaUFW.js} +1 -1
- package/ui-dist/assets/plus-CrkO1kob.js +1 -0
- package/ui-dist/assets/{popover-b9rSYI6X.js → popover-xWbqMnIN.js} +1 -1
- package/ui-dist/assets/{react-CDZz_StC.js → react-3YE87-lE.js} +1 -1
- package/ui-dist/assets/{refresh-ccw-BvSSnnCw.js → refresh-ccw-JQh1lwq-.js} +1 -1
- package/ui-dist/assets/{save-CAf0_-b9.js → save-4VRlzkii.js} +1 -1
- package/ui-dist/assets/search-EX-Papzl.js +1 -0
- package/ui-dist/assets/{security-config-DF66-l25.js → security-config-CGazBahs.js} +1 -1
- package/ui-dist/assets/{select-CEIMqc0H.js → select-DF-AUoie.js} +1 -1
- package/ui-dist/assets/skeleton-B0mmt1vo.js +1 -0
- package/ui-dist/assets/{status-dot-CmQI5Qq2.js → status-dot-Bq_8Ojvv.js} +1 -1
- package/ui-dist/assets/{switch-B7SxDXyR.js → switch-D7JF_RZ-.js} +1 -1
- package/ui-dist/assets/{tabs-custom-Dxt6EJJW.js → tabs-custom-CLksZ2bO.js} +1 -1
- package/ui-dist/assets/{trash-2-BnQ1PDTw.js → trash-2-VV8jvziy.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-B-vMOmhG.js → useConfirmDialog-D6HxybcM.js} +1 -1
- package/ui-dist/assets/{useMutation-Bi39Z9_J.js → useMutation-DBTWPbTg.js} +1 -1
- package/ui-dist/assets/x-B4sxJkGY.js +1 -0
- package/ui-dist/index.html +18 -18
- package/ui-dist/assets/ChannelsList-DekMP4a3.js +0 -8
- package/ui-dist/assets/ChatPage-Dgw4vlDt.js +0 -43
- package/ui-dist/assets/DocBrowser-CExjX5is.js +0 -1
- package/ui-dist/assets/MarketplacePage-DGfzg1LG.js +0 -1
- package/ui-dist/assets/ModelConfig-C_49_a9v.js +0 -1
- package/ui-dist/assets/RuntimeConfig-DBWzwoY-.js +0 -1
- package/ui-dist/assets/SearchConfig-jSdwlH4b.js +0 -1
- package/ui-dist/assets/chat-session-display-8yW6-mtm.js +0 -1
- package/ui-dist/assets/i18n-DAekxt_G.js +0 -1
- package/ui-dist/assets/index-CHEgQIiO.css +0 -1
- package/ui-dist/assets/loader-circle-CGXXikVG.js +0 -1
- package/ui-dist/assets/plus-CrW9BJDy.js +0 -1
- package/ui-dist/assets/provider-models-IJDA940D.js +0 -1
- package/ui-dist/assets/search-DgoXxocn.js +0 -1
- package/ui-dist/assets/skeleton-BiPUQkOD.js +0 -1
- package/ui-dist/assets/x-PBSiWt3l.js +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import{_ as e,a as t,d as n,f as r,g as i,h as a,i as o,m as s,n as c,p as l,u}from"./i18n-hM3v-3YG.js";import{a as d,c as f,n as p,o as m,r as h,s as g,u as _}from"./dist-RWNFhxvR.js";import{c as v,o as y,s as b}from"./chunk-JZWAC4HX-CxfKRD7X.js";import{n as x,t as S}from"./react-3YE87-lE.js";import{t as C}from"./useMutation-DBTWPbTg.js";import{D as w,O as T,_ as E,a as D,b as O,c as ee,d as te,f as k,g as A,h as j,i as ne,k as re,l as ie,m as ae,n as M,o as oe,p as se,r as ce,s as le,t as ue,u as de,v as fe,y as pe}from"./select-DF-AUoie.js";import{t as N}from"./createLucideIcon-C7MmdIX3.js";import{n as me}from"./DocBrowser-C7-1sXqo.js";import{t as he}from"./book-open-DvWqOode.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./ProviderScopedModelInput-SAJH6nkC.js";import{t as xe}from"./external-link-U86Acd1t.js";import{n as Se,t as Ce}from"./logos-U1_qDA3U.js";import{t as we}from"./loader-circle-C8cpaL0w.js";import{a as Te,c as Ee,i as De,l as Oe,n as ke,o as Ae,r as je,s as Me,t as Ne,u as Pe}from"./MarketplacePage-DE0QjYVv.js";import{t as Fe}from"./plus-CrkO1kob.js";import{t as Ie}from"./refresh-ccw-JQh1lwq-.js";import{a as Le,c as Re,d as ze,i as Be,l as Ve,n as He,o as Ue,r as We,s as Ge,t as Ke,u as qe}from"./chat-session-display-D4bYa0b8.js";import{t as Je}from"./search-EX-Papzl.js";import{t as Ye}from"./trash-2-VV8jvziy.js";import{t as Xe}from"./x-B4sxJkGY.js";import{d as Ze}from"./config-BeGwf2Ao.js";import{i as Qe}from"./DocBrowserContext-DN5tjUoS.js";import{F as $e,G as et,I as tt,K as nt,L as rt,N as it,P as at,R as ot,S as st,T as ct,W as lt,_t as ut,a as dt,at as ft,b as pt,c as mt,ct as ht,et as gt,f as _t,ft as vt,gt as yt,ht as bt,i as xt,it as St,l as Ct,lt as wt,n as Tt,nt as Et,o as Dt,ot as Ot,p as kt,pt as At,r as jt,rt as Mt,s as Nt,t as Pt,tt as Ft,ut as It,y as Lt}from"./index-8XNPYwJu.js";import{a as Rt,c as zt,i as Bt,n as Vt,o as Ht,r as Ut,s as Wt,t as Gt}from"./popover-xWbqMnIN.js";import{t as Kt}from"./LogoBadge-DDS1sU_U.js";import{t as qt}from"./label-CHJ1ATds.js";import{n as Jt,t as Yt}from"./page-layout-Z1klaUFW.js";import{t as Xt}from"./useConfirmDialog-D6HxybcM.js";var Zt=N(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Qt=N(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),$t=N(`Brain`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`,key:`ep3f8r`}],[`path`,{d:`M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4`,key:`1p4c4q`}],[`path`,{d:`M17.599 6.5a3 3 0 0 0 .399-1.375`,key:`tmeiqw`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M19.938 10.5a4 4 0 0 1 .585.396`,key:`1qfode`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M19.967 17.484A4 4 0 0 1 18 18`,key:`159ez6`}]]),en=N(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),tn=N(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),nn=N(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),rn=N(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),an=N(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),on=N(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),sn=N(`FolderUp`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`m9 13 3-3 3 3`,key:`1pxg3c`}]]),cn=N(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),ln=N(`HeartPulse`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}],[`path`,{d:`M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`1uw2ng`}]]),un=N(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),dn=N(`MessageSquareText`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M13 8H7`,key:`14i4kc`}],[`path`,{d:`M17 12H7`,key:`16if0g`}]]),fn=N(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),pn=N(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),mn=N(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),hn=N(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),gn=N(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),_n=N(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),vn=N(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),yn=N(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),bn=N(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),P=e(s(),1),F=(e=>(e.EndpointReady=`endpoint.ready`,e.EndpointError=`endpoint.error`,e.MessageRequest=`message.request`,e.MessageStreamRequest=`message.stream-request`,e.MessageSent=`message.sent`,e.MessageAccepted=`message.accepted`,e.MessageIncoming=`message.incoming`,e.MessageCompleted=`message.completed`,e.MessageFailed=`message.failed`,e.MessageAbort=`message.abort`,e.MessageTextStart=`message.text-start`,e.MessageTextDelta=`message.text-delta`,e.MessageTextEnd=`message.text-end`,e.MessageReasoningStart=`message.reasoning-start`,e.MessageReasoningDelta=`message.reasoning-delta`,e.MessageReasoningEnd=`message.reasoning-end`,e.MessageToolCallStart=`message.tool-call-start`,e.MessageToolCallArgs=`message.tool-call-args`,e.MessageToolCallArgsDelta=`message.tool-call-args-delta`,e.MessageToolCallEnd=`message.tool-call-end`,e.MessageToolCallResult=`message.tool-call-result`,e.MessageRead=`message.read`,e.MessageDelivered=`message.delivered`,e.MessageRecalled=`message.recalled`,e.MessageReaction=`message.reaction`,e.RunStarted=`run.started`,e.RunFinished=`run.finished`,e.RunError=`run.error`,e.RunMetadata=`run.metadata`,e.TypingStart=`typing.start`,e.TypingEnd=`typing.end`,e.PresenceUpdated=`presence.updated`,e))(F||{}),xn=/\[\[\s*reply_to_current\s*\]\]/gi,Sn=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function Cn(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function wn(e,t){let n=e,r;xn.test(n)&&(r=Cn(t),n=n.replace(xn,``).trim());let i=n.match(Sn)?.[1];return i&&(r=Cn(i),n=n.replace(Sn,``).trim()),r?{content:n,replyTo:r}:{content:n}}function Tn(e,t=e.id){if(e.role!==`assistant`)return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};let n=e.parts.findIndex(e=>e.type===`text`),r=e.metadata?{...e.metadata}:void 0,i=Cn(r?.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};let a=e.parts[n];if(!a||a.type!==`text`)return{...e,parts:[...e.parts],metadata:r};let{content:o,replyTo:s}=wn(a.text,t),c=s??i,l=e.parts.flatMap((e,t)=>t!==n||e.type!==`text`?[e]:o.length===0?[]:[{...e,text:o}]);return c?{...e,parts:l,metadata:{...r,reply_to:c}}:{...e,parts:l,metadata:r}}function En(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function Dn(e){return En(Tn(e))}function On(e){let t=e.error?.trim();return{code:`runtime-error`,message:t&&t.length>0?t:`Agent run failed.`,details:{sessionId:e.sessionId,messageId:e.messageId,threadId:e.threadId,runId:e.runId}}}function kn(e,t){return t.trim()?e.id.startsWith(`tool-`)?!0:e.parts.some(e=>e.type===`tool-invocation`):!1}function An(e,t,n){for(let[r,i]of e)i===t&&e.set(r,n)}function jn(e,t,n){for(let[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function Mn(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.type===`tool-invocation`&&r.toolCallId===t)return r}return null}function Nn(e,t){return Mn(e,t)?.toolName??null}function Pn(e,t){let n=[...e];for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.type===`tool-invocation`&&r.toolCallId===t.toolCallId)return n[e]={...r,...t},n}return n.push(t),n}var Fn=`assistant`,In=class{messages=[];streamingMessage=null;error=null;activeRun=null;listeners=new Set;toolCallMessageIdByCallId=new Map;toolCallArgsRawByCallId=new Map;lastSettledRunId=null;snapshotCache=null;snapshotVersion=-1;stateVersion=0;getSnapshot=()=>{if(this.snapshotCache&&this.snapshotVersion===this.stateVersion)return this.snapshotCache;let e={messages:this.messages,streamingMessage:this.streamingMessage,error:this.error?{...this.error,details:this.error.details?{...this.error.details}:void 0}:null,activeRun:this.activeRun?{...this.activeRun}:null};return this.snapshotCache=e,this.snapshotVersion=this.stateVersion,e};subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));reset=()=>{this.messages.length===0&&!this.streamingMessage&&!this.error&&!this.activeRun&&this.toolCallMessageIdByCallId.size===0&&this.toolCallArgsRawByCallId.size===0||(this.messages=[],this.streamingMessage=null,this.error=null,this.activeRun=null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners())};hydrate=e=>{this.messages=e.messages.map(e=>Dn(e)),this.streamingMessage=null,this.error=null,this.activeRun=e.activeRun?{...e.activeRun,sessionId:e.activeRun.sessionId??e.sessionId,abortDisabledReason:e.activeRun.abortDisabledReason??null}:null,this.toolCallMessageIdByCallId.clear(),this.toolCallArgsRawByCallId.clear(),this.lastSettledRunId=null,this.stateVersion+=1,this.notifyListeners()};dispatch=e=>this.dispatchBatch([e]);dispatchBatch=async e=>{if(!e.length)return;let t=this.stateVersion;e.forEach(this.applyEvent),this.stateVersion!==t&&this.notifyListeners()};applyEvent=e=>{switch(e.type){case F.MessageSent:this.handleMessageSent(e.payload);break;case F.MessageAbort:this.handleMessageAbort(e.payload);break;case F.MessageTextStart:this.handleMessageTextStart(e.payload);break;case F.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case F.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case F.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case F.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case F.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case F.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case F.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case F.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case F.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case F.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case F.RunStarted:this.handleRunStarted(e.payload);break;case F.RunFinished:this.handleRunFinished(e.payload);break;case F.RunError:this.handleRunError(e.payload);break;case F.RunMetadata:this.handleRunMetadata(e.payload);break;case F.EndpointError:this.handleEndpointError(e.payload);break;default:break}};handleMessageSent=e=>{this.upsertMessage(e.message),this.setError(null)};handleMessageAbort=e=>{let t=e.messageId?.trim();if(this.clearActiveRun(),this.setError(null),this.streamingMessage&&(!t||this.streamingMessage.id===t)){let e=this.streamingMessage.id;this.upsertMessage({...this.streamingMessage,status:`final`}),this.replaceStreamingMessage(null),t?jn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):jn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,e)}};handleMessageTextStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),this.setError(null)};handleMessageTextDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`text`?n[n.length-1]={type:`text`,text:`${r.text}${e.delta}`}:n.push({type:`text`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageTextEnd=e=>{this.streamingMessage?.id===e.messageId&&this.streamingMessage.status===`streaming`&&this.replaceStreamingMessage({...this.streamingMessage,status:`pending`})};handleMessageReasoningStart=e=>{this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`)};handleMessageReasoningDelta=e=>{if(!e.delta)return;let t=this.ensureStreamingMessage(e.sessionId,e.messageId,`streaming`),n=[...t.parts],r=n[n.length-1];r?.type===`reasoning`?n[n.length-1]={type:`reasoning`,text:`${r.text}${e.delta}`}:n.push({type:`reasoning`,text:e.delta}),this.replaceStreamingMessage({...t,parts:n,status:`streaming`})};handleMessageReasoningEnd=e=>{this.streamingMessage?.id,e.messageId};handleMessageToolCallStart=e=>{let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId,e.messageId);this.toolCallArgsRawByCallId.set(e.toolCallId,``);let n=Pn(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:e.toolName,state:`partial-call`,args:``});this.replaceStreamingMessage({...t,parts:n,status:`streaming`}),this.setError(null)};handleMessageToolCallArgs=e=>{this.toolCallArgsRawByCallId.set(e.toolCallId,e.args),this.applyToolCallArgs(e.sessionId,e.toolCallId,e.args)};handleMessageToolCallArgsDelta=e=>{let t=`${this.toolCallArgsRawByCallId.get(e.toolCallId)??``}${e.delta}`;this.toolCallArgsRawByCallId.set(e.toolCallId,t),this.applyToolCallArgs(e.sessionId,e.toolCallId,t,e.messageId)};handleMessageToolCallEnd=e=>{let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=this.toolCallArgsRawByCallId.get(e.toolCallId)??``,r=Pn(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:Nn(t.parts,e.toolCallId)??`unknown`,state:`call`,args:n});this.replaceStreamingMessage({...t,parts:r,status:`streaming`})};handleMessageToolCallResult=e=>{if(!this.updateMessageContainingToolCall(e.toolCallId,(t,n)=>{let r={type:`tool-invocation`,toolCallId:e.toolCallId,toolName:n.toolName,state:`result`,args:n.args,result:e.content};return Pn(t.parts,r)})){let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=Pn(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:`unknown`,state:`result`,result:e.content});this.replaceStreamingMessage({...t,parts:n,status:`streaming`})}};handleRunStarted=e=>{this.isSettledRunId(e.runId)||(this.setError(null),this.activeRun={runId:e.runId??null,sessionId:e.sessionId},this.stateVersion+=1)};handleRunFinished=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`final`),this.setError(null),this.clearActiveRun()};handleRunError=e=>{this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.settleStreamingMessage(`error`),this.setError(On(e)),this.clearActiveRun()};handleRunMetadata=e=>{let t=e.metadata;if(t?.kind===`ready`){let e=t;if(this.isSettledRunId(e.runId))return;this.activeRun={runId:e.runId??this.activeRun?.runId??null,sessionId:e.sessionId??this.activeRun?.sessionId,abortDisabledReason:e.supportsAbort===!1?e.abortDisabledReason??`Unsupported`:null},this.stateVersion+=1}else t?.kind===`final`&&(this.markRunAsSettled(e.runId??this.activeRun?.runId??null),this.clearActiveRun())};handleEndpointError=e=>{if(e.code===`abort-error`){this.handleMessageAbort({sessionId:this.activeRun?.sessionId??this.streamingMessage?.sessionId??``,...this.streamingMessage?.id?{messageId:this.streamingMessage.id}:{}});return}this.settleStreamingMessage(`error`),this.clearActiveRun(),this.setError(e)};applyToolCallArgs=(e,t,n,r)=>{let i=this.resolveToolCallTargetMessage(e,t,r),a=Nn(i.parts,t)??`unknown`,o=Pn(i.parts,{type:`tool-invocation`,toolCallId:t,toolName:a,state:`partial-call`,args:n});this.replaceStreamingMessage({...i,parts:o,status:`streaming`})};ensureStreamingMessage=(e,t,n)=>{if(this.streamingMessage?.id===t){if(this.streamingMessage.status===n)return this.streamingMessage;let e={...this.streamingMessage,status:n};return this.replaceStreamingMessage(e),e}let r=this.messages.findIndex(e=>e.id===t);if(r>=0){let t=En(this.messages[r]),i=[...this.messages];i.splice(r,1),this.messages=i,this.stateVersion+=1;let a={...t,sessionId:e,status:n};return this.replaceStreamingMessage(a),a}let i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&kn(i,t)){let r={...i,id:t,sessionId:e,status:n};return An(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(r),r}let a={id:t,sessionId:e,role:Fn,status:n,parts:[],timestamp:new Date().toISOString()};return this.replaceStreamingMessage(a),a};resolveToolCallTargetMessage=(e,t,n)=>{let r=n?.trim()||this.toolCallMessageIdByCallId.get(t)||this.streamingMessage?.id||`tool-${t}`;return this.toolCallMessageIdByCallId.set(t,r),this.ensureStreamingMessage(e,r,`streaming`)};updateMessageContainingToolCall=(e,t)=>{if(this.streamingMessage){let n=Mn(this.streamingMessage.parts,e);if(n){let e=t(this.streamingMessage,n);return this.replaceStreamingMessage({...this.streamingMessage,parts:e}),!0}}for(let n=this.messages.length-1;n>=0;--n){let r=this.messages[n],i=Mn(r.parts,e);if(!i)continue;let a=[...this.messages];return a[n]={...r,parts:t(r,i)},this.messages=a,this.stateVersion+=1,!0}return!1};upsertMessage=e=>{let t=Dn(e),n=this.messages.findIndex(e=>e.id===t.id);if(n<0){this.messages=[...this.messages,t],this.stateVersion+=1;return}let r=[...this.messages];r[n]=t,this.messages=r,this.stateVersion+=1};replaceStreamingMessage=e=>{!e&&!this.streamingMessage||(this.streamingMessage=e?Dn(e):null,this.stateVersion+=1)};setError=e=>{this.error?.code===e?.code&&this.error?.message===e?.message&&this.error?.details===e?.details&&this.error?.cause===e?.cause||(this.error=e?{...e,details:e.details?{...e.details}:void 0}:null,this.stateVersion+=1)};clearActiveRun=()=>{this.activeRun&&(this.activeRun=null,this.stateVersion+=1)};isSettledRunId=e=>!!e?.trim()&&e===this.lastSettledRunId;markRunAsSettled=e=>{this.lastSettledRunId=e?.trim()||null};settleStreamingMessage=e=>{if(!this.streamingMessage)return;let t={...this.streamingMessage,status:e};this.upsertMessage(t),this.replaceStreamingMessage(null),jn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)};notifyListeners=()=>{let e=this.getSnapshot();for(let t of this.listeners)t(e)}},Ln=16,Rn=class{constructor(e){this.dispatchBatch=e,this.queue=[],this.flushTimerId=null,this.isFlushing=!1,this.isDisposed=!1,this.enqueue=e=>{this.isDisposed||(this.queue.push(e),this.scheduleFlush())},this.dispose=()=>{this.isDisposed=!0,this.flushTimerId!==null&&(window.clearTimeout(this.flushTimerId),this.flushTimerId=null),this.queue.length=0},this.scheduleFlush=()=>{this.flushTimerId!==null||this.isFlushing||this.queue.length===0||(this.flushTimerId=window.setTimeout(()=>{this.flushTimerId=null,this.flush()},Ln))},this.flush=async()=>{if(!(this.isDisposed||this.isFlushing||this.queue.length===0)){this.isFlushing=!0;try{for(;this.queue.length>0;){let e=this.queue.splice(0);await this.dispatchBatch(e)}}finally{this.isFlushing=!1,this.scheduleFlush()}}}}};function zn(e,t){let n=e.dispatchBatch;return typeof n==`function`?n.call(e,t):t.reduce((t,n)=>t.then(()=>e.dispatch(n)),Promise.resolve())}function Bn(e,t){let n=`payload`in e?e.payload:null;return!n||typeof n!=`object`||!(`sessionId`in n)||typeof n.sessionId!=`string`?!0:n.sessionId===t}function Vn(e){return e.parts.some(e=>e.type===`text`||e.type===`rich-text`||e.type===`reasoning`?e.text.trim().length>0:!0)}function Hn(e,t){if(typeof e==`string`){let n=e.trim();return n?{sessionId:t,message:{id:`user-${Date.now().toString(36)}`,sessionId:t,role:`user`,status:`final`,parts:[{type:`text`,text:n}],timestamp:new Date().toISOString()}}:null}return Vn(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function Un(e){let t=(0,P.useRef)();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new In}),t.current.manager}function Wn({sessionId:e,client:t,manager:n}){let r=(0,P.useSyncExternalStore)(e=>n.subscribe(()=>e()),()=>n.getSnapshot(),()=>n.getSnapshot()),[i,a]=(0,P.useState)(!1);(0,P.useEffect)(()=>{a(!1)},[e]),(0,P.useEffect)(()=>{let r=new Rn(e=>zn(n,e)),i=t.subscribe(t=>{Bn(t,e)&&r.enqueue(t)});return()=>{i(),r.dispose(),t.stop()}},[t,n,e]);let o=r.streamingMessage?[...r.messages,r.streamingMessage]:r.messages,s=r.activeRun?.runId??null,c=!!r.activeRun;return{snapshot:r,visibleMessages:o,activeRunId:s,isRunning:c,isSending:i,send:async r=>{if(i||c)return;let o=Hn(r,e);if(o){a(!0),await n.dispatch({type:F.MessageSent,payload:{sessionId:e,message:o.message,metadata:o.metadata}});try{await t.send(o)}finally{a(!1)}}},abort:async()=>{r.activeRun&&await t.abort({sessionId:e})},streamRun:async()=>{await t.stop(),await t.stream({sessionId:e})}}}function Gn(e){return e instanceof Error?e:Error(String(e))}function Kn(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function qn({sessionId:e,client:t,loadSeed:n}){let r=Un(e),i=Wn({sessionId:e,client:t,manager:r}),[a,o]=(0,P.useState)(!0),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(null),d=(0,P.useRef)({requestId:0,controller:null}),f=(0,P.useCallback)(async()=>{d.current.controller?.abort();let i=new AbortController,a=d.current.requestId+1;d.current={requestId:a,controller:i},await t.stop(),r.reset(),c(null),o(!0);try{let s=await n(e,i.signal);if(i.signal.aborted||d.current.requestId!==a)return;r.hydrate({sessionId:e,messages:s.messages,activeRun:s.status===`running`?{runId:null,sessionId:e,abortDisabledReason:null}:null}),c(null),u(e),o(!1),t.stream({sessionId:e}).catch(e=>{d.current.requestId===a&&c(Gn(e))})}catch(t){if(i.signal.aborted||d.current.requestId!==a)return;c(Gn(t)),u(e),o(!1)}finally{d.current.controller===i&&(d.current.controller=null)}},[t,n,r,e]);return(0,P.useEffect)(()=>(f(),()=>{d.current.controller?.abort(),d.current.controller=null}),[f]),{...i,isHydrating:Kn({sessionId:e,hydratedSessionId:l,isHydrating:a}),hydrateError:s}}var Jn=200*1024*1024,Yn=`application/octet-stream`;function Xn(e){let t=e.type.trim().toLowerCase();return t.length>0?t:Yn}function Zn(e,t){let n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(e=>e.trim().toLowerCase())):null,r=t.maxBytes??209715200,i=Xn(e);return n&&!n.has(i)?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`unsupported-type`}}:e.size>r?{ok:!1,rejected:{fileName:e.name,mimeType:i,sizeBytes:e.size,reason:`too-large`}}:{ok:!0,mimeType:i}}function Qn(e){let t=e.parts&&e.parts.length>0?e.parts.map(e=>structuredClone(e)):[...e.text?.trim()??``?[{type:`text`,text:e.text.trim()}]:[],...(e.attachments??[]).map(e=>({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?.trim()?{assetUri:e.assetUri.trim()}:{},...e.url?.trim()?{url:e.url.trim()}:{},...e.contentBase64?.trim()?{contentBase64:e.contentBase64.trim()}:{},sizeBytes:e.sizeBytes}))];if(t.length===0)return null;let n=e.timestamp??new Date().toISOString(),r=e.messageId??`user-${Date.now().toString(36)}`;return{sessionId:e.sessionId,message:{id:r,sessionId:e.sessionId,role:`user`,status:`final`,parts:t,timestamp:n,...e.metadata?{metadata:e.metadata}:{}},...e.metadata?{metadata:e.metadata}:{}}}async function $n(e,t){let n=[],r=[];for(let i of e){let e=Zn(i,t);if(!e.ok){r.push(e.rejected);continue}n.push(i)}if(n.length===0)return{attachments:[],rejected:r};try{return{attachments:await t.uploadBatch(n),rejected:r}}catch{return r.push(...n.map(e=>({fileName:e.name,mimeType:Xn(e),sizeBytes:e.size,reason:`read-failed`}))),{attachments:[],rejected:r}}}var I=l(),er={connected:{dotClass:`bg-emerald-500`},disconnected:{dotClass:`h-2.5 w-2.5 rounded-full border border-gray-400 bg-transparent`},connecting:{dotClass:`text-amber-600`}};function tr({status:e,className:t}){let n=er[e],r=o(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,I.jsx)(De,{delayDuration:250,children:(0,I.jsxs)(ke,{children:[(0,I.jsx)(Te,{asChild:!0,children:(0,I.jsx)(`span`,{role:`status`,"aria-label":r,className:u(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,I.jsx)(we,{className:u(`h-3 w-3 animate-spin`,n.dotClass)}):(0,I.jsx)(`span`,{className:u(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,I.jsx)(je,{side:`bottom`,className:`text-xs`,children:r})]})})}var nr=[[`bg-amber-100`,`text-amber-700`],[`bg-emerald-100`,`text-emerald-700`],[`bg-blue-100`,`text-blue-700`],[`bg-rose-100`,`text-rose-700`],[`bg-cyan-100`,`text-cyan-700`],[`bg-violet-100`,`text-violet-700`]];function rr(e){let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function ir(e){let t=e.trim();return t?t.slice(0,1).toUpperCase():`A`}function ar({agentId:e,displayName:t,avatarUrl:n,className:r}){let i=t?.trim()||e,[a,o]=nr[rr(e)%nr.length]??nr[0];return n?.trim()?(0,I.jsx)(`img`,{src:n,alt:t?.trim()||e,className:u(`rounded-full object-cover`,r)}):(0,I.jsx)(`div`,{className:u(`rounded-full flex items-center justify-center font-semibold`,a,o,r),"aria-label":t?.trim()||e,children:ir(i)})}var or={wx:`weixin`,lark:`feishu`},sr={heartbeat:{icon:`heartbeat`},cron:{icon:`cron`}},cr={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function lr(e){return e?.trim().toLowerCase()??``}function ur(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function dr(e,t){let n=lr(e);if(!n||n===`native`)return null;let r=t.find(e=>lr(e.value)===n);return r?.label.trim()?r.label.trim():ur(n)}function fr(e){let t=lr(e);if(!t)return null;let n=or[t]??t;return Ce(n)?n:null}function pr(e,t){let n=fr(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=sr[lr(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=cr[lr(e.sessionType)];return i?{icon:null,label:o(i)}:{icon:null,label:dr(e.sessionType,t)}}function mr({icon:e,className:t}){return e.kind===`channel-logo`?(0,I.jsx)(hr,{channel:e.channel,className:t}):e.icon===`heartbeat`?(0,I.jsx)(ln,{className:u(`h-3.5 w-3.5`,t)}):(0,I.jsx)(ut,{className:u(`h-3.5 w-3.5`,t)})}function hr({channel:e,className:t}){return(0,I.jsx)(Kt,{name:e,src:Ce(e),className:u(`h-4 w-4 rounded-[4px] border border-gray-200/80 bg-white`,t),imgClassName:`h-3 w-3 object-contain`,fallback:(0,I.jsx)(yt,{className:`h-3 w-3 text-gray-500`})})}function gr(e){let{session:t,active:n,runStatus:r,context:i,title:a,agentId:s,agentLabel:l,agentAvatarUrl:d,isEditing:f,draftLabel:p,isSaving:h,onSelect:g,onStartEditing:_,onDraftLabelChange:v,onSave:y,onCancel:b}=e,x=n?`text-gray-700`:`text-gray-500`,S=s?.trim()??``,C=!!(S&&S.toLowerCase()!==`main`);return(0,I.jsx)(`div`,{className:u(`w-full rounded-xl px-3 py-2 text-left transition-all text-[13px]`,n?`bg-gray-200 text-gray-900 font-semibold shadow-sm`:`text-gray-700 hover:bg-gray-200/60 hover:text-gray-900`),children:f?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(lt,{value:p,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),y()):e.key===`Escape`&&(e.preventDefault(),b())},placeholder:o(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:h}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:t.key}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(m,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:()=>void y(),disabled:h,"aria-label":o(`save`),children:(0,I.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(m,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:b,disabled:h,"aria-label":o(`cancel`),children:(0,I.jsx)(Xe,{className:`h-3.5 w-3.5`})})]})]})]}):(0,I.jsxs)(`div`,{className:`group/session relative`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:g,className:`w-full text-left`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5 pr-8`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[C?(0,I.jsx)(ar,{agentId:S,displayName:l,avatarUrl:d,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate font-medium`,children:a}),i.label?(0,I.jsx)(`span`,{className:u(`shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-semibold leading-none`,n?`border-gray-300 bg-white/80 text-gray-700`:`border-gray-200 bg-gray-100 text-gray-500`),children:i.label}):null,i.icon?(0,I.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,I.jsx)(mr,{icon:i.icon,className:x})}):null]}),(0,I.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:r?(0,I.jsx)(Ve,{status:r}):null})]}),(0,I.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-gray-400 truncate`,children:[l?.trim()?`${l} · `:``,t.messageCount,` · `,c(t.updatedAt)]})]}),(0,I.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),_()},className:u(`absolute right-0 top-0 inline-flex h-7 w-7 items-center justify-center rounded-lg text-gray-400 transition-all hover:bg-white hover:text-gray-900`,n?`opacity-100`:`opacity-0 group-hover/session:opacity-100 group-focus-within/session:opacity-100`),"aria-label":o(`edit`),children:(0,I.jsx)(mn,{className:`h-3.5 w-3.5`})})]})})}function _r(){let e=_();return async t=>{try{rt(e,await $e(t.sessionKey,t.patch)),p.success(t.successMessage??o(`configSavedApplied`))}catch(e){throw p.error(o(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}function vr(){let e=_r();return async t=>{await e({sessionKey:t.sessionKey,patch:{label:t.label},successMessage:o(`configSavedApplied`)})}}var yr={selectedSessionKey:null,selectedAgentId:`main`,query:``},L=S(e=>({snapshot:yr,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function br(e,t){return e.filter(e=>He(e,t))}function xr(e){return e.isChildSession?e.isPromotedChildSession===!0:!0}function Sr(e={}){let t=L(e=>e.snapshot.query),n=pt({limit:e.limit??200}),r=(0,P.useMemo)(()=>{let e=n.data?.sessions??[],r=br(Be(e).filter(xr),t),i=new Map(e.map(e=>[e.sessionId,e]));return r.map(e=>({session:e,runStatus:i.get(e.key)?.status===`running`?`running`:void 0}))},[t,n.data?.sessions]);return{isLoading:n.isLoading,items:r}}var Cr=(0,P.createContext)(null);function wr({presenter:e,children:t}){return(0,I.jsx)(Cr.Provider,{value:e,children:t})}function Tr(){let e=(0,P.useContext)(Cr);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var Er=e=>`[data-item-index="${e}"]`;function Dr(e){let t=e.getItemSelector??Er;(0,P.useEffect)(()=>{if(!e.isEnabled||e.itemCount===0)return;let n=e.containerRef.current;n&&n.querySelector(t(e.activeIndex))?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,e.activeIndex,e.containerRef,e.isEnabled,e.itemCount])}function Or(){let e=(0,P.useRef)(null),[t,n]=(0,P.useState)(null);return(0,P.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let r=()=>{n(t.getBoundingClientRect().width)};r();let i=new ResizeObserver(()=>r());return i.observe(t),()=>i.disconnect()},[]),{elementRef:e,width:t}}function R(...e){return n(r(e))}var kr=P.forwardRef(({className:e,type:t,...n},r)=>(0,I.jsx)(`input`,{type:t,className:R(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-900 file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));kr.displayName=`ChatInput`;var Ar=Wt,jr=zt,Mr=Bt,Nr=P.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,I.jsx)(Ht,{children:(0,I.jsx)(Rt,{ref:i,sideOffset:t,align:n,className:R(`z-[var(--z-popover,50)] w-72 overflow-hidden rounded-2xl border border-gray-200/50 bg-white p-4 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));Nr.displayName=Rt.displayName;var Pr=ae,Fr=le,Ir=pe,Lr=P.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(fe,{ref:r,className:R(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-gray-200/80 bg-white px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,I.jsx)(ee,{asChild:!0,children:(0,I.jsx)(T,{className:`h-4 w-4 opacity-50`})})]}));Lr.displayName=fe.displayName;var Rr=P.forwardRef(({className:e,...t},n)=>(0,I.jsx)(A,{ref:n,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(w,{className:`h-4 w-4`})}));Rr.displayName=A.displayName;var zr=P.forwardRef(({className:e,...t},n)=>(0,I.jsx)(j,{ref:n,className:R(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(T,{className:`h-4 w-4`})}));zr.displayName=j.displayName;var Br=P.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,I.jsx)(se,{children:(0,I.jsxs)(oe,{ref:i,className:R(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md bg-white text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,I.jsx)(Rr,{}),(0,I.jsx)(O,{className:R(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,I.jsx)(zr,{})]})}));Br.displayName=oe.displayName;var Vr=P.forwardRef(({className:e,...t},n)=>(0,I.jsx)(k,{ref:n,className:R(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));Vr.displayName=k.displayName;var Hr=P.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsxs)(ie,{ref:r,className:R(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-gray-100`,e),...n,children:[(0,I.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,I.jsx)(de,{children:(0,I.jsx)(re,{className:`h-4 w-4`})})}),(0,I.jsx)(te,{children:t})]}));Hr.displayName=ie.displayName;var Ur=P.forwardRef(({className:e,...t},n)=>(0,I.jsx)(E,{ref:n,className:R(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Ur.displayName=E.displayName;var Wr=Ee,Gr=Oe,Kr=Pe,qr=P.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,I.jsx)(Me,{children:(0,I.jsx)(Ae,{ref:r,sideOffset:t,className:R(`z-[var(--z-tooltip)] overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));qr.displayName=Ae.displayName;var Jr={Popover:Ar,PopoverAnchor:Mr,PopoverContent:Nr,PopoverTrigger:jr,Input:kr,Select:Pr,SelectContent:Br,SelectGroup:Fr,SelectItem:Hr,SelectLabel:Vr,SelectSeparator:Ur,SelectTrigger:Lr,SelectValue:Ir,Tooltip:Gr,TooltipContent:qr,TooltipProvider:Wr,TooltipTrigger:Kr},Yr=680,Xr=.82,Zr=560;function Qr(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Jr,{elementRef:i,width:a}=Or(),o=(0,P.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onSetActiveIndex:h}=e,g=(0,P.useMemo)(()=>{if(a)return Math.min(a>Zr?a*Xr:a,Yr)},[a]);return Dr({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,I.jsxs)(t,{open:s,onOpenChange:m,children:[(0,I.jsx)(n,{asChild:!0,children:(0,I.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,I.jsx)(r,{side:`top`,align:`start`,sideOffset:10,className:`z-[70] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-2xl border border-gray-200 bg-white/95 p-0 shadow-2xl backdrop-blur-md`,onOpenAutoFocus:e=>e.preventDefault(),style:g?{width:`${g}px`}:void 0,children:(0,I.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,I.jsx)(`div`,{ref:o,role:`listbox`,"aria-label":f.slashSectionLabel,className:`custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5`,children:c?(0,I.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,I.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,I.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-slash-index":t,onMouseEnter:()=>h(t),onClick:()=>p(e),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${n?`bg-gray-100 text-gray-900`:`text-gray-700 hover:bg-gray-50`}`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,I.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,I.jsx)(`div`,{className:`min-w-0 p-2.5`,children:d?(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary`,children:d.subtitle}),(0,I.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,I.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,I.jsx)(`div`,{className:`min-w-0 break-all rounded-md bg-gray-50 px-2 py-1 text-[11px] leading-5 text-gray-600`,children:e},e))}),(0,I.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var $r=g(`inline-flex items-center justify-center whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-gray-200 bg-white hover:bg-gray-50 hover:text-gray-800 text-gray-600`,secondary:`bg-gray-100 text-gray-700 hover:bg-gray-200/80`,ghost:`hover:bg-gray-100/80 hover:text-gray-800`,link:`text-primary underline-offset-4 hover:underline`,primary:`bg-primary text-primary-foreground hover:bg-primary-600 active:bg-primary-700 shadow-sm`,subtle:`bg-gray-100 text-gray-600 hover:bg-gray-200/80`,"primary-outline":`border border-primary/30 text-primary hover:bg-primary hover:text-primary-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 px-3 text-xs`,lg:`h-11 px-5 text-[14px]`,xl:`h-12 px-6 text-[15px]`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}}),ei=P.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,I.jsx)(`button`,{className:R($r({variant:t,size:n,className:e})),ref:i,...r}));ei.displayName=`ChatButton`;function ti(){return(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`chat-stop-icon`,className:`block h-3 w-3 rounded-[2px] bg-gray-700 shadow-[inset_0_0_0_1px_rgba(17,24,39,0.06)]`})}function ni(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Jr;return(0,I.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[e.sendError?.trim()?(0,I.jsx)(`div`,{className:`max-w-[420px] text-right text-[11px] text-red-600`,children:e.sendError}):null,(0,I.jsx)(`div`,{className:`flex items-center gap-2`,children:e.isSending?e.canStopGeneration?(0,I.jsx)(ei,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":e.stopButtonLabel,onClick:()=>void e.onStop(),disabled:e.stopDisabled,children:(0,I.jsx)(ti,{})}):(0,I.jsx)(r,{children:(0,I.jsxs)(t,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsx)(`span`,{children:(0,I.jsx)(ei,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":e.stopButtonLabel,disabled:!0,children:(0,I.jsx)(ti,{})})})}),(0,I.jsx)(n,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:e.stopHint})})]})}):(0,I.jsx)(ei,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:(0,I.jsx)(Qt,{className:`h-5 w-5`})})})]})}function ri(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.label,e.key,e.description].filter(e=>typeof e==`string`&&e.trim().length>0).join(` `).toLowerCase().includes(n)):e}function ii(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Jr,{picker:a}=e,o=(0,P.useRef)(null),s=(0,P.useId)(),[c,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(0),f=(0,P.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=c.trim().length>0,h=(0,P.useMemo)(()=>{if(m)return null;let e=a.groups?.filter(e=>e.options.length>0)??[];return e.length>0?e:null},[m,a.groups]),g=(0,P.useMemo)(()=>h?h.flatMap(e=>e.options):ri(a.options,c),[h,a.options,c]);(0,P.useEffect)(()=>{d(0)},[c]),(0,P.useEffect)(()=>{d(e=>g.length===0?0:Math.min(e,g.length-1))},[g.length]),Dr({containerRef:o,activeIndex:u,itemCount:g.length,isEnabled:g.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let _=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},v=e=>{if(g.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,g.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),d(e=>Math.max(e-1,0));return}if(e.key===`Enter`){e.preventDefault();let t=g[u];t&&_(t.key)}}};return(0,I.jsxs)(n,{children:[(0,I.jsx)(i,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"aria-haspopup":`listbox`,className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,I.jsx)(bt,{className:`h-4 w-4`}),(0,I.jsx)(`span`,{children:a.title}),p>0?(0,I.jsx)(`span`,{className:`ml-0.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary`,children:p}):null]})}),(0,I.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Je,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,I.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":g[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,I.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,I.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):g.length===0?(0,I.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,I.jsx)(`div`,{className:`py-1`,children:(()=>{let e=h??[{key:`all-skills`,options:g}],t=0;return e.map(e=>(0,I.jsxs)(`div`,{children:[e.label?(0,I.jsx)(`div`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:e.label}):null,e.options.map(e=>{let n=t;t+=1;let r=f.has(e.key),i=n===u;return(0,I.jsxs)(`button`,{type:`button`,id:`${s}-option-${n}`,role:`option`,"aria-selected":r,"data-skill-index":n,onClick:()=>_(e.key),onMouseEnter:()=>d(n),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${i?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,I.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,I.jsx)(_n,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:e.badgeLabel}):null]}),(0,I.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,I.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,I.jsx)(`span`,{className:r?`inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-white`:`inline-flex h-5 w-5 items-center justify-center rounded-full border border-gray-300 bg-white`,children:r?(0,I.jsx)(re,{className:`h-3 w-3`}):null})})]},e.key)})]},e.key))})()})}),a.manageHref&&a.manageLabel?(0,I.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,I.jsxs)(`a`,{href:a.manageHref,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80`,children:[a.manageLabel,(0,I.jsx)(xe,{className:`h-3 w-3`})]})}):null]})]})}function ai({icon:e}){return e===`sparkles`?(0,I.jsx)(ht,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,I.jsx)($t,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function oi({icon:e}){return e===`paperclip`?(0,I.jsx)(pn,{className:`h-4 w-4`}):(0,I.jsx)(ai,{icon:e})}function si(e){return e===`model`?`min-w-[220px]`:e===`session-type`?`min-w-[140px]`:e===`thinking`?`min-w-[150px]`:``}function ci(e){return e===`model`?`w-[320px]`:e===`session-type`?`w-[220px]`:e===`thinking`?`w-[180px]`:``}function li({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Jr,l=e.groups?.filter(e=>e.options.length>0)??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),u=l.some(e=>e.options.length>0);return(0,I.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,I.jsx)(s,{className:`h-8 w-auto rounded-lg border-0 bg-transparent px-3 text-xs font-medium text-gray-600 shadow-none hover:bg-gray-100 focus:ring-0 ${si(e.key)}`,children:e.selectedLabel?(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,I.jsx)(ai,{icon:e.icon}),(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700`,children:e.selectedLabel})]}):e.loading?(0,I.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,I.jsx)(c,{placeholder:e.placeholder})}),(0,I.jsxs)(n,{className:ci(e.key),children:[u?null:e.loading?(0,I.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,I.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,I.jsxs)(`div`,{children:[t>0?(0,I.jsx)(o,{}):null,(0,I.jsxs)(r,{children:[e.label?(0,I.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,I.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,I.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,I.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function ui(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Jr;return(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.skillPicker?(0,I.jsx)(ii,{picker:e.skillPicker}):null,e.selects.map(e=>(0,I.jsx)(li,{item:e},e.key)),e.accessories?.map(e=>{let a=(0,I.jsxs)(`button`,{type:`button`,className:`inline-flex items-center rounded-lg py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:text-gray-400 ${e.iconOnly?`h-8 w-8 justify-center px-0`:`gap-1.5 px-3`}`,onClick:e.onClick,disabled:e.disabled,"aria-label":e.label,children:[(0,I.jsx)(oi,{icon:e.icon}),e.iconOnly?null:(0,I.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,I.jsx)(r,{children:(0,I.jsxs)(t,{children:[(0,I.jsx)(i,{asChild:!0,children:e.disabled?(0,I.jsx)(`span`,{className:`inline-flex`,children:a}):a}),(0,I.jsx)(n,{side:`top`,children:(0,I.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,I.jsx)(`div`,{children:a},e.key)})]}),(0,I.jsx)(ni,{...e.actions})]})}function di(){return`composer-${Math.random().toString(36).slice(2,10)}`}function fi(e=``){return{id:di(),type:`text`,text:e}}function pi(e){return{id:di(),type:`token`,tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function mi(e){return e.type===`text`?e.text.length:1}function hi(){return[fi(``)]}function gi(e){return[fi(e)]}function _i(e){let t=[];for(let n of e){if(n.type===`text`){if(n.text.length===0)continue;let e=t[t.length-1];if(e?.type===`text`){t[t.length-1]={...e,text:e.text+n.text};continue}}t.push(n)}return t.length===0?hi():t}function vi(e){return e.map(e=>e.type===`text`?e.text:``).join(``)}function yi(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function bi(e,t){let n=[],r=new Set;for(let i of e)i.type!==`token`||i.tokenKind!==t||r.has(i.tokenKey)||(r.add(i.tokenKey),n.push(i.tokenKey));return n}function xi(e,t,n,r){let i=Math.max(0,n-t),a=Math.max(0,t+e.text.length-r),o=[];return i>0&&o.push({...e,text:e.text.slice(0,i)}),a>0&&o.push({...e,text:e.text.slice(e.text.length-a)}),o}function Si(e,t,n,r){return t<=n||e>=r}function Ci(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function wi(e,t,n,r,i,a,o){let s=xi(t,n,r,i);s[0]&&e.push(s[0]);let c=o;return c||=(e.push(...a),!0),s[1]&&e.push(s[1]),c}function Ti(e,t,n,r,i,a){return!r&&i<=a?(e.push(...n),!0):(e.push(t),r)}function Ei(e,t,n,r){let i=Math.max(0,t),a=Math.max(i,n),o=[],s=0,c=!1;for(let t of e){let e=mi(t),n=s,l=s+e;if(Si(n,l,i,a)){c=Ci(o,r,c,n,a),o.push(t),s=l;continue}c=t.type===`text`?wi(o,t,n,i,a,r,c):Ti(o,t,r,c,i,n),s=l}return c||o.push(...r),_i(o)}function Di(e,t){return _i(e.filter(e=>e.type!==`token`||!t(e)))}function Oi(e,t){if(!t||t.start!==t.end)return null;let n=vi(e),r=t.end,i=n.slice(0,r),a=/(?:^|\s)\/([^\s\uFFFC]*)$/.exec(i);if(!a)return null;let o=r-a[0].length+(a[0].startsWith(`/`)?0:1);return{query:(a[1]??``).trim().toLowerCase(),start:o,end:r}}function ki(e,t,n){return e?e.start<n&&e.end>t:!1}function Ai(e){let t=new Map,n=0;for(let r of e)t.set(r.id,n),n+=mi(r);return t}function ji(e,t){let n=t;for(;n&&n.parentNode!==e;)n=n.parentNode;return n?Array.prototype.indexOf.call(e.childNodes,n):e.childNodes.length}function Mi(e,t,n){if(e instanceof HTMLElement){let t=e.dataset.composerNodeId;if(t)return n.find(e=>e.id===t)}return n[t]}function Ni(e,t,n){let r=0;for(let i=0;i<n;i+=1){let n=Mi(e.childNodes[i],i,t);n&&(r+=mi(n))}return r}function Pi(e,t,n,r){let i=ji(e,t),a=Ni(e,r,i),o=r[i];return o?.type===`text`?a+Math.min(n,o.text.length):a+Math.min(n,t.textContent?.length??0)}function Fi(e,t,n,r,i){return n.type===`text`?e.nodeType===Node.TEXT_NODE?r+Math.min(t,n.text.length):e===i?r+(t>0?n.text.length:0):r+n.text.length:e===i?r+(t>0?1:0):r+1}function Ii(e,t,n,r,i){if(t===e)return Ni(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return Pi(e,t,n,r);let a=t instanceof HTMLElement?t.closest(`[data-composer-node-id]`):t.parentElement?.closest(`[data-composer-node-id]`)??null;if(!(a instanceof HTMLElement))return Ii(e,e,ji(e,t),r,i);let o=a.dataset.composerNodeId;if(!o)return 0;let s=r.find(e=>e.id===o),c=i.get(o)??0;return s?Fi(t,n,s,c,a):c}function Li(e,t){let n=window.getSelection();if(!n||n.rangeCount===0)return null;let r=n.getRangeAt(0);if(!e.contains(r.startContainer)||!e.contains(r.endContainer))return null;let i=Ai(t),a=Ii(e,r.startContainer,r.startOffset,t,i),o=Ii(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(a,o),end:Math.max(a,o)}}function Ri(e,t,n){if(!n)return;let r=window.getSelection();if(!r)return;let i=n=>{let r=0;for(let i=0;i<t.length;i+=1){let a=t[i],o=mi(a),s=r,c=r+o,l=e.childNodes[i];if(!l){r=c;continue}if(a.type===`text`){if(n<=c)return{container:l.firstChild??l,offset:Math.max(0,Math.min(n-s,a.text.length))}}else{if(n<=s)return{container:e,offset:i};if(n<=c)return{container:e,offset:i+1}}r=c}return{container:e,offset:e.childNodes.length}},a=i(n.start),o=i(n.end),s=document.createRange();s.setStart(a.container,a.offset),s.setEnd(o.container,o.offset),r.removeAllRanges(),r.addRange(s)}function zi(e){let t=[];for(let n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(fi(n.textContent??``));continue}if(!(n instanceof HTMLElement))continue;if(n.dataset.composerNodeType===`token`){let e=n.dataset.composerTokenKind,r=n.dataset.composerTokenKey,i=n.dataset.composerLabel;e&&r&&i&&t.push({id:n.dataset.composerNodeId??pi({tokenKind:e,tokenKey:r,label:i}).id,type:`token`,tokenKind:e,tokenKey:r,label:i});continue}let e=n.textContent??``;t.push({id:n.dataset.composerNodeId??fi(e).id,type:`text`,text:e})}return _i(t)}function Bi(e){let t=zi(e);return{nodes:t,selection:Li(e,t)}}var Vi=class{constructor(){this.nodes=hi(),this.selection=null,this.sync=(e,t)=>(this.nodes=_i(e),this.selection=t,this.getSnapshot()),this.setSelection=e=>(this.selection=e,this.getSnapshot()),this.replaceDocument=(e,t)=>(this.nodes=_i(e),this.selection=t,this.getSnapshot()),this.insertText=e=>{let t=this.selection??{start:0,end:0};this.nodes=Ei(this.nodes,t.start,t.end,[fi(e)]);let n=t.start+e.length;return this.selection={start:n,end:n},this.getSnapshot()},this.insertFileToken=(e,t)=>this.insertToken(`file`,e,t),this.insertSkillToken=(e,t)=>this.getSelectedSkillKeys().includes(e)?this.getSnapshot():this.insertToken(`skill`,e,t,this.getSlashTrigger()),this.syncSelectedSkills=(e,t)=>{let n=this.getSelectedSkillKeys(),r=new Map(t.map(e=>[e.key,e])),i=e.find(e=>!n.includes(e));if(i){let e=r.get(i);return this.insertSkillToken(i,e?.label??i)}let a=n.find(t=>!e.includes(t));return a&&(this.nodes=Di(this.nodes,e=>e.tokenKind===`skill`&&e.tokenKey===a)),this.getSnapshot()},this.deleteContent=e=>{let t=this.getDocumentLength(),n=this.selection??{start:t,end:t},r=n.start,i=n.end;if(n.start===n.end)if(e===`backward`&&n.start>0)r=n.start-1;else if(e===`forward`)i=n.end+1;else return this.getSnapshot();return this.nodes=Ei(this.nodes,r,i,[]),this.selection={start:r,end:r},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:Ai(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((e,t)=>e+mi(t),0),this.getSelectedSkillKeys=()=>bi(this.nodes,`skill`),this.insertToken=(e,t,n,r=null)=>{let i=this.getDocumentLength(),a=r?.start??this.selection?.start??i,o=r?.end??this.selection?.end??a;return this.nodes=Ei(this.nodes,a,o,[pi({tokenKind:e,tokenKey:t,label:n})]),this.selection={start:a+1,end:a+1},this.getSnapshot()},this.getSlashTrigger=()=>Oi(this.nodes,this.selection)}};function Hi(e){let{key:t,shiftKey:n,isComposing:r,isSlashMenuOpen:i,slashItemCount:a,activeSlashIndex:o,isSending:s,canStopGeneration:c}=e;if(t===`Enter`&&!n&&s)return{type:`consume`};if(i&&a>0){if(t===`ArrowDown`)return{type:`move-slash-index`,index:(o+1)%a};if(t===`ArrowUp`)return{type:`move-slash-index`,index:(o-1+a)%a};if(t===`Enter`&&!n||t===`Tab`)return{type:`insert-active-slash-item`}}return t===`Escape`?i?{type:`close-slash`}:s&&c?{type:`stop-generation`}:{type:`noop`}:t===`Enter`&&n?{type:`insert-line-break`}:t===`Enter`?{type:`send-message`}:!r&&(t===`Backspace`||t===`Delete`)?{type:`delete-content`,direction:t===`Backspace`?`backward`:`forward`}:{type:`noop`}}var Ui=`http://www.w3.org/2000/svg`,Wi=class{constructor(){this.render=(e,t)=>{if(!e)return;let n=document.createDocumentFragment();for(let e of t.nodes){let r=e.type===`text`?this.createTextNodeElement(e):this.createTokenNodeElement(e,t.selectedRange,t.nodeStartMap);r&&n.appendChild(r)}e.replaceChildren(n)},this.createTextNodeElement=e=>{if(e.text.length===0)return null;let t=document.createElement(`span`);return t.dataset.composerNodeId=e.id,t.dataset.composerNodeType=`text`,t.textContent=e.text,t},this.createTokenNodeElement=(e,t,n)=>{let r=n.get(e.id)??0,i=ki(t,r,r+1),a=document.createElement(`span`);a.contentEditable=`false`,a.dataset.composerNodeId=e.id,a.dataset.composerNodeType=`token`,a.dataset.composerTokenKind=e.tokenKind,a.dataset.composerTokenKey=e.tokenKey,a.dataset.composerLabel=e.label,a.title=e.label,a.className=this.buildTokenClassName(e.tokenKind,i),a.append(this.createTokenIcon(e.tokenKind));let o=document.createElement(`span`);return o.className=e.tokenKind===`file`?`min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700`:`truncate`,o.textContent=e.label,a.append(o),a},this.buildTokenClassName=(e,t)=>e===`file`?[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-[min(100%,17rem)]`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`px-2`,`align-baseline`,`transition-[border-color,background-color,box-shadow,color]`,`duration-150`,t?`border-slate-300 bg-slate-100 text-slate-800 shadow-[0_0_0_2px_rgba(148,163,184,0.14)]`:`border-slate-200/80 bg-slate-50 text-slate-700`].join(` `):[`mx-[2px]`,`inline-flex`,`h-7`,`max-w-full`,`items-center`,`gap-1.5`,`rounded-lg`,`border`,`px-2`,`align-baseline`,`text-[11px]`,`font-medium`,`transition`,t?`border-primary/30 bg-primary/18 text-primary`:`border-primary/12 bg-primary/8 text-primary`].join(` `),this.createTokenIcon=e=>{let t=document.createElement(`span`);return t.className=e===`file`?`inline-flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-white text-slate-500 ring-1 ring-black/5`:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center text-primary/70`,t.append(e===`file`?this.createFileIcon():this.createSkillIcon()),t},this.createSkillIcon=()=>this.createSvgIcon([{tag:`path`,attrs:{d:`M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z`}},{tag:`path`,attrs:{d:`M2.75 10 8.5 13.25 14.25 10`}},{tag:`path`,attrs:{d:`M2.75 6v4l5.75 3.25V9.25L2.75 6Z`}},{tag:`path`,attrs:{d:`M14.25 6v4L8.5 13.25V9.25L14.25 6Z`}}]),this.createFileIcon=()=>this.createSvgIcon([{tag:`path`,attrs:{d:`M3.25 4.25A1.5 1.5 0 0 1 4.75 2.75h6.5a1.5 1.5 0 0 1 1.5 1.5v7.5a1.5 1.5 0 0 1-1.5 1.5h-6.5a1.5 1.5 0 0 1-1.5-1.5v-7.5Z`}},{tag:`path`,attrs:{d:`m4.75 10 2.25-2.5 1.75 1.75 1.25-1.25 2 2`}},{tag:`path`,attrs:{d:`M9.75 6.25h.01`}}]),this.createSvgIcon=e=>{let t=document.createElementNS(Ui,`svg`);t.setAttribute(`viewBox`,`0 0 16 16`),t.setAttribute(`fill`,`none`),t.setAttribute(`stroke`,`currentColor`),t.setAttribute(`stroke-width`,`1.25`),t.setAttribute(`stroke-linecap`,`round`),t.setAttribute(`stroke-linejoin`,`round`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`class`,`h-3 w-3`);for(let n of e){let e=document.createElementNS(Ui,n.tag);for(let[t,r]of Object.entries(n.attrs))e.setAttribute(t,r);t.append(e)}return t}}},Gi=188,Ki=class{constructor(e){this.controller=e,this.surfaceRenderer=new Wi,this.sync=(e,t)=>this.controller.sync(e,t),this.syncSelectionFromRoot=e=>this.controller.setSelection(Li(e,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(e,t)=>{!e||document.activeElement!==e||Ri(e,this.controller.getSnapshot().nodes,t)},this.syncViewport=e=>{e&&(e.style.maxHeight=`${Gi}px`,e.style.overflowY=e.scrollHeight>Gi?`auto`:`hidden`)},this.renderSurface=e=>{this.surfaceRenderer.render(e.root,{nodes:e.snapshot.nodes,selectedRange:e.selectedRange,nodeStartMap:e.snapshot.nodeStartMap})},this.insertSlashItem=(e,t)=>{e.value&&t(this.controller.insertSkillToken(e.value,e.title))},this.syncSelectedSkills=(e,t,n)=>{n(this.controller.syncSelectedSkills(e,t))},this.handleBeforeInput=e=>{let{event:t,disabled:n,isComposing:r,commitSnapshot:i}=e,a=t.nativeEvent;n||r||a.isComposing||!(a.inputType===`insertText`||a.inputType===`insertReplacementText`)||!a.data||(t.preventDefault(),i(this.controller.insertText(a.data)))},this.handleInput=e=>{let{event:t,isComposing:n,commitSnapshot:r}=e,i=t.nativeEvent;if(n||i.isComposing)return;let a=t.currentTarget,o=Bi(a);r(this.controller.replaceDocument(o.nodes,o.selection))},this.handleCompositionEnd=e=>{let{event:t,commitSnapshot:n}=e,r=t.currentTarget,i=Bi(r);n(this.controller.replaceDocument(i.nodes,i.selection))},this.handleKeyDown=e=>{let{event:t,slashItems:n,activeSlashIndex:r,activeSlashItem:i,actions:a,commitSnapshot:o,insertSkillToken:s,onSlashItemSelect:c,onSlashActiveIndexChange:l,onSlashQueryChange:u,onSlashOpenChange:d}=e,f=this.controller.getSnapshot(),p=Hi({key:t.key,shiftKey:t.shiftKey,isComposing:t.nativeEvent.isComposing,isSlashMenuOpen:f.slashTrigger!==null,slashItemCount:n.length,activeSlashIndex:r,isSending:a.isSending,canStopGeneration:a.canStopGeneration});p.type!==`noop`&&(t.preventDefault(),this.applyKeyboardAction({action:p,activeSlashItem:i,actions:a,commitSnapshot:o,insertSkillToken:s,onSlashItemSelect:c,onSlashActiveIndexChange:l,onSlashQueryChange:u,onSlashOpenChange:d}))},this.handlePaste=e=>{let{event:t,onFilesAdd:n,commitSnapshot:r}=e,i=Array.from(t.clipboardData.files??[]);if(i.length>0&&n){t.preventDefault(),n(i);return}let a=t.clipboardData.getData(`text/plain`);a&&(t.preventDefault(),r(this.controller.insertText(a)))},this.handleBlur=e=>{let{clearSelectedRange:t,onSlashQueryChange:n,onSlashOpenChange:r}=e;t(),n?.(null),r(!1)},this.applyKeyboardAction=e=>{let{action:t,activeSlashItem:n,actions:r,commitSnapshot:i,insertSkillToken:a,onSlashItemSelect:o,onSlashActiveIndexChange:s,onSlashQueryChange:c,onSlashOpenChange:l}=e;switch(t.type){case`move-slash-index`:s(t.index);return;case`insert-active-slash-item`:if(!n)return;o?.(n),a(n.value??n.key,n.title);return;case`close-slash`:c?.(null),l(!1);return;case`consume`:return;case`stop-generation`:r.onStop();return;case`insert-line-break`:i(this.controller.insertText(`
|
|
2
|
+
`));return;case`send-message`:r.onSend();return;case`delete-content`:i(this.controller.deleteContent(t.direction));return;case`noop`:return}}}},qi=class{constructor(){this.controller=new Vi,this.viewController=new Ki(this.controller),this.rootElement=null,this.selection=null,this.selectedRange=null,this.snapshot=this.controller.getSnapshot(),this.config=null,this.isComposing=!1,this.bindRootElement=e=>{this.rootElement=e},this.update=e=>(this.config=e,this.snapshot=this.viewController.sync(e.nodes,this.selectedRange),{snapshot:this.snapshot,selectedRange:this.selectedRange,bindRootElement:this.bindRootElement,handleBeforeInput:this.handleBeforeInput,handleInput:this.handleInput,handleCompositionStart:this.handleCompositionStart,handleCompositionEnd:this.handleCompositionEnd,handleKeyDown:this.handleKeyDown,handlePaste:this.handlePaste,handleBlur:this.handleBlur,syncSelectionState:this.syncSelectionState,imperativeHandle:this.createHandle()}),this.createHandle=()=>({insertSlashItem:e=>{this.config?.onSlashItemSelect?.(e),this.viewController.insertSlashItem(e,this.commitSnapshot)},insertFileToken:(e,t)=>{this.commitSnapshot(this.controller.insertFileToken(e,t)),this.focusComposerSoon()},insertFileTokens:e=>{let t=null;for(let n of e)t=this.controller.insertFileToken(n.tokenKey,n.label);t&&(this.commitSnapshot(t),this.focusComposerSoon())},focusComposer:()=>{this.focusComposer()},syncSelectedSkills:(e,t)=>{this.viewController.syncSelectedSkills(e,t,this.commitSnapshot)}}),this.restoreDomAfterCommit=()=>{this.isComposing||this.viewController.restoreSelectionIfFocused(this.rootElement,this.selection)},this.renderSurface=()=>{this.isComposing||this.viewController.renderSurface({root:this.rootElement,snapshot:this.snapshot,selectedRange:this.selectedRange})},this.syncViewport=()=>{this.viewController.syncViewport(this.rootElement)},this.syncSelectionState=()=>{if(!this.rootElement||this.isComposing)return;let e=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=e.selection,this.selectedRange=e.selection,this.syncSlashState(e),this.requestRender()},this.handleBeforeInput=e=>{this.viewController.handleBeforeInput({event:e,disabled:this.requireConfig().disabled,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleInput=e=>{this.viewController.handleInput({event:e,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleCompositionStart=()=>{this.isComposing=!0},this.handleCompositionEnd=e=>{this.isComposing=!1,this.viewController.handleCompositionEnd({event:e,commitSnapshot:this.commitSnapshot})},this.handleKeyDown=e=>{let t=this.requireConfig();if(this.rootElement&&!this.isComposing){let e=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=e.selection,this.selectedRange=e.selection,this.snapshot=e}let n=t.slashItems[t.activeSlashIndex]??null;this.viewController.handleKeyDown({event:e,slashItems:t.slashItems,activeSlashIndex:t.activeSlashIndex,activeSlashItem:n,actions:t.actions,commitSnapshot:this.commitSnapshot,insertSkillToken:this.insertSkillToken,onSlashItemSelect:t.onSlashItemSelect,onSlashActiveIndexChange:t.onSlashActiveIndexChange,onSlashQueryChange:t.onSlashQueryChange,onSlashOpenChange:t.onSlashOpenChange})},this.handlePaste=e=>{this.viewController.handlePaste({event:e,onFilesAdd:this.requireConfig().onFilesAdd,commitSnapshot:this.commitSnapshot})},this.handleBlur=()=>{let e=this.requireConfig();this.isComposing=!1,this.viewController.handleBlur({clearSelectedRange:this.clearSelectedRange,onSlashQueryChange:e.onSlashQueryChange,onSlashOpenChange:e.onSlashOpenChange})},this.setSelectedRange=e=>{this.selectedRange=e,this.selection=e,this.requestRender()},this.clearSelectedRange=()=>{this.selectedRange=null,this.requestRender()},this.commitSnapshot=e=>{let t=this.requireConfig();this.selection=e.selection,this.selectedRange=e.selection,this.snapshot=e,t.onNodesChange(e.nodes),this.syncSlashState(e)},this.insertSkillToken=(e,t)=>{this.commitSnapshot(this.controller.insertSkillToken(e,t))},this.syncSlashState=e=>{let t=this.requireConfig();t.onSlashTriggerChange?.(e.slashTrigger),t.onSlashQueryChange?.(e.slashTrigger?.query??null),t.onSlashOpenChange(e.slashTrigger!==null)},this.requestRender=()=>{this.requireConfig().requestRender()},this.focusComposerSoon=()=>{if(typeof requestAnimationFrame==`function`){requestAnimationFrame(()=>this.focusComposer());return}this.focusComposer()},this.focusComposer=()=>{if(!this.rootElement)return;let e=this.selection;this.rootElement.focus();let t=()=>{this.rootElement&&(this.selection=e,this.selectedRange=e,this.viewController.restoreSelectionIfFocused(this.rootElement,e))};if(typeof requestAnimationFrame==`function`){requestAnimationFrame(t);return}t()},this.requireConfig=()=>{if(!this.config)throw Error(`ChatComposerRuntime is not configured.`);return this.config}}},Ji=(0,P.forwardRef)(function(e,t){let{nodes:n,placeholder:r,disabled:i,slashItems:a,onSlashItemSelect:o,actions:s,onNodesChange:c,onFilesAdd:l,onSlashQueryChange:u,onSlashTriggerChange:d,onSlashOpenChange:f,onSlashActiveIndexChange:p,activeSlashIndex:m}=e,[h,g]=(0,P.useState)(0),[_]=(0,P.useState)(()=>new qi),{snapshot:v,bindRootElement:y,handleBeforeInput:b,handleInput:x,handleCompositionStart:S,handleCompositionEnd:C,handleKeyDown:w,handlePaste:T,handleBlur:E,syncSelectionState:D,imperativeHandle:O}=_.update({nodes:n,disabled:i,slashItems:a,onSlashItemSelect:o,actions:s,onNodesChange:c,onFilesAdd:l,onSlashQueryChange:u,onSlashTriggerChange:d,onSlashOpenChange:f,onSlashActiveIndexChange:p,activeSlashIndex:m,requestRender:()=>g(e=>e+1)});return(0,P.useImperativeHandle)(t,()=>O,[O]),(0,P.useLayoutEffect)(()=>{_.renderSurface(),_.restoreDomAfterCommit(),_.syncViewport()},[_,v.nodes,v.nodeStartMap,h]),(0,I.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,I.jsx)(`div`,{className:`min-h-[60px]`,children:(0,I.jsx)(`div`,{ref:y,contentEditable:!i,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-placeholder":r,onBeforeInput:b,onInput:x,onCompositionStart:S,onCompositionEnd:C,onKeyDown:w,onKeyUp:D,onMouseUp:D,onFocus:D,onBlur:E,onPaste:T,className:`min-h-7 max-h-[188px] w-full overflow-y-auto whitespace-pre-wrap break-words bg-transparent py-0.5 text-sm leading-6 text-gray-800 outline-none empty:before:pointer-events-none empty:before:text-gray-400 empty:before:content-[attr(data-placeholder)]`})})})});function Yi({hint:e}){return e?e.loading?(0,I.jsx)(`div`,{className:`px-4 pb-2`,children:(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`span`,{className:`h-3 w-16 animate-pulse rounded bg-gray-200`})]})}):(0,I.jsx)(`div`,{className:`px-4 pb-2`,children:(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${e.tone===`warning`?`border-amber-200 bg-amber-50 text-amber-800`:`border-gray-200 bg-gray-50 text-gray-700`}`,children:[e.text?(0,I.jsx)(`span`,{children:e.text}):null,e.actionLabel&&e.onAction?(0,I.jsx)(`button`,{type:`button`,onClick:e.onAction,className:`font-semibold underline-offset-2 hover:underline`,children:e.actionLabel}):null]})}):null}var Xi=(0,P.forwardRef)(function(e,t){let n=(0,P.useRef)(null),[r,i]=(0,P.useState)(null),[a,o]=(0,P.useState)(0),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(null),d=s!==null&&l!==s,f=e.slashMenu.items[a]??null;(0,P.useEffect)(()=>{o(t=>e.slashMenu.items.length===0?0:Math.min(t,e.slashMenu.items.length-1))},[e.slashMenu.items.length]),(0,P.useEffect)(()=>{r!==null&&o(0)},[r]),(0,P.useEffect)(()=>{s===null&&l!==null&&u(null)},[s,l]);let p=(0,P.useMemo)(()=>e.toolbar.skillPicker?{...e.toolbar,skillPicker:{...e.toolbar.skillPicker,onSelectedKeysChange:t=>{n.current?.syncSelectedSkills(t,e.toolbar.skillPicker?.options??[])}}}:e.toolbar,[e.toolbar]);return(0,P.useImperativeHandle)(t,()=>({insertFileToken:(e,t)=>n.current?.insertFileToken(e,t),insertFileTokens:e=>n.current?.insertFileTokens(e),focusComposer:()=>n.current?.focusComposer()}),[]),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,I.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Ji,{ref:n,nodes:e.composer.nodes,placeholder:e.composer.placeholder,disabled:e.composer.disabled,slashItems:e.slashMenu.items,onSlashItemSelect:e.slashMenu.onSelectItem,actions:e.toolbar.actions,activeSlashIndex:a,onNodesChange:e.composer.onNodesChange,onFilesAdd:e.composer.onFilesAdd,onSlashQueryChange:t=>{i(t),e.composer.onSlashQueryChange?.(t)},onSlashTriggerChange:e=>{c(e?.start??null)},onSlashOpenChange:e=>{!e&&s!==null&&u(s)},onSlashActiveIndexChange:o}),(0,I.jsx)(Qr,{isOpen:d,isLoading:e.slashMenu.isLoading,items:e.slashMenu.items,activeIndex:a,activeItem:f,texts:e.slashMenu.texts,onSelectItem:e=>{u(null),n.current?.insertSlashItem(e)},onOpenChange:e=>{!e&&s!==null&&u(s)},onSetActiveIndex:o})]}),(0,I.jsx)(Yi,{hint:e.hint}),(0,I.jsx)(ui,{...p})]})})})});Xi.displayName=`ChatInputBar`;function Zi({role:e}){return e===`user`?(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-user`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-white shadow-sm`,children:(0,I.jsx)(qe,{className:`h-4 w-4`})}):e===`tool`?(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-tool`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 shadow-sm`,children:(0,I.jsx)(Ot,{className:`h-4 w-4`})}):(0,I.jsx)(`div`,{"data-testid":`chat-message-avatar-assistant`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-b from-gray-700 to-gray-950 text-white shadow-md ring-1 ring-inset ring-white/20`,children:(0,I.jsx)(yt,{className:`h-[18px] w-[18px] text-white/95`,strokeWidth:2.5})})}function Qi(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var $i=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ea=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ta={};function na(e,t){return((t||ta).jsx?ea:$i).test(e)}var ra=/[ \t\n\f\r]/g;function ia(e){return typeof e==`object`?e.type===`text`?aa(e.value):!1:aa(e)}function aa(e){return e.replace(ra,``)===``}var oa=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};oa.prototype.normal={},oa.prototype.property={},oa.prototype.space=void 0;function sa(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new oa(n,r,t)}function ca(e){return e.toLowerCase()}var z=class{constructor(e,t){this.attribute=t,this.property=e}};z.prototype.attribute=``,z.prototype.booleanish=!1,z.prototype.boolean=!1,z.prototype.commaOrSpaceSeparated=!1,z.prototype.commaSeparated=!1,z.prototype.defined=!1,z.prototype.mustUseProperty=!1,z.prototype.number=!1,z.prototype.overloadedBoolean=!1,z.prototype.property=``,z.prototype.spaceSeparated=!1,z.prototype.space=void 0;var la=i({boolean:()=>B,booleanish:()=>V,commaOrSpaceSeparated:()=>pa,commaSeparated:()=>fa,number:()=>H,overloadedBoolean:()=>da,spaceSeparated:()=>U}),ua=0,B=ma(),V=ma(),da=ma(),H=ma(),U=ma(),fa=ma(),pa=ma();function ma(){return 2**++ua}var ha=Object.keys(la),ga=class extends z{constructor(e,t,n,r){let i=-1;if(super(e,t),_a(this,`space`,r),typeof n==`number`)for(;++i<ha.length;){let e=ha[i];_a(this,ha[i],(n&la[e])===la[e])}}};ga.prototype.defined=!0;function _a(e,t,n){n&&(e[t]=n)}function va(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new ga(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ca(r)]=r,n[ca(a.attribute)]=r}return new oa(t,n,e.space)}var ya=va({properties:{ariaActiveDescendant:null,ariaAtomic:V,ariaAutoComplete:null,ariaBusy:V,ariaChecked:V,ariaColCount:H,ariaColIndex:H,ariaColSpan:H,ariaControls:U,ariaCurrent:null,ariaDescribedBy:U,ariaDetails:null,ariaDisabled:V,ariaDropEffect:U,ariaErrorMessage:null,ariaExpanded:V,ariaFlowTo:U,ariaGrabbed:V,ariaHasPopup:null,ariaHidden:V,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:U,ariaLevel:H,ariaLive:null,ariaModal:V,ariaMultiLine:V,ariaMultiSelectable:V,ariaOrientation:null,ariaOwns:U,ariaPlaceholder:null,ariaPosInSet:H,ariaPressed:V,ariaReadOnly:V,ariaRelevant:null,ariaRequired:V,ariaRoleDescription:U,ariaRowCount:H,ariaRowIndex:H,ariaRowSpan:H,ariaSelected:V,ariaSetSize:H,ariaSort:null,ariaValueMax:H,ariaValueMin:H,ariaValueNow:H,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function ba(e,t){return t in e?e[t]:t}function xa(e,t){return ba(e,t.toLowerCase())}var Sa=va({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:fa,acceptCharset:U,accessKey:U,action:null,allow:null,allowFullScreen:B,allowPaymentRequest:B,allowUserMedia:B,alt:null,as:null,async:B,autoCapitalize:null,autoComplete:U,autoFocus:B,autoPlay:B,blocking:U,capture:null,charSet:null,checked:B,cite:null,className:U,cols:H,colSpan:null,content:null,contentEditable:V,controls:B,controlsList:U,coords:H|fa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:B,defer:B,dir:null,dirName:null,disabled:B,download:da,draggable:V,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:B,formTarget:null,headers:U,height:H,hidden:da,high:H,href:null,hrefLang:null,htmlFor:U,httpEquiv:U,id:null,imageSizes:null,imageSrcSet:null,inert:B,inputMode:null,integrity:null,is:null,isMap:B,itemId:null,itemProp:U,itemRef:U,itemScope:B,itemType:U,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:B,low:H,manifest:null,max:null,maxLength:H,media:null,method:null,min:null,minLength:H,multiple:B,muted:B,name:null,nonce:null,noModule:B,noValidate:B,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:B,optimum:H,pattern:null,ping:U,placeholder:null,playsInline:B,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:B,referrerPolicy:null,rel:U,required:B,reversed:B,rows:H,rowSpan:H,sandbox:U,scope:null,scoped:B,seamless:B,selected:B,shadowRootClonable:B,shadowRootDelegatesFocus:B,shadowRootMode:null,shape:null,size:H,sizes:null,slot:null,span:H,spellCheck:V,src:null,srcDoc:null,srcLang:null,srcSet:null,start:H,step:null,style:null,tabIndex:H,target:null,title:null,translate:null,type:null,typeMustMatch:B,useMap:null,value:V,width:H,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:U,axis:null,background:null,bgColor:null,border:H,borderColor:null,bottomMargin:H,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:B,declare:B,event:null,face:null,frame:null,frameBorder:null,hSpace:H,leftMargin:H,link:null,longDesc:null,lowSrc:null,marginHeight:H,marginWidth:H,noResize:B,noHref:B,noShade:B,noWrap:B,object:null,profile:null,prompt:null,rev:null,rightMargin:H,rules:null,scheme:null,scrolling:V,standby:null,summary:null,text:null,topMargin:H,valueType:null,version:null,vAlign:null,vLink:null,vSpace:H,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:B,disableRemotePlayback:B,prefix:null,property:null,results:H,security:null,unselectable:null},space:`html`,transform:xa}),Ca=va({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:pa,accentHeight:H,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:H,amplitude:H,arabicForm:null,ascent:H,attributeName:null,attributeType:null,azimuth:H,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:H,by:null,calcMode:null,capHeight:H,className:U,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:H,diffuseConstant:H,direction:null,display:null,dur:null,divisor:H,dominantBaseline:null,download:B,dx:null,dy:null,edgeMode:null,editable:null,elevation:H,enableBackground:null,end:null,event:null,exponent:H,externalResourcesRequired:null,fill:null,fillOpacity:H,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:fa,g2:fa,glyphName:fa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:H,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:H,horizOriginX:H,horizOriginY:H,id:null,ideographic:H,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:H,k:H,k1:H,k2:H,k3:H,k4:H,kernelMatrix:pa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:H,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:H,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:H,overlineThickness:H,paintOrder:null,panose1:null,path:null,pathLength:H,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:U,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:H,pointsAtY:H,pointsAtZ:H,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pa,rev:pa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pa,requiredFeatures:pa,requiredFonts:pa,requiredFormats:pa,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:H,specularExponent:H,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:H,strikethroughThickness:H,string:null,stroke:null,strokeDashArray:pa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:H,strokeOpacity:H,strokeWidth:null,style:null,surfaceScale:H,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pa,tabIndex:H,tableValues:null,target:null,targetX:H,targetY:H,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:H,underlineThickness:H,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:H,values:null,vAlphabetic:H,vMathematical:H,vectorEffect:null,vHanging:H,vIdeographic:H,version:null,vertAdvY:H,vertOriginX:H,vertOriginY:H,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:H,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:ba}),wa=va({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()}}),Ta=va({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:xa}),Ea=va({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Da={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`},Oa=/[A-Z]/g,ka=/-[a-z]/g,Aa=/^data[-\w.:]+$/i;function ja(e,t){let n=ca(t),r=t,i=z;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Aa.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(ka,Na);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!ka.test(e)){let n=e.replace(Oa,Ma);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=ga}return new i(r,t)}function Ma(e){return`-`+e.toLowerCase()}function Na(e){return e.charAt(1).toUpperCase()}var Pa=sa([ya,Sa,wa,Ta,Ea],`html`),Fa=sa([ya,Ca,wa,Ta,Ea],`svg`);function Ia(e){return e.join(` `).trim()}var La=a(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
3
|
+
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),Ra=a((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(La());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),za=a((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Ba=a(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ra()),r=za();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),Va=Ua(`end`),Ha=Ua(`start`);function Ua(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Wa(e){let t=Ha(e),n=Va(e);if(t&&n)return{start:t,end:n}}function Ga(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?qa(e.position):`start`in e||`end`in e?qa(e):`line`in e||`column`in e?Ka(e):``}function Ka(e){return Ja(e&&e.line)+`:`+Ja(e&&e.column)}function qa(e){return Ka(e&&e.start)+`-`+Ka(e&&e.end)}function Ja(e){return e&&typeof e==`number`?e:1}var W=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Ga(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};W.prototype.file=``,W.prototype.name=``,W.prototype.reason=``,W.prototype.message=``,W.prototype.stack=``,W.prototype.column=void 0,W.prototype.line=void 0,W.prototype.ancestors=void 0,W.prototype.cause=void 0,W.prototype.fatal=void 0,W.prototype.place=void 0,W.prototype.ruleId=void 0,W.prototype.source=void 0;var Ya=e(Ba(),1),Xa={}.hasOwnProperty,Za=new Map,Qa=/[A-Z]/g,$a=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),eo=new Set([`td`,`th`]),to=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function no(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=mo(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=po(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Fa:Pa,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=ro(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function ro(e,t,n){if(t.type===`element`)return io(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return ao(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return so(e,t,n);if(t.type===`mdxjsEsm`)return oo(e,t);if(t.type===`root`)return co(e,t,n);if(t.type===`text`)return lo(e,t)}function io(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Fa,e.schema=i),e.ancestors.push(t);let a=bo(e,t.tagName,!1),o=ho(e,t),s=_o(e,t);return $a.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!ia(e):!0})),uo(e,o,a,t),fo(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function ao(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}xo(e,t.position)}function oo(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);xo(e,t.position)}function so(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Fa,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:bo(e,t.name,!0),o=go(e,t),s=_o(e,t);return uo(e,o,a,t),fo(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function co(e,t,n){let r={};return fo(r,_o(e,t)),e.create(t,e.Fragment,r,n)}function lo(e,t){return t.value}function uo(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function fo(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function po(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function mo(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Ha(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function ho(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Xa.call(t.properties,i)){let a=vo(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&eo.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function go(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else xo(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else xo(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function _o(e,t){let n=[],r=-1,i=e.passKeys?new Map:Za;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=ro(e,a,o);s!==void 0&&n.push(s)}return n}function vo(e,t,n){let r=ja(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Qi(n):Ia(n)),r.property===`style`){let t=typeof n==`object`?n:yo(e,String(n));return e.stylePropertyNameCase===`css`&&(t=So(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Da[r.property]||r.property:r.attribute,n]}}function yo(e,t){try{return(0,Ya.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new W("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=to+`#cannot-parse-style-attribute`,r}}function bo(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=na(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=na(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Xa.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);xo(e)}function xo(e,t){let n=new W("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=to+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function So(e){let t={},n;for(n in e)Xa.call(e,n)&&(t[Co(n)]=e[n]);return t}function Co(e){let t=e.replace(Qa,wo);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function wo(e){return`-`+e.toLowerCase()}var To={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},Eo={};function Do(e,t){let n=t||Eo;return Oo(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function Oo(e,t,n){if(Ao(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return ko(e.children,t,n)}return Array.isArray(e)?ko(e,t,n):``}function ko(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Oo(e[i],t,n);return r.join(``)}function Ao(e){return!!(e&&typeof e==`object`)}var jo=document.createElement(`i`);function Mo(e){let t=`&`+e+`;`;jo.innerHTML=t;let n=jo.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function No(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Po(e,t){return e.length>0?(No(e,e.length,0,t),e):t}var Fo={}.hasOwnProperty;function Io(e){let t={},n=-1;for(;++n<e.length;)Lo(t,e[n]);return t}function Lo(e,t){let n;for(n in t){let r=(Fo.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Fo.call(r,a)||(r[a]=[]);let e=i[a];Ro(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Ro(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);No(e,0,0,r)}function zo(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function Bo(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var G=Jo(/[A-Za-z]/),K=Jo(/[\dA-Za-z]/),Vo=Jo(/[#-'*+\--9=?A-Z^-~]/);function Ho(e){return e!==null&&(e<32||e===127)}var Uo=Jo(/\d/),Wo=Jo(/[\dA-Fa-f]/),Go=Jo(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function J(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}var Ko=Jo(/\p{P}|\p{S}/u),qo=Jo(/\s/);function Jo(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Yo(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&K(e.charCodeAt(n+1))&&K(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function X(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Y(r)?(e.enter(n),s(r)):t(r)}function s(r){return Y(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Xo={tokenize:Zo};function Zo(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Qo={tokenize:es},$o={tokenize:ts};function es(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return No(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check($o,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt($o,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;No(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ts(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function ns(e){if(e===null||J(e)||qo(e))return 1;if(Ko(e))return 2}function rs(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var is={name:`attention`,resolveAll:as,tokenize:os};function as(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};ss(d,-c),ss(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Po(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Po(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Po(l,rs(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Po(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Po(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,No(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function os(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ns(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=ns(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function ss(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var cs={name:`autolink`,tokenize:ls};function ls(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return G(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||K(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||K(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Ho(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Vo(t)?(e.consume(t),l):n(t)}function u(e){return K(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||K(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var us={partial:!0,tokenize:ds};function ds(e,t,n){return r;function r(t){return Y(t)?X(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var fs={continuation:{tokenize:ms},exit:hs,name:`blockQuote`,tokenize:ps};function ps(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Y(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function ms(e,t,n){let r=this;return i;function i(t){return Y(t)?X(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(fs,t,n)(r)}}function hs(e){e.exit(`blockQuote`)}var gs={name:`characterEscape`,tokenize:_s};function _s(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Go(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var vs={name:`characterReference`,tokenize:ys};function ys(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=K,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Wo,u):(e.enter(`characterReferenceValue`),a=7,o=Uo,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===K&&!Mo(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var bs={partial:!0,tokenize:Cs},xs={concrete:!0,name:`codeFenced`,tokenize:Ss};function Ss(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(bs,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),X(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Y(t)?X(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(bs,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Y(t)?X(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Cs(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var ws={name:`codeIndented`,tokenize:Es},Ts={partial:!0,tokenize:Ds};function Es(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),X(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(Ts,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Ds(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):X(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var Os={name:`codeText`,previous:As,resolve:ks,tokenize:js};function ks(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function As(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function js(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Ms=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Ns(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Ns(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Ns(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);Ns(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Ns(this.left,t.reverse())}}};function Ns(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ps(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Ms(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Fs(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return No(e,0,1/0,u.slice(0)),!l}function Fs(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Is={resolve:Rs,tokenize:zs},Ls={partial:!0,tokenize:Bs};function Rs(e){return Ps(e),e}function zs(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(Ls,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Bs(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Vs(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Ho(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||J(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Ho(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Hs(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Y(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Us(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Ws(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Y(i)?X(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Gs={name:`definition`,tokenize:qs},Ks={partial:!0,tokenize:Js};function qs(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Hs.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Bo(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return J(t)?Ws(e,l)(t):l(t)}function l(t){return Vs(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Ks,d,d)(t)}function d(t){return Y(t)?X(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Js(e,t,n){return r;function r(t){return J(t)?Ws(e,i)(t):n(t)}function i(t){return Us(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Y(t)?X(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var Ys={name:`hardBreakEscape`,tokenize:Xs};function Xs(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Zs={name:`headingAtx`,resolve:Qs,tokenize:$s};function Qs(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},No(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function $s(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||J(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):Y(n)?X(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||J(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var ec=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),tc=[`pre`,`script`,`style`,`textarea`],nc={concrete:!0,name:`htmlFlow`,resolveTo:ac,tokenize:oc},rc={partial:!0,tokenize:cc},ic={partial:!0,tokenize:sc};function ac(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function oc(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ie):G(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):G(a)?(e.consume(a),i=4,r.interrupt?t:ie):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ie):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return G(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||J(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&tc.includes(l)?(i=1,r.interrupt?t(s):O(s)):ec.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||K(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Y(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||G(t)?(e.consume(t),b):Y(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||K(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Y(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Y(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||J(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Y(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):Y(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),A):t===60&&i===1?(e.consume(t),j):t===62&&i===4?(e.consume(t),ae):t===63&&i===3?(e.consume(t),ie):t===93&&i===5?(e.consume(t),re):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(rc,M,ee)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),O)}function ee(t){return e.check(ic,te,M)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),k}function k(t){return t===null||q(t)?ee(t):(e.enter(`htmlFlowData`),O(t))}function A(t){return t===45?(e.consume(t),ie):O(t)}function j(t){return t===47?(e.consume(t),o=``,ne):O(t)}function ne(t){if(t===62){let n=o.toLowerCase();return tc.includes(n)?(e.consume(t),ae):O(t)}return G(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ne):O(t)}function re(t){return t===93?(e.consume(t),ie):O(t)}function ie(t){return t===62?(e.consume(t),ae):t===45&&i===2?(e.consume(t),ie):O(t)}function ae(t){return t===null||q(t)?(e.exit(`htmlFlowData`),M(t)):(e.consume(t),ae)}function M(n){return e.exit(`htmlFlow`),t(n)}}function sc(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function cc(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(us,t,n)}}var lc={name:`htmlText`,tokenize:uc};function uc(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):G(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):G(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,j(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?A(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,j(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?A(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?A(t):q(t)?(o=v,j(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,j(t)):(e.consume(t),y)}function b(e){return e===62?A(e):y(e)}function x(t){return G(t)?(e.consume(t),S):n(t)}function S(t){return t===45||K(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,j(t)):Y(t)?(e.consume(t),C):A(t)}function w(t){return t===45||K(t)?(e.consume(t),w):t===47||t===62||J(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),A):t===58||t===95||G(t)?(e.consume(t),E):q(t)?(o=T,j(t)):Y(t)?(e.consume(t),T):A(t)}function E(t){return t===45||t===46||t===58||t===95||K(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,j(t)):Y(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,ee):q(t)?(o=O,j(t)):Y(t)?(e.consume(t),O):(e.consume(t),te)}function ee(t){return t===i?(e.consume(t),i=void 0,k):t===null?n(t):q(t)?(o=ee,j(t)):(e.consume(t),ee)}function te(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||J(t)?T(t):(e.consume(t),te)}function k(e){return e===47||e===62||J(e)?T(e):n(e)}function A(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function j(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return Y(t)?X(e,re,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):re(t)}function re(t){return e.enter(`htmlTextData`),o(t)}}var dc={name:`labelEnd`,resolveAll:hc,resolveTo:gc,tokenize:_c},fc={tokenize:vc},pc={tokenize:yc},mc={tokenize:bc};function hc(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&No(e,0,e.length,n),e}function gc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Po(s,e.slice(a+1,a+r+3)),s=Po(s,[[`enter`,u,t]]),s=Po(s,rs(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Po(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Po(s,e.slice(o+1)),s=Po(s,[[`exit`,c,t]]),No(e,a,e.length,s),e}function _c(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Bo(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(fc,u,o?u:d)(t):t===91?e.attempt(pc,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(mc,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function vc(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return J(t)?Ws(e,a)(t):a(t)}function a(t){return t===41?u(t):Vs(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return J(t)?Ws(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Us(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return J(t)?Ws(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function yc(e,t,n){let r=this;return i;function i(t){return Hs.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Bo(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function bc(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var xc={name:`labelStartImage`,resolveAll:dc.resolveAll,tokenize:Sc};function Sc(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Cc={name:`labelStartLink`,resolveAll:dc.resolveAll,tokenize:wc};function wc(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Tc={name:`lineEnding`,tokenize:Ec};function Ec(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}}var Dc={name:`thematicBreak`,tokenize:Oc};function Oc(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Y(t)?X(e,s,`whitespace`)(t):s(t))}}var Z={continuation:{tokenize:Mc},exit:Pc,name:`list`,tokenize:jc},kc={partial:!0,tokenize:Fc},Ac={partial:!0,tokenize:Nc};function jc(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Uo(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Dc,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Uo(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(us,r.interrupt?n:u,e.attempt(kc,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Y(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Mc(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(us,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Y(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ac,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(Z,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Nc(e,t,n){let r=this;return X(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Pc(e){e.exit(this.containerState.type)}function Fc(e,t,n){let r=this;return X(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Y(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Ic={name:`setextUnderline`,resolveTo:Lc,tokenize:Rc};function Lc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Rc(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Y(t)?X(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var zc={tokenize:Bc};function Bc(e){let t=this,n=e.attempt(us,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Is,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Vc={resolveAll:Gc()},Hc=Wc(`string`),Uc=Wc(`text`);function Wc(e){return{resolveAll:Gc(e===`text`?Kc:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Gc(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Kc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var qc=i({attentionMarkers:()=>tl,contentInitial:()=>Yc,disable:()=>nl,document:()=>Jc,flow:()=>Zc,flowInitial:()=>Xc,insideSpan:()=>el,string:()=>Qc,text:()=>$c}),Jc={42:Z,43:Z,45:Z,48:Z,49:Z,50:Z,51:Z,52:Z,53:Z,54:Z,55:Z,56:Z,57:Z,62:fs},Yc={91:Gs},Xc={[-2]:ws,[-1]:ws,32:ws},Zc={35:Zs,42:Dc,45:[Ic,Dc],60:nc,61:Ic,95:Dc,96:xs,126:xs},Qc={38:vs,92:gs},$c={[-5]:Tc,[-4]:Tc,[-3]:Tc,33:xc,38:vs,42:is,60:[cs,lc],91:Cc,92:[Ys,gs],93:dc,95:is,96:Os},el={null:[is,Vc]},tl={null:[42,95]},nl={null:[]};function rl(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Po(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=rs(a,l.events,l),l.events):[]}function f(e,t){return al(p(e),t)}function p(e){return il(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&No(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function il(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function al(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
4
|
+
`;break;case-3:o=`\r
|
|
5
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function ol(e){let t={constructs:Io([qc,...(e||{}).extensions||[]]),content:n(Xo),defined:[],document:n(Qo),flow:n(zc),lazy:{},string:n(Hc),text:n(Uc)};return t;function n(e){return n;function n(n){return rl(t,e,n)}}}function sl(e){for(;!Ps(e););return e}var cl=/[\0\t\n\r]/g;function ll(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(cl.lastIndex=u,c=cl.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var ul=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function dl(e){return e.replace(ul,fl)}function fl(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return zo(n.slice(t?2:1),t?16:10)}return Mo(n)||e}var pl={}.hasOwnProperty;function ml(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),hl(n)(sl(ol(n).document().write(ll()(e,t,!0))))}function hl(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(xe),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(_e),blockQuote:a(pe),characterEscape:T,characterReference:T,codeFenced:a(N),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(N,o),codeText:a(me,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(he),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ge),hardBreakEscape:a(ve),hardBreakTrailing:a(ve),htmlFlow:a(ye,o),htmlFlowData:T,htmlText:a(ye,o),htmlTextData:T,image:a(be),label:o,link:a(xe),listItem:a(Ce),listItemValue:f,listOrdered:a(Se,d),listUnordered:a(Se),paragraph:a(we),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(_e),strong:a(Te),thematicBreak:a(De)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:fe,autolinkProtocol:de,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:le,characterReference:ue,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(k),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(ee),htmlFlowData:E,htmlText:c(te),htmlTextData:E,image:c(j),label:re,labelText:ne,lineEnding:D,link:c(A),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:ie,resourceTitleString:ae,resource:M,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};_l(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];pl.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||yl).call(a,void 0,e[0])}for(r.position={start:gl(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:gl(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:gl(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||yl).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Ga({start:e.start,end:e.end})+`): it’s not open`);n.position.end=gl(e.end)}function u(){return Do(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Bo(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ee(),n.position={start:gl(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=gl(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=gl(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ne(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=dl(t),n.identifier=Bo(t).toLowerCase()}function re(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ae(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function M(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Bo(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ce(e){this.data.characterReferenceType=e.type}function le(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=zo(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Mo(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=gl(e.end)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function fe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function pe(){return{type:`blockquote`,children:[]}}function N(){return{type:`code`,lang:null,meta:null,value:``}}function me(){return{type:`inlineCode`,value:``}}function he(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ge(){return{type:`emphasis`,children:[]}}function _e(){return{type:`heading`,depth:0,children:[]}}function ve(){return{type:`break`}}function ye(){return{type:`html`,value:``}}function be(){return{type:`image`,title:null,url:``,alt:null}}function xe(){return{type:`link`,title:null,url:``,children:[]}}function Se(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Ce(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function we(){return{type:`paragraph`,children:[]}}function Te(){return{type:`strong`,children:[]}}function Ee(){return{type:`text`,value:``}}function De(){return{type:`thematicBreak`}}}function gl(e){return{line:e.line,column:e.column,offset:e.offset}}function _l(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?_l(e,r):vl(e,r)}}function vl(e,t){let n;for(n in t)if(pl.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function yl(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Ga({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ga({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Ga({start:t.start,end:t.end})+`) is still open`)}function bl(e){let t=this;t.parser=n;function n(n){return ml(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function xl(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Sl(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
6
|
+
`}]}function Cl(e,t){let n=t.value?t.value+`
|
|
7
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function wl(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Tl(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function El(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=Yo(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function Dl(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ol(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function kl(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function Al(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return kl(e,t);let i={src:Yo(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function jl(e,t){let n={src:Yo(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Ml(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Nl(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return kl(e,t);let i={href:Yo(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function Pl(e,t){let n={href:Yo(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Fl(e,t,n){let r=e.all(t),i=n?Il(n):Ll(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
8
|
+
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
9
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Il(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Ll(n[r])}return t}function Ll(e){return e.spread??e.children.length>1}function Rl(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function zl(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Bl(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Vl(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Hl(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=Ha(t.children[1]),o=Va(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Ul(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Wl(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var Gl=9,Kl=32;function ql(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Jl(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Jl(t.slice(i),i>0,!1)),a.join(``)}function Jl(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===Gl||t===Kl;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===Gl||t===Kl;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function Yl(e,t){let n={type:`text`,value:ql(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Xl(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Zl={blockquote:xl,break:Sl,code:Cl,delete:wl,emphasis:Tl,footnoteReference:El,heading:Dl,html:Ol,imageReference:Al,image:jl,inlineCode:Ml,linkReference:Nl,link:Pl,listItem:Fl,list:Rl,paragraph:zl,root:Bl,strong:Vl,table:Hl,tableCell:Wl,tableRow:Ul,text:Yl,thematicBreak:Xl,toml:Ql,yaml:Ql,definition:Ql,footnoteDefinition:Ql};function Ql(){}var $l=typeof self==`object`?self:globalThis,eu=(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 $l[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 $l[a](o),i)};return r},tu=e=>eu(new Map,e)(0),nu=``,{toString:ru}={},{keys:iu}=Object,au=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=ru.call(e).slice(8,-1);switch(n){case`Array`:return[1,nu];case`Object`:return[2,nu];case`Date`:return[3,nu];case`RegExp`:return[4,nu];case`Map`:return[5,nu];case`Set`:return[6,nu];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},ou=([e,t])=>e===0&&(t===`function`||t===`symbol`),su=(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]=au(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 iu(r))(e||!ou(au(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||!(ou(au(n))||ou(au(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!ou(au(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},cu=(e,{json:t,lossy:n}={})=>{let r=[];return su(!(t||n),!!t,new Map,r)(e),r},lu=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?tu(cu(e,t)):structuredClone(e):(e,t)=>tu(cu(e,t));function uu(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function du(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function fu(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||uu,r=e.options.footnoteBackLabel||du,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=Yo(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...lu(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
10
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
11
|
+
`}]}}var pu=(function(e){if(e==null)return vu;if(typeof e==`function`)return _u(e);if(typeof e==`object`)return Array.isArray(e)?mu(e):hu(e);if(typeof e==`string`)return gu(e);throw Error(`Expected function, string, or object as test`)});function mu(e){let t=[],n=-1;for(;++n<e.length;)t[n]=pu(e[n]);return _u(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function hu(e){let t=e;return _u(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function gu(e){return _u(t);function t(t){return t&&t.type===e}}function _u(e){return t;function t(t,n,r){return!!(yu(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function vu(){return!0}function yu(e){return typeof e==`object`&&!!e&&`type`in e}function bu(e){return e}var xu=[];function Su(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=pu(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 (`+bu(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=xu,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Cu(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 Cu(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?xu:[e]}function wu(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),Su(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 Tu={}.hasOwnProperty,Eu={};function Du(e,t){let n=t||Eu,r=new Map,i=new Map,a={all:s,applyData:ku,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Zl,...n.handlers},one:o,options:n,patch:Ou,wrap:ju};return wu(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(Tu.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=lu(n);return r.children=a.all(e),r}return lu(e)}return(a.options.unknownHandler||Au)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=Mu(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=Mu(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function Ou(e,t){e.position&&(t.position=Wa(e))}function ku(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,lu(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function Au(e,t){let n=t.data||{},r=`value`in t&&!(Tu.call(n,`hProperties`)||Tu.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ju(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
12
|
+
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
13
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
14
|
+
`}),n}function Mu(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Nu(e,t){let n=Du(e,t),r=n.one(e,void 0),i=fu(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
15
|
+
`},i)),a}function Pu(e,t){return e&&`run`in e?async function(n,r){let i=Nu(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Nu(n,{file:r,...e||t})}}function Fu(e){if(e)throw e}var Iu=a(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Lu(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ru(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?zu(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function zu(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Bu={basename:Vu,dirname:Hu,extname:Uu,join:Wu,sep:`/`};function Vu(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);qu(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Hu(e){if(qu(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function Uu(e){qu(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Wu(...e){let t=-1,n;for(;++t<e.length;)qu(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Gu(n)}function Gu(e){qu(e);let t=e.codePointAt(0)===47,n=Ku(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Ku(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function qu(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Ju={cwd:Yu};function Yu(){return`/`}function Xu(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Zu(e){if(typeof e==`string`)e=new URL(e);else if(!Xu(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Qu(e)}function Qu(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var $u=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],ed=class{constructor(e){let t;t=e?Xu(e)?{path:e}:typeof e==`string`||id(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Ju.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<$u.length;){let e=$u[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)$u.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Bu.basename(this.path):void 0}set basename(e){nd(e,`basename`),td(e,`basename`),this.path=Bu.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Bu.dirname(this.path):void 0}set dirname(e){rd(this.basename,`dirname`),this.path=Bu.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Bu.extname(this.path):void 0}set extname(e){if(td(e,`extname`),rd(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Bu.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Xu(e)&&(e=Zu(e)),nd(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Bu.basename(this.path,this.extname):void 0}set stem(e){nd(e,`stem`),td(e,`stem`),this.path=Bu.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new W(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function td(e,t){if(e&&e.includes(Bu.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Bu.sep+"`")}function nd(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function rd(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function id(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var ad=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),od=e(Iu(),1),sd={}.hasOwnProperty,cd=new class e extends ad{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ru()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,od.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(dd(`data`,this.frozen),this.namespace[e]=t,this):sd.call(this.namespace,e)&&this.namespace[e]||void 0:e?(dd(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=md(e),n=this.parser||this.Parser;return ld(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),ld(`process`,this.parser||this.Parser),ud(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=md(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);gd(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),ld(`processSync`,this.parser||this.Parser),ud(`processSync`,this.compiler||this.Compiler),this.process(e,r),pd(`processSync`,`process`,t),n;function r(e,r){t=!0,Fu(e),n=r}}run(e,t,n){fd(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=md(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),pd(`runSync`,`run`,n),r;function i(e,t){Fu(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=md(t),r=this.compiler||this.Compiler;return ud(`stringify`,r),fd(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(dd(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,od.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Lu(o)&&Lu(r)&&(r=(0,od.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function ld(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function ud(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function dd(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function fd(e){if(!Lu(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function pd(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function md(e){return hd(e)?e:new ed(e)}function hd(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function gd(e){return typeof e==`string`||_d(e)}function _d(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var vd=[],yd={allowDangerousHtml:!0},bd=/^(https?|ircs?|mailto|xmpp)$/i,xd=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function Sd(e){let t=Cd(e),n=wd(e);return Td(t.runSync(t.parse(n),n),e)}function Cd(e){let t=e.rehypePlugins||vd,n=e.remarkPlugins||vd,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...yd}:yd;return cd().use(bl).use(n).use(Pu,r).use(t)}function wd(e){let t=e.children||``,n=new ed;return typeof t==`string`?n.value=t:``+t,n}function Td(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Ed;for(let e of xd)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return wu(e,l),no(e,{Fragment:I.Fragment,components:i,ignoreInvalidStyle:!0,jsx:I.jsx,jsxs:I.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in To)if(Object.hasOwn(To,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=To[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Ed(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||bd.test(e.slice(0,t))?e:``}function Dd(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Od(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function kd(e,t,n){let r=pu((n||{}).ignore||[]),i=Ad(t),a=-1;for(;++a<i.length;)Su(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Ad(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([jd(e[0]),Md(e[1])])}return t}function jd(e){return typeof e==`string`?new RegExp(Od(e),`g`):e}function Md(e){return typeof e==`function`?e:function(){return e}}var Nd=`phrasing`,Pd=[`autolink`,`link`,`image`,`label`];function Fd(){return{transforms:[Ud],enter:{literalAutolink:Ld,literalAutolinkEmail:Rd,literalAutolinkHttp:Rd,literalAutolinkWww:Rd},exit:{literalAutolink:Hd,literalAutolinkEmail:Vd,literalAutolinkHttp:zd,literalAutolinkWww:Bd}}}function Id(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:Nd,notInConstruct:Pd},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:Nd,notInConstruct:Pd},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:Nd,notInConstruct:Pd}]}}function Ld(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Rd(e){this.config.enter.autolinkProtocol.call(this,e)}function zd(e){this.config.exit.autolinkProtocol.call(this,e)}function Bd(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Vd(e){this.config.exit.autolinkEmail.call(this,e)}function Hd(e){this.exit(e)}function Ud(e){kd(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Wd],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Gd]],{ignore:[`link`,`linkReference`]})}function Wd(e,t,n,r,i){let a=``;if(!Jd(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Kd(n)))return!1;let o=qd(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Gd(e,t,n,r){return!Jd(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Kd(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function qd(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Dd(e,`(`),a=Dd(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Jd(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||qo(n)||Ko(n))&&(!t||n!==47)}af.peek=rf;function Yd(){this.buffer()}function Xd(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Zd(){this.buffer()}function Qd(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function $d(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Bo(this.sliceSerialize(e)).toLowerCase(),n.label=t}function ef(e){this.exit(e)}function tf(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Bo(this.sliceSerialize(e)).toLowerCase(),n.label=t}function nf(e){this.exit(e)}function rf(){return`[`}function af(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function of(){return{enter:{gfmFootnoteCallString:Yd,gfmFootnoteCall:Xd,gfmFootnoteDefinitionLabelString:Zd,gfmFootnoteDefinition:Qd},exit:{gfmFootnoteCallString:$d,gfmFootnoteCall:ef,gfmFootnoteDefinitionLabelString:tf,gfmFootnoteDefinition:nf}}}function sf(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:af},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
16
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?lf:cf))),s(),o}}function cf(e,t,n){return t===0?e:lf(e,t,n)}function lf(e,t,n){return(n?``:` `)+e}var uf=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];hf.peek=gf;function df(){return{canContainEols:[`delete`],enter:{strikethrough:pf},exit:{strikethrough:mf}}}function ff(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:uf}],handlers:{delete:hf}}}function pf(e){this.enter({type:`delete`,children:[]},e)}function mf(e){this.exit(e)}function hf(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function gf(){return`~`}function _f(e){return e.length}function vf(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||_f,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=yf(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=bf(r[d]);else{let e=bf(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
17
|
+
`)}function yf(e){return e==null?``:String(e)}function bf(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function xf(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Sf);return i(),o}function Sf(e,t,n){return`>`+(n?``:` `)+e}function Cf(e,t){return wf(e,t.inConstruct,!0)&&!wf(e,t.notInConstruct,!1)}function wf(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Tf(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
18
|
+
`&&Cf(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
19
|
+
`}function Ef(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Df(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Of(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function kf(e,t,n,r){let i=Of(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(Df(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Af);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Ef(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
20
|
+
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
21
|
+
`),a&&(u+=s.move(a+`
|
|
22
|
+
`)),u+=s.move(c),l(),u}function Af(e,t,n){return(n?``:` `)+e}function jf(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Mf(e,t,n,r){let i=jf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
23
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Nf(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Pf(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Ff(e,t,n){let r=ns(e),i=ns(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}If.peek=Lf;function If(e,t,n,r){let i=Nf(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Ff(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Pf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Ff(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Pf(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Lf(e,t,n){return n.options.emphasis||`*`}function Rf(e,t){let n=!1;return wu(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&Do(e)&&(t.options.setext||n))}function zf(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Rf(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
24
|
+
`,after:`
|
|
25
|
+
`});return r(),t(),o+`
|
|
26
|
+
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
27
|
+
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
28
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=Pf(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Bf.peek=Vf;function Bf(e){return e.value||``}function Vf(){return`<`}Hf.peek=Uf;function Hf(e,t,n,r){let i=jf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Uf(){return`!`}Wf.peek=Gf;function Wf(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Gf(){return`!`}Kf.peek=qf;function Kf(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function qf(){return"`"}function Jf(e,t){let n=Do(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Yf.peek=Xf;function Yf(e,t,n,r){let i=jf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Jf(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Xf(e,t,n){return Jf(e,n)?`<`:`[`}Zf.peek=Qf;function Zf(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Qf(){return`[`}function $f(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ep(e){let t=$f(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function tp(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function np(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function rp(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?tp(n):$f(n),s=e.ordered?o===`.`?`)`:`.`:ep(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),np(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function ip(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function ap(e,t,n,r){let i=ip(n),a=n.bulletCurrent||$f(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function op(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var sp=pu([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function cp(e,t,n,r){return(e.children.some(function(e){return sp(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function lp(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}up.peek=dp;function up(e,t,n,r){let i=lp(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Ff(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Pf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Ff(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Pf(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function dp(e,t,n){return n.options.strong||`*`}function fp(e,t,n,r){return n.safe(e.value,r)}function pp(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function mp(e,t,n){let r=(np(n)+(n.options.ruleSpaces?` `:``)).repeat(pp(n));return n.options.ruleSpaces?r.slice(0,-1):r}var hp={blockquote:xf,break:Tf,code:kf,definition:Mf,emphasis:If,hardBreak:Tf,heading:zf,html:Bf,image:Hf,imageReference:Wf,inlineCode:Kf,link:Yf,linkReference:Zf,list:rp,listItem:ap,paragraph:op,root:cp,strong:up,text:fp,thematicBreak:mp};function gp(){return{enter:{table:_p,tableData:xp,tableHeader:xp,tableRow:yp},exit:{codeText:Sp,table:vp,tableData:bp,tableHeader:bp,tableRow:bp}}}function _p(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function vp(e){this.exit(e),this.data.inTable=void 0}function yp(e){this.enter({type:`tableRow`,children:[]},e)}function bp(e){this.exit(e)}function xp(e){this.enter({type:`tableCell`,children:[]},e)}function Sp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Cp));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Cp(e,t){return t===`|`?t:e}function wp(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
29
|
+
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
30
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return vf(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=hp.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Tp(){return{exit:{taskListCheckValueChecked:Dp,taskListCheckValueUnchecked:Dp,paragraph:Op}}}function Ep(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:kp}}}function Dp(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Op(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function kp(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=hp.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Ap(){return[Fd(),of(),df(),gp(),Tp()]}function jp(e){return{extensions:[Id(),sf(e),ff(),wp(e),Ep()]}}var Mp={tokenize:Kp,partial:!0},Np={tokenize:qp,partial:!0},Pp={tokenize:Jp,partial:!0},Fp={tokenize:Yp,partial:!0},Ip={tokenize:Xp,partial:!0},Lp={name:`wwwAutolink`,tokenize:Wp,previous:Zp},Rp={name:`protocolAutolink`,tokenize:Gp,previous:Qp},zp={name:`emailAutolink`,tokenize:Up,previous:$p},Bp={};function Vp(){return{text:Bp}}for(var Hp=48;Hp<123;)Bp[Hp]=zp,Hp++,Hp===58?Hp=65:Hp===91&&(Hp=97);Bp[43]=zp,Bp[45]=zp,Bp[46]=zp,Bp[95]=zp,Bp[72]=[zp,Rp],Bp[104]=[zp,Rp],Bp[87]=[zp,Lp],Bp[119]=[zp,Lp];function Up(e,t,n){let r=this,i,a;return o;function o(t){return!em(t)||!$p.call(r,r.previous)||tm(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return em(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Ip,u,l)(t):t===45||t===95||K(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&G(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Wp(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Zp.call(r,r.previous)||tm(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Mp,e.attempt(Np,e.attempt(Pp,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Gp(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Qp.call(r,r.previous)&&!tm(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(G(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ho(t)||J(t)||qo(t)||Ko(t)?n(t):e.attempt(Np,e.attempt(Pp,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Kp(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function qp(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Fp,c,s)(t):t===null||J(t)||qo(t)||t!==45&&Ko(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Jp(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Fp,t,a)(o):o===null||J(o)||qo(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Yp(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||J(o)||qo(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||J(e)||qo(e)?t(e):r(e)}function a(e){return G(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):G(t)?(e.consume(t),o):n(t)}}function Xp(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return K(e)?n(e):t(e)}}function Zp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function Qp(e){return!G(e)}function $p(e){return!(e===47||em(e))}function em(e){return e===43||e===45||e===46||e===95||K(e)}function tm(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var nm={tokenize:um,partial:!0};function rm(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:sm,continuation:{tokenize:cm},exit:lm}},text:{91:{name:`gfmFootnoteCall`,tokenize:om},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:im,resolveTo:am}}}}function im(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Bo(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function am(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function om(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||J(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Bo(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return J(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function sm(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||J(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Bo(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return J(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),X(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function cm(e,t,n){return e.check(us,t,e.attempt(nm,t,n))}function lm(e){e.exit(`gfmFootnoteDefinition`)}function um(e,t,n){let r=this;return X(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function dm(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&No(o,o.length,0,rs(s,e.slice(r+1,n),t)),No(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),No(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=ns(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=ns(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var fm=class{constructor(){this.map=[]}add(e,t,n){pm(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function pm(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function mm(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function hm(){return{flow:{null:{name:`table`,tokenize:gm,resolveAll:_m}}}}function gm(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||J(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||J(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function _m(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new fm;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(ym(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=vm(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=vm(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=vm(f,t,o,i,n,d)):(o[0]=o[1],d=vm(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&ym(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=mm(t.events,n))}return e}function vm(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},bm(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=bm(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=bm(t.events,n[2]),a=bm(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},bm(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function ym(e,t,n,r,i){let a=[],o=bm(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function bm(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var xm={name:`tasklistCheck`,tokenize:Cm};function Sm(){return{text:{91:xm}}}function Cm(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return J(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):Y(r)?e.check({tokenize:wm},t,n)(r):n(r)}}function wm(e,t,n){return X(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Tm(e){return Io([Vp(),rm(),dm(e),hm(),Sm()])}var Em={};function Dm(e){let t=this,n=e||Em,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Tm(n)),a.push(Ap()),o.push(jp(n))}function Om(){return typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`}function km(e){if(typeof document>`u`)return;let t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(e=>t.addRange(e)))}function Am(e){if(typeof document>`u`||!document.body)return!1;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t:null,r=n?{start:n.selectionStart,end:n.selectionEnd}:null,i=document.getSelection(),a=i?Array.from({length:i.rangeCount},(e,t)=>i.getRangeAt(t).cloneRange()):[],o=document.createElement(`textarea`);o.value=e,o.setAttribute(`readonly`,``),o.setAttribute(`aria-hidden`,`true`),o.style.position=`fixed`,o.style.top=`0`,o.style.left=`-9999px`,o.style.opacity=`0`,o.style.pointerEvents=`none`,o.style.fontSize=`12pt`,document.body.appendChild(o);try{o.focus({preventScroll:!0})}catch{o.focus()}o.select(),o.setSelectionRange(0,o.value.length);let s=!1;try{s=typeof document.execCommand==`function`&&document.execCommand(`copy`)}catch{s=!1}if(o.remove(),t)try{t.focus({preventScroll:!0})}catch{t.focus()}return n&&r?n.setSelectionRange(r.start,r.end):km(a),s}async function jm(e){if(!e)return!1;if(Om())try{return await navigator.clipboard.writeText(e),!0}catch{return Am(e)}return Am(e)}var Mm=1300;function Nm(e){let[t,n]=(0,P.useState)(!1),r=(0,P.useCallback)(async()=>{e.text&&(await jm(e.text)?n(!0):n(!1))},[e.text]);return(0,P.useEffect)(()=>{if(!t||typeof window>`u`)return;let r=window.setTimeout(()=>n(!1),e.resetDelayMs??Mm);return()=>window.clearTimeout(r)},[t,e.resetDelayMs]),{copied:t,copy:r}}var Pm=/language-([a-z0-9-]+)/i;function Fm(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(Fm).join(``):``}function Im(e){let t=Fm(e);return t.endsWith(`
|
|
31
|
+
`)?t.slice(0,-1):t}function Lm(e){return(e?Pm.exec(e):null)?.[1]?.toLowerCase()||`text`}function Rm(e){let t=(0,P.useMemo)(()=>Lm(e.className),[e.className]),n=(0,P.useMemo)(()=>Im(e.children),[e.children]),{copied:r,copy:i}=Nm({text:n});return(0,I.jsxs)(`div`,{className:`chat-codeblock`,children:[(0,I.jsxs)(`div`,{className:`chat-codeblock-toolbar`,children:[(0,I.jsx)(`span`,{className:`chat-codeblock-language`,children:t}),(0,I.jsxs)(`button`,{type:`button`,className:`chat-codeblock-copy`,onClick:()=>void i(),"aria-label":r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel,children:[r?(0,I.jsx)(re,{className:`h-3.5 w-3.5`}):(0,I.jsx)(nn,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel})]})]}),(0,I.jsx)(`pre`,{children:(0,I.jsx)(`code`,{className:e.className,children:n})})]})}var zm=14e4,Bm=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function Vm(e){return e.length<=zm?e:`${e.slice(0,zm)}\n\n...`}function Hm(e){if(!e)return null;if(e.startsWith(`#`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))return e;try{let t=new URL(e);return Bm.has(t.protocol)?e:null}catch{return null}}function Um(e){return/^https?:\/\//i.test(e)}function Wm({text:e,role:t,texts:n,inline:r=!1}){let i=t===`user`,a=(0,P.useMemo)(()=>({p:({children:e})=>r?(0,I.jsx)(I.Fragment,{children:e}):(0,I.jsx)(`p`,{children:e}),a:({href:e,children:t,...n})=>{let r=Hm(e);if(!r)return(0,I.jsx)(`span`,{className:`chat-link-invalid`,children:t});let i=Um(r);return(0,I.jsx)(`a`,{...n,href:r,target:i?`_blank`:void 0,rel:i?`noreferrer noopener`:void 0,children:t})},table:({children:e,...t})=>(0,I.jsx)(`div`,{className:`chat-table-wrap`,children:(0,I.jsx)(`table`,{...t,children:e})}),input:({type:e,checked:t,...n})=>e===`checkbox`?(0,I.jsx)(`input`,{...n,type:`checkbox`,checked:t,readOnly:!0,disabled:!0,className:`chat-task-checkbox`}):(0,I.jsx)(`input`,{...n,type:e}),img:({src:e,alt:t,...n})=>{let r=Hm(e);return r?(0,I.jsx)(`img`,{...n,src:r,alt:t||``,loading:`lazy`,decoding:`async`}):null},code:({className:e,children:t,...r})=>!e&&!String(t??``).includes(`
|
|
32
|
+
`)?(0,I.jsx)(`code`,{...r,className:R(`chat-inline-code`,e),children:t}):(0,I.jsx)(Rm,{className:e,texts:n,children:t})}),[r,n]);return(0,I.jsx)(r?`span`:`div`,{className:R(`chat-markdown`,i?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,I.jsx)(Sd,{skipHtml:!0,remarkPlugins:[Dm],components:a,children:Vm(e)})})}function Gm(e){return e.split(``).join(``).split(``).join(``).split(``).join(``).split(``).join(``).split(``).join(``).length>0}function Km(){return(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`h-3 w-3`,children:[(0,I.jsx)(`path`,{d:`M8.5 2.75 2.75 6l5.75 3.25L14.25 6 8.5 2.75Z`}),(0,I.jsx)(`path`,{d:`M2.75 10 8.5 13.25 14.25 10`}),(0,I.jsx)(`path`,{d:`M2.75 6v4l5.75 3.25V9.25L2.75 6Z`}),(0,I.jsx)(`path`,{d:`M14.25 6v4L8.5 13.25V9.25L14.25 6Z`})]})}function qm({kind:e,label:t,isUser:n}){let r=e===`skill`;return(0,I.jsxs)(`span`,{className:R(`mx-[2px] inline-flex h-7 max-w-full items-center gap-1.5 rounded-xl border px-2.5 align-baseline text-[11px] font-medium shadow-[0_0_0_1px_rgba(15,23,42,0.03)]`,r?n?`border-emerald-200/35 bg-emerald-400/18 text-emerald-50/95`:`border-emerald-200/70 bg-emerald-50 text-emerald-700`:n?`border-white/30 bg-white/18 text-white`:`border-slate-200/80 bg-slate-100 text-slate-700`),title:t,children:[(0,I.jsx)(`span`,{className:R(`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,r?n?`text-emerald-100/90`:`text-emerald-600`:n?`text-white/70`:`text-slate-500`),children:(0,I.jsx)(Km,{})}),(0,I.jsx)(`span`,{className:`truncate`,children:t})]})}function Jm({segments:e,role:t,texts:n}){let r=t===`user`;return(0,I.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-6`,children:e.map((e,i)=>e.type===`token`?(0,I.jsx)(qm,{kind:e.token.kind,label:e.token.label,isUser:r},`token-${i}-${e.token.kind}-${e.token.key}`):Gm(e.text)?(0,I.jsx)(Wm,{text:e.text,role:t,texts:n,inline:!0},`markdown-${i}`):(0,I.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.text},`space-${i}`))})}var Ym={archive:`Archive`,audio:`Audio`,code:`Code`,data:`Data`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF`,sheet:`Sheet`,video:`Video`},Xm={archive:`border-amber-200/80 bg-amber-100 text-amber-700`,audio:`border-fuchsia-200/80 bg-fuchsia-100 text-fuchsia-700`,code:`border-cyan-200/80 bg-cyan-100 text-cyan-700`,data:`border-slate-200/80 bg-slate-100 text-slate-700`,document:`border-blue-200/80 bg-blue-100 text-blue-700`,generic:`border-slate-200/80 bg-slate-100 text-slate-700`,image:`border-emerald-200/80 bg-emerald-100 text-emerald-700`,pdf:`border-rose-200/80 bg-rose-100 text-rose-700`,sheet:`border-lime-200/80 bg-lime-100 text-lime-700`,video:`border-violet-200/80 bg-violet-100 text-violet-700`},Zm=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),Qm=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),$m=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),eh=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),th=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function nh(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,``)} ${t[r]}`}function rh(e,t){let n=/\.([a-z0-9]{1,12})$/i.exec(e.trim());if(n?.[1])return n[1].toUpperCase();let r=(t.split(`/`)[1]??``).split(/[+.;-]/)[0]?.trim();return r?r.slice(0,6).toUpperCase():`FILE`}function ih(e,t){let n=/\.([a-z0-9]{1,12})$/i.exec(e.trim())?.[1]?.toLowerCase()??``,r=t.toLowerCase();return r.startsWith(`image/`)?`image`:r.startsWith(`audio/`)?`audio`:r.startsWith(`video/`)?`video`:r.includes(`pdf`)||n===`pdf`?`pdf`:th.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:eh.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:Qm.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:Zm.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:$m.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function ah(e){let t=ih(e.label,e.mimeType),n=nh(e.sizeBytes);return{category:t,extension:rh(e.label,e.mimeType),sizeLabel:n,metaBadges:[Ym[t],n].filter(e=>!!e)}}function oh(e,t){return(0,I.jsx)(`span`,{className:R(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium`,t?`border-white/12 bg-white/10 text-white/82`:`border-slate-200/80 bg-slate-950/[0.04] text-slate-600`),children:e},e)}function sh(e,t){return(0,I.jsx)(`div`,{className:R(`truncate text-[11px]`,t?`text-white/58`:`text-slate-500`),children:e})}function ch(e,t,n){return(0,I.jsx)(`span`,{className:R(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-medium`,n?t?`border-white/14 bg-white/12 text-white`:`border-slate-200/80 bg-white text-slate-700`:t?`border-white/10 bg-white/6 text-white/62`:`border-slate-200/70 bg-slate-100/80 text-slate-500`),children:e})}function lh({file:e,isUser:t=!1}){let{category:n,extension:r,metaBadges:i,sizeLabel:a}=ah(e),o=!!e.dataUrl,s=o?e.isImage?`Open preview`:`Open file`:`Attached`,c=r.slice(0,4),l=R(`block overflow-hidden rounded-[1.25rem] border transition duration-200`,t?`border-white/12 bg-white/10 text-white shadow-[0_18px_40px_-28px_rgba(15,23,42,0.85)]`:`border-slate-200/80 bg-white/95 text-slate-900 shadow-[0_20px_45px_-30px_rgba(15,23,42,0.28)]`,o&&(t?`hover:border-white/18 hover:bg-white/13`:`hover:border-slate-300 hover:bg-white hover:shadow-[0_24px_50px_-30px_rgba(15,23,42,0.3)]`));if(e.isImage&&e.dataUrl)return(0,I.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Open preview: ${e.label}`,className:R(l,`group`),children:(0,I.jsxs)(`figure`,{children:[(0,I.jsxs)(`div`,{className:R(`relative overflow-hidden p-2`,t?`bg-white/[0.04]`:`bg-gradient-to-br from-slate-100 via-white to-slate-100`),children:[(0,I.jsx)(`img`,{src:e.dataUrl,alt:e.label,className:`block max-h-[22rem] w-full rounded-[1rem] object-cover shadow-[0_18px_40px_-26px_rgba(15,23,42,0.55)] transition duration-300 group-hover:scale-[1.01]`}),(0,I.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-4 top-4 flex items-center justify-between`,children:[a?oh(a,t):(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{className:R(`inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-semibold tracking-[0.22em]`,t?`border-white/12 bg-slate-950/20 text-white`:Xm[n]),children:c})]})]}),(0,I.jsxs)(`figcaption`,{className:`flex items-start gap-3 p-4`,children:[(0,I.jsx)(`div`,{className:R(`flex h-11 w-11 shrink-0 items-center justify-center rounded-[1rem] border text-[11px] font-semibold tracking-[0.22em]`,t?`border-white/12 bg-white/10 text-white`:Xm[n]),children:c}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold leading-5`,children:e.label}),(0,I.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:i.map(e=>oh(e,t))}),(0,I.jsx)(`div`,{className:`mt-2`,children:sh(e.mimeType,t)})]}),ch(s,t,!0)]})]})});let u=(0,I.jsxs)(`div`,{className:`flex items-start gap-3 p-3.5`,children:[(0,I.jsx)(`div`,{className:R(`flex h-14 w-14 shrink-0 items-center justify-center rounded-[1rem] border text-xs font-semibold tracking-[0.22em]`,t?`border-white/12 bg-white/10 text-white`:Xm[n]),children:c}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-sm font-semibold leading-5`,children:e.label}),(0,I.jsxs)(`div`,{className:R(`mt-1 text-xs`,t?`text-white/68`:`text-slate-500`),children:[Ym[n],` attachment`]})]}),ch(s,t,o)]}),(0,I.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:i.map(e=>oh(e,t))}),(0,I.jsx)(`div`,{className:`mt-2`,children:sh(e.mimeType,t)})]})]});return o?(0,I.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Open file: ${e.label}`,className:R(l,`group`),children:u}):(0,I.jsx)(`div`,{className:l,children:u})}function uh(e){let{isInProgress:t}=e,[n,r]=(0,P.useState)(t),[i,a]=(0,P.useState)(!1),o=(0,P.useRef)(t);(0,P.useEffect)(()=>{let e=o.current;!e&&t?(r(!0),a(!1)):e&&!t&&!i&&r(!1),o.current=t},[t,i]);function s(e){e.preventDefault();let i=!n;if(r(i),!i){a(!1);return}t&&a(!0)}return{isOpen:n,onSummaryClick:s}}function dh({label:e,text:t,isUser:n,isInProgress:r}){let{isOpen:i,onSummaryClick:a}=uh({isInProgress:r});return(0,I.jsxs)(`details`,{className:`mt-2`,open:i,children:[(0,I.jsx)(`summary`,{className:R(`cursor-pointer text-xs`,n?`text-primary-100`:`text-gray-500`),onClick:a,children:e}),(0,I.jsx)(`pre`,{className:R(`mt-2 w-fit max-w-[500px] whitespace-pre-wrap break-all rounded-lg p-2 text-[11px]`,n?`bg-primary-700/60`:`bg-gray-100`),children:t})]})}function fh({children:e,className:t}){return(0,I.jsx)(`div`,{className:R(`my-2 rounded-lg border border-amber-200/50 bg-amber-100/30 shadow-sm overflow-hidden text-[12px]`,`w-[280px] sm:w-[360px] md:w-[480px] min-w-full max-w-full transition-all flex flex-col`,t),children:e})}function ph({children:e,className:t}){return(0,I.jsx)(`div`,{className:R(`border-t border-amber-200/15 bg-amber-50/50 px-3 pt-1 pb-2 w-full overflow-hidden`,t),children:e})}var mh={running:{text:`text-amber-500/80`,icon:we,spin:!0},success:{text:`text-amber-500/80`,icon:re,spin:!1},error:{text:`text-amber-500/80`,icon:bn,spin:!1},cancelled:{text:`text-amber-500/80`,icon:fn,spin:!1}};function hh({card:e}){let t=mh[e.statusTone]||mh.cancelled,n=t.icon;return(0,I.jsxs)(`span`,{className:R(`inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0`,t.text),children:[(0,I.jsx)(n,{className:R(`h-3.5 w-3.5`,t.spin&&`animate-spin`),strokeWidth:3}),e.statusTone===`running`?e.statusLabel:null]})}function gh({action:e,onAction:t}){let n=e.sessionKind===`child`?`Open child session`:`Open session`;return(0,I.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:R(`inline-flex items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors`,`border-amber-200/80 bg-white/80 text-amber-800 hover:bg-amber-50`),"aria-label":n,title:n,children:(0,I.jsx)(Zt,{className:`h-3 w-3`,strokeWidth:2.5})})}function _h({card:e,icon:t,expanded:n,canExpand:r,hideSummary:i=!1,actionSlot:a,onToggle:o}){let s=i?``:e.summary?.replace(/^(command|path|args|query|input):\s*/i,``)??``;return(0,I.jsxs)(`div`,{className:R(`flex items-center justify-between px-3 py-2.5 transition-colors bg-transparent`,r?`cursor-pointer hover:bg-amber-100/30`:``),onClick:o,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 font-mono min-w-0 max-w-[calc(100%-80px)] text-amber-950/80`,children:[(0,I.jsx)(t,{className:`h-4 w-4 text-amber-600/80 shrink-0`,strokeWidth:3}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,I.jsx)(`span`,{className:`font-bold shrink-0 tracking-tight`,children:e.toolName}),s&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-amber-300 font-bold select-none shrink-0`,children:`›`}),(0,I.jsx)(`span`,{className:`truncate flex-1 min-w-0 font-normal`,title:s,children:s})]})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[a,(0,I.jsx)(hh,{card:e}),r&&(n?(0,I.jsx)(T,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}):(0,I.jsx)(en,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}))]})]})}function vh({action:e,onAction:t}){return(0,I.jsx)(gh,{action:e,onAction:t})}var yh=10;function bh(e){e.scrollTop=e.scrollHeight}function xh(e){e.scrollRef.current&&(e.scheduledScrollFrameRef.current!==null&&cancelAnimationFrame(e.scheduledScrollFrameRef.current),e.scheduledScrollFrameRef.current=requestAnimationFrame(()=>{e.scheduledScrollFrameRef.current=null;let t=e.scrollRef.current;t&&(e.isProgrammaticScrollRef.current=!0,bh(t))}))}function Sh(e){let t=(0,P.useRef)(!0),n=(0,P.useRef)(!1),r=(0,P.useRef)(null),i=(0,P.useRef)(!1),a=(0,P.useRef)(null);return(0,P.useEffect)(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),(0,P.useEffect)(()=>{let e=a.current;return()=>{e!==null&&cancelAnimationFrame(e)}},[]),(0,P.useLayoutEffect)(()=>{!i.current||e.isLoading||!e.hasContent||e.scrollRef.current&&(i.current=!1,xh({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),(0,P.useLayoutEffect)(()=>{!t.current||!e.hasContent||e.scrollRef.current&&xh({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n})},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:()=>{if(n.current){n.current=!1;return}let r=e.scrollRef.current;r&&(t.current=r.scrollHeight-r.scrollTop-r.clientHeight<=(e.stickyThresholdPx??yh))}}}var Ch=`h-5 font-mono text-[11px] leading-5`,wh=`sticky left-0 z-[1] flex h-5 items-center justify-center px-2.5 tabular-nums select-none`;function Th(e){return typeof e==`number`?String(e):``}function Eh(e){return Th(e.newLineNumber??e.oldLineNumber)}function Dh(e,t,n){return`${e}-${n}-${t.oldLineNumber??`x`}-${t.newLineNumber??`x`}`}function Oh(e){return typeof e.newLineNumber==`number`||typeof e.oldLineNumber==`number`}function kh(e){return e.lines.some(Oh)}function Ah(e){let t=e.lines.reduce((e,t)=>Oh(t)?Math.max(e,Eh(t).length):e,0);return`${Math.max(6.5,Math.min(8,t+3.5))}ch`}function jh(e){if(e.showLineNumbers)return{gridTemplateColumns:`${e.lineNumberColumnWidth} minmax(0, 1fr)`}}function Mh(e){return e.kind===`remove`?`border-r border-rose-200 bg-rose-50 text-rose-700`:e.kind===`add`?`border-r border-emerald-200 bg-emerald-50 text-emerald-700`:`border-r border-stone-200 bg-stone-100 text-stone-500`}function Nh(e){return e.kind===`remove`?`bg-rose-50 text-rose-950`:e.kind===`add`?`bg-emerald-50 text-emerald-950`:`bg-white text-amber-950/80`}function Ph({line:e,showLineNumbers:t,lineNumberColumnWidth:n}){return(0,I.jsxs)(`div`,{"data-file-line-row":`true`,className:R(`grid w-max min-w-full`,Ch),style:jh({showLineNumbers:t,lineNumberColumnWidth:n}),children:[t?(0,I.jsx)(`span`,{"data-file-line-number-cell":`true`,style:{width:n},className:R(wh,Mh(e)),children:Eh(e)}):null,(0,I.jsx)(`span`,{"data-file-code-row":`true`,className:R(`block min-w-full whitespace-pre px-2.5`,Nh(e)),children:e.text||` `})]})}function Fh({block:e}){let t=kh(e),n=Ah(e);return(0,I.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber bg-white`,children:e.lines.map((e,r)=>(0,I.jsx)(Ph,{line:e,showLineNumbers:t,lineNumberColumnWidth:n},Dh(`row`,e,r)))})}function Ih(e){return e.display===`preview`}function Lh(e){return e.rawText?e.rawText:e.lines.map(e=>[e.kind,e.oldLineNumber??``,e.newLineNumber??``,e.text].join(`:`)).join(`
|
|
33
|
+
`)}function Rh(e){return/^\+\d+$/.test(e)?`text-emerald-700`:/^-\d+$/.test(e)?`text-rose-700`:`text-stone-500`}function zh(e){let t=e.split(`·`).map(e=>e.trim()).filter(e=>/^\+\d+$/.test(e)||/^-\d+$/.test(e));return t.length===0?null:(0,I.jsx)(`div`,{className:`flex shrink-0 items-center gap-x-1 whitespace-nowrap text-[10px] font-medium uppercase tracking-[0.08em]`,children:t.map((e,t)=>(0,I.jsxs)(P.Fragment,{children:[t>0?(0,I.jsx)(`span`,{className:`text-stone-300`,children:`·`}):null,(0,I.jsx)(`span`,{className:R(Rh(e)),children:e})]},`${e}-${t}`))})}function Bh({children:e,contentVersion:t,resetKey:n,className:r,scrollKind:i}){let a=(0,P.useRef)(null),{onScroll:o}=Sh({scrollRef:a,resetKey:n,isLoading:!1,hasContent:!0,contentVersion:t,stickyThresholdPx:20});return(0,I.jsx)(`div`,{ref:a,onScroll:o,"data-file-scroll-kind":i,className:R(`overflow-y-auto overscroll-contain bg-white custom-scrollbar-amber`,r),children:e})}function Vh({block:e,showPathRow:t,isFirst:n}){let{Tooltip:r,TooltipContent:i,TooltipProvider:a,TooltipTrigger:o}=Jr,s=Ih(e),c=t||!!e.caption;return(0,I.jsxs)(`section`,{className:R(`overflow-hidden bg-white`,!n&&`border-t border-stone-200/80`),children:[c?(0,I.jsxs)(`div`,{className:R(`flex items-center justify-between gap-4 border-b border-stone-200/80 px-4 text-stone-700`,t?`py-2`:`py-1.5`),children:[(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,I.jsx)(a,{delayDuration:250,children:(0,I.jsxs)(r,{children:[(0,I.jsx)(o,{asChild:!0,children:(0,I.jsx)(`div`,{className:`truncate whitespace-nowrap font-mono text-[12px] font-medium text-stone-700`,title:e.path,children:e.path})}),(0,I.jsx)(i,{side:`top`,className:`max-w-[420px] text-xs font-mono break-all`,children:e.path})]})}):null}),e.caption?zh(e.caption):null]}):null,e.lines.length>0?(0,I.jsx)(Bh,{resetKey:`block:${e.key}`,contentVersion:Lh(e),className:`max-h-72`,scrollKind:`block`,children:(0,I.jsx)(Fh,{block:e})}):e.rawText?(0,I.jsx)(Bh,{resetKey:`raw:${e.key}`,contentVersion:e.rawText,className:`max-h-72`,scrollKind:`raw`,children:(0,I.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,I.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:e.rawText})})}):null,e.truncated&&!s?(0,I.jsx)(`div`,{className:`border-t border-stone-200/85 bg-stone-50 px-4 py-2 text-[10px] text-stone-500`,children:`Showing a shortened diff preview.`}):null]})}function Hh({card:e,className:t}){let n=e.fileOperation?.blocks??[],r=e.output?.trim()??``;return n.length===0&&!r?null:(0,I.jsxs)(`div`,{className:R(`overflow-hidden bg-white`,t),children:[n.map((e,t)=>(0,I.jsx)(Vh,{block:e,showPathRow:!0,isFirst:t===0},e.key)),r?(0,I.jsx)(Bh,{resetKey:`output:${e.toolName}:${e.summary??`none`}`,contentVersion:r,className:R(`max-h-56`,n.length>0&&`border-t border-stone-200/80`),scrollKind:`output`,children:(0,I.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar-amber`,children:(0,I.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-white px-4 py-2 font-mono text-[11px] leading-5 text-amber-950/80`,children:r})})}):null]})}var Uh=200,Wh=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`g`);function Gh(e){return typeof e==`string`&&e.length>0?e:null}function Kh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qh(e){return e.replace(Wh,``)}function Jh(e){return`command`in e||`workingDir`in e||`exitCode`in e||`durationMs`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e}function Yh(e){let t=Gh(e.aggregated_output)??Gh(e.combinedOutput)??Gh(e.output);if(t)return t;let n=Gh(e.stdout),r=Gh(e.stderr);return!n&&!r?null:[n,r].filter(e=>!!e).join(`
|
|
34
|
+
`)}function Xh(e,t){if(Kh(t)){let e=Yh(t);if(e)return qh(e);if(Jh(t))return``}if(!e)return``;let n=e.trim();if(!n.startsWith(`{`))return qh(e);try{let t=JSON.parse(n);if(!Kh(t))return qh(e);let r=Yh(t);return r?qh(r):Jh(t)?``:qh(e)}catch{return qh(e)}}function Zh({canExpand:e,isRunning:t,autoExpandWhileRunning:n=!0,expandOnError:r=!1,statusTone:i}){let[a,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(!1),l=(0,P.useRef)(null),u=(0,P.useRef)(t),d=(0,P.useRef)(!0);return(0,P.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,P.useEffect)(()=>{if(r&&i===`error`&&e&&!s){l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(!0),u.current=t,d.current=!1;return}n&&t&&e&&!s&&!a&&(d.current||!u.current)&&(l.current=window.setTimeout(()=>{o(!0),l.current=null},Uh)),t||(l.current!==null&&(window.clearTimeout(l.current),l.current=null),u.current&&!s&&o(!1)),u.current=t,d.current=!1},[n,e,r,a,s,t,i]),{expanded:a,onToggle:()=>{e&&(l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(e=>!e),c(!0))}}}function Qh({label:e,tone:t,children:n}){let r={input:{shell:`border-stone-200/80 bg-stone-50/90`,header:`border-stone-200/80 bg-stone-100/85 text-stone-500`,dot:`bg-stone-400/80`,body:`text-stone-700`},output:{shell:`border-amber-200/70 bg-white/90`,header:`border-amber-200/70 bg-amber-50/90 text-amber-700`,dot:`bg-amber-500/80`,body:`text-amber-950/80`},error:{shell:`border-rose-200/80 bg-rose-50/85`,header:`border-rose-200/80 bg-rose-100/80 text-rose-700`,dot:`bg-rose-500/80`,body:`text-rose-950/85`}}[t];return(0,I.jsxs)(`section`,{className:R(`overflow-hidden rounded-md border shadow-[inset_0_1px_0_rgba(255,255,255,0.45)]`,r.shell),children:[(0,I.jsxs)(`div`,{className:R(`flex items-center gap-2 border-b px-3 py-2 text-[10px] font-semibold uppercase tracking-[0.16em]`,r.header),children:[(0,I.jsx)(`span`,{className:R(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,I.jsx)(`span`,{children:e})]}),(0,I.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,I.jsx)(`pre`,{className:R(`w-full max-w-full min-w-0 max-h-64 overflow-x-auto overflow-y-auto px-3 py-2.5 font-mono text-[12px] leading-relaxed whitespace-pre custom-scrollbar-amber`,r.body),children:n})})]})}function $h({card:e}){let t=Xh(e.output,e.outputData),n=e.statusTone===`running`,r=!!(e.summary?.trim()||t.trim().length>0),{expanded:i,onToggle:a}=Zh({canExpand:t.trim().length>0||n,isRunning:n,expandOnError:r,statusTone:e.statusTone}),o=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``);return(0,I.jsxs)(fh,{children:[(0,I.jsx)(_h,{card:e,icon:yn,expanded:i,canExpand:t.trim().length>0||n,onToggle:a}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`px-3 pb-2 font-mono w-full max-h-48 overflow-y-auto custom-scrollbar-amber min-h-0 text-[12px]`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-2 leading-relaxed`,children:[(0,I.jsx)(`span`,{className:`text-amber-500/50 font-medium shrink-0 select-none mt-[1px]`,children:`$`}),(0,I.jsx)(`div`,{className:`flex-1 min-w-0`,children:o?(0,I.jsxs)(`div`,{className:`text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block`,children:[o,n&&!t&&(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]}):(0,I.jsx)(`div`,{className:`h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2`})})]})}),t&&(0,I.jsx)(ph,{children:(0,I.jsxs)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed px-0`,children:[t,n&&(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]})})]})]})}function eg({card:e}){let t=e.output?.trim()??``,n=e.statusTone===`running`,r=!!e.fileOperation?.blocks.length,i=r||!!t,a=e.fileOperation?.blocks??[],o=a.reduce((e,t)=>e+t.lines.length,0),s=a.reduce((e,t)=>t.rawText?e+t.rawText.length:e+t.lines.reduce((e,t)=>e+t.text.length+1,0),0),c=!(n&&e.toolName===`write_file`&&(o>24||s>1200)),{expanded:l,onToggle:u}=Zh({canExpand:i||n,isRunning:n,autoExpandWhileRunning:c,expandOnError:i,statusTone:e.statusTone});return(0,I.jsxs)(fh,{children:[(0,I.jsx)(_h,{card:e,icon:e.toolName===`edit_file`||e.toolName===`write_file`||e.toolName===`apply_patch`||e.toolName===`file_change`?tn:an,expanded:l,canExpand:i||n,hideSummary:l&&r,onToggle:u}),l&&i&&(0,I.jsx)(ph,{className:`border-t border-amber-200/20 bg-transparent px-0 pt-0 pb-0`,children:(0,I.jsx)(Hh,{card:e})})]})}function tg({card:e}){let t=e.statusTone===`running`,n=e.output?.trim()??``,{expanded:r,onToggle:i}=Zh({canExpand:!!n||t,isRunning:t,statusTone:e.statusTone});return(0,I.jsxs)(fh,{children:[(0,I.jsx)(_h,{card:e,icon:Je,expanded:r,canExpand:!!n||t,onToggle:i}),r&&n&&(0,I.jsx)(ph,{children:(0,I.jsx)(`pre`,{className:`font-mono text-[12px] text-amber-950/70 whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber leading-relaxed`,children:n})})]})}function ng({card:e,onToolAction:t,renderToolAgent:n}){let r=e.input?.trim()??``,i=e.output?.trim()??``,a=e.statusTone===`running`,o=r.length>0,s=i.length>0,c=o||s,l=e.inputLabel?.trim()||`Input`,u=e.outputLabel?.trim()||`Output`,{expanded:d,onToggle:f}=Zh({canExpand:c||a,isRunning:a,statusTone:e.statusTone});return(0,I.jsxs)(fh,{children:[(0,I.jsx)(_h,{card:e,icon:Se,expanded:d,canExpand:c||a,actionSlot:e.agentId||e.action&&t?(0,I.jsxs)(I.Fragment,{children:[e.agentId&&n?n(e.agentId):null,e.action&&t?(0,I.jsx)(vh,{action:e.action,onAction:t}):null]}):void 0,onToggle:f}),d&&c&&(0,I.jsxs)(ph,{className:`bg-transparent px-2.5 py-2.5`,children:[o&&(0,I.jsx)(Qh,{label:l,tone:`input`,children:r}),o&&s&&(0,I.jsx)(`div`,{className:`h-2`}),s&&(0,I.jsx)(Qh,{label:u,tone:e.statusTone===`error`?`error`:`output`,children:i})]})]})}function rg(e){let t=e.toLowerCase();return t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t.includes(`run_`)}function ig(e){let t=e.toLowerCase();return t===`read_file`||t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function ag(e){let t=e.toLowerCase();return t===`grep_search`||t===`find_files`||t.includes(`search`)}function og({card:e,onToolAction:t,renderToolAgent:n}){return rg(e.toolName)?(0,I.jsx)($h,{card:e}):ig(e.toolName)?(0,I.jsx)(eg,{card:e}):ag(e.toolName)?(0,I.jsx)(tg,{card:e}):(0,I.jsx)(ng,{card:e,onToolAction:t,renderToolAgent:n})}function sg(e){return(0,I.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600`,children:[(0,I.jsxs)(`div`,{className:`font-semibold text-gray-700`,children:[e.label,`: `,e.rawType]}),e.text?(0,I.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500`,children:e.text}):null]})}var cg=(0,P.memo)(function(e){let{message:t,texts:n,onToolAction:r,renderToolAgent:i}=e,{role:a}=t,o=a===`user`,s=t.status===`pending`||t.status===`streaming`;return(0,I.jsx)(`div`,{className:R(`inline-block w-fit max-w-full rounded-2xl border px-4 shadow-sm`,o?`border-primary bg-primary py-3 text-white`:a===`assistant`?`border-gray-200 bg-white pb-3 pt-4 text-gray-900`:`border-orange-200/80 bg-orange-50/70 py-3 text-gray-900`),children:(0,I.jsx)(`div`,{className:`space-y-2`,children:t.parts.map((e,c)=>{let{type:l}=e;return l===`markdown`?(0,I.jsx)(Wm,{text:e.text,role:a,texts:n},`markdown-${c}`):l===`inline-content`?(0,I.jsx)(Jm,{segments:e.segments,role:a,texts:n},`inline-content-${c}`):l===`reasoning`?(0,I.jsx)(dh,{label:e.label,text:e.text,isUser:o,isInProgress:s&&c===t.parts.length-1},`reasoning-${c}`):l===`tool-card`?(0,I.jsx)(`div`,{className:`mt-0.5`,children:(0,I.jsx)(og,{card:e.card,onToolAction:r,renderToolAgent:i})},`tool-${c}`):l===`file`?(0,I.jsx)(lh,{file:e.file,isUser:o},`file-${c}`):l===`unknown`?(0,I.jsx)(sg,{label:e.label,rawType:e.rawType,text:e.text},`unknown-${c}`):null})})})});function lg(e){return(0,I.jsxs)(`div`,{className:R(`px-1 text-[11px] leading-4 text-gray-400`,e.isUser?`text-right`:`text-left`),children:[e.roleLabel,` · `,e.timestampLabel]})}function ug({message:e,texts:t}){let n=(0,P.useMemo)(()=>e.parts.map(e=>e.type===`markdown`||e.type===`unknown`?e.text:``).filter(e=>!!e&&e.trim().length>0).join(`
|
|
35
|
+
|
|
36
|
+
`),[e.parts]),{copied:r,copy:i}=Nm({text:n});return n?(0,I.jsx)(`button`,{type:`button`,onClick:()=>void i(),className:`text-gray-400 hover:text-gray-600 transition-colors p-1 rounded-md hover:bg-gray-100 flex items-center justify-center`,"aria-label":r?t.copiedMessageLabel:t.copyMessageLabel,title:r?t.copiedMessageLabel:t.copyMessageLabel,children:r?(0,I.jsx)(re,{className:`h-3.5 w-3.5`}):(0,I.jsx)(nn,{className:`h-3.5 w-3.5`})}):null}var dg=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function fg(e){let t=e.trim();return t?t.replace(dg,``).trim().length>0:!1}function pg(e){return e.parts.some(e=>e.type===`markdown`||e.type===`reasoning`?fg(e.text):!0)}function mg(){return(0,I.jsx)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-[11px] text-gray-400`,children:(0,I.jsxs)(`div`,{className:`flex space-x-1 items-center h-full`,children:[(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}),(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:200ms]`}),(0,I.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:400ms]`})]})})}function hg(e){let t=e.messages.filter(pg),n=t.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`));return(0,I.jsxs)(`div`,{className:R(`space-y-5`,e.className),children:[t.map(t=>{let n=t.role===`user`,r=!n&&(t.status===`streaming`||t.status===`pending`);return(0,I.jsxs)(`div`,{className:R(`flex gap-3`,n?`justify-end`:`justify-start`),children:[n?null:(0,I.jsx)(Zi,{role:t.role}),(0,I.jsxs)(`div`,{className:R(`w-fit max-w-[92%] space-y-2`,n&&`flex flex-col items-end`),children:[(0,I.jsx)(cg,{message:t,texts:e.texts,onToolAction:e.onToolAction,renderToolAgent:e.renderToolAgent}),(0,I.jsx)(`div`,{className:R(`flex items-center gap-2`,n&&`justify-end`),children:r?(0,I.jsx)(mg,{}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(lg,{roleLabel:t.roleLabel,timestampLabel:t.timestampLabel,isUser:n}),n?null:(0,I.jsx)(ug,{message:t,texts:e.texts})]})})]}),n?(0,I.jsx)(Zi,{role:t.role}):null]},t.id)}),e.isSending&&!n?(0,I.jsxs)(`div`,{className:`flex justify-start gap-3`,children:[(0,I.jsx)(Zi,{role:`assistant`}),(0,I.jsx)(`div`,{className:`rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm text-gray-500 shadow-sm`,children:e.texts.typingLabel})]}):null]})}var gg=`$`;function _g(e){return`${gg}${e}`}function vg(e,t){if(t.length===0)return;let n=e[e.length-1];if(n?.type===`text`){n.text+=t;return}e.push({type:`text`,text:t})}function yg(){return hi()}function bg(e){return gi(e)}function xg(e){return yi(e)}function Sg(e){return bi(e,`skill`)}function Cg(e){return bi(e,`file`)}function wg(e,t,n){let r=new Set(t),i=Di(e,e=>e.tokenKind===`skill`&&!r.has(e.tokenKey)),a=bi(i,`skill`),o=new Map(n.map(e=>[e.ref,e])),s=t.filter(e=>!a.includes(e)).map(e=>pi({tokenKind:`skill`,tokenKey:e,label:o.get(e)?.name||e}));return s.length===0?i:_i([...i,...s])}function Tg(e,t){let n=new Set(t.map(e=>e.id));return Di(e,e=>e.tokenKind===`file`&&!n.has(e.tokenKey))}function Eg(e,t){let n=new Set(Cg(e));return t.filter(e=>n.has(e.id))}function Dg(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){if(t.type===`text`){vg(r,t.text);continue}if(t.tokenKind===`skill`){vg(r,_g(t.tokenKey));continue}if(t.tokenKind!==`file`)continue;let e=n.get(t.tokenKey);e&&r.push({type:`file`,name:e.name,mimeType:e.mimeType,...e.assetUri?{assetUri:e.assetUri}:{},...e.url?{url:e.url}:{},...e.contentBase64?{contentBase64:e.contentBase64}:{},sizeBytes:e.sizeBytes})}return r}var Og={isProviderStateResolved:!1,composerNodes:yg(),attachments:[],draft:``,pendingSessionType:`native`,pendingProjectRoot:null,pendingProjectRootSessionKey:null,defaultSessionType:`native`,canStopGeneration:!1,stopDisabledReason:null,sendError:null,isSending:!1,modelOptions:[],selectedModel:``,selectedThinkingLevel:null,sessionTypeOptions:[],selectedSessionType:void 0,stopSupported:!1,stopReason:void 0,canEditSessionType:!1,sessionTypeUnavailable:!1,skillRecords:[],isSkillsLoading:!1,selectedSkills:[]},Q=S(e=>({snapshot:Og,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));async function kg(){let e=await h.get(`/api/agents`);if(!e.ok)throw Error(e.error.message);return e.data}async function Ag(e){let t=await h.post(`/api/agents`,e);if(!t.ok)throw Error(t.error.message);return t.data}async function jg(e,t){let n=await h.put(`/api/agents/${encodeURIComponent(e)}`,t);if(!n.ok)throw Error(n.error.message);return n.data}async function Mg(e){let t=await h.delete(`/api/agents/${encodeURIComponent(e)}`);if(!t.ok)throw Error(t.error.message);return t.data}function Ng(){return f({queryKey:[`agents`],queryFn:kg,staleTime:3e4})}function Pg(){let e=_();return C({mutationFn:({data:e})=>Ag(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),p.success(o(`configSavedApplied`))},onError:e=>{p.error(o(`configSaveFailed`)+`: `+e.message)}})}function Fg(){let e=_();return C({mutationFn:({agentId:e,data:t})=>jg(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),p.success(o(`configSavedApplied`))},onError:e=>{p.error(o(`configSaveFailed`)+`: `+e.message)}})}function Ig(){let e=_();return C({mutationFn:({agentId:e})=>Mg(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`agents`]}),e.invalidateQueries({queryKey:[`config`]}),p.success(o(`configSavedApplied`))},onError:e=>{p.error(o(`configSaveFailed`)+`: `+e.message)}})}function Lg(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,a=[],s=[],c=[],l=[];for(let t of e){let{session:e}=t,o=new Date(e.updatedAt).getTime();o>=n?a.push(t):o>=r?s.push(t):o>=i?c.push(t):l.push(t)}let u=[];return a.length>0&&u.push({label:o(`chatSidebarToday`),items:a}),s.length>0&&u.push({label:o(`chatSidebarYesterday`),items:s}),c.length>0&&u.push({label:o(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:o(`chatSidebarOlder`),items:l}),u}function Rg(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}function zg(e){return e.ready===!1?e.reasonMessage?.trim()||o(`statusSetup`):o(`statusReady`)}var Bg=[{target:`/cron`,label:()=>o(`chatSidebarScheduledTasks`),icon:ut},{target:`/skills`,label:()=>o(`chatSidebarSkills`),icon:bt},{target:`/agents`,label:()=>o(`agentsPageTitle`),icon:yt}];function Vg(){let e=Tr(),n=Qe(),[r,i]=(0,P.useState)(!1),[a,s]=(0,P.useState)(null),[c,l]=(0,P.useState)(``),[d,f]=(0,P.useState)(null),p=Q(e=>e.snapshot),h=L(e=>e.snapshot),g=Pt(e=>e.connectionStatus),_=Ng(),{isLoading:v,items:y}=Sr(),{language:b,setLanguage:x}=jt(),{theme:S,setTheme:C}=Tt(),w=vr(),E=o(ot.find(e=>e.value===S)?.labelKey??`themeWarm`),D=t.find(e=>e.value===b)?.label??b,O=(0,P.useMemo)(()=>new Map((_.data?.agents??[]).map(e=>[e.id,e])),[_.data?.agents]),ee=(0,P.useMemo)(()=>Lg(y),[y]),te=p.defaultSessionType||`native`,k=(0,P.useMemo)(()=>p.sessionTypeOptions.filter(e=>e.value!==te),[te,p.sessionTypeOptions]),A=e=>{b!==e&&(x(e),window.location.reload())},j=e=>{s(e.key),l(e.label?.trim()??``)},ne=()=>{s(null),l(``),f(null)},re=async e=>{let t=c.trim();if(t===(e.label?.trim()??``)){ne();return}f(e.key);try{await w({sessionKey:e.key,label:t||null}),ne()}catch{f(null)}};return(0,I.jsxs)(`aside`,{className:`w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60`,children:[(0,I.jsx)(`div`,{className:`px-5 pt-5 pb-3`,children:(0,I.jsx)(Nt,{className:`flex items-center gap-2.5 min-w-0`,suffix:(0,I.jsx)(tr,{status:g})})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(m,{variant:`primary`,className:u(`min-w-0 rounded-xl`,k.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{i(!1),e.chatSessionListManager.createSession(te)},children:[(0,I.jsx)(Fe,{className:`h-4 w-4 mr-2`}),o(`chatSidebarNewTask`)]}),k.length>0?(0,I.jsxs)(Gt,{open:r,onOpenChange:i,children:[(0,I.jsx)(Ut,{asChild:!0,children:(0,I.jsx)(m,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":o(`chatSessionTypeLabel`),children:(0,I.jsx)(T,{className:`h-4 w-4`})})}),(0,I.jsxs)(Vt,{align:`end`,className:`w-64 p-2`,children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:o(`chatSessionTypeLabel`)}),(0,I.jsx)(`div`,{className:`mt-1 space-y-1`,children:k.map(t=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>{e.chatSessionListManager.createSession(t.value),i(!1)},className:`w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-gray-100`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(`div`,{className:`text-[13px] font-medium text-gray-900`,children:t.label}),(0,I.jsx)(`span`,{className:u(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold`,t.ready===!1?`bg-amber-100 text-amber-800`:`bg-emerald-100 text-emerald-700`),children:t.ready===!1?o(`statusSetup`):o(`statusReady`)})]}),(0,I.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500`,children:zg(t)})]},t.value))})]})]}):null]})}),(0,I.jsx)(`div`,{className:`px-4 pb-3`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Je,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,I.jsx)(lt,{value:h.query,onChange:t=>e.chatSessionListManager.setQuery(t.target.value),placeholder:o(`chatSidebarSearchPlaceholder`),className:`pl-8 h-9 rounded-lg text-xs`})]})}),(0,I.jsx)(`div`,{className:`px-3 pb-2`,children:(0,I.jsx)(`ul`,{className:`space-y-0.5`,children:Bg.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(dt,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),(0,I.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:v?(0,I.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:o(`sessionsLoading`)}):ee.length===0?(0,I.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,I.jsx)(dn,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,I.jsx)(`div`,{className:`text-xs text-gray-500`,children:o(`sessionsEmpty`)})]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:ee.map(t=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:t.label}),(0,I.jsx)(`div`,{className:`space-y-0.5`,children:t.items.map(({session:t,runStatus:n})=>{let r=h.selectedSessionKey===t.key,i=pr(t,p.sessionTypeOptions),o=a===t.key,s=d===t.key;return(0,I.jsx)(gr,{session:t,active:r,runStatus:n,context:i,title:Rg(t),agentId:t.agentId??null,agentLabel:t.agentId?O.get(t.agentId)?.displayName??t.agentId:null,agentAvatarUrl:t.agentId?O.get(t.agentId)?.avatarUrl??null:null,isEditing:o,draftLabel:c,isSaving:s,onSelect:()=>e.chatSessionListManager.selectSession(t.key),onStartEditing:()=>j(t),onDraftLabelChange:l,onSave:()=>re(t),onCancel:ne},t.key)})})]},t.label))})}),(0,I.jsxs)(`div`,{className:`px-3 py-3 border-t border-gray-200/60 space-y-0.5`,children:[(0,I.jsx)(dt,{to:`/settings`,label:o(`settings`),icon:wt,density:`compact`}),(0,I.jsx)(xt,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:he,label:o(`docBrowserHelp`),density:`compact`}),(0,I.jsx)(Dt,{value:S,onValueChange:e=>C(e),icon:It,label:o(`theme`),valueLabel:E,density:`compact`,children:ot.map(e=>(0,I.jsx)(ce,{value:e.value,className:`text-xs`,children:o(e.labelKey)},e.value))}),(0,I.jsx)(Dt,{value:b,onValueChange:e=>A(e),icon:At,label:o(`language`),valueLabel:D,density:`compact`,children:t.map(e=>(0,I.jsx)(ce,{value:e.value,className:`text-xs`,children:e.label},e.value))})]})]})}function Hg(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e.error;if(!n||typeof n!=`object`||Array.isArray(n))return t;let r=n.message;return typeof r==`string`&&r.trim().length>0?r:t}async function Ug(e){let t=new FormData;for(let n of e)t.append(`files`,n);let n=await fetch(`${d}/api/ncp/assets`,{method:`POST`,body:t,credentials:`include`}),r=await n.json();if(!n.ok||!r.ok)throw Error(Hg(r,`Failed to put assets.`));return r.data.assets.map(e=>({id:e.id,name:e.name,mimeType:e.mimeType,sizeBytes:e.sizeBytes,assetUri:e.assetUri,url:e.url}))}var Wg={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function Gg(e){let t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function Kg(e){return(e??``).trim().toLowerCase()}function qg(e,t){if(!e||!t)return!1;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function Jg(e,t){let n=Kg(t);if(!n)return Wg.fallback;let r=Kg(e.key),i=Kg(e.label||e.key),a=Kg(`${e.descriptionZh??``} ${e.description??``}`),o=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Wg.exactSpec:i===n?Wg.exactLabel:r.startsWith(n)?Wg.prefixSpec:i.startsWith(n)?Wg.prefixLabel:o.some(e=>e.startsWith(n))?Wg.prefixToken:r.includes(n)?Wg.containsSpec:i.includes(n)?Wg.containsLabel:a.includes(n)?Wg.containsDescription:qg(n,i)||qg(n,r)?Wg.subsequence:0}function Yg(e){return e>=Wg.exactLabel?4:e>=Wg.prefixToken?3:e>=Wg.containsLabel?2:e>0?1:0}function Xg(e){return new Map(e.map((e,t)=>[e,t]))}function Zg(e,t){let n=Xg(t),r=[],i=[];for(let t of e){if(n.has(t.key)){r.push(t);continue}i.push(t)}return r.sort((e,t)=>(n.get(e.key)??1/0)-(n.get(t.key)??1/0)),[...r,...i]}function Qg(e,t,n,r=[]){let i=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),a=Xg(r);return e.map((e,n)=>({record:e,order:n,score:Jg(e,t)})).filter(e=>e.score>0).sort((e,t)=>{let n=Yg(e.score),r=Yg(t.score);if(r!==n)return r-n;let o=a.get(e.record.key)??1/0,s=a.get(t.record.key)??1/0;if(o!==s)return o-s;if(t.score!==e.score)return t.score-e.score;let c=(e.record.label||e.record.key).trim(),l=(t.record.label||t.record.key).trim(),u=i.compare(c,l);return u===0?e.order-t.order:u}).map(({record:e})=>({key:`skill:${e.key}`,title:e.label||e.key,subtitle:n.slashSkillSubtitle,description:(e.descriptionZh??e.description??``).trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${e.key}`,...e.scopeLabel?[`${n.slashSkillScopeLabel}: ${e.scopeLabel}`]:[]],value:e.key}))}function $g(e){return e.map(e=>({key:e.key,label:e.label,description:e.descriptionZh||e.description||``,badgeLabel:e.badgeLabel}))}function e_(e){let t=Zg(e.skillRecords,e.recentSkillValues??[]),n=new Set(e.groupedRecentSkillValues??[]),r=$g(t.filter(e=>n.has(e.key))),i=$g(t.filter(e=>!n.has(e.key)));return{title:e.texts.title,searchPlaceholder:e.texts.searchPlaceholder,emptyLabel:e.texts.emptyLabel,loadingLabel:e.texts.loadingLabel,isLoading:e.isLoading,manageLabel:e.texts.manageLabel,manageHref:`/marketplace/skills`,options:$g(t),groups:r.length>0?[{key:`recent-skills`,label:e.texts.recentSkillsLabel,options:r},{key:`all-skills`,label:e.texts.allSkillsLabel,options:i}].filter(e=>e.options.length>0):void 0,selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function t_(e){return!e.isModelOptionsLoading&&!e.isModelOptionsEmpty?null:e.isModelOptionsLoading?{tone:`neutral`,loading:!0}:{tone:`warning`,text:e.texts.noModelOptionsLabel,actionLabel:e.texts.configureProviderLabel,onAction:e.onGoToProviders}}function n_(e){let t=e.modelOptions.find(t=>t.value===e.selectedModel),n=e.modelOptions[0],r=t??n,i=e.hasModelOptions?r?.value:void 0,a=new Set(e.recentModelValues??[]),o=new Map(e.modelOptions.map(e=>[e.value,e])),s=(e.recentModelValues??[]).map(e=>o.get(e)).filter(e=>!!e),c=e.modelOptions.filter(e=>!a.has(e.value)),l=s.length>0?[{key:`recent-models`,label:e.texts.recentModelsLabel,options:s.map(e=>({value:e.value,label:Gg(e)}))},{key:`all-models`,label:e.texts.allModelsLabel,options:c.map(e=>({value:e.value,label:Gg(e)}))}].filter(e=>e.options.length>0):void 0;return{key:`model`,value:i,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?Gg(r):void 0,icon:`sparkles`,options:e.modelOptions.map(e=>({value:e.value,label:Gg(e)})),groups:l,disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function r_(e){let t=[];for(let n of[`off`,...e])t.includes(n)||t.push(n);return t}function i_(e){if(e.supportedLevels.length===0)return null;let t=r_(e.supportedLevels),n=t.includes(`off`)?`off`:t[0],r=e.selectedThinkingLevel&&t.includes(e.selectedThinkingLevel)&&e.selectedThinkingLevel||e.defaultThinkingLevel&&t.includes(e.defaultThinkingLevel)&&e.defaultThinkingLevel||n;return{key:`thinking`,value:r,placeholder:e.texts.thinkingLabels[r],selectedLabel:e.texts.thinkingLabels[r],icon:`brain`,options:t.map(t=>({value:t,label:e.texts.thinkingLabels[t]})),onValueChange:t=>e.onValueChange(t)}}var a_=class{constructor(e){this.options=e}read(){let e=this.getStorage();if(!e)return[];try{return this.normalizeList(JSON.parse(e.getItem(this.options.storageKey)??`[]`))}catch{return[]}}remember(e){let t=this.normalizeValue(e);if(!t)return this.read();let n=[t,...this.read().filter(e=>e!==t)].slice(0,this.options.limit);return this.write(n),n}resolveVisible(e){let t=this.normalizeList(e.availableValues,1/0);if(t.length<=e.minAvailableCount)return[];let n=new Set(t),r=[],i=Math.max(1,e.limit??this.options.limit);for(let e of this.read())if(!(!n.has(e)||r.includes(e))&&(r.push(e),r.length>=i))break;return r}write(e){let t=this.getStorage();if(t)try{t.setItem(this.options.storageKey,JSON.stringify(this.normalizeList(e)))}catch{}}getStorage(){return Object.prototype.hasOwnProperty.call(this.options,`storage`)?this.options.storage??null:typeof window>`u`?null:window.localStorage}normalizeList(e,t=this.options.limit){if(!Array.isArray(e))return[];let n=[];for(let r of e){let e=this.normalizeValue(r);if(!(!e||n.includes(e))&&(n.push(e),n.length>=t))break}return n}normalizeValue(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}},o_=new a_({storageKey:`nextclaw.chat.recent-models`,limit:3}),s_=new a_({storageKey:`nextclaw.chat.recent-skills`,limit:5});function c_(){return{off:o(`chatThinkingLevelOff`),minimal:o(`chatThinkingLevelMinimal`),low:o(`chatThinkingLevelLow`),medium:o(`chatThinkingLevelMedium`),high:o(`chatThinkingLevelHigh`),adaptive:o(`chatThinkingLevelAdaptive`),xhigh:o(`chatThinkingLevelXhigh`)}}function l_(e,t){return e.map(e=>({key:e.ref,label:e.name,scopeLabel:t[e.scope],description:e.description,descriptionZh:e.descriptionZh,badgeLabel:t[e.scope]}))}function u_(e){return e.map(e=>({value:e.value,modelLabel:e.modelLabel,providerLabel:e.providerLabel,thinkingCapability:e.thinkingCapability?{supported:e.thinkingCapability.supported,default:e.thinkingCapability.default??null}:null}))}function d_(){let e=Tr(),{language:t}=jt(),n=Q(e=>e.snapshot),[r,i]=(0,P.useState)(null),a=(0,P.useRef)(null),s=(0,P.useRef)(null),c=(0,P.useMemo)(()=>({builtin:o(`chatSkillScopeBuiltin`),project:o(`chatSkillScopeProject`),workspace:o(`chatSkillScopeWorkspace`)}),[t]),l=(0,P.useMemo)(()=>({slashSkillSubtitle:o(`chatSlashTypeSkill`),slashSkillSpecLabel:o(`chatSlashSkillSpec`),slashSkillScopeLabel:o(`chatSlashSkillScope`),noSkillDescription:o(`chatSkillsPickerNoDescription`)}),[t]),u=(0,P.useMemo)(()=>l_(n.skillRecords,c),[n.skillRecords,c]),d=(0,P.useMemo)(()=>u_(n.modelOptions),[n.modelOptions]),f=o_.resolveVisible({availableValues:d.map(e=>e.value),minAvailableCount:5}),m=s_.resolveVisible({availableValues:u.map(e=>e.key),minAvailableCount:0}),h=s_.resolveVisible({availableValues:u.map(e=>e.key),minAvailableCount:4}),g=d.length>0,_=!n.isProviderStateResolved&&!g,v=n.isProviderStateResolved&&!g,y=(_||v)&&!n.isSending||n.sessionTypeUnavailable,b=typeof e.chatInputManager.addAttachments==`function`,x=_?``:o(g?`chatInputPlaceholder`:`chatModelNoOptions`),S=o(`chatPickerRecentModels`),C=o(`chatPickerAllModels`),w=o(`chatPickerRecent`),T=o(`chatPickerAllSkills`),E=(0,P.useMemo)(()=>Qg(u,r??``,l,m),[r,u,l,m]),D=d.find(e=>e.value===n.selectedModel)?.thinkingCapability,O=D?.supported??[],ee=n.stopDisabledReason===`__preparing__`?o(`chatStopPreparing`):n.stopDisabledReason?.trim()||o(`chatStopUnavailable`),te=(0,P.useCallback)(e=>{if(e===`unsupported-type`){p.error(o(`chatInputAttachmentUnsupported`));return}if(e===`too-large`){p.error(o(`chatInputAttachmentTooLarge`).replace(`{maxMb}`,String(Jn/(1024*1024))));return}p.error(o(`chatInputAttachmentReadFailed`))},[]),k=(0,P.useCallback)(async t=>{if(!b||t.length===0)return;let n=await $n(t,{uploadBatch:Ug});if(n.attachments.length>0){let t=e.chatInputManager.addAttachments?.(n.attachments)??[];t.length>0&&a.current?.insertFileTokens(t.map(e=>({tokenKey:e.id,label:e.name})))}n.rejected.length>0&&te(n.rejected[0].reason)},[b,e.chatInputManager,te]),A=[n_({modelOptions:d,recentModelValues:f,selectedModel:n.selectedModel,isModelOptionsLoading:_,hasModelOptions:g,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:o(`chatSelectModel`),modelNoOptionsLabel:o(`chatModelNoOptions`),recentModelsLabel:S,allModelsLabel:C}}),i_({supportedLevels:O,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:D?.default??null,onValueChange:t=>e.chatInputManager.selectThinkingLevel(t),texts:{thinkingLabels:c_()}})].filter(e=>e!==null),j=e_({skillRecords:u,recentSkillValues:m,groupedRecentSkillValues:h,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:o(`chatSkillsPickerTitle`),searchPlaceholder:o(`chatSkillsPickerSearchPlaceholder`),emptyLabel:o(`chatSkillsPickerEmpty`),loadingLabel:o(`sessionsLoading`),manageLabel:o(`chatSkillsPickerManage`),recentSkillsLabel:w,allSkillsLabel:T}}),ne=Sg(n.composerNodes).length,re=n.draft.trim().length>0||n.attachments.length>0||ne>0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Xi,{ref:a,composer:{nodes:n.composerNodes,placeholder:x,disabled:y,onNodesChange:e.chatInputManager.setComposerNodes,...b?{onFilesAdd:k}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:E,onSelectItem:t=>{t.value&&e.chatInputManager.rememberSkillSelection(t.value)},texts:{slashLoadingLabel:o(`chatSlashLoading`),slashSectionLabel:o(`chatSlashSectionSkills`),slashEmptyLabel:o(`chatSlashNoResult`),slashHintLabel:o(`chatSlashHint`),slashSkillHintLabel:o(`chatSlashSkillHint`)}},hint:t_({isModelOptionsLoading:_,isModelOptionsEmpty:v,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:o(`chatModelNoOptions`),configureProviderLabel:o(`chatGoConfigureProvider`)}}),toolbar:{selects:A,accessories:[{key:`attach`,label:o(`chatInputAttach`),icon:`paperclip`,iconOnly:!0,disabled:!b||y||n.isSending,...b?{onClick:()=>s.current?.click()}:{tooltip:o(`chatInputAttachComingSoon`)}}],skillPicker:j,actions:{sendError:n.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:!re||!g||n.sessionTypeUnavailable,stopDisabled:!n.canStopGeneration,stopHint:ee,sendButtonLabel:o(`chatSend`),stopButtonLabel:o(`chatStop`),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),b?(0,I.jsx)(`input`,{ref:s,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=Array.from(e.target.files??[]);e.currentTarget.value=``,await k(t)}}):null]})}var f_=[`cmd`,`command`,`query`,`q`,`path`,`url`,`to`,`channel`,`agentId`,`sessionKey`];function p_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m_(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}\n…`}function h_(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;try{return m_(JSON.stringify(e,null,2))}catch{return String(e)}}function g_(e){if(p_(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return null;try{let e=JSON.parse(t);return p_(e)?e:null}catch{return null}}function __(e){let t=g_(e);if(!t){let t=h_(e).trim();return t?m_(t,120):void 0}let n=[];for(let e of f_){let r=t[e];if(typeof r==`string`&&r.trim()?n.push(`${e}: ${r.trim()}`):(typeof r==`number`||typeof r==`boolean`)&&n.push(`${e}: ${String(r)}`),n.length>=2)break}return n.length>0?n.join(` · `):m_(h_(t),140)}var v_=`ui_inline_tokens`,y_=`$`;function b_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function x_(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function S_(e){let t=new Set,n=[];for(let r of e){let e=`${r.kind}:${r.key}:${r.rawText}`;t.has(e)||(t.add(e),n.push(r))}return n}function C_(e){let t=[];for(let n of e)n.type!==`token`||n.tokenKind!==`skill`||t.push({kind:`skill`,key:n.tokenKey,label:n.label,rawText:`${y_}${n.tokenKey}`});return S_(t)}function w_(e){let t=e?.[v_];if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!b_(e))continue;let t=x_(e.kind),r=x_(e.key),i=x_(e.rawText);!t||!r||!i||n.push({kind:t,key:r,rawText:i,label:x_(e.label)??r})}return S_(n)}function T_(e,t){if(e.length===0||t.length===0)return e.length===0?[]:[{type:`text`,text:e}];let n=[...t].sort((e,t)=>t.rawText.length-e.rawText.length),r=[],i=0;for(;i<e.length;){let t=null;for(let r of n)if(e.startsWith(r.rawText,i)){t=r;break}if(!t){let t=i+1;for(;t<e.length&&!n.some(n=>e.startsWith(n.rawText,t));)t+=1;r.push({type:`text`,text:e.slice(i,t)}),i=t;continue}r.push({type:`token`,token:t}),i+=t.rawText.length}return r}var E_=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function D_(e){let t=e.trim();return t&&t.replace(E_,``).trim()?t:null}function O_(e){return e.replace(E_,``).trim().length>0}function k_(e,t){let n=T_(e,t);if(n.length===0)return null;let r=[],i=!1;for(let e of n){if(e.type===`token`){i=!0,r.push({type:`token`,token:{kind:e.token.kind,key:e.token.key,label:e.token.label,rawText:e.token.rawText}});continue}e.text.length!==0&&(O_(e.text)&&(i=!0),r.push({type:`markdown`,text:e.text}))}return i?r:null}function A_(e,t){let n=k_(e.text,t);if(n&&n.some(e=>e.type===`token`))return{type:`inline-content`,segments:n};let r=D_(e.text);return r?{type:`markdown`,text:r}:null}function j_(e){return D_(e)}function M_(e){return typeof e==`object`&&!!e}function N_(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function P_(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function F_(e){let t=N_(e);return M_(t)?P_(t.agentId):null}function I_(e){return F_(e.parsedArgs)??F_(e.args)??F_(e.result)}var L_=12e3,R_=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function z_(e){let t=e.replace(/\r\n/g,`
|
|
37
|
+
`).replace(/\r/g,`
|
|
38
|
+
`);return t===``?[]:t.split(`
|
|
39
|
+
`)}function B_(e){return typeof e==`number`?e+1:void 0}function V_(e){return{kind:e.kind,text:e.text,...typeof e.oldLineNumber==`number`?{oldLineNumber:e.oldLineNumber}:{},...typeof e.newLineNumber==`number`?{newLineNumber:e.newLineNumber}:{}}}function H_(e){let t=R_.exec(e);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function U_(e){return z_(e.text).map((t,n)=>e.kind===`add`?V_({kind:`add`,text:t,newLineNumber:e.newStartLine+n}):V_({kind:`context`,text:t,oldLineNumber:e.oldStartLine+n,newLineNumber:e.newStartLine+n}))}function W_(e){let t=e.oldStartLine,n=e.newStartLine;return[...e.beforeLines.map(e=>{let n=V_({kind:`remove`,text:e,oldLineNumber:t});return t=B_(t),n}),...e.afterLines.map(e=>{let t=V_({kind:`add`,text:e,newLineNumber:n});return n=B_(n),t})]}function G_(e){let t=Array.from({length:e.beforeLines.length+1},()=>Array.from({length:e.afterLines.length+1},()=>0));for(let n=e.beforeLines.length-1;n>=0;--n)for(let r=e.afterLines.length-1;r>=0;--r)t[n][r]=e.beforeLines[n]===e.afterLines[r]?(t[n+1][r+1]??0)+1:Math.max(t[n+1][r]??0,t[n][r+1]??0);return t}function K_(e){for(let t=e.beforeIndex;t<e.beforeLines.length;t+=1)e.lines.push(V_({kind:`remove`,text:e.beforeLines[t]??``,oldLineNumber:e.oldLineNumber})),e.oldLineNumber=B_(e.oldLineNumber);for(let t=e.afterIndex;t<e.afterLines.length;t+=1)e.lines.push(V_({kind:`add`,text:e.afterLines[t]??``,newLineNumber:e.newLineNumber})),e.newLineNumber=B_(e.newLineNumber)}function q_(e){let t=z_(e.beforeText),n=z_(e.afterText);if(t.length*n.length>L_)return W_({beforeLines:t,afterLines:n,oldStartLine:e.oldStartLine,newStartLine:e.newStartLine});let r=G_({beforeLines:t,afterLines:n}),i=[],a=0,o=0,s=e.oldStartLine,c=e.newStartLine;for(;a<t.length&&o<n.length;){if(t[a]===n[o]){i.push(V_({kind:`context`,text:t[a]??``,oldLineNumber:s,newLineNumber:c})),a+=1,o+=1,s=B_(s),c=B_(c);continue}if((r[a+1][o]??0)>=(r[a][o+1]??0)){i.push(V_({kind:`remove`,text:t[a]??``,oldLineNumber:s})),a+=1,s=B_(s);continue}i.push(V_({kind:`add`,text:n[o]??``,newLineNumber:c})),o+=1,c=B_(c)}return K_({lines:i,beforeLines:t,afterLines:n,beforeIndex:a,afterIndex:o,oldLineNumber:s,newLineNumber:c}),i}var J_=120;function Y_(e){let t=e.lines.filter(e=>e.kind===`add`).length,n=e.lines.filter(e=>e.kind===`remove`).length,r=[],i=e.operation?.trim().toLowerCase()??``;return i&&i!==`update`&&r.push(i),t>0&&r.push(`+${t}`),n>0&&r.push(`-${n}`),r.length>0?r.join(` · `):void 0}function X_(e){let t=e.operation?.trim().toLowerCase()??``;return{oldStartLine:typeof e.oldStartLine==`number`?e.oldStartLine:(t===`delete`||t===`remove`)&&e.beforeText!=null?1:void 0,newStartLine:typeof e.newStartLine==`number`?e.newStartLine:(t===`write`||t===`add`)&&e.afterText!=null?1:void 0}}function Z_(e){return e.length<=J_?{lines:e,truncated:!1}:{lines:e.slice(0,J_),truncated:!0}}function Q_(e){let t=e.text.trim();if(!t)return null;let n=U_({text:t,kind:e.operation?.trim().toLowerCase()===`write`?`add`:`context`,oldStartLine:typeof e.oldStartLine==`number`?e.oldStartLine:1,newStartLine:typeof e.newStartLine==`number`?e.newStartLine:1});return{path:e.path,display:`preview`,caption:Y_({operation:e.operation,lines:n}),lines:n}}function $_(e){let{oldStartLine:t,newStartLine:n}=X_(e),r=q_({beforeText:e.beforeText??``,afterText:e.afterText??``,oldStartLine:t,newStartLine:n}),i=Z_(r);return i.lines.length===0?null:{path:e.path,display:`diff`,caption:Y_({operation:e.operation,lines:r}),lines:i.lines,truncated:i.truncated}}function ev(e){let t=Z_(e.lines);return{path:e.path,display:`diff`,caption:Y_({operation:e.operation,lines:e.lines}),lines:t.lines,truncated:t.truncated}}function tv(e){return e.line.startsWith(`*** Update File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`update`),!0):e.line.startsWith(`*** Add File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(14).trim(),`add`),!0):e.line.startsWith(`*** Delete File: `)?(e.flushCurrent(),e.setCurrent(e.line.slice(17).trim(),`delete`),!0):!1}function nv(e){let{currentLines:t,line:n}=e;return n.startsWith(`+`)?(t.push(V_({kind:`add`,text:n.slice(1),newLineNumber:e.newLineNumber})),{oldLineNumber:e.oldLineNumber,newLineNumber:B_(e.newLineNumber)}):n.startsWith(`-`)?(t.push(V_({kind:`remove`,text:n.slice(1),oldLineNumber:e.oldLineNumber})),{oldLineNumber:B_(e.oldLineNumber),newLineNumber:e.newLineNumber}):n.startsWith(` `)?(t.push(V_({kind:`context`,text:n.slice(1),oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber})),{oldLineNumber:B_(e.oldLineNumber),newLineNumber:B_(e.newLineNumber)}):{oldLineNumber:e.oldLineNumber,newLineNumber:e.newLineNumber}}function rv(e){let t=[],n=null,r=null,i=[],a,o,s=()=>{if(!n){i=[],r=null,a=void 0,o=void 0;return}t.push(ev({path:n,operation:r,lines:i})),n=null,r=null,i=[],a=void 0,o=void 0};for(let t of z_(e)){if(tv({line:t,flushCurrent:s,setCurrent:(e,t)=>{n=e,r=t}})||t.startsWith(`*** Move to: `)||t.startsWith(`*** Begin Patch`)||t.startsWith(`*** End Patch`))continue;if(t.startsWith(`@@`)){let e=H_(t);a=e?.oldLineNumber,o=e?.newLineNumber;continue}if(!n)continue;let e=nv({currentLines:i,line:t,oldLineNumber:a,newLineNumber:o});a=e.oldLineNumber,o=e.newLineNumber}return s(),t}function iv(e){let t=[],n=null,r=[],i,a,o=()=>{if(!n){r=[],i=void 0,a=void 0;return}t.push(ev({path:n,operation:`update`,lines:r})),n=null,r=[],i=void 0,a=void 0};for(let t of z_(e)){if(t.startsWith(`+++ `)){o(),n=t.slice(4).trim().replace(/^b\//,``).replace(/^a\//,``);continue}if(t.startsWith(`--- `))continue;if(t.startsWith(`@@`)){let e=H_(t);i=e?.oldLineNumber,a=e?.newLineNumber;continue}if(!n)continue;let e=nv({currentLines:r,line:t,oldLineNumber:i,newLineNumber:a});i=e.oldLineNumber,a=e.newLineNumber}return o(),t}function av(e){return e.includes(`*** Begin Patch`)?rv(e):e.includes(`--- `)&&e.includes(`+++ `)?iv(e):[]}function ov(e){switch(e){case`"`:case`\\`:case`/`:return e;case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
|
|
40
|
+
`;case`r`:return`\r`;case`t`:return` `;default:return e}}function sv(e,t){let n=`"${t}"`,r=e.indexOf(n);if(r<0)return null;let i=e.indexOf(`:`,r+n.length);if(i<0)return null;let a=i+1;for(;a<e.length&&/\s/.test(e[a]??``);)a+=1;return e[a]===`"`?a+1:null}function cv(e,t,n=1/0){let r=``,i=!1;for(let a=t;a<e.length;a+=1){let t=e[a];if(t==null)break;if(i){r+=ov(t),i=!1;continue}if(t===`\\`){i=!0;continue}if(t===`"`)return{value:r,truncated:!1};if(r+=t,r.length>=n)return{value:r,truncated:!0}}return r.length>0?{value:r,truncated:!1}:null}function lv(e,t,n=1/0){for(let r of t){let t=sv(e,r);if(t!=null)return cv(e,t,n)}return null}function uv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function dv(e){return typeof e==`string`&&e.trim()?e.trim():null}function fv(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:typeof e==`string`&&/^\d+$/.test(e.trim())?Number(e.trim()):null}function pv(e){if(uv(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);return uv(e)?e:null}catch{return null}}function mv(e){if(uv(e))return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;let n=lv(t,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`])?.value??null,r=lv(t,[`content`,`text`,`afterText`,`after_text`])?.value??null,i=lv(t,[`oldText`,`beforeText`,`before_text`])?.value??null,a=lv(t,[`newText`,`afterText`,`after_text`])?.value??null,o=lv(t,[`patch`,`diff`,`unifiedDiff`,`unified_diff`])?.value??null,s={};return n&&(s.path=n),r&&(s.content=r),i&&(s.oldText=i),a&&(s.newText=a),o&&(s.patch=o),Object.keys(s).length>0?s:null}function hv(e){return dv(e.path)??dv(e.filePath)??dv(e.file_path)??dv(e.targetPath)??dv(e.target_path)??dv(e.filename)??dv(e.name)}function gv(e){return $(e.operation)??$(e.op)??$(e.action)??$(e.kind)??$(e.type)??$(e.status)}function _v(e,t){for(let n of t){let t=fv(e[n]);if(t!==null)return t}return null}function vv(e){return _v(e,[`oldStartLine`,`old_start_line`,`startOldLine`,`start_old_line`,`oldLineStart`,`old_line_start`,`oldLineNumber`,`old_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function yv(e){return _v(e,[`newStartLine`,`new_start_line`,`startNewLine`,`start_new_line`,`newLineStart`,`new_line_start`,`newLineNumber`,`new_line_number`,`lineStart`,`line_start`,`startLine`,`start_line`,`lineNumber`,`line_number`])}function bv(e){return $(e.patch)??$(e.diff)??$(e.unifiedDiff)??$(e.unified_diff)}function xv(e){return $(e.beforeText)??$(e.before_text)??$(e.oldText)??$(e.old_text)??$(e.oldContent)??$(e.old_content)??$(e.before)??$(e.previous)}function Sv(e){return $(e.afterText)??$(e.after_text)??$(e.newText)??$(e.new_text)??$(e.newContent)??$(e.new_content)??$(e.content)??$(e.text)??$(e.after)??$(e.updated)}var Cv=new Set([`file_change`,`read_file`,`write_file`,`edit_file`,`apply_patch`]);function wv(e){let t=e.map((e,t)=>({key:`${e.path}-${t+1}`,path:e.path,display:e.display,...e.caption?{caption:e.caption}:{},lines:e.lines,...e.rawText?{rawText:e.rawText}:{},...e.truncated?{truncated:!0}:{}})).filter(e=>e.lines.length>0||!!e.rawText);if(t.length===0)return null;let n=t.map(e=>e.path);return{summary:n.length===1?n[0]:`${n.length} files · ${n.slice(0,2).join(` · `)}${n.length>2?` …`:``}`,fileOperation:{blocks:t}}}function Tv(e,t){let n=hv(e)??t,r=gv(e),i=vv(e),a=yv(e),o=bv(e);if(o){let e=av(o);if(e.length>0)return e[0]??null}let s=xv(e),c=Sv(e);if(s!=null||c!=null)return $_({path:n,beforeText:s,afterText:c,operation:r,oldStartLine:i,newStartLine:a});let l=$(e.preview);return l?Q_({path:n,text:l,operation:r,oldStartLine:i,newStartLine:a}):null}function Ev(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e==`string`){let n=av(e);n.length>0&&t.push(...n);return}if(!uv(e))return;let r=Tv(e,hv(e)??`file-${n+1}`);if(r){t.push(r);return}let i=Array.isArray(e.changes)?Ev(e.changes):[];i.length>0&&t.push(...i)}),t}function Dv(e){let t=pv(e.result)??pv(e.parsedArgs)??pv(e.args);return t?wv(Ev(t.changes)):null}function Ov(e){let t=pv(e.parsedArgs)??pv(e.args)??mv(e.args),n=t&&hv(t),r=$(e.result);return!n||!r?null:wv([Q_({path:n,text:r,operation:`read`})].filter(e=>!!e))}function kv(e){if(e.status===`partial-call`&&typeof e.args==`string`){let t=lv(e.args,[`path`,`filePath`,`file_path`,`targetPath`,`target_path`,`filename`,`name`]),n=lv(e.args,[`content`,`text`,`afterText`,`after_text`]);if(t?.value&&n?.value){let e=Q_({path:t.value,text:n.value,operation:`write`});if(e)return wv([e])}}let t=pv(e.parsedArgs)??pv(e.args)??mv(e.args);if(!t)return null;let n=hv(t),r=$(t.content);return!n||!r?null:wv([Q_({path:n,text:r,operation:`write`})].filter(e=>!!e))}function Av(e){let t=pv(e.result),n=pv(e.parsedArgs)??pv(e.args)??mv(e.args);if(!t&&!n)return null;let r=(t?hv(t):null)??(n?hv(n):null),i=(t?xv(t):null)??(n?xv(n):null),a=(t?Sv(t):null)??(n?Sv(n):null),o=(t?vv(t):null)??(n?vv(n):null),s=(t?yv(t):null)??(n?yv(n):null);return!r||i==null&&a==null?null:wv([$_({path:r,beforeText:i,afterText:a,operation:`edit`,oldStartLine:o,newStartLine:s})].filter(e=>!!e))}function jv(e){let t=pv(e.parsedArgs),n=pv(e.args)??mv(e.args),r=$(e.args)??(t?$(t.patch):null)??(n?$(n.patch):null);return r?wv(av(r)):null}function Mv(e){return Cv.has(e.toolName)?e.toolName===`file_change`?Dv(e):e.toolName===`read_file`?Ov(e):e.toolName===`write_file`?kv(e):e.toolName===`edit_file`?Av(e):e.toolName===`apply_patch`?jv(e):null:null}function Nv(e){return typeof e==`object`&&!!e}function Pv(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Fv(e){return!Nv(e)||e.kind!==`nextclaw.session_request`?null:e}function Iv(e,t){return[Pv(e.title)?`title: ${e.title?.trim()}`:null,Pv(e.sessionId)?`session: ${e.sessionId?.trim()}`:null,Pv(e.task)?`task: ${e.task?.trim()}`:null].filter(e=>!!e).join(` · `)||__(t)}function Lv(e){let t=Pv(e.requestId),n=Pv(e.sessionId),r=Pv(e.title),i=Pv(e.task),a=e.message===void 0?``:h_(e.message).trim(),o=e.finalResponseText===void 0?``:h_(e.finalResponseText).trim(),s=e.error===void 0?``:h_(e.error).trim(),c=[t?`Request ID: ${t}`:null,n?`Session ID: ${n}`:null,typeof e.isChildSession==`boolean`?`Target: ${e.isChildSession?`child`:`session`}`:null,r?`Title: ${r}`:null,i?`Task:\n${i}`:null,o?`Final Response:\n${o}`:s?`Error:\n${s}`:a?`Status:\n${a}`:null].filter(e=>!!e);return c.length>0?c.join(`
|
|
41
|
+
|
|
42
|
+
`):void 0}function Rv(e){let{invocation:t,texts:n}=e,{toolName:r,toolCallId:i,args:a,result:o}=t;if(r!==`spawn`&&r!==`sessions_request`)return null;let s=Fv(o);if(!s)return null;let c=Pv(s.status)?.toLowerCase(),l=Iv(s,a),u=Lv(s),d=Pv(s.sessionId),f=I_({args:a,result:s}),p=d?{kind:`open-session`,sessionId:d,sessionKind:s.isChildSession===!0?`child`:`session`,...f?{agentId:f}:{},...Pv(s.title)?{label:s.title.trim()}:{},...Pv(s.parentSessionId)?{parentSessionId:s.parentSessionId.trim()}:{}}:void 0;return c===`failed`?{kind:`result`,name:r,detail:l,text:u,callId:i||void 0,hasResult:!!u,statusTone:`error`,statusLabel:n.toolStatusFailedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}:c===`completed`?{kind:`result`,name:r,detail:l,text:u,callId:i||void 0,hasResult:!!u,statusTone:`success`,statusLabel:n.toolStatusCompletedLabel,...f?{agentId:f}:{},...p?{action:p}:{}}:{kind:`result`,name:r,detail:l,text:u,callId:i||void 0,hasResult:!!u,statusTone:`running`,statusLabel:n.toolStatusRunningLabel,...f?{agentId:f}:{},...p?{action:p}:{}}}function zv(e){return typeof e==`object`&&!!e}function Bv(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function Vv(e){if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function Hv(e){return zv(e)?`command`in e||`workingDir`in e||`exitCode`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e:!1}function Uv(e,t){if(!zv(e))return null;let n=zv(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&zv(e.assets[0])?e.assets[0]:null;if(!n)return null;let r=Bv(n.url),i=Bv(n.mimeType)??`application/octet-stream`,a=Vv(n.sizeBytes);return r?{type:`file`,file:{label:Bv(n.name)??(i.startsWith(`image/`)?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...a==null?{}:{sizeBytes:a},isImage:i.startsWith(`image/`)}}:null}function Wv(e,t){return{kind:e.kind,toolName:e.name,...`agentId`in e&&e.agentId?{agentId:e.agentId}:{},summary:e.detail,inputLabel:t.toolInputLabel,input:`input`in e&&typeof e.input==`string`?e.input:void 0,output:e.text,outputData:e.outputData,hasResult:!!e.hasResult,statusTone:e.statusTone,statusLabel:e.statusLabel,titleLabel:e.kind===`call`?t.toolCallLabel:t.toolResultLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel,...`action`in e&&e.action?{action:e.action}:{},...`fileOperation`in e&&e.fileOperation?{fileOperation:e.fileOperation}:{}}}function Gv(e){let t=typeof e.status==`string`?e.status.trim().toLowerCase():``,n=typeof e.error==`string`&&e.error.trim().length>0;return e.cancelled===!0||t===`cancelled`?{kind:`result`,hasResult:!0,statusTone:`cancelled`,statusLabel:e.texts.toolStatusCancelledLabel}:n||t===`error`?{kind:`result`,hasResult:!0,statusTone:`error`,statusLabel:e.texts.toolStatusFailedLabel}:t===`result`||e.result!=null?{kind:`result`,hasResult:!0,statusTone:`success`,statusLabel:e.texts.toolStatusCompletedLabel}:{kind:`call`,hasResult:!1,statusTone:`running`,statusLabel:e.texts.toolStatusRunningLabel}}function Kv(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.parse(t)}catch{return e}}function qv(e,t){return h_(t??Kv(e)).trim()||void 0}function Jv(e,t){let n=j_(e.reasoning);return n?{type:`reasoning`,text:n,label:t.reasoningLabel}:null}function Yv(e,t){let n=e.mimeType.startsWith(`image/`),r=Vv(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.imageAttachmentLabel:t.fileAttachmentLabel,mimeType:e.mimeType,dataUrl:typeof e.url==`string`&&e.url.trim().length>0?e.url.trim():`data:${e.mimeType};base64,${e.data}`,...r==null?{}:{sizeBytes:r},isImage:n}}}function Xv(e,t){let n=e.toolInvocation,r=Uv(n.result,t);if(r)return r;let i=Rv({invocation:n,texts:{toolStatusRunningLabel:t.toolStatusRunningLabel,toolStatusCompletedLabel:t.toolStatusCompletedLabel,toolStatusFailedLabel:t.toolStatusFailedLabel}});if(i)return{type:`tool-card`,card:Wv(i,t)};let a=Gv({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t}),o=Mv({toolName:n.toolName,status:n.status,toolCallId:n.toolCallId,args:n.args,parsedArgs:n.parsedArgs,result:n.result}),s=o?.summary??__(n.parsedArgs??n.args),c=o?void 0:qv(n.args,n.parsedArgs),l=typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:h_(n.result).trim(),u=!n.error&&Hv(n.result),d=(!o?.fileOperation||!!n.error)&&!u,f=I_(n);return{type:`tool-card`,card:Wv({kind:a.kind,name:n.toolName,...f?{agentId:f}:{},detail:s,...c?{input:c}:{},text:d&&l?l:void 0,outputData:n.result,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel,...o?.fileOperation?{fileOperation:o.fileOperation}:{}},t)}}function Zv(e,t){return{type:`unknown`,label:t.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:h_(e)}}function Qv(e){return e.type===`text`&&typeof e.text==`string`}function $v(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function ey(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function ty(e){return e.type!==`tool-invocation`||!zv(e.toolInvocation)?!1:typeof e.toolInvocation.toolName==`string`}function ny(e){return Qv(e.part)?A_(e.part,e.inlineTokens):$v(e.part)?Jv(e.part,e.texts):ey(e.part)?Yv(e.part,e.texts):ty(e.part)?Xv(e.part,e.texts):Zv(e.part,e.texts)}function ry(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function iy(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function ay(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function oy(e,t){return{id:e.id,role:ay(e.role),roleLabel:iy(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(ry(e)),status:e.meta?.status,parts:e.parts.map(n=>ny({part:n,inlineTokens:e.meta?.inlineTokens??[],texts:t.texts})).filter(e=>e!==null)}}var sy={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,sessionKey:null,agentId:null,agentDisplayName:null,agentAvatarUrl:null,availableAgents:[],sessionDisplayName:void 0,sessionProjectRoot:null,sessionProjectName:null,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1,parentSessionKey:null,parentSessionLabel:null,childSessionTabs:[],activeChildSessionKey:null},cy=S(e=>({snapshot:sy,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function ly(e,t){return new Map([...t,...e].filter(e=>typeof e.id==`string`&&e.id.trim().length>0).map(e=>[e.id,e]))}function uy(e){let t=e?.trim()??``,n=cy(e=>e.snapshot.availableAgents??[]),r=Ng(),i=(0,P.useMemo)(()=>ly(n,r.data?.agents??[]),[r.data?.agents,n]);return(0,P.useMemo)(()=>{if(!t)return null;let e=i.get(t)??null;return{agentId:t,profile:e,displayName:e?.displayName?.trim()||t,avatarUrl:e?.avatarUrl?.trim()||null}},[i,t])}function dy({agentId:e,className:t}){let n=uy(e);return n?(0,I.jsx)(ar,{agentId:n.agentId,displayName:n.displayName,avatarUrl:n.avatarUrl,className:t}):null}var fy=new WeakMap;function py(e){return{roleLabels:{user:o(`chatRoleUser`),assistant:o(`chatRoleAssistant`),tool:o(`chatRoleTool`),system:o(`chatRoleSystem`),fallback:o(`chatRoleMessage`)},reasoningLabel:o(`chatReasoning`),toolCallLabel:o(`chatToolCall`),toolResultLabel:o(`chatToolResult`),toolInputLabel:o(`chatToolInput`),toolNoOutputLabel:o(`chatToolNoOutput`),toolOutputLabel:o(`chatToolOutput`),toolStatusPreparingLabel:o(`chatToolStatusPreparing`),toolStatusRunningLabel:o(`chatToolStatusRunning`),toolStatusCompletedLabel:o(`chatToolStatusCompleted`),toolStatusFailedLabel:o(`chatToolStatusFailed`),toolStatusCancelledLabel:o(`chatToolStatusCancelled`),imageAttachmentLabel:o(`chatImageAttachment`),fileAttachmentLabel:o(`chatFileAttachment`),unknownPartLabel:o(`chatUnknownPart`)}}function my(e){return{copyCodeLabel:o(`chatCodeCopy`),copiedCodeLabel:o(`chatCodeCopied`),copyMessageLabel:o(`chatMessageCopy`),copiedMessageLabel:o(`chatMessageCopied`),typingLabel:o(`chatTyping`)}}function hy({messages:e,isSending:t,className:n,onToolAction:r}){let{language:i}=jt(),a=(0,P.useMemo)(()=>py(i),[i]),o=(0,P.useMemo)(()=>e.map(e=>{let t=fy.get(e);if(t&&t.language===i)return t.viewModel;let n=We(e),r=oy({id:n.id,role:n.role,meta:{timestamp:n.meta?.timestamp,status:n.meta?.status,inlineTokens:w_(e.metadata)},parts:n.parts},{formatTimestamp:e=>c(e,i),texts:a});return fy.set(e,{language:i,viewModel:r}),r}),[i,e,a]);return(0,I.jsx)(hg,{messages:o,isSending:t,hasAssistantDraft:(0,P.useMemo)(()=>o.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[o]),className:n,texts:(0,P.useMemo)(()=>my(i),[i]),onToolAction:r,renderToolAgent:e=>(0,I.jsx)(dy,{agentId:e,className:`h-4 w-4 shrink-0`})})}function gy(e,t){return e.label?.trim()?e.label.trim():t?Ke(t):e.sessionKey}function _y(e){let t=pt({limit:200}),n=(0,P.useMemo)(()=>{let e=Be(t.data?.sessions??[]);return new Map(e.map(e=>[e.key,e]))},[t.data?.sessions]);return(0,P.useMemo)(()=>e.map(e=>{let t=n.get(e.sessionKey)??null,r=e.agentId?.trim()||t?.agentId||null;return{sessionKey:e.sessionKey,parentSessionKey:e.parentSessionKey,title:gy(e,t),agentId:r}}),[n,e])}function vy(e){let t=e.split(/\r?\n/),n=`message`,r=[];for(let e of t){let t=e.trimEnd();if(!(!t||t.startsWith(`:`))){if(t.startsWith(`event:`)){n=t.slice(6).trim()||`message`;continue}t.startsWith(`data:`)&&r.push(t.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
|
|
43
|
+
`)}}async function*yy(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{value:e,done:i}=await t.read();if(i)break;r+=n.decode(e,{stream:!0});let{frames:a,rest:o}=by(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=by(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function by(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=vy(e);t&&i.push(t)}if(t&&r.trim()){let e=vy(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var xy=`/ncp/agent`,Sy=`ncp-http-agent-client`,Cy=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function wy(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function Ty(e){if(e)return e;if(typeof globalThis.fetch==`function`)return globalThis.fetch.bind(globalThis);throw Error(`No fetch implementation found. Pass options.fetchImpl explicitly.`)}function Ey(e){let t=(e??xy).trim();if(!t)return xy;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function Dy(e){try{return(await e.text()).trim()}catch{return``}}function Oy(e){if(My(e))return e.ncpError;if(Ay(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:Py(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function ky(e,t={}){return new Cy(e,t.alreadyPublished??!1)}function Ay(e){return jy(e)&&typeof e.code==`string`&&typeof e.message==`string`}function jy(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function My(e){return e instanceof Cy}var Ny={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function Py(e){if(!e)return`runtime-error`;let t=Ny[e];if(t)return t;let n=e.toLowerCase();return n.includes(`timeout`)?`timeout-error`:n.includes(`abort`)||n.includes(`cancel`)?`abort-error`:n.includes(`auth`)?`auth-error`:n.includes(`config`)?`config-error`:`runtime-error`}function Fy(e){let t=Ly(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function Iy(e){let t=Ly(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=Py(n),i=jy(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message==`string`&&t.message?t.message:`Unknown stream error.`,...Object.keys(i).length>0?{details:i}:{}}}function Ly(e){try{let t=JSON.parse(e);return jy(t)?t:null}catch{return null}}var Ry=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],zy=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=wy(e.baseUrl),this.basePath=Ey(e.basePath),this.fetchImpl=Ty(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||Sy,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:Ry,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:F.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(let e of this.activeControllers)e.abort();this.activeControllers.clear()}}async emit(e){switch(e.type){case`message.request`:await this.send(e.payload);return;case`message.stream-request`:await this.stream(e.payload);return;case`message.abort`:await this.abort(e.payload);return;default:this.publish(e);return}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}async send(e){await this.ensureStarted(),await this.streamRequest({path:`/send`,method:`POST`,body:e})}async stream(e){await this.ensureStarted();let t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:`GET`})}async abort(e){await this.ensureStarted();let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(`/abort`),{method:`POST`,headers:{...this.defaultHeaders,"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(e),signal:t.signal});if(!n.ok)throw Error(`Abort request failed with HTTP ${n.status}: ${await Dy(n)}`)}catch(e){if(t.signal.aborted)return;let n=Oy(e);throw this.publish({type:F.EndpointError,payload:n}),ky(n)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(let t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){let t=new AbortController;this.activeControllers.add(t);try{let n=await this.fetchImpl(this.resolveUrl(e.path),{method:e.method,headers:{...this.defaultHeaders,accept:`text/event-stream`,...e.body===void 0?{}:{"content-type":`application/json`}},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:t.signal});if(!n.ok)throw Error(`NCP stream request failed with HTTP ${n.status}: ${await Dy(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of yy(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(My(e))throw e;let n=Oy(e);throw this.publish({type:F.EndpointError,payload:n}),ky(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=Fy(e.data);if(!t){this.publish({type:F.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=Iy(e.data);throw this.publish({type:F.EndpointError,payload:t}),ky(t,{alreadyPublished:!0})}}};function By(){return(e,t)=>fetch(e,{credentials:`include`,...t})}var Vy=300;function Hy(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function Uy(){return new zy({baseUrl:d,basePath:`/api/ncp/agent`,fetchImpl:By()})}async function Wy(e,t,n=Vy){t.throwIfAborted();try{let r=await at(e,n);return t.throwIfAborted(),{messages:r.messages,status:r.status??`idle`}}catch(e){if(t.throwIfAborted(),!Hy(e))throw e;return{messages:[],status:`idle`}}}function Gy(e,t={}){let[n]=(0,P.useState)(()=>Uy()),r=t.messageLimit??Vy;return qn({sessionId:e,client:n,loadSeed:(0,P.useCallback)((e,t)=>Wy(e,t,r),[r])})}var Ky=P.createContext(null);function qy({defaultValue:e,value:t,onValueChange:n,children:r}){return(0,I.jsx)(Ky.Provider,{value:{value:t,onValueChange:n},children:r})}function Jy({children:e,className:t}){return(0,I.jsx)(`div`,{className:u(`inline-flex h-9 items-center justify-center rounded-xl bg-gray-100/80 p-1 text-gray-500`,t),children:e})}function Yy({value:e,children:t,className:n}){let r=P.useContext(Ky);if(!r)throw Error(`TabsTrigger must be used within Tabs`);let i=r.value===e;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>r.onValueChange(e),"aria-pressed":i,"data-state":i?`active`:`inactive`,className:u(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-[13px] font-medium ring-offset-white transition-all duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,i?`bg-white text-gray-900 shadow-sm`:`hover:bg-white/50 hover:text-gray-800 text-gray-600`,n),children:t})}function Xy({sessionKey:e,onToolAction:t}){let n=Gy(e),r=n.visibleMessages;return n.isHydrating?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:[(0,I.jsx)(we,{className:`mr-2 h-4 w-4 animate-spin`}),o(`chatChildSessionLoading`)]}):n.hydrateError?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-rose-600`,children:n.hydrateError.message}):r.length===0&&!n.isRunning?(0,I.jsx)(`div`,{className:`px-4 py-5 text-sm text-gray-500`,children:o(`chatChildSessionEmpty`)}):(0,I.jsx)(`div`,{className:`px-4 py-5`,children:(0,I.jsx)(hy,{messages:r,isSending:n.isRunning,onToolAction:t})})}function Zy({tabs:e,activeSessionKey:t,onSelectSession:n,onClose:r,onBackToParent:i,onToolAction:a}){let s=_y(e),c=s.find(e=>e.sessionKey===t)??s[0]??null,l=s.some(e=>!!e.parentSessionKey),d=s.length>1;return c?(0,I.jsx)(`aside`,{className:`hidden md:flex md:w-[24rem] lg:w-[28rem] shrink-0 border-l border-gray-200/70 bg-white/90 backdrop-blur-sm`,children:(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,I.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:i,className:u(`inline-flex items-center gap-1 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,!l&&`pointer-events-none opacity-0`),children:[(0,I.jsx)(me,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{children:o(`chatBackToParent`)})]}),(0,I.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-full border border-gray-200/80 p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":o(`chatChildSessionClosePanel`),children:(0,I.jsx)(Xe,{className:`h-4 w-4`})})]}),d?null:(0,I.jsxs)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2 text-sm font-semibold text-gray-900`,children:[c.agentId?(0,I.jsx)(dy,{agentId:c.agentId,className:`h-5 w-5 shrink-0`}):null,(0,I.jsx)(`span`,{className:`truncate`,title:c.sessionKey,children:c.title})]}),d?(0,I.jsx)(`div`,{className:`mt-3 overflow-x-auto custom-scrollbar`,children:(0,I.jsx)(qy,{value:t,onValueChange:n,children:(0,I.jsx)(Jy,{className:`h-auto min-w-max justify-start gap-1.5 rounded-none bg-transparent p-0 text-gray-500`,children:s.map(e=>(0,I.jsxs)(Yy,{value:e.sessionKey,className:`gap-2 rounded-full border border-gray-200/80 bg-white/85 px-2.5 py-1.5 text-xs font-medium text-gray-600 shadow-none hover:border-primary/30 hover:text-primary data-[state=active]:border-primary/30 data-[state=active]:bg-primary-50/70 data-[state=active]:text-primary data-[state=active]:shadow-sm`,children:[e.agentId?(0,I.jsx)(dy,{agentId:e.agentId,className:`h-4 w-4 shrink-0`}):null,(0,I.jsx)(`span`,{className:`max-w-[132px] truncate`,children:e.title})]},e.sessionKey))})})}):null]}),(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:s.map(e=>(0,I.jsx)(`div`,{className:u(e.sessionKey===t?`block`:`hidden`),children:(0,I.jsx)(Xy,{sessionKey:e.sessionKey,onToolAction:a})},e.sessionKey))})]})}):null}var Qy=[{icon:vt,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:bt,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:ut,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function $y({onCreateSession:e,agents:t,selectedAgentId:n,onSelectAgent:r}){let i=t.find(e=>e.id===n)??null;return(0,I.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,I.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(yt,{className:`h-8 w-8 text-primary`})}),(0,I.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:o(`chatWelcomeTitle`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:o(`chatWelcomeSubtitle`)}),(0,I.jsxs)(`div`,{className:`mb-6 flex items-center justify-center gap-2.5`,children:[(0,I.jsx)(`span`,{className:`text-[13px] font-medium text-gray-500`,children:o(`chatDraftAgentTitle`)}),(0,I.jsxs)(ue,{value:n,onValueChange:r,children:[(0,I.jsxs)(ne,{"aria-label":o(`chatDraftAgentTitle`),className:`h-auto w-auto gap-1 rounded-full border-0 bg-transparent px-1.5 py-1 text-gray-500 shadow-none hover:bg-white/70 hover:text-gray-800 focus:ring-0`,children:[(0,I.jsx)(`span`,{className:`sr-only`,children:o(`chatDraftAgentTitle`)}),(0,I.jsx)(`div`,{className:`flex items-center gap-1.5`,children:i?(0,I.jsx)(ar,{agentId:i.id,displayName:i.displayName,avatarUrl:i.avatarUrl,className:`h-7 w-7 shrink-0`}):null})]}),(0,I.jsx)(M,{className:`rounded-xl border-gray-200/80 shadow-lg`,children:t.map(e=>(0,I.jsx)(ce,{value:e.id,className:`rounded-lg pr-10`,children:(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(ar,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-5 w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-700`,children:e.displayName?.trim()||e.id})]})},e.id))})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:Qy.map(t=>{let n=t.icon;return(0,I.jsxs)(`button`,{onClick:e,className:`rounded-2xl border border-gray-200 bg-white p-4 text-left shadow-card hover:shadow-card-hover transition-shadow cursor-pointer`,children:[(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,I.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,I.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:o(t.titleKey)}),(0,I.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:o(t.descKey)})]},t.titleKey)})})]})})}function eb(){let e=_r();return async t=>{let n=t.projectRoot?o(`chatSessionProjectUpdated`):o(`chatSessionProjectCleared`);if(!t.persistToServer){Q.getState().setSnapshot({pendingProjectRoot:t.projectRoot,pendingProjectRootSessionKey:t.sessionKey}),p.success(n);return}await e({sessionKey:t.sessionKey,patch:{projectRoot:t.projectRoot},successMessage:n}),Q.getState().setSnapshot({pendingProjectRoot:t.projectRoot,pendingProjectRootSessionKey:t.sessionKey})}}function tb({icon:e,label:t,onClick:n,disabled:r=!1,destructive:i=!1}){return(0,I.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,i?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:n,disabled:r,children:[(0,I.jsx)(e,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{children:t})]})}async function nb(e){let t=new URLSearchParams;typeof e?.path==`string`&&e.path.trim().length>0&&t.set(`path`,e.path.trim()),e?.includeFiles&&t.set(`includeFiles`,`1`);let n=t.toString(),r=await h.get(n?`/api/server-paths/browse?${n}`:`/api/server-paths/browse`);if(!r.ok)throw Error(r.error.message);return r.data}function rb(e){return f({queryKey:[`server-path-browse`,e.path??null,e.includeFiles??!1],queryFn:()=>nb({path:e.path,includeFiles:e.includeFiles}),enabled:e.enabled??!0,staleTime:0})}var ib=P.forwardRef(({className:e,children:t,...n},r)=>(0,I.jsx)(`div`,{ref:r,className:u(`overflow-auto`,e),...n,children:t}));ib.displayName=`ScrollArea`;function ab({open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:a,description:s,pathLabel:c,pathPlaceholder:l,confirmLabel:u,hint:d}){let[f,p]=(0,P.useState)(``),[h,g]=(0,P.useState)(null),[_,v]=(0,P.useState)(``);(0,P.useEffect)(()=>{if(!e)return;let n=t?.trim()||null;p(n??``),g(n),v(``)},[t,e]);let y=rb({path:h,enabled:e});(0,P.useEffect)(()=>{!e||!y.data||f.trim().length===0&&p(y.data.currentPath)},[y.data,f,e]);let b=f.trim(),x=b.length===0||n,S=(0,P.useMemo)(()=>y.error?y.error instanceof Error?y.error.message:String(y.error):null,[y.error]),C=_.trim().toLowerCase(),w=(0,P.useMemo)(()=>{let e=y.data?.entries??[];return C.length===0?e:e.filter(e=>{let t=e.name.toLowerCase(),n=e.path.toLowerCase();return t.includes(C)||n.includes(C)})},[y.data?.entries,C]),T=e=>{g(e),v(``),e&&p(e)};return(0,I.jsx)(gt,{open:e,onOpenChange:e=>{n||r(e)},children:(0,I.jsxs)(Ft,{className:`max-h-[85vh] overflow-hidden sm:h-[42rem] sm:max-w-2xl sm:grid-rows-[auto_minmax(0,1fr)]`,children:[(0,I.jsxs)(St,{children:[(0,I.jsx)(ft,{children:a}),s?(0,I.jsx)(Et,{children:s}):null]}),(0,I.jsxs)(`form`,{className:`flex min-h-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),!x&&i(b)},children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(qt,{htmlFor:`server-path-picker-input`,children:c}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(lt,{id:`server-path-picker-input`,value:f,onChange:e=>p(e.target.value),placeholder:l,autoFocus:!0,disabled:n}),(0,I.jsx)(m,{type:`button`,variant:`outline`,onClick:()=>T(b||null),disabled:n,children:o(`openPath`)})]})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-gray-50/70`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2`,children:[(0,I.jsxs)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>T(y.data?.homePath??null),disabled:n||y.isLoading,children:[(0,I.jsx)(un,{className:`mr-1 h-4 w-4`}),o(`homeDirectory`)]}),(0,I.jsxs)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>T(y.data?.parentPath??null),disabled:!y.data?.parentPath||n||y.isLoading,children:[(0,I.jsx)(sn,{className:`mr-1 h-4 w-4`}),o(`parentDirectory`)]}),(0,I.jsxs)(m,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{y.refetch()},disabled:n||y.isLoading,children:[(0,I.jsx)(Ie,{className:`mr-1 h-4 w-4`}),o(`chatRefresh`)]})]}),(0,I.jsxs)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:[(0,I.jsx)(`div`,{className:`mb-2 text-xs font-medium text-gray-500`,children:o(`currentDirectory`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 text-xs text-gray-600`,children:y.data?.breadcrumbs.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 hover:bg-gray-200`,onClick:()=>T(e.path),disabled:n,children:e.label}),t<y.data.breadcrumbs.length-1?(0,I.jsx)(en,{className:`h-3 w-3 text-gray-400`}):null]},e.path))})]}),(0,I.jsx)(`div`,{className:`border-b border-gray-200 px-3 py-2`,children:(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(Je,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,I.jsx)(lt,{value:_,onChange:e=>v(e.target.value),placeholder:o(`pathPickerSearchPlaceholder`),disabled:n||y.isLoading,className:`pl-9`})]})}),(0,I.jsx)(ib,{className:`min-h-0 flex-1 px-2 py-2`,children:y.isLoading?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`loading`)}):S?(0,I.jsxs)(`div`,{className:`px-2 py-4 text-sm text-destructive`,children:[o(`pathBrowseFailed`),`: `,S]}):y.data&&w.length>0?(0,I.jsx)(`div`,{className:`space-y-1`,children:w.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left text-sm text-gray-700 transition-colors hover:bg-white`,onClick:()=>T(e.path),disabled:n,children:[(0,I.jsx)(ge,{className:`h-4 w-4 shrink-0 text-emerald-600`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))}):y.data&&y.data.entries.length>0?(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`pathPickerSearchEmpty`)}):(0,I.jsx)(`div`,{className:`px-2 py-6 text-sm text-gray-500`,children:o(`emptyDirectory`)})})]}),d?(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-gray-500`,children:d}):null,(0,I.jsxs)(Mt,{children:[(0,I.jsx)(m,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:n,children:o(`cancel`)}),(0,I.jsx)(m,{type:`submit`,disabled:x,children:n?o(`saving`):u})]})]})]})})}function ob({open:e,currentProjectRoot:t,isSaving:n,onOpenChange:r,onSave:i}){return(0,I.jsx)(ab,{open:e,currentPath:t,isSaving:n,onOpenChange:r,onConfirm:i,title:o(`chatSessionProjectDialogTitle`),description:o(`chatSessionProjectDialogDescription`),pathLabel:o(`chatSessionProjectPathLabel`),pathPlaceholder:o(`chatSessionProjectPathPlaceholder`),confirmLabel:o(`chatSessionSetProject`),hint:o(`chatSessionProjectUpdateHint`)})}function sb({sessionKey:e,canDeleteSession:t,isDeletePending:n,projectRoot:r,onDeleteSession:i}){let a=eb(),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(!1),[d,f]=(0,P.useState)(!1),p=n||d,h=async n=>{let r=t;f(!0);try{await a({sessionKey:e,projectRoot:n,persistToServer:r}),u(!1),c(!1)}finally{f(!1)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(Gt,{open:s,onOpenChange:c,children:[(0,I.jsx)(Ut,{asChild:!0,children:(0,I.jsx)(m,{variant:`ghost`,size:`icon`,className:`rounded-lg shrink-0 text-gray-400 hover:text-gray-700`,"aria-label":o(`chatSessionMoreActions`),disabled:p,children:(0,I.jsx)(rn,{className:`h-4 w-4`})})}),(0,I.jsx)(Vt,{align:`end`,className:`w-56 p-2`,children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(tb,{icon:on,label:o(`chatSessionSetProject`),onClick:()=>{c(!1),u(!0)},disabled:p}),(0,I.jsx)(tb,{icon:Ye,label:o(`chatDeleteSession`),onClick:()=>{c(!1),i()},disabled:!t||p,destructive:!0})]})})]}),(0,I.jsx)(ob,{open:l,currentProjectRoot:r,isSaving:d,onOpenChange:u,onSave:h})]})}function cb({sessionKey:e,projectName:t,projectRoot:n,persistToServer:r}){let i=eb(),[a,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=async t=>{d(!0);try{await i({sessionKey:e,projectRoot:t,persistToServer:r}),l(!1),s(!1)}finally{d(!1)}};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(Gt,{open:a,onOpenChange:s,children:[(0,I.jsx)(Ut,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,title:n??void 0,className:`min-w-0 max-w-[320px] shrink rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 transition-colors hover:border-emerald-300 hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-60`,"aria-label":o(`chatSessionSetProject`),disabled:u,children:(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(on,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:t}),(0,I.jsx)(T,{className:`h-3 w-3 shrink-0 opacity-70`})]})})}),(0,I.jsxs)(Vt,{align:`start`,className:`w-72 p-2`,children:[(0,I.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-emerald-700/80`,children:t}),n?(0,I.jsx)(`div`,{className:`mt-1 break-all text-xs text-gray-500`,children:n}):null]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(tb,{icon:mn,label:o(`chatSessionSetProject`),onClick:()=>{s(!1),l(!0)},disabled:u}),(0,I.jsx)(tb,{icon:cn,label:o(`chatSessionClearProject`),onClick:()=>{f(null)},disabled:u})]})]})]}),(0,I.jsx)(ob,{open:c,currentProjectRoot:n,isSaving:u,onOpenChange:l,onSave:f})]})}function lb(){return(0,I.jsxs)(`section`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-gray-200`}),(0,I.jsx)(`div`,{className:`h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80`}),(0,I.jsx)(`div`,{className:`h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80`}),(0,I.jsx)(`div`,{className:`h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80`})]})})}),(0,I.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,I.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white shadow-card p-4`,children:[(0,I.jsx)(`div`,{className:`h-16 w-full animate-pulse rounded-xl bg-gray-200/80`}),(0,I.jsxs)(`div`,{className:`mt-3 flex items-center justify-between`,children:[(0,I.jsx)(`div`,{className:`h-8 w-36 animate-pulse rounded-lg bg-gray-200/80`}),(0,I.jsx)(`div`,{className:`h-8 w-20 animate-pulse rounded-lg bg-gray-200/80`})]})]})})})]})}function ub(){let e=Tr(),t=cy(e=>e.snapshot),n=(0,P.useRef)(null),r=t.threadRef??n,i=t.childSessionTabs.filter(e=>e.parentSessionKey===t.sessionKey),a=i.some(e=>e.sessionKey===t.activeChildSessionKey)?t.activeChildSessionKey:i[i.length-1]?.sessionKey??null,s=!!(t.sessionKey||t.sessionTypeLabel),c=t.sessionDisplayName||(t.canDeleteSession&&t.sessionKey?t.sessionKey:null)||o(`chatSidebarNewTask`),l=t.agentId?.trim()??``,d=l.length>0&&l.toLowerCase()!==`main`,f=!t.canDeleteSession&&t.messages.length===0&&!t.isSending,p=t.modelOptions.length>0,m=t.isProviderStateResolved&&!p,h=t.isHistoryLoading&&t.messages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:g}=Sh({scrollRef:r,resetKey:t.sessionKey,isLoading:t.isHistoryLoading,hasContent:t.messages.length>0,contentVersion:t.messages[t.messages.length-1]??null});return t.isProviderStateResolved?(0,I.jsxs)(`section`,{className:`flex-1 min-h-0 flex overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[t.parentSessionKey?(0,I.jsx)(`div`,{className:`border-b border-gray-200/60 bg-white/75 px-5 py-2 backdrop-blur-sm`,children:(0,I.jsxs)(`button`,{type:`button`,onClick:e.chatThreadManager.goToParentSession,className:`inline-flex items-center gap-2 text-xs font-medium text-gray-600 transition-colors hover:text-gray-900`,children:[(0,I.jsx)(me,{className:`h-3.5 w-3.5`}),(0,I.jsxs)(`span`,{children:[o(`chatBackToParent`),t.parentSessionLabel?.trim()?` · ${t.parentSessionLabel.trim()}`:``]})]})}):null,(0,I.jsxs)(`div`,{className:u(`px-5 border-b border-gray-200/60 bg-white/80 backdrop-blur-sm flex items-center justify-between shrink-0 overflow-hidden transition-all duration-200`,s?`py-3 opacity-100`:`h-0 py-0 opacity-0 border-b-0`),children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[d?(0,I.jsx)(`div`,{className:`inline-flex shrink-0 items-center`,children:(0,I.jsx)(ar,{agentId:l,displayName:t.agentDisplayName,avatarUrl:t.agentAvatarUrl,className:`h-5 w-5`})}):null,(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:c}),t.sessionTypeLabel?(0,I.jsx)(`span`,{className:`shrink-0 rounded-full border border-gray-200 bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:t.sessionTypeLabel}):null,t.sessionProjectName?(0,I.jsx)(cb,{sessionKey:t.sessionKey??`draft`,projectName:t.sessionProjectName,projectRoot:t.sessionProjectRoot,persistToServer:t.canDeleteSession}):null]}),t.sessionKey?(0,I.jsx)(sb,{sessionKey:t.sessionKey,canDeleteSession:t.canDeleteSession,isDeletePending:t.isDeletePending,projectRoot:t.sessionProjectRoot,onDeleteSession:e.chatThreadManager.deleteSession}):null]}),m&&(0,I.jsxs)(`div`,{className:`px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 flex items-center justify-between gap-3 shrink-0`,children:[(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:o(`chatModelNoOptions`)}),(0,I.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:o(`chatGoConfigureProvider`)})]}),t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()&&(0,I.jsx)(`div`,{className:`px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0`,children:(0,I.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}),(0,I.jsx)(`div`,{ref:r,onScroll:g,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:f?(0,I.jsx)($y,{onCreateSession:e.chatThreadManager.createSession,agents:t.availableAgents??[],selectedAgentId:t.agentId??`main`,onSelectAgent:e.chatSessionListManager.setSelectedAgentId}):h?(0,I.jsx)(`div`,{className:`h-full`}):t.messages.length===0?(0,I.jsx)(`div`,{className:`px-5 py-5 text-sm text-gray-500`,children:o(`chatNoMessages`)}):(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,I.jsx)(hy,{messages:t.messages,isSending:t.isSending&&t.isAwaitingAssistantOutput,onToolAction:e.chatThreadManager.openSessionFromToolAction},t.sessionKey??`draft`)})}),(0,I.jsx)(d_,{})]}),a?(0,I.jsx)(Zy,{tabs:i,activeSessionKey:a,onSelectSession:e.chatThreadManager.selectChildSessionDetail,onClose:e.chatThreadManager.closeChildSessionDetail,onBackToParent:e.chatThreadManager.goToParentSession,onToolAction:e.chatThreadManager.openSessionFromToolAction}):null]}):(0,I.jsx)(lb,{})}var db=`native`;function fb(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:db}function pb(e,t){return e===`native`?o(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function mb(e){let t=new Map;for(let n of e){let e=fb(n.value);t.set(e,{value:e,label:n.label?.trim()||pb(e),ready:n.ready??!0,reason:n.reason??null,reasonMessage:n.reasonMessage??null,supportedModels:n.supportedModels,recommendedModel:n.recommendedModel??null,cta:n.cta??null})}return t.has(`native`)||t.set(db,{value:db,label:pb(db),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function hb(e){let{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:a}=e,s=(0,P.useMemo)(()=>mb(a?.options??[]),[a?.options]),c=(0,P.useMemo)(()=>{let e=[...s],n=fb(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:pb(n),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),e.sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))},[s,t?.sessionType]),l=(0,P.useMemo)(()=>fb(a?.defaultType??`native`),[a?.defaultType]),u=(0,P.useRef)(null),d=(0,P.useMemo)(()=>fb(t?.sessionType??r??l),[l,r,t?.sessionType]),f=(0,P.useMemo)(()=>c.find(e=>e.value===d)??null,[d,c]);(0,P.useEffect)(()=>{if(n)return;let e=typeof r==`string`?r.trim():``,t=fb(r);(e.length===0||u.current===t||u.current===null&&t===`native`)&&(u.current=l,t!==l&&i(l))},[l,r,n,i]);let p=!n||!!t?.sessionTypeMutable,m=(0,P.useMemo)(()=>new Set(s.map(e=>e.value)),[s]);return{sessionTypeOptions:c,selectedSessionTypeOption:f,defaultSessionType:l,selectedSessionType:d,canEditSessionType:p,sessionTypeUnavailable:(0,P.useMemo)(()=>t&&!m.has(fb(t.sessionType))?!0:f?.ready===!1,[m,t,f?.ready]),sessionTypeUnavailableMessage:(0,P.useMemo)(()=>t&&!m.has(fb(t.sessionType))?`${pb(d)} ${o(`chatSessionTypeUnavailableSuffix`)}`:f?.ready===!1?f.reasonMessage?.trim()||`${f.label} setup required`:null,[m,t,d,f])}}var gb={id:``,displayName:``,description:``,avatar:``,model:``,home:``,runtime:``},_b={displayName:``,description:``,avatar:``,model:``,runtime:``};function vb(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``}}function yb(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=fb(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:pb(i),ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function bb({value:e,disabled:t=!1,runtimeOptions:n,defaultRuntime:r,onChange:i}){let a=e.trim()?fb(e):``,s=yb({runtimeOptions:n,currentRuntime:e}),c=s.find(e=>e.value===a)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?o(`agentsRuntimeUnavailableHelp`):``);return(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(ue,{value:a||r,onValueChange:e=>i(e===r?``:e),disabled:t,children:[(0,I.jsx)(ne,{"aria-label":o(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,I.jsx)(D,{placeholder:o(`agentsRuntimeSelectPlaceholder`)})}),(0,I.jsx)(M,{className:`rounded-xl`,children:s.map(e=>(0,I.jsx)(ce,{value:e.value,disabled:e.ready===!1&&e.value!==a,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,I.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function xb({open:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:s}){let[c,l]=(0,P.useState)(gb);return(0,P.useEffect)(()=>{e||t||l(gb)},[e,t]),(0,I.jsx)(gt,{open:e,onOpenChange:a,children:(0,I.jsxs)(Ft,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,I.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,I.jsxs)(St,{className:`text-left`,children:[(0,I.jsx)(ft,{children:o(`agentsCreateDialogTitle`)}),(0,I.jsx)(Et,{children:o(`agentsCreateDialogDescription`)})]})}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,I.jsx)(lt,{value:c.id,onChange:e=>l(t=>({...t,id:e.target.value})),placeholder:o(`agentsFormIdPlaceholder`)}),(0,I.jsx)(lt,{value:c.displayName,onChange:e=>l(t=>({...t,displayName:e.target.value})),placeholder:o(`agentsFormNamePlaceholder`)}),(0,I.jsx)(`textarea`,{value:c.description,onChange:e=>l(t=>({...t,description:e.target.value})),placeholder:o(`agentsFormDescriptionPlaceholder`),rows:4,className:`min-h-28 rounded-xl border border-gray-200/80 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-300 focus:border-primary/40 focus:outline-none focus:ring-1 focus:ring-primary/40 md:col-span-2`}),(0,I.jsx)(lt,{value:c.avatar,onChange:e=>l(t=>({...t,avatar:e.target.value})),placeholder:o(`agentsFormAvatarPlaceholder`)}),(0,I.jsx)(lt,{value:c.home,onChange:e=>l(t=>({...t,home:e.target.value})),placeholder:o(`agentsFormHomePlaceholder`)}),(0,I.jsx)(be,{value:c.model,onChange:e=>l(t=>({...t,model:e})),providerCatalog:n,disabled:t,className:`md:col-span-2`}),(0,I.jsx)(bb,{value:c.runtime,onChange:e=>l(t=>({...t,runtime:e})),runtimeOptions:r,defaultRuntime:i,disabled:t})]}),(0,I.jsx)(`div`,{className:`rounded-2xl border border-[#efe3ca] bg-[#fff9ef] px-4 py-3 text-xs leading-6 text-[#7a6246]`,children:o(`agentsCreateDialogHint`)})]})}),(0,I.jsxs)(Mt,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,I.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>a(!1),disabled:t,children:o(`cancel`)}),(0,I.jsxs)(m,{type:`button`,className:`rounded-2xl bg-[#1f5c4d] px-5 text-white hover:bg-[#184d40]`,onClick:()=>void s(c),disabled:t||c.id.trim().length===0,children:[(0,I.jsx)(Fe,{className:`mr-2 h-4 w-4`}),o(`agentsCreateAction`)]})]})]})})}function Sb({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:s}){let[c,l]=(0,P.useState)(_b);return(0,P.useEffect)(()=>{if(!e){l(_b);return}l(vb(e))},[e]),(0,I.jsx)(gt,{open:e!==null,onOpenChange:a,children:(0,I.jsxs)(Ft,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,I.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,I.jsxs)(St,{className:`text-left`,children:[(0,I.jsx)(ft,{children:o(`agentsEditDialogTitle`)}),(0,I.jsx)(Et,{children:o(`agentsEditDialogDescription`)})]})}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`rounded-2xl border border-[#efe3ca] bg-[#fff9ef] px-4 py-3 text-xs leading-6 text-[#7a6246]`,children:[(0,I.jsx)(`div`,{className:`font-semibold uppercase tracking-[0.16em] text-[#9b6118]`,children:o(`agentsEditHomeReadonly`)}),(0,I.jsx)(`div`,{className:`mt-1 break-all text-sm text-[#3f3323]`,children:e?.workspace??`-`}),(0,I.jsx)(`div`,{className:`mt-1 text-[11px] text-[#8d7456]`,children:o(`agentsEditHomeReadonlyHint`)})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,I.jsx)(lt,{value:c.displayName,onChange:e=>l(t=>({...t,displayName:e.target.value})),placeholder:o(`agentsFormNamePlaceholder`)}),(0,I.jsx)(`textarea`,{value:c.description,onChange:e=>l(t=>({...t,description:e.target.value})),placeholder:o(`agentsFormDescriptionPlaceholder`),rows:4,className:`min-h-28 rounded-xl border border-gray-200/80 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-300 focus:border-primary/40 focus:outline-none focus:ring-1 focus:ring-primary/40 md:col-span-2`}),(0,I.jsx)(lt,{value:c.avatar,onChange:e=>l(t=>({...t,avatar:e.target.value})),placeholder:o(`agentsFormAvatarPlaceholder`)}),(0,I.jsx)(be,{value:c.model,onChange:e=>l(t=>({...t,model:e})),providerCatalog:n,disabled:t,className:`md:col-span-2`}),(0,I.jsx)(bb,{value:c.runtime,onChange:e=>l(t=>({...t,runtime:e})),runtimeOptions:r,defaultRuntime:i,disabled:t})]})]})}),(0,I.jsxs)(Mt,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,I.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>a(!1),disabled:t,children:o(`cancel`)}),(0,I.jsxs)(m,{type:`button`,className:`rounded-2xl bg-[#1f5c4d] px-5 text-white hover:bg-[#184d40]`,onClick:()=>e&&s(e.id,c),disabled:t||e===null,children:[(0,I.jsx)(mn,{className:`mr-2 h-4 w-4`}),o(`agentsEditSaveAction`)]})]})]})})}function Cb(){return f({queryKey:[`ncp-session-types`],queryFn:Ze,staleTime:1e4,retry:!1})}var wb=[{strip:`bg-[#efc37a]`,chip:`border-[#f2d7a7] bg-[#fff8eb] text-[#8d5a18]`},{strip:`bg-[#8fd4c0]`,chip:`border-[#bde6da] bg-[#effbf7] text-[#156653]`},{strip:`bg-[#b7c9fb]`,chip:`border-[#d7e2ff] bg-[#f4f7ff] text-[#2d4d8f]`}];function Tb(e,t){return t?{strip:`bg-[#e6b765]`,chip:`border-[#f2d19c] bg-[#fff8ec] text-[#90550d]`}:wb[e%wb.length]}function Eb(){let e=b(),t=Ng(),n=mt(),r=Ct(),i=Cb(),a=Pg(),s=Fg(),c=Ig(),[l,d]=(0,P.useState)(!1),[f,p]=(0,P.useState)(null),h=L(e=>e.setSnapshot),g=(0,P.useMemo)(()=>t.data?.agents??[],[t.data?.agents]),_=(0,P.useMemo)(()=>[...g].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[g]),v=(0,P.useMemo)(()=>ve({config:n.data,meta:r.data,onlyConfigured:!0}),[r.data,n.data]),y=(0,P.useMemo)(()=>mb(i.data?.options??[]),[i.data?.options]),x=(0,P.useMemo)(()=>fb(i.data?.defaultType??`native`),[i.data?.defaultType]),S=(0,P.useMemo)(()=>y.find(e=>e.value===x)?.label??pb(x),[x,y]),C=async e=>{await a.mutateAsync({data:{id:e.id,...e.displayName.trim()?{displayName:e.displayName.trim()}:{},...e.description.trim()?{description:e.description.trim()}:{},...e.avatar.trim()?{avatar:e.avatar.trim()}:{},...e.home.trim()?{home:e.home.trim()}:{},...e.model.trim()?{model:e.model.trim()}:{},...e.runtime.trim()?{runtime:e.runtime.trim()}:{}}}),d(!1)},w=e=>{p(e)},T=async(e,t)=>{await s.mutateAsync({agentId:e,data:{displayName:t.displayName,description:t.description,avatar:t.avatar,model:t.model,...t.runtime.trim()?{runtime:t.runtime.trim()}:{runtime:``}}}),p(null)},E=t=>{h({selectedAgentId:t,selectedSessionKey:null}),e(`/chat`)};return(0,I.jsxs)(Jt,{className:`space-y-5`,children:[(0,I.jsxs)(`section`,{className:`relative overflow-hidden rounded-[28px] border border-[#f0d6aa] bg-[linear-gradient(135deg,#fff7ea_0%,#fff9f1_32%,#f2fbff_100%)] px-5 py-5 sm:px-6`,children:[(0,I.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-[46%] bg-[radial-gradient(circle_at_top_right,rgba(255,215,163,0.52),transparent_54%)]`}),(0,I.jsx)(`div`,{className:`absolute -bottom-10 left-8 h-32 w-32 rounded-full bg-[#ffe6c0]/55 blur-3xl`}),(0,I.jsxs)(`div`,{className:`relative grid gap-5 xl:grid-cols-[minmax(0,1fr)_320px] xl:items-center`,children:[(0,I.jsxs)(`div`,{className:`max-w-3xl space-y-3`,children:[(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-white/70 bg-white/80 px-3 py-1 text-[11px] font-semibold tracking-[0.16em] text-[#9b6118]`,children:[(0,I.jsx)(ht,{className:`h-3.5 w-3.5`}),o(`agentsHeroEyebrow`)]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(`h1`,{className:`max-w-2xl text-[30px] font-semibold leading-tight tracking-[-0.05em] text-[#2f2212] sm:text-[38px]`,children:o(`agentsHeroTitle`)}),(0,I.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-[#6d5841] sm:text-[15px] sm:leading-7`,children:o(`agentsHeroDescription`)})]}),(0,I.jsx)(`div`,{className:`pt-1`,children:(0,I.jsxs)(`div`,{className:`inline-flex items-center gap-3 rounded-2xl border border-[#f2d5a4] bg-white/82 px-3 py-2 text-[#7a4d12] shadow-[0_14px_30px_rgba(167,117,47,0.07)]`,children:[(0,I.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[0.14em]`,children:o(`agentsOverviewTotal`)}),(0,I.jsx)(`span`,{className:`text-xl font-semibold tracking-[-0.04em] text-[#1f2937]`,children:g.length})]})})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-3`,children:[(0,I.jsxs)(m,{type:`button`,className:`h-10 rounded-2xl bg-[#1f5c4d] px-5 text-sm font-semibold text-white hover:bg-[#184d40]`,onClick:()=>d(!0),children:[(0,I.jsx)(Fe,{className:`mr-2 h-4 w-4`}),o(`agentsCreateButton`)]}),(0,I.jsx)(`div`,{className:`rounded-2xl border border-white/70 bg-white/72 px-4 py-3 text-xs leading-6 text-[#6d5841] shadow-[0_18px_40px_rgba(167,117,47,0.08)]`,children:o(`agentsCreateDialogHint`)})]})]})]}),(0,I.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:t.isLoading?(0,I.jsx)(et,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,I.jsx)(nt,{className:`py-14 text-center text-sm text-gray-500`,children:o(`agentsLoading`)})}):_.length===0?(0,I.jsx)(et,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-[#d9dce3] bg-[linear-gradient(135deg,#fff7ea_0%,#f4fbff_100%)]`,children:(0,I.jsxs)(nt,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,I.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,I.jsx)(yt,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,I.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:o(`agentsEmpty`)}),(0,I.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:o(`agentsEmptyDescription`)}),(0,I.jsxs)(m,{type:`button`,className:`mt-5 rounded-2xl bg-[#1f5c4d] px-5 text-white hover:bg-[#184d40]`,onClick:()=>d(!0),children:[(0,I.jsx)(Fe,{className:`mr-2 h-4 w-4`}),o(`agentsCreateButton`)]})]})}):_.map((e,t)=>{let n=Tb(t,!!e.builtIn),r=e.runtime?.trim()||e.engine?.trim()||``,i=r?y.find(e=>e.value===fb(r))?.label??pb(r):S;return(0,I.jsxs)(et,{className:`overflow-hidden border border-gray-200 bg-white shadow-sm transition-shadow duration-200 hover:shadow-md`,children:[(0,I.jsx)(`div`,{className:u(`h-1.5 w-full`,n.strip)}),(0,I.jsxs)(nt,{className:`flex h-full flex-col gap-4 px-4 py-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(ar,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-11 w-11 shrink-0`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 pt-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`truncate text-lg font-semibold tracking-[-0.03em] text-[#1f2937]`,children:e.displayName?.trim()||e.id}),e.builtIn?(0,I.jsxs)(`span`,{className:u(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,n.chip),children:[(0,I.jsx)(vn,{className:`h-3 w-3`}),o(`agentsCardBuiltInTag`)]}):null]}),(0,I.jsxs)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.18em] text-[#94a3b8]`,children:[`@`,e.id]})]})]}),(0,I.jsx)(`p`,{className:`text-sm leading-6 text-[#64748b]`,children:e.description?.trim()||(e.builtIn?o(`agentsCardBuiltInSummary`):o(`agentsCardCustomSummary`))}),(0,I.jsxs)(`div`,{className:`mt-auto flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.18em] text-[#94a3b8]`,children:[(0,I.jsx)(ht,{className:`h-3.5 w-3.5`}),o(`agentsCardRuntimeLabel`)]}),(0,I.jsx)(`div`,{className:`mt-1.5 text-sm leading-6 text-[#475569]`,children:i})]}),(0,I.jsxs)(`div`,{className:`border-t border-gray-100 pt-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.18em] text-[#94a3b8]`,children:[(0,I.jsx)(un,{className:`h-3.5 w-3.5`}),o(`agentsCardHomeLabel`)]}),(0,I.jsx)(`div`,{className:`mt-1.5 break-all text-sm leading-6 text-[#475569]`,children:e.workspace??`-`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(m,{type:`button`,className:`h-9 rounded-xl bg-[#1f5c4d] px-4 text-white hover:bg-[#184d40]`,onClick:()=>E(e.id),children:[(0,I.jsx)(vt,{className:`mr-2 h-4 w-4`}),o(`agentsCardStartChat`)]}),(0,I.jsxs)(m,{type:`button`,variant:`ghost`,className:`h-8 rounded-xl px-3 text-xs text-[#7b8794] hover:bg-[#f3f4f6] hover:text-[#475569]`,onClick:()=>w(e),disabled:s.isPending,children:[(0,I.jsx)(mn,{className:`mr-1.5 h-3.5 w-3.5`}),o(`agentsEditAction`)]}),e.builtIn?null:(0,I.jsxs)(m,{type:`button`,variant:`ghost`,className:`h-8 rounded-xl px-3 text-xs text-[#7b8794] hover:bg-[#f3f4f6] hover:text-[#475569]`,onClick:()=>c.mutate({agentId:e.id}),disabled:c.isPending,children:[(0,I.jsx)(Ye,{className:`mr-1.5 h-3.5 w-3.5`}),o(`agentsRemoveAction`)]})]})]})]})]},e.id)})}),(0,I.jsx)(xb,{open:l,pending:a.isPending,providerCatalog:v,runtimeOptions:y,defaultRuntime:x,onOpenChange:d,onSubmit:C}),(0,I.jsx)(Sb,{agent:f,pending:s.isPending,providerCatalog:v,runtimeOptions:y,defaultRuntime:x,onOpenChange:e=>{!e&&!s.isPending&&p(null)},onSubmit:T})]})}function Db(e){return c(e??void 0)}function Ob(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:c(new Date(e))}function kb(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function Ab(e){let t=e.schedule;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${kb(t.everyMs)}`:t.kind===`at`?`at ${Ob(t.atMs)}`:`-`}function jb(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function Mb(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.channel??``,e.payload.to??``].join(` `).toLowerCase().includes(n):!0}function Nb(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function Pb(){let[e,t]=(0,P.useState)(``),[n,r]=(0,P.useState)(`all`),i=_t({all:!0}),a=kt(),s=ct(),c=st(),{confirm:l,ConfirmDialog:d}=Xt(),f=(0,P.useMemo)(()=>(i.data?.jobs??[]).filter(t=>Mb(t,e)).filter(e=>Nb(e,n)),[i.data,e,n]),p=async e=>{await l({title:`${o(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:o(`delete`)})&&a.mutate({id:e.id})},h=async e=>{let t=!e.enabled;await l({title:t?`${o(`cronEnableConfirm`)}?`:`${o(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:t?`default`:`destructive`,confirmLabel:o(t?`cronEnable`:`cronDisable`)})&&s.mutate({id:e.id,enabled:t})},g=async e=>{let t=!e.enabled;await l({title:t?`${o(`cronRunForceConfirm`)}?`:`${o(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:o(`cronRunNow`)})&&c.mutate({id:e.id,force:t})};return(0,I.jsxs)(Jt,{fullHeight:!0,children:[(0,I.jsx)(Yt,{title:o(`cronPageTitle`),description:o(`cronPageDescription`),actions:(0,I.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>i.refetch(),children:(0,I.jsx)(ze,{className:u(`h-4 w-4`,i.isFetching&&`animate-spin`)})})}),(0,I.jsx)(`div`,{className:`mb-6`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,I.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,I.jsx)(lt,{value:e,onChange:e=>t(e.target.value),placeholder:o(`cronSearchPlaceholder`),className:`pl-9`}),(0,I.jsx)(ut,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,I.jsx)(`div`,{className:`min-w-[180px]`,children:(0,I.jsxs)(ue,{value:n,onValueChange:e=>r(e),children:[(0,I.jsx)(ne,{className:`w-full`,children:(0,I.jsx)(D,{placeholder:o(`cronStatusLabel`)})}),(0,I.jsxs)(M,{children:[(0,I.jsx)(ce,{value:`all`,children:o(`cronStatusAll`)}),(0,I.jsx)(ce,{value:`enabled`,children:o(`cronStatusEnabled`)}),(0,I.jsx)(ce,{value:`disabled`,children:o(`cronStatusDisabled`)})]})]})}),(0,I.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[o(`cronTotalLabel`),`: `,i.data?.total??0,` / `,f.length]})]})}),(0,I.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:i.isLoading?(0,I.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:o(`cronLoading`)}):f.length===0?(0,I.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:o(`cronEmpty`)}):(0,I.jsx)(`div`,{className:`space-y-4`,children:f.map(e=>(0,I.jsx)(et,{className:`border border-gray-200`,children:(0,I.jsx)(nt,{className:`pt-5 pb-5`,children:(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,I.jsx)(`span`,{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500`,children:e.id}),(0,I.jsx)(`span`,{className:u(`text-[10px] font-semibold px-2 py-0.5 rounded-full`,e.enabled?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-500`),children:e.enabled?o(`enabled`):o(`disabled`)}),e.deleteAfterRun&&(0,I.jsx)(`span`,{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700`,children:o(`cronOneShot`)})]}),(0,I.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[o(`cronScheduleLabel`),`: `,Ab(e)]}),(0,I.jsx)(`div`,{className:`mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words`,children:e.payload.message}),(0,I.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[o(`cronDeliverTo`),`: `,jb(e)]})]}),(0,I.jsxs)(`div`,{className:`min-w-[220px] text-xs text-gray-500 space-y-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[o(`cronNextRun`),`:`]}),` `,Db(e.state.nextRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[o(`cronLastRun`),`:`]}),` `,Db(e.state.lastRunAt)]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[o(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),e.state.lastError&&(0,I.jsx)(`div`,{className:`text-[11px] text-red-500 break-words`,children:e.state.lastError})]}),(0,I.jsxs)(`div`,{className:`flex items-start gap-2 flex-wrap justify-end`,children:[(0,I.jsxs)(m,{variant:`subtle`,size:`sm`,onClick:()=>g(e),className:`gap-1`,children:[(0,I.jsx)(hn,{className:`h-3.5 w-3.5`}),o(`cronRunNow`)]}),(0,I.jsxs)(m,{variant:e.enabled?`outline`:`primary`,size:`sm`,onClick:()=>h(e),className:`gap-1`,children:[(0,I.jsx)(gn,{className:`h-3.5 w-3.5`}),e.enabled?o(`cronDisable`):o(`cronEnable`)]}),(0,I.jsxs)(m,{variant:`destructive`,size:`sm`,onClick:()=>p(e),className:`gap-1`,children:[(0,I.jsx)(Ye,{className:`h-3.5 w-3.5`}),o(`delete`)]})]})]})})},e.id))})}),(0,I.jsx)(d,{})]})}function Fb(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,setSelectedSessionKey:i,selectedSessionKeyRef:a,resetStreamState:o}=e;(0,P.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&i(n);return}r!==null&&(i(null),o())}},[o,n,r,i,t]),(0,P.useEffect)(()=>{a.current=r},[r,a])}function Ib({view:e,confirmDialog:t}){return(0,I.jsxs)(`div`,{className:`h-full flex`,children:[(0,I.jsx)(Vg,{}),e===`chat`?(0,I.jsx)(ub,{}):(0,I.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,I.jsx)(Pb,{})})}):e===`agents`?(0,I.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,I.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-6 py-5`,children:(0,I.jsx)(Eb,{})})}):(0,I.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,I.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-6 py-5`,children:(0,I.jsx)(Ne,{forcedType:`skills`})})})}),t]})}var Lb=`sid_`;function Rb(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${Lb}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function zb(e){if(!e.startsWith(Lb))return null;let t=e.slice(4).replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4);try{let e=atob(t+n),r=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function Bb(e){if(!e)return null;let t=zb(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function Vb(e){return`/chat/${Rb(e)}`}function Hb(e){return e?.trim().toLowerCase()||`native`}function Ub(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function Wb(e,t){return typeof t==`string`&&e.includes(t)}function Gb(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function Kb(e){let{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:a,firstAvailableValue:o,preferSessionPreferredValue:s=!1,preserveCurrentValueOnSessionChange:c=!1}=e;return a(t)&&(!s||c)?t:a(n)?n:a(r)?r:a(i)?i:o}function qb(e){let{modelOptions:t}=e;return t.length===0?``:Kb({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:e=>Ub(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function Jb(e){let{supportedThinkingLevels:t}=e;return t.length===0?null:Kb({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:e=>Wb(t,e),firstAvailableValue:Gb(t)??`off`,preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function Yb(e){let t=Hb(e.sessionType),n,r=-1/0;for(let i of e.sessions){if(i.key===e.selectedSessionKey||Hb(i.sessionType)!==t)continue;let a=e.readPreference(i);if(a==null)continue;let o=Date.parse(i.updatedAt),s=Number.isFinite(o)?o:-1/0;(n===void 0||s>r)&&(n=a,r=s)}return n}function Xb(e){return Yb({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:e=>e.preferredModel?.trim()||void 0})}function Zb(e){return Yb({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:e=>e.preferredThinking??void 0})}function Qb(e){let{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:a,resolveValue:o}=e,s=(0,P.useRef)(void 0),c=(0,P.useRef)(o);(0,P.useEffect)(()=>{c.current=o},[o]),(0,P.useEffect)(()=>{let e=s.current!==r;if(!t){a(n),s.current=r;return}a(t=>c.current({currentValue:t,sessionChanged:e,preserveCurrentValueOnSessionChange:e&&!!r&&!i})),s.current=r},[n,t,i,r,a])}function $b(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;Qb({isPreferenceAvailable:t.length>0,emptyValue:``,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>qb({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function ex(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;Qb({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>Jb({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function tx(e,t){return e.filter(e=>He(e,t))}function nx(e){if(!e.supportedModels||e.supportedModels.length===0)return e.modelOptions;let t=new Set(e.supportedModels),n=e.modelOptions.filter(e=>t.has(e.value));return n.length>0?n:e.modelOptions}function rx(e){let t=mt(),n=Ct(),r=pt({limit:200}),i=Cb(),a=Lt({sessionId:e.sessionKey,...Object.prototype.hasOwnProperty.call(e,`projectRootOverride`)?{projectRoot:e.projectRootOverride??null}:{}}),o=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),s=(0,P.useMemo)(()=>{let e=ve({meta:n.data,config:t.data,onlyConfigured:!0}),r=new Set,i=[];for(let t of e)for(let e of t.models){let n=ye(t.prefix,e);!n||r.has(n)||(r.add(n),i.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:_e(t.modelThinking,e,t.aliases)}))}return i.sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})},[n.data,t.data]),c=(0,P.useMemo)(()=>r.data?.sessions??[],[r.data?.sessions]),l=(0,P.useMemo)(()=>Be(c),[c]),u=(0,P.useMemo)(()=>tx(l,e.query),[l,e.query]),d=(0,P.useMemo)(()=>l.find(t=>t.key===e.sessionKey)??null,[l,e.sessionKey]),f=(0,P.useMemo)(()=>a.data?.records??[],[a.data?.records]),p=hb({selectedSession:d,selectedSessionKey:e.sessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=(0,P.useMemo)(()=>nx({modelOptions:s,supportedModels:p.selectedSessionTypeOption?.supportedModels}),[s,p.selectedSessionTypeOption?.supportedModels]),h=(0,P.useMemo)(()=>Xb({sessions:l,selectedSessionKey:e.sessionKey,sessionType:p.selectedSessionType}),[l,e.sessionKey,p.selectedSessionType]),g=(0,P.useMemo)(()=>m.find(t=>t.value===e.currentSelectedModel),[m,e.currentSelectedModel]),_=(0,P.useMemo)(()=>g?.thinkingCapability?.supported??[],[g?.thinkingCapability?.supported]),v=(0,P.useMemo)(()=>g?.thinkingCapability?.default??null,[g?.thinkingCapability?.default]),y=(0,P.useMemo)(()=>Zb({sessions:l,selectedSessionKey:e.sessionKey,sessionType:p.selectedSessionType}),[l,e.sessionKey,p.selectedSessionType]);return $b({modelOptions:m,selectedSessionKey:e.sessionKey,selectedSessionExists:!!d,selectedSessionPreferredModel:d?.preferredModel,fallbackPreferredModel:p.selectedSessionTypeOption?.recommendedModel??h,defaultModel:p.selectedSessionTypeOption?.recommendedModel??t.data?.agents.defaults.model,setSelectedModel:e.setSelectedModel}),ex({supportedThinkingLevels:_,selectedSessionKey:e.sessionKey,selectedSessionExists:!!d,selectedSessionPreferredThinking:d?.preferredThinking??null,fallbackPreferredThinking:y??null,defaultThinkingLevel:v,setSelectedThinkingLevel:e.setSelectedThinkingLevel}),{configQuery:t,configMetaQuery:n,sessionsQuery:r,sessionTypesQuery:i,sessionSkillsQuery:a,isProviderStateResolved:o,modelOptions:m,sessionSummaries:c,sessions:u,skillRecords:f,selectedSession:d,...p}}var ix=class{constructor(e,t){this.uiManager=e,this.streamActionsManager=t,this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.setSelectedAgentId=e=>{let t=L.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&L.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=L.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&L.getState().setSnapshot({selectedSessionKey:n})},this.createSession=e=>{let{snapshot:t}=Q.getState(),{defaultSessionType:n}=t,r=n||`native`,i=typeof e==`string`&&e.trim().length>0?e.trim():r;this.streamActionsManager.resetStreamState(),Q.getState().setSnapshot({pendingSessionType:i,pendingProjectRoot:null,pendingProjectRootSessionKey:null}),this.uiManager.goToChatRoot()},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=L.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&L.getState().setSnapshot({query:n})}}},ax=async()=>{},ox=()=>{},sx=class{constructor(){this.actions={sendMessage:ax,stopCurrentRun:ax,resumeRun:ax,resetStreamState:ox,applyHistoryMessages:ox},this.bind=e=>{this.actions={...this.actions,...e}},this.sendMessage=e=>this.actions.sendMessage(e),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=e=>this.actions.resumeRun(e),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(e,t)=>this.actions.applyHistoryMessages(e,t)}},cx=async e=>!1,lx=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:cx},this.syncState=e=>{this.state={...this.state,...e}},this.bindActions=e=>{this.actions={...this.actions,...e}},this.confirm=async e=>this.actions.confirm(e),this.navigateTo=(e,t)=>{this.actions.navigate&&(this.state.pathname===e&&!t?.replace||(this.actions.navigate(e,t),this.state.pathname=e))},this.goToProviders=()=>{this.navigateTo(`/providers`)},this.goToChatRoot=e=>{this.navigateTo(`/chat`,e)},this.goToSession=(e,t)=>{this.navigateTo(Vb(e),t)}}};function ux(e){let t=e.trim();return t.length>0?t:null}function dx(e){return e??null}var fx=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=Q.getState().snapshot,t=L.getState().snapshot.selectedSessionKey;t&&this.enqueue({sessionKey:t,patch:{preferredModel:ux(e.selectedModel),preferredThinking:dx(e.selectedThinkingLevel)}})}}enqueue(e){this.queued=e,!this.inFlight&&this.startFlush()}startFlush(){this.inFlight=this.flush().catch(e=>{console.error(`Failed to sync chat session preferences: ${String(e)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})}async flush(){for(;this.queued;){let e=this.queued;this.queued=null,await this.updateSession(e.sessionKey,e.patch)}}},px=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.getDraftSessionId=n,this.sessionPreferenceSync=new fx($e),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=Q.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.resolveUpdateValue=(e,t)=>typeof t==`function`?t(e):t,this.isSameStringArray=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),this.syncComposerSnapshot=e=>{let t=Q.getState().snapshot.attachments,n=Eg(e,t);Q.getState().setSnapshot({composerNodes:e,attachments:n,draft:xg(e),selectedSkills:Sg(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{Q.getState().setSnapshot({composerNodes:e,attachments:t,draft:xg(e),selectedSkills:Sg(e)})},this.dedupeAttachments=e=>{let t=new Set,n=[];for(let r of e){let e=this.buildAttachmentSignature(r);t.has(e)||(t.add(e),n.push(r))}return n},this.syncSnapshot=e=>{if(this.hasSnapshotChanges(e)&&(Q.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=Q.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=Q.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(bg(n))},this.setComposerNodes=e=>{let t=Q.getState().snapshot.composerNodes,n=this.resolveUpdateValue(t,e);Object.is(n,t)||this.syncComposerSnapshot(n)},this.addAttachments=e=>{if(e.length===0)return[];let t=Q.getState().snapshot,n=new Set(t.attachments.map(this.buildAttachmentSignature)),r=this.dedupeAttachments([...t.attachments,...e]),i=r.filter(e=>!n.has(this.buildAttachmentSignature(e)));if(i.length===0)return[];let a=Tg(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=Tg(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=Q.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&Q.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=Q.getState().snapshot,t=L.getState().snapshot,n=e.draft.trim(),r=e.attachments,i=Dg(e.composerNodes,r);if(!i.some(e=>e.type!==`text`||e.text.trim().length>0))return;let{selectedSkills:a,composerNodes:o}=e,s=t.selectedSessionKey??this.getDraftSessionId();t.selectedSessionKey||this.uiManager.goToSession(s,{replace:!0}),this.setComposerNodes(yg()),await this.streamActionsManager.sendMessage({message:n,sessionKey:s,agentId:t.selectedAgentId,sessionType:e.selectedSessionType,model:e.selectedModel||void 0,thinkingLevel:e.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:a,attachments:r,parts:i,restoreDraftOnError:!0,composerNodes:o})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=e=>{let t=Q.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&(Q.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=Q.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&Q.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=fb(e);Q.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let t=Q.getState().snapshot,{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(wg(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),o_.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.rememberSkillSelection=e=>{s_.remember(e)},this.selectSkills=e=>{let t=Q.getState().snapshot.selectedSkills;for(let n of e)t.includes(n)||this.rememberSkillSelection(n);this.setSelectedSkills(e)},this.resolveThinkingForModel=(e,t)=>{let n=e?.thinkingCapability;return!n||n.supported.length===0?null:t===`off`?`off`:t&&n.supported.includes(t)?t:n.default&&n.supported.includes(n.default)?n.default:`off`},this.reconcileThinkingForModel=e=>{let t=Q.getState().snapshot,n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&Q.getState().setSnapshot({selectedThinkingLevel:i})}}},mx=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=cy.getState().snapshot;for(let[n,r]of Object.entries(e))if(!Object.is(t[n],r))return!0;return!1},this.syncSnapshot=e=>{this.hasSnapshotChanges(e)&&cy.getState().setSnapshot(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.upsertChildSessionTab=e=>{let{snapshot:t}=cy.getState(),n=t.childSessionTabs.findIndex(t=>t.sessionKey===e.sessionKey),r=n>=0?t.childSessionTabs.map((t,r)=>r===n?{...t,...e}:t):[...t.childSessionTabs,e];cy.getState().setSnapshot({childSessionTabs:r,activeChildSessionKey:e.sessionKey})},this.openSessionFromToolAction=e=>{if(e.kind===`open-session`){if(e.sessionKind===`child`&&!this.isCompactViewport()){let t=e.parentSessionId?.trim()||L.getState().snapshot.selectedSessionKey||null;this.upsertChildSessionTab({sessionKey:e.sessionId,parentSessionKey:t,label:e.label?.trim()||null,agentId:e.agentId?.trim()||null});return}this.uiManager.goToSession(e.sessionId)}},this.selectChildSessionDetail=e=>{let t=e.trim();if(!t)return;let{childSessionTabs:n}=cy.getState().snapshot;n.some(e=>e.sessionKey===t)&&cy.getState().setSnapshot({activeChildSessionKey:t})},this.closeChildSessionDetail=()=>{let{sessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=cy.getState().snapshot;if(!e){cy.getState().setSnapshot({childSessionTabs:[],activeChildSessionKey:null});return}let r=t.filter(t=>t.parentSessionKey!==e),i=r.some(e=>e.sessionKey===n)?n:null;cy.getState().setSnapshot({childSessionTabs:r,activeChildSessionKey:i})},this.goToParentSession=()=>{let{parentSessionKey:e,childSessionTabs:t,activeChildSessionKey:n}=cy.getState().snapshot,r=t.find(e=>e.sessionKey===n)?.parentSessionKey??null,i=e??r;i&&(this.closeChildSessionDetail(),this.uiManager.goToSession(i))},this.isCompactViewport=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(max-width: 767px)`).matches,this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=L.getState();if(e&&await this.uiManager.confirm({title:o(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:o(`delete`)})){cy.getState().setSnapshot({isDeletePending:!0});try{await it(e),tt(x,e),x.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0})}finally{cy.getState().setSnapshot({isDeletePending:!1})}}}}},hx=class{constructor(){this.chatUiManager=new lx,this.chatStreamActionsManager=new sx,this.chatSessionListManager=new ix(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new px(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatThreadManager=new mx(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId=``,this.setDraftSessionId=e=>{this.draftSessionId=e}}getDraftSessionId(){return this.draftSessionId}};function gx(e){let t=e.selectedSession?Ke(e.selectedSession):void 0,n=e.selectedSession?.agentId??e.selectedAgentId;return{currentSessionDisplayName:t,currentAgentId:n,currentAgent:e.availableAgents.find(e=>e.id===n)??null,parentSession:(0,P.useMemo)(()=>{if(!e.parentSessionId)return null;let t=e.sessionSummaries.find(t=>t.sessionId===e.parentSessionId)??null;return t?Le(t):null},[e.parentSessionId,e.sessionSummaries]),currentSessionTypeLabel:e.sessionTypeOptions.find(t=>t.value===e.selectedSessionType)?.label??pb(e.selectedSessionType)}}function _x(e){(0,P.useEffect)(()=>{e.presenter.chatInputManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,defaultSessionType:e.defaultSessionType,canStopGeneration:e.canStopCurrentRun,stopDisabledReason:e.stopDisabledReason,stopSupported:!0,stopReason:void 0,sendError:e.lastSendError,isSending:e.isSending,modelOptions:e.modelOptions,sessionTypeOptions:e.sessionTypeOptions,selectedSessionType:e.selectedSessionType,canEditSessionType:e.canEditSessionType,sessionTypeUnavailable:e.sessionTypeUnavailable,skillRecords:e.skillRecords,isSkillsLoading:e.isSkillsLoading}),e.presenter.chatThreadManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,modelOptions:e.modelOptions,sessionTypeUnavailable:e.sessionTypeUnavailable,sessionTypeUnavailableMessage:e.sessionTypeUnavailableMessage,sessionTypeLabel:e.currentSessionTypeLabel,sessionKey:e.sessionKey,agentId:e.currentAgentId,agentDisplayName:e.currentAgent?.displayName??null,agentAvatarUrl:e.currentAgent?.avatarUrl??null,availableAgents:e.availableAgents,sessionDisplayName:e.currentSessionDisplayName,sessionProjectRoot:e.effectiveSessionProjectRoot,sessionProjectName:e.effectiveSessionProjectName,canDeleteSession:!!e.selectedSession,threadRef:e.threadRef,isHistoryLoading:e.agent.isHydrating,messages:e.agent.visibleMessages,isSending:e.isSending,isAwaitingAssistantOutput:e.isAwaitingAssistantOutput,parentSessionKey:e.parentSession?.key??null,parentSessionLabel:e.parentSession?Ke(e.parentSession):null})},[e])}function vx(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function yx(e){let t={};e.model?.trim()&&(t.model=e.model.trim(),t.preferred_model=e.model.trim()),e.thinkingLevel?.trim()&&(t.thinking=e.thinkingLevel.trim(),t.preferred_thinking=e.thinkingLevel.trim()),e.sessionType?.trim()&&(t.session_type=e.sessionType.trim(),t.runtime=e.sessionType.trim()),e.agentId?.trim()&&(t.agent_id=e.agentId.trim());let n=Re(e.projectRoot);n&&(t.project_root=n);let r=vx(e.requestedSkills);r.length>0&&(t.requested_skill_refs=r);let i=e.composerNodes?C_(e.composerNodes):[];return i.length>0&&(t[v_]=i),t}function bx(e){return e.nextSelectedSessionKey===null&&e.previousSelectedSessionKey!==void 0&&e.previousSelectedSessionKey!==null}function xx({view:e}){let[t]=(0,P.useState)(()=>new hx),[n,r]=(0,P.useState)(()=>Ue()),i=L(e=>e.snapshot.query),a=L(e=>e.snapshot.selectedSessionKey),o=L(e=>e.snapshot.selectedAgentId),s=Q(e=>e.snapshot.pendingSessionType),c=Q(e=>e.snapshot.pendingProjectRoot),l=Q(e=>e.snapshot.pendingProjectRootSessionKey),u=Ng(),d=Q(e=>e.snapshot.selectedModel),{confirm:f,ConfirmDialog:p}=Xt(),m=y(),h=b(),{sessionId:g}=v(),_=(0,P.useRef)(null),x=(0,P.useRef)(a),S=(0,P.useRef)(void 0),C=(0,P.useMemo)(()=>Bb(g),[g]),w=a??n,T=l===w,{sessionSkillsQuery:E,isProviderStateResolved:D,modelOptions:O,sessionSummaries:ee,skillRecords:te,selectedSession:k,sessionTypeOptions:A,defaultSessionType:j,selectedSessionType:ne,canEditSessionType:re,sessionTypeUnavailable:ie,sessionTypeUnavailableMessage:ae}=rx({query:i,sessionKey:w,projectRootOverride:T?c:void 0,currentSelectedModel:d,pendingSessionType:s,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),M=Gy(w);(0,P.useEffect)(()=>{t.setDraftSessionId(n)},[n,t]),(0,P.useEffect)(()=>{if(bx({previousSelectedSessionKey:S.current,nextSelectedSessionKey:a})){let e=Ue();r(e),t.setDraftSessionId(e)}S.current=a},[t,a]);let oe=T?c:k?.projectRoot??null,se=T?Ge(oe):k?.projectName??Ge(oe),ce=k?.parentSessionId??null,le=M.isSending||M.isRunning,ue=M.isRunning,de=M.isRunning,fe=M.isRunning?null:`__preparing__`,pe=M.hydrateError?.message??M.snapshot.error?.message??null;(0,P.useEffect)(()=>{t.chatStreamActionsManager.bind({sendMessage:async e=>{if(e.sessionKey!==w)return;let n=yx({agentId:e.agentId,model:e.model,thinkingLevel:e.thinkingLevel,sessionType:e.sessionType,projectRoot:e.sessionKey===l?c:k?.projectRoot??null,requestedSkills:e.requestedSkills,composerNodes:e.composerNodes}),r=Qn({sessionId:e.sessionKey,text:e.message,attachments:e.attachments,parts:e.parts,metadata:n});if(r)try{await M.send(r)}catch(n){throw e.restoreDraftOnError&&(e.composerNodes&&e.composerNodes.length>0?t.chatInputManager.restoreComposerState?.(e.composerNodes,e.attachments??[]):t.chatInputManager.setDraft(t=>t.trim().length===0?e.message:t)),n}},stopCurrentRun:async()=>{await M.abort()},resumeRun:async e=>{e.sessionKey===w&&await M.streamRun()},resetStreamState:()=>{x.current=null},applyHistoryMessages:()=>{}})},[M,c,l,t,k?.projectRoot,w]),(0,P.useEffect)(()=>{!k||l!==k.key||(k.projectRoot??null)!==c||Q.getState().setSnapshot({pendingProjectRoot:null,pendingProjectRootSessionKey:null})},[c,l,k]),Fb({view:e,routeSessionKey:C,selectedSessionKey:a,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,selectedSessionKeyRef:x,resetStreamState:t.chatStreamActionsManager.resetStreamState}),(0,P.useEffect)(()=>{t.chatUiManager.syncState({pathname:m.pathname}),t.chatUiManager.bindActions({navigate:h,confirm:f})},[f,m.pathname,h,t]);let N=(u.data?.agents?.length??0)>0?u.data?.agents??[]:[{id:k?.agentId??o}],{currentSessionDisplayName:me,currentAgentId:he,currentAgent:ge,parentSession:_e,currentSessionTypeLabel:ve}=gx({selectedSession:k,selectedAgentId:o,availableAgents:N,parentSessionId:ce,sessionSummaries:ee,selectedSessionType:ne,sessionTypeOptions:A});return(0,P.useEffect)(()=>{!k?.agentId||o===k.agentId||t.chatSessionListManager.setSelectedAgentId(k.agentId)},[t,o,k?.agentId]),_x({presenter:t,isProviderStateResolved:D,defaultSessionType:j,canStopCurrentRun:de,stopDisabledReason:fe,lastSendError:pe,isSending:le,modelOptions:O,sessionTypeOptions:A,selectedSessionType:ne,canEditSessionType:re,sessionTypeUnavailable:ie,skillRecords:te,isSkillsLoading:E.isLoading,sessionTypeUnavailableMessage:ae,currentSessionTypeLabel:ve,sessionKey:w,currentAgentId:he,currentAgent:ge,availableAgents:N,currentSessionDisplayName:me,effectiveSessionProjectRoot:oe,effectiveSessionProjectName:se,selectedSession:k,threadRef:_,agent:M,isAwaitingAssistantOutput:ue,parentSession:_e}),(0,I.jsx)(wr,{presenter:t,children:(0,I.jsx)(Ib,{view:e,confirmDialog:(0,I.jsx)(p,{})})})}function Sx({view:e}){return(0,I.jsx)(xx,{view:e})}export{Sx as ChatPage};
|