nextclaw 0.16.26 → 0.16.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cli/index.js +29 -13
  2. package/package.json +13 -13
  3. package/templates/USAGE.md +9 -1
  4. package/ui-dist/assets/ChannelsList-eZfHzvxb.js +8 -0
  5. package/ui-dist/assets/ChatPage-DKD5hcD8.js +38 -0
  6. package/ui-dist/assets/DocBrowser-CIHLqoIm.js +1 -0
  7. package/ui-dist/assets/DocBrowser-DKkE3Y4I.js +1 -0
  8. package/ui-dist/assets/DocBrowserContext-BcZRBsCg.js +1 -0
  9. package/ui-dist/assets/LogoBadge-BIPDLEwK.js +1 -0
  10. package/ui-dist/assets/MarketplacePage-CMPjqEmN.js +1 -0
  11. package/ui-dist/assets/MarketplacePage-D0iqC5o7.js +49 -0
  12. package/ui-dist/assets/McpMarketplacePage-CCmRjGwl.js +40 -0
  13. package/ui-dist/assets/ModelConfig-BiWp8Ymp.js +1 -0
  14. package/ui-dist/assets/ProvidersList-HaCAzF9F.js +1 -0
  15. package/ui-dist/assets/RemoteAccessPage-DOF4oEHW.js +1 -0
  16. package/ui-dist/assets/RuntimeConfig-BnkWf6Eb.js +1 -0
  17. package/ui-dist/assets/SearchConfig-3ofKM9W4.js +1 -0
  18. package/ui-dist/assets/SecretsConfig-BRbC2hfo.js +3 -0
  19. package/ui-dist/assets/SessionsConfig-BpoD_0WD.js +2 -0
  20. package/ui-dist/assets/book-open-DzSduAaw.js +1 -0
  21. package/ui-dist/assets/chat-session-display-CGfXhJoT.js +1 -0
  22. package/ui-dist/assets/chunk-JZWAC4HX-C1vpvW4r.js +3 -0
  23. package/ui-dist/assets/config-Df97LeLR.js +1 -0
  24. package/ui-dist/assets/config-hints-fGnUjDe9.js +1 -0
  25. package/ui-dist/assets/config-layout-B-7erZRN.js +1 -0
  26. package/ui-dist/assets/createLucideIcon-CcR5wVoU.js +1 -0
  27. package/ui-dist/assets/dist-BMlnBah3.js +1 -0
  28. package/ui-dist/assets/dist-Dii9v3X9.js +15 -0
  29. package/ui-dist/assets/external-link-CnSDrvJE.js +1 -0
  30. package/ui-dist/assets/hash-CAnX6PNt.js +1 -0
  31. package/ui-dist/assets/i18n-CXBpwAwA.js +1 -0
  32. package/ui-dist/assets/index-CjPeKafH.js +6 -0
  33. package/ui-dist/assets/index-DMy_fKKh.css +1 -0
  34. package/ui-dist/assets/label-CtIFj7_6.js +1 -0
  35. package/ui-dist/assets/loader-circle-qgU4zQDw.js +1 -0
  36. package/ui-dist/assets/logos-3KFNiOej.js +1 -0
  37. package/ui-dist/assets/marketplace-localization-CXeGRf6E.js +1 -0
  38. package/ui-dist/assets/page-layout-BMwpn87D.js +1 -0
  39. package/ui-dist/assets/plus-C9cYVbL-.js +1 -0
  40. package/ui-dist/assets/popover-BIzq25oH.js +1 -0
  41. package/ui-dist/assets/provider-models-C8JQUd1E.js +1 -0
  42. package/ui-dist/assets/react-ji6GGP_j.js +1 -0
  43. package/ui-dist/assets/save-CMgYkJ-y.js +1 -0
  44. package/ui-dist/assets/search-sl1OeJFl.js +1 -0
  45. package/ui-dist/assets/security-config-BcbOF17w.js +1 -0
  46. package/ui-dist/assets/select-Cz82gl01.js +41 -0
  47. package/ui-dist/assets/skeleton-rgIt7a5q.js +1 -0
  48. package/ui-dist/assets/status-dot-C7q1HvLH.js +1 -0
  49. package/ui-dist/assets/switch-DYswvkYj.js +1 -0
  50. package/ui-dist/assets/tabs-custom-DKYQxrx1.js +1 -0
  51. package/ui-dist/assets/trash-2-DfXI7-ap.js +1 -0
  52. package/ui-dist/assets/useConfirmDialog-Dk15Fj1n.js +1 -0
  53. package/ui-dist/assets/useMutation-s2sn2yzh.js +1 -0
  54. package/ui-dist/assets/x-MIimOGs6.js +1 -0
  55. package/ui-dist/index.html +18 -3
  56. package/ui-dist/assets/ChannelsList-UKA-5t02.js +0 -8
  57. package/ui-dist/assets/ChatPage-xdBp-ddG.js +0 -37
  58. package/ui-dist/assets/DocBrowser-DBUIWJer.js +0 -1
  59. package/ui-dist/assets/LogoBadge-CsSBHZeV.js +0 -1
  60. package/ui-dist/assets/MarketplacePage-BSH836_G.js +0 -49
  61. package/ui-dist/assets/McpMarketplacePage-B9_kPnnM.js +0 -40
  62. package/ui-dist/assets/ModelConfig-DbEKVVg4.js +0 -1
  63. package/ui-dist/assets/ProvidersList-Ck5PgTF2.js +0 -1
  64. package/ui-dist/assets/RemoteAccessPage-4JED9IcK.js +0 -1
  65. package/ui-dist/assets/RuntimeConfig-CB04ug9v.js +0 -1
  66. package/ui-dist/assets/SearchConfig-DmuvL9Pn.js +0 -1
  67. package/ui-dist/assets/SecretsConfig-Dw2sRiSs.js +0 -3
  68. package/ui-dist/assets/SessionsConfig-c-Z9X3xH.js +0 -2
  69. package/ui-dist/assets/chat-session-display-z9RvX-D3.js +0 -1
  70. package/ui-dist/assets/config-hints-CApS3K_7.js +0 -1
  71. package/ui-dist/assets/config-layout-BHnOoweL.js +0 -1
  72. package/ui-dist/assets/index-CfVmBgkf.css +0 -1
  73. package/ui-dist/assets/index-DqzLj8Sw.js +0 -8
  74. package/ui-dist/assets/label-DPGDZvhm.js +0 -1
  75. package/ui-dist/assets/marketplace-localization-Dk31LJJJ.js +0 -1
  76. package/ui-dist/assets/page-layout-DMA_ZiHj.js +0 -1
  77. package/ui-dist/assets/popover-BBLXwfva.js +0 -1
  78. package/ui-dist/assets/provider-models-BOeNnjk9.js +0 -1
  79. package/ui-dist/assets/security-config-FYNEE2eR.js +0 -1
  80. package/ui-dist/assets/skeleton-DLM_39_P.js +0 -1
  81. package/ui-dist/assets/status-dot-BOzEprxw.js +0 -1
  82. package/ui-dist/assets/switch-rE_Ew8fl.js +0 -1
  83. package/ui-dist/assets/tabs-custom-BkfMUTHE.js +0 -1
  84. package/ui-dist/assets/useConfirmDialog-0owrqZcT.js +0 -1
  85. package/ui-dist/assets/vendor-MCpnpiKt.js +0 -461
