nextclaw 0.16.21 → 0.16.23

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 (36) hide show
  1. package/dist/cli/index.js +84 -8
  2. package/package.json +11 -11
  3. package/templates/USAGE.md +12 -4
  4. package/ui-dist/assets/{ChannelsList-C63gOoYI.js → ChannelsList-BlQD1VuM.js} +4 -4
  5. package/ui-dist/assets/ChatPage-DBvm558n.js +37 -0
  6. package/ui-dist/assets/{DocBrowser-CI4jOzJY.js → DocBrowser-DTww3NZc.js} +1 -1
  7. package/ui-dist/assets/{LogoBadge-DImV63-L.js → LogoBadge-D0ogG1ut.js} +1 -1
  8. package/ui-dist/assets/{MarketplacePage-B360oSAV.js → MarketplacePage-DTHw6n0X.js} +1 -1
  9. package/ui-dist/assets/{McpMarketplacePage-KIQgx_7h.js → McpMarketplacePage-BikE0mBl.js} +2 -2
  10. package/ui-dist/assets/{ModelConfig-Ben3tQoX.js → ModelConfig-CvM__Pz1.js} +1 -1
  11. package/ui-dist/assets/{ProvidersList-DE-S9mq0.js → ProvidersList-DtZWZlL0.js} +1 -1
  12. package/ui-dist/assets/RemoteAccessPage-E5fT1pem.js +1 -0
  13. package/ui-dist/assets/RuntimeConfig-DyZNiqYT.js +1 -0
  14. package/ui-dist/assets/{SearchConfig-DeOa-M6j.js → SearchConfig-C1bhOCNX.js} +1 -1
  15. package/ui-dist/assets/{SecretsConfig-Ci8pJmzd.js → SecretsConfig-CYmy1Sqy.js} +2 -2
  16. package/ui-dist/assets/{SessionsConfig-B6zq55yu.js → SessionsConfig-DSlhPpIE.js} +2 -2
  17. package/ui-dist/assets/{chat-session-display--oo5yuIw.js → chat-session-display-D9YuDGe3.js} +1 -1
  18. package/ui-dist/assets/index-BBz4mi7g.js +8 -0
  19. package/ui-dist/assets/{index-Bro-iRcb.css → index-CfVmBgkf.css} +1 -1
  20. package/ui-dist/assets/{label-3TKt0PoZ.js → label-C7Xd_hqz.js} +1 -1
  21. package/ui-dist/assets/{page-layout-CopkIM3Q.js → page-layout-VxCaUcrD.js} +1 -1
  22. package/ui-dist/assets/{popover-CUx8uRJw.js → popover-CC4znqAM.js} +1 -1
  23. package/ui-dist/assets/security-config-7eVxJq8b.js +1 -0
  24. package/ui-dist/assets/skeleton-DhZRDdHm.js +1 -0
  25. package/ui-dist/assets/{status-dot-D6vJMwD7.js → status-dot-Bi7Ze-LS.js} +1 -1
  26. package/ui-dist/assets/{switch-A3-ClT1P.js → switch-COBEivEX.js} +1 -1
  27. package/ui-dist/assets/{tabs-custom-BVSd5urq.js → tabs-custom-B9j40wuu.js} +1 -1
  28. package/ui-dist/assets/{useConfirmDialog-ChPriea6.js → useConfirmDialog-N8nuxOq-.js} +1 -1
  29. package/ui-dist/assets/{vendor-BEQcLDx6.js → vendor-MCpnpiKt.js} +35 -35
  30. package/ui-dist/index.html +3 -3
  31. package/ui-dist/assets/ChatPage-Ci3Gz0qh.js +0 -37
  32. package/ui-dist/assets/RemoteAccessPage-DxUia6R-.js +0 -1
  33. package/ui-dist/assets/RuntimeConfig-CQcGfNZT.js +0 -1
  34. package/ui-dist/assets/index-LhlkB00c.js +0 -8
  35. package/ui-dist/assets/security-config-BL29kTzz.js +0 -1
  36. package/ui-dist/assets/skeleton-Bs4zvcql.js +0 -1
