@evoscientist/webui 0.1.6 → 0.1.7
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/README.md +8 -2
- package/dist/.next/BUILD_ID +1 -1
- package/dist/.next/build-manifest.json +3 -3
- package/dist/.next/prerender-manifest.json +3 -3
- package/dist/.next/required-server-files.json +4 -4
- package/dist/.next/server/app/_global-error.html +1 -1
- package/dist/.next/server/app/_global-error.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/.next/server/app/_not-found.html +1 -1
- package/dist/.next/server/app/_not-found.rsc +1 -1
- package/dist/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/.next/server/app/api/memory/executions/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/memory/observations/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/memory/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/catalog/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/detail/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/install/route.js.nft.json +1 -1
- package/dist/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/dist/.next/server/app/index.html +1 -1
- package/dist/.next/server/app/index.rsc +2 -2
- package/dist/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/dist/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/dist/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0wd7vkh._.js +1 -1
- package/dist/.next/server/middleware-build-manifest.js +3 -3
- package/dist/.next/server/pages/404.html +1 -1
- package/dist/.next/server/pages/500.html +1 -1
- package/dist/.next/server/server-reference-manifest.js +1 -1
- package/dist/.next/server/server-reference-manifest.json +1 -1
- package/dist/.next/static/chunks/{0fjqb1vd-586m.js → 0ar5yonogu4-6.js} +1 -1
- package/dist/package.json +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
- /package/dist/.next/static/{J5JZ8Kz8NMkARVBpq8Pb7 → d4eNysB7a29EpIBBuqJwV}/_buildManifest.js +0 -0
- /package/dist/.next/static/{J5JZ8Kz8NMkARVBpq8Pb7 → d4eNysB7a29EpIBBuqJwV}/_clientMiddlewareManifest.js +0 -0
- /package/dist/.next/static/{J5JZ8Kz8NMkARVBpq8Pb7 → d4eNysB7a29EpIBBuqJwV}/_ssgManifest.js +0 -0
|
@@ -70,4 +70,4 @@ ${a.content}`),t.push(function(e){let t,r=e.getType(),n=Object.fromEntries(Objec
|
|
|
70
70
|
`),t[t.length-1]])}let _i=["text","reasoning","tool_call","tool_call_chunk","invalid_tool_call","server_tool_call","server_tool_call_chunk","server_tool_call_result","image","video","audio","text-plain","file"];uo({},{AIMessage:()=>dC,AIMessageChunk:()=>dL,BaseMessage:()=>uH,BaseMessageChunk:()=>uK,ChatMessage:()=>u8,ChatMessageChunk:()=>u7,DEFAULT_MERGE_IGNORE_KEYS:()=>uq,FunctionMessage:()=>dr,FunctionMessageChunk:()=>dn,HumanMessage:()=>ds,HumanMessageChunk:()=>dl,KNOWN_BLOCK_TYPES:()=>_i,RemoveMessage:()=>dd,SystemMessage:()=>dp,SystemMessageChunk:()=>dm,ToolMessage:()=>u4,ToolMessageChunk:()=>u3,_isMessageFieldWithRole:()=>uZ,_mergeDicts:()=>uV,_mergeLists:()=>uW,_mergeObj:()=>uY,_mergeStatus:()=>uz,coerceMessageLikeToMessage:()=>dj,collapseToolCallChunks:()=>dH,convertToChunk:()=>dz,convertToOpenAIImageBlock:()=>um,convertToProviderContentBlock:()=>ug,defaultTextSplitter:()=>_a,defaultToolCallParser:()=>u5,filterMessages:()=>E3,getBufferString:()=>dF,iife:()=>dD,isAIMessage:()=>dR,isAIMessageChunk:()=>dO,isBase64ContentBlock:()=>uu,isBaseMessage:()=>uX,isBaseMessageChunk:()=>uQ,isChatMessage:()=>de,isChatMessageChunk:()=>dt,isDataContentBlock:()=>ul,isDirectToolOutput:()=>u2,isFunctionMessage:()=>da,isFunctionMessageChunk:()=>di,isHumanMessage:()=>dc,isHumanMessageChunk:()=>du,isIDContentBlock:()=>up,isMessage:()=>ub,isOpenAIToolCallArray:()=>uG,isPlainTextContentBlock:()=>ud,isSystemMessage:()=>dh,isSystemMessageChunk:()=>df,isToolMessage:()=>u6,isToolMessageChunk:()=>u9,isURLContentBlock:()=>uc,mapChatMessagesToStoredMessages:()=>d$,mapStoredMessageToChatMessage:()=>dU,mapStoredMessagesToChatMessages:()=>dB,mergeContent:()=>u$,mergeMessageRuns:()=>E6,mergeResponseMetadata:()=>uJ,mergeUsageMetadata:()=>u1,parseBase64DataUrl:()=>uf,parseMimeType:()=>uh,trimMessages:()=>E8});var _s=class{chunks={};constructor(){this.chunks={}}add(e,t){e.type.endsWith("MessageChunk")&&(e.type=e.type.slice(0,-12).toLowerCase());let r="remove"===e.type&&null!=e.id?new dd({...e,id:e.id}):dj(e),n=function(e){try{return dz(e)}catch{return null}}(r),{id:a}=n??r;if(!a)return console.warn("No message ID found for chunk, ignoring in state",e),null;if(this.chunks[a]??={},this.chunks[a].metadata=t??this.chunks[a].metadata,n){let e=this.chunks[a].chunk;this.chunks[a].chunk=(uQ(e)?e:null)?.concat(n)??n}else this.chunks[a].chunk=r;return a}clear(){this.chunks={}}get(e,t){return null==e||null==this.chunks[e]?null:(null!=t&&(this.chunks[e].index??=t),this.chunks[e])}};let _o=e=>{let{type:t,data:r}=e.toDict();return{...r,type:t}};var _l=class extends Error{constructor(e){super(e.message),this.name=e.name??e.error??"StreamError"}static isStructuredError(e){return"object"==typeof e&&null!=e&&"message"in e}},_c=class{abortRef=new AbortController;messages;listeners=new Set;state;constructor(e){this.messages=e,this.state={isLoading:!1,values:null,error:void 0}}setState=e=>{this.state={...this.state,...e},this.notifyListeners()};notifyListeners=()=>{this.listeners.forEach(e=>e())};subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getSnapshot=()=>this.state;get isLoading(){return this.state.isLoading}get values(){return this.state.values?.[0]??null}get error(){return this.state.error}setStreamValues=(e,t="stream")=>{if("function"==typeof e){let[r,n]=this.state.values??[null,"stream"],a=e(r,n);this.setState({values:null!=a?[a,t]:null})}else this.setState({values:null!=e?[e,t]:null})};getMutateFn=(e,t)=>r=>{let n={...t,...(this.state.values??[null,"stream"])[0]},a="function"==typeof r?r(n):r;this.setStreamValues({...n,...a},e)};matchEventType=(e,t,r)=>e===t||t.startsWith(`${e}|`);start=async(e,t)=>{if(!this.state.isLoading)try{let r;for await(let{event:n,data:a}of(this.setState({isLoading:!0,error:void 0}),this.abortRef=new AbortController,await e(this.abortRef.signal))){if("error"===n){r=new _l(a);break}let e=n.includes("|")?n.split("|").slice(1):void 0,i=this.getMutateFn("stream",t.initialValues);if("metadata"===n&&t.callbacks.onMetadataEvent?.(a),"events"===n&&t.callbacks.onLangChainEvent?.(a),this.matchEventType("updates",n,a)&&t.callbacks.onUpdateEvent?.(a,{namespace:e,mutate:i}),this.matchEventType("custom",n,a)&&t.callbacks.onCustomEvent?.(a,{namespace:e,mutate:i}),this.matchEventType("checkpoints",n,a)&&t.callbacks.onCheckpointEvent?.(a,{namespace:e}),this.matchEventType("tasks",n,a)&&t.callbacks.onTaskEvent?.(a,{namespace:e}),this.matchEventType("debug",n,a)&&t.callbacks.onDebugEvent?.(a,{namespace:e}),"values"===n&&("__interrupt__"in a?this.setStreamValues(e=>({...e,...a})):this.setStreamValues(a)),this.matchEventType("messages",n,a)){let[e,r]=a,n=this.messages.add(e,r);if(!n){console.warn("Failed to add message to manager, no message ID found");continue}this.setStreamValues(e=>{let r={...t.initialValues,...e},a=t.getMessages(r).slice(),{chunk:i,index:s}=this.messages.get(n,a.length)??{};return i&&null!=s?("remove"===i.getType()?a.splice(s,1):a[s]=_o(i),t.setMessages(r,a)):r})}}if(null!=r)throw r;let n=await t.onSuccess?.();void 0!==n&&this.setStreamValues(n)}catch(e){e instanceof Error&&("AbortError"===e.name||"TimeoutError"===e.name)||(console.error(e),this.setState({error:e}),await t.onError?.(e))}finally{this.setState({isLoading:!1}),this.abortRef=new AbortController,t.onFinish?.()}};stop=async(e,t)=>{this.abortRef.abort(),this.abortRef=new AbortController,t.onStop?.({mutate:this.getMutateFn("stop",e)})};clear=()=>{this.abortRef.abort(),this.abortRef=new AbortController,this.setState({error:void 0,values:null,isLoading:!1}),this.messages.clear()}};let _u=e=>{let[t,r]=(0,eC.useState)(e?.threadId??null),n=(0,eC.useRef)(e?.onThreadId);n.current=e?.onThreadId;let a=(0,eC.useCallback)(e=>{r(e),n.current?.(e)},[]);return e&&"threadId"in e?[e.threadId??null,a]:[t,a]};function _d(e,t,r){return[e["~configHash"],t,r].join(":")}function _p(e){let[t]=(0,eC.useState)("transport"in e);return t?function(e){let[t]=(0,eC.useState)(()=>new _s),[r]=(0,eC.useState)(()=>new _c(t));(0,eC.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot);let[n,a]=_u(e),i=(0,eC.useRef)(n);(0,eC.useEffect)(()=>{i.current!==n&&(i.current=n,r.clear())},[n,r]);let s=t=>{let r=e.messagesKey??"messages";return Array.isArray(t[r])?t[r]:[]},o=(t,r)=>{let n=e.messagesKey??"messages";return{...t,[n]:r}},l=e.initialValues??{},c=async(t,c)=>{let u,d=n;r.setStreamValues(()=>c?.optimisticValues!=null?{...l,..."function"==typeof c.optimisticValues?c.optimisticValues(l):c.optimisticValues}:{...l}),await r.start(async r=>{if(d||(i.current=d=crypto.randomUUID(),a(d)),!d)throw Error("Failed to obtain valid thread ID.");return e.transport.stream({input:t,context:c?.context,command:c?.command,signal:r,config:{...c?.config,configurable:{thread_id:d,...c?.config?.configurable}}})},{getMessages:s,setMessages:o,initialValues:{},callbacks:e,onSuccess:()=>void 0,onError(t){e.onError?.(t,u)}})};return{get values(){return r.values??{}},error:r.error,isLoading:r.isLoading,stop:()=>r.stop(l,{onStop:e.onStop}),submit:c,get interrupt(){if(null!=r.values&&"__interrupt__"in r.values&&Array.isArray(r.values.__interrupt__)){let e=r.values.__interrupt__;if(0===e.length)return{when:"breakpoint"};if(1===e.length)return e[0];return e}return},get messages(){if(!r.values)return[];return s(r.values)}}}(e):function(e){let t,r=(0,eC.useRef)(e.reconnectOnMount),n=(0,eC.useMemo)(()=>{if("u"<typeof window)return null;let e=r.current;return!0===e?window.sessionStorage:"function"==typeof e?e():null},[]),a=(0,eC.useMemo)(()=>e.client??new aa({apiUrl:e.apiUrl,apiKey:e.apiKey,callerOptions:e.callerOptions,defaultHeaders:e.defaultHeaders}),[e.client,e.apiKey,e.apiUrl,e.callerOptions,e.defaultHeaders]),[i]=(0,eC.useState)(()=>new _s),[s]=(0,eC.useState)(()=>new _c(i));(0,eC.useSyncExternalStore)(s.subscribe,s.getSnapshot,s.getSnapshot);let[o,l]=_u(e),c=(0,eC.useRef)([]),u=(0,eC.useCallback)((...e)=>{let t=c.current;for(let r of e)t.includes(r)||t.push(r)},[]),d=null!=e.onUpdateEvent,p=null!=e.onCustomEvent,m=null!=e.onLangChainEvent,h=null!=e.onDebugEvent,f=null!=e.onCheckpointEvent,g=null!=e.onTaskEvent,b=(0,eC.useMemo)(()=>{let e=[];return d&&e.push("updates"),p&&e.push("custom"),m&&e.push("events"),h&&e.push("debug"),f&&e.push("checkpoints"),g&&e.push("tasks"),e},[d,p,m,h,f,g]);(0,eC.useRef)(null).current=s.clear;let y=(0,eC.useRef)(o),E=(0,eC.useRef)(null);(0,eC.useEffect)(()=>{y.current!==o&&(y.current=o,s.clear())},[o,s]);let _="object"==typeof e.fetchStateHistory&&null!=e.fetchStateHistory?e.fetchStateHistory.limit??!1:e.fetchStateHistory??!1,v=function(e,t,r,n){let a=_d(e,t,r),[i,s]=(0,eC.useState)(()=>({key:void 0,data:void 0,error:void 0,isLoading:null!=t})),o=(0,eC.useRef)(e);o.current=e;let l=(0,eC.useRef)(n?.onError);l.current=n?.onError;let c=(0,eC.useCallback)((e,t)=>{if(n.passthrough)return Promise.resolve([]);let r=o.current,a=_d(r,e,t);return null!=e?(s(e=>e.key===a?{...e,isLoading:!0}:{key:a,data:void 0,error:void 0,isLoading:!0}),(function(e,t,r){if(r?.limit===!1)return e.threads.getState(t).then(e=>null==e.checkpoint?[]:[e]);let n="number"==typeof r?.limit?r.limit:10;return e.threads.getHistory(t,{limit:n})})(r,e,{limit:t}).then(e=>(s(t=>t.key!==a?t:{key:a,data:e,error:void 0,isLoading:!1}),e),e=>(s(t=>t.key!==a?t:{key:a,data:t.data,error:e,isLoading:!1}),l.current?.(e),Promise.reject(e)))):(s({key:a,data:void 0,error:void 0,isLoading:!1}),Promise.resolve([]))},[n.passthrough]);return(0,eC.useEffect)(()=>{(null==n.submittingRef.current||n.submittingRef.current!==t)&&c(t,r)},[c,a]),{data:i.data,error:i.error,isLoading:i.isLoading,mutate:e=>c(e??t,r)}}(a,o,_,{passthrough:null!=e.experimental_thread,submittingRef:E,onError:e.onError}),x=e.experimental_thread??v,T=t=>{let r=e.messagesKey??"messages";return Array.isArray(t[r])?t[r]:[]},S=(t,r)=>{let n=e.messagesKey??"messages";return{...t,[n]:r}},[w,k]=(0,eC.useState)(""),A=function(e,t){let{rootSequence:r,paths:n}=function(e){let t=new Set,r={};if(e.length<=1)return{rootSequence:{type:"sequence",items:e.map(e=>({type:"node",value:e,path:[]}))},paths:[]};e.forEach(e=>{let n=e.parent_checkpoint?.checkpoint_id??"$";r[n]??=[],r[n].push(e),e.checkpoint?.checkpoint_id!=null&&t.add(e.checkpoint.checkpoint_id)});let n=(...e)=>e.filter(e=>null!=e).sort((e,t)=>e.localeCompare(t)).at(-1),a=null==r.$?Object.keys(r).filter(e=>!t.has(e)).map(e=>{let t=[e],a=new Set,i=e;for(;t.length>0;){let e=t.shift();if(a.has(e))continue;a.add(e);let s=(r[e]??[]).flatMap(e=>e.checkpoint?.checkpoint_id??[]);i=n(i,...s),t.push(...s)}return{parentId:e,lastId:i}}).sort((e,t)=>e.lastId.localeCompare(t.lastId)).at(-1)?.parentId:void 0;null!=a&&(r.$=r[a]);let i={type:"sequence",items:[]},s=[{id:"$",sequence:i,path:[]}],o=[],l=new Set;for(;s.length>0;){let e,t=s.shift();if(l.has(t.id))continue;l.add(t.id);let n=r[t.id];if(null!=n&&0!==n.length)for(let r of(n.length>1&&(e={type:"fork",items:[]},t.sequence.items.push(e)),n)){let n=r.checkpoint?.checkpoint_id;if(null==n)continue;let{sequence:a}=t,{path:i}=t;null!=e&&(a={type:"sequence",items:[]},e.items.unshift(a),(i=i.slice()).push(n),o.push(i)),a.items.push({type:"node",value:r,path:i}),s.push({id:n,sequence:a,path:i})}}return{rootSequence:i,paths:o}}(t??[]),{history:a,branchByCheckpoint:i}=function(e,t,r){let n=r.split(">"),a={};for(let e of t){let t=e.at(-2)??"$";a[t]??=[],a[t].unshift(e)}let i=[],s={},o=n.slice(),l=[...e.items];for(;l.length>0;){let e=l.shift();if("node"===e.type){i.push(e.value);let t=e.value.checkpoint?.checkpoint_id;if(null==t)continue;s[t]={branch:e.path.join(">"),branchOptions:(e.path.length>0?a[e.path.at(-2)??"$"]??[]:[]).map(e=>e.join(">"))}}if("fork"===e.type){let t=o.shift(),r=null!=t?e.items.findIndex(e=>{let r=e.items.at(0);return!!r&&"node"===r.type&&r.value.checkpoint?.checkpoint_id===t}):-1,n=e.items.at(r)?.items??[];l.push(...n)}}return{history:i,branchByCheckpoint:s}}(r,n,e);return{branchTree:r,flatHistory:a,branchByCheckpoint:i,threadHead:a.at(-1)}}(w,x.data??void 0),N=A.threadHead?.values??e.initialValues??{},I=(()=>{let e=A.threadHead?.tasks?.at(-1)?.error;if(null!=e){try{let t=JSON.parse(e);if(_l.isStructuredError(t))return new _l(t);return t}catch{}return e}})(),C=(t=new Set,T(N).map((e,r)=>{let n=e.id??r,a=function(e,t){for(let r=e.length-1;r>=0;r-=1)if(t(e[r]))return e[r]}(x.data??[],e=>T(e.values).map((e,t)=>e.id??t).includes(n)),i=a?.checkpoint?.checkpoint_id,s=null!=i?A.branchByCheckpoint[i]:void 0;s?.branch?.length||(s=void 0);let o=s?.branchOptions?.flat(2).join(",");return o&&(t.has(o)&&(s=void 0),t.add(o)),{messageId:n.toString(),firstSeenState:a,branch:s?.branch,branchOptions:s?.branchOptions}})),R=async(t,r)=>{let i,u,d=r?.checkpoint?.checkpoint_id;k(null!=d?A.branchByCheckpoint[d]?.branch??"":"");let p=!0===_||"number"==typeof _,m=null!=e.onFinish||p;s.setStreamValues(()=>{let e=m?N:{...N,...s.values};return r?.optimisticValues!=null?{...e,..."function"==typeof r.optimisticValues?r.optimisticValues(e):r.optimisticValues}:{...e}});let h=o;await s.start(async s=>{if(h||(y.current=h=(await a.threads.create({threadId:r?.threadId,metadata:r?.metadata})).thread_id,E.current=h,l(h)),!h)throw Error("Failed to obtain valid thread ID.");E.current=h;let o=[...new Set([...r?.streamMode??[],...c.current,...b])],d=r?.checkpoint??(p?A.threadHead?.checkpoint:void 0)??void 0;r?.checkpoint===null&&(d=void 0),null!=d&&delete d.thread_id;let m=r?.streamResumable??!!n;return a.runs.stream(h,e.assistantId,{input:t,config:r?.config,context:r?.context,command:r?.command,interruptBefore:r?.interruptBefore,interruptAfter:r?.interruptAfter,metadata:r?.metadata,multitaskStrategy:r?.multitaskStrategy,onCompletion:r?.onCompletion,onDisconnect:r?.onDisconnect??(m?"continue":"cancel"),signal:s,checkpoint:d,streamMode:o,streamSubgraphs:r?.streamSubgraphs,streamResumable:m,durability:r?.durability,onRunCreated(t){i={run_id:t.run_id,thread_id:t.thread_id??h},n&&(u=`lg:stream:${h}`,n.setItem(u,i.run_id)),e.onCreated?.(i)}})},{getMessages:T,setMessages:S,initialValues:N,callbacks:e,async onSuccess(){if(u&&n?.removeItem(u),m){let t=await x.mutate(h),r=t?.at(0);if(r)return e.onFinish?.(r,i),null}},onError(t){e.onError?.(t,i)},onFinish(){E.current=null}})},O=async(t,r,i)=>{if(r??="-1",!o)return;let l={thread_id:o,run_id:t};await s.start(async e=>(E.current=o,a.runs.joinStream(o,t,{signal:e,lastEventId:r,streamMode:i?.streamMode})),{getMessages:T,setMessages:S,initialValues:N,callbacks:e,async onSuccess(){n?.removeItem(`lg:stream:${o}`);let t=await x.mutate(o),r=t?.at(0);r&&e.onFinish?.(r,l)},onError(t){e.onError?.(t,l)},onFinish(){E.current=null}})},L=(0,eC.useMemo)(()=>{if(!n||s.isLoading||"u"<typeof window)return;let e=n?.getItem(`lg:stream:${o}`);if(e)return{runId:e,threadId:o}},[n,s.isLoading,o]),D=!!n,P=(0,eC.useRef)({threadId:o,shouldReconnect:D}),M=(0,eC.useRef)(O);M.current=O,(0,eC.useEffect)(()=>{P.current.threadId!==o&&(P.current={threadId:o,shouldReconnect:D})},[o,D]),(0,eC.useEffect)(()=>{L&&P.current.shouldReconnect&&(P.current.shouldReconnect=!1,M.current?.(L.runId))},[L]);let j=s.error??I??x.error,F=s.values??N;return{get values(){return u("values"),F},client:a,assistantId:e.assistantId,error:j,isLoading:s.isLoading,stop:()=>s.stop(N,{onStop:t=>{if(n&&o){let e=n.getItem(`lg:stream:${o}`);e&&a.runs.cancel(o,e),n.removeItem(`lg:stream:${o}`)}e.onStop?.(t)}}),submit:R,joinStream:O,branch:w,setBranch:k,get history(){if(!1===_)throw Error("`fetchStateHistory` must be set to `true` to use `history`");return A.flatHistory},isThreadLoading:x.isLoading&&null==x.data,get experimental_branchTree(){if(!1===_)throw Error("`fetchStateHistory` must be set to `true` to use `experimental_branchTree`");return A.branchTree},get interrupt(){if(null!=F&&"__interrupt__"in F&&Array.isArray(F.__interrupt__)){let e=F.__interrupt__;if(0===e.length)return{when:"breakpoint"};if(1===e.length)return e[0];return e}if(s.isLoading)return;let e=A.threadHead?.tasks?.at(-1)?.interrupts;if(null==e||0===e.length){if(!(A.threadHead?.next??[]).length||null!=j)return;return{when:"breakpoint"}}return e.at(-1)},get messages(){return u("messages-tuple","values"),T(F)},getMessagesMetadata(e,t){u("values");let r=i.get(e.id)?.metadata,n=C?.find(r=>r.messageId===(e.id??t));if(null!=r||null!=n)return{...n,streamMetadata:r}}}}(e)}let _m="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),_h=new Uint8Array(16),_f=[];for(let e=0;e<256;++e)_f.push((e+256).toString(16).slice(1));let _g=function(e,t,r){if(_m&&!t&&!e)return _m();let n=(e=e||{}).random||(e.rng||function(){if(!d&&!(d="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return d(_h)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return _f[e[t+0]]+_f[e[t+1]]+_f[e[t+2]]+_f[e[t+3]]+"-"+_f[e[t+4]]+_f[e[t+5]]+"-"+_f[e[t+6]]+_f[e[t+7]]+"-"+_f[e[t+8]]+_f[e[t+9]]+"-"+_f[e[t+10]]+_f[e[t+11]]+_f[e[t+12]]+_f[e[t+13]]+_f[e[t+14]]+_f[e[t+15]]}(n)};function _b(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>e&&"object"==typeof e&&"text"in e?String(e.text??""):"").join(""):""}function _y(e){return"string"==typeof e.content?e.content:Array.isArray(e.content)?e.content.filter(e=>"object"==typeof e&&null!==e&&"type"in e&&"text"===e.type||"string"==typeof e).map(e=>"string"==typeof e?e:"object"==typeof e&&null!==e&&"text"in e&&e.text||"").join(""):""}function _E(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){if(e.description&&"string"==typeof e.description)return e.description;if(e.prompt&&"string"==typeof e.prompt)return e.prompt;if(e.result&&"string"==typeof e.result)return e.result}return JSON.stringify(e,null,2)}let __=[{model:"claude-sonnet-4-6",model_provider:"anthropic"},{model:"claude-haiku-4-5",model_provider:"anthropic"},{model:"claude-opus-4-8",model_provider:"anthropic"},{model:"gpt-5.5-pro",model_provider:"openai"},{model:"gpt-5.5",model_provider:"openai"},{model:"gpt-5-mini",model_provider:"openai"},{model:"gemini-2.5-pro",model_provider:"google-genai"},{model:"gemini-3.5-flash",model_provider:"google-genai"},{model:"deepseek-v3.2",model_provider:"deepseek"}];function _v(e){let t=0;for(let r of e){let e=r.content;if("string"==typeof e)t+=e.length;else if(Array.isArray(e))for(let r of e){let e=r?.text;"string"==typeof e&&(t+=e.length)}}return t}function _x(e){if(!e||"object"!=typeof e)return null;try{return JSON.stringify(e.value??null)}catch{return null}}function _T({children:e,activeAssistant:t,onHistoryRevalidate:r,thread:n}){let a=function({activeAssistant:e,onHistoryRevalidate:t,thread:r}){let[n,a]=e$("threadId"),i=ao(),[s,o]=(0,eC.useState)({}),l=_p({assistantId:e?.assistant_id||"",client:i??void 0,reconnectOnMount:!0,threadId:n??null,onThreadId:a,defaultHeaders:{"x-auth-scheme":"langsmith"},fetchStateHistory:!0,onFinish:t,onError:t,onCreated:t,onUpdateEvent:(e,t)=>{let r=t?.namespace;if(!r||0===r.length)return;let n=function(e){let t=[];if(!e||"object"!=typeof e)return t;for(let r of Object.values(e)){let e=r?.messages;if(Array.isArray(e))for(let r of e)if("ai"===r.type&&r.tool_calls&&r.tool_calls.length>0)for(let e of r.tool_calls)t.push({kind:"tool_call",id:e.id??"",name:e.name??"tool",args:e.args&&"object"==typeof e.args?e.args:{}});else if("ai"===r.type){let e=_b(r.content).trim();e&&t.push({kind:"text",text:e})}else"tool"===r.type&&t.push({kind:"tool_result",toolCallId:r.tool_call_id??"",name:r.name??"tool",text:_b(r.content).trim()})}return t}(e);if(0===n.length)return;let a=r.join("|");o(e=>({...e,[a]:[...e[a]??[],...n]}))},experimental_thread:r}),[c,u]=(0,eC.useState)(void 0),[d,p]=(0,eC.useState)(null),[m,h]=(0,eC.useState)(null),[f,g]=(0,eC.useState)(null),b=(0,eC.useRef)(0),[y,E]=(0,eC.useState)(null),_=(0,eC.useRef)(null);(0,eC.useEffect)(()=>{if(!n){_.current||E(null);return}if(_.current){let e=_.current;_.current=null,(async()=>{try{await c2(n,e)}catch{}})();return}let e=!1;return(async()=>{try{let t=await i.threads.get(n);if(e)return;let r=(t.metadata??{}).model_override;r&&"object"==typeof r&&"string"==typeof r.model?E({model:r.model,model_provider:"string"==typeof r.model_provider?r.model_provider:void 0}):E(null)}catch{e||E(null)}})(),()=>{e=!0}},[i,n]);let v=(0,eC.useCallback)(async e=>{if(E(e),!n){_.current=e;return}_.current=null,await c2(n,e)},[n]);(0,eC.useEffect)(()=>{let e;if(!n){u(void 0),h(null),g(null),p(null);return}if(l.isLoading){b.current+=1,u(void 0),p(null);return}let t=l.messages.length,r=++b.current,a=!1,s=0,o=async()=>{s+=1;try{let[c,d]=await Promise.all([i.threads.getState(n),i.threads.get(n)]);if(a||b.current!==r)return;let m=d.values?.messages,f=function(e){if(Array.isArray(e))for(let t=e.length-1;t>=0;t--){let r=e[t]?.interrupts;if(Array.isArray(r)&&r.length>0)return r[r.length-1]}}(c.tasks),y=Array.isArray(c.next)&&c.next.length>0,E=function(e){if(!e||"object"!=typeof e)return;let t=e.value;if(!t||"object"!=typeof t)return;let r={...t};return"action_requests"in t&&!Array.isArray(t.action_requests)&&(r.action_requests=[]),"review_configs"in t&&!Array.isArray(t.review_configs)&&(r.review_configs=[]),{...e,value:r}}(f);if(E&&function(e){if(!e||"object"!=typeof e)return!1;let t=e.value;return!!t&&"object"==typeof t&&("ask_user"===t.type||Array.isArray(t.action_requests)&&t.action_requests.length>0)}(E)){u(E),p(null),Array.isArray(m)&&(g(n),h(m));return}if(Array.isArray(m)&&m.length>t&&(g(n),h(m)),!y){u(void 0),p(_x(l.interrupt)),Array.isArray(m)&&(g(n),h(m));return}y&&s<15&&!a&&(e=setTimeout(o,1e3))}catch{!a&&b.current===r&&s<15&&(e=setTimeout(o,1e3))}};return o(),()=>{a=!0,e&&clearTimeout(e)}},[n,l.interrupt,l.isLoading,i]);let x=l.interrupt,T=x&&(null===d||_x(x)!==d)?x:f===n?c??void 0:void 0,S=m&&f===n&&(c||!l.isLoading||m.length>l.messages.length||m.length===l.messages.length&&_v(m)>_v(l.messages))?m:l.messages,w=(0,eC.useCallback)(()=>{let t=e?.config??{},r={...t.configurable??{}};return y&&(r.model=y.model,y.model_provider&&(r.model_provider=y.model_provider)),{...t,configurable:r,recursion_limit:100}},[e?.config,y]),k=(0,eC.useCallback)(e=>{u(void 0),h(null),g(null),p(null),b.current+=1;let r={id:_g(),type:"human",content:e};l.submit({messages:[r]},{optimisticValues:e=>({messages:[...e.messages??[],r]}),config:w(),streamSubgraphs:!0,streamMode:["updates"],streamResumable:!0,onDisconnect:"continue"}),t?.()},[l,w,t]),A=(0,eC.useCallback)(async e=>{n&&await i.threads.updateState(n,{values:{files:e}})},[i,n]),N=(0,eC.useCallback)(e=>{u(void 0),h(null),g(null),p(null),b.current+=1,l.submit(null,{command:{resume:e},config:w(),streamSubgraphs:!0,streamMode:["updates"],streamResumable:!0,onDisconnect:"continue"}),t?.()},[l,w,t]),I=(0,eC.useCallback)(()=>{l.stop()},[l]);return{stream:l,todos:l.values.todos??[],files:l.values.files??{},email:l.values.email,asyncTasks:l.values.async_tasks??{},summarizationEvent:function(e){if(!e||"object"!=typeof e)return null;let t=e.summary_message,r="string"==typeof t?.content?t.content:"";if(!r)return null;let n=e.cutoff_index,a=e.file_path;return{cutoffIndex:"number"==typeof n&&n>=0?n:0,content:r,filePath:"string"==typeof a?a:null}}(l.values._summarization_event),ui:l.values.ui,setFiles:A,messages:S,isLoading:l.isLoading,isThreadLoading:l.isThreadLoading,interrupt:T,sendMessage:k,stopStream:I,resumeInterrupt:N,subAgentActivity:s,modelOverride:y,setModelOverride:v}}({activeAssistant:t,onHistoryRevalidate:r,thread:n});return(0,eI.jsx)(_S.Provider,{value:a,children:e})}let _S=(0,eC.createContext)(void 0);function _w(){let e=(0,eC.useContext)(_S);if(void 0===e)throw Error("useChatContext must be used within a ChatProvider");return e}let _k=rj("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),_A=rj("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),_N=rj("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),_I=rj("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),_C=rj("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),_R=rj("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),_O=rj("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),_L=rj("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),_D=rj("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),_P=rj("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),_M=rj("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]),_j=rj("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),_F=rj("list-x",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]),_U=rj("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),_B=eC.default.memo(({subAgent:e,onClick:t,isExpanded:r=!0})=>{let n="pending"===e.status;return(0,eI.jsx)("div",{className:"w-fit max-w-[70vw] overflow-hidden rounded-lg bg-card",children:(0,eI.jsxs)(nP,{variant:"ghost",size:"sm",onClick:t,className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left",children:[(0,eI.jsx)("span",{className:"bg-[var(--brand)]/10 flex size-5 shrink-0 items-center justify-center rounded-md text-[var(--brand)]",children:n?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(_U,{className:"size-3.5","aria-hidden":"true"})}),(0,eI.jsx)("span",{className:"truncate text-sm font-semibold text-foreground",children:e.subAgentName}),(0,eI.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:"subagent"}),r?(0,eI.jsx)(l$,{size:14,className:"ml-auto shrink-0 text-muted-foreground"}):(0,eI.jsx)(lB,{size:14,className:"ml-auto shrink-0 text-muted-foreground"})]})})});_B.displayName="SubAgentIndicator";let _$=rj("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),_z=rj("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),_H=rj("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]),_G=eC.createContext(null);function _q(){let e=eC.useContext(_G);if(!e)throw Error("useStreamContext must be used within a LoadExternalComponent");return new Proxy(e,{get:(e,t)=>"meta"===t?e.meta:e.stream[t]})}let _V=new class{cache={};boundCache={};callbacks={};respond(e,t,r){this.cache[e]={comp:t,target:r},this.callbacks[e]?.forEach(e=>e(t,r))}getBoundStore(e){return this.boundCache[e]??={subscribe:t=>(this.callbacks[e]??=[],this.callbacks[e].push(t),()=>{this.callbacks[e]=this.callbacks[e].filter(e=>e!==t)}),getSnapshot:()=>this.cache[e]},this.boundCache[e]}},_W=Symbol.for("LGUI_EXT_STORE"),_Y=Symbol.for("LGUI_REQUIRE"),_K=Symbol.for("LGUI_REQUIRE_EXTRA");function _Z({stream:e,namespace:t,message:r,meta:n,fallback:a,components:i,...s}){let o=eC.useRef(null),l=eC.useId(),c=`child-shadow-${l}`,u=eC.useMemo(()=>_V.getBoundStore(c),[c]),d=eC.useSyncExternalStore(u.subscribe,u.getSnapshot),p=i?.[r.name],m=null!=p,h=null;(e=>!!eC.isValidElement(e)||null==e||"string"==typeof e||"number"==typeof e||"bigint"==typeof e||"boolean"==typeof e||null!=e&&"object"==typeof e&&Symbol.iterator in e||null!=e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then)(a)?h=a:"object"==typeof a&&null!=a&&(h=a?.[r.name]);let f=t??e.assistantId,g=e.client["~ui"];return(eC.useEffect(()=>{m||g.getComponent(f,r.name).then(e=>{let t=o.current;if(!t)return;let r=t.shadowRoot??t.attachShadow({mode:"open"}),n=document.createRange().createContextualFragment(e.replace("{{shadowRootId}}",c));r.appendChild(n)})},[g,f,r.name,c,m]),m)?(0,eI.jsx)(_G.Provider,{value:{stream:e,meta:n},children:eC.createElement(p,r.props)}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("div",{id:c,ref:o,...s}),(0,eI.jsx)(_G.Provider,{value:{stream:e,meta:n},children:d?.target!=null?e2.createPortal(eC.createElement(d.comp,r.props),d.target):h})]})}"u">typeof window&&(window[_W]=_V,window[_Y]=e=>{if("react"===e)return eC;if("react-dom"===e)return e2;if("react/jsx-runtime"===e)return eI;if("@langchain/langgraph-sdk/react"===e)return{useStream:_p};if("@langchain/langgraph-sdk/react-ui"===e)return{useStreamContext:_q,LoadExternalComponent:()=>{throw Error("Nesting LoadExternalComponent is not supported")}};if(null!=window[_K]&&"object"==typeof window[_K]&&e in window[_K])return window[_K][e];throw Error(`Unknown module...: ${e}`)});let _X=eC.forwardRef(({className:e,...t},r)=>(0,eI.jsx)("textarea",{className:nf("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...t}));function _Q(e){if("string"==typeof e)return e;if(void 0===e)return"undefined";try{return JSON.stringify(e,null,2)??String(e)}catch{return String(e)}}function _J({actionRequest:e,reviewConfig:t,onResume:r,isLoading:n,onSubmitted:a}){let[i,s]=(0,eC.useState)(""),[o,l]=(0,eC.useState)(!1),[c,u]=(0,eC.useState)({}),[d,p]=(0,eC.useState)(!1),[m,h]=(0,eC.useState)(!1),f=(0,eC.useMemo)(()=>{var t;return(t=e.args)&&"object"==typeof t?t:{}},[e.args]),g=t?.allowedDecisions??t?.allowed_decisions??["approve","reject","edit"],b=e=>{(0,e2.flushSync)(()=>{h(!0),a&&a()}),r(e)};return m?null:(0,eI.jsxs)("div",{className:"w-full rounded-md border border-border bg-muted/30 p-4",children:[(0,eI.jsxs)("div",{className:"mb-3 flex items-center gap-2 text-foreground",children:[(0,eI.jsx)(_z,{size:16,className:"text-yellow-600 dark:text-yellow-400","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Approval Required"})]}),e.description&&(0,eI.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:e.description}),(0,eI.jsxs)("div",{className:"mb-4 rounded-sm border border-border bg-background p-3",children:[(0,eI.jsxs)("div",{className:"mb-2",children:[(0,eI.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Tool"}),(0,eI.jsx)("p",{className:"mt-1 font-mono text-sm font-medium text-foreground",children:e.name})]}),o?(0,eI.jsxs)("div",{children:[(0,eI.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Edit Arguments"}),(0,eI.jsx)("div",{className:"mt-2 space-y-3",children:Object.entries(f).map(([e,t])=>(0,eI.jsxs)("div",{children:[(0,eI.jsx)("label",{className:"mb-1 block text-xs font-medium text-foreground",children:e}),(0,eI.jsx)(_X,{value:void 0!==c[e]?"string"==typeof c[e]?c[e]:_Q(c[e]):"string"==typeof t?t:_Q(t),onChange:t=>((e,t)=>{try{let r=t.trim().startsWith("{")||t.trim().startsWith("[")?JSON.parse(t):t;u(t=>({...t,[e]:r}))}catch{u(r=>({...r,[e]:t}))}})(e,t.target.value),className:"font-mono text-xs",rows:"string"==typeof t&&t.length<100?2:4,disabled:n})]},e))})]}):(0,eI.jsxs)("div",{children:[(0,eI.jsx)("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Arguments"}),(0,eI.jsx)("pre",{className:"mt-2 overflow-x-auto whitespace-pre-wrap break-all rounded-sm border border-border bg-muted/40 p-2 font-mono text-xs text-foreground",children:_Q(f)})]})]}),d&&!o&&(0,eI.jsxs)("div",{className:"mb-4",children:[(0,eI.jsx)("label",{className:"mb-2 block text-xs font-medium text-foreground",children:"Rejection Message (optional)"}),(0,eI.jsx)(_X,{value:i,onChange:e=>s(e.target.value),placeholder:"Explain why you're rejecting this action…",className:"text-sm",rows:2,disabled:n})]}),(0,eI.jsx)("div",{className:"flex flex-wrap gap-2",children:o?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nP,{type:"button",variant:"outline",size:"sm",onClick:()=>{l(!1),u({})},disabled:n,children:"Cancel"}),(0,eI.jsxs)(nP,{type:"button",size:"sm",onClick:()=>{o&&(b({decisions:[{type:"edit",edited_action:{name:e.name,args:c}}]}),l(!1),u({}))},disabled:n,className:"bg-green-600 text-white hover:bg-green-700 dark:bg-green-600 dark:hover:bg-green-700",children:[(0,eI.jsx)(lU,{size:14,"aria-hidden":"true"}),n?"Saving…":"Save & Approve"]})]}):d?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nP,{type:"button",variant:"outline",size:"sm",onClick:()=>{p(!1),s("")},disabled:n,children:"Cancel"}),(0,eI.jsx)(nP,{type:"button",variant:"destructive",size:"sm",onClick:()=>{b({decisions:[{type:"reject",message:i.trim()}]})},disabled:n,children:n?"Rejecting…":"Confirm Reject"})]}):(0,eI.jsxs)(eI.Fragment,{children:[g.includes("reject")&&(0,eI.jsxs)(nP,{type:"button",variant:"outline",size:"sm",onClick:()=>{d?b({decisions:[{type:"reject",message:i.trim()}]}):p(!0)},disabled:n,className:"text-destructive hover:bg-destructive/10",children:[(0,eI.jsx)(rF,{size:14,"aria-hidden":"true"}),"Reject"]}),g.includes("edit")&&(0,eI.jsxs)(nP,{type:"button",variant:"outline",size:"sm",onClick:()=>{l(!0),u(function(e){try{return JSON.parse(JSON.stringify(e))}catch{return{...e}}}(f)),p(!1)},disabled:n,children:[(0,eI.jsx)(iR,{size:14,"aria-hidden":"true"}),"Edit"]}),g.includes("approve")&&(0,eI.jsxs)(nP,{type:"button",size:"sm",onClick:()=>{b({decisions:[{type:"approve"}]})},disabled:n,className:nf("bg-green-600 text-white hover:bg-green-700","dark:bg-green-600 dark:hover:bg-green-700"),children:[(0,eI.jsx)(lU,{size:14,"aria-hidden":"true"}),n?"Approving…":"Approve"]})]})})]})}function _0(e,t){if("string"==typeof e)return e;if(null==e)return String(e);try{return JSON.stringify(e,null,2*!!t?.pretty)}catch{return String(e)}}_X.displayName="Textarea";let _1=eC.default.memo(({toolCall:e,uiComponent:t,stream:r,graphId:n,actionRequest:a,actionRequestKey:i,actionRequestSubmitted:s,onActionRequestSubmitted:o,reviewConfig:l,onResume:c,isLoading:u,autoApprove:d,compact:p=!1})=>{let[m,h]=(0,eC.useState)(()=>!!t||!!a&&!d),[f,g]=(0,eC.useState)({}),b=(0,eC.useMemo)(()=>a?`${e.id}:${a.name}:${_0(a.args,{pretty:!1})}`:null,[a,e.id]),y=i??b,[E,_]=(0,eC.useState)(null);(0,eC.useEffect)(()=>{y?_(e=>e&&e!==y?null:e):_(null)},[y]),(0,eC.useEffect)(()=>{t&&h(!0)},[t]);let v=(0,eC.useRef)(a);(0,eC.useEffect)(()=>{let e=!!v.current,t=!!a;!t||e||d?!t&&e&&h(!1):h(!0),v.current=a},[a,d]);let{name:x,args:T,result:S,status:w}=(0,eC.useMemo)(()=>{let t=e.args;return{name:function(e,t){if(!e)return"Unknown Tool";if("ToolSelectionResponse"===e)return"Adaptive tool selection";let r=e.toLowerCase();if("think_tool"===r)return"Reflection";if("read_file"===r||"write_file"===r||"edit_file"===r){let e,n=function(e){if(e&&"object"==typeof e)return e;if("string"==typeof e)try{let t=JSON.parse(e);if(t&&"object"==typeof t)return t}catch{}return{}}(t),a=String(n.path??n.file_path??"");if("/memories"===(e=(a||"").trim())||e.startsWith("/memories/"))return"read_file"===r?"Reading memory":"Updating memory";if("read_file"===r){let e=function(e){let t=(e||"").trim();if(!t.startsWith("/skills/"))return"";let[r]=t.slice(8).split("/");return r||""}(a);if(e)return`Skill: ${e}`}}return e}(e.name,t),args:t&&"object"==typeof t?t:{},result:e.result,status:e.status||"completed"}},[e]),k=(0,eC.useMemo)(()=>{switch(w){case"completed":return(0,eI.jsx)(_N,{});case"error":return(0,eI.jsx)(_z,{size:14,className:"text-destructive"});case"pending":return(0,eI.jsx)(iI,{size:14,className:"animate-spin"});case"interrupted":return(0,eI.jsx)(_H,{size:14,className:"text-orange-500"});default:return(0,eI.jsx)(_$,{size:14,className:"text-muted-foreground"})}},[w]),A=(0,eC.useCallback)(()=>{h(e=>!e)},[]),N=(0,eC.useCallback)(e=>{g(t=>({...t,[e]:!t[e]}))},[]),I=null!=S,C=I||Object.keys(T).length>0,R=s??E===y,O=a&&c&&(!y||!R);return(0,eI.jsxs)("div",{className:nf("w-full overflow-hidden rounded-lg border-none shadow-none outline-none transition-colors duration-200 focus-within:ring-2 focus-within:ring-ring hover:bg-accent",p&&"rounded-md",m&&C&&"bg-accent"),children:[(0,eI.jsx)(nP,{variant:"ghost",size:"sm",onClick:A,className:nf("flex w-full items-center justify-between gap-2 border-none px-2 py-2 text-left shadow-none outline-none disabled:cursor-default",p&&"h-auto min-h-8 py-1.5"),disabled:!C,children:(0,eI.jsxs)("div",{className:"flex w-full items-center justify-between gap-2",children:[(0,eI.jsxs)("div",{className:"flex items-center gap-2",children:[k,(0,eI.jsx)("span",{className:nf("text-[15px] font-medium tracking-[-0.6px] text-foreground",p&&"text-xs tracking-normal"),children:x})]}),C&&(m?(0,eI.jsx)(l$,{size:14,className:"shrink-0 text-muted-foreground"}):(0,eI.jsx)(lB,{size:14,className:"shrink-0 text-muted-foreground"}))]})}),m&&C&&(0,eI.jsx)("div",{className:nf("px-4 pb-4",p&&"px-2 pb-2"),children:t&&r&&n?(0,eI.jsx)("div",{className:"mt-4",children:(0,eI.jsx)(_Z,{stream:r,message:t,namespace:n,meta:{status:w,args:T,result:S??"No Result Yet"}},t.id)}):O?(0,eI.jsx)("div",{className:"mt-4",children:(0,eI.jsx)(_J,{actionRequest:a,reviewConfig:l,onResume:c,isLoading:u,onSubmitted:()=>{_(y),y&&o?.(y),h(!1)}})}):(0,eI.jsxs)(eI.Fragment,{children:[Object.keys(T).length>0&&(0,eI.jsxs)("div",{className:nf("mt-4",p&&"mt-2"),children:[(0,eI.jsx)("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Arguments"}),(0,eI.jsx)("div",{className:"space-y-2",children:Object.entries(T).map(([e,t])=>{let r,n=(r=_0(t,{pretty:!1}).replace(/\s+/g," ").trim()).length>80?r.slice(0,79)+"…":r,a=_0(t,{pretty:!0}),i=n!==a,s=i&&!!f[e],o=(0,eI.jsxs)("span",{className:"flex min-w-0 flex-1 items-baseline gap-2",children:[(0,eI.jsxs)("span",{className:"shrink-0 font-mono",children:[e,":"]}),(0,eI.jsx)("span",{className:"truncate font-mono font-normal text-muted-foreground",children:n})]});return(0,eI.jsxs)("div",{className:"rounded-sm border border-border",children:[i?(0,eI.jsxs)("button",{type:"button",onClick:()=>N(e),className:"flex w-full items-center justify-between gap-2 bg-muted/30 p-2 text-left text-xs font-medium transition-colors hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:[o,s?(0,eI.jsx)(l$,{size:12,className:"shrink-0 text-muted-foreground"}):(0,eI.jsx)(lB,{size:12,className:"shrink-0 text-muted-foreground"})]}):(0,eI.jsx)("div",{className:"flex items-center gap-2 bg-muted/30 p-2 text-xs font-medium",children:o}),s&&(0,eI.jsx)("div",{className:nf("border-t border-border bg-muted/20 p-2",p&&"p-1.5"),children:(0,eI.jsx)("pre",{className:nf("m-0 overflow-x-auto whitespace-pre-wrap break-all font-mono text-xs leading-6 text-foreground",p&&"text-[11px] leading-5"),children:a})})]},e)})})]}),I&&(0,eI.jsxs)("div",{className:nf("mt-4",p&&"mt-2"),children:[(0,eI.jsx)("h4",{className:"mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Result"}),(0,eI.jsx)("pre",{className:nf("m-0 overflow-x-auto whitespace-pre-wrap break-all rounded-sm border border-border bg-muted/40 p-2 font-mono text-xs leading-7 text-foreground",p&&"p-1.5 text-[11px] leading-5"),children:_0(S,{pretty:!0})})]})]})})]})});function _2(){}function _4(){}function _3(e){let t=[],r=String(e||""),n=r.indexOf(","),a=0,i=!1;for(;!i;){-1===n&&(n=r.length,i=!0);let e=r.slice(a,n).trim();(e||!i)&&t.push(e),a=n+1,n=r.indexOf(",",a)}return t}function _5(e,t){let r=t||{};return(""===e[e.length-1]?[...e,""]:e).join((r.padRight?" ":"")+","+(!1===r.padLeft?"":" ")).trim()}_1.displayName="ToolCallBox";let _6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_9=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_8={};function _7(e,t){return((t||_8).jsx?_9:_6).test(e)}let ve=/[ \t\n\f\r]/g;function vt(e){return""===e.replace(ve,"")}class vr{constructor(e,t){this.attribute=t,this.property=e}}vr.prototype.attribute="",vr.prototype.booleanish=!1,vr.prototype.boolean=!1,vr.prototype.commaOrSpaceSeparated=!1,vr.prototype.commaSeparated=!1,vr.prototype.defined=!1,vr.prototype.mustUseProperty=!1,vr.prototype.number=!1,vr.prototype.overloadedBoolean=!1,vr.prototype.property="",vr.prototype.spaceSeparated=!1,vr.prototype.space=void 0;let vn=0,va=vd(),vi=vd(),vs=vd(),vo=vd(),vl=vd(),vc=vd(),vu=vd();function vd(){return 2**++vn}e.s(["boolean",0,va,"booleanish",0,vi,"commaOrSpaceSeparated",0,vu,"commaSeparated",0,vc,"number",0,vo,"overloadedBoolean",0,vs,"spaceSeparated",0,vl],400744);var vp=e.i(400744);let vm=Object.keys(vp);class vh extends vr{constructor(e,t,r,n){let a=-1;if(super(e,t),function(e,t,r){r&&(e[t]=r)}(this,"space",n),"number"==typeof r)for(;++a<vm.length;){const e=vm[a];!function(e,t,r){r&&(e[t]=r)}(this,vm[a],(r&vp[e])===vp[e])}}}function vf(e){return e.toLowerCase()}vh.prototype.defined=!0;let vg=/[A-Z]/g,vb=/-[a-z]/g,vy=/^data[-\w.:]+$/i;function vE(e,t){let r=vf(t),n=t,a=vr;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&"data"===r.slice(0,4)&&vy.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(vb,vv);n="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!vb.test(e)){let r=e.replace(vg,v_);"-"!==r.charAt(0)&&(r="-"+r),t="data"+r}}a=vh}return new a(n,t)}function v_(e){return"-"+e.toLowerCase()}function vv(e){return e.charAt(1).toUpperCase()}let vx={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"};class vT{constructor(e,t,r){this.normal=t,this.property=e,r&&(this.space=r)}}function vS(e,t){let r={},n={};for(let t of e)Object.assign(r,t.property),Object.assign(n,t.normal);return new vT(r,n,t)}function vw(e){let t={},r={};for(let[n,a]of Object.entries(e.properties)){let i=new vh(n,e.transform(e.attributes||{},n),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(n)&&(i.mustUseProperty=!0),t[n]=i,r[vf(n)]=n,r[vf(i.attribute)]=n}return new vT(t,r,e.space)}vT.prototype.normal={},vT.prototype.property={},vT.prototype.space=void 0;let vk=vw({properties:{ariaActiveDescendant:null,ariaAtomic:vi,ariaAutoComplete:null,ariaBusy:vi,ariaChecked:vi,ariaColCount:vo,ariaColIndex:vo,ariaColSpan:vo,ariaControls:vl,ariaCurrent:null,ariaDescribedBy:vl,ariaDetails:null,ariaDisabled:vi,ariaDropEffect:vl,ariaErrorMessage:null,ariaExpanded:vi,ariaFlowTo:vl,ariaGrabbed:vi,ariaHasPopup:null,ariaHidden:vi,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:vl,ariaLevel:vo,ariaLive:null,ariaModal:vi,ariaMultiLine:vi,ariaMultiSelectable:vi,ariaOrientation:null,ariaOwns:vl,ariaPlaceholder:null,ariaPosInSet:vo,ariaPressed:vi,ariaReadOnly:vi,ariaRelevant:null,ariaRequired:vi,ariaRoleDescription:vl,ariaRowCount:vo,ariaRowIndex:vo,ariaRowSpan:vo,ariaSelected:vi,ariaSetSize:vo,ariaSort:null,ariaValueMax:vo,ariaValueMin:vo,ariaValueNow:vo,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function vA(e,t){return t in e?e[t]:t}function vN(e,t){return vA(e,t.toLowerCase())}let vI=vw({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:vc,acceptCharset:vl,accessKey:vl,action:null,allow:null,allowFullScreen:va,allowPaymentRequest:va,allowUserMedia:va,alt:null,as:null,async:va,autoCapitalize:null,autoComplete:vl,autoFocus:va,autoPlay:va,blocking:vl,capture:null,charSet:null,checked:va,cite:null,className:vl,cols:vo,colSpan:null,content:null,contentEditable:vi,controls:va,controlsList:vl,coords:vo|vc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:va,defer:va,dir:null,dirName:null,disabled:va,download:vs,draggable:vi,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:va,formTarget:null,headers:vl,height:vo,hidden:vs,high:vo,href:null,hrefLang:null,htmlFor:vl,httpEquiv:vl,id:null,imageSizes:null,imageSrcSet:null,inert:va,inputMode:null,integrity:null,is:null,isMap:va,itemId:null,itemProp:vl,itemRef:vl,itemScope:va,itemType:vl,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:va,low:vo,manifest:null,max:null,maxLength:vo,media:null,method:null,min:null,minLength:vo,multiple:va,muted:va,name:null,nonce:null,noModule:va,noValidate:va,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:va,optimum:vo,pattern:null,ping:vl,placeholder:null,playsInline:va,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:va,referrerPolicy:null,rel:vl,required:va,reversed:va,rows:vo,rowSpan:vo,sandbox:vl,scope:null,scoped:va,seamless:va,selected:va,shadowRootClonable:va,shadowRootDelegatesFocus:va,shadowRootMode:null,shape:null,size:vo,sizes:null,slot:null,span:vo,spellCheck:vi,src:null,srcDoc:null,srcLang:null,srcSet:null,start:vo,step:null,style:null,tabIndex:vo,target:null,title:null,translate:null,type:null,typeMustMatch:va,useMap:null,value:vi,width:vo,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:vl,axis:null,background:null,bgColor:null,border:vo,borderColor:null,bottomMargin:vo,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:va,declare:va,event:null,face:null,frame:null,frameBorder:null,hSpace:vo,leftMargin:vo,link:null,longDesc:null,lowSrc:null,marginHeight:vo,marginWidth:vo,noResize:va,noHref:va,noShade:va,noWrap:va,object:null,profile:null,prompt:null,rev:null,rightMargin:vo,rules:null,scheme:null,scrolling:vi,standby:null,summary:null,text:null,topMargin:vo,valueType:null,version:null,vAlign:null,vLink:null,vSpace:vo,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:va,disableRemotePlayback:va,prefix:null,property:null,results:vo,security:null,unselectable:null},space:"html",transform:vN}),vC=vw({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:vu,accentHeight:vo,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:vo,amplitude:vo,arabicForm:null,ascent:vo,attributeName:null,attributeType:null,azimuth:vo,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:vo,by:null,calcMode:null,capHeight:vo,className:vl,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:vo,diffuseConstant:vo,direction:null,display:null,dur:null,divisor:vo,dominantBaseline:null,download:va,dx:null,dy:null,edgeMode:null,editable:null,elevation:vo,enableBackground:null,end:null,event:null,exponent:vo,externalResourcesRequired:null,fill:null,fillOpacity:vo,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:vc,g2:vc,glyphName:vc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:vo,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:vo,horizOriginX:vo,horizOriginY:vo,id:null,ideographic:vo,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:vo,k:vo,k1:vo,k2:vo,k3:vo,k4:vo,kernelMatrix:vu,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:vo,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:vo,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:vo,overlineThickness:vo,paintOrder:null,panose1:null,path:null,pathLength:vo,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:vl,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:vo,pointsAtY:vo,pointsAtZ:vo,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vu,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vu,rev:vu,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vu,requiredFeatures:vu,requiredFonts:vu,requiredFormats:vu,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:vo,specularExponent:vo,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:vo,strikethroughThickness:vo,string:null,stroke:null,strokeDashArray:vu,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:vo,strokeOpacity:vo,strokeWidth:null,style:null,surfaceScale:vo,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vu,tabIndex:vo,tableValues:null,target:null,targetX:vo,targetY:vo,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vu,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:vo,underlineThickness:vo,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:vo,values:null,vAlphabetic:vo,vMathematical:vo,vectorEffect:null,vHanging:vo,vIdeographic:vo,version:null,vertAdvY:vo,vertOriginX:vo,vertOriginY:vo,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:vo,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:vA}),vR=vw({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),vO=vw({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:vN}),vL=vw({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),vD=vS([vk,vI,vR,vO,vL],"html"),vP=vS([vk,vC,vR,vO,vL],"svg");function vM(e){let t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function vj(e){return e.join(" ").trim()}var vF=e.i(515511);let vU=v$("end"),vB=v$("start");function v$(e){return function(t){let r=t&&t.position&&t.position[e]||{};if("number"==typeof r.line&&r.line>0&&"number"==typeof r.column&&r.column>0)return{line:r.line,column:r.column,offset:"number"==typeof r.offset&&r.offset>-1?r.offset:void 0}}}function vz(e){let t=vB(e),r=vU(e);if(t&&r)return{start:t,end:r}}function vH(e){return e&&"object"==typeof e?"position"in e||"type"in e?vq(e.position):"start"in e||"end"in e?vq(e):"line"in e||"column"in e?vG(e):"":""}function vG(e){return vV(e&&e.line)+":"+vV(e&&e.column)}function vq(e){return vG(e&&e.start)+"-"+vG(e&&e.end)}function vV(e){return e&&"number"==typeof e?e:1}class vW extends Error{constructor(e,t,r){super(),"string"==typeof t&&(r=t,t=void 0);let n="",a={},i=!1;if(t&&(a="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?n=e:!a.cause&&e&&(i=!0,n=e.message,a.cause=e),!a.ruleId&&!a.source&&"string"==typeof r){const e=r.indexOf(":");-1===e?a.ruleId=r:(a.source=r.slice(0,e),a.ruleId=r.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){const e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}const s=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=n,this.line=s?s.line:void 0,this.name=vH(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=i&&a.cause&&"string"==typeof a.cause.stack?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}vW.prototype.file="",vW.prototype.name="",vW.prototype.reason="",vW.prototype.message="",vW.prototype.stack="",vW.prototype.column=void 0,vW.prototype.line=void 0,vW.prototype.ancestors=void 0,vW.prototype.cause=void 0,vW.prototype.fatal=void 0,vW.prototype.place=void 0,vW.prototype.ruleId=void 0,vW.prototype.source=void 0;let vY={}.hasOwnProperty,vK=new Map,vZ=/[A-Z]/g,vX=new Set(["table","tbody","thead","tfoot","tr"]),vQ=new Set(["td","th"]),vJ="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function v0(e,t,r){var n,a,i,s,o,l,c,u,d;let p,m,h,f,g,b,y,E,_,v,x;return"element"===t.type?(n=e,a=t,i=r,m=p=n.schema,"svg"===a.tagName.toLowerCase()&&"html"===p.space&&(n.schema=vP),n.ancestors.push(a),h=v3(n,a.tagName,!1),f=function(e,t){let r,n,a={};for(n in t.properties)if("children"!==n&&vY.call(t.properties,n)){let i=function(e,t,r){let n=vE(e.schema,t);if(!(null==r||"number"==typeof r&&Number.isNaN(r))){if(Array.isArray(r)&&(r=n.commaSeparated?_5(r):vj(r)),"style"===n.property){let t="object"==typeof r?r:function(e,t){try{return(0,vF.default)(t,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};let t=new vW("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw t.file=e.filePath||void 0,t.url=vJ+"#cannot-parse-style-attribute",t}}(e,String(r));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,r={};for(t in e)vY.call(e,t)&&(r[function(e){let t=e.replace(vZ,v6);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return r}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&n.space?vx[n.property]||n.property:n.attribute,r]}}(e,n,t.properties[n]);if(i){let[n,s]=i;e.tableCellAlignToStyle&&"align"===n&&"string"==typeof s&&vQ.has(t.tagName)?r=s:a[n]=s}}return r&&((a.style||(a.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r),a}(n,a),g=v4(n,a),vX.has(a.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&vt(e.value):vt(e))})),v1(n,f,h,a),v2(f,g),n.ancestors.pop(),n.schema=p,n.create(a,h,f,i)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let r=t.data.estree.body[0];return _2("ExpressionStatement"===r.type),e.evaluater.evaluateExpression(r.expression)}v5(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(s=e,o=t,l=r,y=b=s.schema,"svg"===o.name&&"html"===b.space&&(s.schema=vP),s.ancestors.push(o),E=null===o.name?s.Fragment:v3(s,o.name,!0),_=function(e,t){let r={};for(let n of t.attributes)if("mdxJsxExpressionAttribute"===n.type)if(n.data&&n.data.estree&&e.evaluater){let t=n.data.estree.body[0];_2("ExpressionStatement"===t.type);let a=t.expression;_2("ObjectExpression"===a.type);let i=a.properties[0];_2("SpreadElement"===i.type),Object.assign(r,e.evaluater.evaluateExpression(i.argument))}else v5(e,t.position);else{let a,i=n.name;if(n.value&&"object"==typeof n.value)if(n.value.data&&n.value.data.estree&&e.evaluater){let t=n.value.data.estree.body[0];_2("ExpressionStatement"===t.type),a=e.evaluater.evaluateExpression(t.expression)}else v5(e,t.position);else a=null===n.value||n.value;r[i]=a}return r}(s,o),v=v4(s,o),v1(s,_,E,o),v2(_,v),s.ancestors.pop(),s.schema=b,s.create(o,E,_,l)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);v5(e,t.position)}(e,t):"root"===t.type?(c=e,u=t,d=r,v2(x={},v4(c,u)),c.create(u,c.Fragment,x,d)):"text"===t.type?t.value:void 0}function v1(e,t,r,n){"string"!=typeof r&&r!==e.Fragment&&e.passNode&&(t.node=n)}function v2(e,t){if(t.length>0){let r=t.length>1?t:t[0];r&&(e.children=r)}}function v4(e,t){let r=[],n=-1,a=e.passKeys?new Map:vK;for(;++n<t.children.length;){let i,s=t.children[n];if(e.passKeys){let e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){let t=a.get(e)||0;i=e+"-"+t,a.set(e,t+1)}}let o=v0(e,s,i);void 0!==o&&r.push(o)}return r}function v3(e,t,r){let n;if(r)if(t.includes(".")){let e,r=t.split("."),a=-1;for(;++a<r.length;){let t=_7(r[a])?{type:"Identifier",name:r[a]}:{type:"Literal",value:r[a]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(a&&"Literal"===t.type),optional:!1}:t}_2(e,"always a result"),n=e}else n=_7(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else n={type:"Literal",value:t};if("Literal"===n.type){let t=n.value;return vY.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(n);v5(e)}function v5(e,t){let r=new vW("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=vJ+"#cannot-handle-mdx-estrees-without-createevaluater",r}function v6(e){return"-"+e.toLowerCase()}let v9={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"]},v8={};function v7(e,t){let r=t||v8;return xe(e,"boolean"!=typeof r.includeImageAlt||r.includeImageAlt,"boolean"!=typeof r.includeHtml||r.includeHtml)}function xe(e,t,r){var n;if((n=e)&&"object"==typeof n){if("value"in e)return"html"!==e.type||r?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return xt(e.children,t,r)}return Array.isArray(e)?xt(e,t,r):""}function xt(e,t,r){let n=[],a=-1;for(;++a<e.length;)n[a]=xe(e[a],t,r);return n.join("")}function xr(e,t,r,n){let a,i=e.length,s=0;if(t=t<0?-t>i?0:i+t:t>i?i:t,r=r>0?r:0,n.length<1e4)(a=Array.from(n)).unshift(t,r),e.splice(...a);else for(r&&e.splice(t,r);s<n.length;)(a=n.slice(s,s+1e4)).unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function xn(e,t){return e.length>0?(xr(e,e.length,0,t),e):t}let xa={}.hasOwnProperty;function xi(e){let t={},r=-1;for(;++r<e.length;)!function(e,t){let r;for(r in t){let n,a=(xa.call(e,r)?e[r]:void 0)||(e[r]={}),i=t[r];if(i)for(n in i){xa.call(a,n)||(a[n]=[]);let e=i[n];!function(e,t){let r=-1,n=[];for(;++r<t.length;)("after"===t[r].add?e:n).push(t[r]);xr(e,0,0,n)}(a[n],Array.isArray(e)?e:e?[e]:[])}}}(t,e[r]);return t}let xs=xy(/[A-Za-z]/),xo=xy(/[\dA-Za-z]/),xl=xy(/[#-'*+\--9=?A-Z^-~]/);function xc(e){return null!==e&&(e<32||127===e)}let xu=xy(/\d/),xd=xy(/[\dA-Fa-f]/),xp=xy(/[!-/:-@[-`{-~]/);function xm(e){return null!==e&&e<-2}function xh(e){return null!==e&&(e<0||32===e)}function xf(e){return -2===e||-1===e||32===e}let xg=xy(/\p{P}|\p{S}/u),xb=xy(/\s/);function xy(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function xE(e,t,r,n){let a=n?n-1:1/0,i=0;return function(n){return xf(n)?(e.enter(r),function n(s){return xf(s)&&i++<a?(e.consume(s),n):(e.exit(r),t(s))}(n)):t(n)}}let x_={tokenize:function(e){let t,r=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),xE(e,r,"linePrefix"))},function(r){return e.enter("paragraph"),function r(n){let a=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=a),t=a,function t(n){if(null===n){e.exit("chunkText"),e.exit("paragraph"),e.consume(n);return}return xm(n)?(e.consume(n),e.exit("chunkText"),r):(e.consume(n),t)}(n)}(r)});return r}},xv={tokenize:function(e){let t,r,n,a=this,i=[],s=0;return o;function o(t){if(s<i.length){let r=i[s];return a.containerState=r[1],e.attempt(r[0].continuation,l,c)(t)}return c(t)}function l(e){if(s++,a.containerState._closeFlow){let r;a.containerState._closeFlow=void 0,t&&b();let n=a.events.length,i=n;for(;i--;)if("exit"===a.events[i][0]&&"chunkFlow"===a.events[i][1].type){r=a.events[i][1].end;break}g(s);let o=n;for(;o<a.events.length;)a.events[o][1].end={...r},o++;return xr(a.events,i+1,0,a.events.slice(n)),a.events.length=o,c(e)}return o(e)}function c(r){if(s===i.length){if(!t)return p(r);if(t.currentConstruct&&t.currentConstruct.concrete)return h(r);a.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return a.containerState={},e.check(xx,u,d)(r)}function u(e){return t&&b(),g(s),p(e)}function d(e){return a.parser.lazy[a.now().line]=s!==i.length,n=a.now().offset,h(e)}function p(t){return a.containerState={},e.attempt(xx,m,h)(t)}function m(e){return s++,i.push([a.currentConstruct,a.containerState]),p(e)}function h(n){if(null===n){t&&b(),g(0),e.consume(n);return}return t=t||a.parser.flow(a.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:r}),function t(r){if(null===r){f(e.exit("chunkFlow"),!0),g(0),e.consume(r);return}return xm(r)?(e.consume(r),f(e.exit("chunkFlow")),s=0,a.interrupt=void 0,o):(e.consume(r),t)}(n)}function f(e,i){let o=a.sliceStream(e);if(i&&o.push(null),e.previous=r,r&&(r.next=e),r=e,t.defineSkip(e.start),t.write(o),a.parser.lazy[e.start.line]){let e,r,i=t.events.length;for(;i--;)if(t.events[i][1].start.offset<n&&(!t.events[i][1].end||t.events[i][1].end.offset>n))return;let o=a.events.length,l=o;for(;l--;)if("exit"===a.events[l][0]&&"chunkFlow"===a.events[l][1].type){if(e){r=a.events[l][1].end;break}e=!0}for(g(s),i=o;i<a.events.length;)a.events[i][1].end={...r},i++;xr(a.events,l+1,0,a.events.slice(o)),a.events.length=i}}function g(t){let r=i.length;for(;r-- >t;){let t=i[r];a.containerState=t[1],t[0].exit.call(a,e)}i.length=t}function b(){t.write([null]),r=void 0,t=void 0,a.containerState._closeFlow=void 0}}},xx={tokenize:function(e,t,r){return xE(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},xT={partial:!0,tokenize:function(e,t,r){return function(t){return xf(t)?xE(e,n,"linePrefix")(t):n(t)};function n(e){return null===e||xm(e)?t(e):r(e)}}};class xS{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let r=null==t?1/0:t;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,t,r){this.setCursor(Math.trunc(e));let n=this.right.splice(this.right.length-(t||0),1/0);return r&&xw(this.left,r),n.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),xw(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),xw(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);xw(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);xw(this.left,t.reverse())}}}function xw(e,t){let r=0;if(t.length<1e4)e.push(...t);else for(;r<t.length;)e.push(...t.slice(r,r+1e4)),r+=1e4}function xk(e){let t,r,n,a,i,s,o,l={},c=-1,u=new xS(e);for(;++c<u.length;){for(;c in l;)c=l[c];if(t=u.get(c),c&&"chunkFlow"===t[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&((n=0)<(s=t[1]._tokenizer.events).length&&"lineEndingBlank"===s[n][1].type&&(n+=2),n<s.length&&"content"===s[n][1].type))for(;++n<s.length&&"content"!==s[n][1].type;)"chunkText"===s[n][1].type&&(s[n][1]._isInFirstContentOfListItem=!0,n++);if("enter"===t[0])t[1].contentType&&(Object.assign(l,function(e,t){let r,n,a=e.get(t)[1],i=e.get(t)[2],s=t-1,o=[],l=a._tokenizer;!l&&(l=i.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));let c=l.events,u=[],d={},p=-1,m=a,h=0,f=0,g=[0];for(;m;){for(;e.get(++s)[1]!==m;);o.push(s),!m._tokenizer&&(r=i.sliceStream(m),m.next||r.push(null),n&&l.defineSkip(m.start),m._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(r),m._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),n=m,m=m.next}for(m=a;++p<c.length;)"exit"===c[p][0]&&"enter"===c[p-1][0]&&c[p][1].type===c[p-1][1].type&&c[p][1].start.line!==c[p][1].end.line&&(f=p+1,g.push(f),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(l.events=[],m?(m._tokenizer=void 0,m.previous=void 0):g.pop(),p=g.length;p--;){let t=c.slice(g[p],g[p+1]),r=o.pop();u.push([r,r+t.length-1]),e.splice(r,2,t)}for(u.reverse(),p=-1;++p<u.length;)d[h+u[p][0]]=h+u[p][1],h+=u[p][1]-u[p][0]-1;return d}(u,c)),c=l[c],o=!0);else if(t[1]._container){for(n=c,r=void 0;n--;)if("lineEnding"===(a=u.get(n))[1].type||"lineEndingBlank"===a[1].type)"enter"===a[0]&&(r&&(u.get(r)[1].type="lineEndingBlank"),a[1].type="lineEnding",r=n);else if("linePrefix"===a[1].type||"listItemIndent"===a[1].type);else break;r&&(t[1].end={...u.get(r)[1].start},(i=u.slice(r,c)).unshift(t),u.splice(r,c-r+1,i))}}return xr(e,0,1/0,u.slice(0)),!o}let xA={resolve:function(e){return xk(e),e},tokenize:function(e,t){let r;return function(t){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),n(t)};function n(t){return null===t?a(t):xm(t)?e.check(xN,i,a)(t):(e.consume(t),n)}function a(r){return e.exit("chunkContent"),e.exit("content"),t(r)}function i(t){return e.consume(t),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,n}}},xN={partial:!0,tokenize:function(e,t,r){let n=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),xE(e,a,"linePrefix")};function a(a){if(null===a||xm(a))return r(a);let i=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(a):e.interrupt(n.parser.constructs.flow,r,t)(a)}}},xI={tokenize:function(e){let t=this,r=e.attempt(xT,function(n){return null===n?void e.consume(n):(e.enter("lineEndingBlank"),e.consume(n),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r)},e.attempt(this.parser.constructs.flowInitial,n,xE(e,e.attempt(this.parser.constructs.flow,n,e.attempt(xA,n)),"linePrefix")));return r;function n(n){return null===n?void e.consume(n):(e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),t.currentConstruct=void 0,r)}}},xC={resolveAll:xD()},xR=xL("string"),xO=xL("text");function xL(e){return{resolveAll:xD("text"===e?xP:void 0),tokenize:function(t){let r=this,n=this.parser.constructs[e],a=t.attempt(n,i,s);return i;function i(e){return l(e)?a(e):s(e)}function s(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),o)}function o(e){return l(e)?(t.exit("data"),a(e)):(t.consume(e),o)}function l(e){if(null===e)return!0;let t=n[e],a=-1;if(t)for(;++a<t.length;){let e=t[a];if(!e.previous||e.previous.call(r,r.previous))return!0}return!1}}}}function xD(e){return function(t,r){let n,a=-1;for(;++a<=t.length;)void 0===n?t[a]&&"data"===t[a][1].type&&(n=a,a++):t[a]&&"data"===t[a][1].type||(a!==n+2&&(t[n][1].end=t[a-1][1].end,t.splice(n+2,a-n-2),a=n+2),n=void 0);return e?e(t,r):t}}function xP(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||"lineEnding"===e[r][1].type)&&"data"===e[r-1][1].type){let n,a=e[r-1][1],i=t.sliceStream(a),s=i.length,o=-1,l=0;for(;s--;){let e=i[s];if("string"==typeof e){for(o=e.length;32===e.charCodeAt(o-1);)l++,o--;if(o)break;o=-1}else if(-2===e)n=!0,l++;else if(-1===e);else{s++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(l=0),l){let i={type:r===e.length||n||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:a.start._bufferIndex+o,_index:a.start._index+s,line:a.end.line,column:a.end.column-l,offset:a.end.offset-l},end:{...a.end}};a.end={...i.start},a.start.offset===a.end.offset?Object.assign(a,i):(e.splice(r,0,["enter",i,t],["exit",i,t]),r+=2)}r++}return e}function xM(e){return null===e||xh(e)||xb(e)?1:xg(e)?2:void 0}function xj(e,t,r){let n=[],a=-1;for(;++a<e.length;){let i=e[a].resolveAll;i&&!n.includes(i)&&(t=i(t,r),n.push(i))}return t}let xF={name:"attention",resolveAll:function(e,t){let r,n,a,i,s,o,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close){for(r=u;r--;)if("exit"===e[r][0]&&"attentionSequence"===e[r][1].type&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[r][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;o=e[r][1].end.offset-e[r][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;let d={...e[r][1].end},p={...e[u][1].start};xU(d,-o),xU(p,o),i={type:o>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},s={type:o>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:p},a={type:o>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[u][1].start}},n={type:o>1?"strong":"emphasis",start:{...i.start},end:{...s.end}},e[r][1].end={...i.start},e[u][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=xn(l,[["enter",e[r][1],t],["exit",e[r][1],t]])),l=xn(l,[["enter",n,t],["enter",i,t],["exit",i,t],["enter",a,t]]),l=xn(l,xj(t.parser.constructs.insideSpan.null,e.slice(r+1,u),t)),l=xn(l,[["exit",a,t],["enter",s,t],["exit",s,t],["exit",n,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=xn(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,xr(e,r-1,u-r+3,l),u=r+l.length-c-2;break}}for(u=-1;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){let r,n=this.parser.constructs.attentionMarkers.null,a=this.previous,i=xM(a);return function(s){return r=s,e.enter("attentionSequence"),function s(o){if(o===r)return e.consume(o),s;let l=e.exit("attentionSequence"),c=xM(o),u=!c||2===c&&i||n.includes(o),d=!i||2===i&&c||n.includes(a);return l._open=!!(42===r?u:u&&(i||!d)),l._close=!!(42===r?d:d&&(c||!u)),t(o)}(s)}}};function xU(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let xB={continuation:{tokenize:function(e,t,r){let n=this;return function(t){return xf(t)?xE(e,a,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):a(t)};function a(n){return e.attempt(xB,t,r)(n)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,r){let n=this;return function(t){if(62===t){let r=n.containerState;return r.open||(e.enter("blockQuote",{_container:!0}),r.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),a}return r(t)};function a(r){return xf(r)?(e.enter("blockQuotePrefixWhitespace"),e.consume(r),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(r))}}},x$={name:"characterEscape",tokenize:function(e,t,r){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),n};function n(n){return xp(n)?(e.enter("characterEscapeValue"),e.consume(n),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(n)}}},xz=document.createElement("i");function xH(e){let t="&"+e+";";xz.innerHTML=t;let r=xz.textContent;return(59!==r.charCodeAt(r.length-1)||"semi"===e)&&r!==t&&r}let xG={name:"characterReference",tokenize:function(e,t,r){let n,a,i=this,s=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),o};function o(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),n=31,a=xo,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),n=6,a=xd,c):(e.enter("characterReferenceValue"),n=7,a=xu,c(t))}function c(o){if(59===o&&s){let n=e.exit("characterReferenceValue");return a!==xo||xH(i.sliceSerialize(n))?(e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):r(o)}return a(o)&&s++<n?(e.consume(o),c):r(o)}}},xq={partial:!0,tokenize:function(e,t,r){let n=this;return function(t){return null===t?r(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a)};function a(e){return n.parser.lazy[n.now().line]?r(e):t(e)}}},xV={concrete:!0,name:"codeFenced",tokenize:function(e,t,r){let n,a=this,i={partial:!0,tokenize:function(e,t,r){let i=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s};function s(t){return e.enter("codeFencedFence"),xf(t)?xE(e,l,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===n?(e.enter("codeFencedFenceSequence"),function t(a){return a===n?(i++,e.consume(a),t):i>=o?(e.exit("codeFencedFenceSequence"),xf(a)?xE(e,c,"whitespace")(a):c(a)):r(a)}(t)):r(t)}function c(n){return null===n||xm(n)?(e.exit("codeFencedFence"),t(n)):r(n)}}},s=0,o=0;return function(t){var i;let c;return i=t,s=(c=a.events[a.events.length-1])&&"linePrefix"===c[1].type?c[2].sliceSerialize(c[1],!0).length:0,n=i,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(a){return a===n?(o++,e.consume(a),t):o<3?r(a):(e.exit("codeFencedFenceSequence"),xf(a)?xE(e,l,"whitespace")(a):l(a))}(i)};function l(i){return null===i||xm(i)?(e.exit("codeFencedFence"),a.interrupt?t(i):e.check(xq,u,h)(i)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(a){return null===a||xm(a)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(a)):xf(a)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),xE(e,c,"whitespace")(a)):96===a&&a===n?r(a):(e.consume(a),t)}(i))}function c(t){return null===t||xm(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(a){return null===a||xm(a)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(a)):96===a&&a===n?r(a):(e.consume(a),t)}(t))}function u(t){return e.attempt(i,h,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return s>0&&xf(t)?xE(e,m,"linePrefix",s+1)(t):m(t)}function m(t){return null===t||xm(t)?e.check(xq,u,h)(t):(e.enter("codeFlowValue"),function t(r){return null===r||xm(r)?(e.exit("codeFlowValue"),m(r)):(e.consume(r),t)}(t))}function h(r){return e.exit("codeFenced"),t(r)}}},xW={name:"codeIndented",tokenize:function(e,t,r){let n=this;return function(t){return e.enter("codeIndented"),xE(e,a,"linePrefix",5)(t)};function a(t){let a=n.events[n.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?function t(r){return null===r?i(r):xm(r)?e.attempt(xY,t,i)(r):(e.enter("codeFlowValue"),function r(n){return null===n||xm(n)?(e.exit("codeFlowValue"),t(n)):(e.consume(n),r)}(r))}(t):r(t)}function i(r){return e.exit("codeIndented"),t(r)}}},xY={partial:!0,tokenize:function(e,t,r){let n=this;return a;function a(t){return n.parser.lazy[n.now().line]?r(t):xm(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):xE(e,i,"linePrefix",5)(t)}function i(e){let i=n.events[n.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?t(e):xm(e)?a(e):r(e)}}};function xK(e,t,r,n,a,i,s,o,l){let c=l||1/0,u=0;return function(t){return 60===t?(e.enter(n),e.enter(a),e.enter(i),e.consume(t),e.exit(i),d):null===t||32===t||41===t||xc(t)?r(t):(e.enter(n),e.enter(s),e.enter(o),e.enter("chunkString",{contentType:"string"}),h(t))};function d(r){return 62===r?(e.enter(i),e.consume(r),e.exit(i),e.exit(a),e.exit(n),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),p(r))}function p(t){return 62===t?(e.exit("chunkString"),e.exit(o),d(t)):null===t||60===t||xm(t)?r(t):(e.consume(t),92===t?m:p)}function m(t){return 60===t||62===t||92===t?(e.consume(t),p):p(t)}function h(a){return!u&&(null===a||41===a||xh(a))?(e.exit("chunkString"),e.exit(o),e.exit(s),e.exit(n),t(a)):u<c&&40===a?(e.consume(a),u++,h):41===a?(e.consume(a),u--,h):null===a||32===a||40===a||xc(a)?r(a):(e.consume(a),92===a?f:h)}function f(t){return 40===t||41===t||92===t?(e.consume(t),h):h(t)}}function xZ(e,t,r,n,a,i){let s,o=this,l=0;return function(t){return e.enter(n),e.enter(a),e.consume(t),e.exit(a),e.enter(i),c};function c(d){return l>999||null===d||91===d||93===d&&!s||94===d&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?r(d):93===d?(e.exit(i),e.enter(a),e.consume(d),e.exit(a),e.exit(n),t):xm(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||xm(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),s||(s=!xf(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function xX(e,t,r,n,a,i){let s;return function(t){return 34===t||39===t||40===t?(e.enter(n),e.enter(a),e.consume(t),e.exit(a),s=40===t?41:t,o):r(t)};function o(r){return r===s?(e.enter(a),e.consume(r),e.exit(a),e.exit(n),t):(e.enter(i),l(r))}function l(t){return t===s?(e.exit(i),o(s)):null===t?r(t):xm(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),xE(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===s||null===t||xm(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===s||92===t?(e.consume(t),c):c(t)}}function xQ(e,t){let r;return function n(a){return xm(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r=!0,n):xf(a)?xE(e,n,r?"linePrefix":"lineSuffix")(a):t(a)}}function xJ(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let x0={partial:!0,tokenize:function(e,t,r){return function(t){return xh(t)?xQ(e,n)(t):r(t)};function n(t){return xX(e,a,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return xf(t)?xE(e,i,"whitespace")(t):i(t)}function i(e){return null===e||xm(e)?t(e):r(e)}}},x1=["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"],x2=["pre","script","style","textarea"],x4={partial:!0,tokenize:function(e,t,r){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),e.attempt(xT,t,r)}}},x3={partial:!0,tokenize:function(e,t,r){let n=this;return function(t){return xm(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):r(t)};function a(e){return n.parser.lazy[n.now().line]?r(e):t(e)}}},x5={name:"labelEnd",resolveAll:function(e){let t=-1,r=[];for(;++t<e.length;){let n=e[t][1];if(r.push(e[t]),"labelImage"===n.type||"labelLink"===n.type||"labelEnd"===n.type){let e="labelImage"===n.type?4:2;n.type="data",t+=e}}return e.length!==r.length&&xr(e,0,e.length,r),e},resolveTo:function(e,t){let r,n,a,i,s=e.length,o=0;for(;s--;)if(r=e[s][1],n){if("link"===r.type||"labelLink"===r.type&&r._inactive)break;"enter"===e[s][0]&&"labelLink"===r.type&&(r._inactive=!0)}else if(a){if("enter"===e[s][0]&&("labelImage"===r.type||"labelLink"===r.type)&&!r._balanced&&(n=s,"labelLink"!==r.type)){o=2;break}}else"labelEnd"===r.type&&(a=s);let l={type:"labelLink"===e[n][1].type?"link":"image",start:{...e[n][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[n][1].start},end:{...e[a][1].end}},u={type:"labelText",start:{...e[n+o+2][1].end},end:{...e[a-2][1].start}};return i=xn(i=[["enter",l,t],["enter",c,t]],e.slice(n+1,n+o+3)),i=xn(i,[["enter",u,t]]),i=xn(i,xj(t.parser.constructs.insideSpan.null,e.slice(n+o+4,a-3),t)),i=xn(i,[["exit",u,t],e[a-2],e[a-1],["exit",c,t]]),i=xn(i,e.slice(a+1)),i=xn(i,[["exit",l,t]]),xr(e,n,e.length,i),e},tokenize:function(e,t,r){let n,a,i=this,s=i.events.length;for(;s--;)if(("labelImage"===i.events[s][1].type||"labelLink"===i.events[s][1].type)&&!i.events[s][1]._balanced){n=i.events[s][1];break}return function(t){return n?n._inactive?u(t):(a=i.parser.defined.includes(xJ(i.sliceSerialize({start:n.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),o):r(t)};function o(t){return 40===t?e.attempt(x6,c,a?c:u)(t):91===t?e.attempt(x9,c,a?l:u)(t):a?c(t):u(t)}function l(t){return e.attempt(x8,c,u)(t)}function c(e){return t(e)}function u(e){return n._balanced=!0,r(e)}}},x6={tokenize:function(e,t,r){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),n};function n(t){return xh(t)?xQ(e,a)(t):a(t)}function a(t){return 41===t?c(t):xK(e,i,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function i(t){return xh(t)?xQ(e,o)(t):c(t)}function s(e){return r(e)}function o(t){return 34===t||39===t||40===t?xX(e,l,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return xh(t)?xQ(e,c)(t):c(t)}function c(n){return 41===n?(e.enter("resourceMarker"),e.consume(n),e.exit("resourceMarker"),e.exit("resource"),t):r(n)}}},x9={tokenize:function(e,t,r){let n=this;return function(t){return xZ.call(n,e,a,i,"reference","referenceMarker","referenceString")(t)};function a(e){return n.parser.defined.includes(xJ(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?t(e):r(e)}function i(e){return r(e)}}},x8={tokenize:function(e,t,r){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),n};function n(n){return 93===n?(e.enter("referenceMarker"),e.consume(n),e.exit("referenceMarker"),e.exit("reference"),t):r(n)}}},x7={name:"labelStartImage",resolveAll:x5.resolveAll,tokenize:function(e,t,r){let n=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),a};function a(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),i):r(t)}function i(e){return 94===e&&"_hiddenFootnoteSupport"in n.parser.constructs?r(e):t(e)}}},Te={name:"labelStartLink",resolveAll:x5.resolveAll,tokenize:function(e,t,r){let n=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),a};function a(e){return 94===e&&"_hiddenFootnoteSupport"in n.parser.constructs?r(e):t(e)}}},Tt={name:"lineEnding",tokenize:function(e,t){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),xE(e,t,"linePrefix")}}},Tr={name:"thematicBreak",tokenize:function(e,t,r){let n,a=0;return function(i){var s;return e.enter("thematicBreak"),n=s=i,function i(s){return s===n?(e.enter("thematicBreakSequence"),function t(r){return r===n?(e.consume(r),a++,t):(e.exit("thematicBreakSequence"),xf(r)?xE(e,i,"whitespace")(r):i(r))}(s)):a>=3&&(null===s||xm(s))?(e.exit("thematicBreak"),t(s)):r(s)}(s)}}},Tn={continuation:{tokenize:function(e,t,r){let n=this;return n.containerState._closeFlow=void 0,e.check(xT,function(r){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,xE(e,t,"listItemIndent",n.containerState.size+1)(r)},function(r){return n.containerState.furtherBlankLines||!xf(r)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,a(r)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(Ti,t,a)(r))});function a(a){return n.containerState._closeFlow=!0,n.interrupt=void 0,xE(e,e.attempt(Tn,t,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,r){let n=this,a=n.events[n.events.length-1],i=a&&"linePrefix"===a[1].type?a[2].sliceSerialize(a[1],!0).length:0,s=0;return function(t){let a=n.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===a?!n.containerState.marker||t===n.containerState.marker:xu(t)){if(n.containerState.type||(n.containerState.type=a,e.enter(a,{_container:!0})),"listUnordered"===a)return e.enter("listItemPrefix"),42===t||45===t?e.check(Tr,r,o)(t):o(t);if(!n.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(a){return xu(a)&&++s<10?(e.consume(a),t):(!n.interrupt||s<2)&&(n.containerState.marker?a===n.containerState.marker:41===a||46===a)?(e.exit("listItemValue"),o(a)):r(a)}(t)}return r(t)};function o(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||t,e.check(xT,n.interrupt?r:l,e.attempt(Ta,u,c))}function l(e){return n.containerState.initialBlankLine=!0,i++,u(e)}function c(t){return xf(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):r(t)}function u(r){return n.containerState.size=i+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(r)}}},Ta={partial:!0,tokenize:function(e,t,r){let n=this;return xE(e,function(e){let a=n.events[n.events.length-1];return!xf(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):r(e)},"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Ti={partial:!0,tokenize:function(e,t,r){let n=this;return xE(e,function(e){let a=n.events[n.events.length-1];return a&&"listItemIndent"===a[1].type&&a[2].sliceSerialize(a[1],!0).length===n.containerState.size?t(e):r(e)},"listItemIndent",n.containerState.size+1)}},Ts={name:"setextUnderline",resolveTo:function(e,t){let r,n,a,i=e.length;for(;i--;)if("enter"===e[i][0]){if("content"===e[i][1].type){r=i;break}"paragraph"===e[i][1].type&&(n=i)}else"content"===e[i][1].type&&e.splice(i,1),a||"definition"!==e[i][1].type||(a=i);let s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[n][1].type="setextHeadingText",a?(e.splice(n,0,["enter",s,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=s,e.push(["exit",s,t]),e},tokenize:function(e,t,r){let n,a=this;return function(t){var s;let o,l=a.events.length;for(;l--;)if("lineEnding"!==a.events[l][1].type&&"linePrefix"!==a.events[l][1].type&&"content"!==a.events[l][1].type){o="paragraph"===a.events[l][1].type;break}return!a.parser.lazy[a.now().line]&&(a.interrupt||o)?(e.enter("setextHeadingLine"),n=t,s=t,e.enter("setextHeadingLineSequence"),function t(r){return r===n?(e.consume(r),t):(e.exit("setextHeadingLineSequence"),xf(r)?xE(e,i,"lineSuffix")(r):i(r))}(s)):r(t)};function i(n){return null===n||xm(n)?(e.exit("setextHeadingLine"),t(n)):r(n)}}};e.s(["attentionMarkers",0,{null:[42,95]},"contentInitial",0,{91:{name:"definition",tokenize:function(e,t,r){let n,a=this;return function(t){var n;return e.enter("definition"),n=t,xZ.call(a,e,i,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(n)};function i(t){return(n=xJ(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s):r(t)}function s(t){return xh(t)?xQ(e,o)(t):o(t)}function o(t){return xK(e,l,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(x0,c,c)(t)}function c(t){return xf(t)?xE(e,u,"whitespace")(t):u(t)}function u(i){return null===i||xm(i)?(e.exit("definition"),a.parser.defined.push(n),t(i)):r(i)}}}},"disable",0,{null:[]},"document",0,{42:Tn,43:Tn,45:Tn,48:Tn,49:Tn,50:Tn,51:Tn,52:Tn,53:Tn,54:Tn,55:Tn,56:Tn,57:Tn,62:xB},"flow",0,{35:{name:"headingAtx",resolve:function(e,t){let r,n,a=e.length-2,i=3;return"whitespace"===e[3][1].type&&(i+=2),a-2>i&&"whitespace"===e[a][1].type&&(a-=2),"atxHeadingSequence"===e[a][1].type&&(i===a-1||a-4>i&&"whitespace"===e[a-2][1].type)&&(a-=i+1===a?2:4),a>i&&(r={type:"atxHeadingText",start:e[i][1].start,end:e[a][1].end},n={type:"chunkText",start:e[i][1].start,end:e[a][1].end,contentType:"text"},xr(e,i,a-i+1,[["enter",r,t],["enter",n,t],["exit",n,t],["exit",r,t]])),e},tokenize:function(e,t,r){let n=0;return function(a){var i;return e.enter("atxHeading"),i=a,e.enter("atxHeadingSequence"),function a(i){return 35===i&&n++<6?(e.consume(i),a):null===i||xh(i)?(e.exit("atxHeadingSequence"),function r(n){return 35===n?(e.enter("atxHeadingSequence"),function t(n){return 35===n?(e.consume(n),t):(e.exit("atxHeadingSequence"),r(n))}(n)):null===n||xm(n)?(e.exit("atxHeading"),t(n)):xf(n)?xE(e,r,"whitespace")(n):(e.enter("atxHeadingText"),function t(n){return null===n||35===n||xh(n)?(e.exit("atxHeadingText"),r(n)):(e.consume(n),t)}(n))}(i)):r(i)}(i)}}},42:Tr,45:[Ts,Tr],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(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},tokenize:function(e,t,r){let n,a,i,s,o,l=this;return function(t){var r;return r=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(r),c};function c(s){return 33===s?(e.consume(s),u):47===s?(e.consume(s),a=!0,m):63===s?(e.consume(s),n=3,l.interrupt?t:O):xs(s)?(e.consume(s),i=String.fromCharCode(s),h):r(s)}function u(a){return 45===a?(e.consume(a),n=2,d):91===a?(e.consume(a),n=5,s=0,p):xs(a)?(e.consume(a),n=4,l.interrupt?t:O):r(a)}function d(n){return 45===n?(e.consume(n),l.interrupt?t:O):r(n)}function p(n){let a="CDATA[";return n===a.charCodeAt(s++)?(e.consume(n),s===a.length)?l.interrupt?t:S:p:r(n)}function m(t){return xs(t)?(e.consume(t),i=String.fromCharCode(t),h):r(t)}function h(s){if(null===s||47===s||62===s||xh(s)){let o=47===s,c=i.toLowerCase();return!o&&!a&&x2.includes(c)?(n=1,l.interrupt?t(s):S(s)):x1.includes(i.toLowerCase())?(n=6,o)?(e.consume(s),f):l.interrupt?t(s):S(s):(n=7,l.interrupt&&!l.parser.lazy[l.now().line]?r(s):a?function t(r){return xf(r)?(e.consume(r),t):x(r)}(s):g(s))}return 45===s||xo(s)?(e.consume(s),i+=String.fromCharCode(s),h):r(s)}function f(n){return 62===n?(e.consume(n),l.interrupt?t:S):r(n)}function g(t){return 47===t?(e.consume(t),x):58===t||95===t||xs(t)?(e.consume(t),b):xf(t)?(e.consume(t),g):x(t)}function b(t){return 45===t||46===t||58===t||95===t||xo(t)?(e.consume(t),b):y(t)}function y(t){return 61===t?(e.consume(t),E):xf(t)?(e.consume(t),y):g(t)}function E(t){return null===t||60===t||61===t||62===t||96===t?r(t):34===t||39===t?(e.consume(t),o=t,_):xf(t)?(e.consume(t),E):function t(r){return null===r||34===r||39===r||47===r||60===r||61===r||62===r||96===r||xh(r)?y(r):(e.consume(r),t)}(t)}function _(t){return t===o?(e.consume(t),o=null,v):null===t||xm(t)?r(t):(e.consume(t),_)}function v(e){return 47===e||62===e||xf(e)?g(e):r(e)}function x(t){return 62===t?(e.consume(t),T):r(t)}function T(t){return null===t||xm(t)?S(t):xf(t)?(e.consume(t),T):r(t)}function S(t){return 45===t&&2===n?(e.consume(t),N):60===t&&1===n?(e.consume(t),I):62===t&&4===n?(e.consume(t),L):63===t&&3===n?(e.consume(t),O):93===t&&5===n?(e.consume(t),R):xm(t)&&(6===n||7===n)?(e.exit("htmlFlowData"),e.check(x4,D,w)(t)):null===t||xm(t)?(e.exit("htmlFlowData"),w(t)):(e.consume(t),S)}function w(t){return e.check(x3,k,D)(t)}function k(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),A}function A(t){return null===t||xm(t)?w(t):(e.enter("htmlFlowData"),S(t))}function N(t){return 45===t?(e.consume(t),O):S(t)}function I(t){return 47===t?(e.consume(t),i="",C):S(t)}function C(t){if(62===t){let r=i.toLowerCase();return x2.includes(r)?(e.consume(t),L):S(t)}return xs(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),C):S(t)}function R(t){return 93===t?(e.consume(t),O):S(t)}function O(t){return 62===t?(e.consume(t),L):45===t&&2===n?(e.consume(t),O):S(t)}function L(t){return null===t||xm(t)?(e.exit("htmlFlowData"),D(t)):(e.consume(t),L)}function D(r){return e.exit("htmlFlow"),t(r)}}},61:Ts,95:Tr,96:xV,126:xV},"flowInitial",0,{[-2]:xW,[-1]:xW,32:xW},"insideSpan",0,{null:[xF,xC]},"string",0,{38:xG,92:x$},"text",0,{[-5]:Tt,[-4]:Tt,[-3]:Tt,33:x7,38:xG,42:xF,60:[{name:"autolink",tokenize:function(e,t,r){let n=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a};function a(t){return xs(t)?(e.consume(t),i):64===t?r(t):o(t)}function i(t){return 43===t||45===t||46===t||xo(t)?(n=1,function t(r){return 58===r?(e.consume(r),n=0,s):(43===r||45===r||46===r||xo(r))&&n++<32?(e.consume(r),t):(n=0,o(r))}(t)):o(t)}function s(n){return 62===n?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):null===n||32===n||60===n||xc(n)?r(n):(e.consume(n),s)}function o(t){return 64===t?(e.consume(t),l):xl(t)?(e.consume(t),o):r(t)}function l(a){return xo(a)?function a(i){return 46===i?(e.consume(i),n=0,l):62===i?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(i){if((45===i||xo(i))&&n++<63){let r=45===i?t:a;return e.consume(i),r}return r(i)}(i)}(a):r(a)}}},{name:"htmlText",tokenize:function(e,t,r){let n,a,i,s=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),o};function o(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),_):63===t?(e.consume(t),y):xs(t)?(e.consume(t),x):r(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),a=0,m):xs(t)?(e.consume(t),b):r(t)}function c(t){return 45===t?(e.consume(t),p):r(t)}function u(t){return null===t?r(t):45===t?(e.consume(t),d):xm(t)?(i=u,C(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),p):u(t)}function p(e){return 62===e?I(e):45===e?d(e):u(e)}function m(t){let n="CDATA[";return t===n.charCodeAt(a++)?(e.consume(t),a===n.length?h:m):r(t)}function h(t){return null===t?r(t):93===t?(e.consume(t),f):xm(t)?(i=h,C(t)):(e.consume(t),h)}function f(t){return 93===t?(e.consume(t),g):h(t)}function g(t){return 62===t?I(t):93===t?(e.consume(t),g):h(t)}function b(t){return null===t||62===t?I(t):xm(t)?(i=b,C(t)):(e.consume(t),b)}function y(t){return null===t?r(t):63===t?(e.consume(t),E):xm(t)?(i=y,C(t)):(e.consume(t),y)}function E(e){return 62===e?I(e):y(e)}function _(t){return xs(t)?(e.consume(t),v):r(t)}function v(t){return 45===t||xo(t)?(e.consume(t),v):function t(r){return xm(r)?(i=t,C(r)):xf(r)?(e.consume(r),t):I(r)}(t)}function x(t){return 45===t||xo(t)?(e.consume(t),x):47===t||62===t||xh(t)?T(t):r(t)}function T(t){return 47===t?(e.consume(t),I):58===t||95===t||xs(t)?(e.consume(t),S):xm(t)?(i=T,C(t)):xf(t)?(e.consume(t),T):I(t)}function S(t){return 45===t||46===t||58===t||95===t||xo(t)?(e.consume(t),S):function t(r){return 61===r?(e.consume(r),w):xm(r)?(i=t,C(r)):xf(r)?(e.consume(r),t):T(r)}(t)}function w(t){return null===t||60===t||61===t||62===t||96===t?r(t):34===t||39===t?(e.consume(t),n=t,k):xm(t)?(i=w,C(t)):xf(t)?(e.consume(t),w):(e.consume(t),A)}function k(t){return t===n?(e.consume(t),n=void 0,N):null===t?r(t):xm(t)?(i=k,C(t)):(e.consume(t),k)}function A(t){return null===t||34===t||39===t||60===t||61===t||96===t?r(t):47===t||62===t||xh(t)?T(t):(e.consume(t),A)}function N(e){return 47===e||62===e||xh(e)?T(e):r(e)}function I(n){return 62===n?(e.consume(n),e.exit("htmlTextData"),e.exit("htmlText"),t):r(n)}function C(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return xf(t)?xE(e,O,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):O(t)}function O(t){return e.enter("htmlTextData"),i(t)}}}],91:Te,92:[{name:"hardBreakEscape",tokenize:function(e,t,r){return function(t){return e.enter("hardBreakEscape"),e.consume(t),n};function n(n){return xm(n)?(e.exit("hardBreakEscape"),t(n)):r(n)}}},x$],93:x5,95:xF,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,r,n=e.length-4,a=3;if(("lineEnding"===e[3][1].type||"space"===e[a][1].type)&&("lineEnding"===e[n][1].type||"space"===e[n][1].type)){for(t=a;++t<n;)if("codeTextData"===e[t][1].type){e[a][1].type="codeTextPadding",e[n][1].type="codeTextPadding",a+=2,n-=2;break}}for(t=a-1,n++;++t<=n;)void 0===r?t!==n&&"lineEnding"!==e[t][1].type&&(r=t):(t===n||"lineEnding"===e[t][1].type)&&(e[r][1].type="codeTextData",t!==r+2&&(e[r][1].end=e[t-1][1].end,e.splice(r+2,t-r-2),n-=t-r-2,t=r+2),r=void 0);return e},tokenize:function(e,t,r){let n,a,i=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(r){return 96===r?(e.consume(r),i++,t):(e.exit("codeTextSequence"),s(r))}(t)};function s(l){return null===l?r(l):32===l?(e.enter("space"),e.consume(l),e.exit("space"),s):96===l?(a=e.enter("codeTextSequence"),n=0,function r(s){return 96===s?(e.consume(s),n++,r):n===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(s)):(a.type="codeTextData",o(s))}(l)):xm(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),s):(e.enter("codeTextData"),o(l))}function o(t){return null===t||32===t||96===t||xm(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),o)}}}}],304127);var To=e.i(304127);let Tl=/[\0\t\n\r]/g;function Tc(e,t){let r=Number.parseInt(e,t);return r<9||11===r||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(65535&r)==65535||(65535&r)==65534||r>1114111?"�":String.fromCodePoint(r)}let Tu=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Td(e,t,r){if(t)return t;if(35===r.charCodeAt(0)){let e=r.charCodeAt(1),t=120===e||88===e;return Tc(r.slice(t?2:1),t?16:10)}return xH(r)||e}let Tp={}.hasOwnProperty;function Tm(e){return{line:e.line,column:e.column,offset:e.offset}}function Th(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+vH({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+vH({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+vH({start:t.start,end:t.end})+") is still open")}function Tf(e){let t=this;t.parser=function(r){var n,a;let i,s,o,l;return"object"==typeof(n={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(a=n,n=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:n(b),autolinkProtocol:c,autolinkEmail:c,atxHeading:n(h),blockQuote:n(function(){return{type:"blockquote",children:[]}}),characterEscape:c,characterReference:c,codeFenced:n(m),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:n(m,a),codeText:n(function(){return{type:"inlineCode",value:""}},a),codeTextData:c,data:c,codeFlowValue:c,definition:n(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:n(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:n(f),hardBreakTrailing:n(f),htmlFlow:n(g,a),htmlFlowData:c,htmlText:n(g,a),htmlTextData:c,image:n(function(){return{type:"image",title:null,url:"",alt:null}}),label:a,link:n(b),listItem:n(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:n(y,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:n(y),paragraph:n(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:n(h),strong:n(function(){return{type:"strong",children:[]}}),thematicBreak:n(function(){return{type:"thematicBreak"}})},exit:{atxHeading:s(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:s(),autolinkEmail:function(e){u.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){u.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:s(),characterEscapeValue:u,characterReferenceMarkerHexadecimal:p,characterReferenceMarkerNumeric:p,characterReferenceValue:function(e){let t,r=this.sliceSerialize(e),n=this.data.characterReferenceType;n?(t=Tc(r,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0):t=xH(r);let a=this.stack[this.stack.length-1];a.value+=t},characterReference:function(e){this.stack.pop().position.end=Tm(e.end)},codeFenced:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:u,codeIndented:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:u,data:u,definition:s(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),r=this.stack[this.stack.length-1];r.label=t,r.identifier=xJ(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:s(),hardBreakEscape:s(d),hardBreakTrailing:s(d),htmlFlow:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:u,htmlText:s(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:u,image:s(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),r=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===r.type?r.children=e.children:r.alt=t},labelText:function(e){let t=this.sliceSerialize(e),r=this.stack[this.stack.length-2];r.label=t.replace(Tu,Td),r.identifier=xJ(t).toLowerCase()},lineEnding:function(e){let r=this.stack[this.stack.length-1];if(this.data.atHardBreak){r.children[r.children.length-1].position.end=Tm(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(r.type)&&(c.call(this,e),u.call(this,e))},link:s(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:function(e){let t=this.resume(),r=this.stack[this.stack.length-1];r.label=t,r.identifier=xJ(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:s(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:s(),thematicBreak:s()}};!function e(t,r){let n=-1;for(;++n<r.length;){let a=r[n];Array.isArray(a)?e(t,a):function(e,t){let r;for(r in t)if(Tp.call(t,r))switch(r){case"canContainEols":{let n=t[r];n&&e[r].push(...n);break}case"transforms":{let n=t[r];n&&e[r].push(...n);break}case"enter":case"exit":{let n=t[r];n&&Object.assign(e[r],n)}}}(t,a)}}(t,(e||{}).mdastExtensions||[]);let r={};return function(e){let n={type:"root",children:[]},s={stack:[n],tokenStack:[],config:t,enter:i,exit:o,buffer:a,resume:l,data:r},c=[],u=-1;for(;++u<e.length;)("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)&&("enter"===e[u][0]?c.push(u):u=function(e,t,r){let n,a,i,s,o=t-1,l=-1,c=!1;for(;++o<=r;){let t=e[o];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,s=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!n||s||l||i||(i=o),s=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:s=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(n){let s=o;for(a=void 0;s--;){let t=e[s];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;a&&(e[a][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",a=s}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}i&&(!a||i<a)&&(n._spread=!0),n.end=Object.assign({},a?e[a][1].start:t[1].end),e.splice(a||o,0,["exit",n,t[2]]),o++,r++}if("listItemPrefix"===t[1].type){let a={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};n=a,e.splice(o,0,["enter",a,t[2]]),o++,r++,i=void 0,s=!0}}}return e[t][1]._spread=c,r}(e,c.pop(),u));for(u=-1;++u<e.length;){let r=t[e[u][0]];Tp.call(r,e[u][1].type)&&r[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},s),e[u][1])}if(s.tokenStack.length>0){let e=s.tokenStack[s.tokenStack.length-1];(e[1]||Th).call(s,void 0,e[0])}for(n.position={start:Tm(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Tm(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)n=t.transforms[u](n)||n;return n};function n(e,t){return function(r){i.call(this,e(r),r),t&&t.call(this,r)}}function a(){this.stack.push({type:"fragment",children:[]})}function i(e,t,r){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,r||void 0]),e.position={start:Tm(t.start),end:void 0}}function s(e){return function(t){e&&e.call(this,t),o.call(this,t)}}function o(e,t){let r=this.stack.pop(),n=this.tokenStack.pop();if(n)n[0].type!==e.type&&(t?t.call(this,e,n[0]):(n[1]||Th).call(this,e,n[0]));else throw Error("Cannot close `"+e.type+"` ("+vH({start:e.start,end:e.end})+"): it’s not open");r.position.end=Tm(e.end)}function l(){return v7(this.stack.pop())}function c(e){let t=this.stack[this.stack.length-1].children,r=t[t.length-1];r&&"text"===r.type||((r={type:"text",value:""}).position={start:Tm(e.start),end:void 0},t.push(r)),this.stack.push(r)}function u(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Tm(e.end)}function d(){this.data.atHardBreak=!0}function p(e){this.data.characterReferenceType=e.type}function m(){return{type:"code",lang:null,meta:null,value:""}}function h(){return{type:"heading",depth:0,children:[]}}function f(){return{type:"break"}}function g(){return{type:"html",value:""}}function b(){return{type:"link",title:null,url:"",children:[]}}function y(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(a)(function(e){for(;!xk(e););return e}((function(e){let t={constructs:xi([To,...(e||{}).extensions||[]]),content:r(x_),defined:[],document:r(xv),flow:r(xI),lazy:{},string:r(xR),text:r(xO)};return t;function r(e){return function(r){return function(e,t,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},a={},i=[],s=[],o=[],l={attempt:h(function(e,t){f(e,t.from)}),check:h(m),consume:function(e){xm(e)?(n.line++,n.column=1,n.offset+=-3===e?2:1,g()):-1!==e&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===s[n._index].length&&(n._bufferIndex=-1,n._index++)),c.previous=e},enter:function(e,t){let r=t||{};return r.type=e,r.start=p(),c.events.push(["enter",r,c]),o.push(r),r},exit:function(e){let t=o.pop();return t.end=p(),c.events.push(["exit",t,c]),t},interrupt:h(m,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){a[e.line]=e.column,g()},events:[],now:p,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let r,n=-1,a=[];for(;++n<e.length;){let i,s=e[n];if("string"==typeof s)i=s;else switch(s){case -5:i="\r";break;case -4:i="\n";break;case -3:i="\r\n";break;case -2:i=t?" ":" ";break;case -1:if(!t&&r)continue;i=" ";break;default:i=String.fromCharCode(s)}r=-2===s,a.push(i)}return a.join("")}(d(e),t)},sliceStream:d,write:function(e){return(s=xn(s,e),function(){let e;for(;n._index<s.length;){let r=s[n._index];if("string"==typeof r)for(e=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===e&&n._bufferIndex<r.length;){var t;t=r.charCodeAt(n._bufferIndex),u=u(t)}else u=u(r)}}(),null!==s[s.length-1])?[]:(f(t,0),c.events=xj(i,c.events,c),c.events)}},u=t.tokenize.call(c,l);return t.resolveAll&&i.push(t),c;function d(e){return function(e,t){let r,n=t.start._index,a=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;if(n===i)r=[e[n].slice(a,s)];else{if(r=e.slice(n,i),a>-1){let e=r[0];"string"==typeof e?r[0]=e.slice(a):r.shift()}s>0&&r.push(e[i].slice(0,s))}return r}(s,e)}function p(){let{_bufferIndex:e,_index:t,line:r,column:a,offset:i}=n;return{_bufferIndex:e,_index:t,line:r,column:a,offset:i}}function m(e,t){t.restore()}function h(e,t){return function(r,a,i){var s;let u,d,m,h;return Array.isArray(r)?f(r):"tokenize"in r?f([r]):(s=r,function(e){let t=null!==e&&s[e],r=null!==e&&s.null;return f([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(r)?r:r?[r]:[]])(e)});function f(e){return(u=e,d=0,0===e.length)?i:b(e[d])}function b(e){return function(r){let a,i,s,u,d;return(a=p(),i=c.previous,s=c.currentConstruct,u=c.events.length,d=Array.from(o),h={from:u,restore:function(){n=a,c.previous=i,c.currentConstruct=s,c.events.length=u,o=d,g()}},m=e,e.partial||(c.currentConstruct=e),e.name&&c.parser.constructs.disable.null.includes(e.name))?E(r):e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,y,E)(r)}}function y(t){return e(m,h),a}function E(e){return(h.restore(),++d<u.length)?b(u[d]):i}}}function f(e,t){e.resolveAll&&!i.includes(e)&&i.push(e),e.resolve&&xr(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function g(){n.line in a&&n.column<2&&(n.column=a[n.line],n.offset+=a[n.line]-1)}}(t,e,r)}}})(a).document().write((s=1,o="",l=!0,function(e,t,r){let n,a,c,u,d,p=[];for(e=o+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),c=0,o="",l&&(65279===e.charCodeAt(0)&&c++,l=void 0);c<e.length;){if(Tl.lastIndex=c,u=(n=Tl.exec(e))&&void 0!==n.index?n.index:e.length,d=e.charCodeAt(u),!n){o=e.slice(c);break}if(10===d&&c===u&&i)p.push(-3),i=void 0;else switch(i&&(p.push(-5),i=void 0),c<u&&(p.push(e.slice(c,u)),s+=u-c),d){case 0:p.push(65533),s++;break;case 9:for(a=4*Math.ceil(s/4),p.push(-2);s++<a;)p.push(-1);break;case 10:p.push(-4),s=1;break;default:i=!0,s=1}c=u+1}return r&&(i&&p.push(-5),o&&p.push(o),p.push(null)),p})(r,n,!0))))}}let Tg="object"==typeof self?self:globalThis,Tb=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw TypeError("unable to deserialize "+e)}return new Tg[e](t)},Ty=e=>{var t;let r,n;return(t=new Map,r=(e,r)=>(t.set(r,e),e),n=a=>{if(t.has(a))return t.get(a);let[i,s]=e[a];switch(i){case 0:case -1:return r(s,a);case 1:{let e=r([],a);for(let t of s)e.push(n(t));return e}case 2:{let e=r({},a);for(let[t,r]of s)e[n(t)]=n(r);return e}case 3:return r(new Date(s),a);case 4:{let{source:e,flags:t}=s;return r(new RegExp(e,t),a)}case 5:{let e=r(new Map,a);for(let[t,r]of s)e.set(n(t),n(r));return e}case 6:{let e=r(new Set,a);for(let t of s)e.add(n(t));return e}case 7:{let{name:e,message:t}=s;return r(Tb(e,t),a)}case 8:return r(BigInt(s),a);case"BigInt":return r(Object(BigInt(s)),a);case"ArrayBuffer":return r(new Uint8Array(s).buffer,s);case"DataView":{let{buffer:e}=new Uint8Array(s);return r(new DataView(e),s)}}return r(Tb(i,s),a)})(0)},{toString:TE}={},{keys:T_}=Object,Tv=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let r=TE.call(e).slice(8,-1);switch(r){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""];case"DataView":return[1,r]}return r.includes("Array")?[1,r]:r.includes("Error")?[7,r]:[2,r]},Tx=([e,t])=>0===e&&("function"===t||"symbol"===t),TT=(e,{json:t,lossy:r}={})=>{var n,a,i;let s,o,l=[];return(n=!(t||r),a=!!t,i=new Map,s=(e,t)=>{let r=l.push(e)-1;return i.set(t,r),r},o=e=>{if(i.has(e))return i.get(e);let[t,r]=Tv(e);switch(t){case 0:{let a=e;switch(r){case"bigint":t=8,a=e.toString();break;case"function":case"symbol":if(n)throw TypeError("unable to serialize "+r);a=null;break;case"undefined":return s([-1],e)}return s([t,a],e)}case 1:{if(r){let t=e;return"DataView"===r?t=new Uint8Array(e.buffer):"ArrayBuffer"===r&&(t=new Uint8Array(e)),s([r,[...t]],e)}let n=[],a=s([t,n],e);for(let t of e)n.push(o(t));return a}case 2:{if(r)switch(r){case"BigInt":return s([r,e.toString()],e);case"Boolean":case"Number":case"String":return s([r,e.valueOf()],e)}if(a&&"toJSON"in e)return o(e.toJSON());let i=[],l=s([t,i],e);for(let t of T_(e))(n||!Tx(Tv(e[t])))&&i.push([o(t),o(e[t])]);return l}case 3:return s([t,e.toISOString()],e);case 4:{let{source:r,flags:n}=e;return s([t,{source:r,flags:n}],e)}case 5:{let r=[],a=s([t,r],e);for(let[t,a]of e)(n||!(Tx(Tv(t))||Tx(Tv(a))))&&r.push([o(t),o(a)]);return a}case 6:{let r=[],a=s([t,r],e);for(let t of e)(n||!Tx(Tv(t)))&&r.push(o(t));return a}}let{message:l}=e;return s([t,{name:r,message:l}],e)})(e),l},TS="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Ty(TT(e,t)):structuredClone(e):(e,t)=>Ty(TT(e,t));function Tw(e){let t=[],r=-1,n=0,a=0;for(;++r<e.length;){let i=e.charCodeAt(r),s="";if(37===i&&xo(e.charCodeAt(r+1))&&xo(e.charCodeAt(r+2)))a=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(s=String.fromCharCode(i));else if(i>55295&&i<57344){let t=e.charCodeAt(r+1);i<56320&&t>56319&&t<57344?(s=String.fromCharCode(i,t),a=1):s="�"}else s=String.fromCharCode(i);s&&(t.push(e.slice(n,r),encodeURIComponent(s)),n=r+a+1,s=""),a&&(r+=a,a=0)}return t.join("")+e.slice(n)}function Tk(e,t){let r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function TA(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let TN=function(e){var t,r;if(null==e)return TC;if("function"==typeof e)return TI(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],r=-1;for(;++r<e.length;)t[r]=TN(e[r]);return TI(function(...e){let r=-1;for(;++r<t.length;)if(t[r].apply(this,e))return!0;return!1})}(e):(t=e,TI(function(e){let r;for(r in t)if(e[r]!==t[r])return!1;return!0}))}if("string"==typeof e){return r=e,TI(function(e){return e&&e.type===r})}throw Error("Expected function, string, or object as test")};function TI(e){return function(t,r,n){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof r?r:void 0,n||void 0))}}function TC(){return!0}let TR=[],TO="skip";function TL(e,t,r,n){let a;"function"==typeof t&&"function"!=typeof r?(n=r,r=t):a=t;let i=TN(a),s=n?-1:1;(function e(a,o,l){let c=a&&"object"==typeof a?a:{};if("string"==typeof c.type){let e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(u,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return u;function u(){var c;let u,d,p,m=TR;if((!t||i(a,o,l[l.length-1]||void 0))&&!1===(m=Array.isArray(c=r(a,l))?c:"number"==typeof c?[!0,c]:null==c?TR:[c])[0])return m;if("children"in a&&a.children&&a.children&&m[0]!==TO)for(d=(n?a.children.length:-1)+s,p=l.concat(a);d>-1&&d<a.children.length;){if(!1===(u=e(a.children[d],d,p)())[0])return u;d="number"==typeof u[1]?u[1]:d+s}return m}})(e,void 0,[])()}function TD(e,t,r,n){let a,i,s;"function"==typeof t&&"function"!=typeof r?(i=void 0,s=t,a=r):(i=t,s=r,a=n),TL(e,i,function(e,t){let r=t[t.length-1],n=r?r.children.indexOf(e):void 0;return s(e,n,r)},a)}function TP(e,t){let r=t.referenceType,n="]";if("collapsed"===r?n+="[]":"full"===r&&(n+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+n}];let a=e.all(t),i=a[0];i&&"text"===i.type?i.value="["+i.value:a.unshift({type:"text",value:"["});let s=a[a.length-1];return s&&"text"===s.type?s.value+=n:a.push({type:"text",value:n}),a}function TM(e){let t=e.spread;return null==t?e.children.length>1:t}function Tj(e,t,r){let n=0,a=e.length;if(t){let t=e.codePointAt(n);for(;9===t||32===t;)n++,t=e.codePointAt(n)}if(r){let t=e.codePointAt(a-1);for(;9===t||32===t;)a--,t=e.codePointAt(a-1)}return a>n?e.slice(n,a):""}let TF={blockquote:function(e,t){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)},break:function(e,t){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:"\n"}]},code:function(e,t){let r=t.value?t.value+"\n":"",n={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(n.className=["language-"+a[0]]);let i={type:"element",tagName:"code",properties:n,children:[{type:"text",value:r}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i={type:"element",tagName:"pre",properties:{},children:[i=e.applyData(t,i)]},e.patch(t,i),i},delete:function(e,t){let r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},emphasis:function(e,t){let r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},footnoteReference:function(e,t){let r,n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",a=String(t.identifier).toUpperCase(),i=Tw(a.toLowerCase()),s=e.footnoteOrder.indexOf(a),o=e.footnoteCounts.get(a);void 0===o?(o=0,e.footnoteOrder.push(a),r=e.footnoteOrder.length):r=s+1,o+=1,e.footnoteCounts.set(a,o);let l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(t,l);let c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){let r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},html:function(e,t){if(e.options.allowDangerousHtml){let r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}},imageReference:function(e,t){let r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return TP(e,t);let a={src:Tw(n.url||""),alt:t.alt};null!==n.title&&void 0!==n.title&&(a.title=n.title);let i={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,i),e.applyData(t,i)},image:function(e,t){let r={src:Tw(t.url)};null!==t.alt&&void 0!==t.alt&&(r.alt=t.alt),null!==t.title&&void 0!==t.title&&(r.title=t.title);let n={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,n),e.applyData(t,n)},inlineCode:function(e,t){let r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);let n={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,n),e.applyData(t,n)},linkReference:function(e,t){let r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return TP(e,t);let a={href:Tw(n.url||"")};null!==n.title&&void 0!==n.title&&(a.title=n.title);let i={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},link:function(e,t){let r={href:Tw(t.url)};null!==t.title&&void 0!==t.title&&(r.title=t.title);let n={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},listItem:function(e,t,r){let n=e.all(t),a=r?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let r=e.children,n=-1;for(;!t&&++n<r.length;)t=TM(r[n])}return t}(r):TM(t),i={},s=[];if("boolean"==typeof t.checked){let e,r=n[0];r&&"element"===r.type&&"p"===r.tagName?e=r:(e={type:"element",tagName:"p",properties:{},children:[]},n.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let o=-1;for(;++o<n.length;){let e=n[o];(a||0!==o||"element"!==e.type||"p"!==e.tagName)&&s.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||a?s.push(e):s.push(...e.children)}let l=n[n.length-1];l&&(a||"element"!==l.type||"p"!==l.tagName)&&s.push({type:"text",value:"\n"});let c={type:"element",tagName:"li",properties:i,children:s};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){let r={},n=e.all(t),a=-1;for("number"==typeof t.start&&1!==t.start&&(r.start=t.start);++a<n.length;){let e=n[a];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}let i={type:"element",tagName:t.ordered?"ol":"ul",properties:r,children:e.wrap(n,!0)};return e.patch(t,i),e.applyData(t,i)},paragraph:function(e,t){let r={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},root:function(e,t){let r={type:"root",children:e.wrap(e.all(t))};return e.patch(t,r),e.applyData(t,r)},strong:function(e,t){let r={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},table:function(e,t){let r=e.all(t),n=r.shift(),a=[];if(n){let r={type:"element",tagName:"thead",properties:{},children:e.wrap([n],!0)};e.patch(t.children[0],r),a.push(r)}if(r.length>0){let n={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},i=vB(t.children[1]),s=vU(t.children[t.children.length-1]);i&&s&&(n.position={start:i,end:s}),a.push(n)}let i={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,i),e.applyData(t,i)},tableCell:function(e,t){let r={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},tableRow:function(e,t,r){let n=r?r.children:void 0,a=0===(n?n.indexOf(t):1)?"th":"td",i=r&&"table"===r.type?r.align:void 0,s=i?i.length:t.children.length,o=-1,l=[];for(;++o<s;){let r=t.children[o],n={},s=i?i[o]:void 0;s&&(n.align=s);let c={type:"element",tagName:a,properties:n,children:[]};r&&(c.children=e.all(r),e.patch(r,c),c=e.applyData(r,c)),l.push(c)}let c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){let r={type:"text",value:function(e){let t=String(e),r=/\r?\n|\r/g,n=r.exec(t),a=0,i=[];for(;n;)i.push(Tj(t.slice(a,n.index),a>0,!0),n[0]),a=n.index+n[0].length,n=r.exec(t);return i.push(Tj(t.slice(a),a>0,!1)),i.join("")}(String(t.value))};return e.patch(t,r),e.applyData(t,r)},thematicBreak:function(e,t){let r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)},toml:TU,yaml:TU,definition:TU,footnoteDefinition:TU};function TU(){}let TB={}.hasOwnProperty,T$={};function Tz(e,t){e.position&&(t.position=vz(e))}function TH(e,t){let r=t;if(e&&e.data){let t=e.data.hName,n=e.data.hChildren,a=e.data.hProperties;"string"==typeof t&&("element"===r.type?r.tagName=t:r={type:"element",tagName:t,properties:{},children:"children"in r?r.children:[r]}),"element"===r.type&&a&&Object.assign(r.properties,TS(a)),"children"in r&&r.children&&null!=n&&(r.children=n)}return r}function TG(e,t){let r=[],n=-1;for(t&&r.push({type:"text",value:"\n"});++n<e.length;)n&&r.push({type:"text",value:"\n"}),r.push(e[n]);return t&&e.length>0&&r.push({type:"text",value:"\n"}),r}function Tq(e){let t=0,r=e.charCodeAt(t);for(;9===r||32===r;)t++,r=e.charCodeAt(t);return e.slice(t)}function TV(e,t){let r,n,a,i,s=(r=t||T$,n=new Map,a=new Map,i={all:function(e){let t=[];if("children"in e){let r=e.children,n=-1;for(;++n<r.length;){let a=i.one(r[n],e);if(a){if(n&&"break"===r[n-1].type&&(Array.isArray(a)||"text"!==a.type||(a.value=Tq(a.value)),!Array.isArray(a)&&"element"===a.type)){let e=a.children[0];e&&"text"===e.type&&(e.value=Tq(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:TH,definitionById:n,footnoteById:a,footnoteCounts:new Map,footnoteOrder:[],handlers:{...TF,...r.handlers},one:function(e,t){let r=e.type,n=i.handlers[r];if(TB.call(i.handlers,r)&&n)return n(i,e,t);if(i.options.passThrough&&i.options.passThrough.includes(r)){if("children"in e){let{children:t,...r}=e,n=TS(r);return n.children=i.all(e),n}return TS(e)}return(i.options.unknownHandler||function(e,t){let r=t.data||{},n="value"in t&&!(TB.call(r,"hProperties")||TB.call(r,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)})(i,e,t)},options:r,patch:Tz,wrap:TG},TD(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?n:a,r=String(e.identifier).toUpperCase();t.has(r)||t.set(r,e)}}),i),o=s.one(e,void 0),l=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||Tk,n=e.options.footnoteBackLabel||TA,a=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",s=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[],l=-1;for(;++l<e.footnoteOrder.length;){let a=e.footnoteById.get(e.footnoteOrder[l]);if(!a)continue;let i=e.all(a),s=String(a.identifier).toUpperCase(),c=Tw(s.toLowerCase()),u=0,d=[],p=e.footnoteCounts.get(s);for(;void 0!==p&&++u<=p;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof r?r:r(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof n?n:n(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let m=i[i.length-1];if(m&&"element"===m.type&&"p"===m.tagName){let e=m.children[m.children.length-1];e&&"text"===e.type?e.value+=" ":m.children.push({type:"text",value:" "}),m.children.push(...d)}else i.push(...d);let h={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(i,!0)};e.patch(a,h),o.push(h)}if(0!==o.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...TS(s),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:"\n"}]}}(s),c=Array.isArray(o)?{type:"root",children:o}:o||{type:"root",children:[]};return l&&(_2("children"in c),c.children.push({type:"text",value:"\n"},l)),c}function TW(e,t){return e&&"run"in e?async function(r,n){let a=TV(r,{file:n,...t});await e.run(a,n)}:function(r,n){return TV(r,{file:n,...e||t})}}function TY(e){if(e)throw e}var TK=e.i(104100);function TZ(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let TX=function(e,t){let r;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');T1(e);let n=0,a=-1,i=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;i--;)if(47===e.codePointAt(i)){if(r){n=i+1;break}}else a<0&&(r=!0,a=i+1);return a<0?"":e.slice(n,a)}if(t===e)return"";let s=-1,o=t.length-1;for(;i--;)if(47===e.codePointAt(i)){if(r){n=i+1;break}}else s<0&&(r=!0,s=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(a=i):(o=-1,a=s));return n===a?a=s:a<0&&(a=e.length),e.slice(n,a)},TQ=function(e){let t;if(T1(e),0===e.length)return".";let r=-1,n=e.length;for(;--n;)if(47===e.codePointAt(n)){if(t){r=n;break}}else t||(t=!0);return r<0?47===e.codePointAt(0)?"/":".":1===r&&47===e.codePointAt(0)?"//":e.slice(0,r)},TJ=function(e){let t;T1(e);let r=e.length,n=-1,a=0,i=-1,s=0;for(;r--;){let o=e.codePointAt(r);if(47===o){if(t){a=r+1;break}continue}n<0&&(t=!0,n=r+1),46===o?i<0?i=r:1!==s&&(s=1):i>-1&&(s=-1)}return i<0||n<0||0===s||1===s&&i===n-1&&i===a+1?"":e.slice(i,n)},T0=function(...e){var t;let r,n,a,i=-1;for(;++i<e.length;)T1(e[i]),e[i]&&(a=void 0===a?e[i]:a+"/"+e[i]);return void 0===a?".":(T1(t=a),r=47===t.codePointAt(0),0!==(n=function(e,t){let r,n,a="",i=0,s=-1,o=0,l=-1;for(;++l<=e.length;){if(l<e.length)r=e.codePointAt(l);else if(47===r)break;else r=47;if(47===r){if(s===l-1||1===o);else if(s!==l-1&&2===o){if(a.length<2||2!==i||46!==a.codePointAt(a.length-1)||46!==a.codePointAt(a.length-2)){if(a.length>2){if((n=a.lastIndexOf("/"))!==a.length-1){n<0?(a="",i=0):i=(a=a.slice(0,n)).length-1-a.lastIndexOf("/"),s=l,o=0;continue}}else if(a.length>0){a="",i=0,s=l,o=0;continue}}t&&(a=a.length>0?a+"/..":"..",i=2)}else a.length>0?a+="/"+e.slice(s+1,l):a=e.slice(s+1,l),i=l-s-1;s=l,o=0}else 46===r&&o>-1?o++:o=-1}return a}(t,!r)).length||r||(n="."),n.length>0&&47===t.codePointAt(t.length-1)&&(n+="/"),r?"/"+n:n)};function T1(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function T2(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let T4=["history","path","basename","stem","extname","dirname"];class T3{constructor(e){let t,r;t=e?T2(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<T4.length;){const e=T4[n];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(r in t)T4.includes(r)||(this[r]=t[r])}get basename(){return"string"==typeof this.path?TX(this.path):void 0}set basename(e){T6(e,"basename"),T5(e,"basename"),this.path=T0(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?TQ(this.path):void 0}set dirname(e){T9(this.basename,"dirname"),this.path=T0(e||"",this.basename)}get extname(){return"string"==typeof this.path?TJ(this.path):void 0}set extname(e){if(T5(e,"extname"),T9(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=T0(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){T2(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!T2(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,r=-1;for(;++r<t.length;)if(37===t.codePointAt(r)&&50===t.codePointAt(r+1)){let e=t.codePointAt(r+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),T6(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?TX(this.path,this.extname):void 0}set stem(e){T6(e,"stem"),T5(e,"stem"),this.path=T0(this.dirname||"",e+(this.extname||""))}fail(e,t,r){let n=this.message(e,t,r);throw n.fatal=!0,n}info(e,t,r){let n=this.message(e,t,r);return n.fatal=void 0,n}message(e,t,r){let n=new vW(e,t,r);return this.path&&(n.name=this.path+":"+n.name,n.file=this.path),n.fatal=!1,this.messages.push(n),n}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function T5(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function T6(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function T9(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let T8=function(e){let t=this.constructor.prototype,r=t[e],n=function(){return r.apply(n,arguments)};return Object.setPrototypeOf(n,t),n},T7={}.hasOwnProperty;class Se extends T8{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=function(){let e=[],t={run:function(...t){let r=-1,n=t.pop();if("function"!=typeof n)throw TypeError("Expected function as last argument, not "+n);!function a(i,...s){let o=e[++r],l=-1;if(i)return void n(i);for(;++l<t.length;)(null===s[l]||void 0===s[l])&&(s[l]=t[l]);t=s,o?(function(e,t){let r;return function(...t){let i,s=e.length>t.length;s&&t.push(n);try{i=e.apply(this,t)}catch(e){if(s&&r)throw e;return n(e)}s||(i&&i.then&&"function"==typeof i.then?i.then(a,n):i instanceof Error?n(i):a(i))};function n(e,...a){r||(r=!0,t(e,...a))}function a(e){n(null,e)}})(o,a)(...s):n(null,...s)}(null,...t)},use:function(r){if("function"!=typeof r)throw TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}};return t}()}copy(){let e=new Se,t=-1;for(;++t<this.attachers.length;){let r=this.attachers[t];e.use(...r)}return e.data((0,TK.default)(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(Sa("data",this.frozen),this.namespace[e]=t,this):T7.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Sa("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let r=e.call(this,...t);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=So(e),r=this.parser||this.Parser;return Sr("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),Sr("process",this.parser||this.Parser),Sn("process",this.compiler||this.Compiler),t?n(void 0,t):new Promise(n);function n(n,a){let i=So(e),s=r.parse(i);function o(e,r){e||!r?a(e):n?n(r):(_2(t,"`done` is defined if `resolve` is not"),t(void 0,r))}r.run(s,i,function(e,t,n){var a,i;if(e||!t||!n)return o(e);let s=r.stringify(t,n);"string"==typeof(a=s)||(i=a)&&"object"==typeof i&&"byteLength"in i&&"byteOffset"in i?n.value=s:n.result=s,o(e,n)})}}processSync(e){let t,r=!1;return this.freeze(),Sr("processSync",this.parser||this.Parser),Sn("processSync",this.compiler||this.Compiler),this.process(e,function(e,n){r=!0,TY(e),t=n}),Ss("processSync","process",r),_2(t,"we either bailed on an error or have a tree"),t}run(e,t,r){Si(e),this.freeze();let n=this.transformers;return r||"function"!=typeof t||(r=t,t=void 0),r?a(void 0,r):new Promise(a);function a(a,i){_2("function"!=typeof t,"`file` can’t be a `done` anymore, we checked");let s=So(t);n.run(e,s,function(t,n,s){let o=n||e;t?i(t):a?a(o):(_2(r,"`done` is defined if `resolve` is not"),r(void 0,o,s))})}}runSync(e,t){let r,n=!1;return this.run(e,t,function(e,t){TY(e),r=t,n=!0}),Ss("runSync","run",n),_2(r,"we either bailed on an error or have a tree"),r}stringify(e,t){this.freeze();let r=So(t),n=this.compiler||this.Compiler;return Sn("stringify",n),Si(e),n(e,r)}use(e,...t){let r=this.attachers,n=this.namespace;if(Sa("use",this.frozen),null==e);else if("function"==typeof e)s(e,t);else if("object"==typeof e)Array.isArray(e)?i(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function a(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(n.settings=(0,TK.default)(!0,n.settings,e.settings))}function i(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)s(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...r]=e;s(t,r)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let n=-1,a=-1;for(;++n<r.length;)if(r[n][0]===e){a=n;break}if(-1===a)r.push([e,...t]);else if(t.length>0){let[n,...i]=t,s=r[a][1];TZ(s)&&TZ(n)&&(n=(0,TK.default)(!0,s,n)),r[a]=[e,n,...i]}}}}let St=new Se().freeze();function Sr(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function Sn(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function Sa(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Si(e){if(!TZ(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function Ss(e,t,r){if(!r)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function So(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new T3(e)}let Sl=[],Sc={allowDangerousHtml:!0},Su=/^(https?|ircs?|mailto|xmpp)$/i,Sd=[{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:"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 Sp(e){var t;let r,n,a,i,s,o=(r=(t=e).rehypePlugins||Sl,n=t.remarkPlugins||Sl,a=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...Sc}:Sc,St().use(Tf).use(n).use(TW,a).use(r)),l=(i=e.children||"",s=new T3,"string"==typeof i?s.value=i:_4("Unexpected value `"+i+"` for `children` prop, expected `string`"),s);return function(e,t){let r=t.allowedElements,n=t.allowElement,a=t.components,i=t.disallowedElements,s=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||Sm;for(let e of Sd)Object.hasOwn(t,e.from)&&_4("Unexpected `"+e.from+"` prop, "+(e.to?"use `"+e.to+"` instead":"remove it")+" (see <https://github.com/remarkjs/react-markdown/blob/main/changelog.md#"+e.id+"> for more info)");return r&&i&&_4("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other"),t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:"root"===e.type?e.children:[e]}),TD(e,function(e,t,a){if("raw"===e.type&&a&&"number"==typeof t)return s?a.children.splice(t,1):a.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in v9)if(Object.hasOwn(v9,t)&&Object.hasOwn(e.properties,t)){let r=e.properties[t],n=v9[t];(null===n||n.includes(e.tagName))&&(e.properties[t]=l(String(r||""),t,e))}}if("element"===e.type){let s=r?!r.includes(e.tagName):!!i&&i.includes(e.tagName);if(!s&&n&&"number"==typeof t&&(s=!n(e,t,a)),s&&a&&"number"==typeof t)return o&&e.children?a.children.splice(t,1,...e.children):a.children.splice(t,1),t}}),function(e,t){var r,n,a,i;let s;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let o=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=o,n=t.jsxDEV,s=function(e,t,a,i){let s=Array.isArray(a.children),o=vB(e);return n(t,a,i,s,{columnNumber:o?o.column-1:void 0,fileName:r,lineNumber:o?o.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");a=t.jsx,i=t.jsxs,s=function(e,t,r,n){let s=Array.isArray(r.children)?i:a;return n?s(t,r,n):s(t,r)}}let l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:o,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?vP:vD,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},c=v0(l,e,void 0);return c&&"string"!=typeof c?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}(e,{Fragment:eI.Fragment,components:a,ignoreInvalidStyle:!0,jsx:eI.jsx,jsxs:eI.jsxs,passKeys:!0,passNode:!0})}(o.runSync(o.parse(l),l),e)}function Sm(e){let t=e.indexOf(":"),r=e.indexOf("?"),n=e.indexOf("#"),a=e.indexOf("/");return -1===t||-1!==a&&t>a||-1!==r&&t>r||-1!==n&&t>n||Su.test(e.slice(0,t))?e:""}function Sh(e,t){let r=String(e);if("string"!=typeof t)throw TypeError("Expected character");let n=0,a=r.indexOf(t);for(;-1!==a;)n++,a=r.indexOf(t,a+t.length);return n}let Sf="phrasing",Sg=["autolink","link","image","label"];function Sb(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Sy(e){this.config.enter.autolinkProtocol.call(this,e)}function SE(e){this.config.exit.autolinkProtocol.call(this,e)}function S_(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];_2("link"===t.type),t.url="http://"+this.sliceSerialize(e)}function Sv(e){this.config.exit.autolinkEmail.call(this,e)}function Sx(e){this.exit(e)}function ST(e){!function(e,t,r){let n=TN((r||{}).ignore||[]),a=function(e){let t=[];if(!Array.isArray(e))throw TypeError("Expected find and replace tuple or list of tuples");let r=!e[0]||Array.isArray(e[0])?e:[e],n=-1;for(;++n<r.length;){var a;let e=r[n];t.push(["string"==typeof(a=e[0])?RegExp(function(e){if("string"!=typeof e)throw TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(a),"g"):a,function(e){return"function"==typeof e?e:function(){return e}}(e[1])])}return t}(t),i=-1;for(;++i<a.length;)TL(e,"text",s);function s(e,t){let r,s=-1;for(;++s<t.length;){let e=t[s],a=r?r.children:void 0;if(n(e,a?a.indexOf(e):void 0,r))return;r=e}if(r)return function(e,t){let r=t[t.length-1],n=a[i][0],s=a[i][1],o=0,l=r.children.indexOf(e),c=!1,u=[];n.lastIndex=0;let d=n.exec(e.value);for(;d;){let r=d.index,a={index:d.index,input:d.input,stack:[...t,e]},i=s(...d,a);if("string"==typeof i&&(i=i.length>0?{type:"text",value:i}:void 0),!1===i?n.lastIndex=r+1:(o!==r&&u.push({type:"text",value:e.value.slice(o,r)}),Array.isArray(i)?u.push(...i):i&&u.push(i),o=r+d[0].length,c=!0),!n.global)break;d=n.exec(e.value)}return c?(o<e.value.length&&u.push({type:"text",value:e.value.slice(o)}),r.children.splice(l,1,...u)):u=[e],l+u.length}(e,t)}}(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,SS],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Sw]],{ignore:["link","linkReference"]})}function SS(e,t,r,n,a){let i,s="";if(!Sk(a))return!1;if(/^w/i.test(t)&&(r=t+r,t="",s="http://"),(i=r.split(".")).length<2||i[i.length-1]&&(/_/.test(i[i.length-1])||!/[a-zA-Z\d]/.test(i[i.length-1]))||i[i.length-2]&&(/_/.test(i[i.length-2])||!/[a-zA-Z\d]/.test(i[i.length-2])))return!1;let o=function(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],n=r.indexOf(")"),a=Sh(e,"("),i=Sh(e,")");for(;-1!==n&&a>i;)e+=r.slice(0,n+1),n=(r=r.slice(n+1)).indexOf(")"),i++;return[e,r]}(r+n);if(!o[0])return!1;let l={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[l,{type:"text",value:o[1]}]:l}function Sw(e,t,r,n){return!(!Sk(n,!0)||/[-\d_]$/.test(r))&&{type:"link",title:null,url:"mailto:"+t+"@"+r,children:[{type:"text",value:t+"@"+r}]}}function Sk(e,t){let r=e.input.charCodeAt(e.index-1);return(0===e.index||xb(r)||xg(r))&&(!t||47!==r)}function SA(){this.buffer()}function SN(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function SI(){this.buffer()}function SC(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function SR(e){let t=this.resume(),r=this.stack[this.stack.length-1];_2("footnoteReference"===r.type),r.identifier=xJ(this.sliceSerialize(e)).toLowerCase(),r.label=t}function SO(e){this.exit(e)}function SL(e){let t=this.resume(),r=this.stack[this.stack.length-1];_2("footnoteDefinition"===r.type),r.identifier=xJ(this.sliceSerialize(e)).toLowerCase(),r.label=t}function SD(e){this.exit(e)}function SP(e,t,r,n){let a=r.createTracker(n),i=a.move("[^"),s=r.enter("footnoteReference"),o=r.enter("reference");return i+=a.move(r.safe(r.associationId(e),{after:"]",before:i})),o(),s(),i+=a.move("]")}function SM(e,t,r){return 0===t?e:Sj(e,t,r)}function Sj(e,t,r){return(r?"":" ")+e}SP.peek=function(){return"["};let SF=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function SU(e){this.enter({type:"delete",children:[]},e)}function SB(e){this.exit(e)}function S$(e,t,r,n){let a=r.createTracker(n),i=r.enter("strikethrough"),s=a.move("~~");return s+=r.containerPhrasing(e,{...a.current(),before:s,after:"~"}),s+=a.move("~~"),i(),s}function Sz(e){return e.length}function SH(e){let t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:114*(82===t||114===t)}S$.peek=function(){return"~"};function SG(e,t,r){let n=e.value||"",a="`",i=-1;for(;RegExp("(^|[^`])"+a+"([^`]|$)").test(n);)a+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++i<r.unsafe.length;){let e,t=r.unsafe[i],a=r.compilePattern(t);if(t.atBreak)for(;e=a.exec(n);){let t=e.index;10===n.charCodeAt(t)&&13===n.charCodeAt(t-1)&&t--,n=n.slice(0,t)+" "+n.slice(e.index+1)}}return a+n+a}SG.peek=function(){return"`"};TN(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);let Sq=function(e,t,r,n){let a=function(e){let t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(r),i=r.bulletCurrent||function(e){let t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}(r);t&&"list"===t.type&&t.ordered&&(i=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===r.options.incrementListMarker?0:t.children.indexOf(e))+i);let s=i.length+1;("tab"===a||"mixed"===a&&(t&&"list"===t.type&&t.spread||e.spread))&&(s=4*Math.ceil(s/4));let o=r.createTracker(n);o.move(i+" ".repeat(s-i.length)),o.shift(s);let l=r.enter("listItem"),c=r.indentLines(r.containerFlow(e,o.current()),function(e,t,r){return t?(r?"":" ".repeat(s))+e:(r?i:i+" ".repeat(s-i.length))+e});return l(),c};function SV(e){let t=e._align;_2(t,"expected `_align` on table"),this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function SW(e){this.exit(e),this.data.inTable=void 0}function SY(e){this.enter({type:"tableRow",children:[]},e)}function SK(e){this.exit(e)}function SZ(e){this.enter({type:"tableCell",children:[]},e)}function SX(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,SQ));let r=this.stack[this.stack.length-1];_2("inlineCode"===r.type),r.value=t,this.exit(e)}function SQ(e,t){return"|"===t?t:e}function SJ(e){let t=this.stack[this.stack.length-2];_2("listItem"===t.type),t.checked="taskListCheckValueChecked"===e.type}function S0(e){let t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){let e=this.stack[this.stack.length-1];_2("paragraph"===e.type);let r=e.children[0];if(r&&"text"===r.type){let n,a=t.children,i=-1;for(;++i<a.length;){let e=a[i];if("paragraph"===e.type){n=e;break}}n===e&&(r.value=r.value.slice(1),0===r.value.length?e.children.shift():e.position&&r.position&&"number"==typeof r.position.start.offset&&(r.position.start.column++,r.position.start.offset++,e.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function S1(e,t,r,n){let a=e.children[0],i="boolean"==typeof e.checked&&a&&"paragraph"===a.type,s="["+(e.checked?"x":" ")+"] ",o=r.createTracker(n);i&&o.move(s);let l=Sq(e,t,r,{...n,...o.current()});return i&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+s})),l}let S2={tokenize:function(e,t,r){let n=0;return function t(i){return(87===i||119===i)&&n<3?(n++,e.consume(i),t):46===i&&3===n?(e.consume(i),a):r(i)};function a(e){return null===e?r(e):t(e)}},partial:!0},S4={tokenize:function(e,t,r){let n,a,i;return s;function s(t){return 46===t||95===t?e.check(S5,l,o)(t):null===t||xh(t)||xb(t)||45!==t&&xg(t)?l(t):(i=!0,e.consume(t),s)}function o(t){return 95===t?n=!0:(a=n,n=void 0),e.consume(t),s}function l(e){return a||n||!i?r(e):t(e)}},partial:!0},S3={tokenize:function(e,t){let r=0,n=0;return a;function a(s){return 40===s?(r++,e.consume(s),a):41===s&&n<r?i(s):33===s||34===s||38===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||60===s||63===s||93===s||95===s||126===s?e.check(S5,t,i)(s):null===s||xh(s)||xb(s)?t(s):(e.consume(s),a)}function i(t){return 41===t&&n++,e.consume(t),a}},partial:!0},S5={tokenize:function(e,t,r){return n;function n(s){return 33===s||34===s||39===s||41===s||42===s||44===s||46===s||58===s||59===s||63===s||95===s||126===s?(e.consume(s),n):38===s?(e.consume(s),i):93===s?(e.consume(s),a):60===s||null===s||xh(s)||xb(s)?t(s):r(s)}function a(e){return null===e||40===e||91===e||xh(e)||xb(e)?t(e):n(e)}function i(t){return xs(t)?function t(a){return 59===a?(e.consume(a),n):xs(a)?(e.consume(a),t):r(a)}(t):r(t)}},partial:!0},S6={tokenize:function(e,t,r){return function(t){return e.consume(t),n};function n(e){return xo(e)?r(e):t(e)}},partial:!0},S9={name:"wwwAutolink",tokenize:function(e,t,r){let n=this;return function(t){return 87!==t&&119!==t||!wr.call(n,n.previous)||ws(n.events)?r(t):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(S2,e.attempt(S4,e.attempt(S3,a),r),r)(t))};function a(r){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(r)}},previous:wr},S8={name:"protocolAutolink",tokenize:function(e,t,r){let n=this,a="",i=!1;return function(t){return(72===t||104===t)&&wn.call(n,n.previous)&&!ws(n.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),s):r(t)};function s(t){if(xs(t)&&a.length<5)return a+=String.fromCodePoint(t),e.consume(t),s;if(58===t){let r=a.toLowerCase();if("http"===r||"https"===r)return e.consume(t),o}return r(t)}function o(t){return 47===t?(e.consume(t),i)?l:(i=!0,o):r(t)}function l(t){return null===t||xc(t)||xh(t)||xb(t)||xg(t)?r(t):e.attempt(S4,e.attempt(S3,c),r)(t)}function c(r){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(r)}},previous:wn},S7={name:"emailAutolink",tokenize:function(e,t,r){let n,a,i=this;return function(t){return!wi(t)||!wa.call(i,i.previous)||ws(i.events)?r(t):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),function t(n){return wi(n)?(e.consume(n),t):64===n?(e.consume(n),s):r(n)}(t))};function s(t){return 46===t?e.check(S6,l,o)(t):45===t||95===t||xo(t)?(a=!0,e.consume(t),s):l(t)}function o(t){return e.consume(t),n=!0,s}function l(s){return a&&n&&xs(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(s)):r(s)}},previous:wa},we={},wt=48;for(;wt<123;)we[wt]=S7,58==++wt?wt=65:91===wt&&(wt=97);function wr(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||xh(e)}function wn(e){return!xs(e)}function wa(e){return!(47===e||wi(e))}function wi(e){return 43===e||45===e||46===e||95===e||xo(e)}function ws(e){let t=e.length,r=!1;for(;t--;){let n=e[t][1];if(("labelLink"===n.type||"labelImage"===n.type)&&!n._balanced){r=!0;break}if(n._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}we[43]=S7,we[45]=S7,we[46]=S7,we[95]=S7,we[72]=[S7,S8],we[104]=[S7,S8],we[87]=[S7,S9],we[119]=[S7,S9];let wo={tokenize:function(e,t,r){let n=this;return xE(e,function(e){let a=n.events[n.events.length-1];return a&&"gfmFootnoteDefinitionIndent"===a[1].type&&4===a[2].sliceSerialize(a[1],!0).length?t(e):r(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function wl(e,t,r){let n,a=this,i=a.events.length,s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);for(;i--;){let e=a.events[i][1];if("labelImage"===e.type){n=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(i){if(!n||!n._balanced)return r(i);let o=xJ(a.sliceSerialize({start:n.end,end:a.now()}));return 94===o.codePointAt(0)&&s.includes(o.slice(1))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(i),e.exit("gfmFootnoteCallLabelMarker"),t(i)):r(i)}}function wc(e,t){let r=e.length;for(;r--;)if("labelImage"===e[r][1].type&&"enter"===e[r][0]){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";let n={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;let i={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},o=[e[r+1],e[r+2],["enter",n,t],e[r+3],e[r+4],["enter",a,t],["exit",a,t],["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",n,t]];return e.splice(r,e.length-r+1,...o),e}function wu(e,t,r){let n,a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]),s=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),o};function o(t){return 94!==t?r(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(o){if(s>999||93===o&&!n||null===o||91===o||xh(o))return r(o);if(93===o){e.exit("chunkString");let n=e.exit("gfmFootnoteCallString");return i.includes(xJ(a.sliceSerialize(n)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(o)}return xh(o)||(n=!0),s++,e.consume(o),92===o?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),s++,l):l(t)}}function wd(e,t,r){let n,a,i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]),o=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):r(t)}function c(t){if(o>999||93===t&&!a||null===t||91===t||xh(t))return r(t);if(93===t){e.exit("chunkString");let r=e.exit("gfmFootnoteDefinitionLabelString");return n=xJ(i.sliceSerialize(r)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return xh(t)||(a=!0),o++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),s.includes(n)||s.push(n),xE(e,p,"gfmFootnoteDefinitionWhitespace")):r(t)}function p(e){return t(e)}}function wp(e,t,r){return e.check(xT,t,e.attempt(wo,t,r))}function wm(e){e.exit("gfmFootnoteDefinition")}class wh{constructor(){this.map=[]}add(e,t,r){!function(e,t,r,n){let a=0;if(0!==r||0!==n.length){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=r,e.map[a][2].push(...n);return}a+=1}e.map.push([t,r,n])}}(this,e,t,r)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length,r=[];for(;t>0;)t-=1,r.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];r.push(e.slice()),e.length=0;let n=r.pop();for(;n;){for(let t of n)e.push(t);n=r.pop()}this.map.length=0}}function wf(e,t,r){let n,a=this,i=0,s=0;return function(e){let t=a.events.length-1;for(;t>-1;){let e=a.events[t][1].type;if("lineEnding"===e||"linePrefix"===e)t--;else break}let n=t>-1?a.events[t][1].type:null,i="tableHead"===n||"tableRow"===n?y:o;return i===y&&a.parser.lazy[a.now().line]?r(e):i(e)};function o(t){var r;return e.enter("tableHead"),e.enter("tableRow"),124===(r=t)||(n=!0,s+=1),l(r)}function l(t){return null===t?r(t):xm(t)?s>1?(s=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):r(t):xf(t)?xE(e,l,"whitespace")(t):(s+=1,n&&(n=!1,i+=1),124===t)?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),n=!0,l):(e.enter("data"),c(t))}function c(t){return null===t||124===t||xh(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return(a.interrupt=!1,a.parser.lazy[a.now().line])?r(t):(e.enter("tableDelimiterRow"),n=!1,xf(t))?xE(e,p,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):p(t)}function p(t){return 45===t||58===t?h(t):124===t?(n=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),m):r(t)}function m(t){return xf(t)?xE(e,h,"whitespace")(t):h(t)}function h(t){return 58===t?(s+=1,n=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):45===t?(s+=1,f(t)):null===t||xm(t)?b(t):r(t)}function f(t){return 45===t?(e.enter("tableDelimiterFiller"),function t(r){return 45===r?(e.consume(r),t):58===r?(n=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(r),e.exit("tableDelimiterMarker"),g):(e.exit("tableDelimiterFiller"),g(r))}(t)):r(t)}function g(t){return xf(t)?xE(e,b,"whitespace")(t):b(t)}function b(a){if(124===a)return p(a);if(null===a||xm(a))return n&&i===s?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(a)):r(a);return r(a)}function y(t){return e.enter("tableRow"),E(t)}function E(r){return 124===r?(e.enter("tableCellDivider"),e.consume(r),e.exit("tableCellDivider"),E):null===r||xm(r)?(e.exit("tableRow"),t(r)):xf(r)?xE(e,E,"whitespace")(r):(e.enter("data"),_(r))}function _(t){return null===t||124===t||xh(t)?(e.exit("data"),E(t)):(e.consume(t),92===t?v:_)}function v(t){return 92===t||124===t?(e.consume(t),_):_(t)}}function wg(e,t){let r,n,a,i=-1,s=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0,p=new wh;for(;++i<e.length;){let m=e[i],h=m[1];"enter"===m[0]?"tableHead"===h.type?(u=!1,0!==d&&(wy(p,t,d,r,n),n=void 0,d=0),r={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(i,0,[["enter",r,t]])):"tableRow"===h.type||"tableDelimiterRow"===h.type?(s=!0,a=void 0,l=[0,0,0,0],c=[0,i+1,0,0],u&&(u=!1,n={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(i,0,[["enter",n,t]])),o="tableDelimiterRow"===h.type?2:n?3:1):o&&("data"===h.type||"tableDelimiterMarker"===h.type||"tableDelimiterFiller"===h.type)?(s=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],a=wb(p,t,l,o,void 0,a),l=[0,0,0,0]),c[2]=i)):"tableCellDivider"===h.type&&(s?s=!1:(0!==l[1]&&(c[0]=c[1],a=wb(p,t,l,o,void 0,a)),c=[(l=c)[1],i,0,0])):"tableHead"===h.type?(u=!0,d=i):"tableRow"===h.type||"tableDelimiterRow"===h.type?(d=i,0!==l[1]?(c[0]=c[1],a=wb(p,t,l,o,i,a)):0!==c[1]&&(a=wb(p,t,c,o,i,a)),o=0):o&&("data"===h.type||"tableDelimiterMarker"===h.type||"tableDelimiterFiller"===h.type)&&(c[3]=i)}for(0!==d&&wy(p,t,d,r,n),p.consume(t.events),i=-1;++i<t.events.length;){let e=t.events[i];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=function(e,t){let r=!1,n=[];for(;t<e.length;){let a=e[t];if(r){if("enter"===a[0])"tableContent"===a[1].type&&n.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===a[1].type){if("tableDelimiterMarker"===e[t-1][1].type){let e=n.length-1;n[e]="left"===n[e]?"center":"right"}}else if("tableDelimiterRow"===a[1].type)break}else"enter"===a[0]&&"tableDelimiterRow"===a[1].type&&(r=!0);t+=1}return n}(t.events,i))}return e}function wb(e,t,r,n,a,i){0!==r[0]&&(i.end=Object.assign({},wE(t.events,r[0])),e.add(r[0],0,[["exit",i,t]]));let s=wE(t.events,r[1]);if(i={type:1===n?"tableHeader":2===n?"tableDelimiter":"tableData",start:Object.assign({},s),end:Object.assign({},s)},e.add(r[1],0,[["enter",i,t]]),0!==r[2]){let a=wE(t.events,r[2]),i=wE(t.events,r[3]),s={type:"tableContent",start:Object.assign({},a),end:Object.assign({},i)};if(e.add(r[2],0,[["enter",s,t]]),2!==n){let n=t.events[r[2]],a=t.events[r[3]];if(n[1].end=Object.assign({},a[1].end),n[1].type="chunkText",n[1].contentType="text",r[3]>r[2]+1){let t=r[2]+1,n=r[3]-r[2]-1;e.add(t,n,[])}}e.add(r[3]+1,0,[["exit",s,t]])}return void 0!==a&&(i.end=Object.assign({},wE(t.events,a)),e.add(a,0,[["exit",i,t]]),i=void 0),i}function wy(e,t,r,n,a){let i=[],s=wE(t.events,r);a&&(a.end=Object.assign({},s),i.push(["exit",a,t])),n.end=Object.assign({},s),i.push(["exit",n,t]),e.add(r+1,0,i)}function wE(e,t){let r=e[t],n="enter"===r[0]?"start":"end";return r[1][n]}let w_={name:"tasklistCheck",tokenize:function(e,t,r){let n=this;return function(t){return null===n.previous&&n._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),a):r(t)};function a(t){return xh(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),i):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),i):r(t)}function i(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):r(t)}function s(n){return xm(n)?t(n):xf(n)?e.check({tokenize:wv},t,r)(n):r(n)}}};function wv(e,t,r){return xE(e,function(e){return null===e?r(e):t(e)},"whitespace")}let wx={};function wT(e){let t,r,n,a=e||wx,i=this.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),l=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(xi([{text:we},{document:{91:{name:"gfmFootnoteDefinition",tokenize:wd,continuation:{tokenize:wp},exit:wm}},text:{91:{name:"gfmFootnoteCall",tokenize:wu},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:wl,resolveTo:wc}}},(t=(a||{}).singleTilde,r={name:"strikethrough",tokenize:function(e,r,n){let a=this.previous,i=this.events,s=0;return function(o){return 126===a&&"characterEscape"!==i[i.length-1][1].type?n(o):(e.enter("strikethroughSequenceTemporary"),function i(o){let l=xM(a);if(126===o)return s>1?n(o):(e.consume(o),s++,i);if(s<2&&!t)return n(o);let c=e.exit("strikethroughSequenceTemporary"),u=xM(o);return c._open=!u||2===u&&!!l,c._close=!l||2===l&&!!u,r(o)}(o))}},resolveAll:function(e,t){let r=-1;for(;++r<e.length;)if("enter"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._close){let n=r;for(;n--;)if("exit"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._open&&e[r][1].end.offset-e[r][1].start.offset==e[n][1].end.offset-e[n][1].start.offset){e[r][1].type="strikethroughSequence",e[n][1].type="strikethroughSequence";let a={type:"strikethrough",start:Object.assign({},e[n][1].start),end:Object.assign({},e[r][1].end)},i={type:"strikethroughText",start:Object.assign({},e[n][1].end),end:Object.assign({},e[r][1].start)},s=[["enter",a,t],["enter",e[n][1],t],["exit",e[n][1],t],["enter",i,t]],o=t.parser.constructs.insideSpan.null;o&&xr(s,s.length,0,xj(o,e.slice(n+1,r),t)),xr(s,s.length,0,[["exit",i,t],["enter",e[r][1],t],["exit",e[r][1],t],["exit",a,t]]),xr(e,n-1,r-n+3,s),r=n+s.length-2;break}}for(r=-1;++r<e.length;)"strikethroughSequenceTemporary"===e[r][1].type&&(e[r][1].type="data");return e}},null==t&&(t=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}}),{flow:{null:{name:"table",tokenize:wf,resolveAll:wg}}},{text:{91:w_}}])),o.push([{transforms:[ST],enter:{literalAutolink:Sb,literalAutolinkEmail:Sy,literalAutolinkHttp:Sy,literalAutolinkWww:Sy},exit:{literalAutolink:Sx,literalAutolinkEmail:Sv,literalAutolinkHttp:SE,literalAutolinkWww:S_}},{enter:{gfmFootnoteCallString:SA,gfmFootnoteCall:SN,gfmFootnoteDefinitionLabelString:SI,gfmFootnoteDefinition:SC},exit:{gfmFootnoteCallString:SR,gfmFootnoteCall:SO,gfmFootnoteDefinitionLabelString:SL,gfmFootnoteDefinition:SD}},{canContainEols:["delete"],enter:{strikethrough:SU},exit:{strikethrough:SB}},{enter:{table:SV,tableData:SZ,tableHeader:SZ,tableRow:SY},exit:{codeText:SX,table:SW,tableData:SK,tableHeader:SK,tableRow:SK}},{exit:{taskListCheckValueChecked:SJ,taskListCheckValueUnchecked:SJ,paragraph:S0}}]),l.push({extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Sf,notInConstruct:Sg},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Sf,notInConstruct:Sg},{character:":",before:"[ps]",after:"\\/",inConstruct:Sf,notInConstruct:Sg}]},(n=!1,a&&a.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:function(e,t,r,a){let i=r.createTracker(a),s=i.move("[^"),o=r.enter("footnoteDefinition"),l=r.enter("label");return s+=i.move(r.safe(r.associationId(e),{before:s,after:"]"})),l(),s+=i.move("]:"),e.children&&e.children.length>0&&(i.shift(4),s+=i.move((n?"\n":" ")+r.indentLines(r.containerFlow(e,i.current()),n?Sj:SM))),o(),s},footnoteReference:SP},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:SF}],handlers:{delete:S$}},function(e){let t=e||{},r=t.tableCellPadding,n=t.tablePipeAlign,a=t.stringLength,i=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,r){let n=SG(e,t,r);return r.stack.includes("tableCell")&&(n=n.replace(/\|/g,"\\$&")),n},table:function(e,t,r,n){return o(function(e,t,r){let n=e.children,a=-1,i=[],s=t.enter("table");for(;++a<n.length;)i[a]=l(n[a],t,r);return s(),i}(e,r,n),e.align)},tableCell:s,tableRow:function(e,t,r,n){let a=o([l(e,r,n)]);return a.slice(0,a.indexOf("\n"))}}};function s(e,t,r,n){let a=r.enter("tableCell"),s=r.enter("phrasing"),o=r.containerPhrasing(e,{...n,before:i,after:i});return s(),a(),o}function o(e,t){return function(e,t){let r=t||{},n=(r.align||[]).concat(),a=r.stringLength||Sz,i=[],s=[],o=[],l=[],c=0,u=-1;for(;++u<e.length;){let t=[],n=[],i=-1;for(e[u].length>c&&(c=e[u].length);++i<e[u].length;){var d;let s=null==(d=e[u][i])?"":String(d);if(!1!==r.alignDelimiters){let e=a(s);n[i]=e,(void 0===l[i]||e>l[i])&&(l[i]=e)}t.push(s)}s[u]=t,o[u]=n}let p=-1;if("object"==typeof n&&"length"in n)for(;++p<c;)i[p]=SH(n[p]);else{let e=SH(n);for(;++p<c;)i[p]=e}p=-1;let m=[],h=[];for(;++p<c;){let e=i[p],t="",n="";99===e?(t=":",n=":"):108===e?t=":":114===e&&(n=":");let a=!1===r.alignDelimiters?1:Math.max(1,l[p]-t.length-n.length),s=t+"-".repeat(a)+n;!1!==r.alignDelimiters&&((a=t.length+a+n.length)>l[p]&&(l[p]=a),h[p]=a),m[p]=s}s.splice(1,0,m),o.splice(1,0,h),u=-1;let f=[];for(;++u<s.length;){let e=s[u],t=o[u];p=-1;let n=[];for(;++p<c;){let a=e[p]||"",s="",o="";if(!1!==r.alignDelimiters){let e=l[p]-(t[p]||0),r=i[p];114===r?s=" ".repeat(e):99===r?e%2?(s=" ".repeat(e/2+.5),o=" ".repeat(e/2-.5)):o=s=" ".repeat(e/2):o=" ".repeat(e)}!1===r.delimiterStart||p||n.push("|"),!1!==r.padding&&(!1!==r.alignDelimiters||""!==a)&&(!1!==r.delimiterStart||p)&&n.push(" "),!1!==r.alignDelimiters&&n.push(s),n.push(a),!1!==r.alignDelimiters&&n.push(o),!1!==r.padding&&n.push(" "),(!1!==r.delimiterEnd||p!==c-1)&&n.push("|")}f.push(!1===r.delimiterEnd?n.join("").replace(/ +$/,""):n.join(""))}return f.join("\n")}(e,{align:t,alignDelimiters:n,padding:r,stringLength:a})}function l(e,t,r){let n=e.children,a=-1,i=[],o=t.enter("tableRow");for(;++a<n.length;)i[a]=s(n[a],e,t,r);return o(),i}}(a),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:S1}}]})}let wS={tokenize:function(e,t,r){let n=this,a=n.events[n.events.length-1],i=a&&"linePrefix"===a[1].type?a[2].sliceSerialize(a[1],!0).length:0,s=0;return function(t){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),function t(n){return 36===n?(e.consume(n),s++,t):s<2?r(n):(e.exit("mathFlowFenceSequence"),xE(e,o,"whitespace")(n))}(t)};function o(t){return null===t||xm(t)?l(t):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(n){return null===n||xm(n)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),l(n)):36===n?r(n):(e.consume(n),t)}(t))}function l(r){return(e.exit("mathFlowFence"),n.interrupt)?t(r):e.attempt(ww,c,p)(r)}function c(t){return e.attempt({tokenize:m,partial:!0},p,u)(t)}function u(t){return(i?xE(e,d,"linePrefix",i+1):d)(t)}function d(t){return null===t?p(t):xm(t)?e.attempt(ww,c,p)(t):(e.enter("mathFlowValue"),function t(r){return null===r||xm(r)?(e.exit("mathFlowValue"),d(r)):(e.consume(r),t)}(t))}function p(r){return e.exit("mathFlow"),t(r)}function m(e,t,r){let a=0;return xE(e,function(t){return e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),function t(n){return 36===n?(a++,e.consume(n),t):a<s?r(n):(e.exit("mathFlowFenceSequence"),xE(e,i,"whitespace")(n))}(t)},"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function i(n){return null===n||xm(n)?(e.exit("mathFlowFence"),t(n)):r(n)}}},concrete:!0,name:"mathFlow"},ww={tokenize:function(e,t,r){let n=this;return function(r){return null===r?t(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),a)};function a(e){return n.parser.lazy[n.now().line]?r(e):t(e)}},partial:!0};function wk(e){let t,r,n=e.length-4,a=3;if(("lineEnding"===e[3][1].type||"space"===e[a][1].type)&&("lineEnding"===e[n][1].type||"space"===e[n][1].type)){for(t=a;++t<n;)if("mathTextData"===e[t][1].type){e[n][1].type="mathTextPadding",e[a][1].type="mathTextPadding",a+=2,n-=2;break}}for(t=a-1,n++;++t<=n;)void 0===r?t!==n&&"lineEnding"!==e[t][1].type&&(r=t):(t===n||"lineEnding"===e[t][1].type)&&(e[r][1].type="mathTextData",t!==r+2&&(e[r][1].end=e[t-1][1].end,e.splice(r+2,t-r-2),n-=t-r-2,t=r+2),r=void 0);return e}function wA(e){return 36!==e||"characterEscape"===this.events[this.events.length-1][1].type}let wN={};function wI(e){let t,r=e||wN,n=this.data(),a=n.micromarkExtensions||(n.micromarkExtensions=[]),i=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);a.push({flow:{36:wS},text:{36:(null==(t=(r||{}).singleDollarTextMath)&&(t=!0),{tokenize:function(e,r,n){let a,i,s=0;return function(r){return e.enter("mathText"),e.enter("mathTextSequence"),function r(a){return 36===a?(e.consume(a),s++,r):s<2&&!t?n(a):(e.exit("mathTextSequence"),o(a))}(r)};function o(t){return null===t?n(t):36===t?(i=e.enter("mathTextSequence"),a=0,function t(n){return 36===n?(e.consume(n),a++,t):a===s?(e.exit("mathTextSequence"),e.exit("mathText"),r(n)):(i.type="mathTextData",l(n))}(t)):32===t?(e.enter("space"),e.consume(t),e.exit("space"),o):xm(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):(e.enter("mathTextData"),l(t))}function l(t){return null===t||32===t||36===t||xm(t)?(e.exit("mathTextData"),o(t)):(e.consume(t),l)}},resolve:wk,previous:wA,name:"mathText"})}}),i.push(function(){return{enter:{mathFlow:function(e){this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[{type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]}]}},e)},mathFlowFenceMeta:function(){this.buffer()},mathText:function(e){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},e),this.buffer()}},exit:{mathFlow:function(e){let t=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),r=this.stack[this.stack.length-1];_2("math"===r.type),this.exit(e),r.value=t;let n=r.data.hChildren[0];_2("element"===n.type),_2("code"===n.tagName),n.children.push({type:"text",value:t}),this.data.mathFlowInside=void 0},mathFlowFence:function(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)},mathFlowFenceMeta:function(){let e=this.resume(),t=this.stack[this.stack.length-1];_2("math"===t.type),t.meta=e},mathFlowValue:e,mathText:function(e){let t=this.resume(),r=this.stack[this.stack.length-1];_2("inlineMath"===r.type),this.exit(e),r.value=t,r.data.hChildren.push({type:"text",value:t})},mathTextData:e}};function e(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}}()),s.push(function(e){let t=(e||{}).singleDollarTextMath;return null==t&&(t=!0),r.peek=function(){return"$"},{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:"\n",inConstruct:"mathFlowMeta"},{character:"$",after:t?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:function(e,t,r,n){let a=e.value||"",i=r.createTracker(n),s="$".repeat(Math.max(function(e){let t=String(e),r=t.indexOf("$"),n=r,a=0,i=0;!1;for(;-1!==r;)r===n?++a>i&&(i=a):a=1,n=r+1,r=t.indexOf("$",n);return i}(a)+1,2)),o=r.enter("mathFlow"),l=i.move(s);if(e.meta){let t=r.enter("mathFlowMeta");l+=i.move(r.safe(e.meta,{after:"\n",before:l,encode:["$"],...i.current()})),t()}return l+=i.move("\n"),a&&(l+=i.move(a+"\n")),l+=i.move(s),o(),l},inlineMath:r}};function r(e,r,n){let a=e.value||"",i=1;for(!t&&i++;RegExp("(^|[^$])"+"\\$".repeat(i)+"([^$]|$)").test(a);)i++;let s="$".repeat(i);/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^\$|\$$/.test(a))&&(a=" "+a+" ");let o=-1;for(;++o<n.unsafe.length;){let e,t=n.unsafe[o];if(!t.atBreak)continue;let r=n.compilePattern(t);for(;e=r.exec(a);){let t=e.index;10===a.codePointAt(t)&&13===a.codePointAt(t-1)&&t--,a=a.slice(0,t)+" "+a.slice(e.index+1)}}return s+a+s}}(r))}let wC=/[#.]/g;function wR(e,t,r){let n=r?function(e){let t=new Map;for(let r of e)t.set(r.toLowerCase(),r);return t}(r):void 0;return function(r,a,...i){let s;if(null==r)s={type:"root",children:[]},i.unshift(a);else{let o=(s=function(e,t){let r,n,a=e||"",i={},s=0;for(;s<a.length;){wC.lastIndex=s;let e=wC.exec(a),t=a.slice(s,e?e.index:a.length);t&&(r?"#"===r?i.id=t:Array.isArray(i.className)?i.className.push(t):i.className=[t]:n=t,s+=t.length),e&&(r=e[0],s++)}return{type:"element",tagName:n||t||"div",properties:i,children:[]}}(r,t)).tagName.toLowerCase(),l=n?n.get(o):void 0;if(s.tagName=l||o,function(e){if(null===e||"object"!=typeof e||Array.isArray(e))return!0;if("string"!=typeof e.type)return!1;for(let t of Object.keys(e)){let r=e[t];if(r&&"object"==typeof r){if(!Array.isArray(r))return!0;for(let e of r)if("number"!=typeof e&&"string"!=typeof e)return!0}}return!!("children"in e&&Array.isArray(e.children))}(a))i.unshift(a);else for(let[t,r]of Object.entries(a))!function(e,t,r,n){let a,i=vE(e,r);if(null!=n){if("number"==typeof n){if(Number.isNaN(n))return;a=n}else a="boolean"==typeof n?n:"string"==typeof n?i.spaceSeparated?vM(n):i.commaSeparated?_3(n):i.commaOrSpaceSeparated?vM(_3(n).join(" ")):wO(i,i.property,n):Array.isArray(n)?[...n]:"style"===i.property?function(e){let t=[];for(let[r,n]of Object.entries(e))t.push([r,n].join(": "));return t.join("; ")}(n):String(n);if(Array.isArray(a)){let e=[];for(let t of a)e.push(wO(i,i.property,t));a=e}"className"===i.property&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}(e,s.properties,t,r)}for(let e of i)!function e(t,r){if(null==r);else if("number"==typeof r||"string"==typeof r)t.push({type:"text",value:String(r)});else if(Array.isArray(r))for(let n of r)e(t,n);else if("object"==typeof r&&"type"in r)"root"===r.type?e(t,r.children):t.push(r);else throw Error("Expected node, nodes, or string, got `"+r+"`")}(s.children,e);return"element"===s.type&&"template"===s.tagName&&(s.content={type:"root",children:s.children},s.children=[]),s}}function wO(e,t,r){if("string"==typeof r){if(e.number&&r&&!Number.isNaN(Number(r)))return Number(r);if((e.boolean||e.overloadedBoolean)&&(""===r||vf(r)===vf(t)))return!0}return r}let wL=wR(vD,"div"),wD=wR(vP,"g",["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"]);function wP(e,t){let r=e.indexOf("\r",t),n=e.indexOf("\n",t);return -1===n?r:-1===r||r+1===n?n:r<n?r:n}let wM={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},wj={}.hasOwnProperty,wF=Object.prototype;function wU(e,t){let r;switch(t.nodeName){case"#comment":return r={type:"comment",value:t.data},w$(e,t,r),r;case"#document":case"#document-fragment":{let n="mode"in t&&("quirks"===t.mode||"limited-quirks"===t.mode);if(r={type:"root",children:wB(e,t.childNodes),data:{quirksMode:n}},e.file&&e.location){let t,n,a=String(e.file),i=(t=String(a),n=[],{toOffset:function(e){if(e&&"number"==typeof e.line&&"number"==typeof e.column&&!Number.isNaN(e.line)&&!Number.isNaN(e.column)){for(;n.length<e.line;){let e=n[n.length-1],r=wP(t,e),a=-1===r?t.length+1:r+1;if(e===a)break;n.push(a)}let r=(e.line>1?n[e.line-2]:0)+e.column-1;if(r<n[e.line-1])return r}},toPoint:function(e){if("number"==typeof e&&e>-1&&e<=t.length){let r=0;for(;;){let a=n[r];if(void 0===a){let e=wP(t,n[r-1]);a=-1===e?t.length+1:e+1,n[r]=a}if(a>e)return{line:r+1,column:e-(r>0?n[r-1]:0)+1,offset:e};r++}}}}),s=i.toPoint(0),o=i.toPoint(a.length);_2(s,"expected `start`"),_2(o,"expected `end`"),r.position={start:s,end:o}}return r}case"#documentType":return w$(e,t,r={type:"doctype"}),r;case"#text":return r={type:"text",value:t.value},w$(e,t,r),r;default:return function(e,t){let r=e.schema;e.schema=t.namespaceURI===wM.svg?vP:vD;let n=-1,a={};for(;++n<t.attrs.length;){let e=t.attrs[n],r=(e.prefix?e.prefix+":":"")+e.name;wj.call(wF,r)||(a[r]=e.value)}let i=("svg"===e.schema.space?wD:wL)(t.tagName,a,wB(e,t.childNodes));if(w$(e,t,i),"template"===i.tagName){let r=t.sourceCodeLocation,n=r&&r.startTag&&wz(r.startTag),a=r&&r.endTag&&wz(r.endTag),s=wU(e,t.content);n&&a&&e.file&&(s.position={start:n.end,end:a.start}),i.content=s}return e.schema=r,i}(e,t)}}function wB(e,t){let r=-1,n=[];for(;++r<t.length;){let a=wU(e,t[r]);n.push(a)}return n}function w$(e,t,r){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){let n=function(e,t,r){let n=wz(r);if("element"===t.type){let a=t.children[t.children.length-1];if(n&&!r.endTag&&a&&a.position&&a.position.end&&(n.end=Object.assign({},a.position.end)),e.verbose){let n,a={};if(r.attrs)for(n in r.attrs)wj.call(r.attrs,n)&&(a[vE(e.schema,n).property]=wz(r.attrs[n]));_2(r.startTag,"a start tag should exist");let i=wz(r.startTag),s=r.endTag?wz(r.endTag):void 0,o={opening:i};s&&(o.closing=s),o.properties=a,t.data={position:o}}}return n}(e,r,t.sourceCodeLocation);n&&(e.location=!0,r.position=n)}}function wz(e){let t=wH({line:e.startLine,column:e.startCol,offset:e.startOffset}),r=wH({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||r?{start:t,end:r}:void 0}function wH(e){return e.line&&e.column?e:void 0}let wG={}.hasOwnProperty;function wq(e,t){let r=t||{};function n(t,...r){let a=n.invalid,i=n.handlers;if(t&&wG.call(t,e)){let r=String(t[e]);a=wG.call(i,r)?i[r]:n.unknown}if(a)return a.call(this,t,...r)}return n.handlers=r.handlers||{},n.invalid=r.invalid,n.unknown=r.unknown,n}let wV={}.hasOwnProperty,wW=wq("type",{handlers:{root:function(e,t){let r={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return r.childNodes=wY(e.children,r,t),wK(e,r),r},element:function(e,t){var r,n;let a,i,s=t;"element"===e.type&&"svg"===e.tagName.toLowerCase()&&"html"===t.space&&(s=vP);let o=[];if(e.properties){for(a in e.properties)if("children"!==a&&wV.call(e.properties,a)){let t=function(e,t,r){let n=vE(e,t);if(!1===r||null==r||"number"==typeof r&&Number.isNaN(r)||!r&&n.boolean)return;Array.isArray(r)&&(r=n.commaSeparated?_5(r):vj(r));let a={name:n.attribute,value:!0===r?"":String(r)};if(n.space&&"html"!==n.space&&"svg"!==n.space){let e=a.name.indexOf(":");e<0?a.prefix="":(a.name=a.name.slice(e+1),a.prefix=n.attribute.slice(0,e)),a.namespace=wM[n.space]}return a}(s,a,e.properties[a]);t&&o.push(t)}}let l=s.space;_2(l);let c={nodeName:e.tagName,tagName:e.tagName,attrs:o,namespaceURI:wM[l],childNodes:[],parentNode:null};return c.childNodes=wY(e.children,c,s),wK(e,c),"template"===e.tagName&&e.content&&(r=e.content,n=s,(i={nodeName:"#document-fragment",childNodes:[]}).childNodes=wY(r.children,i,n),wK(r,i),c.content=i),c},text:function(e){let t={nodeName:"#text",value:e.value,parentNode:null};return wK(e,t),t},comment:function(e){let t={nodeName:"#comment",data:e.value,parentNode:null};return wK(e,t),t},doctype:function(e){let t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return wK(e,t),t}}});function wY(e,t,r){let n=-1,a=[];if(e)for(;++n<e.length;){let i=wW(e[n],r);i.parentNode=t,a.push(i)}return a}function wK(e,t){let r=e.position;r&&r.start&&r.end&&(_2("number"==typeof r.start.offset),_2("number"==typeof r.end.offset),t.sourceCodeLocation={startLine:r.start.line,startCol:r.start.column,startOffset:r.start.offset,endLine:r.end.line,endCol:r.end.column,endOffset:r.end.offset})}let wZ=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],wX=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]);(U=ep||(ep={}))[U.EOF=-1]="EOF",U[U.NULL=0]="NULL",U[U.TABULATION=9]="TABULATION",U[U.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",U[U.LINE_FEED=10]="LINE_FEED",U[U.FORM_FEED=12]="FORM_FEED",U[U.SPACE=32]="SPACE",U[U.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",U[U.QUOTATION_MARK=34]="QUOTATION_MARK",U[U.AMPERSAND=38]="AMPERSAND",U[U.APOSTROPHE=39]="APOSTROPHE",U[U.HYPHEN_MINUS=45]="HYPHEN_MINUS",U[U.SOLIDUS=47]="SOLIDUS",U[U.DIGIT_0=48]="DIGIT_0",U[U.DIGIT_9=57]="DIGIT_9",U[U.SEMICOLON=59]="SEMICOLON",U[U.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",U[U.EQUALS_SIGN=61]="EQUALS_SIGN",U[U.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",U[U.QUESTION_MARK=63]="QUESTION_MARK",U[U.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",U[U.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",U[U.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",U[U.GRAVE_ACCENT=96]="GRAVE_ACCENT",U[U.LATIN_SMALL_A=97]="LATIN_SMALL_A",U[U.LATIN_SMALL_Z=122]="LATIN_SMALL_Z";let wQ="[CDATA[",wJ="doctype",w0="script";function w1(e){return e>=55296&&e<=57343}function w2(e){return 32!==e&&10!==e&&13!==e&&9!==e&&12!==e&&e>=1&&e<=31||e>=127&&e<=159}function w4(e){return e>=64976&&e<=65007||wX.has(e)}(B=em||(em={})).controlCharacterInInputStream="control-character-in-input-stream",B.noncharacterInInputStream="noncharacter-in-input-stream",B.surrogateInInputStream="surrogate-in-input-stream",B.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",B.endTagWithAttributes="end-tag-with-attributes",B.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",B.unexpectedSolidusInTag="unexpected-solidus-in-tag",B.unexpectedNullCharacter="unexpected-null-character",B.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",B.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",B.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",B.missingEndTagName="missing-end-tag-name",B.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",B.unknownNamedCharacterReference="unknown-named-character-reference",B.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",B.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",B.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",B.eofBeforeTagName="eof-before-tag-name",B.eofInTag="eof-in-tag",B.missingAttributeValue="missing-attribute-value",B.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",B.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",B.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",B.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",B.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",B.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",B.missingDoctypePublicIdentifier="missing-doctype-public-identifier",B.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",B.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",B.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",B.cdataInHtmlContent="cdata-in-html-content",B.incorrectlyOpenedComment="incorrectly-opened-comment",B.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",B.eofInDoctype="eof-in-doctype",B.nestedComment="nested-comment",B.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",B.eofInComment="eof-in-comment",B.incorrectlyClosedComment="incorrectly-closed-comment",B.eofInCdata="eof-in-cdata",B.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",B.nullCharacterReference="null-character-reference",B.surrogateCharacterReference="surrogate-character-reference",B.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",B.controlCharacterReference="control-character-reference",B.noncharacterCharacterReference="noncharacter-character-reference",B.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",B.missingDoctypeName="missing-doctype-name",B.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",B.duplicateAttribute="duplicate-attribute",B.nonConformingDoctype="non-conforming-doctype",B.missingDoctype="missing-doctype",B.misplacedDoctype="misplaced-doctype",B.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",B.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",B.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",B.openElementsLeftAfterEof="open-elements-left-after-eof",B.abandonedHeadElementChild="abandoned-head-element-child",B.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",B.nestedNoscriptInHead="nested-noscript-in-head",B.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text";class w3{constructor(e){this.handler=e,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=65536,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+Number(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(e,t){let{line:r,col:n,offset:a}=this,i=n+t,s=a+t;return{code:e,startLine:r,endLine:r,startCol:i,endCol:i,startOffset:s,endOffset:s}}_err(e){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(e,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(e){if(this.pos!==this.html.length-1){let t=this.html.charCodeAt(this.pos+1);if(t>=56320&&t<=57343)return this.pos++,this._addGap(),(e-55296)*1024+9216+t}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,ep.EOF;return this._err(em.surrogateInInputStream),e}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(e,t){this.html.length>0?this.html+=e:this.html=e,this.endOfChunkHit=!1,this.lastChunkWritten=t}insertHtmlAtCurrentPos(e){this.html=this.html.substring(0,this.pos+1)+e+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(e,t){if(this.pos+e.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(t)return this.html.startsWith(e,this.pos);for(let t=0;t<e.length;t++)if((32|this.html.charCodeAt(this.pos+t))!==e.charCodeAt(t))return!1;return!0}peek(e){let t=this.pos+e;if(t>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,ep.EOF;let r=this.html.charCodeAt(t);return r===ep.CARRIAGE_RETURN?ep.LINE_FEED:r}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,ep.EOF;let e=this.html.charCodeAt(this.pos);return e===ep.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,ep.LINE_FEED):e===ep.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,w1(e)&&(e=this._processSurrogate(e)),null===this.handler.onParseError||e>31&&e<127||e===ep.LINE_FEED||e===ep.CARRIAGE_RETURN||e>159&&e<64976||this._checkForProblematicCharacters(e),e)}_checkForProblematicCharacters(e){w2(e)?this._err(em.controlCharacterInInputStream):w4(e)&&this._err(em.noncharacterInInputStream)}retreat(e){for(this.pos-=e;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}function w5(e,t){for(let r=e.attrs.length-1;r>=0;r--)if(e.attrs[r].name===t)return e.attrs[r].value;return null}($=eh||(eh={}))[$.CHARACTER=0]="CHARACTER",$[$.NULL_CHARACTER=1]="NULL_CHARACTER",$[$.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",$[$.START_TAG=3]="START_TAG",$[$.END_TAG=4]="END_TAG",$[$.COMMENT=5]="COMMENT",$[$.DOCTYPE=6]="DOCTYPE",$[$.EOF=7]="EOF",$[$.HIBERNATION=8]="HIBERNATION",e.s(["TokenType",0,eh,"getTokenAttr",0,w5],382698);let w6=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),w9=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function w8(e){return e>=eg.ZERO&&e<=eg.NINE}ef=String.fromCodePoint,(z=eg||(eg={}))[z.NUM=35]="NUM",z[z.SEMI=59]="SEMI",z[z.EQUALS=61]="EQUALS",z[z.ZERO=48]="ZERO",z[z.NINE=57]="NINE",z[z.LOWER_A=97]="LOWER_A",z[z.LOWER_F=102]="LOWER_F",z[z.LOWER_X=120]="LOWER_X",z[z.LOWER_Z=122]="LOWER_Z",z[z.UPPER_A=65]="UPPER_A",z[z.UPPER_F=70]="UPPER_F",z[z.UPPER_Z=90]="UPPER_Z",(H=eb||(eb={}))[H.VALUE_LENGTH=49152]="VALUE_LENGTH",H[H.BRANCH_LENGTH=16256]="BRANCH_LENGTH",H[H.JUMP_TABLE=127]="JUMP_TABLE",(G=ey||(ey={}))[G.EntityStart=0]="EntityStart",G[G.NumericStart=1]="NumericStart",G[G.NumericDecimal=2]="NumericDecimal",G[G.NumericHex=3]="NumericHex",G[G.NamedEntity=4]="NamedEntity",(q=eE||(eE={}))[q.Legacy=0]="Legacy",q[q.Strict=1]="Strict",q[q.Attribute=2]="Attribute";class w7{constructor(e,t,r){this.decodeTree=e,this.emitCodePoint=t,this.errors=r,this.state=ey.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=eE.Strict}startEntity(e){this.decodeMode=e,this.state=ey.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case ey.EntityStart:if(e.charCodeAt(t)===eg.NUM)return this.state=ey.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1);return this.state=ey.NamedEntity,this.stateNamedEntity(e,t);case ey.NumericStart:return this.stateNumericStart(e,t);case ey.NumericDecimal:return this.stateNumericDecimal(e,t);case ey.NumericHex:return this.stateNumericHex(e,t);case ey.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(32|e.charCodeAt(t))===eg.LOWER_X?(this.state=ey.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=ey.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,r,n){if(t!==r){let a=r-t;this.result=this.result*Math.pow(n,a)+Number.parseInt(e.substr(t,a),n),this.consumed+=a}}stateNumericHex(e,t){let r=t;for(;t<e.length;){var n;let a=e.charCodeAt(t);if(!w8(a)&&(!((n=a)>=eg.UPPER_A)||!(n<=eg.UPPER_F))&&(!(n>=eg.LOWER_A)||!(n<=eg.LOWER_F)))return this.addToNumericResult(e,r,t,16),this.emitNumericEntity(a,3);t+=1}return this.addToNumericResult(e,r,t,16),-1}stateNumericDecimal(e,t){let r=t;for(;t<e.length;){let n=e.charCodeAt(t);if(!w8(n))return this.addToNumericResult(e,r,t,10),this.emitNumericEntity(n,2);t+=1}return this.addToNumericResult(e,r,t,10),-1}emitNumericEntity(e,t){var r,n,a;if(this.consumed<=t)return null==(r=this.errors)||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===eg.SEMI)this.consumed+=1;else if(this.decodeMode===eE.Strict)return 0;return this.emitCodePoint((n=this.result)>=55296&&n<=57343||n>1114111?65533:null!=(a=w9.get(n))?a:n,this.consumed),this.errors&&(e!==eg.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:r}=this,n=r[this.treeIndex],a=(n&eb.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){let i=e.charCodeAt(t);if(this.treeIndex=function(e,t,r,n){let a=(t&eb.BRANCH_LENGTH)>>7,i=t&eb.JUMP_TABLE;if(0===a)return 0!==i&&n===i?r:-1;if(i){let t=n-i;return t<0||t>=a?-1:e[r+t]-1}let s=r,o=s+a-1;for(;s<=o;){let t=s+o>>>1,r=e[t];if(r<n)s=t+1;else{if(!(r>n))return e[t+a];o=t-1}}return -1}(r,n,this.treeIndex+Math.max(1,a),i),this.treeIndex<0)return 0===this.result||this.decodeMode===eE.Attribute&&(0===a||function(e){var t;return e===eg.EQUALS||(t=e)>=eg.UPPER_A&&t<=eg.UPPER_Z||t>=eg.LOWER_A&&t<=eg.LOWER_Z||w8(t)}(i))?0:this.emitNotTerminatedNamedEntity();if(0!=(a=((n=r[this.treeIndex])&eb.VALUE_LENGTH)>>14)){if(i===eg.SEMI)return this.emitNamedEntityData(this.treeIndex,a,this.consumed+this.excess);this.decodeMode!==eE.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return -1}emitNotTerminatedNamedEntity(){var e;let{result:t,decodeTree:r}=this,n=(r[t]&eb.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,n,this.consumed),null==(e=this.errors)||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,r){let{decodeTree:n}=this;return this.emitCodePoint(1===t?n[e]&~eb.VALUE_LENGTH:n[e+1],r),3===t&&this.emitCodePoint(n[e+2],r),r}end(){var e;switch(this.state){case ey.NamedEntity:return 0!==this.result&&(this.decodeMode!==eE.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case ey.NumericDecimal:return this.emitNumericEntity(0,2);case ey.NumericHex:return this.emitNumericEntity(0,3);case ey.NumericStart:return null==(e=this.errors)||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case ey.EntityStart:return 0}}}(V=e_||(e_={})).HTML="http://www.w3.org/1999/xhtml",V.MATHML="http://www.w3.org/1998/Math/MathML",V.SVG="http://www.w3.org/2000/svg",V.XLINK="http://www.w3.org/1999/xlink",V.XML="http://www.w3.org/XML/1998/namespace",V.XMLNS="http://www.w3.org/2000/xmlns/",(W=ev||(ev={})).TYPE="type",W.ACTION="action",W.ENCODING="encoding",W.PROMPT="prompt",W.NAME="name",W.COLOR="color",W.FACE="face",W.SIZE="size",(Y=ex||(ex={})).NO_QUIRKS="no-quirks",Y.QUIRKS="quirks",Y.LIMITED_QUIRKS="limited-quirks",(K=eT||(eT={})).A="a",K.ADDRESS="address",K.ANNOTATION_XML="annotation-xml",K.APPLET="applet",K.AREA="area",K.ARTICLE="article",K.ASIDE="aside",K.B="b",K.BASE="base",K.BASEFONT="basefont",K.BGSOUND="bgsound",K.BIG="big",K.BLOCKQUOTE="blockquote",K.BODY="body",K.BR="br",K.BUTTON="button",K.CAPTION="caption",K.CENTER="center",K.CODE="code",K.COL="col",K.COLGROUP="colgroup",K.DD="dd",K.DESC="desc",K.DETAILS="details",K.DIALOG="dialog",K.DIR="dir",K.DIV="div",K.DL="dl",K.DT="dt",K.EM="em",K.EMBED="embed",K.FIELDSET="fieldset",K.FIGCAPTION="figcaption",K.FIGURE="figure",K.FONT="font",K.FOOTER="footer",K.FOREIGN_OBJECT="foreignObject",K.FORM="form",K.FRAME="frame",K.FRAMESET="frameset",K.H1="h1",K.H2="h2",K.H3="h3",K.H4="h4",K.H5="h5",K.H6="h6",K.HEAD="head",K.HEADER="header",K.HGROUP="hgroup",K.HR="hr",K.HTML="html",K.I="i",K.IMG="img",K.IMAGE="image",K.INPUT="input",K.IFRAME="iframe",K.KEYGEN="keygen",K.LABEL="label",K.LI="li",K.LINK="link",K.LISTING="listing",K.MAIN="main",K.MALIGNMARK="malignmark",K.MARQUEE="marquee",K.MATH="math",K.MENU="menu",K.META="meta",K.MGLYPH="mglyph",K.MI="mi",K.MO="mo",K.MN="mn",K.MS="ms",K.MTEXT="mtext",K.NAV="nav",K.NOBR="nobr",K.NOFRAMES="noframes",K.NOEMBED="noembed",K.NOSCRIPT="noscript",K.OBJECT="object",K.OL="ol",K.OPTGROUP="optgroup",K.OPTION="option",K.P="p",K.PARAM="param",K.PLAINTEXT="plaintext",K.PRE="pre",K.RB="rb",K.RP="rp",K.RT="rt",K.RTC="rtc",K.RUBY="ruby",K.S="s",K.SCRIPT="script",K.SEARCH="search",K.SECTION="section",K.SELECT="select",K.SOURCE="source",K.SMALL="small",K.SPAN="span",K.STRIKE="strike",K.STRONG="strong",K.STYLE="style",K.SUB="sub",K.SUMMARY="summary",K.SUP="sup",K.TABLE="table",K.TBODY="tbody",K.TEMPLATE="template",K.TEXTAREA="textarea",K.TFOOT="tfoot",K.TD="td",K.TH="th",K.THEAD="thead",K.TITLE="title",K.TR="tr",K.TRACK="track",K.TT="tt",K.U="u",K.UL="ul",K.SVG="svg",K.VAR="var",K.WBR="wbr",K.XMP="xmp",(Z=eS||(eS={}))[Z.UNKNOWN=0]="UNKNOWN",Z[Z.A=1]="A",Z[Z.ADDRESS=2]="ADDRESS",Z[Z.ANNOTATION_XML=3]="ANNOTATION_XML",Z[Z.APPLET=4]="APPLET",Z[Z.AREA=5]="AREA",Z[Z.ARTICLE=6]="ARTICLE",Z[Z.ASIDE=7]="ASIDE",Z[Z.B=8]="B",Z[Z.BASE=9]="BASE",Z[Z.BASEFONT=10]="BASEFONT",Z[Z.BGSOUND=11]="BGSOUND",Z[Z.BIG=12]="BIG",Z[Z.BLOCKQUOTE=13]="BLOCKQUOTE",Z[Z.BODY=14]="BODY",Z[Z.BR=15]="BR",Z[Z.BUTTON=16]="BUTTON",Z[Z.CAPTION=17]="CAPTION",Z[Z.CENTER=18]="CENTER",Z[Z.CODE=19]="CODE",Z[Z.COL=20]="COL",Z[Z.COLGROUP=21]="COLGROUP",Z[Z.DD=22]="DD",Z[Z.DESC=23]="DESC",Z[Z.DETAILS=24]="DETAILS",Z[Z.DIALOG=25]="DIALOG",Z[Z.DIR=26]="DIR",Z[Z.DIV=27]="DIV",Z[Z.DL=28]="DL",Z[Z.DT=29]="DT",Z[Z.EM=30]="EM",Z[Z.EMBED=31]="EMBED",Z[Z.FIELDSET=32]="FIELDSET",Z[Z.FIGCAPTION=33]="FIGCAPTION",Z[Z.FIGURE=34]="FIGURE",Z[Z.FONT=35]="FONT",Z[Z.FOOTER=36]="FOOTER",Z[Z.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",Z[Z.FORM=38]="FORM",Z[Z.FRAME=39]="FRAME",Z[Z.FRAMESET=40]="FRAMESET",Z[Z.H1=41]="H1",Z[Z.H2=42]="H2",Z[Z.H3=43]="H3",Z[Z.H4=44]="H4",Z[Z.H5=45]="H5",Z[Z.H6=46]="H6",Z[Z.HEAD=47]="HEAD",Z[Z.HEADER=48]="HEADER",Z[Z.HGROUP=49]="HGROUP",Z[Z.HR=50]="HR",Z[Z.HTML=51]="HTML",Z[Z.I=52]="I",Z[Z.IMG=53]="IMG",Z[Z.IMAGE=54]="IMAGE",Z[Z.INPUT=55]="INPUT",Z[Z.IFRAME=56]="IFRAME",Z[Z.KEYGEN=57]="KEYGEN",Z[Z.LABEL=58]="LABEL",Z[Z.LI=59]="LI",Z[Z.LINK=60]="LINK",Z[Z.LISTING=61]="LISTING",Z[Z.MAIN=62]="MAIN",Z[Z.MALIGNMARK=63]="MALIGNMARK",Z[Z.MARQUEE=64]="MARQUEE",Z[Z.MATH=65]="MATH",Z[Z.MENU=66]="MENU",Z[Z.META=67]="META",Z[Z.MGLYPH=68]="MGLYPH",Z[Z.MI=69]="MI",Z[Z.MO=70]="MO",Z[Z.MN=71]="MN",Z[Z.MS=72]="MS",Z[Z.MTEXT=73]="MTEXT",Z[Z.NAV=74]="NAV",Z[Z.NOBR=75]="NOBR",Z[Z.NOFRAMES=76]="NOFRAMES",Z[Z.NOEMBED=77]="NOEMBED",Z[Z.NOSCRIPT=78]="NOSCRIPT",Z[Z.OBJECT=79]="OBJECT",Z[Z.OL=80]="OL",Z[Z.OPTGROUP=81]="OPTGROUP",Z[Z.OPTION=82]="OPTION",Z[Z.P=83]="P",Z[Z.PARAM=84]="PARAM",Z[Z.PLAINTEXT=85]="PLAINTEXT",Z[Z.PRE=86]="PRE",Z[Z.RB=87]="RB",Z[Z.RP=88]="RP",Z[Z.RT=89]="RT",Z[Z.RTC=90]="RTC",Z[Z.RUBY=91]="RUBY",Z[Z.S=92]="S",Z[Z.SCRIPT=93]="SCRIPT",Z[Z.SEARCH=94]="SEARCH",Z[Z.SECTION=95]="SECTION",Z[Z.SELECT=96]="SELECT",Z[Z.SOURCE=97]="SOURCE",Z[Z.SMALL=98]="SMALL",Z[Z.SPAN=99]="SPAN",Z[Z.STRIKE=100]="STRIKE",Z[Z.STRONG=101]="STRONG",Z[Z.STYLE=102]="STYLE",Z[Z.SUB=103]="SUB",Z[Z.SUMMARY=104]="SUMMARY",Z[Z.SUP=105]="SUP",Z[Z.TABLE=106]="TABLE",Z[Z.TBODY=107]="TBODY",Z[Z.TEMPLATE=108]="TEMPLATE",Z[Z.TEXTAREA=109]="TEXTAREA",Z[Z.TFOOT=110]="TFOOT",Z[Z.TD=111]="TD",Z[Z.TH=112]="TH",Z[Z.THEAD=113]="THEAD",Z[Z.TITLE=114]="TITLE",Z[Z.TR=115]="TR",Z[Z.TRACK=116]="TRACK",Z[Z.TT=117]="TT",Z[Z.U=118]="U",Z[Z.UL=119]="UL",Z[Z.SVG=120]="SVG",Z[Z.VAR=121]="VAR",Z[Z.WBR=122]="WBR",Z[Z.XMP=123]="XMP";let ke=new Map([[eT.A,eS.A],[eT.ADDRESS,eS.ADDRESS],[eT.ANNOTATION_XML,eS.ANNOTATION_XML],[eT.APPLET,eS.APPLET],[eT.AREA,eS.AREA],[eT.ARTICLE,eS.ARTICLE],[eT.ASIDE,eS.ASIDE],[eT.B,eS.B],[eT.BASE,eS.BASE],[eT.BASEFONT,eS.BASEFONT],[eT.BGSOUND,eS.BGSOUND],[eT.BIG,eS.BIG],[eT.BLOCKQUOTE,eS.BLOCKQUOTE],[eT.BODY,eS.BODY],[eT.BR,eS.BR],[eT.BUTTON,eS.BUTTON],[eT.CAPTION,eS.CAPTION],[eT.CENTER,eS.CENTER],[eT.CODE,eS.CODE],[eT.COL,eS.COL],[eT.COLGROUP,eS.COLGROUP],[eT.DD,eS.DD],[eT.DESC,eS.DESC],[eT.DETAILS,eS.DETAILS],[eT.DIALOG,eS.DIALOG],[eT.DIR,eS.DIR],[eT.DIV,eS.DIV],[eT.DL,eS.DL],[eT.DT,eS.DT],[eT.EM,eS.EM],[eT.EMBED,eS.EMBED],[eT.FIELDSET,eS.FIELDSET],[eT.FIGCAPTION,eS.FIGCAPTION],[eT.FIGURE,eS.FIGURE],[eT.FONT,eS.FONT],[eT.FOOTER,eS.FOOTER],[eT.FOREIGN_OBJECT,eS.FOREIGN_OBJECT],[eT.FORM,eS.FORM],[eT.FRAME,eS.FRAME],[eT.FRAMESET,eS.FRAMESET],[eT.H1,eS.H1],[eT.H2,eS.H2],[eT.H3,eS.H3],[eT.H4,eS.H4],[eT.H5,eS.H5],[eT.H6,eS.H6],[eT.HEAD,eS.HEAD],[eT.HEADER,eS.HEADER],[eT.HGROUP,eS.HGROUP],[eT.HR,eS.HR],[eT.HTML,eS.HTML],[eT.I,eS.I],[eT.IMG,eS.IMG],[eT.IMAGE,eS.IMAGE],[eT.INPUT,eS.INPUT],[eT.IFRAME,eS.IFRAME],[eT.KEYGEN,eS.KEYGEN],[eT.LABEL,eS.LABEL],[eT.LI,eS.LI],[eT.LINK,eS.LINK],[eT.LISTING,eS.LISTING],[eT.MAIN,eS.MAIN],[eT.MALIGNMARK,eS.MALIGNMARK],[eT.MARQUEE,eS.MARQUEE],[eT.MATH,eS.MATH],[eT.MENU,eS.MENU],[eT.META,eS.META],[eT.MGLYPH,eS.MGLYPH],[eT.MI,eS.MI],[eT.MO,eS.MO],[eT.MN,eS.MN],[eT.MS,eS.MS],[eT.MTEXT,eS.MTEXT],[eT.NAV,eS.NAV],[eT.NOBR,eS.NOBR],[eT.NOFRAMES,eS.NOFRAMES],[eT.NOEMBED,eS.NOEMBED],[eT.NOSCRIPT,eS.NOSCRIPT],[eT.OBJECT,eS.OBJECT],[eT.OL,eS.OL],[eT.OPTGROUP,eS.OPTGROUP],[eT.OPTION,eS.OPTION],[eT.P,eS.P],[eT.PARAM,eS.PARAM],[eT.PLAINTEXT,eS.PLAINTEXT],[eT.PRE,eS.PRE],[eT.RB,eS.RB],[eT.RP,eS.RP],[eT.RT,eS.RT],[eT.RTC,eS.RTC],[eT.RUBY,eS.RUBY],[eT.S,eS.S],[eT.SCRIPT,eS.SCRIPT],[eT.SEARCH,eS.SEARCH],[eT.SECTION,eS.SECTION],[eT.SELECT,eS.SELECT],[eT.SOURCE,eS.SOURCE],[eT.SMALL,eS.SMALL],[eT.SPAN,eS.SPAN],[eT.STRIKE,eS.STRIKE],[eT.STRONG,eS.STRONG],[eT.STYLE,eS.STYLE],[eT.SUB,eS.SUB],[eT.SUMMARY,eS.SUMMARY],[eT.SUP,eS.SUP],[eT.TABLE,eS.TABLE],[eT.TBODY,eS.TBODY],[eT.TEMPLATE,eS.TEMPLATE],[eT.TEXTAREA,eS.TEXTAREA],[eT.TFOOT,eS.TFOOT],[eT.TD,eS.TD],[eT.TH,eS.TH],[eT.THEAD,eS.THEAD],[eT.TITLE,eS.TITLE],[eT.TR,eS.TR],[eT.TRACK,eS.TRACK],[eT.TT,eS.TT],[eT.U,eS.U],[eT.UL,eS.UL],[eT.SVG,eS.SVG],[eT.VAR,eS.VAR],[eT.WBR,eS.WBR],[eT.XMP,eS.XMP]]);function kt(e){var t;return null!=(t=ke.get(e))?t:eS.UNKNOWN}let kr=eS,kn={[e_.HTML]:new Set([kr.ADDRESS,kr.APPLET,kr.AREA,kr.ARTICLE,kr.ASIDE,kr.BASE,kr.BASEFONT,kr.BGSOUND,kr.BLOCKQUOTE,kr.BODY,kr.BR,kr.BUTTON,kr.CAPTION,kr.CENTER,kr.COL,kr.COLGROUP,kr.DD,kr.DETAILS,kr.DIR,kr.DIV,kr.DL,kr.DT,kr.EMBED,kr.FIELDSET,kr.FIGCAPTION,kr.FIGURE,kr.FOOTER,kr.FORM,kr.FRAME,kr.FRAMESET,kr.H1,kr.H2,kr.H3,kr.H4,kr.H5,kr.H6,kr.HEAD,kr.HEADER,kr.HGROUP,kr.HR,kr.HTML,kr.IFRAME,kr.IMG,kr.INPUT,kr.LI,kr.LINK,kr.LISTING,kr.MAIN,kr.MARQUEE,kr.MENU,kr.META,kr.NAV,kr.NOEMBED,kr.NOFRAMES,kr.NOSCRIPT,kr.OBJECT,kr.OL,kr.P,kr.PARAM,kr.PLAINTEXT,kr.PRE,kr.SCRIPT,kr.SECTION,kr.SELECT,kr.SOURCE,kr.STYLE,kr.SUMMARY,kr.TABLE,kr.TBODY,kr.TD,kr.TEMPLATE,kr.TEXTAREA,kr.TFOOT,kr.TH,kr.THEAD,kr.TITLE,kr.TR,kr.TRACK,kr.UL,kr.WBR,kr.XMP]),[e_.MATHML]:new Set([kr.MI,kr.MO,kr.MN,kr.MS,kr.MTEXT,kr.ANNOTATION_XML]),[e_.SVG]:new Set([kr.TITLE,kr.FOREIGN_OBJECT,kr.DESC]),[e_.XLINK]:new Set,[e_.XML]:new Set,[e_.XMLNS]:new Set},ka=new Set([kr.H1,kr.H2,kr.H3,kr.H4,kr.H5,kr.H6]),ki=new Set([eT.STYLE,eT.SCRIPT,eT.XMP,eT.IFRAME,eT.NOEMBED,eT.NOFRAMES,eT.PLAINTEXT]);e.s(["ATTRS",0,ev,"DOCUMENT_MODE",0,ex,"NS",0,e_,"NUMBERED_HEADERS",0,ka,"SPECIAL_ELEMENTS",0,kn,"TAG_ID",0,eS,"TAG_NAMES",0,eT,"getTagID",0,kt,"hasUnescapedText",0,function(e,t){return ki.has(e)||t&&e===eT.NOSCRIPT}],615473),(X=ew||(ew={}))[X.DATA=0]="DATA",X[X.RCDATA=1]="RCDATA",X[X.RAWTEXT=2]="RAWTEXT",X[X.SCRIPT_DATA=3]="SCRIPT_DATA",X[X.PLAINTEXT=4]="PLAINTEXT",X[X.TAG_OPEN=5]="TAG_OPEN",X[X.END_TAG_OPEN=6]="END_TAG_OPEN",X[X.TAG_NAME=7]="TAG_NAME",X[X.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",X[X.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",X[X.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",X[X.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",X[X.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",X[X.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",X[X.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",X[X.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",X[X.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",X[X.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",X[X.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",X[X.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",X[X.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",X[X.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",X[X.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",X[X.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",X[X.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",X[X.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",X[X.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",X[X.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",X[X.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",X[X.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",X[X.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",X[X.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",X[X.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",X[X.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",X[X.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",X[X.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",X[X.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",X[X.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",X[X.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",X[X.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",X[X.BOGUS_COMMENT=40]="BOGUS_COMMENT",X[X.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",X[X.COMMENT_START=42]="COMMENT_START",X[X.COMMENT_START_DASH=43]="COMMENT_START_DASH",X[X.COMMENT=44]="COMMENT",X[X.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",X[X.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",X[X.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",X[X.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",X[X.COMMENT_END_DASH=49]="COMMENT_END_DASH",X[X.COMMENT_END=50]="COMMENT_END",X[X.COMMENT_END_BANG=51]="COMMENT_END_BANG",X[X.DOCTYPE=52]="DOCTYPE",X[X.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",X[X.DOCTYPE_NAME=54]="DOCTYPE_NAME",X[X.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",X[X.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",X[X.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",X[X.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",X[X.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",X[X.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",X[X.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",X[X.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",X[X.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",X[X.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",X[X.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",X[X.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",X[X.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",X[X.CDATA_SECTION=68]="CDATA_SECTION",X[X.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",X[X.CDATA_SECTION_END=70]="CDATA_SECTION_END",X[X.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",X[X.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND";let ks={DATA:ew.DATA,RCDATA:ew.RCDATA,RAWTEXT:ew.RAWTEXT,SCRIPT_DATA:ew.SCRIPT_DATA,PLAINTEXT:ew.PLAINTEXT,CDATA_SECTION:ew.CDATA_SECTION};function ko(e){return e>=ep.LATIN_CAPITAL_A&&e<=ep.LATIN_CAPITAL_Z}function kl(e){return e>=ep.LATIN_SMALL_A&&e<=ep.LATIN_SMALL_Z||ko(e)}function kc(e){return kl(e)||e>=ep.DIGIT_0&&e<=ep.DIGIT_9}function ku(e){return e===ep.SPACE||e===ep.LINE_FEED||e===ep.TABULATION||e===ep.FORM_FEED}function kd(e){return ku(e)||e===ep.SOLIDUS||e===ep.GREATER_THAN_SIGN}class kp{constructor(e,t){this.options=e,this.handler=t,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=ew.DATA,this.returnState=ew.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new w3(t),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new w7(w6,(e,t)=>{this.preprocessor.pos=this.entityStartPos+t-1,this._flushCodePointConsumedAsCharacterReference(e)},t.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(em.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:e=>{this._err(em.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+e)},validateNumericCharacterReference:e=>{let t=function(e){if(e===ep.NULL)return em.nullCharacterReference;if(e>1114111)return em.characterReferenceOutsideUnicodeRange;if(w1(e))return em.surrogateCharacterReference;if(w4(e))return em.noncharacterCharacterReference;if(w2(e)||e===ep.CARRIAGE_RETURN)return em.controlCharacterReference;return null}(e);t&&this._err(t,1)}}:void 0)}_err(e,t=0){var r,n;null==(n=(r=this.handler).onParseError)||n.call(r,this.preprocessor.getError(e,t))}getCurrentLocation(e){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-e,startOffset:this.preprocessor.offset-e,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;let e=this._consume();this._ensureHibernation()||this._callState(e)}this.inLoop=!1}}pause(){this.paused=!0}resume(e){if(!this.paused)throw Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||null==e||e())}write(e,t,r){this.active=!0,this.preprocessor.write(e,t),this._runParsingLoop(),this.paused||null==r||r()}insertHtmlAtCurrentPos(e){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(e),this._runParsingLoop()}_ensureHibernation(){return!!this.preprocessor.endOfChunkHit&&(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0)}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(e){this.consumedAfterSnapshot+=e;for(let t=0;t<e;t++)this.preprocessor.advance()}_consumeSequenceIfMatch(e,t){return!!this.preprocessor.startsWith(e,t)&&(this._advanceBy(e.length-1),!0)}_createStartTagToken(){this.currentToken={type:eh.START_TAG,tagName:"",tagID:eS.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:eh.END_TAG,tagName:"",tagID:eS.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(e){this.currentToken={type:eh.COMMENT,data:"",location:this.getCurrentLocation(e)}}_createDoctypeToken(e){this.currentToken={type:eh.DOCTYPE,name:e,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(e,t){this.currentCharacterToken={type:e,chars:t,location:this.currentLocation}}_createAttr(e){this.currentAttr={name:e,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var e,t;let r=this.currentToken;null===w5(r,this.currentAttr.name)?(r.attrs.push(this.currentAttr),r.location&&this.currentLocation&&((null!=(e=(t=r.location).attrs)?e:t.attrs=Object.create(null))[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue())):this._err(em.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(e){this._emitCurrentCharacterToken(e.location),this.currentToken=null,e.location&&(e.location.endLine=this.preprocessor.line,e.location.endCol=this.preprocessor.col+1,e.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){let e=this.currentToken;this.prepareToken(e),e.tagID=kt(e.tagName),e.type===eh.START_TAG?(this.lastStartTagName=e.tagName,this.handler.onStartTag(e)):(e.attrs.length>0&&this._err(em.endTagWithAttributes),e.selfClosing&&this._err(em.endTagWithTrailingSolidus),this.handler.onEndTag(e)),this.preprocessor.dropParsedChunk()}emitCurrentComment(e){this.prepareToken(e),this.handler.onComment(e),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(e){this.prepareToken(e),this.handler.onDoctype(e),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(e){if(this.currentCharacterToken){switch(e&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=e.startLine,this.currentCharacterToken.location.endCol=e.startCol,this.currentCharacterToken.location.endOffset=e.startOffset),this.currentCharacterToken.type){case eh.CHARACTER:this.handler.onCharacter(this.currentCharacterToken);break;case eh.NULL_CHARACTER:this.handler.onNullCharacter(this.currentCharacterToken);break;case eh.WHITESPACE_CHARACTER:this.handler.onWhitespaceCharacter(this.currentCharacterToken)}this.currentCharacterToken=null}}_emitEOFToken(){let e=this.getCurrentLocation(0);e&&(e.endLine=e.startLine,e.endCol=e.startCol,e.endOffset=e.startOffset),this._emitCurrentCharacterToken(e),this.handler.onEof({type:eh.EOF,location:e}),this.active=!1}_appendCharToCurrentCharacterToken(e,t){if(this.currentCharacterToken)if(this.currentCharacterToken.type===e){this.currentCharacterToken.chars+=t;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(e,t)}_emitCodePoint(e){let t=ku(e)?eh.WHITESPACE_CHARACTER:e===ep.NULL?eh.NULL_CHARACTER:eh.CHARACTER;this._appendCharToCurrentCharacterToken(t,String.fromCodePoint(e))}_emitChars(e){this._appendCharToCurrentCharacterToken(eh.CHARACTER,e)}_startCharacterReference(){this.returnState=this.state,this.state=ew.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?eE.Attribute:eE.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===ew.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===ew.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===ew.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(e){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(e):this._emitCodePoint(e)}_callState(e){switch(this.state){case ew.DATA:this._stateData(e);break;case ew.RCDATA:this._stateRcdata(e);break;case ew.RAWTEXT:this._stateRawtext(e);break;case ew.SCRIPT_DATA:this._stateScriptData(e);break;case ew.PLAINTEXT:this._statePlaintext(e);break;case ew.TAG_OPEN:this._stateTagOpen(e);break;case ew.END_TAG_OPEN:this._stateEndTagOpen(e);break;case ew.TAG_NAME:this._stateTagName(e);break;case ew.RCDATA_LESS_THAN_SIGN:this._stateRcdataLessThanSign(e);break;case ew.RCDATA_END_TAG_OPEN:this._stateRcdataEndTagOpen(e);break;case ew.RCDATA_END_TAG_NAME:this._stateRcdataEndTagName(e);break;case ew.RAWTEXT_LESS_THAN_SIGN:this._stateRawtextLessThanSign(e);break;case ew.RAWTEXT_END_TAG_OPEN:this._stateRawtextEndTagOpen(e);break;case ew.RAWTEXT_END_TAG_NAME:this._stateRawtextEndTagName(e);break;case ew.SCRIPT_DATA_LESS_THAN_SIGN:this._stateScriptDataLessThanSign(e);break;case ew.SCRIPT_DATA_END_TAG_OPEN:this._stateScriptDataEndTagOpen(e);break;case ew.SCRIPT_DATA_END_TAG_NAME:this._stateScriptDataEndTagName(e);break;case ew.SCRIPT_DATA_ESCAPE_START:this._stateScriptDataEscapeStart(e);break;case ew.SCRIPT_DATA_ESCAPE_START_DASH:this._stateScriptDataEscapeStartDash(e);break;case ew.SCRIPT_DATA_ESCAPED:this._stateScriptDataEscaped(e);break;case ew.SCRIPT_DATA_ESCAPED_DASH:this._stateScriptDataEscapedDash(e);break;case ew.SCRIPT_DATA_ESCAPED_DASH_DASH:this._stateScriptDataEscapedDashDash(e);break;case ew.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataEscapedLessThanSign(e);break;case ew.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:this._stateScriptDataEscapedEndTagOpen(e);break;case ew.SCRIPT_DATA_ESCAPED_END_TAG_NAME:this._stateScriptDataEscapedEndTagName(e);break;case ew.SCRIPT_DATA_DOUBLE_ESCAPE_START:this._stateScriptDataDoubleEscapeStart(e);break;case ew.SCRIPT_DATA_DOUBLE_ESCAPED:this._stateScriptDataDoubleEscaped(e);break;case ew.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:this._stateScriptDataDoubleEscapedDash(e);break;case ew.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:this._stateScriptDataDoubleEscapedDashDash(e);break;case ew.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:this._stateScriptDataDoubleEscapedLessThanSign(e);break;case ew.SCRIPT_DATA_DOUBLE_ESCAPE_END:this._stateScriptDataDoubleEscapeEnd(e);break;case ew.BEFORE_ATTRIBUTE_NAME:this._stateBeforeAttributeName(e);break;case ew.ATTRIBUTE_NAME:this._stateAttributeName(e);break;case ew.AFTER_ATTRIBUTE_NAME:this._stateAfterAttributeName(e);break;case ew.BEFORE_ATTRIBUTE_VALUE:this._stateBeforeAttributeValue(e);break;case ew.ATTRIBUTE_VALUE_DOUBLE_QUOTED:this._stateAttributeValueDoubleQuoted(e);break;case ew.ATTRIBUTE_VALUE_SINGLE_QUOTED:this._stateAttributeValueSingleQuoted(e);break;case ew.ATTRIBUTE_VALUE_UNQUOTED:this._stateAttributeValueUnquoted(e);break;case ew.AFTER_ATTRIBUTE_VALUE_QUOTED:this._stateAfterAttributeValueQuoted(e);break;case ew.SELF_CLOSING_START_TAG:this._stateSelfClosingStartTag(e);break;case ew.BOGUS_COMMENT:this._stateBogusComment(e);break;case ew.MARKUP_DECLARATION_OPEN:this._stateMarkupDeclarationOpen(e);break;case ew.COMMENT_START:this._stateCommentStart(e);break;case ew.COMMENT_START_DASH:this._stateCommentStartDash(e);break;case ew.COMMENT:this._stateComment(e);break;case ew.COMMENT_LESS_THAN_SIGN:this._stateCommentLessThanSign(e);break;case ew.COMMENT_LESS_THAN_SIGN_BANG:this._stateCommentLessThanSignBang(e);break;case ew.COMMENT_LESS_THAN_SIGN_BANG_DASH:this._stateCommentLessThanSignBangDash(e);break;case ew.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:this._stateCommentLessThanSignBangDashDash(e);break;case ew.COMMENT_END_DASH:this._stateCommentEndDash(e);break;case ew.COMMENT_END:this._stateCommentEnd(e);break;case ew.COMMENT_END_BANG:this._stateCommentEndBang(e);break;case ew.DOCTYPE:this._stateDoctype(e);break;case ew.BEFORE_DOCTYPE_NAME:this._stateBeforeDoctypeName(e);break;case ew.DOCTYPE_NAME:this._stateDoctypeName(e);break;case ew.AFTER_DOCTYPE_NAME:this._stateAfterDoctypeName(e);break;case ew.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._stateAfterDoctypePublicKeyword(e);break;case ew.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:this._stateBeforeDoctypePublicIdentifier(e);break;case ew.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypePublicIdentifierDoubleQuoted(e);break;case ew.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypePublicIdentifierSingleQuoted(e);break;case ew.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:this._stateAfterDoctypePublicIdentifier(e);break;case ew.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:this._stateBetweenDoctypePublicAndSystemIdentifiers(e);break;case ew.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._stateAfterDoctypeSystemKeyword(e);break;case ew.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:this._stateBeforeDoctypeSystemIdentifier(e);break;case ew.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:this._stateDoctypeSystemIdentifierDoubleQuoted(e);break;case ew.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:this._stateDoctypeSystemIdentifierSingleQuoted(e);break;case ew.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:this._stateAfterDoctypeSystemIdentifier(e);break;case ew.BOGUS_DOCTYPE:this._stateBogusDoctype(e);break;case ew.CDATA_SECTION:this._stateCdataSection(e);break;case ew.CDATA_SECTION_BRACKET:this._stateCdataSectionBracket(e);break;case ew.CDATA_SECTION_END:this._stateCdataSectionEnd(e);break;case ew.CHARACTER_REFERENCE:this._stateCharacterReference();break;case ew.AMBIGUOUS_AMPERSAND:this._stateAmbiguousAmpersand(e);break;default:throw Error("Unknown state")}}_stateData(e){switch(e){case ep.LESS_THAN_SIGN:this.state=ew.TAG_OPEN;break;case ep.AMPERSAND:this._startCharacterReference();break;case ep.NULL:this._err(em.unexpectedNullCharacter),this._emitCodePoint(e);break;case ep.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRcdata(e){switch(e){case ep.AMPERSAND:this._startCharacterReference();break;case ep.LESS_THAN_SIGN:this.state=ew.RCDATA_LESS_THAN_SIGN;break;case ep.NULL:this._err(em.unexpectedNullCharacter),this._emitChars("�");break;case ep.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateRawtext(e){switch(e){case ep.LESS_THAN_SIGN:this.state=ew.RAWTEXT_LESS_THAN_SIGN;break;case ep.NULL:this._err(em.unexpectedNullCharacter),this._emitChars("�");break;case ep.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptData(e){switch(e){case ep.LESS_THAN_SIGN:this.state=ew.SCRIPT_DATA_LESS_THAN_SIGN;break;case ep.NULL:this._err(em.unexpectedNullCharacter),this._emitChars("�");break;case ep.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_statePlaintext(e){switch(e){case ep.NULL:this._err(em.unexpectedNullCharacter),this._emitChars("�");break;case ep.EOF:this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateTagOpen(e){if(kl(e))this._createStartTagToken(),this.state=ew.TAG_NAME,this._stateTagName(e);else switch(e){case ep.EXCLAMATION_MARK:this.state=ew.MARKUP_DECLARATION_OPEN;break;case ep.SOLIDUS:this.state=ew.END_TAG_OPEN;break;case ep.QUESTION_MARK:this._err(em.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=ew.BOGUS_COMMENT,this._stateBogusComment(e);break;case ep.EOF:this._err(em.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break;default:this._err(em.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=ew.DATA,this._stateData(e)}}_stateEndTagOpen(e){if(kl(e))this._createEndTagToken(),this.state=ew.TAG_NAME,this._stateTagName(e);else switch(e){case ep.GREATER_THAN_SIGN:this._err(em.missingEndTagName),this.state=ew.DATA;break;case ep.EOF:this._err(em.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break;default:this._err(em.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=ew.BOGUS_COMMENT,this._stateBogusComment(e)}}_stateTagName(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this.state=ew.BEFORE_ATTRIBUTE_NAME;break;case ep.SOLIDUS:this.state=ew.SELF_CLOSING_START_TAG;break;case ep.GREATER_THAN_SIGN:this.state=ew.DATA,this.emitCurrentTagToken();break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.tagName+="�";break;case ep.EOF:this._err(em.eofInTag),this._emitEOFToken();break;default:t.tagName+=String.fromCodePoint(ko(e)?e+32:e)}}_stateRcdataLessThanSign(e){e===ep.SOLIDUS?this.state=ew.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=ew.RCDATA,this._stateRcdata(e))}_stateRcdataEndTagOpen(e){kl(e)?(this.state=ew.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(e)):(this._emitChars("</"),this.state=ew.RCDATA,this._stateRcdata(e))}handleSpecialEndTag(e){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();switch(this._createEndTagToken(),this.currentToken.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=ew.BEFORE_ATTRIBUTE_NAME,!1;case ep.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=ew.SELF_CLOSING_START_TAG,!1;case ep.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=ew.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ew.RCDATA,this._stateRcdata(e))}_stateRawtextLessThanSign(e){e===ep.SOLIDUS?this.state=ew.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=ew.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagOpen(e){kl(e)?(this.state=ew.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(e)):(this._emitChars("</"),this.state=ew.RAWTEXT,this._stateRawtext(e))}_stateRawtextEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ew.RAWTEXT,this._stateRawtext(e))}_stateScriptDataLessThanSign(e){switch(e){case ep.SOLIDUS:this.state=ew.SCRIPT_DATA_END_TAG_OPEN;break;case ep.EXCLAMATION_MARK:this.state=ew.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break;default:this._emitChars("<"),this.state=ew.SCRIPT_DATA,this._stateScriptData(e)}}_stateScriptDataEndTagOpen(e){kl(e)?(this.state=ew.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(e)):(this._emitChars("</"),this.state=ew.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ew.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStart(e){e===ep.HYPHEN_MINUS?(this.state=ew.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=ew.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscapeStartDash(e){e===ep.HYPHEN_MINUS?(this.state=ew.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=ew.SCRIPT_DATA,this._stateScriptData(e))}_stateScriptDataEscaped(e){switch(e){case ep.HYPHEN_MINUS:this.state=ew.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break;case ep.LESS_THAN_SIGN:this.state=ew.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case ep.NULL:this._err(em.unexpectedNullCharacter),this._emitChars("�");break;case ep.EOF:this._err(em.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataEscapedDash(e){switch(e){case ep.HYPHEN_MINUS:this.state=ew.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break;case ep.LESS_THAN_SIGN:this.state=ew.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.state=ew.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case ep.EOF:this._err(em.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ew.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedDashDash(e){switch(e){case ep.HYPHEN_MINUS:this._emitChars("-");break;case ep.LESS_THAN_SIGN:this.state=ew.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break;case ep.GREATER_THAN_SIGN:this.state=ew.SCRIPT_DATA,this._emitChars(">");break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.state=ew.SCRIPT_DATA_ESCAPED,this._emitChars("�");break;case ep.EOF:this._err(em.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ew.SCRIPT_DATA_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataEscapedLessThanSign(e){e===ep.SOLIDUS?this.state=ew.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:kl(e)?(this._emitChars("<"),this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(e)):(this._emitChars("<"),this.state=ew.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagOpen(e){kl(e)?(this.state=ew.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(e)):(this._emitChars("</"),this.state=ew.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataEscapedEndTagName(e){this.handleSpecialEndTag(e)&&(this._emitChars("</"),this.state=ew.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscapeStart(e){if(this.preprocessor.startsWith(w0,!1)&&kd(this.preprocessor.peek(w0.length))){this._emitCodePoint(e);for(let e=0;e<w0.length;e++)this._emitCodePoint(this._consume());this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=ew.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(e))}_stateScriptDataDoubleEscaped(e){switch(e){case ep.HYPHEN_MINUS:this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break;case ep.LESS_THAN_SIGN:this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case ep.NULL:this._err(em.unexpectedNullCharacter),this._emitChars("�");break;case ep.EOF:this._err(em.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDash(e){switch(e){case ep.HYPHEN_MINUS:this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break;case ep.LESS_THAN_SIGN:this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case ep.EOF:this._err(em.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedDashDash(e){switch(e){case ep.HYPHEN_MINUS:this._emitChars("-");break;case ep.LESS_THAN_SIGN:this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break;case ep.GREATER_THAN_SIGN:this.state=ew.SCRIPT_DATA,this._emitChars(">");break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars("�");break;case ep.EOF:this._err(em.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break;default:this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(e)}}_stateScriptDataDoubleEscapedLessThanSign(e){e===ep.SOLIDUS?(this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateScriptDataDoubleEscapeEnd(e){if(this.preprocessor.startsWith(w0,!1)&&kd(this.preprocessor.peek(w0.length))){this._emitCodePoint(e);for(let e=0;e<w0.length;e++)this._emitCodePoint(this._consume());this.state=ew.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=ew.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(e))}_stateBeforeAttributeName(e){switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.SOLIDUS:case ep.GREATER_THAN_SIGN:case ep.EOF:this.state=ew.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case ep.EQUALS_SIGN:this._err(em.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=ew.ATTRIBUTE_NAME;break;default:this._createAttr(""),this.state=ew.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateAttributeName(e){switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:case ep.SOLIDUS:case ep.GREATER_THAN_SIGN:case ep.EOF:this._leaveAttrName(),this.state=ew.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(e);break;case ep.EQUALS_SIGN:this._leaveAttrName(),this.state=ew.BEFORE_ATTRIBUTE_VALUE;break;case ep.QUOTATION_MARK:case ep.APOSTROPHE:case ep.LESS_THAN_SIGN:this._err(em.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(e);break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.currentAttr.name+="�";break;default:this.currentAttr.name+=String.fromCodePoint(ko(e)?e+32:e)}}_stateAfterAttributeName(e){switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.SOLIDUS:this.state=ew.SELF_CLOSING_START_TAG;break;case ep.EQUALS_SIGN:this.state=ew.BEFORE_ATTRIBUTE_VALUE;break;case ep.GREATER_THAN_SIGN:this.state=ew.DATA,this.emitCurrentTagToken();break;case ep.EOF:this._err(em.eofInTag),this._emitEOFToken();break;default:this._createAttr(""),this.state=ew.ATTRIBUTE_NAME,this._stateAttributeName(e)}}_stateBeforeAttributeValue(e){switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.QUOTATION_MARK:this.state=ew.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break;case ep.APOSTROPHE:this.state=ew.ATTRIBUTE_VALUE_SINGLE_QUOTED;break;case ep.GREATER_THAN_SIGN:this._err(em.missingAttributeValue),this.state=ew.DATA,this.emitCurrentTagToken();break;default:this.state=ew.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(e)}}_stateAttributeValueDoubleQuoted(e){switch(e){case ep.QUOTATION_MARK:this.state=ew.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case ep.AMPERSAND:this._startCharacterReference();break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.currentAttr.value+="�";break;case ep.EOF:this._err(em.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueSingleQuoted(e){switch(e){case ep.APOSTROPHE:this.state=ew.AFTER_ATTRIBUTE_VALUE_QUOTED;break;case ep.AMPERSAND:this._startCharacterReference();break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.currentAttr.value+="�";break;case ep.EOF:this._err(em.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAttributeValueUnquoted(e){switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this._leaveAttrValue(),this.state=ew.BEFORE_ATTRIBUTE_NAME;break;case ep.AMPERSAND:this._startCharacterReference();break;case ep.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=ew.DATA,this.emitCurrentTagToken();break;case ep.NULL:this._err(em.unexpectedNullCharacter),this.currentAttr.value+="�";break;case ep.QUOTATION_MARK:case ep.APOSTROPHE:case ep.LESS_THAN_SIGN:case ep.EQUALS_SIGN:case ep.GRAVE_ACCENT:this._err(em.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(e);break;case ep.EOF:this._err(em.eofInTag),this._emitEOFToken();break;default:this.currentAttr.value+=String.fromCodePoint(e)}}_stateAfterAttributeValueQuoted(e){switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this._leaveAttrValue(),this.state=ew.BEFORE_ATTRIBUTE_NAME;break;case ep.SOLIDUS:this._leaveAttrValue(),this.state=ew.SELF_CLOSING_START_TAG;break;case ep.GREATER_THAN_SIGN:this._leaveAttrValue(),this.state=ew.DATA,this.emitCurrentTagToken();break;case ep.EOF:this._err(em.eofInTag),this._emitEOFToken();break;default:this._err(em.missingWhitespaceBetweenAttributes),this.state=ew.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateSelfClosingStartTag(e){switch(e){case ep.GREATER_THAN_SIGN:this.currentToken.selfClosing=!0,this.state=ew.DATA,this.emitCurrentTagToken();break;case ep.EOF:this._err(em.eofInTag),this._emitEOFToken();break;default:this._err(em.unexpectedSolidusInTag),this.state=ew.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(e)}}_stateBogusComment(e){let t=this.currentToken;switch(e){case ep.GREATER_THAN_SIGN:this.state=ew.DATA,this.emitCurrentComment(t);break;case ep.EOF:this.emitCurrentComment(t),this._emitEOFToken();break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.data+="�";break;default:t.data+=String.fromCodePoint(e)}}_stateMarkupDeclarationOpen(e){this._consumeSequenceIfMatch("--",!0)?(this._createCommentToken(3),this.state=ew.COMMENT_START):this._consumeSequenceIfMatch(wJ,!1)?(this.currentLocation=this.getCurrentLocation(wJ.length+1),this.state=ew.DOCTYPE):this._consumeSequenceIfMatch(wQ,!0)?this.inForeignNode?this.state=ew.CDATA_SECTION:(this._err(em.cdataInHtmlContent),this._createCommentToken(wQ.length+1),this.currentToken.data="[CDATA[",this.state=ew.BOGUS_COMMENT):this._ensureHibernation()||(this._err(em.incorrectlyOpenedComment),this._createCommentToken(2),this.state=ew.BOGUS_COMMENT,this._stateBogusComment(e))}_stateCommentStart(e){switch(e){case ep.HYPHEN_MINUS:this.state=ew.COMMENT_START_DASH;break;case ep.GREATER_THAN_SIGN:{this._err(em.abruptClosingOfEmptyComment),this.state=ew.DATA;let e=this.currentToken;this.emitCurrentComment(e);break}default:this.state=ew.COMMENT,this._stateComment(e)}}_stateCommentStartDash(e){let t=this.currentToken;switch(e){case ep.HYPHEN_MINUS:this.state=ew.COMMENT_END;break;case ep.GREATER_THAN_SIGN:this._err(em.abruptClosingOfEmptyComment),this.state=ew.DATA,this.emitCurrentComment(t);break;case ep.EOF:this._err(em.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=ew.COMMENT,this._stateComment(e)}}_stateComment(e){let t=this.currentToken;switch(e){case ep.HYPHEN_MINUS:this.state=ew.COMMENT_END_DASH;break;case ep.LESS_THAN_SIGN:t.data+="<",this.state=ew.COMMENT_LESS_THAN_SIGN;break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.data+="�";break;case ep.EOF:this._err(em.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+=String.fromCodePoint(e)}}_stateCommentLessThanSign(e){let t=this.currentToken;switch(e){case ep.EXCLAMATION_MARK:t.data+="!",this.state=ew.COMMENT_LESS_THAN_SIGN_BANG;break;case ep.LESS_THAN_SIGN:t.data+="<";break;default:this.state=ew.COMMENT,this._stateComment(e)}}_stateCommentLessThanSignBang(e){e===ep.HYPHEN_MINUS?this.state=ew.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=ew.COMMENT,this._stateComment(e))}_stateCommentLessThanSignBangDash(e){e===ep.HYPHEN_MINUS?this.state=ew.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=ew.COMMENT_END_DASH,this._stateCommentEndDash(e))}_stateCommentLessThanSignBangDashDash(e){e!==ep.GREATER_THAN_SIGN&&e!==ep.EOF&&this._err(em.nestedComment),this.state=ew.COMMENT_END,this._stateCommentEnd(e)}_stateCommentEndDash(e){let t=this.currentToken;switch(e){case ep.HYPHEN_MINUS:this.state=ew.COMMENT_END;break;case ep.EOF:this._err(em.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="-",this.state=ew.COMMENT,this._stateComment(e)}}_stateCommentEnd(e){let t=this.currentToken;switch(e){case ep.GREATER_THAN_SIGN:this.state=ew.DATA,this.emitCurrentComment(t);break;case ep.EXCLAMATION_MARK:this.state=ew.COMMENT_END_BANG;break;case ep.HYPHEN_MINUS:t.data+="-";break;case ep.EOF:this._err(em.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--",this.state=ew.COMMENT,this._stateComment(e)}}_stateCommentEndBang(e){let t=this.currentToken;switch(e){case ep.HYPHEN_MINUS:t.data+="--!",this.state=ew.COMMENT_END_DASH;break;case ep.GREATER_THAN_SIGN:this._err(em.incorrectlyClosedComment),this.state=ew.DATA,this.emitCurrentComment(t);break;case ep.EOF:this._err(em.eofInComment),this.emitCurrentComment(t),this._emitEOFToken();break;default:t.data+="--!",this.state=ew.COMMENT,this._stateComment(e)}}_stateDoctype(e){switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this.state=ew.BEFORE_DOCTYPE_NAME;break;case ep.GREATER_THAN_SIGN:this.state=ew.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e);break;case ep.EOF:{this._err(em.eofInDoctype),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this._emitEOFToken();break}default:this._err(em.missingWhitespaceBeforeDoctypeName),this.state=ew.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(e)}}_stateBeforeDoctypeName(e){if(ko(e))this._createDoctypeToken(String.fromCharCode(e+32)),this.state=ew.DOCTYPE_NAME;else switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.NULL:this._err(em.unexpectedNullCharacter),this._createDoctypeToken("�"),this.state=ew.DOCTYPE_NAME;break;case ep.GREATER_THAN_SIGN:{this._err(em.missingDoctypeName),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this.state=ew.DATA;break}case ep.EOF:{this._err(em.eofInDoctype),this._createDoctypeToken(null);let e=this.currentToken;e.forceQuirks=!0,this.emitCurrentDoctype(e),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(e)),this.state=ew.DOCTYPE_NAME}}_stateDoctypeName(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this.state=ew.AFTER_DOCTYPE_NAME;break;case ep.GREATER_THAN_SIGN:this.state=ew.DATA,this.emitCurrentDoctype(t);break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.name+="�";break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.name+=String.fromCodePoint(ko(e)?e+32:e)}}_stateAfterDoctypeName(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.GREATER_THAN_SIGN:this.state=ew.DATA,this.emitCurrentDoctype(t);break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._consumeSequenceIfMatch("public",!1)?this.state=ew.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch("system",!1)?this.state=ew.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(em.invalidCharacterSequenceAfterDoctypeName),t.forceQuirks=!0,this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e))}}_stateAfterDoctypePublicKeyword(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this.state=ew.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break;case ep.QUOTATION_MARK:this._err(em.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=ew.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case ep.APOSTROPHE:this._err(em.missingWhitespaceAfterDoctypePublicKeyword),t.publicId="",this.state=ew.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case ep.GREATER_THAN_SIGN:this._err(em.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ew.DATA,this.emitCurrentDoctype(t);break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(em.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypePublicIdentifier(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.QUOTATION_MARK:t.publicId="",this.state=ew.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break;case ep.APOSTROPHE:t.publicId="",this.state=ew.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break;case ep.GREATER_THAN_SIGN:this._err(em.missingDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ew.DATA,this.emitCurrentDoctype(t);break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(em.missingQuoteBeforeDoctypePublicIdentifier),t.forceQuirks=!0,this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypePublicIdentifierDoubleQuoted(e){let t=this.currentToken;switch(e){case ep.QUOTATION_MARK:this.state=ew.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.publicId+="�";break;case ep.GREATER_THAN_SIGN:this._err(em.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ew.DATA;break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateDoctypePublicIdentifierSingleQuoted(e){let t=this.currentToken;switch(e){case ep.APOSTROPHE:this.state=ew.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.publicId+="�";break;case ep.GREATER_THAN_SIGN:this._err(em.abruptDoctypePublicIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ew.DATA;break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.publicId+=String.fromCodePoint(e)}}_stateAfterDoctypePublicIdentifier(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this.state=ew.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break;case ep.GREATER_THAN_SIGN:this.state=ew.DATA,this.emitCurrentDoctype(t);break;case ep.QUOTATION_MARK:this._err(em.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case ep.APOSTROPHE:this._err(em.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(em.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBetweenDoctypePublicAndSystemIdentifiers(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ew.DATA;break;case ep.QUOTATION_MARK:t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case ep.APOSTROPHE:t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(em.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateAfterDoctypeSystemKeyword(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:this.state=ew.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break;case ep.QUOTATION_MARK:this._err(em.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case ep.APOSTROPHE:this._err(em.missingWhitespaceAfterDoctypeSystemKeyword),t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case ep.GREATER_THAN_SIGN:this._err(em.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ew.DATA,this.emitCurrentDoctype(t);break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(em.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBeforeDoctypeSystemIdentifier(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.QUOTATION_MARK:t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break;case ep.APOSTROPHE:t.systemId="",this.state=ew.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break;case ep.GREATER_THAN_SIGN:this._err(em.missingDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ew.DATA,this.emitCurrentDoctype(t);break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(em.missingQuoteBeforeDoctypeSystemIdentifier),t.forceQuirks=!0,this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateDoctypeSystemIdentifierDoubleQuoted(e){let t=this.currentToken;switch(e){case ep.QUOTATION_MARK:this.state=ew.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.systemId+="�";break;case ep.GREATER_THAN_SIGN:this._err(em.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ew.DATA;break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateDoctypeSystemIdentifierSingleQuoted(e){let t=this.currentToken;switch(e){case ep.APOSTROPHE:this.state=ew.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break;case ep.NULL:this._err(em.unexpectedNullCharacter),t.systemId+="�";break;case ep.GREATER_THAN_SIGN:this._err(em.abruptDoctypeSystemIdentifier),t.forceQuirks=!0,this.emitCurrentDoctype(t),this.state=ew.DATA;break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:t.systemId+=String.fromCodePoint(e)}}_stateAfterDoctypeSystemIdentifier(e){let t=this.currentToken;switch(e){case ep.SPACE:case ep.LINE_FEED:case ep.TABULATION:case ep.FORM_FEED:break;case ep.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ew.DATA;break;case ep.EOF:this._err(em.eofInDoctype),t.forceQuirks=!0,this.emitCurrentDoctype(t),this._emitEOFToken();break;default:this._err(em.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=ew.BOGUS_DOCTYPE,this._stateBogusDoctype(e)}}_stateBogusDoctype(e){let t=this.currentToken;switch(e){case ep.GREATER_THAN_SIGN:this.emitCurrentDoctype(t),this.state=ew.DATA;break;case ep.NULL:this._err(em.unexpectedNullCharacter);break;case ep.EOF:this.emitCurrentDoctype(t),this._emitEOFToken()}}_stateCdataSection(e){switch(e){case ep.RIGHT_SQUARE_BRACKET:this.state=ew.CDATA_SECTION_BRACKET;break;case ep.EOF:this._err(em.eofInCdata),this._emitEOFToken();break;default:this._emitCodePoint(e)}}_stateCdataSectionBracket(e){e===ep.RIGHT_SQUARE_BRACKET?this.state=ew.CDATA_SECTION_END:(this._emitChars("]"),this.state=ew.CDATA_SECTION,this._stateCdataSection(e))}_stateCdataSectionEnd(e){switch(e){case ep.GREATER_THAN_SIGN:this.state=ew.DATA;break;case ep.RIGHT_SQUARE_BRACKET:this._emitChars("]");break;default:this._emitChars("]]"),this.state=ew.CDATA_SECTION,this._stateCdataSection(e)}}_stateCharacterReference(){let e=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(e<0)if(this.preprocessor.lastChunkWritten)e=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}0===e?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(ep.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&kc(this.preprocessor.peek(1))?ew.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(e){kc(e)?this._flushCodePointConsumedAsCharacterReference(e):(e===ep.SEMICOLON&&this._err(em.unknownNamedCharacterReference),this.state=this.returnState,this._callState(e))}}let km=new Set([eS.DD,eS.DT,eS.LI,eS.OPTGROUP,eS.OPTION,eS.P,eS.RB,eS.RP,eS.RT,eS.RTC]),kh=new Set([...km,eS.CAPTION,eS.COLGROUP,eS.TBODY,eS.TD,eS.TFOOT,eS.TH,eS.THEAD,eS.TR]),kf=new Set([eS.APPLET,eS.CAPTION,eS.HTML,eS.MARQUEE,eS.OBJECT,eS.TABLE,eS.TD,eS.TEMPLATE,eS.TH]),kg=new Set([...kf,eS.OL,eS.UL]),kb=new Set([...kf,eS.BUTTON]),ky=new Set([eS.ANNOTATION_XML,eS.MI,eS.MN,eS.MO,eS.MS,eS.MTEXT]),kE=new Set([eS.DESC,eS.FOREIGN_OBJECT,eS.TITLE]),k_=new Set([eS.TR,eS.TEMPLATE,eS.HTML]),kv=new Set([eS.TBODY,eS.TFOOT,eS.THEAD,eS.TEMPLATE,eS.HTML]),kx=new Set([eS.TABLE,eS.TEMPLATE,eS.HTML]),kT=new Set([eS.TD,eS.TH]);class kS{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(e,t,r){this.treeAdapter=t,this.handler=r,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=eS.UNKNOWN,this.current=e}_indexOf(e){return this.items.lastIndexOf(e,this.stackTop)}_isInTemplate(){return this.currentTagId===eS.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===e_.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(e,t){this.stackTop++,this.items[this.stackTop]=e,this.current=e,this.tagIDs[this.stackTop]=t,this.currentTagId=t,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(e,t,!0)}pop(){let e=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!0)}replace(e,t){let r=this._indexOf(e);this.items[r]=t,r===this.stackTop&&(this.current=t)}insertAfter(e,t,r){let n=this._indexOf(e)+1;this.items.splice(n,0,t),this.tagIDs.splice(n,0,r),this.stackTop++,n===this.stackTop&&this._updateCurrentElement(),this.current&&void 0!==this.currentTagId&&this.handler.onItemPush(this.current,this.currentTagId,n===this.stackTop)}popUntilTagNamePopped(e){let t=this.stackTop+1;do t=this.tagIDs.lastIndexOf(e,t-1);while(t>0&&this.treeAdapter.getNamespaceURI(this.items[t])!==e_.HTML)this.shortenToLength(Math.max(t,0))}shortenToLength(e){for(;this.stackTop>=e;){let t=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,this.stackTop<e)}}popUntilElementPopped(e){let t=this._indexOf(e);this.shortenToLength(Math.max(t,0))}popUntilPopped(e,t){let r=this._indexOfTagNames(e,t);this.shortenToLength(Math.max(r,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(ka,e_.HTML)}popUntilTableCellPopped(){this.popUntilPopped(kT,e_.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(e,t){for(let r=this.stackTop;r>=0;r--)if(e.has(this.tagIDs[r])&&this.treeAdapter.getNamespaceURI(this.items[r])===t)return r;return -1}clearBackTo(e,t){let r=this._indexOfTagNames(e,t);this.shortenToLength(r+1)}clearBackToTableContext(){this.clearBackTo(kx,e_.HTML)}clearBackToTableBodyContext(){this.clearBackTo(kv,e_.HTML)}clearBackToTableRowContext(){this.clearBackTo(k_,e_.HTML)}remove(e){let t=this._indexOf(e);t>=0&&(t===this.stackTop?this.pop():(this.items.splice(t,1),this.tagIDs.splice(t,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(e,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===eS.BODY?this.items[1]:null}contains(e){return this._indexOf(e)>-1}getCommonAncestor(e){let t=this._indexOf(e)-1;return t>=0?this.items[t]:null}isRootHtmlElementCurrent(){return 0===this.stackTop&&this.tagIDs[0]===eS.HTML}hasInDynamicScope(e,t){for(let r=this.stackTop;r>=0;r--){let n=this.tagIDs[r];switch(this.treeAdapter.getNamespaceURI(this.items[r])){case e_.HTML:if(n===e)return!0;if(t.has(n))return!1;break;case e_.SVG:if(kE.has(n))return!1;break;case e_.MATHML:if(ky.has(n))return!1}}return!0}hasInScope(e){return this.hasInDynamicScope(e,kf)}hasInListItemScope(e){return this.hasInDynamicScope(e,kg)}hasInButtonScope(e){return this.hasInDynamicScope(e,kb)}hasNumberedHeaderInScope(){for(let e=this.stackTop;e>=0;e--){let t=this.tagIDs[e];switch(this.treeAdapter.getNamespaceURI(this.items[e])){case e_.HTML:if(ka.has(t))return!0;if(kf.has(t))return!1;break;case e_.SVG:if(kE.has(t))return!1;break;case e_.MATHML:if(ky.has(t))return!1}}return!0}hasInTableScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===e_.HTML)switch(this.tagIDs[t]){case e:return!0;case eS.TABLE:case eS.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let e=this.stackTop;e>=0;e--)if(this.treeAdapter.getNamespaceURI(this.items[e])===e_.HTML)switch(this.tagIDs[e]){case eS.TBODY:case eS.THEAD:case eS.TFOOT:return!0;case eS.TABLE:case eS.HTML:return!1}return!0}hasInSelectScope(e){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===e_.HTML)switch(this.tagIDs[t]){case e:return!0;case eS.OPTION:case eS.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;void 0!==this.currentTagId&&km.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;void 0!==this.currentTagId&&kh.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(e){for(;void 0!==this.currentTagId&&this.currentTagId!==e&&kh.has(this.currentTagId);)this.pop()}}(Q=ek||(ek={}))[Q.Marker=0]="Marker",Q[Q.Element=1]="Element";let kw={type:ek.Marker};class kk{constructor(e){this.treeAdapter=e,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(e,t){let r=[],n=t.length,a=this.treeAdapter.getTagName(e),i=this.treeAdapter.getNamespaceURI(e);for(let e=0;e<this.entries.length;e++){let t=this.entries[e];if(t.type===ek.Marker)break;let{element:s}=t;if(this.treeAdapter.getTagName(s)===a&&this.treeAdapter.getNamespaceURI(s)===i){let t=this.treeAdapter.getAttrList(s);t.length===n&&r.push({idx:e,attrs:t})}}return r}_ensureNoahArkCondition(e){if(this.entries.length<3)return;let t=this.treeAdapter.getAttrList(e),r=this._getNoahArkConditionCandidates(e,t);if(r.length<3)return;let n=new Map(t.map(e=>[e.name,e.value])),a=0;for(let e=0;e<r.length;e++){let t=r[e];t.attrs.every(e=>n.get(e.name)===e.value)&&(a+=1)>=3&&this.entries.splice(t.idx,1)}}insertMarker(){this.entries.unshift(kw)}pushElement(e,t){this._ensureNoahArkCondition(e),this.entries.unshift({type:ek.Element,element:e,token:t})}insertElementAfterBookmark(e,t){let r=this.entries.indexOf(this.bookmark);this.entries.splice(r,0,{type:ek.Element,element:e,token:t})}removeEntry(e){let t=this.entries.indexOf(e);-1!==t&&this.entries.splice(t,1)}clearToLastMarker(){let e=this.entries.indexOf(kw);-1===e?this.entries.length=0:this.entries.splice(0,e+1)}getElementEntryInScopeWithTagName(e){let t=this.entries.find(t=>t.type===ek.Marker||this.treeAdapter.getTagName(t.element)===e);return t&&t.type===ek.Element?t:null}getElementEntry(e){return this.entries.find(t=>t.type===ek.Element&&t.element===e)}}let kA={createDocument:()=>({nodeName:"#document",mode:ex.NO_QUIRKS,childNodes:[]}),createDocumentFragment:()=>({nodeName:"#document-fragment",childNodes:[]}),createElement:(e,t,r)=>({nodeName:e,tagName:e,attrs:r,namespaceURI:t,childNodes:[],parentNode:null}),createCommentNode:e=>({nodeName:"#comment",data:e,parentNode:null}),createTextNode:e=>({nodeName:"#text",value:e,parentNode:null}),appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,r){let n=e.childNodes.indexOf(r);e.childNodes.splice(n,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent:e=>e.content,setDocumentType(e,t,r,n){let a=e.childNodes.find(e=>"#documentType"===e.nodeName);a?(a.name=t,a.publicId=r,a.systemId=n):kA.appendChild(e,{nodeName:"#documentType",name:t,publicId:r,systemId:n,parentNode:null})},setDocumentMode(e,t){e.mode=t},getDocumentMode:e=>e.mode,detachNode(e){if(e.parentNode){let t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){let r=e.childNodes[e.childNodes.length-1];if(kA.isTextNode(r)){r.value+=t;return}}kA.appendChild(e,kA.createTextNode(t))},insertTextBefore(e,t,r){let n=e.childNodes[e.childNodes.indexOf(r)-1];n&&kA.isTextNode(n)?n.value+=t:kA.insertBefore(e,kA.createTextNode(t),r)},adoptAttributes(e,t){let r=new Set(e.attrs.map(e=>e.name));for(let n=0;n<t.length;n++)r.has(t[n].name)||e.attrs.push(t[n])},getFirstChild:e=>e.childNodes[0],getChildNodes:e=>e.childNodes,getParentNode:e=>e.parentNode,getAttrList:e=>e.attrs,getTagName:e=>e.tagName,getNamespaceURI:e=>e.namespaceURI,getTextNodeContent:e=>e.value,getCommentNodeContent:e=>e.data,getDocumentTypeNodeName:e=>e.name,getDocumentTypeNodePublicId:e=>e.publicId,getDocumentTypeNodeSystemId:e=>e.systemId,isTextNode:e=>"#text"===e.nodeName,isCommentNode:e=>"#comment"===e.nodeName,isDocumentTypeNode:e=>"#documentType"===e.nodeName,isElementNode:e=>Object.prototype.hasOwnProperty.call(e,"tagName"),setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation:e=>e.sourceCodeLocation,updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},kN="html",kI=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],kC=[...kI,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],kR=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),kO=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],kL=[...kO,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function kD(e,t){return t.some(t=>e.startsWith(t))}let kP=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),kM=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:e_.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:e_.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:e_.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:e_.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:e_.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:e_.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:e_.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:e_.XML}],["xml:space",{prefix:"xml",name:"space",namespace:e_.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:e_.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:e_.XMLNS}]]),kj=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),kF=new Set([eS.B,eS.BIG,eS.BLOCKQUOTE,eS.BODY,eS.BR,eS.CENTER,eS.CODE,eS.DD,eS.DIV,eS.DL,eS.DT,eS.EM,eS.EMBED,eS.H1,eS.H2,eS.H3,eS.H4,eS.H5,eS.H6,eS.HEAD,eS.HR,eS.I,eS.IMG,eS.LI,eS.LISTING,eS.MENU,eS.META,eS.NOBR,eS.OL,eS.P,eS.PRE,eS.RUBY,eS.S,eS.SMALL,eS.SPAN,eS.STRONG,eS.STRIKE,eS.SUB,eS.SUP,eS.TABLE,eS.TT,eS.U,eS.UL,eS.VAR]);function kU(e){for(let t=0;t<e.attrs.length;t++)if("definitionurl"===e.attrs[t].name){e.attrs[t].name="definitionURL";break}}function kB(e){for(let t=0;t<e.attrs.length;t++){let r=kP.get(e.attrs[t].name);null!=r&&(e.attrs[t].name=r)}}function k$(e){for(let t=0;t<e.attrs.length;t++){let r=kM.get(e.attrs[t].name);r&&(e.attrs[t].prefix=r.prefix,e.attrs[t].name=r.name,e.attrs[t].namespace=r.namespace)}}(J=eA||(eA={}))[J.INITIAL=0]="INITIAL",J[J.BEFORE_HTML=1]="BEFORE_HTML",J[J.BEFORE_HEAD=2]="BEFORE_HEAD",J[J.IN_HEAD=3]="IN_HEAD",J[J.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",J[J.AFTER_HEAD=5]="AFTER_HEAD",J[J.IN_BODY=6]="IN_BODY",J[J.TEXT=7]="TEXT",J[J.IN_TABLE=8]="IN_TABLE",J[J.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",J[J.IN_CAPTION=10]="IN_CAPTION",J[J.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",J[J.IN_TABLE_BODY=12]="IN_TABLE_BODY",J[J.IN_ROW=13]="IN_ROW",J[J.IN_CELL=14]="IN_CELL",J[J.IN_SELECT=15]="IN_SELECT",J[J.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",J[J.IN_TEMPLATE=17]="IN_TEMPLATE",J[J.AFTER_BODY=18]="AFTER_BODY",J[J.IN_FRAMESET=19]="IN_FRAMESET",J[J.AFTER_FRAMESET=20]="AFTER_FRAMESET",J[J.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",J[J.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET";let kz={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},kH=new Set([eS.TABLE,eS.TBODY,eS.TFOOT,eS.THEAD,eS.TR]),kG={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:kA,onParseError:null};class kq{constructor(e,t,r=null,n=null){this.fragmentContext=r,this.scriptHandler=n,this.currentToken=null,this.stopped=!1,this.insertionMode=eA.INITIAL,this.originalInsertionMode=eA.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...kG,...e},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=null!=t?t:this.treeAdapter.createDocument(),this.tokenizer=new kp(this.options,this),this.activeFormattingElements=new kk(this.treeAdapter),this.fragmentContextID=r?kt(this.treeAdapter.getTagName(r)):eS.UNKNOWN,this._setContextModes(null!=r?r:this.document,this.fragmentContextID),this.openElements=new kS(this.document,this.treeAdapter,this)}static parse(e,t){let r=new this(t);return r.tokenizer.write(e,!0),r.document}static getFragmentParser(e,t){let r={...kG,...t};null!=e||(e=r.treeAdapter.createElement(eT.TEMPLATE,e_.HTML,[]));let n=r.treeAdapter.createElement("documentmock",e_.HTML,[]),a=new this(r,n,e);return a.fragmentContextID===eS.TEMPLATE&&a.tmplInsertionModeStack.unshift(eA.IN_TEMPLATE),a._initTokenizerForFragmentParsing(),a._insertFakeRootElement(),a._resetInsertionMode(),a._findFormInFragmentContext(),a}getFragment(){let e=this.treeAdapter.getFirstChild(this.document),t=this.treeAdapter.createDocumentFragment();return this._adoptNodes(e,t),t}_err(e,t,r){var n;if(!this.onParseError)return;let a=null!=(n=e.location)?n:kz,i={code:t,startLine:a.startLine,startCol:a.startCol,startOffset:a.startOffset,endLine:r?a.startLine:a.endLine,endCol:r?a.startCol:a.endCol,endOffset:r?a.startOffset:a.endOffset};this.onParseError(i)}onItemPush(e,t,r){var n,a;null==(a=(n=this.treeAdapter).onItemPush)||a.call(n,e),r&&this.openElements.stackTop>0&&this._setContextModes(e,t)}onItemPop(e,t){var r,n;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(e,this.currentToken),null==(n=(r=this.treeAdapter).onItemPop)||n.call(r,e,this.openElements.current),t){let e,t;0===this.openElements.stackTop&&this.fragmentContext?(e=this.fragmentContext,t=this.fragmentContextID):{current:e,currentTagId:t}=this.openElements,this._setContextModes(e,t)}}_setContextModes(e,t){let r=e===this.document||e&&this.treeAdapter.getNamespaceURI(e)===e_.HTML;this.currentNotInHTML=!r,this.tokenizer.inForeignNode=!r&&void 0!==e&&void 0!==t&&!this._isIntegrationPoint(t,e)}_switchToTextParsing(e,t){this._insertElement(e,e_.HTML),this.tokenizer.state=t,this.originalInsertionMode=this.insertionMode,this.insertionMode=eA.TEXT}switchToPlaintextParsing(){this.insertionMode=eA.TEXT,this.originalInsertionMode=eA.IN_BODY,this.tokenizer.state=ks.PLAINTEXT}_getAdjustedCurrentElement(){return 0===this.openElements.stackTop&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let e=this.fragmentContext;for(;e;){if(this.treeAdapter.getTagName(e)===eT.FORM){this.formElement=e;break}e=this.treeAdapter.getParentNode(e)}}_initTokenizerForFragmentParsing(){if(this.fragmentContext&&this.treeAdapter.getNamespaceURI(this.fragmentContext)===e_.HTML)switch(this.fragmentContextID){case eS.TITLE:case eS.TEXTAREA:this.tokenizer.state=ks.RCDATA;break;case eS.STYLE:case eS.XMP:case eS.IFRAME:case eS.NOEMBED:case eS.NOFRAMES:case eS.NOSCRIPT:this.tokenizer.state=ks.RAWTEXT;break;case eS.SCRIPT:this.tokenizer.state=ks.SCRIPT_DATA;break;case eS.PLAINTEXT:this.tokenizer.state=ks.PLAINTEXT}}_setDocumentType(e){let t=e.name||"",r=e.publicId||"",n=e.systemId||"";if(this.treeAdapter.setDocumentType(this.document,t,r,n),e.location){let t=this.treeAdapter.getChildNodes(this.document).find(e=>this.treeAdapter.isDocumentTypeNode(e));t&&this.treeAdapter.setNodeSourceCodeLocation(t,e.location)}}_attachElementToTree(e,t){if(this.options.sourceCodeLocationInfo){let r=t&&{...t,startTag:t};this.treeAdapter.setNodeSourceCodeLocation(e,r)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(e);else{let t=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(null!=t?t:this.document,e)}}_appendElement(e,t){let r=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(r,e.location)}_insertElement(e,t){let r=this.treeAdapter.createElement(e.tagName,t,e.attrs);this._attachElementToTree(r,e.location),this.openElements.push(r,e.tagID)}_insertFakeElement(e,t){let r=this.treeAdapter.createElement(e,e_.HTML,[]);this._attachElementToTree(r,null),this.openElements.push(r,t)}_insertTemplate(e){let t=this.treeAdapter.createElement(e.tagName,e_.HTML,e.attrs),r=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(t,r),this._attachElementToTree(t,e.location),this.openElements.push(t,e.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,null)}_insertFakeRootElement(){let e=this.treeAdapter.createElement(eT.HTML,e_.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(e,null),this.treeAdapter.appendChild(this.openElements.current,e),this.openElements.push(e,eS.HTML)}_appendCommentNode(e,t){let r=this.treeAdapter.createCommentNode(e.data);this.treeAdapter.appendChild(t,r),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(r,e.location)}_insertCharacters(e){let t,r;if(this._shouldFosterParentOnInsertion()?({parent:t,beforeElement:r}=this._findFosterParentingLocation(),r?this.treeAdapter.insertTextBefore(t,e.chars,r):this.treeAdapter.insertText(t,e.chars)):(t=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(t,e.chars)),!e.location)return;let n=this.treeAdapter.getChildNodes(t),a=r?n.lastIndexOf(r):n.length,i=n[a-1];if(this.treeAdapter.getNodeSourceCodeLocation(i)){let{endLine:t,endCol:r,endOffset:n}=e.location;this.treeAdapter.updateNodeSourceCodeLocation(i,{endLine:t,endCol:r,endOffset:n})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,e.location)}_adoptNodes(e,t){for(let r=this.treeAdapter.getFirstChild(e);r;r=this.treeAdapter.getFirstChild(e))this.treeAdapter.detachNode(r),this.treeAdapter.appendChild(t,r)}_setEndLocation(e,t){if(this.treeAdapter.getNodeSourceCodeLocation(e)&&t.location){let r=t.location,n=this.treeAdapter.getTagName(e),a=t.type===eh.END_TAG&&n===t.tagName?{endTag:{...r},endLine:r.endLine,endCol:r.endCol,endOffset:r.endOffset}:{endLine:r.startLine,endCol:r.startCol,endOffset:r.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(e,a)}}shouldProcessStartTagTokenInForeignContent(e){let t,r;return!!this.currentNotInHTML&&(0===this.openElements.stackTop&&this.fragmentContext?(t=this.fragmentContext,r=this.fragmentContextID):{current:t,currentTagId:r}=this.openElements,(e.tagID!==eS.SVG||this.treeAdapter.getTagName(t)!==eT.ANNOTATION_XML||this.treeAdapter.getNamespaceURI(t)!==e_.MATHML)&&(this.tokenizer.inForeignNode||(e.tagID===eS.MGLYPH||e.tagID===eS.MALIGNMARK)&&void 0!==r&&!this._isIntegrationPoint(r,t,e_.HTML)))}_processToken(e){switch(e.type){case eh.CHARACTER:this.onCharacter(e);break;case eh.NULL_CHARACTER:this.onNullCharacter(e);break;case eh.COMMENT:this.onComment(e);break;case eh.DOCTYPE:this.onDoctype(e);break;case eh.START_TAG:this._processStartTag(e);break;case eh.END_TAG:this.onEndTag(e);break;case eh.EOF:this.onEof(e);break;case eh.WHITESPACE_CHARACTER:this.onWhitespaceCharacter(e)}}_isIntegrationPoint(e,t,r){let n=this.treeAdapter.getNamespaceURI(t),a=this.treeAdapter.getAttrList(t);return(!r||r===e_.HTML)&&function(e,t,r){if(t===e_.MATHML&&e===eS.ANNOTATION_XML){for(let e=0;e<r.length;e++)if(r[e].name===ev.ENCODING){let t=r[e].value.toLowerCase();return"text/html"===t||"application/xhtml+xml"===t}}return t===e_.SVG&&(e===eS.FOREIGN_OBJECT||e===eS.DESC||e===eS.TITLE)}(e,n,a)||(!r||r===e_.MATHML)&&n===e_.MATHML&&(e===eS.MI||e===eS.MO||e===eS.MN||e===eS.MS||e===eS.MTEXT)}_reconstructActiveFormattingElements(){let e=this.activeFormattingElements.entries.length;if(e){let t=this.activeFormattingElements.entries.findIndex(e=>e.type===ek.Marker||this.openElements.contains(e.element)),r=-1===t?e-1:t-1;for(let e=r;e>=0;e--){let t=this.activeFormattingElements.entries[e];this._insertElement(t.token,this.treeAdapter.getNamespaceURI(t.element)),t.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=eA.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(eS.P),this.openElements.popUntilTagNamePopped(eS.P)}_resetInsertionMode(){for(let e=this.openElements.stackTop;e>=0;e--)switch(0===e&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[e]){case eS.TR:this.insertionMode=eA.IN_ROW;return;case eS.TBODY:case eS.THEAD:case eS.TFOOT:this.insertionMode=eA.IN_TABLE_BODY;return;case eS.CAPTION:this.insertionMode=eA.IN_CAPTION;return;case eS.COLGROUP:this.insertionMode=eA.IN_COLUMN_GROUP;return;case eS.TABLE:this.insertionMode=eA.IN_TABLE;return;case eS.BODY:this.insertionMode=eA.IN_BODY;return;case eS.FRAMESET:this.insertionMode=eA.IN_FRAMESET;return;case eS.SELECT:return void this._resetInsertionModeForSelect(e);case eS.TEMPLATE:this.insertionMode=this.tmplInsertionModeStack[0];return;case eS.HTML:this.insertionMode=this.headElement?eA.AFTER_HEAD:eA.BEFORE_HEAD;return;case eS.TD:case eS.TH:if(e>0){this.insertionMode=eA.IN_CELL;return}break;case eS.HEAD:if(e>0){this.insertionMode=eA.IN_HEAD;return}}this.insertionMode=eA.IN_BODY}_resetInsertionModeForSelect(e){if(e>0)for(let t=e-1;t>0;t--){let e=this.openElements.tagIDs[t];if(e===eS.TEMPLATE)break;if(e===eS.TABLE){this.insertionMode=eA.IN_SELECT_IN_TABLE;return}}this.insertionMode=eA.IN_SELECT}_isElementCausesFosterParenting(e){return kH.has(e)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&void 0!==this.openElements.currentTagId&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let e=this.openElements.stackTop;e>=0;e--){let t=this.openElements.items[e];switch(this.openElements.tagIDs[e]){case eS.TEMPLATE:if(this.treeAdapter.getNamespaceURI(t)===e_.HTML)return{parent:this.treeAdapter.getTemplateContent(t),beforeElement:null};break;case eS.TABLE:{let r=this.treeAdapter.getParentNode(t);if(r)return{parent:r,beforeElement:t};return{parent:this.openElements.items[e-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(e){let t=this._findFosterParentingLocation();t.beforeElement?this.treeAdapter.insertBefore(t.parent,e,t.beforeElement):this.treeAdapter.appendChild(t.parent,e)}_isSpecialElement(e,t){return kn[this.treeAdapter.getNamespaceURI(e)].has(t)}onCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){var t,r;return void(t=this,r=e,t._insertCharacters(r),t.framesetOk=!1)}switch(this.insertionMode){case eA.INITIAL:kK(this,e);break;case eA.BEFORE_HTML:kZ(this,e);break;case eA.BEFORE_HEAD:kX(this,e);break;case eA.IN_HEAD:k0(this,e);break;case eA.IN_HEAD_NO_SCRIPT:k1(this,e);break;case eA.AFTER_HEAD:k2(this,e);break;case eA.IN_BODY:case eA.IN_CAPTION:case eA.IN_CELL:case eA.IN_TEMPLATE:k5(this,e);break;case eA.TEXT:case eA.IN_SELECT:case eA.IN_SELECT_IN_TABLE:this._insertCharacters(e);break;case eA.IN_TABLE:case eA.IN_TABLE_BODY:case eA.IN_ROW:Aa(this,e);break;case eA.IN_TABLE_TEXT:Ac(this,e);break;case eA.IN_COLUMN_GROUP:Am(this,e);break;case eA.AFTER_BODY:Ax(this,e);break;case eA.AFTER_AFTER_BODY:AT(this,e)}}onNullCharacter(e){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){var t,r;return void(t=this,(r=e).chars="�",t._insertCharacters(r))}switch(this.insertionMode){case eA.INITIAL:kK(this,e);break;case eA.BEFORE_HTML:kZ(this,e);break;case eA.BEFORE_HEAD:kX(this,e);break;case eA.IN_HEAD:k0(this,e);break;case eA.IN_HEAD_NO_SCRIPT:k1(this,e);break;case eA.AFTER_HEAD:k2(this,e);break;case eA.TEXT:this._insertCharacters(e);break;case eA.IN_TABLE:case eA.IN_TABLE_BODY:case eA.IN_ROW:Aa(this,e);break;case eA.IN_COLUMN_GROUP:Am(this,e);break;case eA.AFTER_BODY:Ax(this,e);break;case eA.AFTER_AFTER_BODY:AT(this,e)}}onComment(e){var t,r,n,a;if(this.skipNextNewLine=!1,this.currentNotInHTML)return void kW(this,e);switch(this.insertionMode){case eA.INITIAL:case eA.BEFORE_HTML:case eA.BEFORE_HEAD:case eA.IN_HEAD:case eA.IN_HEAD_NO_SCRIPT:case eA.AFTER_HEAD:case eA.IN_BODY:case eA.IN_TABLE:case eA.IN_CAPTION:case eA.IN_COLUMN_GROUP:case eA.IN_TABLE_BODY:case eA.IN_ROW:case eA.IN_CELL:case eA.IN_SELECT:case eA.IN_SELECT_IN_TABLE:case eA.IN_TEMPLATE:case eA.IN_FRAMESET:case eA.AFTER_FRAMESET:kW(this,e);break;case eA.IN_TABLE_TEXT:Au(this,e);break;case eA.AFTER_BODY:t=this,r=e,t._appendCommentNode(r,t.openElements.items[0]);break;case eA.AFTER_AFTER_BODY:case eA.AFTER_AFTER_FRAMESET:n=this,a=e,n._appendCommentNode(a,n.document)}}onDoctype(e){switch(this.skipNextNewLine=!1,this.insertionMode){case eA.INITIAL:!function(e,t){e._setDocumentType(t);let r=t.forceQuirks?ex.QUIRKS:function(e){if(e.name!==kN)return ex.QUIRKS;let{systemId:t}=e;if(t&&"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"===t.toLowerCase())return ex.QUIRKS;let{publicId:r}=e;if(null!==r){if(r=r.toLowerCase(),kR.has(r))return ex.QUIRKS;let e=null===t?kC:kI;if(kD(r,e))return ex.QUIRKS;if(kD(r,e=null===t?kO:kL))return ex.LIMITED_QUIRKS}return ex.NO_QUIRKS}(t);(t.name!==kN||null!==t.publicId||null!==t.systemId&&"about:legacy-compat"!==t.systemId)&&e._err(t,em.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,r),e.insertionMode=eA.BEFORE_HTML}(this,e);break;case eA.BEFORE_HEAD:case eA.IN_HEAD:case eA.IN_HEAD_NO_SCRIPT:case eA.AFTER_HEAD:this._err(e,em.misplacedDoctype);break;case eA.IN_TABLE_TEXT:Au(this,e)}}onStartTag(e){this.skipNextNewLine=!1,this.currentToken=e,this._processStartTag(e),e.selfClosing&&!e.ackSelfClosing&&this._err(e,em.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(e){this.shouldProcessStartTagTokenInForeignContent(e)?function(e,t){let r;if((r=t.tagID)===eS.FONT&&t.attrs.some(({name:e})=>e===ev.COLOR||e===ev.SIZE||e===ev.FACE)||kF.has(r))AS(e),e._startTagOutsideForeignContent(t);else{let r=e._getAdjustedCurrentElement(),n=e.treeAdapter.getNamespaceURI(r);if(n===e_.MATHML)kU(t);else if(n===e_.SVG){let e;null!=(e=kj.get(t.tagName))&&(t.tagName=e,t.tagID=kt(t.tagName)),kB(t)}k$(t),t.selfClosing?e._appendElement(t,n):e._insertElement(t,n),t.ackSelfClosing=!0}}(this,e):this._startTagOutsideForeignContent(e)}_startTagOutsideForeignContent(e){switch(this.insertionMode){case eA.INITIAL:kK(this,e);break;case eA.BEFORE_HTML:t=this,(r=e).tagID===eS.HTML?(t._insertElement(r,e_.HTML),t.insertionMode=eA.BEFORE_HEAD):kZ(t,r);break;case eA.BEFORE_HEAD:var t,r,n,a,i,s,o,l,c,u,d,p,m=this,h=e;switch(h.tagID){case eS.HTML:Ae(m,h);break;case eS.HEAD:m._insertElement(h,e_.HTML),m.headElement=m.openElements.current,m.insertionMode=eA.IN_HEAD;break;default:kX(m,h)}break;case eA.IN_HEAD:kQ(this,e);break;case eA.IN_HEAD_NO_SCRIPT:var f=this,g=e;switch(g.tagID){case eS.HTML:Ae(f,g);break;case eS.BASEFONT:case eS.BGSOUND:case eS.HEAD:case eS.LINK:case eS.META:case eS.NOFRAMES:case eS.STYLE:kQ(f,g);break;case eS.NOSCRIPT:f._err(g,em.nestedNoscriptInHead);break;default:k1(f,g)}break;case eA.AFTER_HEAD:var b=this,y=e;switch(y.tagID){case eS.HTML:Ae(b,y);break;case eS.BODY:b._insertElement(y,e_.HTML),b.framesetOk=!1,b.insertionMode=eA.IN_BODY;break;case eS.FRAMESET:b._insertElement(y,e_.HTML),b.insertionMode=eA.IN_FRAMESET;break;case eS.BASE:case eS.BASEFONT:case eS.BGSOUND:case eS.LINK:case eS.META:case eS.NOFRAMES:case eS.SCRIPT:case eS.STYLE:case eS.TEMPLATE:case eS.TITLE:b._err(y,em.abandonedHeadElementChild),b.openElements.push(b.headElement,eS.HEAD),kQ(b,y),b.openElements.remove(b.headElement);break;case eS.HEAD:b._err(y,em.misplacedStartTagForHeadElement);break;default:k2(b,y)}break;case eA.IN_BODY:Ae(this,e);break;case eA.IN_TABLE:Ai(this,e);break;case eA.IN_TABLE_TEXT:Au(this,e);break;case eA.IN_CAPTION:let E;n=this,E=(a=e).tagID,Ad.has(E)?n.openElements.hasInTableScope(eS.CAPTION)&&(n.openElements.generateImpliedEndTags(),n.openElements.popUntilTagNamePopped(eS.CAPTION),n.activeFormattingElements.clearToLastMarker(),n.insertionMode=eA.IN_TABLE,Ai(n,a)):Ae(n,a);break;case eA.IN_COLUMN_GROUP:Ap(this,e);break;case eA.IN_TABLE_BODY:Ah(this,e);break;case eA.IN_ROW:Ag(this,e);break;case eA.IN_CELL:let _;i=this,_=(s=e).tagID,Ad.has(_)?(i.openElements.hasInTableScope(eS.TD)||i.openElements.hasInTableScope(eS.TH))&&(i._closeTableCell(),Ag(i,s)):Ae(i,s);break;case eA.IN_SELECT:Ay(this,e);break;case eA.IN_SELECT_IN_TABLE:let v;o=this,(v=(l=e).tagID)===eS.CAPTION||v===eS.TABLE||v===eS.TBODY||v===eS.TFOOT||v===eS.THEAD||v===eS.TR||v===eS.TD||v===eS.TH?(o.openElements.popUntilTagNamePopped(eS.SELECT),o._resetInsertionMode(),o._processStartTag(l)):Ay(o,l);break;case eA.IN_TEMPLATE:var x=this,T=e;switch(T.tagID){case eS.BASE:case eS.BASEFONT:case eS.BGSOUND:case eS.LINK:case eS.META:case eS.NOFRAMES:case eS.SCRIPT:case eS.STYLE:case eS.TEMPLATE:case eS.TITLE:kQ(x,T);break;case eS.CAPTION:case eS.COLGROUP:case eS.TBODY:case eS.TFOOT:case eS.THEAD:x.tmplInsertionModeStack[0]=eA.IN_TABLE,x.insertionMode=eA.IN_TABLE,Ai(x,T);break;case eS.COL:x.tmplInsertionModeStack[0]=eA.IN_COLUMN_GROUP,x.insertionMode=eA.IN_COLUMN_GROUP,Ap(x,T);break;case eS.TR:x.tmplInsertionModeStack[0]=eA.IN_TABLE_BODY,x.insertionMode=eA.IN_TABLE_BODY,Ah(x,T);break;case eS.TD:case eS.TH:x.tmplInsertionModeStack[0]=eA.IN_ROW,x.insertionMode=eA.IN_ROW,Ag(x,T);break;default:x.tmplInsertionModeStack[0]=eA.IN_BODY,x.insertionMode=eA.IN_BODY,Ae(x,T)}break;case eA.AFTER_BODY:c=this,(u=e).tagID===eS.HTML?Ae(c,u):Ax(c,u);break;case eA.IN_FRAMESET:var S=this,w=e;switch(w.tagID){case eS.HTML:Ae(S,w);break;case eS.FRAMESET:S._insertElement(w,e_.HTML);break;case eS.FRAME:S._appendElement(w,e_.HTML),w.ackSelfClosing=!0;break;case eS.NOFRAMES:kQ(S,w)}break;case eA.AFTER_FRAMESET:var k=this,A=e;switch(A.tagID){case eS.HTML:Ae(k,A);break;case eS.NOFRAMES:kQ(k,A)}break;case eA.AFTER_AFTER_BODY:d=this,(p=e).tagID===eS.HTML?Ae(d,p):AT(d,p);break;case eA.AFTER_AFTER_FRAMESET:var N=this,I=e;switch(I.tagID){case eS.HTML:Ae(N,I);break;case eS.NOFRAMES:kQ(N,I)}}}onEndTag(e){this.skipNextNewLine=!1,this.currentToken=e,this.currentNotInHTML?function(e,t){if(t.tagID===eS.P||t.tagID===eS.BR){AS(e),e._endTagOutsideForeignContent(t);return}for(let r=e.openElements.stackTop;r>0;r--){let n=e.openElements.items[r];if(e.treeAdapter.getNamespaceURI(n)===e_.HTML){e._endTagOutsideForeignContent(t);break}let a=e.treeAdapter.getTagName(n);if(a.toLowerCase()===t.tagName){t.tagName=a,e.openElements.shortenToLength(r);break}}}(this,e):this._endTagOutsideForeignContent(e)}_endTagOutsideForeignContent(e){switch(this.insertionMode){case eA.INITIAL:kK(this,e);break;case eA.BEFORE_HTML:let t;n=this,((t=(a=e).tagID)===eS.HTML||t===eS.HEAD||t===eS.BODY||t===eS.BR)&&kZ(n,a);break;case eA.BEFORE_HEAD:let r;i=this,(r=(s=e).tagID)===eS.HEAD||r===eS.BODY||r===eS.HTML||r===eS.BR?kX(i,s):i._err(s,em.endTagWithoutMatchingOpenElement);break;case eA.IN_HEAD:var n,a,i,s,o,l,c,u,d,p,m,h,f=this,g=e;switch(g.tagID){case eS.HEAD:f.openElements.pop(),f.insertionMode=eA.AFTER_HEAD;break;case eS.BODY:case eS.BR:case eS.HTML:k0(f,g);break;case eS.TEMPLATE:kJ(f,g);break;default:f._err(g,em.endTagWithoutMatchingOpenElement)}break;case eA.IN_HEAD_NO_SCRIPT:var b=this,y=e;switch(y.tagID){case eS.NOSCRIPT:b.openElements.pop(),b.insertionMode=eA.IN_HEAD;break;case eS.BR:k1(b,y);break;default:b._err(y,em.endTagWithoutMatchingOpenElement)}break;case eA.AFTER_HEAD:var E=this,_=e;switch(_.tagID){case eS.BODY:case eS.HTML:case eS.BR:k2(E,_);break;case eS.TEMPLATE:kJ(E,_);break;default:E._err(_,em.endTagWithoutMatchingOpenElement)}break;case eA.IN_BODY:Ar(this,e);break;case eA.TEXT:o=this,e.tagID===eS.SCRIPT&&(null==(l=o.scriptHandler)||l.call(o,o.openElements.current)),o.openElements.pop(),o.insertionMode=o.originalInsertionMode;break;case eA.IN_TABLE:As(this,e);break;case eA.IN_TABLE_TEXT:Au(this,e);break;case eA.IN_CAPTION:var v=this,x=e;let T=x.tagID;switch(T){case eS.CAPTION:case eS.TABLE:v.openElements.hasInTableScope(eS.CAPTION)&&(v.openElements.generateImpliedEndTags(),v.openElements.popUntilTagNamePopped(eS.CAPTION),v.activeFormattingElements.clearToLastMarker(),v.insertionMode=eA.IN_TABLE,T===eS.TABLE&&As(v,x));break;case eS.BODY:case eS.COL:case eS.COLGROUP:case eS.HTML:case eS.TBODY:case eS.TD:case eS.TFOOT:case eS.TH:case eS.THEAD:case eS.TR:break;default:Ar(v,x)}break;case eA.IN_COLUMN_GROUP:var S=this,w=e;switch(w.tagID){case eS.COLGROUP:S.openElements.currentTagId===eS.COLGROUP&&(S.openElements.pop(),S.insertionMode=eA.IN_TABLE);break;case eS.TEMPLATE:kJ(S,w);break;case eS.COL:break;default:Am(S,w)}break;case eA.IN_TABLE_BODY:Af(this,e);break;case eA.IN_ROW:Ab(this,e);break;case eA.IN_CELL:var k=this,A=e;let N=A.tagID;switch(N){case eS.TD:case eS.TH:k.openElements.hasInTableScope(N)&&(k.openElements.generateImpliedEndTags(),k.openElements.popUntilTagNamePopped(N),k.activeFormattingElements.clearToLastMarker(),k.insertionMode=eA.IN_ROW);break;case eS.TABLE:case eS.TBODY:case eS.TFOOT:case eS.THEAD:case eS.TR:k.openElements.hasInTableScope(N)&&(k._closeTableCell(),Ab(k,A));break;case eS.BODY:case eS.CAPTION:case eS.COL:case eS.COLGROUP:case eS.HTML:break;default:Ar(k,A)}break;case eA.IN_SELECT:AE(this,e);break;case eA.IN_SELECT_IN_TABLE:let I;c=this,(I=(u=e).tagID)===eS.CAPTION||I===eS.TABLE||I===eS.TBODY||I===eS.TFOOT||I===eS.THEAD||I===eS.TR||I===eS.TD||I===eS.TH?c.openElements.hasInTableScope(I)&&(c.openElements.popUntilTagNamePopped(eS.SELECT),c._resetInsertionMode(),c.onEndTag(u)):AE(c,u);break;case eA.IN_TEMPLATE:d=this,(p=e).tagID===eS.TEMPLATE&&kJ(d,p);break;case eA.AFTER_BODY:Av(this,e);break;case eA.IN_FRAMESET:m=this,e.tagID===eS.FRAMESET&&!m.openElements.isRootHtmlElementCurrent()&&(m.openElements.pop(),m.fragmentContext||m.openElements.currentTagId===eS.FRAMESET||(m.insertionMode=eA.AFTER_FRAMESET));break;case eA.AFTER_FRAMESET:h=this,e.tagID===eS.HTML&&(h.insertionMode=eA.AFTER_AFTER_FRAMESET);break;case eA.AFTER_AFTER_BODY:AT(this,e)}}onEof(e){switch(this.insertionMode){case eA.INITIAL:kK(this,e);break;case eA.BEFORE_HTML:kZ(this,e);break;case eA.BEFORE_HEAD:kX(this,e);break;case eA.IN_HEAD:k0(this,e);break;case eA.IN_HEAD_NO_SCRIPT:k1(this,e);break;case eA.AFTER_HEAD:k2(this,e);break;case eA.IN_BODY:case eA.IN_TABLE:case eA.IN_CAPTION:case eA.IN_COLUMN_GROUP:case eA.IN_TABLE_BODY:case eA.IN_ROW:case eA.IN_CELL:case eA.IN_SELECT:case eA.IN_SELECT_IN_TABLE:An(this,e);break;case eA.TEXT:var t,r;t=this,r=e,t._err(r,em.eofInElementThatCanContainOnlyText),t.openElements.pop(),t.insertionMode=t.originalInsertionMode,t.onEof(r);break;case eA.IN_TABLE_TEXT:Au(this,e);break;case eA.IN_TEMPLATE:A_(this,e);break;case eA.AFTER_BODY:case eA.IN_FRAMESET:case eA.AFTER_FRAMESET:case eA.AFTER_AFTER_BODY:case eA.AFTER_AFTER_FRAMESET:kY(this,e)}}onWhitespaceCharacter(e){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,e.chars.charCodeAt(0)===ep.LINE_FEED)){if(1===e.chars.length)return;e.chars=e.chars.substr(1)}if(this.tokenizer.inForeignNode)return void this._insertCharacters(e);switch(this.insertionMode){case eA.IN_HEAD:case eA.IN_HEAD_NO_SCRIPT:case eA.AFTER_HEAD:case eA.TEXT:case eA.IN_COLUMN_GROUP:case eA.IN_SELECT:case eA.IN_SELECT_IN_TABLE:case eA.IN_FRAMESET:case eA.AFTER_FRAMESET:this._insertCharacters(e);break;case eA.IN_BODY:case eA.IN_CAPTION:case eA.IN_CELL:case eA.IN_TEMPLATE:case eA.AFTER_BODY:case eA.AFTER_AFTER_BODY:case eA.AFTER_AFTER_FRAMESET:k3(this,e);break;case eA.IN_TABLE:case eA.IN_TABLE_BODY:case eA.IN_ROW:Aa(this,e);break;case eA.IN_TABLE_TEXT:Al(this,e)}}}function kV(e,t){for(let r=0;r<8;r++){let r=function(e,t){let r=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return r?e.openElements.contains(r.element)?e.openElements.hasInScope(t.tagID)||(r=null):(e.activeFormattingElements.removeEntry(r),r=null):At(e,t),r}(e,t);if(!r)break;let n=function(e,t){let r=null,n=e.openElements.stackTop;for(;n>=0;n--){let a=e.openElements.items[n];if(a===t.element)break;e._isSpecialElement(a,e.openElements.tagIDs[n])&&(r=a)}return r||(e.openElements.shortenToLength(Math.max(n,0)),e.activeFormattingElements.removeEntry(t)),r}(e,r);if(!n)break;e.activeFormattingElements.bookmark=r;let a=function(e,t,r){let n=t,a=e.openElements.getCommonAncestor(t);for(let i=0,s=a;s!==r;i++,s=a){a=e.openElements.getCommonAncestor(s);let r=e.activeFormattingElements.getElementEntry(s),o=r&&i>=3;!r||o?(o&&e.activeFormattingElements.removeEntry(r),e.openElements.remove(s)):(s=function(e,t){let r=e.treeAdapter.getNamespaceURI(t.element),n=e.treeAdapter.createElement(t.token.tagName,r,t.token.attrs);return e.openElements.replace(t.element,n),t.element=n,n}(e,r),n===t&&(e.activeFormattingElements.bookmark=r),e.treeAdapter.detachNode(n),e.treeAdapter.appendChild(s,n),n=s)}return n}(e,n,r.element),i=e.openElements.getCommonAncestor(r.element);e.treeAdapter.detachNode(a),i&&function(e,t,r){let n=kt(e.treeAdapter.getTagName(t));if(e._isElementCausesFosterParenting(n))e._fosterParentElement(r);else{let a=e.treeAdapter.getNamespaceURI(t);n===eS.TEMPLATE&&a===e_.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,r)}}(e,i,a),function(e,t,r){let n=e.treeAdapter.getNamespaceURI(r.element),{token:a}=r,i=e.treeAdapter.createElement(a.tagName,n,a.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,a),e.activeFormattingElements.removeEntry(r),e.openElements.remove(r.element),e.openElements.insertAfter(t,i,a.tagID)}(e,n,r)}}function kW(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function kY(e,t){if(e.stopped=!0,t.location){let r=2*!e.fragmentContext;for(let n=e.openElements.stackTop;n>=r;n--)e._setEndLocation(e.openElements.items[n],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){let r=e.openElements.items[0],n=e.treeAdapter.getNodeSourceCodeLocation(r);if(n&&!n.endTag&&(e._setEndLocation(r,t),e.openElements.stackTop>=1)){let r=e.openElements.items[1],n=e.treeAdapter.getNodeSourceCodeLocation(r);n&&!n.endTag&&e._setEndLocation(r,t)}}}}function kK(e,t){e._err(t,em.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,ex.QUIRKS),e.insertionMode=eA.BEFORE_HTML,e._processToken(t)}function kZ(e,t){e._insertFakeRootElement(),e.insertionMode=eA.BEFORE_HEAD,e._processToken(t)}function kX(e,t){e._insertFakeElement(eT.HEAD,eS.HEAD),e.headElement=e.openElements.current,e.insertionMode=eA.IN_HEAD,e._processToken(t)}function kQ(e,t){switch(t.tagID){case eS.HTML:Ae(e,t);break;case eS.BASE:case eS.BASEFONT:case eS.BGSOUND:case eS.LINK:case eS.META:e._appendElement(t,e_.HTML),t.ackSelfClosing=!0;break;case eS.TITLE:e._switchToTextParsing(t,ks.RCDATA);break;case eS.NOSCRIPT:e.options.scriptingEnabled?e._switchToTextParsing(t,ks.RAWTEXT):(e._insertElement(t,e_.HTML),e.insertionMode=eA.IN_HEAD_NO_SCRIPT);break;case eS.NOFRAMES:case eS.STYLE:e._switchToTextParsing(t,ks.RAWTEXT);break;case eS.SCRIPT:e._switchToTextParsing(t,ks.SCRIPT_DATA);break;case eS.TEMPLATE:e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=eA.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(eA.IN_TEMPLATE);break;case eS.HEAD:e._err(t,em.misplacedStartTagForHeadElement);break;default:k0(e,t)}}function kJ(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==eS.TEMPLATE&&e._err(t,em.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(eS.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,em.endTagWithoutMatchingOpenElement)}function k0(e,t){e.openElements.pop(),e.insertionMode=eA.AFTER_HEAD,e._processToken(t)}function k1(e,t){let r=t.type===eh.EOF?em.openElementsLeftAfterEof:em.disallowedContentInNoscriptInHead;e._err(t,r),e.openElements.pop(),e.insertionMode=eA.IN_HEAD,e._processToken(t)}function k2(e,t){e._insertFakeElement(eT.BODY,eS.BODY),e.insertionMode=eA.IN_BODY,k4(e,t)}function k4(e,t){switch(t.type){case eh.CHARACTER:k5(e,t);break;case eh.WHITESPACE_CHARACTER:k3(e,t);break;case eh.COMMENT:kW(e,t);break;case eh.START_TAG:Ae(e,t);break;case eh.END_TAG:Ar(e,t);break;case eh.EOF:An(e,t)}}function k3(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function k5(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function k6(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,e_.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function k9(e){let t=w5(e,ev.TYPE);return null!=t&&"hidden"===t.toLowerCase()}function k8(e,t){e._switchToTextParsing(t,ks.RAWTEXT)}function k7(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,e_.HTML)}function Ae(e,t){switch(t.tagID){case eS.I:case eS.S:case eS.B:case eS.U:case eS.EM:case eS.TT:case eS.BIG:case eS.CODE:case eS.FONT:case eS.SMALL:case eS.STRIKE:case eS.STRONG:e._reconstructActiveFormattingElements(),e._insertElement(t,e_.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t);break;case eS.A:let r;(r=e.activeFormattingElements.getElementEntryInScopeWithTagName(eT.A))&&(kV(e,t),e.openElements.remove(r.element),e.activeFormattingElements.removeEntry(r)),e._reconstructActiveFormattingElements(),e._insertElement(t,e_.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t);break;case eS.H1:case eS.H2:case eS.H3:case eS.H4:case eS.H5:case eS.H6:e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),void 0!==e.openElements.currentTagId&&ka.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,e_.HTML);break;case eS.P:case eS.DL:case eS.OL:case eS.UL:case eS.DIV:case eS.DIR:case eS.NAV:case eS.MAIN:case eS.MENU:case eS.ASIDE:case eS.CENTER:case eS.FIGURE:case eS.FOOTER:case eS.HEADER:case eS.HGROUP:case eS.DIALOG:case eS.DETAILS:case eS.ADDRESS:case eS.ARTICLE:case eS.SEARCH:case eS.SECTION:case eS.SUMMARY:case eS.FIELDSET:case eS.BLOCKQUOTE:case eS.FIGCAPTION:e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._insertElement(t,e_.HTML);break;case eS.LI:case eS.DD:case eS.DT:e.framesetOk=!1;let n=t.tagID;for(let t=e.openElements.stackTop;t>=0;t--){let r=e.openElements.tagIDs[t];if(n===eS.LI&&r===eS.LI||(n===eS.DD||n===eS.DT)&&(r===eS.DD||r===eS.DT)){e.openElements.generateImpliedEndTagsWithExclusion(r),e.openElements.popUntilTagNamePopped(r);break}if(r!==eS.ADDRESS&&r!==eS.DIV&&r!==eS.P&&e._isSpecialElement(e.openElements.items[t],r))break}e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._insertElement(t,e_.HTML);break;case eS.BR:case eS.IMG:case eS.WBR:case eS.AREA:case eS.EMBED:case eS.KEYGEN:k6(e,t);break;case eS.HR:e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._appendElement(t,e_.HTML),e.framesetOk=!1,t.ackSelfClosing=!0;break;case eS.RB:case eS.RTC:e.openElements.hasInScope(eS.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,e_.HTML);break;case eS.RT:case eS.RP:e.openElements.hasInScope(eS.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(eS.RTC),e._insertElement(t,e_.HTML);break;case eS.PRE:case eS.LISTING:e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._insertElement(t,e_.HTML),e.skipNextNewLine=!0,e.framesetOk=!1;break;case eS.XMP:e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,ks.RAWTEXT);break;case eS.SVG:e._reconstructActiveFormattingElements(),kB(t),k$(t),t.selfClosing?e._appendElement(t,e_.SVG):e._insertElement(t,e_.SVG),t.ackSelfClosing=!0;break;case eS.HTML:0===e.openElements.tmplCount&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs);break;case eS.BASE:case eS.LINK:case eS.META:case eS.STYLE:case eS.TITLE:case eS.SCRIPT:case eS.BGSOUND:case eS.BASEFONT:case eS.TEMPLATE:kQ(e,t);break;case eS.BODY:let a;(a=e.openElements.tryPeekProperlyNestedBodyElement())&&0===e.openElements.tmplCount&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(a,t.attrs));break;case eS.FORM:let i;i=e.openElements.tmplCount>0,(!e.formElement||i)&&(e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._insertElement(t,e_.HTML),i||(e.formElement=e.openElements.current));break;case eS.NOBR:e._reconstructActiveFormattingElements(),e.openElements.hasInScope(eS.NOBR)&&(kV(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,e_.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t);break;case eS.MATH:e._reconstructActiveFormattingElements(),kU(t),k$(t),t.selfClosing?e._appendElement(t,e_.MATHML):e._insertElement(t,e_.MATHML),t.ackSelfClosing=!0;break;case eS.TABLE:e.treeAdapter.getDocumentMode(e.document)!==ex.QUIRKS&&e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._insertElement(t,e_.HTML),e.framesetOk=!1,e.insertionMode=eA.IN_TABLE;break;case eS.INPUT:e._reconstructActiveFormattingElements(),e._appendElement(t,e_.HTML),k9(t)||(e.framesetOk=!1),t.ackSelfClosing=!0;break;case eS.PARAM:case eS.TRACK:case eS.SOURCE:e._appendElement(t,e_.HTML),t.ackSelfClosing=!0;break;case eS.IMAGE:t.tagName=eT.IMG,t.tagID=eS.IMG,k6(e,t);break;case eS.BUTTON:e.openElements.hasInScope(eS.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(eS.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,e_.HTML),e.framesetOk=!1;break;case eS.APPLET:case eS.OBJECT:case eS.MARQUEE:e._reconstructActiveFormattingElements(),e._insertElement(t,e_.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1;break;case eS.IFRAME:e.framesetOk=!1,e._switchToTextParsing(t,ks.RAWTEXT);break;case eS.SELECT:e._reconstructActiveFormattingElements(),e._insertElement(t,e_.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===eA.IN_TABLE||e.insertionMode===eA.IN_CAPTION||e.insertionMode===eA.IN_TABLE_BODY||e.insertionMode===eA.IN_ROW||e.insertionMode===eA.IN_CELL?eA.IN_SELECT_IN_TABLE:eA.IN_SELECT;break;case eS.OPTION:case eS.OPTGROUP:e.openElements.currentTagId===eS.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,e_.HTML);break;case eS.NOEMBED:case eS.NOFRAMES:k8(e,t);break;case eS.FRAMESET:let s;s=e.openElements.tryPeekProperlyNestedBodyElement(),e.framesetOk&&s&&(e.treeAdapter.detachNode(s),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,e_.HTML),e.insertionMode=eA.IN_FRAMESET);break;case eS.TEXTAREA:e._insertElement(t,e_.HTML),e.skipNextNewLine=!0,e.tokenizer.state=ks.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=eA.TEXT;break;case eS.NOSCRIPT:e.options.scriptingEnabled?k8(e,t):k7(e,t);break;case eS.PLAINTEXT:e.openElements.hasInButtonScope(eS.P)&&e._closePElement(),e._insertElement(t,e_.HTML),e.tokenizer.state=ks.PLAINTEXT;break;case eS.COL:case eS.TH:case eS.TD:case eS.TR:case eS.HEAD:case eS.FRAME:case eS.TBODY:case eS.TFOOT:case eS.THEAD:case eS.CAPTION:case eS.COLGROUP:break;default:k7(e,t)}}function At(e,t){let r=t.tagName,n=t.tagID;for(let t=e.openElements.stackTop;t>0;t--){let a=e.openElements.items[t],i=e.openElements.tagIDs[t];if(n===i&&(n!==eS.UNKNOWN||e.treeAdapter.getTagName(a)===r)){e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.stackTop>=t&&e.openElements.shortenToLength(t);break}if(e._isSpecialElement(a,i))break}}function Ar(e,t){switch(t.tagID){case eS.A:case eS.B:case eS.I:case eS.S:case eS.U:case eS.EM:case eS.TT:case eS.BIG:case eS.CODE:case eS.FONT:case eS.NOBR:case eS.SMALL:case eS.STRIKE:case eS.STRONG:kV(e,t);break;case eS.P:e.openElements.hasInButtonScope(eS.P)||e._insertFakeElement(eT.P,eS.P),e._closePElement();break;case eS.DL:case eS.UL:case eS.OL:case eS.DIR:case eS.DIV:case eS.NAV:case eS.PRE:case eS.MAIN:case eS.MENU:case eS.ASIDE:case eS.BUTTON:case eS.CENTER:case eS.FIGURE:case eS.FOOTER:case eS.HEADER:case eS.HGROUP:case eS.DIALOG:case eS.ADDRESS:case eS.ARTICLE:case eS.DETAILS:case eS.SEARCH:case eS.SECTION:case eS.SUMMARY:case eS.LISTING:case eS.FIELDSET:case eS.BLOCKQUOTE:case eS.FIGCAPTION:let r;r=t.tagID,e.openElements.hasInScope(r)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r));break;case eS.LI:e.openElements.hasInListItemScope(eS.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(eS.LI),e.openElements.popUntilTagNamePopped(eS.LI));break;case eS.DD:case eS.DT:let n;n=t.tagID,e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n));break;case eS.H1:case eS.H2:case eS.H3:case eS.H4:case eS.H5:case eS.H6:e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped());break;case eS.BR:e._reconstructActiveFormattingElements(),e._insertFakeElement(eT.BR,eS.BR),e.openElements.pop(),e.framesetOk=!1;break;case eS.BODY:if(e.openElements.hasInScope(eS.BODY)&&(e.insertionMode=eA.AFTER_BODY,e.options.sourceCodeLocationInfo)){let r=e.openElements.tryPeekProperlyNestedBodyElement();r&&e._setEndLocation(r,t)}break;case eS.HTML:e.openElements.hasInScope(eS.BODY)&&(e.insertionMode=eA.AFTER_BODY,Av(e,t));break;case eS.FORM:!function(e){let t=e.openElements.tmplCount>0,{formElement:r}=e;t||(e.formElement=null),(r||t)&&e.openElements.hasInScope(eS.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(eS.FORM):r&&e.openElements.remove(r))}(e);break;case eS.APPLET:case eS.OBJECT:case eS.MARQUEE:let a;a=t.tagID,e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker());break;case eS.TEMPLATE:kJ(e,t);break;default:At(e,t)}}function An(e,t){e.tmplInsertionModeStack.length>0?A_(e,t):kY(e,t)}function Aa(e,t){if(void 0!==e.openElements.currentTagId&&kH.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=eA.IN_TABLE_TEXT,t.type){case eh.CHARACTER:Ac(e,t);break;case eh.WHITESPACE_CHARACTER:Al(e,t)}else Ao(e,t)}function Ai(e,t){switch(t.tagID){case eS.TD:case eS.TH:case eS.TR:e.openElements.clearBackToTableContext(),e._insertFakeElement(eT.TBODY,eS.TBODY),e.insertionMode=eA.IN_TABLE_BODY,Ah(e,t);break;case eS.STYLE:case eS.SCRIPT:case eS.TEMPLATE:kQ(e,t);break;case eS.COL:e.openElements.clearBackToTableContext(),e._insertFakeElement(eT.COLGROUP,eS.COLGROUP),e.insertionMode=eA.IN_COLUMN_GROUP,Ap(e,t);break;case eS.FORM:e.formElement||0!==e.openElements.tmplCount||(e._insertElement(t,e_.HTML),e.formElement=e.openElements.current,e.openElements.pop());break;case eS.TABLE:e.openElements.hasInTableScope(eS.TABLE)&&(e.openElements.popUntilTagNamePopped(eS.TABLE),e._resetInsertionMode(),e._processStartTag(t));break;case eS.TBODY:case eS.TFOOT:case eS.THEAD:e.openElements.clearBackToTableContext(),e._insertElement(t,e_.HTML),e.insertionMode=eA.IN_TABLE_BODY;break;case eS.INPUT:k9(t)?e._appendElement(t,e_.HTML):Ao(e,t),t.ackSelfClosing=!0;break;case eS.CAPTION:e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,e_.HTML),e.insertionMode=eA.IN_CAPTION;break;case eS.COLGROUP:e.openElements.clearBackToTableContext(),e._insertElement(t,e_.HTML),e.insertionMode=eA.IN_COLUMN_GROUP;break;default:Ao(e,t)}}function As(e,t){switch(t.tagID){case eS.TABLE:e.openElements.hasInTableScope(eS.TABLE)&&(e.openElements.popUntilTagNamePopped(eS.TABLE),e._resetInsertionMode());break;case eS.TEMPLATE:kJ(e,t);break;case eS.BODY:case eS.CAPTION:case eS.COL:case eS.COLGROUP:case eS.HTML:case eS.TBODY:case eS.TD:case eS.TFOOT:case eS.TH:case eS.THEAD:case eS.TR:break;default:Ao(e,t)}}function Ao(e,t){let r=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,k4(e,t),e.fosterParentingEnabled=r}function Al(e,t){e.pendingCharacterTokens.push(t)}function Ac(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Au(e,t){let r=0;if(e.hasNonWhitespacePendingCharacterToken)for(;r<e.pendingCharacterTokens.length;r++)Ao(e,e.pendingCharacterTokens[r]);else for(;r<e.pendingCharacterTokens.length;r++)e._insertCharacters(e.pendingCharacterTokens[r]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}let Ad=new Set([eS.CAPTION,eS.COL,eS.COLGROUP,eS.TBODY,eS.TD,eS.TFOOT,eS.TH,eS.THEAD,eS.TR]);function Ap(e,t){switch(t.tagID){case eS.HTML:Ae(e,t);break;case eS.COL:e._appendElement(t,e_.HTML),t.ackSelfClosing=!0;break;case eS.TEMPLATE:kQ(e,t);break;default:Am(e,t)}}function Am(e,t){e.openElements.currentTagId===eS.COLGROUP&&(e.openElements.pop(),e.insertionMode=eA.IN_TABLE,e._processToken(t))}function Ah(e,t){switch(t.tagID){case eS.TR:e.openElements.clearBackToTableBodyContext(),e._insertElement(t,e_.HTML),e.insertionMode=eA.IN_ROW;break;case eS.TH:case eS.TD:e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(eT.TR,eS.TR),e.insertionMode=eA.IN_ROW,Ag(e,t);break;case eS.CAPTION:case eS.COL:case eS.COLGROUP:case eS.TBODY:case eS.TFOOT:case eS.THEAD:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=eA.IN_TABLE,Ai(e,t));break;default:Ai(e,t)}}function Af(e,t){let r=t.tagID;switch(t.tagID){case eS.TBODY:case eS.TFOOT:case eS.THEAD:e.openElements.hasInTableScope(r)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=eA.IN_TABLE);break;case eS.TABLE:e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=eA.IN_TABLE,As(e,t));break;case eS.BODY:case eS.CAPTION:case eS.COL:case eS.COLGROUP:case eS.HTML:case eS.TD:case eS.TH:case eS.TR:break;default:As(e,t)}}function Ag(e,t){switch(t.tagID){case eS.TH:case eS.TD:e.openElements.clearBackToTableRowContext(),e._insertElement(t,e_.HTML),e.insertionMode=eA.IN_CELL,e.activeFormattingElements.insertMarker();break;case eS.CAPTION:case eS.COL:case eS.COLGROUP:case eS.TBODY:case eS.TFOOT:case eS.THEAD:case eS.TR:e.openElements.hasInTableScope(eS.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=eA.IN_TABLE_BODY,Ah(e,t));break;default:Ai(e,t)}}function Ab(e,t){switch(t.tagID){case eS.TR:e.openElements.hasInTableScope(eS.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=eA.IN_TABLE_BODY);break;case eS.TABLE:e.openElements.hasInTableScope(eS.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=eA.IN_TABLE_BODY,Af(e,t));break;case eS.TBODY:case eS.TFOOT:case eS.THEAD:(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(eS.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=eA.IN_TABLE_BODY,Af(e,t));break;case eS.BODY:case eS.CAPTION:case eS.COL:case eS.COLGROUP:case eS.HTML:case eS.TD:case eS.TH:break;default:As(e,t)}}function Ay(e,t){switch(t.tagID){case eS.HTML:Ae(e,t);break;case eS.OPTION:e.openElements.currentTagId===eS.OPTION&&e.openElements.pop(),e._insertElement(t,e_.HTML);break;case eS.OPTGROUP:e.openElements.currentTagId===eS.OPTION&&e.openElements.pop(),e.openElements.currentTagId===eS.OPTGROUP&&e.openElements.pop(),e._insertElement(t,e_.HTML);break;case eS.HR:e.openElements.currentTagId===eS.OPTION&&e.openElements.pop(),e.openElements.currentTagId===eS.OPTGROUP&&e.openElements.pop(),e._appendElement(t,e_.HTML),t.ackSelfClosing=!0;break;case eS.INPUT:case eS.KEYGEN:case eS.TEXTAREA:case eS.SELECT:e.openElements.hasInSelectScope(eS.SELECT)&&(e.openElements.popUntilTagNamePopped(eS.SELECT),e._resetInsertionMode(),t.tagID!==eS.SELECT&&e._processStartTag(t));break;case eS.SCRIPT:case eS.TEMPLATE:kQ(e,t)}}function AE(e,t){switch(t.tagID){case eS.OPTGROUP:e.openElements.stackTop>0&&e.openElements.currentTagId===eS.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===eS.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===eS.OPTGROUP&&e.openElements.pop();break;case eS.OPTION:e.openElements.currentTagId===eS.OPTION&&e.openElements.pop();break;case eS.SELECT:e.openElements.hasInSelectScope(eS.SELECT)&&(e.openElements.popUntilTagNamePopped(eS.SELECT),e._resetInsertionMode());break;case eS.TEMPLATE:kJ(e,t)}}function A_(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(eS.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):kY(e,t)}function Av(e,t){var r;if(t.tagID===eS.HTML){if(e.fragmentContext||(e.insertionMode=eA.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===eS.HTML){e._setEndLocation(e.openElements.items[0],t);let n=e.openElements.items[1];!n||(null==(r=e.treeAdapter.getNodeSourceCodeLocation(n))?void 0:r.endTag)||e._setEndLocation(n,t)}}else Ax(e,t)}function Ax(e,t){e.insertionMode=eA.IN_BODY,k4(e,t)}function AT(e,t){e.insertionMode=eA.IN_BODY,k4(e,t)}function AS(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==e_.HTML&&void 0!==e.openElements.currentTagId&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}eT.AREA,eT.BASE,eT.BASEFONT,eT.BGSOUND,eT.BR,eT.COL,eT.EMBED,eT.FRAME,eT.HR,eT.IMG,eT.INPUT,eT.KEYGEN,eT.LINK,eT.META,eT.PARAM,eT.SOURCE,eT.TRACK,eT.WBR;var Aw=e.i(382698),Aw=Aw,Ak=e.i(615473),Ak=Ak;let AA=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,AN=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),AI={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function AC(e,t){var r,n;let a,i,s=!!((a="root"===(n=e).type?n.children[0]:n)&&("doctype"===a.type||"element"===a.type&&"html"===a.tagName.toLowerCase())),o=wq("type",{handlers:{root:AO,element:AL,text:AD,comment:AM,doctype:AP,raw:Aj},unknown:AF}),l={parser:s?new kq(AI):kq.getFragmentParser(void 0,AI),handle(e){o(e,l)},stitches:!1,options:t||{}};o(e,l),AU(l,vB());let c=(r=s?l.parser.document:l.parser.getFragment(),wU({file:(i={file:l.options.file}).file||void 0,location:!1,schema:"svg"===i.space?vP:vD,verbose:i.verbose||!1},r));return(l.stitches&&TD(c,"comment",function(e,t,r){if(e.value.stitch&&r&&void 0!==t)return r.children[t]=e.value.stitch,t}),"root"===c.type&&1===c.children.length&&c.children[0].type===e.type)?c.children[0]:c}function AR(e,t){let r=-1;if(e)for(;++r<e.length;)t.handle(e[r])}function AO(e,t){AR(e.children,t)}function AL(e,t){(function(e,t){let r=e.tagName.toLowerCase();if(t.parser.tokenizer.state===ks.PLAINTEXT)return;AU(t,vB(e));let n=t.parser.openElements.current,a="namespaceURI"in n?n.namespaceURI:wM.html;a===wM.html&&"svg"===r&&(a=wM.svg);let i=wW({...e,children:[]},"svg"===({space:a===wM.svg?"svg":"html"}).space?vP:vD),s={type:Aw.TokenType.START_TAG,tagName:r,tagID:Ak.getTagID(r),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:A$(e)};t.parser.currentToken=s,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=r})(e,t),AR(e.children,t),function(e,t){let r=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&wZ.includes(r)||t.parser.tokenizer.state===ks.PLAINTEXT)return;AU(t,vU(e));let n={type:Aw.TokenType.END_TAG,tagName:r,tagID:Ak.getTagID(r),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:A$(e)};t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken),r===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===ks.RCDATA||t.parser.tokenizer.state===ks.RAWTEXT||t.parser.tokenizer.state===ks.SCRIPT_DATA)&&(t.parser.tokenizer.state=ks.DATA)}(e,t)}function AD(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);let r={type:Aw.TokenType.CHARACTER,chars:e.value,location:A$(e)};AU(t,vB(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function AP(e,t){let r={type:Aw.TokenType.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:A$(e)};AU(t,vB(e)),t.parser.currentToken=r,t.parser._processToken(t.parser.currentToken)}function AM(e,t){let r=e.value,n={type:Aw.TokenType.COMMENT,data:r,location:A$(e)};AU(t,vB(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Aj(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,AB(t,vB(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(AA,"<$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),72===t.parser.tokenizer.state||78===t.parser.tokenizer.state){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;let e=t.parser.tokenizer._consume();t.parser.tokenizer._callState(e)}}function AF(e,t){if(t.options.passThrough&&t.options.passThrough.includes(e.type)){var r;let n;t.stitches=!0,n="children"in(r=e)?TS({...r,children:[]}):TS(r),"children"in e&&"children"in n&&(n.children=AC({type:"root",children:e.children},t.options).children),AM({type:"comment",value:{stitch:n}},t)}else{let t="";throw AN.has(e.type)&&(t=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),Error("Cannot compile `"+e.type+"` node"+t)}}function AU(e,t){AB(e,t);let r=e.parser.tokenizer.currentCharacterToken;r&&r.location&&(r.location.endLine=e.parser.tokenizer.preprocessor.line,r.location.endCol=e.parser.tokenizer.preprocessor.col+1,r.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=r,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=ks.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function AB(e,t){if(t&&void 0!==t.offset){let r={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=r}}function A$(e){let t=vB(e)||{line:void 0,column:void 0,offset:void 0},r=vU(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:r.line,endCol:r.column,endOffset:r.offset}}function Az(e){return function(t,r){return AC(t,{...e,file:r})}}let AH=/[#.]/g;function AG(e,t,r){let n=r?function(e){let t=new Map;for(let r of e)t.set(r.toLowerCase(),r);return t}(r):void 0;return function(r,a,...i){let s;if(null==r)s={type:"root",children:[]},i.unshift(a);else{let o=(s=function(e,t){let r,n,a=e||"",i={},s=0;for(;s<a.length;){AH.lastIndex=s;let e=AH.exec(a),t=a.slice(s,e?e.index:a.length);t&&(r?"#"===r?i.id=t:Array.isArray(i.className)?i.className.push(t):i.className=[t]:n=t,s+=t.length),e&&(r=e[0],s++)}return{type:"element",tagName:n||t||"div",properties:i,children:[]}}(r,t)).tagName.toLowerCase(),l=n?n.get(o):void 0;if(s.tagName=l||o,function(e){if(null===e||"object"!=typeof e||Array.isArray(e))return!0;if("string"!=typeof e.type)return!1;for(let t of Object.keys(e)){let r=e[t];if(r&&"object"==typeof r){if(!Array.isArray(r))return!0;for(let e of r)if("number"!=typeof e&&"string"!=typeof e)return!0}}return!!("children"in e&&Array.isArray(e.children))}(a))i.unshift(a);else for(let[t,r]of Object.entries(a))!function(e,t,r,n){let a,i=vE(e,r);if(null!=n){if("number"==typeof n){if(Number.isNaN(n))return;a=n}else a="boolean"==typeof n?n:"string"==typeof n?i.spaceSeparated?vM(n):i.commaSeparated?_3(n):i.commaOrSpaceSeparated?vM(_3(n).join(" ")):Aq(i,i.property,n):Array.isArray(n)?[...n]:"style"===i.property?function(e){let t=[];for(let[r,n]of Object.entries(e))t.push([r,n].join(": "));return t.join("; ")}(n):String(n);if(Array.isArray(a)){let e=[];for(let t of a)e.push(Aq(i,i.property,t));a=e}"className"===i.property&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}(e,s.properties,t,r)}for(let e of i)!function e(t,r){if(null==r);else if("number"==typeof r||"string"==typeof r)t.push({type:"text",value:String(r)});else if(Array.isArray(r))for(let n of r)e(t,n);else if("object"==typeof r&&"type"in r)"root"===r.type?e(t,r.children):t.push(r);else throw Error("Expected node, nodes, or string, got `"+r+"`")}(s.children,e);return"element"===s.type&&"template"===s.tagName&&(s.content={type:"root",children:s.children},s.children=[]),s}}function Aq(e,t,r){if("string"==typeof r){if(e.number&&r&&!Number.isNaN(Number(r)))return Number(r);if((e.boolean||e.overloadedBoolean)&&(""===r||vf(r)===vf(t)))return!0}return r}let AV=AG(vD,"div"),AW=AG(vP,"g",["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"]);function AY(e,t){let r=function(e,t){switch(e.nodeType){case 1:return function(e,t){let r=e.namespaceURI,n=r===wM.svg?AW:AV,a=r===wM.html?e.tagName.toLowerCase():e.tagName,i=r===wM.html&&"template"===a?e.content:e,s=e.getAttributeNames(),o={},l=-1;for(;++l<s.length;)o[s[l]]=e.getAttribute(s[l])||"";return n(a,o,AK(i,t))}(e,t);case 3:return{type:"text",value:e.nodeValue||""};case 8:return{type:"comment",value:e.nodeValue||""};case 9:case 11:return function(e,t){return{type:"root",children:AK(e,t)}}(e,t);case 10:return{type:"doctype"};default:return}}(e,t);return r&&t.afterTransform&&t.afterTransform(e,r),r}function AK(e,t){let r=e.childNodes,n=[],a=-1;for(;++a<r.length;){let e=AY(r[a],t);void 0!==e&&n.push(e)}return n}let AZ=new DOMParser,AX=function(e,t,r){let n=TN(r);if(!e||!e.type||!e.children)throw Error("Expected parent node");if("number"==typeof t){if(t<0||t===1/0)throw Error("Expected positive finite number as index")}else if((t=e.children.indexOf(t))<0)throw Error("Expected child node or index");for(;++t<e.children.length;)if(n(e.children[t],t,e))return e.children[t]},AQ=function(e){if(null==e)return A0;if("string"==typeof e){var t;return t=e,AJ(function(e){return e.tagName===t})}if("object"==typeof e){var r=e;let t=[],n=-1;for(;++n<r.length;)t[n]=AQ(r[n]);return AJ(function(...e){let r=-1;for(;++r<t.length;)if(t[r].apply(this,e))return!0;return!1})}if("function"==typeof e)return AJ(e);throw Error("Expected function, string, or array as `test`")};function AJ(e){return function(t,r,n){var a;return!!(null!==(a=t)&&"object"==typeof a&&"type"in a&&"tagName"in a&&e.call(this,t,"number"==typeof r?r:void 0,n||void 0))}}function A0(e){return!!(e&&"object"==typeof e&&"type"in e&&"element"===e.type&&"tagName"in e&&"string"==typeof e.tagName)}let A1=/\n/g,A2=/[\t ]+/g,A4=AQ("br"),A3=AQ(function(e){return"td"===e.tagName||"th"===e.tagName}),A5=AQ("p"),A6=AQ("tr"),A9=AQ(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",function(e){return!!(e.properties||{}).hidden},function(e){return"dialog"===e.tagName&&!(e.properties||{}).open}]),A8=AQ(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function A7(e,t){let r,n=String(e.value),a=[],i=[],s=0;for(;s<=n.length;){A1.lastIndex=s;let e=A1.exec(n),r=e&&"index"in e?e.index:n.length;a.push(function(e,t,r){let n,a=[],i=0;for(;i<e.length;){A2.lastIndex=i;let r=A2.exec(e);n=r?r.index:e.length,i||n||!r||t||a.push(""),i!==n&&a.push(e.slice(i,n)),i=r?n+r[0].length:n}return i===n||r||a.push(""),a.join(" ")}(n.slice(s,r).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),0!==s||t.breakBefore,r!==n.length||t.breakAfter)),s=r+1}let o=-1;for(;++o<a.length;)8203===a[o].charCodeAt(a[o].length-1)||o<a.length-1&&8203===a[o+1].charCodeAt(0)?(i.push(a[o]),r=void 0):a[o]?("number"==typeof r&&i.push(r),i.push(a[o]),r=0):(0===o||o===a.length-1)&&i.push(0);return i}function Ne(e,t){if("element"===e.type){let r=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return r.wrap?"pre-wrap":"pre";case"td":case"th":return r.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}var Nt=e.i(716400);let Nr={},Nn=[];function Na(e){let t=e||Nr;return function(e,r){TL(e,"element",function(e,n){var a,i,s;let o,l,c=Array.isArray(e.properties.className)?e.properties.className:Nn,u=c.includes("language-math"),d=c.includes("math-display"),p=c.includes("math-inline"),m=d;if(!u&&!d&&!p)return;let h=n[n.length-1],f=e;if("code"===e.tagName&&u&&h&&"element"===h.type&&"pre"===h.tagName&&(f=h,h=n[n.length-2],m=!0),!h)return;let g=function(e,t){let r,n="children"in e?e.children:[],a=A8(e),i=Ne(e,{whitespace:(t||{}).whitespace||"normal",breakBefore:!1,breakAfter:!1}),s=[];("text"===e.type||"comment"===e.type)&&s.push(...A7(e,{whitespace:i,breakBefore:!0,breakAfter:!0}));let o=-1;for(;++o<n.length;)s.push(...function e(t,r,n){return"element"===t.type?function(t,r,n){let a,i,s=Ne(t,n),o=t.children||[],l=-1,c=[];if(A9(t))return c;for(A4(t)||A6(t)&&AX(r,t,A6)?i="\n":A5(t)?(a=2,i=2):A8(t)&&(a=1,i=1);++l<o.length;)c=c.concat(e(o[l],t,{whitespace:s,breakBefore:l?void 0:a,breakAfter:l<o.length-1?A4(o[l+1]):i}));return A3(t)&&AX(r,t,A3)&&c.push(" "),a&&c.unshift(a),i&&c.push(i),c}(t,r,n):"text"===t.type?"normal"===n.whitespace?A7(t,n):[String(t.value)]:[]}(n[o],e,{whitespace:i,breakBefore:o?void 0:a,breakAfter:o<n.length-1?A4(n[o+1]):a}));let l=[];for(o=-1;++o<s.length;){let e=s[o];"number"==typeof e?void 0!==r&&e>r&&(r=e):e&&(void 0!==r&&r>-1&&l.push("\n".repeat(r)||" "),r=-1,l.push(e))}return l.join("")}(f,{whitespace:"pre"});try{l=Nt.default.renderToString(g,{...t,displayMode:m,throwOnError:!0})}catch(i){let a=i.name.toLowerCase();r.message("Could not render math with KaTeX",{ancestors:[...n,e],cause:i,place:e.position,ruleId:a,source:"rehype-katex"});try{l=Nt.default.renderToString(g,{...t,displayMode:m,strict:"ignore",throwOnError:!1})}catch{l=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(i)},children:[{type:"text",value:g}]}]}}"string"==typeof l&&(l=(a=l,i={fragment:!0},AY(i?.fragment?(s=a,(o=document.createElement("template")).innerHTML=s,o.content):AZ.parseFromString(a,"text/html"),{})||{type:"root",children:[]}).children);let b=h.children.indexOf(f);return h.children.splice(b,1,...l),TO})}}let Ni=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],Ns={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...Ni,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...Ni],h2:[["className","sr-only"]],img:[...Ni,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...Ni,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...Ni],table:[...Ni],ul:[...Ni,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},No={}.hasOwnProperty;function Nl(e,t){if(t&&"object"==typeof t)switch("string"==typeof t.type?t.type:""){case"comment":var r,n,a=e,i=t;if(a.schema.allowComments){let e="string"==typeof i.value?i.value:"",t=e.indexOf("-->"),r={type:"comment",value:t<0?e:e.slice(0,t)};return Np(r,i),r}return;case"doctype":var s=e,o=t;if(s.schema.allowDoctypes){let e={type:"doctype"};return Np(e,o),e}return;case"element":return function(e,t){let r="string"==typeof t.tagName?t.tagName:"";e.stack.push(r);let n=Nc(e,t.children),a=function(e,t){let r,n=e.stack[e.stack.length-1],a=e.schema.attributes,i=e.schema.required,s=a&&No.call(a,n)?a[n]:void 0,o=a&&No.call(a,"*")?a["*"]:void 0,l=t&&"object"==typeof t?t:{},c={};for(r in l)if(No.call(l,r)){let t=l[r],n=Nu(e,Nm(s,r),r,t);null==n&&(n=Nu(e,Nm(o,r),r,t)),null!=n&&(c[r]=n)}if(i&&No.call(i,n)){let e=i[n];for(r in e)No.call(e,r)&&!No.call(c,r)&&(c[r]=e[r])}return c}(e,t.properties);e.stack.pop();let i=!1;if(r&&"*"!==r&&(!e.schema.tagNames||e.schema.tagNames.includes(r))&&(i=!0,e.schema.ancestors&&No.call(e.schema.ancestors,r))){let t=e.schema.ancestors[r],n=-1;for(i=!1;++n<t.length;)e.stack.includes(t[n])&&(i=!0)}if(!i)return e.schema.strip&&!e.schema.strip.includes(r)?n:void 0;let s={type:"element",tagName:r,properties:a,children:n};return Np(s,t),s}(e,t);case"root":let l;return Np(l={type:"root",children:Nc(e,(r=t).children)},r),l;case"text":let c;return Np(c={type:"text",value:"string"==typeof(n=t).value?n.value:""},n),c}}function Nc(e,t){let r=[];if(Array.isArray(t)){let n=-1;for(;++n<t.length;){let a=Nl(e,t[n]);a&&(Array.isArray(a)?r.push(...a):r.push(a))}}return r}function Nu(e,t,r,n){return t?Array.isArray(n)?function(e,t,r,n){let a=-1,i=[];for(;++a<n.length;){let s=Nd(e,t,r,n[a]);("number"==typeof s||"string"==typeof s)&&i.push(s)}return i}(e,t,r,n):Nd(e,t,r,n):void 0}function Nd(e,t,r,n){if(("boolean"==typeof n||"number"==typeof n||"string"==typeof n)&&function(e,t,r){let n=e.schema.protocols&&No.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!n||0===n.length)return!0;let a=String(r),i=a.indexOf(":"),s=a.indexOf("?"),o=a.indexOf("#"),l=a.indexOf("/");if(i<0||l>-1&&i>l||s>-1&&i>s||o>-1&&i>o)return!0;let c=-1;for(;++c<n.length;){let e=n[c];if(i===e.length&&a.slice(0,e.length)===e)return!0}return!1}(e,r,n)){if("object"==typeof t&&t.length>1){let e=!1,r=0;for(;++r<t.length;){let a=t[r];if(a&&"object"==typeof a&&"flags"in a){if(a.test(String(n))){e=!0;break}}else if(a===n){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(r)?e.schema.clobberPrefix+n:n}}function Np(e,t){let r=vz(t);t.data&&(e.data=TS(t.data)),r&&(e.position=r)}function Nm(e,t){let r,n=-1;if(e)for(;++n<e.length;){let a=e[n],i="string"==typeof a?a:a[0];if(i===t)return a;"data*"===i&&(r=a)}if(t.length>4&&"data"===t.slice(0,4).toLowerCase())return r}function Nh(e){return function(t){let r,n;return r={type:"root",children:[]},(n=Nl({schema:e?{...Ns,...e}:Ns,stack:[]},t))&&(Array.isArray(n)?1===n.length?r=n[0]:r.children=n:r=n),r}}function Nf(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Ng(e){return function(e){if(Array.isArray(e))return Nf(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return Nf(e,void 0);var t=({}).toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Nf(e,void 0):void 0}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nb(e){return(Nb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ny(e,t,r){var n;return(n=function(e,t){if("object"!=Nb(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Nb(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==Nb(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function NE(){return(NE=Object.assign.bind()).apply(null,arguments)}function N_(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Nv(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?N_(Object(r),!0).forEach(function(t){Ny(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):N_(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Nx={},NT=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function NS(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Nw(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?NS(Object(r),!0).forEach(function(t){Ny(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NS(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Nk=/\n/g;function NA(e){var t,r,n,a,i=e.codeString,s=e.codeStyle,o=e.containerStyle,l=e.numberStyle,c=e.startingLineNumber;return eC.default.createElement("code",{style:Object.assign({},s,void 0===o?{float:"left",paddingRight:"10px"}:o)},(r=(t={lines:i.replace(/\n$/,"").split("\n"),style:void 0===l?{}:l,startingLineNumber:c}).lines,n=t.startingLineNumber,a=t.style,r.map(function(e,t){var r=t+n;return eC.default.createElement("span",{key:"line-".concat(t),className:"react-syntax-highlighter-line-number",style:"function"==typeof a?a(r):a},"".concat(r,"\n"))})))}function NN(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function NI(e,t,r){var n={display:"inline-block",minWidth:"".concat(r.toString().length,".25em"),paddingRight:"1em",textAlign:"right",userSelect:"none"},a="function"==typeof e?e(t):e;return Nw(Nw({},n),a)}function NC(e){var t=e.children,r=e.lineNumber,n=e.lineNumberStyle,a=e.largestLineNumber,i=e.showInlineLineNumbers,s=e.lineProps,o=void 0===s?{}:s,l=e.className,c=void 0===l?[]:l,u=e.showLineNumbers,d=e.wrapLongLines,p=e.wrapLines,m=void 0!==p&&p?Nw({},"function"==typeof o?o(r):o):{};if(m.className=m.className?[].concat(Ng(m.className.trim().split(/\s+/)),Ng(c)):c,r&&i){var h=NI(n,r,a);t.unshift(NN(r,h))}return d&u&&(m.style=Nw({display:"flex"},m.style)),{type:"element",tagName:"span",properties:m,children:t}}function NR(e){var t=e.rows,r=e.stylesheet,n=e.useInlineStyles;return t.map(function(e,t){return function e(t){var r=t.node,n=t.stylesheet,a=t.style,i=t.useInlineStyles,s=t.key,o=r.properties,l=r.type,c=r.tagName,u=r.value;if("text"===l)return u;if(c){var d,p,m=(d=0,function(t){return d+=1,t.map(function(t,r){return e({node:t,stylesheet:n,useInlineStyles:i,key:"code-segment-".concat(d,"-").concat(r)})})});if(i){var h=Object.keys(n).reduce(function(e,t){return t.split(".").forEach(function(t){e.includes(t)||e.push(t)}),e},[]),f=o.className&&o.className.includes("token")?["token"]:[],g=o.className&&f.concat(o.className.filter(function(e){return!h.includes(e)}));p=Nv(Nv({},o),{},{className:g.join(" ")||void 0,style:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return(function(e){if(0===e.length||1===e.length)return e;var t,r=e.join(".");return Nx[r]||(Nx[r]=0===(t=e.length)||1===t?e:2===t?[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])]:3===t?[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])]:t>=4?[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]:void 0),Nx[r]})(e.filter(function(e){return"token"!==e})).reduce(function(e,t){return Nv(Nv({},e),r[t])},t)}(o.className,Object.assign({},o.style,void 0===a?{}:a),n)})}else p=Nv(Nv({},o),{},{className:o.className.join(" ")});var b=m(r.children);return eC.default.createElement(c,NE({key:s},p),b)}}({node:e,stylesheet:r,useInlineStyles:n,key:"code-segment-".concat(t)})})}function NO(e){return e&&void 0!==e.highlightAuto}var NL=(ee=e.i(916907).default,et={'code[class*="language-"]':{color:"black",background:"none",textShadow:"0 1px white",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",fontSize:"1em",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"black",background:"#f5f2f0",textShadow:"0 1px white",fontFamily:"Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace",fontSize:"1em",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",wordWrap:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto"},'pre[class*="language-"]::-moz-selection':{textShadow:"none",background:"#b3d4fc"},'pre[class*="language-"] ::-moz-selection':{textShadow:"none",background:"#b3d4fc"},'code[class*="language-"]::-moz-selection':{textShadow:"none",background:"#b3d4fc"},'code[class*="language-"] ::-moz-selection':{textShadow:"none",background:"#b3d4fc"},'pre[class*="language-"]::selection':{textShadow:"none",background:"#b3d4fc"},'pre[class*="language-"] ::selection':{textShadow:"none",background:"#b3d4fc"},'code[class*="language-"]::selection':{textShadow:"none",background:"#b3d4fc"},'code[class*="language-"] ::selection':{textShadow:"none",background:"#b3d4fc"},':not(pre) > code[class*="language-"]':{background:"#f5f2f0",padding:".1em",borderRadius:".3em",whiteSpace:"normal"},comment:{color:"slategray"},prolog:{color:"slategray"},doctype:{color:"slategray"},cdata:{color:"slategray"},punctuation:{color:"#999"},namespace:{Opacity:".7"},property:{color:"#905"},tag:{color:"#905"},boolean:{color:"#905"},number:{color:"#905"},constant:{color:"#905"},symbol:{color:"#905"},deleted:{color:"#905"},selector:{color:"#690"},"attr-name":{color:"#690"},string:{color:"#690"},char:{color:"#690"},builtin:{color:"#690"},inserted:{color:"#690"},operator:{color:"#9a6e3a",background:"hsla(0, 0%, 100%, .5)"},entity:{color:"#9a6e3a",background:"hsla(0, 0%, 100%, .5)",cursor:"help"},url:{color:"#9a6e3a",background:"hsla(0, 0%, 100%, .5)"},".language-css .token.string":{color:"#9a6e3a",background:"hsla(0, 0%, 100%, .5)"},".style .token.string":{color:"#9a6e3a",background:"hsla(0, 0%, 100%, .5)"},atrule:{color:"#07a"},"attr-value":{color:"#07a"},keyword:{color:"#07a"},function:{color:"#DD4A68"},"class-name":{color:"#DD4A68"},regex:{color:"#e90"},important:{color:"#e90",fontWeight:"bold"},variable:{color:"#e90"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},function(e){var t,r,n=e.language,a=e.children,i=e.style,s=void 0===i?et:i,o=e.customStyle,l=void 0===o?{}:o,c=e.codeTagProps,u=void 0===c?{className:n?"language-".concat(n):void 0,style:Nw(Nw({},s['code[class*="language-"]']),s['code[class*="language-'.concat(n,'"]')])}:c,d=e.useInlineStyles,p=void 0===d||d,m=e.showLineNumbers,h=void 0!==m&&m,f=e.showInlineLineNumbers,g=void 0===f||f,b=e.startingLineNumber,y=void 0===b?1:b,E=e.lineNumberContainerStyle,_=e.lineNumberStyle,v=void 0===_?{}:_,x=e.wrapLines,T=e.wrapLongLines,S=void 0!==T&&T,w=e.lineProps,k=e.renderer,A=e.PreTag,N=void 0===A?"pre":A,I=e.CodeTag,C=void 0===I?"code":I,R=e.code,O=void 0===R?(Array.isArray(a)?a[0]:a)||"":R,L=e.astGenerator,D=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if(({}).hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&({}).propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(e,NT);L=L||ee;var P=h?eC.default.createElement(NA,{containerStyle:E,codeStyle:u.style||{},numberStyle:v,startingLineNumber:y,codeString:O}):null,M=s.hljs||s['pre[class*="language-"]']||{backgroundColor:"#fff"},j=NO(L)?"hljs":"prismjs",F=p?Object.assign({},D,{style:Object.assign({},M,l)}):Object.assign({},D,{className:D.className?"".concat(j," ").concat(D.className):j,style:Object.assign({},l)});if(S?u.style=Nw({whiteSpace:"pre-wrap"},u.style):u.style=Nw({whiteSpace:"pre"},u.style),!L)return eC.default.createElement(N,F,P,eC.default.createElement(C,u,O));(void 0===x&&k||S)&&(x=!0),k=k||NR;var U=[{type:"text",value:O}],B=function(e){var t=e.astGenerator,r=e.language,n=e.code,a=e.defaultCodeValue;if(NO(t)){var i=-1!==t.listLanguages().indexOf(r);return"text"===r?{value:a,language:"text"}:i?t.highlight(r,n):t.highlightAuto(n)}try{return r&&"text"!==r?{value:t.highlight(n,r)}:{value:a}}catch(e){return{value:a}}}({astGenerator:L,language:n,code:O,defaultCodeValue:U});null===B.language&&(B.value=U);var $=y+(null!=(t=null==(r=O.match(/\n/g))?void 0:r.length)?t:0),z=function(e,t,r,n,a,i,s,o,l){var c,u=function e(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=0;a<t.length;a++){var i=t[a];if("text"===i.type)n.push(NC({children:[i],className:Ng(new Set(r))}));else if(i.children){var s=r.concat(i.properties.className);e(i.children,s).forEach(function(e){return n.push(e)})}}return n}(e.value),d=[],p=-1,m=0;function h(e,i){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return t||c.length>0?function(e,i){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return NC({children:e,lineNumber:i,lineNumberStyle:o,largestLineNumber:s,showInlineLineNumbers:a,lineProps:r,className:c,showLineNumbers:n,wrapLongLines:l,wrapLines:t})}(e,i,c):function(e,t){if(n&&t&&a){var r=NI(o,t,s);e.unshift(NN(t,r))}return e}(e,i)}for(;m<u.length;)!function(){var e=u[m],t=e.children[0].value;if(t.match(Nk)){var r=t.split("\n");r.forEach(function(t,a){var s=n&&d.length+i,o={type:"text",value:"".concat(t,"\n")};if(0===a){var l=h(u.slice(p+1,m).concat(NC({children:[o],className:e.properties.className})),s);d.push(l)}else if(a===r.length-1){var c=u[m+1]&&u[m+1].children&&u[m+1].children[0],f={type:"text",value:"".concat(t)};if(c){var g=NC({children:[f],className:e.properties.className});u.splice(m+1,0,g)}else{var b=h([f],s,e.properties.className);d.push(b)}}else{var y=h([o],s,e.properties.className);d.push(y)}}),p=m}m++}();if(p!==u.length-1){var f=u.slice(p+1,u.length);if(f&&f.length){var g=h(f,n&&d.length+i);d.push(g)}}return t?d:(c=[]).concat.apply(c,d)}(B,x,void 0===w?{}:w,h,g,y,$,v,S);return eC.default.createElement(N,F,eC.default.createElement(C,u,!g&&P,k({rows:z,stylesheet:s,useInlineStyles:p})))});NL.supportedLanguages=["abap","abnf","actionscript","ada","agda","al","antlr4","apacheconf","apex","apl","applescript","aql","arduino","arff","asciidoc","asm6502","asmatmel","aspnet","autohotkey","autoit","avisynth","avro-idl","bash","basic","batch","bbcode","bicep","birb","bison","bnf","brainfuck","brightscript","bro","bsl","c","cfscript","chaiscript","cil","clike","clojure","cmake","cobol","coffeescript","concurnas","coq","cpp","crystal","csharp","cshtml","csp","css-extras","css","csv","cypher","d","dart","dataweave","dax","dhall","diff","django","dns-zone-file","docker","dot","ebnf","editorconfig","eiffel","ejs","elixir","elm","erb","erlang","etlua","excel-formula","factor","false","firestore-security-rules","flow","fortran","fsharp","ftl","gap","gcode","gdscript","gedcom","gherkin","git","glsl","gml","gn","go-module","go","graphql","groovy","haml","handlebars","haskell","haxe","hcl","hlsl","hoon","hpkp","hsts","http","ichigojam","icon","icu-message-format","idris","iecst","ignore","inform7","ini","io","j","java","javadoc","javadoclike","javascript","javastacktrace","jexl","jolie","jq","js-extras","js-templates","jsdoc","json","json5","jsonp","jsstacktrace","jsx","julia","keepalived","keyman","kotlin","kumir","kusto","latex","latte","less","lilypond","liquid","lisp","livescript","llvm","log","lolcode","lua","magma","makefile","markdown","markup-templating","markup","matlab","maxscript","mel","mermaid","mizar","mongodb","monkey","moonscript","n1ql","n4js","nand2tetris-hdl","naniscript","nasm","neon","nevod","nginx","nim","nix","nsis","objectivec","ocaml","opencl","openqasm","oz","parigp","parser","pascal","pascaligo","pcaxis","peoplecode","perl","php-extras","php","phpdoc","plsql","powerquery","powershell","processing","prolog","promql","properties","protobuf","psl","pug","puppet","pure","purebasic","purescript","python","q","qml","qore","qsharp","r","racket","reason","regex","rego","renpy","rest","rip","roboconf","robotframework","ruby","rust","sas","sass","scala","scheme","scss","shell-session","smali","smalltalk","smarty","sml","solidity","solution-file","soy","sparql","splunk-spl","sqf","sql","squirrel","stan","stylus","swift","systemd","t4-cs","t4-templating","t4-vb","tap","tcl","textile","toml","tremor","tsx","tt2","turtle","twig","typescript","typoscript","unrealscript","uorazor","uri","v","vala","vbnet","velocity","verilog","vhdl","vim","visual-basic","warpscript","wasm","web-idl","wiki","wolfram","wren","xeora","xml-doc","xojo","xquery","yaml","yang","zig"];let ND={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}},NP=rj("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);async function NM(e){try{if("u">typeof navigator&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{if("u"<typeof document)return!1;let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-9999px",t.style.opacity="0",document.body.appendChild(t);try{return t.select(),t.setSelectionRange(0,e.length),document.execCommand("copy")}finally{t.remove()}}catch{return!1}}let Nj=eC.default.memo(({language:e,value:t})=>{let[r,n]=(0,eC.useState)(!1),a=(0,eC.useRef)(void 0);(0,eC.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),(0,eC.useEffect)(()=>{n(!1),a.current&&clearTimeout(a.current)},[t]);let i=(0,eC.useCallback)(async()=>{await NM(t)?(n(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>n(!1),2e3)):c6.toast.error("Couldn't copy to clipboard.")},[t]);return(0,eI.jsxs)("div",{className:"group relative max-w-full",children:[(0,eI.jsx)("button",{type:"button",onClick:i,"aria-label":r?"Copied":"Copy code",className:"absolute right-2 top-2 z-10 rounded-md border border-border bg-[var(--color-surface)] p-1.5 text-[var(--color-text-tertiary)] opacity-0 backdrop-blur-sm transition-opacity hover:text-[var(--color-text-primary)] focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100",children:r?(0,eI.jsx)(lU,{className:"h-3.5 w-3.5","aria-hidden":"true"}):(0,eI.jsx)(NP,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,eI.jsx)(NL,{style:ND,language:e,PreTag:"div",className:"max-w-full rounded-md text-sm",wrapLines:!0,wrapLongLines:!0,lineProps:{style:{wordBreak:"break-all",whiteSpace:"pre-wrap",overflowWrap:"break-word"}},customStyle:{margin:0,maxWidth:"100%",overflowX:"auto",fontSize:"0.875rem"},children:t})]})});Nj.displayName="CodeBlock";let NF=rj("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),NU=rj("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),NB=rj("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var N$=e.i(921675);let Nz=null,NH=Promise.resolve();async function NG(t,r,n){let a=NH.then(async()=>{let a=await (!Nz&&(Nz=e.A(695802).then(e=>e.default)),Nz);if(a.initialize({startOnLoad:!1,theme:n,securityLevel:"strict"}),!await a.parse(r,{suppressErrors:!0}))return null;let{svg:i}=await a.render(t,r);return i});return NH=a.catch(()=>void 0),a}let Nq=eC.default.memo(({code:e,isStreaming:t=!1})=>{let r=(0,eC.useId)().replace(/:/g,""),{resolvedTheme:n}=(0,N$.useTheme)(),a="dark"===n?"dark":"default",[i,s]=(0,eC.useState)(null);return((0,eC.useEffect)(()=>{if(t)return;let n=!1;return s(null),NG(`mermaid-${r}`,e,a).then(e=>{n||s(e)}).catch(()=>{n||s(null)}),()=>{n=!0}},[e,r,t,a]),t)?(0,eI.jsx)("pre",{className:"my-4 max-w-full overflow-x-auto whitespace-pre-wrap break-words rounded-md bg-[var(--color-surface)] p-3 text-xs text-[var(--color-text-tertiary)]",children:(0,eI.jsx)("code",{children:e})}):i?(0,eI.jsx)(NV,{svg:i}):(0,eI.jsx)(Nj,{language:"mermaid",value:e})});Nq.displayName="MermaidDiagram";let NV=eC.default.memo(({svg:e})=>{let[t,r]=(0,eC.useState)(!1),[n,a]=(0,eC.useState)(1),i=Math.round(100*n);return(0,eC.useEffect)(()=>{t&&a(1)},[t]),(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("button",{type:"button","aria-label":"Open diagram in full view","aria-haspopup":"dialog",onClick:()=>r(!0),className:"my-4 block max-w-full cursor-zoom-in overflow-x-auto rounded-md bg-[var(--color-surface)] p-4 text-left transition-shadow hover:ring-2 hover:ring-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",dangerouslySetInnerHTML:{__html:e}}),(0,eI.jsx)(ng,{open:t,onOpenChange:r,children:(0,eI.jsxs)(nE,{className:"max-h-[calc(100svh-1rem)] w-[calc(100vw-1rem)] max-w-[calc(100vw-1rem)] overflow-auto p-3 sm:max-h-[92vh] sm:w-[min(1200px,95vw)] sm:max-w-[95vw] sm:p-4",children:[(0,eI.jsx)(nx,{className:"sr-only",children:"Mermaid diagram"}),(0,eI.jsx)(nT,{className:"sr-only",children:"Full-size preview of the generated Mermaid diagram."}),(0,eI.jsxs)("div",{className:"sticky top-0 z-10 -mx-1 -mt-1 mb-2 flex items-center justify-end gap-1 bg-background/95 pb-2 pr-8 backdrop-blur",children:[(0,eI.jsx)("button",{type:"button",onClick:()=>a(e=>Math.max(.75,e-.25)),disabled:n<=.75,"aria-label":"Zoom out",className:"inline-flex size-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40",children:(0,eI.jsx)(NB,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("span",{className:"min-w-12 text-center text-xs font-medium tabular-nums text-muted-foreground","aria-live":"polite",children:[i,"%"]}),(0,eI.jsx)("button",{type:"button",onClick:()=>a(e=>Math.min(2.5,e+.25)),disabled:n>=2.5,"aria-label":"Zoom in",className:"inline-flex size-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40",children:(0,eI.jsx)(NU,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsx)("button",{type:"button",onClick:()=>a(1),"aria-label":"Reset zoom",className:"inline-flex size-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(NF,{className:"size-4","aria-hidden":"true"})})]}),(0,eI.jsx)("div",{className:"min-w-full overflow-auto rounded-md bg-[var(--color-surface)] p-3",children:(0,eI.jsx)("div",{className:"[&_svg]:!h-auto [&_svg]:!w-full [&_svg]:!max-w-none",style:{width:`${i}%`},dangerouslySetInnerHTML:{__html:e}})})]})})]})});NV.displayName="MermaidPreview";let NW=new Set(["md","txt","json","jsonl","yaml","yml","csv","tsv","log","py","ts","tsx","js","jsx","html","css","sh","pdf","png","jpg","jpeg","gif","svg","webp","mp3","wav","mp4","mov"]);function NY(e){let t=e.trim();if(!t||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:/i.test(t)||!t.includes("/"))return null;let r=t.lastIndexOf(".");if(r<=t.lastIndexOf("/"))return null;let n=t.slice(r+1).toLowerCase();if(!NW.has(n))return null;if(t.startsWith("/memories/"))return{kind:"memory",display:t,path:t.replace(/^\/memories\/+/,"")};let a=t.replace(/^\/+/,"").replace(/^\.\/+/,"");return{kind:"workspace",display:t,path:a}}let NK="evosci:open-file";function NZ(e){window.dispatchEvent(new CustomEvent(NK,{detail:e}))}let NX="#evosci-file:",NQ=Array.from(NW).join("|"),NJ=RegExp(`(?:\\/(?:[\\w\\-.]+\\/)*|(?:[\\w\\-.]+\\/)+)[\\w\\-.]+\\.(?:${NQ})\\b`,"g"),N0=new Set(["a","code","pre","script","style","kbd","samp"]);function N1(){let e=t=>{if(!t.children||0===t.children.length)return;let r=[];for(let n of t.children){let t;if("element"===n.type&&N0.has(n.tagName??"")){r.push(n);continue}if("element"===n.type){e(n),r.push(n);continue}if("text"!==n.type||"string"!=typeof n.value){r.push(n);continue}let a=n.value;NJ.lastIndex=0;let i=0,s=!1;for(;null!==(t=NJ.exec(a));)s=!0,t.index>i&&r.push({type:"text",value:a.slice(i,t.index)}),r.push({type:"element",tagName:"a",properties:{href:`${NX}${encodeURIComponent(t[0])}`},children:[{type:"text",value:t[0]}]}),i=t.index+t[0].length;if(!s){r.push(n);continue}i<a.length&&r.push({type:"text",value:a.slice(i)})}t.children=r};return t=>e(t)}let N2={...Ns,attributes:{...Ns.attributes,code:[...Ns.attributes?.code||[],["className","math-inline","math-display"]]}},N4=eC.default.memo(({content:e,className:t="",isStreaming:r=!1})=>(0,eI.jsx)("div",{className:nf("prose min-w-0 max-w-full overflow-hidden break-words text-sm leading-relaxed text-inherit [&_h1:first-child]:mt-0 [&_h1]:mb-4 [&_h1]:mt-6 [&_h1]:font-semibold [&_h2:first-child]:mt-0 [&_h2]:mb-4 [&_h2]:mt-6 [&_h2]:font-semibold [&_h3:first-child]:mt-0 [&_h3]:mb-4 [&_h3]:mt-6 [&_h3]:font-semibold [&_h4:first-child]:mt-0 [&_h4]:mb-4 [&_h4]:mt-6 [&_h4]:font-semibold [&_h5:first-child]:mt-0 [&_h5]:mb-4 [&_h5]:mt-6 [&_h5]:font-semibold [&_h6:first-child]:mt-0 [&_h6]:mb-4 [&_h6]:mt-6 [&_h6]:font-semibold [&_p:last-child]:mb-0 [&_p]:mb-4",t),children:(0,eI.jsx)(Sp,{remarkPlugins:[wT,wI],rehypePlugins:[Az,N1,[Nh,N2],[Na,{throwOnError:!1,strict:!1}]],components:{code({className:e,children:t,...n}){let a=/language-(\w+)/.exec(e||""),i=String(t),s=i.endsWith("\n"),o=i.replace(/\n$/,"");if(a?.[1]==="mermaid")return(0,eI.jsx)(Nq,{code:o,isStreaming:r});if(a)return(0,eI.jsx)(Nj,{language:a[1],value:o});let l=s?null:NY(o);return l?(0,eI.jsx)("button",{type:"button",onClick:()=>NZ(l),title:`Open ${l.display}`,className:"rounded-sm bg-[var(--color-surface)] px-1 py-0.5 font-mono text-[0.9em] text-primary underline underline-offset-2 hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:l.display}):(0,eI.jsx)("code",{className:"rounded-sm bg-[var(--color-surface)] px-1 py-0.5 font-mono text-[0.9em]",...n,children:t})},pre:({children:e})=>(0,eI.jsx)("div",{className:"my-4 max-w-full overflow-hidden last:mb-0",children:e}),a({href:e,children:t}){if(e&&e.startsWith(NX)){let r,n=e.slice(NX.length);try{r=decodeURIComponent(n)}catch{r=n}let a=NY(r);return a?(0,eI.jsx)("button",{type:"button",onClick:()=>NZ(a),title:`Open ${a.display}`,className:"text-primary underline underline-offset-2 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:t}):(0,eI.jsx)("span",{children:t})}return(0,eI.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-primary no-underline hover:underline",children:t})},blockquote:({children:e})=>(0,eI.jsx)("blockquote",{className:"my-4 border-l-4 border-border pl-4 italic text-[var(--color-text-tertiary)]",children:e}),ul:({children:e})=>(0,eI.jsx)("ul",{className:"my-4 list-disc pl-6 [&>li:last-child]:mb-0 [&>li]:mb-1",children:e}),ol:({children:e})=>(0,eI.jsx)("ol",{className:"my-4 list-decimal pl-6 [&>li:last-child]:mb-0 [&>li]:mb-1",children:e}),details:({children:e,...t})=>(0,eI.jsx)("details",{...t,className:"my-4 rounded-md border border-border bg-[var(--color-surface)] px-3 py-2 [&[open]>summary]:mb-2",children:e}),summary:({children:e,...t})=>(0,eI.jsx)("summary",{...t,className:"cursor-pointer select-none font-medium text-[var(--color-text-primary)] hover:text-[var(--color-text-secondary)]",children:e}),table:({children:e})=>(0,eI.jsx)("div",{className:"my-4 overflow-x-auto",children:(0,eI.jsx)("table",{className:"w-full border-collapse [&_td]:border [&_td]:border-border [&_td]:p-2 [&_th]:border [&_th]:border-border [&_th]:bg-[var(--color-surface)] [&_th]:p-2 [&_th]:text-left [&_th]:font-semibold",children:e})})},children:e})}));function N3({steps:e,hideFinalText:t,compact:r=!1}){let n=new Map;for(let t of e)"tool_result"===t.kind&&t.toolCallId&&n.set(t.toolCallId,t.text);let a=-1;if(t){for(let t=e.length-1;t>=0;t--)if("text"===e[t].kind){a=t;break}}return(0,eI.jsx)("div",{className:nf("flex flex-col gap-1",r&&"gap-0.5"),children:e.map((e,t)=>{if(t===a)return null;if("tool_call"===e.kind){let a={id:e.id,name:e.name,args:e.args,result:n.get(e.id),status:n.has(e.id)?"completed":"pending"};return(0,eI.jsx)(_1,{toolCall:a,compact:r},e.id||`tc-${t}`)}return"text"===e.kind?(0,eI.jsx)("div",{className:nf("px-2 text-sm",r&&"px-1 text-xs"),children:(0,eI.jsx)(N4,{content:e.text,className:r?"text-xs leading-5 [&_blockquote]:my-2 [&_blockquote]:pl-2 [&_h1]:mb-2 [&_h1]:mt-3 [&_h1]:text-base [&_h2]:mb-2 [&_h2]:mt-3 [&_h2]:text-base [&_h3]:mb-1.5 [&_h3]:mt-3 [&_h3]:text-sm [&_h4]:mb-1.5 [&_h4]:mt-3 [&_h4]:text-sm [&_ol]:my-2 [&_ol]:pl-5 [&_p]:mb-2 [&_table]:text-[11px] [&_td]:p-1.5 [&_th]:p-1.5 [&_ul]:my-2 [&_ul]:pl-5":void 0})},`txt-${t}`):null})})}function N5(e){switch(e){case"running":case"pending":case"busy":return"running";case"success":return"success";case"error":case"timeout":return"error";case"cancelled":case"interrupted":return"cancelled";case"expired":return"expired";default:return"unknown"}}N4.displayName="MarkdownContent";let N6={"writing-agent":"Writing agent","data-analysis-agent":"Data analysis agent"},N9="[Async tasks update]";function N8(e){return`${e.task_id}:${e.run_id||"legacy"}`}function N7(e){let t=e.trim().split(/\r?\n/);if(t[0]!==N9||!t[1])return null;try{let e=JSON.parse(t[1]);if("string"!=typeof e.task_id||!e.task_id)return null;return{taskId:e.task_id,runId:"string"==typeof e.run_id&&e.run_id?e.run_id:void 0}}catch{return null}}function Ie(e,t){let r=N7(e);return!!r&&r.taskId===t.task_id&&(!r.runId||r.runId===t.run_id)}function It(e){let t=e.liveStatus||e.status||"success";return[N9,JSON.stringify({agent:e.agent_name,kind:"agent",...e.run_id?{run_id:e.run_id}:{},status:t,task_id:e.task_id}),"(Signal only — fetch full result via check_async_task (sub-agents) if relevant to the current step, else acknowledge & continue.)"].join("\n")}let Ir={running:{dot:"bg-[var(--color-warning)]",label:"Running",pulse:!0},success:{dot:"bg-[var(--color-success)]",label:"Done",pulse:!1},error:{dot:"bg-[var(--color-error)]",label:"Error",pulse:!1},cancelled:{dot:"bg-muted-foreground",label:"Cancelled",pulse:!1},expired:{dot:"bg-muted-foreground",label:"Expired",pulse:!1},unknown:{dot:"bg-muted-foreground",label:"Unknown",pulse:!1}};function In(e){let t=N5(e);return"success"===t||"error"===t||"cancelled"===t}function Ia(e){return e.filter(e=>"running"===N5(e.liveStatus??e.status)).length}let Ii=rj("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]),Is=rj("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),Io=rj("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Il=eC.default.memo(({message:e,toolCalls:t,isLoading:r,isStreaming:n,actionRequests:a,submittedActionRequestKeys:i,onActionRequestSubmitted:s,reviewConfigsMap:o,ui:l,stream:c,onResumeInterrupt:u,graphId:d,onEditMessage:p,autoApprove:m,subAgentSteps:h})=>{let f="human"===e.type,g=_y(e),b=g&&""!==g.trim(),y=t.length>0,E=(0,eC.useMemo)(()=>{let t=e.additional_kwargs?.reasoning_content;return"string"==typeof t&&t.trim()?t.trim():null},[e.additional_kwargs]),_=(0,eC.useMemo)(()=>t.filter(e=>"task"===e.name&&e.args.subagent_type&&""!==e.args.subagent_type&&null!==e.args.subagent_type).map(e=>{let t=e.args.subagent_type;return{id:e.id,name:e.name,subAgentName:t,input:e.args,output:e.result?{result:e.result}:void 0,status:e.status}}),[t]),v=(0,eC.useMemo)(()=>{let e=new Map;if(!a||0===a.length)return e;let r=new Map;a.forEach((e,t)=>{let n=r.get(e.name),a={actionRequest:e,actionIndex:t};n?n.push(a):r.set(e.name,[a])});let n=new Map;for(let a of t){if("interrupted"!==a.status)continue;let t=r.get(a.name);if(!t)continue;let i=n.get(a.name)??0;i<t.length&&(e.set(a.id,t[i]),n.set(a.name,i+1))}return e},[a,t]),x=(0,eC.useMemo)(()=>JSON.stringify((a??[]).map(e=>({name:e.name,args:e.args}))),[a]),T=(0,eC.useRef)({});(0,eC.useEffect)(()=>{T.current={}},[x]);let S=(0,eC.useCallback)((e,t)=>{let r=t?.decisions;if(!Array.isArray(r)||!a?.length||1===a.length||r.length===a.length)return void u?.(t);let n=r[0],i={...T.current,[e]:n};T.current=i,a.every((e,t)=>i[t])&&(T.current={},u?.({decisions:a.map((e,t)=>i[t])}))},[a,u]),[w,k]=(0,eC.useState)(!1),[A,N]=(0,eC.useState)(!1),I=(0,eC.useRef)(void 0);(0,eC.useEffect)(()=>()=>{I.current&&clearTimeout(I.current)},[]),(0,eC.useEffect)(()=>{N(!1),I.current&&clearTimeout(I.current)},[g]);let C=(0,eC.useCallback)(async()=>{g&&(await NM(g)?(N(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>N(!1),2e3)):c6.toast.error("Couldn't copy to clipboard."))},[g]),[R,O]=(0,eC.useState)({}),L=(0,eC.useCallback)(e=>R[e]??!1,[R]),D=(0,eC.useCallback)(e=>{O(t=>({...t,[e]:!t[e]}))},[]);return f&&null!==N7(g)?(0,eI.jsx)("div",{className:"flex w-full justify-center py-1.5",children:(0,eI.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground",children:[(0,eI.jsx)(Ii,{className:"size-3 text-[var(--brand)]","aria-hidden":"true"}),"Background agent reported back"]})}):(0,eI.jsx)("div",{className:nf("group flex w-full max-w-full overflow-x-hidden",f&&"flex-row-reverse"),children:(0,eI.jsxs)("div",{className:nf("min-w-0 max-w-full",f?"max-w-[70%]":"w-full"),children:[!f&&E&&(0,eI.jsxs)("div",{className:"mt-4",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>k(e=>!e),"aria-expanded":w,className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground",children:[(0,eI.jsx)(Io,{className:nf("h-3.5 w-3.5 transition-transform",w&&"rotate-90"),"aria-hidden":"true"}),(0,eI.jsx)(Is,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Thinking"]}),w&&(0,eI.jsx)("div",{className:"mt-2 whitespace-pre-wrap break-words border-l-2 border-border pl-3 text-sm leading-relaxed text-muted-foreground",children:E})]}),b&&(0,eI.jsx)("div",{className:nf("relative flex items-end gap-0"),children:(0,eI.jsx)("div",{className:nf("mt-4 overflow-hidden break-words text-sm font-normal leading-[150%]",f?"rounded-xl rounded-br-none border border-border px-3 py-2 text-foreground":"text-primary"),style:f?{backgroundColor:"var(--color-user-message-bg)"}:void 0,children:f?(0,eI.jsx)("p",{className:"m-0 whitespace-pre-wrap break-words text-sm leading-relaxed",children:g}):b?(0,eI.jsx)(N4,{content:g,isStreaming:n}):null})}),!f&&b&&(0,eI.jsx)("div",{className:"mt-1",children:(0,eI.jsx)("button",{type:"button",onClick:C,"aria-label":A?"Copied":"Copy message",className:"inline-flex items-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:A?(0,eI.jsx)(lU,{className:"h-4 w-4","aria-hidden":"true"}):(0,eI.jsx)(NP,{className:"h-4 w-4","aria-hidden":"true"})})}),f&&b&&(0,eI.jsxs)("div",{className:"mt-1 flex justify-end gap-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100",children:[(0,eI.jsx)("button",{type:"button",onClick:C,"aria-label":A?"Copied":"Copy message",className:"inline-flex items-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:A?(0,eI.jsx)(lU,{className:"h-4 w-4","aria-hidden":"true"}):(0,eI.jsx)(NP,{className:"h-4 w-4","aria-hidden":"true"})}),(0,eI.jsx)("button",{type:"button",onClick:()=>p?.(g),"aria-label":"Edit message",className:"inline-flex items-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(iR,{className:"h-4 w-4","aria-hidden":"true"})})]}),y&&(0,eI.jsx)("div",{className:"mt-4 flex w-full flex-col",children:t.map(e=>{if("task"===e.name)return null;let t=l?.find(t=>t.metadata?.tool_call_id===e.id),n=v.get(e.id),a=n?.actionRequest,p=n?e.id:void 0,h=o?.get(e.name);return(0,eI.jsx)(_1,{toolCall:e,uiComponent:t,stream:c,graphId:d,actionRequest:a,actionRequestKey:p,actionRequestSubmitted:p?i?.has(p):void 0,onActionRequestSubmitted:s,reviewConfig:h,onResume:n?e=>S(n.actionIndex,e):u,isLoading:r,autoApprove:m},e.id)})}),!f&&_.length>0&&(0,eI.jsx)("div",{className:"flex w-fit max-w-full flex-col gap-4",children:_.map(e=>(0,eI.jsxs)("div",{className:"flex w-full flex-col gap-2",children:[(0,eI.jsx)("div",{className:"flex items-end gap-2",children:(0,eI.jsx)("div",{className:"w-[calc(100%-100px)]",children:(0,eI.jsx)(_B,{subAgent:e,onClick:()=>D(e.id),isExpanded:L(e.id)})})}),L(e.id)&&(0,eI.jsx)("div",{className:"w-full max-w-full",children:(0,eI.jsxs)("div",{className:"border-border-light rounded-md border bg-[var(--color-surface)] p-4",children:[(0,eI.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-[var(--color-text-secondary)]",children:"Input"}),(0,eI.jsx)("div",{className:"mb-4",children:(0,eI.jsx)(N4,{content:_E(e.input)})}),(h?.[e.id]?.length??0)>0&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-[var(--color-text-secondary)]",children:"Steps"}),(0,eI.jsx)("div",{className:"mb-4",children:(0,eI.jsx)(N3,{steps:h[e.id],hideFinalText:!!e.output})})]}),e.output&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-[var(--color-text-secondary)]",children:"Output"}),(0,eI.jsx)(N4,{content:_E(e.output)})]})]})})]},e.id))})]})})});Il.displayName="ChatMessage";let Ic=rj("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),Iu=eC.default.memo(({content:e,summarizedCount:t})=>{let[r,n]=(0,eC.useState)(!1),a=function(e){if(!e)return"";let t=e.match(/<summary>\s*([\s\S]*?)\s*<\/summary>/);if(t)return t[1].trim();let r=e.match(/Here is a summary of the conversation to date:\s*([\s\S]*)$/);return r?r[1].trim():e.trim()}(e);return(0,eI.jsxs)("div",{className:"my-3 w-full",children:[(0,eI.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eI.jsx)("div",{className:"h-px flex-1 bg-border"}),(0,eI.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),"aria-expanded":r,className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-3 py-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,eI.jsx)(Ic,{className:"size-3.5 text-[var(--brand)]","aria-hidden":"true"}),"Conversation compacted","number"==typeof t&&t>0&&(0,eI.jsxs)("span",{className:"text-muted-foreground/70",children:["· ",t," earlier"," ",1===t?"message":"messages"," summarized"]}),(0,eI.jsx)(Io,{className:nf("size-3.5 transition-transform",r&&"rotate-90"),"aria-hidden":"true"})]}),(0,eI.jsx)("div",{className:"h-px flex-1 bg-border"})]}),r&&(0,eI.jsx)("div",{className:"mt-2 overflow-hidden rounded-md border border-border bg-muted/20 px-4 py-3",children:(0,eI.jsx)(N4,{content:a})})]})});Iu.displayName="CompactionSummary";let Id=eC.default.memo(function({items:e,isStreaming:t,defaultCollapsed:r,isAtBottom:n,lastMessageId:a,isLoading:i,actionRequests:s,submittedActionRequestKeys:o,onActionRequestSubmitted:l,reviewConfigsMap:c,stream:u,onResumeInterrupt:d,graphId:p,onEditMessage:m,autoApprove:h,subAgentSteps:f,ui:g,compactionAnchorId:b,summarizationEvent:y}){let E=(0,eC.useMemo)(()=>!h&&0!==s.length&&void 0!==a&&e.some(e=>e.message.id===a),[h,s.length,a,e]),[_,v]=(0,eC.useState)(()=>!r),x=(0,eC.useRef)(t);(0,eC.useEffect)(()=>{let e=x.current;x.current=t,e&&!t&&!E&&r&&n&&v(!1)},[t,E,r,n]);let T=e.reduce((e,t)=>e+t.toolCalls.length,0),S=function(e){for(let t=e.length-1;t>=0;t--){let r=e[t].toolCalls;if(r.length>0)return r[r.length-1].name||"tool"}return"action"}(e),w=t?`${T} action${1===T?"":"s"} running — ${S}`:`${T} action${1===T?"":"s"} — last: ${S}`;return(0,eI.jsxs)("div",{className:"my-2",children:[(0,eI.jsxs)("button",{type:"button","aria-expanded":_,"aria-label":`${_?"Collapse":"Expand"} ${w}`,title:w,onClick:()=>v(e=>!e),className:nf("group flex w-full items-center gap-2 rounded-md border border-border bg-[var(--color-surface)] px-3 py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[(0,eI.jsx)(Io,{"aria-hidden":"true",className:nf("size-3.5 shrink-0 transition-transform",_&&"rotate-90")}),t&&(0,eI.jsx)(iI,{"aria-hidden":"true",className:"size-3.5 shrink-0 animate-spin text-[var(--brand)]"}),(0,eI.jsx)("span",{className:"truncate",children:w})]}),(()=>{if(_||!E||void 0===a)return null;let r=e.find(e=>e.message.id===a);if(!r)return null;let n=g?.filter(e=>e.metadata?.message_id===r.message.id);return(0,eI.jsx)("div",{className:"mt-2 space-y-2 border-l-2 border-border pl-3",children:(0,eI.jsx)(Il,{message:r.message,toolCalls:r.toolCalls,isLoading:i,isStreaming:t,actionRequests:s,submittedActionRequestKeys:o,onActionRequestSubmitted:l,reviewConfigsMap:c??void 0,ui:n,stream:u,onResumeInterrupt:d,graphId:p,onEditMessage:m,autoApprove:h,subAgentSteps:f})})})(),_&&(0,eI.jsxs)("div",{className:"mt-2 space-y-2 border-l-2 border-border pl-3",children:[e.map(e=>{let r=e.message.id===a,n=g?.filter(t=>t.metadata?.message_id===e.message.id),E=b===e.message.id;return(0,eI.jsxs)(eC.default.Fragment,{children:[E&&y&&(0,eI.jsx)(Iu,{content:y.content,summarizedCount:y.cutoffIndex}),(0,eI.jsx)(Il,{message:e.message,toolCalls:e.toolCalls,isLoading:i,isStreaming:t&&r,actionRequests:r?s:void 0,submittedActionRequestKeys:o,onActionRequestSubmitted:l,reviewConfigsMap:r?c??void 0:void 0,ui:n,stream:u,onResumeInterrupt:d,graphId:p,onEditMessage:m,autoApprove:h,subAgentSteps:f})]},e.message.id)}),(0,eI.jsxs)("button",{type:"button",onClick:()=>v(!1),className:"flex w-full items-center justify-center gap-1.5 rounded-md py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Collapse ${T} action${1===T?"":"s"}`,children:[(0,eI.jsx)(l$,{"aria-hidden":"true",className:"size-3.5"}),"Collapse"]})]})]})}),Ip=rj("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Im=rj("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]),Ih=rj("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),If=rj("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);function Ig(e,t){let r=0x811c9dc5^t;for(let t=0;t<e.length;t++)r^=e.charCodeAt(t),r=Math.imul(r,0x1000193);return((r>>>0)/0xffffffff-.5)*4}function Ib(e){switch(e){case"complements":return"#10b981";case"contradicts":return"#f43f5e";case"supersedes":return"#f59e0b";default:return"#94a3b8"}}function Iy(e){return Math.max(9,Math.min(22,9+2.5*e))}function IE(e){return"procedural"===e?"#0ea5e9":"#6366f1"}function I_(e){switch(e){case"complements":return"Complements";case"contradicts":return"Contradicts";case"supersedes":return"Supersedes";default:return e}}let Iv="scheduled_task",Ix="scheduler";function IT(){let e=eG();if(!e)return null;let t=e.langsmithApiKey||eN.default.env.NEXT_PUBLIC_LANGSMITH_API_KEY||"";return new aa({apiUrl:e.deploymentUrl,defaultHeaders:t?{"X-Api-Key":t}:{}})}function IS(e){let t=e.metadata??{};return{cron_id:e.cron_id,name:"string"==typeof t.name&&t.name?t.name:"Unnamed Task",prompt:"string"==typeof t.prompt?t.prompt:"",schedule:e.schedule,next_run_date:e.next_run_date??null,created_at:e.created_at,updated_at:e.updated_at}}async function Iw(){let e=IT();return e?(await e.crons.search({limit:200})).filter(e=>e.metadata?.run_kind===Iv).map(IS):[]}async function Ik(e){let t=IT();if(!t)throw Error("No EvoScientist deployment configured.");return IS(await t.crons.create(Ix,{input:{messages:[{role:"user",content:e.prompt}]},schedule:e.schedule,metadata:{run_kind:Iv,name:e.name,prompt:e.prompt}}))}async function IA(e){let t=IT();if(!t)throw Error("No EvoScientist deployment configured.");await t.crons.delete(e)}async function IN(e){let t=await Ik({name:e.name,prompt:e.prompt,schedule:e.schedule});try{return await IA(e.cronId),{task:t,oldTaskDeleted:!0}}catch{return{task:t,oldTaskDeleted:!1}}}async function II(e){let t=IT();if(!t)throw Error("No EvoScientist deployment configured.");let r=await t.threads.create({graphId:Ix});await t.runs.create(r.thread_id,Ix,{input:{messages:[{role:"user",content:e}]},metadata:{run_kind:Iv,name:"manual-run",prompt:e}})}async function IC(e){let t=await e.json().catch(()=>null);return e.ok?t:null}function IR(e){let t=new Date(e).getTime();return Number.isFinite(t)?t:0}function IO({onNavigate:e,onOpenThread:t}){let{data:r}=cZ({limit:100}),n=(0,eC.useMemo)(()=>(r??[]).flat().filter(e=>e.pinned).sort((e,t)=>t.updatedAt.getTime()-e.updatedAt.getTime()).slice(0,5),[r]),[a,i]=(0,eC.useState)(0),[s,o]=(0,eC.useState)(0),[l,c]=(0,eC.useState)(0),[u,d]=(0,eC.useState)(0),[p,m]=(0,eC.useState)([]),[h,f]=(0,eC.useState)(!1),g=(0,eC.useRef)(0);(0,eC.useEffect)(()=>{let e=++g.current;(async()=>{try{let[t,r,n,a]=await Promise.all([fetch("/api/memory/observations",{cache:"no-store"}).catch(()=>null),fetch("/api/memory/executions",{cache:"no-store"}).catch(()=>null),fetch("/api/workspace?recursive=1",{cache:"no-store"}).catch(()=>null),Iw().catch(()=>[])]),s=t?await IC(t):null,l=r?await IC(r):null,u=n?await IC(n):null;if(g.current!==e)return;d(a.length),c((Array.isArray(u?.entries)?u.entries:[]).reduce((e,t)=>e+("number"==typeof t.size?t.size:0),0));let p=Array.isArray(s?.nodes)?s.nodes:[],h=Array.isArray(l?.entries)?l.entries:[];i(p.length),o(h.length);let b=[...h.map(e=>({kind:"execution",id:e.id,created_at:e.created_at,createdAtMs:IR(e.created_at),summary:e.summary||"Execution completed",label:e.agent||"agent",color:"var(--brand)"})),...p.map(e=>({kind:"observation",id:e.id,created_at:e.created_at,createdAtMs:IR(e.created_at),summary:e.summary||e.id,label:e.memory_type||"memory",color:IE(e.memory_type)}))];b.sort((e,t)=>t.createdAtMs-e.createdAtMs),m(b.slice(0,5)),f(!0)}catch{g.current===e&&f(!0)}})()},[]);let b=h&&(a>0||s>0||u>0||l>0);if(!b&&0===n.length)return null;let y=l<=0?{num:"0",unit:""}:l<1024?{num:String(l),unit:"B"}:l<1048576?{num:String(Math.round(l/1024)),unit:"KB"}:{num:(l/1048576).toFixed(1),unit:"MB"},E=[{value:a,label:"Knowledge",hint:"Observations EvoScientist has learned.",Icon:Ip,target:{view:"memory",tab:"knowledge"}},{value:s+a,label:"Timeline",hint:"Runs and observations on the activity timeline.",Icon:Im,target:{view:"memory",tab:"history"}},{value:y.num,unit:y.unit,label:"Workspace",hint:"Total size of files in the current workspace.",Icon:_R,target:{view:"workspace"}},{value:u,label:"Scheduled",hint:"Recurring scheduled tasks.",Icon:iA,target:{view:"schedule"}}];return(0,eI.jsxs)("div",{className:"mt-7 w-full max-w-xl text-left sm:mt-8",children:[b&&(0,eI.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:E.map(({value:t,unit:r,label:n,hint:a,Icon:i,target:s})=>(0,eI.jsxs)("button",{type:"button",onClick:()=>e(s),title:a,"aria-label":`${n}: ${t}${r?` ${r}`:""}. ${a}`,className:"hover:border-[var(--brand)]/40 flex min-h-[82px] flex-col items-center justify-center gap-1 rounded-md border border-border bg-[var(--color-surface)] px-2 py-2.5 transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(i,{className:"size-4 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsxs)("span",{className:"relative inline-block text-base font-bold leading-none text-foreground sm:text-lg",children:[t,r&&(0,eI.jsx)("span",{className:"absolute left-full top-0 ml-0.5 text-[9px] font-medium text-muted-foreground/70",children:r})]}),(0,eI.jsx)("span",{className:"text-[11px] leading-none text-muted-foreground",children:n})]},n))}),n.length>0&&(0,eI.jsxs)("div",{className:"mt-4 sm:mt-5",children:[(0,eI.jsxs)("div",{className:"mb-2 flex items-center gap-1.5",children:[(0,eI.jsx)(iO,{className:"size-3 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Your research"})]}),(0,eI.jsx)("div",{className:"space-y-1",children:n.map(e=>(0,eI.jsxs)("button",{type:"button",onClick:()=>t(e.id),title:`Open ${e.title}`,"aria-label":`Open pinned research thread: ${e.title}`,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(iC,{className:"size-3.5 flex-shrink-0 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:e.title}),(0,eI.jsx)("span",{className:"flex-shrink-0 text-[11px] tabular-nums text-muted-foreground",children:lK(e.updatedAt)})]},e.id))})]}),b&&p.length>0&&(0,eI.jsxs)("div",{className:"mt-4 sm:mt-5",children:[(0,eI.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,eI.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,eI.jsx)(If,{className:"size-3 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Recent activity"})]}),(0,eI.jsxs)("button",{type:"button",onClick:()=>e({view:"memory",tab:"history"}),className:"flex items-center gap-1 text-[11px] text-[var(--brand)] transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:["View all",(0,eI.jsx)(Ih,{className:"size-3","aria-hidden":"true"})]})]}),(0,eI.jsx)("div",{className:"space-y-1",children:p.map(t=>(0,eI.jsxs)("button",{type:"button",onClick:()=>e("observation"===t.kind?{view:"memory",tab:"knowledge",obsId:t.id}:{view:"memory",tab:"history",execId:t.id}),title:t.summary,"aria-label":`Open ${t.kind}: ${t.summary}`,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)("span",{className:"size-2 flex-shrink-0 rounded-full",style:{background:t.color},"aria-hidden":"true"}),(0,eI.jsx)("span",{className:"flex-shrink-0 text-xs font-medium text-foreground",children:t.label}),(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:t.summary}),(0,eI.jsx)("span",{className:"flex-shrink-0 text-[11px] tabular-nums text-muted-foreground",children:lK(new Date(t.createdAtMs||NaN))})]},`${t.kind}-${t.id}`))})]})]})}let IL=rj("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),ID="__other__";function IP({questions:e,onSubmit:t,onCancel:r,isLoading:n}){let[a,i]=(0,eC.useState)(()=>e.map(()=>"")),[s,o]=(0,eC.useState)(()=>e.map(()=>null)),l=(e,t)=>i(r=>r.map((r,n)=>n===e?t:r)),c=(e,t)=>o(r=>r.map((r,n)=>n===e?t:r)),u=e=>"text"===e.type&&!1===e.required,d=e.every((e,t)=>u(e)||""!==a[t].trim());return(0,eI.jsxs)("div",{className:"w-full rounded-lg border border-border bg-muted/30 p-4",children:[(0,eI.jsxs)("div",{className:"mb-3 flex items-center gap-2 text-foreground",children:[(0,eI.jsx)(IL,{size:16,className:"text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"EvoScientist Needs Your Input"})]}),(0,eI.jsx)("div",{className:"space-y-5",children:e.map((e,t)=>(0,eI.jsxs)("div",{children:[(0,eI.jsxs)("p",{className:"mb-2 text-sm font-medium text-foreground",children:[e.question,!u(e)&&(0,eI.jsx)("span",{className:"ml-1 text-destructive",children:"*"})]}),"multiple_choice"===e.type?(0,eI.jsxs)("div",{className:"flex flex-col gap-2",children:[e.choices?.map(e=>{let r=s[t]===e.value;return(0,eI.jsx)("button",{type:"button",disabled:n,onClick:()=>{c(t,e.value),l(t,e.value)},className:nf("rounded-md border px-3 py-2 text-left text-sm transition-colors",r?"border-[var(--brand-solid)] bg-[var(--brand-solid)] text-[var(--brand-foreground)]":"border-border bg-background hover:bg-accent"),children:e.value},e.value)}),(0,eI.jsx)("button",{type:"button",disabled:n,onClick:()=>{c(t,ID),l(t,"")},className:nf("rounded-md border px-3 py-2 text-left text-sm transition-colors",s[t]===ID?"border-[var(--brand)] text-foreground":"border-border bg-background hover:bg-accent"),children:"Other…"}),s[t]===ID&&(0,eI.jsx)(_X,{value:a[t],onChange:e=>l(t,e.target.value),placeholder:"Type your answer…",className:"text-sm",rows:2,disabled:n})]}):(0,eI.jsx)(_X,{value:a[t],onChange:e=>l(t,e.target.value),placeholder:u(e)?"Type your answer… (optional)":"Type your answer…",className:"text-sm",rows:2,disabled:n})]},t))}),(0,eI.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,eI.jsx)(nP,{variant:"outline",size:"sm",onClick:r,disabled:n,children:"Cancel"}),(0,eI.jsx)(nP,{size:"sm",onClick:()=>t(a),disabled:!d||n,className:"bg-[var(--brand-solid)] text-[var(--brand-foreground)] hover:opacity-90",children:n?"Submitting…":"Submit"})]})]})}function IM(e,t){if("string"!=typeof e||!e.trim())return null;let r=e.trim(),n=r.lastIndexOf("/"),a=n>=0?r.slice(0,n):"";n>=0&&(r=r.slice(n+1)),r=r.replace(/-\d{8}$/,"");let i="string"==typeof t&&t.trim()||a;return{name:r,provider:i?i.charAt(0).toUpperCase()+i.slice(1):null}}let Ij="evoscientist-auto-approve",IF="__new__";function IU(){try{let e=localStorage.getItem(Ij);if(!e)return{};let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t))return t}catch{}return{}}function IB(e){try{localStorage.setItem(Ij,JSON.stringify(e))}catch{}}function I$(e){return!0===IU()[e??IF]}function Iz(e,t){let r=IU(),n=e??IF;t?r[n]=!0:delete r[n],IB(r)}function IH(e,t){let r=t?.enabled??!0,n=t?.intervalMs??3e3,a=ao(),[i,s]=(0,eC.useState)([]),[o,l]=(0,eC.useState)(!1),[c,u]=(0,eC.useState)(null),d=(0,eC.useRef)(0),p=(0,eC.useRef)(!0),m=(0,eC.useRef)(new Set);(0,eC.useEffect)(()=>{m.current.clear()},[a,e]);let h=(0,eC.useCallback)(async()=>{if(!r||!e){s([]),l(!0);return}let t=++d.current;try{let r=await a.threads.getState(e),n=function(e){if(!e||"object"!=typeof e)return[];let t=[];for(let r of Object.values(e))r&&"object"==typeof r&&"string"==typeof r.task_id&&"string"==typeof r.agent_name&&t.push({task_id:r.task_id,agent_name:r.agent_name,thread_id:"string"==typeof r.thread_id?r.thread_id:r.task_id,run_id:"string"==typeof r.run_id?r.run_id:"",status:"string"==typeof r.status?r.status:"",created_at:"string"==typeof r.created_at?r.created_at:void 0,last_updated_at:"string"==typeof r.last_updated_at?r.last_updated_at:void 0});return t.sort((e,t)=>(t.created_at??"").localeCompare(e.created_at??"")),t}(r.values?.async_tasks),i=await Promise.all(n.map(async e=>{if(!e.run_id)return{...e,liveStatus:e.status,startedAt:e.created_at};let t=`${e.thread_id}:${e.run_id}`;if(m.current.has(t))return{...e,liveStatus:"expired",startedAt:e.created_at,endedAt:e.last_updated_at??e.created_at};try{let t=await a.runs.get(e.thread_id,e.run_id),r=t.status??e.status;return{...e,liveStatus:r,startedAt:t.created_at??e.created_at,endedAt:In(r)?t.updated_at??e.last_updated_at:void 0}}catch(r){if("object"==typeof r&&null!==r&&404===r.status)return m.current.add(t),{...e,liveStatus:"expired",startedAt:e.created_at,endedAt:e.last_updated_at??e.created_at};return{...e,liveStatus:e.status,startedAt:e.created_at}}}));if(t!==d.current||!p.current)return;s(i),u(null)}catch{t===d.current&&p.current&&u("Couldn't load background agents.")}finally{t===d.current&&p.current&&l(!0)}},[a,e,r]);return(0,eC.useEffect)(()=>{if(p.current=!0,!r)return s([]),l(!0),()=>{p.current=!1};l(!1),h();let e=setInterval(()=>{document.hidden||h()},n);return()=>{p.current=!1,clearInterval(e)}},[h,r,n]),{tasks:i,loaded:o,error:c,refresh:h}}let IG="evoscientist-auto-notify",Iq="evoscientist-auto-notify-reported",IV="evo-auto-notify-change";function IW(){try{let e=localStorage.getItem(IG);if(!e)return{};let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t))return t}catch{}return{}}function IY(){try{let e=localStorage.getItem(Iq);if(!e)return{};let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t))return t}catch{}return{}}function IK(e){try{localStorage.setItem(Iq,JSON.stringify(e))}catch{}}function IZ(e){return!!e&&!1!==IW()[e]}function IX(e,t){if(!e)return;let r=IY(),n=r[e];r[e]={initialized:!0,keys:Array.from(new Set([...n?.keys??[],...t]))},IK(r)}function IQ(e,t){if(!e)return;let r=IY(),n=r[e];r[e]={initialized:n?.initialized??!0,keys:Array.from(new Set([...n?.keys??[],t]))},IK(r)}function IJ(e){let[t,r]=(0,eC.useState)(()=>IZ(e));return(0,eC.useEffect)(()=>{let t=()=>r(IZ(e));return t(),window.addEventListener(IV,t),window.addEventListener("storage",t),()=>{window.removeEventListener(IV,t),window.removeEventListener("storage",t)}},[e]),[t,(0,eC.useCallback)(t=>(function(e,t){if(!e)return;let r=IW();t?delete r[e]:r[e]=!1;try{localStorage.setItem(IG,JSON.stringify(r))}catch{}window.dispatchEvent(new Event(IV))})(e,t),[e])]}let I0={damping:.7,stiffness:.05,mass:1.25},I1=1e3/60,I2=!1;function I4(e,t){let r=(0,eC.useCallback)(t=>(r.current=t,e(t)),t);return r}globalThis.document?.addEventListener("mousedown",()=>{I2=!0}),globalThis.document?.addEventListener("mouseup",()=>{I2=!1}),globalThis.document?.addEventListener("click",()=>{I2=!1});let I3=new Map;function I5(...e){let t={...I0},r=!1;for(let n of e){if("instant"===n){r=!0;continue}"object"==typeof n&&(r=!1,t.damping=n.damping??t.damping,t.stiffness=n.stiffness??t.stiffness,t.mass=n.mass??t.mass)}let n=JSON.stringify(t);return I3.has(n)||I3.set(n,Object.freeze(t)),r?"instant":I3.get(n)}let I6=rj("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),I9=rj("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),I8=ci?e=>{e()}:eC.default.startTransition,I7=cO(cU,()=>(e,t,r={})=>{let{mutate:n}=cC(),a=(0,eC.useRef)(e),i=(0,eC.useRef)(t),s=(0,eC.useRef)(r),o=(0,eC.useRef)(0),[l,c,u]=(e=>{let[,t]=(0,eC.useState)({}),r=(0,eC.useRef)(!1),n=(0,eC.useRef)(e),a=(0,eC.useRef)({data:!1,error:!1,isValidating:!1}),i=(0,eC.useCallback)(e=>{let i=!1,s=n.current;for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&s[t]!==e[t]&&(s[t]=e[t],a.current[t]&&(i=!0));i&&!r.current&&t({})},[]);return co(()=>(r.current=!1,()=>{r.current=!0})),[n,a.current,i]})({data:l0,error:l0,isMutating:!1}),d=l.current,p=(0,eC.useCallback)(async(e,t)=>{let[r,l]=ch(a.current);if(!i.current)throw Error("Can’t trigger the mutation: missing fetcher.");if(!r)throw Error("Can’t trigger the mutation: missing key.");let c=l4(l4({populateCache:!1,throwOnError:!0},s.current),t),d=cg();o.current=d,u({isMutating:!0});try{let t=await n(r,i.current(l,{arg:e}),l4(c,{throwOnError:!0}));return o.current<=d&&(I8(()=>u({data:t,isMutating:!1,error:void 0})),null==c.onSuccess||c.onSuccess.call(c,t,r,c)),t}catch(e){if(o.current<=d&&(I8(()=>u({error:e,isMutating:!1})),null==c.onError||c.onError.call(c,e,r,c),c.throwOnError))throw e}},[]),m=(0,eC.useCallback)(()=>{o.current=cg(),u({data:l0,error:l0,isMutating:!1})},[]);return co(()=>{a.current=e,i.current=t,s.current=r}),{trigger:p,reset:m,get data(){return c.data=!0,d.data},get error(){return c.error=!0,d.error},get isMutating(){return c.isMutating=!0,d.isMutating}}}),Ce={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",cpp:"cpp",c:"c",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",json:"json",xml:"xml",html:"html",css:"css",scss:"scss",sass:"sass",less:"less",sql:"sql",yaml:"yaml",yml:"yaml",toml:"toml",ini:"ini",dockerfile:"dockerfile",makefile:"makefile"},Ct=eC.default.memo(({file:e,onSaveFile:t,onClose:r,editDisabled:n})=>{let[a,i]=(0,eC.useState)(null===e),[s,o]=(0,eC.useState)(String(e?.path||"")),[l,c]=(0,eC.useState)(String(e?.content||"")),u=I7({kind:"files-update",fileName:s,fileContent:l},async({fileName:e,fileContent:r})=>{if(e&&r)return await t(e,r)},{onSuccess:()=>i(!1),onError:e=>c6.toast.error(`Failed to save file: ${e}`)});(0,eC.useEffect)(()=>{o(String(e?.path||"")),c(String(e?.content||"")),i(null===e)},[e]);let d=(0,eC.useMemo)(()=>{let e=String(s||"");return e.split(".").pop()?.toLowerCase()||""},[s]),p=(0,eC.useMemo)(()=>"md"===d||"markdown"===d,[d]),m=(0,eC.useMemo)(()=>Ce[d]||"text",[d]),h=(0,eC.useCallback)(()=>{l&&NM(l)},[l]),f=(0,eC.useCallback)(()=>{if(l&&s){let e=new Blob([l],{type:"text/plain"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=s,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(t)}},[l,s]),g=(0,eC.useCallback)(()=>{i(!0)},[]),b=(0,eC.useCallback)(()=>{null===e?r():(o(String(e.path)),c(String(e.content)),i(!1))},[e,r]),y=(0,eC.useMemo)(()=>""!==s.trim()&&!s.includes("/")&&!s.includes(" "),[s]);return(0,eI.jsx)(ng,{open:!0,onOpenChange:r,children:(0,eI.jsxs)(nE,{"aria-describedby":void 0,className:"flex h-[80vh] max-h-[80vh] min-w-[60vw] flex-col p-6",children:[(0,eI.jsx)(nx,{className:"sr-only",children:e?.path||"New File"}),(0,eI.jsxs)("div",{className:"mb-4 flex items-center justify-between border-b border-border pb-4",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)(I6,{className:"h-5 w-5 shrink-0 text-[var(--color-text-tertiary)]"}),a&&null===e?(0,eI.jsx)(nB,{value:s,onChange:e=>o(e.target.value),placeholder:"Enter filename…",className:"text-base font-medium","aria-invalid":!y}):(0,eI.jsx)("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap text-base font-medium text-primary",children:e?.path})]}),(0,eI.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:!a&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)(nP,{onClick:g,variant:"ghost",size:"sm",className:"h-8 px-2",disabled:n,children:[(0,eI.jsx)(ac,{size:16,className:"mr-1"}),"Edit"]}),(0,eI.jsxs)(nP,{onClick:h,variant:"ghost",size:"sm",className:"h-8 px-2",children:[(0,eI.jsx)(NP,{size:16,className:"mr-1"}),"Copy"]}),(0,eI.jsxs)(nP,{onClick:f,variant:"ghost",size:"sm",className:"h-8 px-2",children:[(0,eI.jsx)(iN,{size:16,className:"mr-1"}),"Download"]})]})})]}),(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:a?(0,eI.jsx)(_X,{value:l,onChange:e=>c(e.target.value),placeholder:"Enter file content…",className:"h-full min-h-[400px] resize-none font-mono text-sm"}):(0,eI.jsx)(sc,{className:"h-full rounded-md bg-[var(--color-surface)]",children:(0,eI.jsx)("div",{className:"p-4",children:l?p?(0,eI.jsx)("div",{className:"rounded-md p-6",children:(0,eI.jsx)(N4,{content:l})}):(0,eI.jsx)(NL,{language:m,style:ND,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem"},showLineNumbers:!0,wrapLines:!0,lineProps:{style:{whiteSpace:"pre-wrap"}},children:l}):(0,eI.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"File is empty"})})})})}),a&&(0,eI.jsxs)("div",{className:"mt-4 flex justify-end gap-2 border-t border-border pt-4",children:[(0,eI.jsxs)(nP,{onClick:b,variant:"outline",size:"sm",children:[(0,eI.jsx)(rF,{size:16,className:"mr-1"}),"Cancel"]}),(0,eI.jsxs)(nP,{onClick:()=>u.trigger(),size:"sm",disabled:u.isMutating||!s.trim()||!l.trim()||!y,children:[u.isMutating?(0,eI.jsx)(iI,{size:16,className:"mr-1 animate-spin"}):(0,eI.jsx)(I9,{size:16,className:"mr-1"}),"Save"]})]})]})})});function Cr({files:e,setFiles:t,editDisabled:r}){let[n,a]=(0,eC.useState)(null),i=(0,eC.useCallback)(async(r,n)=>{await t({...e,[r]:n}),a({path:r,content:n})},[e,t]);return(0,eI.jsxs)(eI.Fragment,{children:[0===Object.keys(e).length?(0,eI.jsx)("div",{className:"flex h-full items-center justify-center p-4 text-center",children:(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"No files created yet"})}):(0,eI.jsx)("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(256px,1fr))] gap-2",children:Object.keys(e).map(t=>{let r,n=String(t),i=e[t];if("object"==typeof i&&null!==i&&"content"in i){let e=i.content;r=Array.isArray(e)?e.join("\n"):String(e||"")}else r=String(i||"");return(0,eI.jsxs)("button",{type:"button",onClick:()=>a({path:n,content:r}),className:"cursor-pointer space-y-1 truncate rounded-md border border-border px-2 py-3 shadow-sm transition-colors",style:{backgroundColor:"var(--color-file-button)"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="var(--color-file-button-hover)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="var(--color-file-button)"},children:[(0,eI.jsx)(I6,{size:24,className:"mx-auto text-muted-foreground"}),(0,eI.jsx)("span",{className:"mx-auto block w-full truncate break-words text-center text-sm leading-relaxed text-foreground",children:n})]},n)})}),n&&(0,eI.jsx)(Ct,{file:n,onSaveFile:i,onClose:()=>a(null),editDisabled:r})]})}Ct.displayName="FileViewDialog",eC.default.memo(({todos:e,files:t,setFiles:r})=>{let{isLoading:n,interrupt:a}=_w(),[i,s]=(0,eC.useState)(!1),[o,l]=(0,eC.useState)(!1),c=(0,eC.useRef)(e.length),u=(0,eC.useRef)(Object.keys(t).length);(0,eC.useEffect)(()=>{0===c.current&&e.length>0&&s(!0),c.current=e.length},[e.length]);let d=Object.keys(t).length;(0,eC.useEffect)(()=>{0===u.current&&d>0&&l(!0),u.current=d},[d]);let p=(0,eC.useCallback)(e=>{switch(e){case"completed":return(0,eI.jsx)(_N,{size:12,className:"text-[var(--color-success)]"});case"in_progress":return(0,eI.jsx)(iA,{size:12,className:"text-[var(--color-warning)]"});default:return(0,eI.jsx)(_I,{size:10,className:"text-[var(--color-text-tertiary)]"})}},[]),m=(0,eC.useMemo)(()=>({pending:e.filter(e=>"pending"===e.status),in_progress:e.filter(e=>"in_progress"===e.status),completed:e.filter(e=>"completed"===e.status)}),[e]),h={pending:"Pending",in_progress:"In Progress",completed:"Completed"};return(0,eI.jsx)("div",{className:"min-h-0 w-full flex-1",children:(0,eI.jsx)("div",{className:"font-inter flex h-full w-full flex-col p-0",children:(0,eI.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-hidden",children:[(0,eI.jsxs)("div",{className:"flex items-center justify-between px-3 pb-1.5 pt-2",children:[(0,eI.jsx)("span",{className:"text-xs font-semibold tracking-wide text-zinc-600",children:"AGENT TASKS"}),(0,eI.jsx)("button",{onClick:()=>s(e=>!e),className:nf("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-transform duration-200 hover:bg-muted",i?"rotate-180":"rotate-0"),"aria-label":"Toggle tasks panel",children:(0,eI.jsx)(lB,{size:14})})]}),i&&(0,eI.jsx)("div",{className:"bg-muted-secondary rounded-xl px-3 pb-2",children:(0,eI.jsx)(sc,{className:"h-full",children:0===e.length?(0,eI.jsx)("div",{className:"flex h-full items-center justify-center p-4 text-center",children:(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"No tasks created yet"})}):(0,eI.jsx)("div",{className:"ml-1 p-0.5",children:Object.entries(m).map(([e,t])=>(0,eI.jsxs)("div",{className:"mb-4",children:[(0,eI.jsx)("h3",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-tertiary",children:h[e]}),t.map((t,r)=>(0,eI.jsxs)("div",{className:"mb-1.5 flex items-start gap-2 rounded-sm p-1 text-sm",children:[p(t.status),(0,eI.jsx)("span",{className:"flex-1 break-words leading-relaxed text-inherit",children:t.content})]},`${e}_${t.id}_${r}`))]}))})})}),(0,eI.jsxs)("div",{className:"flex items-center justify-between px-3 pb-1.5 pt-2",children:[(0,eI.jsx)("span",{className:"text-xs font-semibold tracking-wide text-zinc-600",children:"FILE SYSTEM"}),(0,eI.jsx)("button",{onClick:()=>l(e=>!e),className:nf("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-transform duration-200 hover:bg-muted",o?"rotate-180":"rotate-0"),"aria-label":"Toggle files panel",children:(0,eI.jsx)(lB,{size:14})})]}),o&&(0,eI.jsx)(Cr,{files:t,setFiles:r,editDisabled:!0===n||void 0!==a})]})})})}).displayName="TasksFilesSidebar";let Cn=rj("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Ca={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",cpp:"cpp",c:"c",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",sh:"bash",bash:"bash",zsh:"bash",json:"json",jsonl:"json",xml:"xml",html:"html",css:"css",scss:"scss",sql:"sql",yaml:"yaml",yml:"yaml",toml:"toml",ini:"ini",tex:"latex",bib:"latex",r:"r"},Ci=new Set(["png","jpg","jpeg","gif","webp","svg","bmp"]),Cs=new Set([...Object.keys(Ca),"txt","md","markdown","log","csv","tsv","cfg","conf","env","gitignore"]);function Co(e,t=!1){let r=new URLSearchParams({path:e});return t&&r.set("download","1"),`/api/workspace/file?${r.toString()}`}let Cl=eC.default.memo(({path:e,size:t,onClose:r,onChanged:n})=>{let[a,i]=(0,eC.useState)(null),[s,o]=(0,eC.useState)(!1),[l,c]=(0,eC.useState)(null),[u,d]=(0,eC.useState)(!1),[p,m]=(0,eC.useState)(""),[h,f]=(0,eC.useState)(!1),[g,b]=(0,eC.useState)(null),[y,E]=(0,eC.useState)(!1),[_,v]=(0,eC.useState)(!1),[x,T]=(0,eC.useState)(null),S=(0,eC.useRef)(!0);(0,eC.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]);let w=e?e.split("/").pop()||e:"",k=(0,eC.useMemo)(()=>w.includes(".")?w.split(".").pop().toLowerCase():"",[w]),A=Ci.has(k)?"image":"pdf"===k?"pdf":Cs.has(k)?"text":"binary",N="text"===A&&null!=t&&t>2097152;if((0,eC.useEffect)(()=>{if(!e||"text"!==A||N)return void i(null);let t=!1;return o(!0),c(null),d(!1),b(null),fetch(Co(e)).then(async e=>{if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||`Failed to load file (${e.status})`)}return e.text()}).then(e=>{t||i(e)}).catch(e=>{t||c(e.message??"Failed to load file.")}).finally(()=>{t||o(!1)}),()=>{t=!0}},[e,A,N]),!e)return null;let I="md"===k||"markdown"===k,C=Ca[k]||"text",R=u&&null!==a&&p!==a,O=e=>{R?T(e):"close"===e?r():d(!1)},L=async()=>{f(!0),b(null);try{let t=await fetch(Co(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:p})}),r=await t.json().catch(()=>null);if(!t.ok)throw Error(r?.error||"Failed to save.");if(!S.current)return;i(p),d(!1),n?.()}catch(e){S.current&&b(e instanceof Error?e.message:"Failed to save.")}finally{S.current&&f(!1)}},D=async()=>{E(!0),b(null);try{let t=await fetch(Co(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Failed to delete.")}n?.(),r()}catch(e){S.current&&(v(!1),b(e instanceof Error?e.message:"Failed to delete."))}finally{S.current&&E(!1)}};return(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(ng,{open:!0,onOpenChange:e=>{e||O("close")},children:(0,eI.jsxs)(nE,{"aria-describedby":void 0,className:"flex h-[80vh] max-h-[80vh] min-w-[60vw] flex-col p-6",children:[(0,eI.jsx)(nx,{className:"sr-only",children:e}),(0,eI.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-3 border-b border-border pb-4",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)(I6,{className:"h-5 w-5 shrink-0 text-[var(--color-text-tertiary)]","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap text-base font-medium text-primary",children:e})]}),(0,eI.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:u?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)(nP,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>{O("cancel-edit")},disabled:h,children:[(0,eI.jsx)(Cn,{size:16,className:"mr-1","aria-hidden":"true"}),"Cancel"]}),(0,eI.jsxs)(nP,{size:"sm",className:"h-8 bg-[var(--brand-solid)] px-3 text-[var(--brand-foreground)] hover:opacity-90",onClick:L,disabled:h||!R,children:[h?(0,eI.jsx)(iI,{size:16,className:"mr-1 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(I9,{size:16,className:"mr-1","aria-hidden":"true"}),h?"Saving…":"Save"]})]}):(0,eI.jsxs)(eI.Fragment,{children:["text"===A&&!N&&(0,eI.jsxs)(nP,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>{m(a??""),b(null),d(!0)},disabled:s||null===a,"aria-label":"Edit file",children:[(0,eI.jsx)(iR,{size:16,className:"mr-1","aria-hidden":"true"}),"Edit"]}),(0,eI.jsx)(nP,{variant:"ghost",size:"sm",className:"h-8 px-2",asChild:!0,children:(0,eI.jsxs)("a",{href:Co(e,!0),download:w,children:[(0,eI.jsx)(iN,{size:16,className:"mr-1","aria-hidden":"true"}),"Download"]})}),(0,eI.jsx)(nP,{variant:"ghost",size:"sm",className:"h-8 px-2 text-muted-foreground hover:text-destructive",onClick:()=>v(!0),disabled:y,"aria-label":"Delete file",title:"Delete file",children:y?(0,eI.jsx)(iI,{size:16,className:"animate-spin","aria-hidden":"true"}):(0,eI.jsx)(iM,{size:16,"aria-hidden":"true"})})]})})]}),g&&(0,eI.jsx)("p",{role:"alert",className:"mb-2 text-sm text-destructive",children:g}),(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:u?(0,eI.jsx)("textarea",{value:p,onChange:e=>m(e.target.value),spellCheck:!1,"aria-label":"File content",className:"h-full w-full resize-none rounded-md border border-border bg-background p-4 font-mono text-sm leading-relaxed text-foreground outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",placeholder:"File is empty…"}):"image"===A?(0,eI.jsx)(sc,{className:"h-full rounded-md bg-[var(--color-surface)]",children:(0,eI.jsx)("div",{className:"flex items-center justify-center p-4",children:(0,eI.jsx)("img",{src:Co(e),alt:w,className:"max-h-full max-w-full object-contain"})})}):"pdf"===A?(0,eI.jsx)("iframe",{src:Co(e),title:w,className:"h-full w-full rounded-md border border-border"}):"binary"===A||N?(0,eI.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-12 text-center",children:[(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:N?"This file is too large to preview inline.":"This file type can't be previewed."}),(0,eI.jsx)(nP,{variant:"outline",size:"sm",asChild:!0,children:(0,eI.jsxs)("a",{href:Co(e,!0),download:w,children:[(0,eI.jsx)(iN,{size:16,className:"mr-1","aria-hidden":"true"}),"Download file"]})})]}):s?(0,eI.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,eI.jsx)(iI,{className:"size-5 animate-spin text-muted-foreground","aria-hidden":"true"})}):l?(0,eI.jsx)("div",{className:"flex h-full items-center justify-center p-12",children:(0,eI.jsx)("p",{className:"text-sm text-destructive",children:l})}):(0,eI.jsx)(sc,{className:"h-full rounded-md bg-[var(--color-surface)]",children:(0,eI.jsx)("div",{className:"p-4",children:a&&a.length>0?I?(0,eI.jsx)("div",{className:"rounded-md p-6",children:(0,eI.jsx)(N4,{content:a})}):(0,eI.jsx)(NL,{language:C,style:ND,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem"},showLineNumbers:!0,wrapLines:!0,lineProps:{style:{whiteSpace:"pre-wrap"}},children:a}):(0,eI.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"File is empty"})})})})})]})}),(0,eI.jsx)(ng,{open:null!==x,onOpenChange:e=>{e||T(null)},children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Discard unsaved changes?"}),(0,eI.jsxs)(nT,{children:["Your edits to “",w,"” have not been saved."]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:()=>T(null),children:"Keep Editing"}),(0,eI.jsx)(nP,{onClick:()=>{T(null),"close"===x&&r(),"cancel-edit"===x&&d(!1)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Discard"})]})]})}),(0,eI.jsx)(ng,{open:_,onOpenChange:e=>{y||v(e)},children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Delete file?"}),(0,eI.jsxs)(nT,{children:["“",w,"” will be permanently removed from the workspace. This can't be undone."]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:()=>v(!1),disabled:y,children:"Cancel"}),(0,eI.jsx)(nP,{onClick:D,disabled:y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:y?"Deleting…":"Delete"})]})]})})]})});Cl.displayName="WorkspaceFileDialog";let Cc=eC.default.memo(({path:e,onClose:t})=>{let[r,n]=(0,eC.useState)(null),[a,i]=(0,eC.useState)(!1),[s,o]=(0,eC.useState)(null),l=(0,eC.useRef)(0);(0,eC.useEffect)(()=>{if(!e){n(null),o(null);return}let t=++l.current;i(!0),o(null),n(null),(async()=>{try{let r=await fetch(`/api/memory?path=${encodeURIComponent(e)}`);if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||`HTTP ${r.status}`)}let a=await r.json();if(l.current!==t)return;n("string"==typeof a.content?a.content:"")}catch(e){if(l.current!==t)return;o(e instanceof Error?e.message:"Failed to read file.")}finally{l.current===t&&i(!1)}})()},[e]);let c=null!==e,u=e?e.split("/").filter(Boolean).pop()||e:"",d=u.toLowerCase().endsWith(".md");return(0,eI.jsx)(ng,{open:c,onOpenChange:e=>{e||t()},children:(0,eI.jsxs)(nE,{className:"flex h-[80vh] max-h-[80vh] min-w-[60vw] flex-col gap-3 p-6",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsxs)(nx,{className:"flex items-center gap-2 text-base",children:[(0,eI.jsx)(I6,{className:"size-4 shrink-0","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"truncate",children:u})]}),e&&(0,eI.jsx)(nT,{className:"break-all font-mono text-xs",children:e})]}),(0,eI.jsxs)(sc,{className:"-mx-2 max-h-[65vh] flex-1 px-2",children:[a&&(0,eI.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,eI.jsx)(iI,{className:"size-4 animate-spin text-muted-foreground"})}),s&&(0,eI.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm",children:s}),!a&&!s&&null!==r&&(d?(0,eI.jsx)(N4,{content:r}):(0,eI.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-6",children:r}))]})]})})});Cc.displayName="MemoryFileDialog";let Cu={entries:[],defaultEntry:null},Cd=new Map,Cp=["Survey recent papers on a topic","Design an experiment plan","Analyze workspace files"];function Cm(e,t){let r=t.length>0?`
|
|
71
71
|
|
|
72
72
|
Workspace files uploaded for this request:
|
|
73
|
-
${t.map(e=>`- ${e.path}`).join("\n")}`:"";return`${e}${r}`}let Ch=(e,t)=>{switch(e){case"completed":return(0,eI.jsx)(_N,{size:16,className:nf("text-[var(--color-success)]",t)});case"in_progress":return(0,eI.jsx)(iA,{size:16,className:nf("text-[var(--color-warning)]",t)});default:return(0,eI.jsx)(_I,{size:16,className:nf("text-[var(--color-text-tertiary)]",t)})}},Cf=eC.default.memo(({assistant:e,onShowAgents:t,onNotifyReady:r,onNavigate:n,onOpenThread:a,workspaceOpen:i})=>{let s,o,l,c,u,d,[p,m]=(0,eC.useState)(null),h=(0,eC.useRef)(null),f=(0,eC.useRef)(null),g=(0,eC.useRef)(null),[b,y]=(0,eC.useState)(""),[E,_]=(0,eC.useState)([]),[v,x]=(0,eC.useState)(!1),[T,S]=(0,eC.useState)(null);(0,eC.useEffect)(()=>{let e=!1;return fetch("/api/workspace").then(e=>e.ok?e.json():null).then(t=>{!e&&t?.dir&&S(t.dir)}).catch(()=>{}),()=>{e=!0}},[]);let[w,k]=(0,eC.useState)([]),A=(0,eC.useRef)(w);A.current=w;let N=(0,eC.useRef)(0),I=(0,eC.useRef)(null),[C]=e$("threadId"),[R,O]=(0,eC.useState)(null),[L,D]=(0,eC.useState)(null);(0,eC.useEffect)(()=>{let e=e=>{let t=e.detail;t&&("memory"===t.kind?D(t.path):O(t.path))};return window.addEventListener(NK,e),()=>window.removeEventListener(NK,e)},[]);let[P,M]=(0,eC.useState)(()=>I$(C)),[j,F]=(0,eC.useState)(!1),[U,B]=(0,eC.useState)(!1),[$,z]=(0,eC.useState)("");(0,eC.useEffect)(()=>{U&&z("")},[U]);let{registry:H,loading:G,error:q}=function(){let[e,t]=(0,eC.useState)(Cu),[r,n]=(0,eC.useState)(!0),[a,i]=(0,eC.useState)(null);return(0,eC.useEffect)(()=>{let e=eG();if(!e)return void n(!1);let r=!1,a=e.langsmithApiKey||eN.default.env.NEXT_PUBLIC_LANGSMITH_API_KEY||"";return(function(e,t){let r=e.replace(/\/$/,""),n=Cd.get(r);if(n)return n;let a={};t&&(a["X-Api-Key"]=t);let i=fetch(`${r}/api/models`,{headers:a}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json(),r=[];if(Array.isArray(t.entries))for(let e of t.entries)e&&"object"==typeof e&&"string"==typeof e.name&&"string"==typeof e.provider&&e.name&&e.provider&&r.push({name:e.name,model_id:"string"==typeof e.model_id?e.model_id:e.name,provider:e.provider});let n=null;if(t.default&&"object"==typeof t.default){let e=t.default;"string"==typeof e.name&&e.name&&(n={name:e.name,provider:"string"==typeof e.provider&&e.provider?e.provider:null})}return{entries:r,defaultEntry:n}}).catch(e=>{throw Cd.delete(r),e});return Cd.set(r,i),i})(e.deploymentUrl,a).then(e=>{r||(t(e),i(null))}).catch(e=>{r||(i(e instanceof Error?e.message:"Failed to load models."),t(Cu))}).finally(()=>{r||n(!1)}),()=>{r=!0}},[]),{registry:e,loading:r,error:a}}(),V=!G&&0===H.entries.length;(0,eC.useEffect)(()=>{V&&console.warn("[model picker] using curated fallback list — registry fetch failed or empty",q??"(no error message)")},[V,q]);let W=(0,eC.useMemo)(()=>H.entries.length>0?H.entries.map(e=>({model:e.name,model_provider:e.provider})):__.map(e=>({model:e.model,model_provider:e.model_provider})),[H.entries]),Y=(0,eC.useMemo)(()=>{let e=$.trim().toLowerCase();return e?W.filter(t=>{let r=t.model_provider??"";return t.model.toLowerCase().includes(e)||r.toLowerCase().includes(e)}):W},[W,$]),K=(0,eC.useRef)(null),Z=(0,eC.useRef)(C),X=(0,eC.useRef)(!1),{scrollRef:Q,contentRef:J,scrollToBottom:ee,isAtBottom:et}=((e={})=>{let[t,r]=(0,eC.useState)(!1),[n,a]=(0,eC.useState)(!1!==e.initial),[i,s]=(0,eC.useState)(!1),o=(0,eC.useRef)(null);o.current=e;let l=(0,eC.useCallback)(()=>{if(!I2)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),c=(0,eC.useCallback)(e=>{d.isAtBottom=e,a(e)},[]),u=(0,eC.useCallback)(e=>{d.escapedFromLock=e,r(e)},[]),d=(0,eC.useMemo)(()=>{let r;return{escapedFromLock:t,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(scrollTop){if(g.current){let{scrollBehavior:e}=getComputedStyle(g.current);"auto"!==e&&(g.current.style.scrollBehavior="auto"),g.current.scrollTop=scrollTop,d.ignoreScrollToTop=g.current.scrollTop,"auto"!==e&&(g.current.style.scrollBehavior=e)}},get targetScrollTop(){if(!g.current||!b.current)return 0;return g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!b.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(r?.targetScrollTop===t)return r.calculatedScrollTop;let n=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:b.current}),t),0);return r={targetScrollTop:t,calculatedScrollTop:n},requestAnimationFrame(()=>{r=void 0}),n},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),p=(0,eC.useCallback)((e={})=>{let t;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||c(!0);let r=Date.now()+(Number(e.wait)||0),n=I5(o.current,e.animation),{ignoreEscapes:a=!1}=e,i=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{t=Date.now()}):t=r+(e.duration??0);let s=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:c}=d,u=performance.now(),m=(u-(d.lastTick??u))/I1;if(d.animation||(d.animation={behavior:n,promise:e,ignoreEscapes:a}),d.animation.behavior===n&&(d.lastTick=u),l()||r>Date.now())return s();if(c<Math.min(i,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if("instant"===n)return d.scrollTop=d.calculatedTargetScrollTop,s();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*m,d.scrollTop+=d.accumulated,d.scrollTop!==c&&(d.accumulated=0)}return s()}return t>Date.now()?(i=d.calculatedTargetScrollTop,s()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop)?p({animation:I5(o.current,o.current.resize),ignoreEscapes:a,duration:Math.max(0,t-Date.now())||void 0}):d.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return(!0!==e.wait&&(d.animation=void 0),d.animation?.behavior===n)?d.animation.promise:s()},[c,l,d]),m=(0,eC.useCallback)(()=>{u(!0),c(!1)},[u,c]),h=(0,eC.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:r}=d,{lastScrollTop:n=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,r&&r>t&&(n=r),s(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===r)return;if(l()){u(!0),c(!1);return}let e=t>n,a=t<n;if(d.animation?.ignoreEscapes){d.scrollTop=n;return}a&&(u(!0),c(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,l,d]),f=(0,eC.useCallback)(({target:e,deltaY:t})=>{let r=e;for(;!["scroll","auto"].includes(getComputedStyle(r).overflow);){if(!r.parentElement)return;r=r.parentElement}r===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),g=I4(e=>{g.current?.removeEventListener("scroll",h),g.current?.removeEventListener("wheel",f),e?.addEventListener("scroll",h,{passive:!0}),e?.addEventListener("wheel",f,{passive:!0})},[]),b=I4(e=>{let t;d.resizeObserver?.disconnect(),d.resizeObserver=void 0,e&&(d.resizeObserver=new ResizeObserver(([e])=>{let{height:r}=e.contentRect,n=r-(t??r);if(d.resizeDifference=n,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),s(d.isNearBottom),n>=0){let e=I5(o.current,t?o.current.resize:o.current.initial);p({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else d.isNearBottom&&(u(!1),c(!0));t=r,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===n&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e))},[]);return{contentRef:b,scrollRef:g,scrollToBottom:p,stopScroll:m,isAtBottom:n||i,isNearBottom:i,escapedFromLock:t,state:d}})(),{stream:er,messages:en,todos:ea,files:ei,ui:es,setFiles:eo,isLoading:el,isThreadLoading:ec,interrupt:eu,sendMessage:ed,stopStream:ep,resumeInterrupt:em,subAgentActivity:eh,asyncTasks:ef,summarizationEvent:eg,modelOverride:eb,setModelOverride:ey}=_w(),{tasks:eE}=IH(C,{enabled:Object.keys(ef??{}).length>0}),e_=(0,eC.useMemo)(()=>Ia(eE),[eE]),[ev]=IJ(C),ex=(0,eC.useRef)(!1);(0,eC.useEffect)(()=>{ex.current=!1},[C]),(0,eC.useEffect)(()=>{el&&(ex.current=!1)},[el]),(0,eC.useEffect)(()=>{var e;if(!eE||0===eE.length||!C||!ev)return;if(!(C&&IY()[C]?.initialized===!0))return void IX(C,eE.filter(e=>In(e.liveStatus)).map(N8));if(el||ex.current||b.trim()||w.length>0)return;let t=function(e){if(!e)return new Set;let t=IY()[e];return new Set(Array.isArray(t?.keys)?t.keys:[])}(C);for(let r of eE){if(!In(r.liveStatus))continue;let n=N8(r);if(!t.has(n)){if(en.some(e=>"human"===e.type&&Ie(_y(e),r))){IQ(C,n);continue}ex.current=!0,IQ(C,n),ed(It(r)),c6.toast.success(`Auto-reported ${N6[e=r.agent_name]??e} to the main chat.`);break}}},[eE,ev,el,b,en,ed,C,w]),(0,eC.useEffect)(()=>{el&&ee()},[el,ee]);let eT=(0,eC.useRef)({sendMessage:ed,isLoading:el,messages:en,threadId:C});eT.current={sendMessage:ed,isLoading:el,messages:en,threadId:C};let eS=(0,eC.useRef)(r);eS.current=r,(0,eC.useEffect)(()=>(eS.current?.((e,t)=>{let r=eT.current;return r.threadId!==t?"wrong-thread":r.isLoading?"busy":r.messages.some(t=>"human"===t.type&&Ie(_y(t),e))?"duplicate":(IQ(t,N8(e)),r.sendMessage(It(e)),"sent")}),()=>eS.current?.(null)),[]);let ew=(0,eC.useMemo)(()=>{if(eb)return IM(eb.model,eb.model_provider);if(H.defaultEntry)return IM(H.defaultEntry.name,H.defaultEntry.provider??void 0);let t=e?.config,r=t?.configurable;if(r){let e=IM(r.model??r.model_name,r.model_provider);if(e)return e}for(let e=en.length-1;e>=0;e--){let t=en[e];if("ai"!==t.type)continue;let r=t.response_metadata,n=IM(r?.model_name??r?.model,r?.model_provider);if(n)return n}return null},[en,eb,e?.config,H.defaultEntry]),ek=(0,eC.useMemo)(()=>{let e={},t=Object.keys(eh);if(0===t.length)return e;let r=[],n={};for(let e of en)if("ai"===e.type)for(let t of e.tool_calls??[])"task"===t.name&&t.id&&r.push(t.id);else if("tool"===e.type){let t=e.tool_call_id;t&&(n[t]=_y(e))}let a=e=>e.replace(/\s+/g," ").trim(),i=new Set;for(let s of r){let r=a(n[s]??"");if(!r)continue;let o=t.find(e=>{if(i.has(e))return!1;let t=a(function(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if("text"===r.kind)return r.text}return""}(eh[e]));return""!==t&&(r.includes(t)||t.includes(r))});o&&(e[s]=eh[o],i.add(o))}let s=t.filter(e=>!i.has(e)),o=0;for(let t of r)e[t]||n[t]||o<s.length&&(e[t]=eh[s[o++]]);return e},[en,eh]),eA=eu?.value,eR=eA?.type==="ask_user"||Array.isArray(eA?.action_requests)&&eA.action_requests.length>0,eO=el||!e||eR;(0,eC.useEffect)(()=>{if(el||eR||ex.current||0===w.length)return;let[e,...t]=w;e.threadId===C&&(ex.current=!0,k(t),ed(Cm(e.text,e.files)))},[el,eR,w,ed,C]);let eL=(0,eC.useRef)(C);(0,eC.useEffect)(()=>{let e=eL.current;(eL.current=C,null===e&&null!==C)?k(e=>e.map(e=>null===e.threadId?{...e,threadId:C}:e)):e!==C&&k([])},[C]);let eD=(0,eC.useCallback)(()=>{M(!0),Iz(C,!0),F(!1)},[C]),eP=(0,eC.useCallback)(()=>{M(!1),Iz(C,!1),F(!1),K.current=null},[C]);(0,eC.useEffect)(()=>{let e=Z.current;if(e!==C){if(null===e&&null!==C&&X.current){let e;(e=IU())[IF]&&(e[C]=!0),IF in e&&(delete e[IF],IB(e))}else null===e&&null!==C&&Iz(null,!1);M(I$(C)),K.current=null,F(!1),_([]),X.current=!1,Z.current=C}},[C]);let eM=(0,eC.useCallback)(async e=>{let t=Array.from(e.target.files??[]);if(e.target.value="",0!==t.length){x(!0);try{let e=new FormData;t.forEach(t=>e.append("files",t));let r=await fetch("/api/workspace/upload",{method:"POST",body:e}),n=await r.json();if(!r.ok||!n.files)throw Error(n.error||"Failed to upload files.");_(e=>[...e,...n.files]),c6.toast.success(`${n.files.length} file${1===n.files.length?"":"s"} uploaded to the workspace.`)}catch(e){c6.toast.error(e instanceof Error?e.message:"Failed to upload files.")}finally{x(!1)}}},[]),ej=(0,eC.useCallback)(e=>{_(t=>t.filter(t=>t.path!==e))},[]),eF=(0,eC.useCallback)(async e=>{if(e){if("show"===e.kind)return void B(!0);try{if("reset"===e.kind)await ey(null),c6.toast.success("Model override cleared.");else{let t={model:e.model,...e.provider?{model_provider:e.provider}:{}};await ey(t),c6.toast.success(`Model set to ${e.model}${e.provider?` (${e.provider})`:""}.`)}}catch(e){c6.toast.error(e instanceof Error?`Couldn't update model: ${e.message}`:"Couldn't update model — try again.")}}},[ey]),eU=(0,eC.useCallback)(t=>{t&&t.preventDefault();let r=b.trim();if(!r)return;let n=function(e){let t=e.trim();if("/model"!==t&&!t.startsWith("/model "))return null;let r=t.slice(6).trim();if(!r)return{kind:"show"};let n=r.split(/\s+/);return"reset"===n[0].toLowerCase()&&1===n.length?{kind:"reset"}:n.length>2?null:{kind:"set",model:n[0],provider:n[1]}}(r);if(n){eF(n),y("");return}if(e&&!eR&&!v){if(el){k(e=>[...e,{id:N.current+=1,text:r,files:E,threadId:C}]),y(""),_([]);return}X.current=null===C&&P,ed(Cm(r,E)),y(""),_([])}},[b,eF,e,eR,P,el,v,E,ed,C]),eB=(0,eC.useCallback)(e=>{let t=A.current.find(t=>t.id===e);t&&(k(t=>t.filter(t=>t.id!==e)),y(t.text),_(t.files),requestAnimationFrame(()=>{let e=f.current;e&&(e.focus(),e.setSelectionRange(t.text.length,t.text.length))}))},[]),ez=(0,eC.useCallback)(e=>{k(t=>{let r=t.find(t=>t.id===e);return r&&t[0]?.id!==e?[r,...t.filter(t=>t.id!==e)]:t}),c6.toast.info("This message will run next without interrupting the current turn.")},[]),eH=(0,eC.useCallback)((e,t)=>{k(r=>{let n=r.findIndex(t=>t.id===e),a=n+t;if(n<0||a<0||a>=r.length)return r;let i=[...r],[s]=i.splice(n,1);return i.splice(a,0,s),i})},[]),eq=(0,eC.useCallback)(e=>{let t=I.current;I.current=null,null!==t&&t!==e&&k(r=>{let n=r.findIndex(e=>e.id===t),a=r.findIndex(t=>t.id===e);if(n<0||a<0)return r;let i=[...r],[s]=i.splice(n,1);return i.splice(a,0,s),i})},[]),eV=(0,eC.useCallback)(e=>{k(t=>t.filter(t=>t.id!==e))},[]),eW=(0,eC.useCallback)(()=>{k([])},[]),eY=(0,eC.useCallback)(e=>{if(!eR&&!e.nativeEvent.isComposing&&229!==e.keyCode){if("ArrowUp"===e.key&&0===b.length&&A.current.length>0){e.preventDefault();let t=A.current;eB(t[t.length-1].id);return}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),eU())}},[eU,eR,b,eB]),eK=(0,eC.useCallback)(e=>{y(e),requestAnimationFrame(()=>{let t=f.current;t&&(t.focus(),t.setSelectionRange(e.length,e.length))})},[]),eZ=(0,eC.useCallback)(e=>{y(e),requestAnimationFrame(()=>f.current?.focus())},[]);(0,eC.useEffect)(()=>{if(!P)return;let e=eu?.value&&eu.value.action_requests;if(!eu||!Array.isArray(e)||0===e.length){K.current=null;return}K.current!==eu&&(K.current=eu,em({decisions:e.map(()=>({type:"approve"}))}))},[P,eu,em]);let eX=(0,eC.useMemo)(()=>{let e=eu?.value;return e?.type==="ask_user"&&Array.isArray(e.questions)?e.questions:null},[eu]),eQ=(0,eC.useCallback)(e=>{em({status:"answered",answers:e})},[em]),eJ=(0,eC.useCallback)(()=>{em({status:"cancelled"})},[em]),e0=(0,eC.useMemo)(()=>{let e=eu?.value&&eu.value.action_requests;return Array.isArray(e)?e:[]},[eu]),e1=(0,eC.useMemo)(()=>{let e=new Map,t=new Set,r=en.filter(e=>{if("human"===e.type){let r,n=(r=N7(_y(e)))?`${r.taskId}:${r.runId||"legacy"}`:null;return!n||!t.has(n)&&(t.add(n),!0)}let r=er.getMessagesMetadata(e)?.streamMetadata,n=r?.langgraph_checkpoint_ns;return!("string"==typeof n&&n.includes("|")||function(e){if("human"===e.type){var t;if("human"!==e.type)return!1;let r=e.additional_kwargs;return r?.lc_source==="summarization"}return"ai"===e.type&&!!(t=_y(e))&&(!!(/\bconversation that has been summarized\b/.test(t)||/\bHere is a summary of the conversation to date\b/.test(t)||/<summary>[\s\S]*<\/summary>/.test(t))||/##\s+SESSION INTENT\b/.test(t))}(e))}),n=new Set;for(let e of r){if("tool"!==e.type)continue;let t=e.tool_call_id;t&&n.add(t)}let a=new Map;for(let e of e0)a.set(e.name,(a.get(e.name)??0)+1);r.forEach(t=>{if("ai"===t.type){let r,i=(r=[],t.additional_kwargs?.tool_calls&&Array.isArray(t.additional_kwargs.tool_calls)?r.push(...t.additional_kwargs.tool_calls):t.tool_calls&&Array.isArray(t.tool_calls)?r.push(...t.tool_calls.filter(e=>""!==e.name)):Array.isArray(t.content)&&r.push(...t.content.filter(e=>"tool_use"===e.type)),r.map(e=>{let t=e.function?.arguments||e.args||e.input||{};return{id:e.id,name:e.function?.name||e.name||e.type||"",args:function(e){if(e&&"object"==typeof e)return e;if("string"!=typeof e)return{};try{let t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch{return{}}}(t)}})).filter(e=>"ToolSelectionResponse"!==e.name||el&&!eu).map((e,r)=>{let i=e.name||"unknown",s=e.id||`${t.id??"ai-message"}-tool-${r}-${i}`,o=a.get(i)??0,l=o>0&&!n.has(s);return l&&a.set(i,o-1),{id:s,name:i,args:e.args,status:l?"interrupted":"pending"}});e.set(t.id,{message:t,toolCalls:i})}else if("tool"===t.type){let r=t.tool_call_id;if(!r)return;for(let[,n]of e.entries()){let e=n.toolCalls.findIndex(e=>e.id===r);if(-1!==e){n.toolCalls[e]={...n.toolCalls[e],status:"completed",result:_y(t)};break}}}else"human"===t.type&&e.set(t.id,{message:t,toolCalls:[]})});let i=Array.from(e.values());return i.map((e,t)=>{let r=t>0?i[t-1].message:null;return{...e,showAvatar:e.message.type!==r?.type}})},[en,e0,eu,el,er]),{value:e2}=nH(),e4=e=>{let t=e.content;if("string"==typeof t)return t.trim().length>0;if(Array.isArray(t))for(let e of t){let t=e?.text;if("string"==typeof t&&t.trim().length>0)return!0}return!1},e3=(0,eC.useMemo)(()=>{let e=[];for(let t of e1)if("ai"===t.message.type&&t.toolCalls.length>0&&!e4(t.message)){let r=e[e.length-1];r?.kind==="action-group"?r.items.push(t):e.push({kind:"action-group",items:[t]})}else e.push({kind:"message",data:t});return e},[e1]),e5=e1.length>0?e1[e1.length-1].message.id:void 0,e6=(0,eC.useMemo)(()=>{if(!eg)return null;let e=new Set(e1.map(e=>e.message.id));for(let t=eg.cutoffIndex;t<en.length;t++){let r=en[t]?.id;if(null!=r&&e.has(r))return r}return null},[eg,en,e1]),e9={in_progress:ea.filter(e=>"in_progress"===e.status),pending:ea.filter(e=>"pending"===e.status),completed:ea.filter(e=>"completed"===e.status)},e8=ea.length>0,e7=Object.keys(ei).length>0,[te,tt]=(0,eC.useState)(()=>new Set);(0,eC.useEffect)(()=>{0===e0.length&&tt(new Set)},[e0.length]);let tr=(0,eC.useCallback)(e=>{tt(t=>{let r=new Set(t);return r.add(e),r})},[]),tn=(0,eC.useMemo)(()=>{let e=eu?.value&&eu.value.review_configs;if(!Array.isArray(e))return new Map;let t=[];for(let r of e){let e=r.actionName??r.action_name;e&&t.push([e,{actionName:e,allowedDecisions:r.allowedDecisions??r.allowed_decisions}])}return new Map(t)},[eu]);return(0,eI.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,eI.jsx)(ng,{open:j,onOpenChange:F,children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Enable Auto-approve?"}),(0,eI.jsx)(nT,{children:"EvoScientist will run tool actions in this research without asking you to review each one. Turn this on only when you trust the current task and deployment."})]}),(0,eI.jsxs)("div",{className:"flex items-start gap-3 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100",children:[(0,eI.jsx)(_D,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),(0,eI.jsx)("p",{children:"Auto-approve stays on for this research only — it follows this conversation across views and reloads, and other research keeps its own setting. Turn it off here anytime."})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),(0,eI.jsx)(nP,{onClick:eD,className:"bg-amber-600 text-white hover:bg-amber-700",children:"Enable Auto-approve"})]})]})}),(0,eI.jsx)(Cl,{path:R,onClose:()=>O(null)}),(0,eI.jsx)(Cc,{path:L,onClose:()=>D(null)}),(0,eI.jsx)(ng,{open:U,onOpenChange:B,children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Pick a model for this chat"}),(0,eI.jsxs)(nT,{children:["The choice applies per-thread. Type"," ",(0,eI.jsx)("span",{className:"font-mono text-xs",children:"/model <name>"})," ","in the composer to use a name not in the list."]})]}),(0,eI.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,eI.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Current:"," ",(0,eI.jsx)("span",{className:"font-mono",children:ew?`${ew.name}${ew.provider?` (${ew.provider})`:""}`:"deployment default"}),G&&(0,eI.jsx)("span",{className:"ml-2 italic",children:"loading registry…"})]}),V&&(0,eI.jsxs)("div",{className:"border-[var(--color-warning)]/30 bg-[var(--color-warning)]/5 flex items-start gap-2 rounded-md border px-3 py-2 text-xs text-foreground",children:[(0,eI.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none text-[var(--color-warning)]",children:"⚠"}),(0,eI.jsxs)("span",{children:["Showing a curated subset — the deployment’s",(0,eI.jsx)("span",{className:"mx-1 font-mono",children:"/api/models"}),"registry didn’t load",q?` (${q})`:"",". Other short names still work via"," ",(0,eI.jsx)("span",{className:"font-mono",children:"/model <name>"}),"."]})]}),(0,eI.jsx)("input",{type:"text",value:$,onChange:e=>z(e.target.value),placeholder:"Filter by name or provider…",autoFocus:!0,className:"w-full rounded-md border border-border bg-background px-3 py-1.5 font-mono text-sm placeholder:font-sans placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),(0,eI.jsxs)("ul",{className:"max-h-72 space-y-1 overflow-y-auto pl-0",children:[0===Y.length&&(0,eI.jsxs)("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models match “",$,"”."]}),Y.map(e=>{let t=eb?.model===e.model&&eb?.model_provider===e.model_provider,r=!eb&&H.defaultEntry?.name===e.model&&(H.defaultEntry?.provider??null)===(e.model_provider??null);return(0,eI.jsx)("li",{children:(0,eI.jsxs)("button",{type:"button",onClick:async()=>{try{await ey({model:e.model,...e.model_provider?{model_provider:e.model_provider}:{}}),c6.toast.success(`Model set to ${e.model}${e.model_provider?` (${e.model_provider})`:""}.`),B(!1)}catch(e){c6.toast.error(e instanceof Error?`Couldn't update model: ${e.message}`:"Couldn't update model — try again.")}},className:nf("flex w-full items-center justify-between rounded px-3 py-2 text-left text-sm transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",t&&"bg-accent"),children:[(0,eI.jsxs)("span",{className:"font-mono",children:[e.model,r&&(0,eI.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"· default"})]}),e.model_provider&&(0,eI.jsx)("span",{className:"text-xs text-muted-foreground",children:e.model_provider})]})},`${e.model}|${e.model_provider??""}`)})]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:async()=>{try{await ey(null),c6.toast.success("Model override cleared."),B(!1)}catch(e){c6.toast.error(e instanceof Error?`Couldn't clear override: ${e.message}`:"Couldn't clear override — try again.")}},disabled:!eb,children:"Reset to default"}),(0,eI.jsx)(nP,{onClick:()=>B(!1),children:"Close"})]})]})}),(0,eI.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden overscroll-contain",ref:Q,children:(0,eI.jsx)("div",{className:"mx-auto w-full max-w-[960px] px-4 pb-4 pt-3 sm:px-5",ref:J,children:ec?(0,eI.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,eI.jsx)("p",{className:"text-muted-foreground",children:"Loading…"})}):(0,eI.jsxs)(eI.Fragment,{children:[0===e1.length&&!el&&(0,eI.jsxs)("div",{className:"flex min-h-[42vh] flex-col items-center justify-center px-3 pt-12 text-center sm:pt-16",children:[(0,eI.jsx)("h2",{className:"text-pretty text-lg font-semibold sm:text-xl",children:"Where research evolves"}),(0,eI.jsx)("p",{className:"mt-2 max-w-lg text-sm text-muted-foreground",children:"Your self-evolving lab partner — reads the literature, runs experiments, and remembers what matters."}),(0,eI.jsx)("div",{className:"mt-4 flex max-w-2xl flex-wrap justify-center gap-2",children:Cp.map(e=>(0,eI.jsx)("button",{type:"button",onClick:()=>eZ(e),className:"max-w-full rounded-full border border-border bg-card px-2.5 py-1.5 text-xs text-foreground shadow-sm transition-colors hover:border-[var(--color-border)] hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring sm:text-sm",children:e},e))}),n&&a&&(0,eI.jsx)(IO,{onNavigate:n,onOpenThread:a})]}),e3.map((t,r)=>{if("action-group"===t.kind){let n=t.items[t.items.length-1].message.id,a=r===e3.length-1,i=el&&a&&n===e5;return(0,eI.jsx)(Id,{items:t.items,isStreaming:i,defaultCollapsed:e2,isAtBottom:et,lastMessageId:e5,isLoading:el,actionRequests:e0,submittedActionRequestKeys:te,onActionRequestSubmitted:tr,reviewConfigsMap:tn,stream:er,onResumeInterrupt:em,graphId:e?.graph_id,onEditMessage:eK,autoApprove:P,subAgentSteps:ek,ui:es,compactionAnchorId:e6,summarizationEvent:eg??null},`action-group-${t.items[0].message.id}`)}let n=t.data,a=es?.filter(e=>e.metadata?.message_id===n.message.id),i=r===e3.length-1,s="human"!==n.message.type,o=e6===n.message.id;return(0,eI.jsxs)(eC.default.Fragment,{children:[o&&eg&&(0,eI.jsx)(Iu,{content:eg.content,summarizedCount:eg.cutoffIndex}),(0,eI.jsx)(Il,{message:n.message,toolCalls:n.toolCalls,isLoading:el,isStreaming:el&&i&&s,actionRequests:i?e0:void 0,submittedActionRequestKeys:te,onActionRequestSubmitted:tr,reviewConfigsMap:i?tn:void 0,ui:a,stream:er,onResumeInterrupt:em,graphId:e?.graph_id,onEditMessage:eK,autoApprove:P,subAgentSteps:ek})]},n.message.id)}),eg&&!e6&&(0,eI.jsx)(Iu,{content:eg.content,summarizedCount:eg.cutoffIndex}),eX&&(0,eI.jsx)("div",{className:"mt-4",children:(0,eI.jsx)(IP,{questions:eX,onSubmit:eQ,onCancel:eJ,isLoading:el})})]})})}),(0,eI.jsxs)("div",{className:"flex-shrink-0 bg-background",children:[w.length>0&&(0,eI.jsx)("div",{"aria-label":"Queued messages",className:"relative mx-auto -mb-4 w-[calc(100%-16px)] max-w-[960px] px-2 sm:w-[calc(100%-24px)]",children:(0,eI.jsx)("div",{className:"rounded-b-lg rounded-t-2xl border border-border bg-background pb-5 pt-1 shadow-sm",children:w.map((e,t)=>{let r=b.trim().length>0||E.length>0;return(0,eI.jsxs)("div",{onDragOver:e=>e.preventDefault(),onDrop:()=>eq(e.id),className:"relative flex min-h-11 items-start gap-1.5 px-2 py-2 text-sm sm:gap-2 sm:px-3",children:[(0,eI.jsx)("button",{type:"button",draggable:!0,onDragStart:t=>{I.current=e.id,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e.id))},onDragEnd:()=>{I.current=null},onKeyDown:r=>{"ArrowUp"===r.key&&t>0&&(r.preventDefault(),eH(e.id,-1)),"ArrowDown"===r.key&&t<w.length-1&&(r.preventDefault(),eH(e.id,1))},"aria-label":`Reorder queued message ${t+1} of ${w.length}`,title:"Drag to reorder, or use the arrow keys",className:"mt-0.5 inline-flex size-5 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground/60 focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",children:(0,eI.jsx)(ah,{className:"size-3.5","aria-hidden":"true"})}),(0,eI.jsx)(_M,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,eI.jsx)("span",{className:"line-clamp-2 whitespace-pre-wrap break-words pt-0.5 text-foreground",children:e.text}),e.files.length>0&&(0,eI.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[(0,eI.jsx)(_P,{className:"size-3 shrink-0","aria-hidden":"true"}),e.files.length," file",1===e.files.length?"":"s"]})]}),(0,eI.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>ez(e.id),"aria-label":"Steer with this message next",title:"Submit next without interrupting the current turn",className:"inline-flex h-7 items-center gap-1 rounded-full px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_M,{className:"size-3.5","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"Steer"})]}),(0,eI.jsx)("button",{type:"button",onClick:()=>eV(e.id),"aria-label":"Remove queued message",title:"Remove from queue",className:"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(iM,{className:"size-3.5","aria-hidden":"true"})}),(0,eI.jsxs)("details",{className:"group/menu relative",onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||e.currentTarget.removeAttribute("open")},onKeyDown:e=>{"Escape"===e.key&&(e.currentTarget.removeAttribute("open"),e.currentTarget.querySelector("summary")?.focus())},children:[(0,eI.jsx)("summary",{"aria-label":"More queued message actions",title:"More actions",className:"inline-flex size-7 cursor-pointer list-none items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",children:(0,eI.jsx)(_j,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"absolute right-0 top-8 z-30 min-w-40 rounded-xl border border-border bg-background p-1.5 shadow-lg",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>eB(e.id),disabled:r,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40",children:[(0,eI.jsx)(iR,{className:"size-4","aria-hidden":"true"}),"Edit message"]}),(0,eI.jsxs)("button",{type:"button",onClick:eW,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_F,{className:"size-4","aria-hidden":"true"}),"Close queue"]})]})]})]})]},e.id)})})}),(0,eI.jsxs)("div",{className:nf("relative z-10 mx-auto mb-2 flex w-[calc(100%-16px)] max-w-[960px] flex-shrink-0 flex-col overflow-hidden rounded-xl border border-border bg-background transition-colors duration-200 ease-in-out sm:mb-4 sm:w-[calc(100%-24px)]","focus-within:ring-2 focus-within:ring-ring"),children:[(0,eI.jsxs)("div",{className:"flex max-h-60 flex-col overflow-y-auto border-b border-border bg-sidebar empty:hidden sm:max-h-72",children:[!p&&(0,eI.jsx)(eI.Fragment,{children:(s=ea.find(e=>"in_progress"===e.status),l=(o=ea.length)-e9.pending.length,c=o===l,u=e8?(0,eI.jsx)("button",{type:"button",onClick:()=>m(e=>"tasks"===e?null:"tasks"),className:"grid w-full cursor-pointer grid-cols-[auto_auto_1fr] items-center gap-2.5 px-3 py-2.5 text-left sm:px-4","aria-expanded":"tasks"===p,children:c?[(0,eI.jsx)(_N,{size:16,className:"text-[var(--color-success)]"},"icon"),(0,eI.jsx)("span",{className:"ml-[1px] min-w-0 truncate text-sm",children:"All tasks completed"},"label")]:null!=s?[(0,eI.jsx)("div",{children:Ch(s.status)},"icon"),(0,eI.jsxs)("span",{className:"ml-[1px] min-w-0 truncate text-sm",children:["Task"," ",o-e9.pending.length," ","of ",o]},"label"),(0,eI.jsx)("span",{className:"min-w-0 gap-2 truncate text-sm text-muted-foreground",children:s.content},"content")]:[(0,eI.jsx)(_I,{size:16,className:"text-[var(--color-text-tertiary)]"},"icon"),(0,eI.jsxs)("span",{className:"ml-[1px] min-w-0 truncate text-sm",children:["Task"," ",o-e9.pending.length," of"," ",o]},"label")]}):null,d=e7?(0,eI.jsxs)("button",{type:"button",onClick:()=>m(e=>"files"===e?null:"files"),className:"flex flex-shrink-0 cursor-pointer items-center gap-2 px-3 py-2.5 text-left text-sm sm:px-4","aria-expanded":"files"===p,children:[(0,eI.jsx)(_C,{size:16}),"Files (State)",(0,eI.jsx)("span",{className:"h-4 min-w-4 rounded-full bg-[var(--brand-solid)] px-0.5 text-center text-[10px] leading-[16px] text-[var(--brand-foreground)]",children:Object.keys(ei).length})]}):null,e8||e7?(0,eI.jsxs)("div",{className:"flex items-center",children:[(0,eI.jsx)("div",{className:"min-w-0 flex-1",children:u}),d]}):null)}),p&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)("div",{className:"sticky top-0 flex items-stretch bg-sidebar text-sm",children:[e8&&(0,eI.jsx)("button",{type:"button",className:"py-2.5 pr-4 first:pl-3 aria-expanded:font-semibold sm:first:pl-4",onClick:()=>m(e=>"tasks"===e?null:"tasks"),"aria-expanded":"tasks"===p,children:"Tasks"}),e7&&(0,eI.jsxs)("button",{type:"button",className:"inline-flex items-center gap-2 py-2.5 pr-4 first:pl-3 aria-expanded:font-semibold sm:first:pl-4",onClick:()=>m(e=>"files"===e?null:"files"),"aria-expanded":"files"===p,children:["Files (State)",(0,eI.jsx)("span",{className:"h-4 min-w-4 rounded-full bg-[var(--brand-solid)] px-0.5 text-center text-[10px] leading-[16px] text-[var(--brand-foreground)]",children:Object.keys(ei).length})]}),(0,eI.jsx)("button",{"aria-label":"Close",className:"flex-1",onClick:()=>m(null)})]}),(0,eI.jsxs)("div",{ref:h,className:"px-3 sm:px-4",children:["tasks"===p&&Object.entries(e9).filter(([e,t])=>t.length>0).map(([e,t])=>(0,eI.jsxs)("div",{className:"mb-4",children:[(0,eI.jsx)("h3",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-tertiary",children:{pending:"Pending",in_progress:"In Progress",completed:"Completed"}[e]}),(0,eI.jsx)("div",{className:"grid grid-cols-[auto_1fr] gap-3 rounded-sm p-1 pl-0 text-sm",children:t.map((t,r)=>(0,eI.jsxs)(eC.Fragment,{children:[Ch(t.status,"mt-0.5"),(0,eI.jsx)("span",{className:"break-words text-inherit",children:t.content})]},`${e}_${t.id}_${r}`))})]},e)),"files"===p&&(0,eI.jsx)("div",{className:"mb-6",children:(0,eI.jsx)(Cr,{files:ei,setFiles:eo,editDisabled:!0===el||void 0!==eu})})]})]})]}),P&&(0,eI.jsxs)("div",{"aria-live":"polite",className:"flex items-center justify-between gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100",children:[(0,eI.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,eI.jsx)(_D,{className:"size-3.5 shrink-0","aria-hidden":"true"}),"Tool actions will run without review."]}),(0,eI.jsx)("button",{type:"button",onClick:eP,className:"shrink-0 rounded px-2 py-1 font-semibold transition-colors hover:bg-amber-200 focus-visible:ring-2 focus-visible:ring-amber-700 dark:hover:bg-amber-900",children:"Turn Off"})]}),(ew||e_>0)&&(0,eI.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-border px-3 py-1.5 text-xs text-muted-foreground",children:[ew&&(0,eI.jsxs)("button",{type:"button",onClick:()=>B(!0),title:"Click to change model for this chat","aria-label":"Change model for this chat",className:"-mx-1 flex items-center gap-1.5 rounded px-1 py-0.5 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_L,{className:"size-3.5 shrink-0 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"font-medium text-foreground",children:ew.name}),ew.provider&&(0,eI.jsxs)("span",{children:["· ",ew.provider]})]}),e_>0&&(0,eI.jsxs)("button",{type:"button",onClick:t,title:`${e_} background agent${1===e_?"":"s"} running — click to view`,"aria-label":`${e_} background agent${1===e_?"":"s"} running — view`,className:"ml-auto flex shrink-0 items-center gap-1.5 rounded px-1.5 py-0.5 font-medium text-[var(--brand)] transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)("span",{className:"size-2 animate-pulse rounded-full bg-[var(--color-warning)]","aria-hidden":"true"}),e_," agent",1===e_?"":"s"]})]}),(0,eI.jsxs)("form",{onSubmit:eU,className:"flex flex-col",children:[E.length>0&&(0,eI.jsx)("div",{"aria-label":"Attached files",className:"flex flex-wrap gap-2 border-b border-border px-3 py-2",children:E.map(e=>(0,eI.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1 text-xs text-foreground",children:[(0,eI.jsx)(_C,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"max-w-48 truncate",title:e.path,children:e.name}),(0,eI.jsx)("button",{type:"button",onClick:()=>ej(e.path),"aria-label":`Remove ${e.name} from this message`,title:`Remove ${e.name} from this message`,className:"rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(rF,{className:"size-3.5","aria-hidden":"true"})})]},e.path))}),(0,eI.jsx)("textarea",{ref:f,value:b,onChange:e=>y(e.target.value),onKeyDown:eY,"aria-label":"Message",disabled:eR,placeholder:eR?"Respond to the request above to continue…":el?"Queue a follow-up — sends when this turn finishes…":"Ask EvoScientist anything…",className:"font-inherit field-sizing-content flex-1 resize-none border-0 bg-transparent px-3.5 pb-2.5 pt-3 text-sm leading-6 text-primary outline-none placeholder:text-tertiary disabled:cursor-not-allowed sm:px-4",rows:1}),(0,eI.jsxs)("div",{className:"flex items-center justify-between gap-2 p-2 sm:p-2.5",children:[(0,eI.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eI.jsx)("input",{ref:g,type:"file",multiple:!0,onChange:eM,disabled:!e||eR||v,className:"hidden"}),(0,eI.jsx)("button",{type:"button",onClick:()=>g.current?.click(),disabled:!e||eR||v,"aria-label":"Upload files to workspace",title:"Upload files to workspace (max 50 MB each)",className:"inline-flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:(0,eI.jsx)(_P,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("button",{type:"button",onClick:()=>P?eP():F(!0),"aria-pressed":P,title:"Auto-approve all tool actions in this conversation",className:nf("inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors",P?"bg-amber-600 text-white hover:bg-amber-700":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[(0,eI.jsx)(_O,{className:"size-3.5","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden min-[360px]:inline",children:P?"Auto-approve On":"Auto-approve"})]}),n&&T&&(0,eI.jsxs)("button",{type:"button",onClick:()=>n({view:"workspace"}),title:`${i?"Close":"Open"} workspace: ${T}`,"aria-label":`${i?"Close":"Open"} workspace: ${T}`,"aria-pressed":!!i,className:"inline-flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_R,{className:"size-3.5 flex-shrink-0","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden max-w-[140px] truncate font-mono sm:inline lg:max-w-[220px]",children:T.split("/").filter(Boolean).pop()||T})]})]}),(0,eI.jsx)("div",{className:"flex justify-end gap-2",children:(0,eI.jsx)(nP,{type:el?"button":"submit",variant:el?"destructive":"default",onClick:el?ep:eU,disabled:!el&&(eO||v||!b.trim()),"aria-label":el?"Stop generating":"Send message",children:el?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(_k,{size:14}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"Stop"})]}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(_A,{size:18}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"Send"})]})})})]})]})]})]})]})});Cf.displayName="ChatInterface";let Cg=rj("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),Cb=rj("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]),Cy=rj("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),CE=eC.default.memo(({skill:e,onClose:t})=>{let[r,n]=(0,eC.useState)(null),[a,i]=(0,eC.useState)(!1),[s,o]=(0,eC.useState)(null);if((0,eC.useEffect)(()=>{if(!e)return;let t=!1;return n(null),o(null),i(!0),fetch(`/api/skills/detail?name=${encodeURIComponent(e.name)}`).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`Failed to load (${e.status})`);return t}).then(e=>{t||n(e)}).catch(e=>{t||o(e.message??"Failed to load skill detail.")}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),!e)return null;let l=r?.title??e.title,c=r?.version??e.version,u=r?.description??e.description,d=r?.installed??e.installed,p=r?.body;return(0,eI.jsx)(ng,{open:!0,onOpenChange:t,children:(0,eI.jsxs)(nE,{"aria-describedby":void 0,className:"flex h-[80vh] max-h-[80vh] min-w-[60vw] flex-col p-6",children:[(0,eI.jsx)(nx,{className:"sr-only",children:l}),(0,eI.jsxs)("div",{className:"mb-3 flex items-start gap-3 border-b border-border pb-4",children:[(0,eI.jsx)(iD,{className:"mt-1 size-6 shrink-0 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsx)("div",{className:"min-w-0 flex-1",children:(0,eI.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[(0,eI.jsx)("h2",{className:"break-words text-lg font-semibold",children:l}),c&&(0,eI.jsxs)("span",{className:"font-mono text-xs text-muted-foreground",children:["v",c]}),null!=e.fileCount&&(0,eI.jsxs)("span",{className:"text-xs text-muted-foreground",children:["· ",e.fileCount," file",1===e.fileCount?"":"s"]}),d&&(0,eI.jsxs)("span",{className:"bg-[var(--brand)]/10 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium text-[var(--brand)]",children:[(0,eI.jsx)(Cy,{className:"size-3","aria-hidden":"true"}),"Installed"]})]})})]}),(0,eI.jsx)(sc,{className:"min-h-0 flex-1",children:(0,eI.jsxs)("div",{className:"pr-3",children:[(0,eI.jsx)("p",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground",children:u||"No description."}),(0,eI.jsx)("div",{className:"mt-4 border-t border-border pt-4",children:a?(0,eI.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading skill contents…"]}):s?(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:s}):p?(0,eI.jsx)(N4,{content:p}):(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"No additional contents."})})]})})]})})});function C_(){let[e,t]=(0,eC.useState)([]),[r,n]=(0,eC.useState)([]),[a,i]=(0,eC.useState)(!0),[s,o]=(0,eC.useState)(null),[l,c]=(0,eC.useState)(null),[u,d]=(0,eC.useState)({}),[p,m]=(0,eC.useState)(null),[h,f]=(0,eC.useState)(null),g=(0,eC.useCallback)(async(e=!1)=>{i(!0),c(null),o(null);let[r,a]=await Promise.allSettled([fetch(`/api/skills/catalog${e?"?refresh=1":""}`).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Failed to load catalog");return t.skills??[]}),fetch("/api/skills").then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Failed to load skills");return t.skills??[]})]),s="fulfilled"===r.status?r.value:[];if("rejected"===r.status&&o(r.reason instanceof Error?r.reason.message:"Failed to load the official catalog."),t(s),"fulfilled"===a.status){let e=new Set(s.map(e=>e.name));n(a.value.filter(t=>!e.has(t.name)))}else n([]),c(a.reason instanceof Error?a.reason.message:"Failed to load installed skills.");i(!1)},[]);(0,eC.useEffect)(()=>{g()},[g]);let b=async(e,r="install")=>{d(t=>({...t,[e]:r})),c(null);try{let r=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})}),n=await r.json();if(!r.ok)throw Error(n.error||"Failed to install");t(t=>t.map(t=>t.name===e?{...t,installed:!0,updateAvailable:!1,installedVersion:t.latestVersion??t.installedVersion}:t))}catch(e){c(e instanceof Error?e.message:`Failed to ${r}`)}finally{d(t=>{let r={...t};return delete r[e],r})}},y=async(e,r)=>{d(t=>({...t,[e]:"uninstall"})),c(null);try{let a=await fetch(`/api/skills?name=${encodeURIComponent(e)}`,{method:"DELETE"});if(!a.ok){let e=await a.json();throw Error(e.error||"Failed to uninstall")}r?t(t=>t.map(t=>t.name===e?{...t,installed:!1}:t)):n(t=>t.filter(t=>t.name!==e))}catch(e){c(e instanceof Error?e.message:"Failed to uninstall")}finally{d(t=>{let r={...t};return delete r[e],r})}},E=async()=>{h&&(f(null),await y(h.name,h.isCatalog))};return(0,eI.jsxs)("div",{className:"h-full overflow-y-auto",children:[(0,eI.jsxs)("div",{className:"mx-auto max-w-[960px] px-4 py-5 sm:px-5 sm:py-6",children:[(0,eI.jsxs)("header",{className:"mb-4 flex items-start justify-between gap-3",children:[(0,eI.jsxs)("div",{children:[(0,eI.jsx)("h2",{className:"text-xl font-semibold sm:text-2xl",children:"Research Skills"}),(0,eI.jsxs)("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:["Install official skills from the"," ",(0,eI.jsx)("a",{href:"https://github.com/EvoScientist/EvoSkills",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"EvoSkills"})," ","catalog, or remove ones you don't need."]})]}),(0,eI.jsx)("button",{type:"button",onClick:()=>g(!0),disabled:a,"aria-label":"Refresh",className:"rounded-md p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(Cg,{className:a?"size-4 animate-spin":"size-4","aria-hidden":"true"})})]}),l&&(0,eI.jsx)("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:l}),a?(0,eI.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground","aria-live":"polite",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading skills…"]}):(0,eI.jsxs)("div",{className:"space-y-6",children:[(0,eI.jsxs)("section",{children:[(0,eI.jsx)("h3",{className:"mb-2.5 text-xs font-semibold uppercase tracking-wider text-tertiary",children:"Official catalog"}),s?(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:s}):0===e.length?(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"No skills found in the catalog."}):(0,eI.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",children:e.map(e=>(0,eI.jsx)(Cv,{title:e.title,description:e.description,meta:`${e.fileCount} file${1===e.fileCount?"":"s"}`,installed:e.installed,installedVersion:e.installedVersion,latestVersion:e.latestVersion,updateAvailable:e.updateAvailable,busy:u[e.name],onOpen:()=>m({name:e.name,title:e.title,description:e.description,version:e.installed?e.installedVersion:e.latestVersion,fileCount:e.fileCount,installed:e.installed}),onInstall:()=>b(e.name),onUpdate:()=>b(e.name,"update"),onUninstall:()=>f({name:e.name,title:e.title,isCatalog:!0})},e.name))})]}),r.length>0&&(0,eI.jsxs)("section",{children:[(0,eI.jsx)("h3",{className:"mb-2.5 text-xs font-semibold uppercase tracking-wider text-tertiary",children:"Other installed skills"}),(0,eI.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",children:r.map(e=>(0,eI.jsx)(Cv,{title:e.title,description:e.description,installed:!0,busy:u[e.name],onOpen:()=>m({name:e.name,title:e.title,description:e.description,installed:!0}),onUninstall:()=>f({name:e.name,title:e.title,isCatalog:!1})},e.name))})]})]})]}),(0,eI.jsx)(CE,{skill:p,onClose:()=>m(null)}),(0,eI.jsx)(ng,{open:null!==h,onOpenChange:e=>{e||f(null)},children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Uninstall skill?"}),(0,eI.jsxs)(nT,{children:["“",h?.title??h?.name,"” will be removed from this Web UI. You can install it again later."]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),(0,eI.jsx)(nP,{onClick:E,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Uninstall"})]})]})})]})}function Cv({title:e,description:t,meta:r,installed:n,installedVersion:a,latestVersion:i,updateAvailable:s,busy:o,onOpen:l,onInstall:c,onUpdate:u,onUninstall:d}){let p=n?a&&`v${a}`:i&&`v${i}`;return(0,eI.jsxs)("div",{className:"flex flex-col rounded-lg border border-border bg-card p-3",children:[(0,eI.jsxs)("button",{type:"button",onClick:l,className:"-m-1 flex items-start gap-2.5 rounded-md p-1 text-left transition-colors hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring",title:"View details",children:[(0,eI.jsx)(iD,{className:"mt-0.5 size-5 shrink-0 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[(0,eI.jsx)("h3",{className:"break-words text-lg font-medium leading-tight",children:e}),p&&(0,eI.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:p}),r&&(0,eI.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:["· ",r]})]}),(0,eI.jsx)("p",{className:"mt-1 line-clamp-2 text-sm leading-6 text-muted-foreground",children:t||"No description."})]})]}),(0,eI.jsxs)("div",{className:"mt-2.5 flex items-center justify-end gap-2",children:[n&&s&&(0,eI.jsxs)("button",{type:"button",onClick:u,disabled:!!o,className:"inline-flex items-center gap-1.5 rounded-md bg-[var(--brand-solid)] px-2.5 py-1 text-xs font-medium text-[var(--brand-foreground)] transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",title:i?`Update to v${i}`:"Update",children:["update"===o?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(Cb,{className:"size-3.5","aria-hidden":"true"}),"update"===o?"Updating…":i?`Update → v${i}`:"Update"]}),n?(0,eI.jsxs)("button",{type:"button",onClick:d,disabled:!!o,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:["uninstall"===o?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(iM,{className:"size-3.5","aria-hidden":"true"}),"uninstall"===o?"Removing…":"Uninstall"]}):(0,eI.jsxs)("button",{type:"button",onClick:c,disabled:!!o,className:"inline-flex items-center gap-1.5 rounded-md bg-[var(--brand-solid)] px-2.5 py-1 text-xs font-medium text-[var(--brand-foreground)] transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:["install"===o?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(iN,{className:"size-3.5","aria-hidden":"true"}),"install"===o?"Installing…":"Install"]})]})]})}CE.displayName="SkillDetailDialog";let Cx=rj("fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]),CT=rj("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),CS=rj("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),Cw="rounded border border-border bg-background p-1.5 text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",Ck=["complements","contradicts","supersedes"];function CA({node:e,edges:t,nodeMap:r,onClose:n,onNavigate:a}){let[i,s]=(0,eC.useState)(null),[o,l]=(0,eC.useState)(!0),[c,u]=(0,eC.useState)(null);(0,eC.useEffect)(()=>{let t=new AbortController;return l(!0),s(null),u(null),fetch(`/api/memory?path=${encodeURIComponent(e.path)}`,{cache:"no-store",signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Failed to load observation.");s(t.content??null)}).catch(e=>{t.signal.aborted||(s(null),u(e instanceof Error?e.message:"Failed to load observation."))}).finally(()=>{t.signal.aborted||l(!1)}),()=>t.abort()},[e.path]);let d=t.filter(t=>t.source===e.id||t.target===e.id),p=i?i.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"").trim():"";return(0,eI.jsxs)("div",{className:"flex h-full flex-col overflow-hidden border-l border-border bg-background shadow-xl md:shadow-none",children:[(0,eI.jsxs)("div",{className:"flex items-start justify-between gap-2 border-b border-border px-4 py-3",children:[(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsxs)("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.memory_type," · ",e.scope]}),(0,eI.jsx)("h3",{className:"mt-0.5 line-clamp-3 text-sm font-semibold leading-snug text-foreground",children:e.summary}),e.created_at&&(0,eI.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:(e=>{try{let t=new Date(e);if(Number.isNaN(t.getTime()))return e;return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return e}})(e.created_at)})]}),(0,eI.jsx)("button",{type:"button",onClick:n,className:"mt-0.5 inline-flex size-8 flex-shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close observation details",title:"Close observation details",children:(0,eI.jsx)(rF,{className:"h-4 w-4","aria-hidden":"true"})})]}),(0,eI.jsxs)("div",{className:"flex-1 overflow-y-auto","aria-live":o?"polite":"off",children:[d.length>0&&(0,eI.jsxs)("div",{className:"border-b border-border px-4 py-3",children:[(0,eI.jsx)("p",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Relations"}),(0,eI.jsx)("ul",{className:"space-y-1.5",children:d.map((t,n)=>{let i=t.source===e.id?t.target:t.source,s=r.get(i);return(0,eI.jsxs)("li",{className:"flex items-start gap-2",children:[(0,eI.jsx)("span",{className:"mt-0.5 flex-shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold text-white",style:{background:Ib(t.relation)},children:I_(t.relation)}),s?(0,eI.jsx)("button",{type:"button",onClick:()=>a(i),className:"min-w-0 rounded-sm text-left text-xs text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:s.summary}):(0,eI.jsx)("span",{className:"text-xs text-muted-foreground",children:i})]},n)})})]}),(0,eI.jsx)("div",{className:"px-4 py-3",children:o?(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"Loading…"}):c?(0,eI.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:c}):p?(0,eI.jsx)(N4,{content:p,className:"text-xs leading-relaxed [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-sm [&_p]:mb-3"}):(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"This observation has no body content."})})]})]})}function CN({data:e,selectedId:t,onSelect:r,w:n,h:a}){let i=function(e,t,r,n){let[a,i]=(0,eC.useState)([]),s=(0,eC.useRef)([]),o=(0,eC.useRef)(null),l=(0,eC.useRef)(0),c=(0,eC.useRef)(r),u=(0,eC.useRef)(n);return(0,eC.useEffect)(()=>{c.current=r,u.current=n},[r,n]),(0,eC.useEffect)(()=>{var r,n;let a,d;if(0===e.length||0===c.current||0===u.current){i([]),s.current=[];return}let p=(r=c.current,n=u.current,d=Math.min(r,n)*Math.max(.28,.12*Math.sqrt(a=Math.max(e.length,1))),e.map((e,t)=>{let i=t/a*2*Math.PI;return{id:e.id,x:r/2+d*Math.cos(i)+Ig(e.id,0),y:n/2+d*Math.sin(i)+Ig(e.id,1),vx:0,vy:0}}));s.current=p,i(p),l.current=0,o.current&&cancelAnimationFrame(o.current);let m=0,h=()=>{let{positions:e,energy:r}=function(e,t,r,n){let a=r/2,i=n/2,s=new Float64Array(e.length),o=new Float64Array(e.length),l=new Map(e.map((e,t)=>[e.id,t]));for(let t=0;t<e.length;t++)for(let r=t+1;r<e.length;r++){let n=e[t].x-e[r].x,a=e[t].y-e[r].y,i=Math.max(Math.sqrt(n*n+a*a),1),l=6e3/(i*i),c=n/i,u=a/i;s[t]+=l*c,o[t]+=l*u,s[r]-=l*c,o[r]-=l*u}for(let r of t){let t=l.get(r.source),n=l.get(r.target);if(null==t||null==n)continue;let a=e[n].x-e[t].x,i=e[n].y-e[t].y,c=Math.max(Math.sqrt(a*a+i*i),1),u=.04*(c-180),d=a/c,p=i/c;s[t]+=u*d,o[t]+=u*p,s[n]-=u*d,o[n]-=u*p}for(let t=0;t<e.length;t++)s[t]+=.02*(a-e[t].x),o[t]+=.02*(i-e[t].y);let c=0;return{positions:e.map((e,t)=>{let r=(e.vx+s[t])*.78,n=(e.vy+o[t])*.78,a=Math.sqrt(r*r+n*n);return a>12&&(r=r/a*12,n=n/a*12),c+=r*r+n*n,{id:e.id,x:e.x+r,y:e.y+n,vx:r,vy:n}}),energy:c}}(s.current,t,c.current,u.current);s.current=e,l.current++,++m%2==0&&i([...e]),l.current<600&&r>.3?o.current=requestAnimationFrame(h):i([...s.current])};return o.current=requestAnimationFrame(h),()=>{o.current&&cancelAnimationFrame(o.current)}},[e,t]),a}(e.nodes,e.edges,n,a),[s,o]=(0,eC.useState)(0),[l,c]=(0,eC.useState)(0),[u,d]=(0,eC.useState)(1),p=(0,eC.useRef)(null),m=(0,eC.useRef)(null),[h,f]=(0,eC.useState)(new Set(Ck)),[g,b]=(0,eC.useState)(new Set(["semantic","procedural"])),y=(0,eC.useMemo)(()=>new Map(i.map(e=>[e.id,e])),[i]),E=(0,eC.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e.nodes]),_=(0,eC.useRef)({tx:s,ty:l,scale:u});_.current={tx:s,ty:l,scale:u};let v=(0,eC.useCallback)((e,t,r)=>{let{tx:n,ty:a,scale:i}=_.current,s=Math.max(.2,Math.min(5,i*r)),l=s/i;d(s),o(e-l*(e-n)),c(t-l*(t-a))},[]),x=(0,eC.useCallback)(e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();v(e.clientX-t.left,e.clientY-t.top,e.deltaY<0?1.1:.9)},[v]),T=(0,eC.useCallback)(e=>{(e.target===e.currentTarget||"svg"===e.target.tagName)&&(m.current={startX:e.clientX,startY:e.clientY,tx:s,ty:l},e.currentTarget.setPointerCapture(e.pointerId))},[s,l]),S=(0,eC.useCallback)(e=>{m.current&&(o(m.current.tx+e.clientX-m.current.startX),c(m.current.ty+e.clientY-m.current.startY))},[]),w=(0,eC.useCallback)(()=>{m.current=null},[]);if(0===n||0===a)return null;let k=new Set(e.nodes.filter(e=>g.has("procedural"===e.memory_type?"procedural":"semantic")).map(e=>e.id)),A=e.edges.filter(e=>k.has(e.source)&&k.has(e.target)&&(h.has(e.relation)||!Ck.includes(e.relation)));return(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)("div",{className:"absolute left-3 top-3 z-10 flex gap-1",children:[(0,eI.jsx)("button",{type:"button",onClick:()=>v(n/2,a/2,1.25),className:Cw,"aria-label":"Zoom in observation graph",title:"Zoom in",children:(0,eI.jsx)(NU,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,eI.jsx)("button",{type:"button",onClick:()=>v(n/2,a/2,.8),className:Cw,"aria-label":"Zoom out observation graph",title:"Zoom out",children:(0,eI.jsx)(NB,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,eI.jsx)("button",{type:"button",onClick:()=>{o(0),c(0),d(1)},className:Cw,"aria-label":"Reset observation graph view",title:"Reset view",children:(0,eI.jsx)(CS,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),(0,eI.jsxs)("div",{className:"absolute right-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] select-none flex-col gap-1 rounded border border-border bg-background/90 px-2.5 py-2 text-[11px] shadow-sm backdrop-blur-sm",children:[["complements","contradicts","supersedes"].map(e=>{let t=h.has(e);return(0,eI.jsxs)("button",{type:"button",onClick:()=>{f(t=>{let r=new Set(t);if(r.has(e)){if(1===r.size)return t;r.delete(e)}else r.add(e);return r})},"aria-pressed":t,title:`${t?"Hide":"Show"} ${e} edges`,className:`flex items-center gap-1.5 text-left transition-opacity ${t?"opacity-100":"opacity-35"}`,children:[(0,eI.jsx)("span",{className:"inline-block h-2 w-6 flex-shrink-0 rounded-sm",style:{background:Ib(e)}}),(0,eI.jsx)("span",{className:"capitalize text-muted-foreground",children:I_(e)})]},e)}),(0,eI.jsx)("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border pt-1",children:[["semantic","Semantic"],["procedural","Procedural"]].map(([e,t])=>{let r=g.has(e);return(0,eI.jsxs)("button",{type:"button",onClick:()=>{b(t=>{let r=new Set(t);if(r.has(e)){if(1===r.size)return t;r.delete(e)}else r.add(e);return r})},"aria-pressed":r,title:`${r?"Hide":"Show"} ${t.toLowerCase()} nodes`,className:`flex items-center gap-1.5 text-left transition-opacity ${r?"opacity-100":"opacity-35"}`,children:[(0,eI.jsx)("span",{className:"inline-block h-3 w-3 flex-shrink-0 rounded-full",style:{background:IE(e)}}),(0,eI.jsx)("span",{className:"text-muted-foreground",children:t})]},e)})})]}),(0,eI.jsxs)("svg",{ref:p,width:n,height:a,className:"absolute inset-0 cursor-grab active:cursor-grabbing",style:{userSelect:"none"},role:"img","aria-label":"Observation relationship graph",onWheel:x,onPointerDown:T,onPointerMove:S,onPointerUp:w,onClick:e=>{(e.target===e.currentTarget||"svg"===e.target.tagName)&&r(null)},children:[(0,eI.jsx)("defs",{children:["complements","contradicts","supersedes","default"].map(e=>(0,eI.jsx)("marker",{id:`arrow-${e}`,viewBox:"0 0 10 10",markerWidth:"7",markerHeight:"7",refX:"10",refY:"5",orient:"auto",markerUnits:"userSpaceOnUse",children:(0,eI.jsx)("path",{d:"M0,1.5 L10,5 L0,8.5 z",fill:Ib(e)})},e))}),(0,eI.jsxs)("g",{transform:`translate(${s},${l}) scale(${u})`,children:[A.map((e,t)=>{let r=y.get(e.source),n=y.get(e.target);if(!r||!n)return null;let a=E.get(e.source),i=E.get(e.target),s=a?Iy(a.degree):9,o=i?Iy(i.degree):9,l=n.x-r.x,c=n.y-r.y,u=Math.max(Math.sqrt(l*l+c*c),1),d=l/u,p=c/u,m=r.x+d*s,h=r.y+p*s,f=n.x-d*(o+2),g=n.y-p*(o+2),b=e.relation in{complements:1,contradicts:1,supersedes:1}?e.relation:"default",_=Ib(e.relation),v=`edge-grad-${t}`,x="complements"===e.relation,T=Math.min(45,7/Math.max(u-s-(o+2),1)*100);return(0,eI.jsxs)("g",{children:[(0,eI.jsx)("linearGradient",{id:v,gradientUnits:"userSpaceOnUse",x1:m,y1:h,x2:f,y2:g,children:x?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("stop",{offset:"0%",stopColor:_,stopOpacity:0}),(0,eI.jsx)("stop",{offset:`${T}%`,stopColor:_,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:`${100-T}%`,stopColor:_,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:"100%",stopColor:_,stopOpacity:0})]}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("stop",{offset:"0%",stopColor:_,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:`${100-T}%`,stopColor:_,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:"100%",stopColor:_,stopOpacity:0})]})}),(0,eI.jsx)("line",{x1:m,y1:h,x2:f,y2:g,stroke:`url(#${v})`,strokeWidth:1.5,strokeDasharray:"contradicts"===e.relation?"5,3":void 0,markerEnd:x?void 0:`url(#arrow-${b})`})]},t)}),e.nodes.map(e=>{let n=y.get(e.id);if(!n||!k.has(e.id))return null;let a=Iy(e.degree),i=e.id===t,s=e.summary.length>28?e.summary.slice(0,26)+"…":e.summary;return(0,eI.jsxs)("g",{role:"button",tabIndex:0,"aria-label":`Select observation: ${e.summary}`,className:"outline-none [&:focus-visible]:outline-none [&:focus]:outline-none",style:{cursor:"pointer"},onClick:n=>{n.stopPropagation(),r(e.id===t?null:e.id)},onKeyDown:n=>{("Enter"===n.key||" "===n.key)&&(n.preventDefault(),r(e.id===t?null:e.id))},children:[i&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("circle",{cx:n.x,cy:n.y,r:a+7,fill:"none",style:{stroke:"var(--brand)"},strokeWidth:2,opacity:.3}),(0,eI.jsx)("circle",{cx:n.x,cy:n.y,r:a+4,fill:"none",style:{stroke:"var(--brand)"},strokeWidth:2.5})]}),(0,eI.jsx)("circle",{cx:n.x,cy:n.y,r:a,fill:IE(e.memory_type),stroke:"#fff",strokeWidth:1.5,opacity:.9}),(0,eI.jsx)("text",{x:n.x,y:n.y+a+12,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"select-none fill-foreground/70",children:s}),(0,eI.jsx)("title",{children:e.summary})]},e.id)})]})]})]})}function CI({message:e}){return(0,eI.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:e})}function CC({data:e,loading:t,error:r,highlightNodeId:n}){let a=(0,eC.useRef)(null),[i,s]=(0,eC.useState)({w:0,h:0}),[o,l]=(0,eC.useState)(null),[c,u]=(0,eC.useState)(!1),[d,p]=(0,eC.useState)(360),m=(0,eC.useRef)(null);(0,eC.useEffect)(()=>{null!=n&&l(n)},[n]),(0,eC.useEffect)(()=>{let e=window.matchMedia("(min-width: 768px)"),t=()=>u(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let h=(0,eC.useCallback)(e=>{m.current={startX:e.clientX,startW:d},e.currentTarget.setPointerCapture(e.pointerId)},[d]),f=(0,eC.useCallback)(e=>{if(!m.current)return;let t=e.clientX-m.current.startX;p(Math.min(Math.max(640,.6*window.innerWidth),Math.max(280,m.current.startW-t)))},[]),g=(0,eC.useCallback)(()=>{m.current=null},[]);(0,eC.useEffect)(()=>{let e=a.current;if(!e)return;let t=new ResizeObserver(([e])=>{s({w:e.contentRect.width,h:e.contentRect.height})});return t.observe(e),()=>t.disconnect()},[]);let b=new Map((e?.nodes??[]).map(e=>[e.id,e])),y=o?b.get(o)??null:null,E=null!==y;return(0,eI.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col",children:[(0,eI.jsx)("div",{className:"flex items-center border-b border-border px-4 py-2",children:(0,eI.jsx)("span",{className:"text-xs text-muted-foreground",children:e?`${e.nodes.length} nodes \xb7 ${e.edges.length} edges`:t?"Loading…":""})}),(0,eI.jsxs)("div",{className:"relative flex min-h-0 flex-1",children:[(0,eI.jsxs)("div",{ref:a,className:"relative min-w-0 flex-1 overflow-hidden bg-muted/20",children:[t&&(0,eI.jsx)(CI,{message:"Loading observations…"}),!t&&r&&(0,eI.jsx)(CI,{message:`Error: ${r}`}),!t&&!r&&e&&0===e.nodes.length&&(0,eI.jsx)(CI,{message:"No observations yet."}),!t&&!r&&e&&e.nodes.length>0&&i.w>0&&(0,eI.jsx)(CN,{data:e,selectedId:o,onSelect:l,w:i.w,h:i.h})]}),E&&c&&(0,eI.jsx)("div",{role:"separator","aria-orientation":"vertical",onPointerDown:h,onPointerMove:f,onPointerUp:g,className:"hover:bg-[var(--brand)]/40 w-1 flex-shrink-0 cursor-col-resize bg-border transition-colors"}),E&&(0,eI.jsx)("div",{className:c?"flex-shrink-0 overflow-hidden":"absolute inset-0 z-20 overflow-hidden",style:c?{width:d}:void 0,children:(0,eI.jsx)(CA,{node:y,edges:e?.edges??[],nodeMap:b,onClose:()=>l(null),onNavigate:e=>l(e)})})]})]})}let CR=rj("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),CO=[{path:"profile/USER_PROFILE.md",label:"User",description:"Persistent context about the researcher",Icon:rj("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]])},{path:"profile/RESEARCH_TASTE.md",label:"Taste",description:"Aesthetic and methodological preferences",Icon:CR},{path:"profile/SOUL.md",label:"SOUL",description:"EvoScientist's core values and personality",Icon:_L}];function CL({entry:e,selected:t,onSelect:r}){let{Icon:n}=e;return(0,eI.jsxs)("button",{type:"button",onClick:()=>r(e),className:nf("group flex w-full min-w-0 items-center gap-2 rounded-md border px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t?"border-[var(--brand)]/40 bg-accent":"hover:border-[var(--brand)]/40 border-border bg-[var(--color-surface)] hover:bg-accent/60"),children:[(0,eI.jsx)("span",{className:nf("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",t?"bg-[var(--brand)] text-white":"bg-muted text-[var(--brand)] group-hover:bg-background"),children:(0,eI.jsx)(n,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("span",{className:"block truncate text-sm font-medium",children:e.label}),(0,eI.jsx)("span",{className:"block truncate text-[11px] text-muted-foreground",children:e.description})]})]})}function CD({entry:e}){let[t,r]=(0,eC.useState)(""),[n,a]=(0,eC.useState)(""),[i,s]=(0,eC.useState)(!1),[o,l]=(0,eC.useState)(!1),[c,u]=(0,eC.useState)(!1),[d,p]=(0,eC.useState)(null),m=(0,eC.useRef)(0);(0,eC.useEffect)(()=>{if(!e){r(""),a("");return}let t=++m.current;s(!0),l(!1),p(null),fetch(`/api/memory?path=${encodeURIComponent(e.path)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Failed to load.");return t}).then(e=>{m.current===t&&(r(e.content??""),a(e.content??""))}).catch(e=>{m.current===t&&(r(""),a(""),p(e instanceof Error?e.message:"Failed to load."))}).finally(()=>{m.current===t&&s(!1)})},[e]);let h=async()=>{if(e){u(!0),p(null);try{let t=await fetch("/api/memory",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.path,content:n})}),a=await t.json();if(!t.ok)throw Error(a.error??"Failed to save.");r(n),l(!1)}catch(e){p(e instanceof Error?e.message:"Failed to save.")}finally{u(!1)}}};if(!e)return(0,eI.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a profile to view"});let f=t.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"").trim();return(0,eI.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:[(0,eI.jsx)("span",{className:"text-sm font-medium",children:e.label}),(0,eI.jsx)("div",{className:"flex items-center gap-1.5",children:o?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nP,{variant:"outline",size:"sm",onClick:()=>{l(!1),a(t)},children:"Cancel"}),(0,eI.jsx)(nP,{size:"sm",onClick:h,disabled:c||n===t,children:c?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"Saving"]}):"Save"})]}):(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:()=>l(!0),disabled:i,children:[(0,eI.jsx)(iR,{className:"size-3.5","aria-hidden":"true"}),"Edit raw"]})})]}),d&&(0,eI.jsx)("p",{className:"flex-shrink-0 px-4 py-2 text-xs text-destructive",children:d}),(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:i?(0,eI.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading…"]}):o?(0,eI.jsx)("textarea",{"aria-label":`Edit ${e.label} memory`,className:"size-full resize-none bg-background p-4 font-mono text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",value:n,onChange:e=>a(e.target.value),spellCheck:!1}):(0,eI.jsx)(sc,{className:"h-full",children:(0,eI.jsx)("div",{className:"px-4 py-4",children:(0,eI.jsx)(N4,{content:f})})})})]})}function CP({listing:e,listingLoading:t}){let[r,n]=(0,eC.useState)(null),[a,i]=(0,eC.useState)(!1);(0,eC.useEffect)(()=>{let e=window.matchMedia("(min-width: 768px)"),t=()=>i(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let s=(0,eC.useMemo)(()=>(e?.entries??[]).filter(e=>e.path.startsWith("profile/projects/")&&e.path.endsWith(".md")).map(e=>{let t=e.path.split("/"),r=t.length>=4?`${t[2]}/${t.slice(3).join("/")}`:e.path;return{path:e.path,label:r.replace(/\/PROJECT_PROFILE\.md$/,""),description:"Project profile",Icon:_R}}),[e?.entries]),o=(0,eC.useMemo)(()=>[...CO,...s],[s]);(0,eC.useEffect)(()=>{!t&&0!==o.length&&(r&&o.some(e=>e.path===r.path)||n(o[0]))},[o,t,r]);let l=(0,eI.jsx)(sc,{className:"h-full",children:(0,eI.jsxs)("div",{className:"p-3",children:[(0,eI.jsx)("p",{className:"mb-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Profile"}),(0,eI.jsx)("div",{className:"space-y-1.5",children:CO.map(e=>(0,eI.jsx)(CL,{entry:e,selected:r?.path===e.path,onSelect:n},e.path))}),(0,eI.jsx)("p",{className:"mb-2 mt-5 text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Project Profiles"}),t?(0,eI.jsxs)("div",{className:"flex h-10 items-center gap-2 text-xs text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"Loading projects…"]}):0===s.length?(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"No project profiles yet."}):(0,eI.jsx)("div",{className:"space-y-1.5",children:s.map(e=>(0,eI.jsx)(CL,{entry:e,selected:r?.path===e.path,onSelect:n},e.path))})]})});return a?(0,eI.jsxs)(iS,{direction:"horizontal",autoSaveId:"evomemory-identity",className:"h-full",children:[(0,eI.jsx)(ak,{defaultSize:35,minSize:22,maxSize:55,children:l}),(0,eI.jsx)(iw,{}),(0,eI.jsx)(ak,{defaultSize:65,minSize:45,children:(0,eI.jsx)(CD,{entry:r})})]}):(0,eI.jsxs)("div",{className:"flex min-h-0 w-full flex-1 flex-col",children:[(0,eI.jsx)("div",{className:"max-h-[42svh] flex-shrink-0 overflow-hidden border-b border-border",children:l}),(0,eI.jsx)("div",{className:"min-h-0 flex-1",children:(0,eI.jsx)(CD,{entry:r})})]})}function CM(e){try{let t=new Date(e),r=new Date;return t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate()}catch{return!1}}function Cj({items:e}){let t=new Set(e.filter(e=>"execution"===e.kind).map(e=>e.project_id).filter(Boolean)).size,r=e.filter(e=>e.created_at&&CM(e.created_at)),n=r.filter(e=>"execution"===e.kind).length,a=r.filter(e=>"observation"===e.kind).length,i=[{n:t,label:"Projects"},{n:e.length,label:"Total"},{n:n,label:"Runs Today"},{n:a,label:"Obs Today"}];return(0,eI.jsx)("div",{className:"flex flex-shrink-0 border-b border-border",children:i.map(e=>(0,eI.jsxs)("div",{className:"flex flex-1 flex-col items-center gap-1 border-r border-border py-2 last:border-r-0",children:[(0,eI.jsx)("span",{className:"text-lg font-bold leading-none text-[var(--brand)]",children:e.n}),(0,eI.jsx)("span",{className:"text-[11px] leading-none text-muted-foreground",children:e.label})]},e.label))})}function CF({created_at:e,dotColor:t,children:r}){return(0,eI.jsxs)("div",{className:"flex gap-2",children:[(0,eI.jsx)("time",{dateTime:e,className:"w-14 flex-shrink-0 pt-3 text-right text-xs tabular-nums leading-none text-muted-foreground",children:function(e){try{let t=new Date(e);if(CM(e))return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(t);let r=new Date;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",...t.getFullYear()!==r.getFullYear()?{year:"numeric"}:{}}).format(t)}catch{return e}}(e)}),(0,eI.jsxs)("div",{className:"relative flex w-3 flex-shrink-0 justify-center",children:[(0,eI.jsx)("span",{className:"absolute bottom-0 left-1/2 top-0 w-px -translate-x-1/2 bg-border","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"z-10 mt-3 size-2.5 rounded-full border-2 border-[var(--color-surface)]",style:{background:t}})]}),r]})}function CU({entry:e,onNavigateToObs:t,defaultOpen:r=!1}){let[n,a]=(0,eC.useState)(r),i=(0,eC.useRef)(null),s=`${n?"Collapse":"Expand"} ${e.agent} execution: ${e.summary}`;return(0,eC.useEffect)(()=>{r&&(a(!0),i.current?.scrollIntoView({block:"center"}))},[r]),(0,eI.jsx)(CF,{created_at:e.created_at,dotColor:"var(--brand)",children:(0,eI.jsxs)("div",{ref:i,className:`hover:border-[var(--brand)]/40 mb-2 min-w-0 flex-1 overflow-hidden rounded-lg border bg-[var(--color-surface)] transition-colors ${r?"border-[var(--brand)]/40":"border-border"}`,children:[(0,eI.jsxs)("button",{type:"button","aria-expanded":n,"aria-label":s,title:s,onClick:()=>a(e=>!e),className:"flex w-full items-center gap-2 px-3 py-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:[(0,eI.jsx)("span",{className:"flex-shrink-0 text-sm font-medium text-foreground",children:e.agent}),!n&&(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:e.summary}),(0,eI.jsx)(lB,{className:`ml-auto size-3.5 flex-shrink-0 text-muted-foreground transition-transform duration-200 ${n?"rotate-180":""}`,"aria-hidden":"true"})]}),(0,eI.jsx)("div",{className:"grid transition-[grid-template-rows] duration-200",style:{gridTemplateRows:n?"1fr":"0fr"},children:n&&(0,eI.jsxs)("div",{className:"overflow-hidden",children:[e.project_id&&(0,eI.jsx)("p",{className:"px-3 pb-2 font-mono text-[11px] text-muted-foreground",children:e.project_id}),(0,eI.jsx)("p",{className:"border-t border-border px-3 py-3 text-sm leading-relaxed text-foreground",children:e.summary}),e.obs_ids.length>0&&(0,eI.jsxs)("div",{className:"border-t border-border px-3 py-2.5",children:[(0,eI.jsx)("p",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Linked Observations"}),(0,eI.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.obs_ids.map(e=>(0,eI.jsxs)("button",{type:"button",onClick:r=>{r.stopPropagation(),t(e)},className:"border-[var(--brand)]/40 rounded border bg-background px-2 py-0.5 font-mono text-[11px] text-[var(--brand)] transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:`Jump to ${e} in Knowledge graph`,"aria-label":`Jump to observation ${e} in Knowledge graph`,children:[e.slice(0,14),"…"]},e))})]})]})})]})})}function CB({obs:e,onNavigateToObs:t}){let r=IE(e.memory_type);return(0,eI.jsx)(CF,{created_at:e.created_at,dotColor:r,children:(0,eI.jsx)("button",{type:"button",onClick:()=>t(e.id),title:"View in Knowledge graph","aria-label":`View observation in Knowledge graph: ${e.summary}`,className:"hover:border-[var(--brand)]/40 mb-2 min-w-0 flex-1 cursor-pointer overflow-hidden rounded-lg border border-dashed border-border bg-[var(--color-surface)] px-3 py-2.5 text-left transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eI.jsx)("span",{className:"flex-shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-white",style:{background:r},children:e.memory_type}),(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:e.summary}),(0,eI.jsx)(Ip,{className:"ml-auto size-3.5 flex-shrink-0 text-muted-foreground","aria-hidden":"true"})]})})})}function C$({items:e,truncated:t,loading:r,error:n,highlightExecId:a,onRefresh:i,onNavigateToObs:s}){return r&&!e?(0,eI.jsxs)("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading history…"]}):n?(0,eI.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8",children:[(0,eI.jsx)("p",{className:"text-sm text-destructive",children:n}),(0,eI.jsxs)("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[(0,eI.jsx)(CT,{className:"size-3.5","aria-hidden":"true"}),"Retry"]})]}):e&&0!==e.length?(0,eI.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,eI.jsx)(Cj,{items:e}),(0,eI.jsx)(sc,{type:"always",className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block [&_[data-slot=scroll-area-viewport]>div]:!w-full",children:(0,eI.jsxs)("div",{className:"p-4",children:[(0,eI.jsx)("div",{children:e.map(e=>"execution"===e.kind?(0,eI.jsx)(CU,{entry:e,onNavigateToObs:s,defaultOpen:a===e.id},`e-${e.id}`):(0,eI.jsx)(CB,{obs:e,onNavigateToObs:s},`o-${e.id}`))}),t&&(0,eI.jsxs)("p",{className:"mt-2 text-center text-xs text-muted-foreground",children:["Showing newest ",e.length," items."]})]})})]}):(0,eI.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"No activity yet."})}function Cz(e){return"identity"===e||"knowledge"===e||"history"===e}function CH({initialTab:e,initialObsId:t,initialExecId:r}={}){let[n,a]=(0,eC.useState)(null),[i,s]=(0,eC.useState)(!0),[o,l]=(0,eC.useState)(Cz(e)?e:"identity"),[c,u]=(0,eC.useState)(null),[d,p]=(0,eC.useState)(!1),[m,h]=(0,eC.useState)(null),[f,g]=(0,eC.useState)(null),[b,y]=(0,eC.useState)(!1),[E,_]=(0,eC.useState)(null),[v,x]=(0,eC.useState)(t??null),T=(0,eC.useRef)(0),S=(0,eC.useRef)(0),w=(0,eC.useCallback)(async()=>{s(!0);try{let e=await fetch("/api/memory"),t=await e.json();if(!e.ok)return;a(t);let r=t.entries.reduce((e,t)=>t.mtime>e?t.mtime:e,0);r>0&&c5(r)}catch{}finally{s(!1)}},[]),k=(0,eC.useCallback)(async()=>{let e=++T.current;p(!0),h(null);try{let t=await fetch("/api/memory/observations",{cache:"no-store"}),r=await t.json().catch(()=>({}));if(e!==T.current)return;if(!t.ok)throw Error(r.error||"Failed.");u(r)}catch(t){if(e!==T.current)return;h(t instanceof Error?t.message:"Failed to load.")}finally{e===T.current&&p(!1)}},[]),A=(0,eC.useCallback)(async()=>{let e=++S.current;y(!0),_(null);try{let t=await fetch("/api/memory/executions",{cache:"no-store"}),r=await t.json().catch(()=>({}));if(e!==S.current)return;if(!t.ok)throw Error(r.error||"Failed.");g(r)}catch(t){if(e!==S.current)return;_(t instanceof Error?t.message:"Failed to load.")}finally{e===S.current&&y(!1)}},[]);(0,eC.useEffect)(()=>{w()},[w]),(0,eC.useEffect)(()=>{Cz(e)&&l(e)},[e]),(0,eC.useEffect)(()=>{t?(x(t),l("knowledge")):x(null)},[t]),(0,eC.useEffect)(()=>{r&&l("history")},[r]),(0,eC.useEffect)(()=>{if("history"!==o)return;let e=()=>{A(),k()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[o,A,k]),(0,eC.useEffect)(()=>{"knowledge"!==o||c||d||k()},[o,c,d,k]);let N=(0,eC.useMemo)(()=>{if(!f&&!c)return null;let e=[];for(let t of f?.entries??[])e.push({kind:"execution",...t});for(let t of c?.nodes??[])e.push({kind:"observation",id:t.id,created_at:t.created_at,summary:t.summary,memory_type:t.memory_type,scope:t.scope});return e.sort((e,t)=>e.created_at<t.created_at?1:-1),e},[f,c]),I=[{id:"identity",label:"Identity",Icon:Cx},{id:"knowledge",label:"Knowledge",Icon:Ip},{id:"history",label:"History",Icon:If}];return(0,eI.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,eI.jsxs)("header",{className:"flex flex-shrink-0 items-start justify-between gap-3 border-b border-border px-4 py-3 sm:px-5",children:[(0,eI.jsxs)("div",{className:"min-w-0",children:[(0,eI.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eI.jsx)(ik,{className:"size-5 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsx)("h2",{className:"text-xl font-semibold",children:"EvoMemory"})]}),(0,eI.jsxs)("p",{className:"mt-1 text-sm text-muted-foreground",children:["EvoScientist's"," ",(0,eI.jsx)("span",{className:"font-medium text-[var(--brand)]",children:"self-evolving memory system"})," ","— continuously learns and refines what it knows about you, your research taste, and lessons from past experiments."]})]}),(0,eI.jsx)("button",{type:"button",onClick:()=>{"history"===o?(A(),k()):"knowledge"===o?k():w()},disabled:"history"===o?b||d:"knowledge"===o?d:i,"aria-label":"Refresh",title:"Refresh",className:"mt-0.5 flex-shrink-0 rounded-md p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:(0,eI.jsx)(CT,{className:`size-4 ${"history"===o&&(b||d)||"knowledge"===o&&d||"identity"===o&&i?"animate-spin":""}`,"aria-hidden":"true"})})]}),(0,eI.jsx)("div",{className:"flex flex-shrink-0 items-center gap-1 border-b border-border px-3 pt-1",role:"tablist","aria-label":"Memory views",children:I.map(({id:e,label:t,Icon:r})=>(0,eI.jsxs)("button",{type:"button",role:"tab","aria-selected":o===e,onClick:()=>{l(e),"knowledge"!==e&&x(null)},className:nf("flex items-center gap-1.5 rounded-t-md border-b-2 px-3 py-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",o===e?"border-[var(--brand)] bg-accent text-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground"),children:[(0,eI.jsx)(r,{className:"size-3.5","aria-hidden":"true"}),t]},e))}),(0,eI.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:["identity"===o&&(0,eI.jsx)(CP,{listing:n,listingLoading:i}),"knowledge"===o&&(0,eI.jsx)(CC,{data:c,loading:d,error:m,highlightNodeId:v}),"history"===o&&(0,eI.jsx)("div",{className:"flex min-h-0 w-full flex-1 flex-col",children:(0,eI.jsx)(C$,{items:N,truncated:!!f?.truncated,loading:b||d,error:E||m,highlightExecId:r,onRefresh:()=>{A(),k()},onNavigateToObs:e=>{x(e),l("knowledge")}})})]})]})}let CG=rj("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Cq=rj("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]),CV=rj("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]),CW=rj("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),CY=rj("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),CK=rj("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),CZ=rj("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),CX=rj("repeat-2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]),CQ={frequency:"daily",hour:9,minute:0,dayOfWeek:1,dayOfMonth:1,custom:"0 9 * * *"},CJ=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function C0(e,t,r){return Number.isFinite(e)?Math.min(r,Math.max(t,e)):t}function C1(e){let t=C0(e.minute,0,59),r=C0(e.hour,0,23),n=C0(e.dayOfWeek,0,6),a=C0(e.dayOfMonth,1,28);switch(e.frequency){case"daily":break;case"weekly":return`${t} ${r} * * ${n}`;case"monthly":return`${t} ${r} ${a} * *`;case"custom":return e.custom.trim()}return`${t} ${r} * * *`}function C2(e){let t=e.trim().split(/\s+/);if(5!==t.length)return{...CQ,frequency:"custom",custom:e};let[r,n,a,i,s]=t,o=parseInt(r,10),l=parseInt(n,10);return"*"!==i||"*"!==a||"*"!==s||isNaN(o)||isNaN(l)?"*"!==i||"*"!==a||isNaN(parseInt(s,10))||isNaN(o)||isNaN(l)?"*"!==i||"*"!==s||isNaN(parseInt(a,10))||isNaN(o)||isNaN(l)?{...CQ,frequency:"custom",custom:e}:{...CQ,frequency:"monthly",hour:C0(l,0,23),minute:C0(o,0,59),dayOfMonth:C0(parseInt(a,10),1,28)}:{...CQ,frequency:"weekly",hour:C0(l,0,23),minute:C0(o,0,59),dayOfWeek:C0(parseInt(s,10),0,6)}:{...CQ,frequency:"daily",hour:l,minute:o}}function C4(e){let t=C2(e),r=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`;switch(t.frequency){case"daily":return`Every day at ${r}`;case"weekly":return`Every ${CJ[t.dayOfWeek]} at ${r}`;case"monthly":return`Monthly on day ${t.dayOfMonth} at ${r}`;default:return e}}function C3(e){if(!e)return"—";let t=new Date(e);if(isNaN(t.getTime()))return"—";let r=Date.now(),n=t.getTime()-r;if(n<0)return"Overdue";let a=Math.round(n/6e4);if(a<1)return"in <1m";if(a<60)return`in ${a}m`;let i=Math.round(n/36e5);if(i<24)return`in ${i}h`;let s=Math.round(n/864e5);return`in ${s}d`}let C5=[{icon:CW,label:"Daily Papers",description:"Track new ML papers against your research preferences.",name:"Daily Papers",prompt:"Summarise the latest ML papers from arXiv according to my research preferences with the paper-navigator skill. Focus on papers that are relevant to my current projects, explain why each one matters, and save the summary to ./daily-papers.md in the current workspace.",schedule:"0 9 * * *"},{icon:CX,label:"Weekly Research Review",description:"Summarise this week's research progress and future direction.",name:"Weekly Research Review",prompt:"Summarise this week's research progress across my active projects. Highlight key results, decisions, blockers, open questions, and what changed in my understanding. Then propose future research directions and concrete next steps. Save the review to ./weekly-research-review.md in the current workspace.",schedule:"0 17 * * 5"},{icon:Im,label:"Weekly Research Plan",description:"Draft a Monday plan for the week's research priorities.",name:"Weekly Research Plan",prompt:"Draft this week's research plan based on my active projects, recent progress, project files, and open questions. Prioritise the most important research goals, propose concrete experiments or reading tasks, identify risks, and write a practical schedule for the week. Save the plan to ./weekly-research-plan.md in the current workspace.",schedule:"0 8 * * 1"},{icon:CY,label:"Experiment Backlog",description:"Convert open questions into testable experiment ideas.",name:"Experiment Backlog",prompt:"Review my active project files, recent research notes, and open questions. Turn the most important unresolved ideas into a prioritised experiment backlog with hypotheses, expected signal, required data or code, estimated effort, and success criteria. Save it to ./experiment-backlog.md in the current workspace.",schedule:"0 10 * * 2"}];function C6(e){if(!e)return"Not scheduled";let t=new Date(e);return Number.isNaN(t.getTime())?"Unknown":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t)}function C9(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function C8({children:e,htmlFor:t}){return(0,eI.jsx)("label",{htmlFor:t,className:"text-xs font-medium text-muted-foreground",children:e})}function C7({value:e,onChange:t,error:r}){let n=r=>t({...e,...r}),a="h-9 rounded-md border border-input bg-background py-1.5 pl-2.5 pr-8 text-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",i=nf(a,"w-full sm:min-w-40"),s=nf(a,"w-full sm:w-28");return(0,eI.jsxs)("div",{className:"space-y-2",children:[(0,eI.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[minmax(9rem,1fr)_auto_auto_auto_auto] sm:items-center",children:[(0,eI.jsxs)("select",{"aria-label":"Schedule frequency",value:e.frequency,onChange:e=>n({frequency:e.target.value}),className:i,children:[(0,eI.jsx)("option",{value:"daily",children:"Every day"}),(0,eI.jsx)("option",{value:"weekly",children:"Every week"}),(0,eI.jsx)("option",{value:"monthly",children:"Every month"}),(0,eI.jsx)("option",{value:"custom",children:"Custom cron"})]}),"custom"!==e.frequency&&(0,eI.jsxs)(eI.Fragment,{children:["weekly"===e.frequency&&(0,eI.jsx)("select",{"aria-label":"Day of week",value:e.dayOfWeek,onChange:e=>n({dayOfWeek:Number(e.target.value)}),className:s,children:CJ.map((e,t)=>(0,eI.jsx)("option",{value:t,children:e},e))}),"monthly"===e.frequency&&(0,eI.jsx)("select",{"aria-label":"Day of month",value:e.dayOfMonth,onChange:e=>n({dayOfMonth:Number(e.target.value)}),className:s,children:Array.from({length:28},(e,t)=>t+1).map(e=>(0,eI.jsxs)("option",{value:e,children:["Day ",e]},e))}),(0,eI.jsx)("span",{className:"hidden text-xs text-muted-foreground sm:block",children:"at"}),(0,eI.jsxs)("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-1 sm:col-span-2 sm:w-32",children:[(0,eI.jsx)(nB,{"aria-label":"Hour",type:"number",min:0,max:23,value:e.hour,onChange:e=>n({hour:Number(e.target.value)}),className:"h-9 text-center font-mono tabular-nums"}),(0,eI.jsx)("span",{className:"font-mono text-muted-foreground",children:":"}),(0,eI.jsx)(nB,{"aria-label":"Minute",type:"number",min:0,max:59,value:e.minute,onChange:e=>n({minute:Number(e.target.value)}),className:"h-9 text-center font-mono tabular-nums"})]})]})]}),"custom"===e.frequency&&(0,eI.jsx)(nB,{type:"text",value:e.custom,onChange:e=>n({custom:e.target.value}),placeholder:"0 9 * * 1-5",spellCheck:!1,"aria-invalid":!!r,"aria-describedby":"schedule-cron-help",className:"h-9 font-mono text-sm"}),(0,eI.jsxs)("div",{id:"schedule-cron-help",className:nf("flex items-center gap-1.5 text-xs",r?"text-destructive":"text-muted-foreground"),children:[(0,eI.jsx)(CV,{className:"size-3.5 shrink-0","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"min-w-0 truncate",children:r??C4(C1(e))})]})]})}function Re({template:e,onSelect:t,compact:r}){let n=e.icon;return(0,eI.jsxs)("button",{type:"button",onClick:()=>t(e),className:nf("hover:border-[var(--brand)]/40 group flex w-full min-w-0 items-start gap-2 rounded-md border border-border bg-[var(--color-surface)] text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r?"px-2.5 py-2":"px-3 py-2.5"),children:[(0,eI.jsx)("span",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-[var(--brand)] group-hover:bg-background",children:(0,eI.jsx)(n,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("span",{className:"block truncate text-sm font-medium",children:e.label}),!r&&(0,eI.jsx)("span",{className:"mt-0.5 line-clamp-2 text-xs leading-snug text-muted-foreground",children:e.description}),(0,eI.jsx)("span",{className:"mt-1 block text-[11px] text-muted-foreground",children:C4(e.schedule)})]})]})}function Rt({initialTemplate:e,initialTask:t,onSaved:r,onCancel:n}){let a,i=!!t,[s,o]=(0,eC.useState)(t?.name??e?.name??""),[l,c]=(0,eC.useState)(t?.prompt??e?.prompt??""),[u,d]=(0,eC.useState)(()=>t?C2(t.schedule):e?C2(e.schedule):{...CQ}),[p,m]=(0,eC.useState)(!1),h=(0,eC.useRef)(null),f=C1(u),g="custom"===u.frequency?(a=f.trim())?5!==a.split(/\s+/).length?"Use five cron fields: minute hour day month weekday.":null:"Enter a cron expression.":null,b=!!(s.trim()&&l.trim()&&!g);(0,eC.useEffect)(()=>{h.current?.focus()},[]);let y=async e=>{if(e.preventDefault(),!s.trim())return void c6.toast.error("Task name is required.");if(!l.trim())return void c6.toast.error("Task description is required.");if(g)return void c6.toast.error(g);m(!0);try{if(t){let e=await IN({cronId:t.cron_id,name:s.trim(),prompt:l.trim(),schedule:f});e.oldTaskDeleted?c6.toast.success(`"${s.trim()}" updated.`):c6.toast.warning(`"${s.trim()}" was saved, but the old scheduled task could not be removed.`),r(e.task)}else await Ik({name:s.trim(),prompt:l.trim(),schedule:f}),c6.toast.success(`"${s.trim()}" scheduled.`),r()}catch(e){c6.toast.error(e instanceof Error?e.message:i?"Failed to update scheduled task.":"Failed to create scheduled task.")}finally{m(!1)}};return(0,eI.jsxs)("form",{onSubmit:y,className:"flex h-full min-h-0 flex-col",children:[(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)("button",{type:"button",onClick:n,"aria-label":"Back to scheduled tasks",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring md:hidden",children:(0,eI.jsx)(CG,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("h2",{className:"truncate text-sm font-semibold",children:i?"Edit scheduled task":"New scheduled task"}),(0,eI.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:"EvoScientist will run this task description unattended."})]})]}),(0,eI.jsx)(sc,{className:"min-h-0 flex-1",children:(0,eI.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 p-3 sm:p-5",children:[(0,eI.jsxs)("div",{className:"space-y-1.5",children:[(0,eI.jsx)(C8,{htmlFor:"scheduled-task-name",children:"Task name"}),(0,eI.jsx)(nB,{id:"scheduled-task-name",ref:h,type:"text",value:s,onChange:e=>o(e.target.value),placeholder:"Daily Briefing",autoComplete:"off"})]}),(0,eI.jsxs)("div",{className:"space-y-1.5",children:[(0,eI.jsx)(C8,{htmlFor:"scheduled-task-prompt",children:"Task description"}),(0,eI.jsx)(_X,{id:"scheduled-task-prompt",value:l,onChange:e=>c(e.target.value),placeholder:"Describe what EvoScientist should do each time this task runs...",rows:9,className:"min-h-52 resize-y leading-relaxed"})]}),(0,eI.jsxs)("div",{className:"space-y-1.5",children:[(0,eI.jsx)(C8,{children:"Schedule"}),(0,eI.jsx)(C7,{value:u,onChange:d,error:g})]})]})}),(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-end gap-2 border-t border-border bg-background px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)(nP,{type:"button",variant:"outline",size:"sm",onClick:n,disabled:p,children:"Cancel"}),(0,eI.jsxs)(nP,{type:"submit",size:"sm",disabled:p||!b,children:[p?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin"}):i?(0,eI.jsx)(iR,{className:"size-3.5"}):(0,eI.jsx)(CZ,{className:"size-3.5"}),i?"Save changes":"Create task"]})]})]})}function Rr({task:e,onBack:t,onEdit:r,onDeleted:n}){let a,[i,s]=(0,eC.useState)(!1),[o,l]=(0,eC.useState)(!1),[c,u]=(0,eC.useState)(!1),d=C9(e.next_run_date),p=(0,eC.useCallback)(async()=>{s(!0);try{await II(e.prompt),c6.toast.success(`"${e.name}" started.`)}catch(e){c6.toast.error(e instanceof Error?e.message:"Failed to start the task.")}finally{s(!1)}},[e]),m=(0,eC.useCallback)(async()=>{u(!0);try{await IA(e.cron_id),c6.toast.success(`"${e.name}" deleted.`),l(!1),n()}catch(e){c6.toast.error(e instanceof Error?e.message:"Failed to delete the task.")}finally{u(!1)}},[e,n]);return(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)("button",{type:"button",onClick:t,"aria-label":"Back to scheduled tasks",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring md:hidden",children:(0,eI.jsx)(CG,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("h2",{className:"truncate text-sm font-semibold",children:e.name}),(0,eI.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:C4(e.schedule)})]}),(0,eI.jsxs)(nP,{size:"sm",onClick:p,disabled:i||!e.prompt.trim(),children:[i?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin"}):(0,eI.jsx)(CK,{className:"size-3.5"}),"Run now"]})]}),(0,eI.jsx)(sc,{className:"min-h-0 flex-1",children:(0,eI.jsxs)("div",{className:"mx-auto w-full max-w-3xl space-y-4 p-3 sm:p-5",children:[(0,eI.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3",children:[(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-[var(--color-surface)] px-3 py-2",children:[(0,eI.jsx)("p",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:"Next run"}),(0,eI.jsx)("p",{className:"mt-1 truncate text-sm font-medium tabular-nums",title:d,children:e.next_run_date?`${C3(e.next_run_date)} \xb7 ${C6(e.next_run_date)}`:"Not scheduled"})]}),(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-[var(--color-surface)] px-3 py-2",children:[(0,eI.jsx)("p",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:"Cron"}),(0,eI.jsx)("p",{className:"mt-1 truncate font-mono text-sm",children:e.schedule})]}),(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-[var(--color-surface)] px-3 py-2",children:[(0,eI.jsx)("p",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:"Created"}),(0,eI.jsx)("p",{className:"mt-1 truncate text-sm",children:Number.isNaN((a=new Date(e.created_at)).getTime())?"Unknown":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(a)})]})]}),(0,eI.jsxs)("section",{className:"space-y-1.5",children:[(0,eI.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Task description"}),(0,eI.jsx)("div",{className:"max-h-[min(38rem,55vh)] overflow-auto rounded-md border border-border bg-[var(--color-surface)] px-3 py-2.5",children:e.prompt?(0,eI.jsx)("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:e.prompt}):(0,eI.jsx)("p",{className:"text-sm italic text-muted-foreground",children:"No task description stored."})})]})]})}),(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-between gap-2 border-t border-border bg-background px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)("p",{className:"hidden truncate text-xs text-muted-foreground sm:block",children:"Manual runs create a scheduler thread immediately."}),(0,eI.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:r,"aria-label":`Edit scheduled task "${e.name}"`,children:[(0,eI.jsx)(iR,{className:"size-3.5"}),"Edit"]}),(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:()=>l(!0),"aria-label":`Delete scheduled task "${e.name}"`,className:"text-destructive hover:border-destructive hover:text-destructive",children:[(0,eI.jsx)(iM,{className:"size-3.5"}),"Delete"]})]})]})]}),(0,eI.jsx)(ng,{open:o,onOpenChange:e=>{c||l(e)},children:(0,eI.jsxs)(nE,{className:"sm:max-w-sm",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Delete scheduled task?"}),(0,eI.jsxs)(nT,{children:["“",e.name,"” will stop running. This cannot be undone."]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",size:"sm",onClick:()=>l(!1),disabled:c,children:"Cancel"}),(0,eI.jsxs)(nP,{variant:"destructive",size:"sm",onClick:m,disabled:c,"aria-label":`Confirm delete scheduled task "${e.name}"`,children:[c&&(0,eI.jsx)(iI,{className:"size-3.5 animate-spin"}),"Delete"]})]})]})})]})}function Rn({task:e,active:t,onSelect:r}){let n=e.next_run_date;return(0,eI.jsxs)("button",{type:"button",onClick:r,"aria-current":t,className:nf("flex w-full items-start gap-2 rounded-md px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t?"bg-accent":"hover:bg-accent/60"),children:[(0,eI.jsx)("span",{className:"mt-1 flex size-2 shrink-0 rounded-full bg-[var(--brand)]"}),(0,eI.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("span",{className:"block truncate text-sm font-medium",children:e.name}),(0,eI.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:C4(e.schedule)}),(0,eI.jsxs)("span",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,eI.jsx)(iA,{className:"size-3 shrink-0","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"truncate tabular-nums",title:C9(n),children:n?C3(n):"No next run"})]})]}),(0,eI.jsx)(Io,{className:"mt-1 size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"})]})}function Ra(){let{tasks:e,loading:t,error:r,refresh:n}=function(){let[e,t]=(0,eC.useState)([]),[r,n]=(0,eC.useState)(!0),[a,i]=(0,eC.useState)(null),[s,o]=(0,eC.useState)(0),l=(0,eC.useCallback)(()=>o(e=>e+1),[]);return(0,eC.useEffect)(()=>{let e=!1;return n(!0),Iw().then(r=>{e||(t(r),i(null))}).catch(r=>{e||(i(r instanceof Error?r.message:"Failed to load scheduled tasks."),t([]))}).finally(()=>{e||n(!1)}),()=>{e=!0}},[s]),{tasks:e,loading:r,error:a,refresh:l}}(),[a,i]=(0,eC.useState)({kind:"empty"}),[s,o]=(0,eC.useState)(""),l=(0,eC.useRef)(0),c=(0,eC.useRef)(0),u=(0,eC.useRef)(null),d=(0,eC.useMemo)(()=>[...e].sort((e,t)=>{let r=e.next_run_date?new Date(e.next_run_date).getTime():0,n=t.next_run_date?new Date(t.next_run_date).getTime():0;return r&&n&&r!==n?r-n:r&&!n?-1:!r&&n?1:e.name.localeCompare(t.name)}),[e]),p=(0,eC.useMemo)(()=>{let e=s.trim().toLowerCase();return e?d.filter(t=>[t.name,t.prompt,t.schedule,C4(t.schedule),t.next_run_date?C6(t.next_run_date):""].join(" ").toLowerCase().includes(e)):d},[s,d]),m=d.find(e=>e.next_run_date),h="detail"===a.kind?a.task.cron_id:null;(0,eC.useEffect)(()=>{if(!h||t)return;let n=e.find(e=>e.cron_id===h);if(n){u.current===h&&(u.current=null),i({kind:"detail",task:n});return}(u.current!==h||r)&&(u.current=null,i({kind:"empty"}))},[r,t,h,e]);let f=(0,eC.useCallback)(e=>{l.current+=1,i({kind:"create",template:e,createId:l.current})},[]),g=(0,eC.useCallback)(e=>{c.current+=1,i({kind:"edit",task:e,editId:c.current})},[]),b=(0,eC.useCallback)(e=>{u.current=e?.cron_id??null,n(),i(e?{kind:"detail",task:e}:{kind:"empty"})},[n]),y=(0,eC.useCallback)(()=>{n(),i({kind:"empty"})},[n]);return(0,eI.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,eI.jsxs)("header",{className:"flex flex-shrink-0 items-center justify-between gap-3 border-b border-border px-3 py-2.5 sm:px-4",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-accent text-[var(--brand)]",children:(0,eI.jsx)(CV,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"min-w-0",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)("h1",{className:"truncate text-sm font-semibold",children:"Scheduled"}),!t&&(0,eI.jsx)("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e.length})]}),(0,eI.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:m?.next_run_date?`Next: ${C3(m.next_run_date)}`:"Recurring EvoScientist tasks"})]})]}),(0,eI.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eI.jsx)("button",{type:"button",onClick:n,disabled:t,"aria-label":"Refresh scheduled tasks",title:"Refresh scheduled tasks",className:"rounded-md p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:(0,eI.jsx)(CT,{className:nf("size-4",t&&"animate-spin"),"aria-hidden":"true"})}),(0,eI.jsxs)(nP,{size:"sm",onClick:()=>f(),children:[(0,eI.jsx)(CZ,{className:"size-3.5"}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"New task"}),(0,eI.jsx)("span",{className:"sm:hidden",children:"New"})]})]})]}),(0,eI.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,eI.jsxs)("aside",{className:nf("w-full min-w-0 flex-col border-r border-border md:flex md:w-72 md:flex-shrink-0","empty"===a.kind?"flex":"hidden"),children:[(0,eI.jsx)("div",{className:"flex-shrink-0 space-y-2 border-b border-border p-2.5",children:(0,eI.jsxs)("div",{className:"relative",children:[(0,eI.jsx)(iP,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)(nB,{type:"search",name:"scheduled-search",value:s,onChange:e=>o(e.target.value),placeholder:"Search scheduled tasks...","aria-label":"Search scheduled tasks",autoComplete:"off",spellCheck:!1,className:"h-9 pl-8 pr-8"}),s&&(0,eI.jsx)("button",{type:"button",onClick:()=>o(""),"aria-label":"Clear scheduled task search",className:"absolute right-1 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(rF,{className:"size-3.5","aria-hidden":"true"})})]})}),(0,eI.jsx)(sc,{className:"h-0 flex-1",children:t?(0,eI.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading tasks..."]}):r?(0,eI.jsxs)("div",{role:"alert",className:"space-y-3 p-3",children:[(0,eI.jsx)("p",{className:"text-sm text-destructive",children:r}),(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:n,children:[(0,eI.jsx)(CT,{className:"size-3.5"}),"Retry"]})]}):0===e.length?(0,eI.jsxs)("div",{className:"space-y-4 p-3",children:[(0,eI.jsxs)("div",{className:"rounded-md border border-dashed border-border bg-[var(--color-surface)] px-3 py-5 text-center",children:[(0,eI.jsx)(Cq,{className:"mx-auto size-7 text-muted-foreground/60","aria-hidden":"true"}),(0,eI.jsx)("p",{className:"mt-2 text-sm font-medium",children:"No scheduled tasks"}),(0,eI.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Start from a template or create one from scratch."})]}),(0,eI.jsxs)("div",{className:"space-y-2",children:[(0,eI.jsx)("p",{className:"px-1 text-[11px] font-semibold uppercase text-muted-foreground",children:"Templates"}),C5.map(e=>(0,eI.jsx)(Re,{template:e,onSelect:f},e.label))]})]}):0===p.length?(0,eI.jsxs)("div",{className:"space-y-3 p-4 text-center",children:[(0,eI.jsx)("p",{className:"text-sm font-medium",children:"No matching tasks"}),(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try a task name, schedule, or description keyword."}),(0,eI.jsx)(nP,{variant:"outline",size:"sm",onClick:()=>o(""),children:"Clear search"})]}):(0,eI.jsxs)("div",{className:"p-1.5",children:[(0,eI.jsxs)("div",{className:"mb-2 flex items-center justify-between px-2 py-1",children:[(0,eI.jsx)("p",{className:"text-[11px] font-semibold uppercase text-muted-foreground",children:"Tasks"}),(0,eI.jsx)("p",{className:"text-[11px] text-muted-foreground",children:p.length})]}),(0,eI.jsx)("div",{className:"flex flex-col gap-0.5",children:p.map(e=>{let t="detail"===a.kind&&a.task.cron_id===e.cron_id;return(0,eI.jsx)(Rn,{task:e,active:t,onSelect:()=>i({kind:"detail",task:e})},e.cron_id)})}),(0,eI.jsxs)("div",{className:"mt-3 space-y-2 border-t border-border px-1 py-3",children:[(0,eI.jsx)("p",{className:"px-1 text-[11px] font-semibold uppercase text-muted-foreground",children:"Templates"}),(0,eI.jsx)("div",{className:"grid gap-1.5",children:C5.map(e=>(0,eI.jsx)(Re,{template:e,onSelect:f,compact:!0},e.label))})]})]})})]}),(0,eI.jsxs)("section",{className:nf("min-w-0 flex-1 flex-col","empty"===a.kind?"hidden md:flex":"flex"),children:["empty"===a.kind&&(0,eI.jsx)("div",{className:"flex flex-1 items-center justify-center p-5",children:(0,eI.jsxs)("div",{className:"w-full max-w-lg space-y-4",children:[(0,eI.jsxs)("div",{className:"space-y-1 text-center",children:[(0,eI.jsx)(CV,{className:"mx-auto size-9 text-muted-foreground/40","aria-hidden":"true"}),(0,eI.jsx)("p",{className:"text-sm font-medium",children:"Pick a scheduled task"}),(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"View details, run it manually, or create another recurring research job."})]}),e.length>0&&(0,eI.jsx)("div",{className:"mx-auto grid w-full max-w-xl gap-2 sm:grid-cols-2",children:C5.map(e=>(0,eI.jsx)(Re,{template:e,onSelect:f,compact:!0},e.label))})]})}),"create"===a.kind&&(0,eI.jsx)(Rt,{initialTemplate:a.template,onSaved:b,onCancel:()=>i({kind:"empty"})},a.createId),"edit"===a.kind&&(0,eI.jsx)(Rt,{initialTask:a.task,onSaved:b,onCancel:()=>i({kind:"detail",task:a.task})},a.editId),"detail"===a.kind&&(0,eI.jsx)(Rr,{task:a.task,onBack:()=>i({kind:"empty"}),onEdit:()=>g(a.task),onDeleted:y})]})]})]})}let Ri=rj("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),Rs=rj("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);function Ro(){let{resolvedTheme:e,setTheme:t}=(0,N$.useTheme)(),[r,n]=(0,eC.useState)(!1);(0,eC.useEffect)(()=>n(!0),[]);let a=r&&"dark"===e;return(0,eI.jsx)(nP,{variant:"ghost",size:"icon",className:"size-8 sm:size-9",onClick:()=>t(a?"light":"dark"),"aria-label":a?"Switch to light mode":"Switch to dark mode",title:a?"Switch to light mode":"Switch to dark mode",children:a?(0,eI.jsx)(Ri,{className:"size-5","aria-hidden":"true"}):(0,eI.jsx)(Rs,{className:"size-5","aria-hidden":"true"})})}let Rl={checking:{dot:"bg-[var(--color-warning)]",label:"Connecting…",pulse:!0},online:{dot:"bg-[var(--color-success)]",label:"Connected",pulse:!1},offline:{dot:"bg-[var(--color-error)]",label:"Offline",pulse:!1}};function Rc(e){return e.trim().replace(/\/+$/,"")}async function Ru(e){let t=new AbortController,r=setTimeout(()=>t.abort(),4e3);try{return(await fetch(`${e}/info`,{signal:t.signal,cache:"no-store"})).ok}catch{return!1}finally{clearTimeout(r)}}function Rd({deploymentUrl:e,onReconnect:t}){let[r,n]=(0,eC.useState)("checking"),[a,i]=(0,eC.useState)(null),[s,o]=(0,eC.useState)(null),l=(0,eC.useRef)(0),c=(0,eC.useRef)(!0),u=(0,eC.useRef)(null),d=(0,eC.useCallback)(async t=>{let r=Rc(e);try{let e=await fetch("/api/evosci-config",{cache:"no-store"}),n=await e.json().catch(()=>null),a=n?.deploymentUrl?Rc(n.deploymentUrl):"";if(t!==l.current||!c.current)return;if(!a||a===r)return void o(null);let i=await Ru(a);if(t!==l.current||!c.current)return;o(i?a:null)}catch{t===l.current&&c.current&&o(null)}},[e]),p=(0,eC.useCallback)(async()=>{let t=++l.current,r=Rc(e);if(!r){t===l.current&&c.current&&(i(null),n("offline"),o(null));return}u.current?.abort();let a=new AbortController;u.current=a;let s=setTimeout(()=>a.abort(),4e3);try{let e=await fetch(`${r}/info`,{signal:a.signal,cache:"no-store"});if(t!==l.current||!c.current)return;if(!e.ok){n("offline"),d(t);return}let s=await e.json().catch(()=>null);if(t!==l.current||!c.current)return;i(s),n("online"),o(null)}catch{t===l.current&&c.current&&(n("offline"),d(t))}finally{clearTimeout(s)}},[e,d]);(0,eC.useEffect)(()=>{c.current=!0,n("checking"),p();let e=setInterval(()=>{document.hidden||p()},1e4),t=()=>p(),r=()=>{document.hidden||p()};return window.addEventListener("focus",t),window.addEventListener("online",t),document.addEventListener("visibilitychange",r),()=>{c.current=!1,u.current?.abort(),clearInterval(e),window.removeEventListener("focus",t),window.removeEventListener("online",t),document.removeEventListener("visibilitychange",r)}},[p]);let m=Rl[r],h="online"===r?`Connected to ${e}${a?.version?` \xb7 langgraph ${a.version}`:""}`:"offline"===r?`Can't reach the backend at ${e}. Is "EvoSci deploy" running? Click to retry.`:`Checking connection to ${e}…`;return(0,eI.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eI.jsxs)(nP,{variant:"ghost",size:"sm",onClick:p,title:h,"aria-label":h,className:"h-8 gap-1.5 px-2 text-xs font-normal text-muted-foreground",children:[(0,eI.jsx)("span",{className:`size-2 shrink-0 rounded-full ${m.dot} ${m.pulse?"animate-pulse":""}`,"aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:m.label})]}),"offline"===r&&null!==s&&void 0!==t&&(0,eI.jsxs)(nP,{variant:"ghost",size:"sm",onClick:()=>{s&&(o(null),n("checking"),t?.(s))},title:`Backend detected at ${s}. Click to reconnect.`,"aria-label":`Reconnect to detected backend ${s}`,className:"h-8 gap-1 px-2 text-xs font-medium text-[var(--brand)] hover:text-[var(--brand)]",children:["Reconnect"," ",(0,eI.jsx)("span",{className:"tabular-nums",children:s?function(e){try{let t=new URL(e),r="127.0.0.1"===t.hostname||"localhost"===t.hostname||"0.0.0.0"===t.hostname,n=t.port||("https:"===t.protocol?"443":"80");return r?`:${n}`:`${t.hostname}:${n}`}catch{return e}}(s):""})]})]})}let Rp=rj("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);async function Rm(e){let t=await fetch(`/api/workspace?${new URLSearchParams({path:e})}`),r=await t.json().catch(()=>null);if(!t.ok)throw Error(r?.error||"Failed to list workspace.");return r?.entries??[]}async function Rh(){let e=await fetch("/api/workspace?recursive=1"),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||"Failed to load workspace.");return{entries:t?.entries??[],truncated:!!t?.truncated}}let Rf=[{key:"docs",label:"Papers & docs",Icon:I6,exts:["pdf","tex","bib","md","markdown","txt","docx","doc","rtf","odt"]},{key:"figures",label:"Figures",Icon:rj("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),exts:["png","jpg","jpeg","gif","svg","webp","bmp","tiff","tif","eps"]},{key:"data",label:"Data",Icon:rj("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),exts:["json","jsonl","csv","tsv","xlsx","xls","parquet","pkl","npy","npz","h5","hdf5","db","sqlite","yaml","yml","xml"]},{key:"code",label:"Code",Icon:rj("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),exts:["py","ipynb","js","ts","tsx","jsx","sh","bash","r","jl","cpp","cc","c","h","hpp","java","go","rs","m","rb"]}],Rg={key:"other",label:"Other",Icon:_C},Rb={};for(let e of Rf)for(let t of e.exts)Rb[t]=e.key;function Ry(){let[e,t]=(0,eC.useState)("tree"),[r,n]=(0,eC.useState)({}),[a,i]=(0,eC.useState)(new Set),[s,o]=(0,eC.useState)(new Set),[l,c]=(0,eC.useState)(!1),[u,d]=(0,eC.useState)(null),[p,m]=(0,eC.useState)(!1),[h,f]=(0,eC.useState)(!1),[g,b]=(0,eC.useState)(null),[y,E]=(0,eC.useState)(null),_=(0,eC.useCallback)(async e=>{o(t=>new Set(t).add(e));try{let t=await Rm(e);return n(r=>({...r,[e]:t})),""===e&&b(null),t}catch(t){throw""===e&&b(t instanceof Error?t.message:"Failed to load."),t}finally{o(t=>{let r=new Set(t);return r.delete(e),r})}},[]),v=(0,eC.useCallback)(async()=>{m(!0);try{let{entries:e,truncated:t}=await Rh();d(e),f(t),b(null)}catch(e){b(e instanceof Error?e.message:"Failed to load.")}finally{m(!1)}},[]);(0,eC.useEffect)(()=>{c(!0),_("").catch(()=>{}).finally(()=>c(!1))},[]),(0,eC.useEffect)(()=>{"type"!==e||null!==u||p||v()},[e]);let x=(0,eC.useCallback)(async()=>{(b(null),"type"===e)?await v():(c(!0),await Promise.allSettled(["",...a].map(e=>_(e))),c(!1))},[e,a,_,v]),T=(0,eC.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),r[e]||_(e).catch(()=>{})),n})},[r,_]),S=(0,eC.useMemo)(()=>{let e={};for(let t of u??[]){let r=Rb[t.ext]??Rg.key;(e[r]??=[]).push(t)}for(let t of Object.values(e))t.sort((e,t)=>t.mtime-e.mtime);return e},[u]),w="type"===e?p:l,k=(e,t)=>{let n=r[e];return n?0===n.length&&0===t?(0,eI.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"No files in the workspace yet"}):n.map(e=>{let r=a.has(e.path),n=s.has(e.path);return(0,eI.jsxs)("div",{children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>"dir"===e.type?T(e.path):E({path:e.path,size:e.size}),className:"flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-sm text-foreground transition-colors hover:bg-muted",style:{paddingLeft:`${14*t+4}px`},title:e.name,children:["dir"===e.type?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground",children:n?(0,eI.jsx)(iI,{className:"size-3 animate-spin"}):r?(0,eI.jsx)(lB,{className:"size-3.5"}):(0,eI.jsx)(Io,{className:"size-3.5"})}),(0,eI.jsx)(Rp,{className:"size-4 shrink-0 text-[var(--brand)]"})]}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("span",{className:"size-4 shrink-0"}),(0,eI.jsx)(I6,{className:"size-4 shrink-0 text-muted-foreground"})]}),(0,eI.jsx)("span",{className:"truncate",children:e.name})]}),"dir"===e.type&&r&&k(e.path,t+1)]},e.path)}):null};return(0,eI.jsxs)("div",{className:"flex min-h-0 flex-col",children:[(0,eI.jsxs)("div",{className:"flex items-center justify-between gap-2 pb-1.5",children:[(0,eI.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted p-0.5 text-xs",children:["tree","type"].map(r=>(0,eI.jsx)("button",{type:"button",onClick:()=>t(r),className:nf("rounded px-2 py-0.5 font-medium transition-colors",e===r?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),"aria-pressed":e===r,children:"tree"===r?"Tree":"By type"},r))}),(0,eI.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,eI.jsxs)("a",{href:"/api/workspace/download",download:!0,className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Download the whole workspace as a zip",children:[(0,eI.jsx)(iN,{className:"size-3.5"}),"All"]}),(0,eI.jsx)("button",{type:"button",onClick:x,disabled:w,className:"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50","aria-label":"Refresh workspace",title:"Refresh",children:(0,eI.jsx)(CT,{className:nf("size-3.5",w&&"animate-spin")})})]})]}),g?(0,eI.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:g}):"tree"===e?l&&!r[""]?(0,eI.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,eI.jsx)(iI,{className:"size-4 animate-spin text-muted-foreground"})}):(0,eI.jsx)("div",{className:"-mx-1",children:k("",0)}):p&&null===u?(0,eI.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,eI.jsx)(iI,{className:"size-4 animate-spin text-muted-foreground"})}):(()=>{if(!u)return null;if(0===u.length)return(0,eI.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"No files in the workspace yet"});let e=[...Rf,Rg];return(0,eI.jsxs)("div",{className:"space-y-3",children:[h&&(0,eI.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:"Showing the first files only — the workspace has more than the limit."}),e.map(e=>{let t=S[e.key];if(!t||0===t.length)return null;let r=e.Icon;return(0,eI.jsxs)("div",{children:[(0,eI.jsxs)("div",{className:"mb-0.5 flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wider text-tertiary",children:[(0,eI.jsx)(r,{className:"size-3.5"}),e.label,(0,eI.jsxs)("span",{className:"text-muted-foreground",children:["(",t.length,")"]})]}),t.map(e=>{let t=e.path.includes("/")?e.path.slice(0,e.path.lastIndexOf("/")):"";return(0,eI.jsxs)("button",{type:"button",onClick:()=>E({path:e.path,size:e.size}),className:"flex w-full items-center gap-1.5 rounded-md px-1 py-1 text-left text-sm text-foreground transition-colors hover:bg-muted",title:e.path,children:[(0,eI.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eI.jsx)("span",{className:"truncate",children:e.name}),t&&(0,eI.jsx)("span",{className:"ml-auto shrink-0 truncate pl-2 text-[11px] text-muted-foreground",children:t})]},e.path)})]},e.key)})]})})(),(0,eI.jsx)(Cl,{path:y?.path??null,size:y?.size,onClose:()=>E(null),onChanged:x})]})}let RE=rj("bell-ring",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]),R_=rj("corner-up-left",[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]);function Rv(e){let t="";for(let r of e)if("human"===r.type){let e=_y(r).trim();if(e){t=e;break}}return{prompt:t,steps:function(e){let t=[];for(let r of e)if("ai"===r.type){let e=_b(r.content).trim();for(let n of(e&&t.push({kind:"text",text:e}),function(e){let t=[];if(Array.isArray(e.tool_calls)&&e.tool_calls.length>0){for(let r of e.tool_calls)t.push({id:r.id??"",name:r.name??"tool",args:r.args&&"object"==typeof r.args?r.args:{}});return t}let r=e.additional_kwargs?.tool_calls;if(Array.isArray(r))for(let e of r){let r={},n=e.function?.arguments;if(n&&"object"==typeof n)r=n;else if("string"==typeof n)try{let e=JSON.parse(n);e&&"object"==typeof e&&(r=e)}catch{r={input:n}}t.push({id:e.id??"",name:e.function?.name??"tool",args:r})}return t}(r)))t.push({kind:"tool_call",id:n.id,name:n.name,args:n.args})}else"tool"===r.type&&t.push({kind:"tool_result",toolCallId:r.tool_call_id??"",name:r.name??"tool",text:_b(r.content).trim()});return t}(e)}}function Rx({status:e}){let t=Ir[N5(e)];return(0,eI.jsx)("span",{className:nf("size-2 shrink-0 rounded-full",t.dot,t.pulse&&"animate-pulse"),"aria-hidden":"true"})}function RT({onReportToMainChat:e}){let t=ao(),[r]=e$("threadId"),{tasks:n,loaded:a,error:i,refresh:s}=IH(r),[o,l]=(0,eC.useState)(()=>Date.now()),[c,u]=(0,eC.useState)(null),[d,p]=(0,eC.useState)({}),m=(0,eC.useRef)(new Map),[h,f]=(0,eC.useState)({}),[g,b]=IJ(r),[y,E]=(0,eC.useState)({}),[_,v]=(0,eC.useState)({}),[x,T]=(0,eC.useState)({}),S=(0,eC.useRef)(!0);(0,eC.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,eC.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[]);let w=async e=>{let r=(y[e.task_id]??"").trim();if(r&&!_[e.task_id]){v(t=>({...t,[e.task_id]:!0})),T(t=>({...t,[e.task_id]:null}));try{let n=await t.runs.wait(e.thread_id,e.agent_name,{input:{messages:[{type:"human",content:r}]}});if(!S.current)return;let a=Array.isArray(n?.messages)?n.messages:[];if(0===a.length)return void T(t=>({...t,[e.task_id]:"The agent didn't return a reply — it may have hit an error."}));E(t=>({...t,[e.task_id]:""}));let{prompt:i,steps:s}=Rv(a);p(t=>({...t,[e.task_id]:{loading:!1,error:null,prompt:i,steps:s}}))}catch(r){if(!S.current)return;let t=r instanceof TypeError||"object"==typeof r&&null!==r&&"number"==typeof r.status;T(r=>({...r,[e.task_id]:t?"Couldn't reach this agent — try again.":"The agent hit an error processing this follow-up."}))}finally{S.current&&v(t=>({...t,[e.task_id]:!1}))}}};(0,eC.useEffect)(()=>{if(!c)return;let e=n.find(e=>e.task_id===c);if(!e||"expired"===N5(e.liveStatus))return;let r="running"===N5(e.liveStatus),a=[e.run_id,e.last_updated_at,e.endedAt].join(":");if(!r&&m.current.get(c)===a)return;let i=!1;return p(e=>({...e,[c]:{loading:!e[c],error:null,prompt:e[c]?.prompt??"",steps:e[c]?.steps??[]}})),(async()=>{try{let n=await t.threads.getState(e.thread_id);if(i)return;let{prompt:s,steps:o}=Rv(n.values?.messages??[]);r||m.current.set(c,a),p(e=>({...e,[c]:{loading:!1,error:null,prompt:s,steps:o}}))}catch{if(i)return;m.current.delete(c),p(e=>({...e,[c]:{loading:!1,error:"Couldn't load this agent's steps.",prompt:e[c]?.prompt??"",steps:e[c]?.steps??[]}}))}})(),()=>{i=!0}},[c,n,t]);let k=(0,eC.useMemo)(()=>Ia(n),[n]);return(0,eI.jsxs)("div",{className:"flex h-full flex-col",children:[(0,eI.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1 pb-2",children:[(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:k>0?`${k} running`:n.length>0?`${n.length} total`:"Background agents"}),(0,eI.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>{r&&(g||IX(r,n.filter(e=>In(e.liveStatus)).map(N8)),b(!g))},"aria-pressed":g,"aria-label":`Auto-report ${g?"on":"off"}`,title:g?"Auto-report on: finished agents are sent to the main chat automatically":"Auto-report off: use each agent's “Notify main chat” button",className:nf("inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",g?"bg-accent text-[var(--brand)]":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[(0,eI.jsx)(RE,{className:"size-3.5","aria-hidden":"true"}),(0,eI.jsxs)("span",{className:"hidden min-[340px]:inline",children:["Auto-report ",g?"On":"Off"]})]}),(0,eI.jsx)("button",{type:"button",onClick:s,"aria-label":"Refresh agents",title:"Refresh",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(CT,{className:"size-3.5","aria-hidden":"true"})})]})]}),i&&(0,eI.jsx)("p",{className:"px-1 text-xs text-[var(--color-error)]",children:i}),!a&&(0,eI.jsxs)("div",{className:"flex items-center gap-2 px-1 py-4 text-xs text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading…"]}),a&&0===n.length&&(0,eI.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 px-4 py-10 text-center",children:[(0,eI.jsx)(_U,{className:"size-9 text-muted-foreground/60","aria-hidden":"true"}),(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"No background agents yet."}),(0,eI.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"When EvoScientist delegates long tasks (writing, data analysis) they run in the background and show up here."})]}),(0,eI.jsx)("div",{className:"flex min-h-0 flex-1 flex-col gap-1.5 overflow-y-auto",children:n.map(t=>{var n;let a,i,s,l=N5(t.liveStatus),p=Ir[l],m=c===t.task_id,b="expired"===l,v=d[t.task_id];return(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-background",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>u(m?null:t.task_id),className:"flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-expanded":m,children:[m?(0,eI.jsx)(lB,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,eI.jsx)(Io,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)(Rx,{status:t.liveStatus}),(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:N6[n=t.agent_name]??n}),(0,eI.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[p.label,(a=function(e,t){let r=N5(e.liveStatus);if("expired"===r)return"";let n="running"===r?t:e.endedAt?Date.parse(e.endedAt):t;return function(e,t){if(!e)return"";let r=Date.parse(e);if(Number.isNaN(r))return"";let n=Math.max(0,Math.round((t-r)/1e3)),a=Math.floor(n/60);if(a>=60){let e=Math.floor(a/60);return`${e}h ${a%60}m`}return a>0?`${a}m ${n%60}s`:`${n}s`}(e.startedAt??e.created_at,n)}(t,o))?` \xb7 ${a}`:""]})]}),m&&b&&(0,eI.jsx)("div",{className:"border-t border-border px-2.5 py-2 text-xs",children:(0,eI.jsx)("p",{className:"text-muted-foreground",children:"This task ran before a backend restart and its records are gone, so its steps and result can no longer be loaded. Any files it produced are still in the workspace."})}),m&&!b&&(0,eI.jsxs)("div",{className:"border-t border-border px-2.5 py-2 text-xs",children:[v?.loading&&(0,eI.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"Loading steps…"]}),v?.error&&(0,eI.jsx)("p",{className:"text-[var(--color-error)]",children:v.error}),v&&!v.loading&&!v.error&&(0,eI.jsxs)("div",{className:"flex flex-col gap-2",children:[v.prompt&&(0,eI.jsxs)("div",{children:[(0,eI.jsx)("p",{className:"font-semibold text-foreground",children:"Task"}),(0,eI.jsx)("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:v.prompt.length>600?v.prompt.slice(0,600)+"…":v.prompt})]}),(0,eI.jsxs)("div",{children:[(0,eI.jsxs)("p",{className:"mb-1 font-semibold text-foreground",children:["Steps"," ",(0,eI.jsxs)("span",{className:"font-normal text-muted-foreground",children:["(",v.steps.length,")"]})]}),0===v.steps.length?(0,eI.jsx)("p",{className:"text-muted-foreground",children:"No steps yet."}):(0,eI.jsx)(N3,{steps:v.steps,compact:!0})]}),In(t.liveStatus)&&(0,eI.jsx)("div",{className:"mt-1 border-t border-border pt-2",children:g?(0,eI.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,eI.jsx)(RE,{className:"size-3.5 text-[var(--brand)]","aria-hidden":"true"}),"Auto-report on · future completions notify the main chat"]}):(0,eI.jsxs)("button",{type:"button",onClick:()=>(t=>{if(!e||!r)return void c6.toast.error("Open the conversation to notify the main agent.");let n=e(t,r);if("sent"===n){f(e=>({...e,[N8(t)]:!0})),c6.toast.success("Reported to the main chat.");return}if("duplicate"===n){f(e=>({...e,[N8(t)]:!0})),c6.toast.info("This result is already in the main chat.");return}c6.toast.error("wrong-thread"===n?"The active conversation changed — reopen this task and try again.":"Main chat is busy — try again when it's idle.")})(t),disabled:!e||!!h[N8(t)],title:e?"Send this result back to the main agent":"Open the conversation to notify the main agent",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[(0,eI.jsx)(R_,{className:"size-3.5 text-[var(--brand)]","aria-hidden":"true"}),h[N8(t)]?"Reported to main chat":"Notify main chat"]})}),(i="running"===N5(t.liveStatus),s=!!_[t.task_id],(0,eI.jsxs)("div",{className:"mt-1 border-t border-border pt-2",children:[(0,eI.jsx)("p",{className:"mb-1 text-[11px] text-muted-foreground",children:"Direct follow-up · Main chat is not notified"}),(0,eI.jsxs)("form",{onSubmit:e=>{e.preventDefault(),w(t)},className:"flex items-center gap-1.5",children:[(0,eI.jsx)("input",{type:"text",name:`agent-message-${t.task_id}`,autoComplete:"off",value:y[t.task_id]??"",onChange:e=>E(r=>({...r,[t.task_id]:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&(e.nativeEvent.isComposing||229===e.keyCode)&&e.preventDefault()},disabled:i||s,placeholder:i?"Agent is working…":"Send a direct follow-up…","aria-label":"Message this agent",className:"min-w-0 flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60"}),(0,eI.jsx)("button",{type:"submit",disabled:i||s||!(y[t.task_id]??"").trim(),"aria-label":"Send",title:"Send to this agent",className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--brand-solid)] text-[var(--brand-foreground)] transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40",children:s?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(_A,{className:"size-3.5","aria-hidden":"true"})})]}),x[t.task_id]&&(0,eI.jsx)("p",{className:"mt-1 text-[var(--color-error)]",role:"status","aria-live":"polite",children:x[t.task_id]})]}))]})]})]},t.task_id)})})]})}function RS({onClose:e,onReportToMainChat:t}){let[r,n]=e$("inspectorTab"),a="agents"===r?"agents":"workspace";return(0,eI.jsxs)("div",{className:"flex h-full flex-col border-l border-border bg-sidebar",children:[(0,eI.jsxs)("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 border-b border-border px-2",children:[(0,eI.jsxs)("div",{role:"tablist","aria-label":"Inspector",className:"flex items-center gap-1",children:[(0,eI.jsxs)("button",{type:"button",role:"tab","aria-selected":"workspace"===a,onClick:()=>n(null),className:nf("flex items-center gap-1.5 rounded-md px-2 py-1 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","workspace"===a?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,eI.jsx)(_R,{className:"size-4 text-[var(--brand)]","aria-hidden":"true"}),"Workspace"]}),(0,eI.jsxs)("button",{type:"button",role:"tab","aria-selected":"agents"===a,onClick:()=>n("agents"),className:nf("flex items-center gap-1.5 rounded-md px-2 py-1 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","agents"===a?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,eI.jsx)(_U,{className:"size-4 text-[var(--brand)]","aria-hidden":"true"}),"Agents"]})]}),(0,eI.jsx)(nP,{variant:"ghost",size:"icon",className:"size-7",onClick:e,"aria-label":"Close inspector",title:"Close",children:(0,eI.jsx)(rF,{className:"size-4","aria-hidden":"true"})})]}),"agents"===a?(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden p-3",children:(0,eI.jsx)(RT,{onReportToMainChat:t})}):(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:(0,eI.jsx)(Ry,{})})]})}function Rw({config:e,configDialogOpen:t,setConfigDialogOpen:r,handleSaveConfig:n}){let a=ao(),[i,s]=e$("threadId"),[o,l]=e$("sidebar"),[c,u]=e$("view"),[d,p]=e$("memoryTab"),[m,h]=e$("memoryObs"),[f,g]=e$("memoryExec"),[b,y]=e$("inspector"),[E,_]=e$("inspectorTab"),[v,x]=(0,eC.useState)(null),[T,S]=(0,eC.useState)(0),[w,k]=(0,eC.useState)(null),[A,N]=(0,eC.useState)(null),[I,C]=(0,eC.useState)(0),[R,O]=(0,eC.useState)(null),L=(0,eC.useCallback)(async()=>{let t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e.assistantId),r=async()=>{if(t)return await a.assistants.get(e.assistantId);let r=await a.assistants.search({graphId:e.assistantId,limit:100}),n=r.find(e=>e.metadata?.created_by==="system")??r[0];if(!n)throw Error("No assistant found for this graph.");return n};for(let e=0;e<3;e+=1)try{k(await r());return}catch(t){if(e<2){await new Promise(e=>setTimeout(e,700));continue}console.warn("Couldn't resolve the EvoScientist assistant; addressing the graph by id instead. Is the backend running?",t)}k({assistant_id:e.assistantId,graph_id:e.assistantId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),config:{},metadata:{},version:1,name:e.assistantId,context:{}})},[a,e.assistantId]);(0,eC.useEffect)(()=>{L()},[L]),(0,eC.useEffect)(()=>{let e=window.matchMedia("(min-width: 768px)"),t=()=>N(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,eC.useEffect)(()=>{!1===A&&o&&b&&y(null)},[b,A,y,o]);let D=(0,eC.useCallback)(()=>l(null),[l]),P=(0,eC.useCallback)(()=>{y(null),_(null)},[y,_]),M=(0,eC.useCallback)(()=>{o?l(null):(!1===A&&P(),l("1"))},[P,A,l,o]),j=(0,eC.useCallback)(()=>{b?P():(!1===A&&l(null),_(null),y("1"))},[P,b,A,y,_,l]),F=(0,eC.useCallback)(()=>{_("agents"),!1===A&&l(null),y("1")},[A,y,l,_]),U=c?o?"Hide navigation":"Show navigation":o?"Hide research":"Show research",B=(0,eC.useCallback)(()=>{Iz(null,!1),s(null),u(null),C(e=>e+1)},[s,u]),$=(0,eC.useCallback)(e=>{if("memory"===e.view)p(e.tab),h(e.obsId??null),g(e.execId??null),u("memory");else if("schedule"===e.view)u("schedule");else{if(b&&"agents"!==E)return void P();!1===A&&l(null),_(null),y("1")}},[P,b,E,A,y,_,g,h,p,l,u]),z=(0,eC.useCallback)(async e=>{Iz(null,!1),u(null);let t=i===e;await s(e),t||C(e=>e+1)},[s,u,i]);return(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nG,{open:t,onOpenChange:r,onSave:n,initialConfig:e}),(0,eI.jsxs)("div",{className:"flex h-screen flex-col",children:[(0,eI.jsxs)("header",{className:"flex h-14 items-center justify-between gap-2 border-b border-border px-2.5 sm:px-4",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2 sm:gap-3",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)(eR.default,{src:"/evoscientist-logo.png",alt:"EvoScientist",width:28,height:28,className:"size-6 shrink-0",priority:!0}),o&&(0,eI.jsx)("h1",{className:"truncate text-base font-semibold sm:text-lg",children:"EvoScientist"})]}),(0,eI.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,eI.jsxs)(nP,{variant:"ghost",size:"icon",onClick:M,"aria-label":U,className:"relative size-8",children:[o?(0,eI.jsx)(ad,{className:"size-5","aria-hidden":"true"}):(0,eI.jsx)(au,{className:"size-5","aria-hidden":"true"}),T>0&&(0,eI.jsx)("span",{className:"absolute right-0 top-0 inline-flex min-h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-destructive-foreground",children:T})]}),!o&&(0,eI.jsx)(nP,{variant:"ghost",size:"icon",onClick:B,"aria-label":"New chat",className:"size-8",children:(0,eI.jsx)(ac,{className:"size-5","aria-hidden":"true"})})]})]}),(0,eI.jsxs)("div",{className:"flex shrink-0 items-center gap-1 sm:gap-2",children:[(0,eI.jsx)(Rd,{deploymentUrl:e.deploymentUrl,onReconnect:t=>n({...e,deploymentUrl:t})}),(0,eI.jsx)(Ro,{}),(0,eI.jsx)(nP,{variant:"ghost",size:"icon",onClick:j,"aria-label":b?"Hide inspector":"Show workspace",title:b?"Hide inspector":"Show workspace",className:"size-8",children:b?(0,eI.jsx)(am,{className:"size-5","aria-hidden":"true"}):(0,eI.jsx)(ap,{className:"size-5","aria-hidden":"true"})}),(0,eI.jsx)(nP,{variant:"ghost",size:"icon",onClick:()=>r(!0),"aria-label":"Settings",title:"Settings",className:"size-8",children:(0,eI.jsx)(al,{className:"size-5","aria-hidden":"true"})})]})]}),(0,eI.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[o&&!1===A&&(0,eI.jsxs)("div",{className:"absolute inset-0 z-40 flex md:hidden",children:[(0,eI.jsx)("button",{type:"button","aria-label":"Close research",className:"absolute inset-0 bg-black/40",onClick:D}),(0,eI.jsx)("aside",{"aria-label":c?"Navigation":"Research navigation",className:"relative z-10 h-full w-[min(19rem,calc(100vw-2.25rem))] bg-background shadow-xl",children:(0,eI.jsx)(ui,{onClose:D,onNewChat:B,onThreadSelect:async e=>{await z(e),D()},onMutateReady:e=>x(()=>e),onInterruptCountChange:S})})]}),b&&!1===A&&(0,eI.jsxs)("div",{className:"absolute inset-0 z-40 flex justify-end md:hidden",children:[(0,eI.jsx)("button",{type:"button","aria-label":"Close inspector",className:"absolute inset-0 bg-black/40",onClick:P}),(0,eI.jsx)("aside",{"aria-label":"Inspector",className:"relative z-10 h-full w-[min(22rem,calc(100vw-2.25rem))] bg-background shadow-xl",children:(0,eI.jsx)(RS,{onClose:P,onReportToMainChat:R})})]}),(0,eI.jsxs)(iS,{direction:"horizontal",autoSaveId:"evoscientist-chat",children:[o&&A&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(ak,{id:"thread-history",order:1,defaultSize:23,minSize:18,className:"relative min-w-[260px]",children:(0,eI.jsx)(ui,{onNewChat:B,onThreadSelect:z,onMutateReady:e=>x(()=>e),onInterruptCountChange:S})}),(0,eI.jsx)(iw,{})]}),(0,eI.jsxs)(ak,{id:"chat",className:"relative flex flex-col",order:2,children:[(0,eI.jsx)("div",{className:nf("flex h-full min-h-0 flex-1 flex-col",null!==c&&"hidden"),children:(0,eI.jsx)(_T,{activeAssistant:w,onHistoryRevalidate:()=>v?.(),children:(0,eI.jsx)(Cf,{assistant:w,onShowAgents:F,onNotifyReady:e=>O(()=>e),onNavigate:$,onOpenThread:z,workspaceOpen:!!(b&&"agents"!==E)})},I)}),"skills"===c&&(0,eI.jsx)(C_,{}),"memory"===c&&(0,eI.jsx)(CH,{initialTab:d,initialObsId:m,initialExecId:f}),"schedule"===c&&(0,eI.jsx)(Ra,{})]}),b&&A&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(iw,{}),(0,eI.jsx)(ak,{id:"inspector",order:3,defaultSize:26,minSize:20,className:"relative min-w-[300px]",children:(0,eI.jsx)(RS,{onClose:P,onReportToMainChat:R})})]})]})]})]})]})}function Rk(){let[e,t]=(0,eC.useState)(null),[r,n]=(0,eC.useState)(!1),[a,i]=e$("assistantId");(0,eC.useEffect)(()=>{let e=eG();e?(t(e),a||i(e.assistantId)):n(!0)},[]),(0,eC.useEffect)(()=>{e&&!a&&i(e.assistantId)},[e,a,i]);let s=(0,eC.useCallback)(e=>{localStorage.setItem(eH,JSON.stringify(e)),t(e)},[]),o=e?.langsmithApiKey||eN.default.env.NEXT_PUBLIC_LANGSMITH_API_KEY||"";return e?(0,eI.jsx)(as,{deploymentUrl:e.deploymentUrl,apiKey:o,children:(0,eI.jsx)(Rw,{config:e,configDialogOpen:r,setConfigDialogOpen:n,handleSaveConfig:s})}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nG,{open:r,onOpenChange:n,onSave:s}),(0,eI.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,eI.jsxs)("div",{className:"text-center",children:[(0,eI.jsx)("h1",{className:"text-2xl font-bold",children:"Welcome to EvoScientist"}),(0,eI.jsx)("p",{className:"mt-2 text-muted-foreground",children:"Configure your deployment to get started"}),(0,eI.jsx)(nP,{onClick:()=>n(!0),className:"mt-4",children:"Open Configuration"})]})})]})}e.s(["default",0,function(){return(0,eI.jsx)(eC.Suspense,{fallback:(0,eI.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,eI.jsx)("p",{className:"text-muted-foreground",children:"Loading…"})}),children:(0,eI.jsx)(Rk,{})})}],952683)}]);
|
|
73
|
+
${t.map(e=>`- ${e.path}`).join("\n")}`:"";return`${e}${r}`}let Ch=(e,t)=>{switch(e){case"completed":return(0,eI.jsx)(_N,{size:16,className:nf("text-[var(--color-success)]",t)});case"in_progress":return(0,eI.jsx)(iA,{size:16,className:nf("text-[var(--color-warning)]",t)});default:return(0,eI.jsx)(_I,{size:16,className:nf("text-[var(--color-text-tertiary)]",t)})}},Cf=eC.default.memo(({assistant:e,onShowAgents:t,onNotifyReady:r,onNavigate:n,onOpenThread:a,workspaceOpen:i})=>{let s,o,l,c,u,d,[p,m]=(0,eC.useState)(null),h=(0,eC.useRef)(null),f=(0,eC.useRef)(null),g=(0,eC.useRef)(null),[b,y]=(0,eC.useState)(""),[E,_]=(0,eC.useState)([]),[v,x]=(0,eC.useState)(!1),[T,S]=(0,eC.useState)(null);(0,eC.useEffect)(()=>{let e=!1;return fetch("/api/workspace").then(e=>e.ok?e.json():null).then(t=>{!e&&t?.dir&&S(t.dir)}).catch(()=>{}),()=>{e=!0}},[]);let[w,k]=(0,eC.useState)([]),A=(0,eC.useRef)(w);A.current=w;let N=(0,eC.useRef)(0),I=(0,eC.useRef)(null),[C]=e$("threadId"),[R,O]=(0,eC.useState)(null),[L,D]=(0,eC.useState)(null);(0,eC.useEffect)(()=>{let e=e=>{let t=e.detail;t&&("memory"===t.kind?D(t.path):O(t.path))};return window.addEventListener(NK,e),()=>window.removeEventListener(NK,e)},[]);let[P,M]=(0,eC.useState)(()=>I$(C)),[j,F]=(0,eC.useState)(!1),[U,B]=(0,eC.useState)(!1),[$,z]=(0,eC.useState)("");(0,eC.useEffect)(()=>{U&&z("")},[U]);let{registry:H,loading:G,error:q}=function(){let[e,t]=(0,eC.useState)(Cu),[r,n]=(0,eC.useState)(!0),[a,i]=(0,eC.useState)(null);return(0,eC.useEffect)(()=>{let e=eG();if(!e)return void n(!1);let r=!1,a=e.langsmithApiKey||eN.default.env.NEXT_PUBLIC_LANGSMITH_API_KEY||"";return(function(e,t){let r=e.replace(/\/$/,""),n=Cd.get(r);if(n)return n;let a={};t&&(a["X-Api-Key"]=t);let i=fetch(`${r}/api/models`,{headers:a}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json(),r=[];if(Array.isArray(t.entries))for(let e of t.entries)e&&"object"==typeof e&&"string"==typeof e.name&&"string"==typeof e.provider&&e.name&&e.provider&&r.push({name:e.name,model_id:"string"==typeof e.model_id?e.model_id:e.name,provider:e.provider});let n=null;if(t.default&&"object"==typeof t.default){let e=t.default;"string"==typeof e.name&&e.name&&(n={name:e.name,provider:"string"==typeof e.provider&&e.provider?e.provider:null})}return{entries:r,defaultEntry:n}}).catch(e=>{throw Cd.delete(r),e});return Cd.set(r,i),i})(e.deploymentUrl,a).then(e=>{r||(t(e),i(null))}).catch(e=>{r||(i(e instanceof Error?e.message:"Failed to load models."),t(Cu))}).finally(()=>{r||n(!1)}),()=>{r=!0}},[]),{registry:e,loading:r,error:a}}(),V=!G&&0===H.entries.length;(0,eC.useEffect)(()=>{V&&console.warn("[model picker] using curated fallback list — registry fetch failed or empty",q??"(no error message)")},[V,q]);let W=(0,eC.useMemo)(()=>H.entries.length>0?H.entries.map(e=>({model:e.name,model_provider:e.provider})):__.map(e=>({model:e.model,model_provider:e.model_provider})),[H.entries]),Y=(0,eC.useMemo)(()=>{let e=$.trim().toLowerCase();return e?W.filter(t=>{let r=t.model_provider??"";return t.model.toLowerCase().includes(e)||r.toLowerCase().includes(e)}):W},[W,$]),K=(0,eC.useRef)(null),Z=(0,eC.useRef)(C),X=(0,eC.useRef)(!1),{scrollRef:Q,contentRef:J,scrollToBottom:ee,isAtBottom:et}=((e={})=>{let[t,r]=(0,eC.useState)(!1),[n,a]=(0,eC.useState)(!1!==e.initial),[i,s]=(0,eC.useState)(!1),o=(0,eC.useRef)(null);o.current=e;let l=(0,eC.useCallback)(()=>{if(!I2)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),c=(0,eC.useCallback)(e=>{d.isAtBottom=e,a(e)},[]),u=(0,eC.useCallback)(e=>{d.escapedFromLock=e,r(e)},[]),d=(0,eC.useMemo)(()=>{let r;return{escapedFromLock:t,isAtBottom:n,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(scrollTop){if(g.current){let{scrollBehavior:e}=getComputedStyle(g.current);"auto"!==e&&(g.current.style.scrollBehavior="auto"),g.current.scrollTop=scrollTop,d.ignoreScrollToTop=g.current.scrollTop,"auto"!==e&&(g.current.style.scrollBehavior=e)}},get targetScrollTop(){if(!g.current||!b.current)return 0;return g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!b.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(r?.targetScrollTop===t)return r.calculatedScrollTop;let n=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:b.current}),t),0);return r={targetScrollTop:t,calculatedScrollTop:n},requestAnimationFrame(()=>{r=void 0}),n},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),p=(0,eC.useCallback)((e={})=>{let t;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||c(!0);let r=Date.now()+(Number(e.wait)||0),n=I5(o.current,e.animation),{ignoreEscapes:a=!1}=e,i=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{t=Date.now()}):t=r+(e.duration??0);let s=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:c}=d,u=performance.now(),m=(u-(d.lastTick??u))/I1;if(d.animation||(d.animation={behavior:n,promise:e,ignoreEscapes:a}),d.animation.behavior===n&&(d.lastTick=u),l()||r>Date.now())return s();if(c<Math.min(i,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if("instant"===n)return d.scrollTop=d.calculatedTargetScrollTop,s();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*m,d.scrollTop+=d.accumulated,d.scrollTop!==c&&(d.accumulated=0)}return s()}return t>Date.now()?(i=d.calculatedTargetScrollTop,s()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop)?p({animation:I5(o.current,o.current.resize),ignoreEscapes:a,duration:Math.max(0,t-Date.now())||void 0}):d.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return(!0!==e.wait&&(d.animation=void 0),d.animation?.behavior===n)?d.animation.promise:s()},[c,l,d]),m=(0,eC.useCallback)(()=>{u(!0),c(!1)},[u,c]),h=(0,eC.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:r}=d,{lastScrollTop:n=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,r&&r>t&&(n=r),s(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===r)return;if(l()){u(!0),c(!1);return}let e=t>n,a=t<n;if(d.animation?.ignoreEscapes){d.scrollTop=n;return}a&&(u(!0),c(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,l,d]),f=(0,eC.useCallback)(({target:e,deltaY:t})=>{let r=e;for(;!["scroll","auto"].includes(getComputedStyle(r).overflow);){if(!r.parentElement)return;r=r.parentElement}r===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),g=I4(e=>{g.current?.removeEventListener("scroll",h),g.current?.removeEventListener("wheel",f),e?.addEventListener("scroll",h,{passive:!0}),e?.addEventListener("wheel",f,{passive:!0})},[]),b=I4(e=>{let t;d.resizeObserver?.disconnect(),e&&(d.resizeObserver=new ResizeObserver(([e])=>{let{height:r}=e.contentRect,n=r-(t??r);if(d.resizeDifference=n,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),s(d.isNearBottom),n>=0){let e=I5(o.current,t?o.current.resize:o.current.initial);p({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else d.isNearBottom&&(u(!1),c(!0));t=r,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===n&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e))},[]);return{contentRef:b,scrollRef:g,scrollToBottom:p,stopScroll:m,isAtBottom:n||i,isNearBottom:i,escapedFromLock:t,state:d}})(),{stream:er,messages:en,todos:ea,files:ei,ui:es,setFiles:eo,isLoading:el,isThreadLoading:ec,interrupt:eu,sendMessage:ed,stopStream:ep,resumeInterrupt:em,subAgentActivity:eh,asyncTasks:ef,summarizationEvent:eg,modelOverride:eb,setModelOverride:ey}=_w(),{tasks:eE}=IH(C,{enabled:Object.keys(ef??{}).length>0}),e_=(0,eC.useMemo)(()=>Ia(eE),[eE]),[ev]=IJ(C),ex=(0,eC.useRef)(!1);(0,eC.useEffect)(()=>{ex.current=!1},[C]),(0,eC.useEffect)(()=>{el&&(ex.current=!1)},[el]),(0,eC.useEffect)(()=>{var e;if(!eE||0===eE.length||!C||!ev)return;if(!(C&&IY()[C]?.initialized===!0))return void IX(C,eE.filter(e=>In(e.liveStatus)).map(N8));if(el||ex.current||b.trim()||w.length>0)return;let t=function(e){if(!e)return new Set;let t=IY()[e];return new Set(Array.isArray(t?.keys)?t.keys:[])}(C);for(let r of eE){if(!In(r.liveStatus))continue;let n=N8(r);if(!t.has(n)){if(en.some(e=>"human"===e.type&&Ie(_y(e),r))){IQ(C,n);continue}ex.current=!0,IQ(C,n),ed(It(r)),c6.toast.success(`Auto-reported ${N6[e=r.agent_name]??e} to the main chat.`);break}}},[eE,ev,el,b,en,ed,C,w]),(0,eC.useEffect)(()=>{el&&ee()},[el,ee]);let eT=(0,eC.useRef)({sendMessage:ed,isLoading:el,messages:en,threadId:C});eT.current={sendMessage:ed,isLoading:el,messages:en,threadId:C};let eS=(0,eC.useRef)(r);eS.current=r,(0,eC.useEffect)(()=>(eS.current?.((e,t)=>{let r=eT.current;return r.threadId!==t?"wrong-thread":r.isLoading?"busy":r.messages.some(t=>"human"===t.type&&Ie(_y(t),e))?"duplicate":(IQ(t,N8(e)),r.sendMessage(It(e)),"sent")}),()=>eS.current?.(null)),[]);let ew=(0,eC.useMemo)(()=>{if(eb)return IM(eb.model,eb.model_provider);if(H.defaultEntry)return IM(H.defaultEntry.name,H.defaultEntry.provider??void 0);let t=e?.config,r=t?.configurable;if(r){let e=IM(r.model??r.model_name,r.model_provider);if(e)return e}for(let e=en.length-1;e>=0;e--){let t=en[e];if("ai"!==t.type)continue;let r=t.response_metadata,n=IM(r?.model_name??r?.model,r?.model_provider);if(n)return n}return null},[en,eb,e?.config,H.defaultEntry]),ek=(0,eC.useMemo)(()=>{let e={},t=Object.keys(eh);if(0===t.length)return e;let r=[],n={};for(let e of en)if("ai"===e.type)for(let t of e.tool_calls??[])"task"===t.name&&t.id&&r.push(t.id);else if("tool"===e.type){let t=e.tool_call_id;t&&(n[t]=_y(e))}let a=e=>e.replace(/\s+/g," ").trim(),i=new Set;for(let s of r){let r=a(n[s]??"");if(!r)continue;let o=t.find(e=>{if(i.has(e))return!1;let t=a(function(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if("text"===r.kind)return r.text}return""}(eh[e]));return""!==t&&(r.includes(t)||t.includes(r))});o&&(e[s]=eh[o],i.add(o))}let s=t.filter(e=>!i.has(e)),o=0;for(let t of r)e[t]||n[t]||o<s.length&&(e[t]=eh[s[o++]]);return e},[en,eh]),eA=eu?.value,eR=eA?.type==="ask_user"||Array.isArray(eA?.action_requests)&&eA.action_requests.length>0,eO=el||!e||eR;(0,eC.useEffect)(()=>{if(el||eR||ex.current||0===w.length)return;let[e,...t]=w;e.threadId===C&&(ex.current=!0,k(t),ed(Cm(e.text,e.files)))},[el,eR,w,ed,C]);let eL=(0,eC.useRef)(C);(0,eC.useEffect)(()=>{let e=eL.current;(eL.current=C,null===e&&null!==C)?k(e=>e.map(e=>null===e.threadId?{...e,threadId:C}:e)):e!==C&&k([])},[C]);let eD=(0,eC.useCallback)(()=>{M(!0),Iz(C,!0),F(!1)},[C]),eP=(0,eC.useCallback)(()=>{M(!1),Iz(C,!1),F(!1),K.current=null},[C]);(0,eC.useEffect)(()=>{let e=Z.current;if(e!==C){if(null===e&&null!==C&&X.current){let e;(e=IU())[IF]&&(e[C]=!0),IF in e&&(delete e[IF],IB(e))}else null===e&&null!==C&&Iz(null,!1);M(I$(C)),K.current=null,F(!1),_([]),X.current=!1,Z.current=C}},[C]);let eM=(0,eC.useCallback)(async e=>{let t=Array.from(e.target.files??[]);if(e.target.value="",0!==t.length){x(!0);try{let e=new FormData;t.forEach(t=>e.append("files",t));let r=await fetch("/api/workspace/upload",{method:"POST",body:e}),n=await r.json();if(!r.ok||!n.files)throw Error(n.error||"Failed to upload files.");_(e=>[...e,...n.files]),c6.toast.success(`${n.files.length} file${1===n.files.length?"":"s"} uploaded to the workspace.`)}catch(e){c6.toast.error(e instanceof Error?e.message:"Failed to upload files.")}finally{x(!1)}}},[]),ej=(0,eC.useCallback)(e=>{_(t=>t.filter(t=>t.path!==e))},[]),eF=(0,eC.useCallback)(async e=>{if(e){if("show"===e.kind)return void B(!0);try{if("reset"===e.kind)await ey(null),c6.toast.success("Model override cleared.");else{let t={model:e.model,...e.provider?{model_provider:e.provider}:{}};await ey(t),c6.toast.success(`Model set to ${e.model}${e.provider?` (${e.provider})`:""}.`)}}catch(e){c6.toast.error(e instanceof Error?`Couldn't update model: ${e.message}`:"Couldn't update model — try again.")}}},[ey]),eU=(0,eC.useCallback)(t=>{t&&t.preventDefault();let r=b.trim();if(!r)return;let n=function(e){let t=e.trim();if("/model"!==t&&!t.startsWith("/model "))return null;let r=t.slice(6).trim();if(!r)return{kind:"show"};let n=r.split(/\s+/);return"reset"===n[0].toLowerCase()&&1===n.length?{kind:"reset"}:n.length>2?null:{kind:"set",model:n[0],provider:n[1]}}(r);if(n){eF(n),y("");return}if(e&&!eR&&!v){if(el){k(e=>[...e,{id:N.current+=1,text:r,files:E,threadId:C}]),y(""),_([]);return}X.current=null===C&&P,ed(Cm(r,E)),y(""),_([])}},[b,eF,e,eR,P,el,v,E,ed,C]),eB=(0,eC.useCallback)(e=>{let t=A.current.find(t=>t.id===e);t&&(k(t=>t.filter(t=>t.id!==e)),y(t.text),_(t.files),requestAnimationFrame(()=>{let e=f.current;e&&(e.focus(),e.setSelectionRange(t.text.length,t.text.length))}))},[]),ez=(0,eC.useCallback)(e=>{k(t=>{let r=t.find(t=>t.id===e);return r&&t[0]?.id!==e?[r,...t.filter(t=>t.id!==e)]:t}),c6.toast.info("This message will run next without interrupting the current turn.")},[]),eH=(0,eC.useCallback)((e,t)=>{k(r=>{let n=r.findIndex(t=>t.id===e),a=n+t;if(n<0||a<0||a>=r.length)return r;let i=[...r],[s]=i.splice(n,1);return i.splice(a,0,s),i})},[]),eq=(0,eC.useCallback)(e=>{let t=I.current;I.current=null,null!==t&&t!==e&&k(r=>{let n=r.findIndex(e=>e.id===t),a=r.findIndex(t=>t.id===e);if(n<0||a<0)return r;let i=[...r],[s]=i.splice(n,1);return i.splice(a,0,s),i})},[]),eV=(0,eC.useCallback)(e=>{k(t=>t.filter(t=>t.id!==e))},[]),eW=(0,eC.useCallback)(()=>{k([])},[]),eY=(0,eC.useCallback)(e=>{if(!eR&&!e.nativeEvent.isComposing&&229!==e.keyCode){if("ArrowUp"===e.key&&0===b.length&&A.current.length>0){e.preventDefault();let t=A.current;eB(t[t.length-1].id);return}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),eU())}},[eU,eR,b,eB]),eK=(0,eC.useCallback)(e=>{y(e),requestAnimationFrame(()=>{let t=f.current;t&&(t.focus(),t.setSelectionRange(e.length,e.length))})},[]),eZ=(0,eC.useCallback)(e=>{y(e),requestAnimationFrame(()=>f.current?.focus())},[]);(0,eC.useEffect)(()=>{if(!P)return;let e=eu?.value&&eu.value.action_requests;if(!eu||!Array.isArray(e)||0===e.length){K.current=null;return}K.current!==eu&&(K.current=eu,em({decisions:e.map(()=>({type:"approve"}))}))},[P,eu,em]);let eX=(0,eC.useMemo)(()=>{let e=eu?.value;return e?.type==="ask_user"&&Array.isArray(e.questions)?e.questions:null},[eu]),eQ=(0,eC.useCallback)(e=>{em({status:"answered",answers:e})},[em]),eJ=(0,eC.useCallback)(()=>{em({status:"cancelled"})},[em]),e0=(0,eC.useMemo)(()=>{let e=eu?.value&&eu.value.action_requests;return Array.isArray(e)?e:[]},[eu]),e1=(0,eC.useMemo)(()=>{let e=new Map,t=new Set,r=en.filter(e=>{if("human"===e.type){let r,n=(r=N7(_y(e)))?`${r.taskId}:${r.runId||"legacy"}`:null;return!n||!t.has(n)&&(t.add(n),!0)}let r=er.getMessagesMetadata(e)?.streamMetadata,n=r?.langgraph_checkpoint_ns;return!("string"==typeof n&&n.includes("|")||function(e){if("human"===e.type){var t;if("human"!==e.type)return!1;let r=e.additional_kwargs;return r?.lc_source==="summarization"}return"ai"===e.type&&!!(t=_y(e))&&(!!(/\bconversation that has been summarized\b/.test(t)||/\bHere is a summary of the conversation to date\b/.test(t)||/<summary>[\s\S]*<\/summary>/.test(t))||/##\s+SESSION INTENT\b/.test(t))}(e))}),n=new Set;for(let e of r){if("tool"!==e.type)continue;let t=e.tool_call_id;t&&n.add(t)}let a=new Map;for(let e of e0)a.set(e.name,(a.get(e.name)??0)+1);r.forEach(t=>{if("ai"===t.type){let r,i=(r=[],t.additional_kwargs?.tool_calls&&Array.isArray(t.additional_kwargs.tool_calls)?r.push(...t.additional_kwargs.tool_calls):t.tool_calls&&Array.isArray(t.tool_calls)?r.push(...t.tool_calls.filter(e=>""!==e.name)):Array.isArray(t.content)&&r.push(...t.content.filter(e=>"tool_use"===e.type)),r.map(e=>{let t=e.function?.arguments||e.args||e.input||{};return{id:e.id,name:e.function?.name||e.name||e.type||"",args:function(e){if(e&&"object"==typeof e)return e;if("string"!=typeof e)return{};try{let t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch{return{}}}(t)}})).filter(e=>"ToolSelectionResponse"!==e.name||el&&!eu).map((e,r)=>{let i=e.name||"unknown",s=e.id||`${t.id??"ai-message"}-tool-${r}-${i}`,o=a.get(i)??0,l=o>0&&!n.has(s);return l&&a.set(i,o-1),{id:s,name:i,args:e.args,status:l?"interrupted":"pending"}});e.set(t.id,{message:t,toolCalls:i})}else if("tool"===t.type){let r=t.tool_call_id;if(!r)return;for(let[,n]of e.entries()){let e=n.toolCalls.findIndex(e=>e.id===r);if(-1!==e){n.toolCalls[e]={...n.toolCalls[e],status:"completed",result:_y(t)};break}}}else"human"===t.type&&e.set(t.id,{message:t,toolCalls:[]})});let i=Array.from(e.values());return i.map((e,t)=>{let r=t>0?i[t-1].message:null;return{...e,showAvatar:e.message.type!==r?.type}})},[en,e0,eu,el,er]),{value:e2}=nH(),e4=e=>{let t=e.content;if("string"==typeof t)return t.trim().length>0;if(Array.isArray(t))for(let e of t){let t=e?.text;if("string"==typeof t&&t.trim().length>0)return!0}return!1},e3=(0,eC.useMemo)(()=>{let e=[];for(let t of e1)if("ai"===t.message.type&&t.toolCalls.length>0&&!e4(t.message)){let r=e[e.length-1];r?.kind==="action-group"?r.items.push(t):e.push({kind:"action-group",items:[t]})}else e.push({kind:"message",data:t});return e},[e1]),e5=e1.length>0?e1[e1.length-1].message.id:void 0,e6=(0,eC.useMemo)(()=>{if(!eg)return null;let e=new Set(e1.map(e=>e.message.id));for(let t=eg.cutoffIndex;t<en.length;t++){let r=en[t]?.id;if(null!=r&&e.has(r))return r}return null},[eg,en,e1]),e9={in_progress:ea.filter(e=>"in_progress"===e.status),pending:ea.filter(e=>"pending"===e.status),completed:ea.filter(e=>"completed"===e.status)},e8=ea.length>0,e7=Object.keys(ei).length>0,[te,tt]=(0,eC.useState)(()=>new Set);(0,eC.useEffect)(()=>{0===e0.length&&tt(new Set)},[e0.length]);let tr=(0,eC.useCallback)(e=>{tt(t=>{let r=new Set(t);return r.add(e),r})},[]),tn=(0,eC.useMemo)(()=>{let e=eu?.value&&eu.value.review_configs;if(!Array.isArray(e))return new Map;let t=[];for(let r of e){let e=r.actionName??r.action_name;e&&t.push([e,{actionName:e,allowedDecisions:r.allowedDecisions??r.allowed_decisions}])}return new Map(t)},[eu]);return(0,eI.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,eI.jsx)(ng,{open:j,onOpenChange:F,children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Enable Auto-approve?"}),(0,eI.jsx)(nT,{children:"EvoScientist will run tool actions in this research without asking you to review each one. Turn this on only when you trust the current task and deployment."})]}),(0,eI.jsxs)("div",{className:"flex items-start gap-3 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100",children:[(0,eI.jsx)(_D,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),(0,eI.jsx)("p",{children:"Auto-approve stays on for this research only — it follows this conversation across views and reloads, and other research keeps its own setting. Turn it off here anytime."})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),(0,eI.jsx)(nP,{onClick:eD,className:"bg-amber-600 text-white hover:bg-amber-700",children:"Enable Auto-approve"})]})]})}),(0,eI.jsx)(Cl,{path:R,onClose:()=>O(null)}),(0,eI.jsx)(Cc,{path:L,onClose:()=>D(null)}),(0,eI.jsx)(ng,{open:U,onOpenChange:B,children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Pick a model for this chat"}),(0,eI.jsxs)(nT,{children:["The choice applies per-thread. Type"," ",(0,eI.jsx)("span",{className:"font-mono text-xs",children:"/model <name>"})," ","in the composer to use a name not in the list."]})]}),(0,eI.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,eI.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Current:"," ",(0,eI.jsx)("span",{className:"font-mono",children:ew?`${ew.name}${ew.provider?` (${ew.provider})`:""}`:"deployment default"}),G&&(0,eI.jsx)("span",{className:"ml-2 italic",children:"loading registry…"})]}),V&&(0,eI.jsxs)("div",{className:"border-[var(--color-warning)]/30 bg-[var(--color-warning)]/5 flex items-start gap-2 rounded-md border px-3 py-2 text-xs text-foreground",children:[(0,eI.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none text-[var(--color-warning)]",children:"⚠"}),(0,eI.jsxs)("span",{children:["Showing a curated subset — the deployment’s",(0,eI.jsx)("span",{className:"mx-1 font-mono",children:"/api/models"}),"registry didn’t load",q?` (${q})`:"",". Other short names still work via"," ",(0,eI.jsx)("span",{className:"font-mono",children:"/model <name>"}),"."]})]}),(0,eI.jsx)("input",{type:"text",value:$,onChange:e=>z(e.target.value),placeholder:"Filter by name or provider…",autoFocus:!0,className:"w-full rounded-md border border-border bg-background px-3 py-1.5 font-mono text-sm placeholder:font-sans placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),(0,eI.jsxs)("ul",{className:"max-h-72 space-y-1 overflow-y-auto pl-0",children:[0===Y.length&&(0,eI.jsxs)("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:["No models match “",$,"”."]}),Y.map(e=>{let t=eb?.model===e.model&&eb?.model_provider===e.model_provider,r=!eb&&H.defaultEntry?.name===e.model&&(H.defaultEntry?.provider??null)===(e.model_provider??null);return(0,eI.jsx)("li",{children:(0,eI.jsxs)("button",{type:"button",onClick:async()=>{try{await ey({model:e.model,...e.model_provider?{model_provider:e.model_provider}:{}}),c6.toast.success(`Model set to ${e.model}${e.model_provider?` (${e.model_provider})`:""}.`),B(!1)}catch(e){c6.toast.error(e instanceof Error?`Couldn't update model: ${e.message}`:"Couldn't update model — try again.")}},className:nf("flex w-full items-center justify-between rounded px-3 py-2 text-left text-sm transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",t&&"bg-accent"),children:[(0,eI.jsxs)("span",{className:"font-mono",children:[e.model,r&&(0,eI.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"· default"})]}),e.model_provider&&(0,eI.jsx)("span",{className:"text-xs text-muted-foreground",children:e.model_provider})]})},`${e.model}|${e.model_provider??""}`)})]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:async()=>{try{await ey(null),c6.toast.success("Model override cleared."),B(!1)}catch(e){c6.toast.error(e instanceof Error?`Couldn't clear override: ${e.message}`:"Couldn't clear override — try again.")}},disabled:!eb,children:"Reset to default"}),(0,eI.jsx)(nP,{onClick:()=>B(!1),children:"Close"})]})]})}),(0,eI.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden overscroll-contain",ref:Q,children:(0,eI.jsx)("div",{className:"mx-auto w-full max-w-[960px] px-4 pb-4 pt-3 sm:px-5",ref:J,children:ec?(0,eI.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,eI.jsx)("p",{className:"text-muted-foreground",children:"Loading…"})}):(0,eI.jsxs)(eI.Fragment,{children:[0===e1.length&&!el&&(0,eI.jsxs)("div",{className:"flex min-h-[42vh] flex-col items-center justify-center px-3 pt-12 text-center sm:pt-16",children:[(0,eI.jsx)("h2",{className:"text-pretty text-lg font-semibold sm:text-xl",children:"Where research evolves"}),(0,eI.jsx)("p",{className:"mt-2 max-w-lg text-sm text-muted-foreground",children:"Your self-evolving lab partner — reads the literature, runs experiments, and remembers what matters."}),(0,eI.jsx)("div",{className:"mt-4 flex max-w-2xl flex-wrap justify-center gap-2",children:Cp.map(e=>(0,eI.jsx)("button",{type:"button",onClick:()=>eZ(e),className:"max-w-full rounded-full border border-border bg-card px-2.5 py-1.5 text-xs text-foreground shadow-sm transition-colors hover:border-[var(--color-border)] hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring sm:text-sm",children:e},e))}),n&&a&&(0,eI.jsx)(IO,{onNavigate:n,onOpenThread:a})]}),e3.map((t,r)=>{if("action-group"===t.kind){let n=t.items[t.items.length-1].message.id,a=r===e3.length-1,i=el&&a&&n===e5;return(0,eI.jsx)(Id,{items:t.items,isStreaming:i,defaultCollapsed:e2,isAtBottom:et,lastMessageId:e5,isLoading:el,actionRequests:e0,submittedActionRequestKeys:te,onActionRequestSubmitted:tr,reviewConfigsMap:tn,stream:er,onResumeInterrupt:em,graphId:e?.graph_id,onEditMessage:eK,autoApprove:P,subAgentSteps:ek,ui:es,compactionAnchorId:e6,summarizationEvent:eg??null},`action-group-${t.items[0].message.id}`)}let n=t.data,a=es?.filter(e=>e.metadata?.message_id===n.message.id),i=r===e3.length-1,s="human"!==n.message.type,o=e6===n.message.id;return(0,eI.jsxs)(eC.default.Fragment,{children:[o&&eg&&(0,eI.jsx)(Iu,{content:eg.content,summarizedCount:eg.cutoffIndex}),(0,eI.jsx)(Il,{message:n.message,toolCalls:n.toolCalls,isLoading:el,isStreaming:el&&i&&s,actionRequests:i?e0:void 0,submittedActionRequestKeys:te,onActionRequestSubmitted:tr,reviewConfigsMap:i?tn:void 0,ui:a,stream:er,onResumeInterrupt:em,graphId:e?.graph_id,onEditMessage:eK,autoApprove:P,subAgentSteps:ek})]},n.message.id)}),eg&&!e6&&(0,eI.jsx)(Iu,{content:eg.content,summarizedCount:eg.cutoffIndex}),eX&&(0,eI.jsx)("div",{className:"mt-4",children:(0,eI.jsx)(IP,{questions:eX,onSubmit:eQ,onCancel:eJ,isLoading:el})})]})})}),(0,eI.jsxs)("div",{className:"flex-shrink-0 bg-background",children:[w.length>0&&(0,eI.jsx)("div",{"aria-label":"Queued messages",className:"relative mx-auto -mb-4 w-[calc(100%-16px)] max-w-[960px] px-2 sm:w-[calc(100%-24px)]",children:(0,eI.jsx)("div",{className:"rounded-b-lg rounded-t-2xl border border-border bg-background pb-5 pt-1 shadow-sm",children:w.map((e,t)=>{let r=b.trim().length>0||E.length>0;return(0,eI.jsxs)("div",{onDragOver:e=>e.preventDefault(),onDrop:()=>eq(e.id),className:"relative flex min-h-11 items-start gap-1.5 px-2 py-2 text-sm sm:gap-2 sm:px-3",children:[(0,eI.jsx)("button",{type:"button",draggable:!0,onDragStart:t=>{I.current=e.id,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",String(e.id))},onDragEnd:()=>{I.current=null},onKeyDown:r=>{"ArrowUp"===r.key&&t>0&&(r.preventDefault(),eH(e.id,-1)),"ArrowDown"===r.key&&t<w.length-1&&(r.preventDefault(),eH(e.id,1))},"aria-label":`Reorder queued message ${t+1} of ${w.length}`,title:"Drag to reorder, or use the arrow keys",className:"mt-0.5 inline-flex size-5 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground/60 focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",children:(0,eI.jsx)(ah,{className:"size-3.5","aria-hidden":"true"})}),(0,eI.jsx)(_M,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,eI.jsx)("span",{className:"line-clamp-2 whitespace-pre-wrap break-words pt-0.5 text-foreground",children:e.text}),e.files.length>0&&(0,eI.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[(0,eI.jsx)(_P,{className:"size-3 shrink-0","aria-hidden":"true"}),e.files.length," file",1===e.files.length?"":"s"]})]}),(0,eI.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>ez(e.id),"aria-label":"Steer with this message next",title:"Submit next without interrupting the current turn",className:"inline-flex h-7 items-center gap-1 rounded-full px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_M,{className:"size-3.5","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"Steer"})]}),(0,eI.jsx)("button",{type:"button",onClick:()=>eV(e.id),"aria-label":"Remove queued message",title:"Remove from queue",className:"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(iM,{className:"size-3.5","aria-hidden":"true"})}),(0,eI.jsxs)("details",{className:"group/menu relative",onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||e.currentTarget.removeAttribute("open")},onKeyDown:e=>{"Escape"===e.key&&(e.currentTarget.removeAttribute("open"),e.currentTarget.querySelector("summary")?.focus())},children:[(0,eI.jsx)("summary",{"aria-label":"More queued message actions",title:"More actions",className:"inline-flex size-7 cursor-pointer list-none items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden",children:(0,eI.jsx)(_j,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"absolute right-0 top-8 z-30 min-w-40 rounded-xl border border-border bg-background p-1.5 shadow-lg",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>eB(e.id),disabled:r,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40",children:[(0,eI.jsx)(iR,{className:"size-4","aria-hidden":"true"}),"Edit message"]}),(0,eI.jsxs)("button",{type:"button",onClick:eW,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_F,{className:"size-4","aria-hidden":"true"}),"Close queue"]})]})]})]})]},e.id)})})}),(0,eI.jsxs)("div",{className:nf("relative z-10 mx-auto mb-2 flex w-[calc(100%-16px)] max-w-[960px] flex-shrink-0 flex-col overflow-hidden rounded-xl border border-border bg-background transition-colors duration-200 ease-in-out sm:mb-4 sm:w-[calc(100%-24px)]","focus-within:ring-2 focus-within:ring-ring"),children:[(0,eI.jsxs)("div",{className:"flex max-h-60 flex-col overflow-y-auto border-b border-border bg-sidebar empty:hidden sm:max-h-72",children:[!p&&(0,eI.jsx)(eI.Fragment,{children:(s=ea.find(e=>"in_progress"===e.status),l=(o=ea.length)-e9.pending.length,c=o===l,u=e8?(0,eI.jsx)("button",{type:"button",onClick:()=>m(e=>"tasks"===e?null:"tasks"),className:"grid w-full cursor-pointer grid-cols-[auto_auto_1fr] items-center gap-2.5 px-3 py-2.5 text-left sm:px-4","aria-expanded":"tasks"===p,children:c?[(0,eI.jsx)(_N,{size:16,className:"text-[var(--color-success)]"},"icon"),(0,eI.jsx)("span",{className:"ml-[1px] min-w-0 truncate text-sm",children:"All tasks completed"},"label")]:null!=s?[(0,eI.jsx)("div",{children:Ch(s.status)},"icon"),(0,eI.jsxs)("span",{className:"ml-[1px] min-w-0 truncate text-sm",children:["Task"," ",o-e9.pending.length," ","of ",o]},"label"),(0,eI.jsx)("span",{className:"min-w-0 gap-2 truncate text-sm text-muted-foreground",children:s.content},"content")]:[(0,eI.jsx)(_I,{size:16,className:"text-[var(--color-text-tertiary)]"},"icon"),(0,eI.jsxs)("span",{className:"ml-[1px] min-w-0 truncate text-sm",children:["Task"," ",o-e9.pending.length," of"," ",o]},"label")]}):null,d=e7?(0,eI.jsxs)("button",{type:"button",onClick:()=>m(e=>"files"===e?null:"files"),className:"flex flex-shrink-0 cursor-pointer items-center gap-2 px-3 py-2.5 text-left text-sm sm:px-4","aria-expanded":"files"===p,children:[(0,eI.jsx)(_C,{size:16}),"Files (State)",(0,eI.jsx)("span",{className:"h-4 min-w-4 rounded-full bg-[var(--brand-solid)] px-0.5 text-center text-[10px] leading-[16px] text-[var(--brand-foreground)]",children:Object.keys(ei).length})]}):null,e8||e7?(0,eI.jsxs)("div",{className:"flex items-center",children:[(0,eI.jsx)("div",{className:"min-w-0 flex-1",children:u}),d]}):null)}),p&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)("div",{className:"sticky top-0 flex items-stretch bg-sidebar text-sm",children:[e8&&(0,eI.jsx)("button",{type:"button",className:"py-2.5 pr-4 first:pl-3 aria-expanded:font-semibold sm:first:pl-4",onClick:()=>m(e=>"tasks"===e?null:"tasks"),"aria-expanded":"tasks"===p,children:"Tasks"}),e7&&(0,eI.jsxs)("button",{type:"button",className:"inline-flex items-center gap-2 py-2.5 pr-4 first:pl-3 aria-expanded:font-semibold sm:first:pl-4",onClick:()=>m(e=>"files"===e?null:"files"),"aria-expanded":"files"===p,children:["Files (State)",(0,eI.jsx)("span",{className:"h-4 min-w-4 rounded-full bg-[var(--brand-solid)] px-0.5 text-center text-[10px] leading-[16px] text-[var(--brand-foreground)]",children:Object.keys(ei).length})]}),(0,eI.jsx)("button",{"aria-label":"Close",className:"flex-1",onClick:()=>m(null)})]}),(0,eI.jsxs)("div",{ref:h,className:"px-3 sm:px-4",children:["tasks"===p&&Object.entries(e9).filter(([e,t])=>t.length>0).map(([e,t])=>(0,eI.jsxs)("div",{className:"mb-4",children:[(0,eI.jsx)("h3",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-tertiary",children:{pending:"Pending",in_progress:"In Progress",completed:"Completed"}[e]}),(0,eI.jsx)("div",{className:"grid grid-cols-[auto_1fr] gap-3 rounded-sm p-1 pl-0 text-sm",children:t.map((t,r)=>(0,eI.jsxs)(eC.Fragment,{children:[Ch(t.status,"mt-0.5"),(0,eI.jsx)("span",{className:"break-words text-inherit",children:t.content})]},`${e}_${t.id}_${r}`))})]},e)),"files"===p&&(0,eI.jsx)("div",{className:"mb-6",children:(0,eI.jsx)(Cr,{files:ei,setFiles:eo,editDisabled:!0===el||void 0!==eu})})]})]})]}),P&&(0,eI.jsxs)("div",{"aria-live":"polite",className:"flex items-center justify-between gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100",children:[(0,eI.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,eI.jsx)(_D,{className:"size-3.5 shrink-0","aria-hidden":"true"}),"Tool actions will run without review."]}),(0,eI.jsx)("button",{type:"button",onClick:eP,className:"shrink-0 rounded px-2 py-1 font-semibold transition-colors hover:bg-amber-200 focus-visible:ring-2 focus-visible:ring-amber-700 dark:hover:bg-amber-900",children:"Turn Off"})]}),(ew||e_>0)&&(0,eI.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-border px-3 py-1.5 text-xs text-muted-foreground",children:[ew&&(0,eI.jsxs)("button",{type:"button",onClick:()=>B(!0),title:"Click to change model for this chat","aria-label":"Change model for this chat",className:"-mx-1 flex items-center gap-1.5 rounded px-1 py-0.5 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_L,{className:"size-3.5 shrink-0 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"font-medium text-foreground",children:ew.name}),ew.provider&&(0,eI.jsxs)("span",{children:["· ",ew.provider]})]}),e_>0&&(0,eI.jsxs)("button",{type:"button",onClick:t,title:`${e_} background agent${1===e_?"":"s"} running — click to view`,"aria-label":`${e_} background agent${1===e_?"":"s"} running — view`,className:"ml-auto flex shrink-0 items-center gap-1.5 rounded px-1.5 py-0.5 font-medium text-[var(--brand)] transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)("span",{className:"size-2 animate-pulse rounded-full bg-[var(--color-warning)]","aria-hidden":"true"}),e_," agent",1===e_?"":"s"]})]}),(0,eI.jsxs)("form",{onSubmit:eU,className:"flex flex-col",children:[E.length>0&&(0,eI.jsx)("div",{"aria-label":"Attached files",className:"flex flex-wrap gap-2 border-b border-border px-3 py-2",children:E.map(e=>(0,eI.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1 text-xs text-foreground",children:[(0,eI.jsx)(_C,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"max-w-48 truncate",title:e.path,children:e.name}),(0,eI.jsx)("button",{type:"button",onClick:()=>ej(e.path),"aria-label":`Remove ${e.name} from this message`,title:`Remove ${e.name} from this message`,className:"rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(rF,{className:"size-3.5","aria-hidden":"true"})})]},e.path))}),(0,eI.jsx)("textarea",{ref:f,value:b,onChange:e=>y(e.target.value),onKeyDown:eY,"aria-label":"Message",disabled:eR,placeholder:eR?"Respond to the request above to continue…":el?"Queue a follow-up — sends when this turn finishes…":"Ask EvoScientist anything…",className:"font-inherit field-sizing-content flex-1 resize-none border-0 bg-transparent px-3.5 pb-2.5 pt-3 text-sm leading-6 text-primary outline-none placeholder:text-tertiary disabled:cursor-not-allowed sm:px-4",rows:1}),(0,eI.jsxs)("div",{className:"flex items-center justify-between gap-2 p-2 sm:p-2.5",children:[(0,eI.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eI.jsx)("input",{ref:g,type:"file",multiple:!0,onChange:eM,disabled:!e||eR||v,className:"hidden"}),(0,eI.jsx)("button",{type:"button",onClick:()=>g.current?.click(),disabled:!e||eR||v,"aria-label":"Upload files to workspace",title:"Upload files to workspace (max 50 MB each)",className:"inline-flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:(0,eI.jsx)(_P,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("button",{type:"button",onClick:()=>P?eP():F(!0),"aria-pressed":P,title:"Auto-approve all tool actions in this conversation",className:nf("inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors",P?"bg-amber-600 text-white hover:bg-amber-700":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[(0,eI.jsx)(_O,{className:"size-3.5","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden min-[360px]:inline",children:P?"Auto-approve On":"Auto-approve"})]}),n&&T&&(0,eI.jsxs)("button",{type:"button",onClick:()=>n({view:"workspace"}),title:`${i?"Close":"Open"} workspace: ${T}`,"aria-label":`${i?"Close":"Open"} workspace: ${T}`,"aria-pressed":!!i,className:"inline-flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[(0,eI.jsx)(_R,{className:"size-3.5 flex-shrink-0","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden max-w-[140px] truncate font-mono sm:inline lg:max-w-[220px]",children:T.split("/").filter(Boolean).pop()||T})]})]}),(0,eI.jsx)("div",{className:"flex justify-end gap-2",children:(0,eI.jsx)(nP,{type:el?"button":"submit",variant:el?"destructive":"default",onClick:el?ep:eU,disabled:!el&&(eO||v||!b.trim()),"aria-label":el?"Stop generating":"Send message",children:el?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(_k,{size:14}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"Stop"})]}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(_A,{size:18}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"Send"})]})})})]})]})]})]})]})});Cf.displayName="ChatInterface";let Cg=rj("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),Cb=rj("circle-arrow-up",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]),Cy=rj("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),CE=eC.default.memo(({skill:e,onClose:t})=>{let[r,n]=(0,eC.useState)(null),[a,i]=(0,eC.useState)(!1),[s,o]=(0,eC.useState)(null);if((0,eC.useEffect)(()=>{if(!e)return;let t=!1;return n(null),o(null),i(!0),fetch(`/api/skills/detail?name=${encodeURIComponent(e.name)}`).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`Failed to load (${e.status})`);return t}).then(e=>{t||n(e)}).catch(e=>{t||o(e.message??"Failed to load skill detail.")}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),!e)return null;let l=r?.title??e.title,c=r?.version??e.version,u=r?.description??e.description,d=r?.installed??e.installed,p=r?.body;return(0,eI.jsx)(ng,{open:!0,onOpenChange:t,children:(0,eI.jsxs)(nE,{"aria-describedby":void 0,className:"flex h-[80vh] max-h-[80vh] min-w-[60vw] flex-col p-6",children:[(0,eI.jsx)(nx,{className:"sr-only",children:l}),(0,eI.jsxs)("div",{className:"mb-3 flex items-start gap-3 border-b border-border pb-4",children:[(0,eI.jsx)(iD,{className:"mt-1 size-6 shrink-0 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsx)("div",{className:"min-w-0 flex-1",children:(0,eI.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[(0,eI.jsx)("h2",{className:"break-words text-lg font-semibold",children:l}),c&&(0,eI.jsxs)("span",{className:"font-mono text-xs text-muted-foreground",children:["v",c]}),null!=e.fileCount&&(0,eI.jsxs)("span",{className:"text-xs text-muted-foreground",children:["· ",e.fileCount," file",1===e.fileCount?"":"s"]}),d&&(0,eI.jsxs)("span",{className:"bg-[var(--brand)]/10 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium text-[var(--brand)]",children:[(0,eI.jsx)(Cy,{className:"size-3","aria-hidden":"true"}),"Installed"]})]})})]}),(0,eI.jsx)(sc,{className:"min-h-0 flex-1",children:(0,eI.jsxs)("div",{className:"pr-3",children:[(0,eI.jsx)("p",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground",children:u||"No description."}),(0,eI.jsx)("div",{className:"mt-4 border-t border-border pt-4",children:a?(0,eI.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading skill contents…"]}):s?(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:s}):p?(0,eI.jsx)(N4,{content:p}):(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"No additional contents."})})]})})]})})});function C_(){let[e,t]=(0,eC.useState)([]),[r,n]=(0,eC.useState)([]),[a,i]=(0,eC.useState)(!0),[s,o]=(0,eC.useState)(null),[l,c]=(0,eC.useState)(null),[u,d]=(0,eC.useState)({}),[p,m]=(0,eC.useState)(null),[h,f]=(0,eC.useState)(null),g=(0,eC.useCallback)(async(e=!1)=>{i(!0),c(null),o(null);let[r,a]=await Promise.allSettled([fetch(`/api/skills/catalog${e?"?refresh=1":""}`).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Failed to load catalog");return t.skills??[]}),fetch("/api/skills").then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Failed to load skills");return t.skills??[]})]),s="fulfilled"===r.status?r.value:[];if("rejected"===r.status&&o(r.reason instanceof Error?r.reason.message:"Failed to load the official catalog."),t(s),"fulfilled"===a.status){let e=new Set(s.map(e=>e.name));n(a.value.filter(t=>!e.has(t.name)))}else n([]),c(a.reason instanceof Error?a.reason.message:"Failed to load installed skills.");i(!1)},[]);(0,eC.useEffect)(()=>{g()},[g]);let b=async(e,r="install")=>{d(t=>({...t,[e]:r})),c(null);try{let r=await fetch("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})}),n=await r.json();if(!r.ok)throw Error(n.error||"Failed to install");t(t=>t.map(t=>t.name===e?{...t,installed:!0,updateAvailable:!1,installedVersion:t.latestVersion??t.installedVersion}:t))}catch(e){c(e instanceof Error?e.message:`Failed to ${r}`)}finally{d(t=>{let r={...t};return delete r[e],r})}},y=async(e,r)=>{d(t=>({...t,[e]:"uninstall"})),c(null);try{let a=await fetch(`/api/skills?name=${encodeURIComponent(e)}`,{method:"DELETE"});if(!a.ok){let e=await a.json();throw Error(e.error||"Failed to uninstall")}r?t(t=>t.map(t=>t.name===e?{...t,installed:!1}:t)):n(t=>t.filter(t=>t.name!==e))}catch(e){c(e instanceof Error?e.message:"Failed to uninstall")}finally{d(t=>{let r={...t};return delete r[e],r})}},E=async()=>{h&&(f(null),await y(h.name,h.isCatalog))};return(0,eI.jsxs)("div",{className:"h-full overflow-y-auto",children:[(0,eI.jsxs)("div",{className:"mx-auto max-w-[960px] px-4 py-5 sm:px-5 sm:py-6",children:[(0,eI.jsxs)("header",{className:"mb-4 flex items-start justify-between gap-3",children:[(0,eI.jsxs)("div",{children:[(0,eI.jsx)("h2",{className:"text-xl font-semibold sm:text-2xl",children:"Research Skills"}),(0,eI.jsxs)("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:["Install official skills from the"," ",(0,eI.jsx)("a",{href:"https://github.com/EvoScientist/EvoSkills",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"EvoSkills"})," ","catalog, or remove ones you don't need."]})]}),(0,eI.jsx)("button",{type:"button",onClick:()=>g(!0),disabled:a,"aria-label":"Refresh",className:"rounded-md p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(Cg,{className:a?"size-4 animate-spin":"size-4","aria-hidden":"true"})})]}),l&&(0,eI.jsx)("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:l}),a?(0,eI.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground","aria-live":"polite",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading skills…"]}):(0,eI.jsxs)("div",{className:"space-y-6",children:[(0,eI.jsxs)("section",{children:[(0,eI.jsx)("h3",{className:"mb-2.5 text-xs font-semibold uppercase tracking-wider text-tertiary",children:"Official catalog"}),s?(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:s}):0===e.length?(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"No skills found in the catalog."}):(0,eI.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",children:e.map(e=>(0,eI.jsx)(Cv,{title:e.title,description:e.description,meta:`${e.fileCount} file${1===e.fileCount?"":"s"}`,installed:e.installed,installedVersion:e.installedVersion,latestVersion:e.latestVersion,updateAvailable:e.updateAvailable,busy:u[e.name],onOpen:()=>m({name:e.name,title:e.title,description:e.description,version:e.installed?e.installedVersion:e.latestVersion,fileCount:e.fileCount,installed:e.installed}),onInstall:()=>b(e.name),onUpdate:()=>b(e.name,"update"),onUninstall:()=>f({name:e.name,title:e.title,isCatalog:!0})},e.name))})]}),r.length>0&&(0,eI.jsxs)("section",{children:[(0,eI.jsx)("h3",{className:"mb-2.5 text-xs font-semibold uppercase tracking-wider text-tertiary",children:"Other installed skills"}),(0,eI.jsx)("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",children:r.map(e=>(0,eI.jsx)(Cv,{title:e.title,description:e.description,installed:!0,busy:u[e.name],onOpen:()=>m({name:e.name,title:e.title,description:e.description,installed:!0}),onUninstall:()=>f({name:e.name,title:e.title,isCatalog:!1})},e.name))})]})]})]}),(0,eI.jsx)(CE,{skill:p,onClose:()=>m(null)}),(0,eI.jsx)(ng,{open:null!==h,onOpenChange:e=>{e||f(null)},children:(0,eI.jsxs)(nE,{className:"sm:max-w-md",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Uninstall skill?"}),(0,eI.jsxs)(nT,{children:["“",h?.title??h?.name,"” will be removed from this Web UI. You can install it again later."]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),(0,eI.jsx)(nP,{onClick:E,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Uninstall"})]})]})})]})}function Cv({title:e,description:t,meta:r,installed:n,installedVersion:a,latestVersion:i,updateAvailable:s,busy:o,onOpen:l,onInstall:c,onUpdate:u,onUninstall:d}){let p=n?a&&`v${a}`:i&&`v${i}`;return(0,eI.jsxs)("div",{className:"flex flex-col rounded-lg border border-border bg-card p-3",children:[(0,eI.jsxs)("button",{type:"button",onClick:l,className:"-m-1 flex items-start gap-2.5 rounded-md p-1 text-left transition-colors hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring",title:"View details",children:[(0,eI.jsx)(iD,{className:"mt-0.5 size-5 shrink-0 text-[var(--brand)]","aria-hidden":"true"}),(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[(0,eI.jsx)("h3",{className:"break-words text-lg font-medium leading-tight",children:e}),p&&(0,eI.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:p}),r&&(0,eI.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:["· ",r]})]}),(0,eI.jsx)("p",{className:"mt-1 line-clamp-2 text-sm leading-6 text-muted-foreground",children:t||"No description."})]})]}),(0,eI.jsxs)("div",{className:"mt-2.5 flex items-center justify-end gap-2",children:[n&&s&&(0,eI.jsxs)("button",{type:"button",onClick:u,disabled:!!o,className:"inline-flex items-center gap-1.5 rounded-md bg-[var(--brand-solid)] px-2.5 py-1 text-xs font-medium text-[var(--brand-foreground)] transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",title:i?`Update to v${i}`:"Update",children:["update"===o?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(Cb,{className:"size-3.5","aria-hidden":"true"}),"update"===o?"Updating…":i?`Update → v${i}`:"Update"]}),n?(0,eI.jsxs)("button",{type:"button",onClick:d,disabled:!!o,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:["uninstall"===o?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(iM,{className:"size-3.5","aria-hidden":"true"}),"uninstall"===o?"Removing…":"Uninstall"]}):(0,eI.jsxs)("button",{type:"button",onClick:c,disabled:!!o,className:"inline-flex items-center gap-1.5 rounded-md bg-[var(--brand-solid)] px-2.5 py-1 text-xs font-medium text-[var(--brand-foreground)] transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:["install"===o?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(iN,{className:"size-3.5","aria-hidden":"true"}),"install"===o?"Installing…":"Install"]})]})]})}CE.displayName="SkillDetailDialog";let Cx=rj("fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]),CT=rj("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),CS=rj("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),Cw="rounded border border-border bg-background p-1.5 text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",Ck=["complements","contradicts","supersedes"];function CA({node:e,edges:t,nodeMap:r,onClose:n,onNavigate:a}){let i,[s,o]=(0,eC.useState)(null),[l,c]=(0,eC.useState)(!0),[u,d]=(0,eC.useState)(null);(0,eC.useEffect)(()=>{let t=new AbortController;return c(!0),o(null),d(null),fetch(`/api/memory?path=${encodeURIComponent(e.path)}`,{cache:"no-store",signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Failed to load observation.");o(t.content??null)}).catch(e=>{t.signal.aborted||(o(null),d(e instanceof Error?e.message:"Failed to load observation."))}).finally(()=>{t.signal.aborted||c(!1)}),()=>t.abort()},[e.path]);let p=(i=new Set,t.filter(t=>{if(t.source!==e.id&&t.target!==e.id)return!1;let r=t.source===e.id?t.target:t.source,n=`${r}::${t.relation}`;return!i.has(n)&&(i.add(n),!0)})),m=s?s.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"").trim():"";return(0,eI.jsxs)("div",{className:"flex h-full flex-col overflow-hidden border-l border-border bg-background shadow-xl md:shadow-none",children:[(0,eI.jsxs)("div",{className:"flex items-start justify-between gap-2 border-b border-border px-4 py-3",children:[(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsxs)("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.memory_type," · ",e.scope]}),(0,eI.jsx)("h3",{className:"mt-0.5 line-clamp-3 text-sm font-semibold leading-snug text-foreground",children:e.summary}),e.created_at&&(0,eI.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:(e=>{try{let t=new Date(e);if(Number.isNaN(t.getTime()))return e;return t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return e}})(e.created_at)})]}),(0,eI.jsx)("button",{type:"button",onClick:n,className:"mt-0.5 inline-flex size-8 flex-shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Close observation details",title:"Close observation details",children:(0,eI.jsx)(rF,{className:"h-4 w-4","aria-hidden":"true"})})]}),(0,eI.jsxs)("div",{className:"flex-1 overflow-y-auto","aria-live":l?"polite":"off",children:[p.length>0&&(0,eI.jsxs)("div",{className:"border-b border-border px-4 py-3",children:[(0,eI.jsx)("p",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Relations"}),(0,eI.jsx)("ul",{className:"space-y-1.5",children:p.map((t,n)=>{let i=t.source===e.id?t.target:t.source,s=r.get(i);return(0,eI.jsxs)("li",{className:"flex items-start gap-2",children:[(0,eI.jsx)("span",{className:"mt-0.5 flex-shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold text-white",style:{background:Ib(t.relation)},children:I_(t.relation)}),s?(0,eI.jsx)("button",{type:"button",onClick:()=>a(i),className:"min-w-0 rounded-sm text-left text-xs text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:s.summary}):(0,eI.jsx)("span",{className:"text-xs text-muted-foreground",children:i})]},n)})})]}),(0,eI.jsx)("div",{className:"px-4 py-3",children:l?(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"Loading…"}):u?(0,eI.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:u}):m?(0,eI.jsx)(N4,{content:m,className:"text-xs leading-relaxed [&_h2]:mb-2 [&_h2]:mt-4 [&_h2]:text-sm [&_p]:mb-3"}):(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"This observation has no body content."})})]})]})}function CN({data:e,selectedId:t,onSelect:r,w:n,h:a}){let i=(0,eC.useMemo)(()=>{let t=new Set;return e.edges.filter(e=>{let r=[e.source,e.target].sort().join("::");return!t.has(r)&&(t.add(r),!0)})},[e.edges]),s=function(e,t,r,n){let[a,i]=(0,eC.useState)([]),s=(0,eC.useRef)([]),o=(0,eC.useRef)(null),l=(0,eC.useRef)(0),c=(0,eC.useRef)(r),u=(0,eC.useRef)(n);return(0,eC.useEffect)(()=>{c.current=r,u.current=n},[r,n]),(0,eC.useEffect)(()=>{var r,n;let a,d;if(0===e.length||0===c.current||0===u.current){i([]),s.current=[];return}let p=(r=c.current,n=u.current,d=Math.min(r,n)*Math.max(.28,.12*Math.sqrt(a=Math.max(e.length,1))),e.map((e,t)=>{let i=t/a*2*Math.PI;return{id:e.id,x:r/2+d*Math.cos(i)+Ig(e.id,0),y:n/2+d*Math.sin(i)+Ig(e.id,1),vx:0,vy:0}}));s.current=p,i(p),l.current=0,o.current&&cancelAnimationFrame(o.current);let m=0,h=()=>{let{positions:e,energy:r}=function(e,t,r,n){let a=r/2,i=n/2,s=new Float64Array(e.length),o=new Float64Array(e.length),l=new Map(e.map((e,t)=>[e.id,t]));for(let t=0;t<e.length;t++)for(let r=t+1;r<e.length;r++){let n=e[t].x-e[r].x,a=e[t].y-e[r].y,i=Math.max(Math.sqrt(n*n+a*a),1),l=6e3/(i*i),c=n/i,u=a/i;s[t]+=l*c,o[t]+=l*u,s[r]-=l*c,o[r]-=l*u}for(let r of t){let t=l.get(r.source),n=l.get(r.target);if(null==t||null==n)continue;let a=e[n].x-e[t].x,i=e[n].y-e[t].y,c=Math.max(Math.sqrt(a*a+i*i),1),u=.04*(c-180),d=a/c,p=i/c;s[t]+=u*d,o[t]+=u*p,s[n]-=u*d,o[n]-=u*p}for(let t=0;t<e.length;t++)s[t]+=.02*(a-e[t].x),o[t]+=.02*(i-e[t].y);let c=0;return{positions:e.map((e,t)=>{let r=(e.vx+s[t])*.78,n=(e.vy+o[t])*.78,a=Math.sqrt(r*r+n*n);return a>12&&(r=r/a*12,n=n/a*12),c+=r*r+n*n,{id:e.id,x:e.x+r,y:e.y+n,vx:r,vy:n}}),energy:c}}(s.current,t,c.current,u.current);s.current=e,l.current++,++m%2==0&&i([...e]),l.current<600&&r>.3?o.current=requestAnimationFrame(h):i([...s.current])};return o.current=requestAnimationFrame(h),()=>{o.current&&cancelAnimationFrame(o.current)}},[e,t]),a}(e.nodes,i,n,a),[o,l]=(0,eC.useState)(0),[c,u]=(0,eC.useState)(0),[d,p]=(0,eC.useState)(1),m=(0,eC.useRef)(null),h=(0,eC.useRef)(null),[f,g]=(0,eC.useState)(new Set(Ck)),[b,y]=(0,eC.useState)(new Set(["semantic","procedural"])),E=(0,eC.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),_=(0,eC.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e.nodes]),v=(0,eC.useRef)({tx:o,ty:c,scale:d});v.current={tx:o,ty:c,scale:d};let x=(0,eC.useCallback)((e,t,r)=>{let{tx:n,ty:a,scale:i}=v.current,s=Math.max(.2,Math.min(5,i*r)),o=s/i;p(s),l(e-o*(e-n)),u(t-o*(t-a))},[]),T=(0,eC.useCallback)(e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();x(e.clientX-t.left,e.clientY-t.top,e.deltaY<0?1.1:.9)},[x]),S=(0,eC.useCallback)(e=>{(e.target===e.currentTarget||"svg"===e.target.tagName)&&(h.current={startX:e.clientX,startY:e.clientY,tx:o,ty:c},e.currentTarget.setPointerCapture(e.pointerId))},[o,c]),w=(0,eC.useCallback)(e=>{h.current&&(l(h.current.tx+e.clientX-h.current.startX),u(h.current.ty+e.clientY-h.current.startY))},[]),k=(0,eC.useCallback)(()=>{h.current=null},[]);if(0===n||0===a)return null;let A=new Set(e.nodes.filter(e=>b.has("procedural"===e.memory_type?"procedural":"semantic")).map(e=>e.id)),N=e.edges.filter(e=>A.has(e.source)&&A.has(e.target)&&(f.has(e.relation)||!Ck.includes(e.relation)));return(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)("div",{className:"absolute left-3 top-3 z-10 flex gap-1",children:[(0,eI.jsx)("button",{type:"button",onClick:()=>x(n/2,a/2,1.25),className:Cw,"aria-label":"Zoom in observation graph",title:"Zoom in",children:(0,eI.jsx)(NU,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,eI.jsx)("button",{type:"button",onClick:()=>x(n/2,a/2,.8),className:Cw,"aria-label":"Zoom out observation graph",title:"Zoom out",children:(0,eI.jsx)(NB,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,eI.jsx)("button",{type:"button",onClick:()=>{l(0),u(0),p(1)},className:Cw,"aria-label":"Reset observation graph view",title:"Reset view",children:(0,eI.jsx)(CS,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),(0,eI.jsxs)("div",{className:"absolute right-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] select-none flex-col gap-1 rounded border border-border bg-background/90 px-2.5 py-2 text-[11px] shadow-sm backdrop-blur-sm",children:[["complements","contradicts","supersedes"].map(e=>{let t=f.has(e);return(0,eI.jsxs)("button",{type:"button",onClick:()=>{g(t=>{let r=new Set(t);if(r.has(e)){if(1===r.size)return t;r.delete(e)}else r.add(e);return r})},"aria-pressed":t,title:`${t?"Hide":"Show"} ${e} edges`,className:`flex items-center gap-1.5 text-left transition-opacity ${t?"opacity-100":"opacity-35"}`,children:[(0,eI.jsx)("span",{className:"inline-block h-2 w-6 flex-shrink-0 rounded-sm",style:{background:Ib(e)}}),(0,eI.jsx)("span",{className:"capitalize text-muted-foreground",children:I_(e)})]},e)}),(0,eI.jsx)("div",{className:"mt-1 flex flex-col gap-0.5 border-t border-border pt-1",children:[["semantic","Semantic"],["procedural","Procedural"]].map(([e,t])=>{let r=b.has(e);return(0,eI.jsxs)("button",{type:"button",onClick:()=>{y(t=>{let r=new Set(t);if(r.has(e)){if(1===r.size)return t;r.delete(e)}else r.add(e);return r})},"aria-pressed":r,title:`${r?"Hide":"Show"} ${t.toLowerCase()} nodes`,className:`flex items-center gap-1.5 text-left transition-opacity ${r?"opacity-100":"opacity-35"}`,children:[(0,eI.jsx)("span",{className:"inline-block h-3 w-3 flex-shrink-0 rounded-full",style:{background:IE(e)}}),(0,eI.jsx)("span",{className:"text-muted-foreground",children:t})]},e)})})]}),(0,eI.jsxs)("svg",{ref:m,width:n,height:a,className:"absolute inset-0 cursor-grab active:cursor-grabbing",style:{userSelect:"none"},role:"img","aria-label":"Observation relationship graph",onWheel:T,onPointerDown:S,onPointerMove:w,onPointerUp:k,onClick:e=>{(e.target===e.currentTarget||"svg"===e.target.tagName)&&r(null)},children:[(0,eI.jsx)("defs",{children:["complements","contradicts","supersedes","default"].map(e=>(0,eI.jsx)("marker",{id:`arrow-${e}`,viewBox:"0 0 10 10",markerWidth:"7",markerHeight:"7",refX:"10",refY:"5",orient:"auto",markerUnits:"userSpaceOnUse",children:(0,eI.jsx)("path",{d:"M0,1.5 L10,5 L0,8.5 z",fill:Ib(e)})},e))}),(0,eI.jsxs)("g",{transform:`translate(${o},${c}) scale(${d})`,children:[N.map((e,t)=>{let r=E.get(e.source),n=E.get(e.target);if(!r||!n)return null;let a=_.get(e.source),i=_.get(e.target),s=a?Iy(a.degree):9,o=i?Iy(i.degree):9,l=n.x-r.x,c=n.y-r.y,u=Math.max(Math.sqrt(l*l+c*c),1),d=l/u,p=c/u,m=r.x+d*s,h=r.y+p*s,f=n.x-d*(o+2),g=n.y-p*(o+2),b=e.relation in{complements:1,contradicts:1,supersedes:1}?e.relation:"default",y=Ib(e.relation),v=`edge-grad-${t}`,x="complements"===e.relation,T=Math.min(45,7/Math.max(u-s-(o+2),1)*100);return(0,eI.jsxs)("g",{children:[(0,eI.jsx)("linearGradient",{id:v,gradientUnits:"userSpaceOnUse",x1:m,y1:h,x2:f,y2:g,children:x?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("stop",{offset:"0%",stopColor:y,stopOpacity:0}),(0,eI.jsx)("stop",{offset:`${T}%`,stopColor:y,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:`${100-T}%`,stopColor:y,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:"100%",stopColor:y,stopOpacity:0})]}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("stop",{offset:"0%",stopColor:y,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:`${100-T}%`,stopColor:y,stopOpacity:.7}),(0,eI.jsx)("stop",{offset:"100%",stopColor:y,stopOpacity:0})]})}),(0,eI.jsx)("line",{x1:m,y1:h,x2:f,y2:g,stroke:`url(#${v})`,strokeWidth:1.5,strokeDasharray:"contradicts"===e.relation?"5,3":void 0,markerEnd:x?void 0:`url(#arrow-${b})`})]},t)}),e.nodes.map(e=>{let n=E.get(e.id);if(!n||!A.has(e.id))return null;let a=Iy(e.degree),i=e.id===t,s=e.summary.length>28?e.summary.slice(0,26)+"…":e.summary;return(0,eI.jsxs)("g",{role:"button",tabIndex:0,"aria-label":`Select observation: ${e.summary}`,className:"outline-none [&:focus-visible]:outline-none [&:focus]:outline-none",style:{cursor:"pointer"},onClick:n=>{n.stopPropagation(),r(e.id===t?null:e.id)},onKeyDown:n=>{("Enter"===n.key||" "===n.key)&&(n.preventDefault(),r(e.id===t?null:e.id))},children:[i&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("circle",{cx:n.x,cy:n.y,r:a+7,fill:"none",style:{stroke:"var(--brand)"},strokeWidth:2,opacity:.3}),(0,eI.jsx)("circle",{cx:n.x,cy:n.y,r:a+4,fill:"none",style:{stroke:"var(--brand)"},strokeWidth:2.5})]}),(0,eI.jsx)("circle",{cx:n.x,cy:n.y,r:a,fill:IE(e.memory_type),stroke:"#fff",strokeWidth:1.5,opacity:.9}),(0,eI.jsx)("text",{x:n.x,y:n.y+a+12,textAnchor:"middle",fontSize:10,fill:"currentColor",className:"select-none fill-foreground/70",children:s}),(0,eI.jsx)("title",{children:e.summary})]},e.id)})]})]})]})}function CI({message:e}){return(0,eI.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:e})}function CC({data:e,loading:t,error:r,highlightNodeId:n}){let a=(0,eC.useRef)(null),[i,s]=(0,eC.useState)({w:0,h:0}),[o,l]=(0,eC.useState)(null),[c,u]=(0,eC.useState)(!1),[d,p]=(0,eC.useState)(360),m=(0,eC.useRef)(null);(0,eC.useEffect)(()=>{null!=n&&l(n)},[n]),(0,eC.useEffect)(()=>{let e=window.matchMedia("(min-width: 768px)"),t=()=>u(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let h=(0,eC.useCallback)(e=>{m.current={startX:e.clientX,startW:d},e.currentTarget.setPointerCapture(e.pointerId)},[d]),f=(0,eC.useCallback)(e=>{if(!m.current)return;let t=e.clientX-m.current.startX;p(Math.min(Math.max(640,.6*window.innerWidth),Math.max(280,m.current.startW-t)))},[]),g=(0,eC.useCallback)(()=>{m.current=null},[]);(0,eC.useEffect)(()=>{let e=a.current;if(!e)return;let t=new ResizeObserver(([e])=>{s({w:e.contentRect.width,h:e.contentRect.height})});return t.observe(e),()=>t.disconnect()},[]);let b=new Map((e?.nodes??[]).map(e=>[e.id,e])),y=o?b.get(o)??null:null,E=null!==y;return(0,eI.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-col",children:[(0,eI.jsx)("div",{className:"flex items-center border-b border-border px-4 py-2",children:(0,eI.jsx)("span",{className:"text-xs text-muted-foreground",children:e?`${e.nodes.length} nodes \xb7 ${e.edges.length} edges`:t?"Loading…":""})}),(0,eI.jsxs)("div",{className:"relative flex min-h-0 flex-1",children:[(0,eI.jsxs)("div",{ref:a,className:"relative min-w-0 flex-1 overflow-hidden bg-muted/20",children:[t&&(0,eI.jsx)(CI,{message:"Loading observations…"}),!t&&r&&(0,eI.jsx)(CI,{message:`Error: ${r}`}),!t&&!r&&e&&0===e.nodes.length&&(0,eI.jsx)(CI,{message:"No observations yet."}),!t&&!r&&e&&e.nodes.length>0&&i.w>0&&(0,eI.jsx)(CN,{data:e,selectedId:o,onSelect:l,w:i.w,h:i.h})]}),E&&c&&(0,eI.jsx)("div",{role:"separator","aria-orientation":"vertical",onPointerDown:h,onPointerMove:f,onPointerUp:g,className:"hover:bg-[var(--brand)]/40 w-1 flex-shrink-0 cursor-col-resize bg-border transition-colors"}),E&&(0,eI.jsx)("div",{className:c?"flex-shrink-0 overflow-hidden":"absolute inset-0 z-20 overflow-hidden",style:c?{width:d}:void 0,children:(0,eI.jsx)(CA,{node:y,edges:e?.edges??[],nodeMap:b,onClose:()=>l(null),onNavigate:e=>l(e)})})]})]})}let CR=rj("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),CO=[{path:"profile/USER_PROFILE.md",label:"User",description:"Persistent context about the researcher",Icon:rj("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]])},{path:"profile/RESEARCH_TASTE.md",label:"Taste",description:"Aesthetic and methodological preferences",Icon:CR},{path:"profile/SOUL.md",label:"SOUL",description:"EvoScientist's core values and personality",Icon:_L}];function CL({entry:e,selected:t,onSelect:r}){let{Icon:n}=e;return(0,eI.jsxs)("button",{type:"button",onClick:()=>r(e),className:nf("group flex w-full min-w-0 items-center gap-2 rounded-md border px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t?"border-[var(--brand)]/40 bg-accent":"hover:border-[var(--brand)]/40 border-border bg-[var(--color-surface)] hover:bg-accent/60"),children:[(0,eI.jsx)("span",{className:nf("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",t?"bg-[var(--brand)] text-white":"bg-muted text-[var(--brand)] group-hover:bg-background"),children:(0,eI.jsx)(n,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("span",{className:"block truncate text-sm font-medium",children:e.label}),(0,eI.jsx)("span",{className:"block truncate text-[11px] text-muted-foreground",children:e.description})]})]})}function CD({entry:e}){let[t,r]=(0,eC.useState)(""),[n,a]=(0,eC.useState)(""),[i,s]=(0,eC.useState)(!1),[o,l]=(0,eC.useState)(!1),[c,u]=(0,eC.useState)(!1),[d,p]=(0,eC.useState)(null),m=(0,eC.useRef)(0);(0,eC.useEffect)(()=>{if(!e){r(""),a("");return}let t=++m.current;s(!0),l(!1),p(null),fetch(`/api/memory?path=${encodeURIComponent(e.path)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||"Failed to load.");return t}).then(e=>{m.current===t&&(r(e.content??""),a(e.content??""))}).catch(e=>{m.current===t&&(r(""),a(""),p(e instanceof Error?e.message:"Failed to load."))}).finally(()=>{m.current===t&&s(!1)})},[e]);let h=async()=>{if(e){u(!0),p(null);try{let t=await fetch("/api/memory",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e.path,content:n})}),a=await t.json();if(!t.ok)throw Error(a.error??"Failed to save.");r(n),l(!1)}catch(e){p(e instanceof Error?e.message:"Failed to save.")}finally{u(!1)}}};if(!e)return(0,eI.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Select a profile to view"});let f=t.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"").trim();return(0,eI.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-between border-b border-border px-4 py-2.5",children:[(0,eI.jsx)("span",{className:"text-sm font-medium",children:e.label}),(0,eI.jsx)("div",{className:"flex items-center gap-1.5",children:o?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nP,{variant:"outline",size:"sm",onClick:()=>{l(!1),a(t)},children:"Cancel"}),(0,eI.jsx)(nP,{size:"sm",onClick:h,disabled:c||n===t,children:c?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"Saving"]}):"Save"})]}):(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:()=>l(!0),disabled:i,children:[(0,eI.jsx)(iR,{className:"size-3.5","aria-hidden":"true"}),"Edit raw"]})})]}),d&&(0,eI.jsx)("p",{className:"flex-shrink-0 px-4 py-2 text-xs text-destructive",children:d}),(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:i?(0,eI.jsxs)("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading…"]}):o?(0,eI.jsx)("textarea",{"aria-label":`Edit ${e.label} memory`,className:"size-full resize-none bg-background p-4 font-mono text-sm text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",value:n,onChange:e=>a(e.target.value),spellCheck:!1}):(0,eI.jsx)(sc,{className:"h-full",children:(0,eI.jsx)("div",{className:"px-4 py-4",children:(0,eI.jsx)(N4,{content:f})})})})]})}function CP({listing:e,listingLoading:t}){let[r,n]=(0,eC.useState)(null),[a,i]=(0,eC.useState)(!1);(0,eC.useEffect)(()=>{let e=window.matchMedia("(min-width: 768px)"),t=()=>i(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let s=(0,eC.useMemo)(()=>(e?.entries??[]).filter(e=>e.path.startsWith("profile/projects/")&&e.path.endsWith(".md")).map(e=>{let t=e.path.split("/"),r=t.length>=4?`${t[2]}/${t.slice(3).join("/")}`:e.path;return{path:e.path,label:r.replace(/\/PROJECT_PROFILE\.md$/,""),description:"Project profile",Icon:_R}}),[e?.entries]),o=(0,eC.useMemo)(()=>[...CO,...s],[s]);(0,eC.useEffect)(()=>{!t&&0!==o.length&&(r&&o.some(e=>e.path===r.path)||n(o[0]))},[o,t,r]);let l=(0,eI.jsx)(sc,{className:"h-full",children:(0,eI.jsxs)("div",{className:"p-3",children:[(0,eI.jsx)("p",{className:"mb-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Profile"}),(0,eI.jsx)("div",{className:"space-y-1.5",children:CO.map(e=>(0,eI.jsx)(CL,{entry:e,selected:r?.path===e.path,onSelect:n},e.path))}),(0,eI.jsx)("p",{className:"mb-2 mt-5 text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Project Profiles"}),t?(0,eI.jsxs)("div",{className:"flex h-10 items-center gap-2 text-xs text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"Loading projects…"]}):0===s.length?(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"No project profiles yet."}):(0,eI.jsx)("div",{className:"space-y-1.5",children:s.map(e=>(0,eI.jsx)(CL,{entry:e,selected:r?.path===e.path,onSelect:n},e.path))})]})});return a?(0,eI.jsxs)(iS,{direction:"horizontal",autoSaveId:"evomemory-identity",className:"h-full",children:[(0,eI.jsx)(ak,{defaultSize:35,minSize:22,maxSize:55,children:l}),(0,eI.jsx)(iw,{}),(0,eI.jsx)(ak,{defaultSize:65,minSize:45,children:(0,eI.jsx)(CD,{entry:r})})]}):(0,eI.jsxs)("div",{className:"flex min-h-0 w-full flex-1 flex-col",children:[(0,eI.jsx)("div",{className:"max-h-[42svh] flex-shrink-0 overflow-hidden border-b border-border",children:l}),(0,eI.jsx)("div",{className:"min-h-0 flex-1",children:(0,eI.jsx)(CD,{entry:r})})]})}function CM(e){try{let t=new Date(e),r=new Date;return t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate()}catch{return!1}}function Cj({items:e}){let t=new Set(e.filter(e=>"execution"===e.kind).map(e=>e.project_id).filter(Boolean)).size,r=e.filter(e=>e.created_at&&CM(e.created_at)),n=r.filter(e=>"execution"===e.kind).length,a=r.filter(e=>"observation"===e.kind).length,i=[{n:t,label:"Projects"},{n:e.length,label:"Total"},{n:n,label:"Runs Today"},{n:a,label:"Obs Today"}];return(0,eI.jsx)("div",{className:"flex flex-shrink-0 border-b border-border",children:i.map(e=>(0,eI.jsxs)("div",{className:"flex flex-1 flex-col items-center gap-1 border-r border-border py-2 last:border-r-0",children:[(0,eI.jsx)("span",{className:"text-lg font-bold leading-none text-[var(--brand)]",children:e.n}),(0,eI.jsx)("span",{className:"text-[11px] leading-none text-muted-foreground",children:e.label})]},e.label))})}function CF({created_at:e,dotColor:t,children:r}){return(0,eI.jsxs)("div",{className:"flex gap-2",children:[(0,eI.jsx)("time",{dateTime:e,className:"w-14 flex-shrink-0 pt-3 text-right text-xs tabular-nums leading-none text-muted-foreground",children:function(e){try{let t=new Date(e);if(CM(e))return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).format(t);let r=new Date;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",...t.getFullYear()!==r.getFullYear()?{year:"numeric"}:{}}).format(t)}catch{return e}}(e)}),(0,eI.jsxs)("div",{className:"relative flex w-3 flex-shrink-0 justify-center",children:[(0,eI.jsx)("span",{className:"absolute bottom-0 left-1/2 top-0 w-px -translate-x-1/2 bg-border","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"z-10 mt-3 size-2.5 rounded-full border-2 border-[var(--color-surface)]",style:{background:t}})]}),r]})}function CU({entry:e,onNavigateToObs:t,defaultOpen:r=!1}){let[n,a]=(0,eC.useState)(r),i=(0,eC.useRef)(null),s=`${n?"Collapse":"Expand"} ${e.agent} execution: ${e.summary}`;return(0,eC.useEffect)(()=>{r&&(a(!0),i.current?.scrollIntoView({block:"center"}))},[r]),(0,eI.jsx)(CF,{created_at:e.created_at,dotColor:"var(--brand)",children:(0,eI.jsxs)("div",{ref:i,className:`hover:border-[var(--brand)]/40 mb-2 min-w-0 flex-1 overflow-hidden rounded-lg border bg-[var(--color-surface)] transition-colors ${r?"border-[var(--brand)]/40":"border-border"}`,children:[(0,eI.jsxs)("button",{type:"button","aria-expanded":n,"aria-label":s,title:s,onClick:()=>a(e=>!e),className:"flex w-full items-center gap-2 px-3 py-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:[(0,eI.jsx)("span",{className:"flex-shrink-0 text-sm font-medium text-foreground",children:e.agent}),!n&&(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:e.summary}),(0,eI.jsx)(lB,{className:`ml-auto size-3.5 flex-shrink-0 text-muted-foreground transition-transform duration-200 ${n?"rotate-180":""}`,"aria-hidden":"true"})]}),(0,eI.jsx)("div",{className:"grid transition-[grid-template-rows] duration-200",style:{gridTemplateRows:n?"1fr":"0fr"},children:n&&(0,eI.jsxs)("div",{className:"overflow-hidden",children:[e.project_id&&(0,eI.jsx)("p",{className:"px-3 pb-2 font-mono text-[11px] text-muted-foreground",children:e.project_id}),(0,eI.jsx)("p",{className:"border-t border-border px-3 py-3 text-sm leading-relaxed text-foreground",children:e.summary}),e.obs_ids.length>0&&(0,eI.jsxs)("div",{className:"border-t border-border px-3 py-2.5",children:[(0,eI.jsx)("p",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Linked Observations"}),(0,eI.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.obs_ids.map(e=>(0,eI.jsxs)("button",{type:"button",onClick:r=>{r.stopPropagation(),t(e)},className:"border-[var(--brand)]/40 rounded border bg-background px-2 py-0.5 font-mono text-[11px] text-[var(--brand)] transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:`Jump to ${e} in Knowledge graph`,"aria-label":`Jump to observation ${e} in Knowledge graph`,children:[e.slice(0,14),"…"]},e))})]})]})})]})})}function CB({obs:e,onNavigateToObs:t}){let r=IE(e.memory_type);return(0,eI.jsx)(CF,{created_at:e.created_at,dotColor:r,children:(0,eI.jsx)("button",{type:"button",onClick:()=>t(e.id),title:"View in Knowledge graph","aria-label":`View observation in Knowledge graph: ${e.summary}`,className:"hover:border-[var(--brand)]/40 mb-2 min-w-0 flex-1 cursor-pointer overflow-hidden rounded-lg border border-dashed border-border bg-[var(--color-surface)] px-3 py-2.5 text-left transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsxs)("div",{className:"flex items-center gap-2",children:[(0,eI.jsx)("span",{className:"flex-shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-white",style:{background:r},children:e.memory_type}),(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:e.summary}),(0,eI.jsx)(Ip,{className:"ml-auto size-3.5 flex-shrink-0 text-muted-foreground","aria-hidden":"true"})]})})})}function C$({items:e,truncated:t,loading:r,error:n,highlightExecId:a,onRefresh:i,onNavigateToObs:s}){return r&&!e?(0,eI.jsxs)("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading history…"]}):n?(0,eI.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8",children:[(0,eI.jsx)("p",{className:"text-sm text-destructive",children:n}),(0,eI.jsxs)("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[(0,eI.jsx)(CT,{className:"size-3.5","aria-hidden":"true"}),"Retry"]})]}):e&&0!==e.length?(0,eI.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,eI.jsx)(Cj,{items:e}),(0,eI.jsx)(sc,{type:"always",className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block [&_[data-slot=scroll-area-viewport]>div]:!w-full",children:(0,eI.jsxs)("div",{className:"p-4",children:[(0,eI.jsx)("div",{children:e.map(e=>"execution"===e.kind?(0,eI.jsx)(CU,{entry:e,onNavigateToObs:s,defaultOpen:a===e.id},`e-${e.id}`):(0,eI.jsx)(CB,{obs:e,onNavigateToObs:s},`o-${e.id}`))}),t&&(0,eI.jsxs)("p",{className:"mt-2 text-center text-xs text-muted-foreground",children:["Showing newest ",e.length," items."]})]})})]}):(0,eI.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"No activity yet."})}function Cz(e){return"identity"===e||"knowledge"===e||"history"===e}function CH({initialTab:e,initialObsId:t,initialExecId:r}={}){let[n,a]=(0,eC.useState)(null),[i,s]=(0,eC.useState)(!0),[o,l]=(0,eC.useState)(Cz(e)?e:"identity"),[c,u]=(0,eC.useState)(null),[d,p]=(0,eC.useState)(!1),[m,h]=(0,eC.useState)(null),[f,g]=(0,eC.useState)(null),[b,y]=(0,eC.useState)(!1),[E,_]=(0,eC.useState)(null),[v,x]=(0,eC.useState)(t??null),T=(0,eC.useRef)(0),S=(0,eC.useRef)(0),w=(0,eC.useCallback)(async()=>{s(!0);try{let e=await fetch("/api/memory"),t=await e.json();if(!e.ok)return;a(t);let r=t.entries.reduce((e,t)=>t.mtime>e?t.mtime:e,0);r>0&&c5(r)}catch{}finally{s(!1)}},[]),k=(0,eC.useCallback)(async()=>{let e=++T.current;p(!0),h(null);try{let t=await fetch("/api/memory/observations",{cache:"no-store"}),r=await t.json().catch(()=>({}));if(e!==T.current)return;if(!t.ok)throw Error(r.error||"Failed.");u(r)}catch(t){if(e!==T.current)return;h(t instanceof Error?t.message:"Failed to load.")}finally{e===T.current&&p(!1)}},[]),A=(0,eC.useCallback)(async()=>{let e=++S.current;y(!0),_(null);try{let t=await fetch("/api/memory/executions",{cache:"no-store"}),r=await t.json().catch(()=>({}));if(e!==S.current)return;if(!t.ok)throw Error(r.error||"Failed.");g(r)}catch(t){if(e!==S.current)return;_(t instanceof Error?t.message:"Failed to load.")}finally{e===S.current&&y(!1)}},[]);(0,eC.useEffect)(()=>{w()},[w]),(0,eC.useEffect)(()=>{Cz(e)&&l(e)},[e]),(0,eC.useEffect)(()=>{t?(x(t),l("knowledge")):x(null)},[t]),(0,eC.useEffect)(()=>{r&&l("history")},[r]),(0,eC.useEffect)(()=>{if("history"!==o)return;let e=()=>{A(),k()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[o,A,k]),(0,eC.useEffect)(()=>{"knowledge"!==o||c||d||k()},[o,c,d,k]);let N=(0,eC.useMemo)(()=>{if(!f&&!c)return null;let e=[];for(let t of f?.entries??[])e.push({kind:"execution",...t});for(let t of c?.nodes??[])e.push({kind:"observation",id:t.id,created_at:t.created_at,summary:t.summary,memory_type:t.memory_type,scope:t.scope});return e.sort((e,t)=>e.created_at<t.created_at?1:-1),e},[f,c]),I=[{id:"identity",label:"Identity",Icon:Cx},{id:"knowledge",label:"Knowledge",Icon:Ip},{id:"history",label:"History",Icon:If}];return(0,eI.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,eI.jsxs)("header",{className:"flex flex-shrink-0 items-start justify-between gap-3 border-b border-border px-4 py-3 sm:px-5",children:[(0,eI.jsxs)("div",{className:"min-w-0",children:[(0,eI.jsx)("h2",{className:"text-xl font-semibold sm:text-2xl",children:"EvoMemory"}),(0,eI.jsxs)("p",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:["EvoScientist's"," ",(0,eI.jsx)("span",{className:"font-medium text-[var(--brand)]",children:"self-evolving memory system"})," ","— continuously learns and refines what it knows about you, your research taste, and lessons from past experiments."]})]}),(0,eI.jsx)("button",{type:"button",onClick:()=>{"history"===o?(A(),k()):"knowledge"===o?k():w()},disabled:"history"===o?b||d:"knowledge"===o?d:i,"aria-label":"Refresh",title:"Refresh",className:"mt-0.5 flex-shrink-0 rounded-md p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:(0,eI.jsx)(CT,{className:`size-4 ${"history"===o&&(b||d)||"knowledge"===o&&d||"identity"===o&&i?"animate-spin":""}`,"aria-hidden":"true"})})]}),(0,eI.jsx)("div",{className:"flex flex-shrink-0 items-center gap-1 border-b border-border px-3 pt-1",role:"tablist","aria-label":"Memory views",children:I.map(({id:e,label:t,Icon:r})=>(0,eI.jsxs)("button",{type:"button",role:"tab","aria-selected":o===e,onClick:()=>{l(e),"knowledge"!==e&&x(null)},className:nf("flex items-center gap-1.5 rounded-t-md border-b-2 px-3 py-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",o===e?"border-[var(--brand)] bg-accent text-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground"),children:[(0,eI.jsx)(r,{className:"size-3.5","aria-hidden":"true"}),t]},e))}),(0,eI.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:["identity"===o&&(0,eI.jsx)(CP,{listing:n,listingLoading:i}),"knowledge"===o&&(0,eI.jsx)(CC,{data:c,loading:d,error:m,highlightNodeId:v}),"history"===o&&(0,eI.jsx)("div",{className:"flex min-h-0 w-full flex-1 flex-col",children:(0,eI.jsx)(C$,{items:N,truncated:!!f?.truncated,loading:b||d,error:E||m,highlightExecId:r,onRefresh:()=>{A(),k()},onNavigateToObs:e=>{x(e),l("knowledge")}})})]})]})}let CG=rj("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Cq=rj("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]),CV=rj("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]),CW=rj("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),CY=rj("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),CK=rj("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),CZ=rj("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),CX=rj("repeat-2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]),CQ={frequency:"daily",hour:9,minute:0,dayOfWeek:1,dayOfMonth:1,custom:"0 9 * * *"},CJ=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function C0(e,t,r){return Number.isFinite(e)?Math.min(r,Math.max(t,e)):t}function C1(e){let t=C0(e.minute,0,59),r=C0(e.hour,0,23),n=C0(e.dayOfWeek,0,6),a=C0(e.dayOfMonth,1,28);switch(e.frequency){case"daily":break;case"weekly":return`${t} ${r} * * ${n}`;case"monthly":return`${t} ${r} ${a} * *`;case"custom":return e.custom.trim()}return`${t} ${r} * * *`}function C2(e){let t=e.trim().split(/\s+/);if(5!==t.length)return{...CQ,frequency:"custom",custom:e};let[r,n,a,i,s]=t,o=parseInt(r,10),l=parseInt(n,10);return"*"!==i||"*"!==a||"*"!==s||isNaN(o)||isNaN(l)?"*"!==i||"*"!==a||isNaN(parseInt(s,10))||isNaN(o)||isNaN(l)?"*"!==i||"*"!==s||isNaN(parseInt(a,10))||isNaN(o)||isNaN(l)?{...CQ,frequency:"custom",custom:e}:{...CQ,frequency:"monthly",hour:C0(l,0,23),minute:C0(o,0,59),dayOfMonth:C0(parseInt(a,10),1,28)}:{...CQ,frequency:"weekly",hour:C0(l,0,23),minute:C0(o,0,59),dayOfWeek:C0(parseInt(s,10),0,6)}:{...CQ,frequency:"daily",hour:l,minute:o}}function C4(e){let t=C2(e),r=`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`;switch(t.frequency){case"daily":return`Every day at ${r}`;case"weekly":return`Every ${CJ[t.dayOfWeek]} at ${r}`;case"monthly":return`Monthly on day ${t.dayOfMonth} at ${r}`;default:return e}}function C3(e){if(!e)return"—";let t=new Date(e);if(isNaN(t.getTime()))return"—";let r=Date.now(),n=t.getTime()-r;if(n<0)return"Overdue";let a=Math.round(n/6e4);if(a<1)return"in <1m";if(a<60)return`in ${a}m`;let i=Math.round(n/36e5);if(i<24)return`in ${i}h`;let s=Math.round(n/864e5);return`in ${s}d`}let C5=[{icon:CW,label:"Daily Papers",description:"Track new ML papers against your research preferences.",name:"Daily Papers",prompt:"Summarise the latest ML papers from arXiv according to my research preferences with the paper-navigator skill. Focus on papers that are relevant to my current projects, explain why each one matters, and save the summary to ./daily-papers.md in the current workspace.",schedule:"0 9 * * *"},{icon:CX,label:"Weekly Research Review",description:"Summarise this week's research progress and future direction.",name:"Weekly Research Review",prompt:"Summarise this week's research progress across my active projects. Highlight key results, decisions, blockers, open questions, and what changed in my understanding. Then propose future research directions and concrete next steps. Save the review to ./weekly-research-review.md in the current workspace.",schedule:"0 17 * * 5"},{icon:Im,label:"Weekly Research Plan",description:"Draft a Monday plan for the week's research priorities.",name:"Weekly Research Plan",prompt:"Draft this week's research plan based on my active projects, recent progress, project files, and open questions. Prioritise the most important research goals, propose concrete experiments or reading tasks, identify risks, and write a practical schedule for the week. Save the plan to ./weekly-research-plan.md in the current workspace.",schedule:"0 8 * * 1"},{icon:CY,label:"Experiment Backlog",description:"Convert open questions into testable experiment ideas.",name:"Experiment Backlog",prompt:"Review my active project files, recent research notes, and open questions. Turn the most important unresolved ideas into a prioritised experiment backlog with hypotheses, expected signal, required data or code, estimated effort, and success criteria. Save it to ./experiment-backlog.md in the current workspace.",schedule:"0 10 * * 2"}];function C6(e){if(!e)return"Not scheduled";let t=new Date(e);return Number.isNaN(t.getTime())?"Unknown":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t)}function C9(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function C8({children:e,htmlFor:t}){return(0,eI.jsx)("label",{htmlFor:t,className:"text-xs font-medium text-muted-foreground",children:e})}function C7({value:e,onChange:t,error:r}){let n=r=>t({...e,...r}),a="h-9 rounded-md border border-input bg-background py-1.5 pl-2.5 pr-8 text-sm outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",i=nf(a,"w-full sm:min-w-40"),s=nf(a,"w-full sm:w-28");return(0,eI.jsxs)("div",{className:"space-y-2",children:[(0,eI.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[minmax(9rem,1fr)_auto_auto_auto_auto] sm:items-center",children:[(0,eI.jsxs)("select",{"aria-label":"Schedule frequency",value:e.frequency,onChange:e=>n({frequency:e.target.value}),className:i,children:[(0,eI.jsx)("option",{value:"daily",children:"Every day"}),(0,eI.jsx)("option",{value:"weekly",children:"Every week"}),(0,eI.jsx)("option",{value:"monthly",children:"Every month"}),(0,eI.jsx)("option",{value:"custom",children:"Custom cron"})]}),"custom"!==e.frequency&&(0,eI.jsxs)(eI.Fragment,{children:["weekly"===e.frequency&&(0,eI.jsx)("select",{"aria-label":"Day of week",value:e.dayOfWeek,onChange:e=>n({dayOfWeek:Number(e.target.value)}),className:s,children:CJ.map((e,t)=>(0,eI.jsx)("option",{value:t,children:e},e))}),"monthly"===e.frequency&&(0,eI.jsx)("select",{"aria-label":"Day of month",value:e.dayOfMonth,onChange:e=>n({dayOfMonth:Number(e.target.value)}),className:s,children:Array.from({length:28},(e,t)=>t+1).map(e=>(0,eI.jsxs)("option",{value:e,children:["Day ",e]},e))}),(0,eI.jsx)("span",{className:"hidden text-xs text-muted-foreground sm:block",children:"at"}),(0,eI.jsxs)("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-1 sm:col-span-2 sm:w-32",children:[(0,eI.jsx)(nB,{"aria-label":"Hour",type:"number",min:0,max:23,value:e.hour,onChange:e=>n({hour:Number(e.target.value)}),className:"h-9 text-center font-mono tabular-nums"}),(0,eI.jsx)("span",{className:"font-mono text-muted-foreground",children:":"}),(0,eI.jsx)(nB,{"aria-label":"Minute",type:"number",min:0,max:59,value:e.minute,onChange:e=>n({minute:Number(e.target.value)}),className:"h-9 text-center font-mono tabular-nums"})]})]})]}),"custom"===e.frequency&&(0,eI.jsx)(nB,{type:"text",value:e.custom,onChange:e=>n({custom:e.target.value}),placeholder:"0 9 * * 1-5",spellCheck:!1,"aria-invalid":!!r,"aria-describedby":"schedule-cron-help",className:"h-9 font-mono text-sm"}),(0,eI.jsxs)("div",{id:"schedule-cron-help",className:nf("flex items-center gap-1.5 text-xs",r?"text-destructive":"text-muted-foreground"),children:[(0,eI.jsx)(CV,{className:"size-3.5 shrink-0","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"min-w-0 truncate",children:r??C4(C1(e))})]})]})}function Re({template:e,onSelect:t,compact:r}){let n=e.icon;return(0,eI.jsxs)("button",{type:"button",onClick:()=>t(e),className:nf("hover:border-[var(--brand)]/40 group flex w-full min-w-0 items-start gap-2 rounded-md border border-border bg-[var(--color-surface)] text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r?"px-2.5 py-2":"px-3 py-2.5"),children:[(0,eI.jsx)("span",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-[var(--brand)] group-hover:bg-background",children:(0,eI.jsx)(n,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("span",{className:"block truncate text-sm font-medium",children:e.label}),!r&&(0,eI.jsx)("span",{className:"mt-0.5 line-clamp-2 text-xs leading-snug text-muted-foreground",children:e.description}),(0,eI.jsx)("span",{className:"mt-1 block text-[11px] text-muted-foreground",children:C4(e.schedule)})]})]})}function Rt({initialTemplate:e,initialTask:t,onSaved:r,onCancel:n}){let a,i=!!t,[s,o]=(0,eC.useState)(t?.name??e?.name??""),[l,c]=(0,eC.useState)(t?.prompt??e?.prompt??""),[u,d]=(0,eC.useState)(()=>t?C2(t.schedule):e?C2(e.schedule):{...CQ}),[p,m]=(0,eC.useState)(!1),h=(0,eC.useRef)(null),f=C1(u),g="custom"===u.frequency?(a=f.trim())?5!==a.split(/\s+/).length?"Use five cron fields: minute hour day month weekday.":null:"Enter a cron expression.":null,b=!!(s.trim()&&l.trim()&&!g);(0,eC.useEffect)(()=>{h.current?.focus()},[]);let y=async e=>{if(e.preventDefault(),!s.trim())return void c6.toast.error("Task name is required.");if(!l.trim())return void c6.toast.error("Task description is required.");if(g)return void c6.toast.error(g);m(!0);try{if(t){let e=await IN({cronId:t.cron_id,name:s.trim(),prompt:l.trim(),schedule:f});e.oldTaskDeleted?c6.toast.success(`"${s.trim()}" updated.`):c6.toast.warning(`"${s.trim()}" was saved, but the old scheduled task could not be removed.`),r(e.task)}else await Ik({name:s.trim(),prompt:l.trim(),schedule:f}),c6.toast.success(`"${s.trim()}" scheduled.`),r()}catch(e){c6.toast.error(e instanceof Error?e.message:i?"Failed to update scheduled task.":"Failed to create scheduled task.")}finally{m(!1)}};return(0,eI.jsxs)("form",{onSubmit:y,className:"flex h-full min-h-0 flex-col",children:[(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)("button",{type:"button",onClick:n,"aria-label":"Back to scheduled tasks",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring md:hidden",children:(0,eI.jsx)(CG,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("h2",{className:"truncate text-sm font-semibold",children:i?"Edit scheduled task":"New scheduled task"}),(0,eI.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:"EvoScientist will run this task description unattended."})]})]}),(0,eI.jsx)(sc,{className:"min-h-0 flex-1",children:(0,eI.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 p-3 sm:p-5",children:[(0,eI.jsxs)("div",{className:"space-y-1.5",children:[(0,eI.jsx)(C8,{htmlFor:"scheduled-task-name",children:"Task name"}),(0,eI.jsx)(nB,{id:"scheduled-task-name",ref:h,type:"text",value:s,onChange:e=>o(e.target.value),placeholder:"Daily Briefing",autoComplete:"off"})]}),(0,eI.jsxs)("div",{className:"space-y-1.5",children:[(0,eI.jsx)(C8,{htmlFor:"scheduled-task-prompt",children:"Task description"}),(0,eI.jsx)(_X,{id:"scheduled-task-prompt",value:l,onChange:e=>c(e.target.value),placeholder:"Describe what EvoScientist should do each time this task runs...",rows:9,className:"min-h-52 resize-y leading-relaxed"})]}),(0,eI.jsxs)("div",{className:"space-y-1.5",children:[(0,eI.jsx)(C8,{children:"Schedule"}),(0,eI.jsx)(C7,{value:u,onChange:d,error:g})]})]})}),(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-end gap-2 border-t border-border bg-background px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)(nP,{type:"button",variant:"outline",size:"sm",onClick:n,disabled:p,children:"Cancel"}),(0,eI.jsxs)(nP,{type:"submit",size:"sm",disabled:p||!b,children:[p?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin"}):i?(0,eI.jsx)(iR,{className:"size-3.5"}):(0,eI.jsx)(CZ,{className:"size-3.5"}),i?"Save changes":"Create task"]})]})]})}function Rr({task:e,onBack:t,onEdit:r,onDeleted:n}){let a,[i,s]=(0,eC.useState)(!1),[o,l]=(0,eC.useState)(!1),[c,u]=(0,eC.useState)(!1),d=C9(e.next_run_date),p=(0,eC.useCallback)(async()=>{s(!0);try{await II(e.prompt),c6.toast.success(`"${e.name}" started.`)}catch(e){c6.toast.error(e instanceof Error?e.message:"Failed to start the task.")}finally{s(!1)}},[e]),m=(0,eC.useCallback)(async()=>{u(!0);try{await IA(e.cron_id),c6.toast.success(`"${e.name}" deleted.`),l(!1),n()}catch(e){c6.toast.error(e instanceof Error?e.message:"Failed to delete the task.")}finally{u(!1)}},[e,n]);return(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-2 border-b border-border px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)("button",{type:"button",onClick:t,"aria-label":"Back to scheduled tasks",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring md:hidden",children:(0,eI.jsx)(CG,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("h2",{className:"truncate text-sm font-semibold",children:e.name}),(0,eI.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:C4(e.schedule)})]}),(0,eI.jsxs)(nP,{size:"sm",onClick:p,disabled:i||!e.prompt.trim(),children:[i?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin"}):(0,eI.jsx)(CK,{className:"size-3.5"}),"Run now"]})]}),(0,eI.jsx)(sc,{className:"min-h-0 flex-1",children:(0,eI.jsxs)("div",{className:"mx-auto w-full max-w-3xl space-y-4 p-3 sm:p-5",children:[(0,eI.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3",children:[(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-[var(--color-surface)] px-3 py-2",children:[(0,eI.jsx)("p",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:"Next run"}),(0,eI.jsx)("p",{className:"mt-1 truncate text-sm font-medium tabular-nums",title:d,children:e.next_run_date?`${C3(e.next_run_date)} \xb7 ${C6(e.next_run_date)}`:"Not scheduled"})]}),(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-[var(--color-surface)] px-3 py-2",children:[(0,eI.jsx)("p",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:"Cron"}),(0,eI.jsx)("p",{className:"mt-1 truncate font-mono text-sm",children:e.schedule})]}),(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-[var(--color-surface)] px-3 py-2",children:[(0,eI.jsx)("p",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:"Created"}),(0,eI.jsx)("p",{className:"mt-1 truncate text-sm",children:Number.isNaN((a=new Date(e.created_at)).getTime())?"Unknown":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(a)})]})]}),(0,eI.jsxs)("section",{className:"space-y-1.5",children:[(0,eI.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Task description"}),(0,eI.jsx)("div",{className:"max-h-[min(38rem,55vh)] overflow-auto rounded-md border border-border bg-[var(--color-surface)] px-3 py-2.5",children:e.prompt?(0,eI.jsx)("p",{className:"whitespace-pre-wrap break-words text-sm leading-relaxed",children:e.prompt}):(0,eI.jsx)("p",{className:"text-sm italic text-muted-foreground",children:"No task description stored."})})]})]})}),(0,eI.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-between gap-2 border-t border-border bg-background px-3 py-2.5 sm:px-5",children:[(0,eI.jsx)("p",{className:"hidden truncate text-xs text-muted-foreground sm:block",children:"Manual runs create a scheduler thread immediately."}),(0,eI.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:r,"aria-label":`Edit scheduled task "${e.name}"`,children:[(0,eI.jsx)(iR,{className:"size-3.5"}),"Edit"]}),(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:()=>l(!0),"aria-label":`Delete scheduled task "${e.name}"`,className:"text-destructive hover:border-destructive hover:text-destructive",children:[(0,eI.jsx)(iM,{className:"size-3.5"}),"Delete"]})]})]})]}),(0,eI.jsx)(ng,{open:o,onOpenChange:e=>{c||l(e)},children:(0,eI.jsxs)(nE,{className:"sm:max-w-sm",children:[(0,eI.jsxs)(n_,{children:[(0,eI.jsx)(nx,{children:"Delete scheduled task?"}),(0,eI.jsxs)(nT,{children:["“",e.name,"” will stop running. This cannot be undone."]})]}),(0,eI.jsxs)(nv,{children:[(0,eI.jsx)(nP,{variant:"outline",size:"sm",onClick:()=>l(!1),disabled:c,children:"Cancel"}),(0,eI.jsxs)(nP,{variant:"destructive",size:"sm",onClick:m,disabled:c,"aria-label":`Confirm delete scheduled task "${e.name}"`,children:[c&&(0,eI.jsx)(iI,{className:"size-3.5 animate-spin"}),"Delete"]})]})]})})]})}function Rn({task:e,active:t,onSelect:r}){let n=e.next_run_date;return(0,eI.jsxs)("button",{type:"button",onClick:r,"aria-current":t,className:nf("flex w-full items-start gap-2 rounded-md px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t?"bg-accent":"hover:bg-accent/60"),children:[(0,eI.jsx)("span",{className:"mt-1 flex size-2 shrink-0 rounded-full bg-[var(--brand)]"}),(0,eI.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,eI.jsx)("span",{className:"block truncate text-sm font-medium",children:e.name}),(0,eI.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:C4(e.schedule)}),(0,eI.jsxs)("span",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,eI.jsx)(iA,{className:"size-3 shrink-0","aria-hidden":"true"}),(0,eI.jsx)("span",{className:"truncate tabular-nums",title:C9(n),children:n?C3(n):"No next run"})]})]}),(0,eI.jsx)(Io,{className:"mt-1 size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"})]})}function Ra(){let{tasks:e,loading:t,error:r,refresh:n}=function(){let[e,t]=(0,eC.useState)([]),[r,n]=(0,eC.useState)(!0),[a,i]=(0,eC.useState)(null),[s,o]=(0,eC.useState)(0),l=(0,eC.useCallback)(()=>o(e=>e+1),[]);return(0,eC.useEffect)(()=>{let e=!1;return n(!0),Iw().then(r=>{e||(t(r),i(null))}).catch(r=>{e||(i(r instanceof Error?r.message:"Failed to load scheduled tasks."),t([]))}).finally(()=>{e||n(!1)}),()=>{e=!0}},[s]),{tasks:e,loading:r,error:a,refresh:l}}(),[a,i]=(0,eC.useState)({kind:"empty"}),[s,o]=(0,eC.useState)(""),l=(0,eC.useRef)(0),c=(0,eC.useRef)(0),u=(0,eC.useRef)(null),d=(0,eC.useMemo)(()=>[...e].sort((e,t)=>{let r=e.next_run_date?new Date(e.next_run_date).getTime():0,n=t.next_run_date?new Date(t.next_run_date).getTime():0;return r&&n&&r!==n?r-n:r&&!n?-1:!r&&n?1:e.name.localeCompare(t.name)}),[e]),p=(0,eC.useMemo)(()=>{let e=s.trim().toLowerCase();return e?d.filter(t=>[t.name,t.prompt,t.schedule,C4(t.schedule),t.next_run_date?C6(t.next_run_date):""].join(" ").toLowerCase().includes(e)):d},[s,d]),m=d.find(e=>e.next_run_date),h="detail"===a.kind?a.task.cron_id:null;(0,eC.useEffect)(()=>{if(!h||t)return;let n=e.find(e=>e.cron_id===h);if(n){u.current===h&&(u.current=null),i({kind:"detail",task:n});return}(u.current!==h||r)&&(u.current=null,i({kind:"empty"}))},[r,t,h,e]);let f=(0,eC.useCallback)(e=>{l.current+=1,i({kind:"create",template:e,createId:l.current})},[]),g=(0,eC.useCallback)(e=>{c.current+=1,i({kind:"edit",task:e,editId:c.current})},[]),b=(0,eC.useCallback)(e=>{u.current=e?.cron_id??null,n(),i(e?{kind:"detail",task:e}:{kind:"empty"})},[n]),y=(0,eC.useCallback)(()=>{n(),i({kind:"empty"})},[n]);return(0,eI.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,eI.jsxs)("header",{className:"flex flex-shrink-0 items-center justify-between gap-3 border-b border-border px-3 py-2.5 sm:px-4",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-accent text-[var(--brand)]",children:(0,eI.jsx)(CV,{className:"size-4","aria-hidden":"true"})}),(0,eI.jsxs)("div",{className:"min-w-0",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)("h1",{className:"truncate text-sm font-semibold",children:"Scheduled"}),!t&&(0,eI.jsx)("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e.length})]}),(0,eI.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:m?.next_run_date?`Next: ${C3(m.next_run_date)}`:"Recurring EvoScientist tasks"})]})]}),(0,eI.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,eI.jsx)("button",{type:"button",onClick:n,disabled:t,"aria-label":"Refresh scheduled tasks",title:"Refresh scheduled tasks",className:"rounded-md p-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:(0,eI.jsx)(CT,{className:nf("size-4",t&&"animate-spin"),"aria-hidden":"true"})}),(0,eI.jsxs)(nP,{size:"sm",onClick:()=>f(),children:[(0,eI.jsx)(CZ,{className:"size-3.5"}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:"New task"}),(0,eI.jsx)("span",{className:"sm:hidden",children:"New"})]})]})]}),(0,eI.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,eI.jsxs)("aside",{className:nf("w-full min-w-0 flex-col border-r border-border md:flex md:w-72 md:flex-shrink-0","empty"===a.kind?"flex":"hidden"),children:[(0,eI.jsx)("div",{className:"flex-shrink-0 space-y-2 border-b border-border p-2.5",children:(0,eI.jsxs)("div",{className:"relative",children:[(0,eI.jsx)(iP,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)(nB,{type:"search",name:"scheduled-search",value:s,onChange:e=>o(e.target.value),placeholder:"Search scheduled tasks...","aria-label":"Search scheduled tasks",autoComplete:"off",spellCheck:!1,className:"h-9 pl-8 pr-8"}),s&&(0,eI.jsx)("button",{type:"button",onClick:()=>o(""),"aria-label":"Clear scheduled task search",className:"absolute right-1 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(rF,{className:"size-3.5","aria-hidden":"true"})})]})}),(0,eI.jsx)(sc,{className:"h-0 flex-1",children:t?(0,eI.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading tasks..."]}):r?(0,eI.jsxs)("div",{role:"alert",className:"space-y-3 p-3",children:[(0,eI.jsx)("p",{className:"text-sm text-destructive",children:r}),(0,eI.jsxs)(nP,{variant:"outline",size:"sm",onClick:n,children:[(0,eI.jsx)(CT,{className:"size-3.5"}),"Retry"]})]}):0===e.length?(0,eI.jsxs)("div",{className:"space-y-4 p-3",children:[(0,eI.jsxs)("div",{className:"rounded-md border border-dashed border-border bg-[var(--color-surface)] px-3 py-5 text-center",children:[(0,eI.jsx)(Cq,{className:"mx-auto size-7 text-muted-foreground/60","aria-hidden":"true"}),(0,eI.jsx)("p",{className:"mt-2 text-sm font-medium",children:"No scheduled tasks"}),(0,eI.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Start from a template or create one from scratch."})]}),(0,eI.jsxs)("div",{className:"space-y-2",children:[(0,eI.jsx)("p",{className:"px-1 text-[11px] font-semibold uppercase text-muted-foreground",children:"Templates"}),C5.map(e=>(0,eI.jsx)(Re,{template:e,onSelect:f},e.label))]})]}):0===p.length?(0,eI.jsxs)("div",{className:"space-y-3 p-4 text-center",children:[(0,eI.jsx)("p",{className:"text-sm font-medium",children:"No matching tasks"}),(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"Try a task name, schedule, or description keyword."}),(0,eI.jsx)(nP,{variant:"outline",size:"sm",onClick:()=>o(""),children:"Clear search"})]}):(0,eI.jsxs)("div",{className:"p-1.5",children:[(0,eI.jsxs)("div",{className:"mb-2 flex items-center justify-between px-2 py-1",children:[(0,eI.jsx)("p",{className:"text-[11px] font-semibold uppercase text-muted-foreground",children:"Tasks"}),(0,eI.jsx)("p",{className:"text-[11px] text-muted-foreground",children:p.length})]}),(0,eI.jsx)("div",{className:"flex flex-col gap-0.5",children:p.map(e=>{let t="detail"===a.kind&&a.task.cron_id===e.cron_id;return(0,eI.jsx)(Rn,{task:e,active:t,onSelect:()=>i({kind:"detail",task:e})},e.cron_id)})}),(0,eI.jsxs)("div",{className:"mt-3 space-y-2 border-t border-border px-1 py-3",children:[(0,eI.jsx)("p",{className:"px-1 text-[11px] font-semibold uppercase text-muted-foreground",children:"Templates"}),(0,eI.jsx)("div",{className:"grid gap-1.5",children:C5.map(e=>(0,eI.jsx)(Re,{template:e,onSelect:f,compact:!0},e.label))})]})]})})]}),(0,eI.jsxs)("section",{className:nf("min-w-0 flex-1 flex-col","empty"===a.kind?"hidden md:flex":"flex"),children:["empty"===a.kind&&(0,eI.jsx)("div",{className:"flex flex-1 items-center justify-center p-5",children:(0,eI.jsxs)("div",{className:"w-full max-w-lg space-y-4",children:[(0,eI.jsxs)("div",{className:"space-y-1 text-center",children:[(0,eI.jsx)(CV,{className:"mx-auto size-9 text-muted-foreground/40","aria-hidden":"true"}),(0,eI.jsx)("p",{className:"text-sm font-medium",children:"Pick a scheduled task"}),(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:"Pick a template below, or ask EvoScientist in chat to create a recurring task."})]}),e.length>0&&(0,eI.jsx)("div",{className:"mx-auto grid w-full max-w-xl gap-2 sm:grid-cols-2",children:C5.map(e=>(0,eI.jsx)(Re,{template:e,onSelect:f,compact:!0},e.label))})]})}),"create"===a.kind&&(0,eI.jsx)(Rt,{initialTemplate:a.template,onSaved:b,onCancel:()=>i({kind:"empty"})},a.createId),"edit"===a.kind&&(0,eI.jsx)(Rt,{initialTask:a.task,onSaved:b,onCancel:()=>i({kind:"detail",task:a.task})},a.editId),"detail"===a.kind&&(0,eI.jsx)(Rr,{task:a.task,onBack:()=>i({kind:"empty"}),onEdit:()=>g(a.task),onDeleted:y})]})]})]})}let Ri=rj("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),Rs=rj("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);function Ro(){let{resolvedTheme:e,setTheme:t}=(0,N$.useTheme)(),[r,n]=(0,eC.useState)(!1);(0,eC.useEffect)(()=>n(!0),[]);let a=r&&"dark"===e;return(0,eI.jsx)(nP,{variant:"ghost",size:"icon",className:"size-8 sm:size-9",onClick:()=>t(a?"light":"dark"),"aria-label":a?"Switch to light mode":"Switch to dark mode",title:a?"Switch to light mode":"Switch to dark mode",children:a?(0,eI.jsx)(Ri,{className:"size-5","aria-hidden":"true"}):(0,eI.jsx)(Rs,{className:"size-5","aria-hidden":"true"})})}let Rl={checking:{dot:"bg-[var(--color-warning)]",label:"Connecting…",pulse:!0},online:{dot:"bg-[var(--color-success)]",label:"Connected",pulse:!1},offline:{dot:"bg-[var(--color-error)]",label:"Offline",pulse:!1}};function Rc(e){return e.trim().replace(/\/+$/,"")}async function Ru(e){let t=new AbortController,r=setTimeout(()=>t.abort(),4e3);try{return(await fetch(`${e}/info`,{signal:t.signal,cache:"no-store"})).ok}catch{return!1}finally{clearTimeout(r)}}function Rd({deploymentUrl:e,onReconnect:t}){let[r,n]=(0,eC.useState)("checking"),[a,i]=(0,eC.useState)(null),[s,o]=(0,eC.useState)(null),l=(0,eC.useRef)(0),c=(0,eC.useRef)(!0),u=(0,eC.useRef)(null),d=(0,eC.useCallback)(async t=>{let r=Rc(e);try{let e=await fetch("/api/evosci-config",{cache:"no-store"}),n=await e.json().catch(()=>null),a=n?.deploymentUrl?Rc(n.deploymentUrl):"";if(t!==l.current||!c.current)return;if(!a||a===r)return void o(null);let i=await Ru(a);if(t!==l.current||!c.current)return;o(i?a:null)}catch{t===l.current&&c.current&&o(null)}},[e]),p=(0,eC.useCallback)(async()=>{let t=++l.current,r=Rc(e);if(!r){t===l.current&&c.current&&(i(null),n("offline"),o(null));return}u.current?.abort();let a=new AbortController;u.current=a;let s=setTimeout(()=>a.abort(),4e3);try{let e=await fetch(`${r}/info`,{signal:a.signal,cache:"no-store"});if(t!==l.current||!c.current)return;if(!e.ok){n("offline"),d(t);return}let s=await e.json().catch(()=>null);if(t!==l.current||!c.current)return;i(s),n("online"),o(null)}catch{t===l.current&&c.current&&(n("offline"),d(t))}finally{clearTimeout(s)}},[e,d]);(0,eC.useEffect)(()=>{c.current=!0,n("checking"),p();let e=setInterval(()=>{document.hidden||p()},1e4),t=()=>p(),r=()=>{document.hidden||p()};return window.addEventListener("focus",t),window.addEventListener("online",t),document.addEventListener("visibilitychange",r),()=>{c.current=!1,u.current?.abort(),clearInterval(e),window.removeEventListener("focus",t),window.removeEventListener("online",t),document.removeEventListener("visibilitychange",r)}},[p]);let m=Rl[r],h="online"===r?`Connected to ${e}${a?.version?` \xb7 langgraph ${a.version}`:""}`:"offline"===r?`Can't reach the backend at ${e}. Is "EvoSci deploy" running? Click to retry.`:`Checking connection to ${e}…`;return(0,eI.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eI.jsxs)(nP,{variant:"ghost",size:"sm",onClick:p,title:h,"aria-label":h,className:"h-8 gap-1.5 px-2 text-xs font-normal text-muted-foreground",children:[(0,eI.jsx)("span",{className:`size-2 shrink-0 rounded-full ${m.dot} ${m.pulse?"animate-pulse":""}`,"aria-hidden":"true"}),(0,eI.jsx)("span",{className:"hidden sm:inline",children:m.label})]}),"offline"===r&&null!==s&&void 0!==t&&(0,eI.jsxs)(nP,{variant:"ghost",size:"sm",onClick:()=>{s&&(o(null),n("checking"),t?.(s))},title:`Backend detected at ${s}. Click to reconnect.`,"aria-label":`Reconnect to detected backend ${s}`,className:"h-8 gap-1 px-2 text-xs font-medium text-[var(--brand)] hover:text-[var(--brand)]",children:["Reconnect"," ",(0,eI.jsx)("span",{className:"tabular-nums",children:s?function(e){try{let t=new URL(e),r="127.0.0.1"===t.hostname||"localhost"===t.hostname||"0.0.0.0"===t.hostname,n=t.port||("https:"===t.protocol?"443":"80");return r?`:${n}`:`${t.hostname}:${n}`}catch{return e}}(s):""})]})]})}let Rp=rj("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);async function Rm(e){let t=await fetch(`/api/workspace?${new URLSearchParams({path:e})}`),r=await t.json().catch(()=>null);if(!t.ok)throw Error(r?.error||"Failed to list workspace.");return r?.entries??[]}async function Rh(){let e=await fetch("/api/workspace?recursive=1"),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||"Failed to load workspace.");return{entries:t?.entries??[],truncated:!!t?.truncated}}let Rf=[{key:"docs",label:"Papers & docs",Icon:I6,exts:["pdf","tex","bib","md","markdown","txt","docx","doc","rtf","odt"]},{key:"figures",label:"Figures",Icon:rj("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),exts:["png","jpg","jpeg","gif","svg","webp","bmp","tiff","tif","eps"]},{key:"data",label:"Data",Icon:rj("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),exts:["json","jsonl","csv","tsv","xlsx","xls","parquet","pkl","npy","npz","h5","hdf5","db","sqlite","yaml","yml","xml"]},{key:"code",label:"Code",Icon:rj("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),exts:["py","ipynb","js","ts","tsx","jsx","sh","bash","r","jl","cpp","cc","c","h","hpp","java","go","rs","m","rb"]}],Rg={key:"other",label:"Other",Icon:_C},Rb={};for(let e of Rf)for(let t of e.exts)Rb[t]=e.key;function Ry(){let[e,t]=(0,eC.useState)("tree"),[r,n]=(0,eC.useState)({}),[a,i]=(0,eC.useState)(new Set),[s,o]=(0,eC.useState)(new Set),[l,c]=(0,eC.useState)(!1),[u,d]=(0,eC.useState)(null),[p,m]=(0,eC.useState)(!1),[h,f]=(0,eC.useState)(!1),[g,b]=(0,eC.useState)(null),[y,E]=(0,eC.useState)(null),_=(0,eC.useCallback)(async e=>{o(t=>new Set(t).add(e));try{let t=await Rm(e);return n(r=>({...r,[e]:t})),""===e&&b(null),t}catch(t){throw""===e&&b(t instanceof Error?t.message:"Failed to load."),t}finally{o(t=>{let r=new Set(t);return r.delete(e),r})}},[]),v=(0,eC.useCallback)(async()=>{m(!0);try{let{entries:e,truncated:t}=await Rh();d(e),f(t),b(null)}catch(e){b(e instanceof Error?e.message:"Failed to load.")}finally{m(!1)}},[]);(0,eC.useEffect)(()=>{c(!0),_("").catch(()=>{}).finally(()=>c(!1))},[]),(0,eC.useEffect)(()=>{"type"!==e||null!==u||p||v()},[e]);let x=(0,eC.useCallback)(async()=>{(b(null),"type"===e)?await v():(c(!0),await Promise.allSettled(["",...a].map(e=>_(e))),c(!1))},[e,a,_,v]),T=(0,eC.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),r[e]||_(e).catch(()=>{})),n})},[r,_]),S=(0,eC.useMemo)(()=>{let e={};for(let t of u??[]){let r=Rb[t.ext]??Rg.key;(e[r]??=[]).push(t)}for(let t of Object.values(e))t.sort((e,t)=>t.mtime-e.mtime);return e},[u]),w="type"===e?p:l,k=(e,t)=>{let n=r[e];return n?0===n.length&&0===t?(0,eI.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"No files in the workspace yet"}):n.map(e=>{let r=a.has(e.path),n=s.has(e.path);return(0,eI.jsxs)("div",{children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>"dir"===e.type?T(e.path):E({path:e.path,size:e.size}),className:"flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-sm text-foreground transition-colors hover:bg-muted",style:{paddingLeft:`${14*t+4}px`},title:e.name,children:["dir"===e.type?(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground",children:n?(0,eI.jsx)(iI,{className:"size-3 animate-spin"}):r?(0,eI.jsx)(lB,{className:"size-3.5"}):(0,eI.jsx)(Io,{className:"size-3.5"})}),(0,eI.jsx)(Rp,{className:"size-4 shrink-0 text-[var(--brand)]"})]}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)("span",{className:"size-4 shrink-0"}),(0,eI.jsx)(I6,{className:"size-4 shrink-0 text-muted-foreground"})]}),(0,eI.jsx)("span",{className:"truncate",children:e.name})]}),"dir"===e.type&&r&&k(e.path,t+1)]},e.path)}):null};return(0,eI.jsxs)("div",{className:"flex min-h-0 flex-col",children:[(0,eI.jsxs)("div",{className:"flex items-center justify-between gap-2 pb-1.5",children:[(0,eI.jsx)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted p-0.5 text-xs",children:["tree","type"].map(r=>(0,eI.jsx)("button",{type:"button",onClick:()=>t(r),className:nf("rounded px-2 py-0.5 font-medium transition-colors",e===r?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),"aria-pressed":e===r,children:"tree"===r?"Tree":"By type"},r))}),(0,eI.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,eI.jsxs)("a",{href:"/api/workspace/download",download:!0,className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:"Download the whole workspace as a zip",children:[(0,eI.jsx)(iN,{className:"size-3.5"}),"All"]}),(0,eI.jsx)("button",{type:"button",onClick:x,disabled:w,className:"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50","aria-label":"Refresh workspace",title:"Refresh",children:(0,eI.jsx)(CT,{className:nf("size-3.5",w&&"animate-spin")})})]})]}),g?(0,eI.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:g}):"tree"===e?l&&!r[""]?(0,eI.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,eI.jsx)(iI,{className:"size-4 animate-spin text-muted-foreground"})}):(0,eI.jsx)("div",{className:"-mx-1",children:k("",0)}):p&&null===u?(0,eI.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,eI.jsx)(iI,{className:"size-4 animate-spin text-muted-foreground"})}):(()=>{if(!u)return null;if(0===u.length)return(0,eI.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"No files in the workspace yet"});let e=[...Rf,Rg];return(0,eI.jsxs)("div",{className:"space-y-3",children:[h&&(0,eI.jsx)("p",{className:"px-1 text-[11px] text-muted-foreground",children:"Showing the first files only — the workspace has more than the limit."}),e.map(e=>{let t=S[e.key];if(!t||0===t.length)return null;let r=e.Icon;return(0,eI.jsxs)("div",{children:[(0,eI.jsxs)("div",{className:"mb-0.5 flex items-center gap-1.5 px-1 text-[10px] font-semibold uppercase tracking-wider text-tertiary",children:[(0,eI.jsx)(r,{className:"size-3.5"}),e.label,(0,eI.jsxs)("span",{className:"text-muted-foreground",children:["(",t.length,")"]})]}),t.map(e=>{let t=e.path.includes("/")?e.path.slice(0,e.path.lastIndexOf("/")):"";return(0,eI.jsxs)("button",{type:"button",onClick:()=>E({path:e.path,size:e.size}),className:"flex w-full items-center gap-1.5 rounded-md px-1 py-1 text-left text-sm text-foreground transition-colors hover:bg-muted",title:e.path,children:[(0,eI.jsx)(r,{className:"size-4 shrink-0 text-muted-foreground"}),(0,eI.jsx)("span",{className:"truncate",children:e.name}),t&&(0,eI.jsx)("span",{className:"ml-auto shrink-0 truncate pl-2 text-[11px] text-muted-foreground",children:t})]},e.path)})]},e.key)})]})})(),(0,eI.jsx)(Cl,{path:y?.path??null,size:y?.size,onClose:()=>E(null),onChanged:x})]})}let RE=rj("bell-ring",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]),R_=rj("corner-up-left",[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]);function Rv(e){let t="";for(let r of e)if("human"===r.type){let e=_y(r).trim();if(e){t=e;break}}return{prompt:t,steps:function(e){let t=[];for(let r of e)if("ai"===r.type){let e=_b(r.content).trim();for(let n of(e&&t.push({kind:"text",text:e}),function(e){let t=[];if(Array.isArray(e.tool_calls)&&e.tool_calls.length>0){for(let r of e.tool_calls)t.push({id:r.id??"",name:r.name??"tool",args:r.args&&"object"==typeof r.args?r.args:{}});return t}let r=e.additional_kwargs?.tool_calls;if(Array.isArray(r))for(let e of r){let r={},n=e.function?.arguments;if(n&&"object"==typeof n)r=n;else if("string"==typeof n)try{let e=JSON.parse(n);e&&"object"==typeof e&&(r=e)}catch{r={input:n}}t.push({id:e.id??"",name:e.function?.name??"tool",args:r})}return t}(r)))t.push({kind:"tool_call",id:n.id,name:n.name,args:n.args})}else"tool"===r.type&&t.push({kind:"tool_result",toolCallId:r.tool_call_id??"",name:r.name??"tool",text:_b(r.content).trim()});return t}(e)}}function Rx({status:e}){let t=Ir[N5(e)];return(0,eI.jsx)("span",{className:nf("size-2 shrink-0 rounded-full",t.dot,t.pulse&&"animate-pulse"),"aria-hidden":"true"})}function RT({onReportToMainChat:e}){let t=ao(),[r]=e$("threadId"),{tasks:n,loaded:a,error:i,refresh:s}=IH(r),[o,l]=(0,eC.useState)(()=>Date.now()),[c,u]=(0,eC.useState)(null),[d,p]=(0,eC.useState)({}),m=(0,eC.useRef)(new Map),[h,f]=(0,eC.useState)({}),[g,b]=IJ(r),[y,E]=(0,eC.useState)({}),[_,v]=(0,eC.useState)({}),[x,T]=(0,eC.useState)({}),S=(0,eC.useRef)(!0);(0,eC.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,eC.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[]);let w=async e=>{let r=(y[e.task_id]??"").trim();if(r&&!_[e.task_id]){v(t=>({...t,[e.task_id]:!0})),T(t=>({...t,[e.task_id]:null}));try{let n=await t.runs.wait(e.thread_id,e.agent_name,{input:{messages:[{type:"human",content:r}]}});if(!S.current)return;let a=Array.isArray(n?.messages)?n.messages:[];if(0===a.length)return void T(t=>({...t,[e.task_id]:"The agent didn't return a reply — it may have hit an error."}));E(t=>({...t,[e.task_id]:""}));let{prompt:i,steps:s}=Rv(a);p(t=>({...t,[e.task_id]:{loading:!1,error:null,prompt:i,steps:s}}))}catch(r){if(!S.current)return;let t=r instanceof TypeError||"object"==typeof r&&null!==r&&"number"==typeof r.status;T(r=>({...r,[e.task_id]:t?"Couldn't reach this agent — try again.":"The agent hit an error processing this follow-up."}))}finally{S.current&&v(t=>({...t,[e.task_id]:!1}))}}};(0,eC.useEffect)(()=>{if(!c)return;let e=n.find(e=>e.task_id===c);if(!e||"expired"===N5(e.liveStatus))return;let r="running"===N5(e.liveStatus),a=[e.run_id,e.last_updated_at,e.endedAt].join(":");if(!r&&m.current.get(c)===a)return;let i=!1;return p(e=>({...e,[c]:{loading:!e[c],error:null,prompt:e[c]?.prompt??"",steps:e[c]?.steps??[]}})),(async()=>{try{let n=await t.threads.getState(e.thread_id);if(i)return;let{prompt:s,steps:o}=Rv(n.values?.messages??[]);r||m.current.set(c,a),p(e=>({...e,[c]:{loading:!1,error:null,prompt:s,steps:o}}))}catch{if(i)return;m.current.delete(c),p(e=>({...e,[c]:{loading:!1,error:"Couldn't load this agent's steps.",prompt:e[c]?.prompt??"",steps:e[c]?.steps??[]}}))}})(),()=>{i=!0}},[c,n,t]);let k=(0,eC.useMemo)(()=>Ia(n),[n]);return(0,eI.jsxs)("div",{className:"flex h-full flex-col",children:[(0,eI.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1 pb-2",children:[(0,eI.jsx)("p",{className:"text-xs text-muted-foreground",children:k>0?`${k} running`:n.length>0?`${n.length} total`:"Background agents"}),(0,eI.jsxs)("div",{className:"flex items-center gap-1",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>{r&&(g||IX(r,n.filter(e=>In(e.liveStatus)).map(N8)),b(!g))},"aria-pressed":g,"aria-label":`Auto-report ${g?"on":"off"}`,title:g?"Auto-report on: finished agents are sent to the main chat automatically":"Auto-report off: use each agent's “Notify main chat” button",className:nf("inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",g?"bg-accent text-[var(--brand)]":"text-muted-foreground hover:bg-accent hover:text-foreground"),children:[(0,eI.jsx)(RE,{className:"size-3.5","aria-hidden":"true"}),(0,eI.jsxs)("span",{className:"hidden min-[340px]:inline",children:["Auto-report ",g?"On":"Off"]})]}),(0,eI.jsx)("button",{type:"button",onClick:s,"aria-label":"Refresh agents",title:"Refresh",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:(0,eI.jsx)(CT,{className:"size-3.5","aria-hidden":"true"})})]})]}),i&&(0,eI.jsx)("p",{className:"px-1 text-xs text-[var(--color-error)]",children:i}),!a&&(0,eI.jsxs)("div",{className:"flex items-center gap-2 px-1 py-4 text-xs text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-4 animate-spin","aria-hidden":"true"}),"Loading…"]}),a&&0===n.length&&(0,eI.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 px-4 py-10 text-center",children:[(0,eI.jsx)(_U,{className:"size-9 text-muted-foreground/60","aria-hidden":"true"}),(0,eI.jsx)("p",{className:"text-sm text-muted-foreground",children:"No background agents yet."}),(0,eI.jsx)("p",{className:"text-xs text-muted-foreground/80",children:"When EvoScientist delegates long tasks (writing, data analysis) they run in the background and show up here."})]}),(0,eI.jsx)("div",{className:"flex min-h-0 flex-1 flex-col gap-1.5 overflow-y-auto",children:n.map(t=>{var n;let a,i,s,l=N5(t.liveStatus),p=Ir[l],m=c===t.task_id,b="expired"===l,v=d[t.task_id];return(0,eI.jsxs)("div",{className:"rounded-md border border-border bg-background",children:[(0,eI.jsxs)("button",{type:"button",onClick:()=>u(m?null:t.task_id),className:"flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","aria-expanded":m,children:[m?(0,eI.jsx)(lB,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,eI.jsx)(Io,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,eI.jsx)(Rx,{status:t.liveStatus}),(0,eI.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:N6[n=t.agent_name]??n}),(0,eI.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[p.label,(a=function(e,t){let r=N5(e.liveStatus);if("expired"===r)return"";let n="running"===r?t:e.endedAt?Date.parse(e.endedAt):t;return function(e,t){if(!e)return"";let r=Date.parse(e);if(Number.isNaN(r))return"";let n=Math.max(0,Math.round((t-r)/1e3)),a=Math.floor(n/60);if(a>=60){let e=Math.floor(a/60);return`${e}h ${a%60}m`}return a>0?`${a}m ${n%60}s`:`${n}s`}(e.startedAt??e.created_at,n)}(t,o))?` \xb7 ${a}`:""]})]}),m&&b&&(0,eI.jsx)("div",{className:"border-t border-border px-2.5 py-2 text-xs",children:(0,eI.jsx)("p",{className:"text-muted-foreground",children:"This task ran before a backend restart and its records are gone, so its steps and result can no longer be loaded. Any files it produced are still in the workspace."})}),m&&!b&&(0,eI.jsxs)("div",{className:"border-t border-border px-2.5 py-2 text-xs",children:[v?.loading&&(0,eI.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"Loading steps…"]}),v?.error&&(0,eI.jsx)("p",{className:"text-[var(--color-error)]",children:v.error}),v&&!v.loading&&!v.error&&(0,eI.jsxs)("div",{className:"flex flex-col gap-2",children:[v.prompt&&(0,eI.jsxs)("div",{children:[(0,eI.jsx)("p",{className:"font-semibold text-foreground",children:"Task"}),(0,eI.jsx)("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:v.prompt.length>600?v.prompt.slice(0,600)+"…":v.prompt})]}),(0,eI.jsxs)("div",{children:[(0,eI.jsxs)("p",{className:"mb-1 font-semibold text-foreground",children:["Steps"," ",(0,eI.jsxs)("span",{className:"font-normal text-muted-foreground",children:["(",v.steps.length,")"]})]}),0===v.steps.length?(0,eI.jsx)("p",{className:"text-muted-foreground",children:"No steps yet."}):(0,eI.jsx)(N3,{steps:v.steps,compact:!0})]}),In(t.liveStatus)&&(0,eI.jsx)("div",{className:"mt-1 border-t border-border pt-2",children:g?(0,eI.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,eI.jsx)(RE,{className:"size-3.5 text-[var(--brand)]","aria-hidden":"true"}),"Auto-report on · future completions notify the main chat"]}):(0,eI.jsxs)("button",{type:"button",onClick:()=>(t=>{if(!e||!r)return void c6.toast.error("Open the conversation to notify the main agent.");let n=e(t,r);if("sent"===n){f(e=>({...e,[N8(t)]:!0})),c6.toast.success("Reported to the main chat.");return}if("duplicate"===n){f(e=>({...e,[N8(t)]:!0})),c6.toast.info("This result is already in the main chat.");return}c6.toast.error("wrong-thread"===n?"The active conversation changed — reopen this task and try again.":"Main chat is busy — try again when it's idle.")})(t),disabled:!e||!!h[N8(t)],title:e?"Send this result back to the main agent":"Open the conversation to notify the main agent",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[(0,eI.jsx)(R_,{className:"size-3.5 text-[var(--brand)]","aria-hidden":"true"}),h[N8(t)]?"Reported to main chat":"Notify main chat"]})}),(i="running"===N5(t.liveStatus),s=!!_[t.task_id],(0,eI.jsxs)("div",{className:"mt-1 border-t border-border pt-2",children:[(0,eI.jsx)("p",{className:"mb-1 text-[11px] text-muted-foreground",children:"Direct follow-up · Main chat is not notified"}),(0,eI.jsxs)("form",{onSubmit:e=>{e.preventDefault(),w(t)},className:"flex items-center gap-1.5",children:[(0,eI.jsx)("input",{type:"text",name:`agent-message-${t.task_id}`,autoComplete:"off",value:y[t.task_id]??"",onChange:e=>E(r=>({...r,[t.task_id]:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&(e.nativeEvent.isComposing||229===e.keyCode)&&e.preventDefault()},disabled:i||s,placeholder:i?"Agent is working…":"Send a direct follow-up…","aria-label":"Message this agent",className:"min-w-0 flex-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60"}),(0,eI.jsx)("button",{type:"submit",disabled:i||s||!(y[t.task_id]??"").trim(),"aria-label":"Send",title:"Send to this agent",className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--brand-solid)] text-[var(--brand-foreground)] transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-40",children:s?(0,eI.jsx)(iI,{className:"size-3.5 animate-spin","aria-hidden":"true"}):(0,eI.jsx)(_A,{className:"size-3.5","aria-hidden":"true"})})]}),x[t.task_id]&&(0,eI.jsx)("p",{className:"mt-1 text-[var(--color-error)]",role:"status","aria-live":"polite",children:x[t.task_id]})]}))]})]})]},t.task_id)})})]})}function RS({onClose:e,onReportToMainChat:t}){let[r,n]=e$("inspectorTab"),a="agents"===r?"agents":"workspace";return(0,eI.jsxs)("div",{className:"flex h-full flex-col border-l border-border bg-sidebar",children:[(0,eI.jsxs)("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 border-b border-border px-2",children:[(0,eI.jsxs)("div",{role:"tablist","aria-label":"Inspector",className:"flex items-center gap-1",children:[(0,eI.jsxs)("button",{type:"button",role:"tab","aria-selected":"workspace"===a,onClick:()=>n(null),className:nf("flex items-center gap-1.5 rounded-md px-2 py-1 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","workspace"===a?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,eI.jsx)(_R,{className:"size-4 text-[var(--brand)]","aria-hidden":"true"}),"Workspace"]}),(0,eI.jsxs)("button",{type:"button",role:"tab","aria-selected":"agents"===a,onClick:()=>n("agents"),className:nf("flex items-center gap-1.5 rounded-md px-2 py-1 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","agents"===a?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,eI.jsx)(_U,{className:"size-4 text-[var(--brand)]","aria-hidden":"true"}),"Agents"]})]}),(0,eI.jsx)(nP,{variant:"ghost",size:"icon",className:"size-7",onClick:e,"aria-label":"Close inspector",title:"Close",children:(0,eI.jsx)(rF,{className:"size-4","aria-hidden":"true"})})]}),"agents"===a?(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden p-3",children:(0,eI.jsx)(RT,{onReportToMainChat:t})}):(0,eI.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:(0,eI.jsx)(Ry,{})})]})}function Rw({config:e,configDialogOpen:t,setConfigDialogOpen:r,handleSaveConfig:n}){let a=ao(),[i,s]=e$("threadId"),[o,l]=e$("sidebar"),[c,u]=e$("view"),[d,p]=e$("memoryTab"),[m,h]=e$("memoryObs"),[f,g]=e$("memoryExec"),[b,y]=e$("inspector"),[E,_]=e$("inspectorTab"),[v,x]=(0,eC.useState)(null),[T,S]=(0,eC.useState)(0),[w,k]=(0,eC.useState)(null),[A,N]=(0,eC.useState)(null),[I,C]=(0,eC.useState)(0),[R,O]=(0,eC.useState)(null),L=(0,eC.useCallback)(async()=>{let t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e.assistantId),r=async()=>{if(t)return await a.assistants.get(e.assistantId);let r=await a.assistants.search({graphId:e.assistantId,limit:100}),n=r.find(e=>e.metadata?.created_by==="system")??r[0];if(!n)throw Error("No assistant found for this graph.");return n};for(let e=0;e<3;e+=1)try{k(await r());return}catch(t){if(e<2){await new Promise(e=>setTimeout(e,700));continue}console.warn("Couldn't resolve the EvoScientist assistant; addressing the graph by id instead. Is the backend running?",t)}k({assistant_id:e.assistantId,graph_id:e.assistantId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),config:{},metadata:{},version:1,name:e.assistantId,context:{}})},[a,e.assistantId]);(0,eC.useEffect)(()=>{L()},[L]),(0,eC.useEffect)(()=>{let e=window.matchMedia("(min-width: 768px)"),t=()=>N(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,eC.useEffect)(()=>{!1===A&&o&&b&&y(null)},[b,A,y,o]);let D=(0,eC.useCallback)(()=>l(null),[l]),P=(0,eC.useCallback)(()=>{y(null),_(null)},[y,_]),M=(0,eC.useCallback)(()=>{o?l(null):(!1===A&&P(),l("1"))},[P,A,l,o]),j=(0,eC.useCallback)(()=>{b?P():(!1===A&&l(null),_(null),y("1"))},[P,b,A,y,_,l]),F=(0,eC.useCallback)(()=>{_("agents"),!1===A&&l(null),y("1")},[A,y,l,_]),U=c?o?"Hide navigation":"Show navigation":o?"Hide research":"Show research",B=(0,eC.useCallback)(()=>{Iz(null,!1),s(null),u(null),C(e=>e+1)},[s,u]),$=(0,eC.useCallback)(e=>{if("memory"===e.view)p(e.tab),h(e.obsId??null),g(e.execId??null),u("memory");else if("schedule"===e.view)u("schedule");else{if(b&&"agents"!==E)return void P();!1===A&&l(null),_(null),y("1")}},[P,b,E,A,y,_,g,h,p,l,u]),z=(0,eC.useCallback)(async e=>{Iz(null,!1),u(null);let t=i===e;await s(e),t||C(e=>e+1)},[s,u,i]);return(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nG,{open:t,onOpenChange:r,onSave:n,initialConfig:e}),(0,eI.jsxs)("div",{className:"flex h-screen flex-col",children:[(0,eI.jsxs)("header",{className:"flex h-14 items-center justify-between gap-2 border-b border-border px-2.5 sm:px-4",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2 sm:gap-3",children:[(0,eI.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,eI.jsx)(eR.default,{src:"/evoscientist-logo.png",alt:"EvoScientist",width:28,height:28,className:"size-6 shrink-0",priority:!0}),o&&(0,eI.jsx)("h1",{className:"truncate text-base font-semibold sm:text-lg",children:"EvoScientist"})]}),(0,eI.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,eI.jsxs)(nP,{variant:"ghost",size:"icon",onClick:M,"aria-label":U,className:"relative size-8",children:[o?(0,eI.jsx)(ad,{className:"size-5","aria-hidden":"true"}):(0,eI.jsx)(au,{className:"size-5","aria-hidden":"true"}),T>0&&(0,eI.jsx)("span",{className:"absolute right-0 top-0 inline-flex min-h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] text-destructive-foreground",children:T})]}),!o&&(0,eI.jsx)(nP,{variant:"ghost",size:"icon",onClick:B,"aria-label":"New chat",className:"size-8",children:(0,eI.jsx)(ac,{className:"size-5","aria-hidden":"true"})})]})]}),(0,eI.jsxs)("div",{className:"flex shrink-0 items-center gap-1 sm:gap-2",children:[(0,eI.jsx)(Rd,{deploymentUrl:e.deploymentUrl,onReconnect:t=>n({...e,deploymentUrl:t})}),(0,eI.jsx)(Ro,{}),(0,eI.jsx)(nP,{variant:"ghost",size:"icon",onClick:j,"aria-label":b?"Hide inspector":"Show workspace",title:b?"Hide inspector":"Show workspace",className:"size-8",children:b?(0,eI.jsx)(am,{className:"size-5","aria-hidden":"true"}):(0,eI.jsx)(ap,{className:"size-5","aria-hidden":"true"})}),(0,eI.jsx)(nP,{variant:"ghost",size:"icon",onClick:()=>r(!0),"aria-label":"Settings",title:"Settings",className:"size-8",children:(0,eI.jsx)(al,{className:"size-5","aria-hidden":"true"})})]})]}),(0,eI.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[o&&!1===A&&(0,eI.jsxs)("div",{className:"absolute inset-0 z-40 flex md:hidden",children:[(0,eI.jsx)("button",{type:"button","aria-label":"Close research",className:"absolute inset-0 bg-black/40",onClick:D}),(0,eI.jsx)("aside",{"aria-label":c?"Navigation":"Research navigation",className:"relative z-10 h-full w-[min(19rem,calc(100vw-2.25rem))] bg-background shadow-xl",children:(0,eI.jsx)(ui,{onClose:D,onNewChat:B,onThreadSelect:async e=>{await z(e),D()},onMutateReady:e=>x(()=>e),onInterruptCountChange:S})})]}),b&&!1===A&&(0,eI.jsxs)("div",{className:"absolute inset-0 z-40 flex justify-end md:hidden",children:[(0,eI.jsx)("button",{type:"button","aria-label":"Close inspector",className:"absolute inset-0 bg-black/40",onClick:P}),(0,eI.jsx)("aside",{"aria-label":"Inspector",className:"relative z-10 h-full w-[min(22rem,calc(100vw-2.25rem))] bg-background shadow-xl",children:(0,eI.jsx)(RS,{onClose:P,onReportToMainChat:R})})]}),(0,eI.jsxs)(iS,{direction:"horizontal",autoSaveId:"evoscientist-chat",children:[o&&A&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(ak,{id:"thread-history",order:1,defaultSize:23,minSize:18,className:"relative min-w-[260px]",children:(0,eI.jsx)(ui,{onNewChat:B,onThreadSelect:z,onMutateReady:e=>x(()=>e),onInterruptCountChange:S})}),(0,eI.jsx)(iw,{})]}),(0,eI.jsxs)(ak,{id:"chat",className:"relative flex flex-col",order:2,children:[(0,eI.jsx)("div",{className:nf("flex h-full min-h-0 flex-1 flex-col",null!==c&&"hidden"),children:(0,eI.jsx)(_T,{activeAssistant:w,onHistoryRevalidate:()=>v?.(),children:(0,eI.jsx)(Cf,{assistant:w,onShowAgents:F,onNotifyReady:e=>O(()=>e),onNavigate:$,onOpenThread:z,workspaceOpen:!!(b&&"agents"!==E)})},I)}),"skills"===c&&(0,eI.jsx)(C_,{}),"memory"===c&&(0,eI.jsx)(CH,{initialTab:d,initialObsId:m,initialExecId:f}),"schedule"===c&&(0,eI.jsx)(Ra,{})]}),b&&A&&(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(iw,{}),(0,eI.jsx)(ak,{id:"inspector",order:3,defaultSize:26,minSize:20,className:"relative min-w-[300px]",children:(0,eI.jsx)(RS,{onClose:P,onReportToMainChat:R})})]})]})]})]})]})}function Rk(){let[e,t]=(0,eC.useState)(null),[r,n]=(0,eC.useState)(!1),[a,i]=e$("assistantId");(0,eC.useEffect)(()=>{let e=eG();e?(t(e),a||i(e.assistantId)):n(!0)},[]),(0,eC.useEffect)(()=>{e&&!a&&i(e.assistantId)},[e,a,i]);let s=(0,eC.useCallback)(e=>{localStorage.setItem(eH,JSON.stringify(e)),t(e)},[]),o=e?.langsmithApiKey||eN.default.env.NEXT_PUBLIC_LANGSMITH_API_KEY||"";return e?(0,eI.jsx)(as,{deploymentUrl:e.deploymentUrl,apiKey:o,children:(0,eI.jsx)(Rw,{config:e,configDialogOpen:r,setConfigDialogOpen:n,handleSaveConfig:s})}):(0,eI.jsxs)(eI.Fragment,{children:[(0,eI.jsx)(nG,{open:r,onOpenChange:n,onSave:s}),(0,eI.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,eI.jsxs)("div",{className:"text-center",children:[(0,eI.jsx)("h1",{className:"text-2xl font-bold",children:"Welcome to EvoScientist"}),(0,eI.jsx)("p",{className:"mt-2 text-muted-foreground",children:"Configure your deployment to get started"}),(0,eI.jsx)(nP,{onClick:()=>n(!0),className:"mt-4",children:"Open Configuration"})]})})]})}e.s(["default",0,function(){return(0,eI.jsx)(eC.Suspense,{fallback:(0,eI.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,eI.jsx)("p",{className:"text-muted-foreground",children:"Loading…"})}),children:(0,eI.jsx)(Rk,{})})}],952683)}]);
|