@@ -0,0 +1,38 @@
1
+ import{_ as e,d as t,f as n,g as r,h as i,l as a,m as o,p as s,r as c,t as l,u}from"./i18n-CXBpwAwA.js";import{a as d,c as f,i as p,n as m,o as h,s as g,u as _}from"./dist-Dii9v3X9.js";import{c as v,o as y,s as b}from"./chunk-JZWAC4HX-C1vpvW4r.js";import{n as x,t as S}from"./react-ji6GGP_j.js";import{D as C,O as w,_ as T,a as E,b as D,c as O,d as k,f as ee,g as te,h as A,i as j,k as ne,l as M,m as re,n as ie,o as N,p as ae,r as oe,s as se,t as ce,u as le,v as ue,y as de}from"./select-Cz82gl01.js";import{t as P}from"./createLucideIcon-CcR5wVoU.js";import{t as fe}from"./book-open-DzSduAaw.js";import{a as pe,c as me,i as he,l as ge,n as _e,o as ve,r as ye,s as be,t as xe}from"./chat-session-display-CGfXhJoT.js";import{t as Se}from"./external-link-CnSDrvJE.js";import{n as Ce,t as we}from"./logos-3KFNiOej.js";import{t as Te}from"./loader-circle-qgU4zQDw.js";import{a as Ee,c as De,d as Oe,i as ke,l as Ae,n as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie}from"./MarketplacePage-D0iqC5o7.js";import{t as Le}from"./plus-C9cYVbL-.js";import{t as Re}from"./search-sl1OeJFl.js";import{t as ze}from"./trash-2-DfXI7-ap.js";import{t as Be}from"./x-MIimOGs6.js";import{d as Ve}from"./config-Df97LeLR.js";import{i as He}from"./DocBrowserContext-BcZRBsCg.js";import{F as Ue,G as We,I as Ge,L as Ke,M as qe,N as Je,P as Ye,U as Xe,W as Ze,a as Qe,at as $e,c as et,ct as tt,dt as nt,f as rt,ft as it,ht as at,i as ot,l as st,lt as ct,mt as lt,n as ut,o as dt,p as ft,r as pt,s as mt,st as ht,t as gt,w as _t,x as vt,y as yt}from"./index-CjPeKafH.js";import{a as bt,c as xt,i as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt}from"./popover-BIzq25oH.js";import{t as Ot}from"./LogoBadge-BIPDLEwK.js";import{t as kt}from"./useConfirmDialog-Dk15Fj1n.js";import{n as At,t as jt}from"./page-layout-BMwpn87D.js";import{i as Mt,n as Nt,t as Pt}from"./provider-models-C8JQUd1E.js";var Ft=P(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),It=P(`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`}]]),Lt=P(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Rt=P(`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`}]]),zt=P(`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`}]]),Bt=P(`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`}]]),Vt=P(`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`}]]),Ht=P(`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`}]]),Ut=P(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Wt=P(`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`}]]),Gt=P(`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`}]]),Kt=P(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),qt=P(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Jt=P(`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`}]]),Yt=P(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),Xt=P(`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`}]]),F=e(o(),1),I=(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))(I||{}),Zt=/\[\[\s*reply_to_current\s*\]\]/gi,Qt=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function $t(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function en(e,t){let n=e,r;Zt.test(n)&&(r=$t(t),n=n.replace(Zt,``).trim());let i=n.match(Qt)?.[1];return i&&(r=$t(i),n=n.replace(Qt,``).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=$t(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}=en(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 nn(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(`
2
+ `)}}async function*rn(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}=an(r);r=o;for(let e of a)yield e}r+=n.decode();let{frames:e}=an(r,!0);for(let t of e)yield t}finally{t.releaseLock()}}function an(e,t=!1){let n=e.split(/\r?\n\r?\n/),r=n.pop()??``,i=[];for(let e of n){let t=nn(e);t&&i.push(t)}if(t&&r.trim()){let e=nn(r);return e&&i.push(e),{frames:i,rest:``}}return{frames:i,rest:r}}var on=`/ncp/agent`,sn=`ncp-http-agent-client`,cn=class extends Error{ncpError;alreadyPublished;constructor(e,t=!1){super(e.message),this.name=`NcpHttpAgentClientError(${e.code})`,this.ncpError=e,this.alreadyPublished=t}};function ln(e){let t=e.trim();if(!t)throw Error(`NcpHttpAgentClient requires a non-empty baseUrl.`);return new URL(t)}function un(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 dn(e){let t=(e??on).trim();if(!t)return on;let n=t.startsWith(`/`)?t:`/${t}`;return n.endsWith(`/`)?n.slice(0,-1):n}async function fn(e){try{return(await e.text()).trim()}catch{return``}}function pn(e){if(_n(e))return e.ncpError;if(hn(e))return e;let t=e instanceof Error?e.message:String(e??`Unknown error`);return{code:yn(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function mn(e,t={}){return new cn(e,t.alreadyPublished??!1)}function hn(e){return gn(e)&&typeof e.code==`string`&&typeof e.message==`string`}function gn(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function _n(e){return e instanceof cn}var vn={"config-error":`config-error`,"auth-error":`auth-error`,"runtime-error":`runtime-error`,"timeout-error":`timeout-error`,"abort-error":`abort-error`};function yn(e){if(!e)return`runtime-error`;let t=vn[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 bn(e){let t=Sn(e);return!t||typeof t.type!=`string`||!t.type.trim()?null:t}function xn(e){let t=Sn(e);if(!t)return{code:`runtime-error`,message:e||`Unknown stream error.`};let n=typeof t.code==`string`?t.code:void 0,r=yn(n),i=gn(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 Sn(e){try{let t=JSON.parse(e);return gn(t)?t:null}catch{return null}}var Cn=[`text`,`file`,`source`,`step-start`,`reasoning`,`tool-invocation`,`card`,`rich-text`,`action`,`extension`],wn=class{manifest;baseUrl;basePath;fetchImpl;defaultHeaders;subscribers=new Set;activeControllers=new Set;started=!1;constructor(e){this.baseUrl=ln(e.baseUrl),this.basePath=dn(e.basePath),this.fetchImpl=un(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:`custom`,endpointId:e.endpointId?.trim()||sn,version:`0.1.0`,supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:Cn,expectedLatency:`seconds`,metadata:{transport:`http+sse`,scope:`agent`}}}async start(){this.started||(this.started=!0,this.publish({type:I.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 fn(n)}`)}catch(e){if(t.signal.aborted)return;let n=pn(e);throw this.publish({type:I.EndpointError,payload:n}),mn(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 fn(n)}`);if(!n.body)throw Error(`NCP stream response has no body.`);for await(let e of rn(n.body)){if(t.signal.aborted)return;this.handleSseFrame(e)}}catch(e){if(t.signal.aborted)return;if(_n(e))throw e;let n=pn(e);throw this.publish({type:I.EndpointError,payload:n}),mn(n)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event===`ncp-event`){let t=bn(e.data);if(!t){this.publish({type:I.EndpointError,payload:{code:`runtime-error`,message:`Received malformed ncp-event frame.`}});return}this.publish(t);return}if(e.event===`error`){let t=xn(e.data);throw this.publish({type:I.EndpointError,payload:t}),mn(t,{alreadyPublished:!0})}}};function Tn(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function En(e){return Tn(tn(e))}function Dn(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 On(e,t){return t.trim()?e.id.startsWith(`tool-`)?!0:e.parts.some(e=>e.type===`tool-invocation`):!1}function kn(e,t,n){for(let[r,i]of e)i===t&&e.set(r,n)}function An(e,t,n){for(let[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function jn(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 Mn(e,t){return jn(e,t)?.toolName??null}function Nn(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 Pn=`assistant`,Fn=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=>En(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=async e=>{let t=this.stateVersion;switch(e.type){case I.MessageSent:this.handleMessageSent(e.payload);break;case I.MessageAbort:this.handleMessageAbort(e.payload);break;case I.MessageTextStart:this.handleMessageTextStart(e.payload);break;case I.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case I.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case I.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case I.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case I.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case I.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case I.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case I.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case I.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case I.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case I.RunStarted:this.handleRunStarted(e.payload);break;case I.RunFinished:this.handleRunFinished(e.payload);break;case I.RunError:this.handleRunError(e.payload);break;case I.RunMetadata:this.handleRunMetadata(e.payload);break;case I.EndpointError:this.handleEndpointError(e.payload);break;default:break}this.stateVersion!==t&&this.notifyListeners()};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?An(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):An(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=Nn(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=Nn(t.parts,{type:`tool-invocation`,toolCallId:e.toolCallId,toolName:Mn(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 Nn(t.parts,r)})){let t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=Nn(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(Dn(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=Mn(i.parts,t)??`unknown`,o=Nn(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=Tn(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&&On(i,t)){let r={...i,id:t,sessionId:e,status:n};return kn(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(r),r}let a={id:t,sessionId:e,role:Pn,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=jn(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=jn(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=En(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?En(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),An(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)};notifyListeners=()=>{let e=this.getSnapshot();for(let t of this.listeners)t(e)}};function In(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 Ln(e){return e.parts.some(e=>e.type===`text`||e.type===`rich-text`||e.type===`reasoning`?e.text.trim().length>0:!0)}function Rn(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 Ln(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function zn(e){let t=(0,F.useRef)();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new Fn}),t.current.manager}function Bn({sessionId:e,client:t,manager:n}){let r=(0,F.useSyncExternalStore)(e=>n.subscribe(()=>e()),()=>n.getSnapshot(),()=>n.getSnapshot()),[i,a]=(0,F.useState)(!1);(0,F.useEffect)(()=>{a(!1)},[e]),(0,F.useEffect)(()=>{let r=t.subscribe(t=>{In(t,e)&&n.dispatch(t)});return()=>{r(),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=Rn(r,e);if(o){a(!0),await n.dispatch({type:I.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()=>{r.activeRun&&await t.stream({sessionId:e})}}}function Vn(e){return e instanceof Error?e:Error(String(e))}function Hn(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function Un({sessionId:e,client:t,loadSeed:n,autoResumeRunningSession:r=!0}){let i=zn(e),a=Bn({sessionId:e,client:t,manager:i}),[o,s]=(0,F.useState)(!0),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),f=(0,F.useRef)({requestId:0,controller:null}),p=(0,F.useCallback)(async()=>{f.current.controller?.abort();let a=new AbortController,o=f.current.requestId+1;f.current={requestId:o,controller:a},await t.stop(),i.reset(),l(null),s(!0);try{let c=await n(e,a.signal);if(a.signal.aborted||f.current.requestId!==o)return;i.hydrate({sessionId:e,messages:c.messages,activeRun:c.status===`running`?{runId:null,sessionId:e,abortDisabledReason:null}:null}),l(null),d(e),s(!1),c.status===`running`&&r&&t.stream({sessionId:e}).catch(e=>{f.current.requestId===o&&l(Vn(e))})}catch(t){if(a.signal.aborted||f.current.requestId!==o)return;l(Vn(t)),d(e),s(!1)}finally{f.current.controller===a&&(f.current.controller=null)}},[r,t,n,i,e]);return(0,F.useEffect)(()=>(p(),()=>{f.current.controller?.abort(),f.current.controller=null}),[p]),{...a,isHydrating:Hn({sessionId:e,hydratedSessionId:u,isHydrating:o}),hydrateError:c}}var Wn=200*1024*1024,Gn=`application/octet-stream`;function Kn(e){let t=e.type.trim().toLowerCase();return t.length>0?t:Gn}function qn(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=Kn(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 Jn(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 Yn(e,t){let n=[],r=[];for(let i of e){let e=qn(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:Kn(e),sizeBytes:e.size,reason:`read-failed`}))),{attachments:[],rejected:r}}}var L=s(),Xn={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 Zn({status:e,className:t}){let n=Xn[e],r=a(e===`connected`?`connected`:e===`disconnected`?`disconnected`:`connecting`);return(0,L.jsx)(Ee,{delayDuration:250,children:(0,L.jsxs)(Ne,{children:[(0,L.jsx)(Me,{asChild:!0,children:(0,L.jsx)(`span`,{role:`status`,"aria-label":r,className:u(`inline-flex h-5 w-5 items-center justify-center`,t),children:e===`connecting`?(0,L.jsx)(Te,{className:u(`h-3 w-3 animate-spin`,n.dotClass)}):(0,L.jsx)(`span`,{className:u(e===`connected`?`h-2 w-2 rounded-full`:``,n.dotClass)})})}),(0,L.jsx)(ke,{side:`bottom`,className:`text-xs`,children:r})]})})}var Qn={wx:`weixin`,lark:`feishu`},$n={heartbeat:{icon:`heartbeat`},cron:{icon:`cron`}},er={codex:`chatSessionTypeCodex`,claude:`chatSessionTypeClaude`};function tr(e){return e?.trim().toLowerCase()??``}function nr(e){return e.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function rr(e,t){let n=tr(e);if(!n||n===`native`)return null;let r=t.find(e=>tr(e.value)===n);return r?.label.trim()?r.label.trim():nr(n)}function ir(e){let t=tr(e);if(!t)return null;let n=Qn[t]??t;return we(n)?n:null}function ar(e,t){let n=ir(e.channel??``);if(n)return{icon:{kind:`channel-logo`,channel:n},label:null};let r=$n[tr(e.type)];if(r)return{icon:{kind:`symbol`,icon:r.icon},label:null};let i=er[tr(e.sessionType)];return i?{icon:null,label:a(i)}:{icon:null,label:rr(e.sessionType,t)}}function or({icon:e,className:t}){return e.kind===`channel-logo`?(0,L.jsx)(sr,{channel:e.channel,className:t}):e.icon===`heartbeat`?(0,L.jsx)(Vt,{className:u(`h-3.5 w-3.5`,t)}):(0,L.jsx)(at,{className:u(`h-3.5 w-3.5`,t)})}function sr({channel:e,className:t}){return(0,L.jsx)(Ot,{name:e,src:we(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,L.jsx)(ge,{className:`h-3 w-3 text-gray-500`})})}function cr(e){let{session:t,active:n,runStatus:r,context:i,title:o,isEditing:s,draftLabel:l,isSaving:d,onSelect:f,onStartEditing:p,onDraftLabelChange:m,onSave:g,onCancel:_}=e,v=n?`text-gray-700`:`text-gray-500`;return(0,L.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:s?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(Xe,{value:l,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),g()):e.key===`Escape`&&(e.preventDefault(),_())},placeholder:a(`sessionsLabelPlaceholder`),className:`h-8 rounded-lg border-gray-300 bg-white text-xs`,autoFocus:!0,disabled:d}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 text-[11px] text-gray-400 truncate`,children:t.key}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(h,{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 g(),disabled:d,"aria-label":a(`save`),children:(0,L.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,L.jsx)(h,{type:`button`,size:`icon`,variant:`ghost`,className:`h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900`,onClick:_,disabled:d,"aria-label":a(`cancel`),children:(0,L.jsx)(Be,{className:`h-3.5 w-3.5`})})]})]})]}):(0,L.jsxs)(`div`,{className:`group/session relative`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:f,className:`w-full text-left`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5 pr-8`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:o}),i.label?(0,L.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,L.jsx)(`span`,{className:`inline-flex h-[1.125rem] w-[1.125rem] shrink-0 items-center justify-center`,children:(0,L.jsx)(or,{icon:i.icon,className:v})}):null]}),(0,L.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:r?(0,L.jsx)(ve,{status:r}):null})]}),(0,L.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-gray-400 truncate`,children:[t.messageCount,` · `,c(t.updatedAt)]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),p()},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":a(`edit`),children:(0,L.jsx)(Gt,{className:`h-3.5 w-3.5`})})]})})}function lr(){let e=_();return async t=>{try{Ge(e,await Ye(t.sessionKey,{label:t.label})),m.success(a(`configSavedApplied`))}catch(e){throw m.error(a(`configSaveFailed`)+`: `+(e instanceof Error?e.message:String(e))),e}}}var ur={selectedSessionKey:null,selectedAgentId:`main`,query:``},R=S(e=>({snapshot:ur,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function dr(e,t){return e.filter(e=>_e(e,t))}function fr(e={}){let t=R(e=>e.snapshot.query),n=yt({limit:e.limit??200}),r=(0,F.useMemo)(()=>{let e=n.data?.sessions??[],r=dr(he(e),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 pr=(0,F.createContext)(null);function mr({presenter:e,children:t}){return(0,L.jsx)(pr.Provider,{value:e,children:t})}function hr(){let e=(0,F.useContext)(pr);if(!e)throw Error(`usePresenter must be used inside ChatPresenterProvider`);return e}var gr=e=>`[data-item-index="${e}"]`;function _r(e){let t=e.getItemSelector??gr;(0,F.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 vr(){let e=(0,F.useRef)(null),[t,n]=(0,F.useState)(null);return(0,F.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 z(...e){return t(n(e))}var yr=F.forwardRef(({className:e,type:t,...n},r)=>(0,L.jsx)(`input`,{type:t,className:z(`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}));yr.displayName=`ChatInput`;var br=Et,xr=xt,Sr=St,Cr=F.forwardRef(({className:e,sideOffset:t=8,align:n=`start`,...r},i)=>(0,L.jsx)(wt,{children:(0,L.jsx)(bt,{ref:i,sideOffset:t,align:n,className:z(`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})}));Cr.displayName=bt.displayName;var wr=re,Tr=se,Er=de,Dr=F.forwardRef(({className:e,children:t,...n},r)=>(0,L.jsxs)(ue,{ref:r,className:z(`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,L.jsx)(O,{asChild:!0,children:(0,L.jsx)(w,{className:`h-4 w-4 opacity-50`})})]}));Dr.displayName=ue.displayName;var Or=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(te,{ref:n,className:z(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,L.jsx)(C,{className:`h-4 w-4`})}));Or.displayName=te.displayName;var kr=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(A,{ref:n,className:z(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,L.jsx)(w,{className:`h-4 w-4`})}));kr.displayName=A.displayName;var Ar=F.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,L.jsx)(ae,{children:(0,L.jsxs)(N,{ref:i,className:z(`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,L.jsx)(Or,{}),(0,L.jsx)(D,{className:z(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,L.jsx)(kr,{})]})}));Ar.displayName=N.displayName;var jr=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(ee,{ref:n,className:z(`px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500`,e),...t}));jr.displayName=ee.displayName;var Mr=F.forwardRef(({className:e,children:t,...n},r)=>(0,L.jsxs)(M,{ref:r,className:z(`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,L.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,L.jsx)(le,{children:(0,L.jsx)(ne,{className:`h-4 w-4`})})}),(0,L.jsx)(k,{children:t})]}));Mr.displayName=M.displayName;var Nr=F.forwardRef(({className:e,...t},n)=>(0,L.jsx)(T,{ref:n,className:z(`-mx-1 my-1 h-px bg-gray-100`,e),...t}));Nr.displayName=T.displayName;var Pr=Ae,Fr=Ie,Ir=Oe,Lr=F.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,L.jsx)(De,{children:(0,L.jsx)(Pe,{ref:r,sideOffset:t,className:z(`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})}));Lr.displayName=Pe.displayName;var Rr={Popover:br,PopoverAnchor:Sr,PopoverContent:Cr,PopoverTrigger:xr,Input:yr,Select:wr,SelectContent:Ar,SelectGroup:Tr,SelectItem:Mr,SelectLabel:jr,SelectSeparator:Nr,SelectTrigger:Dr,SelectValue:Er,Tooltip:Fr,TooltipContent:Lr,TooltipProvider:Pr,TooltipTrigger:Ir},zr=680,Br=.82,Vr=560;function Hr(e){let{Popover:t,PopoverAnchor:n,PopoverContent:r}=Rr,{elementRef:i,width:a}=vr(),o=(0,F.useRef)(null),{isOpen:s,isLoading:c,items:l,activeIndex:u,activeItem:d,texts:f,onSelectItem:p,onOpenChange:m,onSetActiveIndex:h}=e,g=(0,F.useMemo)(()=>{if(a)return Math.min(a>Vr?a*Br:a,zr)},[a]);return _r({containerRef:o,activeIndex:u,itemCount:l.length,isEnabled:s&&!c,getItemSelector:e=>`[data-slash-index="${e}"]`}),(0,L.jsxs)(t,{open:s,onOpenChange:m,children:[(0,L.jsx)(n,{asChild:!0,children:(0,L.jsx)(`div`,{ref:i,className:`pointer-events-none absolute bottom-full left-3 right-3 h-0`})}),(0,L.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,L.jsxs)(`div`,{className:`grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]`,children:[(0,L.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,L.jsx)(`div`,{className:`p-2 text-xs text-gray-500`,children:f.slashLoadingLabel}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500`,children:f.slashSectionLabel}),l.length===0?(0,L.jsx)(`div`,{className:`px-2 text-xs text-gray-400`,children:f.slashEmptyLabel}):(0,L.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let n=t===u;return(0,L.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,L.jsx)(`span`,{className:`truncate text-xs font-semibold`,children:e.title}),(0,L.jsx)(`span`,{className:`truncate text-xs text-gray-500`,children:e.subtitle})]},e.key)})})]})}),(0,L.jsx)(`div`,{className:`max-w-[320px] p-3.5`,children:d?(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.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,L.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:d.title})]}),(0,L.jsx)(`p`,{className:`text-xs leading-5 text-gray-600`,children:d.description}),(0,L.jsx)(`div`,{className:`space-y-1`,children:d.detailLines.map(e=>(0,L.jsx)(`div`,{className:`rounded-md bg-gray-50 px-2 py-1 text-[11px] text-gray-600`,children:e},e))}),(0,L.jsx)(`div`,{className:`pt-1 text-[11px] text-gray-500`,children:f.slashSkillHintLabel})]}):(0,L.jsx)(`div`,{className:`text-xs text-gray-500`,children:f.slashHintLabel})})]})})]})}var Ur=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`}}),Wr=F.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,L.jsx)(`button`,{className:z(Ur({variant:t,size:n,className:e})),ref:i,...r}));Wr.displayName=`ChatButton`;function Gr(){return(0,L.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 Kr(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Rr;return(0,L.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[e.sendError?.trim()?(0,L.jsx)(`div`,{className:`max-w-[420px] text-right text-[11px] text-red-600`,children:e.sendError}):null,(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:e.isSending?e.canStopGeneration?(0,L.jsx)(Wr,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":e.stopButtonLabel,onClick:()=>void e.onStop(),disabled:e.stopDisabled,children:(0,L.jsx)(Gr,{})}):(0,L.jsx)(r,{children:(0,L.jsxs)(t,{children:[(0,L.jsx)(i,{asChild:!0,children:(0,L.jsx)(`span`,{children:(0,L.jsx)(Wr,{size:`icon`,variant:`outline`,className:`h-8 w-8 rounded-full`,"aria-label":e.stopButtonLabel,disabled:!0,children:(0,L.jsx)(Gr,{})})})}),(0,L.jsx)(n,{side:`top`,children:(0,L.jsx)(`p`,{className:`text-xs`,children:e.stopHint})})]})}):(0,L.jsx)(Wr,{size:`icon`,className:`h-8 w-8 rounded-full`,"aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:(0,L.jsx)(Ft,{className:`h-5 w-5`})})})]})}function qr(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 Jr(e){let{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=Rr,{picker:a}=e,o=(0,F.useRef)(null),s=(0,F.useId)(),[c,l]=(0,F.useState)(``),[u,d]=(0,F.useState)(0),f=(0,F.useMemo)(()=>new Set(a.selectedKeys),[a.selectedKeys]),p=a.selectedKeys.length,m=(0,F.useMemo)(()=>qr(a.options,c),[a.options,c]);(0,F.useEffect)(()=>{d(0)},[c]),(0,F.useEffect)(()=>{d(e=>m.length===0?0:Math.min(e,m.length-1))},[m.length]),_r({containerRef:o,activeIndex:u,itemCount:m.length,isEnabled:m.length>0,getItemSelector:e=>`[data-skill-index="${e}"]`});let h=e=>{if(f.has(e)){a.onSelectedKeysChange(a.selectedKeys.filter(t=>t!==e));return}a.onSelectedKeysChange([...a.selectedKeys,e])},g=e=>{if(m.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),d(e=>Math.min(e+1,m.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=m[u];t&&h(t.key)}}};return(0,L.jsxs)(n,{children:[(0,L.jsx)(i,{asChild:!0,children:(0,L.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,L.jsx)(lt,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:a.title}),p>0?(0,L.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,L.jsxs)(r,{side:`top`,align:`start`,className:`w-[360px] p-0`,children:[(0,L.jsxs)(`div`,{className:`space-y-2 border-b border-gray-100 px-4 py-3`,children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:a.title}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Re,{className:`pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400`}),(0,L.jsx)(t,{value:c,onChange:e=>l(e.target.value),onKeyDown:g,placeholder:a.searchPlaceholder,role:`combobox`,"aria-controls":s,"aria-expanded":`true`,"aria-autocomplete":`list`,"aria-activedescendant":m[u]?`${s}-option-${u}`:void 0,className:`h-8 rounded-lg pl-8 text-xs`})]})]}),(0,L.jsx)(`div`,{ref:o,id:s,role:`listbox`,"aria-multiselectable":`true`,className:`custom-scrollbar max-h-[320px] overflow-y-auto`,children:a.isLoading?(0,L.jsx)(`div`,{className:`p-4 text-xs text-gray-500`,children:a.loadingLabel}):m.length===0?(0,L.jsx)(`div`,{className:`p-4 text-center text-xs text-gray-500`,children:a.emptyLabel}):(0,L.jsx)(`div`,{className:`py-1`,children:m.map((e,t)=>{let n=f.has(e.key),r=t===u;return(0,L.jsxs)(`button`,{type:`button`,id:`${s}-option-${t}`,role:`option`,"aria-selected":n,"data-skill-index":t,onClick:()=>h(e.key),onMouseEnter:()=>d(t),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${r?`bg-gray-50`:`hover:bg-gray-50`}`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500`,children:(0,L.jsx)(Jt,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate text-sm text-gray-900`,children:e.label}),e.badgeLabel?(0,L.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,L.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-gray-500`,children:e.description||e.key})]}),(0,L.jsx)(`div`,{className:`ml-3 shrink-0`,children:(0,L.jsx)(`span`,{className:n?`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:n?(0,L.jsx)(ne,{className:`h-3 w-3`}):null})})]},e.key)})})}),a.manageHref&&a.manageLabel?(0,L.jsx)(`div`,{className:`border-t border-gray-100 px-4 py-2.5`,children:(0,L.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,L.jsx)(Se,{className:`h-3 w-3`})]})}):null]})]})}function Yr({icon:e}){return e===`sparkles`?(0,L.jsx)(ht,{className:`h-3.5 w-3.5 shrink-0 text-primary`}):e===`brain`?(0,L.jsx)(It,{className:`h-3.5 w-3.5 shrink-0 text-gray-500`}):null}function Xr({icon:e}){return e===`paperclip`?(0,L.jsx)(Wt,{className:`h-4 w-4`}):(0,L.jsx)(Yr,{icon:e})}function Zr(e){return e===`model`?`min-w-[220px]`:e===`session-type`?`min-w-[140px]`:e===`thinking`?`min-w-[150px]`:``}function Qr(e){return e===`model`?`w-[320px]`:e===`session-type`?`w-[220px]`:e===`thinking`?`w-[180px]`:``}function $r({item:e}){let{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:a,SelectSeparator:o,SelectTrigger:s,SelectValue:c}=Rr,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,L.jsxs)(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[(0,L.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 ${Zr(e.key)}`,children:e.selectedLabel?(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-left`,children:[(0,L.jsx)(Yr,{icon:e.icon}),(0,L.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-700`,children:e.selectedLabel})]}):e.loading?(0,L.jsx)(`div`,{className:`h-3 w-24 animate-pulse rounded bg-gray-200`}):(0,L.jsx)(c,{placeholder:e.placeholder})}),(0,L.jsxs)(n,{className:Qr(e.key),children:[u?null:e.loading?(0,L.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,L.jsx)(`div`,{className:`h-3 w-36 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`div`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`div`,{className:`h-3 w-32 animate-pulse rounded bg-gray-200`})]}):e.emptyLabel?(0,L.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500`,children:e.emptyLabel}):null,l.map((e,t)=>(0,L.jsxs)(`div`,{children:[t>0?(0,L.jsx)(o,{}):null,(0,L.jsxs)(r,{children:[e.label?(0,L.jsx)(a,{children:e.label}):null,e.options.map(e=>(0,L.jsx)(i,{value:e.value,className:`py-2`,children:e.description?(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label}),(0,L.jsx)(`span`,{className:`truncate text-[11px] text-gray-500`,children:e.description})]}):(0,L.jsx)(`span`,{className:`truncate text-xs font-semibold text-gray-800`,children:e.label})},e.value))]})]},e.key))]})]})}function ei(e){let{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=Rr;return(0,L.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.skillPicker?(0,L.jsx)(Jr,{picker:e.skillPicker}):null,e.selects.map(e=>(0,L.jsx)($r,{item:e},e.key)),e.accessories?.map(e=>{let a=(0,L.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,L.jsx)(Xr,{icon:e.icon}),e.iconOnly?null:(0,L.jsx)(`span`,{children:e.label})]});return e.tooltip?(0,L.jsx)(r,{children:(0,L.jsxs)(t,{children:[(0,L.jsx)(i,{asChild:!0,children:e.disabled?(0,L.jsx)(`span`,{className:`inline-flex`,children:a}):a}),(0,L.jsx)(n,{side:`top`,children:(0,L.jsx)(`p`,{className:`text-xs`,children:e.tooltip})})]})},e.key):(0,L.jsx)(`div`,{children:a},e.key)})]}),(0,L.jsx)(Kr,{...e.actions})]})}function ti(){return`composer-${Math.random().toString(36).slice(2,10)}`}function ni(e=``){return{id:ti(),type:`text`,text:e}}function ri(e){return{id:ti(),type:`token`,tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function ii(e){return e.type===`text`?e.text.length:1}function ai(){return[ni(``)]}function oi(e){return[ni(e)]}function si(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?ai():t}function ci(e){return e.map(e=>e.type===`text`?e.text:``).join(``)}function li(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function ui(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 di(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 fi(e,t,n,r){return t<=n||e>=r}function pi(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function mi(e,t,n,r,i,a,o){let s=di(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 hi(e,t,n,r,i,a){return!r&&i<=a?(e.push(...n),!0):(e.push(t),r)}function gi(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=ii(t),n=s,l=s+e;if(fi(n,l,i,a)){c=pi(o,r,c,n,a),o.push(t),s=l;continue}c=t.type===`text`?mi(o,t,n,i,a,r,c):hi(o,t,r,c,i,n),s=l}return c||o.push(...r),si(o)}function _i(e,t){return si(e.filter(e=>e.type!==`token`||!t(e)))}function vi(e,t){if(!t||t.start!==t.end)return null;let n=ci(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 yi(e,t,n){return e?e.start<n&&e.end>t:!1}function bi(e){let t=new Map,n=0;for(let r of e)t.set(r.id,n),n+=ii(r);return t}function xi(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 Si(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 Ci(e,t,n){let r=0;for(let i=0;i<n;i+=1){let n=Si(e.childNodes[i],i,t);n&&(r+=ii(n))}return r}function wi(e,t,n,r){let i=xi(e,t),a=Ci(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 Ti(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 Ei(e,t,n,r,i){if(t===e)return Ci(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return wi(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 Ei(e,e,xi(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?Ti(t,n,s,c,a):c}function Di(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=bi(t),a=Ei(e,r.startContainer,r.startOffset,t,i),o=Ei(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(a,o),end:Math.max(a,o)}}function Oi(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=ii(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 ki(e){let t=[];for(let n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(ni(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??ri({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??ni(e).id,type:`text`,text:e})}return si(t)}function Ai(e){let t=ki(e);return{nodes:t,selection:Di(e,t)}}var ji=class{constructor(){this.nodes=ai(),this.selection=null,this.sync=(e,t)=>(this.nodes=si(e),this.selection=t,this.getSnapshot()),this.setSelection=e=>(this.selection=e,this.getSnapshot()),this.replaceDocument=(e,t)=>(this.nodes=si(e),this.selection=t,this.getSnapshot()),this.insertText=e=>{let t=this.selection??{start:0,end:0};this.nodes=gi(this.nodes,t.start,t.end,[ni(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=_i(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=gi(this.nodes,r,i,[]),this.selection={start:r,end:r},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:bi(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((e,t)=>e+ii(t),0),this.getSelectedSkillKeys=()=>ui(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=gi(this.nodes,a,o,[ri({tokenKind:e,tokenKey:t,label:n})]),this.selection={start:a+1,end:a+1},this.getSnapshot()},this.getSlashTrigger=()=>vi(this.nodes,this.selection)}};function Mi(e){let{key:t,shiftKey:n,isComposing:r,isSlashMenuOpen:i,slashItemCount:a,activeSlashIndex:o,isSending:s,canStopGeneration:c}=e;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 Ni=`http://www.w3.org/2000/svg`,Pi=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=yi(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(Ni,`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(Ni,n.tag);for(let[t,r]of Object.entries(n.attrs))e.setAttribute(t,r);t.append(e)}return t}}},Fi=188,Ii=class{constructor(e){this.controller=e,this.surfaceRenderer=new Pi,this.sync=(e,t)=>this.controller.sync(e,t),this.syncSelectionFromRoot=e=>this.controller.setSelection(Di(e,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(e,t)=>{!e||document.activeElement!==e||Oi(e,this.controller.getSnapshot().nodes,t)},this.syncViewport=e=>{e&&(e.style.maxHeight=`${Fi}px`,e.style.overflowY=e.scrollHeight>Fi?`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=Ai(a);r(this.controller.replaceDocument(o.nodes,o.selection))},this.handleCompositionEnd=e=>{let{event:t,commitSnapshot:n}=e,r=t.currentTarget,i=Ai(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,onSlashActiveIndexChange:c,onSlashQueryChange:l,onSlashOpenChange:u}=e,d=this.controller.getSnapshot(),f=Mi({key:t.key,shiftKey:t.shiftKey,isComposing:t.nativeEvent.isComposing,isSlashMenuOpen:d.slashTrigger!==null,slashItemCount:n.length,activeSlashIndex:r,isSending:a.isSending,canStopGeneration:a.canStopGeneration});if(f.type!==`noop`){if(t.preventDefault(),f.type===`move-slash-index`){c(f.index);return}if(f.type===`insert-active-slash-item`){i&&s(i.value??i.key,i.title);return}if(f.type===`close-slash`){l?.(null),u(!1);return}if(f.type===`stop-generation`){a.onStop();return}if(f.type===`insert-line-break`){o(this.controller.insertText(`
3
+ `));return}if(f.type===`send-message`){a.onSend();return}f.type===`delete-content`&&o(this.controller.deleteContent(f.direction))}},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)}}},Li=class{constructor(){this.controller=new ji,this.viewController=new Ii(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.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,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}}},Ri=(0,F.forwardRef)(function(e,t){let{nodes:n,placeholder:r,disabled:i,slashItems:a,actions:o,onNodesChange:s,onFilesAdd:c,onSlashQueryChange:l,onSlashTriggerChange:u,onSlashOpenChange:d,onSlashActiveIndexChange:f,activeSlashIndex:p}=e,[m,h]=(0,F.useState)(0),[g]=(0,F.useState)(()=>new Li),{snapshot:_,bindRootElement:v,handleBeforeInput:y,handleInput:b,handleCompositionStart:x,handleCompositionEnd:S,handleKeyDown:C,handlePaste:w,handleBlur:T,syncSelectionState:E,imperativeHandle:D}=g.update({nodes:n,disabled:i,slashItems:a,actions:o,onNodesChange:s,onFilesAdd:c,onSlashQueryChange:l,onSlashTriggerChange:u,onSlashOpenChange:d,onSlashActiveIndexChange:f,activeSlashIndex:p,requestRender:()=>h(e=>e+1)});return(0,F.useImperativeHandle)(t,()=>D,[D]),(0,F.useLayoutEffect)(()=>{g.renderSurface(),g.restoreDomAfterCommit(),g.syncViewport()},[g,_.nodes,_.nodeStartMap,m]),(0,L.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,L.jsx)(`div`,{className:`min-h-[60px]`,children:(0,L.jsx)(`div`,{ref:v,contentEditable:!i,suppressContentEditableWarning:!0,role:`textbox`,"aria-multiline":`true`,"data-placeholder":r,onBeforeInput:y,onInput:b,onCompositionStart:x,onCompositionEnd:S,onKeyDown:C,onKeyUp:E,onMouseUp:E,onFocus:E,onBlur:T,onPaste:w,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 zi({hint:e}){return e?e.loading?(0,L.jsx)(`div`,{className:`px-4 pb-2`,children:(0,L.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`h-3 w-28 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`span`,{className:`h-3 w-16 animate-pulse rounded bg-gray-200`})]})}):(0,L.jsx)(`div`,{className:`px-4 pb-2`,children:(0,L.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,L.jsx)(`span`,{children:e.text}):null,e.actionLabel&&e.onAction?(0,L.jsx)(`button`,{type:`button`,onClick:e.onAction,className:`font-semibold underline-offset-2 hover:underline`,children:e.actionLabel}):null]})}):null}var Bi=(0,F.forwardRef)(function(e,t){let n=(0,F.useRef)(null),[r,i]=(0,F.useState)(null),[a,o]=(0,F.useState)(0),[s,c]=(0,F.useState)(null),[l,u]=(0,F.useState)(null),d=s!==null&&l!==s,f=e.slashMenu.items[a]??null;(0,F.useEffect)(()=>{o(t=>e.slashMenu.items.length===0?0:Math.min(t,e.slashMenu.items.length-1))},[e.slashMenu.items.length]),(0,F.useEffect)(()=>{r!==null&&o(0)},[r]),(0,F.useEffect)(()=>{s===null&&l!==null&&u(null)},[s,l]);let p=(0,F.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,F.useImperativeHandle)(t,()=>({insertFileToken:(e,t)=>n.current?.insertFileToken(e,t),insertFileTokens:e=>n.current?.insertFileTokens(e),focusComposer:()=>n.current?.focusComposer()}),[]),(0,L.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Ri,{ref:n,nodes:e.composer.nodes,placeholder:e.composer.placeholder,disabled:e.composer.disabled,slashItems:e.slashMenu.items,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,L.jsx)(Hr,{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,L.jsx)(zi,{hint:e.hint}),(0,L.jsx)(ei,{...p})]})})})});Bi.displayName=`ChatInputBar`;function Vi({role:e}){return e===`user`?(0,L.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,L.jsx)(be,{className:`h-4 w-4`})}):e===`tool`?(0,L.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,L.jsx)($e,{className:`h-4 w-4`})}):(0,L.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,L.jsx)(ge,{className:`h-[18px] w-[18px] text-white/95`,strokeWidth:2.5})})}function Hi(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Ui=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Wi=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Gi={};function Ki(e,t){return((t||Gi).jsx?Wi:Ui).test(e)}var qi=/[ \t\n\f\r]/g;function Ji(e){return typeof e==`object`?e.type===`text`?Yi(e.value):!1:Yi(e)}function Yi(e){return e.replace(qi,``)===``}var Xi=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Xi.prototype.normal={},Xi.prototype.property={},Xi.prototype.space=void 0;function Zi(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Xi(n,r,t)}function Qi(e){return e.toLowerCase()}var B=class{constructor(e,t){this.attribute=t,this.property=e}};B.prototype.attribute=``,B.prototype.booleanish=!1,B.prototype.boolean=!1,B.prototype.commaOrSpaceSeparated=!1,B.prototype.commaSeparated=!1,B.prototype.defined=!1,B.prototype.mustUseProperty=!1,B.prototype.number=!1,B.prototype.overloadedBoolean=!1,B.prototype.property=``,B.prototype.spaceSeparated=!1,B.prototype.space=void 0;var $i=r({boolean:()=>V,booleanish:()=>H,commaOrSpaceSeparated:()=>ra,commaSeparated:()=>na,number:()=>U,overloadedBoolean:()=>ta,spaceSeparated:()=>W}),ea=0,V=ia(),H=ia(),ta=ia(),U=ia(),W=ia(),na=ia(),ra=ia();function ia(){return 2**++ea}var aa=Object.keys($i),oa=class extends B{constructor(e,t,n,r){let i=-1;if(super(e,t),sa(this,`space`,r),typeof n==`number`)for(;++i<aa.length;){let e=aa[i];sa(this,aa[i],(n&$i[e])===$i[e])}}};oa.prototype.defined=!0;function sa(e,t,n){n&&(e[t]=n)}function ca(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new oa(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Qi(r)]=r,n[Qi(a.attribute)]=r}return new Xi(t,n,e.space)}var la=ca({properties:{ariaActiveDescendant:null,ariaAtomic:H,ariaAutoComplete:null,ariaBusy:H,ariaChecked:H,ariaColCount:U,ariaColIndex:U,ariaColSpan:U,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:H,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:H,ariaFlowTo:W,ariaGrabbed:H,ariaHasPopup:null,ariaHidden:H,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:U,ariaLive:null,ariaModal:H,ariaMultiLine:H,ariaMultiSelectable:H,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:U,ariaPressed:H,ariaReadOnly:H,ariaRelevant:null,ariaRequired:H,ariaRoleDescription:W,ariaRowCount:U,ariaRowIndex:U,ariaRowSpan:U,ariaSelected:H,ariaSetSize:U,ariaSort:null,ariaValueMax:U,ariaValueMin:U,ariaValueNow:U,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function ua(e,t){return t in e?e[t]:t}function da(e,t){return ua(e,t.toLowerCase())}var fa=ca({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:na,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:W,autoFocus:V,autoPlay:V,blocking:W,capture:null,charSet:null,checked:V,cite:null,className:W,cols:U,colSpan:null,content:null,contentEditable:H,controls:V,controlsList:W,coords:U|na,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:ta,draggable:H,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:W,height:U,hidden:ta,high:U,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:W,itemRef:W,itemScope:V,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:U,manifest:null,max:null,maxLength:U,media:null,method:null,min:null,minLength:U,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,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:V,optimum:U,pattern:null,ping:W,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:W,required:V,reversed:V,rows:U,rowSpan:U,sandbox:W,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:U,sizes:null,slot:null,span:U,spellCheck:H,src:null,srcDoc:null,srcLang:null,srcSet:null,start:U,step:null,style:null,tabIndex:U,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:H,width:U,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:U,borderColor:null,bottomMargin:U,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:U,leftMargin:U,link:null,longDesc:null,lowSrc:null,marginHeight:U,marginWidth:U,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:U,rules:null,scheme:null,scrolling:H,standby:null,summary:null,text:null,topMargin:U,valueType:null,version:null,vAlign:null,vLink:null,vSpace:U,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:U,security:null,unselectable:null},space:`html`,transform:da}),pa=ca({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:ra,accentHeight:U,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:U,amplitude:U,arabicForm:null,ascent:U,attributeName:null,attributeType:null,azimuth:U,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:U,by:null,calcMode:null,capHeight:U,className:W,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:U,diffuseConstant:U,direction:null,display:null,dur:null,divisor:U,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:U,enableBackground:null,end:null,event:null,exponent:U,externalResourcesRequired:null,fill:null,fillOpacity:U,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:na,g2:na,glyphName:na,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:U,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:U,horizOriginX:U,horizOriginY:U,id:null,ideographic:U,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:U,k:U,k1:U,k2:U,k3:U,k4:U,kernelMatrix:ra,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:U,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:U,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:U,overlineThickness:U,paintOrder:null,panose1:null,path:null,pathLength:U,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:U,pointsAtY:U,pointsAtZ:U,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ra,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ra,rev:ra,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ra,requiredFeatures:ra,requiredFonts:ra,requiredFormats:ra,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:U,specularExponent:U,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:U,strikethroughThickness:U,string:null,stroke:null,strokeDashArray:ra,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:U,strokeOpacity:U,strokeWidth:null,style:null,surfaceScale:U,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ra,tabIndex:U,tableValues:null,target:null,targetX:U,targetY:U,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ra,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:U,underlineThickness:U,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:U,values:null,vAlphabetic:U,vMathematical:U,vectorEffect:null,vHanging:U,vIdeographic:U,version:null,vertAdvY:U,vertOriginX:U,vertOriginY:U,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:U,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:ua}),ma=ca({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()}}),ha=ca({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:da}),ga=ca({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),_a={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`},va=/[A-Z]/g,ya=/-[a-z]/g,ba=/^data[-\w.:]+$/i;function xa(e,t){let n=Qi(t),r=t,i=B;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ba.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(ya,Ca);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!ya.test(e)){let n=e.replace(va,Sa);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=oa}return new i(r,t)}function Sa(e){return`-`+e.toLowerCase()}function Ca(e){return e.charAt(1).toUpperCase()}var wa=Zi([la,fa,ma,ha,ga],`html`),Ta=Zi([la,pa,ma,ha,ga],`svg`);function Ea(e){return e.join(` `).trim()}var Da=i(((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=`
4
+ `,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})),Oa=i((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(Da());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}})),ka=i((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))}})),Aa=i(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Oa()),r=ka();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})),ja=Na(`end`),Ma=Na(`start`);function Na(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 Pa(e){let t=Ma(e),n=ja(e);if(t&&n)return{start:t,end:n}}function Fa(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?La(e.position):`start`in e||`end`in e?La(e):`line`in e||`column`in e?Ia(e):``}function Ia(e){return Ra(e&&e.line)+`:`+Ra(e&&e.column)}function La(e){return Ia(e&&e.start)+`-`+Ia(e&&e.end)}function Ra(e){return e&&typeof e==`number`?e:1}var G=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=Fa(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}};G.prototype.file=``,G.prototype.name=``,G.prototype.reason=``,G.prototype.message=``,G.prototype.stack=``,G.prototype.column=void 0,G.prototype.line=void 0,G.prototype.ancestors=void 0,G.prototype.cause=void 0,G.prototype.fatal=void 0,G.prototype.place=void 0,G.prototype.ruleId=void 0,G.prototype.source=void 0;var za=e(Aa(),1),Ba={}.hasOwnProperty,Va=new Map,Ha=/[A-Z]/g,Ua=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Wa=new Set([`td`,`th`]),Ga=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Ka(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=ro(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=no(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`?Ta:wa,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=qa(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function qa(e,t,n){if(t.type===`element`)return Ja(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Ya(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Za(e,t,n);if(t.type===`mdxjsEsm`)return Xa(e,t);if(t.type===`root`)return Qa(e,t,n);if(t.type===`text`)return $a(e,t)}function Ja(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Ta,e.schema=i),e.ancestors.push(t);let a=lo(e,t.tagName,!1),o=io(e,t),s=oo(e,t);return Ua.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Ji(e):!0})),eo(e,o,a,t),to(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ya(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)}uo(e,t.position)}function Xa(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);uo(e,t.position)}function Za(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Ta,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:lo(e,t.name,!0),o=ao(e,t),s=oo(e,t);return eo(e,o,a,t),to(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Qa(e,t,n){let r={};return to(r,oo(e,t)),e.create(t,e.Fragment,r,n)}function $a(e,t){return t.value}function eo(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function to(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function no(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 ro(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Ma(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 io(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Ba.call(t.properties,i)){let a=so(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Wa.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 ao(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 uo(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 uo(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function oo(e,t){let n=[],r=-1,i=e.passKeys?new Map:Va;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=qa(e,a,o);s!==void 0&&n.push(s)}return n}function so(e,t,n){let r=xa(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Hi(n):Ea(n)),r.property===`style`){let t=typeof n==`object`?n:co(e,String(n));return e.stylePropertyNameCase===`css`&&(t=fo(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?_a[r.property]||r.property:r.attribute,n]}}function co(e,t){try{return(0,za.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new G("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=Ga+`#cannot-parse-style-attribute`,r}}function lo(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=Ki(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=Ki(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Ba.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);uo(e)}function uo(e,t){let n=new G("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=Ga+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function fo(e){let t={},n;for(n in e)Ba.call(e,n)&&(t[po(n)]=e[n]);return t}function po(e){let t=e.replace(Ha,mo);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function mo(e){return`-`+e.toLowerCase()}var ho={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`]},go={};function _o(e,t){let n=t||go;return vo(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function vo(e,t,n){if(bo(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 yo(e.children,t,n)}return Array.isArray(e)?yo(e,t,n):``}function yo(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=vo(e[i],t,n);return r.join(``)}function bo(e){return!!(e&&typeof e==`object`)}var xo=document.createElement(`i`);function So(e){let t=`&`+e+`;`;xo.innerHTML=t;let n=xo.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Co(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 wo(e,t){return e.length>0?(Co(e,e.length,0,t),e):t}var To={}.hasOwnProperty;function Eo(e){let t={},n=-1;for(;++n<e.length;)Do(t,e[n]);return t}function Do(e,t){let n;for(n in t){let r=(To.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){To.call(r,a)||(r[a]=[]);let e=i[a];Oo(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Oo(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Co(e,0,0,r)}function ko(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 Ao(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var K=Ro(/[A-Za-z]/),q=Ro(/[\dA-Za-z]/),jo=Ro(/[#-'*+\--9=?A-Z^-~]/);function Mo(e){return e!==null&&(e<32||e===127)}var No=Ro(/\d/),Po=Ro(/[\dA-Fa-f]/),Fo=Ro(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function Y(e){return e!==null&&(e<0||e===32)}function X(e){return e===-2||e===-1||e===32}var Io=Ro(/\p{P}|\p{S}/u),Lo=Ro(/\s/);function Ro(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function zo(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&q(e.charCodeAt(n+1))&&q(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 Z(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return X(r)?(e.enter(n),s(r)):t(r)}function s(r){return X(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Bo={tokenize:Vo};function Vo(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`),Z(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 J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Ho={tokenize:Wo},Uo={tokenize:Go};function Wo(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 Co(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(Uo,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(Uo,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 J(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++;Co(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 Go(e,t,n){return Z(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Ko(e){if(e===null||Y(e)||Lo(e))return 1;if(Io(e))return 2}function qo(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 Jo={name:`attention`,resolveAll:Yo,tokenize:Xo};function Yo(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};Zo(d,-c),Zo(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=wo(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=wo(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=wo(l,qo(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=wo(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=wo(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Co(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 Xo(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ko(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=Ko(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 Zo(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Qo={name:`autolink`,tokenize:$o};function $o(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 K(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||q(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||q(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||Mo(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):jo(t)?(e.consume(t),l):n(t)}function u(e){return q(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||q(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var es={partial:!0,tokenize:ts};function ts(e,t,n){return r;function r(t){return X(t)?Z(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var ns={continuation:{tokenize:is},exit:as,name:`blockQuote`,tokenize:rs};function rs(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 X(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function is(e,t,n){let r=this;return i;function i(t){return X(t)?Z(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(ns,t,n)(r)}}function as(e){e.exit(`blockQuote`)}var os={name:`characterEscape`,tokenize:ss};function ss(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 Fo(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var cs={name:`characterReference`,tokenize:ls};function ls(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=q,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=Po,u):(e.enter(`characterReferenceValue`),a=7,o=No,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===q&&!So(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 us={partial:!0,tokenize:ps},ds={concrete:!0,name:`codeFenced`,tokenize:fs};function fs(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`),X(t)?Z(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(us,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Z(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(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&&X(t)?Z(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(us,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(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`),X(t)?Z(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`),X(t)?Z(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function ps(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 ms={name:`codeIndented`,tokenize:gs},hs={partial:!0,tokenize:_s};function gs(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),Z(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):J(t)?e.attempt(hs,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function _s(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):Z(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):J(e)?i(e):n(e)}}var vs={name:`codeText`,previous:bs,resolve:ys,tokenize:xs};function ys(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 bs(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function xs(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)):J(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||J(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 Ss=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&&Cs(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),Cs(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Cs(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);Cs(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Cs(this.left,t.reverse())}}};function Cs(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 ws(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Ss(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,Ts(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 Co(e,0,1/0,u.slice(0)),!l}function Ts(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 Es={resolve:Os,tokenize:ks},Ds={partial:!0,tokenize:As};function Os(e){return ws(e),e}function ks(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):J(t)?e.check(Ds,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 As(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Z(e,a,`linePrefix`)}function a(i){if(i===null||J(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 js(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||Mo(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||J(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||Y(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||Mo(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 Ms(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):J(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||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!X(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Ns(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):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Z(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(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 Ps(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):X(i)?Z(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Fs={name:`definition`,tokenize:Ls},Is={partial:!0,tokenize:Rs};function Ls(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Ms.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Ao(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 Y(t)?Ps(e,l)(t):l(t)}function l(t){return js(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Is,d,d)(t)}function d(t){return X(t)?Z(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Rs(e,t,n){return r;function r(t){return Y(t)?Ps(e,i)(t):n(t)}function i(t){return Ns(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return X(t)?Z(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var zs={name:`hardBreakEscape`,tokenize:Bs};function Bs(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Vs={name:`headingAtx`,resolve:Hs,tokenize:Us};function Hs(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`},Co(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Us(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||Y(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):X(n)?Z(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||Y(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Ws=`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(`.`),Gs=[`pre`,`script`,`style`,`textarea`],Ks={concrete:!0,name:`htmlFlow`,resolveTo:Ys,tokenize:Xs},qs={partial:!0,tokenize:Qs},Js={partial:!0,tokenize:Zs};function Ys(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 Xs(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:re):K(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):K(a)?(e.consume(a),i=4,r.interrupt?t:re):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:re):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 K(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Y(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Gs.includes(l)?(i=1,r.interrupt?t(s):O(s)):Ws.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||q(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 X(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||K(t)?(e.consume(t),b):X(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||q(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):X(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):X(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(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||Y(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||X(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||J(t)?O(t):X(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),ie):t===63&&i===3?(e.consume(t),re):t===93&&i===5?(e.consume(t),M):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(qs,N,k)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Js,ee,N)(t)}function ee(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return t===null||J(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function A(t){return t===45?(e.consume(t),re):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 Gs.includes(n)?(e.consume(t),ie):O(t)}return K(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ne):O(t)}function M(t){return t===93?(e.consume(t),re):O(t)}function re(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),re):O(t)}function ie(t){return t===null||J(t)?(e.exit(`htmlFlowData`),N(t)):(e.consume(t),ie)}function N(n){return e.exit(`htmlFlow`),t(n)}}function Zs(e,t,n){let r=this;return i;function i(t){return J(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 Qs(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(es,t,n)}}var $s={name:`htmlText`,tokenize:ec};function ec(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):K(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):K(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):J(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):J(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):J(t)?(o=v,j(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,j(t)):(e.consume(t),y)}function b(e){return e===62?A(e):y(e)}function x(t){return K(t)?(e.consume(t),S):n(t)}function S(t){return t===45||q(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,j(t)):X(t)?(e.consume(t),C):A(t)}function w(t){return t===45||q(t)?(e.consume(t),w):t===47||t===62||Y(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),A):t===58||t===95||K(t)?(e.consume(t),E):J(t)?(o=T,j(t)):X(t)?(e.consume(t),T):A(t)}function E(t){return t===45||t===46||t===58||t===95||q(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):J(t)?(o=D,j(t)):X(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,k):J(t)?(o=O,j(t)):X(t)?(e.consume(t),O):(e.consume(t),ee)}function k(t){return t===i?(e.consume(t),i=void 0,te):t===null?n(t):J(t)?(o=k,j(t)):(e.consume(t),k)}function ee(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Y(t)?T(t):(e.consume(t),ee)}function te(e){return e===47||e===62||Y(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 X(t)?Z(e,M,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):M(t)}function M(t){return e.enter(`htmlTextData`),o(t)}}var tc={name:`labelEnd`,resolveAll:ac,resolveTo:oc,tokenize:sc},nc={tokenize:cc},rc={tokenize:lc},ic={tokenize:uc};function ac(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&&Co(e,0,e.length,n),e}function oc(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=wo(s,e.slice(a+1,a+r+3)),s=wo(s,[[`enter`,u,t]]),s=wo(s,qo(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=wo(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=wo(s,e.slice(o+1)),s=wo(s,[[`exit`,c,t]]),Co(e,a,e.length,s),e}function sc(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(Ao(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(nc,u,o?u:d)(t):t===91?e.attempt(rc,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(ic,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function cc(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 Y(t)?Ps(e,a)(t):a(t)}function a(t){return t===41?u(t):js(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Y(t)?Ps(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Ns(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Y(t)?Ps(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 lc(e,t,n){let r=this;return i;function i(t){return Ms.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Ao(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function uc(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 dc={name:`labelStartImage`,resolveAll:tc.resolveAll,tokenize:fc};function fc(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 pc={name:`labelStartLink`,resolveAll:tc.resolveAll,tokenize:mc};function mc(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 hc={name:`lineEnding`,tokenize:gc};function gc(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Z(e,t,`linePrefix`)}}var _c={name:`thematicBreak`,tokenize:vc};function vc(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||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),X(t)?Z(e,s,`whitespace`)(t):s(t))}}var Q={continuation:{tokenize:Sc},exit:wc,name:`list`,tokenize:xc},yc={partial:!0,tokenize:Tc},bc={partial:!0,tokenize:Cc};function xc(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:No(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(_c,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 No(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(es,r.interrupt?n:u,e.attempt(yc,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return X(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 Sc(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(es,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Z(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!X(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(bc,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Z(e,e.attempt(Q,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Cc(e,t,n){let r=this;return Z(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 wc(e){e.exit(this.containerState.type)}function Tc(e,t,n){let r=this;return Z(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!X(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Ec={name:`setextUnderline`,resolveTo:Dc,tokenize:Oc};function Dc(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 Oc(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`),X(t)?Z(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var kc={tokenize:Ac};function Ac(e){let t=this,n=e.attempt(es,r,e.attempt(this.parser.constructs.flowInitial,i,Z(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Es,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 jc={resolveAll:Fc()},Mc=Pc(`string`),Nc=Pc(`text`);function Pc(e){return{resolveAll:Fc(e===`text`?Ic: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 Fc(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 Ic(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 Lc=r({attentionMarkers:()=>Gc,contentInitial:()=>zc,disable:()=>Kc,document:()=>Rc,flow:()=>Vc,flowInitial:()=>Bc,insideSpan:()=>Wc,string:()=>Hc,text:()=>Uc}),Rc={42:Q,43:Q,45:Q,48:Q,49:Q,50:Q,51:Q,52:Q,53:Q,54:Q,55:Q,56:Q,57:Q,62:ns},zc={91:Fs},Bc={[-2]:ms,[-1]:ms,32:ms},Vc={35:Vs,42:_c,45:[Ec,_c],60:Ks,61:Ec,95:_c,96:ds,126:ds},Hc={38:cs,92:os},Uc={[-5]:hc,[-4]:hc,[-3]:hc,33:dc,38:cs,42:Jo,60:[Qo,$s],91:pc,92:[zs,os],93:tc,95:Jo,96:vs},Wc={null:[Jo,jc]},Gc={null:[42,95]},Kc={null:[]};function qc(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=wo(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=qo(a,l.events,l),l.events):[]}function f(e,t){return Yc(p(e),t)}function p(e){return Jc(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){J(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&&Co(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 Jc(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 Yc(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=`
5
+ `;break;case-3:o=`\r
6
+ `;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 Xc(e){let t={constructs:Eo([Lc,...(e||{}).extensions||[]]),content:n(Bo),defined:[],document:n(Ho),flow:n(kc),lazy:{},string:n(Mc),text:n(Nc)};return t;function n(e){return n;function n(n){return qc(t,e,n)}}}function Zc(e){for(;!ws(e););return e}var Qc=/[\0\t\n\r]/g;function $c(){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(Qc.lastIndex=u,c=Qc.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 el=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tl(e){return e.replace(el,nl)}function nl(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return ko(n.slice(t?2:1),t?16:10)}return So(n)||e}var rl={}.hasOwnProperty;function il(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),al(n)(Zc(Xc(n).document().write($c()(e,t,!0))))}function al(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(be),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ge),blockQuote:a(P),characterEscape:T,characterReference:T,codeFenced:a(fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(fe,o),codeText:a(pe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(he),hardBreakEscape:a(_e),hardBreakTrailing:a(_e),htmlFlow:a(ve,o),htmlFlowData:T,htmlText:a(ve,o),htmlTextData:T,image:a(ye),label:o,link:a(be),listItem:a(Se),listItemValue:f,listOrdered:a(xe,d),listUnordered:a(xe),paragraph:a(Ce),reference:ae,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ge),strong:a(we),thematicBreak:a(Ee)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(te),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(ee),htmlTextData:E,image:c(j),label:M,labelText:ne,lineEnding:D,link:c(A),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:oe,resourceDestinationString:re,resourceTitleString:ie,resource:N,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};sl(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]];rl.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]||ll).call(a,void 0,e[0])}for(r.position={start:ol(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:ol(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:ol(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]||ll).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Fa({start:e.start,end:e.end})+`): it’s not open`);n.position.end=ol(e.end)}function u(){return _o(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=Ao(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=Te(),n.position={start:ol(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=ol(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=ol(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 k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}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 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=tl(t),n.identifier=Ao(t).toLowerCase()}function M(){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 re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function N(){this.data.inReference=void 0}function ae(){this.data.referenceType=`collapsed`}function oe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Ao(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function se(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=ko(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=So(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=ol(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function P(){return{type:`blockquote`,children:[]}}function fe(){return{type:`code`,lang:null,meta:null,value:``}}function pe(){return{type:`inlineCode`,value:``}}function me(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function he(){return{type:`emphasis`,children:[]}}function ge(){return{type:`heading`,depth:0,children:[]}}function _e(){return{type:`break`}}function ve(){return{type:`html`,value:``}}function ye(){return{type:`image`,title:null,url:``,alt:null}}function be(){return{type:`link`,title:null,url:``,children:[]}}function xe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Se(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Ce(){return{type:`paragraph`,children:[]}}function we(){return{type:`strong`,children:[]}}function Te(){return{type:`text`,value:``}}function Ee(){return{type:`thematicBreak`}}}function ol(e){return{line:e.line,column:e.column,offset:e.offset}}function sl(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?sl(e,r):cl(e,r)}}function cl(e,t){let n;for(n in t)if(rl.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 ll(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Fa({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Fa({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Fa({start:t.start,end:t.end})+`) is still open`)}function ul(e){let t=this;t.parser=n;function n(n){return il(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function dl(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 fl(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
7
+ `}]}function pl(e,t){let n=t.value?t.value+`
8
+ `:``,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 ml(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hl(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function gl(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=zo(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 _l(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 vl(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function yl(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 bl(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return yl(e,t);let i={src:zo(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 xl(e,t){let n={src:zo(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 Sl(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 Cl(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return yl(e,t);let i={href:zo(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 wl(e,t){let n={href:zo(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 Tl(e,t,n){let r=e.all(t),i=n?El(n):Dl(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:`
9
+ `}),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:`
10
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function El(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Dl(n[r])}return t}function Dl(e){return e.spread??e.children.length>1}function Ol(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 kl(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Al(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function jl(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ml(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=Ma(t.children[1]),o=ja(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 Nl(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 Pl(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var Fl=9,Il=32;function Ll(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Rl(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Rl(t.slice(i),i>0,!1)),a.join(``)}function Rl(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===Fl||t===Il;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===Fl||t===Il;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function zl(e,t){let n={type:`text`,value:Ll(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Bl(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Vl={blockquote:dl,break:fl,code:pl,delete:ml,emphasis:hl,footnoteReference:gl,heading:_l,html:vl,imageReference:bl,image:xl,inlineCode:Sl,linkReference:Cl,link:wl,listItem:Tl,list:Ol,paragraph:kl,root:Al,strong:jl,table:Ml,tableCell:Pl,tableRow:Nl,text:zl,thematicBreak:Bl,toml:Hl,yaml:Hl,definition:Hl,footnoteDefinition:Hl};function Hl(){}var Ul=typeof self==`object`?self:globalThis,Wl=(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 Ul[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 Ul[a](o),i)};return r},Gl=e=>Wl(new Map,e)(0),Kl=``,{toString:ql}={},{keys:Jl}=Object,Yl=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=ql.call(e).slice(8,-1);switch(n){case`Array`:return[1,Kl];case`Object`:return[2,Kl];case`Date`:return[3,Kl];case`RegExp`:return[4,Kl];case`Map`:return[5,Kl];case`Set`:return[6,Kl];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},Xl=([e,t])=>e===0&&(t===`function`||t===`symbol`),Zl=(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]=Yl(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 Jl(r))(e||!Xl(Yl(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||!(Xl(Yl(n))||Xl(Yl(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!Xl(Yl(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},Ql=(e,{json:t,lossy:n}={})=>{let r=[];return Zl(!(t||n),!!t,new Map,r)(e),r},$l=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?Gl(Ql(e,t)):structuredClone(e):(e,t)=>Gl(Ql(e,t));function eu(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 tu(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function nu(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||eu,r=e.options.footnoteBackLabel||tu,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=zo(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:{...$l(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
11
+ `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
12
+ `}]}}var ru=(function(e){if(e==null)return cu;if(typeof e==`function`)return su(e);if(typeof e==`object`)return Array.isArray(e)?iu(e):au(e);if(typeof e==`string`)return ou(e);throw Error(`Expected function, string, or object as test`)});function iu(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ru(e[n]);return su(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function au(e){let t=e;return su(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function ou(e){return su(t);function t(t){return t&&t.type===e}}function su(e){return t;function t(t,n,r){return!!(lu(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function cu(){return!0}function lu(e){return typeof e==`object`&&!!e&&`type`in e}function uu(e){return e}var du=[];function fu(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=ru(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 (`+uu(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=du,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=pu(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 pu(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?du:[e]}function mu(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),fu(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 hu={}.hasOwnProperty,gu={};function _u(e,t){let n=t||gu,r=new Map,i=new Map,a={all:s,applyData:yu,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Vl,...n.handlers},one:o,options:n,patch:vu,wrap:xu};return mu(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(hu.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=$l(n);return r.children=a.all(e),r}return $l(e)}return(a.options.unknownHandler||bu)(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=Su(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=Su(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function vu(e,t){e.position&&(t.position=Pa(e))}function yu(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,$l(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function bu(e,t){let n=t.data||{},r=`value`in t&&!(hu.call(n,`hProperties`)||hu.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 xu(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
13
+ `});++r<e.length;)r&&n.push({type:`text`,value:`
14
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
15
+ `}),n}function Su(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Cu(e,t){let n=_u(e,t),r=n.one(e,void 0),i=nu(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
16
+ `},i)),a}function wu(e,t){return e&&`run`in e?async function(n,r){let i=Cu(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Cu(n,{file:r,...e||t})}}function Tu(e){if(e)throw e}var Eu=i(((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 Du(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 Ou(){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?ku(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 ku(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 Au={basename:ju,dirname:Mu,extname:Nu,join:Pu,sep:`/`};function ju(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Lu(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 Mu(e){if(Lu(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 Nu(e){Lu(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 Pu(...e){let t=-1,n;for(;++t<e.length;)Lu(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Fu(n)}function Fu(e){Lu(e);let t=e.codePointAt(0)===47,n=Iu(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Iu(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 Lu(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Ru={cwd:zu};function zu(){return`/`}function Bu(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Vu(e){if(typeof e==`string`)e=new URL(e);else if(!Bu(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 Hu(e)}function Hu(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 Uu=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Wu=class{constructor(e){let t;t=e?Bu(e)?{path:e}:typeof e==`string`||Ju(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Ru.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Uu.length;){let e=Uu[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)Uu.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Au.basename(this.path):void 0}set basename(e){Ku(e,`basename`),Gu(e,`basename`),this.path=Au.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Au.dirname(this.path):void 0}set dirname(e){qu(this.basename,`dirname`),this.path=Au.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Au.extname(this.path):void 0}set extname(e){if(Gu(e,`extname`),qu(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=Au.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Bu(e)&&(e=Vu(e)),Ku(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Au.basename(this.path,this.extname):void 0}set stem(e){Ku(e,`stem`),Gu(e,`stem`),this.path=Au.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 G(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 Gu(e,t){if(e&&e.includes(Au.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Au.sep+"`")}function Ku(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function qu(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Ju(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Yu=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Xu=e(Eu(),1),Zu={}.hasOwnProperty,Qu=new class e extends Yu{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=Ou()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Xu.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(td(`data`,this.frozen),this.namespace[e]=t,this):Zu.call(this.namespace,e)&&this.namespace[e]||void 0:e?(td(`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=id(e),n=this.parser||this.Parser;return $u(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),$u(`process`,this.parser||this.Parser),ed(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=id(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);od(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(),$u(`processSync`,this.parser||this.Parser),ed(`processSync`,this.compiler||this.Compiler),this.process(e,r),rd(`processSync`,`process`,t),n;function r(e,r){t=!0,Tu(e),n=r}}run(e,t,n){nd(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=id(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),rd(`runSync`,`run`,n),r;function i(e,t){Tu(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=id(t),r=this.compiler||this.Compiler;return ed(`stringify`,r),nd(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(td(`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,Xu.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];Du(o)&&Du(r)&&(r=(0,Xu.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function $u(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function ed(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function td(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 nd(e){if(!Du(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function rd(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function id(e){return ad(e)?e:new Wu(e)}function ad(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function od(e){return typeof e==`string`||sd(e)}function sd(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var cd=[],ld={allowDangerousHtml:!0},ud=/^(https?|ircs?|mailto|xmpp)$/i,dd=[{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 fd(e){let t=pd(e),n=md(e);return hd(t.runSync(t.parse(n),n),e)}function pd(e){let t=e.rehypePlugins||cd,n=e.remarkPlugins||cd,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ld}:ld;return Qu().use(ul).use(n).use(wu,r).use(t)}function md(e){let t=e.children||``,n=new Wu;return typeof t==`string`?n.value=t:``+t,n}function hd(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||gd;for(let e of dd)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return mu(e,l),Ka(e,{Fragment:L.Fragment,components:i,ignoreInvalidStyle:!0,jsx:L.jsx,jsxs:L.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 ho)if(Object.hasOwn(ho,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=ho[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 gd(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||ud.test(e.slice(0,t))?e:``}function _d(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 vd(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function yd(e,t,n){let r=ru((n||{}).ignore||[]),i=bd(t),a=-1;for(;++a<i.length;)fu(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 bd(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([xd(e[0]),Sd(e[1])])}return t}function xd(e){return typeof e==`string`?new RegExp(vd(e),`g`):e}function Sd(e){return typeof e==`function`?e:function(){return e}}var Cd=`phrasing`,wd=[`autolink`,`link`,`image`,`label`];function Td(){return{transforms:[Nd],enter:{literalAutolink:Dd,literalAutolinkEmail:Od,literalAutolinkHttp:Od,literalAutolinkWww:Od},exit:{literalAutolink:Md,literalAutolinkEmail:jd,literalAutolinkHttp:kd,literalAutolinkWww:Ad}}}function Ed(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:Cd,notInConstruct:wd},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:Cd,notInConstruct:wd},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:Cd,notInConstruct:wd}]}}function Dd(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Od(e){this.config.enter.autolinkProtocol.call(this,e)}function kd(e){this.config.exit.autolinkProtocol.call(this,e)}function Ad(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 jd(e){this.config.exit.autolinkEmail.call(this,e)}function Md(e){this.exit(e)}function Nd(e){yd(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Pd],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Fd]],{ignore:[`link`,`linkReference`]})}function Pd(e,t,n,r,i){let a=``;if(!Rd(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Id(n)))return!1;let o=Ld(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 Fd(e,t,n,r){return!Rd(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Id(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 Ld(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=_d(e,`(`),a=_d(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 Rd(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Lo(n)||Io(n))&&(!t||n!==47)}Jd.peek=qd;function zd(){this.buffer()}function Bd(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Vd(){this.buffer()}function Hd(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Ud(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ao(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Wd(e){this.exit(e)}function Gd(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ao(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Kd(e){this.exit(e)}function qd(){return`[`}function Jd(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 Yd(){return{enter:{gfmFootnoteCallString:zd,gfmFootnoteCall:Bd,gfmFootnoteDefinitionLabelString:Vd,gfmFootnoteDefinition:Hd},exit:{gfmFootnoteCallString:Ud,gfmFootnoteCall:Wd,gfmFootnoteDefinitionLabelString:Gd,gfmFootnoteDefinition:Kd}}}function Xd(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Jd},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?`
17
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Qd:Zd))),s(),o}}function Zd(e,t,n){return t===0?e:Qd(e,t,n)}function Qd(e,t,n){return(n?``:` `)+e}var $d=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];af.peek=of;function ef(){return{canContainEols:[`delete`],enter:{strikethrough:nf},exit:{strikethrough:rf}}}function tf(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:$d}],handlers:{delete:af}}}function nf(e){this.enter({type:`delete`,children:[]},e)}function rf(e){this.exit(e)}function af(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 of(){return`~`}function sf(e){return e.length}function cf(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||sf,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=lf(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]=uf(r[d]);else{let e=uf(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(`
18
+ `)}function lf(e){return e==null?``:String(e)}function uf(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 df(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()),ff);return i(),o}function ff(e,t,n){return`>`+(n?``:` `)+e}function pf(e,t){return mf(e,t.inConstruct,!0)&&!mf(e,t.notInConstruct,!1)}function mf(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 hf(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
19
+ `&&pf(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
20
+ `}function gf(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 _f(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 vf(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function yf(e,t,n,r){let i=vf(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(_f(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,bf);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(gf(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:`
21
+ `,encode:["`"],...s.current()})),t()}return u+=s.move(`
22
+ `),a&&(u+=s.move(a+`
23
+ `)),u+=s.move(c),l(),u}function bf(e,t,n){return(n?``:` `)+e}function xf(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Sf(e,t,n,r){let i=xf(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?` `:`
24
+ `,...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 Cf(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function wf(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Tf(e,t,n){let r=Ko(e),i=Ko(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}}Ef.peek=Df;function Ef(e,t,n,r){let i=Cf(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=Tf(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=wf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Tf(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+wf(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Df(e,t,n){return n.options.emphasis||`*`}function Of(e,t){let n=!1;return mu(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)&&_o(e)&&(t.options.setext||n))}function kf(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Of(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
25
+ `,after:`
26
+ `});return r(),t(),o+`
27
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
28
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
29
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=wf(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Af.peek=jf;function Af(e){return e.value||``}function jf(){return`<`}Mf.peek=Nf;function Mf(e,t,n,r){let i=xf(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 Nf(){return`!`}Pf.peek=Ff;function Pf(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 Ff(){return`!`}If.peek=Lf;function If(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 Lf(){return"`"}function Rf(e,t){let n=_o(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))}zf.peek=Bf;function zf(e,t,n,r){let i=xf(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Rf(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 Bf(e,t,n){return Rf(e,n)?`<`:`[`}Vf.peek=Hf;function Vf(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 Hf(){return`[`}function Uf(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 Wf(e){let t=Uf(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 Gf(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Kf(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 qf(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Gf(n):Uf(n),s=e.ordered?o===`.`?`)`:`.`:Wf(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),Kf(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 Jf(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 Yf(e,t,n,r){let i=Jf(n),a=n.bulletCurrent||Uf(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 Xf(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Zf=ru([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Qf(e,t,n,r){return(e.children.some(function(e){return Zf(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function $f(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}ep.peek=tp;function ep(e,t,n,r){let i=$f(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=Tf(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=wf(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Tf(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+wf(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function tp(e,t,n){return n.options.strong||`*`}function np(e,t,n,r){return n.safe(e.value,r)}function rp(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 ip(e,t,n){let r=(Kf(n)+(n.options.ruleSpaces?` `:``)).repeat(rp(n));return n.options.ruleSpaces?r.slice(0,-1):r}var ap={blockquote:df,break:hf,code:yf,definition:Sf,emphasis:Ef,hardBreak:hf,heading:kf,html:Af,image:Mf,imageReference:Pf,inlineCode:If,link:zf,linkReference:Vf,list:qf,listItem:Yf,paragraph:Xf,root:Qf,strong:ep,text:np,thematicBreak:ip};function op(){return{enter:{table:sp,tableData:dp,tableHeader:dp,tableRow:lp},exit:{codeText:fp,table:cp,tableData:up,tableHeader:up,tableRow:up}}}function sp(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 cp(e){this.exit(e),this.data.inTable=void 0}function lp(e){this.enter({type:`tableRow`,children:[]},e)}function up(e){this.exit(e)}function dp(e){this.enter({type:`tableCell`,children:[]},e)}function fp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,pp));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function pp(e,t){return t===`|`?t:e}function mp(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
30
+ `,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(`
31
+ `))}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 cf(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=ap.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function hp(){return{exit:{taskListCheckValueChecked:_p,taskListCheckValueUnchecked:_p,paragraph:vp}}}function gp(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:yp}}}function _p(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function vp(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 yp(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=ap.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 bp(){return[Td(),Yd(),ef(),op(),hp()]}function xp(e){return{extensions:[Ed(),Xd(e),tf(),mp(e),gp()]}}var Sp={tokenize:Ip,partial:!0},Cp={tokenize:Lp,partial:!0},wp={tokenize:Rp,partial:!0},Tp={tokenize:zp,partial:!0},Ep={tokenize:Bp,partial:!0},Dp={name:`wwwAutolink`,tokenize:Pp,previous:Vp},Op={name:`protocolAutolink`,tokenize:Fp,previous:Hp},kp={name:`emailAutolink`,tokenize:Np,previous:Up},Ap={};function jp(){return{text:Ap}}for(var Mp=48;Mp<123;)Ap[Mp]=kp,Mp++,Mp===58?Mp=65:Mp===91&&(Mp=97);Ap[43]=kp,Ap[45]=kp,Ap[46]=kp,Ap[95]=kp,Ap[72]=[kp,Op],Ap[104]=[kp,Op],Ap[87]=[kp,Dp],Ap[119]=[kp,Dp];function Np(e,t,n){let r=this,i,a;return o;function o(t){return!Wp(t)||!Up.call(r,r.previous)||Gp(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Wp(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Ep,u,l)(t):t===45||t===95||q(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&&K(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Pp(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Vp.call(r,r.previous)||Gp(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Sp,e.attempt(Cp,e.attempt(wp,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Fp(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Hp.call(r,r.previous)&&!Gp(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(K(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||Mo(t)||Y(t)||Lo(t)||Io(t)?n(t):e.attempt(Cp,e.attempt(wp,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Ip(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 Lp(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Tp,c,s)(t):t===null||Y(t)||Lo(t)||t!==45&&Io(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 Rp(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(Tp,t,a)(o):o===null||Y(o)||Lo(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zp(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||Y(o)||Lo(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Y(e)||Lo(e)?t(e):r(e)}function a(e){return K(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):K(t)?(e.consume(t),o):n(t)}}function Bp(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return q(e)?n(e):t(e)}}function Vp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Y(e)}function Hp(e){return!K(e)}function Up(e){return!(e===47||Wp(e))}function Wp(e){return e===43||e===45||e===46||e===95||q(e)}function Gp(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 Kp={tokenize:em,partial:!0};function qp(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Zp,continuation:{tokenize:Qp},exit:$p}},text:{91:{name:`gfmFootnoteCall`,tokenize:Xp},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Jp,resolveTo:Yp}}}}function Jp(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=Ao(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 Yp(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 Xp(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||Y(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Ao(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Y(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 Zp(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||Y(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Ao(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Y(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),Z(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Qp(e,t,n){return e.check(es,t,e.attempt(Kp,t,n))}function $p(e){e.exit(`gfmFootnoteDefinition`)}function em(e,t,n){let r=this;return Z(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 tm(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&&Co(o,o.length,0,qo(s,e.slice(r+1,n),t)),Co(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Co(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=Ko(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=Ko(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var nm=class{constructor(){this.map=[]}add(e,t,n){rm(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 rm(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 im(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 am(){return{flow:{null:{name:`table`,tokenize:om,resolveAll:sm}}}}function om(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):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):X(t)?Z(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||Y(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,X(t)?Z(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 X(t)?Z(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||J(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 X(t)?Z(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(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||J(n)?(e.exit(`tableRow`),t(n)):X(n)?Z(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Y(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 sm(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 nm;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(lm(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=cm(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=cm(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=cm(f,t,o,i,n,d)):(o[0]=o[1],d=cm(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&lm(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=im(t.events,n))}return e}function cm(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},um(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=um(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=um(t.events,n[2]),a=um(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({},um(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function lm(e,t,n,r,i){let a=[],o=um(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 um(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var dm={name:`tasklistCheck`,tokenize:pm};function fm(){return{text:{91:dm}}}function pm(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 Y(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 J(r)?t(r):X(r)?e.check({tokenize:mm},t,n)(r):n(r)}}function mm(e,t,n){return Z(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function hm(e){return Eo([jp(),qp(),tm(e),am(),fm()])}var gm={};function _m(e){let t=this,n=e||gm,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(hm(n)),a.push(bp()),o.push(xp(n))}function vm(){return typeof navigator<`u`&&typeof navigator.clipboard?.writeText==`function`}function ym(e){if(typeof document>`u`)return;let t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(e=>t.addRange(e)))}function bm(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):ym(a),s}async function xm(e){if(!e)return!1;if(vm())try{return await navigator.clipboard.writeText(e),!0}catch{return bm(e)}return bm(e)}var Sm=1300;function Cm(e){let[t,n]=(0,F.useState)(!1),r=(0,F.useCallback)(async()=>{e.text&&(await xm(e.text)?n(!0):n(!1))},[e.text]);return(0,F.useEffect)(()=>{if(!t||typeof window>`u`)return;let r=window.setTimeout(()=>n(!1),e.resetDelayMs??Sm);return()=>window.clearTimeout(r)},[t,e.resetDelayMs]),{copied:t,copy:r}}var wm=/language-([a-z0-9-]+)/i;function Tm(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(Tm).join(``):``}function Em(e){let t=Tm(e);return t.endsWith(`
32
+ `)?t.slice(0,-1):t}function Dm(e){return(e?wm.exec(e):null)?.[1]?.toLowerCase()||`text`}function Om(e){let t=(0,F.useMemo)(()=>Dm(e.className),[e.className]),n=(0,F.useMemo)(()=>Em(e.children),[e.children]),{copied:r,copy:i}=Cm({text:n});return(0,L.jsxs)(`div`,{className:`chat-codeblock`,children:[(0,L.jsxs)(`div`,{className:`chat-codeblock-toolbar`,children:[(0,L.jsx)(`span`,{className:`chat-codeblock-language`,children:t}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-codeblock-copy`,onClick:()=>void i(),"aria-label":r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel,children:[r?(0,L.jsx)(ne,{className:`h-3.5 w-3.5`}):(0,L.jsx)(zt,{className:`h-3.5 w-3.5`}),(0,L.jsx)(`span`,{children:r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel})]})]}),(0,L.jsx)(`pre`,{children:(0,L.jsx)(`code`,{className:e.className,children:n})})]})}var km=14e4,Am=new Set([`http:`,`https:`,`mailto:`,`tel:`]);function jm(e){return e.length<=km?e:`${e.slice(0,km)}\n\n...`}function Mm(e){if(!e)return null;if(e.startsWith(`#`)||e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))return e;try{let t=new URL(e);return Am.has(t.protocol)?e:null}catch{return null}}function Nm(e){return/^https?:\/\//i.test(e)}function Pm(e){let t=e.role===`user`,n=(0,F.useMemo)(()=>({a:({href:e,children:t,...n})=>{let r=Mm(e);if(!r)return(0,L.jsx)(`span`,{className:`chat-link-invalid`,children:t});let i=Nm(r);return(0,L.jsx)(`a`,{...n,href:r,target:i?`_blank`:void 0,rel:i?`noreferrer noopener`:void 0,children:t})},table:({children:e,...t})=>(0,L.jsx)(`div`,{className:`chat-table-wrap`,children:(0,L.jsx)(`table`,{...t,children:e})}),input:({type:e,checked:t,...n})=>e===`checkbox`?(0,L.jsx)(`input`,{...n,type:`checkbox`,checked:t,readOnly:!0,disabled:!0,className:`chat-task-checkbox`}):(0,L.jsx)(`input`,{...n,type:e}),img:({src:e,alt:t,...n})=>{let r=Mm(e);return r?(0,L.jsx)(`img`,{...n,src:r,alt:t||``,loading:`lazy`,decoding:`async`}):null},code:({className:t,children:n,...r})=>!t&&!String(n??``).includes(`
33
+ `)?(0,L.jsx)(`code`,{...r,className:z(`chat-inline-code`,t),children:n}):(0,L.jsx)(Om,{className:t,texts:e.texts,children:n})}),[e.texts]);return(0,L.jsx)(`div`,{className:z(`chat-markdown`,t?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,L.jsx)(fd,{skipHtml:!0,remarkPlugins:[_m],components:n,children:jm(e.text)})})}var Fm={archive:`Archive`,audio:`Audio`,code:`Code`,data:`Data`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF`,sheet:`Sheet`,video:`Video`},Im={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`},Lm=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),Rm=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),zm=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),Bm=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),Vm=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function Hm(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 Um(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 Wm(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`:Vm.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:Bm.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:Rm.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:Lm.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:zm.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function Gm(e){let t=Wm(e.label,e.mimeType),n=Hm(e.sizeBytes);return{category:t,extension:Um(e.label,e.mimeType),sizeLabel:n,metaBadges:[Fm[t],n].filter(e=>!!e)}}function Km(e,t){return(0,L.jsx)(`span`,{className:z(`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 qm(e,t){return(0,L.jsx)(`div`,{className:z(`truncate text-[11px]`,t?`text-white/58`:`text-slate-500`),children:e})}function Jm(e,t,n){return(0,L.jsx)(`span`,{className:z(`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 Ym({file:e,isUser:t=!1}){let{category:n,extension:r,metaBadges:i,sizeLabel:a}=Gm(e),o=!!e.dataUrl,s=o?e.isImage?`Open preview`:`Open file`:`Attached`,c=r.slice(0,4),l=z(`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,L.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Open preview: ${e.label}`,className:z(l,`group`),children:(0,L.jsxs)(`figure`,{children:[(0,L.jsxs)(`div`,{className:z(`relative overflow-hidden p-2`,t?`bg-white/[0.04]`:`bg-gradient-to-br from-slate-100 via-white to-slate-100`),children:[(0,L.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,L.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-4 top-4 flex items-center justify-between`,children:[a?Km(a,t):(0,L.jsx)(`span`,{}),(0,L.jsx)(`span`,{className:z(`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`:Im[n]),children:c})]})]}),(0,L.jsxs)(`figcaption`,{className:`flex items-start gap-3 p-4`,children:[(0,L.jsx)(`div`,{className:z(`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`:Im[n]),children:c}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold leading-5`,children:e.label}),(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:i.map(e=>Km(e,t))}),(0,L.jsx)(`div`,{className:`mt-2`,children:qm(e.mimeType,t)})]}),Jm(s,t,!0)]})]})});let u=(0,L.jsxs)(`div`,{className:`flex items-start gap-3 p-3.5`,children:[(0,L.jsx)(`div`,{className:z(`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`:Im[n]),children:c}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold leading-5`,children:e.label}),(0,L.jsxs)(`div`,{className:z(`mt-1 text-xs`,t?`text-white/68`:`text-slate-500`),children:[Fm[n],` attachment`]})]}),Jm(s,t,o)]}),(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:i.map(e=>Km(e,t))}),(0,L.jsx)(`div`,{className:`mt-2`,children:qm(e.mimeType,t)})]})]});return o?(0,L.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`Open file: ${e.label}`,className:z(l,`group`),children:u}):(0,L.jsx)(`div`,{className:l,children:u})}function Xm(e){let{isInProgress:t}=e,[n,r]=(0,F.useState)(t),[i,a]=(0,F.useState)(!1),o=(0,F.useRef)(t);(0,F.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 Zm({label:e,text:t,isUser:n,isInProgress:r}){let{isOpen:i,onSummaryClick:a}=Xm({isInProgress:r});return(0,L.jsxs)(`details`,{className:`mt-2`,open:i,children:[(0,L.jsx)(`summary`,{className:z(`cursor-pointer text-xs`,n?`text-primary-100`:`text-gray-500`),onClick:a,children:e}),(0,L.jsx)(`pre`,{className:z(`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 Qm({children:e,className:t}){return(0,L.jsx)(`div`,{className:z(`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 $m({children:e,className:t}){return(0,L.jsx)(`div`,{className:z(`border-t border-amber-200/15 bg-amber-50/50 px-3 pt-1 pb-2 w-full overflow-hidden`,t),children:e})}var eh={running:{text:`text-amber-500/80`,icon:Te,spin:!0},success:{text:`text-amber-500/80`,icon:ne,spin:!1},error:{text:`text-amber-500/80`,icon:Xt,spin:!1},cancelled:{text:`text-amber-500/80`,icon:Ut,spin:!1}};function th({card:e}){let t=eh[e.statusTone]||eh.cancelled,n=t.icon;return(0,L.jsxs)(`span`,{className:z(`inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0`,t.text),children:[(0,L.jsx)(n,{className:z(`h-3.5 w-3.5`,t.spin&&`animate-spin`),strokeWidth:3}),e.statusTone===`running`?e.statusLabel:null]})}function nh({card:e,icon:t,expanded:n,canExpand:r,onToggle:i}){let a=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``);return(0,L.jsxs)(`div`,{className:z(`flex items-center justify-between px-3 py-2.5 transition-colors bg-transparent`,r?`cursor-pointer hover:bg-amber-100/30`:``),onClick:i,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 font-mono min-w-0 max-w-[calc(100%-80px)] text-amber-950/80`,children:[(0,L.jsx)(t,{className:`h-4 w-4 text-amber-600/80 shrink-0`,strokeWidth:3}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,L.jsx)(`span`,{className:`font-bold shrink-0 tracking-tight`,children:e.toolName}),a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-amber-300 font-bold select-none shrink-0`,children:`›`}),(0,L.jsx)(`span`,{className:`truncate flex-1 min-w-0 font-normal`,title:a,children:a})]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,L.jsx)(th,{card:e}),r&&(n?(0,L.jsx)(w,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}):(0,L.jsx)(Lt,{className:`h-4 w-4 text-amber-400/80`,strokeWidth:3}))]})]})}function rh({card:e}){let t=e.output?.trim()??``,n=e.statusTone===`running`,r=!!(e.summary?.trim()||t.length>0),i=(0,F.useRef)(!r),[a,o]=(0,F.useState)(r&&(n||e.statusTone===`error`)),[s,c]=(0,F.useState)(!1),l=(0,F.useRef)(n);(0,F.useEffect)(()=>{i.current&&r&&n&&(o(!0),i.current=!1)},[r,n]),(0,F.useEffect)(()=>{l.current&&!n&&!s&&o(!1),l.current=n},[n,s]);let u=()=>{!t&&!n||(o(!a),c(!0))},d=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``);return(0,L.jsxs)(Qm,{children:[(0,L.jsx)(nh,{card:e,icon:Yt,expanded:a,canExpand:!!t||n,onToggle:u}),a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.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,L.jsxs)(`div`,{className:`flex items-start gap-2 leading-relaxed`,children:[(0,L.jsx)(`span`,{className:`text-amber-500/50 font-medium shrink-0 select-none mt-[1px]`,children:`$`}),(0,L.jsx)(`div`,{className:`flex-1 min-w-0`,children:d?(0,L.jsxs)(`div`,{className:`text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block`,children:[d,n&&!t&&(0,L.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]}):(0,L.jsx)(`div`,{className:`h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2`})})]})}),t&&(0,L.jsx)($m,{children:(0,L.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,L.jsx)(`span`,{className:`inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle`})]})})]})]})}function ih({card:e}){let t=e.output?.trim()??``,n=e.statusTone===`running`,[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(n);(0,F.useEffect)(()=>{s.current&&!n&&!a&&i(!1),s.current=n},[n,a]);let c=()=>{!t&&!n||(i(!r),o(!0))},l=e.toolName===`edit_file`||e.toolName===`write_file`,u=(e,t)=>{if(l){if(e.startsWith(`+`)&&!e.startsWith(`+++`))return(0,L.jsxs)(`div`,{className:`bg-emerald-500/10 text-emerald-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap`,children:[(0,L.jsx)(`span`,{className:`select-none opacity-40 mr-2 w-3 inline-block shrink-0`,children:`+`}),(0,L.jsx)(`span`,{children:e.slice(1)})]},t);if(e.startsWith(`-`)&&!e.startsWith(`---`))return(0,L.jsxs)(`div`,{className:`bg-rose-500/10 text-rose-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap`,children:[(0,L.jsx)(`span`,{className:`select-none opacity-40 mr-2 w-3 inline-block shrink-0`,children:`-`}),(0,L.jsx)(`span`,{className:`line-through decoration-rose-400/50`,children:e.slice(1)})]},t)}return(0,L.jsx)(`div`,{className:`py-0.5 text-amber-950/80 w-full break-all whitespace-pre-wrap`,children:(0,L.jsx)(`span`,{children:e})},t)},d=t.split(`
34
+ `),f=d.length>15,p=!r&&f?d.slice(0,15):d;return(0,L.jsxs)(Qm,{children:[(0,L.jsx)(nh,{card:e,icon:l?Rt:Bt,expanded:r,canExpand:!!t||n,onToggle:c}),r&&t&&(0,L.jsx)($m,{children:(0,L.jsx)(`div`,{className:`font-mono text-[12px] leading-relaxed max-h-48 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar-amber text-amber-950/80 w-full`,children:p.map(u)})})]})}function ah({card:e}){let t=e.statusTone===`running`,[n,r]=(0,F.useState)(t),[i,a]=(0,F.useState)(!1),o=(0,F.useRef)(t),s=e.output?.trim()??``;return(0,F.useEffect)(()=>{o.current&&!t&&!i&&r(!1),o.current=t},[t,i]),(0,L.jsxs)(Qm,{children:[(0,L.jsx)(nh,{card:e,icon:Re,expanded:n,canExpand:!!s||t,onToggle:()=>{!s&&!t||(r(!n),a(!0))}}),n&&s&&(0,L.jsx)($m,{children:(0,L.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:s})})]})}function oh({card:e}){let t=e.output?.trim()??``,n=e.statusTone===`running`,[r,i]=(0,F.useState)(n),[a,o]=(0,F.useState)(!1),s=(0,F.useRef)(n),c=e.kind===`result`||e.hasResult;return(0,F.useEffect)(()=>{s.current&&!n&&!a&&i(!1),s.current=n},[n,a]),(0,L.jsxs)(Qm,{children:[(0,L.jsx)(nh,{card:e,icon:Ce,expanded:r,canExpand:c,onToggle:()=>{c&&(i(!r),o(!0))}}),r&&t&&(0,L.jsx)($m,{children:(0,L.jsx)(`pre`,{className:`text-amber-950/80 whitespace-pre-wrap break-all overflow-y-auto overflow-x-hidden max-h-64 custom-scrollbar-amber w-full min-w-0 max-w-full leading-relaxed`,children:t})})]})}function sh(e){let t=e.toLowerCase();return t===`exec`||t===`execute_command`||t===`bash`||t===`shell`||t.includes(`run_`)}function ch(e){let t=e.toLowerCase();return t===`read_file`||t===`write_file`||t===`edit_file`||t===`apply_patch`}function lh(e){let t=e.toLowerCase();return t===`grep_search`||t===`find_files`||t.includes(`search`)}function uh({card:e}){return sh(e.toolName)?(0,L.jsx)(rh,{card:e}):ch(e.toolName)?(0,L.jsx)(ih,{card:e}):lh(e.toolName)?(0,L.jsx)(ah,{card:e}):(0,L.jsx)(oh,{card:e})}function dh(e){return(0,L.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600`,children:[(0,L.jsxs)(`div`,{className:`font-semibold text-gray-700`,children:[e.label,`: `,e.rawType]}),e.text?(0,L.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500`,children:e.text}):null]})}var fh=(0,F.memo)(function(e){let{message:t,texts:n}=e,{role:r}=t,i=r===`user`,a=t.status===`pending`||t.status===`streaming`;return(0,L.jsx)(`div`,{className:z(`inline-block w-fit max-w-full rounded-2xl border px-4 shadow-sm`,i?`border-primary bg-primary py-3 text-white`:r===`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,L.jsx)(`div`,{className:`space-y-2`,children:t.parts.map((e,o)=>e.type===`markdown`?(0,L.jsx)(Pm,{text:e.text,role:r,texts:n},`markdown-${o}`):e.type===`reasoning`?(0,L.jsx)(Zm,{label:e.label,text:e.text,isUser:i,isInProgress:a&&o===t.parts.length-1},`reasoning-${o}`):e.type===`tool-card`?(0,L.jsx)(`div`,{className:`mt-0.5`,children:(0,L.jsx)(uh,{card:e.card})},`tool-${o}`):e.type===`file`?(0,L.jsx)(Ym,{file:e.file,isUser:i},`file-${o}`):e.type===`unknown`?(0,L.jsx)(dh,{label:e.label,rawType:e.rawType,text:e.text},`unknown-${o}`):null)})})});function ph(e){return(0,L.jsxs)(`div`,{className:z(`px-1 text-[11px] leading-4 text-gray-400`,e.isUser?`text-right`:`text-left`),children:[e.roleLabel,` · `,e.timestampLabel]})}function mh({message:e,texts:t}){let n=(0,F.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}=Cm({text:n});return n?(0,L.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,L.jsx)(ne,{className:`h-3.5 w-3.5`}):(0,L.jsx)(zt,{className:`h-3.5 w-3.5`})}):null}var hh=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function gh(e){let t=e.trim();return t?t.replace(hh,``).trim().length>0:!1}function _h(e){return e.parts.some(e=>e.type===`markdown`||e.type===`reasoning`?gh(e.text):!0)}function vh(){return(0,L.jsx)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 text-[11px] text-gray-400`,children:(0,L.jsxs)(`div`,{className:`flex space-x-1 items-center h-full`,children:[(0,L.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse`}),(0,L.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:200ms]`}),(0,L.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-gray-400 animate-pulse [animation-delay:400ms]`})]})})}function yh(e){let t=e.messages.filter(_h),n=t.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`));return(0,L.jsxs)(`div`,{className:z(`space-y-5`,e.className),children:[t.map(t=>{let n=t.role===`user`,r=!n&&(t.status===`streaming`||t.status===`pending`);return(0,L.jsxs)(`div`,{className:z(`flex gap-3`,n?`justify-end`:`justify-start`),children:[n?null:(0,L.jsx)(Vi,{role:t.role}),(0,L.jsxs)(`div`,{className:z(`w-fit max-w-[92%] space-y-2`,n&&`flex flex-col items-end`),children:[(0,L.jsx)(fh,{message:t,texts:e.texts}),(0,L.jsx)(`div`,{className:z(`flex items-center gap-2`,n&&`justify-end`),children:r?(0,L.jsx)(vh,{}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ph,{roleLabel:t.roleLabel,timestampLabel:t.timestampLabel,isUser:n}),n?null:(0,L.jsx)(mh,{message:t,texts:e.texts})]})})]}),n?(0,L.jsx)(Vi,{role:t.role}):null]},t.id)}),e.isSending&&!n?(0,L.jsxs)(`div`,{className:`flex justify-start gap-3`,children:[(0,L.jsx)(Vi,{role:`assistant`}),(0,L.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 bh=10;function xh(e){e.scrollTop=e.scrollHeight}function Sh(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,xh(t))}))}function Ch(e){let t=(0,F.useRef)(!0),n=(0,F.useRef)(!1),r=(0,F.useRef)(null),i=(0,F.useRef)(!1),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),(0,F.useEffect)(()=>{let e=a.current;return()=>{e!==null&&cancelAnimationFrame(e)}},[]),(0,F.useLayoutEffect)(()=>{!i.current||e.isLoading||!e.hasContent||e.scrollRef.current&&(i.current=!1,Sh({scrollRef:e.scrollRef,scheduledScrollFrameRef:a,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),(0,F.useLayoutEffect)(()=>{!t.current||!e.hasContent||e.scrollRef.current&&Sh({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??bh))}}}function wh(){return ai()}function Th(e){return oi(e)}function Eh(e){return li(e)}function Dh(e){return ui(e,`skill`)}function Oh(e){return ui(e,`file`)}function kh(e,t,n){let r=new Set(t),i=_i(e,e=>e.tokenKind===`skill`&&!r.has(e.tokenKey)),a=ui(i,`skill`),o=new Map(n.map(e=>[e.spec,e])),s=t.filter(e=>!a.includes(e)).map(e=>ri({tokenKind:`skill`,tokenKey:e,label:o.get(e)?.label||e}));return s.length===0?i:si([...i,...s])}function Ah(e,t){let n=new Set(t.map(e=>e.id));return _i(e,e=>e.tokenKind===`file`&&!n.has(e.tokenKey))}function jh(e,t){let n=new Set(Oh(e));return t.filter(e=>n.has(e.id))}function Mh(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){if(t.type===`text`){t.text.length>0&&r.push({type:`text`,text:t.text});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 Nh={isProviderStateResolved:!1,composerNodes:wh(),attachments:[],draft:``,pendingSessionType:`native`,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:[]},$=S(e=>({snapshot:Nh,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function Ph(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,o=[],s=[],c=[],l=[];for(let t of e){let{session:e}=t,a=new Date(e.updatedAt).getTime();a>=n?o.push(t):a>=r?s.push(t):a>=i?c.push(t):l.push(t)}let u=[];return o.length>0&&u.push({label:a(`chatSidebarToday`),items:o}),s.length>0&&u.push({label:a(`chatSidebarYesterday`),items:s}),c.length>0&&u.push({label:a(`chatSidebarPrevious7Days`),items:c}),l.length>0&&u.push({label:a(`chatSidebarOlder`),items:l}),u}function Fh(e){if(e.label&&e.label.trim())return e.label.trim();let t=e.key.split(`:`);return t[t.length-1]||e.key}function Ih(e){return e.ready===!1?e.reasonMessage?.trim()||a(`statusSetup`):a(`statusReady`)}var Lh=[{target:`/cron`,label:()=>a(`chatSidebarScheduledTasks`),icon:at},{target:`/skills`,label:()=>a(`chatSidebarSkills`),icon:lt}];function Rh(){let e=hr(),t=He(),[n,r]=(0,F.useState)(!1),[i,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(``),[d,f]=(0,F.useState)(null),p=$(e=>e.snapshot),m=R(e=>e.snapshot),g=gt(e=>e.connectionStatus),{isLoading:_,items:v}=fr(),{language:y,setLanguage:b}=pt(),{theme:x,setTheme:S}=ut(),C=lr(),T=a(Ke.find(e=>e.value===x)?.labelKey??`themeWarm`),E=l.find(e=>e.value===y)?.label??y,D=(0,F.useMemo)(()=>Ph(v),[v]),O=p.defaultSessionType||`native`,k=(0,F.useMemo)(()=>p.sessionTypeOptions.filter(e=>e.value!==O),[O,p.sessionTypeOptions]),ee=e=>{y!==e&&(b(e),window.location.reload())},te=e=>{o(e.key),c(e.label?.trim()??``)},A=()=>{o(null),c(``),f(null)},j=async e=>{let t=s.trim();if(t===(e.label?.trim()??``)){A();return}f(e.key);try{await C({sessionKey:e.key,label:t||null}),A()}catch{f(null)}};return(0,L.jsxs)(`aside`,{className:`w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60`,children:[(0,L.jsx)(`div`,{className:`px-5 pt-5 pb-3`,children:(0,L.jsx)(mt,{className:`flex items-center gap-2.5 min-w-0`,suffix:(0,L.jsx)(Zn,{status:g})})}),(0,L.jsx)(`div`,{className:`px-4 pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(h,{variant:`primary`,className:u(`min-w-0 rounded-xl`,k.length>0?`flex-1 rounded-r-md`:`w-full`),onClick:()=>{r(!1),e.chatSessionListManager.createSession(O)},children:[(0,L.jsx)(Le,{className:`h-4 w-4 mr-2`}),a(`chatSidebarNewTask`)]}),k.length>0?(0,L.jsxs)(Dt,{open:n,onOpenChange:r,children:[(0,L.jsx)(Tt,{asChild:!0,children:(0,L.jsx)(h,{variant:`primary`,size:`icon`,className:`h-9 w-10 shrink-0 rounded-xl rounded-l-md`,"aria-label":a(`chatSessionTypeLabel`),children:(0,L.jsx)(w,{className:`h-4 w-4`})})}),(0,L.jsxs)(Ct,{align:`end`,className:`w-64 p-2`,children:[(0,L.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-gray-400`,children:a(`chatSessionTypeLabel`)}),(0,L.jsx)(`div`,{className:`mt-1 space-y-1`,children:k.map(t=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{e.chatSessionListManager.createSession(t.value),r(!1)},className:`w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-gray-100`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`div`,{className:`text-[13px] font-medium text-gray-900`,children:t.label}),(0,L.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?a(`statusSetup`):a(`statusReady`)})]}),(0,L.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500`,children:Ih(t)})]},t.value))})]})]}):null]})}),(0,L.jsx)(`div`,{className:`px-4 pb-3`,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Re,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,L.jsx)(Xe,{value:m.query,onChange:t=>e.chatSessionListManager.setQuery(t.target.value),placeholder:a(`chatSidebarSearchPlaceholder`),className:`pl-8 h-9 rounded-lg text-xs`})]})}),(0,L.jsx)(`div`,{className:`px-3 pb-2`,children:(0,L.jsx)(`ul`,{className:`space-y-0.5`,children:Lh.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(Qe,{to:e.target,label:e.label(),icon:e.icon,density:`compact`})},e.target))})}),(0,L.jsx)(`div`,{className:`mx-4 border-t border-gray-200/60`}),(0,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2`,children:_?(0,L.jsx)(`div`,{className:`text-xs text-gray-500 p-3`,children:a(`sessionsLoading`)}):D.length===0?(0,L.jsxs)(`div`,{className:`p-4 text-center`,children:[(0,L.jsx)(Ht,{className:`h-6 w-6 mx-auto mb-2 text-gray-300`}),(0,L.jsx)(`div`,{className:`text-xs text-gray-500`,children:a(`sessionsEmpty`)})]}):(0,L.jsx)(`div`,{className:`space-y-3`,children:D.map(t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider`,children:t.label}),(0,L.jsx)(`div`,{className:`space-y-0.5`,children:t.items.map(({session:t,runStatus:n})=>{let r=m.selectedSessionKey===t.key,a=ar(t,p.sessionTypeOptions),o=i===t.key,l=d===t.key;return(0,L.jsx)(cr,{session:t,active:r,runStatus:n,context:a,title:Fh(t),isEditing:o,draftLabel:s,isSaving:l,onSelect:()=>e.chatSessionListManager.selectSession(t.key),onStartEditing:()=>te(t),onDraftLabelChange:c,onSave:()=>j(t),onCancel:A},t.key)})})]},t.label))})}),(0,L.jsxs)(`div`,{className:`px-3 py-3 border-t border-gray-200/60 space-y-0.5`,children:[(0,L.jsx)(Qe,{to:`/settings`,label:a(`settings`),icon:tt,density:`compact`}),(0,L.jsx)(ot,{onClick:()=>t.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:fe,label:a(`docBrowserHelp`),density:`compact`}),(0,L.jsx)(dt,{value:x,onValueChange:e=>S(e),icon:ct,label:a(`theme`),valueLabel:T,density:`compact`,children:Ke.map(e=>(0,L.jsx)(oe,{value:e.value,className:`text-xs`,children:a(e.labelKey)},e.value))}),(0,L.jsx)(dt,{value:y,onValueChange:e=>ee(e),icon:it,label:a(`language`),valueLabel:E,density:`compact`,children:l.map(e=>(0,L.jsx)(oe,{value:e.value,className:`text-xs`,children:e.label},e.value))})]})]})}function zh(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 Bh(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(zh(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 Vh={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function Hh(e){let t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function Uh(e){return(e??``).trim().toLowerCase()}function Wh(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 Gh(e,t){let n=Uh(t);if(!n)return Vh.fallback;let r=Uh(e.key),i=Uh(e.label||e.key),a=Uh(`${e.descriptionZh??``} ${e.description??``}`),o=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Vh.exactSpec:i===n?Vh.exactLabel:r.startsWith(n)?Vh.prefixSpec:i.startsWith(n)?Vh.prefixLabel:o.some(e=>e.startsWith(n))?Vh.prefixToken:r.includes(n)?Vh.containsSpec:i.includes(n)?Vh.containsLabel:a.includes(n)?Vh.containsDescription:Wh(n,i)||Wh(n,r)?Vh.subsequence:0}function Kh(e,t,n){let r=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0});return e.map((e,n)=>({record:e,order:n,score:Gh(e,t)})).filter(e=>e.score>0).sort((e,t)=>{if(t.score!==e.score)return t.score-e.score;let n=(e.record.label||e.record.key).trim(),i=(t.record.label||t.record.key).trim(),a=r.compare(n,i);return a===0?e.order-t.order:a}).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}`],value:e.key}))}function qh(e){return e.map(e=>({key:e.key,label:e.label,description:e.descriptionZh||e.description||``,badgeLabel:e.badgeLabel}))}function Jh(e){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:qh(e.skillRecords),selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function Yh(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 Xh(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:Hh(e)}))},{key:`all-models`,label:e.texts.allModelsLabel,options:c.map(e=>({value:e.value,label:Hh(e)}))}].filter(e=>e.options.length>0):void 0;return{key:`model`,value:i,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?Hh(r):void 0,icon:`sparkles`,options:e.modelOptions.map(e=>({value:e.value,label:Hh(e)})),groups:l,disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function Zh(e){let t=[];for(let n of[`off`,...e])t.includes(n)||t.push(n);return t}function Qh(e){if(e.supportedLevels.length===0)return null;let t=Zh(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 $h=new 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}}({storageKey:`nextclaw.chat.recent-models`,limit:3});function eg(){return{off:a(`chatThinkingLevelOff`),minimal:a(`chatThinkingLevelMinimal`),low:a(`chatThinkingLevelLow`),medium:a(`chatThinkingLevelMedium`),high:a(`chatThinkingLevelHigh`),adaptive:a(`chatThinkingLevelAdaptive`),xhigh:a(`chatThinkingLevelXhigh`)}}function tg(e,t){return e.map(e=>({key:e.spec,label:e.label||e.spec,description:e.description,descriptionZh:e.descriptionZh,badgeLabel:e.origin===`builtin`?t:void 0}))}function ng(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 rg(){let e=hr(),{language:t}=pt(),n=$(e=>e.snapshot),[r,i]=(0,F.useState)(null),o=(0,F.useRef)(null),s=(0,F.useRef)(null),c=(0,F.useMemo)(()=>a(`chatSkillsPickerOfficial`),[t]),l=(0,F.useMemo)(()=>({slashSkillSubtitle:a(`chatSlashTypeSkill`),slashSkillSpecLabel:a(`chatSlashSkillSpec`),noSkillDescription:a(`chatSkillsPickerNoDescription`)}),[t]),u=(0,F.useMemo)(()=>tg(n.skillRecords,c),[n.skillRecords,c]),d=(0,F.useMemo)(()=>ng(n.modelOptions),[n.modelOptions]),f=$h.resolveVisible({availableValues:d.map(e=>e.value),minAvailableCount:5}),p=d.length>0,h=!n.isProviderStateResolved&&!p,g=n.isProviderStateResolved&&!p,_=(h||g)&&!n.isSending||n.sessionTypeUnavailable,v=typeof e.chatInputManager.addAttachments==`function`,y=h?``:a(p?`chatInputPlaceholder`:`chatModelNoOptions`),b=t===`zh`?`最近选择`:`Recent`,x=t===`zh`?`全部模型`:`All models`,S=(0,F.useMemo)(()=>Kh(u,r??``,l),[r,u,l]),C=d.find(e=>e.value===n.selectedModel)?.thinkingCapability,w=C?.supported??[],T=n.stopDisabledReason===`__preparing__`?a(`chatStopPreparing`):n.stopDisabledReason?.trim()||a(`chatStopUnavailable`),E=(0,F.useCallback)(e=>{if(e===`unsupported-type`){m.error(a(`chatInputAttachmentUnsupported`));return}if(e===`too-large`){m.error(a(`chatInputAttachmentTooLarge`).replace(`{maxMb}`,String(Wn/(1024*1024))));return}m.error(a(`chatInputAttachmentReadFailed`))},[]),D=(0,F.useCallback)(async t=>{if(!v||t.length===0)return;let n=await Yn(t,{uploadBatch:Bh});if(n.attachments.length>0){let t=e.chatInputManager.addAttachments?.(n.attachments)??[];t.length>0&&o.current?.insertFileTokens(t.map(e=>({tokenKey:e.id,label:e.name})))}n.rejected.length>0&&E(n.rejected[0].reason)},[v,e.chatInputManager,E]),O=[Xh({modelOptions:d,recentModelValues:f,selectedModel:n.selectedModel,isModelOptionsLoading:h,hasModelOptions:p,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:a(`chatSelectModel`),modelNoOptionsLabel:a(`chatModelNoOptions`),recentModelsLabel:b,allModelsLabel:x}}),Qh({supportedLevels:w,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:C?.default??null,onValueChange:t=>e.chatInputManager.selectThinkingLevel(t),texts:{thinkingLabels:eg()}})].filter(e=>e!==null),k=Jh({skillRecords:u,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:a(`chatSkillsPickerTitle`),searchPlaceholder:a(`chatSkillsPickerSearchPlaceholder`),emptyLabel:a(`chatSkillsPickerEmpty`),loadingLabel:a(`sessionsLoading`),manageLabel:a(`chatSkillsPickerManage`)}});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Bi,{ref:o,composer:{nodes:n.composerNodes,placeholder:y,disabled:_,onNodesChange:e.chatInputManager.setComposerNodes,...v?{onFilesAdd:D}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:S,texts:{slashLoadingLabel:a(`chatSlashLoading`),slashSectionLabel:a(`chatSlashSectionSkills`),slashEmptyLabel:a(`chatSlashNoResult`),slashHintLabel:a(`chatSlashHint`),slashSkillHintLabel:a(`chatSlashSkillHint`)}},hint:Yh({isModelOptionsLoading:h,isModelOptionsEmpty:g,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:a(`chatModelNoOptions`),configureProviderLabel:a(`chatGoConfigureProvider`)}}),toolbar:{selects:O,accessories:[{key:`attach`,label:a(`chatInputAttach`),icon:`paperclip`,iconOnly:!0,disabled:!v||_||n.isSending,...v?{onClick:()=>s.current?.click()}:{tooltip:a(`chatInputAttachComingSoon`)}}],skillPicker:k,actions:{sendError:n.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:n.draft.trim().length===0&&n.attachments.length===0||!p||n.sessionTypeUnavailable,stopDisabled:!n.canStopGeneration,stopHint:T,sendButtonLabel:a(`chatSend`),stopButtonLabel:a(`chatStop`),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),v?(0,L.jsx)(`input`,{ref:s,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=Array.from(e.target.files??[]);e.currentTarget.value=``,await D(t)}}):null]})}var ig=[`cmd`,`command`,`query`,`q`,`path`,`url`,`to`,`channel`,`agentId`,`sessionKey`];function ag(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function og(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}\n…`}function sg(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(e==null)return``;try{return og(JSON.stringify(e,null,2))}catch{return String(e)}}function cg(e){if(ag(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 ag(e)?e:null}catch{return null}}function lg(e){let t=cg(e);if(!t){let t=sg(e).trim();return t?og(t,120):void 0}let n=[];for(let e of ig){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(` · `):og(sg(t),140)}function ug(e){return typeof e==`object`&&!!e}function dg(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function fg(e){return ug(e)&&(e.kind===`nextclaw.subagent_run`||typeof e.runId==`string`&&typeof e.status==`string`)?e:null}function pg(e,t){return[dg(e.label)?`label: ${e.label?.trim()}`:null,dg(e.runId)?`run: ${e.runId?.trim()}`:null,dg(e.task)?`task: ${e.task?.trim()}`:null].filter(e=>!!e).join(` · `)||lg(t)}function mg(e){let t=dg(e.runId),n=dg(e.label),r=dg(e.task),i=dg(e.status)?.toLowerCase(),a=e.result===void 0?``:sg(e.result).trim(),o=dg(e.message),s=[t?`Run ID: ${t}`:null,n?`Label: ${n}`:null,r?`Task:\n${r}`:null,a?`${i===`failed`?`Error`:`Result`}:\n${a}`:o?`Status:\n${o}`:null].filter(e=>!!e);return s.length>0?s.join(`
37
+
38
+ `):void 0}function hg(e){if(e.invocation.toolName!==`spawn`)return null;let t=fg(e.invocation.result);if(!t)return null;let n=dg(t.status)?.toLowerCase(),r=pg(t,e.invocation.args),i=mg(t);return n===`failed`?{kind:`result`,name:e.invocation.toolName,detail:r,text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:`error`,statusLabel:e.texts.toolStatusFailedLabel}:n===`completed`?{kind:`result`,name:e.invocation.toolName,detail:r,text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:`success`,statusLabel:e.texts.toolStatusCompletedLabel}:{kind:`result`,name:e.invocation.toolName,detail:r,text:i,callId:e.invocation.toolCallId||void 0,hasResult:!!i,statusTone:`running`,statusLabel:e.texts.toolStatusRunningLabel}}var gg=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function _g(e){return typeof e==`object`&&!!e}function vg(e){if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null}function yg(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 bg(e,t){if(!_g(e))return null;let n=_g(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&_g(e.assets[0])?e.assets[0]:null;if(!n)return null;let r=vg(n.url),i=vg(n.mimeType)??`application/octet-stream`,a=yg(n.sizeBytes);return r?{type:`file`,file:{label:vg(n.name)??(i.startsWith(`image/`)?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...a==null?{}:{sizeBytes:a},isImage:i.startsWith(`image/`)}}:null}function xg(e){return e.type===`text`&&typeof e.text==`string`}function Sg(e){return e.type===`reasoning`&&typeof e.reasoning==`string`}function Cg(e){return e.type===`file`&&typeof e.mimeType==`string`&&typeof e.data==`string`}function wg(e){return e.type!==`tool-invocation`||!_g(e.toolInvocation)?!1:typeof e.toolInvocation.toolName==`string`}function Tg(e){let t=e.meta?.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function Eg(e,t){return e===`user`?t.user:e===`assistant`?t.assistant:e===`tool`?t.tool:e===`system`?t.system:t.fallback}function Dg(e){return e===`user`||e===`assistant`||e===`tool`||e===`system`?e:`message`}function Og(e,t){return{kind:e.kind,toolName:e.name,summary:e.detail,output:e.text,hasResult:!!e.hasResult,statusTone:e.statusTone,statusLabel:e.statusLabel,titleLabel:e.kind===`call`?t.toolCallLabel:t.toolResultLabel,outputLabel:t.toolOutputLabel,emptyLabel:t.toolNoOutputLabel}}function kg(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}:t===`partial-call`?{kind:`call`,hasResult:!1,statusTone:`running`,statusLabel:e.texts.toolStatusPreparingLabel}:{kind:`call`,hasResult:!1,statusTone:`running`,statusLabel:e.texts.toolStatusRunningLabel}}function Ag(e){let t=e.trim();return t&&t.replace(gg,``).trim()?t:null}function jg(e,t){return{id:e.id,role:Dg(e.role),roleLabel:Eg(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(Tg(e)),status:e.meta?.status,parts:e.parts.map(e=>{if(xg(e)){let t=Ag(e.text);return t?{type:`markdown`,text:t}:null}if(Sg(e)){let n=Ag(e.reasoning);return n?{type:`reasoning`,text:n,label:t.texts.reasoningLabel}:null}if(Cg(e)){let n=e.mimeType.startsWith(`image/`),r=yg(e.sizeBytes);return{type:`file`,file:{label:typeof e.name==`string`&&e.name.trim()?e.name.trim():n?t.texts.imageAttachmentLabel:t.texts.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}}}if(wg(e)){let n=e.toolInvocation,r=bg(n.result,t.texts);if(r)return r;let i=hg({invocation:n,texts:t.texts});if(i)return{type:`tool-card`,card:Og(i,t.texts)};let a=kg({status:n.status,error:n.error,cancelled:n.cancelled,result:n.result,texts:t.texts}),o=lg(n.parsedArgs??n.args),s=typeof n.error==`string`&&n.error.trim()?n.error.trim():n.result==null?``:sg(n.result).trim();return{type:`tool-card`,card:Og({kind:a.kind,name:n.toolName,detail:o,text:s||void 0,callId:n.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel},t.texts)}}return{type:`unknown`,label:t.texts.unknownPartLabel,rawType:typeof e.type==`string`?e.type:`unknown`,text:sg(e)}}).filter(e=>e!==null)}}var Mg=new WeakMap;function Ng(e){return{roleLabels:{user:a(`chatRoleUser`),assistant:a(`chatRoleAssistant`),tool:a(`chatRoleTool`),system:a(`chatRoleSystem`),fallback:a(`chatRoleMessage`)},reasoningLabel:a(`chatReasoning`),toolCallLabel:a(`chatToolCall`),toolResultLabel:a(`chatToolResult`),toolNoOutputLabel:a(`chatToolNoOutput`),toolOutputLabel:a(`chatToolOutput`),toolStatusPreparingLabel:a(`chatToolStatusPreparing`),toolStatusRunningLabel:a(`chatToolStatusRunning`),toolStatusCompletedLabel:a(`chatToolStatusCompleted`),toolStatusFailedLabel:a(`chatToolStatusFailed`),toolStatusCancelledLabel:a(`chatToolStatusCancelled`),imageAttachmentLabel:a(`chatImageAttachment`),fileAttachmentLabel:a(`chatFileAttachment`),unknownPartLabel:a(`chatUnknownPart`)}}function Pg(e){return{copyCodeLabel:a(`chatCodeCopy`),copiedCodeLabel:a(`chatCodeCopied`),copyMessageLabel:a(`chatMessageCopy`),copiedMessageLabel:a(`chatMessageCopied`),typingLabel:a(`chatTyping`)}}function Fg(e){let{language:t}=pt(),n=(0,F.useMemo)(()=>Ng(t),[t]),r=(0,F.useMemo)(()=>e.messages.map(e=>{let r=Mg.get(e);if(r&&r.language===t)return r.viewModel;let i=ye(e),a=jg({id:i.id,role:i.role,meta:{timestamp:i.meta?.timestamp,status:i.meta?.status},parts:i.parts},{formatTimestamp:e=>c(e,t),texts:n});return Mg.set(e,{language:t,viewModel:a}),a}),[t,e.messages,n]),i=(0,F.useMemo)(()=>r.some(e=>e.role===`assistant`&&(e.status===`streaming`||e.status===`pending`)),[r]),a=(0,F.useMemo)(()=>Pg(t),[t]);return(0,L.jsx)(yh,{messages:r,isSending:e.isSending,hasAssistantDraft:i,className:e.className,texts:a})}var Ig=[{icon:nt,titleKey:`chatWelcomeCapability1Title`,descKey:`chatWelcomeCapability1Desc`},{icon:lt,titleKey:`chatWelcomeCapability2Title`,descKey:`chatWelcomeCapability2Desc`},{icon:at,titleKey:`chatWelcomeCapability3Title`,descKey:`chatWelcomeCapability3Desc`}];function Lg({onCreateSession:e}){return(0,L.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,L.jsxs)(`div`,{className:`max-w-lg w-full text-center`,children:[(0,L.jsx)(`div`,{className:`mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center`,children:(0,L.jsx)(ge,{className:`h-8 w-8 text-primary`})}),(0,L.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 mb-2`,children:a(`chatWelcomeTitle`)}),(0,L.jsx)(`p`,{className:`text-sm text-gray-500 mb-8`,children:a(`chatWelcomeSubtitle`)}),(0,L.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:Ig.map(t=>{let n=t.icon;return(0,L.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,L.jsx)(`div`,{className:`h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3`,children:(0,L.jsx)(n,{className:`h-4.5 w-4.5 text-primary`})}),(0,L.jsx)(`div`,{className:`text-sm font-semibold text-gray-900 mb-1`,children:a(t.titleKey)}),(0,L.jsx)(`div`,{className:`text-[11px] text-gray-500 leading-relaxed`,children:a(t.descKey)})]},t.titleKey)})})]})})}var Rg={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,selectedSessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,messages:[],isSending:!1,isAwaitingAssistantOutput:!1},zg=S(e=>({snapshot:Rg,setSnapshot:t=>e(e=>({snapshot:{...e.snapshot,...t}}))}));function Bg(){return(0,L.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,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`div`,{className:`h-6 w-48 animate-pulse rounded bg-gray-200`}),(0,L.jsx)(`div`,{className:`h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80`}),(0,L.jsx)(`div`,{className:`h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80`}),(0,L.jsx)(`div`,{className:`h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80`})]})})}),(0,L.jsx)(`div`,{className:`border-t border-gray-200/80 bg-white p-4`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)]`,children:(0,L.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white shadow-card p-4`,children:[(0,L.jsx)(`div`,{className:`h-16 w-full animate-pulse rounded-xl bg-gray-200/80`}),(0,L.jsxs)(`div`,{className:`mt-3 flex items-center justify-between`,children:[(0,L.jsx)(`div`,{className:`h-8 w-36 animate-pulse rounded-lg bg-gray-200/80`}),(0,L.jsx)(`div`,{className:`h-8 w-20 animate-pulse rounded-lg bg-gray-200/80`})]})]})})})]})}function Vg(){let e=hr(),t=zg(e=>e.snapshot),n=(0,F.useRef)(null),r=t.threadRef??n,i=!!(t.selectedSessionKey||t.sessionTypeLabel),o=t.sessionDisplayName||t.selectedSessionKey||a(`chatSidebarNewTask`),s=!t.selectedSessionKey&&t.messages.length===0&&!t.isSending,c=t.modelOptions.length>0,l=t.isProviderStateResolved&&!c,d=t.isHistoryLoading&&t.messages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:f}=Ch({scrollRef:r,resetKey:t.selectedSessionKey,isLoading:t.isHistoryLoading,hasContent:t.messages.length>0,contentVersion:t.messages[t.messages.length-1]??null});return t.isProviderStateResolved?(0,L.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,L.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`,i?`py-3 opacity-100`:`h-0 py-0 opacity-0 border-b-0`),children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 truncate`,children:o}),t.sessionTypeLabel?(0,L.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.selectedSessionKey?(0,L.jsx)(h,{variant:`ghost`,size:`icon`,className:`rounded-lg shrink-0 text-gray-400 hover:text-destructive`,onClick:e.chatThreadManager.deleteSession,disabled:!t.canDeleteSession||t.isDeletePending,children:(0,L.jsx)(ze,{className:`h-4 w-4`})}):null]}),l&&(0,L.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,L.jsx)(`span`,{className:`text-xs text-amber-800`,children:a(`chatModelNoOptions`)}),(0,L.jsx)(`button`,{type:`button`,onClick:e.chatThreadManager.goToProviders,className:`text-xs font-semibold text-amber-900 underline-offset-2 hover:underline`,children:a(`chatGoConfigureProvider`)})]}),t.sessionTypeUnavailable&&t.sessionTypeUnavailableMessage?.trim()&&(0,L.jsx)(`div`,{className:`px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0`,children:(0,L.jsx)(`span`,{className:`text-xs text-amber-800`,children:t.sessionTypeUnavailableMessage})}),(0,L.jsx)(`div`,{ref:r,onScroll:f,className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:s?(0,L.jsx)(Lg,{onCreateSession:e.chatThreadManager.createSession}):d?(0,L.jsx)(`div`,{className:`h-full`}):t.messages.length===0?(0,L.jsx)(`div`,{className:`px-5 py-5 text-sm text-gray-500`,children:a(`chatNoMessages`)}):(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,L.jsx)(Fg,{messages:t.messages,isSending:t.isSending&&t.isAwaitingAssistantOutput},t.selectedSessionKey??`draft`)})}),(0,L.jsx)(rg,{})]}):(0,L.jsx)(Bg,{})}function Hg(e){return c(e??void 0)}function Ug(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:c(new Date(e))}function Wg(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 Gg(e){let t=e.schedule;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${Wg(t.everyMs)}`:t.kind===`at`?`at ${Ug(t.atMs)}`:`-`}function Kg(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function qg(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 Jg(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function Yg(){let[e,t]=(0,F.useState)(``),[n,r]=(0,F.useState)(`all`),i=rt({all:!0}),o=ft(),s=_t(),c=vt(),{confirm:l,ConfirmDialog:d}=kt(),f=(0,F.useMemo)(()=>(i.data?.jobs??[]).filter(t=>qg(t,e)).filter(e=>Jg(e,n)),[i.data,e,n]),p=async e=>{await l({title:`${a(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:a(`delete`)})&&o.mutate({id:e.id})},m=async e=>{let t=!e.enabled;await l({title:t?`${a(`cronEnableConfirm`)}?`:`${a(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:t?`default`:`destructive`,confirmLabel:a(t?`cronEnable`:`cronDisable`)})&&s.mutate({id:e.id,enabled:t})},g=async e=>{let t=!e.enabled;await l({title:t?`${a(`cronRunForceConfirm`)}?`:`${a(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:a(`cronRunNow`)})&&c.mutate({id:e.id,force:t})};return(0,L.jsxs)(At,{fullHeight:!0,children:[(0,L.jsx)(jt,{title:a(`cronPageTitle`),description:a(`cronPageDescription`),actions:(0,L.jsx)(h,{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,L.jsx)(me,{className:u(`h-4 w-4`,i.isFetching&&`animate-spin`)})})}),(0,L.jsx)(`div`,{className:`mb-6`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,L.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),placeholder:a(`cronSearchPlaceholder`),className:`pl-9`}),(0,L.jsx)(at,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,L.jsx)(`div`,{className:`min-w-[180px]`,children:(0,L.jsxs)(ce,{value:n,onValueChange:e=>r(e),children:[(0,L.jsx)(j,{className:`w-full`,children:(0,L.jsx)(E,{placeholder:a(`cronStatusLabel`)})}),(0,L.jsxs)(ie,{children:[(0,L.jsx)(oe,{value:`all`,children:a(`cronStatusAll`)}),(0,L.jsx)(oe,{value:`enabled`,children:a(`cronStatusEnabled`)}),(0,L.jsx)(oe,{value:`disabled`,children:a(`cronStatusDisabled`)})]})]})}),(0,L.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[a(`cronTotalLabel`),`: `,i.data?.total??0,` / `,f.length]})]})}),(0,L.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:i.isLoading?(0,L.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:a(`cronLoading`)}):f.length===0?(0,L.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:a(`cronEmpty`)}):(0,L.jsx)(`div`,{className:`space-y-4`,children:f.map(e=>(0,L.jsx)(Ze,{className:`border border-gray-200`,children:(0,L.jsx)(We,{className:`pt-5 pb-5`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:e.name||e.id}),(0,L.jsx)(`span`,{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500`,children:e.id}),(0,L.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?a(`enabled`):a(`disabled`)}),e.deleteAfterRun&&(0,L.jsx)(`span`,{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700`,children:a(`cronOneShot`)})]}),(0,L.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[a(`cronScheduleLabel`),`: `,Gg(e)]}),(0,L.jsx)(`div`,{className:`mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words`,children:e.payload.message}),(0,L.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[a(`cronDeliverTo`),`: `,Kg(e)]})]}),(0,L.jsxs)(`div`,{className:`min-w-[220px] text-xs text-gray-500 space-y-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[a(`cronNextRun`),`:`]}),` `,Hg(e.state.nextRunAt)]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[a(`cronLastRun`),`:`]}),` `,Hg(e.state.lastRunAt)]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[a(`cronLastStatus`),`:`]}),` `,e.state.lastStatus??`-`]}),e.state.lastError&&(0,L.jsx)(`div`,{className:`text-[11px] text-red-500 break-words`,children:e.state.lastError})]}),(0,L.jsxs)(`div`,{className:`flex items-start gap-2 flex-wrap justify-end`,children:[(0,L.jsxs)(h,{variant:`subtle`,size:`sm`,onClick:()=>g(e),className:`gap-1`,children:[(0,L.jsx)(Kt,{className:`h-3.5 w-3.5`}),a(`cronRunNow`)]}),(0,L.jsxs)(h,{variant:e.enabled?`outline`:`primary`,size:`sm`,onClick:()=>m(e),className:`gap-1`,children:[(0,L.jsx)(qt,{className:`h-3.5 w-3.5`}),e.enabled?a(`cronDisable`):a(`cronEnable`)]}),(0,L.jsxs)(h,{variant:`destructive`,size:`sm`,onClick:()=>p(e),className:`gap-1`,children:[(0,L.jsx)(ze,{className:`h-3.5 w-3.5`}),a(`delete`)]})]})]})})},e.id))})}),(0,L.jsx)(d,{})]})}function Xg(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:a,setSelectedAgentId:o,selectedSessionKeyRef:s,resetStreamState:c,resolveAgentIdFromSessionKey:l}=e;(0,F.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&a(n);return}r!==null&&(a(null),c())}},[c,n,r,a,t]),(0,F.useEffect)(()=>{let e=r?l(r):null;e&&i!==e&&o(e)},[l,i,r,o]),(0,F.useEffect)(()=>{s.current=r},[r,s])}function Zg({view:e,confirmDialog:t}){return(0,L.jsxs)(`div`,{className:`h-full flex`,children:[(0,L.jsx)(Rh,{}),e===`chat`?(0,L.jsx)(Vg,{}):(0,L.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,L.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,L.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5`,children:(0,L.jsx)(Yg,{})})}):(0,L.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,L.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,L.jsx)(Fe,{forcedType:`skills`})})})}),t]})}function Qg(){return(e,t)=>fetch(e,{credentials:`include`,...t})}var $g=`sid_`;function e_(e){let t=/^agent:([^:]+):/i.exec(e.trim());return t&&t[1]?.trim()||null}function t_(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return`${$g}${btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}`}function n_(e){if(!e.startsWith($g))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 r_(e){if(!e)return null;let t=n_(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function i_(e){return`/chat/${t_(e)}`}var a_=`native`;function o_(e){return typeof e==`string`?e.trim().toLowerCase()||`native`:a_}function s_(e,t){return e===`native`?a(`chatSessionTypeNative`):t?.trim()||e.trim().split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||e}function c_(e){let t=new Map;for(let n of e){let e=o_(n.value);t.set(e,{value:e,label:n.label?.trim()||s_(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(a_,{value:a_,label:s_(a_),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 l_(e){let{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:o}=e,s=(0,F.useMemo)(()=>c_(o?.options??[]),[o?.options]),c=(0,F.useMemo)(()=>{let e=[...s],n=o_(t?.sessionType);return e.some(e=>e.value===n)||e.push({value:n,label:s_(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,F.useMemo)(()=>o_(o?.defaultType??`native`),[o?.defaultType]),u=(0,F.useRef)(null),d=(0,F.useMemo)(()=>o_(t?.sessionType??r??l),[l,r,t?.sessionType]),f=(0,F.useMemo)(()=>c.find(e=>e.value===d)??null,[d,c]);(0,F.useEffect)(()=>{if(n)return;let e=typeof r==`string`?r.trim():``,t=o_(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,F.useMemo)(()=>new Set(s.map(e=>e.value)),[s]);return{sessionTypeOptions:c,selectedSessionTypeOption:f,defaultSessionType:l,selectedSessionType:d,canEditSessionType:p,sessionTypeUnavailable:(0,F.useMemo)(()=>t&&!m.has(o_(t.sessionType))?!0:f?.ready===!1,[m,t,f?.ready]),sessionTypeUnavailableMessage:(0,F.useMemo)(()=>t&&!m.has(o_(t.sessionType))?`${s_(d)} ${a(`chatSessionTypeUnavailableSuffix`)}`:f?.ready===!1?f.reasonMessage?.trim()||`${f.label} setup required`:null,[m,t,d,f])}}function u_(e){return e?.trim().toLowerCase()||`native`}function d_(e,t){if(typeof t!=`string`)return!1;let n=t.trim();return n?e.some(e=>e.value===n):!1}function f_(e,t){return typeof t==`string`&&e.includes(t)}function p_(e){return e.length===0?null:e.includes(`off`)?`off`:e[0]??null}function m_(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 h_(e){let{modelOptions:t}=e;return t.length===0?``:m_({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:e=>d_(t,e),firstAvailableValue:t[0]?.value??``,preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function g_(e){let{supportedThinkingLevels:t}=e;return t.length===0?null:m_({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:e=>f_(t,e),firstAvailableValue:p_(t)??`off`,preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function __(e){let t=u_(e.sessionType),n,r=-1/0;for(let i of e.sessions){if(i.key===e.selectedSessionKey||u_(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 v_(e){return __({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:e=>e.preferredModel?.trim()||void 0})}function y_(e){return __({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:e=>e.preferredThinking??void 0})}function b_(e){let{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:a,resolveValue:o}=e,s=(0,F.useRef)(void 0),c=(0,F.useRef)(o);(0,F.useEffect)(()=>{c.current=o},[o]),(0,F.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 x_(e){let{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,setSelectedModel:s}=e;b_({isPreferenceAvailable:t.length>0,emptyValue:``,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>h_({currentSelectedModel:e,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:a,defaultModel:o,preferSessionPreferredModel:n,preserveCurrentSelectedModelOnSessionChange:r})})}function S_(e){let{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,setSelectedThinkingLevel:s}=e;b_({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:s,resolveValue:({currentValue:e,sessionChanged:n,preserveCurrentValueOnSessionChange:r})=>g_({currentSelectedThinkingLevel:e,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:a,defaultThinkingLevel:o,preferSessionPreferredThinking:n,preserveCurrentSelectedThinkingOnSessionChange:r})})}function C_(){return f({queryKey:[`ncp-session-types`],queryFn:Ve,staleTime:1e4,retry:!1})}function w_(e,t){return e.filter(e=>_e(e,t))}function T_(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 E_(e){let t=et(),n=st(),r=yt({limit:200}),i=C_(),a=je(`skill`),o=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),s=(0,F.useMemo)(()=>{let e=Pt({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=Nt(t.prefix,e);!n||r.has(n)||(r.add(n),i.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:Mt(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,F.useMemo)(()=>r.data?.sessions??[],[r.data?.sessions]),l=(0,F.useMemo)(()=>he(c),[c]),u=(0,F.useMemo)(()=>w_(l,e.query),[l,e.query]),d=(0,F.useMemo)(()=>l.find(t=>t.key===e.selectedSessionKey)??null,[l,e.selectedSessionKey]),f=(0,F.useMemo)(()=>a.data?.records??[],[a.data?.records]),p=l_({selectedSession:d,selectedSessionKey:e.selectedSessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=(0,F.useMemo)(()=>T_({modelOptions:s,supportedModels:p.selectedSessionTypeOption?.supportedModels}),[s,p.selectedSessionTypeOption?.supportedModels]),h=(0,F.useMemo)(()=>v_({sessions:l,selectedSessionKey:e.selectedSessionKey,sessionType:p.selectedSessionType}),[l,e.selectedSessionKey,p.selectedSessionType]),g=(0,F.useMemo)(()=>m.find(t=>t.value===e.currentSelectedModel),[m,e.currentSelectedModel]),_=(0,F.useMemo)(()=>g?.thinkingCapability?.supported??[],[g?.thinkingCapability?.supported]),v=(0,F.useMemo)(()=>g?.thinkingCapability?.default??null,[g?.thinkingCapability?.default]),y=(0,F.useMemo)(()=>y_({sessions:l,selectedSessionKey:e.selectedSessionKey,sessionType:p.selectedSessionType}),[l,e.selectedSessionKey,p.selectedSessionType]);return x_({modelOptions:m,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!d,selectedSessionPreferredModel:d?.preferredModel,fallbackPreferredModel:p.selectedSessionTypeOption?.recommendedModel??h,defaultModel:p.selectedSessionTypeOption?.recommendedModel??t.data?.agents.defaults.model,setSelectedModel:e.setSelectedModel}),S_({supportedThinkingLevels:_,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!d,selectedSessionPreferredThinking:d?.preferredThinking??null,fallbackPreferredThinking:y??null,defaultThinkingLevel:v,setSelectedThinkingLevel:e.setSelectedThinkingLevel}),{configQuery:t,configMetaQuery:n,sessionsQuery:r,sessionTypesQuery:i,installedSkillsQuery:a,isProviderStateResolved:o,modelOptions:m,sessionSummaries:c,sessions:u,skillRecords:f,selectedSession:d,...p}}var D_=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=R.getState().snapshot.selectedAgentId,n=this.resolveUpdateValue(t,e);n!==t&&R.getState().setSnapshot({selectedAgentId:n})},this.setSelectedSessionKey=e=>{let t=R.getState().snapshot.selectedSessionKey,n=this.resolveUpdateValue(t,e);n!==t&&R.getState().setSnapshot({selectedSessionKey:n})},this.createSession=e=>{let{snapshot:t}=$.getState(),{defaultSessionType:n}=t,r=n||`native`,i=typeof e==`string`&&e.trim().length>0?e.trim():r;this.streamActionsManager.resetStreamState(),$.getState().setSnapshot({pendingSessionType:i}),this.uiManager.goToChatRoot()},this.selectSession=e=>{this.uiManager.goToSession(e)},this.setQuery=e=>{let t=R.getState().snapshot.query,n=this.resolveUpdateValue(t,e);n!==t&&R.getState().setSnapshot({query:n})}}},O_=async()=>{},k_=()=>{},A_=class{constructor(){this.actions={sendMessage:O_,stopCurrentRun:O_,resumeRun:O_,resetStreamState:k_,applyHistoryMessages:k_},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)}},j_=async e=>!1,M_=class{constructor(){this.state={pathname:``},this.actions={navigate:null,confirm:j_},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(i_(e),t)}}};function N_(e){let t=e.trim();return t.length>0?t:null}function P_(e){return e??null}var F_=class{constructor(e){this.updateSession=e,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{let e=$.getState().snapshot,t=R.getState().snapshot.selectedSessionKey;t&&this.enqueue({sessionKey:t,patch:{preferredModel:N_(e.selectedModel),preferredThinking:P_(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)}}},I_=class{constructor(e,t,n){this.uiManager=e,this.streamActionsManager=t,this.getDraftSessionId=n,this.sessionPreferenceSync=new F_(Ye),this.buildAttachmentSignature=e=>[e.assetUri??``,e.url??``,e.name,e.mimeType,String(e.sizeBytes),e.contentBase64??``].join(`:`),this.hasSnapshotChanges=e=>{let t=$.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=$.getState().snapshot.attachments,n=jh(e,t);$.getState().setSnapshot({composerNodes:e,attachments:n,draft:Eh(e),selectedSkills:Dh(e)})},this.syncComposerSnapshotWithAttachments=(e,t)=>{$.getState().setSnapshot({composerNodes:e,attachments:t,draft:Eh(e),selectedSkills:Dh(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)&&($.getState().setSnapshot(e),Object.prototype.hasOwnProperty.call(e,`modelOptions`)||Object.prototype.hasOwnProperty.call(e,`selectedModel`)||Object.prototype.hasOwnProperty.call(e,`selectedThinkingLevel`))){let{selectedModel:e}=$.getState().snapshot;this.reconcileThinkingForModel(e)}},this.setDraft=e=>{let t=$.getState().snapshot.draft,n=this.resolveUpdateValue(t,e);n!==t&&this.syncComposerSnapshot(Th(n))},this.setComposerNodes=e=>{let t=$.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=$.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=Ah(t.composerNodes,r);return this.syncComposerSnapshotWithAttachments(a,r),i},this.restoreComposerState=(e,t)=>{let n=this.dedupeAttachments(t),r=Ah(e,n);this.syncComposerSnapshotWithAttachments(r,n)},this.setPendingSessionType=e=>{let t=$.getState().snapshot.pendingSessionType,n=this.resolveUpdateValue(t,e);n!==t&&$.getState().setSnapshot({pendingSessionType:n})},this.send=async()=>{let e=$.getState().snapshot,t=R.getState().snapshot,n=e.draft.trim(),r=e.attachments,i=Mh(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(wh()),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=$.getState().snapshot.selectedModel,n=this.resolveUpdateValue(t,e);n!==t&&($.getState().setSnapshot({selectedModel:n}),this.reconcileThinkingForModel(n))},this.setSelectedThinkingLevel=e=>{let t=$.getState().snapshot.selectedThinkingLevel,n=this.resolveUpdateValue(t,e);n!==t&&$.getState().setSnapshot({selectedThinkingLevel:n})},this.selectSessionType=e=>{let t=o_(e);$.getState().setSnapshot({selectedSessionType:t,pendingSessionType:t})},this.setSelectedSkills=e=>{let t=$.getState().snapshot,{selectedSkills:n}=t,r=this.resolveUpdateValue(n,e);this.isSameStringArray(r,n)||this.syncComposerSnapshot(kh(t.composerNodes,r,t.skillRecords))},this.selectModel=e=>{this.setSelectedModel(e),$h.remember(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=e=>{this.setSelectedThinkingLevel(e),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectSkills=e=>{this.setSelectedSkills(e)}}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`}reconcileThinkingForModel(e){let t=$.getState().snapshot,n=t.modelOptions.find(t=>t.value===e),{selectedThinkingLevel:r}=t,i=this.resolveThinkingForModel(n,r);i!==r&&$.getState().setSnapshot({selectedThinkingLevel:i})}},L_=class{constructor(e,t,n){this.uiManager=e,this.sessionListManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=e=>{let t=zg.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)&&zg.getState().setSnapshot(e)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.deleteCurrentSession=async()=>{let{snapshot:{selectedSessionKey:e}}=R.getState();if(e&&await this.uiManager.confirm({title:a(`chatDeleteSessionConfirm`),variant:`destructive`,confirmLabel:a(`delete`)})){zg.getState().setSnapshot({isDeletePending:!0});try{await qe(e),Ue(x,e),x.removeQueries({queryKey:[`ncp-session-messages`,e]}),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0})}finally{zg.getState().setSnapshot({isDeletePending:!1})}}}}},R_=class{constructor(){this.chatUiManager=new M_,this.chatStreamActionsManager=new A_,this.chatSessionListManager=new D_(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new I_(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatThreadManager=new L_(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId=``,this.setDraftSessionId=e=>{this.draftSessionId=e}}getDraftSessionId(){return this.draftSessionId}};function z_(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 B_(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());let n=z_(e.requestedSkills);return n.length>0&&(t.requested_skills=n),t}function V_(e){return e instanceof Error?e.message.includes(`ncp session not found:`):!1}function H_({view:e}){let[t]=(0,F.useState)(()=>new R_),[n,r]=(0,F.useState)(()=>pe()),i=R(e=>e.snapshot.query),a=R(e=>e.snapshot.selectedSessionKey),o=R(e=>e.snapshot.selectedAgentId),s=$(e=>e.snapshot.pendingSessionType),c=$(e=>e.snapshot.selectedModel),{confirm:l,ConfirmDialog:u}=kt(),f=y(),m=b(),{sessionId:h}=v(),g=(0,F.useRef)(null),_=(0,F.useRef)(a),x=(0,F.useRef)(!1),S=(0,F.useMemo)(()=>r_(h),[h]),{installedSkillsQuery:C,isProviderStateResolved:w,modelOptions:T,sessionSummaries:E,skillRecords:D,selectedSession:O,sessionTypeOptions:k,defaultSessionType:ee,selectedSessionType:te,canEditSessionType:A,sessionTypeUnavailable:j,sessionTypeUnavailableMessage:ne}=E_({query:i,selectedSessionKey:a,currentSelectedModel:c,pendingSessionType:s,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),M=a??n,re=(0,F.useRef)(E);(0,F.useEffect)(()=>{re.current=E},[E]);let[ie]=(0,F.useState)(()=>new wn({baseUrl:d,basePath:`/api/ncp/agent`,fetchImpl:Qg()})),N=Un({sessionId:M,client:ie,loadSeed:(0,F.useCallback)(async(e,t)=>{t.throwIfAborted();let n=null;try{n=await Je(e,300)}catch(e){if(!V_(e))throw e}t.throwIfAborted();let r=re.current.find(t=>t.sessionId===e)??null;return{messages:n?.messages??[],status:r?.status===`running`?`running`:`idle`}},[])});(0,F.useEffect)(()=>{t.setDraftSessionId(n)},[n,t]),(0,F.useEffect)(()=>{if(a===null){let e=pe();r(e),t.setDraftSessionId(e)}},[t,a]);let ae=N.isSending||N.isRunning,oe=N.isRunning,se=N.isRunning,ce=N.isRunning?null:`__preparing__`,le=N.hydrateError?.message??N.snapshot.error?.message??null;(0,F.useEffect)(()=>{let e=()=>{x.current||N.isHydrating||N.isRunning||N.isSending||(x.current=!0,ie.stream({sessionId:M}).catch(()=>void 0).finally(()=>{x.current=!1}))};return p.subscribe(t=>{t.type===`session.run-status`&&t.payload.sessionKey===M&&t.payload.status===`running`&&e()})},[M,N.isHydrating,N.isRunning,N.isSending,ie]),(0,F.useEffect)(()=>{t.chatStreamActionsManager.bind({sendMessage:async e=>{if(e.sessionKey!==M)return;let n=B_({model:e.model,thinkingLevel:e.thinkingLevel,sessionType:e.sessionType,requestedSkills:e.requestedSkills}),r=Jn({sessionId:e.sessionKey,text:e.message,attachments:e.attachments,parts:e.parts,metadata:n});if(r)try{await N.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 N.abort()},resumeRun:async e=>{e.sessionKey===M&&await N.streamRun()},resetStreamState:()=>{_.current=null},applyHistoryMessages:()=>{}})},[M,N,t]),Xg({view:e,routeSessionKey:S,selectedSessionKey:a,selectedAgentId:o,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:_,resetStreamState:t.chatStreamActionsManager.resetStreamState,resolveAgentIdFromSessionKey:e_}),(0,F.useEffect)(()=>{t.chatUiManager.syncState({pathname:f.pathname}),t.chatUiManager.bindActions({navigate:m,confirm:l})},[l,f.pathname,m,t]);let ue=O?xe(O):void 0,de=k.find(e=>e.value===te)?.label??s_(te);return(0,F.useEffect)(()=>{t.chatInputManager.syncSnapshot({isProviderStateResolved:w,defaultSessionType:ee,canStopGeneration:se,stopDisabledReason:ce,stopSupported:!0,stopReason:void 0,sendError:le,isSending:ae,modelOptions:T,sessionTypeOptions:k,selectedSessionType:te,canEditSessionType:A,sessionTypeUnavailable:j,skillRecords:D,isSkillsLoading:C.isLoading}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:w,modelOptions:T,sessionTypeUnavailable:j,sessionTypeUnavailableMessage:ne,sessionTypeLabel:de,selectedSessionKey:a,sessionDisplayName:ue,canDeleteSession:!!O,threadRef:g,isHistoryLoading:N.isHydrating,messages:N.visibleMessages,isSending:ae,isAwaitingAssistantOutput:oe})},[N.isHydrating,A,se,ue,de,ee,C.isLoading,oe,w,ae,le,T.length,T,t,O,a,te,k,j,ne,D,ce,g,N.visibleMessages]),(0,L.jsx)(mr,{presenter:t,children:(0,L.jsx)(Zg,{view:e,confirmDialog:(0,L.jsx)(u,{})})})}function U_({view:e}){return(0,L.jsx)(H_,{view:e})}export{U_ as ChatPage};