@@ -0,0 +1,37 @@
1
+ var Xa=Object.defineProperty;var Ya=(e,t,n)=>t in e?Xa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ne=(e,t,n)=>Ya(e,typeof t!="symbol"?t+"":t,n);import{r as k,j as h,ae as Hi,v as xt,X as Ja,af as Za,f as el,e as ot,d as zn,t as tl,c as nl,y as rl,z as il,ag as sl,h as Ui,I as al,i as Ot,n as ll,o as $i,V as ol,x as Ki,p as qi,q as Wi,s as ul,w as cl,k as Qi,l as dl,m as Gi,a as hl,ah as fl,B as _n,G as Bn,ai as pl,aj as ml,ak as gl,F as xl,al as yl,am as bl,_ as Sl,an as Xi,ao as Yi,ap as kl,aq as wl,ar as Cl,as as vl,at as Tl,au as Il,av as Ml,aw as Nl,ax as El,A as Vn,ay as Ll,a0 as Al,a3 as Rl,a1 as jl,a2 as Pl,M as Dl,az as Ji,aA as Fl,aB as Ol,aC as zl,u as _l,a4 as Bl,aD as Vl,aE as Hl}from"./vendor-MCpnpiKt.js";import{t as v,c as ve,I as Hn,B as je,i as zt,j as Zi,k as Ul,l as es,m as $l,n as Kl,o as Un,p as ql,T as xr,L as yr,q as Wl,r as br,s as Ql,v as Sr,h as ut,A as ts,w as Gl,x as Xl,y as Yl,z as Jl,S as Zl,e as eo,f as to,g as no,C as ro,E as io,F as so,u as ao,a as lo,G as oo,H as uo,J as kr,K as co,M as ho}from"./index-BBz4mi7g.js";import{T as fo,a as po,b as mo,c as go,P as xo,R as yo,d as bo,e as So,C as ns,M as ko,u as wo}from"./MarketplacePage-DTHw6n0X.js";import{R as Co,A as vo,P as To,C as rs,T as Io,a as Mo,b as No,c as Eo}from"./popover-CC4znqAM.js";import{S as Lo,a as is,b as Ao,c as wr,s as Ro}from"./chat-session-display-D9YuDGe3.js";import{u as ss}from"./useConfirmDialog-N8nuxOq-.js";import{P as jo,a as Po}from"./page-layout-VxCaUcrD.js";import{b as Do,c as Fo,r as Oo}from"./provider-models-BOeNnjk9.js";import"./tabs-custom-B9j40wuu.js";import"./skeleton-DhZRDdHm.js";import"./marketplace-localization-Dk31LJJJ.js";var te=(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))(te||{}),Cr=/\[\[\s*reply_to_current\s*\]\]/gi,vr=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function wn(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function zo(e,t){var s;let n=e,r;Cr.test(n)&&(r=wn(t),n=n.replace(Cr,"").trim());const i=(s=n.match(vr))==null?void 0:s[1];return i&&(r=wn(i),n=n.replace(vr,"").trim()),r?{content:n,replyTo:r}:{content:n}}function _o(e,t=e.id){if(e.role!=="assistant")return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0};const n=e.parts.findIndex(d=>d.type==="text"),r=e.metadata?{...e.metadata}:void 0,i=wn(r==null?void 0:r.reply_to);if(n<0)return{...e,parts:[...e.parts],metadata:r};const s=e.parts[n];if(!s||s.type!=="text")return{...e,parts:[...e.parts],metadata:r};const{content:a,replyTo:l}=zo(s.text,t),o=l??i,u=e.parts.flatMap((d,c)=>c!==n||d.type!=="text"?[d]:a.length===0?[]:[{...d,text:a}]);return o?{...e,parts:u,metadata:{...r,reply_to:o}}:{...e,parts:u,metadata:r}}function Tr(e){const t=e.split(/\r?\n/);let n="message";const r=[];for(const i of t){const s=i.trimEnd();if(!(!s||s.startsWith(":"))){if(s.startsWith("event:")){n=s.slice(6).trim()||"message";continue}s.startsWith("data:")&&r.push(s.slice(5).trimStart())}}return r.length===0?null:{event:n,data:r.join(`
2
+ `)}}async function*Bo(e){const t=e.getReader(),n=new TextDecoder;let r="";try{for(;;){const{value:s,done:a}=await t.read();if(a)break;r+=n.decode(s,{stream:!0});const{frames:l,rest:o}=Ir(r);r=o;for(const u of l)yield u}r+=n.decode();const{frames:i}=Ir(r,!0);for(const s of i)yield s}finally{t.releaseLock()}}function Ir(e,t=!1){const n=e.split(/\r?\n\r?\n/),r=n.pop()??"",i=[];for(const s of n){const a=Tr(s);a&&i.push(a)}if(t&&r.trim()){const s=Tr(r);return s&&i.push(s),{frames:i,rest:""}}return{frames:i,rest:r}}var Mr="/ncp/agent",Vo="ncp-http-agent-client",as=class extends Error{constructor(t,n=!1){super(t.message);ne(this,"ncpError");ne(this,"alreadyPublished");this.name=`NcpHttpAgentClientError(${t.code})`,this.ncpError=t,this.alreadyPublished=n}};function Ho(e){const t=e.trim();if(!t)throw new Error("NcpHttpAgentClient requires a non-empty baseUrl.");return new URL(t)}function Uo(e){if(e)return e;if(typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error("No fetch implementation found. Pass options.fetchImpl explicitly.")}function $o(e){const t=(e??Mr).trim();if(!t)return Mr;const n=t.startsWith("/")?t:`/${t}`;return n.endsWith("/")?n.slice(0,-1):n}async function Nr(e){try{return(await e.text()).trim()}catch{return""}}function Er(e){if(ls(e))return e.ncpError;if(Ko(e))return e;const t=e instanceof Error?e.message:String(e??"Unknown error");return{code:os(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function Gt(e,t={}){return new as(e,t.alreadyPublished??!1)}function Ko(e){return $n(e)&&typeof e.code=="string"&&typeof e.message=="string"}function $n(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ls(e){return e instanceof as}var qo={"config-error":"config-error","auth-error":"auth-error","runtime-error":"runtime-error","timeout-error":"timeout-error","abort-error":"abort-error"};function os(e){if(!e)return"runtime-error";const t=qo[e];if(t)return t;const 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 Wo(e){const t=us(e);return!t||typeof t.type!="string"||!t.type.trim()?null:t}function Qo(e){const t=us(e);if(!t)return{code:"runtime-error",message:e||"Unknown stream error."};const n=typeof t.code=="string"?t.code:void 0,r=os(n),i=$n(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 us(e){try{const t=JSON.parse(e);return $n(t)?t:null}catch{return null}}var Go=["text","file","source","step-start","reasoning","tool-invocation","card","rich-text","action","extension"],Xo=class{constructor(e){ne(this,"manifest");ne(this,"baseUrl");ne(this,"basePath");ne(this,"fetchImpl");ne(this,"defaultHeaders");ne(this,"subscribers",new Set);ne(this,"activeControllers",new Set);ne(this,"started",!1);var t;this.baseUrl=Ho(e.baseUrl),this.basePath=$o(e.basePath),this.fetchImpl=Uo(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:"custom",endpointId:((t=e.endpointId)==null?void 0:t.trim())||Vo,version:"0.1.0",supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:Go,expectedLatency:"seconds",metadata:{transport:"http+sse",scope:"agent"}}}async start(){this.started||(this.started=!0,this.publish({type:te.EndpointReady}))}async stop(){if(this.started){this.started=!1;for(const 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();const t=new URLSearchParams({sessionId:e.sessionId});await this.streamRequest({path:`/stream?${t.toString()}`,method:"GET"})}async abort(e){await this.ensureStarted();const t=new AbortController;this.activeControllers.add(t);try{const 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 new Error(`Abort request failed with HTTP ${n.status}: ${await Nr(n)}`)}catch(n){if(t.signal.aborted)return;const r=Er(n);throw this.publish({type:te.EndpointError,payload:r}),Gt(r)}finally{this.activeControllers.delete(t)}}async ensureStarted(){this.started||await this.start()}publish(e){for(const t of this.subscribers)t(e)}resolveUrl(e){return new URL(`${this.basePath}${e}`,this.baseUrl)}async streamRequest(e){const t=new AbortController;this.activeControllers.add(t);try{const 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 new Error(`NCP stream request failed with HTTP ${n.status}: ${await Nr(n)}`);if(!n.body)throw new Error("NCP stream response has no body.");for await(const r of Bo(n.body)){if(t.signal.aborted)return;this.handleSseFrame(r)}}catch(n){if(t.signal.aborted)return;if(ls(n))throw n;const r=Er(n);throw this.publish({type:te.EndpointError,payload:r}),Gt(r)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event==="ncp-event"){const t=Wo(e.data);if(!t){this.publish({type:te.EndpointError,payload:{code:"runtime-error",message:"Received malformed ncp-event frame."}});return}this.publish(t);return}if(e.event==="error"){const t=Qo(e.data);throw this.publish({type:te.EndpointError,payload:t}),Gt(t,{alreadyPublished:!0})}}};function cs(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function Xt(e){return cs(_o(e))}function Yo(e){var n;const t=(n=e.error)==null?void 0:n.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 Jo(e,t){return t.trim()?e.id.startsWith("tool-")?!0:e.parts.some(n=>n.type==="tool-invocation"):!1}function Zo(e,t,n){for(const[r,i]of e)i===t&&e.set(r,n)}function Yt(e,t,n){for(const[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function Cn(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.type==="tool-invocation"&&r.toolCallId===t)return r}return null}function Lr(e,t){const n=Cn(e,t);return(n==null?void 0:n.toolName)??null}function nt(e,t){const n=[...e];for(let r=n.length-1;r>=0;r-=1){const i=n[r];if(i.type==="tool-invocation"&&i.toolCallId===t.toolCallId)return n[r]={...i,...t},n}return n.push(t),n}var eu="assistant",tu=class{constructor(){ne(this,"messages",[]);ne(this,"streamingMessage",null);ne(this,"error",null);ne(this,"activeRun",null);ne(this,"listeners",new Set);ne(this,"toolCallMessageIdByCallId",new Map);ne(this,"toolCallArgsRawByCallId",new Map);ne(this,"snapshotCache",null);ne(this,"snapshotVersion",-1);ne(this,"stateVersion",0)}getSnapshot(){if(this.snapshotCache&&this.snapshotVersion===this.stateVersion)return this.snapshotCache;const 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){return 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.stateVersion+=1,this.notifyListeners())}hydrate(e){this.messages=e.messages.map(t=>Xt(t)),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.stateVersion+=1,this.notifyListeners()}async dispatch(e){const t=this.stateVersion;switch(e.type){case te.MessageSent:this.handleMessageSent(e.payload);break;case te.MessageAbort:this.handleMessageAbort(e.payload);break;case te.MessageTextStart:this.handleMessageTextStart(e.payload);break;case te.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case te.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case te.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case te.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case te.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case te.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case te.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case te.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case te.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case te.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case te.RunStarted:this.handleRunStarted(e.payload);break;case te.RunFinished:this.handleRunFinished(e.payload);break;case te.RunError:this.handleRunError(e.payload);break;case te.RunMetadata:this.handleRunMetadata(e.payload);break;case te.EndpointError:this.handleEndpointError(e.payload);break}this.stateVersion!==t&&this.notifyListeners()}handleMessageSent(e){this.upsertMessage(e.message),this.setError(null)}handleMessageAbort(e){var n;const t=(n=e.messageId)==null?void 0:n.trim();if(this.clearActiveRun(),this.setError(null),this.streamingMessage&&(!t||this.streamingMessage.id===t)){const r=this.streamingMessage.id;this.upsertMessage({...this.streamingMessage,status:"final"}),this.replaceStreamingMessage(null),t?Yt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):Yt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,r)}}handleMessageTextStart(e){this.ensureStreamingMessage(e.sessionId,e.messageId,"streaming"),this.setError(null)}handleMessageTextDelta(e){if(!e.delta)return;const t=this.ensureStreamingMessage(e.sessionId,e.messageId,"streaming"),n=[...t.parts],r=n[n.length-1];(r==null?void 0: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){var t;((t=this.streamingMessage)==null?void 0:t.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;const t=this.ensureStreamingMessage(e.sessionId,e.messageId,"streaming"),n=[...t.parts],r=n[n.length-1];(r==null?void 0: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){var t;(t=this.streamingMessage)==null||t.id,e.messageId}handleMessageToolCallStart(e){const t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId,e.messageId);this.toolCallArgsRawByCallId.set(e.toolCallId,"");const n=nt(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){const n=`${this.toolCallArgsRawByCallId.get(e.toolCallId)??""}${e.delta}`;this.toolCallArgsRawByCallId.set(e.toolCallId,n),this.applyToolCallArgs(e.sessionId,e.toolCallId,n,e.messageId)}handleMessageToolCallEnd(e){const t=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),n=this.toolCallArgsRawByCallId.get(e.toolCallId)??"",r=nt(t.parts,{type:"tool-invocation",toolCallId:e.toolCallId,toolName:Lr(t.parts,e.toolCallId)??"unknown",state:"call",args:n});this.replaceStreamingMessage({...t,parts:r,status:"streaming"})}handleMessageToolCallResult(e){if(!this.updateMessageContainingToolCall(e.toolCallId,(n,r)=>{const i={type:"tool-invocation",toolCallId:e.toolCallId,toolName:r.toolName,state:"result",args:r.args,result:e.content};return nt(n.parts,i)})){const n=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),r=nt(n.parts,{type:"tool-invocation",toolCallId:e.toolCallId,toolName:"unknown",state:"result",result:e.content});this.replaceStreamingMessage({...n,parts:r,status:"streaming"})}}handleRunStarted(e){this.setError(null),this.activeRun={runId:e.runId??null,sessionId:e.sessionId},this.stateVersion+=1}handleRunFinished(e){this.settleStreamingMessage("final"),this.setError(null),this.clearActiveRun()}handleRunError(e){this.settleStreamingMessage("error"),this.setError(Yo(e)),this.clearActiveRun()}handleRunMetadata(e){var n,r;const t=e.metadata;if((t==null?void 0:t.kind)==="ready"){const i=t;this.activeRun={runId:i.runId??((n=this.activeRun)==null?void 0:n.runId)??null,sessionId:i.sessionId??((r=this.activeRun)==null?void 0:r.sessionId),abortDisabledReason:i.supportsAbort===!1?i.abortDisabledReason??"Unsupported":null},this.stateVersion+=1}else(t==null?void 0:t.kind)==="final"&&this.clearActiveRun()}handleEndpointError(e){var t,n,r;if(e.code==="abort-error"){this.handleMessageAbort({sessionId:((t=this.activeRun)==null?void 0:t.sessionId)??((n=this.streamingMessage)==null?void 0:n.sessionId)??"",...(r=this.streamingMessage)!=null&&r.id?{messageId:this.streamingMessage.id}:{}});return}this.settleStreamingMessage("error"),this.clearActiveRun(),this.setError(e)}applyToolCallArgs(e,t,n,r){const i=this.resolveToolCallTargetMessage(e,t,r),s=Lr(i.parts,t)??"unknown",a=nt(i.parts,{type:"tool-invocation",toolCallId:t,toolName:s,state:"partial-call",args:n});this.replaceStreamingMessage({...i,parts:a,status:"streaming"})}ensureStreamingMessage(e,t,n){var a;if(((a=this.streamingMessage)==null?void 0:a.id)===t){if(this.streamingMessage.status===n)return this.streamingMessage;const l={...this.streamingMessage,status:n};return this.replaceStreamingMessage(l),l}const r=this.messages.findIndex(l=>l.id===t);if(r>=0){const l=cs(this.messages[r]),o=[...this.messages];o.splice(r,1),this.messages=o,this.stateVersion+=1;const u={...l,sessionId:e,status:n};return this.replaceStreamingMessage(u),u}const i=this.streamingMessage;if(i&&i.id!==t&&i.sessionId===e&&Jo(i,t)){const l={...i,id:t,sessionId:e,status:n};return Zo(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(l),l}const s={id:t,sessionId:e,role:eu,status:n,parts:[],timestamp:new Date().toISOString()};return this.replaceStreamingMessage(s),s}resolveToolCallTargetMessage(e,t,n){var i;const r=(n==null?void 0:n.trim())||this.toolCallMessageIdByCallId.get(t)||((i=this.streamingMessage)==null?void 0:i.id)||`tool-${t}`;return this.toolCallMessageIdByCallId.set(t,r),this.ensureStreamingMessage(e,r,"streaming")}updateMessageContainingToolCall(e,t){if(this.streamingMessage){const n=Cn(this.streamingMessage.parts,e);if(n){const r=t(this.streamingMessage,n);return this.replaceStreamingMessage({...this.streamingMessage,parts:r}),!0}}for(let n=this.messages.length-1;n>=0;n-=1){const r=this.messages[n],i=Cn(r.parts,e);if(!i)continue;const s=[...this.messages];return s[n]={...r,parts:t(r,i)},this.messages=s,this.stateVersion+=1,!0}return!1}upsertMessage(e){const t=Xt(e),n=this.messages.findIndex(i=>i.id===t.id);if(n<0){this.messages=[...this.messages,t],this.stateVersion+=1;return}const r=[...this.messages];r[n]=t,this.messages=r,this.stateVersion+=1}replaceStreamingMessage(e){!e&&!this.streamingMessage||(this.streamingMessage=e?Xt(e):null,this.stateVersion+=1)}setError(e){var n,r,i,s;((n=this.error)==null?void 0:n.code)===(e==null?void 0:e.code)&&((r=this.error)==null?void 0:r.message)===(e==null?void 0:e.message)&&((i=this.error)==null?void 0:i.details)===(e==null?void 0:e.details)&&((s=this.error)==null?void 0:s.cause)===(e==null?void 0: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)}settleStreamingMessage(e){if(!this.streamingMessage)return;const t={...this.streamingMessage,status:e};this.upsertMessage(t),this.replaceStreamingMessage(null),Yt(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)}notifyListeners(){const e=this.getSnapshot();for(const t of this.listeners)t(e)}};function nu(e,t){const n="payload"in e?e.payload:null;return!n||typeof n!="object"||!("sessionId"in n)||typeof n.sessionId!="string"?!0:n.sessionId===t}function ru(e){return e.parts.some(t=>t.type==="text"||t.type==="rich-text"||t.type==="reasoning"?t.text.trim().length>0:!0)}function iu(e,t){if(typeof e=="string"){const 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 ru(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function su(e){const t=k.useRef();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new tu}),t.current.manager}function au({sessionId:e,client:t,manager:n}){var p;const r=k.useSyncExternalStore(f=>n.subscribe(()=>f()),()=>n.getSnapshot(),()=>n.getSnapshot()),[i,s]=k.useState(!1);k.useEffect(()=>{s(!1)},[e]),k.useEffect(()=>{const f=t.subscribe(m=>{nu(m,e)&&n.dispatch(m)});return()=>{f(),t.stop()}},[t,n,e]);const a=r.streamingMessage?[...r.messages,r.streamingMessage]:r.messages,l=((p=r.activeRun)==null?void 0:p.runId)??null,o=!!r.activeRun;return{snapshot:r,visibleMessages:a,activeRunId:l,isRunning:o,isSending:i,send:async f=>{if(i||o)return;const m=iu(f,e);if(m){s(!0),await n.dispatch({type:te.MessageSent,payload:{sessionId:e,message:m.message,metadata:m.metadata}});try{await t.send(m)}finally{s(!1)}}},abort:async()=>{r.activeRun&&await t.abort({sessionId:e})},streamRun:async()=>{r.activeRun&&await t.stream({sessionId:e})}}}function Ar(e){return e instanceof Error?e:new Error(String(e))}function lu(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function ou({sessionId:e,client:t,loadSeed:n,autoResumeRunningSession:r=!0}){const i=su(e),s=au({sessionId:e,client:t,manager:i}),[a,l]=k.useState(!0),[o,u]=k.useState(null),[d,c]=k.useState(null),p=k.useRef({requestId:0,controller:null}),f=k.useCallback(async()=>{var S;(S=p.current.controller)==null||S.abort();const m=new AbortController,x=p.current.requestId+1;p.current={requestId:x,controller:m},await t.stop(),i.reset(),u(null),l(!0);try{const g=await n(e,m.signal);if(m.signal.aborted||p.current.requestId!==x)return;i.hydrate({sessionId:e,messages:g.messages,activeRun:g.status==="running"?{runId:null,sessionId:e,abortDisabledReason:null}:null}),u(null),c(e),l(!1),g.status==="running"&&r&&t.stream({sessionId:e}).catch(I=>{p.current.requestId===x&&u(Ar(I))})}catch(g){if(m.signal.aborted||p.current.requestId!==x)return;u(Ar(g)),c(e),l(!1)}finally{p.current.controller===m&&(p.current.controller=null)}},[r,t,n,i,e]);return k.useEffect(()=>(f(),()=>{var m;(m=p.current.controller)==null||m.abort(),p.current.controller=null}),[f]),{...s,isHydrating:lu({sessionId:e,hydratedSessionId:d,isHydrating:a}),hydrateError:o,reloadSeed:f}}var ds=200*1024*1024,uu="application/octet-stream";function hs(e){const t=e.type.trim().toLowerCase();return t.length>0?t:uu}function cu(e,t){const n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(s=>s.trim().toLowerCase())):null,r=t.maxBytes??ds,i=hs(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 du(e){var i;const t=e.parts&&e.parts.length>0?e.parts.map(s=>structuredClone(s)):[...((i=e.text)==null?void 0:i.trim())??""?[{type:"text",text:e.text.trim()}]:[],...(e.attachments??[]).map(s=>{var a,l,o;return{type:"file",name:s.name,mimeType:s.mimeType,...(a=s.assetUri)!=null&&a.trim()?{assetUri:s.assetUri.trim()}:{},...(l=s.url)!=null&&l.trim()?{url:s.url.trim()}:{},...(o=s.contentBase64)!=null&&o.trim()?{contentBase64:s.contentBase64.trim()}:{},sizeBytes:s.sizeBytes}})];if(t.length===0)return null;const 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 hu(e,t){const n=[],r=[];for(const i of e){const s=cu(i,t);if(!s.ok){r.push(s.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(i=>({fileName:i.name,mimeType:hs(i),sizeBytes:i.size,reason:"read-failed"}))),{attachments:[],rejected:r}}}const fu={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 pu({status:e,className:t}){const n=fu[e],r=e==="connected"?v("connected"):e==="disconnected"?v("disconnected"):v("connecting");return h.jsx(fo,{delayDuration:250,children:h.jsxs(po,{children:[h.jsx(mo,{asChild:!0,children:h.jsx("span",{role:"status","aria-label":r,className:ve("inline-flex h-5 w-5 items-center justify-center",t),children:e==="connecting"?h.jsx(Hi,{className:ve("h-3 w-3 animate-spin",n.dotClass)}):h.jsx("span",{className:ve(e==="connected"?"h-2 w-2 rounded-full":"",n.dotClass)})})}),h.jsx(go,{side:"bottom",className:"text-xs",children:r})]})})}function mu(e){const{session:t,active:n,runStatus:r,sessionTypeLabel:i,title:s,isEditing:a,draftLabel:l,isSaving:o,onSelect:u,onStartEditing:d,onDraftLabelChange:c,onSave:p,onCancel:f}=e;return h.jsx("div",{className:ve("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:a?h.jsxs("div",{className:"space-y-2",children:[h.jsx(Hn,{value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),f())},placeholder:v("sessionsLabelPlaceholder"),className:"h-8 rounded-lg border-gray-300 bg-white text-xs",autoFocus:!0,disabled:o}),h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("div",{className:"min-w-0 text-[11px] text-gray-400 truncate",children:t.key}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(je,{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 p(),disabled:o,"aria-label":v("save"),children:h.jsx(xt,{className:"h-3.5 w-3.5"})}),h.jsx(je,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7 rounded-lg text-gray-500 hover:bg-white hover:text-gray-900",onClick:f,disabled:o,"aria-label":v("cancel"),children:h.jsx(Ja,{className:"h-3.5 w-3.5"})})]})]})]}):h.jsxs("div",{className:"group/session relative",children:[h.jsxs("button",{type:"button",onClick:u,className:"w-full text-left",children:[h.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_0.875rem] items-center gap-1.5 pr-8",children:[h.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[h.jsx("span",{className:"truncate font-medium",children:s}),i?h.jsx("span",{className:ve("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}):null]}),h.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:r?h.jsx(Lo,{status:r}):null})]}),h.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400 truncate",children:[t.messageCount," · ",zt(t.updatedAt)]})]}),h.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),d()},className:ve("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":v("edit"),children:h.jsx(Za,{className:"h-3.5 w-3.5"})})]})})}function gu(){const e=el();return async t=>{try{const n=await Zi(t.sessionKey,{label:t.label});Ul(e,n),ot.success(v("configSavedApplied"))}catch(n){throw ot.error(v("configSaveFailed")+": "+(n instanceof Error?n.message:String(n))),n}}}const xu={selectedSessionKey:null,selectedAgentId:"main",query:""},fe=zn(e=>({snapshot:xu,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function yu(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):[...e]}function bu(e={}){var i;const t=fe(s=>s.snapshot.query),n=es({limit:e.limit??200}),r=k.useMemo(()=>{var u;const s=((u=n.data)==null?void 0:u.sessions)??[],a=is(s),l=yu(a,t),o=new Map(s.map(d=>[d.sessionId,d]));return l.map(d=>{var c;return{session:d,runStatus:((c=o.get(d.key))==null?void 0:c.status)==="running"?"running":void 0}})},[t,(i=n.data)==null?void 0:i.sessions]);return{isLoading:n.isLoading,items:r}}const fs=k.createContext(null);function Su({presenter:e,children:t}){return h.jsx(fs.Provider,{value:e,children:t})}function Kn(){const e=k.useContext(fs);if(!e)throw new Error("usePresenter must be used inside ChatPresenterProvider");return e}const ku=e=>`[data-item-index="${e}"]`;function ps(e){const t=e.getItemSelector??ku;k.useEffect(()=>{if(!e.isEnabled||e.itemCount===0)return;const n=e.containerRef.current;if(!n)return;const r=n.querySelector(t(e.activeIndex));r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},[t,e.activeIndex,e.containerRef,e.isEnabled,e.itemCount])}function wu(){const e=k.useRef(null),[t,n]=k.useState(null);return k.useEffect(()=>{const r=e.current;if(!r||typeof ResizeObserver>"u")return;const i=()=>{n(r.getBoundingClientRect().width)};i();const s=new ResizeObserver(()=>i());return s.observe(r),()=>s.disconnect()},[]),{elementRef:e,width:t}}function q(...e){return tl(nl(e))}const ms=k.forwardRef(({className:e,type:t,...n},r)=>h.jsx("input",{type:t,className:q("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}));ms.displayName="ChatInput";const Cu=Co,vu=Io,Tu=vo,gs=k.forwardRef(({className:e,sideOffset:t=8,align:n="start",...r},i)=>h.jsx(To,{children:h.jsx(rs,{ref:i,sideOffset:t,align:n,className:q("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})}));gs.displayName=rs.displayName;const Iu=rl,Mu=sl,Nu=il,xs=k.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Ui,{ref:r,className:q("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,h.jsx(al,{asChild:!0,children:h.jsx(Ot,{className:"h-4 w-4 opacity-50"})})]}));xs.displayName=Ui.displayName;const ys=k.forwardRef(({className:e,...t},n)=>h.jsx(Qi,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(dl,{className:"h-4 w-4"})}));ys.displayName=Qi.displayName;const bs=k.forwardRef(({className:e,...t},n)=>h.jsx(Gi,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(Ot,{className:"h-4 w-4"})}));bs.displayName=Gi.displayName;const Ss=k.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>h.jsx(ll,{children:h.jsxs($i,{ref:i,className:q("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:[h.jsx(ys,{}),h.jsx(ol,{className:q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),h.jsx(bs,{})]})}));Ss.displayName=$i.displayName;const ks=k.forwardRef(({className:e,...t},n)=>h.jsx(qi,{ref:n,className:q("px-2 py-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-gray-500",e),...t}));ks.displayName=qi.displayName;const ws=k.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Wi,{ref:r,className:q("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:[h.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(ul,{children:h.jsx(xt,{className:"h-4 w-4"})})}),h.jsx(cl,{children:t})]}));ws.displayName=Wi.displayName;const Cs=k.forwardRef(({className:e,...t},n)=>h.jsx(Ki,{ref:n,className:q("-mx-1 my-1 h-px bg-gray-100",e),...t}));Cs.displayName=Ki.displayName;const Eu=xo,Lu=yo,Au=bo,vs=k.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(So,{children:h.jsx(ns,{ref:r,sideOffset:t,className:q("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})}));vs.displayName=ns.displayName;const yt={Popover:Cu,PopoverAnchor:Tu,PopoverContent:gs,PopoverTrigger:vu,Input:ms,Select:Iu,SelectContent:Ss,SelectGroup:Mu,SelectItem:ws,SelectLabel:ks,SelectSeparator:Cs,SelectTrigger:xs,SelectValue:Nu,Tooltip:Lu,TooltipContent:vs,TooltipProvider:Eu,TooltipTrigger:Au},Ru=680,ju=.82,Pu=560;function Du(e){const{Popover:t,PopoverAnchor:n,PopoverContent:r}=yt,{elementRef:i,width:s}=wu(),a=k.useRef(null),{isOpen:l,isLoading:o,items:u,activeIndex:d,activeItem:c,texts:p,onSelectItem:f,onOpenChange:m,onSetActiveIndex:x}=e,S=k.useMemo(()=>{if(s)return Math.min(s>Pu?s*ju:s,Ru)},[s]);return ps({containerRef:a,activeIndex:d,itemCount:u.length,isEnabled:l&&!o,getItemSelector:g=>`[data-slash-index="${g}"]`}),h.jsxs(t,{open:l,onOpenChange:m,children:[h.jsx(n,{asChild:!0,children:h.jsx("div",{ref:i,className:"pointer-events-none absolute bottom-full left-3 right-3 h-0"})}),h.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:g=>g.preventDefault(),style:S?{width:`${S}px`}:void 0,children:h.jsxs("div",{className:"grid min-h-[240px] grid-cols-[minmax(220px,300px)_minmax(0,1fr)]",children:[h.jsx("div",{ref:a,role:"listbox","aria-label":p.slashSectionLabel,className:"custom-scrollbar max-h-[320px] overflow-y-auto border-r border-gray-200 p-2.5",children:o?h.jsx("div",{className:"p-2 text-xs text-gray-500",children:p.slashLoadingLabel}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500",children:p.slashSectionLabel}),u.length===0?h.jsx("div",{className:"px-2 text-xs text-gray-400",children:p.slashEmptyLabel}):h.jsx("div",{className:"space-y-1",children:u.map((g,I)=>{const N=I===d;return h.jsxs("button",{type:"button",role:"option","aria-selected":N,"data-slash-index":I,onMouseEnter:()=>x(I),onClick:()=>f(g),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:[h.jsx("span",{className:"truncate text-xs font-semibold",children:g.title}),h.jsx("span",{className:"truncate text-xs text-gray-500",children:g.subtitle})]},g.key)})})]})}),h.jsx("div",{className:"max-w-[320px] p-3.5",children:c?h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"inline-flex rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary",children:c.subtitle}),h.jsx("span",{className:"text-sm font-semibold text-gray-900",children:c.title})]}),h.jsx("p",{className:"text-xs leading-5 text-gray-600",children:c.description}),h.jsx("div",{className:"space-y-1",children:c.detailLines.map(g=>h.jsx("div",{className:"rounded-md bg-gray-50 px-2 py-1 text-[11px] text-gray-600",children:g},g))}),h.jsx("div",{className:"pt-1 text-[11px] text-gray-500",children:p.slashSkillHintLabel})]}):h.jsx("div",{className:"text-xs text-gray-500",children:p.slashHintLabel})})]})})]})}const Fu=hl("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"}}),Et=k.forwardRef(({className:e,variant:t,size:n,...r},i)=>h.jsx("button",{className:q(Fu({variant:t,size:n,className:e})),ref:i,...r}));Et.displayName="ChatButton";function Rr(){return h.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 Ou(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=yt;return h.jsxs("div",{className:"flex flex-col items-end gap-1",children:[(s=e.sendError)!=null&&s.trim()?h.jsx("div",{className:"max-w-[420px] text-right text-[11px] text-red-600",children:e.sendError}):null,h.jsx("div",{className:"flex items-center gap-2",children:e.isSending?e.canStopGeneration?h.jsx(Et,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,onClick:()=>void e.onStop(),disabled:e.stopDisabled,children:h.jsx(Rr,{})}):h.jsx(r,{children:h.jsxs(t,{children:[h.jsx(i,{asChild:!0,children:h.jsx("span",{children:h.jsx(Et,{size:"icon",variant:"outline",className:"h-8 w-8 rounded-full","aria-label":e.stopButtonLabel,disabled:!0,children:h.jsx(Rr,{})})})}),h.jsx(n,{side:"top",children:h.jsx("p",{className:"text-xs",children:e.stopHint})})]})}):h.jsx(Et,{size:"icon",className:"h-8 w-8 rounded-full","aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:h.jsx(fl,{className:"h-5 w-5"})})})]})}function zu(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>[r.label,r.key,r.description].filter(s=>typeof s=="string"&&s.trim().length>0).join(" ").toLowerCase().includes(n)):e}function _u(e){const{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=yt,{picker:s}=e,a=k.useRef(null),l=k.useId(),[o,u]=k.useState(""),[d,c]=k.useState(0),p=k.useMemo(()=>new Set(s.selectedKeys),[s.selectedKeys]),f=s.selectedKeys.length,m=k.useMemo(()=>zu(s.options,o),[s.options,o]);k.useEffect(()=>{c(0)},[o]),k.useEffect(()=>{c(g=>m.length===0?0:Math.min(g,m.length-1))},[m.length]),ps({containerRef:a,activeIndex:d,itemCount:m.length,isEnabled:m.length>0,getItemSelector:g=>`[data-skill-index="${g}"]`});const x=g=>{if(p.has(g)){s.onSelectedKeysChange(s.selectedKeys.filter(I=>I!==g));return}s.onSelectedKeysChange([...s.selectedKeys,g])},S=g=>{if(m.length!==0){if(g.key==="ArrowDown"){g.preventDefault(),c(I=>Math.min(I+1,m.length-1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(I=>Math.max(I-1,0));return}if(g.key==="Enter"){g.preventDefault();const I=m[d];I&&x(I.key)}}};return h.jsxs(n,{children:[h.jsx(i,{asChild:!0,children:h.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:[h.jsx(_n,{className:"h-4 w-4"}),h.jsx("span",{children:s.title}),f>0?h.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:f}):null]})}),h.jsxs(r,{side:"top",align:"start",className:"w-[360px] p-0",children:[h.jsxs("div",{className:"space-y-2 border-b border-gray-100 px-4 py-3",children:[h.jsx("div",{className:"text-sm font-semibold text-gray-900",children:s.title}),h.jsxs("div",{className:"relative",children:[h.jsx(Bn,{className:"pointer-events-none absolute left-3 top-2.5 h-3.5 w-3.5 text-gray-400"}),h.jsx(t,{value:o,onChange:g=>u(g.target.value),onKeyDown:S,placeholder:s.searchPlaceholder,role:"combobox","aria-controls":l,"aria-expanded":"true","aria-autocomplete":"list","aria-activedescendant":m[d]?`${l}-option-${d}`:void 0,className:"h-8 rounded-lg pl-8 text-xs"})]})]}),h.jsx("div",{ref:a,id:l,role:"listbox","aria-multiselectable":"true",className:"custom-scrollbar max-h-[320px] overflow-y-auto",children:s.isLoading?h.jsx("div",{className:"p-4 text-xs text-gray-500",children:s.loadingLabel}):m.length===0?h.jsx("div",{className:"p-4 text-center text-xs text-gray-500",children:s.emptyLabel}):h.jsx("div",{className:"py-1",children:m.map((g,I)=>{const N=p.has(g.key),P=I===d;return h.jsxs("button",{type:"button",id:`${l}-option-${I}`,role:"option","aria-selected":N,"data-skill-index":I,onClick:()=>x(g.key),onMouseEnter:()=>c(I),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${P?"bg-gray-50":"hover:bg-gray-50"}`,children:[h.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-500",children:h.jsx(pl,{className:"h-4 w-4"})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"truncate text-sm text-gray-900",children:g.label}),g.badgeLabel?h.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:g.badgeLabel}):null]}),h.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",children:g.description||g.key})]}),h.jsx("div",{className:"ml-3 shrink-0",children:h.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?h.jsx(xt,{className:"h-3 w-3"}):null})})]},g.key)})})}),s.manageHref&&s.manageLabel?h.jsx("div",{className:"border-t border-gray-100 px-4 py-2.5",children:h.jsxs("a",{href:s.manageHref,className:"inline-flex items-center gap-1.5 text-xs font-medium text-primary transition-colors hover:text-primary/80",children:[s.manageLabel,h.jsx(ml,{className:"h-3 w-3"})]})}):null]})]})}function Ts({icon:e}){return e==="sparkles"?h.jsx(xl,{className:"h-3.5 w-3.5 shrink-0 text-primary"}):e==="brain"?h.jsx(yl,{className:"h-3.5 w-3.5 shrink-0 text-gray-500"}):null}function Bu({icon:e}){return e==="paperclip"?h.jsx(gl,{className:"h-4 w-4"}):h.jsx(Ts,{icon:e})}function Vu(e){return e==="model"?"min-w-[220px]":e==="session-type"?"min-w-[140px]":e==="thinking"?"min-w-[150px]":""}function Hu(e){return e==="model"?"w-[320px]":e==="session-type"?"w-[220px]":e==="thinking"?"w-[180px]":""}function Uu({item:e}){var c;const{Select:t,SelectContent:n,SelectGroup:r,SelectItem:i,SelectLabel:s,SelectSeparator:a,SelectTrigger:l,SelectValue:o}=yt,u=((c=e.groups)==null?void 0:c.filter(p=>p.options.length>0))??(e.options.length>0?[{key:`${e.key}-default`,options:e.options}]:[]),d=u.some(p=>p.options.length>0);return h.jsxs(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[h.jsx(l,{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 ${Vu(e.key)}`,children:e.selectedLabel?h.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-left",children:[h.jsx(Ts,{icon:e.icon}),h.jsx("span",{className:"truncate text-xs font-semibold text-gray-700",children:e.selectedLabel})]}):e.loading?h.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-gray-200"}):h.jsx(o,{placeholder:e.placeholder})}),h.jsxs(n,{className:Hu(e.key),children:[d?null:e.loading?h.jsxs("div",{className:"space-y-2 px-3 py-2",children:[h.jsx("div",{className:"h-3 w-36 animate-pulse rounded bg-gray-200"}),h.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),h.jsx("div",{className:"h-3 w-32 animate-pulse rounded bg-gray-200"})]}):e.emptyLabel?h.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:e.emptyLabel}):null,u.map((p,f)=>h.jsxs("div",{children:[f>0?h.jsx(a,{}):null,h.jsxs(r,{children:[p.label?h.jsx(s,{children:p.label}):null,p.options.map(m=>h.jsx(i,{value:m.value,className:"py-2",children:m.description?h.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:m.label}),h.jsx("span",{className:"truncate text-[11px] text-gray-500",children:m.description})]}):h.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:m.label})},m.value))]})]},p.key))]})]})}function $u(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=yt;return h.jsxs("div",{className:"flex items-center justify-between px-3 pb-3",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[e.skillPicker?h.jsx(_u,{picker:e.skillPicker}):null,e.selects.map(a=>h.jsx(Uu,{item:a},a.key)),(s=e.accessories)==null?void 0:s.map(a=>{const l=h.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 ${a.iconOnly?"h-8 w-8 justify-center px-0":"gap-1.5 px-3"}`,onClick:a.onClick,disabled:a.disabled,"aria-label":a.label,children:[h.jsx(Bu,{icon:a.icon}),a.iconOnly?null:h.jsx("span",{children:a.label})]});if(!a.tooltip)return h.jsx("div",{children:l},a.key);const o=a.disabled?h.jsx("span",{className:"inline-flex",children:l}):l;return h.jsx(r,{children:h.jsxs(t,{children:[h.jsx(i,{asChild:!0,children:o}),h.jsx(n,{side:"top",children:h.jsx("p",{className:"text-xs",children:a.tooltip})})]})},a.key)})]}),h.jsx(Ou,{...e.actions})]})}const Ku="";function Is(){return`composer-${Math.random().toString(36).slice(2,10)}`}function ft(e=""){return{id:Is(),type:"text",text:e}}function qn(e){return{id:Is(),type:"token",tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function bt(e){return e.type==="text"?e.text.length:1}function Wn(){return[ft("")]}function qu(e){return[ft(e)]}function Ge(e){const t=[];for(const n of e){if(n.type==="text"){if(n.text.length===0)continue;const r=t[t.length-1];if((r==null?void 0:r.type)==="text"){t[t.length-1]={...r,text:r.text+n.text};continue}}t.push(n)}return t.length===0?Wn():t}function Wu(e){return e.map(t=>t.type==="text"?t.text:Ku).join("")}function Qu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function _t(e,t){const n=[],r=new Set;for(const i of e)i.type!=="token"||i.tokenKind!==t||r.has(i.tokenKey)||(r.add(i.tokenKey),n.push(i.tokenKey));return n}function Gu(e,t,n,r){const i=Math.max(0,n-t),s=Math.max(0,t+e.text.length-r),a=[];return i>0&&a.push({...e,text:e.text.slice(0,i)}),s>0&&a.push({...e,text:e.text.slice(e.text.length-s)}),a}function Xu(e,t,n,r){return t<=n||e>=r}function Yu(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function Ju(e,t,n,r,i,s,a){const l=Gu(t,n,r,i);l[0]&&e.push(l[0]);let o=a;return o||(e.push(...s),o=!0),l[1]&&e.push(l[1]),o}function Zu(e,t,n,r,i,s){return!r&&i<=s?(e.push(...n),!0):(e.push(t),r)}function Jt(e,t,n,r){const i=Math.max(0,t),s=Math.max(i,n),a=[];let l=0,o=!1;for(const u of e){const d=bt(u),c=l,p=l+d;if(Xu(c,p,i,s)){o=Yu(a,r,o,c,s),a.push(u),l=p;continue}u.type==="text"?o=Ju(a,u,c,i,s,r,o):o=Zu(a,u,r,o,i,c),l=p}return o||a.push(...r),Ge(a)}function Qn(e,t){return Ge(e.filter(n=>n.type!=="token"||!t(n)))}function ec(e,t){if(!t||t.start!==t.end)return null;const n=Wu(e),r=t.end,i=n.slice(0,r),s=/(?:^|\s)\/([^\s\uFFFC]*)$/.exec(i);if(!s)return null;const a=r-s[0].length+(s[0].startsWith("/")?0:1);return{query:(s[1]??"").trim().toLowerCase(),start:a,end:r}}function tc(e,t,n){return e?e.start<n&&e.end>t:!1}function Ms(e){const t=new Map;let n=0;for(const r of e)t.set(r.id,n),n+=bt(r);return t}function Ns(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 nc(e,t,n){if(e instanceof HTMLElement){const r=e.dataset.composerNodeId;if(r)return n.find(i=>i.id===r)}return n[t]}function Es(e,t,n){let r=0;for(let i=0;i<n;i+=1){const s=nc(e.childNodes[i],i,t);s&&(r+=bt(s))}return r}function rc(e,t,n,r){var l;const i=Ns(e,t),s=Es(e,r,i),a=r[i];return(a==null?void 0:a.type)==="text"?s+Math.min(n,a.text.length):s+Math.min(n,((l=t.textContent)==null?void 0:l.length)??0)}function ic(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 vn(e,t,n,r,i){var u;if(t===e)return Es(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return rc(e,t,n,r);const s=t instanceof HTMLElement?t.closest("[data-composer-node-id]"):((u=t.parentElement)==null?void 0:u.closest("[data-composer-node-id]"))??null;if(!(s instanceof HTMLElement)){const d=Ns(e,t);return vn(e,e,d,r,i)}const a=s.dataset.composerNodeId;if(!a)return 0;const l=r.find(d=>d.id===a),o=i.get(a)??0;return l?ic(t,n,l,o,s):o}function Ls(e,t){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const r=n.getRangeAt(0);if(!e.contains(r.startContainer)||!e.contains(r.endContainer))return null;const i=Ms(t),s=vn(e,r.startContainer,r.startOffset,t,i),a=vn(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(s,a),end:Math.max(s,a)}}function sc(e,t,n){if(!n)return;const r=window.getSelection();if(!r)return;const i=o=>{let u=0;for(let d=0;d<t.length;d+=1){const c=t[d],p=bt(c),f=u,m=u+p,x=e.childNodes[d];if(!x){u=m;continue}if(c.type==="text"){if(o<=m)return{container:x.firstChild??x,offset:Math.max(0,Math.min(o-f,c.text.length))}}else{if(o<=f)return{container:e,offset:d};if(o<=m)return{container:e,offset:d+1}}u=m}return{container:e,offset:e.childNodes.length}},s=i(n.start),a=i(n.end),l=document.createRange();l.setStart(s.container,s.offset),l.setEnd(a.container,a.offset),r.removeAllRanges(),r.addRange(l)}function ac(e){const t=[];for(const n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(ft(n.textContent??""));continue}if(!(n instanceof HTMLElement))continue;if(n.dataset.composerNodeType==="token"){const s=n.dataset.composerTokenKind,a=n.dataset.composerTokenKey,l=n.dataset.composerLabel;s&&a&&l&&t.push({id:n.dataset.composerNodeId??qn({tokenKind:s,tokenKey:a,label:l}).id,type:"token",tokenKind:s,tokenKey:a,label:l});continue}const i=n.textContent??"";t.push({id:n.dataset.composerNodeId??ft(i).id,type:"text",text:i})}return Ge(t)}function jr(e){const t=ac(e);return{nodes:t,selection:Ls(e,t)}}class lc{constructor(){this.nodes=Wn(),this.selection=null,this.sync=(t,n)=>(this.nodes=Ge(t),this.selection=n,this.getSnapshot()),this.setSelection=t=>(this.selection=t,this.getSnapshot()),this.replaceDocument=(t,n)=>(this.nodes=Ge(t),this.selection=n,this.getSnapshot()),this.insertText=t=>{const n=this.selection??{start:0,end:0};this.nodes=Jt(this.nodes,n.start,n.end,[ft(t)]);const r=n.start+t.length;return this.selection={start:r,end:r},this.getSnapshot()},this.insertFileToken=(t,n)=>this.insertToken("file",t,n),this.insertSkillToken=(t,n)=>this.getSelectedSkillKeys().includes(t)?this.getSnapshot():this.insertToken("skill",t,n,this.getSlashTrigger()),this.syncSelectedSkills=(t,n)=>{const r=this.getSelectedSkillKeys(),i=new Map(n.map(l=>[l.key,l])),s=t.find(l=>!r.includes(l));if(s){const l=i.get(s);return this.insertSkillToken(s,(l==null?void 0:l.label)??s)}const a=r.find(l=>!t.includes(l));return a&&(this.nodes=Qn(this.nodes,l=>l.tokenKind==="skill"&&l.tokenKey===a)),this.getSnapshot()},this.deleteContent=t=>{const n=this.getDocumentLength(),r=this.selection??{start:n,end:n};let i=r.start,s=r.end;if(r.start===r.end)if(t==="backward"&&r.start>0)i=r.start-1;else if(t==="forward")s=r.end+1;else return this.getSnapshot();return this.nodes=Jt(this.nodes,i,s,[]),this.selection={start:i,end:i},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:Ms(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((t,n)=>t+bt(n),0),this.getSelectedSkillKeys=()=>_t(this.nodes,"skill"),this.insertToken=(t,n,r,i=null)=>{var o,u;const s=this.getDocumentLength(),a=(i==null?void 0:i.start)??((o=this.selection)==null?void 0:o.start)??s,l=(i==null?void 0:i.end)??((u=this.selection)==null?void 0:u.end)??a;return this.nodes=Jt(this.nodes,a,l,[qn({tokenKind:t,tokenKey:n,label:r})]),this.selection={start:a+1,end:a+1},this.getSnapshot()},this.getSlashTrigger=()=>ec(this.nodes,this.selection)}}function oc(e){const{key:t,shiftKey:n,isComposing:r,isSlashMenuOpen:i,slashItemCount:s,activeSlashIndex:a,isSending:l,canStopGeneration:o}=e;if(i&&s>0){if(t==="ArrowDown")return{type:"move-slash-index",index:(a+1)%s};if(t==="ArrowUp")return{type:"move-slash-index",index:(a-1+s)%s};if(t==="Enter"&&!n||t==="Tab")return{type:"insert-active-slash-item"}}return t==="Escape"?i?{type:"close-slash"}:l&&o?{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"}}const Pr="http://www.w3.org/2000/svg";class uc{constructor(){this.render=(t,n)=>{if(!t)return;const r=document.createDocumentFragment();for(const i of n.nodes){const s=i.type==="text"?this.createTextNodeElement(i):this.createTokenNodeElement(i,n.selectedRange,n.nodeStartMap);s&&r.appendChild(s)}t.replaceChildren(r)},this.createTextNodeElement=t=>{if(t.text.length===0)return null;const n=document.createElement("span");return n.dataset.composerNodeId=t.id,n.dataset.composerNodeType="text",n.textContent=t.text,n},this.createTokenNodeElement=(t,n,r)=>{const i=r.get(t.id)??0,s=tc(n,i,i+1),a=document.createElement("span");a.contentEditable="false",a.dataset.composerNodeId=t.id,a.dataset.composerNodeType="token",a.dataset.composerTokenKind=t.tokenKind,a.dataset.composerTokenKey=t.tokenKey,a.dataset.composerLabel=t.label,a.title=t.label,a.className=this.buildTokenClassName(t.tokenKind,s),a.append(this.createTokenIcon(t.tokenKind));const l=document.createElement("span");return l.className=t.tokenKind==="file"?"min-w-0 flex-1 truncate text-[12px] font-medium text-slate-700":"truncate",l.textContent=t.label,a.append(l),a},this.buildTokenClassName=(t,n)=>t==="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",n?"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",n?"border-primary/30 bg-primary/18 text-primary":"border-primary/12 bg-primary/8 text-primary"].join(" "),this.createTokenIcon=t=>{const n=document.createElement("span");return n.className=t==="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",n.append(t==="file"?this.createFileIcon():this.createSkillIcon()),n},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=t=>{const n=document.createElementNS(Pr,"svg");n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.25"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true"),n.setAttribute("class","h-3 w-3");for(const r of t){const i=document.createElementNS(Pr,r.tag);for(const[s,a]of Object.entries(r.attrs))i.setAttribute(s,a);n.append(i)}return n}}}const Dr=188;class cc{constructor(t){this.controller=t,this.surfaceRenderer=new uc,this.sync=(n,r)=>this.controller.sync(n,r),this.syncSelectionFromRoot=n=>this.controller.setSelection(Ls(n,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(n,r)=>{!n||document.activeElement!==n||sc(n,this.controller.getSnapshot().nodes,r)},this.syncViewport=n=>{n&&(n.style.maxHeight=`${Dr}px`,n.style.overflowY=n.scrollHeight>Dr?"auto":"hidden")},this.renderSurface=n=>{this.surfaceRenderer.render(n.root,{nodes:n.snapshot.nodes,selectedRange:n.selectedRange,nodeStartMap:n.snapshot.nodeStartMap})},this.insertSlashItem=(n,r)=>{n.value&&r(this.controller.insertSkillToken(n.value,n.title))},this.syncSelectedSkills=(n,r,i)=>{i(this.controller.syncSelectedSkills(n,r))},this.handleBeforeInput=n=>{const{event:r,disabled:i,isComposing:s,commitSnapshot:a}=n,l=r.nativeEvent;i||s||l.isComposing||!(l.inputType==="insertText"||l.inputType==="insertReplacementText")||!l.data||(r.preventDefault(),a(this.controller.insertText(l.data)))},this.handleInput=n=>{const{event:r,isComposing:i,commitSnapshot:s}=n,a=r.nativeEvent;if(i||a.isComposing)return;const l=r.currentTarget,o=jr(l);s(this.controller.replaceDocument(o.nodes,o.selection))},this.handleCompositionEnd=n=>{const{event:r,commitSnapshot:i}=n,s=r.currentTarget,a=jr(s);i(this.controller.replaceDocument(a.nodes,a.selection))},this.handleKeyDown=n=>{const{event:r,slashItems:i,activeSlashIndex:s,activeSlashItem:a,actions:l,commitSnapshot:o,insertSkillToken:u,onSlashActiveIndexChange:d,onSlashQueryChange:c,onSlashOpenChange:p}=n,f=this.controller.getSnapshot(),m=oc({key:r.key,shiftKey:r.shiftKey,isComposing:r.nativeEvent.isComposing,isSlashMenuOpen:f.slashTrigger!==null,slashItemCount:i.length,activeSlashIndex:s,isSending:l.isSending,canStopGeneration:l.canStopGeneration});if(m.type!=="noop"){if(r.preventDefault(),m.type==="move-slash-index"){d(m.index);return}if(m.type==="insert-active-slash-item"){a&&u(a.value??a.key,a.title);return}if(m.type==="close-slash"){c==null||c(null),p(!1);return}if(m.type==="stop-generation"){l.onStop();return}if(m.type==="insert-line-break"){o(this.controller.insertText(`
3
+ `));return}if(m.type==="send-message"){l.onSend();return}m.type==="delete-content"&&o(this.controller.deleteContent(m.direction))}},this.handlePaste=n=>{const{event:r,onFilesAdd:i,commitSnapshot:s}=n,a=Array.from(r.clipboardData.files??[]);if(a.length>0&&i){r.preventDefault(),i(a);return}const l=r.clipboardData.getData("text/plain");l&&(r.preventDefault(),s(this.controller.insertText(l)))},this.handleBlur=n=>{const{clearSelectedRange:r,onSlashQueryChange:i,onSlashOpenChange:s}=n;r(),i==null||i(null),s(!1)}}}class dc{constructor(){this.controller=new lc,this.viewController=new cc(this.controller),this.rootElement=null,this.selection=null,this.selectedRange=null,this.snapshot=this.controller.getSnapshot(),this.config=null,this.isComposing=!1,this.bindRootElement=t=>{this.rootElement=t},this.update=t=>(this.config=t,this.snapshot=this.viewController.sync(t.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:t=>{this.viewController.insertSlashItem(t,this.commitSnapshot)},insertFileToken:(t,n)=>{this.commitSnapshot(this.controller.insertFileToken(t,n)),this.focusComposerSoon()},insertFileTokens:t=>{let n=null;for(const r of t)n=this.controller.insertFileToken(r.tokenKey,r.label);n&&(this.commitSnapshot(n),this.focusComposerSoon())},focusComposer:()=>{this.focusComposer()},syncSelectedSkills:(t,n)=>{this.viewController.syncSelectedSkills(t,n,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;const t=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=t.selection,this.selectedRange=t.selection,this.syncSlashState(t),this.requestRender()},this.handleBeforeInput=t=>{this.viewController.handleBeforeInput({event:t,disabled:this.requireConfig().disabled,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleInput=t=>{this.viewController.handleInput({event:t,isComposing:this.isComposing,commitSnapshot:this.commitSnapshot})},this.handleCompositionStart=()=>{this.isComposing=!0},this.handleCompositionEnd=t=>{this.isComposing=!1,this.viewController.handleCompositionEnd({event:t,commitSnapshot:this.commitSnapshot})},this.handleKeyDown=t=>{const n=this.requireConfig();if(this.rootElement&&!this.isComposing){const i=this.viewController.syncSelectionFromRoot(this.rootElement);this.selection=i.selection,this.selectedRange=i.selection,this.snapshot=i}const r=n.slashItems[n.activeSlashIndex]??null;this.viewController.handleKeyDown({event:t,slashItems:n.slashItems,activeSlashIndex:n.activeSlashIndex,activeSlashItem:r,actions:n.actions,commitSnapshot:this.commitSnapshot,insertSkillToken:this.insertSkillToken,onSlashActiveIndexChange:n.onSlashActiveIndexChange,onSlashQueryChange:n.onSlashQueryChange,onSlashOpenChange:n.onSlashOpenChange})},this.handlePaste=t=>{this.viewController.handlePaste({event:t,onFilesAdd:this.requireConfig().onFilesAdd,commitSnapshot:this.commitSnapshot})},this.handleBlur=()=>{const t=this.requireConfig();this.isComposing=!1,this.viewController.handleBlur({clearSelectedRange:this.clearSelectedRange,onSlashQueryChange:t.onSlashQueryChange,onSlashOpenChange:t.onSlashOpenChange})},this.setSelectedRange=t=>{this.selectedRange=t,this.selection=t,this.requestRender()},this.clearSelectedRange=()=>{this.selectedRange=null,this.requestRender()},this.commitSnapshot=t=>{const n=this.requireConfig();this.selection=t.selection,this.selectedRange=t.selection,this.snapshot=t,n.onNodesChange(t.nodes),this.syncSlashState(t)},this.insertSkillToken=(t,n)=>{this.commitSnapshot(this.controller.insertSkillToken(t,n))},this.syncSlashState=t=>{var r,i,s;const n=this.requireConfig();(r=n.onSlashTriggerChange)==null||r.call(n,t.slashTrigger),(s=n.onSlashQueryChange)==null||s.call(n,((i=t.slashTrigger)==null?void 0:i.query)??null),n.onSlashOpenChange(t.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;const t=this.selection;this.rootElement.focus();const n=()=>{this.rootElement&&(this.selection=t,this.selectedRange=t,this.viewController.restoreSelectionIfFocused(this.rootElement,t))};if(typeof requestAnimationFrame=="function"){requestAnimationFrame(n);return}n()},this.requireConfig=()=>{if(!this.config)throw new Error("ChatComposerRuntime is not configured.");return this.config}}}const hc=k.forwardRef(function(t,n){const{nodes:r,placeholder:i,disabled:s,slashItems:a,actions:l,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:d,onSlashTriggerChange:c,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m}=t,[x,S]=k.useState(0),[g]=k.useState(()=>new dc),{snapshot:I,bindRootElement:N,handleBeforeInput:P,handleInput:F,handleCompositionStart:T,handleCompositionEnd:O,handleKeyDown:B,handlePaste:U,handleBlur:w,syncSelectionState:R,imperativeHandle:E}=g.update({nodes:r,disabled:s,slashItems:a,actions:l,onNodesChange:o,onFilesAdd:u,onSlashQueryChange:d,onSlashTriggerChange:c,onSlashOpenChange:p,onSlashActiveIndexChange:f,activeSlashIndex:m,requestRender:()=>S(V=>V+1)});return k.useImperativeHandle(n,()=>E,[E]),k.useLayoutEffect(()=>{g.renderSurface(),g.restoreDomAfterCommit(),g.syncViewport()},[g,I.nodes,I.nodeStartMap,x]),h.jsx("div",{className:"px-4 py-2.5",children:h.jsx("div",{className:"min-h-[60px]",children:h.jsx("div",{ref:N,contentEditable:!s,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","data-placeholder":i,onBeforeInput:P,onInput:F,onCompositionStart:T,onCompositionEnd:O,onKeyDown:B,onKeyUp:R,onMouseUp:R,onFocus:R,onBlur:w,onPaste:U,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 fc({hint:e}){if(!e)return null;if(e.loading)return h.jsx("div",{className:"px-4 pb-2",children:h.jsxs("div",{className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2",children:[h.jsx("span",{className:"h-3 w-28 animate-pulse rounded bg-gray-200"}),h.jsx("span",{className:"h-3 w-16 animate-pulse rounded bg-gray-200"})]})});const t=e.tone==="warning"?"border-amber-200 bg-amber-50 text-amber-800":"border-gray-200 bg-gray-50 text-gray-700";return h.jsx("div",{className:"px-4 pb-2",children:h.jsxs("div",{className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs ${t}`,children:[e.text?h.jsx("span",{children:e.text}):null,e.actionLabel&&e.onAction?h.jsx("button",{type:"button",onClick:e.onAction,className:"font-semibold underline-offset-2 hover:underline",children:e.actionLabel}):null]})})}const As=k.forwardRef(function(t,n){const r=k.useRef(null),[i,s]=k.useState(null),[a,l]=k.useState(0),[o,u]=k.useState(null),[d,c]=k.useState(null),p=o!==null&&d!==o,f=t.slashMenu.items[a]??null;k.useEffect(()=>{l(x=>t.slashMenu.items.length===0?0:Math.min(x,t.slashMenu.items.length-1))},[t.slashMenu.items.length]),k.useEffect(()=>{i!==null&&l(0)},[i]),k.useEffect(()=>{o===null&&d!==null&&c(null)},[o,d]);const m=k.useMemo(()=>t.toolbar.skillPicker?{...t.toolbar,skillPicker:{...t.toolbar.skillPicker,onSelectedKeysChange:x=>{var S,g;(g=r.current)==null||g.syncSelectedSkills(x,((S=t.toolbar.skillPicker)==null?void 0:S.options)??[])}}}:t.toolbar,[t.toolbar]);return k.useImperativeHandle(n,()=>({insertFileToken:(x,S)=>{var g;return(g=r.current)==null?void 0:g.insertFileToken(x,S)},insertFileTokens:x=>{var S;return(S=r.current)==null?void 0:S.insertFileTokens(x)},focusComposer:()=>{var x;return(x=r.current)==null?void 0:x.focusComposer()}}),[]),h.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:h.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-card",children:[h.jsxs("div",{className:"relative",children:[h.jsx(hc,{ref:r,nodes:t.composer.nodes,placeholder:t.composer.placeholder,disabled:t.composer.disabled,slashItems:t.slashMenu.items,actions:t.toolbar.actions,activeSlashIndex:a,onNodesChange:t.composer.onNodesChange,onFilesAdd:t.composer.onFilesAdd,onSlashQueryChange:x=>{var S,g;s(x),(g=(S=t.composer).onSlashQueryChange)==null||g.call(S,x)},onSlashTriggerChange:x=>{u((x==null?void 0:x.start)??null)},onSlashOpenChange:x=>{!x&&o!==null&&c(o)},onSlashActiveIndexChange:l}),h.jsx(Du,{isOpen:p,isLoading:t.slashMenu.isLoading,items:t.slashMenu.items,activeIndex:a,activeItem:f,texts:t.slashMenu.texts,onSelectItem:x=>{var S;c(null),(S=r.current)==null||S.insertSlashItem(x)},onOpenChange:x=>{!x&&o!==null&&c(o)},onSetActiveIndex:l})]}),h.jsx(fc,{hint:t.hint}),h.jsx($u,{...m})]})})})});As.displayName="ChatInputBar";function Zt({role:e}){return e==="user"?h.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:h.jsx(bl,{className:"h-4 w-4"})}):e==="tool"?h.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:h.jsx(Sl,{className:"h-4 w-4"})}):h.jsx("div",{"data-testid":"chat-message-avatar-assistant",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200/80 bg-gray-900 text-white shadow-sm",children:h.jsx(Xi,{className:"h-4 w-4"})})}function pc(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const mc=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gc=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xc={};function Fr(e,t){return(xc.jsx?gc:mc).test(e)}const yc=/[ \t\n\f\r]/g;function bc(e){return typeof e=="object"?e.type==="text"?Or(e.value):!1:Or(e)}function Or(e){return e.replace(yc,"")===""}class St{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}St.prototype.normal={};St.prototype.property={};St.prototype.space=void 0;function Rs(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new St(n,r,t)}function Tn(e){return e.toLowerCase()}class pe{constructor(t,n){this.attribute=n,this.property=t}}pe.prototype.attribute="";pe.prototype.booleanish=!1;pe.prototype.boolean=!1;pe.prototype.commaOrSpaceSeparated=!1;pe.prototype.commaSeparated=!1;pe.prototype.defined=!1;pe.prototype.mustUseProperty=!1;pe.prototype.number=!1;pe.prototype.overloadedBoolean=!1;pe.prototype.property="";pe.prototype.spaceSeparated=!1;pe.prototype.space=void 0;let Sc=0;const K=Ue(),ie=Ue(),In=Ue(),L=Ue(),ee=Ue(),Qe=Ue(),ge=Ue();function Ue(){return 2**++Sc}const Mn=Object.freeze(Object.defineProperty({__proto__:null,boolean:K,booleanish:ie,commaOrSpaceSeparated:ge,commaSeparated:Qe,number:L,overloadedBoolean:In,spaceSeparated:ee},Symbol.toStringTag,{value:"Module"})),en=Object.keys(Mn);class Gn extends pe{constructor(t,n,r,i){let s=-1;if(super(t,n),zr(this,"space",i),typeof r=="number")for(;++s<en.length;){const a=en[s];zr(this,en[s],(r&Mn[a])===Mn[a])}}}Gn.prototype.defined=!0;function zr(e,t,n){n&&(e[t]=n)}function Ye(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Gn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Tn(r)]=r,n[Tn(s.attribute)]=r}return new St(t,n,e.space)}const js=Ye({properties:{ariaActiveDescendant:null,ariaAtomic:ie,ariaAutoComplete:null,ariaBusy:ie,ariaChecked:ie,ariaColCount:L,ariaColIndex:L,ariaColSpan:L,ariaControls:ee,ariaCurrent:null,ariaDescribedBy:ee,ariaDetails:null,ariaDisabled:ie,ariaDropEffect:ee,ariaErrorMessage:null,ariaExpanded:ie,ariaFlowTo:ee,ariaGrabbed:ie,ariaHasPopup:null,ariaHidden:ie,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ee,ariaLevel:L,ariaLive:null,ariaModal:ie,ariaMultiLine:ie,ariaMultiSelectable:ie,ariaOrientation:null,ariaOwns:ee,ariaPlaceholder:null,ariaPosInSet:L,ariaPressed:ie,ariaReadOnly:ie,ariaRelevant:null,ariaRequired:ie,ariaRoleDescription:ee,ariaRowCount:L,ariaRowIndex:L,ariaRowSpan:L,ariaSelected:ie,ariaSetSize:L,ariaSort:null,ariaValueMax:L,ariaValueMin:L,ariaValueNow:L,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ps(e,t){return t in e?e[t]:t}function Ds(e,t){return Ps(e,t.toLowerCase())}const kc=Ye({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Qe,acceptCharset:ee,accessKey:ee,action:null,allow:null,allowFullScreen:K,allowPaymentRequest:K,allowUserMedia:K,alt:null,as:null,async:K,autoCapitalize:null,autoComplete:ee,autoFocus:K,autoPlay:K,blocking:ee,capture:null,charSet:null,checked:K,cite:null,className:ee,cols:L,colSpan:null,content:null,contentEditable:ie,controls:K,controlsList:ee,coords:L|Qe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:K,defer:K,dir:null,dirName:null,disabled:K,download:In,draggable:ie,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:K,formTarget:null,headers:ee,height:L,hidden:In,high:L,href:null,hrefLang:null,htmlFor:ee,httpEquiv:ee,id:null,imageSizes:null,imageSrcSet:null,inert:K,inputMode:null,integrity:null,is:null,isMap:K,itemId:null,itemProp:ee,itemRef:ee,itemScope:K,itemType:ee,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:K,low:L,manifest:null,max:null,maxLength:L,media:null,method:null,min:null,minLength:L,multiple:K,muted:K,name:null,nonce:null,noModule:K,noValidate:K,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:K,optimum:L,pattern:null,ping:ee,placeholder:null,playsInline:K,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:K,referrerPolicy:null,rel:ee,required:K,reversed:K,rows:L,rowSpan:L,sandbox:ee,scope:null,scoped:K,seamless:K,selected:K,shadowRootClonable:K,shadowRootDelegatesFocus:K,shadowRootMode:null,shape:null,size:L,sizes:null,slot:null,span:L,spellCheck:ie,src:null,srcDoc:null,srcLang:null,srcSet:null,start:L,step:null,style:null,tabIndex:L,target:null,title:null,translate:null,type:null,typeMustMatch:K,useMap:null,value:ie,width:L,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ee,axis:null,background:null,bgColor:null,border:L,borderColor:null,bottomMargin:L,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:K,declare:K,event:null,face:null,frame:null,frameBorder:null,hSpace:L,leftMargin:L,link:null,longDesc:null,lowSrc:null,marginHeight:L,marginWidth:L,noResize:K,noHref:K,noShade:K,noWrap:K,object:null,profile:null,prompt:null,rev:null,rightMargin:L,rules:null,scheme:null,scrolling:ie,standby:null,summary:null,text:null,topMargin:L,valueType:null,version:null,vAlign:null,vLink:null,vSpace:L,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:K,disableRemotePlayback:K,prefix:null,property:null,results:L,security:null,unselectable:null},space:"html",transform:Ds}),wc=Ye({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:ge,accentHeight:L,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:L,amplitude:L,arabicForm:null,ascent:L,attributeName:null,attributeType:null,azimuth:L,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:L,by:null,calcMode:null,capHeight:L,className:ee,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:L,diffuseConstant:L,direction:null,display:null,dur:null,divisor:L,dominantBaseline:null,download:K,dx:null,dy:null,edgeMode:null,editable:null,elevation:L,enableBackground:null,end:null,event:null,exponent:L,externalResourcesRequired:null,fill:null,fillOpacity:L,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:Qe,g2:Qe,glyphName:Qe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:L,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:L,horizOriginX:L,horizOriginY:L,id:null,ideographic:L,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:L,k:L,k1:L,k2:L,k3:L,k4:L,kernelMatrix:ge,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:L,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:L,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:L,overlineThickness:L,paintOrder:null,panose1:null,path:null,pathLength:L,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ee,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:L,pointsAtY:L,pointsAtZ:L,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ge,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ge,rev:ge,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ge,requiredFeatures:ge,requiredFonts:ge,requiredFormats:ge,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:L,specularExponent:L,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:L,strikethroughThickness:L,string:null,stroke:null,strokeDashArray:ge,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:L,strokeOpacity:L,strokeWidth:null,style:null,surfaceScale:L,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ge,tabIndex:L,tableValues:null,target:null,targetX:L,targetY:L,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ge,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:L,underlineThickness:L,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:L,values:null,vAlphabetic:L,vMathematical:L,vectorEffect:null,vHanging:L,vIdeographic:L,version:null,vertAdvY:L,vertOriginX:L,vertOriginY:L,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:L,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ps}),Fs=Ye({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()}}),Os=Ye({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ds}),zs=Ye({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Cc={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"},vc=/[A-Z]/g,_r=/-[a-z]/g,Tc=/^data[-\w.:]+$/i;function Ic(e,t){const n=Tn(t);let r=t,i=pe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Tc.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(_r,Nc);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!_r.test(s)){let a=s.replace(vc,Mc);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Gn}return new i(r,t)}function Mc(e){return"-"+e.toLowerCase()}function Nc(e){return e.charAt(1).toUpperCase()}const Ec=Rs([js,kc,Fs,Os,zs],"html"),Xn=Rs([js,wc,Fs,Os,zs],"svg");function Lc(e){return e.join(" ").trim()}var Ke={},tn,Br;function Ac(){if(Br)return tn;Br=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,l=/^\s+|\s+$/g,o=`
4
+ `,u="/",d="*",c="",p="comment",f="declaration";function m(S,g){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];g=g||{};var I=1,N=1;function P(j){var C=j.match(t);C&&(I+=C.length);var D=j.lastIndexOf(o);N=~D?j.length-D:N+j.length}function F(){var j={line:I,column:N};return function(C){return C.position=new T(j),U(),C}}function T(j){this.start=j,this.end={line:I,column:N},this.source=g.source}T.prototype.content=S;function O(j){var C=new Error(g.source+":"+I+":"+N+": "+j);if(C.reason=j,C.filename=g.source,C.line=I,C.column=N,C.source=S,!g.silent)throw C}function B(j){var C=j.exec(S);if(C){var D=C[0];return P(D),S=S.slice(D.length),C}}function U(){B(n)}function w(j){var C;for(j=j||[];C=R();)C!==!1&&j.push(C);return j}function R(){var j=F();if(!(u!=S.charAt(0)||d!=S.charAt(1))){for(var C=2;c!=S.charAt(C)&&(d!=S.charAt(C)||u!=S.charAt(C+1));)++C;if(C+=2,c===S.charAt(C-1))return O("End of comment missing");var D=S.slice(2,C-2);return N+=2,P(D),S=S.slice(C),N+=2,j({type:p,comment:D})}}function E(){var j=F(),C=B(r);if(C){if(R(),!B(i))return O("property missing ':'");var D=B(s),Q=j({type:f,property:x(C[0].replace(e,c)),value:D?x(D[0].replace(e,c)):c});return B(a),Q}}function V(){var j=[];w(j);for(var C;C=E();)C!==!1&&(j.push(C),w(j));return j}return U(),V()}function x(S){return S?S.replace(l,c):c}return tn=m,tn}var Vr;function Rc(){if(Vr)return Ke;Vr=1;var e=Ke&&Ke.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.default=n;const t=e(Ac());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),l=typeof i=="function";return a.forEach(o=>{if(o.type!=="declaration")return;const{property:u,value:d}=o;l?i(u,d,o):d&&(s=s||{},s[u]=d)}),s}return Ke}var rt={},Hr;function jc(){if(Hr)return rt;Hr=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},a=function(u,d){return d.toUpperCase()},l=function(u,d){return"".concat(d,"-")},o=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,l):u=u.replace(r,l),u.replace(t,a))};return rt.camelCase=o,rt}var it,Ur;function Pc(){if(Ur)return it;Ur=1;var e=it&&it.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Rc()),n=jc();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(l,o){l&&o&&(a[(0,n.camelCase)(l,s)]=o)}),a}return r.default=r,it=r,it}var Dc=Pc();const Fc=Yi(Dc),_s=Bs("end"),Yn=Bs("start");function Bs(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Oc(e){const t=Yn(e),n=_s(e);if(t&&n)return{start:t,end:n}}function ct(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?$r(e.position):"start"in e||"end"in e?$r(e):"line"in e||"column"in e?Nn(e):""}function Nn(e){return Kr(e&&e.line)+":"+Kr(e&&e.column)}function $r(e){return Nn(e&&e.start)+"-"+Nn(e&&e.end)}function Kr(e){return e&&typeof e=="number"?e:1}class oe extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const o=r.indexOf(":");o===-1?s.ruleId=r:(s.source=r.slice(0,o),s.ruleId=r.slice(o+1))}if(!s.place&&s.ancestors&&s.ancestors){const o=s.ancestors[s.ancestors.length-1];o&&(s.place=o.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=ct(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}oe.prototype.file="";oe.prototype.name="";oe.prototype.reason="";oe.prototype.message="";oe.prototype.stack="";oe.prototype.column=void 0;oe.prototype.line=void 0;oe.prototype.ancestors=void 0;oe.prototype.cause=void 0;oe.prototype.fatal=void 0;oe.prototype.place=void 0;oe.prototype.ruleId=void 0;oe.prototype.source=void 0;const Jn={}.hasOwnProperty,zc=new Map,_c=/[A-Z]/g,Bc=new Set(["table","tbody","thead","tfoot","tr"]),Vc=new Set(["td","th"]),Vs="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Hc(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Xc(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Gc(n,t.jsx,t.jsxs)}const 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"?Xn:Ec,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Hs(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Hs(e,t,n){if(t.type==="element")return Uc(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return $c(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return qc(e,t,n);if(t.type==="mdxjsEsm")return Kc(e,t);if(t.type==="root")return Wc(e,t,n);if(t.type==="text")return Qc(e,t)}function Uc(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Xn,e.schema=i),e.ancestors.push(t);const s=$s(e,t.tagName,!1),a=Yc(e,t);let l=er(e,t);return Bc.has(t.tagName)&&(l=l.filter(function(o){return typeof o=="string"?!bc(o):!0})),Us(e,a,s,t),Zn(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function $c(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}pt(e,t.position)}function Kc(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pt(e,t.position)}function qc(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Xn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:$s(e,t.name,!0),a=Jc(e,t),l=er(e,t);return Us(e,a,s,t),Zn(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Wc(e,t,n){const r={};return Zn(r,er(e,t)),e.create(t,e.Fragment,r,n)}function Qc(e,t){return t.value}function Us(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Zn(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Gc(e,t,n){return r;function r(i,s,a,l){const u=Array.isArray(a.children)?n:t;return l?u(s,a,l):u(s,a)}}function Xc(e,t){return n;function n(r,i,s,a){const l=Array.isArray(s.children),o=Yn(r);return t(i,s,a,l,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}function Yc(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Jn.call(t.properties,i)){const s=Zc(e,i,t.properties[i]);if(s){const[a,l]=s;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&Vc.has(t.tagName)?r=l:n[a]=l}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Jc(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else pt(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else pt(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function er(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:zc;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const o=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(o){const u=i.get(o)||0;a=o+"-"+u,i.set(o,u+1)}}const l=Hs(e,s,a);l!==void 0&&n.push(l)}return n}function Zc(e,t,n){const r=Ic(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?pc(n):Lc(n)),r.property==="style"){let i=typeof n=="object"?n:ed(e,String(n));return e.stylePropertyNameCase==="css"&&(i=td(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Cc[r.property]||r.property:r.attribute,n]}}function ed(e,t){try{return Fc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new oe("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Vs+"#cannot-parse-style-attribute",i}}function $s(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const l=Fr(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}r=a}else r=Fr(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Jn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);pt(e)}function pt(e,t){const n=new oe("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=Vs+"#cannot-handle-mdx-estrees-without-createevaluater",n}function td(e){const t={};let n;for(n in e)Jn.call(e,n)&&(t[nd(n)]=e[n]);return t}function nd(e){let t=e.replace(_c,rd);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function rd(e){return"-"+e.toLowerCase()}const nn={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"]},id={};function tr(e,t){const n=id,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Ks(e,r,i)}function Ks(e,t,n){if(sd(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 qr(e.children,t,n)}return Array.isArray(e)?qr(e,t,n):""}function qr(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Ks(e[i],t,n);return r.join("")}function sd(e){return!!(e&&typeof e=="object")}const Wr=document.createElement("i");function nr(e){const t="&"+e+";";Wr.innerHTML=t;const n=Wr.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xe(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Se(e,t){return e.length>0?(xe(e,e.length,0,t),e):t}const Qr={}.hasOwnProperty;function qs(e){const t={};let n=-1;for(;++n<e.length;)ad(t,e[n]);return t}function ad(e,t){let n;for(n in t){const i=(Qr.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){Qr.call(i,a)||(i[a]=[]);const l=s[a];ld(i[a],Array.isArray(l)?l:l?[l]:[])}}}function ld(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);xe(e,0,0,r)}function Ws(e,t){const 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 Te(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ce=_e(/[A-Za-z]/),le=_e(/[\dA-Za-z]/),od=_e(/[#-'*+\--9=?A-Z^-~]/);function Rt(e){return e!==null&&(e<32||e===127)}const En=_e(/\d/),ud=_e(/[\dA-Fa-f]/),cd=_e(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function Z(e){return e!==null&&(e<0||e===32)}function W(e){return e===-2||e===-1||e===32}const Bt=_e(new RegExp("\\p{P}|\\p{S}","u")),He=_e(/\s/);function _e(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Je(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&le(e.charCodeAt(n+1))&&le(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(n+1);s<56320&&l>56319&&l<57344?(a=String.fromCharCode(s,l),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function X(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(o){return W(o)?(e.enter(n),l(o)):t(o)}function l(o){return W(o)&&s++<i?(e.consume(o),l):(e.exit(n),t(o))}}const dd={tokenize:hd};function hd(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),X(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),s(l)}function s(l){const o=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=o),n=o,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return z(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),a)}}const fd={tokenize:pd},Gr={tokenize:md};function pd(e){const t=this,n=[];let r=0,i,s,a;return l;function l(N){if(r<n.length){const P=n[r];return t.containerState=P[1],e.attempt(P[0].continuation,o,u)(N)}return u(N)}function o(N){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&I();const P=t.events.length;let F=P,T;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){T=t.events[F][1].end;break}g(r);let O=P;for(;O<t.events.length;)t.events[O][1].end={...T},O++;return xe(t.events,F+1,0,t.events.slice(P)),t.events.length=O,u(N)}return l(N)}function u(N){if(r===n.length){if(!i)return p(N);if(i.currentConstruct&&i.currentConstruct.concrete)return m(N);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Gr,d,c)(N)}function d(N){return i&&I(),g(r),p(N)}function c(N){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(N)}function p(N){return t.containerState={},e.attempt(Gr,f,m)(N)}function f(N){return r++,n.push([t.currentConstruct,t.containerState]),p(N)}function m(N){if(N===null){i&&I(),g(0),e.consume(N);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),x(N)}function x(N){if(N===null){S(e.exit("chunkFlow"),!0),g(0),e.consume(N);return}return z(N)?(e.consume(N),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(N),x)}function S(N,P){const F=t.sliceStream(N);if(P&&F.push(null),N.previous=s,s&&(s.next=N),s=N,i.defineSkip(N.start),i.write(F),t.parser.lazy[N.start.line]){let T=i.events.length;for(;T--;)if(i.events[T][1].start.offset<a&&(!i.events[T][1].end||i.events[T][1].end.offset>a))return;const O=t.events.length;let B=O,U,w;for(;B--;)if(t.events[B][0]==="exit"&&t.events[B][1].type==="chunkFlow"){if(U){w=t.events[B][1].end;break}U=!0}for(g(r),T=O;T<t.events.length;)t.events[T][1].end={...w},T++;xe(t.events,B+1,0,t.events.slice(O)),t.events.length=T}}function g(N){let P=n.length;for(;P-- >N;){const F=n[P];t.containerState=F[1],F[0].exit.call(t,e)}n.length=N}function I(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function md(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Xe(e){if(e===null||Z(e)||He(e))return 1;if(Bt(e))return 2}function Vt(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Ln={name:"attention",resolveAll:gd,tokenize:xd};function gd(e,t){let n=-1,r,i,s,a,l,o,u,d;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;o=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};Xr(c,-o),Xr(p,o),a={type:o>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},l={type:o>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:o>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:o>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Se(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Se(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Se(u,Vt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Se(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Se(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,xe(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function xd(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Xe(r);let s;return a;function a(o){return s=o,e.enter("attentionSequence"),l(o)}function l(o){if(o===s)return e.consume(o),l;const u=e.exit("attentionSequence"),d=Xe(o),c=!d||d===2&&i||n.includes(o),p=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?c:c&&(i||!p)),u._close=!!(s===42?p:p&&(d||!c)),t(o)}}function Xr(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const yd={name:"autolink",tokenize:bd};function bd(e,t,n){let r=0;return i;function i(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(f){return ce(f)?(e.consume(f),a):f===64?n(f):u(f)}function a(f){return f===43||f===45||f===46||le(f)?(r=1,l(f)):u(f)}function l(f){return f===58?(e.consume(f),r=0,o):(f===43||f===45||f===46||le(f))&&r++<32?(e.consume(f),l):(r=0,u(f))}function o(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Rt(f)?n(f):(e.consume(f),o)}function u(f){return f===64?(e.consume(f),d):od(f)?(e.consume(f),u):n(f)}function d(f){return le(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,d):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):p(f)}function p(f){if((f===45||le(f))&&r++<63){const m=f===45?p:c;return e.consume(f),m}return n(f)}}const kt={partial:!0,tokenize:Sd};function Sd(e,t,n){return r;function r(s){return W(s)?X(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||z(s)?t(s):n(s)}}const Qs={continuation:{tokenize:wd},exit:Cd,name:"blockQuote",tokenize:kd};function kd(e,t,n){const r=this;return i;function i(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return W(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function wd(e,t,n){const r=this;return i;function i(a){return W(a)?X(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Qs,t,n)(a)}}function Cd(e){e.exit("blockQuote")}const Gs={name:"characterEscape",tokenize:vd};function vd(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return cd(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Xs={name:"characterReference",tokenize:Td};function Td(e,t,n){const r=this;let i=0,s,a;return l;function l(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),o}function o(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=le,d(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=ud,d):(e.enter("characterReferenceValue"),s=7,a=En,d(c))}function d(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return a===le&&!nr(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(c)&&i++<s?(e.consume(c),d):n(c)}}const Yr={partial:!0,tokenize:Md},Jr={concrete:!0,name:"codeFenced",tokenize:Id};function Id(e,t,n){const r=this,i={partial:!0,tokenize:F};let s=0,a=0,l;return o;function o(T){return u(T)}function u(T){const O=r.events[r.events.length-1];return s=O&&O[1].type==="linePrefix"?O[2].sliceSerialize(O[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(T)}function d(T){return T===l?(a++,e.consume(T),d):a<3?n(T):(e.exit("codeFencedFenceSequence"),W(T)?X(e,c,"whitespace")(T):c(T))}function c(T){return T===null||z(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(Yr,x,P)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(T))}function p(T){return T===null||z(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(T)):W(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),X(e,f,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),p)}function f(T){return T===null||z(T)?c(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(T))}function m(T){return T===null||z(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(T)):T===96&&T===l?n(T):(e.consume(T),m)}function x(T){return e.attempt(i,P,S)(T)}function S(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),g}function g(T){return s>0&&W(T)?X(e,I,"linePrefix",s+1)(T):I(T)}function I(T){return T===null||z(T)?e.check(Yr,x,P)(T):(e.enter("codeFlowValue"),N(T))}function N(T){return T===null||z(T)?(e.exit("codeFlowValue"),I(T)):(e.consume(T),N)}function P(T){return e.exit("codeFenced"),t(T)}function F(T,O,B){let U=0;return w;function w(C){return T.enter("lineEnding"),T.consume(C),T.exit("lineEnding"),R}function R(C){return T.enter("codeFencedFence"),W(C)?X(T,E,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):E(C)}function E(C){return C===l?(T.enter("codeFencedFenceSequence"),V(C)):B(C)}function V(C){return C===l?(U++,T.consume(C),V):U>=a?(T.exit("codeFencedFenceSequence"),W(C)?X(T,j,"whitespace")(C):j(C)):B(C)}function j(C){return C===null||z(C)?(T.exit("codeFencedFence"),O(C)):B(C)}}}function Md(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const rn={name:"codeIndented",tokenize:Ed},Nd={partial:!0,tokenize:Ld};function Ed(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),X(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?o(u):z(u)?e.attempt(Nd,a,o)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||z(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function o(u){return e.exit("codeIndented"),t(u)}}function Ld(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):z(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):X(e,s,"linePrefix",5)(a)}function s(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):z(a)?i(a):n(a)}}const Ad={name:"codeText",previous:jd,resolve:Rd,tokenize:Pd};function Rd(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 jd(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Pd(e,t,n){let r=0,i,s;return a;function a(c){return e.enter("codeText"),e.enter("codeTextSequence"),l(c)}function l(c){return c===96?(e.consume(c),r++,l):(e.exit("codeTextSequence"),o(c))}function o(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),o):c===96?(s=e.enter("codeTextSequence"),i=0,d(c)):z(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||z(c)?(e.exit("codeTextData"),o(c)):(e.consume(c),u)}function d(c){return c===96?(e.consume(c),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(s.type="codeTextData",u(c))}}class Dd{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&st(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),st(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),st(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);st(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);st(this.left,n.reverse())}}}function st(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 Ys(e){const t={};let n=-1,r,i,s,a,l,o,u;const d=new Dd(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(o=r[1]._tokenizer.events,s=0,s<o.length&&o[s][1].type==="lineEndingBlank"&&(s+=2),s<o.length&&o[s][1].type==="content"))for(;++s<o.length&&o[s][1].type!=="content";)o[s][1].type==="chunkText"&&(o[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Fd(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=d.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},l=d.slice(i,n),l.unshift(r),d.splice(i,n-i+1,l))}}return xe(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Fd(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,o=[],u={};let d,c,p=-1,f=n,m=0,x=0;const S=[x];for(;f;){for(;e.get(++i)[1]!==f;);s.push(i),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),c&&a.defineSkip(f.start),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(x=p+1,S.push(x),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(a.events=[],f?(f._tokenizer=void 0,f.previous=void 0):S.pop(),p=S.length;p--;){const g=l.slice(S[p],S[p+1]),I=s.pop();o.push([I,I+g.length-1]),e.splice(I,2,g)}for(o.reverse(),p=-1;++p<o.length;)u[m+o[p][0]]=m+o[p][1],m+=o[p][1]-o[p][0]-1;return u}const Od={resolve:_d,tokenize:Bd},zd={partial:!0,tokenize:Vd};function _d(e){return Ys(e),e}function Bd(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):z(l)?e.check(zd,a,s)(l):(e.consume(l),i)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Vd(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),X(e,s,"linePrefix")}function s(a){if(a===null||z(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Js(e,t,n,r,i,s,a,l,o){const u=o||Number.POSITIVE_INFINITY;let d=0;return c;function c(g){return g===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(g),e.exit(s),p):g===null||g===32||g===41||Rt(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),x(g))}function p(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(g))}function f(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||z(g)?n(g):(e.consume(g),g===92?m:f)}function m(g){return g===60||g===62||g===92?(e.consume(g),f):f(g)}function x(g){return!d&&(g===null||g===41||Z(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):d<u&&g===40?(e.consume(g),d++,x):g===41?(e.consume(g),d--,x):g===null||g===32||g===40||Rt(g)?n(g):(e.consume(g),g===92?S:x)}function S(g){return g===40||g===41||g===92?(e.consume(g),x):x(g)}}function Zs(e,t,n,r,i,s){const a=this;let l=0,o;return u;function u(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(s),d}function d(f){return l>999||f===null||f===91||f===93&&!o||f===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(f):f===93?(e.exit(s),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):z(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),c(f))}function c(f){return f===null||f===91||f===93||z(f)||l++>999?(e.exit("chunkString"),d(f)):(e.consume(f),o||(o=!W(f)),f===92?p:c)}function p(f){return f===91||f===92||f===93?(e.consume(f),l++,c):c(f)}}function ea(e,t,n,r,i,s){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,o):n(p)}function o(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===a?(e.exit(s),o(a)):p===null?n(p):z(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),X(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||z(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?c:d)}function c(p){return p===a||p===92?(e.consume(p),d):d(p)}}function dt(e,t){let n;return r;function r(i){return z(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):W(i)?X(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Hd={name:"definition",tokenize:$d},Ud={partial:!0,tokenize:Kd};function $d(e,t,n){const r=this;let i;return s;function s(f){return e.enter("definition"),a(f)}function a(f){return Zs.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=Te(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),o):n(f)}function o(f){return Z(f)?dt(e,u)(f):u(f)}function u(f){return Js(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function d(f){return e.attempt(Ud,c,c)(f)}function c(f){return W(f)?X(e,p,"whitespace")(f):p(f)}function p(f){return f===null||z(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function Kd(e,t,n){return r;function r(l){return Z(l)?dt(e,i)(l):n(l)}function i(l){return ea(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return W(l)?X(e,a,"whitespace")(l):a(l)}function a(l){return l===null||z(l)?t(l):n(l)}}const qd={name:"hardBreakEscape",tokenize:Wd};function Wd(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return z(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Qd={name:"headingAtx",resolve:Gd,tokenize:Xd};function Gd(e,t){let n=e.length-2,r=3,i,s;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},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},xe(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Xd(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||Z(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),o(d)):d===null||z(d)?(e.exit("atxHeading"),t(d)):W(d)?X(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function o(d){return d===35?(e.consume(d),o):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||Z(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const Yd=["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"],Zr=["pre","script","style","textarea"],Jd={concrete:!0,name:"htmlFlow",resolveTo:th,tokenize:nh},Zd={partial:!0,tokenize:ih},eh={partial:!0,tokenize:rh};function th(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 nh(e,t,n){const r=this;let i,s,a,l,o;return u;function u(b){return d(b)}function d(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),c}function c(b){return b===33?(e.consume(b),p):b===47?(e.consume(b),s=!0,x):b===63?(e.consume(b),i=3,r.interrupt?t:y):ce(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function p(b){return b===45?(e.consume(b),i=2,f):b===91?(e.consume(b),i=5,l=0,m):ce(b)?(e.consume(b),i=4,r.interrupt?t:y):n(b)}function f(b){return b===45?(e.consume(b),r.interrupt?t:y):n(b)}function m(b){const de="CDATA[";return b===de.charCodeAt(l++)?(e.consume(b),l===de.length?r.interrupt?t:E:m):n(b)}function x(b){return ce(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||Z(b)){const de=b===47,Ie=a.toLowerCase();return!de&&!s&&Zr.includes(Ie)?(i=1,r.interrupt?t(b):E(b)):Yd.includes(a.toLowerCase())?(i=6,de?(e.consume(b),g):r.interrupt?t(b):E(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?I(b):N(b))}return b===45||le(b)?(e.consume(b),a+=String.fromCharCode(b),S):n(b)}function g(b){return b===62?(e.consume(b),r.interrupt?t:E):n(b)}function I(b){return W(b)?(e.consume(b),I):w(b)}function N(b){return b===47?(e.consume(b),w):b===58||b===95||ce(b)?(e.consume(b),P):W(b)?(e.consume(b),N):w(b)}function P(b){return b===45||b===46||b===58||b===95||le(b)?(e.consume(b),P):F(b)}function F(b){return b===61?(e.consume(b),T):W(b)?(e.consume(b),F):N(b)}function T(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),o=b,O):W(b)?(e.consume(b),T):B(b)}function O(b){return b===o?(e.consume(b),o=null,U):b===null||z(b)?n(b):(e.consume(b),O)}function B(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Z(b)?F(b):(e.consume(b),B)}function U(b){return b===47||b===62||W(b)?N(b):n(b)}function w(b){return b===62?(e.consume(b),R):n(b)}function R(b){return b===null||z(b)?E(b):W(b)?(e.consume(b),R):n(b)}function E(b){return b===45&&i===2?(e.consume(b),D):b===60&&i===1?(e.consume(b),Q):b===62&&i===4?(e.consume(b),se):b===63&&i===3?(e.consume(b),y):b===93&&i===5?(e.consume(b),ue):z(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Zd,ye,V)(b)):b===null||z(b)?(e.exit("htmlFlowData"),V(b)):(e.consume(b),E)}function V(b){return e.check(eh,j,ye)(b)}function j(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),C}function C(b){return b===null||z(b)?V(b):(e.enter("htmlFlowData"),E(b))}function D(b){return b===45?(e.consume(b),y):E(b)}function Q(b){return b===47?(e.consume(b),a="",_):E(b)}function _(b){if(b===62){const de=a.toLowerCase();return Zr.includes(de)?(e.consume(b),se):E(b)}return ce(b)&&a.length<8?(e.consume(b),a+=String.fromCharCode(b),_):E(b)}function ue(b){return b===93?(e.consume(b),y):E(b)}function y(b){return b===62?(e.consume(b),se):b===45&&i===2?(e.consume(b),y):E(b)}function se(b){return b===null||z(b)?(e.exit("htmlFlowData"),ye(b)):(e.consume(b),se)}function ye(b){return e.exit("htmlFlow"),t(b)}}function rh(e,t,n){const r=this;return i;function i(a){return z(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function ih(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(kt,t,n)}}const sh={name:"htmlText",tokenize:ah};function ah(e,t,n){const r=this;let i,s,a;return l;function l(y){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(y),o}function o(y){return y===33?(e.consume(y),u):y===47?(e.consume(y),F):y===63?(e.consume(y),N):ce(y)?(e.consume(y),B):n(y)}function u(y){return y===45?(e.consume(y),d):y===91?(e.consume(y),s=0,m):ce(y)?(e.consume(y),I):n(y)}function d(y){return y===45?(e.consume(y),f):n(y)}function c(y){return y===null?n(y):y===45?(e.consume(y),p):z(y)?(a=c,Q(y)):(e.consume(y),c)}function p(y){return y===45?(e.consume(y),f):c(y)}function f(y){return y===62?D(y):y===45?p(y):c(y)}function m(y){const se="CDATA[";return y===se.charCodeAt(s++)?(e.consume(y),s===se.length?x:m):n(y)}function x(y){return y===null?n(y):y===93?(e.consume(y),S):z(y)?(a=x,Q(y)):(e.consume(y),x)}function S(y){return y===93?(e.consume(y),g):x(y)}function g(y){return y===62?D(y):y===93?(e.consume(y),g):x(y)}function I(y){return y===null||y===62?D(y):z(y)?(a=I,Q(y)):(e.consume(y),I)}function N(y){return y===null?n(y):y===63?(e.consume(y),P):z(y)?(a=N,Q(y)):(e.consume(y),N)}function P(y){return y===62?D(y):N(y)}function F(y){return ce(y)?(e.consume(y),T):n(y)}function T(y){return y===45||le(y)?(e.consume(y),T):O(y)}function O(y){return z(y)?(a=O,Q(y)):W(y)?(e.consume(y),O):D(y)}function B(y){return y===45||le(y)?(e.consume(y),B):y===47||y===62||Z(y)?U(y):n(y)}function U(y){return y===47?(e.consume(y),D):y===58||y===95||ce(y)?(e.consume(y),w):z(y)?(a=U,Q(y)):W(y)?(e.consume(y),U):D(y)}function w(y){return y===45||y===46||y===58||y===95||le(y)?(e.consume(y),w):R(y)}function R(y){return y===61?(e.consume(y),E):z(y)?(a=R,Q(y)):W(y)?(e.consume(y),R):U(y)}function E(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),i=y,V):z(y)?(a=E,Q(y)):W(y)?(e.consume(y),E):(e.consume(y),j)}function V(y){return y===i?(e.consume(y),i=void 0,C):y===null?n(y):z(y)?(a=V,Q(y)):(e.consume(y),V)}function j(y){return y===null||y===34||y===39||y===60||y===61||y===96?n(y):y===47||y===62||Z(y)?U(y):(e.consume(y),j)}function C(y){return y===47||y===62||Z(y)?U(y):n(y)}function D(y){return y===62?(e.consume(y),e.exit("htmlTextData"),e.exit("htmlText"),t):n(y)}function Q(y){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),_}function _(y){return W(y)?X(e,ue,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(y):ue(y)}function ue(y){return e.enter("htmlTextData"),a(y)}}const rr={name:"labelEnd",resolveAll:ch,resolveTo:dh,tokenize:hh},lh={tokenize:fh},oh={tokenize:ph},uh={tokenize:mh};function ch(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&xe(e,0,e.length,n),e}function dh(e,t){let n=e.length,r=0,i,s,a,l;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const o={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",o,t],["enter",u,t]],l=Se(l,e.slice(s+1,s+r+3)),l=Se(l,[["enter",d,t]]),l=Se(l,Vt(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),l=Se(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=Se(l,e.slice(a+1)),l=Se(l,[["exit",o,t]]),xe(e,s,e.length,l),e}function hh(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return l;function l(p){return s?s._inactive?c(p):(a=r.parser.defined.includes(Te(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),o):n(p)}function o(p){return p===40?e.attempt(lh,d,a?d:c)(p):p===91?e.attempt(oh,d,a?u:c)(p):a?d(p):c(p)}function u(p){return e.attempt(uh,d,c)(p)}function d(p){return t(p)}function c(p){return s._balanced=!0,n(p)}}function fh(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return Z(c)?dt(e,s)(c):s(c)}function s(c){return c===41?d(c):Js(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return Z(c)?dt(e,o)(c):d(c)}function l(c){return n(c)}function o(c){return c===34||c===39||c===40?ea(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):d(c)}function u(c){return Z(c)?dt(e,d)(c):d(c)}function d(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function ph(e,t,n){const r=this;return i;function i(l){return Zs.call(r,e,s,a,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(Te(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function mh(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const gh={name:"labelStartImage",resolveAll:rr.resolveAll,tokenize:xh};function xh(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const yh={name:"labelStartLink",resolveAll:rr.resolveAll,tokenize:bh};function bh(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const sn={name:"lineEnding",tokenize:Sh};function Sh(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),X(e,t,"linePrefix")}}const Lt={name:"thematicBreak",tokenize:kh};function kh(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,l(u)}function l(u){return u===i?(e.enter("thematicBreakSequence"),o(u)):r>=3&&(u===null||z(u))?(e.exit("thematicBreak"),t(u)):n(u)}function o(u){return u===i?(e.consume(u),r++,o):(e.exit("thematicBreakSequence"),W(u)?X(e,l,"whitespace")(u):l(u))}}const he={continuation:{tokenize:Th},exit:Mh,name:"list",tokenize:vh},wh={partial:!0,tokenize:Nh},Ch={partial:!0,tokenize:Ih};function vh(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(f){const m=r.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||f===r.containerState.marker:En(f)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(Lt,n,u)(f):u(f);if(!r.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(f)}return n(f)}function o(f){return En(f)&&++a<10?(e.consume(f),o):(!r.interrupt||a<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),u(f)):n(f)}function u(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||f,e.check(kt,r.interrupt?n:d,e.attempt(wh,p,c))}function d(f){return r.containerState.initialBlankLine=!0,s++,p(f)}function c(f){return W(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),p):n(f)}function p(f){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function Th(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(kt,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!W(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ch,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(he,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Ih(e,t,n){const r=this;return X(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function Mh(e){e.exit(this.containerState.type)}function Nh(e,t,n){const r=this;return X(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!W(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ei={name:"setextUnderline",resolveTo:Eh,tokenize:Lh};function Eh(e,t){let n=e.length,r,i,s;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),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function Lh(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,c;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){c=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),W(u)?X(e,o,"lineSuffix")(u):o(u))}function o(u){return u===null||z(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Ah={tokenize:Rh};function Rh(e){const t=this,n=e.attempt(kt,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Od,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const jh={resolveAll:na()},Ph=ta("string"),Dh=ta("text");function ta(e){return{resolveAll:na(e==="text"?Fh:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,l);return a;function a(d){return u(d)?s(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),o}function o(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),o)}function u(d){if(d===null)return!0;const c=i[d];let p=-1;if(c)for(;++p<c.length;){const f=c[p];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function na(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Fh(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,l=0,o;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)o=!0,l++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||o||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Oh={42:he,43:he,45:he,48:he,49:he,50:he,51:he,52:he,53:he,54:he,55:he,56:he,57:he,62:Qs},zh={91:Hd},_h={[-2]:rn,[-1]:rn,32:rn},Bh={35:Qd,42:Lt,45:[ei,Lt],60:Jd,61:ei,95:Lt,96:Jr,126:Jr},Vh={38:Xs,92:Gs},Hh={[-5]:sn,[-4]:sn,[-3]:sn,33:gh,38:Xs,42:Ln,60:[yd,sh],91:yh,92:[qd,Gs],93:rr,95:Ln,96:Ad},Uh={null:[Ln,jh]},$h={null:[42,95]},Kh={null:[]},qh=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:$h,contentInitial:zh,disable:Kh,document:Oh,flow:Bh,flowInitial:_h,insideSpan:Uh,string:Vh,text:Hh},Symbol.toStringTag,{value:"Module"}));function Wh(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],l=[];const o={attempt:O(F),check:O(T),consume:I,enter:N,exit:P,interrupt:O(T,{interrupt:!0})},u={code:null,containerState:{},defineSkip:x,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:f,write:c};let d=t.tokenize.call(u,o);return t.resolveAll&&s.push(t),u;function c(R){return a=Se(a,R),S(),a[a.length-1]!==null?[]:(B(t,0),u.events=Vt(s,u.events,u),u.events)}function p(R,E){return Gh(f(R),E)}function f(R){return Qh(a,R)}function m(){const{_bufferIndex:R,_index:E,line:V,column:j,offset:C}=r;return{_bufferIndex:R,_index:E,line:V,column:j,offset:C}}function x(R){i[R.line]=R.column,w()}function S(){let R;for(;r._index<a.length;){const E=a[r._index];if(typeof E=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<E.length;)g(E.charCodeAt(r._bufferIndex));else g(E)}}function g(R){d=d(R)}function I(R){z(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,w()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=R}function N(R,E){const V=E||{};return V.type=R,V.start=m(),u.events.push(["enter",V,u]),l.push(V),V}function P(R){const E=l.pop();return E.end=m(),u.events.push(["exit",E,u]),E}function F(R,E){B(R,E.from)}function T(R,E){E.restore()}function O(R,E){return V;function V(j,C,D){let Q,_,ue,y;return Array.isArray(j)?ye(j):"tokenize"in j?ye([j]):se(j);function se(re){return De;function De(we){const H=we!==null&&re[we],ae=we!==null&&re.null,be=[...Array.isArray(H)?H:H?[H]:[],...Array.isArray(ae)?ae:ae?[ae]:[]];return ye(be)(we)}}function ye(re){return Q=re,_=0,re.length===0?D:b(re[_])}function b(re){return De;function De(we){return y=U(),ue=re,re.partial||(u.currentConstruct=re),re.name&&u.parser.constructs.disable.null.includes(re.name)?Ie():re.tokenize.call(E?Object.assign(Object.create(u),E):u,o,de,Ie)(we)}}function de(re){return R(ue,y),C}function Ie(re){return y.restore(),++_<Q.length?b(Q[_]):D}}}function B(R,E){R.resolveAll&&!s.includes(R)&&s.push(R),R.resolve&&xe(u.events,E,u.events.length-E,R.resolve(u.events.slice(E),u)),R.resolveTo&&(u.events=R.resolveTo(u.events,u))}function U(){const R=m(),E=u.previous,V=u.currentConstruct,j=u.events.length,C=Array.from(l);return{from:j,restore:D};function D(){r=R,u.previous=E,u.currentConstruct=V,u.events.length=j,l=C,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Qh(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Gh(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
5
+ `;break}case-3:{a=`\r
6
+ `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Xh(e){const r={constructs:qs([qh,...(e||{}).extensions||[]]),content:i(dd),defined:[],document:i(fd),flow:i(Ah),lazy:{},string:i(Ph),text:i(Dh)};return r;function i(s){return a;function a(l){return Wh(r,s,l)}}}function Yh(e){for(;!Ys(e););return e}const ti=/[\0\t\n\r]/g;function Jh(){let e=1,t="",n=!0,r;return i;function i(s,a,l){const o=[];let u,d,c,p,f;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),c=0,t="",n&&(s.charCodeAt(0)===65279&&c++,n=void 0);c<s.length;){if(ti.lastIndex=c,u=ti.exec(s),p=u&&u.index!==void 0?u.index:s.length,f=s.charCodeAt(p),!u){t=s.slice(c);break}if(f===10&&c===p&&r)o.push(-3),r=void 0;else switch(r&&(o.push(-5),r=void 0),c<p&&(o.push(s.slice(c,p)),e+=p-c),f){case 0:{o.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,o.push(-2);e++<d;)o.push(-1);break}case 10:{o.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return l&&(r&&o.push(-5),t&&o.push(t),o.push(null)),o}}const Zh=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ef(e){return e.replace(Zh,tf)}function tf(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Ws(n.slice(s?2:1),s?16:10)}return nr(n)||e}const ra={}.hasOwnProperty;function nf(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),rf(n)(Yh(Xh(n).document().write(Jh()(e,t,!0))))}function rf(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(mr),autolinkProtocol:U,autolinkEmail:U,atxHeading:s(Ze),blockQuote:s(ae),characterEscape:U,characterReference:U,codeFenced:s(be),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(be,a),codeText:s(Fe,a),codeTextData:U,data:U,codeFlowValue:U,definition:s(Le),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(Qt),hardBreakEscape:s(fr),hardBreakTrailing:s(fr),htmlFlow:s(pr,a),htmlFlowData:U,htmlText:s(pr,a),htmlTextData:U,image:s($a),label:a,link:s(mr),listItem:s(Ka),listItemValue:p,listOrdered:s(gr,c),listUnordered:s(gr),paragraph:s(qa),reference:b,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Ze),strong:s(Wa),thematicBreak:s(Ga)},exit:{atxHeading:o(),atxHeadingSequence:F,autolink:o(),autolinkEmail:H,autolinkProtocol:we,blockQuote:o(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:Ie,characterReferenceMarkerNumeric:Ie,characterReferenceValue:re,characterReference:De,codeFenced:o(S),codeFencedFence:x,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:o(g),codeText:o(C),codeTextData:w,data:w,definition:o(),definitionDestinationString:P,definitionLabelString:I,definitionTitleString:N,emphasis:o(),hardBreakEscape:o(E),hardBreakTrailing:o(E),htmlFlow:o(V),htmlFlowData:w,htmlText:o(j),htmlTextData:w,image:o(Q),label:ue,labelText:_,lineEnding:R,link:o(D),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:de,resourceDestinationString:y,resourceTitleString:se,resource:ye,setextHeading:o(B),setextHeadingLineSequence:O,setextHeadingText:T,strong:o(),thematicBreak:o()}};ia(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(M){let A={type:"root",children:[]};const $={stack:[A],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:d,data:n},G=[];let Y=-1;for(;++Y<M.length;)if(M[Y][1].type==="listOrdered"||M[Y][1].type==="listUnordered")if(M[Y][0]==="enter")G.push(Y);else{const Ce=G.pop();Y=i(M,Ce,Y)}for(Y=-1;++Y<M.length;){const Ce=t[M[Y][0]];ra.call(Ce,M[Y][1].type)&&Ce[M[Y][1].type].call(Object.assign({sliceSerialize:M[Y][2].sliceSerialize},$),M[Y][1])}if($.tokenStack.length>0){const Ce=$.tokenStack[$.tokenStack.length-1];(Ce[1]||ni).call($,void 0,Ce[0])}for(A.position={start:Oe(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Oe(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},Y=-1;++Y<t.transforms.length;)A=t.transforms[Y](A)||A;return A}function i(M,A,$){let G=A-1,Y=-1,Ce=!1,Be,Ae,et,tt;for(;++G<=$;){const me=M[G];switch(me[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{me[0]==="enter"?Y++:Y--,tt=void 0;break}case"lineEndingBlank":{me[0]==="enter"&&(Be&&!tt&&!Y&&!et&&(et=G),tt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tt=void 0}if(!Y&&me[0]==="enter"&&me[1].type==="listItemPrefix"||Y===-1&&me[0]==="exit"&&(me[1].type==="listUnordered"||me[1].type==="listOrdered")){if(Be){let $e=G;for(Ae=void 0;$e--;){const Re=M[$e];if(Re[1].type==="lineEnding"||Re[1].type==="lineEndingBlank"){if(Re[0]==="exit")continue;Ae&&(M[Ae][1].type="lineEndingBlank",Ce=!0),Re[1].type="lineEnding",Ae=$e}else if(!(Re[1].type==="linePrefix"||Re[1].type==="blockQuotePrefix"||Re[1].type==="blockQuotePrefixWhitespace"||Re[1].type==="blockQuoteMarker"||Re[1].type==="listItemIndent"))break}et&&(!Ae||et<Ae)&&(Be._spread=!0),Be.end=Object.assign({},Ae?M[Ae][1].start:me[1].end),M.splice(Ae||G,0,["exit",Be,me[2]]),G++,$++}if(me[1].type==="listItemPrefix"){const $e={type:"listItem",_spread:!1,start:Object.assign({},me[1].start),end:void 0};Be=$e,M.splice(G,0,["enter",$e,me[2]]),G++,$++,et=void 0,tt=!0}}}return M[A][1]._spread=Ce,$}function s(M,A){return $;function $(G){l.call(this,M(G),G),A&&A.call(this,G)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(M,A,$){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([A,$||void 0]),M.position={start:Oe(A.start),end:void 0}}function o(M){return A;function A($){M&&M.call(this,$),u.call(this,$)}}function u(M,A){const $=this.stack.pop(),G=this.tokenStack.pop();if(G)G[0].type!==M.type&&(A?A.call(this,M,G[0]):(G[1]||ni).call(this,M,G[0]));else throw new Error("Cannot close `"+M.type+"` ("+ct({start:M.start,end:M.end})+"): it’s not open");$.position.end=Oe(M.end)}function d(){return tr(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(M){if(this.data.expectingFirstListItemValue){const A=this.stack[this.stack.length-2];A.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function f(){const M=this.resume(),A=this.stack[this.stack.length-1];A.lang=M}function m(){const M=this.resume(),A=this.stack[this.stack.length-1];A.meta=M}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const M=this.resume(),A=this.stack[this.stack.length-1];A.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const M=this.resume(),A=this.stack[this.stack.length-1];A.value=M.replace(/(\r?\n|\r)$/g,"")}function I(M){const A=this.resume(),$=this.stack[this.stack.length-1];$.label=A,$.identifier=Te(this.sliceSerialize(M)).toLowerCase()}function N(){const M=this.resume(),A=this.stack[this.stack.length-1];A.title=M}function P(){const M=this.resume(),A=this.stack[this.stack.length-1];A.url=M}function F(M){const A=this.stack[this.stack.length-1];if(!A.depth){const $=this.sliceSerialize(M).length;A.depth=$}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function O(M){const A=this.stack[this.stack.length-1];A.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function B(){this.data.setextHeadingSlurpLineEnding=void 0}function U(M){const $=this.stack[this.stack.length-1].children;let G=$[$.length-1];(!G||G.type!=="text")&&(G=Qa(),G.position={start:Oe(M.start),end:void 0},$.push(G)),this.stack.push(G)}function w(M){const A=this.stack.pop();A.value+=this.sliceSerialize(M),A.position.end=Oe(M.end)}function R(M){const A=this.stack[this.stack.length-1];if(this.data.atHardBreak){const $=A.children[A.children.length-1];$.position.end=Oe(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(A.type)&&(U.call(this,M),w.call(this,M))}function E(){this.data.atHardBreak=!0}function V(){const M=this.resume(),A=this.stack[this.stack.length-1];A.value=M}function j(){const M=this.resume(),A=this.stack[this.stack.length-1];A.value=M}function C(){const M=this.resume(),A=this.stack[this.stack.length-1];A.value=M}function D(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const A=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=A,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function Q(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const A=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=A,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function _(M){const A=this.sliceSerialize(M),$=this.stack[this.stack.length-2];$.label=ef(A),$.identifier=Te(A).toLowerCase()}function ue(){const M=this.stack[this.stack.length-1],A=this.resume(),$=this.stack[this.stack.length-1];if(this.data.inReference=!0,$.type==="link"){const G=M.children;$.children=G}else $.alt=A}function y(){const M=this.resume(),A=this.stack[this.stack.length-1];A.url=M}function se(){const M=this.resume(),A=this.stack[this.stack.length-1];A.title=M}function ye(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function de(M){const A=this.resume(),$=this.stack[this.stack.length-1];$.label=A,$.identifier=Te(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function Ie(M){this.data.characterReferenceType=M.type}function re(M){const A=this.sliceSerialize(M),$=this.data.characterReferenceType;let G;$?(G=Ws(A,$==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):G=nr(A);const Y=this.stack[this.stack.length-1];Y.value+=G}function De(M){const A=this.stack.pop();A.position.end=Oe(M.end)}function we(M){w.call(this,M);const A=this.stack[this.stack.length-1];A.url=this.sliceSerialize(M)}function H(M){w.call(this,M);const A=this.stack[this.stack.length-1];A.url="mailto:"+this.sliceSerialize(M)}function ae(){return{type:"blockquote",children:[]}}function be(){return{type:"code",lang:null,meta:null,value:""}}function Fe(){return{type:"inlineCode",value:""}}function Le(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Qt(){return{type:"emphasis",children:[]}}function Ze(){return{type:"heading",depth:0,children:[]}}function fr(){return{type:"break"}}function pr(){return{type:"html",value:""}}function $a(){return{type:"image",title:null,url:"",alt:null}}function mr(){return{type:"link",title:null,url:"",children:[]}}function gr(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Ka(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function qa(){return{type:"paragraph",children:[]}}function Wa(){return{type:"strong",children:[]}}function Qa(){return{type:"text",value:""}}function Ga(){return{type:"thematicBreak"}}}function Oe(e){return{line:e.line,column:e.column,offset:e.offset}}function ia(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ia(e,r):sf(e,r)}}function sf(e,t){let n;for(n in t)if(ra.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function ni(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ct({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ct({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ct({start:t.start,end:t.end})+") is still open")}function af(e){const t=this;t.parser=n;function n(r){return nf(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function lf(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function of(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
7
+ `}]}function uf(e,t){const n=t.value?t.value+`
8
+ `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function cf(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function df(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hf(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Je(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,l+=1,e.footnoteCounts.set(r,l);const o={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,o);const u={type:"element",tagName:"sup",properties:{},children:[o]};return e.patch(t,u),e.applyData(t,u)}function ff(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pf(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function sa(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function mf(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return sa(e,t);const i={src:Je(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function gf(e,t){const n={src:Je(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function xf(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function yf(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return sa(e,t);const i={href:Je(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function bf(e,t){const n={href:Je(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Sf(e,t,n){const r=e.all(t),i=n?kf(n):aa(t),s={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let c;d&&d.type==="element"&&d.tagName==="p"?c=d:(c={type:"element",tagName:"p",properties:{},children:[]},r.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const d=r[l];(i||l!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
9
+ `}),d.type==="element"&&d.tagName==="p"&&!i?a.push(...d.children):a.push(d)}const o=r[r.length-1];o&&(i||o.type!=="element"||o.tagName!=="p")&&a.push({type:"text",value:`
10
+ `});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function kf(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=aa(n[r])}return t}function aa(e){const t=e.spread;return t??e.children.length>1}function wf(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function Cf(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vf(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Tf(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function If(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Yn(t.children[1]),o=_s(t.children[t.children.length-1]);l&&o&&(a.position={start:l,end:o}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Mf(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let o=-1;const u=[];for(;++o<l;){const c=t.children[o],p={},f=a?a[o]:void 0;f&&(p.align=f);let m={type:"element",tagName:s,properties:p,children:[]};c&&(m.children=e.all(c),e.patch(c,m),m=e.applyData(c,m)),u.push(m)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function Nf(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const ri=9,ii=32;function Ef(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(si(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(si(t.slice(i),i>0,!1)),s.join("")}function si(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===ri||s===ii;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===ri||s===ii;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Lf(e,t){const n={type:"text",value:Ef(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Af(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Rf={blockquote:lf,break:of,code:uf,delete:cf,emphasis:df,footnoteReference:hf,heading:ff,html:pf,imageReference:mf,image:gf,inlineCode:xf,linkReference:yf,link:bf,listItem:Sf,list:wf,paragraph:Cf,root:vf,strong:Tf,table:If,tableCell:Nf,tableRow:Mf,text:Lf,thematicBreak:Af,toml:Ct,yaml:Ct,definition:Ct,footnoteDefinition:Ct};function Ct(){}const la=-1,Ht=0,ht=1,jt=2,ir=3,sr=4,ar=5,lr=6,oa=7,ua=8,ai=typeof self=="object"?self:globalThis,jf=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case Ht:case la:return n(a,i);case ht:{const l=n([],i);for(const o of a)l.push(r(o));return l}case jt:{const l=n({},i);for(const[o,u]of a)l[r(o)]=r(u);return l}case ir:return n(new Date(a),i);case sr:{const{source:l,flags:o}=a;return n(new RegExp(l,o),i)}case ar:{const l=n(new Map,i);for(const[o,u]of a)l.set(r(o),r(u));return l}case lr:{const l=n(new Set,i);for(const o of a)l.add(r(o));return l}case oa:{const{name:l,message:o}=a;return n(new ai[l](o),i)}case ua:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new ai[s](a),i)};return r},li=e=>jf(new Map,e)(0),qe="",{toString:Pf}={},{keys:Df}=Object,at=e=>{const t=typeof e;if(t!=="object"||!e)return[Ht,t];const n=Pf.call(e).slice(8,-1);switch(n){case"Array":return[ht,qe];case"Object":return[jt,qe];case"Date":return[ir,qe];case"RegExp":return[sr,qe];case"Map":return[ar,qe];case"Set":return[lr,qe];case"DataView":return[ht,n]}return n.includes("Array")?[ht,n]:n.includes("Error")?[oa,n]:[jt,n]},vt=([e,t])=>e===Ht&&(t==="function"||t==="symbol"),Ff=(e,t,n,r)=>{const i=(a,l)=>{const o=r.push(a)-1;return n.set(l,o),o},s=a=>{if(n.has(a))return n.get(a);let[l,o]=at(a);switch(l){case Ht:{let d=a;switch(o){case"bigint":l=ua,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);d=null;break;case"undefined":return i([la],a)}return i([l,d],a)}case ht:{if(o){let p=a;return o==="DataView"?p=new Uint8Array(a.buffer):o==="ArrayBuffer"&&(p=new Uint8Array(a)),i([o,[...p]],a)}const d=[],c=i([l,d],a);for(const p of a)d.push(s(p));return c}case jt:{if(o)switch(o){case"BigInt":return i([o,a.toString()],a);case"Boolean":case"Number":case"String":return i([o,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const d=[],c=i([l,d],a);for(const p of Df(a))(e||!vt(at(a[p])))&&d.push([s(p),s(a[p])]);return c}case ir:return i([l,a.toISOString()],a);case sr:{const{source:d,flags:c}=a;return i([l,{source:d,flags:c}],a)}case ar:{const d=[],c=i([l,d],a);for(const[p,f]of a)(e||!(vt(at(p))||vt(at(f))))&&d.push([s(p),s(f)]);return c}case lr:{const d=[],c=i([l,d],a);for(const p of a)(e||!vt(at(p)))&&d.push(s(p));return c}}const{message:u}=a;return i([l,{name:o,message:u}],a)};return s},oi=(e,{json:t,lossy:n}={})=>{const r=[];return Ff(!(t||n),!!t,new Map,r)(e),r},Pt=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?li(oi(e,t)):structuredClone(e):(e,t)=>li(oi(e,t));function Of(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function zf(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function _f(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Of,r=e.options.footnoteBackLabel||zf,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let o=-1;for(;++o<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[o]);if(!u)continue;const d=e.all(u),c=String(u.identifier).toUpperCase(),p=Je(c.toLowerCase());let f=0;const m=[],x=e.footnoteCounts.get(c);for(;x!==void 0&&++f<=x;){m.length>0&&m.push({type:"text",value:" "});let I=typeof n=="string"?n:n(o,f);typeof I=="string"&&(I={type:"text",value:I}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(f>1?"-"+f:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(o,f),className:["data-footnote-backref"]},children:Array.isArray(I)?I:[I]})}const S=d[d.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const I=S.children[S.children.length-1];I&&I.type==="text"?I.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else d.push(...m);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Pt(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
11
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
12
+ `}]}}const Ut=(function(e){if(e==null)return Uf;if(typeof e=="function")return $t(e);if(typeof e=="object")return Array.isArray(e)?Bf(e):Vf(e);if(typeof e=="string")return Hf(e);throw new Error("Expected function, string, or object as test")});function Bf(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ut(e[n]);return $t(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Vf(e){const t=e;return $t(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Hf(e){return $t(t);function t(n){return n&&n.type===e}}function $t(e){return t;function t(n,r,i){return!!($f(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Uf(){return!0}function $f(e){return e!==null&&typeof e=="object"&&"type"in e}const ca=[],Kf=!0,An=!1,qf="skip";function da(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Ut(i),a=r?-1:1;l(e,void 0,[])();function l(o,u,d){const c=o&&typeof o=="object"?o:{};if(typeof c.type=="string"){const f=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(o.type+(f?"<"+f+">":""))+")"})}return p;function p(){let f=ca,m,x,S;if((!t||s(o,u,d[d.length-1]||void 0))&&(f=Wf(n(o,d)),f[0]===An))return f;if("children"in o&&o.children){const g=o;if(g.children&&f[0]!==qf)for(x=(r?g.children.length:-1)+a,S=d.concat(g);x>-1&&x<g.children.length;){const I=g.children[x];if(m=l(I,x,S)(),m[0]===An)return m;x=typeof m[1]=="number"?m[1]:x+a}}return f}}}function Wf(e){return Array.isArray(e)?e:typeof e=="number"?[Kf,e]:e==null?ca:[e]}function or(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),da(e,s,l,i);function l(o,u){const d=u[u.length-1],c=d?d.children.indexOf(o):void 0;return a(o,c,d)}}const Rn={}.hasOwnProperty,Qf={};function Gf(e,t){const n=t||Qf,r=new Map,i=new Map,s=new Map,a={...Rf,...n.handlers},l={all:u,applyData:Yf,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:o,options:n,patch:Xf,wrap:Zf};return or(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const c=d.type==="definition"?r:i,p=String(d.identifier).toUpperCase();c.has(p)||c.set(p,d)}}),l;function o(d,c){const p=d.type,f=l.handlers[p];if(Rn.call(l.handlers,p)&&f)return f(l,d,c);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in d){const{children:x,...S}=d,g=Pt(S);return g.children=l.all(d),g}return Pt(d)}return(l.options.unknownHandler||Jf)(l,d,c)}function u(d){const c=[];if("children"in d){const p=d.children;let f=-1;for(;++f<p.length;){const m=l.one(p[f],d);if(m){if(f&&p[f-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=ui(m.value)),!Array.isArray(m)&&m.type==="element")){const x=m.children[0];x&&x.type==="text"&&(x.value=ui(x.value))}Array.isArray(m)?c.push(...m):c.push(m)}}}return c}}function Xf(e,t){e.position&&(t.position=Oc(e))}function Yf(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,Pt(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Jf(e,t){const n=t.data||{},r="value"in t&&!(Rn.call(n,"hProperties")||Rn.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 Zf(e,t){const n=[];let 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 ui(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ci(e,t){const n=Gf(e,t),r=n.one(e,void 0),i=_f(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
16
+ `},i),s}function ep(e,t){return e&&"run"in e?async function(n,r){const i=ci(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ci(n,{file:r,...e||t})}}function di(e){if(e)throw e}var an,hi;function tp(){if(hi)return an;hi=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),c=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!c)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},a=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},l=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return an=function o(){var u,d,c,p,f,m,x=arguments[0],S=1,g=arguments.length,I=!1;for(typeof x=="boolean"&&(I=x,x=arguments[1]||{},S=2),(x==null||typeof x!="object"&&typeof x!="function")&&(x={});S<g;++S)if(u=arguments[S],u!=null)for(d in u)c=l(x,d),p=l(u,d),x!==p&&(I&&p&&(s(p)||(f=i(p)))?(f?(f=!1,m=c&&i(c)?c:[]):m=c&&s(c)?c:{},a(x,{name:d,newValue:o(I,m,p)})):typeof p<"u"&&a(x,{name:d,newValue:p}));return x},an}var np=tp();const ln=Yi(np);function jn(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function rp(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...i);function l(o,...u){const d=e[++s];let c=-1;if(o){a(o);return}for(;++c<i.length;)(u[c]===null||u[c]===void 0)&&(u[c]=i[c]);i=u,d?ip(d,l)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function ip(e,t){let n;return r;function r(...a){const l=e.length>a.length;let o;l&&a.push(i);try{o=e.apply(this,a)}catch(u){const d=u;if(l&&n)throw d;return i(d)}l||(o&&o.then&&typeof o.then=="function"?o.then(s,i):o instanceof Error?i(o):s(o))}function i(a,...l){n||(n=!0,t(a,...l))}function s(a){i(null,a)}}const Ne={basename:sp,dirname:ap,extname:lp,join:op,sep:"/"};function sp(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');wt(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function ap(e){if(wt(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||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function lp(e){wt(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function op(...e){let t=-1,n;for(;++t<e.length;)wt(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":up(n)}function up(e){wt(e);const t=e.codePointAt(0)===47;let n=cp(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function cp(e,t){let n="",r=0,i=-1,s=0,a=-1,l,o;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(o=n.lastIndexOf("/"),o!==n.length-1){o<0?(n="",r=0):(n=n.slice(0,o),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else l===46&&s>-1?s++:s=-1}return n}function wt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const dp={cwd:hp};function hp(){return"/"}function Pn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function fp(e){if(typeof e=="string")e=new URL(e);else if(!Pn(e)){const t=new 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:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return pp(e)}function pp(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const on=["history","path","basename","stem","extname","dirname"];class ha{constructor(t){let n;t?Pn(t)?n={path:t}:typeof t=="string"||mp(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":dp.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<on.length;){const s=on[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)on.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ne.basename(this.path):void 0}set basename(t){cn(t,"basename"),un(t,"basename"),this.path=Ne.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ne.dirname(this.path):void 0}set dirname(t){fi(this.basename,"dirname"),this.path=Ne.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ne.extname(this.path):void 0}set extname(t){if(un(t,"extname"),fi(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ne.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Pn(t)&&(t=fp(t)),cn(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ne.basename(this.path,this.extname):void 0}set stem(t){cn(t,"stem"),un(t,"stem"),this.path=Ne.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new oe(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function un(e,t){if(e&&e.includes(Ne.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ne.sep+"`")}function cn(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function fi(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function mp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const gp=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),xp={}.hasOwnProperty;class ur extends gp{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=rp()}copy(){const t=new ur;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ln(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(fn("data",this.frozen),this.namespace[t]=n,this):xp.call(this.namespace,t)&&this.namespace[t]||void 0:t?(fn("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Tt(t),r=this.parser||this.Parser;return dn("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),dn("process",this.parser||this.Parser),hn("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const l=Tt(t),o=r.parse(l);r.run(o,l,function(d,c,p){if(d||!c||!p)return u(d);const f=c,m=r.stringify(f,p);Sp(m)?p.value=m:p.result=m,u(d,p)});function u(d,c){d||!c?a(d):s?s(c):n(void 0,c)}}}processSync(t){let n=!1,r;return this.freeze(),dn("processSync",this.parser||this.Parser),hn("processSync",this.compiler||this.Compiler),this.process(t,i),mi("processSync","process",n),r;function i(s,a){n=!0,di(s),r=a}}run(t,n,r){pi(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,l){const o=Tt(n);i.run(t,o,u);function u(d,c,p){const f=c||t;d?l(d):a?a(f):r(void 0,f,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),mi("runSync","run",r),i;function s(a,l){di(a),i=l,r=!0}}stringify(t,n){this.freeze();const r=Tt(n),i=this.compiler||this.Compiler;return hn("stringify",i),pi(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(fn("use",this.frozen),t!=null)if(typeof t=="function")o(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")o(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...c]=u;o(d,c)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new 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");l(u.plugins),u.settings&&(i.settings=ln(!0,i.settings,u.settings))}function l(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const c=u[d];s(c)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function o(u,d){let c=-1,p=-1;for(;++c<r.length;)if(r[c][0]===u){p=c;break}if(p===-1)r.push([u,...d]);else if(d.length>0){let[f,...m]=d;const x=r[p][1];jn(x)&&jn(f)&&(f=ln(!0,x,f)),r[p]=[u,f,...m]}}}}const yp=new ur().freeze();function dn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function hn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function fn(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function pi(e){if(!jn(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function mi(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Tt(e){return bp(e)?e:new ha(e)}function bp(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Sp(e){return typeof e=="string"||kp(e)}function kp(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const wp="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",gi=[],xi={allowDangerousHtml:!0},Cp=/^(https?|ircs?|mailto|xmpp)$/i,vp=[{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 Tp(e){const t=Ip(e),n=Mp(e);return Np(t.runSync(t.parse(n),n),e)}function Ip(e){const t=e.rehypePlugins||gi,n=e.remarkPlugins||gi,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...xi}:xi;return yp().use(af).use(n).use(ep,r).use(t)}function Mp(e){const t=e.children||"",n=new ha;return typeof t=="string"&&(n.value=t),n}function Np(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,o=t.urlTransform||Ep;for(const d of vp)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+wp+d.id,void 0);return or(e,u),Hc(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function u(d,c,p){if(d.type==="raw"&&p&&typeof c=="number")return a?p.children.splice(c,1):p.children[c]={type:"text",value:d.value},c;if(d.type==="element"){let f;for(f in nn)if(Object.hasOwn(nn,f)&&Object.hasOwn(d.properties,f)){const m=d.properties[f],x=nn[f];(x===null||x.includes(d.tagName))&&(d.properties[f]=o(String(m||""),f,d))}}if(d.type==="element"){let f=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!f&&r&&typeof c=="number"&&(f=!r(d,c,p)),f&&p&&typeof c=="number")return l&&d.children?p.children.splice(c,1,...d.children):p.children.splice(c,1),c}}}function Ep(e){const 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||Cp.test(e.slice(0,t))?e:""}function yi(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Lp(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Ap(e,t,n){const i=Ut((n||{}).ignore||[]),s=Rp(t);let a=-1;for(;++a<s.length;)da(e,"text",l);function l(u,d){let c=-1,p;for(;++c<d.length;){const f=d[c],m=p?p.children:void 0;if(i(f,m?m.indexOf(f):void 0,p))return;p=f}if(p)return o(u,d)}function o(u,d){const c=d[d.length-1],p=s[a][0],f=s[a][1];let m=0;const S=c.children.indexOf(u);let g=!1,I=[];p.lastIndex=0;let N=p.exec(u.value);for(;N;){const P=N.index,F={index:N.index,input:N.input,stack:[...d,u]};let T=f(...N,F);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?p.lastIndex=P+1:(m!==P&&I.push({type:"text",value:u.value.slice(m,P)}),Array.isArray(T)?I.push(...T):T&&I.push(T),m=P+N[0].length,g=!0),!p.global)break;N=p.exec(u.value)}return g?(m<u.value.length&&I.push({type:"text",value:u.value.slice(m)}),c.children.splice(S,1,...I)):I=[u],S+I.length}}function Rp(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([jp(i[0]),Pp(i[1])])}return t}function jp(e){return typeof e=="string"?new RegExp(Lp(e),"g"):e}function Pp(e){return typeof e=="function"?e:function(){return e}}const pn="phrasing",mn=["autolink","link","image","label"];function Dp(){return{transforms:[Hp],enter:{literalAutolink:Op,literalAutolinkEmail:gn,literalAutolinkHttp:gn,literalAutolinkWww:gn},exit:{literalAutolink:Vp,literalAutolinkEmail:Bp,literalAutolinkHttp:zp,literalAutolinkWww:_p}}}function Fp(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:pn,notInConstruct:mn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:pn,notInConstruct:mn},{character:":",before:"[ps]",after:"\\/",inConstruct:pn,notInConstruct:mn}]}}function Op(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function gn(e){this.config.enter.autolinkProtocol.call(this,e)}function zp(e){this.config.exit.autolinkProtocol.call(this,e)}function _p(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Bp(e){this.config.exit.autolinkEmail.call(this,e)}function Vp(e){this.exit(e)}function Hp(e){Ap(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Up],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),$p]],{ignore:["link","linkReference"]})}function Up(e,t,n,r,i){let s="";if(!fa(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Kp(n)))return!1;const a=qp(n+r);if(!a[0])return!1;const l={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[l,{type:"text",value:a[1]}]:l}function $p(e,t,n,r){return!fa(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Kp(e){const 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 qp(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=yi(e,"(");let s=yi(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function fa(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||He(n)||Bt(n))&&(!t||n!==47)}pa.peek=tm;function Wp(){this.buffer()}function Qp(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Gp(){this.buffer()}function Xp(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Yp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Te(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Jp(e){this.exit(e)}function Zp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Te(this.sliceSerialize(e)).toLowerCase(),n.label=t}function em(e){this.exit(e)}function tm(){return"["}function pa(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),l=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),l(),a(),s+=i.move("]"),s}function nm(){return{enter:{gfmFootnoteCallString:Wp,gfmFootnoteCall:Qp,gfmFootnoteDefinitionLabelString:Gp,gfmFootnoteDefinition:Xp},exit:{gfmFootnoteCallString:Yp,gfmFootnoteCall:Jp,gfmFootnoteDefinitionLabelString:Zp,gfmFootnoteDefinition:em}}}function rm(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:pa},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const l=s.createTracker(a);let o=l.move("[^");const u=s.enter("footnoteDefinition"),d=s.enter("label");return o+=l.move(s.safe(s.associationId(r),{before:o,after:"]"})),d(),o+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),o+=l.move((t?`
17
+ `:" ")+s.indentLines(s.containerFlow(r,l.current()),t?ma:im))),u(),o}}function im(e,t,n){return t===0?e:ma(e,t,n)}function ma(e,t,n){return(n?"":" ")+e}const sm=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ga.peek=cm;function am(){return{canContainEols:["delete"],enter:{strikethrough:om},exit:{strikethrough:um}}}function lm(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:sm}],handlers:{delete:ga}}}function om(e){this.enter({type:"delete",children:[]},e)}function um(e){this.exit(e)}function ga(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function cm(){return"~"}function dm(e){return e.length}function hm(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||dm,s=[],a=[],l=[],o=[];let u=0,d=-1;for(;++d<e.length;){const x=[],S=[];let g=-1;for(e[d].length>u&&(u=e[d].length);++g<e[d].length;){const I=fm(e[d][g]);if(n.alignDelimiters!==!1){const N=i(I);S[g]=N,(o[g]===void 0||N>o[g])&&(o[g]=N)}x.push(I)}a[d]=x,l[d]=S}let c=-1;if(typeof r=="object"&&"length"in r)for(;++c<u;)s[c]=bi(r[c]);else{const x=bi(r);for(;++c<u;)s[c]=x}c=-1;const p=[],f=[];for(;++c<u;){const x=s[c];let S="",g="";x===99?(S=":",g=":"):x===108?S=":":x===114&&(g=":");let I=n.alignDelimiters===!1?1:Math.max(1,o[c]-S.length-g.length);const N=S+"-".repeat(I)+g;n.alignDelimiters!==!1&&(I=S.length+I+g.length,I>o[c]&&(o[c]=I),f[c]=I),p[c]=N}a.splice(1,0,p),l.splice(1,0,f),d=-1;const m=[];for(;++d<a.length;){const x=a[d],S=l[d];c=-1;const g=[];for(;++c<u;){const I=x[c]||"";let N="",P="";if(n.alignDelimiters!==!1){const F=o[c]-(S[c]||0),T=s[c];T===114?N=" ".repeat(F):T===99?F%2?(N=" ".repeat(F/2+.5),P=" ".repeat(F/2-.5)):(N=" ".repeat(F/2),P=N):P=" ".repeat(F)}n.delimiterStart!==!1&&!c&&g.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&I==="")&&(n.delimiterStart!==!1||c)&&g.push(" "),n.alignDelimiters!==!1&&g.push(N),g.push(I),n.alignDelimiters!==!1&&g.push(P),n.padding!==!1&&g.push(" "),(n.delimiterEnd!==!1||c!==u-1)&&g.push("|")}m.push(n.delimiterEnd===!1?g.join("").replace(/ +$/,""):g.join(""))}return m.join(`
18
+ `)}function fm(e){return e==null?"":String(e)}function bi(e){const 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 pm(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),mm);return i(),a}function mm(e,t,n){return">"+(n?"":" ")+e}function gm(e,t){return Si(e,t.inConstruct,!0)&&!Si(e,t.notInConstruct,!1)}function Si(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 ki(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
19
+ `&&gm(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
20
+ `}function xm(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function ym(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 bm(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Sm(e,t,n,r){const i=bm(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(ym(e,n)){const c=n.enter("codeIndented"),p=n.indentLines(s,km);return c(),p}const l=n.createTracker(r),o=i.repeat(Math.max(xm(s,i)+1,3)),u=n.enter("codeFenced");let d=l.move(o);if(e.lang){const c=n.enter(`codeFencedLang${a}`);d+=l.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...l.current()})),c()}if(e.lang&&e.meta){const c=n.enter(`codeFencedMeta${a}`);d+=l.move(" "),d+=l.move(n.safe(e.meta,{before:d,after:`
21
+ `,encode:["`"],...l.current()})),c()}return d+=l.move(`
22
+ `),s&&(d+=l.move(s+`
23
+ `)),d+=l.move(o),u(),d}function km(e,t,n){return(n?"":" ")+e}function cr(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function wm(e,t,n,r){const i=cr(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("[");return u+=o.move(n.safe(n.associationId(e),{before:u,after:"]",...o.current()})),u+=o.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":`
24
+ `,...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),a(),u}function Cm(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function mt(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Dt(e,t,n){const r=Xe(e),i=Xe(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}}xa.peek=vm;function xa(e,t,n,r){const i=Cm(n),s=n.enter("emphasis"),a=n.createTracker(r),l=a.move(i);let o=a.move(n.containerPhrasing(e,{after:i,before:l,...a.current()}));const u=o.charCodeAt(0),d=Dt(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(o=mt(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Dt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+mt(c));const f=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},l+o+f}function vm(e,t,n){return n.options.emphasis||"*"}function Tm(e,t){let n=!1;return or(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,An}),!!((!e.depth||e.depth<3)&&tr(e)&&(t.options.setext||n))}function Im(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(Tm(e,n)){const d=n.enter("headingSetext"),c=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
25
+ `,after:`
26
+ `});return c(),d(),p+`
27
+ `+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
28
+ `))+1))}const a="#".repeat(i),l=n.enter("headingAtx"),o=n.enter("phrasing");s.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
29
+ `,...s.current()});return/^[\t ]/.test(u)&&(u=mt(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),o(),l(),u}ya.peek=Mm;function ya(e){return e.value||""}function Mm(){return"<"}ba.peek=Nm;function ba(e,t,n,r){const i=cr(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let l=n.enter("label");const o=n.createTracker(r);let u=o.move("![");return u+=o.move(n.safe(e.alt,{before:u,after:"]",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),a(),u}function Nm(){return"!"}Sa.peek=Em;function Sa(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const l=n.createTracker(r);let o=l.move("![");const u=n.safe(e.alt,{before:o,after:"]",...l.current()});o+=l.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:o,after:"]",...l.current()});return a(),n.stack=d,s(),i==="full"||!u||u!==c?o+=l.move(c+"]"):i==="shortcut"?o=o.slice(0,-1):o+=l.move("]"),o}function Em(){return"!"}ka.peek=Lm;function ka(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],l=n.compilePattern(a);let o;if(a.atBreak)for(;o=l.exec(r);){let u=o.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(o.index+1)}}return i+r+i}function Lm(){return"`"}function wa(e,t){const n=tr(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))}Ca.peek=Am;function Ca(e,t,n,r){const i=cr(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let l,o;if(wa(e,n)){const d=n.stack;n.stack=[],l=n.enter("autolink");let c=a.move("<");return c+=a.move(n.containerPhrasing(e,{before:c,after:">",...a.current()})),c+=a.move(">"),l(),n.stack=d,c}l=n.enter("link"),o=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(o=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(n.safe(e.title,{before:u,after:i,...a.current()})),u+=a.move(i),o()),u+=a.move(")"),l(),u}function Am(e,t,n){return wa(e,n)?"<":"["}va.peek=Rm;function va(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const l=n.createTracker(r);let o=l.move("[");const u=n.containerPhrasing(e,{before:o,after:"]",...l.current()});o+=l.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const c=n.safe(n.associationId(e),{before:o,after:"]",...l.current()});return a(),n.stack=d,s(),i==="full"||!u||u!==c?o+=l.move(c+"]"):i==="shortcut"?o=o.slice(0,-1):o+=l.move("]"),o}function Rm(){return"["}function dr(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function jm(e){const t=dr(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Pm(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ta(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Dm(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?Pm(n):dr(n);const l=e.ordered?a==="."?")":".":jm(n);let o=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.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&&(o=!0),Ta(n)===a&&d){let c=-1;for(;++c<e.children.length;){const p=e.children[c];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){o=!0;break}}}}o&&(a=l),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function Fm(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Om(e,t,n,r){const i=Fm(n);let s=n.bulletCurrent||dr(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const l=n.createTracker(r);l.move(s+" ".repeat(a-s.length)),l.shift(a);const o=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,l.current()),d);return o(),u;function d(c,p,f){return p?(f?"":" ".repeat(a))+c:(f?s:s+" ".repeat(a-s.length))+c}}function zm(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const _m=Ut(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Bm(e,t,n,r){return(e.children.some(function(a){return _m(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Vm(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ia.peek=Hm;function Ia(e,t,n,r){const i=Vm(n),s=n.enter("strong"),a=n.createTracker(r),l=a.move(i+i);let o=a.move(n.containerPhrasing(e,{after:i,before:l,...a.current()}));const u=o.charCodeAt(0),d=Dt(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(o=mt(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Dt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+mt(c));const f=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},l+o+f}function Hm(e,t,n){return n.options.strong||"*"}function Um(e,t,n,r){return n.safe(e.value,r)}function $m(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Km(e,t,n){const r=(Ta(n)+(n.options.ruleSpaces?" ":"")).repeat($m(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Ma={blockquote:pm,break:ki,code:Sm,definition:wm,emphasis:xa,hardBreak:ki,heading:Im,html:ya,image:ba,imageReference:Sa,inlineCode:ka,link:Ca,linkReference:va,list:Dm,listItem:Om,paragraph:zm,root:Bm,strong:Ia,text:Um,thematicBreak:Km};function qm(){return{enter:{table:Wm,tableData:wi,tableHeader:wi,tableRow:Gm},exit:{codeText:Xm,table:Qm,tableData:xn,tableHeader:xn,tableRow:xn}}}function Wm(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Qm(e){this.exit(e),this.data.inTable=void 0}function Gm(e){this.enter({type:"tableRow",children:[]},e)}function xn(e){this.exit(e)}function wi(e){this.enter({type:"tableCell",children:[]},e)}function Xm(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Ym));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Ym(e,t){return t==="|"?t:e}function Jm(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=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:p,table:a,tableCell:o,tableRow:l}};function a(f,m,x,S){return u(d(f,x,S),f.align)}function l(f,m,x,S){const g=c(f,x,S),I=u([g]);return I.slice(0,I.indexOf(`
31
+ `))}function o(f,m,x,S){const g=x.enter("tableCell"),I=x.enter("phrasing"),N=x.containerPhrasing(f,{...S,before:s,after:s});return I(),g(),N}function u(f,m){return hm(f,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function d(f,m,x){const S=f.children;let g=-1;const I=[],N=m.enter("table");for(;++g<S.length;)I[g]=c(S[g],m,x);return N(),I}function c(f,m,x){const S=f.children;let g=-1;const I=[],N=m.enter("tableRow");for(;++g<S.length;)I[g]=o(S[g],f,m,x);return N(),I}function p(f,m,x){let S=Ma.inlineCode(f,m,x);return x.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function Zm(){return{exit:{taskListCheckValueChecked:Ci,taskListCheckValueUnchecked:Ci,paragraph:tg}}}function eg(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ng}}}function Ci(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function tg(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const l=i[s];if(l.type==="paragraph"){a=l;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function ng(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);s&&l.move(a);let o=Ma.listItem(e,t,n,{...r,...l.current()});return s&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),o;function u(d){return d+a}}function rg(){return[Dp(),nm(),am(),qm(),Zm()]}function ig(e){return{extensions:[Fp(),rm(e),lm(),Jm(e),eg()]}}const sg={tokenize:dg,partial:!0},Na={tokenize:hg,partial:!0},Ea={tokenize:fg,partial:!0},La={tokenize:pg,partial:!0},ag={tokenize:mg,partial:!0},Aa={name:"wwwAutolink",tokenize:ug,previous:ja},Ra={name:"protocolAutolink",tokenize:cg,previous:Pa},Pe={name:"emailAutolink",tokenize:og,previous:Da},Ee={};function lg(){return{text:Ee}}let Ve=48;for(;Ve<123;)Ee[Ve]=Pe,Ve++,Ve===58?Ve=65:Ve===91&&(Ve=97);Ee[43]=Pe;Ee[45]=Pe;Ee[46]=Pe;Ee[95]=Pe;Ee[72]=[Pe,Ra];Ee[104]=[Pe,Ra];Ee[87]=[Pe,Aa];Ee[119]=[Pe,Aa];function og(e,t,n){const r=this;let i,s;return a;function a(c){return!Dn(c)||!Da.call(r,r.previous)||hr(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(c))}function l(c){return Dn(c)?(e.consume(c),l):c===64?(e.consume(c),o):n(c)}function o(c){return c===46?e.check(ag,d,u)(c):c===45||c===95||le(c)?(s=!0,e.consume(c),o):d(c)}function u(c){return e.consume(c),i=!0,o}function d(c){return s&&i&&ce(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):n(c)}}function ug(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!ja.call(r,r.previous)||hr(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(sg,e.attempt(Na,e.attempt(Ea,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function cg(e,t,n){const r=this;let i="",s=!1;return a;function a(c){return(c===72||c===104)&&Pa.call(r,r.previous)&&!hr(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),l):n(c)}function l(c){if(ce(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),l;if(c===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(c),o}return n(c)}function o(c){return c===47?(e.consume(c),s?u:(s=!0,o)):n(c)}function u(c){return c===null||Rt(c)||Z(c)||He(c)||Bt(c)?n(c):e.attempt(Na,e.attempt(Ea,d),n)(c)}function d(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function dg(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function hg(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(La,o,l)(u):u===null||Z(u)||He(u)||u!==45&&Bt(u)?o(u):(s=!0,e.consume(u),a)}function l(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),a}function o(u){return i||r||!s?n(u):t(u)}}function fg(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(La,t,s)(a):a===null||Z(a)||He(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function pg(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),s):l===93?(e.consume(l),i):l===60||l===null||Z(l)||He(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||Z(l)||He(l)?t(l):r(l)}function s(l){return ce(l)?a(l):n(l)}function a(l){return l===59?(e.consume(l),r):ce(l)?(e.consume(l),a):n(l)}}function mg(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return le(s)?n(s):t(s)}}function ja(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Z(e)}function Pa(e){return!ce(e)}function Da(e){return!(e===47||Dn(e))}function Dn(e){return e===43||e===45||e===46||e===95||le(e)}function hr(e){let t=e.length,n=!1;for(;t--;){const 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}const gg={tokenize:vg,partial:!0};function xg(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:kg,continuation:{tokenize:wg},exit:Cg}},text:{91:{name:"gfmFootnoteCall",tokenize:Sg},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:yg,resolveTo:bg}}}}function yg(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const o=r.events[i][1];if(o.type==="labelImage"){a=o;break}if(o.type==="gfmFootnoteCall"||o.type==="labelLink"||o.type==="label"||o.type==="image"||o.type==="link")break}return l;function l(o){if(!a||!a._balanced)return n(o);const u=Te(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(o):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),t(o))}}function bg(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";const 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++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function Sg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return l;function l(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),o}function o(c){return c!==94?n(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(s>999||c===93&&!a||c===null||c===91||Z(c))return n(c);if(c===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Te(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return Z(c)||(a=!0),s++,e.consume(c),c===92?d:u}function d(c){return c===91||c===92||c===93?(e.consume(c),s++,u):u(c)}}function kg(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,l;return o;function o(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(a>999||m===93&&!l||m===null||m===91||Z(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return s=Te(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Z(m)||(l=!0),a++,e.consume(m),m===92?c:d}function c(m){return m===91||m===92||m===93?(e.consume(m),a++,d):d(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),X(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function wg(e,t,n){return e.check(kt,t,e.attempt(gg,t,n))}function Cg(e){e.exit("gfmFootnoteDefinition")}function vg(e,t,n){const r=this;return X(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function Tg(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,l){let o=-1;for(;++o<a.length;)if(a[o][0]==="enter"&&a[o][1].type==="strikethroughSequenceTemporary"&&a[o][1]._close){let u=o;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[o][1].end.offset-a[o][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[o][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[o][1].end)},c={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[o][1].start)},p=[["enter",d,l],["enter",a[u][1],l],["exit",a[u][1],l],["enter",c,l]],f=l.parser.constructs.insideSpan.null;f&&xe(p,p.length,0,Vt(f,a.slice(u+1,o),l)),xe(p,p.length,0,[["exit",c,l],["enter",a[o][1],l],["exit",a[o][1],l],["exit",d,l]]),xe(a,u-1,o-u+3,p),o=u+p.length-2;break}}for(o=-1;++o<a.length;)a[o][1].type==="strikethroughSequenceTemporary"&&(a[o][1].type="data");return a}function s(a,l,o){const u=this.previous,d=this.events;let c=0;return p;function p(m){return u===126&&d[d.length-1][1].type!=="characterEscape"?o(m):(a.enter("strikethroughSequenceTemporary"),f(m))}function f(m){const x=Xe(u);if(m===126)return c>1?o(m):(a.consume(m),c++,f);if(c<2&&!n)return o(m);const S=a.exit("strikethroughSequenceTemporary"),g=Xe(m);return S._open=!g||g===2&&!!x,S._close=!x||x===2&&!!g,l(m)}}}class Ig{constructor(){this.map=[]}add(t,n,r){Mg(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function Mg(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 Ng(e,t){let n=!1;const r=[];for(;t<e.length;){const 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"){const s=r.length-1;r[s]=r[s]==="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 Eg(){return{flow:{null:{name:"table",tokenize:Lg,resolveAll:Ag}}}}function Lg(e,t,n){const r=this;let i=0,s=0,a;return l;function l(w){let R=r.events.length-1;for(;R>-1;){const j=r.events[R][1].type;if(j==="lineEnding"||j==="linePrefix")R--;else break}const E=R>-1?r.events[R][1].type:null,V=E==="tableHead"||E==="tableRow"?T:o;return V===T&&r.parser.lazy[r.now().line]?n(w):V(w)}function o(w){return e.enter("tableHead"),e.enter("tableRow"),u(w)}function u(w){return w===124||(a=!0,s+=1),d(w)}function d(w){return w===null?n(w):z(w)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),f):n(w):W(w)?X(e,d,"whitespace")(w):(s+=1,a&&(a=!1,i+=1),w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),c(w)))}function c(w){return w===null||w===124||Z(w)?(e.exit("data"),d(w)):(e.consume(w),w===92?p:c)}function p(w){return w===92||w===124?(e.consume(w),c):c(w)}function f(w){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(w):(e.enter("tableDelimiterRow"),a=!1,W(w)?X(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):m(w))}function m(w){return w===45||w===58?S(w):w===124?(a=!0,e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),x):F(w)}function x(w){return W(w)?X(e,S,"whitespace")(w):S(w)}function S(w){return w===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),g):w===45?(s+=1,g(w)):w===null||z(w)?P(w):F(w)}function g(w){return w===45?(e.enter("tableDelimiterFiller"),I(w)):F(w)}function I(w){return w===45?(e.consume(w),I):w===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),N):(e.exit("tableDelimiterFiller"),N(w))}function N(w){return W(w)?X(e,P,"whitespace")(w):P(w)}function P(w){return w===124?m(w):w===null||z(w)?!a||i!==s?F(w):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(w)):F(w)}function F(w){return n(w)}function T(w){return e.enter("tableRow"),O(w)}function O(w){return w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),O):w===null||z(w)?(e.exit("tableRow"),t(w)):W(w)?X(e,O,"whitespace")(w):(e.enter("data"),B(w))}function B(w){return w===null||w===124||Z(w)?(e.exit("data"),O(w)):(e.consume(w),w===92?U:B)}function U(w){return w===92||w===124?(e.consume(w),B):B(w)}}function Ag(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],l=!1,o=0,u,d,c;const p=new Ig;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(l=!1,o!==0&&(vi(p,t,o,u,d),d=void 0,o=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,c=void 0,s=[0,0,0,0],a=[0,n+1,0,0],l&&(l=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",d,t]])),i=m.type==="tableDelimiterRow"?2:d?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],c=It(p,t,s,i,void 0,c),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],c=It(p,t,s,i,void 0,c)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(l=!0,o=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(o=n,s[1]!==0?(a[0]=a[1],c=It(p,t,s,i,n,c)):a[1]!==0&&(c=It(p,t,a,i,n,c)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(o!==0&&vi(p,t,o,u,d),p.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=Ng(t.events,n))}return e}function It(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(s.end=Object.assign({},We(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=We(t.events,n[1]);if(s={type:a,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=We(t.events,n[2]),d=We(t.events,n[3]),c={type:l,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",c,t]]),r!==2){const p=t.events[n[2]],f=t.events[n[3]];if(p[1].end=Object.assign({},f[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,x=n[3]-n[2]-1;e.add(m,x,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(s.end=Object.assign({},We(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function vi(e,t,n,r,i){const s=[],a=We(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function We(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Rg={name:"tasklistCheck",tokenize:Pg};function jg(){return{text:{91:Rg}}}function Pg(e,t,n){const r=this;return i;function i(o){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(o):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(o),e.exit("taskListCheckMarker"),s)}function s(o){return Z(o)?(e.enter("taskListCheckValueUnchecked"),e.consume(o),e.exit("taskListCheckValueUnchecked"),a):o===88||o===120?(e.enter("taskListCheckValueChecked"),e.consume(o),e.exit("taskListCheckValueChecked"),a):n(o)}function a(o){return o===93?(e.enter("taskListCheckMarker"),e.consume(o),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(o)}function l(o){return z(o)?t(o):W(o)?e.check({tokenize:Dg},t,n)(o):n(o)}}function Dg(e,t,n){return X(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Fg(e){return qs([lg(),xg(),Tg(e),Eg(),jg()])}const Og={};function zg(e){const t=this,n=e||Og,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Fg(n)),s.push(rg()),a.push(ig(n))}function _g(){var e;return typeof navigator<"u"&&typeof((e=navigator.clipboard)==null?void 0:e.writeText)=="function"}function Bg(e){if(typeof document>"u")return;const t=document.getSelection();t&&(t.removeAllRanges(),e.forEach(n=>t.addRange(n)))}function Ti(e){if(typeof document>"u"||!document.body)return!1;const 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(),s=i?Array.from({length:i.rangeCount},(o,u)=>i.getRangeAt(u).cloneRange()):[],a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.setAttribute("aria-hidden","true"),a.style.position="fixed",a.style.top="0",a.style.left="-9999px",a.style.opacity="0",a.style.pointerEvents="none",a.style.fontSize="12pt",document.body.appendChild(a);try{a.focus({preventScroll:!0})}catch{a.focus()}a.select(),a.setSelectionRange(0,a.value.length);let l=!1;try{l=typeof document.execCommand=="function"&&document.execCommand("copy")}catch{l=!1}if(a.remove(),t)try{t.focus({preventScroll:!0})}catch{t.focus()}return n&&r?n.setSelectionRange(r.start,r.end):Bg(s),l}async function Vg(e){if(!e)return!1;if(_g())try{return await navigator.clipboard.writeText(e),!0}catch{return Ti(e)}return Ti(e)}const Hg=1300;function Ug(e){const[t,n]=k.useState(!1),r=k.useCallback(async()=>{if(!e.text)return;const i=await Vg(e.text);n(!!i)},[e.text]);return k.useEffect(()=>{if(!t||typeof window>"u")return;const i=window.setTimeout(()=>n(!1),e.resetDelayMs??Hg);return()=>window.clearTimeout(i)},[t,e.resetDelayMs]),{copied:t,copy:r}}const $g=/language-([a-z0-9-]+)/i;function Fa(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Fa).join(""):""}function Kg(e){const t=Fa(e);return t.endsWith(`
32
+ `)?t.slice(0,-1):t}function qg(e){var n;const t=e?$g.exec(e):null;return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())||"text"}function Wg(e){const t=k.useMemo(()=>qg(e.className),[e.className]),n=k.useMemo(()=>Kg(e.children),[e.children]),{copied:r,copy:i}=Ug({text:n});return h.jsxs("div",{className:"chat-codeblock",children:[h.jsxs("div",{className:"chat-codeblock-toolbar",children:[h.jsx("span",{className:"chat-codeblock-language",children:t}),h.jsxs("button",{type:"button",className:"chat-codeblock-copy",onClick:()=>void i(),"aria-label":r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel,children:[r?h.jsx(xt,{className:"h-3.5 w-3.5"}):h.jsx(kl,{className:"h-3.5 w-3.5"}),h.jsx("span",{children:r?e.texts.copiedCodeLabel:e.texts.copyCodeLabel})]})]}),h.jsx("pre",{children:h.jsx("code",{className:e.className,children:n})})]})}const Ii=14e4,Qg=new Set(["http:","https:","mailto:","tel:"]);function Gg(e){return e.length<=Ii?e:`${e.slice(0,Ii)}
33
+
34
+ ...`}function Mi(e){if(!e)return null;if(e.startsWith("#")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return e;try{const t=new URL(e);return Qg.has(t.protocol)?e:null}catch{return null}}function Xg(e){return/^https?:\/\//i.test(e)}function Yg(e){const t=e.role==="user",n=k.useMemo(()=>({a:({href:r,children:i,...s})=>{const a=Mi(r);if(!a)return h.jsx("span",{className:"chat-link-invalid",children:i});const l=Xg(a);return h.jsx("a",{...s,href:a,target:l?"_blank":void 0,rel:l?"noreferrer noopener":void 0,children:i})},table:({children:r,...i})=>h.jsx("div",{className:"chat-table-wrap",children:h.jsx("table",{...i,children:r})}),input:({type:r,checked:i,...s})=>r!=="checkbox"?h.jsx("input",{...s,type:r}):h.jsx("input",{...s,type:"checkbox",checked:i,readOnly:!0,disabled:!0,className:"chat-task-checkbox"}),img:({src:r,alt:i,...s})=>{const a=Mi(r);return a?h.jsx("img",{...s,src:a,alt:i||"",loading:"lazy",decoding:"async"}):null},code:({className:r,children:i,...s})=>{const a=String(i??"");return!r&&!a.includes(`
35
+ `)?h.jsx("code",{...s,className:q("chat-inline-code",r),children:i}):h.jsx(Wg,{className:r,texts:e.texts,children:i})}}),[e.texts]);return h.jsx("div",{className:q("chat-markdown",t?"chat-markdown-user":"chat-markdown-assistant"),children:h.jsx(Tp,{skipHtml:!0,remarkPlugins:[zg],components:n,children:Gg(e.text)})})}const Oa={archive:"Archive",audio:"Audio",code:"Code",data:"Data",document:"Document",generic:"File",image:"Image",pdf:"PDF",sheet:"Sheet",video:"Video"},yn={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"},Jg=new Set(["c","cpp","css","go","html","java","js","jsx","md","php","py","rb","rs","sh","sql","svg","ts","tsx"]),Zg=new Set(["graphql","json","toml","xml","yaml","yml"]),ex=new Set(["doc","docx","odt","pages","rtf","txt"]),tx=new Set(["csv","numbers","ods","tsv","xls","xlsx"]),nx=new Set(["7z","bz2","gz","rar","tar","tgz","zip"]);function rx(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return"0 B";const t=["B","KB","MB","GB","TB"];let n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;const i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,"")} ${t[r]}`}function ix(e,t){var s;const n=/\.([a-z0-9]{1,12})$/i.exec(e.trim());if(n!=null&&n[1])return n[1].toUpperCase();const i=(s=(t.split("/")[1]??"").split(/[+.;-]/)[0])==null?void 0:s.trim();return i?i.slice(0,6).toUpperCase():"FILE"}function sx(e,t){var i,s;const n=((s=(i=/\.([a-z0-9]{1,12})$/i.exec(e.trim()))==null?void 0:i[1])==null?void 0:s.toLowerCase())??"",r=t.toLowerCase();return r.startsWith("image/")?"image":r.startsWith("audio/")?"audio":r.startsWith("video/")?"video":r.includes("pdf")||n==="pdf"?"pdf":nx.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?"archive":tx.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?"sheet":Zg.has(n)||/(json|xml|yaml|toml)/.test(r)?"data":Jg.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?"code":ex.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?"document":"generic"}function ax(e){const t=sx(e.label,e.mimeType),n=rx(e.sizeBytes);return{category:t,extension:ix(e.label,e.mimeType),sizeLabel:n,metaBadges:[Oa[t],n].filter(r=>!!r)}}function bn(e,t){return h.jsx("span",{className:q("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 Ni(e,t){return h.jsx("div",{className:q("truncate text-[11px]",t?"text-white/58":"text-slate-500"),children:e})}function Ei(e,t,n){return h.jsx("span",{className:q("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 lx({file:e,isUser:t=!1}){const{category:n,extension:r,metaBadges:i,sizeLabel:s}=ax(e),a=!!e.dataUrl,l=a?e.isImage?"Open preview":"Open file":"Attached",o=r.slice(0,4),u=q("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)]",a&&(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 h.jsx("a",{href:e.dataUrl,target:"_blank",rel:"noreferrer","aria-label":`Open preview: ${e.label}`,className:q(u,"group"),children:h.jsxs("figure",{children:[h.jsxs("div",{className:q("relative overflow-hidden p-2",t?"bg-white/[0.04]":"bg-gradient-to-br from-slate-100 via-white to-slate-100"),children:[h.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]"}),h.jsxs("div",{className:"pointer-events-none absolute inset-x-4 top-4 flex items-center justify-between",children:[s?bn(s,t):h.jsx("span",{}),h.jsx("span",{className:q("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":yn[n]),children:o})]})]}),h.jsxs("figcaption",{className:"flex items-start gap-3 p-4",children:[h.jsx("div",{className:q("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":yn[n]),children:o}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("div",{className:"truncate text-sm font-semibold leading-5",children:e.label}),h.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:i.map(c=>bn(c,t))}),h.jsx("div",{className:"mt-2",children:Ni(e.mimeType,t)})]}),Ei(l,t,!0)]})]})});const d=h.jsxs("div",{className:"flex items-start gap-3 p-3.5",children:[h.jsx("div",{className:q("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":yn[n]),children:o}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("div",{className:"truncate text-sm font-semibold leading-5",children:e.label}),h.jsxs("div",{className:q("mt-1 text-xs",t?"text-white/68":"text-slate-500"),children:[Oa[n]," attachment"]})]}),Ei(l,t,a)]}),h.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.map(c=>bn(c,t))}),h.jsx("div",{className:"mt-2",children:Ni(e.mimeType,t)})]})]});return a?h.jsx("a",{href:e.dataUrl,target:"_blank",rel:"noreferrer","aria-label":`Open file: ${e.label}`,className:q(u,"group"),children:d}):h.jsx("div",{className:u,children:d})}function ox(e){return h.jsxs("details",{className:"mt-3",open:!0,children:[h.jsx("summary",{className:q("cursor-pointer text-xs",e.isUser?"text-primary-100":"text-gray-500"),children:e.label}),h.jsx("pre",{className:q("mt-2 whitespace-pre-wrap break-words rounded-lg p-2 text-[11px]",e.isUser?"bg-primary-700/60":"bg-gray-100"),children:e.text})]})}function Kt({children:e,className:t}){return h.jsx("div",{className:q("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 qt({children:e,className:t}){return h.jsx("div",{className:q("border-t border-amber-200/15 bg-amber-50/50 px-3 pt-1 pb-2 w-full overflow-hidden",t),children:e})}const Li={running:{text:"text-amber-500/80",icon:Hi,spin:!0},success:{text:"text-amber-500/80",icon:xt,spin:!1},error:{text:"text-amber-500/80",icon:Cl,spin:!1},cancelled:{text:"text-amber-500/80",icon:wl,spin:!1}};function ux({card:e}){const t=Li[e.statusTone]||Li.cancelled,n=t.icon;return h.jsxs("span",{className:q("inline-flex items-center gap-1.5 text-[11px] font-medium leading-none shrink-0",t.text),children:[h.jsx(n,{className:q("h-3.5 w-3.5",t.spin&&"animate-spin"),strokeWidth:3}),e.statusTone==="running"?e.statusLabel:null]})}function Wt({card:e,icon:t,expanded:n,canExpand:r,onToggle:i}){var a;const s=(a=e.summary)==null?void 0:a.replace(/^(command|path|args|query|input):\s*/i,"");return h.jsxs("div",{className:q("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:[h.jsxs("div",{className:"flex items-center gap-2 font-mono min-w-0 max-w-[calc(100%-80px)] text-amber-950/80",children:[h.jsx(t,{className:"h-4 w-4 text-amber-600/80 shrink-0",strokeWidth:3}),h.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[h.jsx("span",{className:"font-bold shrink-0 tracking-tight",children:e.toolName}),s&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-amber-300 font-bold select-none shrink-0",children:"›"}),h.jsx("span",{className:"truncate flex-1 min-w-0 font-normal",title:s,children:s})]})]})]}),h.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[h.jsx(ux,{card:e}),r&&(n?h.jsx(Ot,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}):h.jsx(vl,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}))]})]})}function cx({card:e}){var p,f,m;const t=((p=e.output)==null?void 0:p.trim())??"",n=e.statusTone==="running",r=!!((f=e.summary)!=null&&f.trim()||t.length>0),i=k.useRef(!r),[s,a]=k.useState(r&&(n||e.statusTone==="error"||t.length<500)),[l,o]=k.useState(!1),u=k.useRef(n);k.useEffect(()=>{i.current&&r&&n&&(a(!0),i.current=!1)},[r,n]),k.useEffect(()=>{u.current&&!n&&!l&&a(!1),u.current=n},[n,l]);const d=()=>{!t&&!n||(a(!s),o(!0))},c=(m=e.summary)==null?void 0:m.replace(/^(command|path|args|query|input):\s*/i,"");return h.jsxs(Kt,{children:[h.jsx(Wt,{card:e,icon:Tl,expanded:s,canExpand:!!t||n,onToggle:d}),s&&h.jsxs(h.Fragment,{children:[h.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:h.jsxs("div",{className:"flex items-start gap-2 leading-relaxed",children:[h.jsx("span",{className:"text-amber-500/50 font-medium shrink-0 select-none mt-[1px]",children:"$"}),h.jsx("div",{className:"flex-1 min-w-0",children:c?h.jsxs("div",{className:"text-amber-950/80 break-words whitespace-pre-wrap tracking-tight font-medium inline-block",children:[c,n&&!t&&h.jsx("span",{className:"inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle"})]}):h.jsx("div",{className:"h-3 w-32 bg-amber-200/30 rounded animate-pulse mt-2"})})]})}),t&&h.jsx(qt,{children:h.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&&h.jsx("span",{className:"inline-block w-1.5 h-3 ml-1 bg-amber-500/60 animate-pulse align-middle"})]})})]})]})}function dx({card:e}){var x;const t=((x=e.output)==null?void 0:x.trim())??"",n=e.statusTone==="running",[r,i]=k.useState(!1),[s,a]=k.useState(!1),l=k.useRef(n);k.useEffect(()=>{l.current&&!n&&!s&&i(!1),l.current=n},[n,s]);const o=()=>{!t&&!n||(i(!r),a(!0))},u=e.toolName==="edit_file"||e.toolName==="write_file",d=(S,g)=>{if(u){if(S.startsWith("+")&&!S.startsWith("+++"))return h.jsxs("div",{className:"bg-emerald-500/10 text-emerald-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap",children:[h.jsx("span",{className:"select-none opacity-40 mr-2 w-3 inline-block shrink-0",children:"+"}),h.jsx("span",{children:S.slice(1)})]},g);if(S.startsWith("-")&&!S.startsWith("---"))return h.jsxs("div",{className:"bg-rose-500/10 text-rose-700 px-2 py-0.5 w-full break-all whitespace-pre-wrap",children:[h.jsx("span",{className:"select-none opacity-40 mr-2 w-3 inline-block shrink-0",children:"-"}),h.jsx("span",{className:"line-through decoration-rose-400/50",children:S.slice(1)})]},g)}return h.jsx("div",{className:"py-0.5 text-amber-950/80 w-full break-all whitespace-pre-wrap",children:h.jsx("span",{children:S})},g)},c=t.split(`
36
+ `),p=15,f=c.length>p,m=!r&&f?c.slice(0,p):c;return h.jsxs(Kt,{children:[h.jsx(Wt,{card:e,icon:u?Il:Ml,expanded:r,canExpand:!!t||n,onToggle:o}),r&&t&&h.jsx(qt,{children:h.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:m.map(d)})})]})}function hx({card:e}){var u;const t=e.statusTone==="running",[n,r]=k.useState(t),[i,s]=k.useState(!1),a=k.useRef(t),l=((u=e.output)==null?void 0:u.trim())??"";k.useEffect(()=>{a.current&&!t&&!i&&r(!1),a.current=t},[t,i]);const o=()=>{!l&&!t||(r(!n),s(!0))};return h.jsxs(Kt,{children:[h.jsx(Wt,{card:e,icon:Bn,expanded:n,canExpand:!!l||t,onToggle:o}),n&&l&&h.jsx(qt,{children:h.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:l})})]})}function fx({card:e}){var d;const t=((d=e.output)==null?void 0:d.trim())??"",n=e.statusTone==="running",[r,i]=k.useState(n),[s,a]=k.useState(!1),l=k.useRef(n),o=e.kind==="result"||e.hasResult;k.useEffect(()=>{l.current&&!n&&!s&&i(!1),l.current=n},[n,s]);const u=()=>{o&&(i(!r),a(!0))};return h.jsxs(Kt,{children:[h.jsx(Wt,{card:e,icon:Nl,expanded:r,canExpand:o,onToggle:u}),r&&t&&h.jsx(qt,{children:h.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 px(e){const t=e.toLowerCase();return t==="exec"||t==="execute_command"||t==="bash"||t==="shell"||t.includes("run_")}function mx(e){const t=e.toLowerCase();return t==="read_file"||t==="write_file"||t==="edit_file"||t==="apply_patch"}function gx(e){const t=e.toLowerCase();return t==="grep_search"||t==="find_files"||t.includes("search")}function xx({card:e}){return px(e.toolName)?h.jsx(cx,{card:e}):mx(e.toolName)?h.jsx(dx,{card:e}):gx(e.toolName)?h.jsx(hx,{card:e}):h.jsx(fx,{card:e})}function yx(e){return h.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 text-xs text-gray-600",children:[h.jsxs("div",{className:"font-semibold text-gray-700",children:[e.label,": ",e.rawType]}),e.text?h.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-gray-500",children:e.text}):null]})}const bx=k.memo(function(t){const{message:n,texts:r}=t,{role:i}=n,s=i==="user";return h.jsx("div",{className:q("inline-block w-fit max-w-full rounded-2xl border px-4 py-3 shadow-sm",s?"border-primary bg-primary text-white":i==="assistant"?"border-gray-200 bg-white text-gray-900":"border-orange-200/80 bg-orange-50/70 text-gray-900"),children:h.jsx("div",{className:"space-y-2",children:n.parts.map((a,l)=>a.type==="markdown"?h.jsx(Yg,{text:a.text,role:i,texts:r},`markdown-${l}`):a.type==="reasoning"?h.jsx(ox,{label:a.label,text:a.text,isUser:s},`reasoning-${l}`):a.type==="tool-card"?h.jsx("div",{className:"mt-0.5",children:h.jsx(xx,{card:a.card})},`tool-${l}`):a.type==="file"?h.jsx(lx,{file:a.file,isUser:s},`file-${l}`):a.type==="unknown"?h.jsx(yx,{label:a.label,rawType:a.rawType,text:a.text},`unknown-${l}`):null)})})});function Sx(e){return h.jsxs("div",{className:q("px-1 text-[11px] leading-4 text-gray-400",e.isUser?"text-right":"text-left"),children:[e.roleLabel," · ",e.timestampLabel]})}const kx=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function wx(e){const t=e.trim();return t?t.replace(kx,"").trim().length>0:!1}function Cx(e){return e.parts.some(t=>t.type==="markdown"||t.type==="reasoning"?wx(t.text):!0)}function vx(e){const t=e.messages.filter(Cx),n=t.some(r=>r.role==="assistant"&&(r.status==="streaming"||r.status==="pending"));return h.jsxs("div",{className:q("space-y-5",e.className),children:[t.map(r=>{const i=r.role==="user";return h.jsxs("div",{className:q("flex gap-3",i?"justify-end":"justify-start"),children:[i?null:h.jsx(Zt,{role:r.role}),h.jsxs("div",{className:q("w-fit max-w-[92%] space-y-2",i&&"flex flex-col items-end"),children:[h.jsx(bx,{message:r,texts:e.texts}),h.jsx(Sx,{roleLabel:r.roleLabel,timestampLabel:r.timestampLabel,isUser:i})]}),i?h.jsx(Zt,{role:r.role}):null]},r.id)}),e.isSending&&!n?h.jsxs("div",{className:"flex justify-start gap-3",children:[h.jsx(Zt,{role:"assistant"}),h.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]})}const Tx=10;function Ix(e){e.scrollTop=e.scrollHeight}function Ai(e){e.scrollRef.current&&(e.scheduledScrollFrameRef.current!==null&&cancelAnimationFrame(e.scheduledScrollFrameRef.current),e.scheduledScrollFrameRef.current=requestAnimationFrame(()=>{e.scheduledScrollFrameRef.current=null;const n=e.scrollRef.current;n&&(e.isProgrammaticScrollRef.current=!0,Ix(n))}))}function Mx(e){const t=k.useRef(!0),n=k.useRef(!1),r=k.useRef(null),i=k.useRef(!1),s=k.useRef(null),a=()=>{if(n.current){n.current=!1;return}const l=e.scrollRef.current;if(!l)return;const o=l.scrollHeight-l.scrollTop-l.clientHeight;t.current=o<=(e.stickyThresholdPx??Tx)};return k.useEffect(()=>{r.current!==e.resetKey&&(r.current=e.resetKey,t.current=!0,i.current=!0)},[e.resetKey]),k.useEffect(()=>{const l=s.current;return()=>{l!==null&&cancelAnimationFrame(l)}},[]),k.useLayoutEffect(()=>{!i.current||e.isLoading||!e.hasContent||!e.scrollRef.current||(i.current=!1,Ai({scrollRef:e.scrollRef,scheduledScrollFrameRef:s,isProgrammaticScrollRef:n}))},[e.hasContent,e.isLoading,e.scrollRef]),k.useLayoutEffect(()=>{!t.current||!e.hasContent||!e.scrollRef.current||Ai({scrollRef:e.scrollRef,scheduledScrollFrameRef:s,isProgrammaticScrollRef:n})},[e.contentVersion,e.hasContent,e.scrollRef]),{onScroll:a}}function za(){return Wn()}function Nx(e){return qu(e)}function Ri(e){return Qu(e)}function ji(e){return _t(e,"skill")}function Ex(e){return _t(e,"file")}function Lx(e,t,n){const r=new Set(t),i=Qn(e,o=>o.tokenKind==="skill"&&!r.has(o.tokenKey)),s=_t(i,"skill"),a=new Map(n.map(o=>[o.spec,o])),l=t.filter(o=>!s.includes(o)).map(o=>{var u;return qn({tokenKind:"skill",tokenKey:o,label:((u=a.get(o))==null?void 0:u.label)||o})});return l.length===0?i:Ge([...i,...l])}function Pi(e,t){const n=new Set(t.map(r=>r.id));return Qn(e,r=>r.tokenKind==="file"&&!n.has(r.tokenKey))}function Ax(e,t){const n=new Set(Ex(e));return t.filter(r=>n.has(r.id))}function Rx(e,t){const n=new Map(t.map(i=>[i.id,i])),r=[];for(const i of e){if(i.type==="text"){i.text.length>0&&r.push({type:"text",text:i.text});continue}if(i.tokenKind!=="file")continue;const s=n.get(i.tokenKey);s&&r.push({type:"file",name:s.name,mimeType:s.mimeType,...s.assetUri?{assetUri:s.assetUri}:{},...s.url?{url:s.url}:{},...s.contentBase64?{contentBase64:s.contentBase64}:{},sizeBytes:s.sizeBytes})}return r}const jx={isProviderStateResolved:!1,composerNodes:za(),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:[]},J=zn(e=>({snapshot:jx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function Px(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=n-864e5,i=n-7*864e5,s=[],a=[],l=[],o=[];for(const d of e){const{session:c}=d,p=new Date(c.updatedAt).getTime();p>=n?s.push(d):p>=r?a.push(d):p>=i?l.push(d):o.push(d)}const u=[];return s.length>0&&u.push({label:v("chatSidebarToday"),items:s}),a.length>0&&u.push({label:v("chatSidebarYesterday"),items:a}),l.length>0&&u.push({label:v("chatSidebarPrevious7Days"),items:l}),o.length>0&&u.push({label:v("chatSidebarOlder"),items:o}),u}function Dx(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}function Fx(e,t){const n=e.trim().toLowerCase();if(!n||n==="native")return null;const r=t.find(i=>i.value.trim().toLowerCase()===n);return r!=null&&r.label.trim()?r.label.trim():n.split(/[-_]+/g).filter(Boolean).map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ")}function Ox(e){var t;return e.ready===!1?((t=e.reasonMessage)==null?void 0:t.trim())||v("statusSetup"):v("statusReady")}const zx=[{target:"/cron",label:()=>v("chatSidebarScheduledTasks"),icon:Vn},{target:"/skills",label:()=>v("chatSidebarSkills"),icon:_n}];function _x(){var V,j;const e=Kn(),t=$l(),[n,r]=k.useState(!1),[i,s]=k.useState(null),[a,l]=k.useState(""),[o,u]=k.useState(null),d=J(C=>C.snapshot),c=fe(C=>C.snapshot),p=Kl(C=>C.connectionStatus),{isLoading:f,items:m}=bu(),{language:x,setLanguage:S}=Un(),{theme:g,setTheme:I}=ql(),N=gu(),P=v(((V=xr.find(C=>C.value===g))==null?void 0:V.labelKey)??"themeWarm"),F=((j=yr.find(C=>C.value===x))==null?void 0:j.label)??x,T=k.useMemo(()=>Px(m),[m]),O=d.defaultSessionType||"native",B=k.useMemo(()=>d.sessionTypeOptions.filter(C=>C.value!==O),[O,d.sessionTypeOptions]),U=C=>{x!==C&&(S(C),window.location.reload())},w=C=>{var D;s(C.key),l(((D=C.label)==null?void 0:D.trim())??"")},R=()=>{s(null),l(""),u(null)},E=async C=>{var _;const D=a.trim(),Q=((_=C.label)==null?void 0:_.trim())??"";if(D===Q){R();return}u(C.key);try{await N({sessionKey:C.key,label:D||null}),R()}catch{u(null)}};return h.jsxs("aside",{className:"w-[280px] shrink-0 flex flex-col h-full bg-secondary border-r border-gray-200/60",children:[h.jsx("div",{className:"px-5 pt-5 pb-3",children:h.jsx(Wl,{className:"flex items-center gap-2.5 min-w-0",suffix:h.jsx(pu,{status:p})})}),h.jsx("div",{className:"px-4 pb-3",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(je,{variant:"primary",className:ve("min-w-0 rounded-xl",B.length>0?"flex-1 rounded-r-md":"w-full"),onClick:()=>{r(!1),e.chatSessionListManager.createSession(O)},children:[h.jsx(El,{className:"h-4 w-4 mr-2"}),v("chatSidebarNewTask")]}),B.length>0?h.jsxs(Mo,{open:n,onOpenChange:r,children:[h.jsx(No,{asChild:!0,children:h.jsx(je,{variant:"primary",size:"icon",className:"h-9 w-10 shrink-0 rounded-xl rounded-l-md","aria-label":v("chatSessionTypeLabel"),children:h.jsx(Ot,{className:"h-4 w-4"})})}),h.jsxs(Eo,{align:"end",className:"w-64 p-2",children:[h.jsx("div",{className:"px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-gray-400",children:v("chatSessionTypeLabel")}),h.jsx("div",{className:"mt-1 space-y-1",children:B.map(C=>h.jsxs("button",{type:"button",onClick:()=>{e.chatSessionListManager.createSession(C.value),r(!1)},className:"w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-gray-100",children:[h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("div",{className:"text-[13px] font-medium text-gray-900",children:C.label}),h.jsx("span",{className:ve("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold",C.ready===!1?"bg-amber-100 text-amber-800":"bg-emerald-100 text-emerald-700"),children:C.ready===!1?v("statusSetup"):v("statusReady")})]}),h.jsx("div",{className:"mt-0.5 text-[11px] text-gray-500",children:Ox(C)})]},C.value))})]})]}):null]})}),h.jsx("div",{className:"px-4 pb-3",children:h.jsxs("div",{className:"relative",children:[h.jsx(Bn,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),h.jsx(Hn,{value:c.query,onChange:C=>e.chatSessionListManager.setQuery(C.target.value),placeholder:v("chatSidebarSearchPlaceholder"),className:"pl-8 h-9 rounded-lg text-xs"})]})}),h.jsx("div",{className:"px-3 pb-2",children:h.jsx("ul",{className:"space-y-0.5",children:zx.map(C=>h.jsx("li",{children:h.jsx(br,{to:C.target,label:C.label(),icon:C.icon,density:"compact"})},C.target))})}),h.jsx("div",{className:"mx-4 border-t border-gray-200/60"}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar px-3 py-2",children:f?h.jsx("div",{className:"text-xs text-gray-500 p-3",children:v("sessionsLoading")}):T.length===0?h.jsxs("div",{className:"p-4 text-center",children:[h.jsx(Ll,{className:"h-6 w-6 mx-auto mb-2 text-gray-300"}),h.jsx("div",{className:"text-xs text-gray-500",children:v("sessionsEmpty")})]}):h.jsx("div",{className:"space-y-3",children:T.map(C=>h.jsxs("div",{children:[h.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider",children:C.label}),h.jsx("div",{className:"space-y-0.5",children:C.items.map(({session:D,runStatus:Q})=>{const _=c.selectedSessionKey===D.key,ue=Fx(D.sessionType,d.sessionTypeOptions),y=i===D.key,se=o===D.key;return h.jsx(mu,{session:D,active:_,runStatus:Q,sessionTypeLabel:ue,title:Dx(D),isEditing:y,draftLabel:a,isSaving:se,onSelect:()=>e.chatSessionListManager.selectSession(D.key),onStartEditing:()=>w(D),onDraftLabelChange:l,onSave:()=>E(D),onCancel:R},D.key)})})]},C.label))})}),h.jsxs("div",{className:"px-3 py-3 border-t border-gray-200/60 space-y-0.5",children:[h.jsx(br,{to:"/settings",label:v("settings"),icon:Al,density:"compact"}),h.jsx(Ql,{onClick:()=>t.open(void 0,{kind:"docs",newTab:!0,title:"Docs"}),icon:Rl,label:v("docBrowserHelp"),density:"compact"}),h.jsx(Sr,{value:g,onValueChange:C=>I(C),icon:jl,label:v("theme"),valueLabel:P,density:"compact",children:xr.map(C=>h.jsx(ut,{value:C.value,className:"text-xs",children:v(C.labelKey)},C.value))}),h.jsx(Sr,{value:x,onValueChange:C=>U(C),icon:Pl,label:v("language"),valueLabel:F,density:"compact",children:yr.map(C=>h.jsx(ut,{value:C.value,className:"text-xs",children:C.label},C.value))})]})]})}function Bx(e,t){if(!e||typeof e!="object"||Array.isArray(e))return t;const n=e.error;if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n.message;return typeof r=="string"&&r.trim().length>0?r:t}async function Vx(e){const t=new FormData;for(const i of e)t.append("files",i);const n=await fetch(`${ts}/api/ncp/assets`,{method:"POST",body:t,credentials:"include"}),r=await n.json();if(!n.ok||!r.ok)throw new Error(Bx(r,"Failed to put assets."));return r.data.assets.map(i=>({id:i.id,name:i.name,mimeType:i.mimeType,sizeBytes:i.sizeBytes,assetUri:i.assetUri,url:i.url}))}const Me={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function Mt(e){const t=e.modelLabel.trim(),n=e.providerLabel.trim();return n?`${n}/${t}`:t}function Nt(e){return(e??"").trim().toLowerCase()}function Di(e,t){if(!e||!t)return!1;let n=0;for(const r of t)if(r===e[n]&&(n+=1,n>=e.length))return!0;return!1}function Hx(e,t){const n=Nt(t);if(!n)return Me.fallback;const r=Nt(e.key),i=Nt(e.label||e.key),s=Nt(`${e.descriptionZh??""} ${e.description??""}`),a=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Me.exactSpec:i===n?Me.exactLabel:r.startsWith(n)?Me.prefixSpec:i.startsWith(n)?Me.prefixLabel:a.some(l=>l.startsWith(n))?Me.prefixToken:r.includes(n)?Me.containsSpec:i.includes(n)?Me.containsLabel:s.includes(n)?Me.containsDescription:Di(n,i)||Di(n,r)?Me.subsequence:0}function Ux(e,t,n){const r=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0});return e.map((i,s)=>({record:i,order:s,score:Hx(i,t)})).filter(i=>i.score>0).sort((i,s)=>{if(s.score!==i.score)return s.score-i.score;const a=(i.record.label||i.record.key).trim(),l=(s.record.label||s.record.key).trim(),o=r.compare(a,l);return o!==0?o:i.order-s.order}).map(({record:i})=>({key:`skill:${i.key}`,title:i.label||i.key,subtitle:n.slashSkillSubtitle,description:(i.descriptionZh??i.description??"").trim()||n.noSkillDescription,detailLines:[`${n.slashSkillSpecLabel}: ${i.key}`],value:i.key}))}function $x(e){return e.map(t=>({key:t.key,label:t.label,description:t.descriptionZh||t.description||"",badgeLabel:t.badgeLabel}))}function Kx(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:$x(e.skillRecords),selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function qx(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 Wx(e){const t=e.modelOptions.find(u=>u.value===e.selectedModel),n=e.modelOptions[0],r=t??n,i=e.hasModelOptions?r==null?void 0:r.value:void 0,s=new Set(e.recentModelValues??[]),a=e.modelOptions.filter(u=>s.has(u.value)),l=e.modelOptions.filter(u=>!s.has(u.value)),o=a.length>0?[{key:"recent-models",label:e.texts.recentModelsLabel,options:a.map(u=>({value:u.value,label:Mt(u)}))},{key:"all-models",label:e.texts.allModelsLabel,options:l.map(u=>({value:u.value,label:Mt(u)}))}].filter(u=>u.options.length>0):void 0;return{key:"model",value:i,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?Mt(r):void 0,icon:"sparkles",options:e.modelOptions.map(u=>({value:u.value,label:Mt(u)})),groups:o,disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function Qx(e){const t=[];for(const n of["off",...e])t.includes(n)||t.push(n);return t}function Gx(e){if(e.supportedLevels.length===0)return null;const t=Qx(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(i=>({value:i,label:e.texts.thinkingLabels[i]})),onValueChange:i=>e.onValueChange(i)}}class Xx{constructor(t){this.options=t}read(){const t=this.getStorage();if(!t)return[];try{return this.normalizeList(JSON.parse(t.getItem(this.options.storageKey)??"[]"))}catch{return[]}}remember(t){const n=this.normalizeValue(t);if(!n)return this.read();const r=[n,...this.read().filter(i=>i!==n)].slice(0,this.options.limit);return this.write(r),r}resolveVisible(t){const n=this.normalizeList(t.availableValues,Number.POSITIVE_INFINITY);if(n.length<=t.minAvailableCount)return[];const r=new Set(n),i=[],s=Math.max(1,t.limit??this.options.limit);for(const a of this.read())if(!(!r.has(a)||i.includes(a))&&(i.push(a),i.length>=s))break;return i}write(t){const n=this.getStorage();if(n)try{n.setItem(this.options.storageKey,JSON.stringify(this.normalizeList(t)))}catch{}}getStorage(){return typeof window>"u"?null:window.localStorage}normalizeList(t,n=this.options.limit){if(!Array.isArray(t))return[];const r=[];for(const i of t){const s=this.normalizeValue(i);if(!(!s||r.includes(s))&&(r.push(s),r.length>=n))break}return r}normalizeValue(t){if(typeof t!="string")return null;const n=t.trim();return n.length>0?n:null}}const _a=new Xx({storageKey:"nextclaw.chat.recent-models",limit:3}),Yx=5;function Jx(){return{off:v("chatThinkingLevelOff"),minimal:v("chatThinkingLevelMinimal"),low:v("chatThinkingLevelLow"),medium:v("chatThinkingLevelMedium"),high:v("chatThinkingLevelHigh"),adaptive:v("chatThinkingLevelAdaptive"),xhigh:v("chatThinkingLevelXhigh")}}function Zx(e,t){return e.map(n=>({key:n.spec,label:n.label||n.spec,description:n.description,descriptionZh:n.descriptionZh,badgeLabel:n.origin==="builtin"?t:void 0}))}function ey(e){return e.map(t=>({value:t.value,modelLabel:t.modelLabel,providerLabel:t.providerLabel,thinkingCapability:t.thinkingCapability?{supported:t.thinkingCapability.supported,default:t.thinkingCapability.default??null}:null}))}function ty(){var R;const e=Kn(),{language:t}=Un(),n=J(E=>E.snapshot),[r,i]=k.useState(null),s=k.useRef(null),a=k.useRef(null),l=k.useMemo(()=>v("chatSkillsPickerOfficial"),[t]),o=k.useMemo(()=>({slashSkillSubtitle:v("chatSlashTypeSkill"),slashSkillSpecLabel:v("chatSlashSkillSpec"),noSkillDescription:v("chatSkillsPickerNoDescription")}),[t]),u=k.useMemo(()=>Zx(n.skillRecords,l),[n.skillRecords,l]),d=k.useMemo(()=>ey(n.modelOptions),[n.modelOptions]),c=k.useMemo(()=>_a.resolveVisible({availableValues:d.map(E=>E.value),minAvailableCount:Yx}),[d,n.selectedModel]),p=d.length>0,f=!n.isProviderStateResolved&&!p,m=n.isProviderStateResolved&&!p,x=(f||m)&&!n.isSending||n.sessionTypeUnavailable,S=typeof e.chatInputManager.addAttachments=="function",g=f?"":p?v("chatInputPlaceholder"):v("chatModelNoOptions"),I=k.useMemo(()=>Ux(u,r??"",o),[r,u,o]),N=d.find(E=>E.value===n.selectedModel),P=N==null?void 0:N.thinkingCapability,F=(P==null?void 0:P.supported)??[],T=n.stopDisabledReason==="__preparing__"?v("chatStopPreparing"):((R=n.stopDisabledReason)==null?void 0:R.trim())||v("chatStopUnavailable"),O=k.useCallback(E=>{if(E==="unsupported-type"){ot.error(v("chatInputAttachmentUnsupported"));return}if(E==="too-large"){ot.error(v("chatInputAttachmentTooLarge").replace("{maxMb}",String(ds/(1024*1024))));return}ot.error(v("chatInputAttachmentReadFailed"))},[]),B=k.useCallback(async E=>{var j,C,D;if(!S||E.length===0)return;const V=await hu(E,{uploadBatch:Vx});if(V.attachments.length>0){const Q=((C=(j=e.chatInputManager).addAttachments)==null?void 0:C.call(j,V.attachments))??[];Q.length>0&&((D=s.current)==null||D.insertFileTokens(Q.map(_=>({tokenKey:_.id,label:_.name}))))}V.rejected.length>0&&O(V.rejected[0].reason)},[S,e.chatInputManager,O]),U=[Wx({modelOptions:d,recentModelValues:c,selectedModel:n.selectedModel,isModelOptionsLoading:f,hasModelOptions:p,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:v("chatSelectModel"),modelNoOptionsLabel:v("chatModelNoOptions"),recentModelsLabel:v("chatRecentModels"),allModelsLabel:v("chatAllModels")}}),Gx({supportedLevels:F,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:(P==null?void 0:P.default)??null,onValueChange:E=>e.chatInputManager.selectThinkingLevel(E),texts:{thinkingLabels:Jx()}})].filter(E=>E!==null),w=Kx({skillRecords:u,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:v("chatSkillsPickerTitle"),searchPlaceholder:v("chatSkillsPickerSearchPlaceholder"),emptyLabel:v("chatSkillsPickerEmpty"),loadingLabel:v("sessionsLoading"),manageLabel:v("chatSkillsPickerManage")}});return h.jsxs(h.Fragment,{children:[h.jsx(As,{ref:s,composer:{nodes:n.composerNodes,placeholder:g,disabled:x,onNodesChange:e.chatInputManager.setComposerNodes,...S?{onFilesAdd:B}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:I,texts:{slashLoadingLabel:v("chatSlashLoading"),slashSectionLabel:v("chatSlashSectionSkills"),slashEmptyLabel:v("chatSlashNoResult"),slashHintLabel:v("chatSlashHint"),slashSkillHintLabel:v("chatSlashSkillHint")}},hint:qx({isModelOptionsLoading:f,isModelOptionsEmpty:m,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:v("chatModelNoOptions"),configureProviderLabel:v("chatGoConfigureProvider")}}),toolbar:{selects:U,accessories:[{key:"attach",label:v("chatInputAttach"),icon:"paperclip",iconOnly:!0,disabled:!S||x||n.isSending,...S?{onClick:()=>{var E;return(E=a.current)==null?void 0:E.click()}}:{tooltip:v("chatInputAttachComingSoon")}}],skillPicker:w,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:v("chatSend"),stopButtonLabel:v("chatStop"),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),S?h.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:async E=>{const V=Array.from(E.target.files??[]);E.currentTarget.value="",await B(V)}}):null]})}const ny=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function Fi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fn(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}
37
+ …`}function Ft(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";try{return Fn(JSON.stringify(e,null,2))}catch{return String(e)}}function ry(e){if(Fi(e))return e;if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{const n=JSON.parse(t);return Fi(n)?n:null}catch{return null}}function iy(e){const t=ry(e);if(!t){const r=Ft(e).trim();return r?Fn(r,120):void 0}const n=[];for(const r of ny){const i=t[r];if(typeof i=="string"&&i.trim()?n.push(`${r}: ${i.trim()}`):(typeof i=="number"||typeof i=="boolean")&&n.push(`${r}: ${String(i)}`),n.length>=2)break}return n.length>0?n.join(" · "):Fn(Ft(t),140)}const sy=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function At(e){return typeof e=="object"&&e!==null}function Sn(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function Ba(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function ay(e,t){if(!At(e))return null;const n=At(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&At(e.assets[0])?e.assets[0]:null;if(!n)return null;const r=Sn(n.url),i=Sn(n.mimeType)??"application/octet-stream",s=Ba(n.sizeBytes);return r?{type:"file",file:{label:Sn(n.name)??(i.startsWith("image/")?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...s!=null?{sizeBytes:s}:{},isImage:i.startsWith("image/")}}:null}function ly(e){return e.type==="text"&&typeof e.text=="string"}function oy(e){return e.type==="reasoning"&&typeof e.reasoning=="string"}function uy(e){return e.type==="file"&&typeof e.mimeType=="string"&&typeof e.data=="string"}function cy(e){return e.type!=="tool-invocation"||!At(e.toolInvocation)?!1:typeof e.toolInvocation.toolName=="string"}function dy(e){var n;const t=(n=e.meta)==null?void 0:n.timestamp;return t&&Number.isFinite(Date.parse(t))?t:new Date().toISOString()}function hy(e,t){return e==="user"?t.user:e==="assistant"?t.assistant:e==="tool"?t.tool:e==="system"?t.system:t.fallback}function fy(e){return e==="user"||e==="assistant"||e==="tool"||e==="system"?e:"message"}function py(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 my(e){const 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 Oi(e){const t=e.trim();return t&&t.replace(sy,"").trim()?t:null}function gy(e,t){var n;return{id:e.id,role:fy(e.role),roleLabel:hy(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(dy(e)),status:(n=e.meta)==null?void 0:n.status,parts:e.parts.map(r=>{if(ly(r)){const i=Oi(r.text);return i?{type:"markdown",text:i}:null}if(oy(r)){const i=Oi(r.reasoning);return i?{type:"reasoning",text:i,label:t.texts.reasoningLabel}:null}if(uy(r)){const i=r.mimeType.startsWith("image/"),s=Ba(r.sizeBytes);return{type:"file",file:{label:typeof r.name=="string"&&r.name.trim()?r.name.trim():i?t.texts.imageAttachmentLabel:t.texts.fileAttachmentLabel,mimeType:r.mimeType,dataUrl:typeof r.url=="string"&&r.url.trim().length>0?r.url.trim():`data:${r.mimeType};base64,${r.data}`,...s!=null?{sizeBytes:s}:{},isImage:i}}}if(cy(r)){const i=r.toolInvocation,s=ay(i.result,t.texts);if(s)return s;const a=my({status:i.status,error:i.error,cancelled:i.cancelled,result:i.result,texts:t.texts}),l=iy(i.parsedArgs??i.args),o=typeof i.error=="string"&&i.error.trim()?i.error.trim():i.result!=null?Ft(i.result).trim():"",u={kind:a.kind,name:i.toolName,detail:l,text:o||void 0,callId:i.toolCallId||void 0,hasResult:a.hasResult,statusTone:a.statusTone,statusLabel:a.statusLabel};return{type:"tool-card",card:py(u,t.texts)}}return{type:"unknown",label:t.texts.unknownPartLabel,rawType:typeof r.type=="string"?r.type:"unknown",text:Ft(r)}}).filter(r=>r!==null)}}const zi=new WeakMap;function xy(e){return{roleLabels:{user:v("chatRoleUser"),assistant:v("chatRoleAssistant"),tool:v("chatRoleTool"),system:v("chatRoleSystem"),fallback:v("chatRoleMessage")},reasoningLabel:v("chatReasoning"),toolCallLabel:v("chatToolCall"),toolResultLabel:v("chatToolResult"),toolNoOutputLabel:v("chatToolNoOutput"),toolOutputLabel:v("chatToolOutput"),toolStatusPreparingLabel:v("chatToolStatusPreparing"),toolStatusRunningLabel:v("chatToolStatusRunning"),toolStatusCompletedLabel:v("chatToolStatusCompleted"),toolStatusFailedLabel:v("chatToolStatusFailed"),toolStatusCancelledLabel:v("chatToolStatusCancelled"),imageAttachmentLabel:v("chatImageAttachment"),fileAttachmentLabel:v("chatFileAttachment"),unknownPartLabel:v("chatUnknownPart")}}function yy(e){return{copyCodeLabel:v("chatCodeCopy"),copiedCodeLabel:v("chatCodeCopied"),typingLabel:v("chatTyping")}}function by(e){const{language:t}=Un(),n=k.useMemo(()=>xy(),[t]),r=k.useMemo(()=>e.messages.map(a=>{var c,p;const l=zi.get(a);if(l&&l.language===t)return l.viewModel;const o=Ao(a),u={id:o.id,role:o.role,meta:{timestamp:(c=o.meta)==null?void 0:c.timestamp,status:(p=o.meta)==null?void 0:p.status},parts:o.parts},d=gy(u,{formatTimestamp:f=>zt(f,t),texts:n});return zi.set(a,{language:t,viewModel:d}),d}),[t,e.messages,n]),i=k.useMemo(()=>r.some(a=>a.role==="assistant"&&(a.status==="streaming"||a.status==="pending")),[r]),s=k.useMemo(()=>yy(),[t]);return h.jsx(vx,{messages:r,isSending:e.isSending,hasAssistantDraft:i,className:e.className,texts:s})}const Sy=[{icon:Dl,titleKey:"chatWelcomeCapability1Title",descKey:"chatWelcomeCapability1Desc"},{icon:_n,titleKey:"chatWelcomeCapability2Title",descKey:"chatWelcomeCapability2Desc"},{icon:Vn,titleKey:"chatWelcomeCapability3Title",descKey:"chatWelcomeCapability3Desc"}];function ky({onCreateSession:e}){return h.jsx("div",{className:"h-full flex items-center justify-center p-8",children:h.jsxs("div",{className:"max-w-lg w-full text-center",children:[h.jsx("div",{className:"mx-auto mb-6 h-16 w-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:h.jsx(Xi,{className:"h-8 w-8 text-primary"})}),h.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:v("chatWelcomeTitle")}),h.jsx("p",{className:"text-sm text-gray-500 mb-8",children:v("chatWelcomeSubtitle")}),h.jsx("div",{className:"grid grid-cols-3 gap-3",children:Sy.map(t=>{const n=t.icon;return h.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:[h.jsx("div",{className:"h-9 w-9 rounded-xl bg-primary/8 flex items-center justify-center mb-3",children:h.jsx(n,{className:"h-4.5 w-4.5 text-primary"})}),h.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-1",children:v(t.titleKey)}),h.jsx("div",{className:"text-[11px] text-gray-500 leading-relaxed",children:v(t.descKey)})]},t.titleKey)})})]})})}const wy={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},lt=zn(e=>({snapshot:wy,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function Cy(){return h.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-gray-200"}),h.jsx("div",{className:"h-24 w-[78%] animate-pulse rounded-2xl bg-gray-200/80"}),h.jsx("div",{className:"h-20 w-[62%] animate-pulse rounded-2xl bg-gray-200/80"}),h.jsx("div",{className:"h-28 w-[84%] animate-pulse rounded-2xl bg-gray-200/80"})]})})}),h.jsx("div",{className:"border-t border-gray-200/80 bg-white p-4",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)]",children:h.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white shadow-card p-4",children:[h.jsx("div",{className:"h-16 w-full animate-pulse rounded-xl bg-gray-200/80"}),h.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[h.jsx("div",{className:"h-8 w-36 animate-pulse rounded-lg bg-gray-200/80"}),h.jsx("div",{className:"h-8 w-20 animate-pulse rounded-lg bg-gray-200/80"})]})]})})})]})}function vy(){var c;const e=Kn(),t=lt(p=>p.snapshot),n=k.useRef(null),r=t.threadRef??n,i=!!(t.selectedSessionKey||t.sessionTypeLabel),s=t.sessionDisplayName||t.selectedSessionKey||v("chatSidebarNewTask"),a=!t.selectedSessionKey&&t.messages.length===0&&!t.isSending,l=t.modelOptions.length>0,o=t.isProviderStateResolved&&!l,u=t.isHistoryLoading&&t.messages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:d}=Mx({scrollRef:r,resetKey:t.selectedSessionKey,isLoading:t.isHistoryLoading,hasContent:t.messages.length>0,contentVersion:t.messages[t.messages.length-1]??null});return t.isProviderStateResolved?h.jsxs("section",{className:"flex-1 min-h-0 flex flex-col overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:[h.jsxs("div",{className:ve("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:[h.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-medium text-gray-700 truncate",children:s}),t.sessionTypeLabel?h.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?h.jsx(je,{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:h.jsx(Ji,{className:"h-4 w-4"})}):null]}),o&&h.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:[h.jsx("span",{className:"text-xs text-amber-800",children:v("chatModelNoOptions")}),h.jsx("button",{type:"button",onClick:e.chatThreadManager.goToProviders,className:"text-xs font-semibold text-amber-900 underline-offset-2 hover:underline",children:v("chatGoConfigureProvider")})]}),t.sessionTypeUnavailable&&((c=t.sessionTypeUnavailableMessage)==null?void 0:c.trim())&&h.jsx("div",{className:"px-5 py-2.5 border-b border-amber-200/70 bg-amber-50/70 shrink-0",children:h.jsx("span",{className:"text-xs text-amber-800",children:t.sessionTypeUnavailableMessage})}),h.jsx("div",{ref:r,onScroll:d,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:a?h.jsx(ky,{onCreateSession:e.chatThreadManager.createSession}):u?h.jsx("div",{className:"h-full"}):t.messages.length===0?h.jsx("div",{className:"px-5 py-5 text-sm text-gray-500",children:v("chatNoMessages")}):h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:h.jsx(by,{messages:t.messages,isSending:t.isSending&&t.isAwaitingAssistantOutput})})}),h.jsx(ty,{})]}):h.jsx(Cy,{})}function _i(e){return zt(e??void 0)}function Ty(e){return typeof e!="number"||!Number.isFinite(e)?"-":zt(new Date(e))}function Iy(e){if(typeof e!="number"||!Number.isFinite(e))return"-";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function My(e){const t=e.schedule;return t.kind==="cron"?t.expr?`cron ${t.expr}`:"cron":t.kind==="every"?`every ${Iy(t.everyMs)}`:t.kind==="at"?`at ${Ty(t.atMs)}`:"-"}function Ny(e){if(!e.payload.deliver)return"-";const t=e.payload.channel??"-",n=e.payload.to??"-";return`${t}:${n}`}function Ey(e,t){const 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 Ly(e,t){return t==="all"?!0:t==="enabled"?e.enabled:!e.enabled}function Ay(){var m;const[e,t]=k.useState(""),[n,r]=k.useState("all"),i=Gl({all:!0}),s=Xl(),a=Yl(),l=Jl(),{confirm:o,ConfirmDialog:u}=ss(),d=k.useMemo(()=>{var S;return(((S=i.data)==null?void 0:S.jobs)??[]).filter(g=>Ey(g,e)).filter(g=>Ly(g,n))},[i.data,e,n]),c=async x=>{await o({title:`${v("cronDeleteConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,variant:"destructive",confirmLabel:v("delete")})&&s.mutate({id:x.id})},p=async x=>{const S=!x.enabled;await o({title:S?`${v("cronEnableConfirm")}?`:`${v("cronDisableConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,variant:S?"default":"destructive",confirmLabel:S?v("cronEnable"):v("cronDisable")})&&a.mutate({id:x.id,enabled:S})},f=async x=>{const S=!x.enabled;await o({title:S?`${v("cronRunForceConfirm")}?`:`${v("cronRunConfirm")}?`,description:x.name?`${x.name} (${x.id})`:x.id,confirmLabel:v("cronRunNow")})&&l.mutate({id:x.id,force:S})};return h.jsxs(jo,{fullHeight:!0,children:[h.jsx(Po,{title:v("cronPageTitle"),description:v("cronPageDescription"),actions:h.jsx(je,{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:h.jsx(Fl,{className:ve("h-4 w-4",i.isFetching&&"animate-spin")})})}),h.jsx("div",{className:"mb-6",children:h.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[h.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[h.jsx(Hn,{value:e,onChange:x=>t(x.target.value),placeholder:v("cronSearchPlaceholder"),className:"pl-9"}),h.jsx(Vn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"})]}),h.jsx("div",{className:"min-w-[180px]",children:h.jsxs(Zl,{value:n,onValueChange:x=>r(x),children:[h.jsx(eo,{className:"w-full",children:h.jsx(to,{placeholder:v("cronStatusLabel")})}),h.jsxs(no,{children:[h.jsx(ut,{value:"all",children:v("cronStatusAll")}),h.jsx(ut,{value:"enabled",children:v("cronStatusEnabled")}),h.jsx(ut,{value:"disabled",children:v("cronStatusDisabled")})]})]})}),h.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[v("cronTotalLabel"),": ",((m=i.data)==null?void 0:m.total)??0," / ",d.length]})]})}),h.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar",children:i.isLoading?h.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:v("cronLoading")}):d.length===0?h.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:v("cronEmpty")}):h.jsx("div",{className:"space-y-4",children:d.map(x=>h.jsx(ro,{className:"border border-gray-200",children:h.jsx(io,{className:"pt-5 pb-5",children:h.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[h.jsxs("div",{className:"min-w-[220px] flex-1",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx("span",{className:"text-sm font-semibold text-gray-900",children:x.name||x.id}),h.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:x.id}),h.jsx("span",{className:ve("text-[10px] font-semibold px-2 py-0.5 rounded-full",x.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:x.enabled?v("enabled"):v("disabled")}),x.deleteAfterRun&&h.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:v("cronOneShot")})]}),h.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[v("cronScheduleLabel"),": ",My(x)]}),h.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:x.payload.message}),h.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[v("cronDeliverTo"),": ",Ny(x)]})]}),h.jsxs("div",{className:"min-w-[220px] text-xs text-gray-500 space-y-2",children:[h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronNextRun"),":"]})," ",_i(x.state.nextRunAt)]}),h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronLastRun"),":"]})," ",_i(x.state.lastRunAt)]}),h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[v("cronLastStatus"),":"]})," ",x.state.lastStatus??"-"]}),x.state.lastError&&h.jsx("div",{className:"text-[11px] text-red-500 break-words",children:x.state.lastError})]}),h.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[h.jsxs(je,{variant:"subtle",size:"sm",onClick:()=>f(x),className:"gap-1",children:[h.jsx(Ol,{className:"h-3.5 w-3.5"}),v("cronRunNow")]}),h.jsxs(je,{variant:x.enabled?"outline":"primary",size:"sm",onClick:()=>p(x),className:"gap-1",children:[h.jsx(zl,{className:"h-3.5 w-3.5"}),x.enabled?v("cronDisable"):v("cronEnable")]}),h.jsxs(je,{variant:"destructive",size:"sm",onClick:()=>c(x),className:"gap-1",children:[h.jsx(Ji,{className:"h-3.5 w-3.5"}),v("delete")]})]})]})})},x.id))})}),h.jsx(u,{})]})}function Ry(e){const{view:t,routeSessionKey:n,selectedSessionKey:r,selectedAgentId:i,setSelectedSessionKey:s,setSelectedAgentId:a,selectedSessionKeyRef:l,resetStreamState:o,resolveAgentIdFromSessionKey:u}=e;k.useEffect(()=>{if(t==="chat"){if(n){r!==n&&s(n);return}r!==null&&(s(null),o())}},[o,n,r,s,t]),k.useEffect(()=>{const d=r?u(r):null;d&&i!==d&&a(d)},[u,i,r,a]),k.useEffect(()=>{l.current=r},[r,l])}function jy({view:e,confirmDialog:t}){return h.jsxs("div",{className:"h-full flex",children:[h.jsx(_x,{}),e==="chat"?h.jsx(vy,{}):h.jsx("section",{className:"flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white",children:e==="cron"?h.jsx("div",{className:"h-full overflow-auto custom-scrollbar",children:h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:h.jsx(Ay,{})})}):h.jsx("div",{className:"h-full overflow-hidden",children:h.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:h.jsx(ko,{forcedType:"skills"})})})}),t]})}function Py(){return(e,t)=>fetch(e,{credentials:"include",...t})}const On="sid_";function Dy(e){var r;const t=/^agent:([^:]+):/i.exec(e.trim());if(!t)return null;const n=(r=t[1])==null?void 0:r.trim();return n||null}function Fy(e){const t=new TextEncoder().encode(e);let n="";for(const i of t)n+=String.fromCharCode(i);const r=btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"");return`${On}${r}`}function Oy(e){if(!e.startsWith(On))return null;const t=e.slice(On.length).replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4===0?"":"=".repeat(4-t.length%4);try{const r=atob(t+n),i=Uint8Array.from(r,s=>s.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}}function zy(e){if(!e)return null;const t=Oy(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function _y(e){return`/chat/${Fy(e)}`}const ke="native";function ze(e){return typeof e!="string"?ke:e.trim().toLowerCase()||ke}function gt(e,t){return e==="native"?v("chatSessionTypeNative"):e.trim().split(/[-_]+/g).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function By(e){var n;const t=new Map;for(const r of e){const i=ze(r.value);t.set(i,{value:i,label:((n=r.label)==null?void 0:n.trim())||gt(i),ready:r.ready??!0,reason:r.reason??null,reasonMessage:r.reasonMessage??null,supportedModels:r.supportedModels,recommendedModel:r.recommendedModel??null,cta:r.cta??null})}return t.has(ke)||t.set(ke,{value:ke,label:gt(ke),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((r,i)=>r.value===ke?-1:i.value===ke?1:r.value.localeCompare(i.value))}function Vy(e){const{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:s}=e,a=k.useMemo(()=>By((s==null?void 0:s.options)??[]),[s==null?void 0:s.options]),l=k.useMemo(()=>{const S=[...a],g=ze(t==null?void 0:t.sessionType);return S.some(I=>I.value===g)||S.push({value:g,label:gt(g),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),S.sort((I,N)=>I.value===ke?-1:N.value===ke?1:I.value.localeCompare(N.value))},[a,t==null?void 0:t.sessionType]),o=k.useMemo(()=>ze((s==null?void 0:s.defaultType)??ke),[s==null?void 0:s.defaultType]),u=k.useRef(null),d=k.useMemo(()=>ze((t==null?void 0:t.sessionType)??r??o),[o,r,t==null?void 0:t.sessionType]),c=k.useMemo(()=>l.find(S=>S.value===d)??null,[d,l]);k.useEffect(()=>{if(n)return;const S=typeof r=="string"?r.trim():"",g=ze(r);(S.length===0||u.current===g||u.current===null&&g===ke)&&(u.current=o,g!==o&&i(o))},[o,r,n,i]);const p=!n||!!(t!=null&&t.sessionTypeMutable),f=k.useMemo(()=>new Set(a.map(S=>S.value)),[a]),m=k.useMemo(()=>t&&!f.has(ze(t.sessionType))?!0:(c==null?void 0:c.ready)===!1,[f,t,c==null?void 0:c.ready]),x=k.useMemo(()=>{var S;return t&&!f.has(ze(t.sessionType))?`${gt(d)} ${v("chatSessionTypeUnavailableSuffix")}`:(c==null?void 0:c.ready)===!1?((S=c.reasonMessage)==null?void 0:S.trim())||`${c.label} setup required`:null},[f,t,d,c]);return{sessionTypeOptions:l,selectedSessionTypeOption:c,defaultSessionType:o,selectedSessionType:d,canEditSessionType:p,sessionTypeUnavailable:m,sessionTypeUnavailableMessage:x}}function Bi(e){return(e==null?void 0:e.trim().toLowerCase())||"native"}function Hy(e,t){if(typeof t!="string")return!1;const n=t.trim();return n?e.some(r=>r.value===n):!1}function Uy(e,t){return typeof t=="string"&&e.includes(t)}function $y(e){return e.length===0?null:e.includes("off")?"off":e[0]??null}function Va(e){const{currentValue:t,selectedSessionPreferredValue:n,fallbackPreferredValue:r,defaultValue:i,isValueSupported:s,firstAvailableValue:a,preferSessionPreferredValue:l=!1,preserveCurrentValueOnSessionChange:o=!1}=e;return s(t)&&(!l||o)?t:s(n)?n:s(r)?r:s(i)?i:a}function Ky(e){var n;const{modelOptions:t}=e;return t.length===0?"":Va({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:r=>Hy(t,r),firstAvailableValue:((n=t[0])==null?void 0:n.value)??"",preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function qy(e){const{supportedThinkingLevels:t}=e;return t.length===0?null:Va({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:n=>Uy(t,n),firstAvailableValue:$y(t)??"off",preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function Ha(e){const t=Bi(e.sessionType);let n,r=Number.NEGATIVE_INFINITY;for(const i of e.sessions){if(i.key===e.selectedSessionKey||Bi(i.sessionType)!==t)continue;const s=e.readPreference(i);if(s==null)continue;const a=Date.parse(i.updatedAt),l=Number.isFinite(a)?a:Number.NEGATIVE_INFINITY;(n===void 0||l>r)&&(n=s,r=l)}return n}function Wy(e){return Ha({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:t=>{var r;return((r=t.preferredModel)==null?void 0:r.trim())||void 0}})}function Qy(e){return Ha({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:t=>t.preferredThinking??void 0})}function Ua(e){const{isPreferenceAvailable:t,emptyValue:n,selectedSessionKey:r,selectedSessionExists:i=!1,setValue:s,resolveValue:a}=e,l=k.useRef(void 0),o=k.useRef(a);k.useEffect(()=>{o.current=a},[a]),k.useEffect(()=>{const u=l.current!==r;if(!t){s(n),l.current=r;return}s(d=>o.current({currentValue:d,sessionChanged:u,preserveCurrentValueOnSessionChange:u&&!!r&&!i})),l.current=r},[n,t,i,r,s])}function Gy(e){const{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,setSelectedModel:l}=e;Ua({isPreferenceAvailable:t.length>0,emptyValue:"",selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:d})=>Ky({currentSelectedModel:o,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,preferSessionPreferredModel:u,preserveCurrentSelectedModelOnSessionChange:d})})}function Xy(e){const{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,setSelectedThinkingLevel:l}=e;Ua({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:d})=>qy({currentSelectedThinkingLevel:o,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,preferSessionPreferredThinking:u,preserveCurrentSelectedThinkingOnSessionChange:d})})}function Yy(){return _l({queryKey:["ncp-session-types"],queryFn:so,staleTime:1e4,retry:!1})}function Jy(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):e}function Zy(e){if(!e.supportedModels||e.supportedModels.length===0)return e.modelOptions;const t=new Set(e.supportedModels),n=e.modelOptions.filter(r=>t.has(r.value));return n.length>0?n:e.modelOptions}function eb(e){var P,F,T,O,B,U,w,R;const t=ao(),n=lo(),r=es({limit:200}),i=Yy(),s=wo("skill"),a=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),l=k.useMemo(()=>{const E=Do({meta:n.data,config:t.data,onlyConfigured:!0}),V=new Set,j=[];for(const C of E)for(const D of C.models){const Q=Fo(C.prefix,D);!Q||V.has(Q)||(V.add(Q),j.push({value:Q,modelLabel:D,providerLabel:C.displayName,thinkingCapability:Oo(C.modelThinking,D,C.aliases)}))}return j.sort((C,D)=>{const Q=C.providerLabel.localeCompare(D.providerLabel);return Q!==0?Q:C.modelLabel.localeCompare(D.modelLabel)})},[n.data,t.data]),o=k.useMemo(()=>{var E;return((E=r.data)==null?void 0:E.sessions)??[]},[(P=r.data)==null?void 0:P.sessions]),u=k.useMemo(()=>is(o),[o]),d=k.useMemo(()=>Jy(u,e.query),[u,e.query]),c=k.useMemo(()=>u.find(E=>E.key===e.selectedSessionKey)??null,[u,e.selectedSessionKey]),p=k.useMemo(()=>{var E;return((E=s.data)==null?void 0:E.records)??[]},[(F=s.data)==null?void 0:F.records]),f=Vy({selectedSession:c,selectedSessionKey:e.selectedSessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=k.useMemo(()=>{var E;return Zy({modelOptions:l,supportedModels:(E=f.selectedSessionTypeOption)==null?void 0:E.supportedModels})},[l,(T=f.selectedSessionTypeOption)==null?void 0:T.supportedModels]),x=k.useMemo(()=>Wy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]),S=k.useMemo(()=>m.find(E=>E.value===e.currentSelectedModel),[m,e.currentSelectedModel]),g=k.useMemo(()=>{var E;return((E=S==null?void 0:S.thinkingCapability)==null?void 0:E.supported)??[]},[(O=S==null?void 0:S.thinkingCapability)==null?void 0:O.supported]),I=k.useMemo(()=>{var E;return((E=S==null?void 0:S.thinkingCapability)==null?void 0:E.default)??null},[(B=S==null?void 0:S.thinkingCapability)==null?void 0:B.default]),N=k.useMemo(()=>Qy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]);return Gy({modelOptions:m,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredModel:c==null?void 0:c.preferredModel,fallbackPreferredModel:((U=f.selectedSessionTypeOption)==null?void 0:U.recommendedModel)??x,defaultModel:((w=f.selectedSessionTypeOption)==null?void 0:w.recommendedModel)??((R=t.data)==null?void 0:R.agents.defaults.model),setSelectedModel:e.setSelectedModel}),Xy({supportedThinkingLevels:g,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredThinking:(c==null?void 0:c.preferredThinking)??null,fallbackPreferredThinking:N??null,defaultThinkingLevel:I,setSelectedThinkingLevel:e.setSelectedThinkingLevel}),{configQuery:t,configMetaQuery:n,sessionsQuery:r,sessionTypesQuery:i,installedSkillsQuery:s,isProviderStateResolved:a,modelOptions:m,sessionSummaries:o,sessions:d,skillRecords:p,selectedSession:c,...f}}class tb{constructor(t,n){this.uiManager=t,this.streamActionsManager=n,this.resolveUpdateValue=(r,i)=>typeof i=="function"?i(r):i,this.setSelectedAgentId=r=>{const i=fe.getState().snapshot.selectedAgentId,s=this.resolveUpdateValue(i,r);s!==i&&fe.getState().setSnapshot({selectedAgentId:s})},this.setSelectedSessionKey=r=>{const i=fe.getState().snapshot.selectedSessionKey,s=this.resolveUpdateValue(i,r);s!==i&&fe.getState().setSnapshot({selectedSessionKey:s})},this.createSession=r=>{const{snapshot:i}=J.getState(),{defaultSessionType:s}=i,a=s||"native",l=typeof r=="string"&&r.trim().length>0?r.trim():a;this.streamActionsManager.resetStreamState(),J.getState().setSnapshot({pendingSessionType:l}),this.uiManager.goToChatRoot()},this.selectSession=r=>{this.uiManager.goToSession(r)},this.setQuery=r=>{const i=fe.getState().snapshot.query,s=this.resolveUpdateValue(i,r);s!==i&&fe.getState().setSnapshot({query:s})}}}const kn=async()=>{},Vi=()=>{};class nb{constructor(){this.actions={sendMessage:kn,stopCurrentRun:kn,resumeRun:kn,resetStreamState:Vi,applyHistoryMessages:Vi},this.bind=t=>{this.actions={...this.actions,...t}},this.sendMessage=t=>this.actions.sendMessage(t),this.stopCurrentRun=()=>this.actions.stopCurrentRun(),this.resumeRun=t=>this.actions.resumeRun(t),this.resetStreamState=()=>this.actions.resetStreamState(),this.applyHistoryMessages=(t,n)=>this.actions.applyHistoryMessages(t,n)}}const rb=async e=>!1;class ib{constructor(){this.state={pathname:""},this.actions={navigate:null,confirm:rb},this.syncState=t=>{this.state={...this.state,...t}},this.bindActions=t=>{this.actions={...this.actions,...t}},this.confirm=async t=>this.actions.confirm(t),this.navigateTo=(t,n)=>{this.actions.navigate&&(this.state.pathname===t&&!(n!=null&&n.replace)||(this.actions.navigate(t,n),this.state.pathname=t))},this.goToProviders=()=>{this.navigateTo("/providers")},this.goToChatRoot=t=>{this.navigateTo("/chat",t)},this.goToSession=(t,n)=>{this.navigateTo(_y(t),n)}}}function sb(e){const t=e.trim();return t.length>0?t:null}function ab(e){return e??null}class lb{constructor(t){this.updateSession=t,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{const n=J.getState().snapshot,i=fe.getState().snapshot.selectedSessionKey;i&&this.enqueue({sessionKey:i,patch:{preferredModel:sb(n.selectedModel),preferredThinking:ab(n.selectedThinkingLevel)}})}}enqueue(t){this.queued=t,!this.inFlight&&this.startFlush()}startFlush(){this.inFlight=this.flush().catch(t=>{console.error(`Failed to sync chat session preferences: ${String(t)}`)}).finally(()=>{this.inFlight=null,this.queued&&this.startFlush()})}async flush(){for(;this.queued;){const t=this.queued;this.queued=null,await this.updateSession(t.sessionKey,t.patch)}}}class ob{constructor(t,n,r){this.uiManager=t,this.streamActionsManager=n,this.getDraftSessionId=r,this.sessionPreferenceSync=new lb(Zi),this.buildAttachmentSignature=i=>[i.assetUri??"",i.url??"",i.name,i.mimeType,String(i.sizeBytes),i.contentBase64??""].join(":"),this.hasSnapshotChanges=i=>{const s=J.getState().snapshot;for(const[a,l]of Object.entries(i))if(!Object.is(s[a],l))return!0;return!1},this.resolveUpdateValue=(i,s)=>typeof s=="function"?s(i):s,this.isSameStringArray=(i,s)=>i.length===s.length&&i.every((a,l)=>a===s[l]),this.syncComposerSnapshot=i=>{const s=J.getState().snapshot.attachments,a=Ax(i,s);J.getState().setSnapshot({composerNodes:i,attachments:a,draft:Ri(i),selectedSkills:ji(i)})},this.syncComposerSnapshotWithAttachments=(i,s)=>{J.getState().setSnapshot({composerNodes:i,attachments:s,draft:Ri(i),selectedSkills:ji(i)})},this.dedupeAttachments=i=>{const s=new Set,a=[];for(const l of i){const o=this.buildAttachmentSignature(l);s.has(o)||(s.add(o),a.push(l))}return a},this.syncSnapshot=i=>{if(this.hasSnapshotChanges(i)&&(J.getState().setSnapshot(i),Object.prototype.hasOwnProperty.call(i,"modelOptions")||Object.prototype.hasOwnProperty.call(i,"selectedModel")||Object.prototype.hasOwnProperty.call(i,"selectedThinkingLevel"))){const{selectedModel:s}=J.getState().snapshot;this.reconcileThinkingForModel(s)}},this.setDraft=i=>{const s=J.getState().snapshot.draft,a=this.resolveUpdateValue(s,i);a!==s&&this.syncComposerSnapshot(Nx(a))},this.setComposerNodes=i=>{const s=J.getState().snapshot.composerNodes,a=this.resolveUpdateValue(s,i);Object.is(a,s)||this.syncComposerSnapshot(a)},this.addAttachments=i=>{if(i.length===0)return[];const s=J.getState().snapshot,a=new Set(s.attachments.map(this.buildAttachmentSignature)),l=this.dedupeAttachments([...s.attachments,...i]),o=l.filter(d=>!a.has(this.buildAttachmentSignature(d)));if(o.length===0)return[];const u=Pi(s.composerNodes,l);return this.syncComposerSnapshotWithAttachments(u,l),o},this.restoreComposerState=(i,s)=>{const a=this.dedupeAttachments(s),l=Pi(i,a);this.syncComposerSnapshotWithAttachments(l,a)},this.setPendingSessionType=i=>{const s=J.getState().snapshot.pendingSessionType,a=this.resolveUpdateValue(s,i);a!==s&&J.getState().setSnapshot({pendingSessionType:a})},this.send=async()=>{const i=J.getState().snapshot,s=fe.getState().snapshot,a=i.draft.trim(),l=i.attachments,o=Rx(i.composerNodes,l);if(!o.some(f=>f.type!=="text"||f.text.trim().length>0))return;const{selectedSkills:d,composerNodes:c}=i,p=s.selectedSessionKey??this.getDraftSessionId();s.selectedSessionKey||this.uiManager.goToSession(p,{replace:!0}),this.setComposerNodes(za()),await this.streamActionsManager.sendMessage({message:a,sessionKey:p,agentId:s.selectedAgentId,sessionType:i.selectedSessionType,model:i.selectedModel||void 0,thinkingLevel:i.selectedThinkingLevel??void 0,stopSupported:!0,requestedSkills:d,attachments:l,parts:o,restoreDraftOnError:!0,composerNodes:c})},this.stop=async()=>{await this.streamActionsManager.stopCurrentRun()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.setSelectedModel=i=>{const s=J.getState().snapshot.selectedModel,a=this.resolveUpdateValue(s,i);a!==s&&(J.getState().setSnapshot({selectedModel:a}),this.reconcileThinkingForModel(a))},this.setSelectedThinkingLevel=i=>{const s=J.getState().snapshot.selectedThinkingLevel,a=this.resolveUpdateValue(s,i);a!==s&&J.getState().setSnapshot({selectedThinkingLevel:a})},this.selectSessionType=i=>{const s=ze(i);J.getState().setSnapshot({selectedSessionType:s,pendingSessionType:s})},this.setSelectedSkills=i=>{const s=J.getState().snapshot,{selectedSkills:a}=s,l=this.resolveUpdateValue(a,i);this.isSameStringArray(l,a)||this.syncComposerSnapshot(Lx(s.composerNodes,l,s.skillRecords))},this.selectModel=i=>{this.setSelectedModel(i),_a.remember(i),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectThinkingLevel=i=>{this.setSelectedThinkingLevel(i),this.sessionPreferenceSync.syncSelectedSessionPreferences()},this.selectSkills=i=>{this.setSelectedSkills(i)}}resolveThinkingForModel(t,n){const r=t==null?void 0:t.thinkingCapability;return!r||r.supported.length===0?null:n==="off"?"off":n&&r.supported.includes(n)?n:r.default&&r.supported.includes(r.default)?r.default:"off"}reconcileThinkingForModel(t){const n=J.getState().snapshot,r=n.modelOptions.find(a=>a.value===t),{selectedThinkingLevel:i}=n,s=this.resolveThinkingForModel(r,i);s!==i&&J.getState().setSnapshot({selectedThinkingLevel:s})}}class ub{constructor(t,n,r){this.uiManager=t,this.sessionListManager=n,this.streamActionsManager=r,this.hasSnapshotChanges=i=>{const s=lt.getState().snapshot;for(const[a,l]of Object.entries(i))if(!Object.is(s[a],l))return!0;return!1},this.syncSnapshot=i=>{this.hasSnapshotChanges(i)&&lt.getState().setSnapshot(i)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.deleteCurrentSession=async()=>{const{snapshot:{selectedSessionKey:i}}=fe.getState();if(!(!i||!await this.uiManager.confirm({title:v("chatDeleteSessionConfirm"),variant:"destructive",confirmLabel:v("delete")}))){lt.getState().setSnapshot({isDeletePending:!0});try{await oo(i),uo(kr,i),kr.removeQueries({queryKey:["ncp-session-messages",i]}),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0})}finally{lt.getState().setSnapshot({isDeletePending:!1})}}}}}class cb{constructor(){this.chatUiManager=new ib,this.chatStreamActionsManager=new nb,this.chatSessionListManager=new tb(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new ob(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatThreadManager=new ub(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId="",this.setDraftSessionId=t=>{this.draftSessionId=t}}getDraftSessionId(){return this.draftSessionId}}function db(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const r=n.trim();r&&t.add(r)}return[...t]}function hb(e){var r,i,s;const t={};(r=e.model)!=null&&r.trim()&&(t.model=e.model.trim(),t.preferred_model=e.model.trim()),(i=e.thinkingLevel)!=null&&i.trim()&&(t.thinking=e.thinkingLevel.trim(),t.preferred_thinking=e.thinkingLevel.trim()),(s=e.sessionType)!=null&&s.trim()&&(t.session_type=e.sessionType.trim());const n=db(e.requestedSkills);return n.length>0&&(t.requested_skills=n),t}function fb(e){return e instanceof Error?e.message.includes("ncp session not found:"):!1}function pb({view:e}){var re,De,we;const[t]=k.useState(()=>new cb),[n,r]=k.useState(()=>wr()),i=fe(H=>H.snapshot.query),s=fe(H=>H.snapshot.selectedSessionKey),a=fe(H=>H.snapshot.selectedAgentId),l=J(H=>H.snapshot.pendingSessionType),o=J(H=>H.snapshot.selectedModel),{confirm:u,ConfirmDialog:d}=ss(),c=Bl(),p=Vl(),{sessionId:f}=Hl(),m=k.useRef(null),x=k.useRef(s),S=k.useRef(!1),g=k.useMemo(()=>zy(f),[f]),{installedSkillsQuery:I,isProviderStateResolved:N,modelOptions:P,sessionSummaries:F,skillRecords:T,selectedSession:O,sessionTypeOptions:B,defaultSessionType:U,selectedSessionType:w,canEditSessionType:R,sessionTypeUnavailable:E,sessionTypeUnavailableMessage:V}=eb({query:i,selectedSessionKey:s,currentSelectedModel:o,pendingSessionType:l,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),j=s??n,C=k.useRef(F);k.useEffect(()=>{C.current=F},[F]);const[D]=k.useState(()=>new Xo({baseUrl:ts,basePath:"/api/ncp/agent",fetchImpl:Py()})),Q=k.useCallback(async(H,ae)=>{ae.throwIfAborted();let be=null;try{be=await co(H,300)}catch(Le){if(!fb(Le))throw Le}ae.throwIfAborted();const Fe=C.current.find(Le=>Le.sessionId===H)??null;return{messages:(be==null?void 0:be.messages)??[],status:(Fe==null?void 0:Fe.status)==="running"?"running":"idle"}},[]),_=ou({sessionId:j,client:D,loadSeed:Q});k.useEffect(()=>{t.setDraftSessionId(n)},[n,t]),k.useEffect(()=>{if(s===null){const H=wr();r(H),t.setDraftSessionId(H)}},[t,s]);const ue=_.isSending||_.isRunning,y=_.isRunning,se=_.isRunning,ye=_.isRunning?null:"__preparing__",b=((re=_.hydrateError)==null?void 0:re.message)??((De=_.snapshot.error)==null?void 0:De.message)??null;k.useEffect(()=>{const H=()=>{if(_.isHydrating||_.isRunning||_.isSending){S.current=!0;return}S.current=!1,_.reloadSeed()};return ho.subscribe(ae=>{if(ae.type==="session.summary.upsert"){if(ae.payload.summary.sessionId!==j)return;H();return}ae.type==="session.updated"&&ae.payload.sessionKey===j&&H()})},[j,_.isHydrating,_.isRunning,_.isSending,_.reloadSeed]),k.useEffect(()=>{S.current&&(_.isHydrating||_.isRunning||_.isSending||(S.current=!1,_.reloadSeed()))},[_.isHydrating,_.isRunning,_.isSending,_.reloadSeed]),k.useEffect(()=>{t.chatStreamActionsManager.bind({sendMessage:async H=>{var Fe,Le;if(H.sessionKey!==j)return;const ae=hb({model:H.model,thinkingLevel:H.thinkingLevel,sessionType:H.sessionType,requestedSkills:H.requestedSkills}),be=du({sessionId:H.sessionKey,text:H.message,attachments:H.attachments,parts:H.parts,metadata:ae});if(be)try{await _.send(be)}catch(Qt){throw H.restoreDraftOnError&&(H.composerNodes&&H.composerNodes.length>0?(Le=(Fe=t.chatInputManager).restoreComposerState)==null||Le.call(Fe,H.composerNodes,H.attachments??[]):t.chatInputManager.setDraft(Ze=>Ze.trim().length===0?H.message:Ze)),Qt}},stopCurrentRun:async()=>{await _.abort()},resumeRun:async H=>{H.sessionKey===j&&await _.streamRun()},resetStreamState:()=>{x.current=null},applyHistoryMessages:()=>{}})},[j,_,t]),Ry({view:e,routeSessionKey:g,selectedSessionKey:s,selectedAgentId:a,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:x,resetStreamState:t.chatStreamActionsManager.resetStreamState,resolveAgentIdFromSessionKey:Dy}),k.useEffect(()=>{t.chatUiManager.syncState({pathname:c.pathname}),t.chatUiManager.bindActions({navigate:p,confirm:u})},[u,c.pathname,p,t]);const de=O?Ro(O):void 0,Ie=((we=B.find(H=>H.value===w))==null?void 0:we.label)??gt(w);return k.useEffect(()=>{t.chatInputManager.syncSnapshot({isProviderStateResolved:N,defaultSessionType:U,canStopGeneration:se,stopDisabledReason:ye,stopSupported:!0,stopReason:void 0,sendError:b,isSending:ue,modelOptions:P,sessionTypeOptions:B,selectedSessionType:w,canEditSessionType:R,sessionTypeUnavailable:E,skillRecords:T,isSkillsLoading:I.isLoading}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:N,modelOptions:P,sessionTypeUnavailable:E,sessionTypeUnavailableMessage:V,sessionTypeLabel:Ie,selectedSessionKey:s,sessionDisplayName:de,canDeleteSession:!!O,threadRef:m,isHistoryLoading:_.isHydrating,messages:_.visibleMessages,isSending:ue,isAwaitingAssistantOutput:y})},[_.isHydrating,R,se,de,Ie,U,I.isLoading,y,N,ue,b,P.length,P,t,O,s,w,B,E,V,T,ye,m,_.visibleMessages]),h.jsx(Su,{presenter:t,children:h.jsx(jy,{view:e,confirmDialog:h.jsx(d,{})})})}function Mb({view:e}){return h.jsx(pb,{view:e})}export{Mb as ChatPage};