nextclaw 0.16.13 → 0.16.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +225 -103
- package/package.json +11 -11
- package/ui-dist/assets/{ChannelsList-XGMfinnc.js → ChannelsList-C63gOoYI.js} +3 -3
- package/ui-dist/assets/ChatPage-Ci3Gz0qh.js +37 -0
- package/ui-dist/assets/{DocBrowser-DTRCNsSM.js → DocBrowser-CI4jOzJY.js} +1 -1
- package/ui-dist/assets/{LogoBadge-CPMOwWdA.js → LogoBadge-DImV63-L.js} +1 -1
- package/ui-dist/assets/{MarketplacePage-De2qZ9C0.js → MarketplacePage-B360oSAV.js} +1 -1
- package/ui-dist/assets/{McpMarketplacePage-cjVKSQ2f.js → McpMarketplacePage-KIQgx_7h.js} +2 -2
- package/ui-dist/assets/{ModelConfig-CMn3-VZk.js → ModelConfig-Ben3tQoX.js} +1 -1
- package/ui-dist/assets/{ProvidersList-CArDOswN.js → ProvidersList-DE-S9mq0.js} +1 -1
- package/ui-dist/assets/RemoteAccessPage-DxUia6R-.js +1 -0
- package/ui-dist/assets/RuntimeConfig-CQcGfNZT.js +1 -0
- package/ui-dist/assets/{SearchConfig-a38m8Ynx.js → SearchConfig-DeOa-M6j.js} +1 -1
- package/ui-dist/assets/{SecretsConfig-B6mf4JY9.js → SecretsConfig-Ci8pJmzd.js} +2 -2
- package/ui-dist/assets/{SessionsConfig-B_WQ1lVd.js → SessionsConfig-B6zq55yu.js} +2 -2
- package/ui-dist/assets/chat-session-display--oo5yuIw.js +1 -0
- package/ui-dist/assets/{index-D-wEIgPn.js → index-LhlkB00c.js} +4 -4
- package/ui-dist/assets/{label-usOOP7mv.js → label-3TKt0PoZ.js} +1 -1
- package/ui-dist/assets/{page-layout-CuIf20mx.js → page-layout-CopkIM3Q.js} +1 -1
- package/ui-dist/assets/{popover-CTtTCP5d.js → popover-CUx8uRJw.js} +1 -1
- package/ui-dist/assets/security-config-BL29kTzz.js +1 -0
- package/ui-dist/assets/{skeleton-BNUaFYE7.js → skeleton-Bs4zvcql.js} +1 -1
- package/ui-dist/assets/{status-dot-BeHTBy9k.js → status-dot-D6vJMwD7.js} +1 -1
- package/ui-dist/assets/{switch-CtNnWZpa.js → switch-A3-ClT1P.js} +1 -1
- package/ui-dist/assets/{tabs-custom-Dz_4tV62.js → tabs-custom-BVSd5urq.js} +1 -1
- package/ui-dist/assets/{useConfirmDialog-C_n_JIEq.js → useConfirmDialog-ChPriea6.js} +1 -1
- package/ui-dist/index.html +1 -1
- package/ui-dist/assets/ChatPage-DYTcCRPp.js +0 -37
- package/ui-dist/assets/RemoteAccessPage-C0I4tHey.js +0 -1
- package/ui-dist/assets/RuntimeConfig-B4o6uJq9.js +0 -1
- package/ui-dist/assets/ncp-session-adapter-DSacECph.js +0 -1
- package/ui-dist/assets/security-config-Bxrrv8Ac.js +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var Ua=Object.defineProperty;var Va=(e,t,n)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ne=(e,t,n)=>Va(e,typeof t!="symbol"?t+"":t,n);import{r as k,j as h,ae as Ui,v as St,X as $a,af as Ka,f as qa,e as ht,t as Wa,c as Qa,y as Ga,z as Xa,h as Vi,I as Ya,i as Ut,n as Ja,o as $i,V as Za,q as Ki,s as el,w as tl,k as qi,l as nl,m as Wi,a as rl,ag as il,B as $n,G as Kn,ah as sl,ai as al,aj as ll,F as ol,ak as ul,al as cl,_ as hl,am as Qi,an as Gi,ao as dl,ap as fl,aq as pl,ar as ml,as as gl,at as xl,au as yl,av as bl,d as Vt,aw as Sl,A as qn,ax as kl,a0 as wl,a3 as vl,a1 as Cl,a2 as Tl,M as Ml,ay as Xi,az as Il,aA as Nl,aB as El,u as Ll,a4 as Al,aC as Rl,aD as jl}from"./vendor-BEQcLDx6.js";import{t as C,c as ve,I as Wn,B as Fe,i as $t,j as Yi,k as Pl,l as Dl,m as Qn,n as Fl,T as yr,L as br,o as Ol,p as Sr,q as _l,r as kr,h as dt,A as Ji,s as zl,v as Bl,w as Hl,x as Ul,S as Vl,e as $l,f as Kl,g as ql,C as Wl,y as Ql,z as Gl,u as Xl,a as Yl,E as Jl,F as Zl,G as eo}from"./index-D-wEIgPn.js";import{T as to,a as no,b as ro,c as io,P as so,R as ao,d as lo,e as oo,C as Zi,M as uo,u as co}from"./MarketplacePage-De2qZ9C0.js";import{R as ho,A as fo,P as po,C as es,T as mo,a as go,b as xo,c as yo}from"./popover-CTtTCP5d.js";import{S as bo,a as So,c as wr,b as ko,d as wo,s as vo}from"./ncp-session-adapter-DSacECph.js";import{u as ts}from"./useConfirmDialog-C_n_JIEq.js";import{P as Co,a as To}from"./page-layout-CuIf20mx.js";import{b as Mo,c as Io,r as No}from"./provider-models-BOeNnjk9.js";import"./tabs-custom-Dz_4tV62.js";import"./skeleton-BNUaFYE7.js";import"./marketplace-localization-Dk31LJJJ.js";var ee=(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))(ee||{}),vr=/\[\[\s*reply_to_current\s*\]\]/gi,Cr=/\[\[\s*reply_to\s*:\s*([^\]]+?)\s*\]\]/i;function In(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}function Eo(e,t){var s;let n=e,r;vr.test(n)&&(r=In(t),n=n.replace(vr,"").trim());const i=(s=n.match(Cr))==null?void 0:s[1];return i&&(r=In(i),n=n.replace(Cr,"").trim()),r?{content:n,replyTo:r}:{content:n}}function Lo(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=In(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}=Eo(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*Ao(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}=Mr(r);r=o;for(const u of l)yield u}r+=n.decode();const{frames:i}=Mr(r,!0);for(const s of i)yield s}finally{t.releaseLock()}}function Mr(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 Ir="/ncp/agent",Ro="ncp-http-agent-client",ns=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 jo(e){const t=e.trim();if(!t)throw new Error("NcpHttpAgentClient requires a non-empty baseUrl.");return new URL(t)}function Po(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 Do(e){const t=(e??Ir).trim();if(!t)return Ir;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(rs(e))return e.ncpError;if(Fo(e))return e;const t=e instanceof Error?e.message:String(e??"Unknown error");return{code:is(void 0),message:t,...e instanceof Error&&e.stack?{details:{stack:e.stack}}:{}}}function en(e,t={}){return new ns(e,t.alreadyPublished??!1)}function Fo(e){return Gn(e)&&typeof e.code=="string"&&typeof e.message=="string"}function Gn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function rs(e){return e instanceof ns}var Oo={"config-error":"config-error","auth-error":"auth-error","runtime-error":"runtime-error","timeout-error":"timeout-error","abort-error":"abort-error"};function is(e){if(!e)return"runtime-error";const t=Oo[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 _o(e){const t=ss(e);return!t||typeof t.type!="string"||!t.type.trim()?null:t}function zo(e){const t=ss(e);if(!t)return{code:"runtime-error",message:e||"Unknown stream error."};const n=typeof t.code=="string"?t.code:void 0,r=is(n),i=Gn(t.details)?t.details:{};return n&&n!==r&&(i.originalCode=n),{code:r,message:typeof t.message=="string"&&t.message?t.message:"Unknown stream error.",...Object.keys(i).length>0?{details:i}:{}}}function ss(e){try{const t=JSON.parse(e);return Gn(t)?t:null}catch{return null}}var Bo=["text","file","source","step-start","reasoning","tool-invocation","card","rich-text","action","extension"],Ho=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=jo(e.baseUrl),this.basePath=Do(e.basePath),this.fetchImpl=Po(e.fetchImpl),this.defaultHeaders=e.headers??{},this.manifest={endpointKind:"custom",endpointId:((t=e.endpointId)==null?void 0:t.trim())||Ro,version:"0.1.0",supportsStreaming:!0,supportsAbort:!0,supportsProactiveMessages:!1,supportsLiveSessionStream:!0,supportedPartTypes:Bo,expectedLatency:"seconds",metadata:{transport:"http+sse",scope:"agent"}}}async start(){this.started||(this.started=!0,this.publish({type:ee.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:ee.EndpointError,payload:r}),en(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 Ao(n.body)){if(t.signal.aborted)return;this.handleSseFrame(r)}}catch(n){if(t.signal.aborted)return;if(rs(n))throw n;const r=Er(n);throw this.publish({type:ee.EndpointError,payload:r}),en(r)}finally{this.activeControllers.delete(t)}}handleSseFrame(e){if(e.event==="ncp-event"){const t=_o(e.data);if(!t){this.publish({type:ee.EndpointError,payload:{code:"runtime-error",message:"Received malformed ncp-event frame."}});return}this.publish(t);return}if(e.event==="error"){const t=zo(e.data);throw this.publish({type:ee.EndpointError,payload:t}),en(t,{alreadyPublished:!0})}}};function as(e){return{...e,parts:[...e.parts],metadata:e.metadata?{...e.metadata}:void 0}}function tn(e){return as(Lo(e))}function Uo(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 Vo(e,t){return t.trim()?e.id.startsWith("tool-")?!0:e.parts.some(n=>n.type==="tool-invocation"):!1}function $o(e,t,n){for(const[r,i]of e)i===t&&e.set(r,n)}function nn(e,t,n){for(const[r,i]of e)i===n&&(e.delete(r),t.delete(r))}function Nn(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=Nn(e,t);return(n==null?void 0:n.toolName)??null}function st(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 Ko="assistant",qo=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=>tn(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 ee.MessageSent:this.handleMessageSent(e.payload);break;case ee.MessageAbort:this.handleMessageAbort(e.payload);break;case ee.MessageTextStart:this.handleMessageTextStart(e.payload);break;case ee.MessageTextDelta:this.handleMessageTextDelta(e.payload);break;case ee.MessageTextEnd:this.handleMessageTextEnd(e.payload);break;case ee.MessageReasoningStart:this.handleMessageReasoningStart(e.payload);break;case ee.MessageReasoningDelta:this.handleMessageReasoningDelta(e.payload);break;case ee.MessageReasoningEnd:this.handleMessageReasoningEnd(e.payload);break;case ee.MessageToolCallStart:this.handleMessageToolCallStart(e.payload);break;case ee.MessageToolCallArgs:this.handleMessageToolCallArgs(e.payload);break;case ee.MessageToolCallArgsDelta:this.handleMessageToolCallArgsDelta(e.payload);break;case ee.MessageToolCallEnd:this.handleMessageToolCallEnd(e.payload);break;case ee.MessageToolCallResult:this.handleMessageToolCallResult(e.payload);break;case ee.RunStarted:this.handleRunStarted(e.payload);break;case ee.RunFinished:this.handleRunFinished(e.payload);break;case ee.RunError:this.handleRunError(e.payload);break;case ee.RunMetadata:this.handleRunMetadata(e.payload);break;case ee.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?nn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t):nn(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=st(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=st(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 st(n.parts,i)})){const n=this.resolveToolCallTargetMessage(e.sessionId,e.toolCallId),r=st(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(Uo(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=st(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=as(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&&Vo(i,t)){const l={...i,id:t,sessionId:e,status:n};return $o(this.toolCallMessageIdByCallId,i.id,t),this.replaceStreamingMessage(l),l}const s={id:t,sessionId:e,role:Ko,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=Nn(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=Nn(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=tn(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?tn(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),nn(this.toolCallMessageIdByCallId,this.toolCallArgsRawByCallId,t.id)}notifyListeners(){const e=this.getSnapshot();for(const t of this.listeners)t(e)}};function Wo(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 Qo(e){return e.parts.some(t=>t.type==="text"||t.type==="rich-text"||t.type==="reasoning"?t.text.trim().length>0:!0)}function Go(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 Qo(e.message)?{...e,sessionId:e.sessionId,message:{...e.message,sessionId:e.message.sessionId||e.sessionId}}:null}function Xo(e){const t=k.useRef();return(!t.current||t.current.sessionId!==e)&&(t.current={sessionId:e,manager:new qo}),t.current.manager}function Yo({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=>{Wo(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=Go(f,e);if(m){s(!0),await n.dispatch({type:ee.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 Jo(e){return e.isHydrating||e.hydratedSessionId!==e.sessionId}function Zo({sessionId:e,client:t,loadSeed:n,autoResumeRunningSession:r=!0}){const i=Xo(e),s=Yo({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,y=p.current.requestId+1;p.current={requestId:y,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!==y)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(M=>{p.current.requestId===y&&u(Ar(M))})}catch(g){if(m.signal.aborted||p.current.requestId!==y)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:Jo({sessionId:e,hydratedSessionId:d,isHydrating:a}),hydrateError:o,reloadSeed:f}}var ls=200*1024*1024,eu="application/octet-stream";function os(e){const t=e.type.trim().toLowerCase();return t.length>0?t:eu}function tu(e,t){const n=t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0?new Set(t.acceptedMimeTypes.map(s=>s.trim().toLowerCase())):null,r=t.maxBytes??ls,i=os(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 nu(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 ru(e,t){const n=[],r=[];for(const i of e){const s=tu(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:os(i),sizeBytes:i.size,reason:"read-failed"}))),{attachments:[],rejected:r}}}const iu={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 su({status:e,className:t}){const n=iu[e],r=e==="connected"?C("connected"):e==="disconnected"?C("disconnected"):C("connecting");return h.jsx(to,{delayDuration:250,children:h.jsxs(no,{children:[h.jsx(ro,{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(Ui,{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(io,{side:"bottom",className:"text-xs",children:r})]})})}function au(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(Wn,{value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),f())},placeholder:C("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(Fe,{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":C("save"),children:h.jsx(St,{className:"h-3.5 w-3.5"})}),h.jsx(Fe,{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":C("cancel"),children:h.jsx($a,{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(bo,{status:r}):null})]}),h.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400 truncate",children:[t.messageCount," · ",$t(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":C("edit"),children:h.jsx(Ka,{className:"h-3.5 w-3.5"})})]})})}function lu(){const e=qa();return async t=>{try{await Yi(t.sessionKey,{label:t.label}),e.invalidateQueries({queryKey:["ncp-sessions"]}),e.invalidateQueries({queryKey:["ncp-session-messages",t.sessionKey]}),ht.success(C("configSavedApplied"))}catch(n){throw ht.error(C("configSaveFailed")+": "+(n instanceof Error?n.message:String(n))),n}}}const us=k.createContext(null);function ou({presenter:e,children:t}){return h.jsx(us.Provider,{value:e,children:t})}function Xn(){const e=k.useContext(us);if(!e)throw new Error("usePresenter must be used inside ChatPresenterProvider");return e}const uu=e=>`[data-item-index="${e}"]`;function cs(e){const t=e.getItemSelector??uu;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 cu(){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 Wa(Qa(e))}const hs=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}));hs.displayName="ChatInput";const hu=ho,du=mo,fu=fo,ds=k.forwardRef(({className:e,sideOffset:t=8,align:n="start",...r},i)=>h.jsx(po,{children:h.jsx(es,{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})}));ds.displayName=es.displayName;const pu=Ga,mu=Xa,fs=k.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Vi,{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(Ya,{asChild:!0,children:h.jsx(Ut,{className:"h-4 w-4 opacity-50"})})]}));fs.displayName=Vi.displayName;const ps=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(nl,{className:"h-4 w-4"})}));ps.displayName=qi.displayName;const ms=k.forwardRef(({className:e,...t},n)=>h.jsx(Wi,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(Ut,{className:"h-4 w-4"})}));ms.displayName=Wi.displayName;const gs=k.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>h.jsx(Ja,{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(ps,{}),h.jsx(Za,{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(ms,{})]})}));gs.displayName=$i.displayName;const xs=k.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Ki,{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(el,{children:h.jsx(St,{className:"h-4 w-4"})})}),h.jsx(tl,{children:t})]}));xs.displayName=Ki.displayName;const gu=so,xu=ao,yu=lo,ys=k.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(oo,{children:h.jsx(Zi,{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})}));ys.displayName=Zi.displayName;const kt={Popover:hu,PopoverAnchor:fu,PopoverContent:ds,PopoverTrigger:du,Input:hs,Select:pu,SelectContent:gs,SelectItem:xs,SelectTrigger:fs,SelectValue:mu,Tooltip:xu,TooltipContent:ys,TooltipProvider:gu,TooltipTrigger:yu},bu=680,Su=.82,ku=560;function wu(e){const{Popover:t,PopoverAnchor:n,PopoverContent:r}=kt,{elementRef:i,width:s}=cu(),a=k.useRef(null),{isOpen:l,isLoading:o,items:u,activeIndex:d,activeItem:c,texts:p,onSelectItem:f,onOpenChange:m,onSetActiveIndex:y}=e,S=k.useMemo(()=>{if(s)return Math.min(s>ku?s*Su:s,bu)},[s]);return cs({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,M)=>{const I=M===d;return h.jsxs("button",{type:"button",role:"option","aria-selected":I,"data-slash-index":M,onMouseEnter:()=>y(M),onClick:()=>f(g),className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition ${I?"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 vu=rl("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"}}),Pt=k.forwardRef(({className:e,variant:t,size:n,...r},i)=>h.jsx("button",{className:Q(vu({variant:t,size:n,className:e})),ref:i,...r}));Pt.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 Cu(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=kt;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(Pt,{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(Pt,{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(Pt,{size:"icon",className:"h-8 w-8 rounded-full","aria-label":e.sendButtonLabel,onClick:()=>void e.onSend(),disabled:e.sendDisabled,children:h.jsx(il,{className:"h-5 w-5"})})})]})}function Tu(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 Mu(e){const{Input:t,Popover:n,PopoverContent:r,PopoverTrigger:i}=kt,{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(()=>Tu(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]),cs({containerRef:a,activeIndex:d,itemCount:m.length,isEnabled:m.length>0,getItemSelector:g=>`[data-skill-index="${g}"]`});const y=g=>{if(p.has(g)){s.onSelectedKeysChange(s.selectedKeys.filter(M=>M!==g));return}s.onSelectedKeysChange([...s.selectedKeys,g])},S=g=>{if(m.length!==0){if(g.key==="ArrowDown"){g.preventDefault(),c(M=>Math.min(M+1,m.length-1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(M=>Math.max(M-1,0));return}if(g.key==="Enter"){g.preventDefault();const M=m[d];M&&y(M.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(Kn,{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,M)=>{const I=p.has(g.key),D=M===d;return h.jsxs("button",{type:"button",id:`${l}-option-${M}`,role:"option","aria-selected":I,"data-skill-index":M,onClick:()=>y(g.key),onMouseEnter:()=>c(M),className:`flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors ${D?"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(sl,{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:I?"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:I?h.jsx(St,{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(al,{className:"h-3 w-3"})]})}):null]})]})}function bs({icon:e}){return e==="sparkles"?h.jsx(ol,{className:"h-3.5 w-3.5 shrink-0 text-primary"}):e==="brain"?h.jsx(ul,{className:"h-3.5 w-3.5 shrink-0 text-gray-500"}):null}function Iu({icon:e}){return e==="paperclip"?h.jsx(ll,{className:"h-4 w-4"}):h.jsx(bs,{icon:e})}function Nu(e){return e==="model"?"min-w-[220px]":e==="session-type"?"min-w-[140px]":e==="thinking"?"min-w-[150px]":""}function Eu(e){return e==="model"?"w-[320px]":e==="session-type"?"w-[220px]":e==="thinking"?"w-[180px]":""}function Lu({item:e}){const{Select:t,SelectContent:n,SelectItem:r,SelectTrigger:i,SelectValue:s}=kt;return h.jsxs(t,{value:e.value,onValueChange:e.onValueChange,disabled:e.disabled,children:[h.jsx(i,{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 ${Nu(e.key)}`,children:e.selectedLabel?h.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-left",children:[h.jsx(bs,{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(s,{placeholder:e.placeholder})}),h.jsxs(n,{className:Eu(e.key),children:[e.options.length===0?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:null,e.options.map(a=>h.jsx(r,{value:a.value,className:"py-2",children:a.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:a.label}),h.jsx("span",{className:"truncate text-[11px] text-gray-500",children:a.description})]}):h.jsx("span",{className:"truncate text-xs font-semibold text-gray-800",children:a.label})},a.value))]})]})}function Au(e){var s;const{Tooltip:t,TooltipContent:n,TooltipProvider:r,TooltipTrigger:i}=kt;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(Mu,{picker:e.skillPicker}):null,e.selects.map(a=>h.jsx(Lu,{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(Iu,{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(Cu,{...e.actions})]})}const Ru="";function Ss(){return`composer-${Math.random().toString(36).slice(2,10)}`}function gt(e=""){return{id:Ss(),type:"text",text:e}}function Yn(e){return{id:Ss(),type:"token",tokenKind:e.tokenKind,tokenKey:e.tokenKey,label:e.label}}function wt(e){return e.type==="text"?e.text.length:1}function Jn(){return[gt("")]}function ju(e){return[gt(e)]}function Je(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?Jn():t}function Pu(e){return e.map(t=>t.type==="text"?t.text:Ru).join("")}function Du(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Kt(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 Fu(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 Ou(e,t,n,r){return t<=n||e>=r}function _u(e,t,n,r,i){return!n&&r>=i?(e.push(...t),!0):n}function zu(e,t,n,r,i,s,a){const l=Fu(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 Bu(e,t,n,r,i,s){return!r&&i<=s?(e.push(...n),!0):(e.push(t),r)}function rn(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=wt(u),c=l,p=l+d;if(Ou(c,p,i,s)){o=_u(a,r,o,c,s),a.push(u),l=p;continue}u.type==="text"?o=zu(a,u,c,i,s,r,o):o=Bu(a,u,r,o,i,c),l=p}return o||a.push(...r),Je(a)}function Zn(e,t){return Je(e.filter(n=>n.type!=="token"||!t(n)))}function Hu(e,t){if(!t||t.start!==t.end)return null;const n=Pu(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 Uu(e,t,n){return e?e.start<n&&e.end>t:!1}function ks(e){const t=new Map;let n=0;for(const r of e)t.set(r.id,n),n+=wt(r);return t}function ws(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 Vu(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 vs(e,t,n){let r=0;for(let i=0;i<n;i+=1){const s=Vu(e.childNodes[i],i,t);s&&(r+=wt(s))}return r}function $u(e,t,n,r){var l;const i=ws(e,t),s=vs(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 Ku(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 En(e,t,n,r,i){var u;if(t===e)return vs(e,r,n);if(t.nodeType===Node.TEXT_NODE&&t.parentNode===e)return $u(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=ws(e,t);return En(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?Ku(t,n,l,o,s):o}function Cs(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=ks(t),s=En(e,r.startContainer,r.startOffset,t,i),a=En(e,r.endContainer,r.endOffset,t,i);return{start:Math.min(s,a),end:Math.max(s,a)}}function qu(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=wt(c),f=u,m=u+p,y=e.childNodes[d];if(!y){u=m;continue}if(c.type==="text"){if(o<=m)return{container:y.firstChild??y,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 Wu(e){const t=[];for(const n of Array.from(e.childNodes)){if(n.nodeType===Node.TEXT_NODE){t.push(gt(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??Yn({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??gt(i).id,type:"text",text:i})}return Je(t)}function jr(e){const t=Wu(e);return{nodes:t,selection:Cs(e,t)}}class Qu{constructor(){this.nodes=Jn(),this.selection=null,this.sync=(t,n)=>(this.nodes=Je(t),this.selection=n,this.getSnapshot()),this.setSelection=t=>(this.selection=t,this.getSnapshot()),this.replaceDocument=(t,n)=>(this.nodes=Je(t),this.selection=n,this.getSnapshot()),this.insertText=t=>{const n=this.selection??{start:0,end:0};this.nodes=rn(this.nodes,n.start,n.end,[gt(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=Zn(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=rn(this.nodes,i,s,[]),this.selection={start:i,end:i},this.getSnapshot()},this.getSnapshot=()=>({nodes:this.nodes,selection:this.selection,nodeStartMap:ks(this.nodes),documentLength:this.getDocumentLength(),selectedSkillKeys:this.getSelectedSkillKeys(),slashTrigger:this.getSlashTrigger()}),this.getDocumentLength=()=>this.nodes.reduce((t,n)=>t+wt(n),0),this.getSelectedSkillKeys=()=>Kt(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=rn(this.nodes,a,l,[Yn({tokenKind:t,tokenKey:n,label:r})]),this.selection={start:a+1,end:a+1},this.getSnapshot()},this.getSlashTrigger=()=>Hu(this.nodes,this.selection)}}function Gu(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 Xu{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=Uu(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 Yu{constructor(t){this.controller=t,this.surfaceRenderer=new Xu,this.sync=(n,r)=>this.controller.sync(n,r),this.syncSelectionFromRoot=n=>this.controller.setSelection(Cs(n,this.controller.getSnapshot().nodes)),this.restoreSelectionIfFocused=(n,r)=>{!n||document.activeElement!==n||qu(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=Gu({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 Ju{constructor(){this.controller=new Qu,this.viewController=new Yu(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 Zu=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,[y,S]=k.useState(0),[g]=k.useState(()=>new Ju),{snapshot:M,bindRootElement:I,handleBeforeInput:D,handleInput:F,handleCompositionStart:T,handleCompositionEnd:_,handleKeyDown:z,handlePaste:B,handleBlur:w,syncSelectionState:E,imperativeHandle:L}=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(H=>H+1)});return k.useImperativeHandle(n,()=>L,[L]),k.useLayoutEffect(()=>{g.renderSurface(),g.restoreDomAfterCommit(),g.syncViewport()},[g,M.nodes,M.nodeStartMap,y]),h.jsx("div",{className:"px-4 py-2.5",children:h.jsx("div",{className:"min-h-[60px]",children:h.jsx("div",{ref:I,contentEditable:!s,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":"true","data-placeholder":i,onBeforeInput:D,onInput:F,onCompositionStart:T,onCompositionEnd:_,onKeyDown:z,onKeyUp:E,onMouseUp:E,onFocus:E,onBlur:w,onPaste:B,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 ec({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 Ts=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(y=>t.slashMenu.items.length===0?0:Math.min(y,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:y=>{var S,g;(g=r.current)==null||g.syncSelectedSkills(y,((S=t.toolbar.skillPicker)==null?void 0:S.options)??[])}}}:t.toolbar,[t.toolbar]);return k.useImperativeHandle(n,()=>({insertFileToken:(y,S)=>{var g;return(g=r.current)==null?void 0:g.insertFileToken(y,S)},insertFileTokens:y=>{var S;return(S=r.current)==null?void 0:S.insertFileTokens(y)},focusComposer:()=>{var y;return(y=r.current)==null?void 0:y.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(Zu,{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:y=>{var S,g;s(y),(g=(S=t.composer).onSlashQueryChange)==null||g.call(S,y)},onSlashTriggerChange:y=>{u((y==null?void 0:y.start)??null)},onSlashOpenChange:y=>{!y&&o!==null&&c(o)},onSlashActiveIndexChange:l}),h.jsx(wu,{isOpen:p,isLoading:t.slashMenu.isLoading,items:t.slashMenu.items,activeIndex:a,activeItem:f,texts:t.slashMenu.texts,onSelectItem:y=>{var S;c(null),(S=r.current)==null||S.insertSlashItem(y)},onOpenChange:y=>{!y&&o!==null&&c(o)},onSetActiveIndex:l})]}),h.jsx(ec,{hint:t.hint}),h.jsx(Au,{...m})]})})})});Ts.displayName="ChatInputBar";function sn({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(cl,{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(hl,{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(Qi,{className:"h-4 w-4"})})}function tc(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const nc=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rc=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ic={};function Fr(e,t){return(ic.jsx?rc:nc).test(e)}const sc=/[ \t\n\f\r]/g;function ac(e){return typeof e=="object"?e.type==="text"?Or(e.value):!1:Or(e)}function Or(e){return e.replace(sc,"")===""}class vt{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}vt.prototype.normal={};vt.prototype.property={};vt.prototype.space=void 0;function Ms(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new vt(n,r,t)}function Ln(e){return e.toLowerCase()}class fe{constructor(t,n){this.attribute=n,this.property=t}}fe.prototype.attribute="";fe.prototype.booleanish=!1;fe.prototype.boolean=!1;fe.prototype.commaOrSpaceSeparated=!1;fe.prototype.commaSeparated=!1;fe.prototype.defined=!1;fe.prototype.mustUseProperty=!1;fe.prototype.number=!1;fe.prototype.overloadedBoolean=!1;fe.prototype.property="";fe.prototype.spaceSeparated=!1;fe.prototype.space=void 0;let lc=0;const V=qe(),ie=qe(),An=qe(),A=qe(),Z=qe(),Ye=qe(),xe=qe();function qe(){return 2**++lc}const Rn=Object.freeze(Object.defineProperty({__proto__:null,boolean:V,booleanish:ie,commaOrSpaceSeparated:xe,commaSeparated:Ye,number:A,overloadedBoolean:An,spaceSeparated:Z},Symbol.toStringTag,{value:"Module"})),an=Object.keys(Rn);class er extends fe{constructor(t,n,r,i){let s=-1;if(super(t,n),_r(this,"space",i),typeof r=="number")for(;++s<an.length;){const a=an[s];_r(this,an[s],(r&Rn[a])===Rn[a])}}}er.prototype.defined=!0;function _r(e,t,n){n&&(e[t]=n)}function et(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new er(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Ln(r)]=r,n[Ln(s.attribute)]=r}return new vt(t,n,e.space)}const Is=et({properties:{ariaActiveDescendant:null,ariaAtomic:ie,ariaAutoComplete:null,ariaBusy:ie,ariaChecked:ie,ariaColCount:A,ariaColIndex:A,ariaColSpan:A,ariaControls:Z,ariaCurrent:null,ariaDescribedBy:Z,ariaDetails:null,ariaDisabled:ie,ariaDropEffect:Z,ariaErrorMessage:null,ariaExpanded:ie,ariaFlowTo:Z,ariaGrabbed:ie,ariaHasPopup:null,ariaHidden:ie,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Z,ariaLevel:A,ariaLive:null,ariaModal:ie,ariaMultiLine:ie,ariaMultiSelectable:ie,ariaOrientation:null,ariaOwns:Z,ariaPlaceholder:null,ariaPosInSet:A,ariaPressed:ie,ariaReadOnly:ie,ariaRelevant:null,ariaRequired:ie,ariaRoleDescription:Z,ariaRowCount:A,ariaRowIndex:A,ariaRowSpan:A,ariaSelected:ie,ariaSetSize:A,ariaSort:null,ariaValueMax:A,ariaValueMin:A,ariaValueNow:A,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ns(e,t){return t in e?e[t]:t}function Es(e,t){return Ns(e,t.toLowerCase())}const oc=et({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ye,acceptCharset:Z,accessKey:Z,action:null,allow:null,allowFullScreen:V,allowPaymentRequest:V,allowUserMedia:V,alt:null,as:null,async:V,autoCapitalize:null,autoComplete:Z,autoFocus:V,autoPlay:V,blocking:Z,capture:null,charSet:null,checked:V,cite:null,className:Z,cols:A,colSpan:null,content:null,contentEditable:ie,controls:V,controlsList:Z,coords:A|Ye,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V,defer:V,dir:null,dirName:null,disabled:V,download:An,draggable:ie,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V,formTarget:null,headers:Z,height:A,hidden:An,high:A,href:null,hrefLang:null,htmlFor:Z,httpEquiv:Z,id:null,imageSizes:null,imageSrcSet:null,inert:V,inputMode:null,integrity:null,is:null,isMap:V,itemId:null,itemProp:Z,itemRef:Z,itemScope:V,itemType:Z,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V,low:A,manifest:null,max:null,maxLength:A,media:null,method:null,min:null,minLength:A,multiple:V,muted:V,name:null,nonce:null,noModule:V,noValidate:V,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:V,optimum:A,pattern:null,ping:Z,placeholder:null,playsInline:V,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V,referrerPolicy:null,rel:Z,required:V,reversed:V,rows:A,rowSpan:A,sandbox:Z,scope:null,scoped:V,seamless:V,selected:V,shadowRootClonable:V,shadowRootDelegatesFocus:V,shadowRootMode:null,shape:null,size:A,sizes:null,slot:null,span:A,spellCheck:ie,src:null,srcDoc:null,srcLang:null,srcSet:null,start:A,step:null,style:null,tabIndex:A,target:null,title:null,translate:null,type:null,typeMustMatch:V,useMap:null,value:ie,width:A,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Z,axis:null,background:null,bgColor:null,border:A,borderColor:null,bottomMargin:A,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V,declare:V,event:null,face:null,frame:null,frameBorder:null,hSpace:A,leftMargin:A,link:null,longDesc:null,lowSrc:null,marginHeight:A,marginWidth:A,noResize:V,noHref:V,noShade:V,noWrap:V,object:null,profile:null,prompt:null,rev:null,rightMargin:A,rules:null,scheme:null,scrolling:ie,standby:null,summary:null,text:null,topMargin:A,valueType:null,version:null,vAlign:null,vLink:null,vSpace:A,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V,disableRemotePlayback:V,prefix:null,property:null,results:A,security:null,unselectable:null},space:"html",transform:Es}),uc=et({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:xe,accentHeight:A,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:A,amplitude:A,arabicForm:null,ascent:A,attributeName:null,attributeType:null,azimuth:A,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:A,by:null,calcMode:null,capHeight:A,className:Z,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:A,diffuseConstant:A,direction:null,display:null,dur:null,divisor:A,dominantBaseline:null,download:V,dx:null,dy:null,edgeMode:null,editable:null,elevation:A,enableBackground:null,end:null,event:null,exponent:A,externalResourcesRequired:null,fill:null,fillOpacity:A,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:Ye,g2:Ye,glyphName:Ye,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:A,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:A,horizOriginX:A,horizOriginY:A,id:null,ideographic:A,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:A,k:A,k1:A,k2:A,k3:A,k4:A,kernelMatrix:xe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:A,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:A,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:A,overlineThickness:A,paintOrder:null,panose1:null,path:null,pathLength:A,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Z,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:A,pointsAtY:A,pointsAtZ:A,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:xe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:xe,rev:xe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:xe,requiredFeatures:xe,requiredFonts:xe,requiredFormats:xe,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:A,specularExponent:A,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:A,strikethroughThickness:A,string:null,stroke:null,strokeDashArray:xe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:A,strokeOpacity:A,strokeWidth:null,style:null,surfaceScale:A,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:xe,tabIndex:A,tableValues:null,target:null,targetX:A,targetY:A,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:xe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:A,underlineThickness:A,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:A,values:null,vAlphabetic:A,vMathematical:A,vectorEffect:null,vHanging:A,vIdeographic:A,version:null,vertAdvY:A,vertOriginX:A,vertOriginY:A,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:A,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ns}),Ls=et({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()}}),As=et({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Es}),Rs=et({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"},hc=/[A-Z]/g,zr=/-[a-z]/g,dc=/^data[-\w.:]+$/i;function fc(e,t){const n=Ln(t);let r=t,i=fe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&dc.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(zr,mc);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!zr.test(s)){let a=s.replace(hc,pc);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=er}return new i(r,t)}function pc(e){return"-"+e.toLowerCase()}function mc(e){return e.charAt(1).toUpperCase()}const gc=Ms([Is,oc,Ls,As,Rs],"html"),tr=Ms([Is,uc,Ls,As,Rs],"svg");function xc(e){return e.join(" ").trim()}var Qe={},ln,Br;function yc(){if(Br)return ln;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 M=1,I=1;function D(P){var v=P.match(t);v&&(M+=v.length);var j=P.lastIndexOf(o);I=~j?P.length-j:I+P.length}function F(){var P={line:M,column:I};return function(v){return v.position=new T(P),B(),v}}function T(P){this.start=P,this.end={line:M,column:I},this.source=g.source}T.prototype.content=S;function _(P){var v=new Error(g.source+":"+M+":"+I+": "+P);if(v.reason=P,v.filename=g.source,v.line=M,v.column=I,v.source=S,!g.silent)throw v}function z(P){var v=P.exec(S);if(v){var j=v[0];return D(j),S=S.slice(j.length),v}}function B(){z(n)}function w(P){var v;for(P=P||[];v=E();)v!==!1&&P.push(v);return P}function E(){var P=F();if(!(u!=S.charAt(0)||d!=S.charAt(1))){for(var v=2;c!=S.charAt(v)&&(d!=S.charAt(v)||u!=S.charAt(v+1));)++v;if(v+=2,c===S.charAt(v-1))return _("End of comment missing");var j=S.slice(2,v-2);return I+=2,D(j),S=S.slice(v),I+=2,P({type:p,comment:j})}}function L(){var P=F(),v=z(r);if(v){if(E(),!z(i))return _("property missing ':'");var j=z(s),$=P({type:f,property:y(v[0].replace(e,c)),value:j?y(j[0].replace(e,c)):c});return z(a),$}}function H(){var P=[];w(P);for(var v;v=L();)v!==!1&&(P.push(v),w(P));return P}return B(),H()}function y(S){return S?S.replace(l,c):c}return ln=m,ln}var Hr;function bc(){if(Hr)return Qe;Hr=1;var e=Qe&&Qe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.default=n;const t=e(yc());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 Qe}var at={},Ur;function Sc(){if(Ur)return at;Ur=1,Object.defineProperty(at,"__esModule",{value:!0}),at.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 at.camelCase=o,at}var lt,Vr;function kc(){if(Vr)return lt;Vr=1;var e=lt&<.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(bc()),n=Sc();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,lt=r,lt}var wc=kc();const vc=Gi(wc),js=Ps("end"),nr=Ps("start");function Ps(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 Cc(e){const t=nr(e),n=js(e);if(t&&n)return{start:t,end:n}}function ft(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?jn(e):""}function jn(e){return Kr(e&&e.line)+":"+Kr(e&&e.column)}function $r(e){return jn(e&&e.start)+"-"+jn(e&&e.end)}function Kr(e){return e&&typeof e=="number"?e:1}class ue 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=ft(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}}ue.prototype.file="";ue.prototype.name="";ue.prototype.reason="";ue.prototype.message="";ue.prototype.stack="";ue.prototype.column=void 0;ue.prototype.line=void 0;ue.prototype.ancestors=void 0;ue.prototype.cause=void 0;ue.prototype.fatal=void 0;ue.prototype.place=void 0;ue.prototype.ruleId=void 0;ue.prototype.source=void 0;const rr={}.hasOwnProperty,Tc=new Map,Mc=/[A-Z]/g,Ic=new Set(["table","tbody","thead","tfoot","tr"]),Nc=new Set(["td","th"]),Ds="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Ec(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=Oc(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=Fc(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"?tr:gc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Fs(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Fs(e,t,n){if(t.type==="element")return Lc(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ac(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return jc(e,t,n);if(t.type==="mdxjsEsm")return Rc(e,t);if(t.type==="root")return Pc(e,t,n);if(t.type==="text")return Dc(e,t)}function Lc(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=tr,e.schema=i),e.ancestors.push(t);const s=_s(e,t.tagName,!1),a=_c(e,t);let l=sr(e,t);return Ic.has(t.tagName)&&(l=l.filter(function(o){return typeof o=="string"?!ac(o):!0})),Os(e,a,s,t),ir(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Ac(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)}xt(e,t.position)}function Rc(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);xt(e,t.position)}function jc(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=tr,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:_s(e,t.name,!0),a=zc(e,t),l=sr(e,t);return Os(e,a,s,t),ir(a,l),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Pc(e,t,n){const r={};return ir(r,sr(e,t)),e.create(t,e.Fragment,r,n)}function Dc(e,t){return t.value}function Os(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ir(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Fc(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 Oc(e,t){return n;function n(r,i,s,a){const l=Array.isArray(s.children),o=nr(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 _c(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&rr.call(t.properties,i)){const s=Bc(e,i,t.properties[i]);if(s){const[a,l]=s;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&Nc.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 zc(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 xt(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 xt(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function sr(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Tc;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=Fs(e,s,a);l!==void 0&&n.push(l)}return n}function Bc(e,t,n){const r=fc(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?tc(n):xc(n)),r.property==="style"){let i=typeof n=="object"?n:Hc(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Uc(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?cc[r.property]||r.property:r.attribute,n]}}function Hc(e,t){try{return vc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new ue("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=Ds+"#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 rr.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);xt(e)}function xt(e,t){const n=new ue("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=Ds+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Uc(e){const t={};let n;for(n in e)rr.call(e,n)&&(t[Vc(n)]=e[n]);return t}function Vc(e){let t=e.replace(Mc,$c);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function $c(e){return"-"+e.toLowerCase()}const on={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"]},Kc={};function ar(e,t){const n=Kc,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return zs(e,r,i)}function zs(e,t,n){if(qc(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]=zs(e[i],t,n);return r.join("")}function qc(e){return!!(e&&typeof e=="object")}const Wr=document.createElement("i");function lr(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 ye(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 be(e,t){return e.length>0?(ye(e,e.length,0,t),e):t}const Qr={}.hasOwnProperty;function Bs(e){const t={};let n=-1;for(;++n<e.length;)Wc(t,e[n]);return t}function Wc(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];Qc(i[a],Array.isArray(l)?l:l?[l]:[])}}}function Qc(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ye(e,0,0,r)}function Hs(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 Ce(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ce=Be(/[A-Za-z]/),oe=Be(/[\dA-Za-z]/),Gc=Be(/[#-'*+\--9=?A-Z^-~]/);function Ot(e){return e!==null&&(e<32||e===127)}const Pn=Be(/\d/),Xc=Be(/[\dA-Fa-f]/),Yc=Be(/[!-/:-@[-`{-~]/);function O(e){return e!==null&&e<-2}function J(e){return e!==null&&(e<0||e===32)}function q(e){return e===-2||e===-1||e===32}const qt=Be(new RegExp("\\p{P}|\\p{S}","u")),Ke=Be(/\s/);function Be(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function tt(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&oe(e.charCodeAt(n+1))&&oe(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 G(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(o){return q(o)?(e.enter(n),l(o)):t(o)}function l(o){return q(o)&&s++<i?(e.consume(o),l):(e.exit(n),t(o))}}const Jc={tokenize:Zc};function Zc(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"),G(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 O(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),a)}}const eh={tokenize:th},Gr={tokenize:nh};function th(e){const t=this,n=[];let r=0,i,s,a;return l;function l(I){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,o,u)(I)}return u(I)}function o(I){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&M();const D=t.events.length;let F=D,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 _=D;for(;_<t.events.length;)t.events[_][1].end={...T},_++;return ye(t.events,F+1,0,t.events.slice(D)),t.events.length=_,u(I)}return l(I)}function u(I){if(r===n.length){if(!i)return p(I);if(i.currentConstruct&&i.currentConstruct.concrete)return m(I);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Gr,d,c)(I)}function d(I){return i&&M(),g(r),p(I)}function c(I){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(I)}function p(I){return t.containerState={},e.attempt(Gr,f,m)(I)}function f(I){return r++,n.push([t.currentConstruct,t.containerState]),p(I)}function m(I){if(I===null){i&&M(),g(0),e.consume(I);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(I)}function y(I){if(I===null){S(e.exit("chunkFlow"),!0),g(0),e.consume(I);return}return O(I)?(e.consume(I),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(I),y)}function S(I,D){const F=t.sliceStream(I);if(D&&F.push(null),I.previous=s,s&&(s.next=I),s=I,i.defineSkip(I.start),i.write(F),t.parser.lazy[I.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 _=t.events.length;let z=_,B,w;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){if(B){w=t.events[z][1].end;break}B=!0}for(g(r),T=_;T<t.events.length;)t.events[T][1].end={...w},T++;ye(t.events,z+1,0,t.events.slice(_)),t.events.length=T}}function g(I){let D=n.length;for(;D-- >I;){const F=n[D];t.containerState=F[1],F[0].exit.call(t,e)}n.length=I}function M(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function nh(e,t,n){return G(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ze(e){if(e===null||J(e)||Ke(e))return 1;if(qt(e))return 2}function Wt(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 Dn={name:"attention",resolveAll:rh,tokenize:ih};function rh(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=be(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=be(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=be(u,Wt(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=be(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=be(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,ye(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 ih(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ze(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=Ze(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 sh={name:"autolink",tokenize:ah};function ah(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||oe(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||oe(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||Ot(f)?n(f):(e.consume(f),o)}function u(f){return f===64?(e.consume(f),d):Gc(f)?(e.consume(f),u):n(f)}function d(f){return oe(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||oe(f))&&r++<63){const m=f===45?p:c;return e.consume(f),m}return n(f)}}const Ct={partial:!0,tokenize:lh};function lh(e,t,n){return r;function r(s){return q(s)?G(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||O(s)?t(s):n(s)}}const Us={continuation:{tokenize:uh},exit:ch,name:"blockQuote",tokenize:oh};function oh(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 q(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function uh(e,t,n){const r=this;return i;function i(a){return q(a)?G(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Us,t,n)(a)}}function ch(e){e.exit("blockQuote")}const Vs={name:"characterEscape",tokenize:hh};function hh(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 Yc(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const $s={name:"characterReference",tokenize:dh};function dh(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=oe,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=Xc,d):(e.enter("characterReferenceValue"),s=7,a=Pn,d(c))}function d(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return a===oe&&!lr(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:ph},Jr={concrete:!0,name:"codeFenced",tokenize:fh};function fh(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 _=r.events[r.events.length-1];return s=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[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"),q(T)?G(e,c,"whitespace")(T):c(T))}function c(T){return T===null||O(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(Yr,y,D)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(T))}function p(T){return T===null||O(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(T)):q(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),G(e,f,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),p)}function f(T){return T===null||O(T)?c(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(T))}function m(T){return T===null||O(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(T)):T===96&&T===l?n(T):(e.consume(T),m)}function y(T){return e.attempt(i,D,S)(T)}function S(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),g}function g(T){return s>0&&q(T)?G(e,M,"linePrefix",s+1)(T):M(T)}function M(T){return T===null||O(T)?e.check(Yr,y,D)(T):(e.enter("codeFlowValue"),I(T))}function I(T){return T===null||O(T)?(e.exit("codeFlowValue"),M(T)):(e.consume(T),I)}function D(T){return e.exit("codeFenced"),t(T)}function F(T,_,z){let B=0;return w;function w(v){return T.enter("lineEnding"),T.consume(v),T.exit("lineEnding"),E}function E(v){return T.enter("codeFencedFence"),q(v)?G(T,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):L(v)}function L(v){return v===l?(T.enter("codeFencedFenceSequence"),H(v)):z(v)}function H(v){return v===l?(B++,T.consume(v),H):B>=a?(T.exit("codeFencedFenceSequence"),q(v)?G(T,P,"whitespace")(v):P(v)):z(v)}function P(v){return v===null||O(v)?(T.exit("codeFencedFence"),_(v)):z(v)}}}function ph(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 un={name:"codeIndented",tokenize:gh},mh={partial:!0,tokenize:xh};function gh(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),G(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):O(u)?e.attempt(mh,a,o)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||O(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function o(u){return e.exit("codeIndented"),t(u)}}function xh(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):O(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):G(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):O(a)?i(a):n(a)}}const yh={name:"codeText",previous:Sh,resolve:bh,tokenize:kh};function bh(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 Sh(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function kh(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)):O(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||O(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 wh{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&&ot(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),ot(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ot(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);ot(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ot(this.left,n.reverse())}}}function ot(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 Ks(e){const t={};let n=-1,r,i,s,a,l,o,u;const d=new wh(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,vh(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 ye(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function vh(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,y=0;const S=[y];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&&(y=p+1,S.push(y),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]),M=s.pop();o.push([M,M+g.length-1]),e.splice(M,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 Ch={resolve:Mh,tokenize:Ih},Th={partial:!0,tokenize:Nh};function Mh(e){return Ks(e),e}function Ih(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):O(l)?e.check(Th,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 Nh(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),G(e,s,"linePrefix")}function s(a){if(a===null||O(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 qs(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||Ot(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),y(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||O(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 y(g){return!d&&(g===null||g===41||J(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):d<u&&g===40?(e.consume(g),d++,y):g===41?(e.consume(g),d--,y):g===null||g===32||g===40||Ot(g)?n(g):(e.consume(g),g===92?S:y)}function S(g){return g===40||g===41||g===92?(e.consume(g),y):y(g)}}function Ws(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):O(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||O(f)||l++>999?(e.exit("chunkString"),d(f)):(e.consume(f),o||(o=!q(f)),f===92?p:c)}function p(f){return f===91||f===92||f===93?(e.consume(f),l++,c):c(f)}}function Qs(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):O(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),G(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||O(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 pt(e,t){let n;return r;function r(i){return O(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):q(i)?G(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Eh={name:"definition",tokenize:Ah},Lh={partial:!0,tokenize:Rh};function Ah(e,t,n){const r=this;let i;return s;function s(f){return e.enter("definition"),a(f)}function a(f){return Ws.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return i=Ce(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 J(f)?pt(e,u)(f):u(f)}function u(f){return qs(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function d(f){return e.attempt(Lh,c,c)(f)}function c(f){return q(f)?G(e,p,"whitespace")(f):p(f)}function p(f){return f===null||O(f)?(e.exit("definition"),r.parser.defined.push(i),t(f)):n(f)}}function Rh(e,t,n){return r;function r(l){return J(l)?pt(e,i)(l):n(l)}function i(l){return Qs(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return q(l)?G(e,a,"whitespace")(l):a(l)}function a(l){return l===null||O(l)?t(l):n(l)}}const jh={name:"hardBreakEscape",tokenize:Ph};function Ph(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return O(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Dh={name:"headingAtx",resolve:Fh,tokenize:Oh};function Fh(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"},ye(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Oh(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||J(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),o(d)):d===null||O(d)?(e.exit("atxHeading"),t(d)):q(d)?G(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||J(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const _h=["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"],zh={concrete:!0,name:"htmlFlow",resolveTo:Uh,tokenize:Vh},Bh={partial:!0,tokenize:Kh},Hh={partial:!0,tokenize:$h};function Uh(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 Vh(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,y):b===63?(e.consume(b),i=3,r.interrupt?t:x):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:x):n(b)}function f(b){return b===45?(e.consume(b),r.interrupt?t:x):n(b)}function m(b){const he="CDATA[";return b===he.charCodeAt(l++)?(e.consume(b),l===he.length?r.interrupt?t:L:m):n(b)}function y(b){return ce(b)?(e.consume(b),a=String.fromCharCode(b),S):n(b)}function S(b){if(b===null||b===47||b===62||J(b)){const he=b===47,Te=a.toLowerCase();return!he&&!s&&Zr.includes(Te)?(i=1,r.interrupt?t(b):L(b)):_h.includes(a.toLowerCase())?(i=6,he?(e.consume(b),g):r.interrupt?t(b):L(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?M(b):I(b))}return b===45||oe(b)?(e.consume(b),a+=String.fromCharCode(b),S):n(b)}function g(b){return b===62?(e.consume(b),r.interrupt?t:L):n(b)}function M(b){return q(b)?(e.consume(b),M):w(b)}function I(b){return b===47?(e.consume(b),w):b===58||b===95||ce(b)?(e.consume(b),D):q(b)?(e.consume(b),I):w(b)}function D(b){return b===45||b===46||b===58||b===95||oe(b)?(e.consume(b),D):F(b)}function F(b){return b===61?(e.consume(b),T):q(b)?(e.consume(b),F):I(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,_):q(b)?(e.consume(b),T):z(b)}function _(b){return b===o?(e.consume(b),o=null,B):b===null||O(b)?n(b):(e.consume(b),_)}function z(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||J(b)?F(b):(e.consume(b),z)}function B(b){return b===47||b===62||q(b)?I(b):n(b)}function w(b){return b===62?(e.consume(b),E):n(b)}function E(b){return b===null||O(b)?L(b):q(b)?(e.consume(b),E):n(b)}function L(b){return b===45&&i===2?(e.consume(b),j):b===60&&i===1?(e.consume(b),$):b===62&&i===4?(e.consume(b),le):b===63&&i===3?(e.consume(b),x):b===93&&i===5?(e.consume(b),pe):O(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Bh,se,H)(b)):b===null||O(b)?(e.exit("htmlFlowData"),H(b)):(e.consume(b),L)}function H(b){return e.check(Hh,P,se)(b)}function P(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),v}function v(b){return b===null||O(b)?H(b):(e.enter("htmlFlowData"),L(b))}function j(b){return b===45?(e.consume(b),x):L(b)}function $(b){return b===47?(e.consume(b),a="",te):L(b)}function te(b){if(b===62){const he=a.toLowerCase();return Zr.includes(he)?(e.consume(b),le):L(b)}return ce(b)&&a.length<8?(e.consume(b),a+=String.fromCharCode(b),te):L(b)}function pe(b){return b===93?(e.consume(b),x):L(b)}function x(b){return b===62?(e.consume(b),le):b===45&&i===2?(e.consume(b),x):L(b)}function le(b){return b===null||O(b)?(e.exit("htmlFlowData"),se(b)):(e.consume(b),le)}function se(b){return e.exit("htmlFlow"),t(b)}}function $h(e,t,n){const r=this;return i;function i(a){return O(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 Kh(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Ct,t,n)}}const qh={name:"htmlText",tokenize:Wh};function Wh(e,t,n){const r=this;let i,s,a;return l;function l(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),o}function o(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),F):x===63?(e.consume(x),I):ce(x)?(e.consume(x),z):n(x)}function u(x){return x===45?(e.consume(x),d):x===91?(e.consume(x),s=0,m):ce(x)?(e.consume(x),M):n(x)}function d(x){return x===45?(e.consume(x),f):n(x)}function c(x){return x===null?n(x):x===45?(e.consume(x),p):O(x)?(a=c,$(x)):(e.consume(x),c)}function p(x){return x===45?(e.consume(x),f):c(x)}function f(x){return x===62?j(x):x===45?p(x):c(x)}function m(x){const le="CDATA[";return x===le.charCodeAt(s++)?(e.consume(x),s===le.length?y:m):n(x)}function y(x){return x===null?n(x):x===93?(e.consume(x),S):O(x)?(a=y,$(x)):(e.consume(x),y)}function S(x){return x===93?(e.consume(x),g):y(x)}function g(x){return x===62?j(x):x===93?(e.consume(x),g):y(x)}function M(x){return x===null||x===62?j(x):O(x)?(a=M,$(x)):(e.consume(x),M)}function I(x){return x===null?n(x):x===63?(e.consume(x),D):O(x)?(a=I,$(x)):(e.consume(x),I)}function D(x){return x===62?j(x):I(x)}function F(x){return ce(x)?(e.consume(x),T):n(x)}function T(x){return x===45||oe(x)?(e.consume(x),T):_(x)}function _(x){return O(x)?(a=_,$(x)):q(x)?(e.consume(x),_):j(x)}function z(x){return x===45||oe(x)?(e.consume(x),z):x===47||x===62||J(x)?B(x):n(x)}function B(x){return x===47?(e.consume(x),j):x===58||x===95||ce(x)?(e.consume(x),w):O(x)?(a=B,$(x)):q(x)?(e.consume(x),B):j(x)}function w(x){return x===45||x===46||x===58||x===95||oe(x)?(e.consume(x),w):E(x)}function E(x){return x===61?(e.consume(x),L):O(x)?(a=E,$(x)):q(x)?(e.consume(x),E):B(x)}function L(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,H):O(x)?(a=L,$(x)):q(x)?(e.consume(x),L):(e.consume(x),P)}function H(x){return x===i?(e.consume(x),i=void 0,v):x===null?n(x):O(x)?(a=H,$(x)):(e.consume(x),H)}function P(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||J(x)?B(x):(e.consume(x),P)}function v(x){return x===47||x===62||J(x)?B(x):n(x)}function j(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function $(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),te}function te(x){return q(x)?G(e,pe,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):pe(x)}function pe(x){return e.enter("htmlTextData"),a(x)}}const or={name:"labelEnd",resolveAll:Yh,resolveTo:Jh,tokenize:Zh},Qh={tokenize:ed},Gh={tokenize:td},Xh={tokenize:nd};function Yh(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&&ye(e,0,e.length,n),e}function Jh(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=be(l,e.slice(s+1,s+r+3)),l=be(l,[["enter",d,t]]),l=be(l,Wt(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),l=be(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=be(l,e.slice(a+1)),l=be(l,[["exit",o,t]]),ye(e,s,e.length,l),e}function Zh(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(Ce(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(Qh,d,a?d:c)(p):p===91?e.attempt(Gh,d,a?u:c)(p):a?d(p):c(p)}function u(p){return e.attempt(Xh,d,c)(p)}function d(p){return t(p)}function c(p){return s._balanced=!0,n(p)}}function ed(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 J(c)?pt(e,s)(c):s(c)}function s(c){return c===41?d(c):qs(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return J(c)?pt(e,o)(c):d(c)}function l(c){return n(c)}function o(c){return c===34||c===39||c===40?Qs(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):d(c)}function u(c){return J(c)?pt(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 td(e,t,n){const r=this;return i;function i(l){return Ws.call(r,e,s,a,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(Ce(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function nd(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 rd={name:"labelStartImage",resolveAll:or.resolveAll,tokenize:id};function id(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 sd={name:"labelStartLink",resolveAll:or.resolveAll,tokenize:ad};function ad(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 cn={name:"lineEnding",tokenize:ld};function ld(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),G(e,t,"linePrefix")}}const Dt={name:"thematicBreak",tokenize:od};function od(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||O(u))?(e.exit("thematicBreak"),t(u)):n(u)}function o(u){return u===i?(e.consume(u),r++,o):(e.exit("thematicBreakSequence"),q(u)?G(e,l,"whitespace")(u):l(u))}}const de={continuation:{tokenize:dd},exit:pd,name:"list",tokenize:hd},ud={partial:!0,tokenize:md},cd={partial:!0,tokenize:fd};function hd(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:Pn(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(Dt,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 Pn(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(Ct,r.interrupt?n:d,e.attempt(ud,p,c))}function d(f){return r.containerState.initialBlankLine=!0,s++,p(f)}function c(f){return q(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 dd(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ct,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,G(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!q(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(cd,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,G(e,e.attempt(de,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function fd(e,t,n){const r=this;return G(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 pd(e){e.exit(this.containerState.type)}function md(e,t,n){const r=this;return G(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!q(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ei={name:"setextUnderline",resolveTo:gd,tokenize:xd};function gd(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 xd(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"),q(u)?G(e,o,"lineSuffix")(u):o(u))}function o(u){return u===null||O(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const yd={tokenize:bd};function bd(e){const t=this,n=e.attempt(Ct,r,e.attempt(this.parser.constructs.flowInitial,i,G(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ch,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 Sd={resolveAll:Xs()},kd=Gs("string"),wd=Gs("text");function Gs(e){return{resolveAll:Xs(e==="text"?vd: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 Xs(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 vd(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 Cd={42:de,43:de,45:de,48:de,49:de,50:de,51:de,52:de,53:de,54:de,55:de,56:de,57:de,62:Us},Td={91:Eh},Md={[-2]:un,[-1]:un,32:un},Id={35:Dh,42:Dt,45:[ei,Dt],60:zh,61:ei,95:Dt,96:Jr,126:Jr},Nd={38:$s,92:Vs},Ed={[-5]:cn,[-4]:cn,[-3]:cn,33:rd,38:$s,42:Dn,60:[sh,qh],91:sd,92:[jh,Vs],93:or,95:Dn,96:yh},Ld={null:[Dn,Sd]},Ad={null:[42,95]},Rd={null:[]},jd=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ad,contentInitial:Td,disable:Rd,document:Cd,flow:Id,flowInitial:Md,insideSpan:Ld,string:Nd,text:Ed},Symbol.toStringTag,{value:"Module"}));function Pd(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:_(F),check:_(T),consume:M,enter:I,exit:D,interrupt:_(T,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,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(E){return a=be(a,E),S(),a[a.length-1]!==null?[]:(z(t,0),u.events=Wt(s,u.events,u),u.events)}function p(E,L){return Fd(f(E),L)}function f(E){return Dd(a,E)}function m(){const{_bufferIndex:E,_index:L,line:H,column:P,offset:v}=r;return{_bufferIndex:E,_index:L,line:H,column:P,offset:v}}function y(E){i[E.line]=E.column,w()}function S(){let E;for(;r._index<a.length;){const L=a[r._index];if(typeof L=="string")for(E=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===E&&r._bufferIndex<L.length;)g(L.charCodeAt(r._bufferIndex));else g(L)}}function g(E){d=d(E)}function M(E){O(E)?(r.line++,r.column=1,r.offset+=E===-3?2:1,w()):E!==-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=E}function I(E,L){const H=L||{};return H.type=E,H.start=m(),u.events.push(["enter",H,u]),l.push(H),H}function D(E){const L=l.pop();return L.end=m(),u.events.push(["exit",L,u]),L}function F(E,L){z(E,L.from)}function T(E,L){L.restore()}function _(E,L){return H;function H(P,v,j){let $,te,pe,x;return Array.isArray(P)?se(P):"tokenize"in P?se([P]):le(P);function le(re){return me;function me(ke){const Le=ke!==null&&re[ke],Ae=ke!==null&&re.null,He=[...Array.isArray(Le)?Le:Le?[Le]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return se(He)(ke)}}function se(re){return $=re,te=0,re.length===0?j:b(re[te])}function b(re){return me;function me(ke){return x=B(),pe=re,re.partial||(u.currentConstruct=re),re.name&&u.parser.constructs.disable.null.includes(re.name)?Te():re.tokenize.call(L?Object.assign(Object.create(u),L):u,o,he,Te)(ke)}}function he(re){return E(pe,x),v}function Te(re){return x.restore(),++te<$.length?b($[te]):j}}}function z(E,L){E.resolveAll&&!s.includes(E)&&s.push(E),E.resolve&&ye(u.events,L,u.events.length-L,E.resolve(u.events.slice(L),u)),E.resolveTo&&(u.events=E.resolveTo(u.events,u))}function B(){const E=m(),L=u.previous,H=u.currentConstruct,P=u.events.length,v=Array.from(l);return{from:P,restore:j};function j(){r=E,u.previous=L,u.currentConstruct=H,u.events.length=P,l=v,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Dd(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 Fd(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 Od(e){const r={constructs:Bs([jd,...(e||{}).extensions||[]]),content:i(Jc),defined:[],document:i(eh),flow:i(yd),lazy:{},string:i(kd),text:i(wd)};return r;function i(s){return a;function a(l){return Pd(r,s,l)}}}function _d(e){for(;!Ks(e););return e}const ti=/[\0\t\n\r]/g;function zd(){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 Bd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Hd(e){return e.replace(Bd,Ud)}function Ud(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Hs(n.slice(s?2:1),s?16:10)}return lr(n)||e}const Ys={}.hasOwnProperty;function Vd(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),$d(n)(_d(Od(n).document().write(zd()(e,t,!0))))}function $d(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Nt),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(Ue),blockQuote:s(Ae),characterEscape:B,characterReference:B,codeFenced:s(He),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(He,a),codeText:s(Mt,a),codeTextData:B,data:B,codeFlowValue:B,definition:s(It),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(K),hardBreakEscape:s(Me),hardBreakTrailing:s(Me),htmlFlow:s(Re,a),htmlFlowData:B,htmlText:s(Re,a),htmlTextData:B,image:s(je),label:a,link:s(Nt),listItem:s(Oa),listItemValue:p,listOrdered:s(nt,c),listUnordered:s(nt),paragraph:s(_a),reference:b,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Ue),strong:s(za),thematicBreak:s(Ha)},exit:{atxHeading:o(),atxHeadingSequence:F,autolink:o(),autolinkEmail:Le,autolinkProtocol:ke,blockQuote:o(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:Te,characterReferenceMarkerNumeric:Te,characterReferenceValue:re,characterReference:me,codeFenced:o(S),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:w,codeIndented:o(g),codeText:o(v),codeTextData:w,data:w,definition:o(),definitionDestinationString:D,definitionLabelString:M,definitionTitleString:I,emphasis:o(),hardBreakEscape:o(L),hardBreakTrailing:o(L),htmlFlow:o(H),htmlFlowData:w,htmlText:o(P),htmlTextData:w,image:o($),label:pe,labelText:te,lineEnding:E,link:o(j),listItem:o(),listOrdered:o(),listUnordered:o(),paragraph:o(),referenceString:he,resourceDestinationString:x,resourceTitleString:le,resource:se,setextHeading:o(z),setextHeadingLineSequence:_,setextHeadingText:T,strong:o(),thematicBreak:o()}};Js(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(N){let R={type:"root",children:[]};const U={stack:[R],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:d,data:n},W=[];let X=-1;for(;++X<N.length;)if(N[X][1].type==="listOrdered"||N[X][1].type==="listUnordered")if(N[X][0]==="enter")W.push(X);else{const we=W.pop();X=i(N,we,X)}for(X=-1;++X<N.length;){const we=t[N[X][0]];Ys.call(we,N[X][1].type)&&we[N[X][1].type].call(Object.assign({sliceSerialize:N[X][2].sliceSerialize},U),N[X][1])}if(U.tokenStack.length>0){const we=U.tokenStack[U.tokenStack.length-1];(we[1]||ni).call(U,void 0,we[0])}for(R.position={start:_e(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:_e(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},X=-1;++X<t.transforms.length;)R=t.transforms[X](R)||R;return R}function i(N,R,U){let W=R-1,X=-1,we=!1,Ve,Pe,rt,it;for(;++W<=U;){const ge=N[W];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?X++:X--,it=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(Ve&&!it&&!X&&!rt&&(rt=W),it=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:it=void 0}if(!X&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||X===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if(Ve){let We=W;for(Pe=void 0;We--;){const De=N[We];if(De[1].type==="lineEnding"||De[1].type==="lineEndingBlank"){if(De[0]==="exit")continue;Pe&&(N[Pe][1].type="lineEndingBlank",we=!0),De[1].type="lineEnding",Pe=We}else if(!(De[1].type==="linePrefix"||De[1].type==="blockQuotePrefix"||De[1].type==="blockQuotePrefixWhitespace"||De[1].type==="blockQuoteMarker"||De[1].type==="listItemIndent"))break}rt&&(!Pe||rt<Pe)&&(Ve._spread=!0),Ve.end=Object.assign({},Pe?N[Pe][1].start:ge[1].end),N.splice(Pe||W,0,["exit",Ve,ge[2]]),W++,U++}if(ge[1].type==="listItemPrefix"){const We={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};Ve=We,N.splice(W,0,["enter",We,ge[2]]),W++,U++,rt=void 0,it=!0}}}return N[R][1]._spread=we,U}function s(N,R){return U;function U(W){l.call(this,N(W),W),R&&R.call(this,W)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(N,R,U){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([R,U||void 0]),N.position={start:_e(R.start),end:void 0}}function o(N){return R;function R(U){N&&N.call(this,U),u.call(this,U)}}function u(N,R){const U=this.stack.pop(),W=this.tokenStack.pop();if(W)W[0].type!==N.type&&(R?R.call(this,N,W[0]):(W[1]||ni).call(this,N,W[0]));else throw new Error("Cannot close `"+N.type+"` ("+ft({start:N.start,end:N.end})+"): it’s not open");U.position.end=_e(N.end)}function d(){return ar(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(N){if(this.data.expectingFirstListItemValue){const R=this.stack[this.stack.length-2];R.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function f(){const N=this.resume(),R=this.stack[this.stack.length-1];R.lang=N}function m(){const N=this.resume(),R=this.stack[this.stack.length-1];R.meta=N}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N.replace(/(\r?\n|\r)$/g,"")}function M(N){const R=this.resume(),U=this.stack[this.stack.length-1];U.label=R,U.identifier=Ce(this.sliceSerialize(N)).toLowerCase()}function I(){const N=this.resume(),R=this.stack[this.stack.length-1];R.title=N}function D(){const N=this.resume(),R=this.stack[this.stack.length-1];R.url=N}function F(N){const R=this.stack[this.stack.length-1];if(!R.depth){const U=this.sliceSerialize(N).length;R.depth=U}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function _(N){const R=this.stack[this.stack.length-1];R.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function z(){this.data.setextHeadingSlurpLineEnding=void 0}function B(N){const U=this.stack[this.stack.length-1].children;let W=U[U.length-1];(!W||W.type!=="text")&&(W=Ba(),W.position={start:_e(N.start),end:void 0},U.push(W)),this.stack.push(W)}function w(N){const R=this.stack.pop();R.value+=this.sliceSerialize(N),R.position.end=_e(N.end)}function E(N){const R=this.stack[this.stack.length-1];if(this.data.atHardBreak){const U=R.children[R.children.length-1];U.position.end=_e(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(R.type)&&(B.call(this,N),w.call(this,N))}function L(){this.data.atHardBreak=!0}function H(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function P(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function v(){const N=this.resume(),R=this.stack[this.stack.length-1];R.value=N}function j(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=R,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function $(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const R=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=R,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function te(N){const R=this.sliceSerialize(N),U=this.stack[this.stack.length-2];U.label=Hd(R),U.identifier=Ce(R).toLowerCase()}function pe(){const N=this.stack[this.stack.length-1],R=this.resume(),U=this.stack[this.stack.length-1];if(this.data.inReference=!0,U.type==="link"){const W=N.children;U.children=W}else U.alt=R}function x(){const N=this.resume(),R=this.stack[this.stack.length-1];R.url=N}function le(){const N=this.resume(),R=this.stack[this.stack.length-1];R.title=N}function se(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function he(N){const R=this.resume(),U=this.stack[this.stack.length-1];U.label=R,U.identifier=Ce(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function Te(N){this.data.characterReferenceType=N.type}function re(N){const R=this.sliceSerialize(N),U=this.data.characterReferenceType;let W;U?(W=Hs(R,U==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):W=lr(R);const X=this.stack[this.stack.length-1];X.value+=W}function me(N){const R=this.stack.pop();R.position.end=_e(N.end)}function ke(N){w.call(this,N);const R=this.stack[this.stack.length-1];R.url=this.sliceSerialize(N)}function Le(N){w.call(this,N);const R=this.stack[this.stack.length-1];R.url="mailto:"+this.sliceSerialize(N)}function Ae(){return{type:"blockquote",children:[]}}function He(){return{type:"code",lang:null,meta:null,value:""}}function Mt(){return{type:"inlineCode",value:""}}function It(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function K(){return{type:"emphasis",children:[]}}function Ue(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function Re(){return{type:"html",value:""}}function je(){return{type:"image",title:null,url:"",alt:null}}function Nt(){return{type:"link",title:null,url:"",children:[]}}function nt(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[]}}function Oa(N){return{type:"listItem",spread:N._spread,checked:null,children:[]}}function _a(){return{type:"paragraph",children:[]}}function za(){return{type:"strong",children:[]}}function Ba(){return{type:"text",value:""}}function Ha(){return{type:"thematicBreak"}}}function _e(e){return{line:e.line,column:e.column,offset:e.offset}}function Js(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Js(e,r):Kd(e,r)}}function Kd(e,t){let n;for(n in t)if(Ys.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+"` ("+ft({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ft({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ft({start:t.start,end:t.end})+") is still open")}function qd(e){const t=this;t.parser=n;function n(r){return Vd(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Wd(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 Qd(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
7
|
-
`}]}function Gd(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 Xd(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Yd(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Jd(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=tt(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 Zd(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 ef(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Zs(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 tf(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zs(e,t);const i={src:tt(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 nf(e,t){const n={src:tt(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 rf(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 sf(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Zs(e,t);const i={href:tt(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 af(e,t){const n={href:tt(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 lf(e,t,n){const r=e.all(t),i=n?of(n):ea(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 of(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=ea(n[r])}return t}function ea(e){const t=e.spread;return t??e.children.length>1}function uf(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 hf(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function df(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ff(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=nr(t.children[1]),o=js(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 pf(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 mf(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 gf(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 xf(e,t){const n={type:"text",value:gf(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function yf(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const bf={blockquote:Wd,break:Qd,code:Gd,delete:Xd,emphasis:Yd,footnoteReference:Jd,heading:Zd,html:ef,imageReference:tf,image:nf,inlineCode:rf,linkReference:sf,link:af,listItem:lf,list:uf,paragraph:cf,root:hf,strong:df,table:ff,tableCell:mf,tableRow:pf,text:xf,thematicBreak:yf,toml:Et,yaml:Et,definition:Et,footnoteDefinition:Et};function Et(){}const ta=-1,Qt=0,mt=1,_t=2,ur=3,cr=4,hr=5,dr=6,na=7,ra=8,ai=typeof self=="object"?self:globalThis,Sf=(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 Qt:case ta:return n(a,i);case mt:{const l=n([],i);for(const o of a)l.push(r(o));return l}case _t:{const l=n({},i);for(const[o,u]of a)l[r(o)]=r(u);return l}case ur:return n(new Date(a),i);case cr:{const{source:l,flags:o}=a;return n(new RegExp(l,o),i)}case hr:{const l=n(new Map,i);for(const[o,u]of a)l.set(r(o),r(u));return l}case dr:{const l=n(new Set,i);for(const o of a)l.add(r(o));return l}case na:{const{name:l,message:o}=a;return n(new ai[l](o),i)}case ra: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=>Sf(new Map,e)(0),Ge="",{toString:kf}={},{keys:wf}=Object,ut=e=>{const t=typeof e;if(t!=="object"||!e)return[Qt,t];const n=kf.call(e).slice(8,-1);switch(n){case"Array":return[mt,Ge];case"Object":return[_t,Ge];case"Date":return[ur,Ge];case"RegExp":return[cr,Ge];case"Map":return[hr,Ge];case"Set":return[dr,Ge];case"DataView":return[mt,n]}return n.includes("Array")?[mt,n]:n.includes("Error")?[na,n]:[_t,n]},Lt=([e,t])=>e===Qt&&(t==="function"||t==="symbol"),vf=(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]=ut(a);switch(l){case Qt:{let d=a;switch(o){case"bigint":l=ra,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);d=null;break;case"undefined":return i([ta],a)}return i([l,d],a)}case mt:{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 _t:{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 wf(a))(e||!Lt(ut(a[p])))&&d.push([s(p),s(a[p])]);return c}case ur:return i([l,a.toISOString()],a);case cr:{const{source:d,flags:c}=a;return i([l,{source:d,flags:c}],a)}case hr:{const d=[],c=i([l,d],a);for(const[p,f]of a)(e||!(Lt(ut(p))||Lt(ut(f))))&&d.push([s(p),s(f)]);return c}case dr:{const d=[],c=i([l,d],a);for(const p of a)(e||!Lt(ut(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 vf(!(t||n),!!t,new Map,r)(e),r},zt=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 Cf(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 Tf(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Mf(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Cf,r=e.options.footnoteBackLabel||Tf,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=tt(c.toLowerCase());let f=0;const m=[],y=e.footnoteCounts.get(c);for(;y!==void 0&&++f<=y;){m.length>0&&m.push({type:"text",value:" "});let M=typeof n=="string"?n:n(o,f);typeof M=="string"&&(M={type:"text",value:M}),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(M)?M:[M]})}const S=d[d.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const M=S.children[S.children.length-1];M&&M.type==="text"?M.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:{...zt(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 Gt=(function(e){if(e==null)return Lf;if(typeof e=="function")return Xt(e);if(typeof e=="object")return Array.isArray(e)?If(e):Nf(e);if(typeof e=="string")return Ef(e);throw new Error("Expected function, string, or object as test")});function If(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Gt(e[n]);return Xt(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Nf(e){const t=e;return Xt(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Ef(e){return Xt(t);function t(n){return n&&n.type===e}}function Xt(e){return t;function t(n,r,i){return!!(Af(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Lf(){return!0}function Af(e){return e!==null&&typeof e=="object"&&"type"in e}const ia=[],Rf=!0,Fn=!1,jf="skip";function sa(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Gt(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=ia,m,y,S;if((!t||s(o,u,d[d.length-1]||void 0))&&(f=Pf(n(o,d)),f[0]===Fn))return f;if("children"in o&&o.children){const g=o;if(g.children&&f[0]!==jf)for(y=(r?g.children.length:-1)+a,S=d.concat(g);y>-1&&y<g.children.length;){const M=g.children[y];if(m=l(M,y,S)(),m[0]===Fn)return m;y=typeof m[1]=="number"?m[1]:y+a}}return f}}}function Pf(e){return Array.isArray(e)?e:typeof e=="number"?[Rf,e]:e==null?ia:[e]}function fr(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),sa(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 On={}.hasOwnProperty,Df={};function Ff(e,t){const n=t||Df,r=new Map,i=new Map,s=new Map,a={...bf,...n.handlers},l={all:u,applyData:_f,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:o,options:n,patch:Of,wrap:Bf};return fr(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(On.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:y,...S}=d,g=zt(S);return g.children=l.all(d),g}return zt(d)}return(l.options.unknownHandler||zf)(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 y=m.children[0];y&&y.type==="text"&&(y.value=ui(y.value))}Array.isArray(m)?c.push(...m):c.push(m)}}}return c}}function Of(e,t){e.position&&(t.position=Cc(e))}function _f(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,zt(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function zf(e,t){const n=t.data||{},r="value"in t&&!(On.call(n,"hProperties")||On.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 Bf(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=Ff(e,t),r=n.one(e,void 0),i=Mf(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 Hf(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 hi(e){if(e)throw e}var hn,di;function Uf(){if(di)return hn;di=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 hn=function o(){var u,d,c,p,f,m,y=arguments[0],S=1,g=arguments.length,M=!1;for(typeof y=="boolean"&&(M=y,y=arguments[1]||{},S=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});S<g;++S)if(u=arguments[S],u!=null)for(d in u)c=l(y,d),p=l(u,d),y!==p&&(M&&p&&(s(p)||(f=i(p)))?(f?(f=!1,m=c&&i(c)?c:[]):m=c&&s(c)?c:{},a(y,{name:d,newValue:o(M,m,p)})):typeof p<"u"&&a(y,{name:d,newValue:p}));return y},hn}var Vf=Uf();const dn=Gi(Vf);function _n(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 $f(){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?Kf(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 Kf(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:qf,dirname:Wf,extname:Qf,join:Gf,sep:"/"};function qf(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Tt(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 Wf(e){if(Tt(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 Qf(e){Tt(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 Gf(...e){let t=-1,n;for(;++t<e.length;)Tt(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Xf(n)}function Xf(e){Tt(e);const t=e.codePointAt(0)===47;let n=Yf(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Yf(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 Tt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Jf={cwd:Zf};function Zf(){return"/"}function zn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ep(e){if(typeof e=="string")e=new URL(e);else if(!zn(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 tp(e)}function tp(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 fn=["history","path","basename","stem","extname","dirname"];class aa{constructor(t){let n;t?zn(t)?n={path:t}:typeof t=="string"||np(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Jf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<fn.length;){const s=fn[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)fn.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ne.basename(this.path):void 0}set basename(t){mn(t,"basename"),pn(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(pn(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){zn(t)&&(t=ep(t)),mn(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){mn(t,"stem"),pn(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 ue(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 pn(e,t){if(e&&e.includes(Ne.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ne.sep+"`")}function mn(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 np(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const rp=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),ip={}.hasOwnProperty;class pr extends rp{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=$f()}copy(){const t=new pr;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(dn(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(yn("data",this.frozen),this.namespace[t]=n,this):ip.call(this.namespace,t)&&this.namespace[t]||void 0:t?(yn("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=At(t),r=this.parser||this.Parser;return gn("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),gn("process",this.parser||this.Parser),xn("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const l=At(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);lp(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(),gn("processSync",this.parser||this.Parser),xn("processSync",this.compiler||this.Compiler),this.process(t,i),mi("processSync","process",n),r;function i(s,a){n=!0,hi(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=At(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){hi(a),i=l,r=!0}}stringify(t,n){this.freeze();const r=At(n),i=this.compiler||this.Compiler;return xn("stringify",i),pi(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(yn("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=dn(!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 y=r[p][1];_n(y)&&_n(f)&&(f=dn(!0,y,f)),r[p]=[u,f,...m]}}}}const sp=new pr().freeze();function gn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function xn(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function yn(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(!_n(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 At(e){return ap(e)?e:new aa(e)}function ap(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function lp(e){return typeof e=="string"||op(e)}function op(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const up="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",gi=[],xi={allowDangerousHtml:!0},cp=/^(https?|ircs?|mailto|xmpp)$/i,hp=[{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 dp(e){const t=fp(e),n=pp(e);return mp(t.runSync(t.parse(n),n),e)}function fp(e){const t=e.rehypePlugins||gi,n=e.remarkPlugins||gi,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...xi}:xi;return sp().use(qd).use(n).use(Hf,r).use(t)}function pp(e){const t=e.children||"",n=new aa;return typeof t=="string"&&(n.value=t),n}function mp(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,o=t.urlTransform||gp;for(const d of hp)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+up+d.id,void 0);return fr(e,u),Ec(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 on)if(Object.hasOwn(on,f)&&Object.hasOwn(d.properties,f)){const m=d.properties[f],y=on[f];(y===null||y.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 gp(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 xp(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function yp(e,t,n){const i=Gt((n||{}).ignore||[]),s=bp(t);let a=-1;for(;++a<s.length;)sa(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,M=[];p.lastIndex=0;let I=p.exec(u.value);for(;I;){const D=I.index,F={index:I.index,input:I.input,stack:[...d,u]};let T=f(...I,F);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?p.lastIndex=D+1:(m!==D&&M.push({type:"text",value:u.value.slice(m,D)}),Array.isArray(T)?M.push(...T):T&&M.push(T),m=D+I[0].length,g=!0),!p.global)break;I=p.exec(u.value)}return g?(m<u.value.length&&M.push({type:"text",value:u.value.slice(m)}),c.children.splice(S,1,...M)):M=[u],S+M.length}}function bp(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([Sp(i[0]),kp(i[1])])}return t}function Sp(e){return typeof e=="string"?new RegExp(xp(e),"g"):e}function kp(e){return typeof e=="function"?e:function(){return e}}const bn="phrasing",Sn=["autolink","link","image","label"];function wp(){return{transforms:[Ep],enter:{literalAutolink:Cp,literalAutolinkEmail:kn,literalAutolinkHttp:kn,literalAutolinkWww:kn},exit:{literalAutolink:Np,literalAutolinkEmail:Ip,literalAutolinkHttp:Tp,literalAutolinkWww:Mp}}}function vp(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:bn,notInConstruct:Sn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:bn,notInConstruct:Sn},{character:":",before:"[ps]",after:"\\/",inConstruct:bn,notInConstruct:Sn}]}}function Cp(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function kn(e){this.config.enter.autolinkProtocol.call(this,e)}function Tp(e){this.config.exit.autolinkProtocol.call(this,e)}function Mp(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 Ip(e){this.config.exit.autolinkEmail.call(this,e)}function Np(e){this.exit(e)}function Ep(e){yp(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Lp],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Ap]],{ignore:["link","linkReference"]})}function Lp(e,t,n,r,i){let s="";if(!la(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Rp(n)))return!1;const a=jp(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 Ap(e,t,n,r){return!la(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Rp(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 jp(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 la(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ke(n)||qt(n))&&(!t||n!==47)}oa.peek=Up;function Pp(){this.buffer()}function Dp(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Fp(){this.buffer()}function Op(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function _p(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ce(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zp(e){this.exit(e)}function Bp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ce(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Hp(e){this.exit(e)}function Up(){return"["}function oa(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 Vp(){return{enter:{gfmFootnoteCallString:Pp,gfmFootnoteCall:Dp,gfmFootnoteDefinitionLabelString:Fp,gfmFootnoteDefinition:Op},exit:{gfmFootnoteCallString:_p,gfmFootnoteCall:zp,gfmFootnoteDefinitionLabelString:Bp,gfmFootnoteDefinition:Hp}}}function $p(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:oa},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?ua:Kp))),u(),o}}function Kp(e,t,n){return t===0?e:ua(e,t,n)}function ua(e,t,n){return(n?"":" ")+e}const qp=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ca.peek=Yp;function Wp(){return{canContainEols:["delete"],enter:{strikethrough:Gp},exit:{strikethrough:Xp}}}function Qp(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:qp}],handlers:{delete:ca}}}function Gp(e){this.enter({type:"delete",children:[]},e)}function Xp(e){this.exit(e)}function ca(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 Yp(){return"~"}function Jp(e){return e.length}function Zp(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Jp,s=[],a=[],l=[],o=[];let u=0,d=-1;for(;++d<e.length;){const y=[],S=[];let g=-1;for(e[d].length>u&&(u=e[d].length);++g<e[d].length;){const M=em(e[d][g]);if(n.alignDelimiters!==!1){const I=i(M);S[g]=I,(o[g]===void 0||I>o[g])&&(o[g]=I)}y.push(M)}a[d]=y,l[d]=S}let c=-1;if(typeof r=="object"&&"length"in r)for(;++c<u;)s[c]=bi(r[c]);else{const y=bi(r);for(;++c<u;)s[c]=y}c=-1;const p=[],f=[];for(;++c<u;){const y=s[c];let S="",g="";y===99?(S=":",g=":"):y===108?S=":":y===114&&(g=":");let M=n.alignDelimiters===!1?1:Math.max(1,o[c]-S.length-g.length);const I=S+"-".repeat(M)+g;n.alignDelimiters!==!1&&(M=S.length+M+g.length,M>o[c]&&(o[c]=M),f[c]=M),p[c]=I}a.splice(1,0,p),l.splice(1,0,f),d=-1;const m=[];for(;++d<a.length;){const y=a[d],S=l[d];c=-1;const g=[];for(;++c<u;){const M=y[c]||"";let I="",D="";if(n.alignDelimiters!==!1){const F=o[c]-(S[c]||0),T=s[c];T===114?I=" ".repeat(F):T===99?F%2?(I=" ".repeat(F/2+.5),D=" ".repeat(F/2-.5)):(I=" ".repeat(F/2),D=I):D=" ".repeat(F)}n.delimiterStart!==!1&&!c&&g.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&M==="")&&(n.delimiterStart!==!1||c)&&g.push(" "),n.alignDelimiters!==!1&&g.push(I),g.push(M),n.alignDelimiters!==!1&&g.push(D),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 em(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 tm(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()),nm);return i(),a}function nm(e,t,n){return">"+(n?"":" ")+e}function rm(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
|
-
`&&rm(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
20
|
-
`}function im(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 sm(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 am(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 lm(e,t,n,r){const i=am(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(sm(e,n)){const c=n.enter("codeIndented"),p=n.indentLines(s,om);return c(),p}const l=n.createTracker(r),o=i.repeat(Math.max(im(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 om(e,t,n){return(n?"":" ")+e}function mr(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 um(e,t,n,r){const i=mr(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 yt(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Bt(e,t,n){const r=Ze(e),i=Ze(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}}ha.peek=hm;function ha(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=Bt(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(o=yt(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Bt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+yt(c));const f=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},l+o+f}function hm(e,t,n){return n.options.emphasis||"*"}function dm(e,t){let n=!1;return fr(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Fn}),!!((!e.depth||e.depth<3)&&ar(e)&&(t.options.setext||n))}function fm(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(dm(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=yt(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),o(),l(),u}da.peek=pm;function da(e){return e.value||""}function pm(){return"<"}fa.peek=mm;function fa(e,t,n,r){const i=mr(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 mm(){return"!"}pa.peek=gm;function pa(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 gm(){return"!"}ma.peek=xm;function ma(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 xm(){return"`"}function ga(e,t){const n=ar(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))}xa.peek=ym;function xa(e,t,n,r){const i=mr(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let l,o;if(ga(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 ym(e,t,n){return ga(e,n)?"<":"["}ya.peek=bm;function ya(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 bm(){return"["}function gr(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 Sm(e){const t=gr(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 km(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 ba(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 wm(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?km(n):gr(n);const l=e.ordered?a==="."?")":".":Sm(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),ba(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 vm(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 Cm(e,t,n,r){const i=vm(n);let s=n.bulletCurrent||gr(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 Tm(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const Mm=Gt(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Im(e,t,n,r){return(e.children.some(function(a){return Mm(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Nm(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Sa.peek=Em;function Sa(e,t,n,r){const i=Nm(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=Bt(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(o=yt(u)+o.slice(1));const c=o.charCodeAt(o.length-1),p=Bt(r.after.charCodeAt(0),c,i);p.inside&&(o=o.slice(0,-1)+yt(c));const f=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},l+o+f}function Em(e,t,n){return n.options.strong||"*"}function Lm(e,t,n,r){return n.safe(e.value,r)}function Am(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 Rm(e,t,n){const r=(ba(n)+(n.options.ruleSpaces?" ":"")).repeat(Am(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ka={blockquote:tm,break:ki,code:lm,definition:um,emphasis:ha,hardBreak:ki,heading:fm,html:da,image:fa,imageReference:pa,inlineCode:ma,link:xa,linkReference:ya,list:wm,listItem:Cm,paragraph:Tm,root:Im,strong:Sa,text:Lm,thematicBreak:Rm};function jm(){return{enter:{table:Pm,tableData:wi,tableHeader:wi,tableRow:Fm},exit:{codeText:Om,table:Dm,tableData:wn,tableHeader:wn,tableRow:wn}}}function Pm(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 Dm(e){this.exit(e),this.data.inTable=void 0}function Fm(e){this.enter({type:"tableRow",children:[]},e)}function wn(e){this.exit(e)}function wi(e){this.enter({type:"tableCell",children:[]},e)}function Om(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,_m));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function _m(e,t){return t==="|"?t:e}function zm(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,y,S){return u(d(f,y,S),f.align)}function l(f,m,y,S){const g=c(f,y,S),M=u([g]);return M.slice(0,M.indexOf(`
|
|
31
|
-
`))}function o(f,m,y,S){const g=y.enter("tableCell"),M=y.enter("phrasing"),I=y.containerPhrasing(f,{...S,before:s,after:s});return M(),g(),I}function u(f,m){return Zp(f,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function d(f,m,y){const S=f.children;let g=-1;const M=[],I=m.enter("table");for(;++g<S.length;)M[g]=c(S[g],m,y);return I(),M}function c(f,m,y){const S=f.children;let g=-1;const M=[],I=m.enter("tableRow");for(;++g<S.length;)M[g]=o(S[g],f,m,y);return I(),M}function p(f,m,y){let S=ka.inlineCode(f,m,y);return y.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function Bm(){return{exit:{taskListCheckValueChecked:vi,taskListCheckValueUnchecked:vi,paragraph:Um}}}function Hm(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Vm}}}function vi(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Um(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 Vm(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=ka.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 $m(){return[wp(),Vp(),Wp(),jm(),Bm()]}function Km(e){return{extensions:[vp(),$p(e),Qp(),zm(e),Hm()]}}const qm={tokenize:Jm,partial:!0},wa={tokenize:Zm,partial:!0},va={tokenize:eg,partial:!0},Ca={tokenize:tg,partial:!0},Wm={tokenize:ng,partial:!0},Ta={name:"wwwAutolink",tokenize:Xm,previous:Ia},Ma={name:"protocolAutolink",tokenize:Ym,previous:Na},Oe={name:"emailAutolink",tokenize:Gm,previous:Ea},Ee={};function Qm(){return{text:Ee}}let $e=48;for(;$e<123;)Ee[$e]=Oe,$e++,$e===58?$e=65:$e===91&&($e=97);Ee[43]=Oe;Ee[45]=Oe;Ee[46]=Oe;Ee[95]=Oe;Ee[72]=[Oe,Ma];Ee[104]=[Oe,Ma];Ee[87]=[Oe,Ta];Ee[119]=[Oe,Ta];function Gm(e,t,n){const r=this;let i,s;return a;function a(c){return!Bn(c)||!Ea.call(r,r.previous)||xr(r.events)?n(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(c))}function l(c){return Bn(c)?(e.consume(c),l):c===64?(e.consume(c),o):n(c)}function o(c){return c===46?e.check(Wm,d,u)(c):c===45||c===95||oe(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 Xm(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Ia.call(r,r.previous)||xr(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(qm,e.attempt(wa,e.attempt(va,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function Ym(e,t,n){const r=this;let i="",s=!1;return a;function a(c){return(c===72||c===104)&&Na.call(r,r.previous)&&!xr(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||Ot(c)||J(c)||Ke(c)||qt(c)?n(c):e.attempt(wa,e.attempt(va,d),n)(c)}function d(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function Jm(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 Zm(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(Ca,o,l)(u):u===null||J(u)||Ke(u)||u!==45&&qt(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 eg(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(Ca,t,s)(a):a===null||J(a)||Ke(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function tg(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||J(l)||Ke(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||J(l)||Ke(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 ng(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return oe(s)?n(s):t(s)}}function Ia(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function Na(e){return!ce(e)}function Ea(e){return!(e===47||Bn(e))}function Bn(e){return e===43||e===45||e===46||e===95||oe(e)}function xr(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 rg={tokenize:hg,partial:!0};function ig(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:og,continuation:{tokenize:ug},exit:cg}},text:{91:{name:"gfmFootnoteCall",tokenize:lg},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:sg,resolveTo:ag}}}}function sg(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=Ce(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 ag(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 lg(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||J(c))return n(c);if(c===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Ce(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(c)}return J(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 og(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||J(m))return n(m);if(m===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return s=Ce(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return J(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),G(e,f,"gfmFootnoteDefinitionWhitespace")):n(m)}function f(m){return t(m)}}function ug(e,t,n){return e.check(Ct,t,e.attempt(rg,t,n))}function cg(e){e.exit("gfmFootnoteDefinition")}function hg(e,t,n){const r=this;return G(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 dg(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&&ye(p,p.length,0,Wt(f,a.slice(u+1,o),l)),ye(p,p.length,0,[["exit",c,l],["enter",a[o][1],l],["exit",a[o][1],l],["exit",d,l]]),ye(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 y=Ze(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=Ze(m);return S._open=!g||g===2&&!!y,S._close=!y||y===2&&!!g,l(m)}}}class fg{constructor(){this.map=[]}add(t,n,r){pg(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 pg(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 mg(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 gg(){return{flow:{null:{name:"table",tokenize:xg,resolveAll:yg}}}}function xg(e,t,n){const r=this;let i=0,s=0,a;return l;function l(w){let E=r.events.length-1;for(;E>-1;){const P=r.events[E][1].type;if(P==="lineEnding"||P==="linePrefix")E--;else break}const L=E>-1?r.events[E][1].type:null,H=L==="tableHead"||L==="tableRow"?T:o;return H===T&&r.parser.lazy[r.now().line]?n(w):H(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):O(w)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),f):n(w):q(w)?G(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||J(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,q(w)?G(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"),y):F(w)}function y(w){return q(w)?G(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||O(w)?D(w):F(w)}function g(w){return w===45?(e.enter("tableDelimiterFiller"),M(w)):F(w)}function M(w){return w===45?(e.consume(w),M):w===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(w),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(w))}function I(w){return q(w)?G(e,D,"whitespace")(w):D(w)}function D(w){return w===124?m(w):w===null||O(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"),_(w)}function _(w){return w===124?(e.enter("tableCellDivider"),e.consume(w),e.exit("tableCellDivider"),_):w===null||O(w)?(e.exit("tableRow"),t(w)):q(w)?G(e,_,"whitespace")(w):(e.enter("data"),z(w))}function z(w){return w===null||w===124||J(w)?(e.exit("data"),_(w)):(e.consume(w),w===92?B:z)}function B(w){return w===92||w===124?(e.consume(w),z):z(w)}}function yg(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 fg;for(;++n<e.length;){const f=e[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(l=!1,o!==0&&(Ci(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=Rt(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=Rt(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=Rt(p,t,s,i,n,c)):a[1]!==0&&(c=Rt(p,t,a,i,n,c)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(o!==0&&Ci(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=mg(t.events,n))}return e}function Rt(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(s.end=Object.assign({},Xe(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=Xe(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=Xe(t.events,n[2]),d=Xe(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,y=n[3]-n[2]-1;e.add(m,y,[])}}e.add(n[3]+1,0,[["exit",c,t]])}return i!==void 0&&(s.end=Object.assign({},Xe(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Ci(e,t,n,r,i){const s=[],a=Xe(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 Xe(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const bg={name:"tasklistCheck",tokenize:kg};function Sg(){return{text:{91:bg}}}function kg(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 J(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 O(o)?t(o):q(o)?e.check({tokenize:wg},t,n)(o):n(o)}}function wg(e,t,n){return G(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function vg(e){return Bs([Qm(),ig(),dg(e),gg(),Sg()])}const Cg={};function Tg(e){const t=this,n=e||Cg,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(vg(n)),s.push($m()),a.push(Km(n))}function Mg(){var e;return typeof navigator<"u"&&typeof((e=navigator.clipboard)==null?void 0:e.writeText)=="function"}function Ig(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):Ig(s),l}async function Ng(e){if(!e)return!1;if(Mg())try{return await navigator.clipboard.writeText(e),!0}catch{return Ti(e)}return Ti(e)}const Eg=1300;function Lg(e){const[t,n]=k.useState(!1),r=k.useCallback(async()=>{if(!e.text)return;const i=await Ng(e.text);n(!!i)},[e.text]);return k.useEffect(()=>{if(!t||typeof window>"u")return;const i=window.setTimeout(()=>n(!1),e.resetDelayMs??Eg);return()=>window.clearTimeout(i)},[t,e.resetDelayMs]),{copied:t,copy:r}}const Ag=/language-([a-z0-9-]+)/i;function La(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(La).join(""):""}function Rg(e){const t=La(e);return t.endsWith(`
|
|
32
|
-
`)?t.slice(0,-1):t}function jg(e){var n;const t=e?Ag.exec(e):null;return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())||"text"}function Pg(e){const t=k.useMemo(()=>jg(e.className),[e.className]),n=k.useMemo(()=>Rg(e.children),[e.children]),{copied:r,copy:i}=Lg({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(St,{className:"h-3.5 w-3.5"}):h.jsx(dl,{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 Mi=14e4,Dg=new Set(["http:","https:","mailto:","tel:"]);function Fg(e){return e.length<=Mi?e:`${e.slice(0,Mi)}
|
|
33
|
-
|
|
34
|
-
...`}function Ii(e){if(!e)return null;if(e.startsWith("#")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))return e;try{const t=new URL(e);return Dg.has(t.protocol)?e:null}catch{return null}}function Og(e){return/^https?:\/\//i.test(e)}function _g(e){const t=e.role==="user",n=k.useMemo(()=>({a:({href:r,children:i,...s})=>{const a=Ii(r);if(!a)return h.jsx("span",{className:"chat-link-invalid",children:i});const l=Og(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=Ii(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(Pg,{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(dp,{skipHtml:!0,remarkPlugins:[Tg],components:n,children:Fg(e.text)})})}const Aa={archive:"Archive",audio:"Audio",code:"Code",data:"Data",document:"Document",generic:"File",image:"Image",pdf:"PDF",sheet:"Sheet",video:"Video"},vn={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"},zg=new Set(["c","cpp","css","go","html","java","js","jsx","md","php","py","rb","rs","sh","sql","svg","ts","tsx"]),Bg=new Set(["graphql","json","toml","xml","yaml","yml"]),Hg=new Set(["doc","docx","odt","pages","rtf","txt"]),Ug=new Set(["csv","numbers","ods","tsv","xls","xlsx"]),Vg=new Set(["7z","bz2","gz","rar","tar","tgz","zip"]);function $g(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 Kg(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 qg(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":Vg.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?"archive":Ug.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?"sheet":Bg.has(n)||/(json|xml|yaml|toml)/.test(r)?"data":zg.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?"code":Hg.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?"document":"generic"}function Wg(e){const t=qg(e.label,e.mimeType),n=$g(e.sizeBytes);return{category:t,extension:Kg(e.label,e.mimeType),sizeLabel:n,metaBadges:[Aa[t],n].filter(r=>!!r)}}function Cn(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 Qg({file:e,isUser:t=!1}){const{category:n,extension:r,metaBadges:i,sizeLabel:s}=Wg(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?Cn(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":vn[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":vn[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=>Cn(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":vn[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:[Aa[n]," attachment"]})]}),Ei(l,t,a)]}),h.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.map(c=>Cn(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 Gg(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 Yt({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 Jt({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:Ui,spin:!0},success:{text:"text-amber-500/80",icon:St,spin:!1},error:{text:"text-amber-500/80",icon:pl,spin:!1},cancelled:{text:"text-amber-500/80",icon:fl,spin:!1}};function Xg({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 Zt({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(Xg,{card:e}),r&&(n?h.jsx(Ut,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}):h.jsx(ml,{className:"h-4 w-4 text-amber-400/80",strokeWidth:3}))]})]})}function Yg({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(Yt,{children:[h.jsx(Zt,{card:e,icon:gl,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(Jt,{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 Jg({card:e}){var y;const t=((y=e.output)==null?void 0:y.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(Yt,{children:[h.jsx(Zt,{card:e,icon:u?xl:yl,expanded:r,canExpand:!!t||n,onToggle:o}),r&&t&&h.jsx(Jt,{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 Zg({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(Yt,{children:[h.jsx(Zt,{card:e,icon:Kn,expanded:n,canExpand:!!l||t,onToggle:o}),n&&l&&h.jsx(Jt,{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 ex({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(Yt,{children:[h.jsx(Zt,{card:e,icon:bl,expanded:r,canExpand:o,onToggle:u}),r&&t&&h.jsx(Jt,{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 tx(e){const t=e.toLowerCase();return t==="exec"||t==="execute_command"||t==="bash"||t==="shell"||t.includes("run_")}function nx(e){const t=e.toLowerCase();return t==="read_file"||t==="write_file"||t==="edit_file"||t==="apply_patch"}function rx(e){const t=e.toLowerCase();return t==="grep_search"||t==="find_files"||t.includes("search")}function ix({card:e}){return tx(e.toolName)?h.jsx(Yg,{card:e}):nx(e.toolName)?h.jsx(Jg,{card:e}):rx(e.toolName)?h.jsx(Zg,{card:e}):h.jsx(ex,{card:e})}function sx(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 ax=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(_g,{text:a.text,role:i,texts:r},`markdown-${l}`):a.type==="reasoning"?h.jsx(Gg,{label:a.label,text:a.text,isUser:s},`reasoning-${l}`):a.type==="tool-card"?h.jsx("div",{className:"mt-0.5",children:h.jsx(ix,{card:a.card})},`tool-${l}`):a.type==="file"?h.jsx(Qg,{file:a.file,isUser:s},`file-${l}`):a.type==="unknown"?h.jsx(sx,{label:a.label,rawType:a.rawType,text:a.text},`unknown-${l}`):null)})})});function lx(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 ox=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function ux(e){const t=e.trim();return t?t.replace(ox,"").trim().length>0:!1}function cx(e){return e.parts.some(t=>t.type==="markdown"||t.type==="reasoning"?ux(t.text):!0)}function hx(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(sn,{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(ax,{message:r,texts:e.texts}),h.jsx(lx,{roleLabel:r.roleLabel,timestampLabel:r.timestampLabel,isUser:i})]}),i?h.jsx(sn,{role:r.role}):null]},r.id)}),e.isSending&&!n?h.jsxs("div",{className:"flex justify-start gap-3",children:[h.jsx(sn,{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 dx=10;function fx(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,fx(n))}))}function px(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??dx)};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 Ra(){return Jn()}function mx(e){return ju(e)}function Ri(e){return Du(e)}function ji(e){return Kt(e,"skill")}function gx(e){return Kt(e,"file")}function xx(e,t,n){const r=new Set(t),i=Zn(e,o=>o.tokenKind==="skill"&&!r.has(o.tokenKey)),s=Kt(i,"skill"),a=new Map(n.map(o=>[o.spec,o])),l=t.filter(o=>!s.includes(o)).map(o=>{var u;return Yn({tokenKind:"skill",tokenKey:o,label:((u=a.get(o))==null?void 0:u.label)||o})});return l.length===0?i:Je([...i,...l])}function Pi(e,t){const n=new Set(t.map(r=>r.id));return Zn(e,r=>r.tokenKind==="file"&&!n.has(r.tokenKey))}function yx(e,t){const n=new Set(gx(e));return t.filter(r=>n.has(r.id))}function bx(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 Sx={isProviderStateResolved:!1,composerNodes:Ra(),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:[]},Y=Vt(e=>({snapshot:Sx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))})),kx={sessionRunStatusByKey:new Map,isLocallyRunning:!1,activeBackendRunId:null},Hn=Vt(e=>({snapshot:kx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))})),wx={sessions:[],selectedSessionKey:null,selectedAgentId:"main",query:"",isLoading:!1},ae=Vt(e=>({snapshot:wx,setSnapshot:t=>e(n=>({snapshot:{...n.snapshot,...t}}))}));function vx(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 c=new Date(d.updatedAt).getTime();c>=n?s.push(d):c>=r?a.push(d):c>=i?l.push(d):o.push(d)}const u=[];return s.length>0&&u.push({label:C("chatSidebarToday"),sessions:s}),a.length>0&&u.push({label:C("chatSidebarYesterday"),sessions:a}),l.length>0&&u.push({label:C("chatSidebarPrevious7Days"),sessions:l}),o.length>0&&u.push({label:C("chatSidebarOlder"),sessions:o}),u}function Cx(e){if(e.label&&e.label.trim())return e.label.trim();const t=e.key.split(":");return t[t.length-1]||e.key}function Tx(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 Mx(e){var t;return e.ready===!1?((t=e.reasonMessage)==null?void 0:t.trim())||C("statusSetup"):C("statusReady")}const Ix=[{target:"/cron",label:()=>C("chatSidebarScheduledTasks"),icon:qn},{target:"/skills",label:()=>C("chatSidebarSkills"),icon:$n}];function Nx(){var H,P;const e=Xn(),t=Pl(),[n,r]=k.useState(!1),[i,s]=k.useState(null),[a,l]=k.useState(""),[o,u]=k.useState(null),d=Y(v=>v.snapshot),c=ae(v=>v.snapshot),p=Hn(v=>v.snapshot),f=Dl(v=>v.connectionStatus),{language:m,setLanguage:y}=Qn(),{theme:S,setTheme:g}=Fl(),M=lu(),I=C(((H=yr.find(v=>v.value===S))==null?void 0:H.labelKey)??"themeWarm"),D=((P=br.find(v=>v.value===m))==null?void 0:P.label)??m,F=k.useMemo(()=>vx(c.sessions),[c.sessions]),T=d.defaultSessionType||"native",_=k.useMemo(()=>d.sessionTypeOptions.filter(v=>v.value!==T),[T,d.sessionTypeOptions]),z=v=>{m!==v&&(y(v),window.location.reload())},B=(v,j)=>{const{sessions:$}=ae.getState().snapshot;ae.getState().setSnapshot({sessions:$.map(te=>te.key===v?{...te,...j?{label:j}:{label:void 0}}:te)})},w=v=>{var j;s(v.key),l(((j=v.label)==null?void 0:j.trim())??"")},E=()=>{s(null),l(""),u(null)},L=async v=>{var te;const j=a.trim(),$=((te=v.label)==null?void 0:te.trim())??"";if(j===$){E();return}u(v.key);try{await M({sessionKey:v.key,label:j||null}),B(v.key,j||void 0),E()}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(Ol,{className:"flex items-center gap-2.5 min-w-0",suffix:h.jsx(su,{status:f})})}),h.jsx("div",{className:"px-4 pb-3",children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Fe,{variant:"primary",className:ve("min-w-0 rounded-xl",_.length>0?"flex-1 rounded-r-md":"w-full"),onClick:()=>{r(!1),e.chatSessionListManager.createSession(T)},children:[h.jsx(Sl,{className:"h-4 w-4 mr-2"}),C("chatSidebarNewTask")]}),_.length>0?h.jsxs(go,{open:n,onOpenChange:r,children:[h.jsx(xo,{asChild:!0,children:h.jsx(Fe,{variant:"primary",size:"icon",className:"h-9 w-10 shrink-0 rounded-xl rounded-l-md","aria-label":C("chatSessionTypeLabel"),children:h.jsx(Ut,{className:"h-4 w-4"})})}),h.jsxs(yo,{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:C("chatSessionTypeLabel")}),h.jsx("div",{className:"mt-1 space-y-1",children:_.map(v=>h.jsxs("button",{type:"button",onClick:()=>{e.chatSessionListManager.createSession(v.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:v.label}),h.jsx("span",{className:ve("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold",v.ready===!1?"bg-amber-100 text-amber-800":"bg-emerald-100 text-emerald-700"),children:v.ready===!1?C("statusSetup"):C("statusReady")})]}),h.jsx("div",{className:"mt-0.5 text-[11px] text-gray-500",children:Mx(v)})]},v.value))})]})]}):null]})}),h.jsx("div",{className:"px-4 pb-3",children:h.jsxs("div",{className:"relative",children:[h.jsx(Kn,{className:"h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400"}),h.jsx(Wn,{value:c.query,onChange:v=>e.chatSessionListManager.setQuery(v.target.value),placeholder:C("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:Ix.map(v=>h.jsx("li",{children:h.jsx(Sr,{to:v.target,label:v.label(),icon:v.icon,density:"compact"})},v.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:c.isLoading?h.jsx("div",{className:"text-xs text-gray-500 p-3",children:C("sessionsLoading")}):F.length===0?h.jsxs("div",{className:"p-4 text-center",children:[h.jsx(kl,{className:"h-6 w-6 mx-auto mb-2 text-gray-300"}),h.jsx("div",{className:"text-xs text-gray-500",children:C("sessionsEmpty")})]}):h.jsx("div",{className:"space-y-3",children:F.map(v=>h.jsxs("div",{children:[h.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-400 uppercase tracking-wider",children:v.label}),h.jsx("div",{className:"space-y-0.5",children:v.sessions.map(j=>{const $=c.selectedSessionKey===j.key,te=p.sessionRunStatusByKey.get(j.key),pe=Tx(j.sessionType,d.sessionTypeOptions),x=i===j.key,le=o===j.key;return h.jsx(au,{session:j,active:$,runStatus:te,sessionTypeLabel:pe,title:Cx(j),isEditing:x,draftLabel:a,isSaving:le,onSelect:()=>e.chatSessionListManager.selectSession(j.key),onStartEditing:()=>w(j),onDraftLabelChange:l,onSave:()=>L(j),onCancel:E},j.key)})})]},v.label))})}),h.jsxs("div",{className:"px-3 py-3 border-t border-gray-200/60 space-y-0.5",children:[h.jsx(Sr,{to:"/settings",label:C("settings"),icon:wl,density:"compact"}),h.jsx(_l,{onClick:()=>t.open(void 0,{kind:"docs",newTab:!0,title:"Docs"}),icon:vl,label:C("docBrowserHelp"),density:"compact"}),h.jsx(kr,{value:S,onValueChange:v=>g(v),icon:Cl,label:C("theme"),valueLabel:I,density:"compact",children:yr.map(v=>h.jsx(dt,{value:v.value,className:"text-xs",children:C(v.labelKey)},v.value))}),h.jsx(kr,{value:m,onValueChange:v=>z(v),icon:Tl,label:C("language"),valueLabel:D,density:"compact",children:br.map(v=>h.jsx(dt,{value:v.value,className:"text-xs",children:v.label},v.value))})]})]})}function Ex(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 Lx(e){const t=new FormData;for(const i of e)t.append("files",i);const n=await fetch(`${Ji}/api/ncp/assets`,{method:"POST",body:t,credentials:"include"}),r=await n.json();if(!n.ok||!r.ok)throw new Error(Ex(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 Ie={exactSpec:1200,exactLabel:1150,prefixSpec:1e3,prefixLabel:950,prefixToken:900,containsSpec:800,containsLabel:760,containsDescription:500,subsequence:300,fallback:1};function jt(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 Ax(e,t){const n=jt(t);if(!n)return Ie.fallback;const r=jt(e.key),i=jt(e.label||e.key),s=jt(`${e.descriptionZh??""} ${e.description??""}`),a=i.split(/[\s/_-]+/).filter(Boolean);return r===n?Ie.exactSpec:i===n?Ie.exactLabel:r.startsWith(n)?Ie.prefixSpec:i.startsWith(n)?Ie.prefixLabel:a.some(l=>l.startsWith(n))?Ie.prefixToken:r.includes(n)?Ie.containsSpec:i.includes(n)?Ie.containsLabel:s.includes(n)?Ie.containsDescription:Di(n,i)||Di(n,r)?Ie.subsequence:0}function Rx(e,t,n){const r=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0});return e.map((i,s)=>({record:i,order:s,score:Ax(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 jx(e){return e.map(t=>({key:t.key,label:t.label,description:t.descriptionZh||t.description||"",badgeLabel:t.badgeLabel}))}function Px(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:jx(e.skillRecords),selectedKeys:e.selectedSkills,onSelectedKeysChange:e.onSelectedKeysChange}}function Dx(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 Fx(e){const t=e.modelOptions.find(s=>s.value===e.selectedModel),n=e.modelOptions[0],r=t??n;return{key:"model",value:e.hasModelOptions?r==null?void 0:r.value:void 0,placeholder:e.texts.modelSelectPlaceholder,selectedLabel:r?`${r.providerLabel}/${r.modelLabel}`:void 0,icon:"sparkles",options:e.modelOptions.map(s=>({value:s.value,label:s.modelLabel,description:s.providerLabel})),disabled:!e.hasModelOptions,loading:e.isModelOptionsLoading,emptyLabel:e.texts.modelNoOptionsLabel,onValueChange:e.onValueChange}}function Ox(e){const t=[];for(const n of["off",...e])t.includes(n)||t.push(n);return t}function _x(e){if(e.supportedLevels.length===0)return null;const t=Ox(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)}}function zx(){return{off:C("chatThinkingLevelOff"),minimal:C("chatThinkingLevelMinimal"),low:C("chatThinkingLevelLow"),medium:C("chatThinkingLevelMedium"),high:C("chatThinkingLevelHigh"),adaptive:C("chatThinkingLevelAdaptive"),xhigh:C("chatThinkingLevelXhigh")}}function Bx(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 Hx(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 Ux(){var w;const e=Xn(),{language:t}=Qn(),n=Y(E=>E.snapshot),[r,i]=k.useState(null),s=k.useRef(null),a=k.useRef(null),l=k.useMemo(()=>C("chatSkillsPickerOfficial"),[t]),o=k.useMemo(()=>({slashSkillSubtitle:C("chatSlashTypeSkill"),slashSkillSpecLabel:C("chatSlashSkillSpec"),noSkillDescription:C("chatSkillsPickerNoDescription")}),[t]),u=k.useMemo(()=>Bx(n.skillRecords,l),[n.skillRecords,l]),d=k.useMemo(()=>Hx(n.modelOptions),[n.modelOptions]),c=d.length>0,p=!n.isProviderStateResolved&&!c,f=n.isProviderStateResolved&&!c,m=(p||f)&&!n.isSending||n.sessionTypeUnavailable,y=typeof e.chatInputManager.addAttachments=="function",S=p?"":c?C("chatInputPlaceholder"):C("chatModelNoOptions"),g=k.useMemo(()=>Rx(u,r??"",o),[r,u,o]),M=d.find(E=>E.value===n.selectedModel),I=M==null?void 0:M.thinkingCapability,D=(I==null?void 0:I.supported)??[],F=n.stopDisabledReason==="__preparing__"?C("chatStopPreparing"):((w=n.stopDisabledReason)==null?void 0:w.trim())||C("chatStopUnavailable"),T=k.useCallback(E=>{if(E==="unsupported-type"){ht.error(C("chatInputAttachmentUnsupported"));return}if(E==="too-large"){ht.error(C("chatInputAttachmentTooLarge").replace("{maxMb}",String(ls/(1024*1024))));return}ht.error(C("chatInputAttachmentReadFailed"))},[]),_=k.useCallback(async E=>{var H,P,v;if(!y||E.length===0)return;const L=await ru(E,{uploadBatch:Lx});if(L.attachments.length>0){const j=((P=(H=e.chatInputManager).addAttachments)==null?void 0:P.call(H,L.attachments))??[];j.length>0&&((v=s.current)==null||v.insertFileTokens(j.map($=>({tokenKey:$.id,label:$.name}))))}L.rejected.length>0&&T(L.rejected[0].reason)},[y,e.chatInputManager,T]),z=[Fx({modelOptions:d,selectedModel:n.selectedModel,isModelOptionsLoading:p,hasModelOptions:c,onValueChange:e.chatInputManager.selectModel,texts:{modelSelectPlaceholder:C("chatSelectModel"),modelNoOptionsLabel:C("chatModelNoOptions")}}),_x({supportedLevels:D,selectedThinkingLevel:n.selectedThinkingLevel,defaultThinkingLevel:(I==null?void 0:I.default)??null,onValueChange:E=>e.chatInputManager.selectThinkingLevel(E),texts:{thinkingLabels:zx()}})].filter(E=>E!==null),B=Px({skillRecords:u,selectedSkills:n.selectedSkills,isLoading:n.isSkillsLoading,onSelectedKeysChange:e.chatInputManager.selectSkills,texts:{title:C("chatSkillsPickerTitle"),searchPlaceholder:C("chatSkillsPickerSearchPlaceholder"),emptyLabel:C("chatSkillsPickerEmpty"),loadingLabel:C("sessionsLoading"),manageLabel:C("chatSkillsPickerManage")}});return h.jsxs(h.Fragment,{children:[h.jsx(Ts,{ref:s,composer:{nodes:n.composerNodes,placeholder:S,disabled:m,onNodesChange:e.chatInputManager.setComposerNodes,...y?{onFilesAdd:_}:{},onSlashQueryChange:i},slashMenu:{isLoading:n.isSkillsLoading,items:g,texts:{slashLoadingLabel:C("chatSlashLoading"),slashSectionLabel:C("chatSlashSectionSkills"),slashEmptyLabel:C("chatSlashNoResult"),slashHintLabel:C("chatSlashHint"),slashSkillHintLabel:C("chatSlashSkillHint")}},hint:Dx({isModelOptionsLoading:p,isModelOptionsEmpty:f,onGoToProviders:e.chatInputManager.goToProviders,texts:{noModelOptionsLabel:C("chatModelNoOptions"),configureProviderLabel:C("chatGoConfigureProvider")}}),toolbar:{selects:z,accessories:[{key:"attach",label:C("chatInputAttach"),icon:"paperclip",iconOnly:!0,disabled:!y||m||n.isSending,...y?{onClick:()=>{var E;return(E=a.current)==null?void 0:E.click()}}:{tooltip:C("chatInputAttachComingSoon")}}],skillPicker:B,actions:{sendError:n.sendError,isSending:n.isSending,canStopGeneration:n.canStopGeneration,sendDisabled:n.draft.trim().length===0&&n.attachments.length===0||!c||n.sessionTypeUnavailable,stopDisabled:!n.canStopGeneration,stopHint:F,sendButtonLabel:C("chatSend"),stopButtonLabel:C("chatStop"),onSend:e.chatInputManager.send,onStop:e.chatInputManager.stop}}}),y?h.jsx("input",{ref:a,type:"file",multiple:!0,className:"hidden",onChange:async E=>{const L=Array.from(E.target.files??[]);E.currentTarget.value="",await _(L)}}):null]})}const Vx=["cmd","command","query","q","path","url","to","channel","agentId","sessionKey"];function Fi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Un(e,t=2400){return e.length<=t?e:`${e.slice(0,t)}
|
|
37
|
-
…`}function Ht(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";try{return Un(JSON.stringify(e,null,2))}catch{return String(e)}}function $x(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 Kx(e){const t=$x(e);if(!t){const r=Ht(e).trim();return r?Un(r,120):void 0}const n=[];for(const r of Vx){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(" · "):Un(Ht(t),140)}const qx=/\u200B|\u200C|\u200D|\u2060|\uFEFF/g;function Ft(e){return typeof e=="object"&&e!==null}function Tn(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function ja(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 Wx(e,t){if(!Ft(e))return null;const n=Ft(e.asset)?e.asset:Array.isArray(e.assets)&&e.assets.length>0&&Ft(e.assets[0])?e.assets[0]:null;if(!n)return null;const r=Tn(n.url),i=Tn(n.mimeType)??"application/octet-stream",s=ja(n.sizeBytes);return r?{type:"file",file:{label:Tn(n.name)??(i.startsWith("image/")?t.imageAttachmentLabel:t.fileAttachmentLabel),mimeType:i,dataUrl:r,...s!=null?{sizeBytes:s}:{},isImage:i.startsWith("image/")}}:null}function Qx(e){return e.type==="text"&&typeof e.text=="string"}function Gx(e){return e.type==="reasoning"&&typeof e.reasoning=="string"}function Xx(e){return e.type==="file"&&typeof e.mimeType=="string"&&typeof e.data=="string"}function Yx(e){return e.type!=="tool-invocation"||!Ft(e.toolInvocation)?!1:typeof e.toolInvocation.toolName=="string"}function Jx(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 Zx(e,t){return e==="user"?t.user:e==="assistant"?t.assistant:e==="tool"?t.tool:e==="system"?t.system:t.fallback}function ey(e){return e==="user"||e==="assistant"||e==="tool"||e==="system"?e:"message"}function ty(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 ny(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(qx,"").trim()?t:null}function ry(e,t){var n;return{id:e.id,role:ey(e.role),roleLabel:Zx(e.role,t.texts.roleLabels),timestampLabel:t.formatTimestamp(Jx(e)),status:(n=e.meta)==null?void 0:n.status,parts:e.parts.map(r=>{if(Qx(r)){const i=Oi(r.text);return i?{type:"markdown",text:i}:null}if(Gx(r)){const i=Oi(r.reasoning);return i?{type:"reasoning",text:i,label:t.texts.reasoningLabel}:null}if(Xx(r)){const i=r.mimeType.startsWith("image/"),s=ja(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(Yx(r)){const i=r.toolInvocation,s=Wx(i.result,t.texts);if(s)return s;const a=ny({status:i.status,error:i.error,cancelled:i.cancelled,result:i.result,texts:t.texts}),l=Kx(i.parsedArgs??i.args),o=typeof i.error=="string"&&i.error.trim()?i.error.trim():i.result!=null?Ht(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:ty(u,t.texts)}}return{type:"unknown",label:t.texts.unknownPartLabel,rawType:typeof r.type=="string"?r.type:"unknown",text:Ht(r)}}).filter(r=>r!==null)}}const _i=new WeakMap;function iy(e){return{roleLabels:{user:C("chatRoleUser"),assistant:C("chatRoleAssistant"),tool:C("chatRoleTool"),system:C("chatRoleSystem"),fallback:C("chatRoleMessage")},reasoningLabel:C("chatReasoning"),toolCallLabel:C("chatToolCall"),toolResultLabel:C("chatToolResult"),toolNoOutputLabel:C("chatToolNoOutput"),toolOutputLabel:C("chatToolOutput"),toolStatusPreparingLabel:C("chatToolStatusPreparing"),toolStatusRunningLabel:C("chatToolStatusRunning"),toolStatusCompletedLabel:C("chatToolStatusCompleted"),toolStatusFailedLabel:C("chatToolStatusFailed"),toolStatusCancelledLabel:C("chatToolStatusCancelled"),imageAttachmentLabel:C("chatImageAttachment"),fileAttachmentLabel:C("chatFileAttachment"),unknownPartLabel:C("chatUnknownPart")}}function sy(e){return{copyCodeLabel:C("chatCodeCopy"),copiedCodeLabel:C("chatCodeCopied"),typingLabel:C("chatTyping")}}function ay(e){const{language:t}=Qn(),n=k.useMemo(()=>iy(),[t]),r=k.useMemo(()=>e.uiMessages.map(a=>{var d,c;const l=_i.get(a);if(l&&l.language===t)return l.viewModel;const o={id:a.id,role:a.role,meta:{timestamp:(d=a.meta)==null?void 0:d.timestamp,status:(c=a.meta)==null?void 0:c.status},parts:a.parts},u=ry(o,{formatTimestamp:p=>$t(p,t),texts:n});return _i.set(a,{language:t,viewModel:u}),u}),[t,e.uiMessages,n]),i=k.useMemo(()=>e.uiMessages.some(a=>{var l,o;return a.role==="assistant"&&(((l=a.meta)==null?void 0:l.status)==="streaming"||((o=a.meta)==null?void 0:o.status)==="pending")}),[e.uiMessages]),s=k.useMemo(()=>sy(),[t]);return h.jsx(hx,{messages:r,isSending:e.isSending,hasAssistantDraft:i,className:e.className,texts:s})}const ly=[{icon:Ml,titleKey:"chatWelcomeCapability1Title",descKey:"chatWelcomeCapability1Desc"},{icon:$n,titleKey:"chatWelcomeCapability2Title",descKey:"chatWelcomeCapability2Desc"},{icon:qn,titleKey:"chatWelcomeCapability3Title",descKey:"chatWelcomeCapability3Desc"}];function oy({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(Qi,{className:"h-8 w-8 text-primary"})}),h.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:C("chatWelcomeTitle")}),h.jsx("p",{className:"text-sm text-gray-500 mb-8",children:C("chatWelcomeSubtitle")}),h.jsx("div",{className:"grid grid-cols-3 gap-3",children:ly.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:C(t.titleKey)}),h.jsx("div",{className:"text-[11px] text-gray-500 leading-relaxed",children:C(t.descKey)})]},t.titleKey)})})]})})}const uy={isProviderStateResolved:!1,modelOptions:[],sessionTypeUnavailable:!1,sessionTypeUnavailableMessage:null,sessionTypeLabel:null,selectedSessionKey:null,sessionDisplayName:void 0,canDeleteSession:!1,isDeletePending:!1,threadRef:null,isHistoryLoading:!1,uiMessages:[],isSending:!1,isAwaitingAssistantOutput:!1},ct=Vt(e=>({snapshot:uy,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 hy(){var c;const e=Xn(),t=ct(p=>p.snapshot),n=k.useRef(null),r=t.threadRef??n,i=!!(t.selectedSessionKey||t.sessionTypeLabel),s=t.sessionDisplayName||t.selectedSessionKey||C("chatSidebarNewTask"),a=!t.selectedSessionKey&&t.uiMessages.length===0&&!t.isSending,l=t.modelOptions.length>0,o=t.isProviderStateResolved&&!l,u=t.isHistoryLoading&&t.uiMessages.length===0&&!t.isSending&&!t.isAwaitingAssistantOutput,{onScroll:d}=px({scrollRef:r,resetKey:t.selectedSessionKey,isLoading:t.isHistoryLoading,hasContent:t.uiMessages.length>0,contentVersion:t.uiMessages[t.uiMessages.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(Fe,{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(Xi,{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:C("chatModelNoOptions")}),h.jsx("button",{type:"button",onClick:e.chatThreadManager.goToProviders,className:"text-xs font-semibold text-amber-900 underline-offset-2 hover:underline",children:C("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(oy,{onCreateSession:e.chatThreadManager.createSession}):u?h.jsx("div",{className:"h-full"}):t.uiMessages.length===0?h.jsx("div",{className:"px-5 py-5 text-sm text-gray-500",children:C("chatNoMessages")}):h.jsx("div",{className:"mx-auto w-full max-w-[min(1120px,100%)] px-6 py-5",children:h.jsx(ay,{uiMessages:t.uiMessages,isSending:t.isSending&&t.isAwaitingAssistantOutput})})}),h.jsx(Ux,{})]}):h.jsx(cy,{})}function zi(e){return $t(e??void 0)}function dy(e){return typeof e!="number"||!Number.isFinite(e)?"-":$t(new Date(e))}function fy(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 py(e){const t=e.schedule;return t.kind==="cron"?t.expr?`cron ${t.expr}`:"cron":t.kind==="every"?`every ${fy(t.everyMs)}`:t.kind==="at"?`at ${dy(t.atMs)}`:"-"}function my(e){if(!e.payload.deliver)return"-";const t=e.payload.channel??"-",n=e.payload.to??"-";return`${t}:${n}`}function gy(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 xy(e,t){return t==="all"?!0:t==="enabled"?e.enabled:!e.enabled}function yy(){var m;const[e,t]=k.useState(""),[n,r]=k.useState("all"),i=zl({all:!0}),s=Bl(),a=Hl(),l=Ul(),{confirm:o,ConfirmDialog:u}=ts(),d=k.useMemo(()=>{var S;return(((S=i.data)==null?void 0:S.jobs)??[]).filter(g=>gy(g,e)).filter(g=>xy(g,n))},[i.data,e,n]),c=async y=>{await o({title:`${C("cronDeleteConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,variant:"destructive",confirmLabel:C("delete")})&&s.mutate({id:y.id})},p=async y=>{const S=!y.enabled;await o({title:S?`${C("cronEnableConfirm")}?`:`${C("cronDisableConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,variant:S?"default":"destructive",confirmLabel:S?C("cronEnable"):C("cronDisable")})&&a.mutate({id:y.id,enabled:S})},f=async y=>{const S=!y.enabled;await o({title:S?`${C("cronRunForceConfirm")}?`:`${C("cronRunConfirm")}?`,description:y.name?`${y.name} (${y.id})`:y.id,confirmLabel:C("cronRunNow")})&&l.mutate({id:y.id,force:S})};return h.jsxs(Co,{fullHeight:!0,children:[h.jsx(To,{title:C("cronPageTitle"),description:C("cronPageDescription"),actions:h.jsx(Fe,{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(Il,{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(Wn,{value:e,onChange:y=>t(y.target.value),placeholder:C("cronSearchPlaceholder"),className:"pl-9"}),h.jsx(qn,{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(Vl,{value:n,onValueChange:y=>r(y),children:[h.jsx($l,{className:"w-full",children:h.jsx(Kl,{placeholder:C("cronStatusLabel")})}),h.jsxs(ql,{children:[h.jsx(dt,{value:"all",children:C("cronStatusAll")}),h.jsx(dt,{value:"enabled",children:C("cronStatusEnabled")}),h.jsx(dt,{value:"disabled",children:C("cronStatusDisabled")})]})]})}),h.jsxs("div",{className:"text-xs text-gray-500 ml-auto",children:[C("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:C("cronLoading")}):d.length===0?h.jsx("div",{className:"text-sm text-gray-400 p-4 text-center",children:C("cronEmpty")}):h.jsx("div",{className:"space-y-4",children:d.map(y=>h.jsx(Wl,{className:"border border-gray-200",children:h.jsx(Ql,{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:y.name||y.id}),h.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500",children:y.id}),h.jsx("span",{className:ve("text-[10px] font-semibold px-2 py-0.5 rounded-full",y.enabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"),children:y.enabled?C("enabled"):C("disabled")}),y.deleteAfterRun&&h.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full bg-amber-50 text-amber-700",children:C("cronOneShot")})]}),h.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[C("cronScheduleLabel"),": ",py(y)]}),h.jsx("div",{className:"mt-2 text-sm text-gray-700 whitespace-pre-wrap break-words",children:y.payload.message}),h.jsxs("div",{className:"mt-2 text-xs text-gray-500",children:[C("cronDeliverTo"),": ",my(y)]})]}),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:[C("cronNextRun"),":"]})," ",zi(y.state.nextRunAt)]}),h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[C("cronLastRun"),":"]})," ",zi(y.state.lastRunAt)]}),h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-gray-700",children:[C("cronLastStatus"),":"]})," ",y.state.lastStatus??"-"]}),y.state.lastError&&h.jsx("div",{className:"text-[11px] text-red-500 break-words",children:y.state.lastError})]}),h.jsxs("div",{className:"flex items-start gap-2 flex-wrap justify-end",children:[h.jsxs(Fe,{variant:"subtle",size:"sm",onClick:()=>f(y),className:"gap-1",children:[h.jsx(Nl,{className:"h-3.5 w-3.5"}),C("cronRunNow")]}),h.jsxs(Fe,{variant:y.enabled?"outline":"primary",size:"sm",onClick:()=>p(y),className:"gap-1",children:[h.jsx(El,{className:"h-3.5 w-3.5"}),y.enabled?C("cronDisable"):C("cronEnable")]}),h.jsxs(Fe,{variant:"destructive",size:"sm",onClick:()=>c(y),className:"gap-1",children:[h.jsx(Xi,{className:"h-3.5 w-3.5"}),C("delete")]})]})]})})},y.id))})}),h.jsx(u,{})]})}function by(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 Sy({view:e,confirmDialog:t}){return h.jsxs("div",{className:"h-full flex",children:[h.jsx(Nx,{}),e==="chat"?h.jsx(hy,{}):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(yy,{})})}):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(uo,{forcedType:"skills"})})})}),t]})}function ky(){return(e,t)=>fetch(e,{credentials:"include",...t})}const Vn="sid_";function wy(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 vy(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`${Vn}${r}`}function Cy(e){if(!e.startsWith(Vn))return null;const t=e.slice(Vn.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 Ty(e){if(!e)return null;const t=Cy(e);if(t)return t;try{return decodeURIComponent(e)}catch{return e}}function My(e){return`/chat/${vy(e)}`}const Se="native";function ze(e){return typeof e!="string"?Se:e.trim().toLowerCase()||Se}function bt(e,t){return e==="native"?C("chatSessionTypeNative"):e.trim().split(/[-_]+/g).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function Iy(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())||bt(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(Se)||t.set(Se,{value:Se,label:bt(Se),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),Array.from(t.values()).sort((r,i)=>r.value===Se?-1:i.value===Se?1:r.value.localeCompare(i.value))}function Ny(e){const{selectedSession:t,selectedSessionKey:n,pendingSessionType:r,setPendingSessionType:i,sessionTypesData:s}=e,a=k.useMemo(()=>Iy((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(M=>M.value===g)||S.push({value:g,label:bt(g),ready:!0,reason:null,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}),S.sort((M,I)=>M.value===Se?-1:I.value===Se?1:M.value.localeCompare(I.value))},[a,t==null?void 0:t.sessionType]),o=k.useMemo(()=>ze((s==null?void 0:s.defaultType)??Se),[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===Se)&&(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]),y=k.useMemo(()=>{var S;return t&&!f.has(ze(t.sessionType))?`${bt(d)} ${C("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:y}}function Bi(e){return(e==null?void 0:e.trim().toLowerCase())||"native"}function Ey(e,t){if(typeof t!="string")return!1;const n=t.trim();return n?e.some(r=>r.value===n):!1}function Ly(e,t){return typeof t=="string"&&e.includes(t)}function Ay(e){return e.length===0?null:e.includes("off")?"off":e[0]??null}function Pa(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 Ry(e){var n;const{modelOptions:t}=e;return t.length===0?"":Pa({currentValue:e.currentSelectedModel,selectedSessionPreferredValue:e.selectedSessionPreferredModel,fallbackPreferredValue:e.fallbackPreferredModel,defaultValue:e.defaultModel,isValueSupported:r=>Ey(t,r),firstAvailableValue:((n=t[0])==null?void 0:n.value)??"",preferSessionPreferredValue:e.preferSessionPreferredModel,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedModelOnSessionChange})}function jy(e){const{supportedThinkingLevels:t}=e;return t.length===0?null:Pa({currentValue:e.currentSelectedThinkingLevel,selectedSessionPreferredValue:e.selectedSessionPreferredThinking,fallbackPreferredValue:e.fallbackPreferredThinking,defaultValue:e.defaultThinkingLevel,isValueSupported:n=>Ly(t,n),firstAvailableValue:Ay(t)??"off",preferSessionPreferredValue:e.preferSessionPreferredThinking,preserveCurrentValueOnSessionChange:e.preserveCurrentSelectedThinkingOnSessionChange})}function Da(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 Py(e){return Da({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 Dy(e){return Da({sessions:e.sessions,selectedSessionKey:e.selectedSessionKey,sessionType:e.sessionType,readPreference:t=>t.preferredThinking??void 0})}function Fa(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 Fy(e){const{modelOptions:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,setSelectedModel:l}=e;Fa({isPreferenceAvailable:t.length>0,emptyValue:"",selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:d})=>Ry({currentSelectedModel:o,modelOptions:t,selectedSessionPreferredModel:i,fallbackPreferredModel:s,defaultModel:a,preferSessionPreferredModel:u,preserveCurrentSelectedModelOnSessionChange:d})})}function Oy(e){const{supportedThinkingLevels:t,selectedSessionKey:n,selectedSessionExists:r=!1,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,setSelectedThinkingLevel:l}=e;Fa({isPreferenceAvailable:t.length>0,emptyValue:null,selectedSessionKey:n,selectedSessionExists:r,setValue:l,resolveValue:({currentValue:o,sessionChanged:u,preserveCurrentValueOnSessionChange:d})=>jy({currentSelectedThinkingLevel:o,supportedThinkingLevels:t,selectedSessionPreferredThinking:i,fallbackPreferredThinking:s,defaultThinkingLevel:a,preferSessionPreferredThinking:u,preserveCurrentSelectedThinkingOnSessionChange:d})})}function _y(){return Ll({queryKey:["ncp-session-types"],queryFn:Gl,staleTime:1e4,retry:!1})}function zy(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.key.toLowerCase().includes(n)):e}function By(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 Hy(e){var D,F,T,_,z,B,w,E;const t=Xl(),n=Yl(),r=Jl({limit:200}),i=_y(),s=co("skill"),a=(t.isFetched||t.isSuccess)&&(n.isFetched||n.isSuccess),l=k.useMemo(()=>{const L=Mo({meta:n.data,config:t.data,onlyConfigured:!0}),H=new Set,P=[];for(const v of L)for(const j of v.models){const $=Io(v.prefix,j);!$||H.has($)||(H.add($),P.push({value:$,modelLabel:j,providerLabel:v.displayName,thinkingCapability:No(v.modelThinking,j,v.aliases)}))}return P.sort((v,j)=>{const $=v.providerLabel.localeCompare(j.providerLabel);return $!==0?$:v.modelLabel.localeCompare(j.modelLabel)})},[n.data,t.data]),o=k.useMemo(()=>{var L;return((L=r.data)==null?void 0:L.sessions)??[]},[(D=r.data)==null?void 0:D.sessions]),u=k.useMemo(()=>So(o),[o]),d=k.useMemo(()=>zy(u,e.query),[u,e.query]),c=k.useMemo(()=>u.find(L=>L.key===e.selectedSessionKey)??null,[u,e.selectedSessionKey]),p=k.useMemo(()=>{var L;return((L=s.data)==null?void 0:L.records)??[]},[(F=s.data)==null?void 0:F.records]),f=Ny({selectedSession:c,selectedSessionKey:e.selectedSessionKey,pendingSessionType:e.pendingSessionType,setPendingSessionType:e.setPendingSessionType,sessionTypesData:i.data}),m=k.useMemo(()=>{var L;return By({modelOptions:l,supportedModels:(L=f.selectedSessionTypeOption)==null?void 0:L.supportedModels})},[l,(T=f.selectedSessionTypeOption)==null?void 0:T.supportedModels]),y=k.useMemo(()=>Py({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]),S=k.useMemo(()=>m.find(L=>L.value===e.currentSelectedModel),[m,e.currentSelectedModel]),g=k.useMemo(()=>{var L;return((L=S==null?void 0:S.thinkingCapability)==null?void 0:L.supported)??[]},[(_=S==null?void 0:S.thinkingCapability)==null?void 0:_.supported]),M=k.useMemo(()=>{var L;return((L=S==null?void 0:S.thinkingCapability)==null?void 0:L.default)??null},[(z=S==null?void 0:S.thinkingCapability)==null?void 0:z.default]),I=k.useMemo(()=>Dy({sessions:u,selectedSessionKey:e.selectedSessionKey,sessionType:f.selectedSessionType}),[u,e.selectedSessionKey,f.selectedSessionType]);return Fy({modelOptions:m,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredModel:c==null?void 0:c.preferredModel,fallbackPreferredModel:((B=f.selectedSessionTypeOption)==null?void 0:B.recommendedModel)??y,defaultModel:((w=f.selectedSessionTypeOption)==null?void 0:w.recommendedModel)??((E=t.data)==null?void 0:E.agents.defaults.model),setSelectedModel:e.setSelectedModel}),Oy({supportedThinkingLevels:g,selectedSessionKey:e.selectedSessionKey,selectedSessionExists:!!c,selectedSessionPreferredThinking:(c==null?void 0:c.preferredThinking)??null,fallbackPreferredThinking:I??null,defaultThinkingLevel:M,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}}function Uy(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const[n,r]of e.entries())if(!Object.is(r,t.get(n)))return!1;return!0}class Vy{constructor(){this.syncSnapshot=t=>{const n=Hn.getState().snapshot,r=t.sessionRunStatusByKey;(!r||Uy(n.sessionRunStatusByKey,r))&&(t.isLocallyRunning===void 0||Object.is(n.isLocallyRunning,t.isLocallyRunning))&&(t.activeBackendRunId===void 0||Object.is(n.activeBackendRunId,t.activeBackendRunId))||Hn.getState().setSnapshot(t)}}}class $y{constructor(t,n){this.uiManager=t,this.streamActionsManager=n,this.hasSnapshotChanges=r=>{const i=ae.getState().snapshot;for(const[s,a]of Object.entries(r))if(!Object.is(i[s],a))return!0;return!1},this.resolveUpdateValue=(r,i)=>typeof i=="function"?i(r):i,this.syncSnapshot=r=>{this.hasSnapshotChanges(r)&&ae.getState().setSnapshot(r)},this.setSelectedAgentId=r=>{const i=ae.getState().snapshot.selectedAgentId,s=this.resolveUpdateValue(i,r);s!==i&&ae.getState().setSnapshot({selectedAgentId:s})},this.setSelectedSessionKey=r=>{const i=ae.getState().snapshot.selectedSessionKey,s=this.resolveUpdateValue(i,r);s!==i&&ae.getState().setSnapshot({selectedSessionKey:s})},this.createSession=r=>{const{snapshot:i}=Y.getState(),{defaultSessionType:s}=i,a=s||"native",l=typeof r=="string"&&r.trim().length>0?r.trim():a;this.streamActionsManager.resetStreamState(),Y.getState().setSnapshot({pendingSessionType:l}),this.uiManager.goToChatRoot()},this.selectSession=r=>{this.uiManager.goToSession(r)},this.setQuery=r=>{const i=ae.getState().snapshot.query,s=this.resolveUpdateValue(i,r);s!==i&&ae.getState().setSnapshot({query:s})}}}const Mn=async()=>{},Hi=()=>{};class Ky{constructor(){this.actions={sendMessage:Mn,stopCurrentRun:Mn,resumeRun:Mn,resetStreamState:Hi,applyHistoryMessages:Hi},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 qy=async e=>!1;class Wy{constructor(){this.state={pathname:""},this.actions={navigate:null,confirm:qy},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(My(t),n)}}}function Qy(e){const t=e.trim();return t.length>0?t:null}function Gy(e){return e??null}class Xy{constructor(t){this.updateSession=t,this.inFlight=null,this.queued=null,this.syncSelectedSessionPreferences=()=>{const n=Y.getState().snapshot,i=ae.getState().snapshot.selectedSessionKey;i&&this.enqueue({sessionKey:i,patch:{preferredModel:Qy(n.selectedModel),preferredThinking:Gy(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 Yy{constructor(t,n,r){this.uiManager=t,this.streamActionsManager=n,this.getDraftSessionId=r,this.sessionPreferenceSync=new Xy(Yi),this.buildAttachmentSignature=i=>[i.assetUri??"",i.url??"",i.name,i.mimeType,String(i.sizeBytes),i.contentBase64??""].join(":"),this.hasSnapshotChanges=i=>{const s=Y.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=Y.getState().snapshot.attachments,a=yx(i,s);Y.getState().setSnapshot({composerNodes:i,attachments:a,draft:Ri(i),selectedSkills:ji(i)})},this.syncComposerSnapshotWithAttachments=(i,s)=>{Y.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)&&(Y.getState().setSnapshot(i),Object.prototype.hasOwnProperty.call(i,"modelOptions")||Object.prototype.hasOwnProperty.call(i,"selectedModel")||Object.prototype.hasOwnProperty.call(i,"selectedThinkingLevel"))){const{selectedModel:s}=Y.getState().snapshot;this.reconcileThinkingForModel(s)}},this.setDraft=i=>{const s=Y.getState().snapshot.draft,a=this.resolveUpdateValue(s,i);a!==s&&this.syncComposerSnapshot(mx(a))},this.setComposerNodes=i=>{const s=Y.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=Y.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=Y.getState().snapshot.pendingSessionType,a=this.resolveUpdateValue(s,i);a!==s&&Y.getState().setSnapshot({pendingSessionType:a})},this.send=async()=>{const i=Y.getState().snapshot,s=ae.getState().snapshot,a=i.draft.trim(),l=i.attachments,o=bx(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(Ra()),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=Y.getState().snapshot.selectedModel,a=this.resolveUpdateValue(s,i);a!==s&&(Y.getState().setSnapshot({selectedModel:a}),this.reconcileThinkingForModel(a))},this.setSelectedThinkingLevel=i=>{const s=Y.getState().snapshot.selectedThinkingLevel,a=this.resolveUpdateValue(s,i);a!==s&&Y.getState().setSnapshot({selectedThinkingLevel:a})},this.selectSessionType=i=>{const s=ze(i);Y.getState().setSnapshot({selectedSessionType:s,pendingSessionType:s})},this.setSelectedSkills=i=>{const s=Y.getState().snapshot,{selectedSkills:a}=s,l=this.resolveUpdateValue(a,i);this.isSameStringArray(l,a)||this.syncComposerSnapshot(xx(s.composerNodes,l,s.skillRecords))},this.selectModel=i=>{this.setSelectedModel(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=Y.getState().snapshot,r=n.modelOptions.find(a=>a.value===t),{selectedThinkingLevel:i}=n,s=this.resolveThinkingForModel(r,i);s!==i&&Y.getState().setSnapshot({selectedThinkingLevel:s})}}const Jy=async()=>{};class Zy{constructor(t,n,r){this.uiManager=t,this.sessionListManager=n,this.streamActionsManager=r,this.actions={refetchSessions:Jy},this.bindActions=i=>{this.actions={...this.actions,...i}},this.hasSnapshotChanges=i=>{const s=ct.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)&&ct.getState().setSnapshot(i)},this.deleteSession=()=>{this.deleteCurrentSession()},this.createSession=()=>{this.sessionListManager.createSession()},this.goToProviders=()=>{this.uiManager.goToProviders()},this.deleteCurrentSession=async()=>{const{snapshot:{selectedSessionKey:i}}=ae.getState();if(!(!i||!await this.uiManager.confirm({title:C("chatDeleteSessionConfirm"),variant:"destructive",confirmLabel:C("delete")}))){ct.getState().setSnapshot({isDeletePending:!0});try{await Zl(i),this.streamActionsManager.resetStreamState(),this.uiManager.goToChatRoot({replace:!0}),await this.actions.refetchSessions()}finally{ct.getState().setSnapshot({isDeletePending:!1})}}}}}class eb{constructor(){this.chatUiManager=new Wy,this.chatStreamActionsManager=new Ky,this.chatSessionListManager=new $y(this.chatUiManager,this.chatStreamActionsManager),this.chatInputManager=new Yy(this.chatUiManager,this.chatStreamActionsManager,()=>this.getDraftSessionId()),this.chatRunStatusManager=new Vy,this.chatThreadManager=new Zy(this.chatUiManager,this.chatSessionListManager,this.chatStreamActionsManager),this.draftSessionId="",this.setDraftSessionId=t=>{this.draftSessionId=t}}getDraftSessionId(){return this.draftSessionId}}function tb(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 nb(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=tb(e.requestedSkills);return n.length>0&&(t.requested_skills=n),t}function rb(e){return e instanceof Error?e.message.includes("ncp session not found:"):!1}function ib({view:e}){var He,Mt,It;const[t]=k.useState(()=>new eb),[n,r]=k.useState(()=>wr()),i=ae(K=>K.snapshot.query),s=ae(K=>K.snapshot.selectedSessionKey),a=ae(K=>K.snapshot.selectedAgentId),l=Y(K=>K.snapshot.pendingSessionType),o=Y(K=>K.snapshot.selectedModel),{confirm:u,ConfirmDialog:d}=ts(),c=Al(),p=Rl(),{sessionId:f}=jl(),m=k.useRef(null),y=k.useRef(s),S=k.useMemo(()=>Ty(f),[f]),{sessionsQuery:g,installedSkillsQuery:M,isProviderStateResolved:I,modelOptions:D,sessionSummaries:F,sessions:T,skillRecords:_,selectedSession:z,sessionTypeOptions:B,defaultSessionType:w,selectedSessionType:E,canEditSessionType:L,sessionTypeUnavailable:H,sessionTypeUnavailableMessage:P}=Hy({query:i,selectedSessionKey:s,currentSelectedModel:o,pendingSessionType:l,setPendingSessionType:t.chatInputManager.setPendingSessionType,setSelectedModel:t.chatInputManager.setSelectedModel,setSelectedThinkingLevel:t.chatInputManager.setSelectedThinkingLevel}),v=g.refetch,j=s??n,$=k.useRef(F);k.useEffect(()=>{$.current=F},[F]);const[te]=k.useState(()=>new Ho({baseUrl:Ji,basePath:"/api/ncp/agent",fetchImpl:ky()})),pe=k.useCallback(async(K,Ue)=>{Ue.throwIfAborted();let Me=null;try{Me=await eo(K,300)}catch(je){if(!rb(je))throw je}Ue.throwIfAborted();const Re=$.current.find(je=>je.sessionId===K)??null;return{messages:(Me==null?void 0:Me.messages)??[],status:(Re==null?void 0:Re.status)==="running"?"running":"idle"}},[]),x=Zo({sessionId:j,client:te,loadSeed:pe});k.useEffect(()=>{t.setDraftSessionId(n)},[n,t]),k.useEffect(()=>{if(s===null){const K=wr();r(K),t.setDraftSessionId(K)}},[t,s]);const le=k.useMemo(()=>ko(x.visibleMessages),[x.visibleMessages]),se=x.isSending||x.isRunning,b=x.isRunning,he=x.isRunning,Te=x.isRunning?null:"__preparing__",re=((He=x.hydrateError)==null?void 0:He.message)??((Mt=x.snapshot.error)==null?void 0:Mt.message)??null,me=x.activeRunId,ke=k.useMemo(()=>wo({summaries:F,activeSessionId:j,isLocallyRunning:se||!!me}),[me,j,se,F]);k.useEffect(()=>{!se&&!me||v()},[me,se,v]),k.useEffect(()=>{t.chatStreamActionsManager.bind({sendMessage:async K=>{var Re,je;if(K.sessionKey!==j)return;const Ue=nb({model:K.model,thinkingLevel:K.thinkingLevel,sessionType:K.sessionType,requestedSkills:K.requestedSkills}),Me=nu({sessionId:K.sessionKey,text:K.message,attachments:K.attachments,parts:K.parts,metadata:Ue});if(Me)try{g.refetch(),await x.send(Me),await g.refetch()}catch(Nt){throw K.restoreDraftOnError&&(K.composerNodes&&K.composerNodes.length>0?(je=(Re=t.chatInputManager).restoreComposerState)==null||je.call(Re,K.composerNodes,K.attachments??[]):t.chatInputManager.setDraft(nt=>nt.trim().length===0?K.message:nt)),Nt}},stopCurrentRun:async()=>{await x.abort(),await g.refetch()},resumeRun:async K=>{K.sessionKey===j&&await x.streamRun()},resetStreamState:()=>{y.current=null},applyHistoryMessages:()=>{}})},[j,x,t,g]),by({view:e,routeSessionKey:S,selectedSessionKey:s,selectedAgentId:a,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,setSelectedAgentId:t.chatSessionListManager.setSelectedAgentId,selectedSessionKeyRef:y,resetStreamState:t.chatStreamActionsManager.resetStreamState,resolveAgentIdFromSessionKey:wy}),k.useEffect(()=>{t.chatUiManager.syncState({pathname:c.pathname}),t.chatUiManager.bindActions({navigate:p,confirm:u})},[u,c.pathname,p,t]);const Le=z?vo(z):void 0,Ae=((It=B.find(K=>K.value===E))==null?void 0:It.label)??bt(E);return k.useEffect(()=>{t.chatThreadManager.bindActions({refetchSessions:g.refetch})},[t,g.refetch]),k.useEffect(()=>{t.chatInputManager.syncSnapshot({isProviderStateResolved:I,defaultSessionType:w,canStopGeneration:he,stopDisabledReason:Te,stopSupported:!0,stopReason:void 0,sendError:re,isSending:se,modelOptions:D,sessionTypeOptions:B,selectedSessionType:E,canEditSessionType:L,sessionTypeUnavailable:H,skillRecords:_,isSkillsLoading:M.isLoading}),t.chatSessionListManager.syncSnapshot({sessions:T,query:i,isLoading:g.isLoading}),t.chatRunStatusManager.syncSnapshot({sessionRunStatusByKey:ke,isLocallyRunning:se||!!me,activeBackendRunId:me}),t.chatThreadManager.syncSnapshot({isProviderStateResolved:I,modelOptions:D,sessionTypeUnavailable:H,sessionTypeUnavailableMessage:P,sessionTypeLabel:Ae,selectedSessionKey:s,sessionDisplayName:Le,canDeleteSession:!!z,threadRef:m,isHistoryLoading:x.isHydrating,uiMessages:le,isSending:se,isAwaitingAssistantOutput:b})},[me,x.isHydrating,L,he,Le,Ae,w,M.isLoading,b,I,se,re,D.length,D,t,i,z,s,E,ke,B,H,P,T,g.isLoading,_,Te,m,le]),h.jsx(ou,{presenter:t,children:h.jsx(Sy,{view:e,confirmDialog:h.jsx(d,{})})})}function xb({view:e}){return h.jsx(ib,{view:e})}export{xb as ChatPage};
|