@markus-global/cli 0.9.6 → 0.9.7-rc.1
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 +1 -1
- package/dist/commands/skill.d.ts +3 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +148 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +17 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/markus.mjs +5522 -2746
- package/dist/web-ui/assets/{CommentInput-CBNbViJY.js → CommentInput-CIxUL6dU.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-DE3pZgeX.js → ContentRenderer-Bb_drUpO.js} +2 -2
- package/dist/web-ui/assets/DeliverableShareModal-BEeIlXig.js +1 -0
- package/dist/web-ui/assets/Deliverables-CJFzxbLw.js +3 -0
- package/dist/web-ui/assets/{Notifications-DnOdXHNc.js → Notifications-Cz2LKhGE.js} +1 -1
- package/dist/web-ui/assets/{Search-BxFLlgcf.js → Search-dq45wHQN.js} +1 -1
- package/dist/web-ui/assets/Settings-WAXEtxMR.js +8 -0
- package/dist/web-ui/assets/{Store-BELkjEqO.js → Store-DOGCOxTK.js} +1 -1
- package/dist/web-ui/assets/Team-NM2SsmjN.js +81 -0
- package/dist/web-ui/assets/Work-ornw-1Zh.js +11 -0
- package/dist/web-ui/assets/{arc-CyhYnNcy.js → arc-D4xcu8MX.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BYIYNrCP.js → architectureDiagram-3BPJPVTR-DP3EZPSb.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-Tj8Yz066.js → blockDiagram-GPEHLZMM-BnSHtwXa.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-Ifa4IAJa.js → c4Diagram-AAUBKEIU-DpPSihlY.js} +1 -1
- package/dist/web-ui/assets/channel-DSB2MBEK.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-CNSbz4EK.js → chunk-2J33WTMH-DD5lZIGF.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-DhNtaIHh.js → chunk-4BX2VUAB-D9wu9GG0.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-WUpOSLP9.js → chunk-55IACEB6-p_n2ARjh.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-BJV_Jz1H.js → chunk-727SXJPM-BiTqi43c.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-BHu_5o0Y.js → chunk-AQP2D5EJ-DVPMedje.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-CfxugWTK.js → chunk-FMBD7UC4-B53AqN8D.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-hIFBUDLZ.js → chunk-ND2GUHAM-sACe_lkd.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-DF0OYrsG.js → chunk-QZHKN3VN-B0qDAQUW.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-D5cDjaiz.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-D5cDjaiz.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-C3LM31P0.js → cose-bilkent-S5V4N54A-BzZayQQf.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-C_m79Kes.js → dagre-BM42HDAG-DjcfWzm_.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-D8liSSSE.js → diagram-2AECGRRQ-CEK9T3rW.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-DqtsU-bB.js → diagram-5GNKFQAL-BJsJPwEI.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-C6zkMDRo.js → diagram-KO2AKTUF-BZlki2qo.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-Dx2JnYqj.js → diagram-LMA3HP47-Bkmh3WcY.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-ZI_lN3Ui.js → diagram-OG6HWLK6-4THSXHiA.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DQ5VepuZ.js → erDiagram-TEJ5UH35-CPj2HGe-.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-6GiDnWFL.js → flowDiagram-I6XJVG4X-Bu8HgFqR.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-D6HROKP8.js → ganttDiagram-6RSMTGT7-C5gs9b9P.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-CXm0stFt.js → gitGraphDiagram-PVQCEYII-DxnBgR_T.js} +1 -1
- package/dist/web-ui/assets/index-BbQpGkiM.css +1 -0
- package/dist/web-ui/assets/index-CiAGgfZx.js +672 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-C1RxESvu.js → infoDiagram-5YYISTIA-D4M-cR8I.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-K65PlAf9.js → ishikawaDiagram-YF4QCWOH-Oiq6jknk.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-_Rs_Vudv.js → journeyDiagram-JHISSGLW-D2gmyCKv.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Jf6WnoNW.js → kanban-definition-UN3LZRKU-DqjzkO8l.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-C6jfI8lj.js → mermaid.core-N5tL3hIv.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-CuVR_m6C.js → mindmap-definition-RKZ34NQL-ATHsVy0v.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-BiPJBXLU.js → pieDiagram-4H26LBE5-CprLr2Gv.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-C4hoAfNv.js → quadrantDiagram-W4KKPZXB-0uN86dlU.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BmjjjPuK.js → requirementDiagram-4Y6WPE33-CQmWbZXW.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-ts7xFx2o.js → sankeyDiagram-5OEKKPKP-D6kdJsQI.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-C3je_x5z.js → sequenceDiagram-3UESZ5HK-1Y79snKt.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-CREzVZ-3.js → stateDiagram-AJRCARHV-BqmCPSIN.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DRaoGsBn.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-CriALCTC.js → timeline-definition-PNZ67QCA-OG71KAzb.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-Bc9NNe3M.js → vennDiagram-CIIHVFJN-V9c-71bn.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-psF9We_q.js → wardley-L42UT6IY-C3A6_LpL.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DNZ9Jdgm.js → wardleyDiagram-YWT4CUSO-B54ZiT7U.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-COezi66E.js → xychartDiagram-2RQKCTM6-DpWlpUfV.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/package.json +2 -2
- package/templates/roles/{SHARED.md → HANDBOOK.md} +17 -7
- package/templates/roles/org-manager/ROLE.md +1 -5
- package/templates/roles/skill-architect/ROLE.md +1 -1
- package/templates/skills/agent-building/SKILL.md +109 -11
- package/templates/skills/skill-building/SKILL.md +61 -0
- package/templates/skills/team-building/SKILL.md +110 -4
- package/dist/web-ui/assets/Deliverables-Cx97uG2f.js +0 -6
- package/dist/web-ui/assets/Settings-D0i8Lnsk.js +0 -8
- package/dist/web-ui/assets/Team-D_C3tvWh.js +0 -80
- package/dist/web-ui/assets/Work-DpRdSwD5.js +0 -11
- package/dist/web-ui/assets/channel-B33xJsNY.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BePK-BYt.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BePK-BYt.js +0 -1
- package/dist/web-ui/assets/index-BMzsi3-i.js +0 -670
- package/dist/web-ui/assets/index-C9gwAZYM.css +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CZU51KZ-.js +0 -1
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BMzsi3-i.js","assets/index-C9gwAZYM.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as C,k as fx,u as Pt,O as YS,j as h,y as ma,ac as US,a as Sf,b as _f,P as Ht,c as wf,l as J,w as gt,M as HS,A as _s,n as Or,V as Wa,i as px,ad as GS,ae as KS,af as JS,ag as ym,ah as Sl,d as mx,ai as gx,h as Ox,p as Oc,aj as e_,ak as t_,al as Sm,am as s_,a3 as i_,a5 as xx,a4 as vx,X as r_,an as n_,ao as o_,_ as bx,E as _m,ap as xn,aq as a_,ar as l_,as as ed,at as wm,au as c_,B as td,D as km,o as Cm,s as h_,m as d_,Q as Pm,q as Tm,t as u_,av as f_,v as p_,aw as Qm,x as m_,ax as g_,z as O_,ay as x_,az as v_,R as b_,aA as y_,F as S_,aB as Jl,aC as ec,C as __}from"./index-BMzsi3-i.js";import{r as $m,p as w_}from"./CommentInput-CBNbViJY.js";import{ContentRenderer as du,resolveFormat as k_}from"./ContentRenderer-DE3pZgeX.js";function Fn(s,e,t){let i=t.initialDeps??[],r,n=!0;function a(){var o,l,c;let d;t.key&&((o=t.debug)!=null&&o.call(t))&&(d=Date.now());const u=s();if(!(u.length!==i.length||u.some((b,v)=>i[v]!==b)))return r;i=u;let g;if(t.key&&((l=t.debug)!=null&&l.call(t))&&(g=Date.now()),r=e(...u),t.key&&((c=t.debug)!=null&&c.call(t))){const b=Math.round((Date.now()-d)*100)/100,v=Math.round((Date.now()-g)*100)/100,m=v/16,O=(p,x)=>{for(p=String(p);p.length<x;)p=" "+p;return p};console.info(`%c⏱ ${O(v,5)} /${O(b,5)} ms`,`
|
|
3
|
-
font-size: .6rem;
|
|
4
|
-
font-weight: bold;
|
|
5
|
-
color: hsl(${Math.max(0,Math.min(120-120*m,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(n&&t.skipInitialOnChange)&&t.onChange(r),n=!1,r}return a.updateDeps=o=>{i=o},a}function jm(s,e){if(s===void 0)throw new Error("Unexpected undefined");return s}const C_=(s,e)=>Math.abs(s-e)<1.01,P_=(s,e,t)=>{let i;return function(...r){s.clearTimeout(i),i=s.setTimeout(()=>e.apply(this,r),t)}},Em=s=>{const{offsetWidth:e,offsetHeight:t}=s;return{width:e,height:t}},T_=s=>s,Q_=s=>{const e=Math.max(s.startIndex-s.overscan,0),t=Math.min(s.endIndex+s.overscan,s.count-1),i=[];for(let r=e;r<=t;r++)i.push(r);return i},$_=(s,e)=>{const t=s.scrollElement;if(!t)return;const i=s.targetWindow;if(!i)return;const r=a=>{const{width:o,height:l}=a;e({width:Math.round(o),height:Math.round(l)})};if(r(Em(t)),!i.ResizeObserver)return()=>{};const n=new i.ResizeObserver(a=>{const o=()=>{const l=a[0];if(l?.borderBoxSize){const c=l.borderBoxSize[0];if(c){r({width:c.inlineSize,height:c.blockSize});return}}r(Em(t))};s.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()});return n.observe(t,{box:"border-box"}),()=>{n.unobserve(t)}},Rm={passive:!0},Am=typeof window>"u"?!0:"onscrollend"in window,j_=(s,e)=>{const t=s.scrollElement;if(!t)return;const i=s.targetWindow;if(!i)return;let r=0;const n=s.options.useScrollendEvent&&Am?()=>{}:P_(i,()=>{e(r,!1)},s.options.isScrollingResetDelay),a=d=>()=>{const{horizontal:u,isRtl:f}=s.options;r=u?t.scrollLeft*(f&&-1||1):t.scrollTop,n(),e(r,d)},o=a(!0),l=a(!1);t.addEventListener("scroll",o,Rm);const c=s.options.useScrollendEvent&&Am;return c&&t.addEventListener("scrollend",l,Rm),()=>{t.removeEventListener("scroll",o),c&&t.removeEventListener("scrollend",l)}},E_=(s,e,t)=>{if(e?.borderBoxSize){const i=e.borderBoxSize[0];if(i)return Math.round(i[t.options.horizontal?"inlineSize":"blockSize"])}return s[t.options.horizontal?"offsetWidth":"offsetHeight"]},R_=(s,{adjustments:e=0,behavior:t},i)=>{var r,n;const a=s+e;(n=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||n.call(r,{[i.options.horizontal?"left":"top"]:a,behavior:t})};class A_{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,i,r;return((r=(i=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let t=null;const i=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(n=>{const a=()=>{const o=n.target,l=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(o,n,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),t=null},observe:r=>{var n;return(n=i())==null?void 0:n.observe(r,{box:"border-box"})},unobserve:r=>{var n;return(n=i())==null?void 0:n.unobserve(r)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([i,r])=>{typeof r>"u"&&delete t[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:T_,rangeExtractor:Q_,onChange:()=>{},measureElement:E_,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,t)},this.maybeNotify=Fn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,n)=>{this.scrollAdjustments=0,this.scrollDirection=n?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=n,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,i)=>{const r=new Map,n=new Map;for(let a=i-1;a>=0;a--){const o=t[a];if(r.has(o.lane))continue;const l=n.get(o.lane);if(l==null||o.end>l.end?n.set(o.lane,o):o.end<l.end&&r.set(o.lane,!0),r.size===this.options.lanes)break}return n.size===this.options.lanes?Array.from(n.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=Fn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,i,r,n,a,o,l)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:i,scrollMargin:r,getItemKey:n,enabled:a,lanes:o,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=Fn(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:i,scrollMargin:r,getItemKey:n,enabled:a,lanes:o,laneAssignmentMode:l},c)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const g of this.laneAssignments.keys())g>=t&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const d=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const u=this.measurementsCache.slice(0,d),f=new Array(o).fill(void 0);for(let g=0;g<d;g++){const b=u[g];b&&(f[b.lane]=g)}for(let g=d;g<t;g++){const b=n(g),v=this.laneAssignments.get(g);let m,O;const p=l==="estimate"||c.has(b);if(v!==void 0&&this.options.lanes>1){m=v;const k=f[m],w=k!==void 0?u[k]:void 0;O=w?w.end+this.options.gap:i+r}else{const k=this.options.lanes===1?u[g-1]:this.getFurthestMeasurement(u,g);O=k?k.end+this.options.gap:i+r,m=k?k.lane:g%this.options.lanes,this.options.lanes>1&&p&&this.laneAssignments.set(g,m)}const x=c.get(b),y=typeof x=="number"?x:this.options.estimateSize(g),_=O+y;u[g]={index:g,start:O,size:y,end:_,key:b,lane:m},f[m]=g}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Fn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,i,r,n)=>this.range=t.length>0&&i>0?M_({measurements:t,outerSize:i,scrollOffset:r,lanes:n}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Fn(()=>{let t=null,i=null;const r=this.calculateRange();return r&&(t=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,i]},(t,i,r,n,a)=>n===null||a===null?[]:t({startIndex:n,endIndex:a,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const i=this.options.indexAttribute,r=t.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,r-n),o=Math.min(this.options.count-1,r+n);return t>=a&&t<=o}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((a,o)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(o))});return}const i=this.indexFromElement(t),r=this.options.getItemKey(i),n=this.elementsCache.get(r);n!==t&&(n&&this.observer.unobserve(n),this.observer.observe(t),this.elementsCache.set(r,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,i)=>{var r;const n=this.measurementsCache[t];if(!n)return;const a=this.itemSizeCache.get(n.key)??n.size,o=i-a;o!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,o,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,i)),this.notify(!1))},this.getVirtualItems=Fn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,i)=>{const r=[];for(let n=0,a=t.length;n<a;n++){const o=t[n],l=i[o];r.push(l)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const i=this.getMeasurements();if(i.length!==0)return jm(i[yx(0,i.length-1,r=>jm(i[r]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,i,r=0)=>{if(!this.scrollElement)return 0;const n=this.getSize(),a=this.getScrollOffset();i==="auto"&&(i=t>=a+n?"end":"start"),i==="center"?t+=(r-n)/2:i==="end"&&(t-=n);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,i="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const r=this.getSize(),n=this.getScrollOffset(),a=this.measurementsCache[t];if(!a)return;if(i==="auto")if(a.end>=n+r-this.options.scrollPaddingEnd)i="end";else if(a.start<=n+this.options.scrollPaddingStart)i="start";else return[n,i];if(i==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),i];const o=i==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,i,a.size),i]},this.scrollToOffset=(t,{align:i="start",behavior:r="auto"}={})=>{const n=this.getOffsetForAlignment(t,i),a=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:a,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:i="auto",behavior:r="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.getOffsetForIndex(t,i);if(!n)return;const[a,o]=n,l=this.now();this.scrollState={index:t,align:o,behavior:r,startedAt:l,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+t,n=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:n,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((t=i[i.length-1])==null?void 0:t.end)??0;else{const n=Array(this.options.lanes).fill(null);let a=i.length-1;for(;a>=0&&n.some(o=>o===null);){const o=i[a];n[o.lane]===null&&(n[o.lane]=o.end),a--}r=Math.max(...n.filter(o=>o!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:i,behavior:r})=>{this.options.scrollToFn(t,{behavior:r,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,n=1,a=r!==this.scrollState.lastTargetOffset;if(!a&&C_(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=n){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=r,this.scrollState.behavior="auto",this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const yx=(s,e,t,i)=>{for(;s<=e;){const r=(s+e)/2|0,n=t(r);if(n<i)s=r+1;else if(n>i)e=r-1;else return r}return s>0?s-1:0};function M_({measurements:s,outerSize:e,scrollOffset:t,lanes:i}){const r=s.length-1,n=l=>s[l].start;if(s.length<=i)return{startIndex:0,endIndex:r};let a=yx(0,r,n,t),o=a;if(i===1)for(;o<r&&s[o].end<t+e;)o++;else if(i>1){const l=Array(i).fill(0);for(;o<r&&l.some(d=>d<t+e);){const d=s[o];l[d.lane]=d.end,o++}const c=Array(i).fill(t+e);for(;a>=0&&c.some(d=>d>=t);){const d=s[a];c[d.lane]=d.start,a--}a=Math.max(0,a-a%i),o=Math.min(r,o+(i-1-o%i))}return{startIndex:a,endIndex:o}}const Mm=typeof document<"u"?C.useLayoutEffect:C.useEffect;function L_({useFlushSync:s=!0,...e}){const t=C.useReducer(()=>({}),{})[1],i={...e,onChange:(n,a)=>{var o;s&&a?fx.flushSync(t):t(),(o=e.onChange)==null||o.call(e,n,a)}},[r]=C.useState(()=>new A_(i));return r.setOptions(i),Mm(()=>r._didMount(),[]),Mm(()=>r._willUpdate()),r}function N_(s){return L_({observeElementRect:$_,observeElementOffset:j_,scrollToFn:R_,...s})}const Lm={urgent:"bg-red-500/15 text-red-500",high:"bg-amber-500/15 text-amber-600",normal:"bg-blue-500/15 text-blue-500",low:"bg-surface-overlay text-fg-tertiary"};function D_({notification:s,agentName:e,acknowledging:t,onClose:i,onAcknowledge:r}){const{t:n}=Pt(["team","common"]);YS(!0);const a=s.priority||"normal",o=s.metadata??{},l=e||(typeof o.agentName=="string"?o.agentName:void 0);return fx.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:c=>{c.target===c.currentTarget&&i()},children:h.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[h.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[h.jsx("div",{className:"w-9 h-9 rounded-lg bg-blue-500/15 text-blue-500 flex items-center justify-center shrink-0",children:h.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),h.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:s.title}),h.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[l&&h.jsx("p",{className:"text-xs text-fg-tertiary",children:l}),a!=="normal"&&h.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ${Lm[a]??Lm.normal}`,children:a})]})]}),h.jsx("button",{onClick:i,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:n("common:close"),children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M18 6L6 18"}),h.jsx("path",{d:"M6 6l12 12"})]})})]}),h.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:h.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:h.jsx(ma,{content:s.body||""})})}),h.jsxs("div",{className:"flex items-center justify-end gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[h.jsx("button",{onClick:i,className:"px-3.5 py-2 text-sm text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:n("common:close")}),h.jsx("button",{onClick:()=>{r()},disabled:t,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-500 disabled:opacity-50 rounded-lg transition-colors",children:t?n("common:loading"):n("page.notifyUserGotIt",{ns:"team",defaultValue:"Got it"})})]})]})}),document.body)}function ga({children:s,onClose:e,title:t,width:i="w-[440px]"}){return h.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:e,children:h.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${i} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:r=>r.stopPropagation(),children:[h.jsx("h3",{className:"text-base font-semibold mb-5",children:t}),s]})})}function to({label:s,children:e}){return h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:s}),e]})}function I_({onClose:s,onCreate:e}){const{t}=Pt(["team","common"]),[i,r]=C.useState(""),[n,a]=C.useState("");return h.jsx(ga,{onClose:s,title:t("team:modals.createTeam.title"),children:h.jsxs("div",{className:"space-y-4",children:[h.jsx(to,{label:t("team:modals.createTeam.teamName"),children:h.jsx("input",{value:i,onChange:o=>r(o.target.value),placeholder:t("team:modals.createTeam.teamNamePlaceholder"),className:"input",autoFocus:!0,onKeyDown:o=>{o.key==="Enter"&&i.trim()&&e(i.trim(),n.trim()||void 0)}})}),h.jsx(to,{label:t("team:modals.createTeam.description"),children:h.jsx("textarea",{value:n,onChange:o=>a(o.target.value),placeholder:t("team:modals.createTeam.descriptionPlaceholder"),className:"input",rows:2})}),h.jsx("div",{className:"text-xs text-fg-tertiary",children:t("team:modals.createTeam.hint")}),h.jsx("div",{className:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:h.jsx(US,{i18nKey:"modals.createTeam.tipTrans",ns:"team",components:{0:h.jsx("span",{className:"text-brand-400 font-medium"}),1:h.jsx("span",{className:"text-brand-400"})}})}),h.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[h.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("common:cancel")}),h.jsx("button",{onClick:()=>i.trim()&&e(i.trim(),n.trim()||void 0),disabled:!i.trim(),className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:t("team:modals.createTeam.createTeam")})]})]})})}function B_({onClose:s,onAdd:e}){const{t}=Pt(["team","common"]),[i,r]=C.useState(""),[n,a]=C.useState("member"),[o,l]=C.useState(""),[c,d]=C.useState(""),[u,f]=C.useState(!1),[g,b]=C.useState(null),[v,m]=C.useState(!1),O=g?.inviteToken?`${window.location.origin}/#invite?token=${g.inviteToken}`:null,p=async()=>{if(d(""),!i.trim()){d(t("team:modals.addHuman.nameRequired"));return}if(!o.trim()){d(t("team:modals.addHuman.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim())){d(t("team:modals.addHuman.invalidEmail"));return}f(!0);try{const y=await e(i.trim(),n,o.trim());b({...y,userName:i.trim()})}catch(y){d(y instanceof Error?y.message:String(y))}finally{f(!1)}},x=()=>{O&&(navigator.clipboard.writeText(O),m(!0),setTimeout(()=>m(!1),2e3))};return g?h.jsxs(ga,{onClose:s,title:t("team:modals.addHuman.title"),width:"w-[460px]",children:[h.jsxs("div",{className:"text-center py-4",children:[h.jsx("div",{className:"w-12 h-12 rounded-full bg-green-600/20 flex items-center justify-center mx-auto mb-3",children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-green-500",children:h.jsx("polyline",{points:"20 6 9 17 4 12"})})}),h.jsx("div",{className:"text-base font-medium mb-1",children:t("team:modals.addHuman.memberCreated",{name:g.userName})}),O?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"text-xs text-fg-secondary mt-1 mb-4",children:t("team:modals.addHuman.inviteHint")}),h.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-lg p-3 text-left mb-3",children:[h.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase mb-1.5",children:t("team:modals.addHuman.inviteLink")}),h.jsx("div",{className:"text-xs text-fg-primary break-all font-mono select-all",children:O})]}),h.jsx("button",{onClick:x,className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${v?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:t(v?"common:copied":"team:modals.addHuman.copyInviteLink")})]}):h.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:t("team:modals.addHuman.memberCreatedNoInvite")})]}),h.jsx("div",{className:"flex justify-end pt-3",children:h.jsx("button",{onClick:s,className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:t("common:done")})})]}):h.jsx(ga,{onClose:s,title:t("team:modals.addHuman.title"),width:"w-[460px]",children:h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"text-xs text-fg-secondary bg-surface-primary border border-border-default rounded-lg px-3 py-2.5 leading-relaxed",children:[h.jsx("div",{className:"font-semibold text-fg-primary mb-1",children:t("team:modals.addHuman.sharedInstanceTitle")}),t("team:modals.addHuman.sharedInstanceDesc"),h.jsxs("div",{className:"mt-1.5 text-fg-tertiary",children:[t("team:modals.addHuman.orgHint")," ",h.jsx("a",{href:"#settings/organization",className:"text-brand-500 hover:text-brand-400 underline",children:t("team:modals.addHuman.orgLink")})]})]}),h.jsx(to,{label:t("team:modals.addHuman.name"),children:h.jsx("input",{value:i,onChange:y=>r(y.target.value),placeholder:t("team:modals.addHuman.namePlaceholder"),className:"input",autoFocus:!0})}),h.jsx(to,{label:t("team:modals.addHuman.role"),children:h.jsxs("select",{value:n,onChange:y=>a(y.target.value),className:"input",children:[h.jsx("option",{value:"owner",children:t("common:role.owner")}),h.jsx("option",{value:"admin",children:t("common:role.admin")}),h.jsx("option",{value:"member",children:t("common:role.member")}),h.jsx("option",{value:"guest",children:t("common:role.guest")})]})}),h.jsx(to,{label:t("team:modals.addHuman.emailRequired"),children:h.jsx("input",{value:o,onChange:y=>l(y.target.value),type:"email",placeholder:t("team:modals.addHuman.emailPlaceholder"),className:"input"})}),h.jsx("div",{className:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:t("team:modals.addHuman.inviteFlowHint")}),c&&h.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:c}),h.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[h.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("common:cancel")}),h.jsx("button",{onClick:p,disabled:u,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 disabled:opacity-50 rounded-lg text-white",children:t(u?"common:saving":"team:modals.addHuman.addMember")})]})]})})}function W_({teamId:s,ungrouped:e,onClose:t,onAdd:i}){const{t:r}=Pt(["team","common"]);return h.jsx(ga,{onClose:t,title:r("team:modals.addExisting.title"),children:h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:"text-xs text-fg-tertiary",children:r("team:modals.addExisting.hint")}),e.length===0?h.jsx("div",{className:"text-center py-8 text-sm text-fg-tertiary",children:r("team:modals.addExisting.allInTeam")}):h.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:e.map(n=>h.jsxs("button",{onClick:()=>i(n.id,n.type),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:border-brand-500 hover:bg-brand-500/10 text-left transition-all",children:[h.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold text-white ${n.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:n.name.charAt(0)}),h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"font-medium text-sm",children:n.name}),h.jsxs("div",{className:"text-xs text-fg-tertiary",children:[n.role," · ",n.type==="agent"?r("team:modals.addExisting.typeAgent"):r("team:modals.addExisting.typeHuman")]})]}),n.status&&h.jsx("span",{className:`w-2 h-2 rounded-full ${n.status==="idle"?"bg-green-400":n.status==="working"?"bg-blue-400":"bg-gray-600"}`})]},n.id))}),h.jsx("div",{className:"flex justify-end pt-2",children:h.jsx("button",{onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:r("common:close")})})]})})}function X_({onClose:s,onConnected:e}){const{t}=Pt(["team","common"]),[i,r]=C.useState(""),[n,a]=C.useState(""),[o,l]=C.useState(!1),[c,d]=C.useState(null),[u,f]=C.useState(null),g=async()=>{if(!i.trim()){a(t("team:modals.openClaw.agentNameRequired"));return}const v=i.trim().toLowerCase().replace(/\s+/g,"-");l(!0),a("");try{const m=await fetch("/api/external-agents/register",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({externalAgentId:v,agentName:i.trim(),orgId:"default",capabilities:["general"]})});if(!m.ok){const p=await m.json().catch(()=>({}));throw new Error(p.error??`HTTP ${m.status}`)}const O=await m.json();d({externalAgentId:v,markusAgentId:O.registration?.markusAgentId,token:O.token,gatewayUrl:O.gatewayUrl})}catch(m){a(String(m))}l(!1)},b=(v,m)=>{navigator.clipboard.writeText(v),f(m),setTimeout(()=>f(null),2e3)};return h.jsx(ga,{onClose:s,title:t("team:modals.openClaw.title"),width:"w-[560px]",children:c?(()=>{const v=c.gatewayUrl??`${window.location.origin}/api/gateway`,m=c.token?t("team:modals.openClaw.bearerTokenLine",{token:c.token}):"",O=t("team:modals.openClaw.connectionPromptBody",{gwUrl:v,externalAgentId:c.externalAgentId,tokenSection:m});return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"text-center py-6",children:[h.jsx("div",{className:"text-3xl mb-3 text-green-600",children:"✓"}),h.jsx("div",{className:"text-base text-green-600 font-medium mb-1",children:t("team:modals.openClaw.agentRegistered")}),h.jsx("div",{className:"text-sm text-fg-secondary mt-1",children:h.jsx("strong",{children:i})})]}),h.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/30 rounded-xl p-4",children:[h.jsx("div",{className:"text-xs text-fg-secondary mb-3",children:t("team:modals.openClaw.copyInstruction")}),h.jsx("button",{onClick:()=>b(O,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${u==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:t(u==="prompt"?"common:copied":"team:modals.openClaw.copyPrompt")})]}),h.jsx("div",{className:"flex justify-end pt-5",children:h.jsx("button",{onClick:()=>{e()},className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:t("team:modals.openClaw.done")})})]})})():h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"text-xs text-fg-secondary mb-4",children:t("team:modals.openClaw.description")}),h.jsxs("div",{className:"space-y-4",children:[h.jsx(to,{label:t("team:modals.openClaw.agentName"),children:h.jsx("input",{className:"input",placeholder:t("team:modals.openClaw.agentNamePlaceholder"),value:i,onChange:v=>r(v.target.value),autoFocus:!0})}),n&&h.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:n}),h.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[h.jsx("button",{onClick:s,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:t("common:cancel")}),h.jsx("button",{onClick:g,disabled:o,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-white disabled:opacity-50",children:t(o?"team:modals.openClaw.connecting":"team:modals.openClaw.importAgent")})]})]})]})})}let _l=new Map;function q_({agents:s,humans:e,authUser:t,onClose:i,onCreate:r}){const{t:n}=Pt(["team","common"]),[a,o]=C.useState(""),[l,c]=C.useState(new Set),[d,u]=C.useState(""),[f,g]=C.useState(!1),b=C.useMemo(()=>{const p=[];for(const x of s)p.push({id:x.id,name:x.name,type:"agent",subtitle:x.role||"Agent"});for(const x of e)x.id!==t?.id&&p.push({id:x.id,name:x.name,type:"human",subtitle:x.email||x.role||"Human"});return p},[s,e,t]),v=C.useMemo(()=>{if(!d)return b;const p=d.toLowerCase();return b.filter(x=>x.name.toLowerCase().includes(p)||x.subtitle.toLowerCase().includes(p))},[b,d]),m=p=>{c(x=>{const y=new Set(x);return y.has(p)?y.delete(p):y.add(p),y})},O=async()=>{if(!a.trim()||l.size===0)return;g(!0);const p=[...l],x={},y={};for(const _ of p){const k=b.find(w=>w.id===_);k&&(x[_]=k.type,y[_]=k.name)}await r(a.trim(),p,x,y),g(!1)};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:h.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] max-h-[80vh] flex flex-col",onClick:p=>p.stopPropagation(),children:[h.jsxs("div",{className:"px-5 py-4 border-b border-border-default",children:[h.jsx("h3",{className:"text-sm font-semibold",children:n("modals.createGroupChat.title")}),h.jsx("p",{className:"text-[11px] text-fg-tertiary mt-0.5",children:n("modals.createGroupChat.subtitle")})]}),h.jsx("div",{className:"px-5 py-3 border-b border-border-default",children:h.jsx("input",{value:a,onChange:p=>o(p.target.value),placeholder:n("modals.createGroupChat.groupNamePlaceholder"),className:"w-full bg-surface-primary border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary placeholder:text-fg-muted outline-none focus:ring-1 focus:ring-brand-500/50",autoFocus:!0})}),h.jsx("div",{className:"px-5 py-2 border-b border-border-default",children:h.jsx("input",{value:d,onChange:p=>u(p.target.value),placeholder:n("modals.createGroupChat.searchPlaceholder"),className:"w-full bg-surface-primary border border-border-default rounded-lg px-3 py-1.5 text-xs text-fg-primary placeholder:text-fg-muted outline-none focus:ring-1 focus:ring-brand-500/50"})}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 min-h-0 max-h-[300px]",children:[v.length===0&&h.jsx("p",{className:"text-xs text-fg-tertiary px-2 py-4 text-center",children:n("modals.createGroupChat.noMembersFound")}),v.map(p=>h.jsxs("button",{onClick:()=>m(p.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${l.has(p.id)?"bg-brand-500/10 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[h.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center shrink-0 transition-colors ${l.has(p.id)?"bg-brand-500 border-brand-500":"border-border-default"}`,children:l.has(p.id)&&h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("polyline",{points:"20 6 9 17 4 12"})})}),h.jsx(_s,{name:p.name,size:20,bgClass:p.type==="agent"?"bg-brand-500/15 text-brand-500":"bg-green-500/15 text-green-600"}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsx("span",{className:"truncate text-[11px] font-medium block",children:p.name}),h.jsx("span",{className:"text-[9px] text-fg-tertiary",children:p.subtitle})]}),h.jsx("span",{className:`text-[8px] px-1.5 py-0.5 rounded-full font-medium ${p.type==="agent"?"bg-brand-500/10 text-brand-500":"bg-green-500/10 text-green-600"}`,children:p.type==="agent"?n("modals.addExisting.typeAgent"):n("modals.addExisting.typeHuman")})]},p.id))]}),h.jsxs("div",{className:"px-5 py-3 border-t border-border-default flex items-center justify-between",children:[h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:n("modals.createGroupChat.selected",{count:l.size})}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:i,className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:n("common:cancel")}),h.jsx("button",{onClick:O,disabled:!a.trim()||l.size===0||f,className:"px-4 py-1.5 text-xs font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors disabled:opacity-50 disabled:pointer-events-none",children:n(f?"modals.createGroupChat.creating":"modals.createGroupChat.create")})]})]})]})})}const z_=C.memo(function({authUser:e,agents:t,teams:i,humans:r,tasks:n,externalAgents:a,groupChats:o,chatMode:l,selectedAgent:c,activeChannel:d,activeDmUserId:u,onSelectAgent:f,onSelectChannel:g,onSelectDm:b,onSelectTeam:v,selectedTeamId:m,onRefreshTeams:O,onRefreshAgents:p,onRefreshHumans:x,onRefreshGroupChats:y,onViewProfile:_,onManageGroupMembers:k,unreadByAgent:w,unreadByChannel:S,width:Q,onResizeStart:I,hidden:D,onCollapse:$,initialLoading:j,previewMode:B,focused:F,l2Available:V}){const{t:Z}=Pt(["team","common"]),se=Sf(),T=_f(Ht.TEAM),A=wf(),N=e?.role==="owner"||e?.role==="admin",z=C.useMemo(()=>new Set(a.map(W=>W.markusAgentId).filter(Boolean)),[a]),[U,ne]=C.useState([]),[Se,Pe]=C.useState(new Set),[X,M]=C.useState(!1),[K,ie]=C.useState(!1),[oe,G]=C.useState(null),[$e,Ie]=C.useState(!1),[We,Y]=C.useState(!1),[ee,le]=C.useState(null),[ke,Ce]=C.useState(null),[dt,ht]=C.useState(null),[yt,ss]=C.useState(!1),[Lt,zs]=C.useState(""),[vs,bs]=C.useState(null),[si,Zs]=C.useState(null),[Ps,xt]=C.useState(null),[$i,ji]=C.useState(!1),Ga=C.useRef(null),[gh,Hr]=C.useState(null),Ji=C.useRef(null),Ka=C.useRef(null),[Po,To]=C.useState(null),Gr=(W,he="success")=>{To({message:W,type:he}),setTimeout(()=>To(null),3e3)},[ii,xi]=C.useState(null),[Ja,Qo]=C.useState(!1),An=C.useRef(!1);C.useEffect(()=>{if(B)return;J.governance.getSystemStatus().then(ue=>{An.current=!0,xi(ue.globalPaused)}).catch(()=>{An.current=!0,xi(!1)});const W=gt.on("system:pause-all",()=>{An.current&&xi(!0)}),he=gt.on("system:resume-all",()=>{An.current&&xi(!1)});return()=>{W(),he()}},[]),C.useEffect(()=>{if(!B)return;const W=setTimeout(()=>{const he=Ka.current,ue=Ji.current;he&&ue&&ue.scrollTo({top:he.offsetTop-ue.offsetTop-8,behavior:"instant"})},100);return()=>clearTimeout(W)},[B]);const $o=C.useCallback(()=>{ii!==null&&Kr({title:Z(ii?"modals.resumeAll.title":"modals.pauseAll.title"),message:Z(ii?"modals.resumeAll.message":"modals.pauseAll.message"),confirmLabel:Z(ii?"chat.resume":"chat.pause"),onConfirm:async()=>{Qo(!0);try{ii?(await J.governance.resumeAll(),xi(!1)):(await J.governance.pauseAll(),xi(!0))}catch{}Qo(!1)}})},[ii]),[Ei,Kr]=C.useState(null),Mn=(W,he,ue,Re,Fe)=>{Kr({title:W,message:he,onConfirm:ue,confirmLabel:Re,checkboxes:Fe})},[ri,Tr]=C.useState(null),[Jr,jo]=C.useState(null),ni=C.useRef(null),Ts=C.useRef(null),[vi,Eo]=C.useState(!1),[ce,ut]=C.useState(null),[ge,is]=C.useState(""),lt=C.useCallback((W,he=176,ue=220)=>{const Re=window.innerWidth,Fe=window.innerHeight,tt=8;let vt=W.clientX,mt=W.clientY;return vt+he>Re-tt&&(vt=Math.max(tt,Re-he-tt)),mt+ue>Fe-tt&&(mt=Math.max(tt,Fe-ue-tt)),vt=Math.max(tt,Math.min(vt,Re-he-tt)),mt=Math.max(tt,Math.min(mt,Fe-ue-tt)),{x:vt,y:mt}},[]),[As,Nt]=C.useState(_l),en=C.useMemo(()=>t.map(W=>W.id).sort().join(","),[t]);C.useEffect(()=>{if(!t.length||!T)return;let W=!1;(async()=>{const mt=[];await Promise.allSettled(t.map(async Ye=>{if(!_l.has(Ye.id))try{const{sessions:Yt}=await J.sessions.listByAgent(Ye.id,1);if(!Yt.length)return;const{messages:Dt}=await J.sessions.getMessages(Yt[0].id,1);if(Dt.length){const Ut=Dt[0],Ls=Ut.metadata?.segments;let Zt=Ut.content;if(Ls&&Ls.length>0){const Ai=[...Ls].reverse().find(Nn=>Nn.type==="text");Ai&&Ai.type==="text"&&(Zt=Ai.content)}const us=Zt.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80);us&&mt.push([Ye.id,us])}}catch{}})),!W&&mt.length&&Nt(Ye=>{const Yt=new Map(Ye);for(const[Dt,Ut]of mt)Yt.set(Dt,Ut);return _l=Yt,Yt})})();const ue=new Set(t.map(mt=>mt.id)),Re=mt=>mt.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80),Fe=(mt,Ye)=>{if(!mt||!Ye||!ue.has(mt))return;const Yt=Re(Ye);Yt&&Nt(Dt=>{const Ut=new Map(Dt);return Ut.set(mt,Yt),_l=Ut,Ut})},tt=gt.on("chat:proactive_message",mt=>{const Ye=mt.payload;Fe(Ye.agentId??"",Ye.message??"")}),vt=gt.on("chat:message",mt=>{const Ye=mt.payload,Yt=Ye.senderId??Ye.agentId??"",Dt=Ye.text??Ye.message??"";Fe(Yt,Dt)});return()=>{W=!0,tt(),vt()}},[en,T]);const Ms=C.useCallback(()=>{B||J.teams.list().then(W=>ne(W.ungrouped)).catch(()=>{})},[B]);C.useEffect(()=>{Ms()},[Ms]),C.useEffect(()=>{if(!T)return;const W=gt.on("team:update",Ms),he=gt.on("agent:removed",Ms);return()=>{W(),he()}},[Ms,T]),C.useEffect(()=>{if(!ke&&!dt&&!vs&&!$i&&!Ps)return;const W=()=>{Ce(null),ht(null),bs(null),xt(null),ji(!1)},he=setTimeout(()=>document.addEventListener("click",W),0);return()=>{clearTimeout(he),document.removeEventListener("click",W)}},[ke,dt,vs,$i,Ps]);const tn=(W,he)=>{Mn(`${Z("common:delete")} "${he}"?`,Z("modals.deleteTeam.message"),async ue=>{const Re=ue?.deleteMembers??!0,Fe=ue?.purgeFiles??!1;await J.teams.delete(W,Re,{purgeFiles:Fe}),O(),Ms(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},Z("contextMenu.deleteTeam"),[{id:"deleteMembers",label:Z("modals.deleteTeam.deleteMembers"),defaultChecked:!0},{id:"purgeFiles",label:Z("modals.deleteTeam.purgeFiles"),defaultChecked:!1}])},Ln=async(W,he)=>{try{const Re=await(he==="start"?J.teams.startAll:J.teams.stopAll)(W),Fe=Re.success?.length??0,tt=Re.failed?.length??0;tt>0?Gr(Z("batchAction.failed",{action:Z(`batchAction.operation.${he}`),ok:Fe,fail:tt}),"error"):Fe>0&&Gr(Z("batchAction.succeeded",{count:Fe,action:Z(`batchAction.past.${he}`)}),"success"),p()}catch(ue){Gr(Z("batchAction.failedToRun",{action:Z(`batchAction.operation.${he}`),error:ue instanceof Error?ue.message:String(ue)}),"error")}},Oh=async(W,he,ue)=>{await J.teams.update(W,{managerId:he,managerType:ue}),O()},el=async W=>{if(!ge.trim()){ut(null);return}await J.teams.update(W,{name:ge.trim()}),ut(null),O()},At=async(W,he)=>{he==="offline"?await J.agents.start(W):await J.agents.stop(W),p()},Qs=(W,he)=>{Mn(Z("modals.removeFromTeam.title"),Z("modals.removeFromTeam.message"),async()=>{await J.teams.removeMember(W,he),O(),Ms()},Z("common:remove"))},Vs=(W,he,ue)=>{Mn(`${Z("common:remove")} "${he}"?`,Z(ue==="agent"?"modals.removeAgent.message":"modals.removeHuman.message"),async Re=>{if(ue==="agent"){const Fe=Re?.purgeFiles??!1;await J.agents.remove(W,{purgeFiles:Fe})}else await J.users.remove(W);p(),O(),x?.(),Ms(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},Z("common:remove"),ue==="agent"?[{id:"purgeFiles",label:Z("modals.removeAgent.purgeFiles"),defaultChecked:!1}]:void 0)},rs=W=>{if(W.isOrgSecretary||W.protected)return!0;if(W.teamId)return!1;const he=(W.role??"").toLowerCase().trim(),ue=(W.name??"").trim();return ue==="Secretary"||ue==="秘书"||he==="secretary"||he.startsWith("secretary")},xh=(W,he,ue)=>{const Re=t.find(Fe=>Fe.id===he);Re&&rs(Re)||(Ts.current={x:W.clientX,y:W.clientY},ni.current=setTimeout(()=>{Tr({agentId:he,fromTeamId:ue}),Eo(!0)},200))},bi=W=>{if(!Ts.current||!ni.current)return;const he=Math.abs(W.clientX-Ts.current.x),ue=Math.abs(W.clientY-Ts.current.y);(he>5||ue>5)&&(vi||(clearTimeout(ni.current),ni.current=null))},hs=async()=>{if(ni.current&&(clearTimeout(ni.current),ni.current=null),Ts.current=null,vi&&ri&&Jr){const W=Jr==="_ungrouped"?void 0:Jr;try{if(ri.fromTeamId&&ri.fromTeamId!==W&&await J.teams.removeMember(ri.fromTeamId,ri.agentId),W&&W!==ri.fromTeamId){const he=t.find(ue=>ue.id===ri.agentId);await J.teams.addMember(W,ri.agentId,"agent")}O(),p(),Ms()}catch(he){Gr(Z("batchAction.moveFailed",{error:he instanceof Error?he.message:String(he)}),"error")}}Tr(null),jo(null),Eo(!1)},sn=C.useMemo(()=>new Map(i.map(W=>[W.id,W])),[i]),ds=C.useMemo(()=>{const W=new Map,he=[];for(const ue of t)if(ue.teamId&&sn.has(ue.teamId)){const Re=W.get(ue.teamId)??[];Re.push(ue),W.set(ue.teamId,Re)}else he.push(ue);return{byTeam:W,ungrouped:he}},[t,sn]),oi=(W,he)=>{const ue=l==="direct"&&c===W.id,Re=z.has(W.id),Fe=W.status==="offline",tt=W.status==="idle"?"bg-green-500":W.status==="working"?"bg-blue-500 animate-pulse":W.status==="error"?"bg-red-500":"bg-gray-600",mt=(void 0)?.managerId===W.id,Ye=W.role?.toLowerCase().replace(/[-_]/g," ").trim(),Yt=W.name.toLowerCase().trim(),Dt=Ye&&Ye!==Yt,Ut=As.get(W.id)||W.currentActivity?.label?.slice(0,60)||"",Ls=W.status==="idle"?Z("common:status.online"):W.status==="working"?Z("common:status.working"):W.status==="error"?Z("common:status.error"):Z("common:status.offline");return h.jsx("div",{className:`relative mb-0.5 ${vi&&ri?.agentId===W.id?"opacity-40":""}`,onPointerDown:Zt=>xh(Zt,W.id,he),onPointerMove:bi,onPointerUp:hs,children:h.jsxs("button",{"data-l1-nav-id":`agent:${W.id}`,onClick:()=>{vi||f(W.id)},onContextMenu:Zt=>{if(!N)return;Zt.preventDefault();const us=lt(Zt);ss(!1),zs(""),ht({agentId:W.id,teamId:he,...us})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors select-none ${se?"":"touch-none"} ${Fe?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${Ri(ue)}`,children:[h.jsx(_s,{name:W.name,avatarUrl:W.avatarUrl,size:28,bgClass:Fe?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"truncate font-medium text-[12px] leading-tight",children:W.name}),Dt&&h.jsxs("span",{className:"text-[9px] text-fg-secondary shrink-0 truncate max-w-[80px]",children:["(",W.role,")"]}),mt&&h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-500 shrink-0",children:h.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),Re&&h.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-brand-500/20 text-brand-400 font-medium shrink-0 leading-relaxed",children:"EXT"}),Fe&&h.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium shrink-0 leading-relaxed",children:Z("common:status.offline")})]}),h.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-secondary",children:Ut||" "})]}),h.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[(w?.get(W.id)??0)>0&&h.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none",children:w.get(W.id)}),W.mailboxDepth!=null&&W.mailboxDepth>0&&h.jsx("span",{className:"text-[8px] text-fg-tertiary bg-surface-overlay rounded-full px-1 leading-relaxed",children:W.mailboxDepth}),h.jsx("span",{title:Ls,onClick:Zt=>{Zt.stopPropagation(),_(W.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${tt}`}),se&&N&&h.jsx("span",{role:"button",tabIndex:0,onClick:Zt=>{if(Zt.stopPropagation(),dt?.agentId===W.id)ht(null);else{const us=lt(Zt);ss(!1),zs(""),ht({agentId:W.id,teamId:he,...us})}},className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors",title:Z("chat.moreOptions"),children:h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("circle",{cx:"12",cy:"12",r:"1"}),h.jsx("circle",{cx:"12",cy:"5",r:"1"}),h.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]})]})},W.id)},tl=(W,he,ue,Re)=>{const Fe=vi&&Jr===W&&ri?.fromTeamId!==W,tt=gh===W,vt=m===W,mt=w?(ds.byTeam.get(W)??[]).reduce((Rt,ns)=>Rt+(w.get(ns.id)??0),0):0,Ye=o.find(Rt=>Rt.type==="team"&&Rt.teamId===W),Yt=Ye&&S?S[Ye.channelKey]??0:0,Dt=mt+Yt,Ut=ds.byTeam.get(W)??[],Ls=Ut.filter(Rt=>Rt.status==="offline").length,Zt=Ut.length,us=Zt>0&&Ls===Zt,Ai=Ls>0&&!us,Nn=us?"bg-gray-500":Ai?"bg-amber-500":"bg-green-500";return h.jsxs("div",{"data-team-id":W,className:`mb-0.5 rounded-lg transition-all duration-500 ${Fe?"ring-1 ring-brand-500/50 bg-brand-500/5":""} ${tt?"ring-2 ring-brand-500 bg-brand-500/10":""}`,onPointerEnter:()=>{vi&&jo(W)},onPointerLeave:()=>{vi&&Jr===W&&jo(null)},children:[h.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[h.jsxs("button",{"data-l1-nav-id":`team:${W}`,onClick:()=>{v&&W!=="_ungrouped"&&v(W)},onContextMenu:Rt=>{if(!N||!he)return;Rt.preventDefault();const ns=lt(Rt);Ce({teamId:W,...ns})},className:`flex-1 flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors min-w-0 ${us?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${Ri(vt)}`,children:[h.jsxs("div",{className:`w-7 h-7 rounded-full flex items-center justify-center shrink-0 relative ${us?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}`,children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),Zt>0&&h.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full border-2 border-surface-primary ${Nn}`})]}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[ce===W?h.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-primary text-[12px] font-medium outline-none w-full",value:ge,onChange:Rt=>is(Rt.target.value),onBlur:()=>el(W),onKeyDown:Rt=>{Rt.key==="Enter"&&el(W),Rt.key==="Escape"&&ut(null)},onClick:Rt=>Rt.stopPropagation(),autoFocus:!0}):h.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:Re}),h.jsxs("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5 flex items-center gap-1.5",children:[Z("chat.members_other",{count:ue}),us&&h.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium leading-relaxed",children:Z("common:status.offline")}),Ai&&h.jsxs("span",{className:"text-[8px] px-1 py-0 rounded bg-amber-500/20 text-amber-500 font-medium leading-relaxed",children:[Ls,"/",Zt]})]})]}),Dt>0&&h.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:Dt}),h.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:h.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})]}),N&&he&&h.jsx("button",{onClick:Rt=>{if(Rt.stopPropagation(),ke?.teamId===W)Ce(null);else{const ns=lt(Rt);Ce({teamId:W,...ns})}},className:"w-7 h-7 flex items-center justify-center text-fg-muted hover:text-fg-primary rounded-md hover:bg-white/[0.08] transition-colors shrink-0",title:Z("chat.moreOptions"),children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("circle",{cx:"12",cy:"12",r:"1"}),h.jsx("circle",{cx:"12",cy:"5",r:"1"}),h.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]}),Fe&&vi&&h.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:Z("chat.dropHere")})]},W)},Ve=C.useMemo(()=>{const W=new Map,he=[],ue=[],Re=[];for(const Fe of o)if(Fe.channelKey.startsWith("dm:a2a:"))Re.push(Fe);else if(Fe.type==="custom")ue.push(Fe);else if(Fe.teamId){const tt=W.get(Fe.teamId)??[];tt.push(Fe),W.set(Fe.teamId,tt)}else{const tt=i.find(vt=>Fe.name.toLowerCase().includes(vt.name.toLowerCase())||vt.name.toLowerCase().includes(Fe.name.toLowerCase()));if(tt){const vt=W.get(tt.id)??[];vt.push(Fe),W.set(tt.id,vt)}else he.push(Fe)}return{byTeam:W,unmatched:he,custom:ue,dmChannels:Re}},[o,i]),[rt,er]=C.useState(!1),rn=l==="channel"&&Ve.dmChannels.some(W=>W.channelKey===d);C.useEffect(()=>{rn&&er(!0)},[rn]);const sl=C.useMemo(()=>{const W=[];e&&W.push({kind:"dm",id:`dm:${e.id}`,userId:e.id});for(const ue of r)ue.id!==e?.id&&W.push({kind:"dm",id:`dm:${ue.id}`,userId:ue.id});for(const ue of Ve.custom)W.push({kind:"channel",id:`channel:${ue.channelKey}`,channelKey:ue.channelKey});for(const ue of Ve.unmatched)W.push({kind:"channel",id:`channel:${ue.channelKey}`,channelKey:ue.channelKey});const he=ds.ungrouped.length>0?ds.ungrouped:i.length===0?t:[];for(const ue of he)W.push({kind:"agent",id:`agent:${ue.id}`,agentId:ue.id});for(const ue of i)W.push({kind:"team",id:`team:${ue.id}`,teamId:ue.id});if(rt)for(const ue of Ve.dmChannels)W.push({kind:"channel",id:`channel:${ue.channelKey}`,channelKey:ue.channelKey});return W},[e,r,Ve,ds,i,t,rt]),nn=C.useRef(sl);nn.current=sl;const ai=C.useCallback(W=>{W.kind==="dm"?b(W.userId):W.kind==="channel"?g(W.channelKey):W.kind==="agent"?f(W.agentId):W.kind==="team"&&v?.(W.teamId),requestAnimationFrame(()=>{document.querySelector(`[data-l1-nav-id="${W.id}"]`)?.scrollIntoView({block:"nearest"})})},[b,g,f,v]);C.useEffect(()=>{if(B||se||!T||D)return;const W=he=>{const ue=A?.keyboardPane??"content";if(ue==="l0"||ue==="l2"||he.metaKey||he.ctrlKey||he.altKey||px(he.target))return;const Re=he.key.length===1?he.key.toLowerCase():he.key;if(Re==="h"||Re==="ArrowLeft"){if(ue!=="l1")return;he.preventDefault(),he.stopPropagation(),A?.setL0FocusPageId(Ht.TEAM),A?.setLeftCollapsed(!1),A?.setKeyboardPane("l0");return}if(Re==="l"||Re==="ArrowRight"){if(ue!=="l1")return;he.preventDefault(),he.stopPropagation(),V&&A?.setKeyboardPane("l2");return}if(ue!=="l1"&&!(F&&(Re==="j"||Re==="k"||Re==="ArrowDown"||Re==="ArrowUp")))return;const Fe=Re==="j"||Re==="ArrowDown"?1:Re==="k"||Re==="ArrowUp"?-1:0;if(!Fe)return;he.preventDefault(),he.stopPropagation(),A?.setKeyboardPane("l1");const tt=nn.current;if(tt.length===0)return;let vt=-1;if(l==="dm"){const Ye=u||e?.id;Ye&&(vt=tt.findIndex(Yt=>Yt.kind==="dm"&&Yt.userId===Ye))}else l==="direct"?vt=tt.findIndex(Ye=>Ye.kind==="agent"&&Ye.agentId===c):l==="channel"&&(vt=tt.findIndex(Ye=>Ye.kind==="channel"&&Ye.channelKey===d),vt<0&&m&&(vt=tt.findIndex(Ye=>Ye.kind==="team"&&Ye.teamId===m)));vt<0&&(vt=Fe>0?-1:0);const mt=Math.max(0,Math.min(tt.length-1,vt+Fe));ai(tt[mt])};return document.addEventListener("keydown",W,!0),()=>document.removeEventListener("keydown",W,!0)},[B,se,T,D,A,F,V,l,u,e?.id,c,d,m,ai]);const Ri=W=>W?F?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":"bg-surface-overlay":"hover:bg-surface-overlay/60";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-keyboard-pane":"l1",className:`bg-surface-primary flex flex-col ${Q!=null?"shrink-0":"flex-1 min-w-0"} ${F?"ring-1 ring-inset ring-brand-500/30":""}`,style:D?{display:"none"}:Q!=null?{width:Q}:void 0,children:[h.jsxs("div",{"data-electron-drag":!0,className:"px-4 h-14 flex items-center shrink-0 gap-2",children:[se&&h.jsx(HS,{}),!se&&$&&h.jsx("button",{onClick:$,className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),h.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),h.jsx("h2",{className:"text-lg font-semibold",children:Z("chat.title")}),N&&h.jsxs("div",{"data-no-drag":!0,className:"ml-auto relative",ref:Ga,children:[h.jsxs("button",{onClick:()=>ji(!$i),className:"flex items-center gap-1 px-2.5 py-1 text-xs font-medium text-fg-secondary hover:text-fg-primary bg-surface-elevated/60 hover:bg-surface-elevated rounded-md transition-colors",children:[h.jsx("span",{className:"text-brand-500",children:"+"})," ",Z("chat.manage"),h.jsx("svg",{className:`w-2.5 h-2.5 transition-transform ${$i?"rotate-180":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:h.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),$i&&h.jsxs("div",{ref:W=>{if(!W)return;const he=W.getBoundingClientRect(),ue=window.innerWidth,Re=8;he.right>ue-Re&&(W.style.left="auto",W.style.right="0"),he.left<Re&&(W.style.left="0",W.style.right="auto")},className:"absolute right-0 top-full mt-1 w-48 max-w-[calc(100vw-1rem)] bg-surface-elevated border border-border-default rounded-lg shadow-xl z-50 overflow-hidden",children:[h.jsxs("button",{onClick:()=>{ji(!1),le("agent")},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated transition-colors",children:[h.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),h.jsx("circle",{cx:"12",cy:"5",r:"2"}),h.jsx("path",{d:"M12 7v4"}),h.jsx("circle",{cx:"9",cy:"16",r:"1",fill:"currentColor",stroke:"none"}),h.jsx("circle",{cx:"15",cy:"16",r:"1",fill:"currentColor",stroke:"none"})]}),Z("chat.addAgent")]}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:Z("chat.addAgentDesc")})]}),h.jsxs("button",{onClick:()=>{ji(!1),le("team")},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[h.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("line",{x1:"19",y1:"8",x2:"19",y2:"14"}),h.jsx("line",{x1:"22",y1:"11",x2:"16",y2:"11"})]}),Z("chat.newTeam")]}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:Z("chat.newTeamDesc")})]}),h.jsxs("button",{onClick:()=>{ji(!1),ie(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-green-600 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[h.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M20 8v6"}),h.jsx("path",{d:"M23 11h-6"})]}),Z("chat.addHuman")]}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:Z("chat.addHumanDesc")})]}),h.jsxs("button",{onClick:()=>{ji(!1),Y(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[h.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),h.jsx("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),Z("chat.newGroupChat")]}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:Z("chat.newGroupChatDesc")})]}),ii!==null&&h.jsxs("button",{onClick:()=>{ji(!1),$o()},disabled:Ja,className:`w-full text-left px-4 py-2.5 text-xs hover:bg-surface-elevated border-t border-border-default transition-colors disabled:opacity-50 ${ii?"text-green-600":"text-red-500"}`,children:[h.jsx("div",{className:"font-medium flex items-center gap-1.5",children:ii?h.jsxs(h.Fragment,{children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})," ",Z("chat.resume")]}):h.jsxs(h.Fragment,{children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})," ",Z("contextMenu.stopAll")]})}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:Z(ii?"modals.resumeAll.title":"modals.pauseAll.title")})]})]})]})]}),h.jsxs("div",{ref:Ji,className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[h.jsxs("div",{className:"mb-2",children:[h.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:Z("chat.people")}),e&&h.jsxs("button",{"data-l1-nav-id":`dm:${e.id}`,onClick:()=>b(e.id),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${Ri(l==="dm"&&(u===e.id||!u))}`,children:[h.jsx(_s,{name:e.name,avatarUrl:e.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-400"}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsx("div",{className:"truncate font-medium text-[12px] leading-tight",children:e.name}),h.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:Z("chat.myNotes")})]}),h.jsx("span",{className:"text-fg-secondary shrink-0",children:h.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),h.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),r.filter(W=>W.id!==e?.id).map(W=>{const he=e?.id?`dm:${[e.id,W.id].sort().join(":")}`:"",ue=he&&S?S[he]??0:0;return h.jsxs("button",{"data-l1-nav-id":`dm:${W.id}`,onClick:()=>b(W.id),onContextMenu:Re=>{if(!N||W.id===e?.id)return;Re.preventDefault();const Fe=lt(Re);bs({userId:W.id,...Fe})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${l==="dm"&&u===W.id?F?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":"bg-green-500/15":"hover:bg-surface-overlay/60"}`,children:[h.jsx(_s,{name:W.name,avatarUrl:W.avatarUrl,size:28,bgClass:"bg-green-500/10 text-green-500"}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsx("div",{className:"truncate font-medium text-[12px] leading-tight",children:W.name}),h.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:W.email||W.role})]}),ue>0?h.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:ue}):h.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0"})]},W.id)})]}),Ve.custom.length>0&&h.jsxs("div",{className:"mb-2",children:[h.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-2.5",children:Z("chat.groups")}),Ve.custom.map(W=>{const he=l==="channel"&&d===W.channelKey;return h.jsxs("button",{"data-l1-nav-id":`channel:${W.channelKey}`,onClick:()=>g(W.channelKey),onContextMenu:ue=>{ue.preventDefault();const Re=lt(ue);xt({gcId:W.id,...Re})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${Ri(he)}`,children:[h.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:W.name}),h.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:Z("chat.members_other",{count:W.memberCount??0})})]})]},W.id)})]}),j?h.jsx("div",{className:"space-y-3 px-1 mb-2",children:[...Array(6)].map((W,he)=>h.jsxs("div",{className:"flex items-center gap-2.5 animate-pulse",children:[h.jsx("div",{className:"w-6 h-6 rounded-lg bg-surface-overlay shrink-0"}),h.jsxs("div",{className:"flex-1 space-y-1.5",children:[h.jsx("div",{className:"h-2.5 bg-surface-overlay rounded w-24"}),h.jsx("div",{className:"h-2 bg-surface-overlay rounded w-36"})]}),h.jsx("div",{className:"w-2 h-2 rounded-full bg-surface-overlay shrink-0"})]},he))}):t.length===0&&i.length===0?h.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:Z("chat.noAgentsYet")}):null,Ve.unmatched.map(W=>{const he=S?.[W.channelKey]??0;return h.jsxs("button",{"data-l1-nav-id":`channel:${W.channelKey}`,onClick:()=>g(W.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${Ri(l==="channel"&&d===W.channelKey)}`,children:[h.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:W.name}),h.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:Z("chat.groupChat")})]}),he>0?h.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none",children:he}):W.memberCount!==void 0&&W.memberCount>0?h.jsx("span",{className:"text-[9px] text-fg-secondary shrink-0",children:W.memberCount}):null]},W.id)}),ds.ungrouped.length>0&&h.jsxs("div",{className:"mb-2",children:[h.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:Z("chat.agents")}),ds.ungrouped.map(W=>oi(W))]}),i.length>0&&h.jsxs("div",{className:"mb-2",ref:Ka,children:[h.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:Z("chat.teams")}),i.map(W=>{const he=ds.byTeam.get(W.id)??[],ue=W.members?.length||he.length;return tl(W.id,W,ue,W.name)})]}),i.length===0&&ds.ungrouped.length===0&&t.length>0&&t.map(W=>oi(W)),Ve.dmChannels.length>0&&h.jsxs("div",{className:"mb-2",children:[h.jsxs("button",{onClick:()=>er(W=>!W),className:"w-full flex items-center gap-1.5 px-2.5 py-1 text-[10px] font-semibold text-fg-muted uppercase tracking-wider hover:text-fg-secondary transition-colors",children:[h.jsx("svg",{className:`w-2.5 h-2.5 transition-transform ${rt?"rotate-90":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:h.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),Z("chat.agentDMs"),h.jsx("span",{className:"ml-auto text-[9px] font-normal text-fg-tertiary",children:Ve.dmChannels.length})]}),rt&&Ve.dmChannels.map(W=>{const he=l==="channel"&&d===W.channelKey,ue=S?.[W.channelKey]??0,Re=W.name.replace(/^DM:\s*/,"");return h.jsxs("button",{"data-l1-nav-id":`channel:${W.channelKey}`,onClick:()=>g(W.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 pl-5 py-1.5 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${Ri(he)}`,children:[h.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center shrink-0 bg-surface-overlay/60 text-fg-tertiary text-[9px]",children:h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),h.jsx("span",{className:"flex-1 min-w-0 text-left truncate text-[11px] text-fg-secondary",children:Re}),ue>0&&h.jsx("span",{className:"min-w-[14px] h-[14px] flex items-center justify-center text-[8px] font-semibold text-white bg-red-500 rounded-full px-0.5 leading-none",children:ue})]},W.id)})]})]})]}),I&&h.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative flex items-center justify-center",onMouseDown:I,children:h.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),ke&&(()=>{const W=ds.byTeam.get(ke.teamId)??[],he=W.some(Re=>Re.status==="offline"),ue=W.some(Re=>Re.status!=="offline");return h.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:ke.x,top:ke.y},onClick:Re=>Re.stopPropagation(),children:[h.jsxs("button",{onClick:()=>{const Re=sn.get(ke.teamId);Re&&(ut(ke.teamId),is(Re.name)),Ce(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),h.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Z("contextMenu.renameTeam")]}),he&&h.jsxs("button",{onClick:()=>{Ln(ke.teamId,"start"),Ce(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),Z("contextMenu.startAll")]}),ue&&h.jsxs("button",{onClick:()=>{Ln(ke.teamId,"stop"),Ce(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),Z("contextMenu.stopAll")]}),h.jsx("div",{className:"border-t border-border-default/50 my-1"}),h.jsxs("button",{onClick:()=>{Ce(null),Or.navigate(Ht.STORE)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),Z("chat.addAgent")]}),U.length>0&&h.jsxs("button",{onClick:()=>{Ce(null),G(ke.teamId)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),h.jsx("polyline",{points:"17 11 19 13 23 9"})]}),Z("contextMenu.addExisting")]}),h.jsx("div",{className:"border-t border-border-default/50 my-1"}),h.jsxs("button",{onClick:()=>{const Re=sn.get(ke.teamId);Re&&tn(ke.teamId,Re.name),Ce(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"3 6 5 6 21 6"}),h.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),Z("contextMenu.deleteTeam")]})]})})(),dt&&(()=>{const W=t.find(tt=>tt.id===dt.agentId);if(!W||!N)return null;const ue=(dt.teamId?sn.get(dt.teamId):void 0)?.managerId===W.id,Re=W.id===e?.id,Fe=rs(W);return h.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-48 max-w-[calc(100vw-1rem)] overflow-y-auto",style:{left:dt.x,top:dt.y,maxHeight:Math.max(160,window.innerHeight-dt.y-8)},onClick:tt=>tt.stopPropagation(),children:[Fe&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"px-3 py-2 text-[10px] leading-snug text-fg-secondary font-medium",children:Z("contextMenu.orgSecretaryProtected")}),h.jsx("div",{className:"border-t border-border-default/50 my-1"})]}),h.jsxs("button",{onClick:()=>{ht(null),_(W.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),Z("contextMenu.viewProfile")]}),W.status==="offline"?h.jsxs("button",{onClick:()=>{At(W.id,"offline"),ht(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),Z("contextMenu.start")]}):h.jsxs("button",{onClick:()=>{At(W.id,W.status??"idle"),ht(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),Z("contextMenu.stop")]}),!Fe&&dt.teamId&&!ue&&h.jsxs("button",{onClick:()=>{Oh(dt.teamId,W.id,"agent"),ht(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),Z("contextMenu.setAsManager")]}),!Fe&&dt.teamId&&h.jsxs("button",{onClick:()=>{Qs(dt.teamId,W.id),ht(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"9 14 4 9 9 4"}),h.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),Z("contextMenu.removeFromTeam")]}),!Fe&&(()=>{const tt=i.filter(Ye=>Ye.id!==dt.teamId);if(tt.length===0)return null;const vt=Lt.trim().toLowerCase(),mt=vt?tt.filter(Ye=>Ye.name.toLowerCase().includes(vt)):tt;return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"border-t border-border-default/50 my-1"}),h.jsxs("button",{type:"button",onClick:()=>ss(Ye=>!Ye),className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M5 12h14"}),h.jsx("path",{d:"M12 5l7 7-7 7"})]}),h.jsx("span",{className:"flex-1",children:Z("contextMenu.moveTo")}),h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-fg-tertiary transition-transform ${yt?"rotate-180":""}`,children:h.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),yt&&h.jsxs("div",{className:"px-2 pb-1.5",onClick:Ye=>Ye.stopPropagation(),children:[h.jsx("input",{autoFocus:!0,value:Lt,onChange:Ye=>zs(Ye.target.value),onKeyDown:Ye=>Ye.stopPropagation(),placeholder:Z("contextMenu.moveToSearch"),className:"w-full mb-1 px-2 py-1.5 text-xs rounded-md bg-surface-overlay border border-border-default text-fg-primary placeholder:text-fg-tertiary outline-none focus:border-brand-500/50"}),h.jsx("div",{className:"max-h-36 overflow-y-auto rounded-md",children:mt.length===0?h.jsx("div",{className:"px-2 py-2 text-[10px] text-fg-tertiary",children:Z("contextMenu.moveToEmpty")}):mt.map(Ye=>h.jsx("button",{type:"button",onClick:async()=>{dt.teamId&&await J.teams.removeMember(dt.teamId,W.id),await J.teams.addMember(Ye.id,W.id,"agent"),O(),p(),Ms(),ht(null)},className:"w-full text-left px-2 py-1.5 text-xs hover:bg-surface-overlay text-fg-secondary rounded truncate",title:Ye.name,children:Ye.name},Ye.id))})]})]})})(),!Fe&&!Re&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"border-t border-border-default/50 my-1"}),h.jsxs("button",{onClick:()=>{Vs(W.id,W.name,"agent"),ht(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"3 6 5 6 21 6"}),h.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),Z("contextMenu.removeFromOrg")]})]})]})})(),vs&&(()=>{const W=r.find(he=>he.id===vs.userId);return!W||!N?null:h.jsx("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:vs.x,top:vs.y},onClick:he=>he.stopPropagation(),children:h.jsxs("button",{onClick:()=>{Vs(W.id,W.name,"human"),bs(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"3 6 5 6 21 6"}),h.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),Z("contextMenu.removeFromOrg")]})})})(),X&&h.jsx(I_,{onClose:()=>M(!1),onCreate:async(W,he)=>{try{const{team:ue}=await J.teams.create(W,he);M(!1),O(),Hr(ue.id),setTimeout(()=>{document.querySelector(`[data-team-id="${ue.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},300),setTimeout(()=>Hr(null),3e3)}catch(ue){Gr(Z("chat.failedToCreateTeam",{message:ue instanceof Error?ue.message:String(ue)}),"error")}}}),K&&h.jsx(B_,{onClose:()=>{ie(!1),x?.()},onAdd:async(W,he,ue)=>{const{inviteToken:Re}=await J.users.create(W,he,void 0,ue);return x?.(),{inviteToken:Re}}}),oe!==null&&h.jsx(W_,{teamId:oe,ungrouped:U,onClose:()=>G(null),onAdd:async(W,he)=>{await J.teams.addMember(oe,W,he),G(null),O(),Ms()}}),$e&&h.jsx(X_,{onClose:()=>Ie(!1),onConnected:()=>{Ie(!1),p(),O()}}),Ps&&(()=>{const W=o.find(he=>he.id===Ps.gcId);return W?h.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:Ps.x,top:Ps.y},onClick:he=>he.stopPropagation(),children:[W.type==="custom"&&h.jsxs("button",{onClick:()=>{xt(null),k?k(W.channelKey):g(W.channelKey)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),Z("contextMenu.manageMembers")]}),h.jsxs("button",{onClick:async()=>{xt(null),Mn(Z("modals.deleteGroupChat.title"),Z("modals.deleteGroupChat.message",{name:W.name}),async()=>{await J.groupChats.delete(W.id),y()},Z("modals.deleteGroupChat.confirm"))},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"3 6 5 6 21 6"}),h.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),Z("modals.deleteGroupChat.menuLabel")]})]}):null})(),We&&h.jsx(q_,{agents:t,humans:r,authUser:e,onClose:()=>Y(!1),onCreate:async(W,he,ue,Re)=>{await J.groupChats.create({name:W,memberIds:he,memberTypes:ue,memberNames:Re,creatorId:e?.id,creatorName:e?.name}),Y(!1),y()}}),ee&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:()=>le(null),children:h.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[340px] max-w-[90vw] overflow-hidden",onClick:W=>W.stopPropagation(),children:[h.jsxs("div",{className:"px-5 py-4 border-b border-border-default",children:[h.jsx("h3",{className:"text-sm font-semibold",children:Z(ee==="agent"?"chat.addAgent":"chat.newTeam")}),h.jsx("p",{className:"text-[11px] text-fg-tertiary mt-0.5",children:Z("chat.methodChoiceSubtitle")})]}),h.jsxs("div",{className:"p-3 space-y-2",children:[h.jsxs("button",{onClick:()=>{const W=ee;le(null);const he=t.find(ue=>ue.role==="secretary")??t.find(ue=>ue.name?.toLowerCase().includes("secretary"));he?(f(he.id),Or.navigate(Ht.TEAM,{agentId:he.id,prefillMessage:Z(W==="agent"?"chat.addAgentPrefill":"chat.newTeamPrefill")})):W==="agent"?Or.navigate(Ht.STORE):M(!0)},className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-brand-500/30 bg-brand-500/5 hover:bg-brand-500/10 transition-colors text-left",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-brand-500/15 flex items-center justify-center shrink-0",children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"text-brand-500",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"}),h.jsx("path",{d:"M20 3v4"}),h.jsx("path",{d:"M22 5h-4"})]})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-xs font-medium text-brand-500",children:Z("chat.methodSecretary")}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:Z("chat.methodSecretaryDesc")})]}),h.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-brand-500/10 text-brand-500 font-medium shrink-0",children:Z("chat.recommended")})]}),h.jsxs("button",{onClick:()=>{const W=ee;le(null),W==="agent"?Or.navigate(Ht.STORE):M(!0)},className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:bg-surface-overlay transition-colors text-left",children:[h.jsx("div",{className:"w-8 h-8 rounded-full bg-surface-overlay flex items-center justify-center shrink-0",children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"text-fg-secondary",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7z"}),h.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-xs font-medium text-fg-secondary",children:Z("chat.methodManual")}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:Z(ee==="agent"?"chat.methodManualAgentDesc":"chat.methodManualTeamDesc")})]})]})]}),h.jsx("div",{className:"px-5 py-3 border-t border-border-default flex justify-end",children:h.jsx("button",{onClick:()=>le(null),className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:Z("common:cancel")})})]})}),Ei&&h.jsx(Wa,{title:Ei.title,message:Ei.message,confirmLabel:Ei.confirmLabel,checkboxes:Ei.checkboxes,onConfirm:W=>{Ei.onConfirm(W),Kr(null)},onCancel:()=>Kr(null)}),Po&&h.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2.5 rounded-lg shadow-xl text-sm font-medium ${Po.type==="error"?"bg-red-500/10 text-red-500 border border-red-500/30":"bg-surface-elevated/95 text-fg-primary border border-border-default/50"}`,children:Po.message})]})});function Nm({team:s,agents:e,humans:t,authUser:i,groupChat:r,chatMode:n,selectedAgent:a,activeChannel:o,activeDmUserId:l,teams:c,onSelectAgent:d,onSelectChannel:u,onSelectDm:f,onBack:g,onViewProfile:b,onRefreshAgents:v,onRefreshTeams:m,unreadByAgent:O,width:p,onResizeStart:x,focused:y}){const{t:_}=Pt(["team","common"]),k=wf(),w=_f(Ht.TEAM),S=i?.role==="owner"||i?.role==="admin",Q=C.useMemo(()=>e.filter(X=>X.teamId===s.id),[e,s.id]),I=C.useMemo(()=>{const X=new Set((s.members??[]).filter(M=>M.type==="human").map(M=>M.id));return t.filter(M=>X.has(M.id))},[s.members,t]),D=r&&n==="channel"&&o===r.channelKey,$=C.useMemo(()=>{const X=[];r&&X.push({kind:"channel",id:`channel:${r.channelKey}`,channelKey:r.channelKey});for(const M of Q)X.push({kind:"agent",id:`agent:${M.id}`,agentId:M.id});for(const M of I)X.push({kind:"dm",id:`dm:${M.id}`,userId:M.id});return X},[r,Q,I]),j=C.useRef($);j.current=$;const B=C.useCallback(X=>{X.kind==="channel"?u(X.channelKey):X.kind==="agent"?d(X.agentId):f(X.userId),requestAnimationFrame(()=>{document.querySelector(`[data-l2-nav-id="${X.id}"]`)?.scrollIntoView({block:"nearest"})})},[u,d,f]);C.useEffect(()=>{if(!w)return;const X=M=>{if((k?.keyboardPane??"content")!=="l2"||M.metaKey||M.ctrlKey||M.altKey||px(M.target))return;const ie=M.key.length===1?M.key.toLowerCase():M.key;if(ie==="h"||ie==="ArrowLeft"){M.preventDefault(),M.stopPropagation(),k?.setKeyboardPane("l1");return}if(ie==="l"||ie==="ArrowRight"){M.preventDefault(),M.stopPropagation();return}const oe=ie==="j"||ie==="ArrowDown"?1:ie==="k"||ie==="ArrowUp"?-1:0;if(!oe)return;M.preventDefault(),M.stopPropagation();const G=j.current;if(G.length===0)return;let $e=-1;n==="channel"?$e=G.findIndex(We=>We.kind==="channel"&&We.channelKey===o):n==="direct"?$e=G.findIndex(We=>We.kind==="agent"&&We.agentId===a):n==="dm"&&l&&($e=G.findIndex(We=>We.kind==="dm"&&We.userId===l)),$e<0&&($e=oe>0?-1:0);const Ie=Math.max(0,Math.min(G.length-1,$e+oe));B(G[Ie])};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[w,k,n,o,a,l,B]);const F=X=>X?y?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":"bg-surface-overlay":"hover:bg-surface-overlay/60",[V,Z]=C.useState(null),[se,T]=C.useState(!1),[A,N]=C.useState(""),z=C.useCallback((X,M=176,K=220)=>{const ie=window.innerWidth,oe=window.innerHeight,G=8;let $e=X.clientX,Ie=X.clientY;return $e+M>ie-G&&($e=Math.max(G,ie-M-G)),Ie+K>oe-G&&(Ie=Math.max(G,oe-K-G)),$e=Math.max(G,Math.min($e,ie-M-G)),Ie=Math.max(G,Math.min(Ie,oe-K-G)),{x:$e,y:Ie}},[]);C.useEffect(()=>{if(!V)return;const X=()=>Z(null),M=setTimeout(()=>document.addEventListener("click",X),0);return()=>{clearTimeout(M),document.removeEventListener("click",X)}},[V]);const U=C.useCallback(async(X,M)=>{M==="offline"?await J.agents.start(X):await J.agents.stop(X),v()},[v]),ne=C.useCallback(async X=>{await J.teams.update(s.id,{managerId:X,managerType:"agent"}),m()},[s.id,m]),Se=C.useCallback(async X=>{await J.teams.removeMember(s.id,X),m(),v()},[s.id,m,v]),Pe=C.useCallback(async(X,M)=>{await J.teams.removeMember(s.id,X),await J.teams.addMember(M,X,"agent"),m(),v()},[s.id,m,v]);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-keyboard-pane":"l2",className:`bg-surface-primary flex flex-col shrink-0 ${y?"ring-1 ring-inset ring-brand-500/30":""}`,style:p!=null?{width:p}:{width:260},children:[h.jsxs("div",{className:"px-3 h-14 flex items-center gap-2 shrink-0",children:[h.jsx("button",{onClick:g,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-brand-500/15 text-brand-500 transition-colors shrink-0",title:_("common:back",{defaultValue:"Back"}),children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),h.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"truncate font-semibold text-sm",children:s.name}),s.description&&h.jsx("div",{className:"truncate text-[10px] text-fg-tertiary",children:s.description})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[r&&h.jsxs("div",{className:"mb-3",children:[h.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:_("chat.groupChat",{defaultValue:"Group Chat"})}),h.jsxs("button",{"data-l2-nav-id":`channel:${r.channelKey}`,onClick:()=>u(r.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors text-fg-primary ${F(!!D)}`,children:[h.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:s.name}),h.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:_("chat.members_other",{count:r.memberCount||Q.length+I.length})})]})]})]}),Q.length>0&&h.jsxs("div",{className:"mb-3",children:[h.jsxs("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:[_("chat.agents",{defaultValue:"Agents"}),h.jsx("span",{className:"ml-1 text-fg-tertiary font-normal",children:Q.length})]}),Q.map(X=>{const M=n==="direct"&&a===X.id,K=s.managerId===X.id,ie=X.status==="offline",oe=X.status==="idle"?"bg-green-500":X.status==="working"?"bg-blue-500 animate-pulse":X.status==="error"?"bg-red-500":"bg-gray-600";return h.jsxs("button",{"data-l2-nav-id":`agent:${X.id}`,onClick:()=>d(X.id),onContextMenu:G=>{if(!S)return;G.preventDefault();const $e=z(G);T(!1),N(""),Z({agentId:X.id,...$e})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors ${ie?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${F(M)}`,children:[h.jsx(_s,{name:X.name,avatarUrl:X.avatarUrl,size:28,bgClass:ie?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"truncate font-medium text-[12px] leading-tight",children:X.name}),K&&h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-500 shrink-0",children:h.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),ie&&h.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium shrink-0 leading-relaxed",children:_("common:status.offline")})]}),h.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-secondary",children:X.role||" "})]}),(O?.get(X.id)??0)>0&&h.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:O.get(X.id)}),h.jsx("span",{title:X.status,onClick:G=>{G.stopPropagation(),b(X.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] shrink-0 ${oe}`})]},X.id)})]}),I.length>0&&h.jsxs("div",{className:"mb-3",children:[h.jsxs("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:[_("chat.people"),h.jsx("span",{className:"ml-1 text-fg-tertiary font-normal",children:I.length})]}),I.map(X=>{const M=X.id===i?.id,K=n==="dm"&&l===X.id;return h.jsxs("button",{"data-l2-nav-id":`dm:${X.id}`,onClick:()=>f(X.id),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${F(K)}`,children:[h.jsx(_s,{name:X.name,avatarUrl:X.avatarUrl,size:28,bgClass:"bg-green-500/10 text-green-500"}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsxs("div",{className:"truncate font-medium text-[12px] leading-tight",children:[X.name,M?` (${_("chat.you",{defaultValue:"You"})})`:""]}),h.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:X.email||X.role})]}),h.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0"})]},X.id)})]}),Q.length===0&&I.length===0&&h.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6 px-2",children:_("chat.noMembers",{defaultValue:"No members in this team yet."})})]})]}),x&&h.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative flex items-center justify-center",onMouseDown:x,children:h.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),V&&(()=>{const X=Q.find(K=>K.id===V.agentId);if(!X||!S)return null;const M=s.managerId===X.id;return h.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-48 max-w-[calc(100vw-1rem)] overflow-y-auto",style:{left:V.x,top:V.y,maxHeight:Math.max(160,window.innerHeight-V.y-8)},onClick:K=>K.stopPropagation(),children:[h.jsxs("button",{onClick:()=>{Z(null),b(X.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),_("contextMenu.viewProfile")]}),X.status==="offline"?h.jsxs("button",{onClick:()=>{U(X.id,"offline"),Z(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),_("contextMenu.start")]}):h.jsxs("button",{onClick:()=>{U(X.id,X.status??"idle"),Z(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),_("contextMenu.stop")]}),!M&&h.jsxs("button",{onClick:()=>{ne(X.id),Z(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),_("contextMenu.setAsManager")]}),h.jsxs("button",{onClick:()=>{Se(X.id),Z(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"9 14 4 9 9 4"}),h.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),_("contextMenu.removeFromTeam")]}),(()=>{const K=c.filter(G=>G.id!==s.id);if(K.length===0)return null;const ie=A.trim().toLowerCase(),oe=ie?K.filter(G=>G.name.toLowerCase().includes(ie)):K;return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"border-t border-border-default/50 my-1"}),h.jsxs("button",{type:"button",onClick:()=>T(G=>!G),className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M5 12h14"}),h.jsx("path",{d:"M12 5l7 7-7 7"})]}),h.jsx("span",{className:"flex-1",children:_("contextMenu.moveTo")}),h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-fg-tertiary transition-transform ${se?"rotate-180":""}`,children:h.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),se&&h.jsxs("div",{className:"px-2 pb-1.5",onClick:G=>G.stopPropagation(),children:[h.jsx("input",{autoFocus:!0,value:A,onChange:G=>N(G.target.value),onKeyDown:G=>G.stopPropagation(),placeholder:_("contextMenu.moveToSearch"),className:"w-full mb-1 px-2 py-1.5 text-xs rounded-md bg-surface-overlay border border-border-default text-fg-primary placeholder:text-fg-tertiary outline-none focus:border-brand-500/50"}),h.jsx("div",{className:"max-h-36 overflow-y-auto rounded-md",children:oe.length===0?h.jsx("div",{className:"px-2 py-2 text-[10px] text-fg-tertiary",children:_("contextMenu.moveToEmpty")}):oe.map(G=>h.jsx("button",{type:"button",onClick:()=>{Pe(X.id,G.id),Z(null)},className:"w-full text-left px-2 py-1.5 text-xs hover:bg-surface-overlay text-fg-secondary rounded truncate",title:G.name,children:G.name},G.id))})]})]})})(),h.jsx("div",{className:"border-t border-border-default/50 my-1"}),h.jsxs("button",{onClick:async()=>{await J.agents.remove(X.id),v(),Z(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"3 6 5 6 21 6"}),h.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),_("contextMenu.removeFromOrg")]})]})})()]})}function uu(){return uu=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},uu.apply(null,arguments)}function Z_(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}let fu=[],Sx=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?Sx:fu).push(t=t+s[e])})();function V_(s){if(s<768)return!1;for(let e=0,t=fu.length;;){let i=e+t>>1;if(s<fu[i])t=i;else if(s>=Sx[i])e=i+1;else return!0;if(e==t)return!1}}function Dm(s){return s>=127462&&s<=127487}const Im=8205;function F_(s,e,t=!0,i=!0){return(t?_x:Y_)(s,e,i)}function _x(s,e,t){if(e==s.length)return e;e&&wx(s.charCodeAt(e))&&kx(s.charCodeAt(e-1))&&e--;let i=sd(s,e);for(e+=Bm(i);e<s.length;){let r=sd(s,e);if(i==Im||r==Im||t&&V_(r))e+=Bm(r),i=r;else if(Dm(r)){let n=0,a=e-2;for(;a>=0&&Dm(sd(s,a));)n++,a-=2;if(n%2==0)break;e+=2}else break}return e}function Y_(s,e,t){for(;e>1;){let i=_x(s,e-2,t);if(i<e)return i;e--}return 0}function sd(s,e){let t=s.charCodeAt(e);if(!kx(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return wx(i)?(t-55296<<10)+(i-56320)+65536:t}function wx(s){return s>=56320&&s<57344}function kx(s){return s>=55296&&s<56320}function Bm(s){return s<65536?1:2}let bt=class Cx{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=uo(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),Xi.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=uo(this,e,t);let i=[];return this.decompose(e,t,i,0),Xi.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new oa(this),n=new oa(e);for(let a=t,o=t;;){if(r.next(a),n.next(a),a=0,r.lineBreak!=n.lineBreak||r.done!=n.done||r.value!=n.value)return!1;if(o+=r.value.length,r.done||o>=i)return!0}}iter(e=1){return new oa(this,e)}iterRange(e,t=this.length){return new Px(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Tx(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Cx.empty:e.length<=32?new Ft(e):Xi.from(Ft.split(e,[]))}};class Ft extends bt{constructor(e,t=U_(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let n=0;;n++){let a=this.text[n],o=r+a.length;if((t?i:o)>=e)return new H_(r,o,i,a);r=o+1,i++}}decompose(e,t,i,r){let n=e<=0&&t>=this.length?this:new Ft(Wm(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let a=i.pop(),o=tc(n.text,a.text.slice(),0,n.length);if(o.length<=32)i.push(new Ft(o,a.length+n.length));else{let l=o.length>>1;i.push(new Ft(o.slice(0,l)),new Ft(o.slice(l)))}}else i.push(n)}replace(e,t,i){if(!(i instanceof Ft))return super.replace(e,t,i);[e,t]=uo(this,e,t);let r=tc(this.text,tc(i.text,Wm(this.text,0,e)),t),n=this.length+i.length-(t-e);return r.length<=32?new Ft(r,n):Xi.from(Ft.split(r,[]),n)}sliceString(e,t=this.length,i=`
|
|
6
|
-
`){[e,t]=uo(this,e,t);let r="";for(let n=0,a=0;n<=t&&a<this.text.length;a++){let o=this.text[a],l=n+o.length;n>e&&a&&(r+=i),e<l&&t>n&&(r+=o.slice(Math.max(0,e-n),t-n)),n=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let n of e)i.push(n),r+=n.length+1,i.length==32&&(t.push(new Ft(i,r)),i=[],r=-1);return r>-1&&t.push(new Ft(i,r)),t}}class Xi extends bt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let n=0;;n++){let a=this.children[n],o=r+a.length,l=i+a.lines-1;if((t?l:o)>=e)return a.lineInner(e,t,i,r);r=o+1,i=l+1}}decompose(e,t,i,r){for(let n=0,a=0;a<=t&&n<this.children.length;n++){let o=this.children[n],l=a+o.length;if(e<=l&&t>=a){let c=r&((a<=e?1:0)|(l>=t?2:0));a>=e&&l<=t&&!c?i.push(o):o.decompose(e-a,t-a,i,c)}a=l+1}}replace(e,t,i){if([e,t]=uo(this,e,t),i.lines<this.lines)for(let r=0,n=0;r<this.children.length;r++){let a=this.children[r],o=n+a.length;if(e>=n&&t<=o){let l=a.replace(e-n,t-n,i),c=this.lines-a.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let d=this.children.slice();return d[r]=l,new Xi(d,this.length-(t-e)+i.length)}return super.replace(n,o,l)}n=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
7
|
-
`){[e,t]=uo(this,e,t);let r="";for(let n=0,a=0;n<this.children.length&&a<=t;n++){let o=this.children[n],l=a+o.length;a>e&&n&&(r+=i),e<l&&t>a&&(r+=o.sliceString(e-a,t-a,i)),a=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Xi))return 0;let i=0,[r,n,a,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,n+=t){if(r==a||n==o)return i;let l=this.children[r],c=e.children[n];if(l!=c)return i+l.scanIdentical(c,t);i+=l.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let g of e)i+=g.lines;if(i<32){let g=[];for(let b of e)b.flatten(g);return new Ft(g,t)}let r=Math.max(32,i>>5),n=r<<1,a=r>>1,o=[],l=0,c=-1,d=[];function u(g){let b;if(g.lines>n&&g instanceof Xi)for(let v of g.children)u(v);else g.lines>a&&(l>a||!l)?(f(),o.push(g)):g instanceof Ft&&l&&(b=d[d.length-1])instanceof Ft&&g.lines+b.lines<=32?(l+=g.lines,c+=g.length+1,d[d.length-1]=new Ft(b.text.concat(g.text),b.length+1+g.length)):(l+g.lines>r&&f(),l+=g.lines,c+=g.length+1,d.push(g))}function f(){l!=0&&(o.push(d.length==1?d[0]:Xi.from(d,c)),c=-1,l=d.length=0)}for(let g of e)u(g);return f(),o.length==1?o[0]:new Xi(o,t)}}bt.empty=new Ft([""],0);function U_(s){let e=-1;for(let t of s)e+=t.length+1;return e}function tc(s,e,t=0,i=1e9){for(let r=0,n=0,a=!0;n<s.length&&r<=i;n++){let o=s[n],l=r+o.length;l>=t&&(l>i&&(o=o.slice(0,i-r)),r<t&&(o=o.slice(t-r)),a?(e[e.length-1]+=o,a=!1):e.push(o)),r=l+1}return e}function Wm(s,e,t){return tc(s,[""],e,t)}class oa{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Ft?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],n=this.offsets[i],a=n>>1,o=r instanceof Ft?r.text.length:r.children.length;if(a==(t>0?o:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((n&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
8
|
-
`,this;e--}else if(r instanceof Ft){let l=r.text[a+(t<0?-1:0)];if(this.offsets[i]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[a+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof Ft?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Px{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new oa(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Tx{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(bt.prototype[Symbol.iterator]=function(){return this.iter()},oa.prototype[Symbol.iterator]=Px.prototype[Symbol.iterator]=Tx.prototype[Symbol.iterator]=function(){return this});let H_=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function uo(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function cs(s,e,t=!0,i=!0){return F_(s,e,t,i)}function G_(s){return s>=56320&&s<57344}function K_(s){return s>=55296&&s<56320}function Is(s,e){let t=s.charCodeAt(e);if(!K_(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return G_(i)?(t-55296<<10)+(i-56320)+65536:t}function kf(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function qi(s){return s<65536?1:2}const pu=/\r\n?|\n/;var gs=(function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s})(gs||(gs={}));class Ui{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let n=this.sections[t++],a=this.sections[t++];a<0?(e(i,r,n),r+=n):r+=a,i+=n}}iterChangedRanges(e,t=!1){mu(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new Ui(e)}composeDesc(e){return this.empty?e:e.empty?this:Qx(this,e)}mapDesc(e,t=!1){return e.empty?this:gu(this,e,t)}mapPos(e,t=-1,i=gs.Simple){let r=0,n=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],l=this.sections[a++],c=r+o;if(l<0){if(c>e)return n+(e-r);n+=o}else{if(i!=gs.Simple&&c>=e&&(i==gs.TrackDel&&r<e&&c>e||i==gs.TrackBefore&&r<e||i==gs.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?n:n+l;n+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return n}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let n=this.sections[i++],a=this.sections[i++],o=r+n;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?"cover":!0;r=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ui(e)}static create(e){return new Ui(e)}}class Jt extends Ui{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return mu(this,(t,i,r,n,a)=>e=e.replace(r,r+(i-t),a),!1),e}mapDesc(e,t=!1){return gu(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,n=0;r<t.length;r+=2){let a=t[r],o=t[r+1];if(o>=0){t[r]=o,t[r+1]=a;let l=r>>1;for(;i.length<l;)i.push(bt.empty);i.push(a?e.slice(n,n+a):bt.empty)}n+=a}return new Jt(t,i)}compose(e){return this.empty?e:e.empty?this:Qx(this,e,!0)}map(e,t=!1){return e.empty?this:gu(this,e,t,!0)}iterChanges(e,t=!1){mu(this,e,t)}get desc(){return Ui.create(this.sections)}filter(e){let t=[],i=[],r=[],n=new Oa(this);e:for(let a=0,o=0;;){let l=a==e.length?1e9:e[a++];for(;o<l||o==l&&n.len==0;){if(n.done)break e;let d=Math.min(n.len,l-o);ws(r,d,-1);let u=n.ins==-1?-1:n.off==0?n.ins:0;ws(t,d,u),u>0&&Dr(i,t,n.text),n.forward(d),o+=d}let c=e[a++];for(;o<c;){if(n.done)break e;let d=Math.min(n.len,c-o);ws(t,d,-1),ws(r,d,n.ins==-1?-1:n.off==0?n.ins:0),n.forward(d),o+=d}}return{changes:new Jt(t,i),filtered:Ui.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],n=[],a=0,o=null;function l(d=!1){if(!d&&!r.length)return;a<t&&ws(r,t-a,-1);let u=new Jt(r,n);o=o?o.compose(u.map(o)):u,r=[],n=[],a=0}function c(d){if(Array.isArray(d))for(let u of d)c(u);else if(d instanceof Jt){if(d.length!=t)throw new RangeError(`Mismatched change set length (got ${d.length}, expected ${t})`);l(),o=o?o.compose(d.map(o)):d}else{let{from:u,to:f=u,insert:g}=d;if(u>f||u<0||f>t)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${t})`);let b=g?typeof g=="string"?bt.of(g.split(i||pu)):g:bt.empty,v=b.length;if(u==f&&v==0)return;u<a&&l(),u>a&&ws(r,u-a,-1),ws(r,f-u,v),Dr(n,r,b),a=f}}return c(e),l(!o),o}static empty(e){return new Jt(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let n=e[r];if(typeof n=="number")t.push(n,-1);else{if(!Array.isArray(n)||typeof n[0]!="number"||n.some((a,o)=>o&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(n.length==1)t.push(n[0],0);else{for(;i.length<r;)i.push(bt.empty);i[r]=bt.of(n.slice(1)),t.push(n[0],i[r].length)}}}return new Jt(t,i)}static createSet(e,t){return new Jt(e,t)}}function ws(s,e,t,i=!1){if(e==0&&t<=0)return;let r=s.length-2;r>=0&&t<=0&&t==s[r+1]?s[r]+=e:r>=0&&e==0&&s[r]==0?s[r+1]+=t:i?(s[r]+=e,s[r+1]+=t):s.push(e,t)}function Dr(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(bt.empty);s.push(t)}}function mu(s,e,t){let i=s.inserted;for(let r=0,n=0,a=0;a<s.sections.length;){let o=s.sections[a++],l=s.sections[a++];if(l<0)r+=o,n+=o;else{let c=r,d=n,u=bt.empty;for(;c+=o,d+=l,l&&i&&(u=u.append(i[a-2>>1])),!(t||a==s.sections.length||s.sections[a+1]<0);)o=s.sections[a++],l=s.sections[a++];e(r,c,n,d,u),r=c,n=d}}}function gu(s,e,t,i=!1){let r=[],n=i?[]:null,a=new Oa(s),o=new Oa(e);for(let l=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let c=Math.min(a.len,o.len);ws(r,c,-1),a.forward(c),o.forward(c)}else if(o.ins>=0&&(a.ins<0||l==a.i||a.off==0&&(o.len<a.len||o.len==a.len&&!t))){let c=o.len;for(ws(r,o.ins,-1);c;){let d=Math.min(a.len,c);a.ins>=0&&l<a.i&&a.len<=d&&(ws(r,0,a.ins),n&&Dr(n,r,a.text),l=a.i),a.forward(d),c-=d}o.next()}else if(a.ins>=0){let c=0,d=a.len;for(;d;)if(o.ins==-1){let u=Math.min(d,o.len);c+=u,d-=u,o.forward(u)}else if(o.ins==0&&o.len<d)d-=o.len,o.next();else break;ws(r,c,l<a.i?a.ins:0),n&&l<a.i&&Dr(n,r,a.text),l=a.i,a.forward(a.len-d)}else{if(a.done&&o.done)return n?Jt.createSet(r,n):Ui.create(r);throw new Error("Mismatched change set lengths")}}}function Qx(s,e,t=!1){let i=[],r=t?[]:null,n=new Oa(s),a=new Oa(e);for(let o=!1;;){if(n.done&&a.done)return r?Jt.createSet(i,r):Ui.create(i);if(n.ins==0)ws(i,n.len,0,o),n.next();else if(a.len==0&&!a.done)ws(i,0,a.ins,o),r&&Dr(r,i,a.text),a.next();else{if(n.done||a.done)throw new Error("Mismatched change set lengths");{let l=Math.min(n.len2,a.len),c=i.length;if(n.ins==-1){let d=a.ins==-1?-1:a.off?0:a.ins;ws(i,l,d,o),r&&d&&Dr(r,i,a.text)}else a.ins==-1?(ws(i,n.off?0:n.len,l,o),r&&Dr(r,i,n.textBit(l))):(ws(i,n.off?0:n.len,a.off?0:a.ins,o),r&&!a.off&&Dr(r,i,a.text));o=(n.ins>l||a.ins>=0&&a.len>l)&&(o||i.length>c),n.forward2(l),a.forward(l)}}}}class Oa{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?bt.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?bt.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,t,i,r){this.from=e,this.to=t,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Lr(i,r,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return re.range(e,t,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return re.range(this.anchor,r,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return re.range(e.anchor,e.head)}static create(e,t,i,r){return new Lr(e,t,i,r)}}class re{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:re.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new re([this.main],0)}addRange(e,t=!0){return re.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,re.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new re(e.ranges.map(t=>Lr.fromJSON(t)),e.main)}static single(e,t=e){return new re([re.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let n=e[r];if(n.empty?n.from<=i:n.from<i)return re.normalized(e.slice(),t);i=n.to}return new re(e,t)}static cursor(e,t=0,i,r){return Lr.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),r)}static range(e,t,i,r,n){let a=r==null?7:Math.min(6,r);return!n&&e!=t&&(n=t<e?1:-1),n&&(a|=n<0?8:16),t<e?Lr.create(t,e,a|32,i):Lr.create(e,t,a,i)}static undirectionalRange(e,t){return Lr.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((r,n)=>r.from-n.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let n=e[r],a=e[r-1];if(n.empty?n.from<=a.to:n.from<a.to){let o=a.from,l=Math.max(n.to,a.to);r<=t&&t--,e.splice(--r,2,n.anchor>n.head?re.range(l,o):re.range(o,l))}}return new re(e,t)}}function $x(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Cf=0;class Ae{constructor(e,t,i,r,n){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Cf++,this.default=e([]),this.extensions=typeof n=="function"?n(this):n}get reader(){return this}static define(e={}){return new Ae(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Pf),!!e.static,e.enables)}of(e){return new sc([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new sc(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new sc(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Pf(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class sc{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Cf++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,n=this.id,a=e[n]>>1,o=this.type==2,l=!1,c=!1,d=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:(((t=e[u.id])!==null&&t!==void 0?t:1)&1)==0&&d.push(e[u.id]);return{create(u){return u.values[a]=i(u),1},update(u,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||Ou(u,d)){let g=i(u);if(o?!Xm(g,u.values[a],r):!r(g,u.values[a]))return u.values[a]=g,1}return 0},reconfigure:(u,f)=>{let g,b=f.config.address[n];if(b!=null){let v=vc(f,b);if(this.dependencies.every(m=>m instanceof Ae?f.facet(m)===u.facet(m):m instanceof xs?f.field(m,!1)==u.field(m,!1):!0)||(o?Xm(g=i(u),v,r):r(g=i(u),v)))return u.values[a]=v,0}else g=i(u);return u.values[a]=g,1}}}get extension(){return this}}function Xm(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function Ou(s,e){let t=!1;for(let i of e)aa(s,i)&1&&(t=!0);return t}function J_(s,e,t){let i=t.map(l=>s[l.id]),r=t.map(l=>l.type),n=i.filter(l=>!(l&1)),a=s[e.id]>>1;function o(l){let c=[];for(let d=0;d<i.length;d++){let u=vc(l,i[d]);if(r[d]==2)for(let f of u)c.push(f);else c.push(u)}return e.combine(c)}return{create(l){for(let c of i)aa(l,c);return l.values[a]=o(l),1},update(l,c){if(!Ou(l,n))return 0;let d=o(l);return e.compare(d,l.values[a])?0:(l.values[a]=d,1)},reconfigure(l,c){let d=Ou(l,i),u=c.config.facets[e.id],f=c.facet(e);if(u&&!d&&Pf(t,u))return l.values[a]=f,0;let g=o(l);return e.compare(g,f)?(l.values[a]=f,0):(l.values[a]=g,1)}}}const wl=Ae.define({static:!0});class xs{constructor(e,t,i,r,n){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=n,this.provides=void 0}static define(e){let t=new xs(Cf++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(wl).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let n=i.values[t],a=this.updateF(n,r);return this.compareF(n,a)?0:(i.values[t]=a,1)},reconfigure:(i,r)=>{let n=i.facet(wl),a=r.facet(wl),o;return(o=n.find(l=>l.field==this))&&o!=a.find(l=>l.field==this)?(i.values[t]=o.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,wl.of({field:this,create:e})]}get extension(){return this}}const yn={lowest:4,low:3,default:2,high:1,highest:0};function Yo(s){return e=>new jx(e,s)}const kr={highest:Yo(yn.highest),high:Yo(yn.high),default:Yo(yn.default),low:Yo(yn.low),lowest:Yo(yn.lowest)};class jx{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Kc{of(e){return new xu(this,e)}reconfigure(e){return Kc.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class xu{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class xc{constructor(e,t,i,r,n,a){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=n,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],n=Object.create(null),a=new Map;for(let f of ew(e,t,a))f instanceof xs?r.push(f):(n[f.facet.id]||(n[f.facet.id]=[])).push(f);let o=Object.create(null),l=[],c=[];for(let f of r)o[f.id]=c.length<<1,c.push(g=>f.slot(g));let d=i?.config.facets;for(let f in n){let g=n[f],b=g[0].facet,v=d&&d[f]||[];if(g.every(m=>m.type==0))if(o[b.id]=l.length<<1|1,Pf(v,g))l.push(i.facet(b));else{let m=b.combine(g.map(O=>O.value));l.push(i&&b.compare(m,i.facet(b))?i.facet(b):m)}else{for(let m of g)m.type==0?(o[m.id]=l.length<<1|1,l.push(m.value)):(o[m.id]=c.length<<1,c.push(O=>m.dynamicSlot(O)));o[b.id]=c.length<<1,c.push(m=>J_(m,b,g))}}let u=c.map(f=>f(o));return new xc(e,a,u,o,l,n)}}function ew(s,e,t){let i=[[],[],[],[],[]],r=new Map;function n(a,o){let l=r.get(a);if(l!=null){if(l<=o)return;let c=i[l].indexOf(a);c>-1&&i[l].splice(c,1),a instanceof xu&&t.delete(a.compartment)}if(r.set(a,o),Array.isArray(a))for(let c of a)n(c,o);else if(a instanceof xu){if(t.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(a.compartment)||a.inner;t.set(a.compartment,c),n(c,o)}else if(a instanceof jx)n(a.inner,a.prec);else if(a instanceof xs)i[o].push(a),a.provides&&n(a.provides,o);else if(a instanceof sc)i[o].push(a),a.facet.extensions&&n(a.facet.extensions,yn.default);else{let c=a.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(c==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);n(c,o)}}return n(s,yn.default),i.reduce((a,o)=>a.concat(o))}function aa(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let r=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|r}function vc(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const Ex=Ae.define(),vu=Ae.define({combine:s=>s.some(e=>e),static:!0}),Rx=Ae.define({combine:s=>s.length?s[0]:void 0,static:!0}),Ax=Ae.define(),Mx=Ae.define(),Lx=Ae.define(),Nx=Ae.define({combine:s=>s.length?s[0]:!1});class Gi{constructor(e,t){this.type=e,this.value=t}static define(){return new tw}}class tw{of(e){return new Gi(this,e)}}class sw{constructor(e){this.map=e}of(e){return new nt(this,e)}}class nt{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new nt(this.type,t)}is(e){return this.type==e}static define(e={}){return new sw(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let n=r.map(t);n&&i.push(n)}return i}}nt.reconfigure=nt.define();nt.appendConfig=nt.define();class Kt{constructor(e,t,i,r,n,a){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=n,this.scrollIntoView=a,this._doc=null,this._state=null,i&&$x(i,t.newLength),n.some(o=>o.type==Kt.time)||(this.annotations=n.concat(Kt.time.of(Date.now())))}static create(e,t,i,r,n,a){return new Kt(e,t,i,r,n,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Kt.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Kt.time=Gi.define();Kt.userEvent=Gi.define();Kt.addToHistory=Gi.define();Kt.remote=Gi.define();function iw(s,e){let t=[];for(let i=0,r=0;;){let n,a;if(i<s.length&&(r==e.length||e[r]>=s[i]))n=s[i++],a=s[i++];else if(r<e.length)n=e[r++],a=e[r++];else return t;!t.length||t[t.length-1]<n?t.push(n,a):t[t.length-1]<a&&(t[t.length-1]=a)}}function Dx(s,e,t){var i;let r,n,a;return t?(r=e.changes,n=Jt.empty(e.changes.length),a=s.changes.compose(e.changes)):(r=e.changes.map(s.changes),n=s.changes.mapDesc(e.changes,!0),a=s.changes.compose(r)),{changes:a,selection:e.selection?e.selection.map(n):(i=s.selection)===null||i===void 0?void 0:i.map(r),effects:nt.mapEffects(s.effects,r).concat(nt.mapEffects(e.effects,n)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function bu(s,e,t){let i=e.selection,r=so(e.annotations);return e.userEvent&&(r=r.concat(Kt.userEvent.of(e.userEvent))),{changes:e.changes instanceof Jt?e.changes:Jt.of(e.changes||[],t,s.facet(Rx)),selection:i&&(i instanceof re?i:re.single(i.anchor,i.head)),effects:so(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Ix(s,e,t){let i=bu(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let n=1;n<e.length;n++){e[n].filter===!1&&(t=!1);let a=!!e[n].sequential;i=Dx(i,bu(s,e[n],a?i.changes.newLength:s.doc.length),a)}let r=Kt.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return nw(t?rw(r):r)}function rw(s){let e=s.startState,t=!0;for(let r of e.facet(Ax)){let n=r(s);if(n===!1){t=!1;break}Array.isArray(n)&&(t=t===!0?n:iw(t,n))}if(t!==!0){let r,n;if(t===!1)n=s.changes.invertedDesc,r=Jt.empty(e.doc.length);else{let a=s.changes.filter(t);r=a.changes,n=a.filtered.mapDesc(a.changes).invertedDesc}s=Kt.create(e,r,s.selection&&s.selection.map(n),nt.mapEffects(s.effects,n),s.annotations,s.scrollIntoView)}let i=e.facet(Mx);for(let r=i.length-1;r>=0;r--){let n=i[r](s);n instanceof Kt?s=n:Array.isArray(n)&&n.length==1&&n[0]instanceof Kt?s=n[0]:s=Ix(e,so(n),!1)}return s}function nw(s){let e=s.startState,t=e.facet(Lx),i=s;for(let r=t.length-1;r>=0;r--){let n=t[r](s);n&&Object.keys(n).length&&(i=Dx(i,bu(e,n,s.changes.newLength),!0))}return i==s?s:Kt.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const ow=[];function so(s){return s==null?ow:Array.isArray(s)?s:[s]}var Mt=(function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s})(Mt||(Mt={}));const aw=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let yu;try{yu=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function lw(s){if(yu)return yu.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||aw.test(t)))return!0}return!1}function cw(s){return e=>{if(!/\S/.test(e))return Mt.Space;if(lw(e))return Mt.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Mt.Word;return Mt.Other}}class pt{constructor(e,t,i,r,n,a){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=n,a&&(a._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)aa(this,o<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return aa(this,i),vc(this,i)}update(...e){return Ix(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let o of e.effects)o.is(Kc.reconfigure)?(t&&(r=new Map,t.compartments.forEach((l,c)=>r.set(c,l)),t=null),r.set(o.value.compartment,o.value.extension)):o.is(nt.reconfigure)?(t=null,i=o.value):o.is(nt.appendConfig)&&(t=null,i=so(i).concat(o.value));let n;t?n=e.startState.values.slice():(t=xc.resolve(i,r,this),n=new pt(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let a=e.startState.facet(vu)?e.newSelection:e.newSelection.asSingle();new pt(t,e.newDoc,a,n,(o,l)=>l.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:re.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),n=[i.range],a=so(i.effects);for(let o=1;o<t.ranges.length;o++){let l=e(t.ranges[o]),c=this.changes(l.changes),d=c.map(r);for(let f=0;f<o;f++)n[f]=n[f].map(d);let u=r.mapDesc(c,!0);n.push(l.range.map(u)),r=r.compose(d),a=nt.mapEffects(a,d).concat(nt.mapEffects(so(l.effects),u))}return{changes:r,selection:re.create(n,t.mainIndex),effects:a}}changes(e=[]){return e instanceof Jt?e:Jt.of(e,this.doc.length,this.facet(pt.lineSeparator))}toText(e){return bt.of(e.split(this.facet(pt.lineSeparator)||pu))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(aa(this,t),vc(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof xs&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let n in i)if(Object.prototype.hasOwnProperty.call(e,n)){let a=i[n],o=e[n];r.push(a.init(l=>a.spec.fromJSON(o,l)))}}return pt.create({doc:e.doc,selection:re.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=xc.resolve(e.extensions||[],new Map),i=e.doc instanceof bt?e.doc:bt.of((e.doc||"").split(t.staticFacet(pt.lineSeparator)||pu)),r=e.selection?e.selection instanceof re?e.selection:re.single(e.selection.anchor,e.selection.head):re.single(0);return $x(r,i.length),t.staticFacet(vu)||(r=r.asSingle()),new pt(t,i,r,t.dynamicSlots.map(()=>null),(n,a)=>a.create(n),null)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||`
|
|
9
|
-
`}get readOnly(){return this.facet(Nx)}phrase(e,...t){for(let i of this.facet(pt.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let n=+(r||1);return!n||n>t.length?i:t[n-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let n of this.facet(Ex))for(let a of n(this,t,i))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return cw(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),n=this.charCategorizer(e),a=e-i,o=e-i;for(;a>0;){let l=cs(t,a,!1);if(n(t.slice(l,a))!=Mt.Word)break;a=l}for(;o<r;){let l=cs(t,o);if(n(t.slice(o,l))!=Mt.Word)break;o=l}return a==o?null:re.range(a+i,o+i)}}pt.allowMultipleSelections=vu;pt.tabSize=Ae.define({combine:s=>s.length?s[0]:4});pt.lineSeparator=Rx;pt.readOnly=Nx;pt.phrases=Ae.define({compare(s,e){let t=Object.keys(s),i=Object.keys(e);return t.length==i.length&&t.every(r=>s[r]==e[r])}});pt.languageData=Ex;pt.changeFilter=Ax;pt.transactionFilter=Mx;pt.transactionExtender=Lx;Kc.reconfigure=nt.define();function Ki(s,e,t={}){let i={};for(let r of s)for(let n of Object.keys(r)){let a=r[n],o=i[n];if(o===void 0)i[n]=a;else if(!(o===a||a===void 0))if(Object.hasOwnProperty.call(t,n))i[n]=t[n](o,a);else throw new Error("Config merge conflict for field "+n)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class Br{eq(e){return this==e}range(e,t=e){return Su.create(e,t,this)}}Br.prototype.startSide=Br.prototype.endSide=0;Br.prototype.point=!1;Br.prototype.mapMode=gs.TrackDel;function Tf(s,e){return s==e||s.constructor==e.constructor&&s.eq(e)}let Su=class Bx{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Bx(e,t,i)}};function _u(s,e){return s.from-e.from||s.value.startSide-e.value.startSide}class Qf{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let n=i?this.to:this.from;for(let a=r,o=n.length;;){if(a==o)return a;let l=a+o>>1,c=n[l]-e||(i?this.value[l].endSide:this.value[l].startSide)-t;if(l==a)return c>=0?a:o;c>=0?o=l:a=l+1}}between(e,t,i,r){for(let n=this.findIndex(t,-1e9,!0),a=this.findIndex(i,1e9,!1,n);n<a;n++)if(r(this.from[n]+e,this.to[n]+e,this.value[n])===!1)return!1}map(e,t){let i=[],r=[],n=[],a=-1,o=-1;for(let l=0;l<this.value.length;l++){let c=this.value[l],d=this.from[l]+e,u=this.to[l]+e,f,g;if(d==u){let b=t.mapPos(d,c.startSide,c.mapMode);if(b==null||(f=g=b,c.startSide!=c.endSide&&(g=t.mapPos(d,c.endSide),g<f)))continue}else if(f=t.mapPos(d,c.startSide),g=t.mapPos(u,c.endSide),f>g||f==g&&c.startSide>0&&c.endSide<=0)continue;(g-f||c.endSide-c.startSide)<0||(a<0&&(a=f),c.point&&(o=Math.max(o,g-f)),i.push(c),r.push(f-a),n.push(g-a))}return{mapped:i.length?new Qf(r,n,i,o):null,pos:a}}}class ft{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new ft(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:n=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(i&&(t=t.slice().sort(_u)),this.isEmpty)return t.length?ft.of(t):this;let o=new Wx(this,null,-1).goto(0),l=0,c=[],d=new br;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let u=t[l++];d.addInner(u.from,u.to,u.value)||c.push(u)}else o.rangeIndex==1&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!a||r>this.chunkEnd(o.chunkIndex)||n<this.chunkPos[o.chunkIndex])&&d.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!a||r>o.to||n<o.from||a(o.from,o.to,o.value))&&(d.addInner(o.from,o.to,o.value)||c.push(Su.create(o.from,o.to,o.value))),o.next());return d.finishInner(this.nextLayer.isEmpty&&!c.length?ft.empty:this.nextLayer.update({add:c,filter:a,filterFrom:r,filterTo:n}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let a=0;a<this.chunk.length;a++){let o=this.chunkPos[a],l=this.chunk[a],c=e.touchesRange(o,o+l.length);if(c===!1)r=Math.max(r,l.maxPoint),t.push(l),i.push(e.mapPos(o));else if(c===!0){let{mapped:d,pos:u}=l.map(o,e);d&&(r=Math.max(r,d.maxPoint),t.push(d),i.push(u))}}let n=this.nextLayer.map(e);return t.length==0?n:new ft(i,t,n||ft.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let n=this.chunkPos[r],a=this.chunk[r];if(t>=n&&e<=n+a.length&&a.between(n,e-n,t-n,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return xa.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return xa.from(e).goto(t)}static compare(e,t,i,r,n=-1){let a=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=n),o=t.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=n),l=qm(a,o,i),c=new Uo(a,l,n),d=new Uo(o,l,n);i.iterGaps((u,f,g)=>zm(c,u,d,f,g,r)),i.empty&&i.length==0&&zm(c,0,d,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let n=e.filter(d=>!d.isEmpty&&t.indexOf(d)<0),a=t.filter(d=>!d.isEmpty&&e.indexOf(d)<0);if(n.length!=a.length)return!1;if(!n.length)return!0;let o=qm(n,a),l=new Uo(n,o,0).goto(i),c=new Uo(a,o,0).goto(i);for(;;){if(l.to!=c.to||!wu(l.active,c.active)||l.point&&(!c.point||!Tf(l.point,c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,t,i,r,n=-1){let a=new Uo(e,null,n).goto(t),o=t,l=a.openStart;for(;;){let c=Math.min(a.to,i);if(a.point){let d=a.activeForPoint(a.to),u=a.pointFrom<t?d.length+1:a.point.startSide<0?d.length:Math.min(d.length,l);r.point(o,c,a.point,d,u,a.pointRank),l=Math.min(a.openEnd(c),d.length)}else c>o&&(r.span(o,c,a.active,l),l=a.openEnd(c));if(a.to>i)return l+(a.point&&a.to>i?1:0);o=a.to,a.next()}}static of(e,t=!1){let i=new br;for(let r of e instanceof Su?[e]:t?hw(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return ft.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=ft.empty;r=r.nextLayer)t=new ft(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}ft.empty=new ft([],[],null,-1);function hw(s){if(s.length>1)for(let e=s[0],t=1;t<s.length;t++){let i=s[t];if(_u(e,i)>0)return s.slice().sort(_u);e=i}return s}ft.empty.nextLayer=ft.empty;class br{finishChunk(e){this.chunks.push(new Qf(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new br)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ft.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ft.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function qm(s,e,t){let i=new Map;for(let n of s)for(let a=0;a<n.chunk.length;a++)n.chunk[a].maxPoint<=0&&i.set(n.chunk[a],n.chunkPos[a]);let r=new Set;for(let n of e)for(let a=0;a<n.chunk.length;a++){let o=i.get(n.chunk[a]);o!=null&&(t?t.mapPos(o):o)==n.chunkPos[a]&&!t?.touchesRange(o,o+n.chunk[a].length)&&r.add(n.chunk[a])}return r}class Wx{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class xa{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let n=0;n<e.length;n++)for(let a=e[n];!a.isEmpty;a=a.nextLayer)a.maxPoint>=i&&r.push(new Wx(a,t,i,n));return r.length==1?r[0]:new xa(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)id(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)id(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),id(this.heap,0)}}}function id(s,e){for(let t=s[e];;){let i=(e<<1)+1;if(i>=s.length)break;let r=s[i];if(i+1<s.length&&r.compare(s[i+1])>=0&&(r=s[i+1],i++),t.compare(r)<0)break;s[i]=t,s[e]=r,e=i}}class Uo{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=xa.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){kl(this.active,e),kl(this.activeTo,e),kl(this.activeRank,e),this.minActive=Zm(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:n}=this.cursor;for(;t<this.activeRank.length&&(n-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Cl(this.active,t,i),Cl(this.activeTo,t,r),Cl(this.activeRank,t,n),e&&Cl(e,t,this.cursor.from),this.minActive=Zm(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&kl(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let n=this.cursor.value;if(!n.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=n,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=n.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function zm(s,e,t,i,r,n){s.goto(e),t.goto(i);let a=i+r,o=i,l=i-e,c=!!n.boundChange;for(let d=!1;;){let u=s.to+l-t.to,f=u||s.endSide-t.endSide,g=f<0?s.to+l:t.to,b=Math.min(g,a);if(s.point||t.point?(s.point&&t.point&&Tf(s.point,t.point)&&wu(s.activeForPoint(s.to),t.activeForPoint(t.to))||n.comparePoint(o,b,s.point,t.point),d=!1):(d&&n.boundChange(o),b>o&&!wu(s.active,t.active)&&n.compareRange(o,b,s.active,t.active),c&&b<a&&(u||s.openEnd(g)!=t.openEnd(g))&&(d=!0)),g>a)break;o=g,f<=0&&s.next(),f>=0&&t.next()}}function wu(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!=e[t]&&!Tf(s[t],e[t]))return!1;return!0}function kl(s,e){for(let t=e,i=s.length-1;t<i;t++)s[t]=s[t+1];s.pop()}function Cl(s,e,t){for(let i=s.length-1;i>=e;i--)s[i+1]=s[i];s[e]=t}function Zm(s,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||s[r].endSide-s[t].endSide)<0&&(t=r,i=e[r]);return t}function ki(s,e,t=s.length){let i=0;for(let r=0;r<t&&r<s.length;)s.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=cs(s,r));return i}function ku(s,e,t,i){for(let r=0,n=0;;){if(n>=e)return r;if(r==s.length)break;n+=s.charCodeAt(r)==9?t-n%t:1,r=cs(s,r)}return i===!0?-1:s.length}const Cu="ͼ",Vm=typeof Symbol>"u"?"__"+Cu:Symbol.for(Cu),Pu=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Fm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Wr{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function n(a,o,l,c){let d=[],u=/^@(\w+)\b/.exec(a[0]),f=u&&u[1]=="keyframes";if(u&&o==null)return l.push(a[0]+";");for(let g in o){let b=o[g];if(/&/.test(g))n(g.split(/,\s*/).map(v=>a.map(m=>v.replace(/&/,m))).reduce((v,m)=>v.concat(m)),b,l);else if(b&&typeof b=="object"){if(!u)throw new RangeError("The value of a property ("+g+") should be a primitive value.");n(r(g),b,d,f)}else b!=null&&d.push(g.replace(/_.*/,"").replace(/[A-Z]/g,v=>"-"+v.toLowerCase())+": "+b+";")}(d.length||f)&&l.push((i&&!u&&!c?a.map(i):a).join(", ")+" {"+d.join(" ")+"}")}for(let a in e)n(r(a),e[a],this.rules)}getRules(){return this.rules.join(`
|
|
10
|
-
`)}static newName(){let e=Fm[Vm]||1;return Fm[Vm]=e+1,Cu+e.toString(36)}static mount(e,t,i){let r=e[Pu],n=i&&i.nonce;r?n&&r.setNonce(n):r=new dw(e,n),r.mount(Array.isArray(t)?t:[t],e)}}let Ym=new Map;class dw{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let n=Ym.get(i);if(n)return e[Pu]=n;this.sheet=new r.CSSStyleSheet,Ym.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Pu]=this}mount(e,t){let i=this.sheet,r=0,n=0;for(let a=0;a<e.length;a++){let o=e[a],l=this.modules.indexOf(o);if(l<n&&l>-1&&(this.modules.splice(l,1),n--,l=-1),l==-1){if(this.modules.splice(n++,0,o),i)for(let c=0;c<o.rules.length;c++)i.insertRule(o.rules[c],r++)}else{for(;n<l;)r+=this.modules[n++].rules.length;r+=o.rules.length,n++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let a="";for(let l=0;l<this.modules.length;l++)a+=this.modules[l].getRules()+`
|
|
11
|
-
`;this.styleTag.textContent=a;let o=t.head||t;this.styleTag.parentNode!=o&&o.insertBefore(this.styleTag,o.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var Xr={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},va={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},uw=typeof navigator<"u"&&/Mac/.test(navigator.platform),fw=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ms=0;ms<10;ms++)Xr[48+ms]=Xr[96+ms]=String(ms);for(var ms=1;ms<=24;ms++)Xr[ms+111]="F"+ms;for(var ms=65;ms<=90;ms++)Xr[ms]=String.fromCharCode(ms+32),va[ms]=String.fromCharCode(ms);for(var rd in Xr)va.hasOwnProperty(rd)||(va[rd]=Xr[rd]);function pw(s){var e=uw&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||fw&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",t=!e&&s.key||(s.shiftKey?va:Xr)[s.keyCode]||s.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Tt(){var s=arguments[0];typeof s=="string"&&(s=document.createElement(s));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?s.setAttribute(i,r):r!=null&&(s[i]=r)}e++}for(;e<arguments.length;e++)Xx(s,arguments[e]);return s}function Xx(s,e){if(typeof e=="string")s.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)s.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Xx(s,e[t]);else throw new RangeError("Unsupported child node: "+e)}let js=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Tu=typeof document<"u"?document:{documentElement:{style:{}}};const Qu=/Edge\/(\d+)/.exec(js.userAgent),qx=/MSIE \d/.test(js.userAgent),$u=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(js.userAgent),Jc=!!(qx||$u||Qu),Um=!Jc&&/gecko\/(\d+)/i.test(js.userAgent),nd=!Jc&&/Chrome\/(\d+)/.exec(js.userAgent),Hm="webkitFontSmoothing"in Tu.documentElement.style,ju=!Jc&&/Apple Computer/.test(js.vendor),Gm=ju&&(/Mobile\/\w+/.test(js.userAgent)||js.maxTouchPoints>2);var Ee={mac:Gm||/Mac/.test(js.platform),windows:/Win/.test(js.platform),linux:/Linux|X11/.test(js.platform),ie:Jc,ie_version:qx?Tu.documentMode||6:$u?+$u[1]:Qu?+Qu[1]:0,gecko:Um,gecko_version:Um?+(/Firefox\/(\d+)/.exec(js.userAgent)||[0,0])[1]:0,chrome:!!nd,chrome_version:nd?+nd[1]:0,ios:Gm,android:/Android\b/.test(js.userAgent),webkit:Hm,webkit_version:Hm?+(/\bAppleWebKit\/(\d+)/.exec(js.userAgent)||[0,0])[1]:0,safari:ju,safari_version:ju?+(/\bVersion\/(\d+(\.\d+)?)/.exec(js.userAgent)||[0,0])[1]:0,tabSize:Tu.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function $f(s,e){for(let t in s)t=="class"&&e.class?e.class+=" "+s.class:t=="style"&&e.style?e.style+=";"+s.style:e[t]=s[t];return e}const bc=Object.create(null);function jf(s,e,t){if(s==e)return!0;s||(s=bc),e||(e=bc);let i=Object.keys(s),r=Object.keys(e);if(i.length-0!=r.length-0)return!1;for(let n of i)if(n!=t&&(r.indexOf(n)==-1||s[n]!==e[n]))return!1;return!0}function mw(s,e){for(let t=s.attributes.length-1;t>=0;t--){let i=s.attributes[t].name;e[i]==null&&s.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?s.style.cssText=i:s.getAttribute(t)!=i&&s.setAttribute(t,i)}}function Km(s,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?s.style.cssText="":s.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?s.style.cssText=t[r]:s.setAttribute(r,t[r]));return i}function gw(s){let e=Object.create(null);for(let t=0;t<s.attributes.length;t++){let i=s.attributes[t];e[i.name]=i.value}return e}class Pi{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Os=(function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s})(Os||(Os={}));class ze extends Br{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Xa(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Qn(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:n,end:a}=zx(e,t);i=(n?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new Qn(e,i,r,t,e.widget||null,!0)}static line(e){return new qa(e)}static set(e,t=!1){return ft.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ze.none=ft.empty;class Xa extends ze{constructor(e){let{start:t,end:i}=zx(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?$f(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||bc}eq(e){return this==e||e instanceof Xa&&this.tagName==e.tagName&&jf(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Xa.prototype.point=!1;class qa extends ze{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof qa&&this.spec.class==e.spec.class&&jf(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}qa.prototype.mapMode=gs.TrackBefore;qa.prototype.point=!0;class Qn extends ze{constructor(e,t,i,r,n,a){super(t,i,n,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?gs.TrackBefore:gs.TrackAfter:gs.TrackDel}get type(){return this.startSide!=this.endSide?Os.WidgetRange:this.startSide<=0?Os.WidgetBefore:Os.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Qn&&Ow(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Qn.prototype.point=!0;function zx(s,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=s;return t==null&&(t=s.inclusive),i==null&&(i=s.inclusive),{start:t??e,end:i??e}}function Ow(s,e){return s==e||!!(s&&e&&s.compare(e))}function io(s,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=s?t[r]=Math.max(t[r],e):t.push(s,e)}class ba extends Br{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof ba&&this.tagName==e.tagName&&jf(this.attributes,e.attributes)}static create(e){return new ba(e.tagName,e.attributes||bc,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return ft.of(e,t)}}ba.prototype.startSide=ba.prototype.endSide=-1;function ya(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function Eu(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function la(s,e){if(!e.anchorNode)return!1;try{return Eu(s,e.anchorNode)}catch{return!1}}function ca(s){return s.nodeType==3?_a(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function ha(s,e,t,i){return t?Jm(s,e,t,i,-1)||Jm(s,e,t,i,1):!1}function qr(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function yc(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}function Jm(s,e,t,i,r){for(;;){if(s==t&&e==i)return!0;if(e==(r<0?0:yr(s))){if(s.nodeName=="DIV")return!1;let n=s.parentNode;if(!n||n.nodeType!=1)return!1;e=qr(s)+(r<0?0:1),s=n}else if(s.nodeType==1){if(s=s.childNodes[e+(r<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=r<0?yr(s):0}else return!1}}function yr(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function Sa(s,e){let{left:t,right:i}=s;if(t==i)return s;let r=e?t:i;return{left:r,right:r,top:s.top,bottom:s.bottom}}function xw(s){let e=s.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function Zx(s,e){let t=e.width/s.offsetWidth,i=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-s.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function vw(s,e,t,i,r,n,a,o){let l=s.ownerDocument,c=l.defaultView||window;for(let d=s,u=!1;d&&!u;)if(d.nodeType==1){let f,g=d==l.body,b=1,v=1;if(g)f=xw(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(d).position)&&(u=!0),d.scrollHeight<=d.clientHeight&&d.scrollWidth<=d.clientWidth){d=d.assignedSlot||d.parentNode;continue}let p=d.getBoundingClientRect();({scaleX:b,scaleY:v}=Zx(d,p)),f={left:p.left,right:p.left+d.clientWidth*b,top:p.top,bottom:p.top+d.clientHeight*v}}let m=0,O=0;if(r=="nearest")e.top<f.top+a?(O=e.top-(f.top+a),t>0&&e.bottom>f.bottom+O&&(O=e.bottom-f.bottom+a)):e.bottom>f.bottom-a&&(O=e.bottom-f.bottom+a,t<0&&e.top-O<f.top&&(O=e.top-(f.top+a)));else{let p=e.bottom-e.top,x=f.bottom-f.top;O=(r=="center"&&p<=x?e.top+p/2-x/2:r=="start"||r=="center"&&t<0?e.top-a:e.bottom-x+a)-f.top}if(i=="nearest"?e.left<f.left+n?(m=e.left-(f.left+n),t>0&&e.right>f.right+m&&(m=e.right-f.right+n)):e.right>f.right-n&&(m=e.right-f.right+n,t<0&&e.left<f.left+m&&(m=e.left-(f.left+n))):m=(i=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:i=="start"==o?e.left-n:e.right-(f.right-f.left)+n)-f.left,m||O)if(g)c.scrollBy(m,O);else{let p=0,x=0;if(O){let y=d.scrollTop;d.scrollTop+=O/v,x=(d.scrollTop-y)*v}if(m){let y=d.scrollLeft;d.scrollLeft+=m/b,p=(d.scrollLeft-y)*b}e={left:e.left-p,top:e.top-x,right:e.right-p,bottom:e.bottom-x},p&&Math.abs(p-m)<1&&(i="nearest"),x&&Math.abs(x-O)<1&&(r="nearest")}if(g)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function Vx(s,e=!0){let t=s.ownerDocument,i=null,r=null;for(let n=s.parentNode;n&&!(n==t.body||(!e||i)&&r);)if(n.nodeType==1)!r&&n.scrollHeight>n.clientHeight&&(r=n),e&&!i&&n.scrollWidth>n.clientWidth&&(i=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:i,y:r}}class bw{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?yr(t):0),i,Math.min(e.focusOffset,i?yr(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}}let bn=null;Ee.safari&&Ee.safari_version>=26&&(bn=!1);function Fx(s){if(s.setActive)return s.setActive();if(bn)return s.focus(bn);let e=[];for(let t=s;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(s.focus(bn==null?{get preventScroll(){return bn={preventScroll:!0},!0}}:void 0),!bn){bn=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],n=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=n&&(i.scrollLeft=n)}}}let eg;function _a(s,e,t=e){let i=eg||(eg=document.createRange());return i.setEnd(s,t),i.setStart(s,e),i}function ro(s,e,t,i){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let n=new KeyboardEvent("keydown",r);n.synthetic=!0,s.dispatchEvent(n);let a=new KeyboardEvent("keyup",r);return a.synthetic=!0,s.dispatchEvent(a),n.defaultPrevented||a.defaultPrevented}function yw(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function Sw(s,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,yr(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=yr(t))}else{if(t==s)return!0;i=qr(t),t=t.parentNode}}function Yx(s){return s instanceof Window?s.pageYOffset>Math.max(0,s.document.documentElement.scrollHeight-s.innerHeight-4):s.scrollTop>Math.max(1,s.scrollHeight-s.clientHeight-4)}function Ux(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=yr(t)}else if(t.parentNode&&!yc(t))i=qr(t),t=t.parentNode;else return null}}function Hx(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!yc(t))i=qr(t)+1,t=t.parentNode;else return null}}class wi{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new wi(e.parentNode,qr(e),t)}static after(e,t){return new wi(e.parentNode,qr(e)+1,t)}}var jt=(function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s})(jt||(jt={}));const $n=jt.LTR,Ef=jt.RTL;function Gx(s){let e=[];for(let t=0;t<s.length;t++)e.push(1<<+s[t]);return e}const _w=Gx("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ww=Gx("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ru=Object.create(null),Di=[];for(let s of["()","[]","{}"]){let e=s.charCodeAt(0),t=s.charCodeAt(1);Ru[e]=t,Ru[t]=-e}function Kx(s){return s<=247?_w[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?ww[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1}const kw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Zi{get dir(){return this.level%2?Ef:$n}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,r){let n=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==i)return a;(n<0||(r!=0?r<0?o.from<t:o.to>t:e[n].level>o.level))&&(n=a)}}if(n<0)throw new RangeError("Index out of range");return n}}function Jx(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++){let i=s[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Jx(i.inner,r.inner))return!1}return!0}const $t=[];function Cw(s,e,t,i,r){for(let n=0;n<=i.length;n++){let a=n?i[n-1].to:e,o=n<i.length?i[n].from:t,l=n?256:r;for(let c=a,d=l,u=l;c<o;c++){let f=Kx(s.charCodeAt(c));f==512?f=d:f==8&&u==4&&(f=16),$t[c]=f==4?2:f,f&7&&(u=f),d=f}for(let c=a,d=l,u=l;c<o;c++){let f=$t[c];if(f==128)c<o-1&&d==$t[c+1]&&d&24?f=$t[c]=d:$t[c]=256;else if(f==64){let g=c+1;for(;g<o&&$t[g]==64;)g++;let b=c&&d==8||g<t&&$t[g]==8?u==1?1:8:256;for(let v=c;v<g;v++)$t[v]=b;c=g-1}else f==8&&u==1&&($t[c]=1);d=f,f&7&&(u=f)}}}function Pw(s,e,t,i,r){let n=r==1?2:1;for(let a=0,o=0,l=0;a<=i.length;a++){let c=a?i[a-1].to:e,d=a<i.length?i[a].from:t;for(let u=c,f,g,b;u<d;u++)if(g=Ru[f=s.charCodeAt(u)])if(g<0){for(let v=o-3;v>=0;v-=3)if(Di[v+1]==-g){let m=Di[v+2],O=m&2?r:m&4?m&1?n:r:0;O&&($t[u]=$t[Di[v]]=O),o=v;break}}else{if(Di.length==189)break;Di[o++]=u,Di[o++]=f,Di[o++]=l}else if((b=$t[u])==2||b==1){let v=b==r;l=v?0:1;for(let m=o-3;m>=0;m-=3){let O=Di[m+2];if(O&2)break;if(v)Di[m+2]|=2;else{if(O&4)break;Di[m+2]|=4}}}}}function Tw(s,e,t,i){for(let r=0,n=i;r<=t.length;r++){let a=r?t[r-1].to:s,o=r<t.length?t[r].from:e;for(let l=a;l<o;){let c=$t[l];if(c==256){let d=l+1;for(;;)if(d==o){if(r==t.length)break;d=t[r++].to,o=r<t.length?t[r].from:e}else if($t[d]==256)d++;else break;let u=n==1,f=(d<e?$t[d]:i)==1,g=u==f?u?1:2:i;for(let b=d,v=r,m=v?t[v-1].to:s;b>l;)b==m&&(b=t[--v].from,m=v?t[v-1].to:s),$t[--b]=g;l=d}else n=c,l++}}}function Au(s,e,t,i,r,n,a){let o=i%2?2:1;if(i%2==r%2)for(let l=e,c=0;l<t;){let d=!0,u=!1;if(c==n.length||l<n[c].from){let v=$t[l];v!=o&&(d=!1,u=v==16)}let f=!d&&o==1?[]:null,g=d?i:i+1,b=l;e:for(;;)if(c<n.length&&b==n[c].from){if(u)break e;let v=n[c];if(!d)for(let m=v.to,O=c+1;;){if(m==t)break e;if(O<n.length&&n[O].from==m)m=n[O++].to;else{if($t[m]==o)break e;break}}if(c++,f)f.push(v);else{v.from>l&&a.push(new Zi(l,v.from,g));let m=v.direction==$n!=!(g%2);Mu(s,m?i+1:i,r,v.inner,v.from,v.to,a),l=v.to}b=v.to}else{if(b==t||(d?$t[b]!=o:$t[b]==o))break;b++}f?Au(s,l,b,i+1,r,f,a):l<b&&a.push(new Zi(l,b,g)),l=b}else for(let l=t,c=n.length;l>e;){let d=!0,u=!1;if(!c||l>n[c-1].to){let v=$t[l-1];v!=o&&(d=!1,u=v==16)}let f=!d&&o==1?[]:null,g=d?i:i+1,b=l;e:for(;;)if(c&&b==n[c-1].to){if(u)break e;let v=n[--c];if(!d)for(let m=v.from,O=c;;){if(m==e)break e;if(O&&n[O-1].to==m)m=n[--O].from;else{if($t[m-1]==o)break e;break}}if(f)f.push(v);else{v.to<l&&a.push(new Zi(v.to,l,g));let m=v.direction==$n!=!(g%2);Mu(s,m?i+1:i,r,v.inner,v.from,v.to,a),l=v.from}b=v.from}else{if(b==e||(d?$t[b-1]!=o:$t[b-1]==o))break;b--}f?Au(s,b,l,i+1,r,f,a):b<l&&a.push(new Zi(b,l,g)),l=b}}function Mu(s,e,t,i,r,n,a){let o=e%2?2:1;Cw(s,r,n,i,o),Pw(s,r,n,i,o),Tw(r,n,i,o),Au(s,r,n,e,t,i,a)}function Qw(s,e,t){if(!s)return[new Zi(0,0,e==Ef?1:0)];if(e==$n&&!t.length&&!kw.test(s))return ev(s.length);if(t.length)for(;s.length>$t.length;)$t[$t.length]=256;let i=[],r=e==$n?0:1;return Mu(s,r,r,t,0,s.length,i),i}function ev(s){return[new Zi(0,s,0)]}let tv="";function $w(s,e,t,i,r){var n;let a=i.head-s.from,o=Zi.find(e,a,(n=i.bidiLevel)!==null&&n!==void 0?n:-1,i.assoc),l=e[o],c=l.side(r,t);if(a==c){let f=o+=r?1:-1;if(f<0||f>=e.length)return null;l=e[o=f],a=l.side(!r,t),c=l.side(r,t)}let d=cs(s.text,a,l.forward(r,t));(d<l.from||d>l.to)&&(d=c),tv=s.text.slice(Math.min(a,d),Math.max(a,d));let u=o==(r?e.length-1:0)?null:e[o+(r?1:-1)];return u&&d==c&&u.level+(r?0:1)<l.level?re.cursor(u.side(!r,t)+s.from,u.forward(r,t)?1:-1,u.level):re.cursor(d+s.from,l.forward(r,t)?-1:1,l.level)}function jw(s,e,t){for(let i=e;i<t;i++){let r=Kx(s.charCodeAt(i));if(r==1)return $n;if(r==2||r==4)return Ef}return $n}const sv=Ae.define(),iv=Ae.define(),rv=Ae.define(),nv=Ae.define(),Lu=Ae.define(),ov=Ae.define(),av=Ae.define(),Rf=Ae.define(),Af=Ae.define(),lv=Ae.define({combine:s=>s.some(e=>e)}),cv=Ae.define({combine:s=>s.some(e=>e)}),hv=Ae.define();class no{constructor(e,t,i,r,n,a=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=n,this.isSnapshot=a}map(e){return e.empty?this:new no(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new no(re.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Pl=nt.define({map:(s,e)=>s.map(e)}),dv=nt.define();function Xs(s,e,t){let i=s.facet(nv);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const gr=Ae.define({combine:s=>s.length?s[0]:!0});let Ew=0;const Kn=Ae.define({combine(s){return s.filter((e,t)=>{for(let i=0;i<t;i++)if(s[i].plugin==e.plugin)return!1;return!0})}});class zt{constructor(e,t,i,r,n){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.baseExtensions=n(this),this.extension=this.baseExtensions.concat(Kn.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Kn.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:r,provide:n,decorations:a}=t||{};return new zt(Ew++,e,i,r,o=>{let l=[];return a&&l.push(eh.of(c=>{let d=c.plugin(o);return d?a(d):ze.none})),n&&l.push(n(o)),l})}static fromClass(e,t){return zt.define((i,r)=>new e(i,r),t)}}class od{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Xs(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Xs(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Xs(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const uv=Ae.define(),Mf=Ae.define(),eh=Ae.define(),fv=Ae.define(),Lf=Ae.define(),za=Ae.define(),pv=Ae.define();function tg(s,e){let t=s.state.facet(pv);if(!t.length)return t;let i=t.map(n=>n instanceof Function?n(s):n),r=[];return ft.spans(i,e.from,e.to,{point(){},span(n,a,o,l){let c=n-e.from,d=a-e.from,u=r;for(let f=o.length-1;f>=0;f--,l--){let g=o[f].spec.bidiIsolate,b;if(g==null&&(g=jw(e.text,c,d)),l>0&&u.length&&(b=u[u.length-1]).to==c&&b.direction==g)b.to=d,u=b.inner;else{let v={from:c,to:d,direction:g,inner:[]};u.push(v),u=v.inner}}}}),r}const mv=Ae.define();function Nf(s){let e=0,t=0,i=0,r=0;for(let n of s.state.facet(mv)){let a=n(s);a&&(a.left!=null&&(e=Math.max(e,a.left)),a.right!=null&&(t=Math.max(t,a.right)),a.top!=null&&(i=Math.max(i,a.top)),a.bottom!=null&&(r=Math.max(r,a.bottom)))}return{left:e,right:t,top:i,bottom:r}}const sa=Ae.define();class di{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new di(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,n=0,a=0;;){let o=r<e.length?e[r].fromB:1e9,l=n<t.length?t[n]:1e9,c=Math.min(o,l);if(c==1e9)break;let d=c+a,u=c,f=d;for(;;)if(n<t.length&&t[n]<=u){let g=t[n+1];n+=2,u=Math.max(u,g);for(let b=r;b<e.length&&e[b].fromB<=u;b++)a=e[b].toA-e[b].toB;f=Math.max(f,g+a)}else if(r<e.length&&e[r].fromB<=u){let g=e[r++];u=Math.max(u,g.toB),f=Math.max(f,g.toA),a=g.toA-g.toB}else break;i.push(new di(d,f,c,u))}return i}}class Sc{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Jt.empty(this.startState.doc.length);for(let n of i)this.changes=this.changes.compose(n.changes);let r=[];this.changes.iterChangedRanges((n,a,o,l)=>r.push(new di(n,a,o,l))),this.changedRanges=r}static create(e,t,i){return new Sc(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Rw=[];class qt{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Rw}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&mw(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=qr(this.dom),r=this.length?e>0:t>0;return new wi(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof sh)return e;return null}static get(e){return e.cmTile}}class th extends qt{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,r,n=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=i?i.nextSibling:t.firstChild,n&&r!=o.dom&&(n.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=sg(r);else t.insertBefore(o.dom,r);i=o.dom}for(r=i?i.nextSibling:t.firstChild,n&&r&&(n.written=!0);r;)r=sg(r);this.length=a}}function sg(s){let e=s.nextSibling;return s.parentNode.removeChild(s),e}class sh extends th{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=qt.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,r=0,n=0;;)if(r==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&n++,r=t.pop()}else{let a=i.children[r++];if(a instanceof xr)t.push(r),i=a,r=0;else{let o=n+a.length,l=e(a,n);if(l!==void 0)return l;n=o+a.breakAfter}}}resolveBlock(e,t){let i,r=-1,n,a=-1;if(this.blockTiles((o,l)=>{let c=l+o.length;if(e>=l&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(i=void 0)}(l<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,r=e-l),(c>e||e==l&&(t>1?o.length:o.covers(-1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,a=e-l)}}),!i&&!n)throw new Error("No tile at position "+e);return i&&t<0||!n?{tile:i,offset:r}:{tile:n,offset:a}}}class xr extends th{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new xr(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class fo extends th{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let r=new fo(t||document.createElement("div"),e);return(!t||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,i){let r=null,n=-1,a=null,o=-1;function l(d,u){for(let f=0,g=0;f<d.children.length&&g<=u;f++){let b=d.children[f],v=g+b.length;v>=u&&(b.isComposite()?l(b,u-g):(!a||a.isHidden&&(t>0&&!(a.flags&32)||i&&Mw(a,b)))&&(v>u||b.flags&32&&t<=1)?(a=b,o=u-g):(g<u||b.flags&16&&!b.isHidden&&t>=-1)&&(r=b,n=u-g)),g=v}}l(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?n:o}:null}coordsIn(e,t,i){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,i):Aw(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:r,offset:n}=i;if(this.dom.contains(r.dom))return r.isText()?new wi(r.dom,Math.min(r.dom.nodeValue.length,n)):r.domPosFor(n,r.flags&16?1:r.flags&32?-1:t);let a=i.tile.parent,o=!1;for(let l of a.children){if(o)return new wi(l.dom,0);l==i.tile&&(o=!0)}}return new wi(this.dom,0)}}function Aw(s){let e=s.dom.lastChild;if(!e)return s.dom.getBoundingClientRect();let t=ca(e);return t[t.length-1]||null}function Mw(s,e){let t=s.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class Ws extends th{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new Ws(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class wn extends qt{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let r=this.dom.nodeValue.length;e>r&&(e=r);let n=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?Ee.chrome||Ee.gecko||(e?(n--,o=1):a<r&&(a++,o=-1)):t<0?n--:a<r&&a++;let l=_a(this.dom,n,a).getClientRects();if(!l.length)return null;let c=l[(o?o<0:t>=0)?0:l.length-1];return Ee.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(l,d=>d.width)||c),i==null?c:Sa(c,(o?o>0:t<0)==i)}static of(e,t){let i=new wn(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class jn extends qt{constructor(e,t,i,r){super(e,t,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(i)return Sa(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let n=this.dom.getClientRects(),a=null;if(!n.length)return null;let o=this.flags&16?!0:this.flags&32?!1:e>0;for(let l=o?n.length-1:0;a=n[l],!(e>0?l==0:l==n.length-1||a.top<a.bottom);l+=o?-1:1);return Sa(a,!o)}}get overrideDOMText(){if(!this.length)return bt.empty;let{root:e}=this;if(!e)return bt.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,r,n){return n||(n=e.toDOM(t),e.editable||(n.contentEditable="false")),new jn(n,i,e,r)}}class _c extends qt{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return bt.empty}coordsIn(e,t,i){let r=this.dom.getBoundingClientRect();return i==null?r:Sa(r,t>0==i)}}class Lw{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:r,index:n,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(r.isComposite())if(a){if(!e)break;i&&i.break(),e--,a=!1}else if(n==r.children.length){if(!e&&!o.length)break;i&&i.leave(r),a=!!r.breakAfter,{tile:r,index:n}=o.pop(),n++}else{let l=r.children[n],c=l.breakAfter;(t>0?l.length<=e:l.length<e)&&(!i||i.skip(l,0,l.length)!==!1||!l.isComposite)?(a=!!c,n++,e-=l.length):(o.push({tile:r,index:n}),r=l,n=0,i&&l.isComposite()&&i.enter(l))}else{let l=r.length;if(n<l&&e){let c=Math.min(e,l-n);i&&i.skip(r,n,n+c),e-=c,n+=c}if(n==l)a=!!r.breakAfter,{tile:r,index:n}=o.pop(),n++;else if(!e)break}return this.tile=r,this.index=n,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Nw{constructor(e,t,i,r){this.from=e,this.to=t,this.wrapper=i,this.rank=r}}class Dw{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,r){var n;this.flushBuffer();let a=this.ensureMarks(t,i),o=a.lastChild;if(o&&o.isText()&&!(o.flags&8)&&o.length+e.length<512){this.cache.reused.set(o,2);let l=a.children[a.children.length-1]=new wn(o.dom,o.text+e);l.parent=a}else a.append(r||wn.of(e,(n=this.cache.find(wn))===null||n===void 0?void 0:n.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?ad(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=i;for(let o=t.marks.length-1;o>=0;o--){let l=t.marks[o],c=r.lastChild;if(c instanceof Ws&&c.mark.eq(l.mark))c.dom!=l.dom&&c.setDOM(ad(l.dom)),r=c;else{if(this.cache.reused.get(l)){let u=qt.get(l.dom);u&&u.setDOM(ad(l.dom))}let d=Ws.of(l.mark,l.dom);r.append(d),r=d}this.cache.reused.set(l,2)}let n=qt.get(e.text);n&&this.cache.reused.set(n,2);let a=new wn(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let n=this.ensureMarks(t,i);!r&&!(e.flags&16)&&n.append(this.getBuffer(1)),n.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=gv);let r=fo.start(e,t||((i=this.cache.find(fo))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let r=this.curLine;for(let n=e.length-1;n>=0;n--){let a=e[n],o;if(t>0&&(o=r.lastChild)&&o instanceof Ws&&o.mark.eq(a))r=o,t--;else{let l=Ws.of(a,(i=this.cache.find(Ws,c=>c.mark.eq(a)))===null||i===void 0?void 0:i.dom);r.append(l),r=l,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ig(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ee.ios&&ig(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ld,0,32)||new jn(ld.toDOM(),0,ld,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new Nw(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let r=t.lastChild;if(i.from<this.pos&&r instanceof xr&&r.wrapper.eq(i.wrapper))t=r;else{let n=xr.of(i.wrapper,(e=this.cache.find(xr,a=>a.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(n),t=n}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(_c,void 0,1);return i&&(i.flags=t),i||new _c(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Iw{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:n,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=r;let o=this.textOff=Math.min(e,r.length);return n?null:r.slice(0,o)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const wc=[jn,fo,wn,Ws,_c,xr,sh];for(let s=0;s<wc.length;s++)wc[s].bucket=s;class Bw{constructor(e){this.view=e,this.buckets=wc.map(()=>[]),this.index=wc.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let r=e.bucket,n=this.buckets[r],a=this.index[r];for(let o=0;o<n.length;o++){let l=(o+a)%n.length,c=n[l];if((!t||t(c))&&!this.reused.has(c))return n.splice(l,1),l<a&&this.index[r]--,this.reused.set(c,i),c}return null}findWidget(e,t,i){let r=this.buckets[0];if(r.length)for(let n=0,a=0;;n++){if(n==r.length){if(a)return null;a=1,n=0}let o=r[n];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(n,1),n<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==i?(this.reused.set(o,1),o):(this.reused.set(o,2),new jn(o.dom,t,e,o.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Ww{constructor(e,t,i,r,n){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=n,this.openWidget=!1,this.openMarks=0,this.cache=new Bw(e),this.text=new Iw(e.state.doc),this.builder=new Dw(this.cache,new sh(e,e.contentDOM),ft.iter(i)),this.cache.reused.set(t,2),this.old=new Lw(t),this.reuseWalker={skip:(a,o,l)=>{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let r=0,n=0,a=0;;){let o=a<e.length?e[a++]:null,l=o?o.fromA:this.old.root.length;if(l>r){let c=l-r;this.preserve(c,!a,!o),r=l,n+=c}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(n,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(n,o.toB)),n=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let r=zw(this.old),n=this.openMarks;this.old.advance(e,i?1:-1,{skip:(a,o,l)=>{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(l-o);else{let c=l>0||o<a.length?jn.of(a.widget,this.view,l-o,a.flags&496,this.cache.maybeReuse(a)):this.cache.reuse(a);c.flags&256?(c.flags&=-2,this.builder.addBlockWidget(c)):(this.builder.ensureLine(null),this.builder.addInlineWidget(c,r,n),n=r.length)}else if(a.isText())this.builder.ensureLine(null),!o&&l==a.length&&!this.cache.reused.has(a)?this.builder.addText(a.text,r,n,this.cache.reuse(a)):(this.cache.add(a),this.builder.addText(a.text.slice(o,l),r,n)),n=r.length;else if(a.isLine())a.flags&=-2,this.cache.reused.set(a,1),this.builder.addLine(a);else if(a instanceof _c)this.cache.add(a);else if(a instanceof Ws)this.builder.ensureLine(null),this.builder.addMark(a,r,n),this.cache.reused.set(a,1),n=r.length;else return!1;this.openWidget=!1},enter:a=>{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof Ws&&r.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?r.length&&(r.length=n=0):a instanceof Ws&&(r.shift(),n=Math.min(n,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,r=this.builder,n=-1,a=ft.spans(this.decorations,e,t,{point:(o,l,c,d,u,f)=>{if(c instanceof Qn){if(this.disallowBlockEffectsFor[f]){if(c.block)throw new RangeError("Block decorations may not be specified via plugins");if(l>this.view.state.doc.lineAt(o).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(n=d.length,u>d.length)r.continueWidget(l-o);else{let g=c.widget||(c.block?po.block:po.inline),b=Xw(c),v=this.cache.findWidget(g,l-o,b)||jn.of(g,this.view,l-o,b);c.block?(c.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(v)):(r.ensureLine(i),r.addInlineWidget(v,d,u))}i=null}else i=qw(i,c);l>o&&this.text.skip(l-o)},span:(o,l,c,d)=>{for(let u=o;u<l;){let f=this.text.next(Math.min(512,l-u));f==null?(r.addLineStartIfNotCovered(i),r.addBreak(),u++):(r.ensureLine(i),r.addText(f,c,u==o?d:c.length),u+=f.length),i=null}n=c.length}});n>-1&&(this.openWidget=a>n),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=a}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let n=qt.get(r);if(r==this.view.contentDOM)break;n instanceof Ws?t.push(n):n?.isLine()?i=n:n instanceof xr||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new fo(r,gv):i||t.push(Ws.of(new Xa({tagName:r.nodeName.toLowerCase(),attributes:gw(r)}),r)))}return{line:i,marks:t}}}function ig(s,e){let t=i=>{for(let r of i.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(s)}function Xw(s){let e=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16;return s.block&&(e|=256),e}const gv={class:"cm-line"};function qw(s,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(s||(s={class:"cm-line"}),t&&$f(t,s),i&&(s.class+=" "+i)),s}function zw(s){let e=[];for(let t=s.parents.length;t>1;t--){let i=t==s.parents.length?s.tile:s.parents[t].tile;i instanceof Ws&&e.push(i.mark)}return e}function ad(s){let e=qt.get(s);return e&&e.setDOM(s.cloneNode()),s}class po extends Pi{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}po.inline=new po("span");po.block=new po("div");const ld=new class extends Pi{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class rg{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ze.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new sh(e,e.contentDOM),this.updateInner([new di(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:d,toA:u})=>u<this.minWidthFrom||d>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Jw(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let n=r>-1?Vw(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:d,to:u}=this.hasComposition;i=new di(d,u,e.changes.mapPos(d,-1),e.changes.mapPos(u,1)).addToSet(i.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(Ee.ie||Ee.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,o=this.blockWrappers;this.updateDeco();let l=Uw(a,this.decorations,e.changes);l.length&&(i=di.extendWithRanges(i,l));let c=Gw(o,this.blockWrappers,e.changes);return c.length&&(i=di.extendWithRanges(i,c)),n&&!i.some(d=>d.fromA<=n.range.fromA&&d.toA>=n.range.toA)&&(i=n.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let a=this.tile,o=new Ww(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&qt.get(t.text)&&o.cache.reused.set(qt.get(t.text),2),this.tile=o.run(e,t),Nu(a,o.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let n=Ee.chrome||Ee.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(n),n&&(n.written||i.selectionRange.focusNode!=n.node||!this.tile.dom.contains(n.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let n of this.tile.children)n.isWidget()&&n.widget instanceof cd&&r.push(n.dom);i.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(dv)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,r=this.view.root.activeElement,n=r==i,a=!n&&!(this.view.state.facet(gr)||i.tabIndex>-1)&&la(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(n||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,c,d;if(l.empty?d=c=this.inlineDOMNearPos(l.anchor,l.assoc||1):(d=this.inlineDOMNearPos(l.head,l.head==l.from?1:-1),c=this.inlineDOMNearPos(l.anchor,l.anchor==l.from?1:-1)),Ee.gecko&&l.empty&&!this.hasComposition&&Zw(c)){let f=document.createTextNode("");this.view.observer.ignore(()=>c.node.insertBefore(f,c.node.childNodes[c.offset]||null)),c=d=new wi(f,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!ha(c.node,c.offset,u.anchorNode,u.anchorOffset)||!ha(d.node,d.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{Ee.android&&Ee.chrome&&i.contains(u.focusNode)&&Kw(u.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let f=ya(this.view.root);if(f)if(l.empty){if(Ee.gecko){let g=Fw(c.node,c.offset);if(g&&g!=3){let b=(g==1?Ux:Hx)(c.node,c.offset);b&&(c=new wi(b.node,b.offset))}}f.collapse(c.node,c.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(c.node,c.offset);try{f.extend(d.node,d.offset)}catch{}}else{let g=document.createRange();l.anchor>l.head&&([c,d]=[d,c]),g.setEnd(d.node,d.offset),g.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(g)}a&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,d)),this.impreciseAnchor=c.precise?null:new wi(u.anchorNode,u.anchorOffset),this.impreciseHead=d.precise?null:new wi(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ha(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=ya(e.root),{anchorNode:r,anchorOffset:n}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let d=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(d.node,d.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&i.collapse(r,n)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let n;if(e==i.dom)n=i.dom.childNodes[t];else{let a=yr(e)==0?0:t==0?-1:1;for(;;){let o=e.parentNode;if(o==i.dom)break;a==0&&o.firstChild!=o.lastChild&&(e==o.firstChild?a=-1:a=1),e=o}a<0?n=e:n=e.nextSibling}if(n==i.dom.firstChild)return r;for(;n&&!qt.get(n);)n=n.nextSibling;if(!n)return r+i.length;for(let a=0,o=r;;a++){let l=i.children[a];if(l.dom==n)return o;o+=l.length+l.breakAfter}}else return i.isText()?e==i.dom?r+t:r+(t?i.length:0):r}domAtPos(e,t){let{tile:i,offset:r}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(r,t):i.domIn(r,t)}inlineDOMNearPos(e,t){let i,r=-1,n=!1,a,o=-1,l=!1;return this.tile.blockTiles((c,d)=>{if(c.isWidget()){if(c.flags&32&&d>=e)return!0;c.flags&16&&(n=!0)}else{let u=d+c.length;if(d<=e&&(i=c,r=e-d,n=u<e),u>=e&&!a&&(a=c,o=e-d,l=d>e),d>e&&a)return!0}}),!i&&!a?this.domAtPos(e,t):(n&&a?i=null:l&&i&&(a=null),i&&t<0||!a?i.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,i){let{tile:r,offset:n}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof cd?null:r.coordsInWidget(n,t,!0):r.coordsIn(n,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(n,a){if(n.isComposite())for(let o of n.children){if(o.length>=a){let l=r(o,a);if(l)return l}if(a-=o.length,a<0)break}else if(n.isText()&&a<n.length){let o=cs(n.text,a);if(o==a)return null;let l=_a(n.dom,a,o).getClientRects();for(let c=0;c<l.length;c++){let d=l[c];if(c==l.length-1||d.top<d.bottom&&d.left<d.right)return d}}return null}return r(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,n=this.view.contentDOM.clientWidth,a=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==jt.LTR,c=0,d=(u,f,g)=>{for(let b=0;b<u.children.length&&!(f>r);b++){let v=u.children[b],m=f+v.length,O=v.dom.getBoundingClientRect(),{height:p}=O;if(g&&!b&&(c+=O.top-g.top),v instanceof xr)m>i&&d(v,f,O);else if(f>=i&&(c>0&&t.push(-c),t.push(p+c),c=0,a)){let x=v.dom.lastChild,y=x?ca(x):[];if(y.length){let _=y[y.length-1],k=l?_.right-O.left:O.right-_.left;k>o&&(o=k,this.minWidth=n,this.minWidthFrom=f,this.minWidthTo=m)}}g&&b==u.children.length-1&&(c+=g.bottom-O.bottom),f=m+v.breakAfter}};return d(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?jt.RTL:jt.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let o=0,l;for(let c of a.children){if(!c.isText()||/[^ -~]/.test(c.text))return;let d=ca(c.dom);if(d.length!=1)return;o+=d[0].width,l=d[0].height}if(o)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:o/a.length,textHeight:l}}});if(e)return e;let t=document.createElement("div"),i,r,n;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let a=ca(t.firstChild)[0];i=t.getBoundingClientRect().height,r=a&&a.width?a.width/27:7,n=a&&a.height?a.height:i,t.remove()}),{lineHeight:i,charWidth:r,textHeight:n}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let n=r==t.viewports.length?null:t.viewports[r],a=n?n.from-1:this.view.state.doc.length;if(a>i){let o=(t.lineBlockAt(a).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(ze.replace({widget:new cd(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!n)break;i=n.to+1}return ze.set(e)}updateDeco(){let e=1,t=this.view.state.facet(eh).map(n=>(this.dynamicDecorationMap[e++]=typeof n=="function")?n(this.view):n),i=!1,r=this.view.state.facet(Lf).map((n,a)=>{let o=typeof n=="function";return o&&(i=!0),o?n(this.view):n});for(r.length&&(this.dynamicDecorationMap[e++]=i,t.push(ft.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(fv).map(n=>typeof n=="function"?n(this.view):n)}scrollIntoView(e){if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(hv))try{if(c(this.view,e.range,e))return!0}catch(d){Xs(this.view.state,d,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let n=Nf(this.view),a={left:i.left-n.left,top:i.top-n.top,right:i.right+n.right,bottom:i.bottom+n.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;if(vw(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==jt.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let c=this.view.docView.lineAt(t.head,1);c&&c.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Nu(this.tile)}}function Nu(s,e){let t=e?.get(s);if(t!=1){t==null&&s.destroy();for(let i of s.children)Nu(i,e)}}function Zw(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}function Ov(s,e){let t=s.observer.selectionRange;if(!t.focusNode)return null;let i=Ux(t.focusNode,t.focusOffset),r=Hx(t.focusNode,t.focusOffset),n=i||r;if(r&&i&&r.node!=i.node){let o=qt.get(r.node);if(!o||o.isText()&&o.text!=r.node.nodeValue)n=r;else if(s.docView.lastCompositionAfterCursor){let l=qt.get(i.node);!l||l.isText()&&l.text!=i.node.nodeValue||(n=r)}}if(s.docView.lastCompositionAfterCursor=n!=i,!n)return null;let a=e-n.offset;return{from:a,to:a+n.node.nodeValue.length,node:n.node}}function Vw(s,e,t){let i=Ov(s,t);if(!i)return null;let{node:r,from:n,to:a}=i,o=r.nodeValue;if(/[\n\r]/.test(o)||s.state.doc.sliceString(i.from,i.to)!=o)return null;let l=e.invertedDesc;return{range:new di(l.mapPos(n),l.mapPos(a),n,a),text:r}}function Fw(s,e){return s.nodeType!=1?0:(e&&s.childNodes[e-1].contentEditable=="false"?1:0)|(e<s.childNodes.length&&s.childNodes[e].contentEditable=="false"?2:0)}let Yw=class{constructor(){this.changes=[]}compareRange(e,t){io(e,t,this.changes)}comparePoint(e,t){io(e,t,this.changes)}boundChange(e){io(e,e,this.changes)}};function Uw(s,e,t){let i=new Yw;return ft.compare(s,e,t,i),i.changes}class Hw{constructor(){this.changes=[]}compareRange(e,t){io(e,t,this.changes)}comparePoint(){}boundChange(e){io(e,e,this.changes)}}function Gw(s,e,t){let i=new Hw;return ft.compare(s,e,t,i),i.changes}function Kw(s,e){for(let t=s;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Jw(s,e){let t=!1;return e&&s.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}class cd extends Pi{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function ek(s,e,t=1){let i=s.charCategorizer(e),r=s.doc.lineAt(e),n=e-r.from;if(r.length==0)return re.cursor(e);n==0?t=1:n==r.length&&(t=-1);let a=n,o=n;t<0?a=cs(r.text,n,!1):o=cs(r.text,n);let l=i(r.text.slice(a,o));for(;a>0;){let c=cs(r.text,a,!1);if(i(r.text.slice(c,a))!=l)break;a=c}for(;o<r.length;){let c=cs(r.text,o);if(i(r.text.slice(o,c))!=l)break;o=c}return re.undirectionalRange(a+r.from,o+r.from)}function tk(s,e,t,i,r){let n=Math.round((i-e.left)*s.defaultCharacterWidth);if(s.lineWrapping&&t.height>s.defaultLineHeight*1.5){let o=s.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(s.defaultLineHeight-o)*.5)/o);n+=l*s.viewState.heightOracle.lineLength}let a=s.state.sliceDoc(t.from,t.to);return t.from+ku(a,n,s.state.tabSize)}function Du(s,e,t){let i=s.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let n of i.type){if(n.from>e)break;if(!(n.to<e)){if(n.from<e&&n.to>e)return n;(!r||n.type==Os.Text&&(r.type!=n.type||(t<0?n.from<e:n.to>e)))&&(r=n)}}return r||i}return i}function sk(s,e,t,i){let r=Du(s,e.head,e.assoc||-1),n=!i||r.type!=Os.Text||!(s.lineWrapping||r.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(n){let a=s.dom.getBoundingClientRect(),o=s.textDirectionAt(r.from),l=s.posAtCoords({x:t==(o==jt.LTR)?a.right-1:a.left+1,y:(n.top+n.bottom)/2});if(l!=null)return re.cursor(l,t?-1:1)}return re.cursor(t?r.to:r.from,t?-1:1)}function ng(s,e,t,i){let r=s.state.doc.lineAt(e.head),n=s.bidiSpans(r),a=s.textDirectionAt(r.from);for(let o=e,l=null;;){let c=$w(r,n,a,o,t),d=tv;if(!c){if(r.number==(t?s.state.doc.lines:1))return o;d=`
|
|
12
|
-
`,r=s.state.doc.line(r.number+(t?1:-1)),n=s.bidiSpans(r),c=s.visualLineSide(r,!t)}if(l){if(!l(d))return o}else{if(!i)return c;l=i(d)}o=c}}function ik(s,e,t){let i=s.state.charCategorizer(e),r=i(t);return n=>{let a=i(n);return r==Mt.Space&&(r=a),r==a}}function rk(s,e,t,i){let r=e.head,n=t?1:-1;if(r==(t?s.state.doc.length:0))return re.cursor(r,e.assoc);let a=e.goalColumn,o,l=s.contentDOM.getBoundingClientRect(),c=s.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),d=s.documentTop;if(c)a==null&&(a=c.left-l.left),o=n<0?c.top:c.bottom;else{let b=s.viewState.lineBlockAt(r);a==null&&(a=Math.min(l.right-l.left,s.defaultCharacterWidth*(r-b.from))),o=(n<0?b.top:b.bottom)+d}let u=l.left+a,f=s.viewState.heightOracle.textHeight>>1,g=i??f;for(let b=0;;b+=f){let v=o+(g+b)*n,m=Iu(s,{x:u,y:v},!1,n);if(t?v>l.bottom:v<l.top)return re.cursor(m.pos,m.assoc);let O=s.coordsAtPos(m.pos,m.assoc),p=O?(O.top+O.bottom)/2:0;if(!O||(t?p>o:p<o))return re.cursor(m.pos,m.assoc,void 0,a)}}function da(s,e,t){for(;;){let i=0;for(let r of s)r.between(e-1,e+1,(n,a,o)=>{if(e>n&&e<a){let l=i||t||(e-n<a-e?-1:1);e=l<0?n:a,i=l}});if(!i)return e}}function xv(s,e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],n=null;if(r.empty){let a=da(s,r.from,0);a!=r.from&&(n=re.cursor(a,-1))}else{let a=da(s,r.from,-1),o=da(s,r.to,1);(a!=r.from||o!=r.to)&&(r.undirectional?n=re.undirectionalRange(r.from,r.to):n=re.range(r.from==r.anchor?a:o,r.from==r.head?a:o))}n&&(t||(t=e.ranges.slice()),t[i]=n)}return t?re.create(t,e.mainIndex):e}function hd(s,e,t){let i=da(s.state.facet(za).map(r=>r(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:re.cursor(i,i<t.from?1:-1)}class zi{constructor(e,t){this.pos=e,this.assoc=t}}function Iu(s,e,t,i){let r=s.contentDOM.getBoundingClientRect(),n=r.top+s.viewState.paddingTop,{x:a,y:o}=e,l=o-n,c;for(;;){if(l<0)return new zi(0,1);if(l>s.viewState.docHeight)return new zi(s.state.doc.length,-1);if(c=s.elementAtHeight(l),i==null)break;if(c.type==Os.Text){if(i<0?c.to<s.viewport.from:c.from>s.viewport.to)break;let f=s.docView.coordsAt(i<0?c.from:c.to,i>0?-1:1);if(f&&(i<0?f.top<=l+n:f.bottom>=l+n))break}let u=s.viewState.heightOracle.textHeight/2;l=i>0?c.bottom+u:c.top-u}if(s.viewport.from>=c.to||s.viewport.to<=c.from){if(t)return null;if(c.type==Os.Text){let u=tk(s,r,c,a,o);return new zi(u,u==c.from?1:-1)}}if(c.type!=Os.Text)return l<(c.top+c.bottom)/2?new zi(c.from,1):new zi(c.to,-1);let d=s.docView.lineAt(c.from,2);return(!d||d.length!=c.length)&&(d=s.docView.lineAt(c.from,-2)),new nk(s,a,o,s.textDirectionAt(c.from)).scanTile(d,c.from)}class nk{constructor(e,t,i,r){this.view=e,this.x=t,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Zi.find(r,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:r}=this.bidiSpansAt(e);return r[Zi.find(r,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:r}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from<t)}scan(e,t,i=!1){let r=0,n=e.length-1,a=new Set,o=this.bidiIn(e[0],e[n]),l,c,d=-1,u=1e9,f;e:for(;r<n;){let b=n-r,v=r+n>>1;t:if(a.has(v)){let O=r+Math.floor(Math.random()*b);for(let p=0;p<b;p++){if(!a.has(O)){v=O;break t}O++,O==n&&(O=r)}break e}a.add(v);let m=t(v);if(m)for(let O=0;O<m.length;O++){let p=m[O],x=0;if(!(p.width==0&&m.length>1)){if(p.bottom<this.y)(!l||l.bottom<p.bottom)&&(l=p),x=1;else if(p.top>this.y)(!c||c.top>p.top)&&(c=p),x=-1;else{let y=p.left>this.x?this.x-p.left:p.right<this.x?this.x-p.right:0,_=Math.abs(y);_<u&&(d=v,u=_,f=p),y&&(x=y<0==(this.baseDir==jt.LTR)?-1:1)}x==-1&&(!o||this.baseDirAt(e[v],1))?n=v:x==1&&(!o||this.baseDirAt(e[v+1],-1))&&(r=v+1)}}}if(!f){if(!c&&!l)return{i:e[0],after:!1};let b=l&&(!c||this.y-l.bottom<c.top-this.y)?l:c;return this.y=(b.top+b.bottom)/2,this.scan(e,t,!0)}if(u&&!i){let{top:b,bottom:v}=f;if(l&&l.bottom>(b+b+v)/3)return this.y=l.bottom-1,this.scan(e,t,!0);if(c&&c.top<(b+v+v)/3)return this.y=c.top+1,this.scan(e,t,!0)}let g=(o?this.dirAt(e[d],1):this.baseDir)==jt.LTR;return{i:d,after:this.x>(f.left+f.right)/2==g}}scanText(e,t){let i=[];for(let n=0;n<e.length;n=cs(e.text,n))i.push(t+n);i.push(t+e.length);let r=this.scan(i,n=>{let a=i[n]-t,o=i[n+1]-t;return _a(e.dom,a,o).getClientRects()});return r.after?new zi(i[r.i+1],-1):new zi(i[r.i],1)}scanTile(e,t){if(!e.length)return new zi(t,1);if(e.children.length==1){let o=e.children[0];if(o.isText())return this.scanText(o,t);if(o.isComposite())return this.scanTile(o,t)}let i=[t];for(let o=0,l=t;o<e.children.length;o++)i.push(l+=e.children[o].length);let r=this.scan(i,o=>{let l=e.children[o];return l.flags&48?null:(l.dom.nodeType==1?l.dom:_a(l.dom,0,l.length)).getClientRects()}),n=e.children[r.i],a=i[r.i];return n.isText()?this.scanText(n,a):n.isComposite()?this.scanTile(n,a):r.after?new zi(i[r.i+1],-1):new zi(a,1)}}const Yn="";class ok{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(pt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Yn}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let n=this.text.length;this.readNode(r);let a=qt.get(r),o=r.nextSibling;if(o==t){a?.breakAfter&&!o&&i!=this.view.contentDOM&&this.lineBreak();break}let l=qt.get(o);(a&&l?a.breakAfter:(a?a.breakAfter:yc(r))||yc(o)&&(r.nodeName!="BR"||a?.isWidget())&&this.text.length>n)&&!lk(o,t)&&this.lineBreak(),r=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let n=-1,a=1,o;if(this.lineSeparator?(n=t.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(o=r.exec(t))&&(n=o.index,a=o[0].length),this.append(t.slice(i,n<0?t.length:n)),n<0)break;if(this.lineBreak(),a>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=a-1);i=n+a}}readNode(e){let t=qt.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(ak(e,i.node,i.offset)?t:0))}}function ak(s,e,t){for(;;){if(!e||t<yr(e))return!1;if(e==s)return!0;t=qr(e)+1,e=e.parentNode}}function lk(s,e){let t;for(;!(s==e||!s);s=s.nextSibling){let i=qt.get(s);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let r=i.overrideDOMText;if(r?.length)return!1}return!0}class og{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class ck{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:n,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=vv(e.docView.tile,t,i,0))){let l=n||a?[]:dk(e),c=new ok(l,e);c.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=c.text,this.newSel=uk(l,this.bounds.from)}else{let l=e.observer.selectionRange,c=n&&n.node==l.focusNode&&n.offset==l.focusOffset||!Eu(e.contentDOM,l.focusNode)?o.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),d=a&&a.node==l.anchorNode&&a.offset==l.anchorOffset||!Eu(e.contentDOM,l.anchorNode)?o.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((Ee.ios||Ee.chrome)&&c!=d&&Math.min(c,d)<=o.main.from&&Math.max(c,d)>=o.main.to&&(u.from>0||u.to<e.state.doc.length)){let f=Math.min(c,d),g=Math.max(c,d),b=u.from-f,v=u.to-g;(b==0||b==1||f==0)&&(v==0||v==-1||g==e.state.doc.length)&&(c=0,d=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(re.range(d,c));else if(e.lineWrapping&&d==c&&!(o.main.empty&&o.main.head==c)&&e.inputState.lastTouchTime>Date.now()-100){let f=e.coordsAtPos(c,-1),g=0;f&&(g=e.inputState.lastTouchY<=f.bottom?-1:1),this.newSel=re.create([re.cursor(c,g)])}else this.newSel=re.single(d,c)}}}function vv(s,e,t,i){if(s.isComposite()){let r=-1,n=-1,a=-1,o=-1;for(let l=0,c=i,d=i;l<s.children.length;l++){let u=s.children[l],f=c+u.length;if(c<e&&f>t)return vv(u,e,t,c);if(f>=e&&r==-1&&(r=l,n=c),c>t&&u.dom.parentNode==s.dom){a=l,o=d;break}d=f,c=f+u.breakAfter}return{from:n,to:o<0?i+s.length:o,startDOM:(r?s.children[r-1].dom.nextSibling:null)||s.dom.firstChild,endDOM:a<s.children.length&&a>=0?s.children[a].dom:null}}else return s.isText()?{from:i,to:i+s.length,startDOM:s.dom,endDOM:s.dom.nextSibling}:null}function bv(s,e){let t,{newSel:i}=e,{state:r}=s,n=r.selection.main,a=s.inputState.lastKeyTime>Date.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,c=n.from,d=null;(a===8||Ee.android&&e.text.length<l-o)&&(c=n.to,d="end");let u=r.doc.sliceString(o,l,Yn),f,g;!n.empty&&n.from>=o&&n.to<=l&&(e.typeOver||u!=e.text)&&u.slice(0,n.from-o)==e.text.slice(0,n.from-o)&&u.slice(n.to-o)==e.text.slice(f=e.text.length-(u.length-(n.to-o)))?t={from:n.from,to:n.to,insert:bt.of(e.text.slice(n.from-o,f).split(Yn))}:(g=yv(u,e.text,c-o,d))&&(Ee.chrome&&a==13&&g.toB==g.from+2&&e.text.slice(g.from,g.toB)==Yn+Yn&&g.toB--,t={from:o+g.from,to:o+g.toA,insert:bt.of(e.text.slice(g.from,g.toB).split(Yn))})}else i&&(!s.hasFocus&&r.facet(gr)||kc(i,n))&&(i=null);if(!t&&!i)return!1;if((Ee.mac||Ee.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=re.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:bt.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(n.from).to<n.to&&s.docView.lineHasWidget(n.to)&&s.inputState.insertingTextAt>Date.now()-50?t={from:n.from,to:n.to,insert:r.toText(s.inputState.insertingText)}:Ee.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==`
|
|
13
|
-
`&&s.lineWrapping&&(i&&(i=re.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:bt.of([" "])}),t)return Df(s,t,i,a);if(i&&!kc(i,n)){let o=!1,l="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(o=!0),l=s.inputState.lastSelectionOrigin,l=="select.pointer"&&(i=xv(r.facet(za).map(c=>c(s)),i))),s.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Df(s,e,t,i=-1){if(Ee.ios&&s.inputState.flushIOSKey(e))return!0;let r=s.state.selection.main;if(Ee.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&s.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ro(s.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&ro(s.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&ro(s.contentDOM,"Delete",46)))return!0;let n=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let a,o=()=>a||(a=hk(s,e,t));return s.state.facet(ov).some(l=>l(s,e.from,e.to,n,o))||s.dispatch(o()),!0}function hk(s,e,t){let i,r=s.state,n=r.selection.main,a=-1;if(e.from==e.to&&e.from<n.from||e.from>n.to){let l=e.from<n.from?-1:1,c=l<0?n.from:n.to,d=da(r.facet(za).map(u=>u(s)),c,l);e.from==d&&(a=d)}if(a>-1)i={changes:e,selection:re.cursor(e.from+e.insert.length,-1)};else if(e.from>=n.from&&e.to<=n.to&&e.to-e.from>=(n.to-n.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let l=n.from<e.from?r.sliceDoc(n.from,e.from):"",c=n.to>e.to?r.sliceDoc(e.to,n.to):"";i=r.replaceSelection(s.state.toText(l+e.insert.sliceString(0,void 0,s.state.lineBreak)+c))}else{let l=r.changes(e),c=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(s.inputState.composing>=0||s.inputState.compositionPendingChange)&&e.to<=n.to+10&&e.to>=n.to-10){let d=s.state.sliceDoc(e.from,e.to),u,f=t&&Ov(s,t.main.head);if(f){let b=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-b}}else u=s.state.doc.lineAt(n.head);let g=n.to-e.to;i=r.changeByRange(b=>{if(b.from==n.from&&b.to==n.to)return{changes:l,range:c||b.map(l)};let v=b.to-g,m=v-d.length;if(s.state.sliceDoc(m,v)!=d||v>=u.from&&m<=u.to)return{range:b};let O=r.changes({from:m,to:v,insert:e.insert}),p=b.to-n.to;return{changes:O,range:c?re.range(Math.max(0,c.anchor+p),Math.max(0,c.head+p)):b.map(O)}})}else i={changes:l,selection:c&&r.selection.replaceRange(c)}}let o="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,o+=".compose",s.inputState.compositionFirstChange&&(o+=".start",s.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function yv(s,e,t,i){let r=Math.min(s.length,e.length),n=0;for(;n<r&&s.charCodeAt(n)==e.charCodeAt(n);)n++;if(n==r&&s.length==e.length)return null;let a=s.length,o=e.length;for(;a>0&&o>0&&s.charCodeAt(a-1)==e.charCodeAt(o-1);)a--,o--;if(i=="end"){let l=Math.max(0,n-Math.min(a,o));t-=a+l-n}if(a<n&&s.length<e.length){let l=t<=n&&t>=a?n-t:0;n-=l,o=n+(o-a),a=n}else if(o<n){let l=t<=n&&t>=o?n-t:0;n-=l,a=n+(a-o),o=n}return{from:n,toA:a,toB:o}}function dk(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:n}=s.observer.selectionRange;return t&&(e.push(new og(t,i)),(r!=t||n!=i)&&e.push(new og(r,n))),e}function uk(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?re.single(t+e,i+e):null}function kc(s,e){return e.head==s.main.head&&e.anchor==s.main.anchor}class fk{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Ee.safari&&e.contentDOM.addEventListener("input",()=>null),Ee.gecko&&Qk(e.contentDOM.ownerDocument)}handleEvent(e){!Sk(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=mk(e),i=this.handlers,r=this.view.contentDOM;for(let n in t)if(n!="scroll"){let a=!t[n].handlers.length,o=i[n];o&&a!=!o.handlers.length&&(r.removeEventListener(n,this.handleEvent),o=null),o||r.addEventListener(n,this.handleEvent,{passive:a})}for(let n in i)n!="scroll"&&!t[n]&&r.removeEventListener(n,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&_v.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ee.android&&Ee.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Ee.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Sv.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||gk.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&Ee.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&pk(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ro(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Ee.safari&&!Ee.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function pk(s){return s.visualViewport?s.visualViewport.height*s.visualViewport.scale/s.document.documentElement.clientHeight<.85:!1}function ag(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(r){Xs(t.state,r)}}}function mk(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let r=i.spec,n=r&&r.plugin.domEventHandlers,a=r&&r.plugin.domEventObservers;if(n)for(let o in n){let l=n[o];l&&t(o).handlers.push(ag(i.value,l))}if(a)for(let o in a){let l=a[o];l&&t(o).observers.push(ag(i.value,l))}}for(let i in Ci)t(i).handlers.push(Ci[i]);for(let i in Rs)t(i).observers.push(Rs[i]);return e}const Sv=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],gk="dthko",_v=[16,17,18,20,91,92,224,225],Tl=6;function Ql(s){return Math.max(0,s)*.7+8}function Ok(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}class xk{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Vx(e.contentDOM),this.atoms=e.state.facet(za).map(a=>a(e));let n=e.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(pt.allowMultipleSelections)&&vk(e,t),this.dragging=yk(e,t)&&Cv(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Ok(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,r=0,n=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:n,bottom:o}=this.scrollParents.y.getBoundingClientRect());let l=Nf(this.view);e.clientX-l.left<=r+Tl?t=-Ql(r-e.clientX):e.clientX+l.right>=a-Tl&&(t=Ql(e.clientX-a)),e.clientY-l.top<=n+Tl?i=-Ql(n-e.clientY):e.clientY+l.bottom>=o-Tl&&(i=Ql(e.clientY-o)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=xv(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function vk(s,e){let t=s.state.facet(sv);return t.length?t[0](e):Ee.mac?e.metaKey:e.ctrlKey}function bk(s,e){let t=s.state.facet(iv);return t.length?t[0](e):Ee.mac?!e.altKey:!e.ctrlKey}function yk(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=ya(s.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let n=0;n<r.length;n++){let a=r[n];if(a.left<=e.clientX&&a.right>=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function Sk(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=qt.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Ci=Object.create(null),Rs=Object.create(null),wv=Ee.ie&&Ee.ie_version<15||Ee.ios&&Ee.webkit_version<604;function _k(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),kv(s,t.value)},50)}function ih(s,e,t){for(let i of s.facet(e))t=i(t,s);return t}function kv(s,e){e=ih(s.state,Rf,e);let{state:t}=s,i,r=1,n=t.toText(e),a=n.lines==t.selection.ranges.length;if(Bu!=null&&t.selection.ranges.every(l=>l.empty)&&Bu==n.toString()){let l=-1;i=t.changeByRange(c=>{let d=t.doc.lineAt(c.from);if(d.from==l)return{range:c};l=d.from;let u=t.toText((a?n.line(r++).text:e)+t.lineBreak);return{changes:{from:d.from,insert:u},range:re.cursor(c.from+u.length)}})}else a?i=t.changeByRange(l=>{let c=n.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:re.cursor(l.from+c.length)}}):i=t.replaceSelection(n);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Rs.scroll=s=>{let e=s.inputState;e.lastScrollTop=s.scrollDOM.scrollTop,e.lastScrollLeft=s.scrollDOM.scrollLeft,Ee.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Rs.wheel=Rs.mousewheel=s=>{s.inputState.lastWheelEvent=Date.now()};Ci.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);Rs.touchstart=(s,e)=>{let t=s.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};Rs.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};Rs.touchend=(s,e)=>{s.inputState.touchActive=!1};Ci.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(rv))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=kk(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new xk(s,e,t,i)),i&&s.observer.ignore(()=>{Fx(s.contentDOM);let n=s.root.activeElement;n&&!n.contains(s.contentDOM)&&n.blur()});let r=s.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else s.inputState.setSelectionOrigin("select.pointer");return!1};function lg(s,e,t,i){if(i==1)return re.cursor(e,t);if(i==2)return ek(s.state,e,t);{let r=s.docView.lineAt(e,t),n=s.state.doc.lineAt(r?r.posAtEnd:e),a=r?r.posAtStart:n.from,o=r?r.posAtEnd:n.to;return o<s.state.doc.length&&o==n.to&&o++,re.undirectionalRange(a,o)}}const wk=Ee.ie&&Ee.ie_version<=11;let cg=null,hg=0,dg=0;function Cv(s){if(!wk)return s.detail;let e=cg,t=dg;return cg=s,dg=Date.now(),hg=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(hg+1)%3:1}function kk(s,e){let t=s.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Cv(e),r=s.state.selection;return{update(n){n.docChanged&&(t.pos=n.changes.mapPos(t.pos),r=r.map(n.changes))},get(n,a,o){let l=s.posAndSideAtCoords({x:n.clientX,y:n.clientY},!1),c,d=lg(s,l.pos,l.assoc,i);if(t.pos!=l.pos&&!a){let u=lg(s,t.pos,t.assoc,i),f=Math.min(u.from,d.from),g=Math.max(u.to,d.to);d=f<d.from?re.range(f,g,d.assoc):re.range(g,f,d.assoc)}return a?r.replaceRange(r.main.extend(d.from,d.to,d.assoc)):o&&i==1&&r.ranges.length>1&&(c=Ck(r,l.pos))?c:o?r.addRange(d):re.create([d])}}}function Ck(s,e){for(let t=0;t<s.ranges.length;t++){let{from:i,to:r}=s.ranges[t];if(i<=e&&r>=e)return re.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}Ci.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let r=s.docView.tile.nearest(e.target);if(r&&r.isWidget()){let n=r.posAtStart,a=n+r.length;(n>=t.to||a<=t.from)&&(t=re.undirectionalRange(n,a))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",ih(s.state,Af,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ci.dragend=s=>(s.inputState.draggedContent=null,!1);function ug(s,e,t,i){if(t=ih(s.state,Rf,t),!t)return;let r=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:n}=s.inputState,a=i&&n&&bk(s,e)?{from:n.from,to:n.to}:null,o={from:r,insert:t},l=s.state.changes(a?[a,o]:o);s.focus(),s.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:a?"move.drop":"input.drop"}),s.inputState.draggedContent=null}Ci.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,n=()=>{++r==t.length&&ug(s,e,i.filter(a=>a!=null).join(s.state.lineBreak),!1)};for(let a=0;a<t.length;a++){let o=new FileReader;o.onerror=n,o.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(o.result)||(i[a]=o.result),n()},o.readAsText(t[a])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return ug(s,e,i,!0),!0}return!1};Ci.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=wv?null:e.clipboardData;return t?(kv(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(_k(s),!1)};function Pk(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function Tk(s){let e=[],t=[],i=!1;for(let r of s.selection.ranges)r.empty||(e.push(s.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:n}of s.selection.ranges){let a=s.doc.lineAt(n);a.number>r&&(e.push(a.text),t.push({from:a.from,to:Math.min(s.doc.length,a.to+1)})),r=a.number}i=!0}return{text:ih(s,Af,e.join(s.lineBreak)),ranges:t,linewise:i}}let Bu=null;Ci.copy=Ci.cut=(s,e)=>{if(!la(s.contentDOM,s.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:r}=Tk(s.state);if(!t&&!r)return!1;Bu=r?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let n=wv?null:e.clipboardData;return n?(n.clearData(),n.setData("text/plain",t),!0):(Pk(s,t),!1)};const Pv=Gi.define();function Tv(s,e){let t=[];for(let i of s.facet(av)){let r=i(s,e);r&&t.push(r)}return t.length?s.update({effects:t,annotations:Pv.of(!0)}):null}function Qv(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Tv(s.state,e);t?s.dispatch(t):s.update([])}},10)}Rs.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),Qv(s)};Rs.blur=s=>{s.observer.clearSelectionRange(),Qv(s)};Rs.compositionstart=Rs.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};Rs.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,Ee.chrome&&Ee.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};Rs.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};Ci.beforeinput=(s,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(s.inputState.insertingText=e.data,s.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&s.observer.editContext){let n=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(n&&a.length){let o=a[0],l=s.posAtDOM(o.startContainer,o.startOffset),c=s.posAtDOM(o.endContainer,o.endOffset);return Df(s,{from:l,to:c,insert:s.state.toText(n)},null),!0}}let r;if(Ee.chrome&&Ee.android&&(r=Sv.find(n=>n.inputType==e.inputType))&&(s.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let n=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>n+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return Ee.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),Ee.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>Rs.compositionend(s,e),20),!1};const fg=new Set;function Qk(s){fg.has(s)||(fg.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const pg=["pre-wrap","normal","pre-line","break-spaces"];let mo=!1;function mg(){mo=!1}class $k{constructor(e){this.lineWrapping=e,this.doc=bt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return pg.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,n,a){let o=pg.indexOf(e)>-1,l=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=n,l){this.heightSamples={};for(let c=0;c<a.length;c++){let d=a[c];d<0?c++:this.heightSamples[Math.floor(d*10)]=!0}}return l}}class jk{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class _i{constructor(e,t,i,r,n){this.from=e,this.length=t,this.top=i,this.height=r,this._content=n}get type(){return typeof this._content=="number"?Os.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Qn?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new _i(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Et=(function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s})(Et||(Et={}));const ic=.001;class Es{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ic&&(mo=!0),this.height=e)}replace(e,t,i){return Es.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let n=this,a=i.doc;for(let o=r.length-1;o>=0;o--){let{fromA:l,toA:c,fromB:d,toB:u}=r[o],f=n.lineAt(l,Et.ByPosNoHeight,i.setDoc(t),0,0),g=f.to>=c?f:n.lineAt(c,Et.ByPosNoHeight,i,0,0);for(u+=g.to-c,c=g.to;o>0&&f.from<=r[o-1].toA;)l=r[o-1].fromA,d=r[o-1].fromB,o--,l<f.from&&(f=n.lineAt(l,Et.ByPosNoHeight,i,0,0));d+=f.from-l,l=f.from;let b=If.build(i.setDoc(a),e,d,u);n=Cc(n,n.replace(l,c,b))}return n.updateHeight(i,0)}static empty(){return new Ks(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,n=0;for(;;)if(t==i)if(r>n*2){let o=e[t-1];o.break?e.splice(--t,1,o.left,null,o.right):e.splice(--t,1,o.left,o.right),i+=1+o.break,r-=o.size}else if(n>r*2){let o=e[i];o.break?e.splice(i,1,o.left,null,o.right):e.splice(i,1,o.left,o.right),i+=2+o.break,n-=o.size}else break;else if(r<n){let o=e[t++];o&&(r+=o.size)}else{let o=e[--i];o&&(n+=o.size)}let a=0;return e[t-1]==null?(a=1,t--):e[t]==null&&(a=1,i++),new Rk(Es.of(e.slice(0,t)),a,Es.of(e.slice(i)))}}function Cc(s,e){return s==e?s:(s.constructor!=e.constructor&&(mo=!0),e)}Es.prototype.size=1;const Ek=ze.replace({});class $v extends Es{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new _i(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new _i(r,0,i,this.spaceAbove,Ek):this.mainBlock(i,r)}lineAt(e,t,i,r,n){let a=this.mainBlock(r,n);return this.spaceAbove?this.blockAt(0,i,r,n).join(a):a}forEachLine(e,t,i,r,n,a){e<=n+this.length&&t>=n&&a(this.lineAt(0,Et.ByPos,i,r,n))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ks extends $v{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new _i(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof Ks||r instanceof ps&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof ps?r=new Ks(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Es.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ps extends Es{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,n=r-i+1,a,o=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*n);a=l/n,this.length>n+1&&(o=(this.height-l)/(this.length-n-1))}else a=this.height/n;return{firstLine:i,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,i,r){let{firstLine:n,lastLine:a,perLine:o,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),d=t.doc.lineAt(c),u=o+d.length*l,f=Math.max(i,e-u/2);return new _i(d.from,d.length,f,u,0)}else{let c=Math.max(0,Math.min(a-n,Math.floor((e-i)/o))),{from:d,length:u}=t.doc.line(n+c);return new _i(d,u,i+o*c,o,0)}}lineAt(e,t,i,r,n){if(t==Et.ByHeight)return this.blockAt(e,i,r,n);if(t==Et.ByPosNoHeight){let{from:g,to:b}=i.doc.lineAt(e);return new _i(g,b-g,0,0,0)}let{firstLine:a,perLine:o,perChar:l}=this.heightMetrics(i,n),c=i.doc.lineAt(e),d=o+c.length*l,u=c.number-a,f=r+o*u+l*(c.from-n-u);return new _i(c.from,c.length,Math.max(r,Math.min(f,r+this.height-d)),d,0)}forEachLine(e,t,i,r,n,a){e=Math.max(e,n),t=Math.min(t,n+this.length);let{firstLine:o,perLine:l,perChar:c}=this.heightMetrics(i,n);for(let d=e,u=r;d<=t;){let f=i.doc.lineAt(d);if(d==e){let b=f.number-o;u+=l*b+c*(e-n-b)}let g=l+c*f.length;a(new _i(f.from,f.length,u,g,0)),u+=g,d=f.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let n=i[i.length-1];n instanceof ps?i[i.length-1]=new ps(n.length+r):i.push(null,new ps(r-1))}if(e>0){let n=i[0];n instanceof ps?i[0]=new ps(e+n.length):i.unshift(new ps(e-1),null)}return Es.of(i)}decomposeLeft(e,t){t.push(new ps(e-1),null)}decomposeRight(e,t){t.push(null,new ps(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let n=t+this.length;if(r&&r.from<=t+this.length&&r.more){let a=[],o=Math.max(t,r.from),l=-1;for(r.from>t&&a.push(new ps(r.from-t-1).updateHeight(e,t));o<=n&&r.more;){let d=e.doc.lineAt(o).length;a.length&&a.push(null);let u=r.heights[r.index++],f=0;u<0&&(f=-u,u=r.heights[r.index++]),l==-1?l=u:Math.abs(u-l)>=ic&&(l=-2);let g=new Ks(d,u,f);g.outdated=!1,a.push(g),o+=d+1}o<=n&&a.push(null,new ps(n-o).updateHeight(e,o));let c=Es.of(a);return(l<0||Math.abs(c.height-this.height)>=ic||Math.abs(l-this.heightMetrics(e,t).perLine)>=ic)&&(mo=!0),Cc(this,c)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Rk extends Es{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let n=i+this.left.height;return e<n?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,n,r+this.left.length+this.break)}lineAt(e,t,i,r,n){let a=r+this.left.height,o=n+this.left.length+this.break,l=t==Et.ByHeight?e<a:e<o,c=l?this.left.lineAt(e,t,i,r,n):this.right.lineAt(e,t,i,a,o);if(this.break||(l?c.to<o:c.from>o))return c;let d=t==Et.ByPosNoHeight?Et.ByPosNoHeight:Et.ByPos;return l?c.join(this.right.lineAt(o,d,i,a,o)):this.left.lineAt(o,d,i,r,n).join(c)}forEachLine(e,t,i,r,n,a){let o=r+this.left.height,l=n+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,i,r,n,a),t>=l&&this.right.forEachLine(e,t,i,o,l,a);else{let c=this.lineAt(l,Et.ByPos,i,r,n);e<c.from&&this.left.forEachLine(e,c.from-1,i,r,n,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,i,o,l,a)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let n=[];e>0&&this.decomposeLeft(e,n);let a=n.length;for(let o of i)n.push(o);if(e>0&&gg(n,a-1),t<this.length){let o=n.length;this.decomposeRight(t,n),gg(n,o)}return Es.of(n)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Es.of(this.break?[e,null,t]:[e,t]):(this.left=Cc(this.left,e),this.right=Cc(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:n,right:a}=this,o=t+n.length+this.break,l=null;return r&&r.from<=t+n.length&&r.more?l=n=n.updateHeight(e,t,i,r):n.updateHeight(e,t,i),r&&r.from<=o+a.length&&r.more?l=a=a.updateHeight(e,o,i,r):a.updateHeight(e,o,i),l?this.balanced(n,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function gg(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof ps&&(i=s[e+1])instanceof ps&&s.splice(e-1,3,new ps(t.length+1+i.length))}const Ak=5;class If{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Ks?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ks(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,n=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;i.block?this.addBlock(new $v(a,r,i)):(a||n||r>=Ak)&&this.addLineDeco(r,n,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ks(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new ps(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ks)return e;let t=new Ks(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ks)&&!this.isCovered?this.nodes.push(new Ks(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof Ks&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let n=new If(i,e);return ft.spans(t,i,r,n,0),n.finish(i)}}function Mk(s,e,t){let i=new Lk;return ft.compare(s,e,t,i,0),i.changes}class Lk{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&io(e,t,this.changes,5)}}function Nk(s,e){let t=s.getBoundingClientRect(),i=s.ownerDocument,r=i.defaultView||window,n=Math.max(0,t.left),a=Math.min(r.innerWidth,t.right),o=Math.max(0,t.top),l=Math.min(r.innerHeight,t.bottom);for(let c=s.parentNode;c&&c!=i.body;)if(c.nodeType==1){let d=c,u=window.getComputedStyle(d);if((d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth)&&u.overflow!="visible"){let f=d.getBoundingClientRect();n=Math.max(n,f.left),a=Math.min(a,f.right),o=Math.max(o,f.top),l=Math.min(c==s.parentNode?r.innerHeight:l,f.bottom)}c=u.position=="absolute"||u.position=="fixed"?d.offsetParent:d.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:n-t.left,right:Math.max(n,a)-t.left,top:o-(t.top+e),bottom:Math.max(o,l)-(t.top+e)}}function Dk(s){let e=s.getBoundingClientRect(),t=s.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Ik(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class dd{constructor(e,t,i,r){this.from=e,this.to=t,this.size=i,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],n=t[i];if(r.from!=n.from||r.to!=n.to||r.size!=n.size)return!1}return!0}draw(e,t){return ze.replace({widget:new Bk(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Bk extends Pi{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Og{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=xg,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=jt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(Mf).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new $k(i),this.stateDeco=vg(t),this.heightMap=Es.empty().applyChanges(this.stateDeco,bt.empty,this.heightOracle.setDoc(t.doc),[new di(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ze.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:n,to:a})=>r>=n&&r<=a)){let{from:n,to:a}=this.lineBlockAt(r);e.push(new $l(n,a))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?xg:new Bf(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(ia(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=vg(this.state);let r=e.changedRanges,n=di.extendWithRanges(r,Mk(i,this.stateDeco,e?e.changes:Jt.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);mg(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=a||mo)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let l=n.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<l.from||t.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(cv)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,n=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?jt.RTL:jt.LTR;let a=this.heightOracle.mustRefreshForWrapping(n)||this.mustMeasureContent==="refresh",o=t.getBoundingClientRect(),l=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,d=0;if(o.width&&o.height){let{scaleX:_,scaleY:k}=Zx(t,o);(_>.005&&Math.abs(this.scaleX-_)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=_,this.scaleY=k,c|=16,a=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=f)&&(this.paddingTop=u,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let g=Vx(this.view.contentDOM,!1).y;g!=this.scrollParent&&(this.scrollParent=g,this.scrollAnchorHeight=-1,this.scrollOffset=0);let b=this.getScrollOffset();this.scrollOffset!=b&&(this.scrollAnchorHeight=-1,this.scrollOffset=b),this.scrolledToBottom=Yx(this.scrollParent||e.win);let v=(this.printing?Ik:Nk)(t,this.paddingTop),m=v.top-this.pixelViewport.top,O=v.bottom-this.pixelViewport.bottom;this.pixelViewport=v;let p=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(p!=this.inView&&(this.inView=p,p&&(l=!0)),!this.inView&&!this.scrollTarget&&!Dk(e.dom))return 0;let x=o.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let _=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(_)&&(a=!0),a||r.lineWrapping&&Math.abs(x-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:w,textHeight:S}=e.docView.measureTextSize();a=k>0&&r.refresh(n,k,w,S,Math.max(5,x/w),_),a&&(e.docView.minWidth=0,c|=16)}m>0&&O>0?d=Math.max(m,O):m<0&&O<0&&(d=Math.min(m,O)),mg();for(let k of this.viewports){let w=k.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(k);this.heightMap=(a?Es.empty().applyChanges(this.stateDeco,bt.empty,this.heightOracle,[new di(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new jk(k.from,w))}mo&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,n=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,l=new $l(r.lineAt(a-i*1e3,Et.ByHeight,n,0,0).from,r.lineAt(o+(1-i)*1e3,Et.ByHeight,n,0,0).to);if(t){let{head:c}=t.range;if(c<l.from||c>l.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=r.lineAt(c,Et.ByPos,n,0,0),f;t.y=="center"?f=(u.top+u.bottom)/2-d/2:t.y=="start"||t.y=="nearest"&&c<l.from?f=u.top:f=u.bottom-d,l=new $l(r.lineAt(f-1e3/2,Et.ByHeight,n,0,0).from,r.lineAt(f+d+1e3/2,Et.ByHeight,n,0,0).to)}}return l}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new $l(this.heightMap.lineAt(i,Et.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Et.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,Et.ByPos,this.heightOracle,0,0),{bottom:n}=this.heightMap.lineAt(t,Et.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||n>=o+Math.max(10,Math.min(i,250)))&&r>a-2*1e3&&n<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new dd(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,n=r>>1,a=r<<1;if(this.defaultTextDirection!=jt.LTR&&!i)return[];let o=[],l=(d,u,f,g)=>{if(u-d<n)return;let b=this.state.selection.main,v=[b.from];b.empty||v.push(b.to);for(let O of v)if(O>d&&O<u){l(d,O-10,f,g),l(O+10,u,f,g);return}let m=Xk(e,O=>O.from>=f.from&&O.to<=f.to&&Math.abs(O.from-d)<n&&Math.abs(O.to-u)<n&&!v.some(p=>O.from<p&&O.to>p));if(!m){if(u<f.to&&t&&i&&t.visibleRanges.some(x=>x.from<=u&&x.to>=u)){let x=t.moveToLineBoundary(re.cursor(u),!1,!0).head;x>d&&(u=x)}let O=this.gapSize(f,d,u,g),p=i||O<2e6?O:2e6;m=new dd(d,u,O,p)}o.push(m)},c=d=>{if(d.length<a||d.type!=Os.Text)return;let u=Wk(d.from,d.to,this.stateDeco);if(u.total<a)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,g,b;if(i){let v=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,O;if(f!=null){let p=El(u,f),x=((this.visibleBottom-this.visibleTop)/2+v)/d.height;m=p-x,O=p+x}else m=(this.visibleTop-d.top-v)/d.height,O=(this.visibleBottom-d.top+v)/d.height;g=jl(u,m),b=jl(u,O)}else{let v=u.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,O=0;if(v>2e6)for(let k of e)k.from>=d.from&&k.from<d.to&&k.size!=k.displaySize&&k.from*this.heightOracle.charWidth+O<this.pixelViewport.left&&(O=k.size-k.displaySize);let p=this.pixelViewport.left+O,x=this.pixelViewport.right+O,y,_;if(f!=null){let k=El(u,f),w=((x-p)/2+m)/v;y=k-w,_=k+w}else y=(p-m)/v,_=(x+m)/v;g=jl(u,y),b=jl(u,_)}g>d.from&&l(d.from,g,d,u),b<d.to&&l(b,d.to,d,u)};for(let d of this.viewportLines)Array.isArray(d.type)?d.type.forEach(c):c(d);return o}gapSize(e,t,i,r){let n=El(r,i)-El(r,t);return this.heightOracle.lineWrapping?e.height*n:r.total*this.heightOracle.charWidth*n}updateLineGaps(e){dd.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ze.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];ft.spans(t,this.viewport.from,this.viewport.to,{span(n,a){i.push({from:n,to:a})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let n=0;n<i.length&&!(r&8);n++){let a=this.visibleRanges[n],o=i[n];(a.from!=o.from||a.to!=o.to)&&(r|=4,e&&e.mapPos(a.from,-1)==o.from&&e.mapPos(a.to,1)==o.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ia(this.heightMap.lineAt(e,Et.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||ia(this.heightMap.lineAt(this.scaler.fromDOM(e),Et.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ia(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class $l{constructor(e,t){this.from=e,this.to=t}}function Wk(s,e,t){let i=[],r=s,n=0;return ft.spans(t,s,e,{span(){},point(a,o){a>r&&(i.push({from:r,to:a}),n+=a-r),r=o}},20),r<e&&(i.push({from:r,to:e}),n+=e-r),{total:n,ranges:i}}function jl({total:s,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let r=0;;r++){let{from:n,to:a}=e[r],o=a-n;if(i<=o)return n+i;i-=o}}function El(s,e){let t=0;for(let{from:i,to:r}of s.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/s.total}function Xk(s,e){for(let t of s)if(e(t))return t}const xg={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}};function vg(s){let e=s.facet(eh).filter(i=>typeof i!="function"),t=s.facet(Lf).filter(i=>typeof i!="function");return t.length&&e.push(ft.join(t)),e}class Bf{constructor(e,t,i){let r=0,n=0,a=0;this.viewports=i.map(({from:o,to:l})=>{let c=t.lineAt(o,Et.ByPos,e,0,0).top,d=t.lineAt(l,Et.ByPos,e,0,0).bottom;return r+=d-c,{from:o,to:l,top:c,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let o of this.viewports)o.domTop=a+(o.top-n)*this.scale,a=o.domBottom=o.domTop+(o.bottom-o.top),n=o.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let n=t<this.viewports.length?this.viewports[t]:null;if(!n||e<n.top)return r+(e-i)*this.scale;if(e<=n.bottom)return n.domTop+(e-n.top);i=n.bottom,r=n.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let n=t<this.viewports.length?this.viewports[t]:null;if(!n||e<n.domTop)return i+(e-r)/this.scale;if(e<=n.domBottom)return n.top+(e-n.domTop);i=n.bottom,r=n.domBottom}}eq(e){return e instanceof Bf?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function ia(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),i=e.toDOM(s.bottom);return new _i(s.from,s.length,t,i-t,Array.isArray(s._content)?s._content.map(r=>ia(r,e)):s._content)}const Rl=Ae.define({combine:s=>s.join(" ")}),Wu=Ae.define({combine:s=>s.indexOf(!0)>-1}),Xu=Wr.newName(),jv=Wr.newName(),Ev=Wr.newName(),Rv={"&light":"."+jv,"&dark":"."+Ev};function qu(s,e,t){return new Wr(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return s;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):s+" "+i}})}const qk=qu("."+Xu,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Rv),zk={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ud=Ee.ie&&Ee.ie_version<=11;class Zk{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new bw,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(Ee.ie&&Ee.ie_version<=11||Ee.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ee.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ee.chrome&&Ee.chrome_version<126)&&(this.editContext=new Fk(e),e.state.facet(gr)&&(e.contentDOM.editContext=this.editContext.editContext)),ud&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(gr)?i.root.activeElement!=this.dom:!la(this.dom,r))return;let n=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(n&&n.isWidget()&&n.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Ee.ie&&Ee.ie_version<=11||Ee.android&&Ee.chrome)&&!i.state.selection.main.empty&&r.focusNode&&ha(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ya(e.root);if(!t)return!1;let i=Ee.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Vk(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let r=la(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Sw(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,zk),ud&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ud&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let n=this.delayedAndroidKey;n&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=n.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&n.force&&ro(this.dom,n.key,n.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let n of e){let a=this.readMutation(n);a&&(a.typeOver&&(r=!0),t==-1?{from:t,to:i}=a:(t=Math.min(a.from,t),i=Math.max(a.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&la(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new ck(this.view,e,t,i);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=bv(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!kc(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=bg(t,e.previousSibling||e.target.previousSibling,-1),r=bg(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(gr)!=e.state.facet(gr)&&(e.view.contentDOM.editContext=e.state.facet(gr)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function bg(s,e,t){for(;e;){let i=qt.get(e);if(i&&i.parent==s)return i;let r=e.parentNode;e=r!=s.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function yg(s,e){let t=e.startContainer,i=e.startOffset,r=e.endContainer,n=e.endOffset,a=s.docView.domAtPos(s.state.selection.main.anchor,1);return ha(a.node,a.offset,r,n)&&([t,i,r,n]=[r,n,t,i]),{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:n}}function Vk(s,e){if(e.getComposedRanges){let r=e.getComposedRanges(s.root)[0];if(r)return yg(s,r)}let t=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),t?yg(s,t):null}class Fk{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:n,head:a}=r,o=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:o,drifted:!1});let c=l-o>i.text.length;o==this.from&&n<this.from?o=n:l==this.to&&n>this.to&&(l=n);let d=yv(e.state.sliceDoc(o,l),i.text,(c?r.from:r.to)-o,c?"end":null);if(!d){let f=re.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));kc(f,r)||e.dispatch({selection:f,userEvent:"select"});return}let u={from:d.from+o,to:d.toA+o,insert:bt.of(i.text.slice(d.from,d.toB).split(`
|
|
14
|
-
`))};if((Ee.mac||Ee.android)&&u.from==a-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(u={from:o,to:l,insert:bt.of([i.text.replace("."," ")])}),this.pendingContextChange=u,!e.state.readOnly){let f=this.to-this.from+(u.to-u.from+u.insert.length);Df(e,u,re.single(this.toEditorPos(i.selectionStart,f),this.toEditorPos(i.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],n=null;for(let a=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);a<o;a++){let l=e.coordsForChar(a);n=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||n||new DOMRect,r.push(n)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let n of i.getTextFormats()){let a=n.underlineStyle,o=n.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(o)){let l=this.toEditorPos(n.rangeStart),c=this.toEditorPos(n.rangeEnd);if(l<c){let d=`text-decoration: underline ${/^[a-z]/.test(a)?a+" ":a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${/thin/i.test(o)?1:2}px`;r.push(ze.mark({attributes:{style:d}}).range(l,c))}}}e.dispatch({effects:dv.of(ze.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=ya(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((n,a,o,l,c)=>{if(i)return;let d=c.length-(a-n);if(r&&a>=r.to)if(r.from==n&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=d,this.to+=d;return}else r=null,this.revertPending(e.state);if(n+=t,a+=t,a<=this.from)this.from+=d,this.to+=d;else if(n<this.to){if(n<this.from||a>this.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(n),this.toContextPos(a),c.toString()),this.to+=d}t+=d}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class _e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(n=>i(n,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||yw(e.parent)||document,this.viewState=new Og(this,e.state||pt.create(e)),e.scrollTo&&e.scrollTo.is(Pl)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Kn).map(r=>new od(r));for(let r of this.plugins)r.update(this);this.observer=new Zk(this),this.inputState=new fk(this),this.inputState.ensureHandlers(this.plugins),this.docView=new rg(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Kt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,n=this.state;for(let f of e){if(f.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=f.state}if(this.destroyed){this.viewState.state=n;return}let a=this.hasFocus,o=0,l=null;e.some(f=>f.annotation(Pv))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,l=Tv(n,a),l||(o=1));let c=this.observer.delayedAndroidKey,d=null;if(c?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(d=null)):this.observer.clear(),n.facet(pt.phrases)!=this.state.facet(pt.phrases))return this.setState(n);r=Sc.create(this,n,e),r.flags|=o;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(u&&(u=u.map(f.changes)),f.scrollIntoView){let{main:g}=f.state.selection,{x:b,y:v}=this.state.facet(_e.cursorScrollMargin);u=new no(g.empty?g:re.cursor(g.head,g.head>g.anchor?-1:1),"nearest","nearest",v,b)}for(let g of f.effects)g.is(Pl)&&(u=g.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Pc.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(sa)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Rl)!=r.state.facet(Rl)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Lu))try{f(r)}catch(g){Xs(this.state,g,"update listener")}(l||d)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),d&&!bv(this,d)&&c.force&&ro(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Og(this,e),this.plugins=e.facet(Kn).map(i=>new od(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new rg(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Kn),i=e.state.facet(Kn);if(t!=i){let r=[];for(let n of i){let a=t.indexOf(n);if(a<0)r.push(new od(n));else{let o=this.plugins[a];o.mustUpdate=e,r.push(o)}}for(let n of this.plugins)n.mustUpdate!=e&&n.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){Xs(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:n,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(a<0)if(Yx(i||this.win))n=-1,a=this.viewState.heightMap.height;else{let g=this.viewState.scrollAnchorAt(r);n=g.from,a=g.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let d=c.map(g=>{try{return g.read(this)}catch(b){return Xs(this.state,b),Sg}}),u=Sc.create(this,this.state,[]),f=!1;u.flags|=l,t?t.flags|=l:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),f=this.docView.update(u),f&&this.docViewUpdate());for(let g=0;g<c.length;g++)if(d[g]!=Sg)try{let b=c[g];b.write&&b.write(d[g],this)}catch(b){Xs(this.state,b)}if(f&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let b=((n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)-a)/this.scaleY;if((b>1||b<-1)&&!(Ee.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+b,i?i.scrollTop+=b:this.win.scrollBy(0,b),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let o of this.state.facet(Lu))o(t)}get themeClasses(){return Xu+" "+(this.state.facet(Wu)?Ev:jv)+" "+this.state.facet(Rl)}updateAttrs(){let e=_g(this,uv,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(gr)?"true":"false",class:"cm-content",style:`${Ee.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),_g(this,Mf,t);let i=this.observer.ignore(()=>{let r=Km(this.contentDOM,this.contentAttrs,t),n=Km(this.dom,this.editorAttrs,e);return r||n});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(_e.announce)){t&&(this.announceDOM.textContent=""),t=!1;let n=this.announceDOM.appendChild(document.createElement("div"));n.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(sa);let e=this.state.facet(_e.cspNonce);Wr.mount(this.root,this.styleModules.concat(qk).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return hd(this,e,ng(this,e,t,i))}moveByGroup(e,t){return hd(this,e,ng(this,e,t,i=>ik(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),n=i[t?i.length-1:0];return re.cursor(n.side(t,r)+e.from,n.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return sk(this,e,t,i)}moveVertically(e,t,i){return hd(this,e,rk(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Iu(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Iu(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),n=r[Zi.find(r,e-i.from,-1,t)];return this.docView.coordsAt(e,t,n.dir==jt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(lv)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Yk)return ev(e.length);let t=this.textDirectionAt(e.from),i;for(let n of this.bidiCache)if(n.from==e.from&&n.dir==t&&(n.fresh||Jx(n.isolates,i=tg(this,e))))return n.order;i||(i=tg(this,e));let r=Qw(e.text,t,i);return this.bidiCache.push(new Pc(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ee.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Fx(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,n,a;return Pl.of(new no(typeof e=="number"?re.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(n=t.yMargin)!==null&&n!==void 0?n:5,(a=t.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Pl.of(new no(re.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return zt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return zt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Wr.newName(),r=[Rl.of(i),sa.of(qu(`.${i}`,e))];return t&&t.dark&&r.push(Wu.of(!0)),r}static baseTheme(e){return kr.lowest(sa.of(qu("."+Xu,e,Rv)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&qt.get(i)||qt.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}}_e.styleModule=sa;_e.inputHandler=ov;_e.clipboardInputFilter=Rf;_e.clipboardOutputFilter=Af;_e.scrollHandler=hv;_e.focusChangeEffect=av;_e.perLineTextDirection=lv;_e.exceptionSink=nv;_e.updateListener=Lu;_e.editable=gr;_e.mouseSelectionStyle=rv;_e.dragMovesSelection=iv;_e.clickAddsSelectionRange=sv;_e.decorations=eh;_e.blockWrappers=fv;_e.outerDecorations=Lf;_e.atomicRanges=za;_e.bidiIsolatedRanges=pv;_e.cursorScrollMargin=Ae.define({combine:s=>{let e=5,t=5;for(let i of s)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});_e.scrollMargins=mv;_e.darkTheme=Wu;_e.cspNonce=Ae.define({combine:s=>s.length?s[0]:""});_e.contentAttributes=Mf;_e.editorAttributes=uv;_e.lineWrapping=_e.contentAttributes.of({class:"cm-lineWrapping"});_e.announce=nt.define();const Yk=4096,Sg={};class Pc{constructor(e,t,i,r,n,a){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=n,this.order=a}static update(e,t){if(t.empty&&!e.some(n=>n.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:jt.LTR;for(let n=Math.max(0,e.length-10);n<e.length;n++){let a=e[n];a.dir==r&&!t.touchesRange(a.from,a.to)&&i.push(new Pc(t.mapPos(a.from,1),t.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return i}}function _g(s,e,t){for(let i=s.state.facet(e),r=i.length-1;r>=0;r--){let n=i[r],a=typeof n=="function"?n(s):n;a&&$f(a,t)}return t}const Uk=Ee.mac?"mac":Ee.windows?"win":Ee.linux?"linux":"key";function Hk(s,e){const t=s.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let r,n,a,o;for(let l=0;l<t.length-1;++l){const c=t[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))e=="mac"?o=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(i="Alt-"+i),n&&(i="Ctrl-"+i),o&&(i="Meta-"+i),a&&(i="Shift-"+i),i}function Al(s,e,t){return e.altKey&&(s="Alt-"+s),e.ctrlKey&&(s="Ctrl-"+s),e.metaKey&&(s="Meta-"+s),t!==!1&&e.shiftKey&&(s="Shift-"+s),s}const Gk=kr.default(_e.domEventHandlers({keydown(s,e){return Mv(Av(e.state),s,e,"editor")}})),So=Ae.define({enables:Gk}),wg=new WeakMap;function Av(s){let e=s.facet(So),t=wg.get(e);return t||wg.set(e,t=eC(e.reduce((i,r)=>i.concat(r),[]))),t}function Kk(s,e,t){return Mv(Av(s.state),e,s,t)}let Nr=null;const Jk=4e3;function eC(s,e=Uk){let t=Object.create(null),i=Object.create(null),r=(a,o)=>{let l=i[a];if(l==null)i[a]=o;else if(l!=o)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},n=(a,o,l,c,d)=>{var u,f;let g=t[a]||(t[a]=Object.create(null)),b=o.split(/ (?!$)/).map(O=>Hk(O,e));for(let O=1;O<b.length;O++){let p=b.slice(0,O).join(" ");r(p,!0),g[p]||(g[p]={preventDefault:!0,stopPropagation:!1,run:[x=>{let y=Nr={view:x,prefix:p,scope:a};return setTimeout(()=>{Nr==y&&(Nr=null)},Jk),!0}]})}let v=b.join(" ");r(v,!1);let m=g[v]||(g[v]={preventDefault:!1,stopPropagation:!1,run:((f=(u=g._any)===null||u===void 0?void 0:u.run)===null||f===void 0?void 0:f.slice())||[]});l&&m.run.push(l),c&&(m.preventDefault=!0),d&&(m.stopPropagation=!0)};for(let a of s){let o=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let c of o){let d=t[c]||(t[c]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=a;for(let f in d)d[f].run.push(g=>u(g,zu))}let l=a[e]||a.key;if(l)for(let c of o)n(c,l,a.run,a.preventDefault,a.stopPropagation),a.shift&&n(c,"Shift-"+l,a.shift,a.preventDefault,a.stopPropagation)}return t}let zu=null;function Mv(s,e,t,i){zu=e;let r=pw(e),n=Is(r,0),a=qi(n)==r.length&&r!=" ",o="",l=!1,c=!1,d=!1;Nr&&Nr.view==t&&Nr.scope==i&&(o=Nr.prefix+" ",_v.indexOf(e.keyCode)<0&&(c=!0,Nr=null));let u=new Set,f=m=>{if(m){for(let O of m.run)if(!u.has(O)&&(u.add(O),O(t)))return m.stopPropagation&&(d=!0),!0;m.preventDefault&&(m.stopPropagation&&(d=!0),c=!0)}return!1},g=s[i],b,v;return g&&(f(g[o+Al(r,e,!a)])?l=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ee.windows&&e.ctrlKey&&e.altKey)&&!(Ee.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(b=Xr[e.keyCode])&&b!=r?(f(g[o+Al(b,e,!0)])||e.shiftKey&&(v=va[e.keyCode])!=r&&v!=b&&f(g[o+Al(v,e,!1)]))&&(l=!0):a&&e.shiftKey&&f(g[o+Al(r,e,!0)])&&(l=!0),!l&&f(g._any)&&(l=!0)),c&&(l=!0),l&&d&&e.stopPropagation(),zu=null,l}class Pn{constructor(e,t,i,r,n){this.className=e,this.left=t,this.top=i,this.width=r,this.height=n}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let n=Lv(e);return[new Pn(t,r.left-n.left,r.top-n.top,null,r.bottom-r.top)]}else return tC(e,t,i)}}function Lv(s){let e=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==jt.LTR?e.left:e.right-s.scrollDOM.clientWidth*s.scaleX)-s.scrollDOM.scrollLeft*s.scaleX,top:e.top-s.scrollDOM.scrollTop*s.scaleY}}function kg(s,e,t,i){let r=s.coordsAtPos(e,t*2);if(!r)return i;let n=s.dom.getBoundingClientRect(),a=(r.top+r.bottom)/2,o=s.posAtCoords({x:n.left+1,y:a}),l=s.posAtCoords({x:n.right-1,y:a});return o==null||l==null?i:{from:Math.max(i.from,Math.min(o,l)),to:Math.min(i.to,Math.max(o,l))}}function tC(s,e,t){if(t.to<=s.viewport.from||t.from>=s.viewport.to)return[];let i=Math.max(t.from,s.viewport.from),r=Math.min(t.to,s.viewport.to),n=s.textDirection==jt.LTR,a=s.contentDOM,o=a.getBoundingClientRect(),l=Lv(s),c=a.querySelector(".cm-line"),d=c&&window.getComputedStyle(c),u=o.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),f=o.right-(d?parseInt(d.paddingRight):0),g=Du(s,i,1),b=Du(s,r,-1),v=g.type==Os.Text?g:null,m=b.type==Os.Text?b:null;if(v&&(s.lineWrapping||g.widgetLineBreaks)&&(v=kg(s,i,1,v)),m&&(s.lineWrapping||b.widgetLineBreaks)&&(m=kg(s,r,-1,m)),v&&m&&v.from==m.from&&v.to==m.to)return p(x(t.from,t.to,v));{let _=v?x(t.from,null,v):y(g,!1),k=m?x(null,t.to,m):y(b,!0),w=[];return(v||g).to<(m||b).from-(v&&m?1:0)||g.widgetLineBreaks>1&&_.bottom+s.defaultLineHeight/2<k.top?w.push(O(u,_.bottom,f,k.top)):_.bottom<k.top&&s.elementAtHeight((_.bottom+k.top)/2).type==Os.Text&&(_.bottom=k.top=(_.bottom+k.top)/2),p(_).concat(w).concat(p(k))}function O(_,k,w,S){return new Pn(e,_-l.left,k-l.top,Math.max(0,w-_),S-k)}function p({top:_,bottom:k,horizontal:w}){let S=[];for(let Q=0;Q<w.length;Q+=2)S.push(O(w[Q],_,w[Q+1],k));return S}function x(_,k,w){let S=1e9,Q=-1e9,I=[];function D(B,F,V,Z,se){let T=s.coordsAtPos(B,B==w.to?-2:2),A=s.coordsAtPos(V,V==w.from?2:-2);!T||!A||(S=Math.min(T.top,A.top,S),Q=Math.max(T.bottom,A.bottom,Q),se==jt.LTR?I.push(n&&F?u:T.left,n&&Z?f:A.right):I.push(!n&&Z?u:A.left,!n&&F?f:T.right))}let $=_??w.from,j=k??w.to;for(let B of s.visibleRanges)if(B.to>$&&B.from<j)for(let F=Math.max(B.from,$),V=Math.min(B.to,j);;){let Z=s.state.doc.lineAt(F);for(let se of s.bidiSpans(Z)){let T=se.from+Z.from,A=se.to+Z.from;if(T>=V)break;A>F&&D(Math.max(T,F),_==null&&T<=$,Math.min(A,V),k==null&&A>=j,se.dir)}if(F=Z.to+1,F>=V)break}return I.length==0&&D($,_==null,j,k==null,s.textDirection),{top:S,bottom:Q,horizontal:I}}function y(_,k){let w=o.top+(k?_.top:_.bottom);return{top:w,bottom:w,horizontal:[]}}}function sC(s,e){return s.constructor==e.constructor&&s.eq(e)}class iC{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(rc)!=e.state.facet(rc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(rc);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!sC(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,Ee.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const rc=Ae.define();function Nv(s){return[zt.define(e=>new iC(e,s)),rc.of(s)]}const go=Ae.define({combine(s){return Ki(s,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function rC(s={}){return[go.of(s),nC,oC,lC,cv.of(!0)]}function Dv(s){return s.startState.facet(go)!=s.state.facet(go)}const nC=Nv({above:!0,markers(s){let{state:e}=s,t=e.facet(go),i=[];for(let r of e.selection.ranges){let n=r==e.selection.main;if(r.empty||t.drawRangeCursor&&!(n&&Ee.ios&&t.iosSelectionHandles)){let a=n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=r.empty?r:re.cursor(r.head,r.assoc);for(let l of Pn.forRange(s,a,o))i.push(l)}}return i},update(s,e){s.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Dv(s);return t&&Cg(s.state,e),s.docChanged||s.selectionSet||t},mount(s,e){Cg(e.state,s)},class:"cm-cursorLayer"});function Cg(s,e){e.style.animationDuration=s.facet(go).cursorBlinkRate+"ms"}const oC=Nv({above:!1,markers(s){let e=[],{main:t,ranges:i}=s.state.selection;for(let r of i)if(!r.empty)for(let n of Pn.forRange(s,"cm-selectionBackground",r))e.push(n);if(Ee.ios&&!t.empty&&s.state.facet(go).iosSelectionHandles){for(let r of Pn.forRange(s,"cm-selectionHandle cm-selectionHandle-start",re.cursor(t.from,1)))e.push(r);for(let r of Pn.forRange(s,"cm-selectionHandle cm-selectionHandle-end",re.cursor(t.to,1)))e.push(r)}return e},update(s,e){return s.docChanged||s.selectionSet||s.viewportChanged||Dv(s)},class:"cm-selectionLayer"}),aC=Ee.gecko&&Ee.gecko_version>=153?"#ffffff01":"transparent",lC=kr.highest(_e.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${aC} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Iv=nt.define({map(s,e){return s==null?null:e.mapPos(s)}}),ra=xs.define({create(){return null},update(s,e){return s!=null&&(s=e.changes.mapPos(s)),e.effects.reduce((t,i)=>i.is(Iv)?i.value:t,s)}}),cC=zt.fromClass(class{constructor(s){this.view=s,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(s){var e;let t=s.state.field(ra);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(s.startState.field(ra)!=t||s.docChanged||s.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:s}=this,e=s.state.field(ra),t=e!=null&&s.coordsAtPos(e);if(!t)return null;let i=s.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+s.scrollDOM.scrollLeft*s.scaleX,top:t.top-i.top+s.scrollDOM.scrollTop*s.scaleY,height:t.bottom-t.top}}drawCursor(s){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;s?(this.cursor.style.left=s.left/e+"px",this.cursor.style.top=s.top/t+"px",this.cursor.style.height=s.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(s){this.view.state.field(ra)!=s&&this.view.dispatch({effects:Iv.of(s)})}},{eventObservers:{dragover(s){this.setDropPos(this.view.posAtCoords({x:s.clientX,y:s.clientY}))},dragleave(s){(s.target==this.view.contentDOM||!this.view.contentDOM.contains(s.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function hC(){return[ra,cC]}function Pg(s,e,t,i,r){e.lastIndex=0;for(let n=s.iterRange(t,i),a=t,o;!n.next().done;a+=n.value.length)if(!n.lineBreak)for(;o=e.exec(n.value);)r(a+o.index,o)}function dC(s,e){let t=s.visibleRanges;if(t.length==1&&t[0].from==s.viewport.from&&t[0].to==s.viewport.to)return t;let i=[];for(let{from:r,to:n}of t)r=Math.max(s.state.doc.lineAt(r).from,r-e),n=Math.min(s.state.doc.lineAt(n).to,n+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=n:i.push({from:r,to:n});return i}class uC{constructor(e){const{regexp:t,decoration:i,decorate:r,boundary:n,maxLength:a=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(o,l,c,d)=>r(d,c,c+o[0].length,o,l);else if(typeof i=="function")this.addMatch=(o,l,c,d)=>{let u=i(o,l,c);u&&d(c,c+o[0].length,u)};else if(i)this.addMatch=(o,l,c,d)=>d(c,c+o[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=n,this.maxLength=a}createDeco(e){let t=new br,i=t.add.bind(t);for(let{from:r,to:n}of dC(e,this.maxLength))Pg(e.state.doc,this.regexp,r,n,(a,o)=>this.addMatch(o,e,a,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((n,a,o,l)=>{l>=e.view.viewport.from&&o<=e.view.viewport.to&&(i=Math.min(o,i),r=Math.max(l,r))}),e.viewportMoved||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let n of e.visibleRanges){let a=Math.max(n.from,i),o=Math.min(n.to,r);if(o>=a){let l=e.state.doc.lineAt(a),c=l.to<o?e.state.doc.lineAt(o):l,d=Math.max(n.from,l.from),u=Math.min(n.to,c.to);if(this.boundary){for(;a>l.from;a--)if(this.boundary.test(l.text[a-1-l.from])){d=a;break}for(;o<c.to;o++)if(this.boundary.test(c.text[o-c.from])){u=o;break}}let f=[],g,b=(v,m,O)=>f.push(O.range(v,m));if(l==c)for(this.regexp.lastIndex=d-l.from;(g=this.regexp.exec(l.text))&&g.index<u-l.from;)this.addMatch(g,e,g.index+l.from,b);else Pg(e.state.doc,this.regexp,d,u,(v,m)=>this.addMatch(m,e,v,b));t=t.update({filterFrom:d,filterTo:u,filter:(v,m)=>v<d||m>u,add:f})}}return t}}const Zu=/x/.unicode!=null?"gu":"g",fC=new RegExp(`[\0-\b
|
|
15
|
-
--\u2028\u2029\uFEFF-]`,Zu),pC={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let fd=null;function mC(){var s;if(fd==null&&typeof document<"u"&&document.body){let e=document.body.style;fd=((s=e.tabSize)!==null&&s!==void 0?s:e.MozTabSize)!=null}return fd||!1}const nc=Ae.define({combine(s){let e=Ki(s,{render:null,specialChars:fC,addSpecialChars:null});return(e.replaceTabs=!mC())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Zu)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Zu)),e}});function gC(s={}){return[nc.of(s),OC()]}let Tg=null;function OC(){return Tg||(Tg=zt.fromClass(class{constructor(s){this.view=s,this.decorations=ze.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(s.state.facet(nc)),this.decorations=this.decorator.createDeco(s)}makeDecorator(s){return new uC({regexp:s.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,n=Is(e[0],0);if(n==9){let a=r.lineAt(i),o=t.state.tabSize,l=ki(a.text,o,i-a.from);return ze.replace({widget:new yC((o-l%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[n]||(this.decorationCache[n]=ze.replace({widget:new bC(s,n)}))},boundary:s.replaceTabs?void 0:/[^]/})}update(s){let e=s.state.facet(nc);s.startState.facet(nc)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(s.view)):this.decorations=this.decorator.updateDeco(s,this.decorations)}},{decorations:s=>s.decorations}))}const xC="•";function vC(s){return s>=32?xC:s==10?"":String.fromCharCode(9216+s)}class bC extends Pi{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=vC(this.code),i=e.state.phrase("Control character")+" "+(pC[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let n=document.createElement("span");return n.textContent=t,n.title=i,n.setAttribute("aria-label",i),n.className="cm-specialChar",n}ignoreEvent(){return!1}}class yC extends Pi{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function SC(){return wC}const _C=ze.line({class:"cm-activeLine"}),wC=zt.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.docChanged||s.selectionSet)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=-1,t=[];for(let i of s.state.selection.ranges){let r=s.lineBlockAt(i.head);r.from>e&&(t.push(_C.range(r.from)),e=r.from)}return ze.set(t)}},{decorations:s=>s.decorations});class kC extends Pi{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?ca(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=Sa(t[0],i.direction!="rtl"),n=parseInt(i.lineHeight);return r.bottom-r.top>n*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+n}:r}ignoreEvent(){return!1}}function CC(s){let e=zt.fromClass(class{constructor(t){this.view=t,this.placeholder=s?ze.set([ze.widget({widget:new kC(s),side:1}).range(0)]):ze.none}get decorations(){return this.view.state.doc.length?ze.none:this.placeholder}},{decorations:t=>t.decorations});return typeof s=="string"?[e,_e.contentAttributes.of({"aria-placeholder":s})]:e}const Vu=2e3;function PC(s,e,t){let i=Math.min(e.line,t.line),r=Math.max(e.line,t.line),n=[];if(e.off>Vu||t.off>Vu||e.col<0||t.col<0){let a=Math.min(e.off,t.off),o=Math.max(e.off,t.off);for(let l=i;l<=r;l++){let c=s.doc.line(l);c.length<=o&&n.push(re.range(c.from+a,c.to+o))}}else{let a=Math.min(e.col,t.col),o=Math.max(e.col,t.col);for(let l=i;l<=r;l++){let c=s.doc.line(l),d=ku(c.text,a,s.tabSize,!0);if(d<0)n.push(re.cursor(c.to));else{let u=ku(c.text,o,s.tabSize);n.push(re.range(c.from+d,c.from+u))}}}return n}function TC(s,e){let t=s.coordsAtPos(s.viewport.from);return t?Math.round(Math.abs((t.left-e)/s.defaultCharacterWidth)):-1}function Qg(s,e){let t=s.posAtCoords({x:e.clientX,y:e.clientY},!1),i=s.state.doc.lineAt(t),r=t-i.from,n=r>Vu?-1:r==i.length?TC(s,e.clientX):ki(i.text,s.state.tabSize,t-i.from);return{line:i.number,col:n,off:r}}function QC(s,e){let t=Qg(s,e),i=s.state.selection;return t?{update(r){if(r.docChanged){let n=r.changes.mapPos(r.startState.doc.line(t.line).from),a=r.state.doc.lineAt(n);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},i=i.map(r.changes)}},get(r,n,a){let o=Qg(s,r);if(!o)return i;let l=PC(s.state,t,o);return l.length?a?re.create(l.concat(i.ranges)):re.create(l):i}}:null}function $C(s){let e=(t=>t.altKey&&t.button==0);return _e.mouseSelectionStyle.of((t,i)=>e(i)?QC(t,i):null)}const jC={Alt:[18,s=>!!s.altKey],Control:[17,s=>!!s.ctrlKey],Shift:[16,s=>!!s.shiftKey],Meta:[91,s=>!!s.metaKey]},EC={style:"cursor: crosshair"};function RC(s={}){let[e,t]=jC[s.key||"Alt"],i=zt.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[i,_e.contentAttributes.of(r=>{var n;return!((n=r.plugin(i))===null||n===void 0)&&n.isDown?EC:null})]}const Ml="-10000px";class Bv{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let n=null;this.tooltipViews=this.tooltips.map(a=>n=i(a,n))}update(e,t){var i;let r=e.state.facet(this.facet),n=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let a=[],o=t?[]:null;for(let l=0;l<n.length;l++){let c=n[l],d=-1;if(c){for(let u=0;u<this.tooltips.length;u++){let f=this.tooltips[u];f&&f.create==c.create&&(d=u)}if(d<0)a[l]=this.createTooltipView(c,l?a[l-1]:null),o&&(o[l]=!!c.above);else{let u=a[l]=this.tooltipViews[d];o&&(o[l]=t[d]),u.update&&u.update(e)}}}for(let l of this.tooltipViews)a.indexOf(l)<0&&(this.removeTooltipView(l),(i=l.destroy)===null||i===void 0||i.call(l));return t&&(o.forEach((l,c)=>t[c]=l),t.length=o.length),this.input=r,this.tooltips=n,this.tooltipViews=a,!0}}function AC(s){let e=s.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const pd=Ae.define({combine:s=>{var e,t,i;return{position:Ee.ios?"absolute":((e=s.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=s.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=s.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||AC}}}),$g=new WeakMap,Wf=zt.fromClass(class{constructor(s){this.view=s,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=s.state.facet(pd);this.position=e.position,this.parent=e.parent,this.classes=s.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Bv(s,Xf,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),s.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let s of this.manager.tooltipViews)this.intersectionObserver.observe(s.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(s){s.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(s,this.above);e&&this.observeIntersection();let t=e||s.geometryChanged,i=s.state.facet(pd);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(s,e){let t=s.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),s.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=Ml,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var s,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(s=i.destroy)===null||s===void 0||s.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let s=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:n}=this.manager.tooltipViews[0];if(Ee.safari){let a=n.getBoundingClientRect();t=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}else t=!!n.offsetParent&&n.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(s=n.width/this.parent.offsetWidth,e=n.height/this.parent.offsetHeight)}else({scaleX:s,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=Nf(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((n,a)=>{let o=this.manager.tooltipViews[a];return o.getCoords?o.getCoords(n.pos):this.view.coordsAtPos(n.pos)}),size:this.manager.tooltipViews.map(({dom:n})=>n.getBoundingClientRect()),space:this.view.state.facet(pd).tooltipSpace(this.view),scaleX:s,scaleY:e,makeAbsolute:t}}writeMeasure(s){var e;if(s.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:t,space:i,scaleX:r,scaleY:n}=s,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let l=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:d}=c,u=s.pos[o],f=s.size[o];if(!u||l.clip!==!1&&(u.bottom<=Math.max(t.top,i.top)||u.top>=Math.min(t.bottom,i.bottom)||u.right<Math.max(t.left,i.left)-.1||u.left>Math.min(t.right,i.right)+.1)){d.style.top=Ml;continue}let g=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,b=g?7:0,v=f.right-f.left,m=(e=$g.get(c))!==null&&e!==void 0?e:f.bottom-f.top,O=c.offset||LC,p=this.view.textDirection==jt.LTR,x=f.width>i.right-i.left?p?i.left:i.right-f.width:p?Math.max(i.left,Math.min(u.left-(g?14:0)+O.x,i.right-v)):Math.min(Math.max(i.left,u.left-v+(g?14:0)-O.x),i.right-v),y=this.above[o];!l.strictSide&&(y?u.top-m-b-O.y<i.top:u.bottom+m+b+O.y>i.bottom)&&y==i.bottom-u.bottom>u.top-i.top&&(y=this.above[o]=!y);let _=(y?u.top-i.top:i.bottom-u.bottom)-b;if(_<m&&c.resize!==!1){if(_<this.view.defaultLineHeight){d.style.top=Ml;continue}$g.set(c,m),d.style.height=(m=_)/n+"px"}else d.style.height&&(d.style.height="");let k=y?u.top-m-b-O.y:u.bottom+b+O.y,w=x+v;if(c.overlap!==!0)for(let S of a)S.left<w&&S.right>x&&S.top<k+m&&S.bottom>k&&(k=y?S.top-m-2-b:S.bottom+b+2);if(this.position=="absolute"?(d.style.top=(k-s.parent.top)/n+"px",jg(d,(x-s.parent.left)/r)):(d.style.top=k/n+"px",jg(d,x/r)),g){let S=u.left+(p?O.x:-O.x)-(x+14-7);g.style.left=S/r+"px"}c.overlap!==!0&&a.push({left:x,top:k,right:w,bottom:k+m}),d.classList.toggle("cm-tooltip-above",y),d.classList.toggle("cm-tooltip-below",!y),c.positioned&&c.positioned(s.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let s of this.manager.tooltipViews)s.dom.style.top=Ml}},{eventObservers:{scroll(){this.maybeMeasure()}}});function jg(s,e){let t=parseInt(s.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(s.style.left=e+"px")}const MC=_e.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),LC={x:0,y:0},Xf=Ae.define({enables:[Wf,MC]}),Tc=Ae.define({combine:s=>s.reduce((e,t)=>e.concat(t),[])});class rh{static create(e){return new rh(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Bv(e,Tc,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const NC=Xf.compute([Tc],s=>{let e=s.facet(Tc);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:rh.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Wv=Ae.define();class DC{constructor(e,t,i,r,n,a){this.view=e,this.source=t,this.field=i,this.locked=r,this.setHover=n,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let r,n=1;if(i.isWidget())r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let a=e.coordsAtPos(r);if(!a||t.y<a.top||t.y>a.bottom||t.x<a.left-e.defaultCharacterWidth||t.x>a.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),l=o&&o.dir==jt.RTL?-1:1;n=t.x<a.left?-l:l}this.activateHover(e,r,n)}activateHover(e,t,i,r){let n=this.source(e,t,i),a=o=>{if(o&&!(Array.isArray(o)&&!o.length)){let l=Array.isArray(o)?o:[o];r&&this.locked.set(l,r),e.dispatch({effects:this.setHover.of(l)})}};if(n&&"then"in n){let o=this.pending={pos:t};n.then(l=>{this.pending==o&&(this.pending=null,a(l))},l=>Xs(e.state,l,"hover tooltip"))}else a(n)}get tooltip(){let e=this.view.plugin(Wf),t=e?e.manager.tooltips.findIndex(i=>i.create==rh.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:n}=this;if(r.length&&!this.locked.has(r)&&n&&!IC(n.dom,e)||this.pending){let{pos:a}=r[0]||this.pending,o=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:a;(a==o?this.view.posAtCoords(this.lastMove)!=a:!BC(this.view,a,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Ll=4;function IC(s,e){let{left:t,right:i,top:r,bottom:n}=s.getBoundingClientRect(),a;if(a=s.querySelector(".cm-tooltip-arrow")){let o=a.getBoundingClientRect();r=Math.min(o.top,r),n=Math.max(o.bottom,n)}return e.clientX>=t-Ll&&e.clientX<=i+Ll&&e.clientY>=r-Ll&&e.clientY<=n+Ll}function BC(s,e,t,i,r,n){let a=s.scrollDOM.getBoundingClientRect(),o=s.documentTop+s.documentPadding.top+s.contentHeight;if(a.left>i||a.right<i||a.top>r||Math.min(a.bottom,o)<r)return!1;let l=s.posAtCoords({x:i,y:r},!1);return l>=e&&l<=t}function WC(s,e={}){let t=nt.define(),i=new WeakMap,r=xs.define({create(){return[]},update(a,o){let l=i.get(a);if(a.length&&(e.hideOnChange&&(o.docChanged||o.selection)?a=[]:l&&l(o)?a=[]:e.hideOn&&(a=a.filter(c=>!e.hideOn(o,c)))),o.docChanged&&a.length){let c=[];for(let d of a){let u=o.changes.mapPos(d.pos,-1,gs.TrackDel);if(u!=null){let f=Object.assign(Object.create(null),d);f.pos=u,f.end!=null&&(f.end=o.changes.mapPos(f.end)),c.push(f)}}a=c}for(let c of o.effects)c.is(t)&&(a=c.value,l=void 0),(c.is(qC)&&!c.value||c.value==r)&&(a=[]);return a.length&&l&&i.set(a,l),a},provide:a=>Tc.from(a)});const n=zt.define(a=>new DC(a,s,r,i,t,e.hoverTime||300));return{active:r,extension:[r,n,Wv.of(n),NC]}}function XC(s,e,t,i={}){var r;let n=s.state.facet(Wv).map(a=>s.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=n.find(o=>o.field==i.tooltip.active);a&&(n=[a])}for(let a of n)a.activateHover(s,e,t,(r=i.until)!==null&&r!==void 0?r:(()=>!1))}function Xv(s,e){let t=s.plugin(Wf);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const qC=nt.define(),Eg=Ae.define({combine(s){let e,t;for(let i of s)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function qf(s,e){let t=s.plugin(qv),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const qv=zt.fromClass(class{constructor(s){this.input=s.state.facet(wa),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(s));let e=s.state.facet(Eg);this.top=new Nl(s,!0,e.topContainer),this.bottom=new Nl(s,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(s){let e=s.state.facet(Eg);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Nl(s.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Nl(s.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=s.state.facet(wa);if(t!=this.input){let i=t.filter(l=>l),r=[],n=[],a=[],o=[];for(let l of i){let c=this.specs.indexOf(l),d;c<0?(d=l(s.view),o.push(d)):(d=this.panels[c],d.update&&d.update(s)),r.push(d),(d.top?n:a).push(d)}this.specs=i,this.panels=r,this.top.sync(n),this.bottom.sync(a);for(let l of o)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(s)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:s=>_e.scrollMargins.of(e=>{let t=e.plugin(s);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Nl{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Rg(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Rg(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Rg(s){let e=s.nextSibling;return s.remove(),e}const wa=Ae.define({enables:qv});function zC(s,e){let t,i=new Promise(a=>t=a),r=a=>ZC(a,e,t);s.state.field(md,!1)?s.dispatch({effects:zv.of(r)}):s.dispatch({effects:nt.appendConfig.of(md.init(()=>[r]))});let n=Zv.of(r);return{close:n,result:i.then(a=>((s.win.queueMicrotask||(l=>s.win.setTimeout(l,10)))(()=>{s.state.field(md).indexOf(r)>-1&&s.dispatch({effects:n})}),a))}}const md=xs.define({create(){return[]},update(s,e){for(let t of e.effects)t.is(zv)?s=[t.value].concat(s):t.is(Zv)&&(s=s.filter(i=>i!=t.value));return s},provide:s=>wa.computeN([s],e=>e.field(s))}),zv=nt.define(),Zv=nt.define();function ZC(s,e,t){let i=e.content?e.content(s,()=>a(null)):null;if(!i){if(i=Tt("form"),e.input){let o=Tt("input",e.input);/^(text|password|number|email|tel|url)$/.test(o.type)&&o.classList.add("cm-textfield"),o.name||(o.name="input"),i.appendChild(Tt("label",(e.label||"")+": ",o))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Tt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let o=0;o<r.length;o++){let l=r[o];l.addEventListener("keydown",c=>{c.keyCode==27?(c.preventDefault(),a(null)):c.keyCode==13&&(c.preventDefault(),a(l))}),l.addEventListener("submit",c=>{c.preventDefault(),a(l)})}let n=Tt("div",i,Tt("button",{onclick:()=>a(null),"aria-label":s.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(n.className=e.class),n.classList.add("cm-dialog");function a(o){n.contains(n.ownerDocument.activeElement)&&s.focus(),t(o)}return{dom:n,top:e.top,mount:()=>{if(e.focus){let o;typeof e.focus=="string"?o=i.querySelector(e.focus):o=i.querySelector("input")||i.querySelector("button"),o&&"select"in o?o.select():o&&"focus"in o&&o.focus()}}}}class Sr extends Br{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Sr.prototype.elementClass="";Sr.prototype.toDOM=void 0;Sr.prototype.mapMode=gs.TrackBefore;Sr.prototype.startSide=Sr.prototype.endSide=-1;Sr.prototype.point=!0;const oc=Ae.define(),VC=Ae.define(),FC={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ft.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},ua=Ae.define();function YC(s){return[Vv(),ua.of({...FC,...s})]}const Ag=Ae.define({combine:s=>s.some(e=>e)});function Vv(s){return[UC]}const UC=zt.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=s.state.facet(ua).map(e=>new Lg(s,e)),this.fixed=!s.state.facet(Ag);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),s.scrollDOM.insertBefore(this.dom,s.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(s){if(this.updateGutters(s)){let e=this.prevViewport,t=s.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(s.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ag)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let e=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=ft.iter(this.view.state.facet(oc),this.view.viewport.from),i=[],r=this.gutters.map(n=>new HC(n,this.view.viewport,-this.view.documentPadding.top));for(let n of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(n.type)){let a=!0;for(let o of n.type)if(o.type==Os.Text&&a){Fu(t,i,o.from);for(let l of r)l.line(this.view,o,i);a=!1}else if(o.widget)for(let l of r)l.widget(this.view,o)}else if(n.type==Os.Text){Fu(t,i,n.from);for(let a of r)a.line(this.view,n,i)}else if(n.widget)for(let a of r)a.widget(this.view,n);for(let n of r)n.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let e=s.startState.facet(ua),t=s.state.facet(ua),i=s.docChanged||s.heightChanged||s.viewportChanged||!ft.eq(s.startState.facet(oc),s.state.facet(oc),s.view.viewport.from,s.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(s)&&(i=!0);else{i=!0;let r=[];for(let n of t){let a=e.indexOf(n);a<0?r.push(new Lg(this.view,n)):(this.gutters[a].update(s),r.push(this.gutters[a]))}for(let n of this.gutters)n.dom.remove(),r.indexOf(n)<0&&n.destroy();for(let n of r)n.config.side=="after"?this.getDOMAfter().appendChild(n.dom):this.dom.appendChild(n.dom);this.gutters=r}return i}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>_e.scrollMargins.of(e=>{let t=e.plugin(s);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==jt.LTR?{left:i,right:r}:{right:i,left:r}})});function Mg(s){return Array.isArray(s)?s:[s]}function Fu(s,e,t){for(;s.value&&s.from<=t;)s.from==t&&e.push(s.value),s.next()}class HC{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ft.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,n=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let o=new Fv(e,a,n,i);r.elements.push(o),r.dom.appendChild(o.dom)}else r.elements[this.i].update(e,a,n,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Fu(this.cursor,r,t.from),i.length&&(r=r.concat(i));let n=this.gutter.config.lineMarker(e,t,r);n&&r.unshift(n);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),r=i?[i]:null;for(let n of e.state.facet(VC)){let a=n(e,t.widget,t);a&&(r||(r=[])).push(a)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Lg{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let n=r.target,a;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let l=n.getBoundingClientRect();a=(l.top+l.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[i](e,o,r)&&r.preventDefault()});this.markers=Mg(t.markers(e)),t.initialSpacer&&(this.spacer=new Fv(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Mg(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!ft.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Fv{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),GC(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let n=0,a=0;;){let o=a,l=n<t.length?t[n++]:null,c=!1;if(l){let d=l.elementClass;d&&(i+=" "+d);for(let u=a;u<this.markers.length;u++)if(this.markers[u].compare(l)){o=u,c=!0;break}}else o=this.markers.length;for(;a<o;){let d=this.markers[a++];if(d.toDOM){d.destroy(r);let u=r.nextSibling;r.remove(),r=u}}if(!l)break;l.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(l.toDOM(e),r)),c&&a++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function GC(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(!s[t].compare(e[t]))return!1;return!0}const KC=Ae.define(),JC=Ae.define(),Jn=Ae.define({combine(s){return Ki(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let n=i[r],a=t[r];i[r]=n?(o,l,c)=>n(o,l,c)||a(o,l,c):a}return i}})}});class gd extends Sr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Od(s,e){return s.state.facet(Jn).formatNumber(e,s.state)}const e2=ua.compute([Jn],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(KC)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new gd(Od(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let r of e.state.facet(JC)){let n=r(e,t,i);if(n)return n}return null},lineMarkerChange:e=>e.startState.facet(Jn)!=e.state.facet(Jn),initialSpacer(e){return new gd(Od(e,Ng(e.state.doc.lines)))},updateSpacer(e,t){let i=Od(t.view,Ng(t.view.state.doc.lines));return i==e.number?e:new gd(i)},domEventHandlers:s.facet(Jn).domEventHandlers,side:"before"}));function t2(s={}){return[Jn.of(s),Vv(),e2]}function Ng(s){let e=9;for(;e<s;)e=e*10+9;return e}const s2=new class extends Sr{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},i2=oc.compute(["selection"],s=>{let e=[],t=-1;for(let i of s.selection.ranges){let r=s.doc.lineAt(i.head).from;r>t&&(t=r,e.push(s2.range(r)))}return ft.of(e)});function r2(){return i2}const Yv=1024;let n2=0;class ui{constructor(e,t){this.from=e,this.to=t}}class ot{constructor(e={}){this.id=n2++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=es.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}ot.closedBy=new ot({deserialize:s=>s.split(" ")});ot.openedBy=new ot({deserialize:s=>s.split(" ")});ot.group=new ot({deserialize:s=>s.split(" ")});ot.isolate=new ot({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});ot.contextHash=new ot({perNode:!0});ot.lookAhead=new ot({perNode:!0});ot.mounted=new ot({perNode:!0});class oo{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[ot.mounted.id]}}const o2=Object.create(null);class es{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):o2,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new es(e.name||"",t,e.id,i);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(ot.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(ot.group),n=-1;n<(r?r.length:0);n++){let a=t[n<0?i.name:r[n]];if(a)return a}}}}es.none=new es("",Object.create(null),0,8);class Za{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let n of e){let a=n(i);if(a){r||(r=Object.assign({},i.props));let o=a[1],l=a[0];l.combine&&l.id in r&&(o=l.combine(r[l.id],o)),r[l.id]=o}}t.push(r?new es(i.name,r,i.id,i.flags):i)}return new Za(t)}}const Dl=new WeakMap,Dg=new WeakMap;var _t;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(_t||(_t={}));class wt{constructor(e,t,i,r,n){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,n&&n.length){this.props=Object.create(null);for(let[a,o]of n)this.props[typeof a=="number"?a:a.id]=o}}toString(){let e=oo.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Qc(this.topNode,e)}cursorAt(e,t=0,i=0){let r=Dl.get(this)||this.topNode,n=new Qc(r);return n.moveTo(e,t),Dl.set(this,n._tree),n}get topNode(){return new ks(this,0,0,null)}resolve(e,t=0){let i=ka(Dl.get(this)||this.topNode,e,t,!1);return Dl.set(this,i),i}resolveInner(e,t=0){let i=ka(Dg.get(this)||this.topNode,e,t,!0);return Dg.set(this,i),i}resolveStack(e,t=0){return c2(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:n=this.length}=e,a=e.mode||0,o=(a&_t.IncludeAnonymous)>0;for(let l=this.cursor(a|_t.IncludeAnonymous);;){let c=!1;if(l.from<=n&&l.to>=r&&(!o&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&i&&(o||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Vf(es.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new wt(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new wt(es.none,t,i,r)))}static build(e){return h2(e)}}wt.empty=new wt(es.none,[],[],0);class zf{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new zf(this.buffer,this.index)}}class zr{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return es.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],n=r.name;if(/\W/.test(n)&&!r.isError&&(n=JSON.stringify(n)),e+=4,i==e)return n;let a=[];for(;e<i;)a.push(this.childString(e)),e=this.buffer[e+3];return n+"("+a.join(",")+")"}findChild(e,t,i,r,n){let{buffer:a}=this,o=-1;for(let l=e;l!=t&&!(Uv(n,r,a[l+1],a[l+2])&&(o=l,i>0));l=a[l+3]);return o}slice(e,t,i){let r=this.buffer,n=new Uint16Array(t-e),a=0;for(let o=e,l=0;o<t;){n[l++]=r[o++],n[l++]=r[o++]-i;let c=n[l++]=r[o++]-i;n[l++]=r[o++]-e,a=Math.max(a,c)}return new zr(n,a,this.set)}}function Uv(s,e,t,i){switch(s){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function ka(s,e,t,i){for(var r;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to<e);){let a=!i&&s instanceof ks&&s.index<0?null:s.parent;if(!a)return s;s=a}let n=i?0:_t.IgnoreOverlays;if(i)for(let a=s,o=a.parent;o;a=o,o=a.parent)a instanceof ks&&a.index<0&&((r=o.enter(e,t,n))===null||r===void 0?void 0:r.from)!=a.from&&(s=o);for(;;){let a=s.enter(e,t,n);if(!a)return s;s=a}}class Hv{cursor(e=0){return new Qc(this,e)}getChild(e,t=null,i=null){let r=Ig(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Ig(this,e,t,i)}resolve(e,t=0){return ka(this,e,t,!1)}resolveInner(e,t=0){return ka(this,e,t,!0)}matchContext(e){return Yu(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}}class ks extends Hv{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,n=0){for(let a=this;;){for(let{children:o,positions:l}=a._tree,c=t>0?o.length:-1;e!=c;e+=t){let d=o[e],u=l[e]+a.from,f;if(!(!(n&_t.EnterBracketed&&d instanceof wt&&(f=oo.get(d))&&!f.overlay&&f.bracketed&&i>=u&&i<=u+d.length)&&!Uv(r,i,u,u+d.length))){if(d instanceof zr){if(n&_t.ExcludeBuffers)continue;let g=d.findChild(0,d.buffer.length,t,i-u,r);if(g>-1)return new Vi(new a2(a,d,e,u),null,g)}else if(n&_t.IncludeAnonymous||!d.type.isAnonymous||Zf(d)){let g;if(!(n&_t.IgnoreMounts)&&(g=oo.get(d))&&!g.overlay)return new ks(g.tree,u,e,a);let b=new ks(d,u,e,a);return n&_t.IncludeAnonymous||!b.type.isAnonymous?b:b.nextChild(t<0?d.children.length-1:0,t,i,r,n)}}}if(n&_t.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&_t.IgnoreOverlays)&&(r=oo.get(this._tree))&&r.overlay){let n=e-this.from,a=i&_t.EnterBracketed&&r.bracketed;for(let{from:o,to:l}of r.overlay)if((t>0||a?o<=n:o<n)&&(t<0||a?l>=n:l>n))return new ks(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Ig(s,e,t,i){let r=s.cursor(),n=[];if(!r.firstChild())return n;if(t!=null){for(let a=!1;!a;)if(a=r.type.is(t),!r.nextSibling())return n}for(;;){if(i!=null&&r.type.is(i))return n;if(r.type.is(e)&&n.push(r.node),!r.nextSibling())return i==null?n:[]}}function Yu(s,e,t=e.length-1){for(let i=s;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class a2{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}}class Vi extends Hv{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return n<0?null:new Vi(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&_t.ExcludeBuffers)return null;let{buffer:r}=this.context,n=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new Vi(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vi(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Vi(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,n=i.buffer[this.index+3];if(n>r){let a=i.buffer[this.index+1];e.push(i.slice(r,n,a)),t.push(0)}return new wt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Gv(s){if(!s.length)return null;let e=0,t=s[0];for(let n=1;n<s.length;n++){let a=s[n];(a.from>t.from||a.to<t.to)&&(t=a,e=n)}let i=t instanceof ks&&t.index<0?null:t.parent,r=s.slice();return i?r[e]=i:r.splice(e,1),new l2(r,t)}class l2{constructor(e,t){this.heads=e,this.node=t}get next(){return Gv(this.heads)}}function c2(s,e,t){let i=s.resolveInner(e,t),r=null;for(let n=i instanceof ks?i:i.context.parent;n;n=n.parent)if(n.index<0){let a=n.parent;(r||(r=[i])).push(a.resolve(e,t)),n=a}else{let a=oo.get(n.tree);if(a&&a.overlay&&a.overlay[0].from<=e&&a.overlay[a.overlay.length-1].to>=e){let o=new ks(a.tree,a.overlay[0].from+n.from,-1,n);(r||(r=[i])).push(ka(o,e,t,!1))}}return r?Gv(r):i}class Qc{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~_t.EnterBracketed,e instanceof ks)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof ks?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,n=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return n<0?!1:(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&_t.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&_t.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&_t.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(r.buffer.buffer[n+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let n=t+e,a=e<0?-1:i._tree.children.length;n!=a;n+=e){let o=i._tree.children[n];if(this.mode&_t.IncludeAnonymous||o instanceof zr||!o.type.isAnonymous||Zf(o))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,n=this.stack.length;n>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,i=n+1;break e}r=this.stack[--n]}for(let r=i;r<this.stack.length;r++)t=new Vi(this.buffer,t,this.stack[r]);return this.bufferNode=new Vi(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Yu(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,n=this.stack.length-1;r>=0;n--){if(n<0)return Yu(this._tree,e,r);let a=i[t.buffer[this.stack[n]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}}function Zf(s){return s.children.some(e=>e instanceof zr||!e.type.isAnonymous||Zf(e))}function h2(s){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=Yv,reused:n=[],minRepeatType:a=i.types.length}=s,o=Array.isArray(t)?new zf(t,t.length):t,l=i.types,c=0,d=0;function u(_,k,w,S,Q,I){let{id:D,start:$,end:j,size:B}=o,F=d,V=c;if(B<0)if(o.next(),B==-1){let N=n[D];w.push(N),S.push($-_);return}else if(B==-3){c=D;return}else if(B==-4){d=D;return}else throw new RangeError(`Unrecognized record size: ${B}`);let Z=l[D],se,T,A=$-_;if(j-$<=r&&(T=m(o.pos-k,Q))){let N=new Uint16Array(T.size-T.skip),z=o.pos-T.size,U=N.length;for(;o.pos>z;)U=O(T.start,N,U);se=new zr(N,j-T.start,i),A=T.start-_}else{let N=o.pos-B;o.next();let z=[],U=[],ne=D>=a?D:-1,Se=0,Pe=j;for(;o.pos>N;)ne>=0&&o.id==ne&&o.size>=0?(o.end<=Pe-r&&(b(z,U,$,Se,o.end,Pe,ne,F,V),Se=z.length,Pe=o.end),o.next()):I>2500?f($,N,z,U):u($,N,z,U,ne,I+1);if(ne>=0&&Se>0&&Se<z.length&&b(z,U,$,Se,$,Pe,ne,F,V),z.reverse(),U.reverse(),ne>-1&&Se>0){let X=g(Z,V);se=Vf(Z,z,U,0,z.length,0,j-$,X,X)}else se=v(Z,z,U,j-$,F-j,V)}w.push(se),S.push(A)}function f(_,k,w,S){let Q=[],I=0,D=-1;for(;o.pos>k;){let{id:$,start:j,end:B,size:F}=o;if(F>4)o.next();else{if(D>-1&&j<D)break;D<0&&(D=B-r),Q.push($,j,B),I++,o.next()}}if(I){let $=new Uint16Array(I*4),j=Q[Q.length-2];for(let B=Q.length-3,F=0;B>=0;B-=3)$[F++]=Q[B],$[F++]=Q[B+1]-j,$[F++]=Q[B+2]-j,$[F++]=F;w.push(new zr($,Q[2]-j,i)),S.push(j-_)}}function g(_,k){return(w,S,Q)=>{let I=0,D=w.length-1,$,j;if(D>=0&&($=w[D])instanceof wt){if(!D&&$.type==_&&$.length==Q)return $;(j=$.prop(ot.lookAhead))&&(I=S[D]+$.length+j)}return v(_,w,S,Q,I,k)}}function b(_,k,w,S,Q,I,D,$,j){let B=[],F=[];for(;_.length>S;)B.push(_.pop()),F.push(k.pop()+w-Q);_.push(v(i.types[D],B,F,I-Q,$-I,j)),k.push(Q-w)}function v(_,k,w,S,Q,I,D){if(I){let $=[ot.contextHash,I];D=D?[$].concat(D):[$]}if(Q>25){let $=[ot.lookAhead,Q];D=D?[$].concat(D):[$]}return new wt(_,k,w,S,D)}function m(_,k){let w=o.fork(),S=0,Q=0,I=0,D=w.end-r,$={size:0,start:0,skip:0};e:for(let j=w.pos-_;w.pos>j;){let B=w.size;if(w.id==k&&B>=0){$.size=S,$.start=Q,$.skip=I,I+=4,S+=4,w.next();continue}let F=w.pos-B;if(B<0||F<j||w.start<D)break;let V=w.id>=a?4:0,Z=w.start;for(w.next();w.pos>F;){if(w.size<0)if(w.size==-3||w.size==-4)V+=4;else break e;else w.id>=a&&(V+=4);w.next()}Q=Z,S+=B,I+=V}return(k<0||S==_)&&($.size=S,$.start=Q,$.skip=I),$.size>4?$:void 0}function O(_,k,w){let{id:S,start:Q,end:I,size:D}=o;if(o.next(),D>=0&&S<a){let $=w;if(D>4){let j=o.pos-(D-4);for(;o.pos>j;)w=O(_,k,w)}k[--w]=$,k[--w]=I-_,k[--w]=Q-_,k[--w]=S}else D==-3?c=S:D==-4&&(d=S);return w}let p=[],x=[];for(;o.pos>0;)u(s.start||0,s.bufferStart||0,p,x,-1,0);let y=(e=s.length)!==null&&e!==void 0?e:p.length?x[0]+p[0].length:0;return new wt(l[s.topID],p.reverse(),x.reverse(),y)}const Bg=new WeakMap;function ac(s,e){if(!s.isAnonymous||e instanceof zr||e.type!=s)return 1;let t=Bg.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=s||!(i instanceof wt)){t=1;break}t+=ac(s,i)}Bg.set(e,t)}return t}function Vf(s,e,t,i,r,n,a,o,l){let c=0;for(let b=i;b<r;b++)c+=ac(s,e[b]);let d=Math.ceil(c*1.5/8),u=[],f=[];function g(b,v,m,O,p){for(let x=m;x<O;){let y=x,_=v[x],k=ac(s,b[x]);for(x++;x<O;x++){let w=ac(s,b[x]);if(k+w>=d)break;k+=w}if(x==y+1){if(k>d){let w=b[y];g(w.children,w.positions,0,w.children.length,v[y]+p);continue}u.push(b[y])}else{let w=v[x-1]+b[x-1].length-_;u.push(Vf(s,b,v,y,x,_,w,null,l))}f.push(_+p-n)}}return g(e,t,i,r,0),(o||l)(u,f,a)}class Ff{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Vi?this.setBuffer(e.context.buffer,e.index,t):e instanceof ks&&this.map.set(e.tree,t)}get(e){return e instanceof Vi?this.getBuffer(e.context.buffer,e.index):e instanceof ks?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class vr{constructor(e,t,i,r,n=!1,a=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(n?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new vr(0,e.length,e,0,!1,i)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],n=1,a=e.length?e[0]:null;for(let o=0,l=0,c=0;;o++){let d=o<t.length?t[o]:null,u=d?d.fromA:1e9;if(u-l>=i)for(;a&&a.from<u;){let f=a;if(l>=f.from||u<=f.to||c){let g=Math.max(f.from,l)-c,b=Math.min(f.to,u)-c;f=g>=b?null:new vr(g,b,f.tree,f.offset+c,o>0,!!d)}if(f&&r.push(f),a.to>u)break;a=n<e.length?e[n++]:null}if(!d)break;l=d.toA,c=d.toA-d.toB}return r}}class Yf{startParse(e,t,i){return typeof e=="string"&&(e=new d2(e)),i=i?i.length?i.map(r=>new ui(r.from,r.to)):[new ui(0,0)]:[new ui(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let n=r.advance();if(n)return n}}}class d2{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function Kv(s){return(e,t,i,r)=>new f2(e,s,t,i,r)}class Wg{constructor(e,t,i,r,n,a){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=r,this.target=n,this.from=a}}function Xg(s){if(!s.length||s.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(s))}class u2{constructor(e,t,i,r,n,a,o,l){this.parser=e,this.predicate=t,this.mounts=i,this.index=r,this.start=n,this.bracketed=a,this.target=o,this.prev=l,this.depth=0,this.ranges=[]}}const Uu=new ot({perNode:!0});class f2{constructor(e,t,i,r,n){this.nest=t,this.input=i,this.fragments=r,this.ranges=n,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new wt(i.type,i.children,i.positions,i.length,i.propValues.concat([[Uu,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[ot.mounted.id]=new oo(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new g2(this.fragments),t=null,i=null,r=new Qc(new ks(this.baseTree,this.ranges[0].from,0,null),_t.IncludeAnonymous|_t.IgnoreMounts);e:for(let n,a;;){let o=!0,l;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let c=t.mounts.find(d=>d.frag.from<=r.from&&d.frag.to>=r.to&&d.mount.overlay);if(c)for(let d of c.mount.overlay){let u=d.from+c.pos,f=d.to+c.pos;u>=r.from&&f<=r.to&&!t.ranges.some(g=>g.from<f&&g.to>u)&&t.ranges.push({from:u,to:f})}}o=!1}else if(i&&(a=p2(i.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(n=this.nest(r,this.input))&&(r.from<r.to||!n.overlay)){r.tree||(m2(r),t&&t.depth++,i&&i.depth++);let c=e.findMounts(r.from,n.parser);if(typeof n.overlay=="function")t=new u2(n.parser,n.overlay,c,this.inner.length,r.from,!!n.bracketed,r.tree,t);else{let d=Zg(this.ranges,n.overlay||(r.from<r.to?[new ui(r.from,r.to)]:[]));d.length&&Xg(d),(d.length||!n.overlay)&&this.inner.push(new Wg(n.parser,d.length?n.parser.startParse(this.input,Vg(c,d),d):n.parser.startParse(""),n.overlay?n.overlay.map(u=>new ui(u.from-r.from,u.to-r.from)):null,!!n.bracketed,r.tree,d.length?d[0].from:r.from)),n.overlay?d.length&&(i={ranges:d,depth:0,prev:i}):o=!1}}else if(t&&(l=t.predicate(r))&&(l===!0&&(l=new ui(r.from,r.to)),l.from<l.to)){let c=t.ranges.length-1;c>=0&&t.ranges[c].to==l.from?t.ranges[c]={from:t.ranges[c].from,to:l.to}:t.ranges.push(l)}if(o&&r.firstChild())t&&t.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let c=Zg(this.ranges,t.ranges);c.length&&(Xg(c),this.inner.splice(t.index,0,new Wg(t.parser,t.parser.startParse(this.input,Vg(t.mounts,c),c),t.ranges.map(d=>new ui(d.from-t.start,d.to-t.start)),t.bracketed,t.target,c[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function p2(s,e,t){for(let i of s){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function qg(s,e,t,i,r,n){if(e<t){let a=s.buffer[e+1];i.push(s.slice(e,t,a)),r.push(a-n)}}function m2(s){let{node:e}=s,t=[],i=e.context.buffer;do t.push(s.index),s.parent();while(!s.tree);let r=s.tree,n=r.children.indexOf(i),a=r.children[n],o=a.buffer,l=[n];function c(d,u,f,g,b,v){let m=t[v],O=[],p=[];qg(a,d,m,O,p,g);let x=o[m+1],y=o[m+2];l.push(O.length);let _=v?c(m+4,o[m+3],a.set.types[o[m]],x,y-x,v-1):e.toTree();return O.push(_),p.push(x-g),qg(a,o[m+3],u,O,p,g),new wt(f,O,p,b)}r.children[n]=c(0,o.length,es.none,0,a.length,t.length-1);for(let d of l){let u=s.tree.children[d],f=s.tree.positions[d];s.yield(new ks(u,f+s.from,d,s._tree))}}class zg{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(_t.IncludeAnonymous|_t.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)if(!(t.to>=e&&t.enter(i,1,_t.IgnoreOverlays|_t.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof wt)t=t.children[0];else break}return!1}}let g2=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(Uu))!==null&&t!==void 0?t:i.to,this.inner=new zg(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Uu))!==null&&e!==void 0?e:t.to,this.inner=new zg(t.tree,-t.offset)}}findMounts(e,t){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let n=this.inner.cursor.node;n;n=n.parent){let a=(i=n.tree)===null||i===void 0?void 0:i.prop(ot.mounted);if(a&&a.parser==t)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=n.to)break;l.tree==this.curFrag.tree&&r.push({frag:l,pos:n.from-l.offset,mount:a})}}}return r}};function Zg(s,e){let t=null,i=e;for(let r=1,n=0;r<s.length;r++){let a=s[r-1].to,o=s[r].from;for(;n<i.length;n++){let l=i[n];if(l.from>=o)break;l.to<=a||(t||(i=t=e.slice()),l.from<a?(t[n]=new ui(l.from,a),l.to>o&&t.splice(n+1,0,new ui(o,l.to))):l.to>o?t[n--]=new ui(o,l.to):t.splice(n--,1))}}return i}function O2(s,e,t,i){let r=0,n=0,a=!1,o=!1,l=-1e9,c=[];for(;;){let d=r==s.length?1e9:a?s[r].to:s[r].from,u=n==e.length?1e9:o?e[n].to:e[n].from;if(a!=o){let f=Math.max(l,t),g=Math.min(d,u,i);f<g&&c.push(new ui(f,g))}if(l=Math.min(d,u),l==1e9)break;d==l&&(a?(a=!1,r++):a=!0),u==l&&(o?(o=!1,n++):o=!0)}return c}function Vg(s,e){let t=[];for(let{pos:i,mount:r,frag:n}of s){let a=i+(r.overlay?r.overlay[0].from:0),o=a+r.tree.length,l=Math.max(n.from,a),c=Math.min(n.to,o);if(r.overlay){let d=r.overlay.map(f=>new ui(f.from+i,f.to+i)),u=O2(e,d,l,c);for(let f=0,g=l;;f++){let b=f==u.length,v=b?c:u[f].from;if(v>g&&t.push(new vr(g,v,r.tree,-a,n.from>=g||n.openStart,n.to<=v||n.openEnd)),b)break;g=u[f].to}}else t.push(new vr(l,c,r.tree,-a,n.from>=a||n.openStart,n.to<=o||n.openEnd))}return t}let x2=0;class ei{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=x2++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof ei&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new ei(i,[],null,[]);if(r.set.push(r),t)for(let n of t.set)r.set.push(n);return r}static defineModifier(e){let t=new $c(e);return i=>i.modified.indexOf(t)>-1?i:$c.get(i.base||i,i.modified.concat(t).sort((r,n)=>r.id-n.id))}}let v2=0;class $c{constructor(e){this.name=e,this.instances=[],this.id=v2++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(o=>o.base==e&&b2(t,o.modified));if(i)return i;let r=[],n=new ei(e.name,r,e,t);for(let o of t)o.instances.push(n);let a=y2(t);for(let o of e.set)if(!o.modified.length)for(let l of a)r.push($c.get(o,l));return n}}function b2(s,e){return s.length==e.length&&s.every((t,i)=>t==e[i])}function y2(s){let e=[[]];for(let t=0;t<s.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(s[t]));return e.sort((t,i)=>i.length-t.length)}function Cr(s){let e=Object.create(null);for(let t in s){let i=s[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let n=[],a=2,o=r;for(let u=0;;){if(o=="..."&&u>0&&u+3==r.length){a=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!f)throw new RangeError("Invalid path: "+r);if(n.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),u+=f[0].length,u==r.length)break;let g=r[u++];if(u==r.length&&g=="!"){a=0;break}if(g!="/")throw new RangeError("Invalid path: "+r);o=r.slice(u)}let l=n.length-1,c=n[l];if(!c)throw new RangeError("Invalid path: "+r);let d=new Ca(i,a,l>0?n.slice(0,l):null);e[c]=d.sort(e[c])}}return Jv.add(e)}const Jv=new ot({combine(s,e){let t,i,r;for(;s||e;){if(!s||e&&s.depth>=e.depth?(r=e,e=e.next):(r=s,s=s.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let n=new Ca(r.tags,r.mode,r.context);t?t.next=n:i=n,t=n}return i}});class Ca{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Ca.empty=new Ca([],2,null);function eb(s,e){let t=Object.create(null);for(let n of s)if(!Array.isArray(n.tag))t[n.tag.id]=n.class;else for(let a of n.tag)t[a.id]=n.class;let{scope:i,all:r=null}=e||{};return{style:n=>{let a=r;for(let o of n)for(let l of o.set){let c=t[l.id];if(c){a=a?a+" "+c:c;break}}return a},scope:i}}function S2(s,e){let t=null;for(let i of s){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function _2(s,e,t,i=0,r=s.length){let n=new w2(i,Array.isArray(e)?e:[e],t);n.highlightRange(s.cursor(),i,r,"",n.highlighters),n.flush(r)}class w2{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,n){let{type:a,from:o,to:l}=e;if(o>=i||l<=t)return;a.isTop&&(n=this.highlighters.filter(g=>!g.scope||g.scope(a)));let c=r,d=k2(e)||Ca.empty,u=S2(n,d.tags);if(u&&(c&&(c+=" "),c+=u,d.mode==1&&(r+=(r?" ":"")+u)),this.startSpan(Math.max(t,o),c),d.opaque)return;let f=e.tree&&e.tree.prop(ot.mounted);if(f&&f.overlay){let g=e.node.enter(f.overlay[0].from+o,1),b=this.highlighters.filter(m=>!m.scope||m.scope(f.tree.type)),v=e.firstChild();for(let m=0,O=o;;m++){let p=m<f.overlay.length?f.overlay[m]:null,x=p?p.from+o:l,y=Math.max(t,O),_=Math.min(i,x);if(y<_&&v)for(;e.from<_&&(this.highlightRange(e,y,_,r,n),this.startSpan(Math.min(_,e.to),c),!(e.to>=x||!e.nextSibling())););if(!p||x>i)break;O=p.to+o,O>t&&(this.highlightRange(g.cursor(),Math.max(t,p.from+o),Math.min(i,O),"",b),this.startSpan(Math.min(i,O),c))}v&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,n),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}}function k2(s){let e=s.type.prop(Jv);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}const Te=ei.define,Il=Te(),Ar=Te(),Fg=Te(Ar),Yg=Te(Ar),Mr=Te(),Bl=Te(Mr),xd=Te(Mr),Wi=Te(),vn=Te(Wi),Ii=Te(),Bi=Te(),Hu=Te(),Ho=Te(Hu),Wl=Te(),L={comment:Il,lineComment:Te(Il),blockComment:Te(Il),docComment:Te(Il),name:Ar,variableName:Te(Ar),typeName:Fg,tagName:Te(Fg),propertyName:Yg,attributeName:Te(Yg),className:Te(Ar),labelName:Te(Ar),namespace:Te(Ar),macroName:Te(Ar),literal:Mr,string:Bl,docString:Te(Bl),character:Te(Bl),attributeValue:Te(Bl),number:xd,integer:Te(xd),float:Te(xd),bool:Te(Mr),regexp:Te(Mr),escape:Te(Mr),color:Te(Mr),url:Te(Mr),keyword:Ii,self:Te(Ii),null:Te(Ii),atom:Te(Ii),unit:Te(Ii),modifier:Te(Ii),operatorKeyword:Te(Ii),controlKeyword:Te(Ii),definitionKeyword:Te(Ii),moduleKeyword:Te(Ii),operator:Bi,derefOperator:Te(Bi),arithmeticOperator:Te(Bi),logicOperator:Te(Bi),bitwiseOperator:Te(Bi),compareOperator:Te(Bi),updateOperator:Te(Bi),definitionOperator:Te(Bi),typeOperator:Te(Bi),controlOperator:Te(Bi),punctuation:Hu,separator:Te(Hu),bracket:Ho,angleBracket:Te(Ho),squareBracket:Te(Ho),paren:Te(Ho),brace:Te(Ho),content:Wi,heading:vn,heading1:Te(vn),heading2:Te(vn),heading3:Te(vn),heading4:Te(vn),heading5:Te(vn),heading6:Te(vn),contentSeparator:Te(Wi),list:Te(Wi),quote:Te(Wi),emphasis:Te(Wi),strong:Te(Wi),link:Te(Wi),monospace:Te(Wi),strikethrough:Te(Wi),inserted:Te(),deleted:Te(),changed:Te(),invalid:Te(),meta:Wl,documentMeta:Te(Wl),annotation:Te(Wl),processingInstruction:Te(Wl),definition:ei.defineModifier("definition"),constant:ei.defineModifier("constant"),function:ei.defineModifier("function"),standard:ei.defineModifier("standard"),local:ei.defineModifier("local"),special:ei.defineModifier("special")};for(let s in L){let e=L[s];e instanceof ei&&(e.name=s)}eb([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var vd;const kn=new ot;function Uf(s){return Ae.define({combine:s?e=>e.concat(s):void 0})}const Hf=new ot;class fi{constructor(e,t,i=[],r=""){this.data=e,this.name=r,pt.prototype.hasOwnProperty("tree")||Object.defineProperty(pt.prototype,"tree",{get(){return kt(this)}}),this.parser=t,this.extension=[Zr.of(this),pt.languageData.of((n,a,o)=>{let l=Ug(n,a,o),c=l.type.prop(kn);if(!c)return[];let d=n.facet(c),u=l.type.prop(Hf);if(u){let f=l.resolve(a-l.from,o);for(let g of u)if(g.test(f,n)){let b=n.facet(g.facet);return g.type=="replace"?b:b.concat(d)}}return d})].concat(i)}isActiveAt(e,t,i=-1){return Ug(e,t,i).type.prop(kn)==this.data}findRegions(e){let t=e.facet(Zr);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(n,a)=>{if(n.prop(kn)==this.data){i.push({from:a,to:a+n.length});return}let o=n.prop(ot.mounted);if(o){if(o.tree.prop(kn)==this.data){if(o.overlay)for(let l of o.overlay)i.push({from:l.from+a,to:l.to+a});else i.push({from:a,to:a+n.length});return}else if(o.overlay){let l=i.length;if(r(o.tree,o.overlay[0].from+a),i.length>l)return}}for(let l=0;l<n.children.length;l++){let c=n.children[l];c instanceof wt&&r(c,n.positions[l]+a)}};return r(kt(e),0),i}get allowsNesting(){return!0}}fi.setState=nt.define();function Ug(s,e,t){let i=s.facet(Zr),r=kt(s).topNode;if(!i||i.allowsNesting)for(let n=r;n;n=n.enter(e,t,_t.ExcludeBuffers|_t.EnterBracketed))n.type.isTop&&(r=n);return r}class _r extends fi{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=Uf(e.languageData);return new _r(t,e.parser.configure({props:[kn.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new _r(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function kt(s){let e=s.field(fi.state,!1);return e?e.tree:wt.empty}class C2{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Go=null;class Pa{constructor(e,t,i=[],r,n,a,o,l){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=n,this.viewport=a,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Pa(e,t,[],wt.empty,0,i,[],null)}startParse(){return this.parser.startParse(new C2(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=wt.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(vr.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(vr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Go;Go=this;try{return e()}finally{Go=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Hg(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:n,viewport:a,skipped:o}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,d,u,f)=>l.push({fromA:c,toA:d,fromB:u,toB:f})),i=vr.applyChanges(i,l),r=wt.empty,n=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){o=[];for(let c of this.skipped){let d=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);d<u&&o.push({from:d,to:u})}}}return new Pa(this.parser,t,i,r,n,a,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:n}=this.skipped[i];r<e.to&&n>e.from&&(this.fragments=Hg(this.fragments,r,n),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Yf{createParse(t,i,r){let n=r[0].from,a=r[r.length-1].to;return{parsedPos:n,advance(){let l=Go;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=a,new wt(es.none,[],[],a-n)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Go}}function Hg(s,e,t){return vr.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}class Oo{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Oo(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Pa.create(e.facet(Zr).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new Oo(i)}}fi.state=xs.define({create:Oo.init,update(s,e){for(let t of e.effects)if(t.is(fi.setState))return t.value;return e.startState.facet(Zr)!=e.state.facet(Zr)?Oo.init(e.state):s.apply(e)}});let tb=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(tb=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const bd=typeof navigator<"u"&&(!((vd=navigator.scheduling)===null||vd===void 0)&&vd.isInputPending)?()=>navigator.scheduling.isInputPending():null,P2=zt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(fi.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(fi.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=tb(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,n=i.field(fi.state);if(n.tree==n.context.tree&&n.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!bd?Math.max(25,e.timeRemaining()-5):1e9),o=n.context.treeLen<r&&i.doc.length>r+1e3,l=n.context.work(()=>bd&&bd()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:fi.setState.of(new Oo(n.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Xs(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Zr=Ae.define({combine(s){return s.length?s[0]:null},enables:s=>[fi.state,P2,_e.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});class Vr{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class jc{constructor(e,t,i,r,n,a=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=r,this.loadFunc=n,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new jc(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let r of e)if(r.filename&&r.filename.test(t))return r;let i=/\.([^.]+)$/.exec(t);if(i){for(let r of e)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let r of e)if(r.alias.some(n=>n==t))return r;if(i)for(let r of e)for(let n of r.alias){let a=t.indexOf(n);if(a>-1&&(n.length>2||!/\w/.test(t[a-1])&&!/\w/.test(t[a+n.length])))return r}return null}}const T2=Ae.define(),_o=Ae.define({combine:s=>{if(!s.length)return" ";let e=s[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return e}});function Ec(s){let e=s.facet(_o);return e.charCodeAt(0)==9?s.tabSize*e.length:e.length}function Ta(s,e){let t="",i=s.tabSize,r=s.facet(_o)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let n=0;n<e;n++)t+=r;return t}function Gf(s,e){s instanceof pt&&(s=new nh(s));for(let i of s.state.facet(T2)){let r=i(s,e);if(r!==void 0)return r}let t=kt(s.state);return t.length>=e?Q2(s,t,e):null}class nh{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ec(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:n}=this.options;return r!=null&&r>=i.from&&r<=i.to?n&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),n=this.countColumn(i,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(n+=a-this.countColumn(i,i.search(/\S|$/))),n}countColumn(e,t=e.length){return ki(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),n=this.options.overrideIndentation;if(n){let a=n(r);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Yr=new ot;function Q2(s,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let n=[];for(let a=r;a&&!(a.from<i.node.from||a.to>i.node.to||a.from==i.node.from&&a.type==i.node.type);a=a.parent)n.push(a);for(let a=n.length-1;a>=0;a--)i={node:n[a],next:i}}return sb(i,s,t)}function sb(s,e,t){for(let i=s;i;i=i.next){let r=j2(i.node);if(r)return r(Kf.create(e,t,i))}return 0}function $2(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function j2(s){let e=s.type.prop(Yr);if(e)return e;let t=s.firstChild,i;if(t&&(i=t.type.prop(ot.closedBy))){let r=s.lastChild,n=r&&i.indexOf(r.name)>-1;return a=>ib(a,!0,1,void 0,n&&!$2(a)?r.from:void 0)}return s.parent==null?E2:null}function E2(){return 0}class Kf extends nh{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Kf(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(R2(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return sb(this.context.next,this.base,this.pos)}}function R2(s,e){for(let t=e;t;t=t.parent)if(s==t)return!0;return!1}function A2(s){let e=s.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=s.options.simulateBreak,n=s.state.doc.lineAt(t.from),a=r==null||r<=n.from?n.to:Math.min(n.to,r);for(let o=t.to;;){let l=e.childAfter(o);if(!l||l==i)return null;if(!l.type.isSkipped){if(l.from>=a)return null;let c=/^ */.exec(n.text.slice(t.to-n.from))[0].length;return{from:t.from,to:t.to+c}}o=l.to}}function lc({closing:s,align:e=!0,units:t=1}){return i=>ib(i,e,t,s)}function ib(s,e,t,i,r){let n=s.textAfter,a=n.match(/^\s*/)[0].length,o=i&&n.slice(a,a+i.length)==i||r==s.pos+a,l=e?A2(s):null;return l?o?s.column(l.from):s.column(l.to):s.baseIndent+(o?0:s.unit*t)}const M2=s=>s.baseIndent;function ao({except:s,units:e=1}={}){return t=>{let i=s&&s.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const L2=200;function N2(){return pt.transactionFilter.of(s=>{if(!s.docChanged||!s.isUserEvent("input.type")&&!s.isUserEvent("input.complete"))return s;let e=s.startState.languageDataAt("indentOnInput",s.startState.selection.main.head);if(!e.length)return s;let t=s.newDoc,{head:i}=s.newSelection.main,r=t.lineAt(i);if(i>r.from+L2)return s;let n=t.sliceString(r.from,i);if(!e.some(c=>c.test(n)))return s;let{state:a}=s,o=-1,l=[];for(let{head:c}of a.selection.ranges){let d=a.doc.lineAt(c);if(d.from==o)continue;o=d.from;let u=Gf(a,d.from);if(u==null)continue;let f=/^\s*/.exec(d.text)[0],g=Ta(a,u);f!=g&&l.push({from:d.from,to:d.from+f.length,insert:g})}return l.length?[s,{changes:l,sequential:!0}]:s})}const rb=Ae.define(),Pr=new ot;function oh(s){let e=s.firstChild,t=s.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?s.to:t.from}:null}function D2(s,e,t){let i=kt(s);if(i.length<t)return null;let r=i.resolveStack(t,1),n=null;for(let a=r;a;a=a.next){let o=a.node;if(o.to<=t||o.from>t)continue;if(n&&o.from<e)break;let l=o.type.prop(Pr);if(l&&(o.to<i.length-50||i.length==s.doc.length||!I2(o))){let c=l(o,s);c&&c.from<=t&&c.from>=e&&c.to>t&&(n=c)}}return n}function I2(s){let e=s.lastChild;return e&&e.to==s.to&&e.type.isError}function Rc(s,e,t){for(let i of s.facet(rb)){let r=i(s,e,t);if(r)return r}return D2(s,e,t)}function nb(s,e){let t=e.mapPos(s.from,1),i=e.mapPos(s.to,-1);return t>=i?void 0:{from:t,to:i}}const ah=nt.define({map:nb}),Va=nt.define({map:nb});function ob(s){let e=[];for(let{head:t}of s.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(s.lineBlockAt(t));return e}const En=xs.define({create(){return ze.none},update(s,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,r)=>s=Gg(s,i,r)),s=s.map(e.changes);let t=[];for(let i of e.effects)i.is(ah)&&!B2(s,i.value.from,i.value.to)?t.push(i.value):i.is(Va)&&(s=s.update({filter:(r,n)=>i.value.from!=r||i.value.to!=n,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(cb),r=t.map(n=>(i?ze.replace({widget:new F2(i(e.state,n))}):Kg).range(n.from,n.to));s=s.update({add:r})}return e.selection&&(s=Gg(s,e.selection.main.head)),s},provide:s=>_e.decorations.from(s),toJSON(s,e){let t=[];return s.between(0,e.doc.length,(i,r)=>{t.push(i,r)}),t},fromJSON(s){if(!Array.isArray(s)||s.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<s.length;){let i=s[t++],r=s[t++];if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(Kg.range(i,r))}return ze.set(e,!0)}});function Gg(s,e,t=e){let i=!1;return s.between(e,t,(r,n)=>{r<t&&n>e&&(i=!0)}),i?s.update({filterFrom:e,filterTo:t,filter:(r,n)=>r>=t||n<=e}):s}function Ac(s,e,t){var i;let r=null;return(i=s.field(En,!1))===null||i===void 0||i.between(e,t,(n,a)=>{(!r||r.from>n)&&(r={from:n,to:a})}),r}function B2(s,e,t){let i=!1;return s.between(e,e,(r,n)=>{r==e&&n==t&&(i=!0)}),i}function ab(s,e){return s.field(En,!1)?e:e.concat(nt.appendConfig.of(hb()))}const W2=s=>{for(let e of ob(s)){let t=Rc(s.state,e.from,e.to);if(t)return s.dispatch({effects:ab(s.state,[ah.of(t),lb(s,t)])}),!0}return!1},X2=s=>{if(!s.state.field(En,!1))return!1;let e=[];for(let t of ob(s)){let i=Ac(s.state,t.from,t.to);i&&e.push(Va.of(i),lb(s,i,!1))}return e.length&&s.dispatch({effects:e}),e.length>0};function lb(s,e,t=!0){let i=s.state.doc.lineAt(e.from).number,r=s.state.doc.lineAt(e.to).number;return _e.announce.of(`${s.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${s.state.phrase("to")} ${r}.`)}const q2=s=>{let{state:e}=s,t=[];for(let i=0;i<e.doc.length;){let r=s.lineBlockAt(i),n=Rc(e,r.from,r.to);n&&t.push(ah.of(n)),i=(n?s.lineBlockAt(n.to):r).to+1}return t.length&&s.dispatch({effects:ab(s.state,t)}),!!t.length},z2=s=>{let e=s.state.field(En,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,s.state.doc.length,(i,r)=>{t.push(Va.of({from:i,to:r}))}),s.dispatch({effects:t}),!0},Z2=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:W2},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:X2},{key:"Ctrl-Alt-[",run:q2},{key:"Ctrl-Alt-]",run:z2}],V2={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},cb=Ae.define({combine(s){return Ki(s,V2)}});function hb(s){return[En,H2]}function db(s,e){let{state:t}=s,i=t.facet(cb),r=a=>{let o=s.lineBlockAt(s.posAtDOM(a.target)),l=Ac(s.state,o.from,o.to);l&&s.dispatch({effects:Va.of(l)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(s,r,e);let n=document.createElement("span");return n.textContent=i.placeholderText,n.setAttribute("aria-label",t.phrase("folded code")),n.title=t.phrase("unfold"),n.className="cm-foldPlaceholder",n.onclick=r,n}const Kg=ze.replace({widget:new class extends Pi{toDOM(s){return db(s,null)}}});class F2 extends Pi{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return db(e,this.value)}}const Y2={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class yd extends Sr{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function U2(s={}){let e={...Y2,...s},t=new yd(e,!0),i=new yd(e,!1),r=zt.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(Zr)!=a.state.facet(Zr)||a.startState.field(En,!1)!=a.state.field(En,!1)||kt(a.startState)!=kt(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new br;for(let l of a.viewportLineBlocks){let c=Ac(a.state,l.from,l.to)?i:Rc(a.state,l.from,l.to)?t:null;c&&o.add(l.from,l.from,c)}return o.finish()}}),{domEventHandlers:n}=e;return[r,YC({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(r))===null||o===void 0?void 0:o.markers)||ft.empty},initialSpacer(){return new yd(e,!1)},domEventHandlers:{...n,click:(a,o,l)=>{if(n.click&&n.click(a,o,l))return!0;let c=Ac(a.state,o.from,o.to);if(c)return a.dispatch({effects:Va.of(c)}),!0;let d=Rc(a.state,o.from,o.to);return d?(a.dispatch({effects:ah.of(d)}),!0):!1}}}),hb()]}const H2=_e.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Fa{constructor(e,t){this.specs=e;let i;function r(o){let l=Wr.newName();return(i||(i=Object.create(null)))["."+l]=o,l}const n=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof fi?o=>o.prop(kn)==a.data:a?o=>o==a:void 0,this.style=eb(e.map(o=>({tag:o.tag,class:o.class||r(Object.assign({},o,{tag:null}))})),{all:n}).style,this.module=i?new Wr(i):null,this.themeType=t.themeType}static define(e,t){return new Fa(e,t||{})}}const Gu=Ae.define(),ub=Ae.define({combine(s){return s.length?[s[0]]:null}});function Sd(s){let e=s.facet(Gu);return e.length?e:s.facet(ub)}function fb(s,e){let t=[K2],i;return s instanceof Fa&&(s.module&&t.push(_e.styleModule.of(s.module)),i=s.themeType),e?.fallback?t.push(ub.of(s)):i?t.push(Gu.computeN([_e.darkTheme],r=>r.facet(_e.darkTheme)==(i=="dark")?[s]:[])):t.push(Gu.of(s)),t}class G2{constructor(e){this.markCache=Object.create(null),this.tree=kt(e.state),this.decorations=this.buildDeco(e,Sd(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=kt(e.state),i=Sd(e.state),r=i!=Sd(e.startState),{viewport:n}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<n.to&&!r&&t.type==this.tree.type&&a>=n.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=n.to)}buildDeco(e,t){if(!t||!this.tree.length)return ze.none;let i=new br;for(let{from:r,to:n}of e.visibleRanges)_2(this.tree,t,(a,o,l)=>{i.add(a,o,this.markCache[l]||(this.markCache[l]=ze.mark({class:l})))},r,n);return i.finish()}}const K2=kr.high(zt.fromClass(G2,{decorations:s=>s.decorations})),J2=Fa.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]),eP=_e.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),pb=1e4,mb="()[]{}",gb=Ae.define({combine(s){return Ki(s,{afterCursor:!0,brackets:mb,maxScanDistance:pb,renderMatch:iP})}}),tP=ze.mark({class:"cm-matchingBracket"}),sP=ze.mark({class:"cm-nonmatchingBracket"});function iP(s){let e=[],t=s.matched?tP:sP;return e.push(t.range(s.start.from,s.start.to)),s.end&&e.push(t.range(s.end.from,s.end.to)),e}function Jg(s){let e=[],t=s.facet(gb);for(let i of s.selection.ranges){if(!i.empty)continue;let r=Fi(s,i.head,-1,t)||i.head>0&&Fi(s,i.head-1,1,t)||t.afterCursor&&(Fi(s,i.head,1,t)||i.head<s.doc.length&&Fi(s,i.head+1,-1,t));r&&(e=e.concat(t.renderMatch(r,s)))}return ze.set(e,!0)}const rP=zt.fromClass(class{constructor(s){this.paused=!1,this.decorations=Jg(s.state)}update(s){(s.docChanged||s.selectionSet||this.paused)&&(s.view.composing?(this.decorations=this.decorations.map(s.changes),this.paused=!0):(this.decorations=Jg(s.state),this.paused=!1))}},{decorations:s=>s.decorations}),nP=[rP,eP];function oP(s={}){return[gb.of(s),nP]}const Jf=new ot;function Ku(s,e,t){let i=s.prop(e<0?ot.openedBy:ot.closedBy);if(i)return i;if(s.name.length==1){let r=t.indexOf(s.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Ju(s){let e=s.type.prop(Jf);return e?e(s.node):s}function Fi(s,e,t,i={}){let r=i.maxScanDistance||pb,n=i.brackets||mb,a=kt(s),o=a.resolveInner(e,t);for(let l=o;l;l=l.parent){let c=Ku(l.type,t,n);if(c&&l.from<l.to){let d=Ju(l);if(d&&(t>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return aP(s,e,t,l,d,c,n)}}return lP(s,e,t,a,o.type,r,n)}function aP(s,e,t,i,r,n,a){let o=i.parent,l={from:r.from,to:r.to},c=0,d=o?.cursor();if(d&&(t<0?d.childBefore(i.from):d.childAfter(i.to)))do if(t<0?d.to<=i.from:d.from>=i.to){if(c==0&&n.indexOf(d.type.name)>-1&&d.from<d.to){let u=Ju(d);return{start:l,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(Ku(d.type,t,a))c++;else if(Ku(d.type,-t,a)){if(c==0){let u=Ju(d);return{start:l,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}c--}}while(t<0?d.prevSibling():d.nextSibling());return{start:l,matched:!1}}function lP(s,e,t,i,r,n,a){if(t<0?!e:e==s.doc.length)return null;let o=t<0?s.sliceDoc(e-1,e):s.sliceDoc(e,e+1),l=a.indexOf(o);if(l<0||l%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},d=s.doc.iterRange(e,t>0?s.doc.length:0),u=0;for(let f=0;!d.next().done&&f<=n;){let g=d.value;t<0&&(f+=g.length);let b=e+f*t;for(let v=t>0?0:g.length-1,m=t>0?g.length:-1;v!=m;v+=t){let O=a.indexOf(g[v]);if(!(O<0||i.resolveInner(b+v,1).type!=r))if(O%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:b+v,to:b+v+1},matched:O>>1==l>>1};u--}}t>0&&(f+=g.length)}return d.done?{start:c,matched:!1}:null}const cP=Object.create(null),eO=[es.none],tO=[],sO=Object.create(null),hP=Object.create(null);for(let[s,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])hP[s]=dP(cP,e);function _d(s,e){tO.indexOf(s)>-1||(tO.push(s),console.warn(e))}function dP(s,e){let t=[];for(let o of e.split(" ")){let l=[];for(let c of o.split(".")){let d=s[c]||L[c];d?typeof d=="function"?l.length?l=l.map(d):_d(c,`Modifier ${c} used at start of tag`):l.length?_d(c,`Tag ${c} used as modifier`):l=Array.isArray(d)?d:[d]:_d(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(o=>o.id),n=sO[r];if(n)return n.id;let a=sO[r]=es.define({id:eO.length,name:i,props:[Cr({[i]:t})]});return eO.push(a),a.id}jt.RTL,jt.LTR;const uP=s=>{let{state:e}=s,t=e.doc.lineAt(e.selection.main.from),i=tp(s.state,t.from);return i.line?fP(s):i.block?mP(s):!1};function ep(s,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=s(e,t);return r?(i(t.update(r)),!0):!1}}const fP=ep(xP,0),pP=ep(Ob,0),mP=ep((s,e)=>Ob(s,e,OP(e)),0);function tp(s,e){let t=s.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Ko=50;function gP(s,{open:e,close:t},i,r){let n=s.sliceDoc(i-Ko,i),a=s.sliceDoc(r,r+Ko),o=/\s*$/.exec(n)[0].length,l=/^\s*/.exec(a)[0].length,c=n.length-o;if(n.slice(c-e.length,c)==e&&a.slice(l,l+t.length)==t)return{open:{pos:i-o,margin:o&&1},close:{pos:r+l,margin:l&&1}};let d,u;r-i<=2*Ko?d=u=s.sliceDoc(i,r):(d=s.sliceDoc(i,i+Ko),u=s.sliceDoc(r-Ko,r));let f=/^\s*/.exec(d)[0].length,g=/\s*$/.exec(u)[0].length,b=u.length-g-t.length;return d.slice(f,f+e.length)==e&&u.slice(b,b+t.length)==t?{open:{pos:i+f+e.length,margin:/\s/.test(d.charAt(f+e.length))?1:0},close:{pos:r-g-t.length,margin:/\s/.test(u.charAt(b-1))?1:0}}:null}function OP(s){let e=[];for(let t of s.selection.ranges){let i=s.doc.lineAt(t.from),r=t.to<=i.to?i:s.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:s.doc.lineAt(t.to-1));let n=e.length-1;n>=0&&e[n].to>i.from?e[n].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function Ob(s,e,t=e.selection.ranges){let i=t.map(n=>tp(e,n.from).block);if(!i.every(n=>n))return null;let r=t.map((n,a)=>gP(e,i[a],n.from,n.to));if(s!=2&&!r.every(n=>n))return{changes:e.changes(t.map((n,a)=>r[a]?[]:[{from:n.from,insert:i[a].open+" "},{from:n.to,insert:" "+i[a].close}]))};if(s!=1&&r.some(n=>n)){let n=[];for(let a=0,o;a<r.length;a++)if(o=r[a]){let l=i[a],{open:c,close:d}=o;n.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:d.pos-d.margin,to:d.pos+l.close.length})}return{changes:n}}return null}function xP(s,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:n,to:a}of t){let o=i.length,l=1e9,c;for(let d=n;d<=a;){let u=e.doc.lineAt(d);if(c==null&&(c=tp(e,u.from).line,!c))continue e;if(u.from>r&&(n==a||a>u.from)){r=u.from;let f=/^\s*/.exec(u.text)[0].length,g=f==u.length,b=u.text.slice(f,f+c.length)==c?f:-1;f<u.text.length&&f<l&&(l=f),i.push({line:u,comment:b,token:c,indent:f,empty:g,single:!1})}d=u.to+1}if(l<1e9)for(let d=o;d<i.length;d++)i[d].indent<i[d].line.text.length&&(i[d].indent=l);i.length==o+1&&(i[o].single=!0)}if(s!=2&&i.some(n=>n.comment<0&&(!n.empty||n.single))){let n=[];for(let{line:o,token:l,indent:c,empty:d,single:u}of i)(u||!d)&&n.push({from:o.from+c,insert:l+" "});let a=e.changes(n);return{changes:a,selection:e.selection.map(a,1)}}else if(s!=1&&i.some(n=>n.comment>=0)){let n=[];for(let{line:a,comment:o,token:l}of i)if(o>=0){let c=a.from+o,d=c+l.length;a.text[d-a.from]==" "&&d++,n.push({from:c,to:d})}return{changes:n}}return null}const ef=Gi.define(),vP=Gi.define(),bP=Ae.define(),xb=Ae.define({combine(s){return Ki(s,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),vb=xs.define({create(){return Yi.empty},update(s,e){let t=e.state.facet(xb),i=e.annotation(ef);if(i){let l=qs.fromTransaction(e,i.selection),c=i.side,d=c==0?s.undone:s.done;return l?d=Mc(d,d.length,t.minDepth,l):d=Sb(d,e.startState.selection),new Yi(c==0?i.rest:d,c==0?d:i.rest)}let r=e.annotation(vP);if((r=="full"||r=="before")&&(s=s.isolate()),e.annotation(Kt.addToHistory)===!1)return e.changes.empty?s:s.addMapping(e.changes.desc);let n=qs.fromTransaction(e),a=e.annotation(Kt.time),o=e.annotation(Kt.userEvent);return n?s=s.addChanges(n,a,o,t,e):e.selection&&(s=s.addSelection(e.startState.selection,a,o,t.newGroupDelay)),(r=="full"||r=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(e=>e.toJSON()),undone:s.undone.map(e=>e.toJSON())}},fromJSON(s){return new Yi(s.done.map(qs.fromJSON),s.undone.map(qs.fromJSON))}});function yP(s={}){return[vb,xb.of(s),_e.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?bb:e.inputType=="historyRedo"?tf:null;return i?(e.preventDefault(),i(t)):!1}})]}function lh(s,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(vb,!1);if(!r)return!1;let n=r.pop(s,t,e);return n?(i(n),!0):!1}}const bb=lh(0,!1),tf=lh(1,!1),SP=lh(0,!0),_P=lh(1,!0);class qs{constructor(e,t,i,r,n){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=n}setSelAfter(e){return new qs(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new qs(e.changes&&Jt.fromJSON(e.changes),[],e.mapped&&Ui.fromJSON(e.mapped),e.startSelection&&re.fromJSON(e.startSelection),e.selectionsAfter.map(re.fromJSON))}static fromTransaction(e,t){let i=pi;for(let r of e.startState.facet(bP)){let n=r(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new qs(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,pi)}static selection(e){return new qs(void 0,pi,void 0,void 0,e)}}function Mc(s,e,t,i){let r=e+1>t+20?e-t-1:0,n=s.slice(r,e);return n.push(i),n}function wP(s,e){let t=[],i=!1;return s.iterChangedRanges((r,n)=>t.push(r,n)),e.iterChangedRanges((r,n,a,o)=>{for(let l=0;l<t.length;){let c=t[l++],d=t[l++];o>=c&&a<=d&&(i=!0)}}),i}function kP(s,e){return s.ranges.length==e.ranges.length&&s.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function yb(s,e){return s.length?e.length?s.concat(e):s:e}const pi=[],CP=200;function Sb(s,e){if(s.length){let t=s[s.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-CP));return i.length&&i[i.length-1].eq(e)?s:(i.push(e),Mc(s,s.length-1,1e9,t.setSelAfter(i)))}else return[qs.selection([e])]}function PP(s){let e=s[s.length-1],t=s.slice();return t[s.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function wd(s,e){if(!s.length)return s;let t=s.length,i=pi;for(;t;){let r=TP(s[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let n=s.slice(0,t);return n[t-1]=r,n}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[qs.selection(i)]:pi}function TP(s,e,t){let i=yb(s.selectionsAfter.length?s.selectionsAfter.map(o=>o.map(e)):pi,t);if(!s.changes)return qs.selection(i);let r=s.changes.map(e),n=e.mapDesc(s.changes,!0),a=s.mapped?s.mapped.composeDesc(n):n;return new qs(r,nt.mapEffects(s.effects,e),a,s.startSelection.map(n),i)}const QP=/^(input\.type|delete)($|\.)/;class Yi{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Yi(this.done,this.undone):this}addChanges(e,t,i,r,n){let a=this.done,o=a[a.length-1];return o&&o.changes&&!o.changes.empty&&e.changes&&(!i||QP.test(i))&&(!o.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(n,wP(o.changes,e.changes))||i=="input.type.compose")?a=Mc(a,a.length-1,r.minDepth,new qs(e.changes.compose(o.changes),yb(nt.mapEffects(e.effects,o.changes),o.effects),o.mapped,o.startSelection,pi)):a=Mc(a,a.length,r.minDepth,e),new Yi(a,pi,t,i)}addSelection(e,t,i,r){let n=this.done.length?this.done[this.done.length-1].selectionsAfter:pi;return n.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&kP(n[n.length-1],e)?this:new Yi(Sb(this.done,e),this.undone,t,i)}addMapping(e){return new Yi(wd(this.done,e),wd(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let n=r[r.length-1],a=n.selectionsAfter[0]||(n.startSelection?n.startSelection.map(n.changes.invertedDesc,1):t.selection);if(i&&n.selectionsAfter.length)return t.update({selection:n.selectionsAfter[n.selectionsAfter.length-1],annotations:ef.of({side:e,rest:PP(r),selection:a}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(n.changes){let o=r.length==1?pi:r.slice(0,r.length-1);return n.mapped&&(o=wd(o,n.mapped)),t.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:ef.of({side:e,rest:o,selection:a}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Yi.empty=new Yi(pi,pi);const $P=[{key:"Mod-z",run:bb,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:tf,preventDefault:!0},{linux:"Ctrl-Shift-z",run:tf,preventDefault:!0},{key:"Mod-u",run:SP,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:_P,preventDefault:!0}];function wo(s,e){return re.create(s.ranges.map(e),s.mainIndex)}function Ti(s,e){return s.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Qi({state:s,dispatch:e},t){let i=wo(s.selection,t);return i.eq(s.selection,!0)?!1:(e(Ti(s,i)),!0)}function ch(s,e){return re.cursor(e?s.to:s.from)}function _b(s,e){return Qi(s,t=>t.empty?s.moveByChar(t,e):ch(t,e))}function Cs(s){return s.textDirectionAt(s.state.selection.main.head)==jt.LTR}const wb=s=>_b(s,!Cs(s)),kb=s=>_b(s,Cs(s));function Cb(s,e){return Qi(s,t=>t.empty?s.moveByGroup(t,e):ch(t,e))}const jP=s=>Cb(s,!Cs(s)),EP=s=>Cb(s,Cs(s));function RP(s,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(e.from,e.to)))||e.firstChild}function hh(s,e,t){let i=kt(s).resolveInner(e.head),r=t?ot.closedBy:ot.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;RP(s,c,r)?i=c:l=t?c.to:c.from}let n=i.type.prop(r),a,o;return n&&(a=t?Fi(s,i.from,1):Fi(s,i.to,-1))&&a.matched?o=t?a.end.to:a.end.from:o=t?i.to:i.from,re.cursor(o,t?-1:1)}const AP=s=>Qi(s,e=>hh(s.state,e,!Cs(s))),MP=s=>Qi(s,e=>hh(s.state,e,Cs(s)));function Pb(s,e){return Qi(s,t=>{if(!t.empty)return ch(t,e);let i=s.moveVertically(t,e);return i.head!=t.head?i:s.moveToLineBoundary(t,e)})}const Tb=s=>Pb(s,!1),Qb=s=>Pb(s,!0);function $b(s){let e=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let n of s.state.facet(_e.scrollMargins)){let a=n(s);a?.top&&(t=Math.max(a?.top,t)),a?.bottom&&(i=Math.max(a?.bottom,i))}r=s.scrollDOM.clientHeight-t-i}else r=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(s.defaultLineHeight,r-5)}}function jb(s,e){let t=$b(s),{state:i}=s,r=wo(i.selection,a=>a.empty?s.moveVertically(a,e,t.height):ch(a,e));if(r.eq(i.selection))return!1;let n;if(t.selfScroll){let a=s.coordsAtPos(i.selection.main.head),o=s.scrollDOM.getBoundingClientRect(),l=o.top+t.marginTop,c=o.bottom-t.marginBottom;a&&a.top>l&&a.bottom<c&&(n=_e.scrollIntoView(r.main.head,{y:"start",yMargin:a.top-l}))}return s.dispatch(Ti(i,r),{effects:n}),!0}const iO=s=>jb(s,!1),sf=s=>jb(s,!0);function Ur(s,e,t){let i=s.lineBlockAt(e.head),r=s.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=s.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let n=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&e.head!=i.from+n&&(r=re.cursor(i.from+n))}return r}const LP=s=>Qi(s,e=>Ur(s,e,!0)),NP=s=>Qi(s,e=>Ur(s,e,!1)),DP=s=>Qi(s,e=>Ur(s,e,!Cs(s))),IP=s=>Qi(s,e=>Ur(s,e,Cs(s))),BP=s=>Qi(s,e=>re.cursor(s.lineBlockAt(e.head).from,1)),WP=s=>Qi(s,e=>re.cursor(s.lineBlockAt(e.head).to,-1));function XP(s,e,t){let i=!1,r=wo(s.selection,n=>{let a=Fi(s,n.head,-1)||Fi(s,n.head,1)||n.head>0&&Fi(s,n.head-1,1)||n.head<s.doc.length&&Fi(s,n.head+1,-1);if(!a||!a.end)return n;i=!0;let o=a.start.from==n.head?a.end.to:a.end.from;return re.cursor(o)});return i?(e(Ti(s,r)),!0):!1}const qP=({state:s,dispatch:e})=>XP(s,e);function gi(s,e,t){let i=wo(s.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=re.range(r.head,r.anchor));let n=t(r);return re.range(r.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return i.eq(s.state.selection)?!1:(s.dispatch(Ti(s.state,i)),!0)}function Eb(s,e){return gi(s,e,t=>s.moveByChar(t,e))}const Rb=s=>Eb(s,!Cs(s)),Ab=s=>Eb(s,Cs(s));function Mb(s,e){return gi(s,e,t=>s.moveByGroup(t,e))}const zP=s=>Mb(s,!Cs(s)),ZP=s=>Mb(s,Cs(s)),VP=s=>{let e=!Cs(s);return gi(s,e,t=>hh(s.state,t,e))},FP=s=>{let e=Cs(s);return gi(s,e,t=>hh(s.state,t,e))};function Lb(s,e){return gi(s,e,t=>s.moveVertically(t,e))}const Nb=s=>Lb(s,!1),Db=s=>Lb(s,!0);function Ib(s,e){return gi(s,e,t=>s.moveVertically(t,e,$b(s).height))}const rO=s=>Ib(s,!1),nO=s=>Ib(s,!0),YP=s=>gi(s,!0,e=>Ur(s,e,!0)),UP=s=>gi(s,!1,e=>Ur(s,e,!1)),HP=s=>{let e=!Cs(s);return gi(s,e,t=>Ur(s,t,e))},GP=s=>{let e=Cs(s);return gi(s,e,t=>Ur(s,t,e))},KP=s=>gi(s,!1,e=>re.cursor(s.lineBlockAt(e.head).from)),JP=s=>gi(s,!0,e=>re.cursor(s.lineBlockAt(e.head).to)),oO=({state:s,dispatch:e})=>(e(Ti(s,{anchor:0})),!0),aO=({state:s,dispatch:e})=>(e(Ti(s,{anchor:s.doc.length})),!0),lO=({state:s,dispatch:e})=>(e(Ti(s,{anchor:s.selection.main.anchor,head:0})),!0),cO=({state:s,dispatch:e})=>(e(Ti(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),eT=({state:s,dispatch:e})=>(e(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),tT=({state:s,dispatch:e})=>{let t=dh(s).map(({from:i,to:r})=>re.range(i,Math.min(r+1,s.doc.length)));return e(s.update({selection:re.create(t),userEvent:"select"})),!0},sT=({state:s,dispatch:e})=>{let t=wo(s.selection,i=>{let r=kt(s),n=r.resolveStack(i.from,1);if(i.empty){let a=r.resolveStack(i.from,-1);a.node.from>=n.node.from&&a.node.to<=n.node.to&&(n=a)}for(let a=n;a;a=a.next){let{node:o}=a;if((o.from<i.from&&o.to>=i.to||o.to>i.to&&o.from<=i.from)&&a.next)return re.range(o.to,o.from)}return i});return t.eq(s.selection)?!1:(e(Ti(s,t)),!0)};function Bb(s,e){let{state:t}=s,i=t.selection,r=t.selection.ranges.slice();for(let n of t.selection.ranges){let a=t.doc.lineAt(n.head);if(e?a.to<s.state.doc.length:a.from>0)for(let o=n;;){let l=s.moveVertically(o,e);if(l.head<a.from||l.head>a.to){r.some(c=>c.head==l.head)||r.push(l);break}else{if(l.head==o.head)break;o=l}}}return r.length==i.ranges.length?!1:(s.dispatch(Ti(t,re.create(r,r.length-1))),!0)}const iT=s=>Bb(s,!1),rT=s=>Bb(s,!0),nT=({state:s,dispatch:e})=>{let t=s.selection,i=null;return t.ranges.length>1?i=re.create([t.main]):t.main.empty||(i=re.create([re.cursor(t.main.head)])),i?(e(Ti(s,i)),!0):!1};function Ya(s,e){if(s.state.readOnly)return!1;let t="delete.selection",{state:i}=s,r=i.changeByRange(n=>{let{from:a,to:o}=n;if(a==o){let l=e(n);l<a?(t="delete.backward",l=Xl(s,l,!1)):l>a&&(t="delete.forward",l=Xl(s,l,!0)),a=Math.min(a,l),o=Math.max(o,l)}else a=Xl(s,a,!1),o=Xl(s,o,!0);return a==o?{range:n}:{changes:{from:a,to:o},range:re.cursor(a,a<n.head?-1:1)}});return r.changes.empty?!1:(s.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?_e.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Xl(s,e,t){if(s instanceof _e)for(let i of s.state.facet(_e.atomicRanges).map(r=>r(s)))i.between(e,e,(r,n)=>{r<e&&n>e&&(e=t?n:r)});return e}const Wb=(s,e,t)=>Ya(s,i=>{let r=i.from,{state:n}=s,a=n.doc.lineAt(r),o,l;if(t&&!e&&r>a.from&&r<a.from+200&&!/[^ \t]/.test(o=a.text.slice(0,r-a.from))){if(o[o.length-1]==" ")return r-1;let c=ki(o,n.tabSize),d=c%Ec(n)||Ec(n);for(let u=0;u<d&&o[o.length-1-u]==" ";u++)r--;l=r}else l=cs(a.text,r-a.from,e,e)+a.from,l==r&&a.number!=(e?n.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(a.text.slice(l-a.from,r-a.from))&&(l=cs(a.text,l-a.from,!1,!1)+a.from);return l}),rf=s=>Wb(s,!1,!0),Xb=s=>Wb(s,!0,!1),qb=(s,e)=>Ya(s,t=>{let i=t.head,{state:r}=s,n=r.doc.lineAt(i),a=r.charCategorizer(i);for(let o=null;;){if(i==(e?n.to:n.from)){i==t.head&&n.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=cs(n.text,i-n.from,e)+n.from,c=n.text.slice(Math.min(i,l)-n.from,Math.max(i,l)-n.from),d=a(c);if(o!=null&&d!=o)break;(c!=" "||i!=t.head)&&(o=d),i=l}return i}),zb=s=>qb(s,!1),oT=s=>qb(s,!0),aT=s=>Ya(s,e=>{let t=s.lineBlockAt(e.head).to;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),lT=s=>Ya(s,e=>{let t=s.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),cT=s=>Ya(s,e=>{let t=s.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),hT=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:bt.of(["",""])},range:re.cursor(i.from)}));return e(s.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},dT=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let r=i.from,n=s.doc.lineAt(r),a=r==n.from?r-1:cs(n.text,r-n.from,!1)+n.from,o=r==n.to?r+1:cs(n.text,r-n.from,!0)+n.from;return{changes:{from:a,to:o,insert:s.doc.slice(r,o).append(s.doc.slice(a,r))},range:re.cursor(o)}});return t.changes.empty?!1:(e(s.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function dh(s){let e=[],t=-1;for(let i of s.selection.ranges){let r=s.doc.lineAt(i.from),n=s.doc.lineAt(i.to);if(!i.empty&&i.to==n.from&&(n=s.doc.lineAt(i.to-1)),t>=r.number){let a=e[e.length-1];a.to=n.to,a.ranges.push(i)}else e.push({from:r.from,to:n.to,ranges:[i]});t=n.number+1}return e}function Zb(s,e,t){if(s.readOnly)return!1;let i=[],r=[];for(let n of dh(s)){if(t?n.to==s.doc.length:n.from==0)continue;let a=s.doc.lineAt(t?n.to+1:n.from-1),o=a.length+1;if(t){i.push({from:n.to,to:a.to},{from:n.from,insert:a.text+s.lineBreak});for(let l of n.ranges)r.push(re.range(Math.min(s.doc.length,l.anchor+o),Math.min(s.doc.length,l.head+o)))}else{i.push({from:a.from,to:n.from},{from:n.to,insert:s.lineBreak+a.text});for(let l of n.ranges)r.push(re.range(l.anchor-o,l.head-o))}}return i.length?(e(s.update({changes:i,scrollIntoView:!0,selection:re.create(r,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}const uT=({state:s,dispatch:e})=>Zb(s,e,!1),fT=({state:s,dispatch:e})=>Zb(s,e,!0);function Vb(s,e,t){if(s.readOnly)return!1;let i=[];for(let n of dh(s))t?i.push({from:n.from,insert:s.doc.slice(n.from,n.to)+s.lineBreak}):i.push({from:n.to,insert:s.lineBreak+s.doc.slice(n.from,n.to)});let r=s.changes(i);return e(s.update({changes:r,selection:s.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const pT=({state:s,dispatch:e})=>Vb(s,e,!1),mT=({state:s,dispatch:e})=>Vb(s,e,!0),gT=s=>{if(s.state.readOnly)return!1;let{state:e}=s,t=e.changes(dh(e).map(({from:r,to:n})=>(r>0?r--:n<e.doc.length&&n++,{from:r,to:n}))),i=wo(e.selection,r=>{let n;if(s.lineWrapping){let a=s.lineBlockAt(r.head),o=s.coordsAtPos(r.head,r.assoc||1);o&&(n=a.bottom+s.documentTop-o.bottom+s.defaultLineHeight/2)}return s.moveVertically(r,!0,n)}).map(t);return s.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function OT(s,e){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=kt(s).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),n;return i&&r&&i.to<=e&&r.from>=e&&(n=i.type.prop(ot.closedBy))&&n.indexOf(r.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(r.from).from&&!/\S/.test(s.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const hO=Fb(!1),xT=Fb(!0);function Fb(s){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:n,to:a}=r,o=e.doc.lineAt(n),l=!s&&n==a&&OT(e,n);s&&(n=a=(a<=o.to?o:e.doc.lineAt(a)).to);let c=new nh(e,{simulateBreak:n,simulateDoubleBreak:!!l}),d=Gf(c,n);for(d==null&&(d=ki(/^\s*/.exec(e.doc.lineAt(n).text)[0],e.tabSize));a<o.to&&/\s/.test(o.text[a-o.from]);)a++;l?{from:n,to:a}=l:n>o.from&&n<o.from+100&&!/\S/.test(o.text.slice(0,n))&&(n=o.from);let u=["",Ta(e,d)];return l&&u.push(Ta(e,c.lineIndent(o.from,-1))),{changes:{from:n,to:a,insert:bt.of(u)},range:re.cursor(n+1+u[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function sp(s,e){let t=-1;return s.changeByRange(i=>{let r=[];for(let a=i.from;a<=i.to;){let o=s.doc.lineAt(a);o.number>t&&(i.empty||i.to>o.from)&&(e(o,r,i),t=o.number),a=o.to+1}let n=s.changes(r);return{changes:r,range:re.range(n.mapPos(i.anchor,1),n.mapPos(i.head,1))}})}const vT=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=Object.create(null),i=new nh(s,{overrideIndentation:n=>{let a=t[n];return a??-1}}),r=sp(s,(n,a,o)=>{let l=Gf(i,n.from);if(l==null)return;/\S/.test(n.text)||(l=0);let c=/^\s*/.exec(n.text)[0],d=Ta(s,l);(c!=d||o.from<n.from+c.length)&&(t[n.from]=l,a.push({from:n.from,to:n.from+c.length,insert:d}))});return r.changes.empty||e(s.update(r,{userEvent:"indent"})),!0},Yb=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(sp(s,(t,i)=>{i.push({from:t.from,insert:s.facet(_o)})}),{userEvent:"input.indent"})),!0),Ub=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(sp(s,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let n=ki(r,s.tabSize),a=0,o=Ta(s,Math.max(0,n-Ec(s)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;i.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:"delete.dedent"})),!0),bT=s=>(s.setTabFocusMode(),!0),yT=[{key:"Ctrl-b",run:wb,shift:Rb,preventDefault:!0},{key:"Ctrl-f",run:kb,shift:Ab},{key:"Ctrl-p",run:Tb,shift:Nb},{key:"Ctrl-n",run:Qb,shift:Db},{key:"Ctrl-a",run:BP,shift:KP},{key:"Ctrl-e",run:WP,shift:JP},{key:"Ctrl-d",run:Xb},{key:"Ctrl-h",run:rf},{key:"Ctrl-k",run:aT},{key:"Ctrl-Alt-h",run:zb},{key:"Ctrl-o",run:hT},{key:"Ctrl-t",run:dT},{key:"Ctrl-v",run:sf}],ST=[{key:"ArrowLeft",run:wb,shift:Rb,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:jP,shift:zP,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:DP,shift:HP,preventDefault:!0},{key:"ArrowRight",run:kb,shift:Ab,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:EP,shift:ZP,preventDefault:!0},{mac:"Cmd-ArrowRight",run:IP,shift:GP,preventDefault:!0},{key:"ArrowUp",run:Tb,shift:Nb,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oO,shift:lO},{mac:"Ctrl-ArrowUp",run:iO,shift:rO},{key:"ArrowDown",run:Qb,shift:Db,preventDefault:!0},{mac:"Cmd-ArrowDown",run:aO,shift:cO},{mac:"Ctrl-ArrowDown",run:sf,shift:nO},{key:"PageUp",run:iO,shift:rO},{key:"PageDown",run:sf,shift:nO},{key:"Home",run:NP,shift:UP,preventDefault:!0},{key:"Mod-Home",run:oO,shift:lO},{key:"End",run:LP,shift:YP,preventDefault:!0},{key:"Mod-End",run:aO,shift:cO},{key:"Enter",run:hO,shift:hO},{key:"Mod-a",run:eT},{key:"Backspace",run:rf,shift:rf,preventDefault:!0},{key:"Delete",run:Xb,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:zb,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:oT,preventDefault:!0},{mac:"Mod-Backspace",run:lT,preventDefault:!0},{mac:"Mod-Delete",run:cT,preventDefault:!0}].concat(yT.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),_T=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:AP,shift:VP},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:MP,shift:FP},{key:"Alt-ArrowUp",run:uT},{key:"Shift-Alt-ArrowUp",run:pT},{key:"Alt-ArrowDown",run:fT},{key:"Shift-Alt-ArrowDown",run:mT},{key:"Mod-Alt-ArrowUp",run:iT},{key:"Mod-Alt-ArrowDown",run:rT},{key:"Escape",run:nT},{key:"Mod-Enter",run:xT},{key:"Alt-l",mac:"Ctrl-l",run:tT},{key:"Mod-i",run:sT,preventDefault:!0},{key:"Mod-[",run:Ub},{key:"Mod-]",run:Yb},{key:"Mod-Alt-\\",run:vT},{key:"Shift-Mod-k",run:gT},{key:"Shift-Mod-\\",run:qP},{key:"Mod-/",run:uP},{key:"Alt-A",run:pP},{key:"Ctrl-m",mac:"Shift-Alt-m",run:bT}].concat(ST),wT={key:"Tab",run:Yb,shift:Ub},dO=typeof String.prototype.normalize=="function"?s=>s.normalize("NFKD"):s=>s;class xo{constructor(e,t,i=0,r=e.length,n,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=n?o=>n(dO(o)):dO,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Is(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=kf(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=qi(e);let r=this.normalize(t);if(r.length)for(let n=0,a=i,o=!0;;n++){let l=r.charCodeAt(n),c=this.match(l,a,o,this.bufferPos+this.bufferStart,n==r.length-1);if(c)return this.value=c,this;if(n==r.length-1)break;o&&n<t.length&&t.charCodeAt(n)==l?a++:o=!1}}}match(e,t,i,r,n){let a=null;for(let o=0;o<this.matches.length;){let l=this.matches[o],c=!1;this.query.charCodeAt(l.index)==e&&(l.index==this.query.length-1?a={from:l.from,to:r,precise:n&&l.precise}:(l.index++,c=!0)),c?o++:this.matches.splice(o,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:i&&n}:this.matches.push({from:t,index:1,precise:i})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}}typeof Symbol<"u"&&(xo.prototype[Symbol.iterator]=function(){return this});const Hb={from:-1,to:-1,match:/.*/.exec(""),precise:!0},ip="gm"+(/x/.unicode==null?"":"u");class Gb{constructor(e,t,i,r=0,n=e.length){if(this.text=e,this.to=n,this.curLine="",this.done=!1,this.value=Hb,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Kb(e,t,i,r,n);this.re=new RegExp(t,ip+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=Lc(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=Lc(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const kd=new WeakMap;class lo{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=kd.get(e);if(!r||r.from>=i||r.to<=t){let o=new lo(t,e.sliceString(t,i));return kd.set(e,o),o}if(r.from==t&&r.to==i)return r;let{text:n,from:a}=r;return a>t&&(n=e.sliceString(t,a)+n,a=t),r.to<i&&(n+=e.sliceString(r.to,i)),kd.set(e,new lo(a,n)),new lo(t,n.slice(t-a,i-a))}}class Kb{constructor(e,t,i,r,n){this.text=e,this.to=n,this.done=!1,this.value=Hb,this.matchPos=Lc(e,r),this.re=new RegExp(t,ip+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=lo.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,precise:!0,match:t},this.matchPos=Lc(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=lo.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Gb.prototype[Symbol.iterator]=Kb.prototype[Symbol.iterator]=function(){return this});function kT(s){try{return new RegExp(s,ip),!0}catch{return!1}}function Lc(s,e){if(e>=s.length)return e;let t=s.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}const CT=s=>{let{state:e}=s,t=String(e.doc.lineAt(s.state.selection.main.head).number),{close:i,result:r}=zC(s,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return r.then(n=>{let a=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!a){s.dispatch({effects:i});return}let o=e.doc.lineAt(e.selection.main.head),[,l,c,d,u]=a,f=d?+d.slice(1):0,g=c?+c:o.number;if(c&&u){let m=g/100;l&&(m=m*(l=="-"?-1:1)+o.number/e.doc.lines),g=Math.round(e.doc.lines*m)}else c&&l&&(g=g*(l=="-"?-1:1)+o.number);let b=e.doc.line(Math.max(1,Math.min(e.doc.lines,g))),v=re.cursor(b.from+Math.max(0,Math.min(f,b.length)));s.dispatch({effects:[i,_e.scrollIntoView(v.from,{y:"center"})],selection:v})}),!0},PT={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},TT=Ae.define({combine(s){return Ki(s,PT,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function QT(s){return[AT,RT]}const $T=ze.mark({class:"cm-selectionMatch"}),jT=ze.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function uO(s,e,t,i){return(t==0||s(e.sliceDoc(t-1,t))!=Mt.Word)&&(i==e.doc.length||s(e.sliceDoc(i,i+1))!=Mt.Word)}function ET(s,e,t,i){return s(e.sliceDoc(t,t+1))==Mt.Word&&s(e.sliceDoc(i-1,i))==Mt.Word}const RT=zt.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.selectionSet||s.docChanged||s.viewportChanged)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=s.state.facet(TT),{state:t}=s,i=t.selection;if(i.ranges.length>1)return ze.none;let r=i.main,n,a=null;if(r.empty){if(!e.highlightWordAroundCursor)return ze.none;let l=t.wordAt(r.head);if(!l)return ze.none;a=t.charCategorizer(r.head),n=t.sliceDoc(l.from,l.to)}else{let l=r.to-r.from;if(l<e.minSelectionLength||l>200)return ze.none;if(e.wholeWords){if(n=t.sliceDoc(r.from,r.to),a=t.charCategorizer(r.head),!(uO(a,t,r.from,r.to)&&ET(a,t,r.from,r.to)))return ze.none}else if(n=t.sliceDoc(r.from,r.to),!n)return ze.none}let o=[];for(let l of s.visibleRanges){let c=new xo(t.doc,n,l.from,l.to);for(;!c.next().done;){let{from:d,to:u}=c.value;if((!a||uO(a,t,d,u))&&(r.empty&&d<=r.from&&u>=r.to?o.push(jT.range(d,u)):(d>=r.to||u<=r.from)&&o.push($T.range(d,u)),o.length>e.maxMatches))return ze.none}}return ze.set(o)}},{decorations:s=>s.decorations}),AT=_e.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),MT=({state:s,dispatch:e})=>{let{selection:t}=s,i=re.create(t.ranges.map(r=>s.wordAt(r.head)||re.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(s.update({selection:i})),!0)};function LT(s,e){let{main:t,ranges:i}=s.selection,r=s.wordAt(t.head),n=r&&r.from==t.from&&r.to==t.to;for(let a=!1,o=new xo(s.doc,e,i[i.length-1].to);;)if(o.next(),o.done){if(a)return null;o=new xo(s.doc,e,0,Math.max(0,i[i.length-1].from-1)),a=!0}else{if(a&&i.some(l=>l.from==o.value.from))continue;if(n){let l=s.wordAt(o.value.from);if(!l||l.from!=o.value.from||l.to!=o.value.to)continue}return o.value}}const NT=({state:s,dispatch:e})=>{let{ranges:t}=s.selection;if(t.some(n=>n.from===n.to))return MT({state:s,dispatch:e});let i=s.sliceDoc(t[0].from,t[0].to);if(s.selection.ranges.some(n=>s.sliceDoc(n.from,n.to)!=i))return!1;let r=LT(s,i);return r?(e(s.update({selection:s.selection.addRange(re.range(r.from,r.to),!1),effects:_e.scrollIntoView(r.to)})),!0):!1},ko=Ae.define({combine(s){return Ki(s,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new GT(e),scrollToMatch:e=>_e.scrollIntoView(e)})}});class Jb{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||kT(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
16
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new qT(this):new BT(this)}getCursor(e,t=0,i){let r=e.doc?e:pt.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Hn(this,r,t,i):Un(this,r,t,i)}}class ey{constructor(e){this.spec=e}}function DT(s,e,t){return(i,r,n,a)=>{if(t&&!t(i,r,n,a))return!1;let o=i>=a&&r<=a+n.length?n.slice(i-a,r-a):e.doc.sliceString(i,r);return s(o,e,i,r)}}function Un(s,e,t,i){let r;return s.wholeWord&&(r=IT(e.doc,e.charCategorizer(e.selection.main.head))),s.test&&(r=DT(s.test,e,r)),new xo(e.doc,s.unquoted,t,i,s.caseSensitive?void 0:n=>n.toLowerCase(),r)}function IT(s,e){return(t,i,r,n)=>((n>t||n+r.length<i)&&(n=Math.max(0,t-2),r=s.sliceString(n,Math.min(s.length,i+2))),(e(Nc(r,t-n))!=Mt.Word||e(Dc(r,t-n))!=Mt.Word)&&(e(Dc(r,i-n))!=Mt.Word||e(Nc(r,i-n))!=Mt.Word))}class BT extends ey{constructor(e){super(e)}nextMatch(e,t,i){let r=Un(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=Un(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==i?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),a=Un(this.spec,e,n,r),o=null;for(;!a.nextOverlapping().done;)o=a.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,i){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=i)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Un(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let n=Un(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!n.next().done;)r(n.value.from,n.value.to)}}function WT(s,e,t){return(i,r,n)=>(!t||t(i,r,n))&&s(n[0],e,i,r)}function Hn(s,e,t,i){let r;return s.wholeWord&&(r=XT(e.charCategorizer(e.selection.main.head))),s.test&&(r=WT(s.test,e,r)),new Gb(e.doc,s.search,{ignoreCase:!s.caseSensitive,test:r},t,i)}function Nc(s,e){return s.slice(cs(s,e,!1),e)}function Dc(s,e){return s.slice(e,cs(s,e))}function XT(s){return(e,t,i)=>!i[0].length||(s(Nc(i.input,i.index))!=Mt.Word||s(Dc(i.input,i.index))!=Mt.Word)&&(s(Dc(i.input,i.index+i[0].length))!=Mt.Word||s(Nc(i.input,i.index+i[0].length))!=Mt.Word)}class qT extends ey{nextMatch(e,t,i){let r=Hn(this.spec,e,i,e.doc.length).next();return r.done&&(r=Hn(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let n=Math.max(t,i-r*1e4),a=Hn(this.spec,e,n,i),o=null;for(;!a.next().done;)o=a.value;if(o&&(n==t||o.from>n+10))return o;if(n==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let n=+i.slice(0,r);if(n>0&&n<e.match.length)return e.match[n]+i.slice(r)}return t})}matchAll(e,t){let i=Hn(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let n=Hn(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!n.next().done;)r(n.value.from,n.value.to)}}const Qa=nt.define(),rp=nt.define(),Ir=xs.define({create(s){return new Cd(nf(s).create(),null)},update(s,e){for(let t of e.effects)t.is(Qa)?s=new Cd(t.value.create(),s.panel):t.is(rp)&&(s=new Cd(s.query,t.value?np:null));return s},provide:s=>wa.from(s,e=>e.panel)});class Cd{constructor(e,t){this.query=e,this.panel=t}}const zT=ze.mark({class:"cm-searchMatch"}),ZT=ze.mark({class:"cm-searchMatch cm-searchMatch-selected"}),VT=zt.fromClass(class{constructor(s){this.view=s,this.decorations=this.highlight(s.state.field(Ir))}update(s){let e=s.state.field(Ir);(e!=s.startState.field(Ir)||s.docChanged||s.selectionSet||s.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:s,panel:e}){if(!e||!s.spec.valid)return ze.none;let{view:t}=this,i=new br;for(let r=0,n=t.visibleRanges,a=n.length;r<a;r++){let{from:o,to:l}=n[r];for(;r<a-1&&l>n[r+1].from-500;)l=n[++r].to;s.highlight(t.state,o,l,(c,d)=>{let u=t.state.selection.ranges.some(f=>f.from==c&&f.to==d);i.add(c,d,u?ZT:zT)})}return i.finish()}},{decorations:s=>s.decorations});function Ua(s){return e=>{let t=e.state.field(Ir,!1);return t&&t.query.spec.valid?s(e,t):iy(e)}}const Ic=Ua((s,{query:e})=>{let{to:t}=s.state.selection.main,i=e.nextMatch(s.state,t,t);if(!i)return!1;let r=re.single(i.from,i.to),n=s.state.facet(ko);return s.dispatch({selection:r,effects:[op(s,i),n.scrollToMatch(r.main,s)],userEvent:"select.search"}),sy(s),!0}),Bc=Ua((s,{query:e})=>{let{state:t}=s,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let n=re.single(r.from,r.to),a=s.state.facet(ko);return s.dispatch({selection:n,effects:[op(s,r),a.scrollToMatch(n.main,s)],userEvent:"select.search"}),sy(s),!0}),FT=Ua((s,{query:e})=>{let t=e.matchAll(s.state,1e3);return!t||!t.length?!1:(s.dispatch({selection:re.create(t.map(i=>re.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),YT=({state:s,dispatch:e})=>{let t=s.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,n=[],a=0;for(let o=new xo(s.doc,s.sliceDoc(i,r));!o.next().done;){if(n.length>1e3)return!1;o.value.from==i&&(a=n.length),n.push(re.range(o.value.from,o.value.to))}return e(s.update({selection:re.create(n,a),userEvent:"select.search.matches"})),!0},fO=Ua((s,{query:e})=>{let{state:t}=s,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let n=e.nextMatch(t,i,i);if(!n)return!1;let a=n,o=[],l,c,d=[];a.precise?a.from==i&&a.to==r&&(c=t.toText(e.getReplacement(a)),o.push({from:a.from,to:a.to,insert:c}),a=e.nextMatch(t,a.from,a.to),d.push(_e.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):a=e.nextMatch(t,a.from,a.to);let u=s.state.changes(o);return a&&(l=re.single(a.from,a.to).map(u),d.push(op(s,a)),d.push(t.facet(ko).scrollToMatch(l.main,s))),s.dispatch({changes:u,selection:l,effects:d,userEvent:"input.replace"}),!0}),UT=Ua((s,{query:e})=>{if(s.state.readOnly)return!1;let t=[];for(let r of e.matchAll(s.state,1e9)){let{from:n,to:a,precise:o}=r;o&&t.push({from:n,to:a,insert:e.getReplacement(r)})}if(!t.length)return!1;let i=s.state.phrase("replaced $ matches",t.length)+".";return s.dispatch({changes:t,effects:_e.announce.of(i),userEvent:"input.replace.all"}),!0});function np(s){return s.state.facet(ko).createPanel(s)}function nf(s,e){var t,i,r,n,a;let o=s.selection.main,l=o.empty||o.to>o.from+100?"":s.sliceDoc(o.from,o.to);if(e&&!l)return e;let c=s.facet(ko);return new Jb({search:((t=e?.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:c.literal,regexp:(n=e?.regexp)!==null&&n!==void 0?n:c.regexp,wholeWord:(a=e?.wholeWord)!==null&&a!==void 0?a:c.wholeWord})}function ty(s){let e=qf(s,np);return e&&e.dom.querySelector("[main-field]")}function sy(s){let e=ty(s);e&&e==s.root.activeElement&&e.select()}const iy=s=>{let e=s.state.field(Ir,!1);if(e&&e.panel){let t=ty(s);if(t&&t!=s.root.activeElement){let i=nf(s.state,e.query.spec);i.valid&&s.dispatch({effects:Qa.of(i)}),t.focus(),t.select()}}else s.dispatch({effects:[rp.of(!0),e?Qa.of(nf(s.state,e.query.spec)):nt.appendConfig.of(JT)]});return!0},ry=s=>{let e=s.state.field(Ir,!1);if(!e||!e.panel)return!1;let t=qf(s,np);return t&&t.dom.contains(s.root.activeElement)&&s.focus(),s.dispatch({effects:rp.of(!1)}),!0},HT=[{key:"Mod-f",run:iy,scope:"editor search-panel"},{key:"F3",run:Ic,shift:Bc,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Ic,shift:Bc,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ry,scope:"editor search-panel"},{key:"Mod-Shift-l",run:YT},{key:"Mod-Alt-g",run:CT},{key:"Mod-d",run:NT,preventDefault:!0}];class GT{constructor(e){this.view=e;let t=this.query=e.state.field(Ir).query.spec;this.commit=this.commit.bind(this),this.searchField=Tt("input",{value:t.search,placeholder:Us(e,"Find"),"aria-label":Us(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Tt("input",{value:t.replace,placeholder:Us(e,"Replace"),"aria-label":Us(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Tt("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Tt("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Tt("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,n,a){return Tt("button",{class:"cm-button",name:r,onclick:n,type:"button"},a)}this.dom=Tt("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>Ic(e),[Us(e,"next")]),i("prev",()=>Bc(e),[Us(e,"previous")]),i("select",()=>FT(e),[Us(e,"all")]),Tt("label",null,[this.caseField,Us(e,"match case")]),Tt("label",null,[this.reField,Us(e,"regexp")]),Tt("label",null,[this.wordField,Us(e,"by word")]),...e.state.readOnly?[]:[Tt("br"),this.replaceField,i("replace",()=>fO(e),[Us(e,"replace")]),i("replaceAll",()=>UT(e),[Us(e,"replace all")])],Tt("button",{name:"close",onclick:()=>ry(e),"aria-label":Us(e,"close"),type:"button"},["×"])])}commit(){let e=new Jb({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Qa.of(e)}))}keydown(e){Kk(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Bc:Ic)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),fO(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Qa)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ko).top}}function Us(s,e){return s.state.phrase(e)}const ql=30,zl=/[\s\.,:;?!]/;function op(s,{from:e,to:t}){let i=s.state.doc.lineAt(e),r=s.state.doc.lineAt(t).to,n=Math.max(i.from,e-ql),a=Math.min(r,t+ql),o=s.state.sliceDoc(n,a);if(n!=i.from){for(let l=0;l<ql;l++)if(!zl.test(o[l+1])&&zl.test(o[l])){o=o.slice(l);break}}if(a!=r){for(let l=o.length-1;l>o.length-ql;l--)if(!zl.test(o[l-1])&&zl.test(o[l])){o=o.slice(0,l);break}}return _e.announce.of(`${s.state.phrase("current match")}. ${o} ${s.state.phrase("on line")} ${i.number}.`)}const KT=_e.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),JT=[Ir,kr.low(VT),KT];class ap{constructor(e,t,i,r){this.state=e,this.pos=t,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=kt(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),n=r.search(oy(e,!1));return n<0?null:{from:i+n,to:this.pos,text:r.slice(n)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function pO(s){let e=Object.keys(s).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function eQ(s){let e=Object.create(null),t=Object.create(null);for(let{label:r}of s){e[r[0]]=!0;for(let n=1;n<r.length;n++)t[r[n]]=!0}let i=pO(e)+pO(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function lp(s){let e=s.map(r=>typeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:eQ(e);return r=>{let n=r.matchBefore(i);return n||r.explicit?{from:n?n.from:r.pos,options:e,validFor:t}:null}}function ny(s,e){return t=>{for(let i=kt(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(s.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class mO{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}}function Tn(s){return s.selection.main.from}function oy(s,e){var t;let{source:i}=s,r=e&&i[0]!="^",n=i[i.length-1]!="$";return!r&&!n?s:new RegExp(`${r?"^":""}(?:${i})${n?"$":""}`,(t=s.flags)!==null&&t!==void 0?t:s.ignoreCase?"i":"")}const cp=Gi.define();function tQ(s,e,t,i){let{main:r}=s.selection,n=t-r.from,a=i-r.from;return{...s.changeByRange(o=>{if(o!=r&&t!=i&&s.sliceDoc(o.from+n,o.from+a)!=s.sliceDoc(t,i))return{range:o};let l=s.toText(e);return{changes:{from:o.from+n,to:i==r.from?o.to:o.from+a,insert:l},range:re.cursor(o.from+n+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const gO=new WeakMap;function sQ(s){if(!Array.isArray(s))return s;let e=gO.get(s);return e||gO.set(s,e=lp(s)),e}const Wc=nt.define(),$a=nt.define();class iQ{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=Is(e,t),r=qi(i);this.chars.push(i);let n=e.slice(t,t+r),a=n.toUpperCase();this.folded.push(Is(a==n?n.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:r,precise:n,byWord:a}=this;if(t.length==1){let p=Is(e,0),x=qi(p),y=x==e.length?0:-100;if(p!=t[0])if(p==i[0])y+=-200;else return null;return this.ret(y,[0,x])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(o<0){for(let p=0,x=Math.min(e.length,200);p<x&&c<l;){let y=Is(e,p);(y==t[c]||y==i[c])&&(r[c++]=p),p+=qi(y)}if(c<l)return null}let d=0,u=0,f=!1,g=0,b=-1,v=-1,m=/[a-z]/.test(e),O=!0;for(let p=0,x=Math.min(e.length,200),y=0;p<x&&u<l;){let _=Is(e,p);o<0&&(d<l&&_==t[d]&&(n[d++]=p),g<l&&(_==t[g]||_==i[g]?(g==0&&(b=p),v=p+1,g++):g=0));let k,w=_<255?_>=48&&_<=57||_>=97&&_<=122?2:_>=65&&_<=90?1:0:(k=kf(_))!=k.toLowerCase()?1:k!=k.toUpperCase()?2:0;(!p||w==1&&m||y==0&&w!=0)&&(t[u]==_||i[u]==_&&(f=!0)?a[u++]=p:a.length&&(O=!1)),y=w,p+=qi(_)}return u==l&&a[0]==0&&O?this.result(-100+(f?-200:0),a,e):g==l&&b==0?this.ret(-200-e.length+(v==e.length?0:-100),[0,v]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):g==l?this.ret(-900-e.length,[b,v]):u==l?this.result(-100+(f?-200:0)+-700+(O?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],n=0;for(let a of t){let o=a+(this.astral?qi(Is(i,a)):1);n&&r[n-1]==a?r[n-1]=o:(r[n++]=a,r[n++]=o)}return this.ret(e-i.length,r)}}class rQ{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const ls=Ae.define({combine(s){return Ki(s,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:nQ,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>OO(e(i),t(i)),optionClass:(e,t)=>i=>OO(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function OO(s,e){return s?e?s+" "+e:s:e}function nQ(s,e,t,i,r,n){let a=s.textDirection==jt.RTL,o=a,l=!1,c="top",d,u,f=e.left-r.left,g=r.right-e.right,b=i.right-i.left,v=i.bottom-i.top;if(o&&f<Math.min(b,g)?o=!1:!o&&g<Math.min(b,f)&&(o=!0),b<=(o?f:g))d=Math.max(r.top,Math.min(t.top,r.bottom-v))-e.top,u=Math.min(400,o?f:g);else{l=!0,u=Math.min(400,(a?e.right:r.right-e.left)-30);let p=r.bottom-e.bottom;p>=v||p>e.top?d=t.bottom-e.top:(c="bottom",d=e.bottom-t.top)}let m=(e.bottom-e.top)/n.offsetHeight,O=(e.right-e.left)/n.offsetWidth;return{style:`${c}: ${d/m}px; max-width: ${u/O}px`,class:"cm-completionInfo-"+(l?a?"left-narrow":"right-narrow":o?"left":"right")}}const hp=nt.define();function oQ(s){let e=s.addToOptions.slice();return s.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,n){let a=document.createElement("span");a.className="cm-completionLabel";let o=t.displayLabel||t.label,l=0;for(let c=0;c<n.length;){let d=n[c++],u=n[c++];d>l&&a.appendChild(document.createTextNode(o.slice(l,d)));let f=a.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(d,u))),f.className="cm-completionMatchedText",l=u}return l<o.length&&a.appendChild(document.createTextNode(o.slice(l))),a},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function Pd(s,e,t){if(s<=t)return{from:0,to:s};if(e<0&&(e=0),e<=s>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.ceil((s-e)/t);return{from:s-i*t,to:s-(i-1)*t}}class aQ{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:n,selected:a}=r.open,o=e.state.facet(ls);this.optionContent=oQ(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Pd(n.length,a,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let d=l.target,u;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(u=/-(\d+)$/.exec(d.id))&&+u[1]<c.length){this.applyCompletion(e,c[+u[1]]),l.preventDefault();return}if(l.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:hp.of(d)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(ls).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:$a.of(null)})}),this.showOptions(n,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:n,selected:a,disabled:o}=i.open;(!r.open||r.open.options!=n)&&(this.range=Pd(n.length,a,e.state.facet(ls).maxRenderedOptions),this.showOptions(n,i.id)),this.updateSel(),o!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Pd(t.options.length,t.selected,this.view.state.facet(ls).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:n}=r;if(!n)return;let a=typeof n=="string"?document.createTextNode(n):n(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,r)}).catch(o=>Xs(this.view.state,o,"completion info")):(this.addInfoPane(a,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:n}=e;i.appendChild(r),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&cQ(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),n=this.space;if(!n){let a=this.dom.ownerDocument.documentElement;n={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return r.top>Math.min(n.bottom,t.bottom)-10||r.bottom<Math.max(n.top,t.top)+10?null:this.view.state.facet(ls).positionInfo(this.view,t,r,i,n,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",a=>{a.target==r&&a.preventDefault()});let n=null;for(let a=i.from;a<i.to;a++){let{completion:o,match:l}=e[a],{section:c}=o;if(c){let f=typeof c=="string"?c:c.name;if(f!=n&&(a>i.from||i.from==0))if(n=f,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let g=r.appendChild(document.createElement("completion-section"));g.textContent=f}}const d=r.appendChild(document.createElement("li"));d.id=t+"-"+a,d.setAttribute("role","option");let u=this.optionClass(o);u&&(d.className=u);for(let f of this.optionContent){let g=f(o,this.view.state,this.view,l);g&&d.appendChild(g)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function lQ(s,e){return t=>new aQ(t,s,e)}function cQ(s,e){let t=s.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/s.offsetHeight;i.top<t.top?s.scrollTop-=(t.top-i.top)/r:i.bottom>t.bottom&&(s.scrollTop+=(i.bottom-t.bottom)/r)}function xO(s){return(s.boost||0)*100+(s.apply?10:0)+(s.info?5:0)+(s.type?1:0)}function hQ(s,e){let t=[],i=null,r=null,n=d=>{t.push(d);let{section:u}=d.completion;if(u){i||(i=[]);let f=typeof u=="string"?u:u.name;i.some(g=>g.name==f)||i.push(typeof u=="string"?{name:f}:u)}},a=e.facet(ls);for(let d of s)if(d.hasResult()){let u=d.result.getMatch;if(d.result.filter===!1)for(let f of d.result.options)n(new mO(f,d.source,u?u(f):[],1e9-t.length));else{let f=e.sliceDoc(d.from,d.to),g,b=a.filterStrict?new rQ(f):new iQ(f);for(let v of d.result.options)if(g=b.match(v.label)){let m=v.displayLabel?u?u(v,g.matched):[]:g.matched,O=g.score+(v.boost||0);if(n(new mO(v,d.source,m,O)),typeof v.section=="object"&&v.section.rank==="dynamic"){let{name:p}=v.section;r||(r=Object.create(null)),r[p]=Math.max(O,r[p]||-1e9)}}}}if(i){let d=Object.create(null),u=0,f=(g,b)=>(g.rank==="dynamic"&&b.rank==="dynamic"?r[b.name]-r[g.name]:0)||(typeof g.rank=="number"?g.rank:1e9)-(typeof b.rank=="number"?b.rank:1e9)||(g.name<b.name?-1:1);for(let g of i.sort(f))u-=1e5,d[g.name]=u;for(let g of t){let{section:b}=g.completion;b&&(g.score+=d[typeof b=="string"?b:b.name])}}let o=[],l=null,c=a.compareCompletions;for(let d of t.sort((u,f)=>f.score-u.score||c(u.completion,f.completion))){let u=d.completion;!l||l.label!=u.label||l.detail!=u.detail||l.type!=null&&u.type!=null&&l.type!=u.type||l.apply!=u.apply||l.boost!=u.boost?o.push(d):xO(d.completion)>xO(l)&&(o[o.length-1]=d),l=d.completion}return o}class eo{constructor(e,t,i,r,n,a){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=n,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new eo(this.options,vO(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,n,a){if(r&&!a&&e.some(c=>c.isPending))return r.setDisabled();let o=hQ(e,t);if(!o.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let l=t.facet(ls).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let c=r.options[r.selected].completion;for(let d=0;d<o.length;d++)if(o[d].completion==c){l=d;break}}return new eo(o,vO(i,l),{pos:e.reduce((c,d)=>d.hasResult()?Math.min(c,d.from):c,1e8),create:gQ,above:n.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new eo(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new eo(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Xc{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Xc(pQ,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(ls),n=(i.override||t.languageDataAt("autocomplete",Tn(t)).map(sQ)).map(l=>(this.active.find(d=>d.source==l)||new mi(l,this.active.some(d=>d.state!=0)?1:0)).update(e,i));n.length==this.active.length&&n.every((l,c)=>l==this.active[c])&&(n=this.active);let a=this.open,o=e.effects.some(l=>l.is(dp));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||n.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!dQ(n,this.active)||o?a=eo.build(n,t,this.id,a,i,o):a&&a.disabled&&!n.some(l=>l.isPending)&&(a=null),!a&&n.every(l=>!l.isPending)&&n.some(l=>l.hasResult())&&(n=n.map(l=>l.hasResult()?new mi(l.source,0):l));for(let l of e.effects)l.is(hp)&&(a=a&&a.setSelected(l.value,this.id));return n==this.active&&a==this.open?this:new Xc(n,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?uQ:fQ}}function dQ(s,e){if(s==e)return!0;for(let t=0,i=0;;){for(;t<s.length&&!s[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let r=t==s.length,n=i==e.length;if(r||n)return r==n;if(s[t++].result!=e[i++].result)return!1}}const uQ={"aria-autocomplete":"list"},fQ={};function vO(s,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":s};return e>-1&&(t["aria-activedescendant"]=s+"-"+e),t}const pQ=[];function ay(s,e){if(s.isUserEvent("input.complete")){let i=s.annotation(cp);if(i&&e.activateOnCompletion(i))return 12}let t=s.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:s.isUserEvent("delete.backward")?2:s.selection?8:s.docChanged?16:0}class mi{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=ay(e,t),r=this;(i&8||i&16&&this.touches(e))&&(r=new mi(r.source,0)),i&4&&r.state==0&&(r=new mi(this.source,1)),r=r.updateFor(e,i);for(let n of e.effects)if(n.is(Wc))r=new mi(r.source,1,n.value);else if(n.is($a))r=new mi(r.source,0);else if(n.is(dp))for(let a of n.value)a.source==r.source&&(r=a);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Tn(e.state))}}class co extends mi{constructor(e,t,i,r,n,a){super(e,3,t),this.limit=i,this.result=r,this.from=n,this.to=a}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let n=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),o=Tn(e.state);if(o>a||!r||t&2&&(Tn(e.startState)==this.from||o<this.limit))return new mi(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return mQ(r.validFor,e.state,n,a)?new co(this.source,this.explicit,l,r,n,a):r.update&&(r=r.update(r,n,a,new ap(e.state,o,!1)))?new co(this.source,this.explicit,l,r,r.from,(i=r.to)!==null&&i!==void 0?i:Tn(e.state)):new mi(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new co(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new mi(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function mQ(s,e,t,i){if(!s)return!1;let r=e.sliceDoc(t,i);return typeof s=="function"?s(r,t,i,e):oy(s,!0).test(r)}const dp=nt.define({map(s,e){return s.map(t=>t.map(e))}}),Bs=xs.define({create(){return Xc.start()},update(s,e){return s.update(e)},provide:s=>[Xf.from(s,e=>e.tooltip),_e.contentAttributes.from(s,e=>e.attrs)]});function up(s,e){const t=e.completion.apply||e.completion.label;let i=s.state.field(Bs).active.find(r=>r.source==e.source);return i instanceof co?(typeof t=="string"?s.dispatch({...tQ(s.state,t,i.from,i.to),annotations:cp.of(e.completion)}):t(s,e.completion,i.from,i.to),!0):!1}const gQ=lQ(Bs,up);function Zl(s,e="option"){return t=>{let i=t.state.field(Bs,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(ls).interactionDelay)return!1;let r=1,n;e=="page"&&(n=Xv(t,i.open.tooltip))&&(r=Math.max(2,Math.floor(n.dom.offsetHeight/n.dom.querySelector("li").offsetHeight)-1));let{length:a}=i.open.options,o=i.open.selected>-1?i.open.selected+r*(s?1:-1):s?0:a-1;return o<0?o=e=="page"?0:a-1:o>=a&&(o=e=="page"?a-1:0),t.dispatch({effects:hp.of(o)}),!0}}const OQ=s=>{let e=s.state.field(Bs,!1);return s.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<s.state.facet(ls).interactionDelay?!1:up(s,e.open.options[e.open.selected])},Td=s=>s.state.field(Bs,!1)?(s.dispatch({effects:Wc.of(!0)}),!0):!1,xQ=s=>{let e=s.state.field(Bs,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(s.dispatch({effects:$a.of(null)}),!0)};class vQ{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const bQ=50,yQ=1e3,SQ=zt.fromClass(class{constructor(s){this.view=s,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of s.state.field(Bs).active)e.isPending&&this.startQuery(e)}update(s){let e=s.state.field(Bs),t=s.state.facet(ls);if(!s.selectionSet&&!s.docChanged&&s.startState.field(Bs)==e)return;let i=s.transactions.some(n=>{let a=ay(n,t);return a&8||(n.selection||n.docChanged)&&!(a&3)});for(let n=0;n<this.running.length;n++){let a=this.running[n];if(i||a.context.abortOnDocChange&&s.docChanged||a.updates.length+s.transactions.length>bQ&&Date.now()-a.time>yQ){for(let o of a.context.abortListeners)try{o()}catch(l){Xs(this.view.state,l)}a.context.abortListeners=null,this.running.splice(n--,1)}else a.updates.push(...s.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),s.transactions.some(n=>n.effects.some(a=>a.is(Wc)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(n=>n.isPending&&!this.running.some(a=>a.active.source==n.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let n of s.transactions)n.isUserEvent("input.type")?this.composing=2:this.composing==2&&n.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:s}=this.view,e=s.field(Bs);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ls).updateSyncTime))}startQuery(s){let{state:e}=this.view,t=Tn(e),i=new ap(e,t,s.explicit,this.view),r=new vQ(s,i);this.running.push(r),Promise.resolve(s.source(i)).then(n=>{r.context.aborted||(r.done=n||null,this.scheduleAccept())},n=>{this.view.dispatch({effects:$a.of(null)}),Xs(this.view.state,n)})}scheduleAccept(){this.running.every(s=>s.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ls).updateSyncTime))}accept(){var s;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ls),i=this.view.state.field(Bs);for(let r=0;r<this.running.length;r++){let n=this.running[r];if(n.done===void 0)continue;if(this.running.splice(r--,1),n.done){let o=Tn(n.updates.length?n.updates[0].startState:this.view.state),l=Math.min(o,n.done.from+(n.active.explicit?0:1)),c=new co(n.active.source,n.active.explicit,l,n.done,n.done.from,(s=n.done.to)!==null&&s!==void 0?s:o);for(let d of n.updates)c=c.update(d,t);if(c.hasResult()){e.push(c);continue}}let a=i.active.find(o=>o.source==n.active.source);if(a&&a.isPending)if(n.done==null){let o=new mi(n.active.source,0);for(let l of n.updates)o=o.update(l,t);o.isPending||e.push(o)}else this.startQuery(a)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:dp.of(e)})}},{eventHandlers:{blur(s){let e=this.view.state.field(Bs,!1);if(e&&e.tooltip&&this.view.state.facet(ls).closeOnBlur){let t=e.open&&Xv(this.view,e.open.tooltip);(!t||!t.dom.contains(s.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:$a.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Wc.of(!1)}),20),this.composing=0}}}),_Q=typeof navigator=="object"&&/Win/.test(navigator.platform),wQ=kr.highest(_e.domEventHandlers({keydown(s,e){let t=e.state.field(Bs,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||s.key.length>1||s.ctrlKey&&!(_Q&&s.altKey)||s.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(a=>a.source==i.source),n=i.completion.commitCharacters||r.result.commitCharacters;return n&&n.indexOf(s.key)>-1&&up(e,i),!1}})),ly=_e.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class kQ{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}}class fp{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,gs.TrackDel),i=e.mapPos(this.to,1,gs.TrackDel);return t==null||i==null?null:new fp(this.field,t,i)}}class pp{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],n=e.doc.lineAt(t),a=/^\s*/.exec(n.text)[0];for(let l of this.lines){if(i.length){let c=a,d=/^\t*/.exec(l)[0].length;for(let u=0;u<d;u++)c+=e.facet(_o);r.push(t+c.length-d),l=c+l.slice(d)}i.push(l),t+=l.length+1}let o=this.fieldPositions.map(l=>new fp(l.field,r[l.line]+l.from,r[l.line]+l.to));return{text:i,ranges:o}}static parse(e){let t=[],i=[],r=[],n;for(let a of e.split(/\r\n?|\n/)){for(;n=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(a);){let o=n[1]?+n[1]:null,l=n[2]||n[3]||"",c=-1;o===0&&(o=1e9);let d=l.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u<t.length;u++)(o!=null?t[u].seq==o:d&&t[u].name==d)&&(c=u);if(c<0){let u=0;for(;u<t.length&&(o==null||t[u].seq!=null&&t[u].seq<o);)u++;t.splice(u,0,{seq:o,name:d}),c=u;for(let f of r)f.field>=c&&f.field++}for(let u of r)if(u.line==i.length&&u.from>n.index){let f=n[2]?3+(n[1]||"").length:2;u.from-=f,u.to-=f}r.push(new kQ(c,i.length,n.index,n.index+d.length)),a=a.slice(0,n.index)+l+a.slice(n.index+n[0].length)}a=a.replace(/\\([{}])/g,(o,l,c)=>{for(let d of r)d.line==i.length&&d.from>c&&(d.from--,d.to--);return l}),i.push(a)}return new pp(i,r)}}let CQ=ze.widget({widget:new class extends Pi{toDOM(){let s=document.createElement("span");return s.className="cm-snippetFieldPosition",s}ignoreEvent(){return!1}}}),PQ=ze.mark({class:"cm-snippetField"});class Co{constructor(e,t){this.ranges=e,this.active=t,this.deco=ze.set(e.map(i=>(i.from==i.to?CQ:PQ).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new Co(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const Ha=nt.define({map(s,e){return s&&s.map(e)}}),TQ=nt.define(),ja=xs.define({create(){return null},update(s,e){for(let t of e.effects){if(t.is(Ha))return t.value;if(t.is(TQ)&&s)return new Co(s.ranges,t.value)}return s&&e.docChanged&&(s=s.map(e.changes)),s&&e.selection&&!s.selectionInsideField(e.selection)&&(s=null),s},provide:s=>_e.decorations.from(s,e=>e?e.deco:ze.none)});function mp(s,e){return re.create(s.filter(t=>t.field==e).map(t=>re.range(t.from,t.to)))}function QQ(s){let e=pp.parse(s);return(t,i,r,n)=>{let{text:a,ranges:o}=e.instantiate(t.state,r),{main:l}=t.state.selection,c={changes:{from:r,to:n==l.from?l.to:n,insert:bt.of(a)},scrollIntoView:!0,annotations:i?[cp.of(i),Kt.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=mp(o,0)),o.some(d=>d.field>0)){let d=new Co(o,0),u=c.effects=[Ha.of(d)];t.state.field(ja,!1)===void 0&&u.push(nt.appendConfig.of([ja,AQ,MQ,ly]))}t.dispatch(t.state.update(c))}}function cy(s){return({state:e,dispatch:t})=>{let i=e.field(ja,!1);if(!i||s<0&&i.active==0)return!1;let r=i.active+s,n=s>0&&!i.ranges.some(a=>a.field==r+s);return t(e.update({selection:mp(i.ranges,r),effects:Ha.of(n?null:new Co(i.ranges,r)),scrollIntoView:!0})),!0}}const $Q=({state:s,dispatch:e})=>s.field(ja,!1)?(e(s.update({effects:Ha.of(null)})),!0):!1,jQ=cy(1),EQ=cy(-1),RQ=[{key:"Tab",run:jQ,shift:EQ},{key:"Escape",run:$Q}],bO=Ae.define({combine(s){return s.length?s[0]:RQ}}),AQ=kr.highest(So.compute([bO],s=>s.facet(bO)));function Wt(s,e){return{...e,apply:QQ(s)}}const MQ=_e.domEventHandlers({mousedown(s,e){let t=e.state.field(ja,!1),i;if(!t||(i=e.posAtCoords({x:s.clientX,y:s.clientY}))==null)return!1;let r=t.ranges.find(n=>n.from<=i&&n.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:mp(t.ranges,r.field),effects:Ha.of(t.ranges.some(n=>n.field>r.field)?new Co(t.ranges,r.field):null),scrollIntoView:!0}),!0)}}),Ea={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Cn=nt.define({map(s,e){let t=e.mapPos(s,-1,gs.TrackAfter);return t??void 0}}),gp=new class extends Br{};gp.startSide=1;gp.endSide=-1;const hy=xs.define({create(){return ft.empty},update(s,e){if(s=s.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);s=s.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Cn)&&(s=s.update({add:[gp.range(t.value,t.value+1)]}));return s}});function LQ(){return[DQ,hy]}const Qd="()[]{}<>«»»«[]{}";function dy(s){for(let e=0;e<Qd.length;e+=2)if(Qd.charCodeAt(e)==s)return Qd.charAt(e+1);return kf(s<128?s:s+1)}function uy(s,e){return s.languageDataAt("closeBrackets",e)[0]||Ea}const NQ=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),DQ=_e.inputHandler.of((s,e,t,i)=>{if((NQ?s.composing:s.compositionStarted)||s.state.readOnly)return!1;let r=s.state.selection.main;if(i.length>2||i.length==2&&qi(Is(i,0))==1||e!=r.from||t!=r.to)return!1;let n=WQ(s.state,i);return n?(s.dispatch(n),!0):!1}),IQ=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let i=uy(s,s.selection.main.head).brackets||Ea.brackets,r=null,n=s.changeByRange(a=>{if(a.empty){let o=XQ(s.doc,a.head);for(let l of i)if(l==o&&uh(s.doc,a.head)==dy(Is(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:re.cursor(a.head-l.length)}}return{range:r=a}});return r||e(s.update(n,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},BQ=[{key:"Backspace",run:IQ}];function WQ(s,e){let t=uy(s,s.selection.main.head),i=t.brackets||Ea.brackets;for(let r of i){let n=dy(Is(r,0));if(e==r)return n==r?ZQ(s,r,i.indexOf(r+r+r)>-1,t):qQ(s,r,n,t.before||Ea.before);if(e==n&&fy(s,s.selection.main.from))return zQ(s,r,n)}return null}function fy(s,e){let t=!1;return s.field(hy).between(0,s.doc.length,i=>{i==e&&(t=!0)}),t}function uh(s,e){let t=s.sliceString(e,e+2);return t.slice(0,qi(Is(t,0)))}function XQ(s,e){let t=s.sliceString(e-2,e);return qi(Is(t,0))==t.length?t:t.slice(1)}function qQ(s,e,t,i){let r=null,n=s.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:Cn.of(a.to+e.length),range:re.range(a.anchor+e.length,a.head+e.length)};let o=uh(s.doc,a.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:e+t,from:a.head},effects:Cn.of(a.head+e.length),range:re.cursor(a.head+e.length)}:{range:r=a}});return r?null:s.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function zQ(s,e,t){let i=null,r=s.changeByRange(n=>n.empty&&uh(s.doc,n.head)==t?{changes:{from:n.head,to:n.head+t.length,insert:t},range:re.cursor(n.head+t.length)}:i={range:n});return i?null:s.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ZQ(s,e,t,i){let r=i.stringPrefixes||Ea.stringPrefixes,n=null,a=s.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:e,from:o.to}],effects:Cn.of(o.to+e.length),range:re.range(o.anchor+e.length,o.head+e.length)};let l=o.head,c=uh(s.doc,l),d;if(c==e){if(yO(s,l))return{changes:{insert:e+e,from:l},effects:Cn.of(l+e.length),range:re.cursor(l+e.length)};if(fy(s,l)){let f=t&&s.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+f.length,insert:f},range:re.cursor(l+f.length)}}}else{if(t&&s.sliceDoc(l-2*e.length,l)==e+e&&(d=SO(s,l-2*e.length,r))>-1&&yO(s,d))return{changes:{insert:e+e+e+e,from:l},effects:Cn.of(l+e.length),range:re.cursor(l+e.length)};if(s.charCategorizer(l)(c)!=Mt.Word&&SO(s,l,r)>-1&&!VQ(s,l,e,r))return{changes:{insert:e+e,from:l},effects:Cn.of(l+e.length),range:re.cursor(l+e.length)}}return{range:n=o}});return n?null:s.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function yO(s,e){let t=kt(s).resolveInner(e+1);return t.parent&&t.from==e}function VQ(s,e,t,i){let r=kt(s).resolveInner(e,-1),n=i.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=s.sliceDoc(r.from,Math.min(r.to,r.from+t.length+n)),l=o.indexOf(t);if(!l||l>-1&&i.indexOf(o.slice(0,l))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>t.length+l;){if(s.sliceDoc(d.to-t.length,d.to)==t)return!1;d=d.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function SO(s,e,t){let i=s.charCategorizer(e);if(i(s.sliceDoc(e-1,e))!=Mt.Word)return e;for(let r of t){let n=e-r.length;if(s.sliceDoc(n,e)==r&&i(s.sliceDoc(n-1,n))!=Mt.Word)return n}return-1}function FQ(s={}){return[wQ,Bs,ls.of(s),SQ,YQ,ly]}const py=[{key:"Ctrl-Space",run:Td},{mac:"Alt-`",run:Td},{mac:"Alt-i",run:Td},{key:"Escape",run:xQ},{key:"ArrowDown",run:Zl(!0)},{key:"ArrowUp",run:Zl(!1)},{key:"PageDown",run:Zl(!0,"page")},{key:"PageUp",run:Zl(!1,"page")},{key:"Enter",run:OQ}],YQ=kr.highest(So.computeN([ls],s=>s.facet(ls).defaultKeymap?[py]:[]));class _O{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Sn{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(Ra).markerFilter;r&&(e=r(e,i));let n=e.slice().sort((g,b)=>g.from-b.from||g.to-b.to),a=new br,o=[],l=0,c=i.doc.iter(),d=0,u=i.doc.length;for(let g=0;;){let b=g==n.length?null:n[g];if(!b&&!o.length)break;let v,m;if(o.length)v=l,m=o.reduce((x,y)=>Math.min(x,y.to),b&&b.from>v?b.from:1e8);else{if(v=b.from,v>u)break;m=b.to,o.push(b),g++}for(;g<n.length;){let x=n[g];if(x.from==v&&(x.to>x.from||x.to==v))o.push(x),g++,m=Math.min(x.to,m);else{m=Math.min(x.from,m);break}}m=Math.min(m,u);let O=!1;if(o.some(x=>x.from==v&&(x.to==m||m==u))&&(O=v==m,!O&&m-v<10)){let x=v-(d+c.value.length);x>0&&(c.next(x),d=v);for(let y=v;;){if(y>=m){O=!0;break}if(!c.lineBreak&&d+c.value.length>y)break;y=d+c.value.length,d+=c.value.length,c.next()}}let p=a$(o);if(O)a.add(v,v,ze.widget({widget:new i$(p),diagnostics:o.slice()}));else{let x=o.reduce((y,_)=>_.markClass?y+" "+_.markClass:y,"");a.add(v,m,ze.mark({class:"cm-lintRange cm-lintRange-"+p+x,diagnostics:o.slice(),inclusiveEnd:o.some(y=>y.to>m)}))}if(l=m,l==u)break;for(let x=0;x<o.length;x++)o[x].to<=l&&o.splice(x--,1)}let f=a.finish();return new Sn(f,t,Fr(f))}}function Fr(s,e=null,t=0){let i=null;return s.between(t,1e9,(r,n,{spec:a})=>{if(!(e&&a.diagnostics.indexOf(e)<0))if(!i)i=new _O(r,n,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new _O(i.from,n,i.diagnostic)}}),i}function UQ(s,e){let t=e.pos,i=e.end||t,r=s.state.facet(Ra).hideOn(s,t,i);if(r!=null)return r;let n=s.startState.doc.lineAt(e.pos);return!!(s.effects.some(a=>a.is(my))||s.changes.touchesRange(n.from,Math.max(n.to,i)))}function HQ(s,e){return s.field(ti,!1)?e:e.concat(nt.appendConfig.of(l$))}const my=nt.define(),Op=nt.define(),gy=nt.define(),ti=xs.define({create(){return new Sn(ze.none,null,null)},update(s,e){if(e.docChanged&&s.diagnostics.size){let t=s.diagnostics.map(e.changes),i=null,r=s.panel;if(s.selected){let n=e.changes.mapPos(s.selected.from,1);i=Fr(t,s.selected.diagnostic,n)||Fr(t,null,n)}!t.size&&r&&e.state.facet(Ra).autoPanel&&(r=null),s=new Sn(t,r,i)}for(let t of e.effects)if(t.is(my)){let i=e.state.facet(Ra).autoPanel?t.value.length?Aa.open:null:s.panel;s=Sn.init(t.value,i,e.state)}else t.is(Op)?s=new Sn(s.diagnostics,t.value?Aa.open:null,s.selected):t.is(gy)&&(s=new Sn(s.diagnostics,s.panel,t.value));return s},provide:s=>[wa.from(s,e=>e.panel),_e.decorations.from(s,e=>e.diagnostics)]}),GQ=ze.mark({class:"cm-lintRange cm-lintRange-active"});function KQ(s,e,t){let{diagnostics:i}=s.state.field(ti),r,n=-1,a=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:d})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(e<c||t<0)))return r=d.diagnostics,n=l,a=c,!1});let o=s.state.facet(Ra).tooltipFilter;return r&&o&&(r=o(r,s.state)),r?{pos:n,end:a,above:!0,create(){return{dom:JQ(s,r)}}}:null}function JQ(s,e){return Tt("ul",{class:"cm-tooltip-lint"},e.map(t=>xy(s,t,!1)))}const e$=s=>{let e=s.state.field(ti,!1);(!e||!e.panel)&&s.dispatch({effects:HQ(s.state,[Op.of(!0)])});let t=qf(s,Aa.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},wO=s=>{let e=s.state.field(ti,!1);return!e||!e.panel?!1:(s.dispatch({effects:Op.of(!1)}),!0)},t$=s=>{let e=s.state.field(ti,!1);if(!e)return!1;let t=s.state.selection.main,i=Fr(e.diagnostics,null,t.to+1);return!i&&(i=Fr(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(s.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),XC(s,i.from,1,{tooltip:vy,until:r=>r.docChanged||r.newSelection.main.head<i.from||r.newSelection.main.head>i.to}),!0)},s$=[{key:"Mod-Shift-m",run:e$,preventDefault:!0},{key:"F8",run:t$}],Ra=Ae.define({combine(s){return{sources:s.map(e=>e.source).filter(e=>e!=null),...Ki(s.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:kO,tooltipFilter:kO,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,n)=>e(i,r,n)||t(i,r,n):e:t,autoPanel:(e,t)=>e||t})}}});function kO(s,e){return s?e?(t,i)=>e(s(t,i),i):s:e}function Oy(s){let e=[];if(s)e:for(let{name:t}of s){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(n=>n.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function xy(s,e,t){var i;let r=t?Oy(e.actions):[];return Tt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Tt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(s):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((n,a)=>{let o=!1,l=g=>{if(g.preventDefault(),o)return;o=!0;let b=Fr(s.state.field(ti).diagnostics,e);b&&n.apply(s,b.from,b.to)},{name:c}=n,d=r[a]?c.indexOf(r[a]):-1,u=d<0?c:[c.slice(0,d),Tt("u",c.slice(d,d+1)),c.slice(d+1)],f=n.markClass?" "+n.markClass:"";return Tt("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${d<0?"":` (access key "${r[a]})"`}.`},u)}),e.source&&Tt("div",{class:"cm-diagnosticSource"},e.source))}class i$ extends Pi{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Tt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class CO{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=xy(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Aa{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)wO(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],a=Oy(n.actions);for(let o=0;o<a.length;o++)if(a[o].toUpperCase().charCodeAt(0)==r.keyCode){let l=Fr(this.view.state.field(ti).diagnostics,n);l&&n.actions[o].apply(e,l.from,l.to)}}else return;r.preventDefault()}},i=r=>{for(let n=0;n<this.items.length;n++)this.items[n].dom.contains(r.target)&&this.moveSelection(n)};this.list=Tt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=Tt("div",{class:"cm-panel-lint"},this.list,Tt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>wO(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ti).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(ti),i=0,r=!1,n=null,a=new Set;for(e.between(0,this.view.state.doc.length,(o,l,{spec:c})=>{for(let d of c.diagnostics){if(a.has(d))continue;a.add(d);let u=-1,f;for(let g=i;g<this.items.length;g++)if(this.items[g].diagnostic==d){u=g;break}u<0?(f=new CO(this.view,d),this.items.splice(i,0,f),r=!0):(f=this.items[u],u>i&&(this.items.splice(i,u-i),r=!0)),t&&f.diagnostic==t.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),n=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new CO(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let c=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/c:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(ti),i=Fr(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:gy.of(i)})}static open(e){return new Aa(e)}}function r$(s,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(s)}</svg>')`}function Vl(s){return r$(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const n$=_e.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Vl("#f11")},".cm-lintRange-warning":{backgroundImage:Vl("orange")},".cm-lintRange-info":{backgroundImage:Vl("#999")},".cm-lintRange-hint":{backgroundImage:Vl("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function o$(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function a$(s){let e="hint",t=1;for(let i of s){let r=o$(i.severity);r>t&&(t=r,e=i.severity)}return e}const vy=WC(KQ,{hideOn:UQ}),l$=[ti,_e.decorations.compute([ti],s=>{let{selected:e,panel:t}=s.field(ti);return!e||!t||e.from==e.to?ze.none:ze.set([GQ.range(e.from,e.to)])}),vy,n$];var PO=function(e){e===void 0&&(e={});var t=e,i=t.crosshairCursor,r=i===void 0?!1:i,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(BQ)),e.defaultKeymap!==!1&&(n=n.concat(_T)),e.searchKeymap!==!1&&(n=n.concat(HT)),e.historyKeymap!==!1&&(n=n.concat($P)),e.foldKeymap!==!1&&(n=n.concat(Z2)),e.completionKeymap!==!1&&(n=n.concat(py)),e.lintKeymap!==!1&&(n=n.concat(s$));var a=[];return e.lineNumbers!==!1&&a.push(t2()),e.highlightActiveLineGutter!==!1&&a.push(r2()),e.highlightSpecialChars!==!1&&a.push(gC()),e.history!==!1&&a.push(yP()),e.foldGutter!==!1&&a.push(U2()),e.drawSelection!==!1&&a.push(rC()),e.dropCursor!==!1&&a.push(hC()),e.allowMultipleSelections!==!1&&a.push(pt.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&a.push(N2()),e.syntaxHighlighting!==!1&&a.push(fb(J2,{fallback:!0})),e.bracketMatching!==!1&&a.push(oP()),e.closeBrackets!==!1&&a.push(LQ()),e.autocompletion!==!1&&a.push(FQ()),e.rectangularSelection!==!1&&a.push($C()),r!==!1&&a.push(RC()),e.highlightActiveLine!==!1&&a.push(SC()),e.highlightSelectionMatches!==!1&&a.push(QT()),e.tabSize&&typeof e.tabSize=="number"&&a.push(_o.of(" ".repeat(e.tabSize))),a.concat([So.of(n.flat())]).filter(Boolean)};const c$="#e5c07b",TO="#e06c75",h$="#56b6c2",d$="#ffffff",cc="#abb2bf",of="#7d8799",u$="#61afef",f$="#98c379",QO="#d19a66",p$="#c678dd",m$="#21252b",$O="#2c313a",jO="#282c34",$d="#353a42",g$="#3E4451",EO="#528bff",O$=_e.theme({"&":{color:cc,backgroundColor:jO},".cm-content":{caretColor:EO},".cm-cursor, .cm-dropCursor":{borderLeftColor:EO},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:g$},".cm-panels":{backgroundColor:m$,color:cc},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:jO,color:of,border:"none"},".cm-activeLineGutter":{backgroundColor:$O},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:$d},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:$d,borderBottomColor:$d},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:$O,color:cc}}},{dark:!0}),x$=Fa.define([{tag:L.keyword,color:p$},{tag:[L.name,L.deleted,L.character,L.propertyName,L.macroName],color:TO},{tag:[L.function(L.variableName),L.labelName],color:u$},{tag:[L.color,L.constant(L.name),L.standard(L.name)],color:QO},{tag:[L.definition(L.name),L.separator],color:cc},{tag:[L.typeName,L.className,L.number,L.changed,L.annotation,L.modifier,L.self,L.namespace],color:c$},{tag:[L.operator,L.operatorKeyword,L.url,L.escape,L.regexp,L.link,L.special(L.string)],color:h$},{tag:[L.meta,L.comment],color:of},{tag:L.strong,fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.link,color:of,textDecoration:"underline"},{tag:L.heading,fontWeight:"bold",color:TO},{tag:[L.atom,L.bool,L.special(L.variableName)],color:QO},{tag:[L.processingInstruction,L.string,L.inserted],color:f$},{tag:L.invalid,color:d$}]),by=[O$,fb(x$)];var v$=_e.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),b$=function(e){e===void 0&&(e={});var t=e,i=t.indentWithTab,r=i===void 0?!0:i,n=t.editable,a=n===void 0?!0:n,o=t.readOnly,l=o===void 0?!1:o,c=t.theme,d=c===void 0?"light":c,u=t.placeholder,f=u===void 0?"":u,g=t.basicSetup,b=g===void 0?!0:g,v=[];switch(r&&v.unshift(So.of([wT])),b&&(typeof b=="boolean"?v.unshift(PO()):v.unshift(PO(b))),f&&v.unshift(CC(f)),d){case"light":v.push(v$);break;case"dark":v.push(by);break;case"none":break;default:v.push(d);break}return a===!1&&v.push(_e.editable.of(!1)),l&&v.push(pt.readOnly.of(!0)),[...v]},y$=s=>({line:s.state.doc.lineAt(s.state.selection.main.from),lineCount:s.state.doc.lines,lineBreak:s.state.lineBreak,length:s.state.doc.length,readOnly:s.state.readOnly,tabSize:s.state.tabSize,selection:s.state.selection,selectionAsSingle:s.state.selection.asSingle().main,ranges:s.state.selection.ranges,selectionCode:s.state.sliceDoc(s.state.selection.main.from,s.state.selection.main.to),selections:s.state.selection.ranges.map(e=>s.state.sliceDoc(e.from,e.to)),selectedText:s.state.selection.ranges.some(e=>!e.empty)});class S${constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class RO{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var jd=null,_$=()=>typeof window>"u"?new RO:(jd||(jd=new RO),jd),w$=_e.theme({"& .cm-scroller":{height:"100% !important"}}),AO=null,Ed=null;function k$(s,e,t,i,r,n){if(!s&&!e&&!t&&!i&&!r&&!n)return null;var a=JSON.stringify({height:s,minHeight:e,maxHeight:t,width:i,minWidth:r,maxWidth:n});return a===AO||(AO=a,Ed=_e.theme({"&":{height:s,minHeight:e,maxHeight:t,width:i,minWidth:r,maxWidth:n}})),Ed}var MO=Gi.define(),C$=200,P$=[];function T$(s){var e=s.value,t=s.selection,i=s.onChange,r=s.onStatistics,n=s.onCreateEditor,a=s.onUpdate,o=s.extensions,l=o===void 0?P$:o,c=s.autoFocus,d=s.theme,u=d===void 0?"light":d,f=s.height,g=f===void 0?null:f,b=s.minHeight,v=b===void 0?null:b,m=s.maxHeight,O=m===void 0?null:m,p=s.width,x=p===void 0?null:p,y=s.minWidth,_=y===void 0?null:y,k=s.maxWidth,w=k===void 0?null:k,S=s.placeholder,Q=S===void 0?"":S,I=s.editable,D=I===void 0?!0:I,$=s.readOnly,j=$===void 0?!1:$,B=s.indentWithTab,F=B===void 0?!0:B,V=s.basicSetup,Z=V===void 0?!0:V,se=s.root,T=s.initialState,A=C.useState(),N=A[0],z=A[1],U=C.useState(),ne=U[0],Se=U[1],Pe=C.useState(),X=Pe[0],M=Pe[1],K=C.useState(()=>({current:null}))[0],ie=C.useState(()=>({current:null}))[0],oe=k$(g,v,O,x,_,w),G=_e.updateListener.of(We=>{if(We.docChanged&&typeof i=="function"&&!We.transactions.some(le=>le.annotation(MO))){K.current?K.current.reset():(K.current=new S$(()=>{if(ie.current){var le=ie.current;ie.current=null,le()}K.current=null},C$),_$().add(K.current));var Y=We.state.doc,ee=Y.toString();i(ee,We)}r&&r(y$(We))}),$e=b$({theme:u,editable:D,readOnly:j,placeholder:Q,indentWithTab:F,basicSetup:Z}),Ie=[G,...oe?[oe]:[],w$,...$e];return a&&typeof a=="function"&&Ie.push(_e.updateListener.of(a)),Ie=Ie.concat(l),C.useLayoutEffect(()=>{if(N&&!X){var We={doc:e,selection:t,extensions:Ie},Y=T?pt.fromJSON(T.json,We,T.fields):pt.create(We);if(M(Y),!ne){var ee=new _e({state:Y,parent:N,root:se});Se(ee),n&&n(ee,Y)}}return()=>{ne&&(M(void 0),Se(void 0))}},[N,X]),C.useEffect(()=>{s.container&&z(s.container)},[s.container]),C.useEffect(()=>()=>{ne&&(ne.destroy(),Se(void 0)),K.current&&(K.current.cancel(),K.current=null)},[ne]),C.useEffect(()=>{c&&ne&&ne.focus()},[c,ne]),C.useEffect(()=>{ne&&ne.dispatch({effects:nt.reconfigure.of(Ie)})},[u,l,g,v,O,x,_,w,Q,D,j,F,Z,i,a]),C.useEffect(()=>{if(e!==void 0){var We=ne?ne.state.doc.toString():"";if(ne&&e!==We){var Y=K.current&&!K.current.isDone,ee=()=>{ne&&e!==ne.state.doc.toString()&&ne.dispatch({changes:{from:0,to:ne.state.doc.toString().length,insert:e||""},annotations:[MO.of(!0)]})};Y?ie.current=ee:ee()}}},[e,ne]),{state:X,setState:M,view:ne,setView:Se,container:N,setContainer:z}}var Q$=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],yy=C.forwardRef((s,e)=>{var t=s.className,i=s.value,r=i===void 0?"":i,n=s.selection,a=s.extensions,o=a===void 0?[]:a,l=s.onChange,c=s.onStatistics,d=s.onCreateEditor,u=s.onUpdate,f=s.autoFocus,g=s.theme,b=g===void 0?"light":g,v=s.height,m=s.minHeight,O=s.maxHeight,p=s.width,x=s.minWidth,y=s.maxWidth,_=s.basicSetup,k=s.placeholder,w=s.indentWithTab,S=s.editable,Q=s.readOnly,I=s.root,D=s.initialState,$=Z_(s,Q$),j=C.useRef(null),B=T$({root:I,value:r,autoFocus:f,theme:b,height:v,minHeight:m,maxHeight:O,width:p,minWidth:x,maxWidth:y,basicSetup:_,placeholder:k,indentWithTab:w,editable:S,readOnly:Q,selection:n,onChange:l,onStatistics:c,onCreateEditor:d,onUpdate:u,extensions:o,initialState:D}),F=B.state,V=B.view,Z=B.container,se=B.setContainer;C.useImperativeHandle(e,()=>({editor:j.current,state:F,view:V}),[j,Z,F,V]);var T=C.useCallback(N=>{j.current=N,se(N)},[se]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var A=typeof b=="string"?"cm-theme-"+b:"cm-theme";return h.jsx("div",uu({ref:T,className:""+A+(t?" "+t:"")},$))});yy.displayName="CodeMirror";var LO={};class qc{constructor(e,t,i,r,n,a,o,l,c,d=0,u){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=n,this.score=a,this.buffer=o,this.bufferBase=l,this.curContext=c,this.lookAhead=d,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new qc(e,[],t,i,i,0,[],0,r?new NO(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,r=e&65535,{parser:n}=this.p,a=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),o=n.dynamicPrecedence(r);if(o&&(this.score+=o),i==0){r<n.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(n.getGoto(this.state,r,!0),this.reducePos),r<n.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,a?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(i-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from;r<n.minRepeatTerm&&c==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let d=this.reducePos-c;d>=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=d));let u=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-u;if(r<n.minRepeatTerm||e&131072){let g=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,c,g,f+4,!0)}if(e&262144)this.state=this.stack[l];else{let g=this.stack[l-3];this.state=n.getGoto(g,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,n=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let a=this.buffer.length;if(a>0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(t==i)return;if(this.buffer[a-2]>=t){this.buffer[a-2]=i;return}}}if(!n||this.pos==i)this.buffer.push(e,t,i,r);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let o=!1;for(let l=a;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){o=!0;break}if(o)for(;a>0&&this.buffer[a-2]>i;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,r>4&&(r-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=i,this.buffer[a+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let n=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(n,1);!o&&(r>i||t<=a.maxNode)&&(this.reducePos=r),this.pushState(n,o?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=a.maxNode&&this.buffer.push(t,i,r,4)}else this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4)}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new qc(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new $$(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let n=0,a;n<t.length;n+=2)(a=t[n+1])!=this.state&&this.p.parser.hasAction(a,e)&&r.push(t[n],a);if(this.stack.length<120)for(let n=0;r.length<8&&n<t.length;n+=2){let a=t[n+1];r.some((o,l)=>l&1&&o==a)||r.push(t[n],a)}t=r}let i=[];for(let r=0;r<t.length&&i.length<4;r+=2){let n=t[r+1];if(n==this.state)continue;let a=this.split();a.pushState(n,this.pos),a.storeNode(0,a.pos,a.pos,4,!0),a.shiftContext(t[r],this.pos),a.reducePos=this.pos,a.score-=200,i.push(a)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,r=t&65535,n=this.stack.length-i*3;if(n<0||e.getGoto(this.stack[n],r,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(r,n)=>{if(!t.includes(r))return t.push(r),e.allActions(r,a=>{if(!(a&393216))if(a&65536){let o=(a>>19)-n;if(o>1){let l=a&65535,c=this.stack.length-o*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return o<<19|65536|l}}else{let o=i(a,n+1);if(o!=null)return o}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new NO(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class NO{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class $${constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class zc{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new zc(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new zc(this.stack,this.pos,this.index)}}function na(s,e=Uint16Array){if(typeof s!="string")return s;let t=null;for(let i=0,r=0;i<s.length;){let n=0;for(;;){let a=s.charCodeAt(i++),o=!1;if(a==126){n=65535;break}a>=92&&a--,a>=34&&a--;let l=a-32;if(l>=46&&(l-=46,o=!0),n+=l,o)break;n*=46}t?t[r++]=n:t=new e(n)}return t}class hc{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const DO=new hc;class j${constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=DO,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,n=this.pos+e;for(;n<i.from;){if(!r)return null;let a=this.ranges[--r];n-=i.from-a.to,i=a}for(;t<0?n>i.to:n>=i.to;){if(r==this.ranges.length-1)return null;let a=this.ranges[++r];n+=a.from-i.to,i=a}return n}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(t);else{let n=this.resolveOffset(e,1);if(n==null)return-1;if(i=n,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let a=this.rangeIndex,o=this.range;for(;o.to<=i;)o=this.ranges[++a];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>o.to&&(this.chunk2=this.chunk2.slice(0,o.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=DO,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}}class ho{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;Sy(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}ho.prototype.contextual=ho.prototype.fallback=ho.prototype.extend=!1;class Zc{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?na(e):e}token(e,t){let i=e.pos,r=0;for(;;){let n=e.next<0,a=e.resolveOffset(1,1);if(Sy(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,a==null)break;e.reset(a,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}}Zc.prototype.contextual=ho.prototype.fallback=ho.prototype.extend=!1;class ts{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Sy(s,e,t,i,r,n){let a=0,o=1<<i,{dialect:l}=t.p.parser;e:for(;(o&s[a])!=0;){let c=s[a+1];for(let g=a+3;g<c;g+=2)if((s[g+1]&o)>0){let b=s[g];if(l.allows(b)&&(e.token.value==-1||e.token.value==b||E$(b,e.token.value,r,n))){e.acceptToken(b);break}}let d=e.next,u=0,f=s[a+2];if(e.next<0&&f>u&&s[c+f*3-3]==65535){a=s[c+f*3-1];continue e}for(;u<f;){let g=u+f>>1,b=c+g+(g<<1),v=s[b],m=s[b+1]||65536;if(d<v)f=g;else if(d>=m)u=g+1;else{a=s[b+2],e.advance();continue e}}break}}function IO(s,e,t){for(let i=e,r;(r=s[i])!=65535;i++)if(r==t)return i-e;return-1}function E$(s,e,t,i){let r=IO(t,i,e);return r<0||IO(t,i,s)<r}const Hs=typeof process<"u"&&LO&&/\bparse\b/.test(LO.LOG);let Rd=null;function BO(s,e,t){let i=s.cursor(_t.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(s.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:s.length}}let R$=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?BO(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?BO(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],r=this.index[t];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=i.children[r],a=this.start[t]+i.positions[r];if(a>e)return this.nextStart=a,null;if(n instanceof wt){if(a==e){if(a<this.safeFrom)return null;let o=a+n.length;if(o<=this.safeTo){let l=n.prop(ot.lookAhead);if(!l||o+l<this.fragment.to)return n}}this.index[t]++,a+n.length>=Math.max(this.safeFrom,e)&&(this.trees.push(n),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+n.length}}};class A${constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new hc)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:n}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<n.length;c++){if((1<<c&a)==0)continue;let d=n[c],u=this.tokens[c];if(!(i&&!d.fallback)&&((d.contextual||u.start!=e.pos||u.mask!=a||u.context!=o)&&(this.updateCachedToken(u,d,e),u.mask=a,u.context=o),u.lookAhead>u.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let f=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!d.extend&&(i=u,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new hc,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new hc,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:n}=i.p;for(let a=0;a<n.specialized.length;a++)if(n.specialized[a]==e.value){let o=n.specializers[a](this.stream.read(e.start,e.end),i);if(o>=0&&i.p.parser.dialect.allows(o>>1)){(o&1)==0?e.value=o>>1:e.extended=o>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let n=0;n<r;n+=3)if(this.actions[n]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=i,r}addActions(e,t,i,r){let{state:n}=e,{parser:a}=e.p,{data:o}=a;for(let l=0;l<2;l++)for(let c=a.stateSlot(n,l?2:1);;c+=3){if(o[c]==65535)if(o[c+1]==1)c=pr(o,c+2);else{r==0&&o[c+1]==2&&(r=this.putAction(pr(o,c+2),t,i,r));break}o[c]==t&&(r=this.putAction(pr(o,c+1),t,i,r))}return r}}class M${constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new j$(t,r),this.tokens=new A$(e,this.stream),this.topTerm=e.top[1];let{from:n}=r[0];this.stacks=[qc.start(this,e.top[0],n)],this.fragments=i.length&&this.stream.end-n>e.bufferLength*4?new R$(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,n;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)i.push(o);else{if(this.advanceStack(o,i,e))continue;{r||(r=[],n=[]),r.push(o);let l=this.tokens.getMainToken(o);n.push(l.value,l.end)}}break}}if(!i.length){let a=r&&N$(r);if(a)return Hs&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Hs&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let a=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,n,i);if(a)return Hs&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(i.length>a)for(i.sort((o,l)=>l.score-o.score);i.length>a;)i.pop();i.some(o=>o.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let a=0;a<i.length-1;a++){let o=i[a];for(let l=a+1;l<i.length;l++){let c=i[l];if(o.sameState(c)||o.buffer.length>500&&c.buffer.length>500)if((o.score-c.score||o.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,o)=>o.score-a.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let a=1;a<i.length;a++)i[a].pos<this.minStackPos&&(this.minStackPos=i[a].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let r=e.pos,{parser:n}=this,a=Hs?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,d=c?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let f=this.parser.nodeSet.types[u.type.id]==u.type?n.getGoto(e.state,u.type.id):-1;if(f>-1&&u.length&&(!c||(u.prop(ot.contextHash)||0)==d))return e.useNode(u,f),Hs&&console.log(a+this.stackID(e)+` (via reuse of ${n.getName(u.type.id)})`),!0;if(!(u instanceof wt)||u.children.length==0||u.positions[0]>0)break;let g=u.children[0];if(g instanceof wt&&u.positions[0]==0)u=g;else break}}let o=n.stateSlot(e.state,4);if(o>0)return e.reduce(o),Hs&&console.log(a+this.stackID(e)+` (via always-reduce ${n.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let d=l[c++],u=l[c++],f=l[c++],g=c==l.length||!i,b=g?e:e.split(),v=this.tokens.mainToken;if(b.apply(d,u,v?v.start:b.pos,f),Hs&&console.log(a+this.stackID(b)+` (via ${(d&65536)==0?"shift":`reduce of ${n.getName(d&65535)}`} for ${n.getName(u)} @ ${r}${b==e?"":", split"})`),g)return!0;b.pos>r?t.push(b):i.push(b)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return WO(e,t),!0}}runRecovery(e,t,i){let r=null,n=!1;for(let a=0;a<e.length;a++){let o=e[a],l=t[a<<1],c=t[(a<<1)+1],d=Hs?this.stackID(o)+" -> ":"";if(o.deadEnd&&(n||(n=!0,o.restart(),Hs&&console.log(d+this.stackID(o)+" (restarted)"),this.advanceFully(o,i))))continue;let u=o.split(),f=d;for(let g=0;g<10&&u.forceReduce()&&(Hs&&console.log(f+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,i));g++)Hs&&(f=this.stackID(u)+" -> ");for(let g of o.recoverByInsert(l))Hs&&console.log(d+this.stackID(g)+" (via recover-insert)"),this.advanceFully(g,i);this.stream.end>o.pos?(c==o.pos&&(c++,l=0),o.recoverByDelete(l,c),Hs&&console.log(d+this.stackID(o)+` (via recover-delete ${this.parser.getName(l)})`),WO(o,i)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),wt.build({buffer:zc.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Rd||(Rd=new WeakMap)).get(e);return t||Rd.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function WO(s,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==s.pos&&i.sameState(s)){e[t].score<s.score&&(e[t]=s);return}}e.push(s)}class L${constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const Ad=s=>s;class fh{constructor(e){this.start=e.start,this.shift=e.shift||Ad,this.reduce=e.reduce||Ad,this.reuse=e.reuse||Ad,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class wr extends Yf{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let o=0;o<e.repeatNodeCount;o++)t.push("");let i=Object.keys(e.topRules).map(o=>e.topRules[o][1]),r=[];for(let o=0;o<t.length;o++)r.push([]);function n(o,l,c){r[o].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let o of e.nodeProps){let l=o[0];typeof l=="string"&&(l=ot[l]);for(let c=1;c<o.length;){let d=o[c++];if(d>=0)n(d,l,o[c++]);else{let u=o[c+-d];for(let f=-d;f>0;f--)n(o[c++],l,u);c++}}}this.nodeSet=new Za(t.map((o,l)=>es.define({name:l>=this.minRepeatTerm?void 0:o,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Yv;let a=na(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let o=0;o<this.specializerSpecs.length;o++)this.specialized[o]=this.specializerSpecs[o].term;this.specializers=this.specializerSpecs.map(XO),this.states=na(e.states,Uint32Array),this.data=na(e.stateData),this.goto=na(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(o=>typeof o=="number"?new ho(a,o):o),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new M$(this,e,t,i);for(let n of this.wrappers)r=n(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let n=r[t+1];;){let a=r[n++],o=a&1,l=r[n++];if(o&&i)return l;for(let c=n+(a>>1);n<c;n++)if(r[n]==e)return l;if(o)return-1}}hasAction(e,t){let i=this.data;for(let r=0;r<2;r++)for(let n=this.stateSlot(e,r?2:1),a;;n+=3){if((a=i[n])==65535)if(i[n+1]==1)a=i[n=pr(i,n+2)];else{if(i[n+1]==2)return pr(i,n+2);break}if(a==t||a==0)return pr(i,n+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=pr(this.data,n+2);else break;r=t(pr(this.data,n+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=pr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((n,a)=>a&1&&n==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(wr.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(n=>n.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let n=e.specializers.find(o=>o.from==i.external);if(!n)return i;let a=Object.assign(Object.assign({},i),{external:n.to});return t.specializers[r]=XO(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let n of e.split(" ")){let a=t.indexOf(n);a>=0&&(i[a]=!0)}let r=null;for(let n=0;n<t.length;n++)if(!i[n])for(let a=this.dialects[t[n]],o;(o=this.data[a++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[o]=1;return new L$(e,i,r)}static deserialize(e){return new wr(e)}}function pr(s,e){return s[e]|s[e+1]<<16}function N$(s){let e=null;for(let t of s){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function XO(s){if(s.external){let e=s.extend?1:0;return(t,i)=>s.external(t,i)<<1|e}return s.get}const D$=316,I$=317,qO=1,B$=2,W$=3,X$=4,q$=318,z$=320,Z$=321,V$=5,F$=6,Y$=0,af=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],_y=125,U$=59,lf=47,H$=42,G$=43,K$=45,J$=60,e5=44,t5=63,s5=46,i5=91,r5=new fh({start:!1,shift(s,e){return e==V$||e==F$||e==z$?s:e==Z$},strict:!1}),n5=new ts((s,e)=>{let{next:t}=s;(t==_y||t==-1||e.context)&&s.acceptToken(q$)},{contextual:!0,fallback:!0}),o5=new ts((s,e)=>{let{next:t}=s,i;af.indexOf(t)>-1||t==lf&&((i=s.peek(1))==lf||i==H$)||t!=_y&&t!=U$&&t!=-1&&!e.context&&s.acceptToken(D$)},{contextual:!0}),a5=new ts((s,e)=>{s.next==i5&&!e.context&&s.acceptToken(I$)},{contextual:!0}),l5=new ts((s,e)=>{let{next:t}=s;if(t==G$||t==K$){if(s.advance(),t==s.next){s.advance();let i=!e.context&&e.canShift(qO);s.acceptToken(i?qO:B$)}}else t==t5&&s.peek(1)==s5&&(s.advance(),s.advance(),(s.next<48||s.next>57)&&s.acceptToken(W$))},{contextual:!0});function Md(s,e){return s>=65&&s<=90||s>=97&&s<=122||s==95||s>=192||!e&&s>=48&&s<=57}const c5=new ts((s,e)=>{if(s.next!=J$||!e.dialectEnabled(Y$)||(s.advance(),s.next==lf))return;let t=0;for(;af.indexOf(s.next)>-1;)s.advance(),t++;if(Md(s.next,!0)){for(s.advance(),t++;Md(s.next,!1);)s.advance(),t++;for(;af.indexOf(s.next)>-1;)s.advance(),t++;if(s.next==e5)return;for(let i=0;;i++){if(i==7){if(!Md(s.next,!0))return;break}if(s.next!="extends".charCodeAt(i))break;s.advance(),t++}}s.acceptToken(X$,-t)}),h5=Cr({"get set async static":L.modifier,"for while do if else switch try catch finally return throw break continue default case defer":L.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":L.operatorKeyword,"let var const using function class extends":L.definitionKeyword,"import export from":L.moduleKeyword,"with debugger new":L.keyword,TemplateString:L.special(L.string),super:L.atom,BooleanLiteral:L.bool,this:L.self,null:L.null,Star:L.modifier,VariableName:L.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":L.function(L.variableName),VariableDefinition:L.definition(L.variableName),Label:L.labelName,PropertyName:L.propertyName,PrivatePropertyName:L.special(L.propertyName),"CallExpression/MemberExpression/PropertyName":L.function(L.propertyName),"FunctionDeclaration/VariableDefinition":L.function(L.definition(L.variableName)),"ClassDeclaration/VariableDefinition":L.definition(L.className),"NewExpression/VariableName":L.className,PropertyDefinition:L.definition(L.propertyName),PrivatePropertyDefinition:L.definition(L.special(L.propertyName)),UpdateOp:L.updateOperator,"LineComment Hashbang":L.lineComment,BlockComment:L.blockComment,Number:L.number,String:L.string,Escape:L.escape,ArithOp:L.arithmeticOperator,LogicOp:L.logicOperator,BitOp:L.bitwiseOperator,CompareOp:L.compareOperator,RegExp:L.regexp,Equals:L.definitionOperator,Arrow:L.function(L.punctuation),": Spread":L.punctuation,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace,"InterpolationStart InterpolationEnd":L.special(L.brace),".":L.derefOperator,", ;":L.separator,"@":L.meta,TypeName:L.typeName,TypeDefinition:L.definition(L.typeName),"type enum interface implements namespace module declare":L.definitionKeyword,"abstract global Privacy readonly override":L.modifier,"is keyof unique infer asserts":L.operatorKeyword,JSXAttributeValue:L.attributeValue,JSXText:L.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":L.angleBracket,"JSXIdentifier JSXNameSpacedName":L.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":L.attributeName,"JSXBuiltin/JSXIdentifier":L.standard(L.tagName)}),d5={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},u5={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},f5={__proto__:null,"<":193},p5=wr.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#H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l-VQ4`/pQ6q2dQ7s4aQ9W6rT=m'X+[V#aW%h*YU#`W%h*YS(U#W(^U(Z#Z+Z/mS-['X+[T.O(T.TV'^!e%i*ZQ$lfR)x$qT)m$l)nR4V/UT*_$x*bT*h${*YQ0w+fQ1g,VQ3_.fQ5t1iQ6P1qQ7X3cQ8r6SQ9c7WQ:^8qQ:p9bQ;Z:`Q;c:rQ;n;[R;q;dnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&l!VR,h&itmOXst!U!V!Z#d%m&i&r&t&u&w,s,x2[2_R,o&oT%lm,oR1k,XR,g&gQ&U|S+}&V&WR1^,OR+s&PT&p!W&sT&q!W&sT2^,x2_",nodeNames:"⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:r5,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[h5],skippedNodes:[0,5,6,278],repeatNodeC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~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:s=>d5[s]||-1},{term:343,get:s=>u5[s]||-1},{term:95,get:s=>f5[s]||-1}],tokenPrec:15201}),wy=[Wt("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),Wt("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),Wt("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),Wt("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),Wt("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),Wt(`try {
|
|
17
|
-
\${}
|
|
18
|
-
} catch (\${error}) {
|
|
19
|
-
\${}
|
|
20
|
-
}`,{label:"try",detail:"/ catch block",type:"keyword"}),Wt("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),Wt(`if (\${}) {
|
|
21
|
-
\${}
|
|
22
|
-
} else {
|
|
23
|
-
\${}
|
|
24
|
-
}`,{label:"if",detail:"/ else block",type:"keyword"}),Wt(`class \${name} {
|
|
25
|
-
constructor(\${params}) {
|
|
26
|
-
\${}
|
|
27
|
-
}
|
|
28
|
-
}`,{label:"class",detail:"definition",type:"keyword"}),Wt('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Wt('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],m5=wy.concat([Wt("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Wt("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Wt("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),zO=new Ff,ky=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Jo(s){return(e,t)=>{let i=e.node.getChild("VariableDefinition");return i&&t(i,s),!0}}const g5=["FunctionDeclaration"],O5={FunctionDeclaration:Jo("function"),ClassDeclaration:Jo("class"),ClassExpression:()=>!0,EnumDeclaration:Jo("constant"),TypeAliasDeclaration:Jo("type"),NamespaceDeclaration:Jo("namespace"),VariableDefinition(s,e){s.matchContext(g5)||e(s,"variable")},TypeDefinition(s,e){e(s,"type")},__proto__:null};function Cy(s,e){let t=zO.get(e);if(t)return t;let i=[],r=!0;function n(a,o){let l=s.sliceString(a.from,a.to);i.push({label:l,type:o})}return e.cursor(_t.IncludeAnonymous).iterate(a=>{if(r)r=!1;else if(a.name){let o=O5[a.name];if(o&&o(a,n)||ky.has(a.name))return!1}else if(a.to-a.from>8192){for(let o of Cy(s,a.node))i.push(o);return!1}}),zO.set(e,i),i}const ZO=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Py=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function x5(s){let e=kt(s.state).resolveInner(s.pos,-1);if(Py.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&ZO.test(s.state.sliceDoc(e.from,e.to));if(!t&&!s.explicit)return null;let i=[];for(let r=e;r;r=r.parent)ky.has(r.name)&&(i=i.concat(Cy(s.state.doc,r)));return{options:i,from:t?e.from:s.pos,validFor:ZO}}const Hi=_r.define({name:"javascript",parser:p5.configure({props:[Yr.add({IfStatement:ao({except:/^\s*({|else\b)/}),TryStatement:ao({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:M2,SwitchBody:s=>{let e=s.textAfter,t=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return s.baseIndent+(t?0:i?1:2)*s.unit},Block:lc({closing:"}"}),ArrowFunction:s=>s.baseIndent+s.unit,"TemplateString BlockComment":()=>null,"Statement Property":ao({except:/^\s*{/}),JSXElement(s){let e=/^\s*<\//.test(s.textAfter);return s.lineIndent(s.node.from)+(e?0:s.unit)},JSXEscape(s){let e=/\s*\}/.test(s.textAfter);return s.lineIndent(s.node.from)+(e?0:s.unit)},"JSXOpenTag JSXSelfClosingTag"(s){return s.column(s.node.from)+s.unit}}),Pr.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":oh,BlockComment(s){return{from:s.from+2,to:s.to-2}},JSXElement(s){let e=s.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let t=s.lastChild;return{from:e.to,to:t.type.isError?s.to:t.from}},"JSXSelfClosingTag JSXOpenTag"(s){var e;let t=(e=s.firstChild)===null||e===void 0?void 0:e.nextSibling,i=s.lastChild;return!t||t.type.isError?null:{from:t.to,to:i.type.isError?s.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Ty={test:s=>/^JSX/.test(s.name),facet:Uf({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Qy=Hi.configure({dialect:"ts"},"typescript"),$y=Hi.configure({dialect:"jsx",props:[Hf.add(s=>s.isTop?[Ty]:void 0)]}),jy=Hi.configure({dialect:"jsx ts",props:[Hf.add(s=>s.isTop?[Ty]:void 0)]},"typescript");let Ey=s=>({label:s,type:"keyword"});const Ry="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Ey),v5=Ry.concat(["declare","implements","private","protected","public"].map(Ey));function dc(s={}){let e=s.jsx?s.typescript?jy:$y:s.typescript?Qy:Hi,t=s.typescript?m5.concat(v5):wy.concat(Ry);return new Vr(e,[Hi.data.of({autocomplete:ny(Py,lp(t))}),Hi.data.of({autocomplete:x5}),s.jsx?S5:[]])}function b5(s){for(;;){if(s.name=="JSXOpenTag"||s.name=="JSXSelfClosingTag"||s.name=="JSXFragmentTag")return s;if(s.name=="JSXEscape"||!s.parent)return null;s=s.parent}}function VO(s,e,t=s.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return s.sliceString(i.from,Math.min(i.to,t));return""}const y5=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),S5=_e.inputHandler.of((s,e,t,i,r)=>{if((y5?s.composing:s.compositionStarted)||s.state.readOnly||e!=t||i!=">"&&i!="/"||!Hi.isActiveAt(s.state,e,-1))return!1;let n=r(),{state:a}=n,o=a.changeByRange(l=>{var c;let{head:d}=l,u=kt(a).resolveInner(d-1,-1),f;if(u.name=="JSXStartTag"&&(u=u.parent),!(a.doc.sliceString(d-1,d)!=i||u.name=="JSXAttributeValue"&&u.to>d)){if(i==">"&&u.name=="JSXFragmentTag")return{range:l,changes:{from:d,insert:"</>"}};if(i=="/"&&u.name=="JSXStartCloseTag"){let g=u.parent,b=g.parent;if(b&&g.from==d-2&&((f=VO(a.doc,b.firstChild,d))||((c=b.firstChild)===null||c===void 0?void 0:c.name)=="JSXFragmentTag")){let v=`${f}>`;return{range:re.cursor(d+v.length,-1),changes:{from:d,insert:v}}}}else if(i==">"){let g=b5(u);if(g&&g.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(a.doc.sliceString(d,d+2))&&(f=VO(a.doc,g,d)))return{range:l,changes:{from:d,insert:`</${f}>`}}}}return{range:l}});return o.changes.empty?!1:(s.dispatch([n,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),_5=Cr({String:L.string,Number:L.number,"True False":L.bool,PropertyName:L.propertyName,Null:L.null,", :":L.separator,"[ ]":L.squareBracket,"{ }":L.brace}),w5=wr.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[_5],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),k5=_r.define({name:"json",parser:w5.configure({props:[Yr.add({Object:ao({except:/^\s*\}/}),Array:ao({except:/^\s*\]/})}),Pr.add({"Object Array":oh})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function C5(){return new Vr(k5)}const P5=1,Ay=194,My=195,T5=196,FO=197,Q5=198,$5=199,j5=200,E5=2,Ly=3,YO=201,R5=24,A5=25,M5=49,L5=50,N5=55,D5=56,I5=57,B5=59,W5=60,X5=61,q5=62,z5=63,Z5=65,V5=238,F5=71,Y5=241,U5=242,H5=243,G5=244,K5=245,J5=246,ej=247,tj=248,Ny=72,sj=249,ij=250,rj=251,nj=252,oj=253,aj=254,lj=255,cj=256,hj=73,dj=77,uj=263,fj=112,pj=130,mj=151,gj=152,Oj=155,Rn=10,Ma=13,xp=32,ph=9,vp=35,xj=40,vj=46,cf=123,UO=125,Dy=39,Iy=34,HO=92,bj=111,yj=120,Sj=78,_j=117,wj=85,kj=new Set([A5,M5,L5,uj,Z5,pj,D5,I5,V5,q5,z5,Ny,hj,dj,W5,X5,mj,gj,Oj,fj]);function Ld(s){return s==Rn||s==Ma}function Nd(s){return s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102}const Cj=new ts((s,e)=>{let t;if(s.next<0)s.acceptToken($5);else if(e.context.flags&uc)Ld(s.next)&&s.acceptToken(Q5,1);else if(((t=s.peek(-1))<0||Ld(t))&&e.canShift(FO)){let i=0;for(;s.next==xp||s.next==ph;)s.advance(),i++;(s.next==Rn||s.next==Ma||s.next==vp)&&s.acceptToken(FO,-i)}else Ld(s.next)&&s.acceptToken(T5,1)},{contextual:!0}),Pj=new ts((s,e)=>{let t=e.context;if(t.flags)return;let i=s.peek(-1);if(i==Rn||i==Ma){let r=0,n=0;for(;;){if(s.next==xp)r++;else if(s.next==ph)r+=8-r%8;else break;s.advance(),n++}r!=t.indent&&s.next!=Rn&&s.next!=Ma&&s.next!=vp&&(r<t.indent?s.acceptToken(My,-n):s.acceptToken(Ay))}}),uc=1,By=2,hr=4,dr=8,ur=16,fr=32;function fc(s,e,t){this.parent=s,this.indent=e,this.flags=t,this.hash=(s?s.hash+s.hash<<8:0)+e+(e<<4)+t+(t<<6)}const Tj=new fc(null,0,0);function Qj(s){let e=0;for(let t=0;t<s.length;t++)e+=s.charCodeAt(t)==ph?8-e%8:1;return e}const GO=new Map([[Y5,0],[U5,hr],[H5,dr],[G5,dr|hr],[K5,ur],[J5,ur|hr],[ej,ur|dr],[tj,ur|dr|hr],[sj,fr],[ij,fr|hr],[rj,fr|dr],[nj,fr|dr|hr],[oj,fr|ur],[aj,fr|ur|hr],[lj,fr|ur|dr],[cj,fr|ur|dr|hr]].map(([s,e])=>[s,e|By])),$j=new fh({start:Tj,reduce(s,e,t,i){return s.flags&uc&&kj.has(e)||(e==F5||e==Ny)&&s.flags&By?s.parent:s},shift(s,e,t,i){return e==Ay?new fc(s,Qj(i.read(i.pos,t.pos)),0):e==My?s.parent:e==R5||e==N5||e==B5||e==Ly?new fc(s,0,uc):GO.has(e)?new fc(s,0,GO.get(e)|s.flags&uc):s},hash(s){return s.hash}}),jj=new ts(s=>{for(let e=0;e<5;e++){if(s.next!="print".charCodeAt(e))return;s.advance()}if(!/\w/.test(String.fromCharCode(s.next)))for(let e=0;;e++){let t=s.peek(e);if(!(t==xp||t==ph)){t!=xj&&t!=vj&&t!=Rn&&t!=Ma&&t!=vp&&s.acceptToken(P5);return}}}),Ej=new ts((s,e)=>{let{flags:t}=e.context,i=t&hr?Iy:Dy,r=(t&dr)>0,n=!(t&ur),a=(t&fr)>0,o=s.pos;for(;!(s.next<0);)if(a&&s.next==cf)if(s.peek(1)==cf)s.advance(2);else{if(s.pos==o){s.acceptToken(Ly,1);return}break}else if(n&&s.next==HO){if(s.pos==o){s.advance();let l=s.next;l>=0&&(s.advance(),Rj(s,l)),s.acceptToken(E5);return}break}else if(s.next==HO&&!n&&s.peek(1)>-1)s.advance(2);else if(s.next==i&&(!r||s.peek(1)==i&&s.peek(2)==i)){if(s.pos==o){s.acceptToken(YO,r?3:1);return}break}else if(s.next==Rn){if(r)s.advance();else if(s.pos==o){s.acceptToken(YO);return}break}else s.advance();s.pos>o&&s.acceptToken(j5)});function Rj(s,e){if(e==bj)for(let t=0;t<2&&s.next>=48&&s.next<=55;t++)s.advance();else if(e==yj)for(let t=0;t<2&&Nd(s.next);t++)s.advance();else if(e==_j)for(let t=0;t<4&&Nd(s.next);t++)s.advance();else if(e==wj)for(let t=0;t<8&&Nd(s.next);t++)s.advance();else if(e==Sj&&s.next==cf){for(s.advance();s.next>=0&&s.next!=UO&&s.next!=Dy&&s.next!=Iy&&s.next!=Rn;)s.advance();s.next==UO&&s.advance()}}const Aj=Cr({'async "*" "**" FormatConversion FormatSpec':L.modifier,"for while if elif else try except finally return raise break continue with pass assert await yield match case":L.controlKeyword,"in not and or is del":L.operatorKeyword,"from def class global nonlocal lambda":L.definitionKeyword,import:L.moduleKeyword,"with as print":L.keyword,Boolean:L.bool,None:L.null,VariableName:L.variableName,"CallExpression/VariableName":L.function(L.variableName),"FunctionDefinition/VariableName":L.function(L.definition(L.variableName)),"ClassDefinition/VariableName":L.definition(L.className),PropertyName:L.propertyName,"CallExpression/MemberExpression/PropertyName":L.function(L.propertyName),Comment:L.lineComment,Number:L.number,String:L.string,FormatString:L.special(L.string),Escape:L.escape,UpdateOp:L.updateOperator,"ArithOp!":L.arithmeticOperator,BitOp:L.bitwiseOperator,CompareOp:L.compareOperator,AssignOp:L.definitionOperator,Ellipsis:L.punctuation,At:L.meta,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace,".":L.derefOperator,", ;":L.separator}),Mj={__proto__:null,await:44,or:54,and:56,in:60,not:62,is:64,if:70,else:72,lambda:76,yield:94,from:96,async:102,for:104,None:162,True:164,False:164,del:178,pass:182,break:186,continue:190,return:194,raise:202,import:206,as:208,global:212,nonlocal:214,assert:218,type:223,elif:236,while:240,try:246,except:248,finally:250,with:254,def:258,class:268,match:279,case:285},Lj=wr.deserialize({version:14,states:"##jQ`QeOOP$}OSOOO&WQtO'#HUOOQS'#Co'#CoOOQS'#Cp'#CpO'vQdO'#CnO*UQtO'#HTOOQS'#HU'#HUOOQS'#DU'#DUOOQS'#HT'#HTO*rQdO'#D_O+VQdO'#DfO+gQdO'#DjO+zOWO'#DuO,VOWO'#DvO.[QtO'#GuOOQS'#Gu'#GuO'vQdO'#GtO0ZQtO'#GtOOQS'#Eb'#EbO0rQdO'#EcOOQS'#Gs'#GsO0|QdO'#GrOOQV'#Gr'#GrO1XQdO'#FYOOQS'#G^'#G^O1^QdO'#FXOOQV'#IS'#ISOOQV'#Gq'#GqOOQV'#Fq'#FqQ`QeOOO'vQdO'#CqO1lQdO'#C}O1sQdO'#DRO2RQdO'#HYO2cQtO'#EVO'vQdO'#EWOOQS'#EY'#EYOOQS'#E['#E[OOQS'#E^'#E^O2wQdO'#E`O3_QdO'#EdO3rQdO'#EfO3zQtO'#EfO1XQdO'#EiO0rQdO'#ElO1XQdO'#EnO0rQdO'#EtO0rQdO'#EwO4VQdO'#EyO4^QdO'#FOO4iQdO'#EzO0rQdO'#FOO1XQdO'#FQO1XQdO'#FVO4nQdO'#F[P4uOdO'#GpPOOO)CBd)CBdOOQS'#Ce'#CeOOQS'#Cf'#CfOOQS'#Cg'#CgOOQS'#Ch'#ChOOQS'#Ci'#CiOOQS'#Cj'#CjOOQS'#Cl'#ClO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO'vQdO,59OO5TQdO'#DoOOQS,5:Y,5:YO5hQdO'#HdOOQS,5:],5:]O5uQ!fO,5:]O5zQtO,59YO1lQdO,59bO1lQdO,59bO1lQdO,59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r$ZZ)R&l)S+f+g-RR$^|R)c&wXlOn)t,PQ$f!RR'Q$gQ$m!UR'R$hR*X'_Q*V'_V-g,`-h.TQ.d-lQ/P.^R/Q._U.]-l.^._Q/U.aQ/b.tQ/g.zU/i.|/j/yQ/n/RQ/|/oQ0O/tU0Q/u0S0[Q0]0UQ0a0ZR0b0^R/T.`R/d.t",nodeNames:"⚠ print Escape { Comment Script AssignStatement * BinaryExpression BitOp BitOp BitOp BitOp ArithOp ArithOp @ ArithOp ** UnaryExpression ArithOp BitOp AwaitExpression await ) ( ParenthesizedExpression BinaryExpression or and CompareOp in not is UnaryExpression ConditionalExpression if else LambdaExpression lambda ParamList VariableName AssignOp , : NamedExpression AssignOp YieldExpression yield from TupleExpression ComprehensionExpression async for LambdaExpression ] [ ArrayExpression ArrayComprehensionExpression } { DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression CallExpression ArgList AssignOp MemberExpression . PropertyName Number String FormatString FormatReplacement FormatSelfDoc FormatConversion FormatSpec FormatReplacement FormatSelfDoc ContinuedString Ellipsis None Boolean TypeDef AssignOp UpdateStatement UpdateOp ExpressionStatement DeleteStatement del PassStatement pass BreakStatement break ContinueStatement continue ReturnStatement return YieldStatement PrintStatement RaiseStatement raise ImportStatement import as ScopeStatement global nonlocal AssertStatement assert TypeDefinition type TypeParamList TypeParam StatementGroup ; IfStatement Body elif WhileStatement while ForStatement TryStatement try except finally WithStatement with FunctionDefinition def ParamList AssignOp TypeDef ClassDefinition class DecoratedStatement Decorator At MatchStatement match MatchBody MatchClause case CapturePattern LiteralPattern ArithOp ArithOp AsPattern OrPattern LogicOp AttributePattern SequencePattern MappingPattern StarPattern ClassPattern PatternArgList KeywordPattern KeywordPattern Guard",maxTerm:277,context:$j,nodeProps:[["isolate",-5,4,71,72,73,77,""],["group",-15,6,85,87,88,90,92,94,96,98,99,100,102,105,108,110,"Statement Statement",-22,8,18,21,25,40,49,50,56,57,60,61,62,63,64,67,70,71,72,79,80,81,82,"Expression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k!*}T&n`&jZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!+eV&n`&gZOw%Twx!+zx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,PV&n`Ow%Twx!,fx#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tk!,mT&n`&iZO#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%To!-Vi&n`&YS%uZOr%TrsNWsw%Twx! vx!Q%T!Q![JU![!c%T!c!dJU!d!eLx!e!hJU!h!i!(`!i!}JU!}#R%T#R#SJU#S#T%T#T#UJU#U#VLx#V#YJU#Y#Z!(`#Z#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUo!.}a&n`&YS%uZOr%Trs)Ysw%Twx.Ux!Q%T!Q![JU![!c%T!c!}JU!}#R%T#R#SJU#S#T%T#T#oJU#p#q%T#r$g%T$g;'SJU;'S;=`KW<%lOJUk!0ZT!XZ&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tc!0qT!WR&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%Tj!1XV%kQ&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!1sO!]~k!1zV%jR&n`O!_%T!_!`-Q!`#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T~!2fO![~i!2mT%tX&n`O#o%T#p#q%T#r;'S%T;'S;=`%i<%lO%T",tokenizers:[jj,Pj,Cj,Ej,0,1,2,3,4],topRules:{Script:[0,5]},specialized:[{term:221,get:s=>Mj[s]||-1}],tokenPrec:7668}),KO=new Ff,Wy=new Set(["Script","Body","FunctionDefinition","ClassDefinition","LambdaExpression","ForStatement","MatchClause"]);function Fl(s){return(e,t,i)=>{if(i)return!1;let r=e.node.getChild("VariableName");return r&&t(r,s),!0}}const Nj={FunctionDefinition:Fl("function"),ClassDefinition:Fl("class"),ForStatement(s,e,t){if(t){for(let i=s.node.firstChild;i;i=i.nextSibling)if(i.name=="VariableName")e(i,"variable");else if(i.name=="in")break}},ImportStatement(s,e){var t,i;let{node:r}=s,n=((t=r.firstChild)===null||t===void 0?void 0:t.name)=="from";for(let a=r.getChild("import");a;a=a.nextSibling)a.name=="VariableName"&&((i=a.nextSibling)===null||i===void 0?void 0:i.name)!="as"&&e(a,n?"variable":"namespace")},AssignStatement(s,e){for(let t=s.node.firstChild;t;t=t.nextSibling)if(t.name=="VariableName")e(t,"variable");else if(t.name==":"||t.name=="AssignOp")break},ParamList(s,e){for(let t=null,i=s.node.firstChild;i;i=i.nextSibling)i.name=="VariableName"&&(!t||!/\*|AssignOp/.test(t.name))&&e(i,"variable"),t=i},CapturePattern:Fl("variable"),AsPattern:Fl("variable"),__proto__:null};function Xy(s,e){let t=KO.get(e);if(t)return t;let i=[],r=!0;function n(a,o){let l=s.sliceString(a.from,a.to);i.push({label:l,type:o})}return e.cursor(_t.IncludeAnonymous).iterate(a=>{if(a.name){let o=Nj[a.name];if(o&&o(a,n,r)||!r&&Wy.has(a.name))return!1;r=!1}else if(a.to-a.from>8192){for(let o of Xy(s,a.node))i.push(o);return!1}}),KO.set(e,i),i}const JO=/^[\w\xa1-\uffff][\w\d\xa1-\uffff]*$/,qy=["String","FormatString","Comment","PropertyName"];function Dj(s){let e=kt(s.state).resolveInner(s.pos,-1);if(qy.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&JO.test(s.state.sliceDoc(e.from,e.to));if(!t&&!s.explicit)return null;let i=[];for(let r=e;r;r=r.parent)Wy.has(r.name)&&(i=i.concat(Xy(s.state.doc,r)));return{options:i,from:t?e.from:s.pos,validFor:JO}}const Ij=["__annotations__","__builtins__","__debug__","__doc__","__import__","__name__","__loader__","__package__","__spec__","False","None","True"].map(s=>({label:s,type:"constant"})).concat(["ArithmeticError","AssertionError","AttributeError","BaseException","BlockingIOError","BrokenPipeError","BufferError","BytesWarning","ChildProcessError","ConnectionAbortedError","ConnectionError","ConnectionRefusedError","ConnectionResetError","DeprecationWarning","EOFError","Ellipsis","EncodingWarning","EnvironmentError","Exception","FileExistsError","FileNotFoundError","FloatingPointError","FutureWarning","GeneratorExit","IOError","ImportError","ImportWarning","IndentationError","IndexError","InterruptedError","IsADirectoryError","KeyError","KeyboardInterrupt","LookupError","MemoryError","ModuleNotFoundError","NameError","NotADirectoryError","NotImplemented","NotImplementedError","OSError","OverflowError","PendingDeprecationWarning","PermissionError","ProcessLookupError","RecursionError","ReferenceError","ResourceWarning","RuntimeError","RuntimeWarning","StopAsyncIteration","StopIteration","SyntaxError","SyntaxWarning","SystemError","SystemExit","TabError","TimeoutError","TypeError","UnboundLocalError","UnicodeDecodeError","UnicodeEncodeError","UnicodeError","UnicodeTranslateError","UnicodeWarning","UserWarning","ValueError","Warning","ZeroDivisionError"].map(s=>({label:s,type:"type"}))).concat(["bool","bytearray","bytes","classmethod","complex","float","frozenset","int","list","map","memoryview","object","range","set","staticmethod","str","super","tuple","type"].map(s=>({label:s,type:"class"}))).concat(["abs","aiter","all","anext","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dict","dir","divmod","enumerate","eval","exec","exit","filter","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","license","locals","max","min","next","oct","open","ord","pow","print","property","quit","repr","reversed","round","setattr","slice","sorted","sum","vars","zip"].map(s=>({label:s,type:"function"}))),Bj=[Wt("def ${name}(${params}):\n ${}",{label:"def",detail:"function",type:"keyword"}),Wt("for ${name} in ${collection}:\n ${}",{label:"for",detail:"loop",type:"keyword"}),Wt("while ${}:\n ${}",{label:"while",detail:"loop",type:"keyword"}),Wt("try:\n ${}\nexcept ${error}:\n ${}",{label:"try",detail:"/ except block",type:"keyword"}),Wt(`if \${}:
|
|
29
|
-
|
|
30
|
-
`,{label:"if",detail:"block",type:"keyword"}),Wt("if ${}:\n ${}\nelse:\n ${}",{label:"if",detail:"/ else block",type:"keyword"}),Wt("class ${name}:\n def __init__(self, ${params}):\n ${}",{label:"class",detail:"definition",type:"keyword"}),Wt("import ${module}",{label:"import",detail:"statement",type:"keyword"}),Wt("from ${module} import ${names}",{label:"from",detail:"import",type:"keyword"})],Wj=ny(qy,lp(Ij.concat(Bj)));function Dd(s){let{node:e,pos:t}=s,i=s.lineIndent(t,-1),r=null;for(;;){let n=e.childBefore(t);if(n)if(n.name=="Comment")t=n.from;else if(n.name=="Body"||n.name=="MatchBody")s.baseIndentFor(n)+s.unit<=i&&(r=n),e=n;else if(n.name=="MatchClause")e=n;else if(n.type.is("Statement"))e=n;else break;else break}return r}function Id(s,e){let t=s.baseIndentFor(e),i=s.lineAt(s.pos,-1),r=i.from+i.text.length;return/^\s*($|#)/.test(i.text)&&s.node.to<r+100&&!/\S/.test(s.state.sliceDoc(r,s.node.to))&&s.lineIndent(s.pos,-1)<=t||/^\s*(else:|elif |except |finally:|case\s+[^=:]+:)/.test(s.textAfter)&&s.lineIndent(s.pos,-1)>t?null:t+s.unit}const Bd=_r.define({name:"python",parser:Lj.configure({props:[Yr.add({Body:s=>{var e;let t=/^\s*(#|$)/.test(s.textAfter)&&Dd(s)||s.node;return(e=Id(s,t))!==null&&e!==void 0?e:s.continue()},MatchBody:s=>{var e;let t=Dd(s);return(e=Id(s,t||s.node))!==null&&e!==void 0?e:s.continue()},IfStatement:s=>/^\s*(else:|elif )/.test(s.textAfter)?s.baseIndent:s.continue(),"ForStatement WhileStatement":s=>/^\s*else:/.test(s.textAfter)?s.baseIndent:s.continue(),TryStatement:s=>/^\s*(except[ :]|finally:|else:)/.test(s.textAfter)?s.baseIndent:s.continue(),MatchStatement:s=>/^\s*case /.test(s.textAfter)?s.baseIndent+s.unit:s.continue(),"TupleExpression ComprehensionExpression ParamList ArgList ParenthesizedExpression":lc({closing:")"}),"DictionaryExpression DictionaryComprehensionExpression SetExpression SetComprehensionExpression":lc({closing:"}"}),"ArrayExpression ArrayComprehensionExpression":lc({closing:"]"}),MemberExpression:s=>s.baseIndent+s.unit,"String FormatString":()=>null,Script:s=>{var e;let t=Dd(s);return(e=t&&Id(s,t))!==null&&e!==void 0?e:s.continue()}}),Pr.add({"ArrayExpression DictionaryExpression SetExpression TupleExpression":oh,Body:(s,e)=>({from:s.from+1,to:s.to-(s.to==e.doc.length?0:1)}),"String FormatString":(s,e)=>({from:e.doc.lineAt(s.from).to,to:s.to})})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""'],stringPrefixes:["f","fr","rf","r","u","b","br","rb","F","FR","RF","R","U","B","BR","RB"]},commentTokens:{line:"#"},indentOnInput:/^\s*([\}\]\)]|else:|elif |except |finally:|case\s+[^:]*:?)$/}});function Xj(){return new Vr(Bd,[Bd.data.of({autocomplete:Dj}),Bd.data.of({autocomplete:Wj})])}const qj=148,e0=1,zj=149,Zj=150,zy=2,Vj=151,Fj=3,Yj=4,Zy=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],Uj=58,Hj=40,Vy=95,Gj=91,pc=45,Kj=46,Jj=35,eE=37,tE=38,sE=92,iE=10,rE=42;function La(s){return s>=65&&s<=90||s>=97&&s<=122||s>=161}function bp(s){return s>=48&&s<=57}function t0(s){return bp(s)||s>=97&&s<=102||s>=65&&s<=70}const Fy=(s,e,t)=>(i,r)=>{for(let n=!1,a=0,o=0;;o++){let{next:l}=i;if(La(l)||l==pc||l==Vy||n&&bp(l))!n&&(l!=pc||o>0)&&(n=!0),a===o&&l==pc&&a++,i.advance();else if(l==sE&&i.peek(1)!=iE){if(i.advance(),t0(i.next)){do i.advance();while(t0(i.next));i.next==32&&i.advance()}else i.next>-1&&i.advance();n=!0}else{n&&i.acceptToken(a==2&&r.canShift(zy)?e:l==Hj?t:s);break}}},nE=new ts(Fy(zj,zy,Zj),{contextual:!0}),oE=new ts(Fy(Vj,Fj,Yj),{contextual:!0}),aE=new ts(s=>{if(Zy.includes(s.peek(-1))){let{next:e}=s;(La(e)||e==Vy||e==Jj||e==Kj||e==rE||e==Gj||e==Uj&&La(s.peek(1))||e==pc||e==tE)&&s.acceptToken(qj)}}),lE=new ts(s=>{if(!Zy.includes(s.peek(-1))){let{next:e}=s;if(e==eE&&(s.advance(),s.acceptToken(e0)),La(e)){do s.advance();while(La(s.next)||bp(s.next));s.acceptToken(e0)}}}),cE=Cr({"AtKeyword import charset namespace keyframes media supports font-feature-values":L.definitionKeyword,"from to selector scope MatchFlag":L.keyword,NamespaceName:L.namespace,KeyframeName:L.labelName,KeyframeRangeName:L.operatorKeyword,TagName:L.tagName,ClassName:L.className,PseudoClassName:L.constant(L.className),IdName:L.labelName,"FeatureName PropertyName":L.propertyName,AttributeName:L.attributeName,NumberLiteral:L.number,KeywordQuery:L.keyword,UnaryQueryOp:L.operatorKeyword,"CallTag ValueName FontName":L.atom,VariableName:L.variableName,Callee:L.operatorKeyword,Unit:L.unit,"UniversalSelector NestingSelector":L.definitionOperator,"MatchOp CompareOp":L.compareOperator,"ChildOp SiblingOp, LogicOp":L.logicOperator,BinOp:L.arithmeticOperator,Important:L.modifier,Comment:L.blockComment,ColorLiteral:L.color,"ParenthesizedContent StringLiteral":L.string,":":L.punctuation,"PseudoOp #":L.derefOperator,"; , |":L.separator,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace}),hE={__proto__:null,lang:44,"nth-child":44,"nth-last-child":44,"nth-of-type":44,"nth-last-of-type":44,dir:44,"host-context":44,if:90,url:158,"url-prefix":158,domain:158,regexp:158},dE={__proto__:null,or:104,and:104,not:112,only:112,layer:212},uE={__proto__:null,selector:118,style:124,layer:208},fE={__proto__:null,"@import":204,"@media":216,"@charset":220,"@namespace":224,"@keyframes":230,"@supports":242,"@scope":246,"@font-feature-values":252},pE={__proto__:null,to:249},mE=wr.deserialize({version:14,states:"MrQYQdOOO#}QdOOP$UO`OOO%OQaO'#CfOOQP'#Ce'#CeO%VQdO'#CgO%[Q`O'#CgO%aQaO'#FqO&XQdO'#CkO&xQaO'#CcO'SQdO'#CnO'_QdO'#ERO'dQdO'#ETO'oQdO'#E[O'oQdO'#E_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Q&`$vQ'^&[Q'a&aR(S']SnP!RQ#^oQ%O#[R&g%PZmPo!R#[%PQ$}#ZQ&e${R'd&dR$g!rQ'R%{R(['yR#OgR#QhR$s#QS&[$r&]R(Q'[V&Y$r&]'[R#YkQ#`qR%S#`QcOSoP!RU!lco%PR%P#[Q%]#q[&l%]&r'i'r'x(bQ&r%aQ'i&mQ'r&wQ'x'OR(b(VQ$[!nQ$^!oQ$`!pV%v$[$^$`Q&Q$iR'X&QQ&v%iS'q&v(WR(W'rQ&n%]R'j&nQ&j%YR'h&jQ!QXR#m!QQ&d${R'c&dQ#]nS%Q#]%RR%R#^Q'z'RR(]'zQ$m!yR&U$mQ&]$rR'_&]Q']&[R(R']Q#XkR$y#XQ$P!dR%f$P_bOPco!R#[%P^XOPco!R#[%PQ!`]Q!a^Q#i|Q#j}Q#k!OQ#l!PQ$u#SQ%Y#pR'g&iR%^#qQ!rdQ!{f[$X!n!o!p$[$^$`Q${#Zh%[#q%]%a&m&r&w'O'i'r'x(V(bQ%`#vQ%z$cS&b${&dQ&h%WQ'b&cR'|'T]$Z!n!o!p$[$^$`Q!d`U!ye!r$gQ#RiQ#y!cS#|!d$PQ$R!eQ%d#}Q%e$OQ%i$SS&O$i&QQ&T$lR'o&uQ#{!cW%s$W%m&z'uQ&t%bQ'w&}Q(U'mR(d(ZQ%u$WQ&y%mQ't&zR(Y'uR%k$SR%Z#pQpPR#o!RQ!zeQ$f!rR%}$g",nodeNames:"⚠ Unit VariableName VariableName QueryCallee Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NamespacedTagSelector NamespaceName TagName NestingSelector ClassSelector . ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue AtKeyword # ; ] [ BracketedValue } { BracedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee IfExpression if ArgList IfBranch KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp ComparisonQuery CompareOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector ParenthesizedSelector StyleQuery style ParenthesedQuery CallQuery ArgList ProperyName , ProperyName UnaryQuery ParenthesedQuery BinaryQuery ParenthesedQuery ParenthesedQuery StyleFeature ProperyName StyleRange PseudoQuery CallLiteral CallTag ParenthesizedContent PseudoClassName ArgList IdSelector IdName AttributeSelector AttributeName NamespacedAttribute NamespaceName AttributeName MatchOp MatchFlag ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp Block Declaration PropertyName Important ImportStatement import Layer layer LayerName layer MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports ScopeStatement scope to FontFeatureStatement font-feature-values FontName AtRule Styles",maxTerm:174,nodeProps:[["isolate",-2,5,39,""],["openedBy",23,"(",31,"[",34,"{"],["closedBy",24,")",32,"]",35,"}"]],propSources:[cE],skippedNodes:[0,5,130],repeatNodeCount:17,tokenData:"K`~R!bOX%ZX^&R^p%Zpq&Rqr)ers)vst+jtu2Xuv%Zvw3Rwx3dxy5Ryz5dz{5i{|6S|}:u}!O;W!O!P;u!P!Q<^!Q![=V![!]>Q!]!^>|!^!_?_!_!`@Z!`!a@n!a!b%Z!b!cAo!c!k%Z!k!lC|!l!u%Z!u!vC|!v!}%Z!}#OD_#O#P%Z#P#QDp#Q#R2X#R#]%Z#]#^ER#^#g%Z#g#hC|#h#o%Z#o#pIf#p#qIw#q#rJ`#r#sJq#s#y%Z#y#z&R#z$f%Z$f$g&R$g#BY%Z#BY#BZ&R#BZ$IS%Z$IS$I_&R$I_$I|%Z$I|$JO&R$JO$JT%Z$JT$JU&R$JU$KV%Z$KV$KW&R$KW&FU%Z&FU&FV&R&FV;'S%Z;'S;=`KY<%lO%Z`%^SOy%jz;'S%j;'S;=`%{<%lO%j`%oS!r`Oy%jz;'S%j;'S;=`%{<%lO%j`&OP;=`<%l%j~&Wh$_~OX%jX^'r^p%jpq'rqy%jz#y%j#y#z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jjIkSsYOy%jz;'S%j;'S;=`%{<%lO%jfI|U$fUOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jjJeSrYOy%jz;'S%j;'S;=`%{<%lO%jfJvU#SQOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%j`K]P;=`<%l%Z",tokenizers:[aE,lE,nE,oE,1,2,3,4,new Zc("m~RRYZ[z{a~~g~aO$b~~dP!P!Qg~lO$c~~",28,155)],topRules:{StyleSheet:[0,6],Styles:[1,129]},dynamicPrecedences:{97:1},specialized:[{term:150,get:s=>hE[s]||-1},{term:151,get:s=>dE[s]||-1},{term:4,get:s=>uE[s]||-1},{term:28,get:s=>fE[s]||-1},{term:149,get:s=>pE[s]||-1}],tokenPrec:2444});let Wd=null;function Xd(){if(!Wd&&typeof document=="object"&&document.body){let{style:s}=document.body,e=[],t=new Set;for(let i in s)i!="cssText"&&i!="cssFloat"&&typeof s[i]=="string"&&(/[A-Z]/.test(i)&&(i=i.replace(/[A-Z]/g,r=>"-"+r.toLowerCase())),t.has(i)||(e.push(i),t.add(i)));Wd=e.sort().map(i=>({type:"property",label:i,apply:i+": "}))}return Wd||[]}const s0=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(s=>({type:"class",label:s})),i0=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(s=>({type:"keyword",label:s})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(s=>({type:"constant",label:s}))),gE=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(s=>({type:"type",label:s})),OE=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(s=>({type:"keyword",label:s})),lr=/^(\w[\w-]*|-\w[\w-]*|)$/,xE=/^-(-[\w-]*)?$/;function vE(s,e){var t;if((s.name=="("||s.type.isError)&&(s=s.parent||s),s.name!="ArgList")return!1;let i=(t=s.parent)===null||t===void 0?void 0:t.firstChild;return i?.name!="Callee"?!1:e.sliceString(i.from,i.to)=="var"}const r0=new Ff,bE=["Declaration"];function yE(s){for(let e=s;;){if(e.type.isTop)return e;if(!(e=e.parent))return s}}function Yy(s,e,t){if(e.to-e.from>4096){let i=r0.get(e);if(i)return i;let r=[],n=new Set,a=e.cursor(_t.IncludeAnonymous);if(a.firstChild())do for(let o of Yy(s,a.node,t))n.has(o.label)||(n.add(o.label),r.push(o));while(a.nextSibling());return r0.set(e,r),r}else{let i=[],r=new Set;return e.cursor().iterate(n=>{var a;if(t(n)&&n.matchContext(bE)&&((a=n.node.nextSibling)===null||a===void 0?void 0:a.name)==":"){let o=s.sliceString(n.from,n.to);r.has(o)||(r.add(o),i.push({label:o,type:"variable"}))}}),i}}const SE=s=>e=>{let{state:t,pos:i}=e,r=kt(t).resolveInner(i,-1),n=r.type.isError&&r.from==r.to-1&&t.doc.sliceString(r.from,r.to)=="-";if(r.name=="PropertyName"||(n||r.name=="TagName")&&/^(Block|Styles)$/.test(r.resolve(r.to).name))return{from:r.from,options:Xd(),validFor:lr};if(r.name=="ValueName")return{from:r.from,options:i0,validFor:lr};if(r.name=="PseudoClassName")return{from:r.from,options:s0,validFor:lr};if(s(r)||(e.explicit||n)&&vE(r,t.doc))return{from:s(r)||n?r.from:i,options:Yy(t.doc,yE(r),s),validFor:xE};if(r.name=="TagName"){for(let{parent:l}=r;l;l=l.parent)if(l.name=="Block")return{from:r.from,options:Xd(),validFor:lr};return{from:r.from,options:gE,validFor:lr}}if(r.name=="AtKeyword")return{from:r.from,options:OE,validFor:lr};if(!e.explicit)return null;let a=r.resolve(i),o=a.childBefore(i);return o&&o.name==":"&&a.name=="PseudoClassSelector"?{from:i,options:s0,validFor:lr}:o&&o.name==":"&&a.name=="Declaration"||a.name=="ArgList"?{from:i,options:i0,validFor:lr}:a.name=="Block"||a.name=="Styles"?{from:i,options:Xd(),validFor:lr}:null},_E=SE(s=>s.name=="VariableName"),Vc=_r.define({name:"css",parser:mE.configure({props:[Yr.add({Declaration:ao()}),Pr.add({"Block KeyframeList":oh})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function Uy(){return new Vr(Vc,Vc.data.of({autocomplete:_E}))}const wE=55,kE=1,CE=56,PE=2,TE=57,QE=3,n0=4,$E=5,yp=6,Hy=7,Gy=8,Ky=9,Jy=10,jE=11,EE=12,RE=13,qd=58,AE=14,ME=15,o0=59,e1=21,LE=23,t1=24,NE=25,hf=27,s1=28,DE=29,IE=32,BE=35,WE=37,XE=38,qE=0,zE=1,ZE={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},VE={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},a0={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function FE(s){return s==45||s==46||s==58||s>=65&&s<=90||s==95||s>=97&&s<=122||s>=161}let l0=null,c0=null,h0=0;function df(s,e){let t=s.pos+e;if(h0==t&&c0==s)return l0;let i=s.peek(e),r="";for(;FE(i);)r+=String.fromCharCode(i),i=s.peek(++e);return c0=s,h0=t,l0=r?r.toLowerCase():i==YE||i==UE?void 0:null}const i1=60,Fc=62,Sp=47,YE=63,UE=33,HE=45;function d0(s,e){this.name=s,this.parent=e}const GE=[yp,Jy,Hy,Gy,Ky],KE=new fh({start:null,shift(s,e,t,i){return GE.indexOf(e)>-1?new d0(df(i,1)||"",s):s},reduce(s,e){return e==e1&&s?s.parent:s},reuse(s,e,t,i){let r=e.type.id;return r==yp||r==WE?new d0(df(i,1)||"",s):s},strict:!1}),JE=new ts((s,e)=>{if(s.next!=i1){s.next<0&&e.context&&s.acceptToken(qd);return}s.advance();let t=s.next==Sp;t&&s.advance();let i=df(s,0);if(i===void 0)return;if(!i)return s.acceptToken(t?ME:AE);let r=e.context?e.context.name:null;if(t){if(i==r)return s.acceptToken(jE);if(r&&VE[r])return s.acceptToken(qd,-2);if(e.dialectEnabled(qE))return s.acceptToken(EE);for(let n=e.context;n;n=n.parent)if(n.name==i)return;s.acceptToken(RE)}else{if(i=="script")return s.acceptToken(Hy);if(i=="style")return s.acceptToken(Gy);if(i=="textarea")return s.acceptToken(Ky);if(ZE.hasOwnProperty(i))return s.acceptToken(Jy);r&&a0[r]&&a0[r][i]?s.acceptToken(qd,-1):s.acceptToken(yp)}},{contextual:!0}),eR=new ts(s=>{for(let e=0,t=0;;t++){if(s.next<0){t&&s.acceptToken(o0);break}if(s.next==HE)e++;else if(s.next==Fc&&e>=2){t>=3&&s.acceptToken(o0,-2);break}else e=0;s.advance()}});function tR(s){for(;s;s=s.parent)if(s.name=="svg"||s.name=="math")return!0;return!1}const sR=new ts((s,e)=>{if(s.next==Sp&&s.peek(1)==Fc){let t=e.dialectEnabled(zE)||tR(e.context);s.acceptToken(t?$E:n0,2)}else s.next==Fc&&s.acceptToken(n0,1)});function _p(s,e,t){let i=2+s.length;return new ts(r=>{for(let n=0,a=0,o=0;;o++){if(r.next<0){o&&r.acceptToken(e);break}if(n==0&&r.next==i1||n==1&&r.next==Sp||n>=2&&n<i&&r.next==s.charCodeAt(n-2))n++,a++;else if(n==i&&r.next==Fc){o>a?r.acceptToken(e,-a):r.acceptToken(t,-(a-2));break}else if((r.next==10||r.next==13)&&o){r.acceptToken(e,1);break}else n=a=0;r.advance()}})}const iR=_p("script",wE,kE),rR=_p("style",CE,PE),nR=_p("textarea",TE,QE),oR=Cr({"Text RawText IncompleteTag IncompleteCloseTag":L.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":L.angleBracket,TagName:L.tagName,"MismatchedCloseTag/TagName":[L.tagName,L.invalid],AttributeName:L.attributeName,"AttributeValue UnquotedAttributeValue":L.attributeValue,Is:L.definitionOperator,"EntityReference CharacterReference":L.character,Comment:L.blockComment,ProcessingInst:L.processingInstruction,DoctypeDecl:L.documentMeta}),aR=wr.deserialize({version:14,states:",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&rO'#CtOOQW'#D['#D[O(hQ&rO1G.xOOOa1G.x1G.xOOO`1G/Z1G/ZO(sQ&rO1G/ROOOb1G/R1G/RO)OQ&rO1G/UOOOd1G/U1G/UO)ZQ&rO1G/XOOO`1G/X1G/XO)fQ&rO1G/ZOOOa-E7]-E7]O)qQ#tO'#CzOOO`1G.w1G.wOOOb-E7^-E7^O)vQ#tO'#C}OOOd-E7_-E7_O){Q#tO'#DQOOO`-E7`-E7`O*QQ#|O,59nOOOp-E7a-E7a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P$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:68,context:KE,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,22,31,34,37,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,30,33,36,38,"OpenTag"],["group",-10,14,15,18,19,20,21,40,41,42,43,"Entity",17,"Entity TextContent",-3,29,32,35,"TextContent Entity"],["isolate",-11,22,30,31,33,34,36,37,38,39,42,43,"ltr",-3,27,28,40,""]],propSources:[oR],skippedNodes:[0],repeatNodeCount:9,tokenData:"!<p!aR!YOX$qXY,QYZ,QZ[$q[]&X]^,Q^p$qpq,Qqr-_rs3_sv-_vw3}wxHYx}-_}!OH{!O!P-_!P!Q$q!Q![-_![!]Mz!]!^-_!^!_!$S!_!`!;x!`!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4U-_4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Kh-_$Kh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;uP;=`<%l!4t!V!<TXjSaP!b`!dpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X",tokenizers:[iR,rR,nR,sR,JE,eR,0,1,2,3,4,5],topRules:{Document:[0,16]},dialects:{noMatch:0,selfClosing:515},tokenPrec:517});function r1(s,e){let t=Object.create(null);for(let i of s.getChildren(t1)){let r=i.getChild(NE),n=i.getChild(hf)||i.getChild(s1);r&&(t[e.read(r.from,r.to)]=n?n.type.id==hf?e.read(n.from+1,n.to-1):e.read(n.from,n.to):"")}return t}function u0(s,e){let t=s.getChild(LE);return t?e.read(t.from,t.to):" "}function zd(s,e,t){let i;for(let r of t)if(!r.attrs||r.attrs(i||(i=r1(s.node.parent.firstChild,e))))return{parser:r.parser,bracketed:!0};return null}function n1(s=[],e=[]){let t=[],i=[],r=[],n=[];for(let o of s)(o.tag=="script"?t:o.tag=="style"?i:o.tag=="textarea"?r:n).push(o);let a=e.length?Object.create(null):null;for(let o of e)(a[o.name]||(a[o.name]=[])).push(o);return Kv((o,l)=>{let c=o.type.id;if(c==DE)return zd(o,l,t);if(c==IE)return zd(o,l,i);if(c==BE)return zd(o,l,r);if(c==e1&&n.length){let d=o.node,u=d.firstChild,f=u&&u0(u,l),g;if(f){for(let b of n)if(b.tag==f&&(!b.attrs||b.attrs(g||(g=r1(u,l))))){let v=d.lastChild,m=v.type.id==XE?v.from:d.to;if(m>u.to)return{parser:b.parser,overlay:[{from:u.to,to:m}]}}}}if(a&&c==t1){let d=o.node,u;if(u=d.firstChild){let f=a[l.read(u.from,u.to)];if(f)for(let g of f){if(g.tagName&&g.tagName!=u0(d.parent,l))continue;let b=d.lastChild;if(b.type.id==hf){let v=b.from+1,m=b.lastChild,O=b.to-(m&&m.isError?0:1);if(O>v)return{parser:g.parser,overlay:[{from:v,to:O}],bracketed:!0}}else if(b.type.id==s1)return{parser:g.parser,overlay:[{from:b.from,to:b.to}]}}}}return null})}const ea=["_blank","_self","_top","_parent"],Zd=["ascii","utf-8","utf-16","latin1","latin1"],Vd=["get","post","put","delete"],Fd=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Gs=["true","false"],qe={},lR={a:{attrs:{href:null,ping:null,type:null,media:null,target:ea,hreflang:null}},abbr:qe,address:qe,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:qe,aside:qe,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:qe,base:{attrs:{href:null,target:ea}},bdi:qe,bdo:qe,blockquote:{attrs:{cite:null}},body:qe,br:qe,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Fd,formmethod:Vd,formnovalidate:["novalidate"],formtarget:ea,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:qe,center:qe,cite:qe,code:qe,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:qe,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:qe,div:qe,dl:qe,dt:qe,em:qe,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:qe,figure:qe,footer:qe,form:{attrs:{action:null,name:null,"accept-charset":Zd,autocomplete:["on","off"],enctype:Fd,method:Vd,novalidate:["novalidate"],target:ea}},h1:qe,h2:qe,h3:qe,h4:qe,h5:qe,h6:qe,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:qe,hgroup:qe,hr:qe,html:{attrs:{manifest:null}},i:qe,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Fd,formmethod:Vd,formnovalidate:["novalidate"],formtarget:ea,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:qe,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:qe,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:qe,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Zd,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:qe,noscript:qe,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:qe,param:{attrs:{name:null,value:null}},pre:qe,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:qe,rt:qe,ruby:qe,samp:qe,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Zd}},section:qe,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:qe,source:{attrs:{src:null,type:null,media:null}},span:qe,strong:qe,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:qe,summary:qe,sup:qe,table:qe,tbody:qe,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:qe,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:qe,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:qe,time:{attrs:{datetime:null}},title:qe,tr:qe,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:qe,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:qe},o1={accesskey:null,class:null,contenteditable:Gs,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Gs,autocorrect:Gs,autocapitalize:Gs,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Gs,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Gs,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Gs,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Gs,"aria-hidden":Gs,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Gs,"aria-multiselectable":Gs,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Gs,"aria-relevant":null,"aria-required":Gs,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},a1="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(s=>"on"+s);for(let s of a1)o1[s]=null;class Na{constructor(e,t){this.tags={...lR,...e},this.globalAttrs={...o1,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Na.default=new Na;function vo(s,e,t=s.length){if(!e)return"";let i=e.firstChild,r=i&&i.getChild("TagName");return r?s.sliceString(r.from,Math.min(r.to,t)):""}function bo(s,e=!1){for(;s;s=s.parent)if(s.name=="Element")if(e)e=!1;else return s;return null}function l1(s,e,t){let i=t.tags[vo(s,bo(e))];return i?.children||t.allTags}function wp(s,e){let t=[];for(let i=bo(e);i&&!i.type.isTop;i=bo(i.parent)){let r=vo(s,i);if(r&&i.lastChild.name=="CloseTag")break;r&&t.indexOf(r)<0&&(e.name=="EndTag"||e.from>=i.firstChild.to)&&t.push(r)}return t}const c1=/^[:\-\.\w\u00b7-\uffff]*$/;function f0(s,e,t,i,r){let n=/\s*>/.test(s.sliceDoc(r,r+5))?"":">",a=bo(t,t.name=="StartTag"||t.name=="TagName");return{from:i,to:r,options:l1(s.doc,a,e).map(o=>({label:o,type:"type"})).concat(wp(s.doc,t).map((o,l)=>({label:"/"+o,apply:"/"+o+n,type:"type",boost:99-l}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function p0(s,e,t,i){let r=/\s*>/.test(s.sliceDoc(i,i+5))?"":">";return{from:t,to:i,options:wp(s.doc,e).map((n,a)=>({label:n,apply:n+r,type:"type",boost:99-a})),validFor:c1}}function cR(s,e,t,i){let r=[],n=0;for(let a of l1(s.doc,t,e))r.push({label:"<"+a,type:"type"});for(let a of wp(s.doc,t))r.push({label:"</"+a+">",type:"type",boost:99-n++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function hR(s,e,t,i,r){let n=bo(t),a=n?e.tags[vo(s.doc,n)]:null,o=a&&a.attrs?Object.keys(a.attrs):[],l=a&&a.globalAttrs===!1?o:o.length?o.concat(e.globalAttrNames):e.globalAttrNames;return{from:i,to:r,options:l.map(c=>({label:c,type:"property"})),validFor:c1}}function dR(s,e,t,i,r){var n;let a=(n=t.parent)===null||n===void 0?void 0:n.getChild("AttributeName"),o=[],l;if(a){let c=s.sliceDoc(a.from,a.to),d=e.globalAttrs[c];if(!d){let u=bo(t),f=u?e.tags[vo(s.doc,u)]:null;d=f?.attrs&&f.attrs[c]}if(d){let u=s.sliceDoc(i,r).toLowerCase(),f='"',g='"';/^['"]/.test(u)?(l=u[0]=='"'?/^[^"]*$/:/^[^']*$/,f="",g=s.sliceDoc(r,r+1)==u[0]?"":u[0],u=u.slice(1),i++):l=/^[^\s<>='"]*$/;for(let b of d)o.push({label:b,apply:f+b+g,type:"constant"})}}return{from:i,to:r,options:o,validFor:l}}function h1(s,e){let{state:t,pos:i}=e,r=kt(t).resolveInner(i,-1),n=r.resolve(i);for(let a=i,o;n==r&&(o=r.childBefore(a));){let l=o.lastChild;if(!l||!l.type.isError||l.from<l.to)break;n=r=o,a=l.from}return r.name=="TagName"?r.parent&&/CloseTag$/.test(r.parent.name)?p0(t,r,r.from,i):f0(t,s,r,r.from,i):r.name=="StartTag"||r.name=="IncompleteTag"?f0(t,s,r,i,i):r.name=="StartCloseTag"||r.name=="IncompleteCloseTag"?p0(t,r,i,i):r.name=="OpenTag"||r.name=="SelfClosingTag"||r.name=="AttributeName"?hR(t,s,r,r.name=="AttributeName"?r.from:i,i):r.name=="Is"||r.name=="AttributeValue"||r.name=="UnquotedAttributeValue"?dR(t,s,r,r.name=="Is"?i:r.from,i):e.explicit&&(n.name=="Element"||n.name=="Text"||n.name=="Document")?cR(t,s,r,i):null}function uR(s){return h1(Na.default,s)}function fR(s){let{extraTags:e,extraGlobalAttributes:t}=s,i=t||e?new Na(e,t):Na.default;return r=>h1(i,r)}const pR=Hi.parser.configure({top:"SingleExpression"}),d1=[{tag:"script",attrs:s=>s.type=="text/typescript"||s.lang=="ts",parser:Qy.parser},{tag:"script",attrs:s=>s.type=="text/babel"||s.type=="text/jsx",parser:$y.parser},{tag:"script",attrs:s=>s.type=="text/typescript-jsx",parser:jy.parser},{tag:"script",attrs(s){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(s.type)},parser:pR},{tag:"script",attrs(s){return!s.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(s.type)},parser:Hi.parser},{tag:"style",attrs(s){return(!s.lang||s.lang=="css")&&(!s.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(s.type))},parser:Vc.parser}],u1=[{name:"style",parser:Vc.parser.configure({top:"Styles"})}].concat(a1.map(s=>({name:s,parser:Hi.parser}))),f1=_r.define({name:"html",parser:aR.configure({props:[Yr.add({Element(s){let e=/^(\s*)(<\/)?/.exec(s.textAfter);return s.node.to<=s.pos+e[0].length?s.continue():s.lineIndent(s.node.from)+(e[2]?0:s.unit)},"OpenTag CloseTag SelfClosingTag"(s){return s.column(s.node.from)+s.unit},Document(s){if(s.pos+/\s*/.exec(s.textAfter)[0].length<s.node.to)return s.continue();let e=null,t;for(let i=s.node;;){let r=i.lastChild;if(!r||r.name!="Element"||r.to!=i.to)break;e=i=r}return e&&!((t=e.lastChild)&&(t.name=="CloseTag"||t.name=="SelfClosingTag"))?s.lineIndent(e.from)+s.unit:null}}),Pr.add({Element(s){let e=s.firstChild,t=s.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:s.to}}}),Jf.add({"OpenTag CloseTag":s=>s.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),mc=f1.configure({wrap:n1(d1,u1)});function p1(s={}){let e="",t;s.matchClosingTags===!1&&(e="noMatch"),s.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(s.nestedLanguages&&s.nestedLanguages.length||s.nestedAttributes&&s.nestedAttributes.length)&&(t=n1((s.nestedLanguages||[]).concat(d1),(s.nestedAttributes||[]).concat(u1)));let i=t?f1.configure({wrap:t,dialect:e}):e?mc.configure({dialect:e}):mc;return new Vr(i,[mc.data.of({autocomplete:fR(s)}),s.autoCloseTags!==!1?mR:[],dc().support,Uy().support])}const m0=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),mR=_e.inputHandler.of((s,e,t,i,r)=>{if(s.composing||s.state.readOnly||e!=t||i!=">"&&i!="/"||!mc.isActiveAt(s.state,e,-1))return!1;let n=r(),{state:a}=n,o=a.changeByRange(l=>{var c,d,u;let f=a.doc.sliceString(l.from-1,l.to)==i,{head:g}=l,b=kt(a).resolveInner(g,-1),v;if(f&&i==">"&&b.name=="EndTag"){let m=b.parent;if(((d=(c=m.parent)===null||c===void 0?void 0:c.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(v=vo(a.doc,m.parent,g))&&!m0.has(v)){let O=g+(a.doc.sliceString(g,g+1)===">"?1:0),p=`</${v}>`;return{range:l,changes:{from:g,to:O,insert:p}}}}else if(f&&i=="/"&&b.name=="IncompleteCloseTag"){let m=b.parent;if(b.from==g-2&&((u=m.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(v=vo(a.doc,m,g))&&!m0.has(v)){let O=g+(a.doc.sliceString(g,g+1)===">"?1:0),p=`${v}>`;return{range:re.cursor(g+p.length,-1),changes:{from:g,to:O,insert:p}}}}return{range:l}});return o.changes.empty?!1:(s.dispatch([n,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});class Yc{static create(e,t,i,r,n){let a=r+(r<<8)+e+(t<<4)|0;return new Yc(e,t,i,a,n,[],[])}constructor(e,t,i,r,n,a,o){this.type=e,this.value=t,this.from=i,this.hash=r,this.end=n,this.children=a,this.positions=o,this.hashProp=[[ot.contextHash,r]]}addChild(e,t){e.prop(ot.contextHash)!=this.hash&&(e=new wt(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let i=this.children.length-1;return i>=0&&(t=Math.max(t,this.positions[i]+this.children[i].length+this.from)),new wt(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(r,n,a)=>new wt(es.none,r,n,a,this.hashProp)})}}var ve;(function(s){s[s.Document=1]="Document",s[s.CodeBlock=2]="CodeBlock",s[s.FencedCode=3]="FencedCode",s[s.Blockquote=4]="Blockquote",s[s.HorizontalRule=5]="HorizontalRule",s[s.BulletList=6]="BulletList",s[s.OrderedList=7]="OrderedList",s[s.ListItem=8]="ListItem",s[s.ATXHeading1=9]="ATXHeading1",s[s.ATXHeading2=10]="ATXHeading2",s[s.ATXHeading3=11]="ATXHeading3",s[s.ATXHeading4=12]="ATXHeading4",s[s.ATXHeading5=13]="ATXHeading5",s[s.ATXHeading6=14]="ATXHeading6",s[s.SetextHeading1=15]="SetextHeading1",s[s.SetextHeading2=16]="SetextHeading2",s[s.HTMLBlock=17]="HTMLBlock",s[s.LinkReference=18]="LinkReference",s[s.Paragraph=19]="Paragraph",s[s.CommentBlock=20]="CommentBlock",s[s.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",s[s.Escape=22]="Escape",s[s.Entity=23]="Entity",s[s.HardBreak=24]="HardBreak",s[s.Emphasis=25]="Emphasis",s[s.StrongEmphasis=26]="StrongEmphasis",s[s.Link=27]="Link",s[s.Image=28]="Image",s[s.InlineCode=29]="InlineCode",s[s.HTMLTag=30]="HTMLTag",s[s.Comment=31]="Comment",s[s.ProcessingInstruction=32]="ProcessingInstruction",s[s.Autolink=33]="Autolink",s[s.HeaderMark=34]="HeaderMark",s[s.QuoteMark=35]="QuoteMark",s[s.ListMark=36]="ListMark",s[s.LinkMark=37]="LinkMark",s[s.EmphasisMark=38]="EmphasisMark",s[s.CodeMark=39]="CodeMark",s[s.CodeText=40]="CodeText",s[s.CodeInfo=41]="CodeInfo",s[s.LinkTitle=42]="LinkTitle",s[s.LinkLabel=43]="LinkLabel",s[s.URL=44]="URL"})(ve||(ve={}));class gR{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class OR{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return fa(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,i=0){for(let r=t;r<e;r++)i+=this.text.charCodeAt(r)==9?4-i%4:1;return i}findColumn(e){let t=0;for(let i=0;t<this.text.length&&i<e;t++)i+=this.text.charCodeAt(t)==9?4-i%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e="";for(let t=0;t<this.basePos;t++)e+=" ";return e+this.text.slice(this.basePos)}}function g0(s,e,t){if(t.pos==t.text.length||s!=e.block&&t.indent>=e.stack[t.depth+1].value+t.baseIndent)return!0;if(t.indent>=t.baseIndent+4)return!1;let i=(s.type==ve.OrderedList?Pp:Cp)(t,e,!1);return i>0&&(s.type!=ve.BulletList||kp(t,e,!1)<0)&&t.text.charCodeAt(t.pos+i-1)==s.value}const m1={[ve.Blockquote](s,e,t){return t.next!=62?!1:(t.markers.push(Ot(ve.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1)),t.moveBase(t.pos+(Oi(t.text.charCodeAt(t.pos+1))?2:1)),s.end=e.lineStart+t.text.length,!0)},[ve.ListItem](s,e,t){return t.indent<t.baseIndent+s.value&&t.next>-1?!1:(t.moveBaseColumn(t.baseIndent+s.value),!0)},[ve.OrderedList]:g0,[ve.BulletList]:g0,[ve.Document](){return!0}};function Oi(s){return s==32||s==9||s==10||s==13}function fa(s,e=0){for(;e<s.length&&Oi(s.charCodeAt(e));)e++;return e}function O0(s,e,t){for(;e>t&&Oi(s.charCodeAt(e-1));)e--;return e}function g1(s){if(s.next!=96&&s.next!=126)return-1;let e=s.pos+1;for(;e<s.text.length&&s.text.charCodeAt(e)==s.next;)e++;if(e<s.pos+3)return-1;if(s.next==96){for(let t=e;t<s.text.length;t++)if(s.text.charCodeAt(t)==96)return-1}return e}function O1(s){return s.next!=62?-1:s.text.charCodeAt(s.pos+1)==32?2:1}function kp(s,e,t){if(s.next!=42&&s.next!=45&&s.next!=95)return-1;let i=1;for(let r=s.pos+1;r<s.text.length;r++){let n=s.text.charCodeAt(r);if(n==s.next)i++;else if(!Oi(n))return-1}return t&&s.next==45&&b1(s)>-1&&s.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(w1.SetextHeading)>-1||i<3?-1:1}function x1(s,e){for(let t=s.stack.length-1;t>=0;t--)if(s.stack[t].type==e)return!0;return!1}function Cp(s,e,t){return(s.next==45||s.next==43||s.next==42)&&(s.pos==s.text.length-1||Oi(s.text.charCodeAt(s.pos+1)))&&(!t||x1(e,ve.BulletList)||s.skipSpace(s.pos+2)<s.text.length)?1:-1}function Pp(s,e,t){let i=s.pos,r=s.next;for(;r>=48&&r<=57;){i++;if(i==s.text.length)return-1;r=s.text.charCodeAt(i)}return i==s.pos||i>s.pos+9||r!=46&&r!=41||i<s.text.length-1&&!Oi(s.text.charCodeAt(i+1))||t&&!x1(e,ve.OrderedList)&&(s.skipSpace(i+1)==s.text.length||i>s.pos+1||s.next!=49)?-1:i+1-s.pos}function v1(s){if(s.next!=35)return-1;let e=s.pos+1;for(;e<s.text.length&&s.text.charCodeAt(e)==35;)e++;if(e<s.text.length&&s.text.charCodeAt(e)!=32)return-1;let t=e-s.pos;return t>6?-1:t}function b1(s){if(s.next!=45&&s.next!=61||s.indent>=s.baseIndent+4)return-1;let e=s.pos+1;for(;e<s.text.length&&s.text.charCodeAt(e)==s.next;)e++;let t=e;for(;e<s.text.length&&Oi(s.text.charCodeAt(e));)e++;return e==s.text.length?t:-1}const uf=/^[ \t]*$/,y1=/-->/,S1=/\?>/,ff=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,y1],[/^\s*<\?/,S1],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?: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|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,uf],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,uf]];function _1(s,e,t){if(s.next!=60)return-1;let i=s.text.slice(s.pos);for(let r=0,n=ff.length-(t?1:0);r<n;r++)if(ff[r][0].test(i))return r;return-1}function x0(s,e){let t=s.countIndent(e,s.pos,s.indent),i=s.skipSpace(e),r=s.countIndent(i,e,t);return r>=t+5||i==s.text.length?t+1:r}function Rr(s,e,t){let i=s.length-1;i>=0&&s[i].to==e&&s[i].type==ve.CodeText?s[i].to=t:s.push(Ot(ve.CodeText,e,t))}const Yl={LinkReference:void 0,IndentedCode(s,e){let t=e.baseIndent+4;if(e.indent<t)return!1;let i=e.findColumn(t),r=s.lineStart+i,n=s.lineStart+e.text.length,a=[],o=[];for(Rr(a,r,n);s.nextLine()&&e.depth>=s.stack.length;)if(e.pos==e.text.length){Rr(o,s.lineStart-1,s.lineStart);for(let l of e.markers)o.push(l)}else{if(e.indent<t)break;{if(o.length){for(let c of o)c.type==ve.CodeText?Rr(a,c.from,c.to):a.push(c);o=[]}Rr(a,s.lineStart-1,s.lineStart);for(let c of e.markers)a.push(c);n=s.lineStart+e.text.length;let l=s.lineStart+e.findColumn(e.baseIndent+4);l<n&&Rr(a,l,n)}}return o.length&&(o=o.filter(l=>l.type!=ve.CodeText),o.length&&(e.markers=o.concat(e.markers))),s.addNode(s.buffer.writeElements(a,-r).finish(ve.CodeBlock,n-r),r),!0},FencedCode(s,e){let t=g1(e);if(t<0)return!1;let i=s.lineStart+e.pos,r=e.next,n=t-e.pos,a=e.skipSpace(t),o=O0(e.text,e.text.length,a),l=[Ot(ve.CodeMark,i,i+n)];a<o&&l.push(Ot(ve.CodeInfo,s.lineStart+a,s.lineStart+o));for(let c=!0,d=!0,u=!1;s.nextLine()&&e.depth>=s.stack.length;c=!1){let f=e.pos;if(e.indent-e.baseIndent<4)for(;f<e.text.length&&e.text.charCodeAt(f)==r;)f++;if(f-e.pos>=n&&e.skipSpace(f)==e.text.length){for(let g of e.markers)l.push(g);d&&u&&Rr(l,s.lineStart-1,s.lineStart),l.push(Ot(ve.CodeMark,s.lineStart+e.pos,s.lineStart+f)),s.nextLine();break}else{u=!0,c||(Rr(l,s.lineStart-1,s.lineStart),d=!1);for(let v of e.markers)l.push(v);let g=s.lineStart+e.basePos,b=s.lineStart+e.text.length;g<b&&(Rr(l,g,b),d=!1)}}return s.addNode(s.buffer.writeElements(l,-i).finish(ve.FencedCode,s.prevLineEnd()-i),i),!0},Blockquote(s,e){let t=O1(e);return t<0?!1:(s.startContext(ve.Blockquote,e.pos),s.addNode(ve.QuoteMark,s.lineStart+e.pos,s.lineStart+e.pos+1),e.moveBase(e.pos+t),null)},HorizontalRule(s,e){if(kp(e,s,!1)<0)return!1;let t=s.lineStart+e.pos;return s.nextLine(),s.addNode(ve.HorizontalRule,t),!0},BulletList(s,e){let t=Cp(e,s,!1);if(t<0)return!1;s.block.type!=ve.BulletList&&s.startContext(ve.BulletList,e.basePos,e.next);let i=x0(e,e.pos+1);return s.startContext(ve.ListItem,e.basePos,i-e.baseIndent),s.addNode(ve.ListMark,s.lineStart+e.pos,s.lineStart+e.pos+t),e.moveBaseColumn(i),null},OrderedList(s,e){let t=Pp(e,s,!1);if(t<0)return!1;s.block.type!=ve.OrderedList&&s.startContext(ve.OrderedList,e.basePos,e.text.charCodeAt(e.pos+t-1));let i=x0(e,e.pos+t);return s.startContext(ve.ListItem,e.basePos,i-e.baseIndent),s.addNode(ve.ListMark,s.lineStart+e.pos,s.lineStart+e.pos+t),e.moveBaseColumn(i),null},ATXHeading(s,e){let t=v1(e);if(t<0)return!1;let i=e.pos,r=s.lineStart+i,n=O0(e.text,e.text.length,i),a=n;for(;a>i&&e.text.charCodeAt(a-1)==e.next;)a--;(a==n||a==i||!Oi(e.text.charCodeAt(a-1)))&&(a=e.text.length);let o=s.buffer.write(ve.HeaderMark,0,t).writeElements(s.parser.parseInline(e.text.slice(i+t+1,a),r+t+1),-r);a<e.text.length&&o.write(ve.HeaderMark,a-i,n-i);let l=o.finish(ve.ATXHeading1-1+t,e.text.length-i);return s.nextLine(),s.addNode(l,r),!0},HTMLBlock(s,e){let t=_1(e,s,!1);if(t<0)return!1;let i=s.lineStart+e.pos,r=ff[t][1],n=[],a=r!=uf;for(;!r.test(e.text)&&s.nextLine();){if(e.depth<s.stack.length){a=!1;break}for(let c of e.markers)n.push(c)}a&&s.nextLine();let o=r==y1?ve.CommentBlock:r==S1?ve.ProcessingInstructionBlock:ve.HTMLBlock,l=s.prevLineEnd();return s.addNode(s.buffer.writeElements(n,-i).finish(o,l-i),i),!0},SetextHeading:void 0};class xR{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,i){if(this.stage==-1)return!1;let r=i.content+`
|
|
31
|
-
`+t.scrub(),n=this.advance(r);return n>-1&&n<r.length?this.complete(e,i,n):!1}finish(e,t){return(this.stage==2||this.stage==3)&&fa(t.content,this.pos)==t.content.length?this.complete(e,t,t.content.length):!1}complete(e,t,i){return e.addLeafElement(t,Ot(ve.LinkReference,this.start,this.start+i,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(R1(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(Ot(ve.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(j1(e,fa(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=fa(e,this.pos),i=0;if(t>this.pos){let r=E1(e,t,this.start);if(r){let n=Yd(e,r.to-this.start);n>0&&(this.nextStage(r),i=n)}}return i||(i=Yd(e,this.pos)),i>0&&i<e.length?i:-1}else return Yd(e,this.pos)}}}function Yd(s,e){for(;e<s.length;e++){let t=s.charCodeAt(e);if(t==10)break;if(!Oi(t))return-1}return e}class vR{nextLine(e,t,i){let r=t.depth<e.stack.length?-1:b1(t),n=t.next;if(r<0)return!1;let a=Ot(ve.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(i,Ot(n==61?ve.SetextHeading1:ve.SetextHeading2,i.start,e.prevLineEnd(),[...e.parser.parseInline(i.content,i.start),a])),!0}finish(){return!1}}const w1={LinkReference(s,e){return e.content.charCodeAt(0)==91?new xR(e):null},SetextHeading(){return new vR}},bR=[(s,e)=>v1(e)>=0,(s,e)=>g1(e)>=0,(s,e)=>O1(e)>=0,(s,e)=>Cp(e,s,!0)>=0,(s,e)=>Pp(e,s,!0)>=0,(s,e)=>kp(e,s,!0)>=0,(s,e)=>_1(e,s,!0)>=0],yR={text:"",end:0};class SR{constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.line=new OR,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=Yc.create(ve.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=i.length?new kR(i,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let i=0;;){let r=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;i<e.markers.length&&(!r||e.markers[i].from<r.end);){let n=e.markers[i++];this.addNode(n.type,n.from,n.to)}if(!r)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let i of this.parser.blockParsers)if(i){let r=i(this,e);if(r!=!1){if(r==!0)return null;e.forward();continue e}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let t=new gR(this.lineStart+e.pos,e.text.slice(e.pos));for(let i of this.parser.leafBlockParsers)if(i){let r=i(this,t);r&&t.parsers.push(r)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let i of this.parser.endLeafBlock)if(i(this,e,t))break e}for(let i of t.parsers)if(i.nextLine(this,e,t))return null;t.content+=`
|
|
32
|
-
`+e.scrub();for(let i of e.markers)t.marks.push(i)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=A1(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=yR;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let i=this.absoluteLineStart,r=this.rangeI;for(;this.ranges[r].to<t.end;){r++;let n=this.ranges[r].from,a=this.lineChunkAt(n);t.end=n+a.length,t.text=t.text.slice(0,this.ranges[r-1].to-i)+a,i=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:i}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=i,e.reset(t);e.depth<this.stack.length;e.depth++){let r=this.stack[e.depth],n=this.parser.skipContextMarkup[r.type];if(!n)throw new Error("Unhandled block context "+ve[r.type]);let a=this.line.markers.length;if(!n(r,this,e)){this.line.markers.length>a&&(r.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),i;if(this.input.lineChunks)i=t==`
|
|
33
|
-
`?"":t;else{let r=t.indexOf(`
|
|
34
|
-
`);i=r<0?t:t.slice(0,r)}return e+i.length>this.to?i.slice(0,this.to-e):i}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,i=0){this.block=Yc.create(e,i,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,i=0){this.startContext(this.parser.getNodeType(e),t,i)}addNode(e,t,i){typeof e=="number"&&(e=new wt(this.parser.nodeSet.types[e],yo,yo,(i??this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(mf(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?k1(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let i of e.parsers)if(i.finish(this,e))return;let t=mf(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(ve.Paragraph,e.content.length),e.start)}elt(e,t,i,r){return typeof e=="string"?Ot(this.parser.getNodeType(e),t,i,r):new T1(e,t)}get buffer(){return new P1(this.parser.nodeSet)}}function k1(s,e,t,i,r){let n=s[e].to,a=[],o=[],l=t.from+i;function c(d,u){for(;u?d>=n:d>n;){let f=s[e+1].from-n;i+=f,d+=f,e++,n=s[e].to}}for(let d=t.firstChild;d;d=d.nextSibling){c(d.from+i,!0);let u=d.from+i,f,g=r.get(d.tree);g?f=g:d.to+i>n?(f=k1(s,e,d,i,r),c(d.to+i,!1)):f=d.toTree(),a.push(f),o.push(u-l)}return c(t.to+i,!1),new wt(t.type,a,o,t.to+i-l,t.tree?t.tree.propValues:void 0)}class mh extends Yf{constructor(e,t,i,r,n,a,o,l,c){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=i,this.blockNames=r,this.endLeafBlock=n,this.skipContextMarkup=a,this.inlineParsers=o,this.inlineNames=l,this.wrappers=c,this.nodeTypes=Object.create(null);for(let d of e.types)this.nodeTypes[d.name]=d.id}createParse(e,t,i){let r=new SR(this,e,t,i);for(let n of this.wrappers)r=n(r,e,t,i);return r}configure(e){let t=pf(e);if(!t)return this;let{nodeSet:i,skipContextMarkup:r}=this,n=this.blockParsers.slice(),a=this.leafBlockParsers.slice(),o=this.blockNames.slice(),l=this.inlineParsers.slice(),c=this.inlineNames.slice(),d=this.endLeafBlock.slice(),u=this.wrappers;if(ta(t.defineNodes)){r=Object.assign({},r);let f=i.types.slice(),g;for(let b of t.defineNodes){let{name:v,block:m,composite:O,style:p}=typeof b=="string"?{name:b}:b;if(f.some(_=>_.name==v))continue;O&&(r[f.length]=(_,k,w)=>O(k,w,_.value));let x=f.length,y=O?["Block","BlockContext"]:m?x>=ve.ATXHeading1&&x<=ve.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;f.push(es.define({id:x,name:v,props:y&&[[ot.group,y]]})),p&&(g||(g={}),Array.isArray(p)||p instanceof ei?g[v]=p:Object.assign(g,p))}i=new Za(f),g&&(i=i.extend(Cr(g)))}if(ta(t.props)&&(i=i.extend(...t.props)),ta(t.remove))for(let f of t.remove){let g=this.blockNames.indexOf(f),b=this.inlineNames.indexOf(f);g>-1&&(n[g]=a[g]=void 0),b>-1&&(l[b]=void 0)}if(ta(t.parseBlock))for(let f of t.parseBlock){let g=o.indexOf(f.name);if(g>-1)n[g]=f.parse,a[g]=f.leaf;else{let b=f.before?Ul(o,f.before):f.after?Ul(o,f.after)+1:o.length-1;n.splice(b,0,f.parse),a.splice(b,0,f.leaf),o.splice(b,0,f.name)}f.endLeaf&&d.push(f.endLeaf)}if(ta(t.parseInline))for(let f of t.parseInline){let g=c.indexOf(f.name);if(g>-1)l[g]=f.parse;else{let b=f.before?Ul(c,f.before):f.after?Ul(c,f.after)+1:c.length-1;l.splice(b,0,f.parse),c.splice(b,0,f.name)}}return t.wrap&&(u=u.concat(t.wrap)),new mh(i,n,a,o,d,r,l,c,u)}getNodeType(e){let t=this.nodeTypes[e];if(t==null)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let i=new Tp(this,e,t);e:for(let r=t;r<i.end;){let n=i.char(r);for(let a of this.inlineParsers)if(a){let o=a(i,n,r);if(o>=0){r=o;continue e}}r++}return i.resolveMarkers(0)}}function ta(s){return s!=null&&s.length>0}function pf(s){if(!Array.isArray(s))return s;if(s.length==0)return null;let e=pf(s[0]);if(s.length==1)return e;let t=pf(s.slice(1));if(!t||!e)return e||t;let i=(a,o)=>(a||yo).concat(o||yo),r=e.wrap,n=t.wrap;return{props:i(e.props,t.props),defineNodes:i(e.defineNodes,t.defineNodes),parseBlock:i(e.parseBlock,t.parseBlock),parseInline:i(e.parseInline,t.parseInline),remove:i(e.remove,t.remove),wrap:r?n?(a,o,l,c)=>r(n(a,o,l,c),o,l,c):r:n}}function Ul(s,e){let t=s.indexOf(e);if(t<0)throw new RangeError(`Position specified relative to unknown parser ${e}`);return t}let C1=[es.none];for(let s=1,e;e=ve[s];s++)C1[s]=es.define({id:s,name:e,props:s>=ve.Escape?[]:[[ot.group,s in m1?["Block","BlockContext"]:["Block","LeafBlock"]]],top:e=="Document"});const yo=[];class P1{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,i,r=0){return this.content.push(e,t,i,4+r*4),this}writeElements(e,t=0){for(let i of e)i.writeTo(this,t);return this}finish(e,t){return wt.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}let Da=class{constructor(e,t,i,r=yo){this.type=e,this.from=t,this.to=i,this.children=r}writeTo(e,t){let i=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-i)}toTree(e){return new P1(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}};class T1{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return yo}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}}function Ot(s,e,t,i){return new Da(s,e,t,i)}const Q1={resolve:"Emphasis",mark:"EmphasisMark"},$1={resolve:"Emphasis",mark:"EmphasisMark"},_n={},Uc={};class Js{constructor(e,t,i,r){this.type=e,this.from=t,this.to=i,this.side=r}}const v0="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let Ia=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{Ia=new RegExp("[\\p{S}|\\p{P}]","u")}catch{}const Ud={Escape(s,e,t){if(e!=92||t==s.end-1)return-1;let i=s.char(t+1);for(let r=0;r<v0.length;r++)if(v0.charCodeAt(r)==i)return s.append(Ot(ve.Escape,t,t+2));return-1},Entity(s,e,t){if(e!=38)return-1;let i=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(s.slice(t+1,t+31));return i?s.append(Ot(ve.Entity,t,t+1+i[0].length)):-1},InlineCode(s,e,t){if(e!=96||t&&s.char(t-1)==96)return-1;let i=t+1;for(;i<s.end&&s.char(i)==96;)i++;let r=i-t,n=0;for(;i<s.end;i++)if(s.char(i)==96){if(n++,n==r&&s.char(i+1)!=96)return s.append(Ot(ve.InlineCode,t,i+1,[Ot(ve.CodeMark,t,t+r),Ot(ve.CodeMark,i+1-r,i+1)]))}else n=0;return-1},HTMLTag(s,e,t){if(e!=60||t==s.end-1)return-1;let i=s.slice(t+1,s.end),r=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(i);if(r)return s.append(Ot(ve.Autolink,t,t+1+r[0].length,[Ot(ve.LinkMark,t,t+1),Ot(ve.URL,t+1,t+r[0].length),Ot(ve.LinkMark,t+r[0].length,t+1+r[0].length)]));let n=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(i);if(n)return s.append(Ot(ve.Comment,t,t+1+n[0].length));let a=/^\?[^]*?\?>/.exec(i);if(a)return s.append(Ot(ve.ProcessingInstruction,t,t+1+a[0].length));let o=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return o?s.append(Ot(ve.HTMLTag,t,t+1+o[0].length)):-1},Emphasis(s,e,t){if(e!=95&&e!=42)return-1;let i=t+1;for(;s.char(i)==e;)i++;let r=s.slice(t-1,t),n=s.slice(i,i+1),a=Ia.test(r),o=Ia.test(n),l=/\s|^$/.test(r),c=/\s|^$/.test(n),d=!c&&(!o||l||a),u=!l&&(!a||c||o),f=d&&(e==42||!u||a),g=u&&(e==42||!d||o);return s.append(new Js(e==95?Q1:$1,t,i,(f?1:0)|(g?2:0)))},HardBreak(s,e,t){if(e==92&&s.char(t+1)==10)return s.append(Ot(ve.HardBreak,t,t+2));if(e==32){let i=t+1;for(;s.char(i)==32;)i++;if(s.char(i)==10&&i>=t+2)return s.append(Ot(ve.HardBreak,t,i+1))}return-1},Link(s,e,t){return e==91?s.append(new Js(_n,t,t+1,1)):-1},Image(s,e,t){return e==33&&s.char(t+1)==91?s.append(new Js(Uc,t,t+2,1)):-1},LinkEnd(s,e,t){if(e!=93)return-1;for(let i=s.parts.length-1;i>=0;i--){let r=s.parts[i];if(r instanceof Js&&(r.type==_n||r.type==Uc)){if(!r.side||s.skipSpace(r.to)==t&&!/[(\[]/.test(s.slice(t+1,t+2)))return s.parts[i]=null,-1;let n=s.takeContent(i),a=s.parts[i]=_R(s,n,r.type==_n?ve.Link:ve.Image,r.from,t+1);if(r.type==_n)for(let o=0;o<i;o++){let l=s.parts[o];l instanceof Js&&l.type==_n&&(l.side=0)}return a.to}}return-1}};function _R(s,e,t,i,r){let{text:n}=s,a=s.char(r),o=r;if(e.unshift(Ot(ve.LinkMark,i,i+(t==ve.Image?2:1))),e.push(Ot(ve.LinkMark,r-1,r)),a==40){let l=s.skipSpace(r+1),c=j1(n,l-s.offset,s.offset),d;c&&(l=s.skipSpace(c.to),l!=c.to&&(d=E1(n,l-s.offset,s.offset),d&&(l=s.skipSpace(d.to)))),s.char(l)==41&&(e.push(Ot(ve.LinkMark,r,r+1)),o=l+1,c&&e.push(c),d&&e.push(d),e.push(Ot(ve.LinkMark,l,o)))}else if(a==91){let l=R1(n,r-s.offset,s.offset,!1);l&&(e.push(l),o=l.to)}return Ot(t,i,o,e)}function j1(s,e,t){if(s.charCodeAt(e)==60){for(let r=e+1;r<s.length;r++){let n=s.charCodeAt(r);if(n==62)return Ot(ve.URL,e+t,r+1+t);if(n==60||n==10)return!1}return null}else{let r=0,n=e;for(let a=!1;n<s.length;n++){let o=s.charCodeAt(n);if(Oi(o))break;if(a)a=!1;else if(o==40)r++;else if(o==41){if(!r)break;r--}else o==92&&(a=!0)}return n>e?Ot(ve.URL,e+t,n+t):n==s.length?null:!1}}function E1(s,e,t){let i=s.charCodeAt(e);if(i!=39&&i!=34&&i!=40)return!1;let r=i==40?41:i;for(let n=e+1,a=!1;n<s.length;n++){let o=s.charCodeAt(n);if(a)a=!1;else{if(o==r)return Ot(ve.LinkTitle,e+t,n+1+t);o==92&&(a=!0)}}return null}function R1(s,e,t,i){for(let r=!1,n=e+1,a=Math.min(s.length,n+999);n<a;n++){let o=s.charCodeAt(n);if(r)r=!1;else{if(o==93)return i?!1:Ot(ve.LinkLabel,e+t,n+1+t);if(i&&!Oi(o)&&(i=!1),o==91)return!1;o==92&&(r=!0)}}return null}class Tp{constructor(e,t,i){this.parser=e,this.text=t,this.offset=i,this.parts=[]}char(e){return e>=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,i,r,n){return this.append(new Js(e,t,i,(r?1:0)|(n?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof Js&&(t.type==_n||t.type==Uc))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let i=e;i<this.parts.length;i++){let r=this.parts[i];if(!(r instanceof Js&&r.type.resolve&&r.side&2))continue;let n=r.type==Q1||r.type==$1,a=r.to-r.from,o,l=i-1;for(;l>=e;l--){let v=this.parts[l];if(v instanceof Js&&v.side&1&&v.type==r.type&&!(n&&(r.side&1||v.side&2)&&(v.to-v.from+a)%3==0&&((v.to-v.from)%3||a%3))){o=v;break}}if(!o)continue;let c=r.type.resolve,d=[],u=o.from,f=r.to;if(n){let v=Math.min(2,o.to-o.from,a);u=o.to-v,f=r.from+v,c=v==1?"Emphasis":"StrongEmphasis"}o.type.mark&&d.push(this.elt(o.type.mark,u,o.to));for(let v=l+1;v<i;v++)this.parts[v]instanceof Da&&d.push(this.parts[v]),this.parts[v]=null;r.type.mark&&d.push(this.elt(r.type.mark,r.from,f));let g=this.elt(c,u,f,d);this.parts[l]=n&&o.from!=u?new Js(o.type,o.from,u,o.side):null,(this.parts[i]=n&&r.to!=f?new Js(r.type,f,r.to,r.side):null)?this.parts.splice(i,0,g):this.parts[i]=g}let t=[];for(let i=e;i<this.parts.length;i++){let r=this.parts[i];r instanceof Da&&t.push(r)}return t}findOpeningDelimiter(e){for(let t=this.parts.length-1;t>=0;t--){let i=this.parts[t];if(i instanceof Js&&i.type==e&&i.side&1)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}getDelimiterAt(e){let t=this.parts[e];return t instanceof Js?t:null}skipSpace(e){return fa(this.text,e-this.offset)+this.offset}elt(e,t,i,r){return typeof e=="string"?Ot(this.parser.getNodeType(e),t,i,r):new T1(e,t)}}Tp.linkStart=_n;Tp.imageStart=Uc;function mf(s,e){if(!e.length)return s;if(!s.length)return e;let t=s.slice(),i=0;for(let r of e){for(;i<t.length&&t[i].to<r.to;)i++;if(i<t.length&&t[i].from<r.from){let n=t[i];n instanceof Da&&(t[i]=new Da(n.type,n.from,n.to,mf(n.children,[r])))}else t.splice(i++,0,r)}return t}const wR=[ve.CodeBlock,ve.ListItem,ve.OrderedList,ve.BulletList];class kR{constructor(e,t){this.fragments=e,this.input=t,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(e,t){for(;this.fragment&&this.fragment.to<=e;)this.nextFragment();if(!this.fragment||this.fragment.from>(e?e-1:0))return!1;if(this.fragmentEnd<0){let n=this.fragment.to;for(;n>0&&this.input.read(n-1,n)!=`
|
|
35
|
-
`;)n--;this.fragmentEnd=n?n-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=e+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=t;if(!i.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(ot.contextHash)==e}takeNodes(e){let t=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),n=e.absoluteLineStart,a=n,o=e.block.children.length,l=a,c=o;for(;;){if(t.to-i>r){if(t.type.isAnonymous&&t.firstChild())continue;break}let d=A1(t.from-i,e.ranges);if(t.to-i<=e.ranges[e.rangeI].to)e.addNode(t.tree,d);else{let u=new wt(e.parser.nodeSet.types[ve.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(u,t.tree),e.addNode(u,d)}if(t.type.is("Block")&&(wR.indexOf(t.type.id)<0?(a=t.to-i,o=e.block.children.length):(a=l,o=c),l=t.to-i,c=e.block.children.length),!t.nextSibling())break}for(;e.block.children.length>o;)e.block.children.pop(),e.block.positions.pop();return a-n}}function A1(s,e){let t=s;for(let i=1;i<e.length;i++){let r=e[i-1].to,n=e[i].from;r<s&&(t-=n-r)}return t}const CR=Cr({"Blockquote/...":L.quote,HorizontalRule:L.contentSeparator,"ATXHeading1/... SetextHeading1/...":L.heading1,"ATXHeading2/... SetextHeading2/...":L.heading2,"ATXHeading3/...":L.heading3,"ATXHeading4/...":L.heading4,"ATXHeading5/...":L.heading5,"ATXHeading6/...":L.heading6,"Comment CommentBlock":L.comment,Escape:L.escape,Entity:L.character,"Emphasis/...":L.emphasis,"StrongEmphasis/...":L.strong,"Link/... Image/...":L.link,"OrderedList/... BulletList/...":L.list,"BlockQuote/...":L.quote,"InlineCode CodeText":L.monospace,"URL Autolink":L.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":L.processingInstruction,"CodeInfo LinkLabel":L.labelName,LinkTitle:L.string,Paragraph:L.content}),PR=new mh(new Za(C1).extend(CR),Object.keys(Yl).map(s=>Yl[s]),Object.keys(Yl).map(s=>w1[s]),Object.keys(Yl),bR,m1,Object.keys(Ud).map(s=>Ud[s]),Object.keys(Ud),[]);function TR(s,e,t){let i=[];for(let r=s.firstChild,n=e;;r=r.nextSibling){let a=r?r.from:t;if(a>n&&i.push({from:n,to:a}),!r)break;n=r.to}return i}function QR(s){let{codeParser:e,htmlParser:t}=s;return{wrap:Kv((r,n)=>{let a=r.type.id;if(e&&(a==ve.CodeBlock||a==ve.FencedCode)){let o="";if(a==ve.FencedCode){let c=r.node.getChild(ve.CodeInfo);c&&(o=n.read(c.from,c.to))}let l=e(o);if(l)return{parser:l,overlay:c=>c.type.id==ve.CodeText,bracketed:a==ve.FencedCode}}else if(t&&(a==ve.HTMLBlock||a==ve.HTMLTag||a==ve.CommentBlock))return{parser:t,overlay:TR(r.node,r.from,r.to)};return null})}}const $R={resolve:"Strikethrough",mark:"StrikethroughMark"},jR={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":L.strikethrough}},{name:"StrikethroughMark",style:L.processingInstruction}],parseInline:[{name:"Strikethrough",parse(s,e,t){if(e!=126||s.char(t+1)!=126||s.char(t+2)==126)return-1;let i=s.slice(t-1,t),r=s.slice(t+2,t+3),n=/\s|^$/.test(i),a=/\s|^$/.test(r),o=Ia.test(i),l=Ia.test(r);return s.addDelimiter($R,t,t+2,!a&&(!l||n||o),!n&&(!o||a||l))},after:"Emphasis"}]};function pa(s,e,t=0,i,r=0){let n=0,a=!0,o=-1,l=-1,c=!1,d=()=>{i.push(s.elt("TableCell",r+o,r+l,s.parser.parseInline(e.slice(o,l),r+o)))};for(let u=t;u<e.length;u++){let f=e.charCodeAt(u);f==124&&!c?((!a||o>-1)&&n++,a=!1,i&&(o>-1&&d(),i.push(s.elt("TableDelimiter",u+r,u+r+1))),o=l=-1):(c||f!=32&&f!=9)&&(o<0&&(o=u),l=u+1),c=!c&&f==92}return o>-1&&(n++,i&&d()),n}function b0(s,e){for(let t=e;t<s.length;t++){let i=s.charCodeAt(t);if(i==124)return!0;i==92&&t++}return!1}const M1=/^[>\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class y0{constructor(){this.rows=null}nextLine(e,t,i){if(this.rows==null){this.rows=!1;let r;if((t.next==45||t.next==58||t.next==124)&&M1.test(r=t.text.slice(t.pos))){let n=[];pa(e,i.content,0,n,i.start)==pa(e,r,0)&&(this.rows=[e.elt("TableHeader",i.start,i.start+i.content.length,n),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let r=[];pa(e,t.text,t.pos,r,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+t.pos,e.lineStart+t.text.length,r))}return!1}finish(e,t){return this.rows?(e.addLeafElement(t,e.elt("Table",t.start,t.start+t.content.length,this.rows)),!0):!1}}const ER={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":L.heading}},"TableRow",{name:"TableCell",style:L.content},{name:"TableDelimiter",style:L.processingInstruction}],parseBlock:[{name:"Table",leaf(s,e){return b0(e.content,0)?new y0:null},endLeaf(s,e,t){if(t.parsers.some(r=>r instanceof y0)||!b0(e.text,e.basePos))return!1;let i=s.peekLine();return M1.test(i)&&pa(s,e.text,e.basePos)==pa(s,i,e.basePos)},before:"SetextHeading"}]};class RR{nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt("Task",t.start,t.start+t.content.length,[e.elt("TaskMarker",t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}}const AR={defineNodes:[{name:"Task",block:!0,style:L.list},{name:"TaskMarker",style:L.atom}],parseBlock:[{name:"TaskList",leaf(s,e){return/^\[[ xX]\][ \t]/.test(e.content)&&s.parentType().name=="ListItem"?new RR:null},after:"SetextHeading"}]},S0=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,_0=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,MR=/[\w-]+\.[\w-]+($|[/:])/,w0=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,k0=/\/[a-zA-Z\d@.]+/gy;function C0(s,e,t,i){let r=0;for(let n=e;n<t;n++)s[n]==i&&r++;return r}function LR(s,e){_0.lastIndex=e;let t=_0.exec(s);if(!t||MR.exec(t[0])[0].indexOf("_")>-1)return-1;let i=e+t[0].length;for(;;){let r=s[i-1],n;if(/[?!.,:*_~]/.test(r)||r==")"&&C0(s,e,i,")")>C0(s,e,i,"("))i--;else if(r==";"&&(n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(s.slice(e,i))))i=e+n.index;else break}return i}function P0(s,e){w0.lastIndex=e;let t=w0.exec(s);if(!t)return-1;let i=t[0][t[0].length-1];return i=="_"||i=="-"?-1:e+t[0].length-(i=="."?1:0)}const NR={parseInline:[{name:"Autolink",parse(s,e,t){let i=t-s.offset;if(i&&/\w/.test(s.text[i-1]))return-1;S0.lastIndex=i;let r=S0.exec(s.text),n=-1;if(!r)return-1;if(r[1]||r[2]){if(n=LR(s.text,i+r[0].length),n>-1&&s.hasOpenLink){let a=/([^\[\]]|\[[^\]]*\])*/.exec(s.text.slice(i,n));n=i+a[0].length}}else r[3]?n=P0(s.text,i):(n=P0(s.text,i+r[0].length),n>-1&&r[0]=="xmpp:"&&(k0.lastIndex=n,r=k0.exec(s.text),r&&(n=r.index+r[0].length)));return n<0?-1:(s.addElement(s.elt("URL",t,n+s.offset)),n+s.offset)}}]},DR=[ER,AR,jR,NR];function L1(s,e,t){return(i,r,n)=>{if(r!=s||i.char(n+1)==s)return-1;let a=[i.elt(t,n,n+1)];for(let o=n+1;o<i.end;o++){let l=i.char(o);if(l==s)return i.addElement(i.elt(e,n,o+1,a.concat(i.elt(t,o,o+1))));if(l==92&&a.push(i.elt("Escape",o,o+++2)),Oi(l))break}return-1}}const IR={defineNodes:[{name:"Superscript",style:L.special(L.content)},{name:"SuperscriptMark",style:L.processingInstruction}],parseInline:[{name:"Superscript",parse:L1(94,"Superscript","SuperscriptMark")}]},BR={defineNodes:[{name:"Subscript",style:L.special(L.content)},{name:"SubscriptMark",style:L.processingInstruction}],parseInline:[{name:"Subscript",parse:L1(126,"Subscript","SubscriptMark")}]},WR={defineNodes:[{name:"Emoji",style:L.character}],parseInline:[{name:"Emoji",parse(s,e,t){let i;return e!=58||!(i=/^[a-zA-Z_0-9]+:/.exec(s.slice(t+1,s.end)))?-1:s.addElement(s.elt("Emoji",t,t+1+i[0].length))}}]},N1=Uf({commentTokens:{block:{open:"<!--",close:"-->"}}}),D1=new ot,I1=PR.configure({props:[Pr.add(s=>!s.is("Block")||s.is("Document")||gf(s)!=null||XR(s)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),D1.add(gf),Yr.add({Document:()=>null}),kn.add({Document:N1})]});function gf(s){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(s.name);return e?+e[1]:void 0}function XR(s){return s.name=="OrderedList"||s.name=="BulletList"}function qR(s,e){let t=s;for(;;){let i=t.nextSibling,r;if(!i||(r=gf(i.type))!=null&&r<=e)break;t=i}return t.to}const zR=rb.of((s,e,t)=>{for(let i=kt(s).resolveInner(t,-1);i&&!(i.from<e);i=i.parent){let r=i.type.prop(D1);if(r==null)continue;let n=qR(i,r);if(n>t)return{from:t,to:n}}return null});function Qp(s){return new fi(N1,s,[],"markdown")}const ZR=Qp(I1),VR=I1.configure([DR,BR,IR,WR,{props:[Pr.add({Table:(s,e)=>({from:e.doc.lineAt(s.from).to,to:s.to})})]}]),Hc=Qp(VR);function FR(s,e){return t=>{if(t&&s){let i=null;if(t=/\S*/.exec(t)[0],typeof s=="function"?i=s(t):i=jc.matchLanguageName(s,t,!0),i instanceof jc)return i.support?i.support.language.parser:Pa.getSkippingParser(i.load());if(i)return i.parser}return e?e.parser:null}}class Hd{constructor(e,t,i,r,n,a,o){this.node=e,this.from=t,this.to=i,this.spaceBefore=r,this.spaceAfter=n,this.type=a,this.item=o}blank(e,t=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;i.length<e;)i+=" ";return i}else{for(let r=this.to-this.from-i.length-this.spaceAfter.length;r>0;r--)i+=" ";return i+(t?this.spaceAfter:"")}}marker(e,t){let i=this.node.name=="OrderedList"?String(+W1(this.item,e)[2]+t):"";return this.spaceBefore+i+this.type+this.spaceAfter}}function B1(s,e){let t=[],i=[];for(let r=s;r;r=r.parent){if(r.name=="FencedCode")return i;(r.name=="ListItem"||r.name=="Blockquote")&&t.push(r)}for(let r=t.length-1;r>=0;r--){let n=t[r],a,o=e.lineAt(n.from),l=n.from-o.from;if(n.name=="Blockquote"&&(a=/^ *>( ?)/.exec(o.text.slice(l))))i.push(new Hd(n,l,l+a[0].length,"",a[1],">",null));else if(n.name=="ListItem"&&n.parent.name=="OrderedList"&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(l)))){let c=a[3],d=a[0].length;c.length>=4&&(c=c.slice(0,c.length-4),d-=4),i.push(new Hd(n.parent,l,l+d,a[1],c,a[2],n))}else if(n.name=="ListItem"&&n.parent.name=="BulletList"&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(l)))){let c=a[4],d=a[0].length;c.length>4&&(c=c.slice(0,c.length-4),d-=4);let u=a[2];a[3]&&(u+=a[3].replace(/[xX]/," ")),i.push(new Hd(n.parent,l,l+d,a[1],c,u,n))}}return i}function W1(s,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(s.from,s.from+10))}function Gd(s,e,t,i=0){for(let r=-1,n=s;;){if(n.name=="ListItem"){let o=W1(n,e),l=+o[2];if(r>=0){if(l!=r+1)return;t.push({from:n.from+o[1].length,to:n.from+o[0].length,insert:String(r+2+i)})}r=l}let a=n.nextSibling;if(!a)break;n=a}}function $p(s,e){let t=/^[ \t]*/.exec(s)[0].length;if(!t||e.facet(_o)!=" ")return s;let i=ki(s,4,t),r="";for(let n=i;n>0;)n>=4?(r+=" ",n-=4):(r+=" ",n--);return r+s.slice(t)}const YR=(s={})=>({state:e,dispatch:t})=>{let i=kt(e),{doc:r}=e,n=null,a=e.changeByRange(o=>{if(!o.empty||!Hc.isActiveAt(e,o.from,-1)&&!Hc.isActiveAt(e,o.from,1))return n={range:o};let l=o.from,c=r.lineAt(l),d=B1(i.resolveInner(l,-1),r);for(;d.length&&d[d.length-1].from>l-c.from;)d.pop();if(!d.length)return n={range:o};let u=d[d.length-1];if(u.to-u.spaceAfter.length>l-c.from)return n={range:o};let f=l>=u.to-u.spaceAfter.length&&!/\S/.test(c.text.slice(u.to));if(u.item&&f){let O=u.node.firstChild,p=u.node.getChild("ListItem","ListItem");if(O.to>=l||p&&p.to<l||c.from>0&&!/[^\s>]/.test(r.lineAt(c.from-1).text)||s.nonTightLists===!1){let x=d.length>1?d[d.length-2]:null,y,_="";x&&x.item?(y=c.from+x.from,_=x.marker(r,1)):y=c.from+(x?x.to:0);let k=[{from:y,to:l,insert:_}];return u.node.name=="OrderedList"&&Gd(u.item,r,k,-2),x&&x.node.name=="OrderedList"&&Gd(x.item,r,k),{range:re.cursor(y+_.length),changes:k}}else{let x=Q0(d,e,c);return{range:re.cursor(l+x.length+1),changes:{from:c.from,insert:x+e.lineBreak}}}}if(u.node.name=="Blockquote"&&f&&c.from){let O=r.lineAt(c.from-1),p=/>\s*$/.exec(O.text);if(p&&p.index==u.from){let x=e.changes([{from:O.from+p.index,to:O.to},{from:c.from+u.from,to:c.to}]);return{range:o.map(x),changes:x}}}let g=[];u.node.name=="OrderedList"&&Gd(u.item,r,g);let b=u.item&&u.item.from<c.from,v="";if(!b||/^[\s\d.)\-+*>]*/.exec(c.text)[0].length>=u.to)for(let O=0,p=d.length-1;O<=p;O++)v+=O==p&&!b?d[O].marker(r,1):d[O].blank(O<p?ki(c.text,4,d[O+1].from)-v.length:null);let m=l;for(;m>c.from&&/\s/.test(c.text.charAt(m-c.from-1));)m--;return v=$p(v,e),HR(u.node,e.doc)&&(v=Q0(d,e,c)+e.lineBreak+v),g.push({from:m,to:l,insert:e.lineBreak+v}),{range:re.cursor(m+v.length+1),changes:g}});return n?!1:(t(e.update(a,{scrollIntoView:!0,userEvent:"input"})),!0)},UR=YR();function T0(s){return s.name=="QuoteMark"||s.name=="ListMark"}function HR(s,e){if(s.name!="OrderedList"&&s.name!="BulletList")return!1;let t=s.firstChild,i=s.getChild("ListItem","ListItem");if(!i)return!1;let r=e.lineAt(t.to),n=e.lineAt(i.from),a=/^[\s>]*$/.test(r.text);return r.number+(a?0:1)<n.number}function Q0(s,e,t){let i="";for(let r=0,n=s.length-2;r<=n;r++)i+=s[r].blank(r<n?ki(t.text,4,s[r+1].from)-i.length:null,r<n);return $p(i,e)}function GR(s,e){let t=s.resolveInner(e,-1),i=e;T0(t)&&(i=t.from,t=t.parent);for(let r;r=t.childBefore(i);)if(T0(r))i=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")t=r.lastChild,i=t.to;else break;return t}const KR=({state:s,dispatch:e})=>{let t=kt(s),i=null,r=s.changeByRange(n=>{let a=n.from,{doc:o}=s;if(n.empty&&Hc.isActiveAt(s,n.from)){let l=o.lineAt(a),c=B1(GR(t,a),o);if(c.length){let d=c[c.length-1],u=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(a-l.from>u&&!/\S/.test(l.text.slice(u,a-l.from)))return{range:re.cursor(l.from+u),changes:{from:l.from+u,to:a}};if(a-l.from==u&&(d.item&&l.from<=d.item.from||/^[\s>]*$/.test(l.text.slice(0,d.to)))){let f=l.from+d.from;if(d.item&&d.node.from<d.item.from&&/\S/.test(l.text.slice(d.from,d.to))){let g=d.blank(ki(l.text,4,d.to)-ki(l.text,4,d.from));return f==l.from&&(g=$p(g,s)),{range:re.cursor(f+g.length),changes:{from:f,to:l.from+d.to,insert:g}}}if(f<a)return{range:re.cursor(f),changes:{from:f,to:a}}}}}return i={range:n}});return i?!1:(e(s.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},JR=[{key:"Enter",run:UR},{key:"Backspace",run:KR}],X1=p1({matchClosingTags:!1});function eA(s={}){let{codeLanguages:e,defaultCodeLanguage:t,addKeymap:i=!0,base:{parser:r}=ZR,completeHTMLTags:n=!0,pasteURLAsLink:a=!0,htmlTagLanguage:o=X1}=s;if(!(r instanceof mh))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let l=s.extensions?[s.extensions]:[],c=[o.support,zR],d;a&&c.push(rA),t instanceof Vr?(c.push(t.support),d=t.language):t&&(d=t);let u=e||d?FR(e,d):void 0;l.push(QR({codeParser:u,htmlParser:o.language.parser})),i&&c.push(kr.high(So.of(JR)));let f=Qp(r.configure(l));return n&&c.push(f.data.of({autocomplete:tA})),new Vr(f,c)}function tA(s){let{state:e,pos:t}=s,i=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t-25,t));if(!i)return null;let r=kt(e).resolveInner(t,-1);for(;r&&!r.type.isTop;){if(r.name=="CodeBlock"||r.name=="FencedCode"||r.name=="ProcessingInstructionBlock"||r.name=="CommentBlock"||r.name=="Link"||r.name=="Image")return null;r=r.parent}return{from:t-i[0].length,to:t,options:sA(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let Kd=null;function sA(){if(Kd)return Kd;let s=uR(new ap(pt.create({extensions:X1}),0,!0));return Kd=s?s.options:[]}const iA=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,rA=_e.domEventHandlers({paste:(s,e)=>{var t;let{main:i}=e.state.selection;if(i.empty)return!1;let r=(t=s.clipboardData)===null||t===void 0?void 0:t.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!Hc.isActiveAt(e.state,i.from,1)))return!1;let n=kt(e.state),a=!1;return n.iterate({from:i.from,to:i.to,enter:o=>{(o.from>i.from||iA.test(o.name))&&(a=!0)},leave:o=>{o.to<i.to&&(a=!0)}}),a?!1:(e.dispatch({changes:[{from:i.from,insert:"["},{from:i.to,insert:`](${r})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}}),Of=1,nA=2,oA=3,aA=4,lA=5,cA=36,hA=37,dA=38,uA=11,fA=13;function pA(s){return s==45||s==46||s==58||s>=65&&s<=90||s==95||s>=97&&s<=122||s>=161}function mA(s){return s==9||s==10||s==13||s==32}let $0=null,j0=null,E0=0;function xf(s,e){let t=s.pos+e;if(j0==s&&E0==t)return $0;for(;mA(s.peek(e));)e++;let i="";for(;;){let r=s.peek(e);if(!pA(r))break;i+=String.fromCharCode(r),e++}return j0=s,E0=t,$0=i||null}function R0(s,e){this.name=s,this.parent=e}const gA=new fh({start:null,shift(s,e,t,i){return e==Of?new R0(xf(i,1)||"",s):s},reduce(s,e){return e==uA&&s?s.parent:s},reuse(s,e,t,i){let r=e.type.id;return r==Of||r==fA?new R0(xf(i,1)||"",s):s},strict:!1}),OA=new ts((s,e)=>{if(s.next==60){if(s.advance(),s.next==47){s.advance();let t=xf(s,0);if(!t)return s.acceptToken(lA);if(e.context&&t==e.context.name)return s.acceptToken(nA);for(let i=e.context;i;i=i.parent)if(i.name==t)return s.acceptToken(oA,-2);s.acceptToken(aA)}else if(s.next!=33&&s.next!=63)return s.acceptToken(Of)}},{contextual:!0});function jp(s,e){return new ts(t=>{let i=0,r=e.charCodeAt(0);e:for(;!(t.next<0);t.advance(),i++)if(t.next==r){for(let n=1;n<e.length;n++)if(t.peek(n)!=e.charCodeAt(n))continue e;break}i&&t.acceptToken(s)})}const xA=jp(cA,"-->"),vA=jp(hA,"?>"),bA=jp(dA,"]]>"),yA=Cr({Text:L.content,"StartTag StartCloseTag EndTag SelfCloseEndTag":L.angleBracket,TagName:L.tagName,"MismatchedCloseTag/TagName":[L.tagName,L.invalid],AttributeName:L.attributeName,AttributeValue:L.attributeValue,Is:L.definitionOperator,"EntityReference CharacterReference":L.character,Comment:L.blockComment,ProcessingInst:L.processingInstruction,DoctypeDecl:L.documentMeta,Cdata:L.special(L.string)}),SA=wr.deserialize({version:14,states:",lOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DT'#DTOOOP'#Cv'#CvQQOaOOOOOW'#Cw'#CwO#eOxO,59QOOOP,59Q,59QOOOO'#Cx'#CxO#mOpO,59TO#uO!bO,59TOOOP'#C|'#C|O$TOaO,59RO$[OpO'#CoOOOP,59R,59ROOOQ'#C}'#C}O$dOrO,59^OOOP,59^,59^OOOS'#DO'#DOO$lOtO,59_OOOP,59_,59_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a!eOz^O~Oz^O{!gO}!hO~Oz^O[ma`madma~O[!kOz^O~O[!lOz^O~O[!mO`sOd!nO~OW!qOX!qO{!sO|!qO~OW!tOX!tO}!sO!O!tO~O[!vOz^O~OW!qOX!qO{!yO|!qO~OW!tOX!tO}!yO!O!tO~O",goto:"%cxPPPPPPPPPPyyP!PP!VPP!`!jP!pyyyP!v!|#S$[$k$q$w$}%TPPPP%ZXWORYbXRORYb_t`qru!T!U!bQ!i!YS!p!e!fR!w!oQdRRybXSORYbQYORmYQ[PRn[Q_QQkVjp_krz!R!T!X!Z!^!`!f!j!oQr`QzcQ!RlQ!TqQ!XsQ!ZtQ!^{Q!`!QQ!f!YQ!j!]R!o!eQu`S!UqrU![u!U!bR!b!TQ!r!gR!x!rQ!u!hR!z!uQbRRxbQfTR|fQiUR!OiSXOYTaRb",nodeNames:"⚠ StartTag StartCloseTag MissingCloseTag StartCloseTag StartCloseTag Document Text EntityReference CharacterReference Cdata Element EndTag OpenTag TagName Attribute AttributeName Is AttributeValue CloseTag SelfCloseEndTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag DoctypeDecl",maxTerm:50,context:gA,nodeProps:[["closedBy",1,"SelfCloseEndTag EndTag",13,"CloseTag MissingCloseTag"],["openedBy",12,"StartTag StartCloseTag",19,"OpenTag",20,"StartTag"],["isolate",-6,13,18,19,21,22,24,""]],propSources:[yA],skippedNodes:[0],repeatNodeCount:9,tokenData:"!)v~R!YOX$qXY)iYZ)iZ]$q]^)i^p$qpq)iqr$qrs*vsv$qvw+fwx/ix}$q}!O0[!O!P$q!P!Q2z!Q![$q![!]4n!]!^$q!^!_8U!_!`!#t!`!a!$l!a!b!%d!b!c$q!c!}4n!}#P$q#P#Q!'W#Q#R$q#R#S4n#S#T$q#T#o4n#o%W$q%W%o4n%o%p$q%p&a4n&a&b$q&b1p4n1p4U$q4U4d4n4d4e$q4e$IS4n$IS$I`$q$I`$Ib4n$Ib$Kh$q$Kh%#t4n%#t&/x$q&/x&Et4n&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$q;'S;=`)c<%lO$q",tokenizers:[OA,xA,vA,bA,0,1,2,3,4],topRules:{Document:[0,6]},tokenPrec:0});function gc(s,e){let t=e&&e.getChild("TagName");return t?s.sliceString(t.from,t.to):""}function Jd(s,e){let t=e&&e.firstChild;return!t||t.name!="OpenTag"?"":gc(s,t)}function _A(s,e,t){let i=e&&e.getChildren("Attribute").find(n=>n.from<=t&&n.to>=t),r=i&&i.getChild("AttributeName");return r?s.sliceString(r.from,r.to):""}function eu(s){for(let e=s&&s.parent;e;e=e.parent)if(e.name=="Element")return e;return null}function wA(s,e){var t;let i=kt(s).resolveInner(e,-1),r=null;for(let n=i;!r&&n.parent;n=n.parent)(n.name=="OpenTag"||n.name=="CloseTag"||n.name=="SelfClosingTag"||n.name=="MismatchedCloseTag")&&(r=n);if(r&&(r.to>e||r.lastChild.type.isError)){let n=r.parent;if(i.name=="TagName")return r.name=="CloseTag"||r.name=="MismatchedCloseTag"?{type:"closeTag",from:i.from,context:n}:{type:"openTag",from:i.from,context:eu(n)};if(i.name=="AttributeName")return{type:"attrName",from:i.from,context:r};if(i.name=="AttributeValue")return{type:"attrValue",from:i.from,context:r};let a=i==r||i.name=="Attribute"?i.childBefore(e):i;return a?.name=="StartTag"?{type:"openTag",from:e,context:eu(n)}:a?.name=="StartCloseTag"&&a.to<=e?{type:"closeTag",from:e,context:n}:a?.name=="Is"?{type:"attrValue",from:e,context:r}:a?{type:"attrName",from:e,context:r}:null}else if(i.name=="StartCloseTag")return{type:"closeTag",from:e,context:i.parent};for(;i.parent&&i.to==e&&!(!((t=i.lastChild)===null||t===void 0)&&t.type.isError);)i=i.parent;return i.name=="Element"||i.name=="Text"||i.name=="Document"?{type:"tag",from:e,context:i.name=="Element"?i:eu(i)}:null}class kA{constructor(e,t,i){this.attrs=t,this.attrValues=i,this.children=[],this.name=e.name,this.completion=Object.assign(Object.assign({type:"type"},e.completion||{}),{label:this.name}),this.openCompletion=Object.assign(Object.assign({},this.completion),{label:"<"+this.name}),this.closeCompletion=Object.assign(Object.assign({},this.completion),{label:"</"+this.name+">",boost:2}),this.closeNameCompletion=Object.assign(Object.assign({},this.completion),{label:this.name+">"}),this.text=e.textContent?e.textContent.map(r=>({label:r,type:"text"})):[]}}const tu=/^[:\-\.\w\u00b7-\uffff]*$/;function A0(s){return Object.assign(Object.assign({type:"property"},s.completion||{}),{label:s.name})}function M0(s){return typeof s=="string"?{label:`"${s}"`,type:"constant"}:/^"/.test(s.label)?s:Object.assign(Object.assign({},s),{label:`"${s.label}"`})}function CA(s,e){let t=[],i=[],r=Object.create(null);for(let l of e){let c=A0(l);t.push(c),l.global&&i.push(c),l.values&&(r[l.name]=l.values.map(M0))}let n=[],a=[],o=Object.create(null);for(let l of s){let c=i,d=r;l.attributes&&(c=c.concat(l.attributes.map(f=>typeof f=="string"?t.find(g=>g.label==f)||{label:f,type:"property"}:(f.values&&(d==r&&(d=Object.create(d)),d[f.name]=f.values.map(M0)),A0(f)))));let u=new kA(l,c,d);o[u.name]=u,n.push(u),l.top&&a.push(u)}a.length||(a=n);for(let l=0;l<n.length;l++){let c=s[l],d=n[l];if(c.children)for(let u of c.children)o[u]&&d.children.push(o[u]);else d.children=n}return l=>{var c;let{doc:d}=l.state,u=wA(l.state,l.pos);if(!u||u.type=="tag"&&!l.explicit)return null;let{type:f,from:g,context:b}=u;if(f=="openTag"){let v=a,m=Jd(d,b);if(m){let O=o[m];v=O?.children||n}return{from:g,options:v.map(O=>O.completion),validFor:tu}}else if(f=="closeTag"){let v=Jd(d,b);return v?{from:g,to:l.pos+(d.sliceString(l.pos,l.pos+1)==">"?1:0),options:[((c=o[v])===null||c===void 0?void 0:c.closeNameCompletion)||{label:v+">",type:"type"}],validFor:tu}:null}else if(f=="attrName"){let v=o[gc(d,b)];return{from:g,options:v?.attrs||i,validFor:tu}}else if(f=="attrValue"){let v=_A(d,b,g);if(!v)return null;let m=o[gc(d,b)],O=(m?.attrValues||r)[v];return!O||!O.length?null:{from:g,to:l.pos+(d.sliceString(l.pos,l.pos+1)=='"'?1:0),options:O,validFor:/^"[^"]*"?$/}}else if(f=="tag"){let v=Jd(d,b),m=o[v],O=[],p=b&&b.lastChild;v&&(!p||p.name!="CloseTag"||gc(d,p)!=v)&&O.push(m?m.closeCompletion:{label:"</"+v+">",type:"type",boost:2});let x=O.concat((m?.children||(b?n:a)).map(y=>y.openCompletion));if(b&&m?.text.length){let y=b.firstChild;y.to>l.pos-20&&!/\S/.test(l.state.sliceDoc(y.to,l.pos))&&(x=x.concat(m.text))}return{from:g,options:x,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}else return null}}const vf=_r.define({name:"xml",parser:SA.configure({props:[Yr.add({Element(s){let e=/^\s*<\//.test(s.textAfter);return s.lineIndent(s.node.from)+(e?0:s.unit)},"OpenTag CloseTag SelfClosingTag"(s){return s.column(s.node.from)+s.unit}}),Pr.add({Element(s){let e=s.firstChild,t=s.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:s.to}}}),Jf.add({"OpenTag CloseTag":s=>s.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/$/}});function PA(s={}){let e=[vf.data.of({autocomplete:CA(s.elements||[],s.attributes||[])})];return s.autoCloseTags!==!1&&e.push(TA),new Vr(vf,e)}function L0(s,e,t=s.length){if(!e)return"";let i=e.firstChild,r=i&&i.getChild("TagName");return r?s.sliceString(r.from,Math.min(r.to,t)):""}const TA=_e.inputHandler.of((s,e,t,i,r)=>{if(s.composing||s.state.readOnly||e!=t||i!=">"&&i!="/"||!vf.isActiveAt(s.state,e,-1))return!1;let n=r(),{state:a}=n,o=a.changeByRange(l=>{var c,d,u;let{head:f}=l,g=a.doc.sliceString(f-1,f)==i,b=kt(a).resolveInner(f,-1),v;if(g&&i==">"&&b.name=="EndTag"){let m=b.parent;if(((d=(c=m.parent)===null||c===void 0?void 0:c.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(v=L0(a.doc,m.parent,f))){let O=f+(a.doc.sliceString(f,f+1)===">"?1:0),p=`</${v}>`;return{range:l,changes:{from:f,to:O,insert:p}}}}else if(g&&i=="/"&&b.name=="StartCloseTag"){let m=b.parent;if(b.from==f-2&&((u=m.lastChild)===null||u===void 0?void 0:u.name)!="CloseTag"&&(v=L0(a.doc,m,f))){let O=f+(a.doc.sliceString(f,f+1)===">"?1:0),p=`${v}>`;return{range:re.cursor(f+p.length,-1),changes:{from:f,to:O,insert:p}}}}return{range:l}});return o.changes.empty?!1:(s.dispatch([n,a.update(o,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function QA(){const s=()=>{const i=document.documentElement;return i.classList.contains("light")?!1:i.classList.contains("dark")||i.classList.contains("cyberpunk")||i.classList.contains("mono")?!0:window.matchMedia("(prefers-color-scheme: dark)").matches},[e,t]=C.useState(s);return C.useEffect(()=>{const i=new MutationObserver(()=>t(s()));i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});const r=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>t(s());return r.addEventListener("change",n),()=>{i.disconnect(),r.removeEventListener("change",n)}},[]),e}function Ep(s,e){if(e==="markdown")return"markdown";if(e==="html")return"html";if(e==="json")return"json";const t=s.split(/[/\\]/).pop()?.toLowerCase()||"";switch(t.includes(".")?t.split(".").pop():t){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"json":case"jsonc":return"json";case"py":return"python";case"css":case"scss":case"less":return"css";case"html":case"htm":return"html";case"md":case"markdown":return"markdown";case"xml":case"svg":return"xml";default:return"text"}}function $A(s){switch(s){case"typescript":return[dc({typescript:!0})];case"tsx":return[dc({typescript:!0,jsx:!0})];case"javascript":return[dc({jsx:!0})];case"json":return[C5()];case"python":return[Xj()];case"css":return[Uy()];case"html":return[p1()];case"markdown":return[eA()];case"xml":return[PA()];default:return[]}}function q1({path:s,initialContent:e,language:t,hideToolbar:i=!1,onSaved:r,onDirtyChange:n,className:a=""}){const{t:o}=Pt("common"),l=QA(),c=t??Ep(s),[d,u]=C.useState(e),[f,g]=C.useState(e),[b,v]=C.useState(!1),[m,O]=C.useState("idle"),[p,x]=C.useState(null),y=C.useRef(null),_=C.useRef(d),k=C.useRef(f);_.current=d,k.current=f;const w=d!==f;C.useEffect(()=>{u(e),g(e),O("idle"),x(null)},[s,e]),C.useEffect(()=>{n?.(w)},[w,n]);const S=C.useMemo(()=>{const $=[...$A(c),_e.theme({"&":{height:"100%",fontSize:"13px"},".cm-scroller":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",lineHeight:"1.5"},".cm-content":{paddingBottom:"2rem"}})];return(c==="markdown"||c==="html")&&$.push(_e.lineWrapping),$},[c]),Q=C.useCallback(async()=>{if(b)return;const $=_.current;if($!==k.current){v(!0),x(null),O("idle");try{await J.files.write(s,$),g($),k.current=$,O("saved"),r?.($),window.setTimeout(()=>O(j=>j==="saved"?"idle":j),1600)}catch(j){O("error"),x(j instanceof Error?j.message:String(j))}finally{v(!1)}}},[s,b,r]),I=C.useCallback(()=>{u(k.current),O("idle"),x(null)},[]);C.useEffect(()=>{const $=j=>{if(!(navigator.platform.toUpperCase().includes("MAC")?j.metaKey:j.ctrlKey)||j.altKey||j.shiftKey||j.key.toLowerCase()!=="s")return;const V=y.current,Z=document.activeElement;!V||!(Z instanceof Node)||!V.contains(Z)||(j.preventDefault(),Q())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[Q]);const D=s.split(/[/\\]/).pop()||s;return h.jsxs("div",{ref:y,className:`flex flex-col min-h-0 flex-1 ${a}`,children:[!i&&h.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-2 py-1.5 border-b border-border-default bg-surface-elevated/60",children:[h.jsxs("span",{className:"text-xs text-fg-secondary truncate min-w-0 flex items-center gap-1.5",children:[w&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 shrink-0",title:o("fileEditor.unsaved")}),h.jsx("span",{className:"truncate font-mono",children:D})]}),h.jsx("div",{className:"flex-1"}),m==="saved"&&h.jsx("span",{className:"text-[11px] text-green-600",children:o("fileEditor.saved")}),m==="error"&&h.jsx("span",{className:"text-[11px] text-red-500 truncate max-w-[40%]",title:p||void 0,children:o("fileEditor.saveFailed")}),w&&h.jsx("button",{type:"button",onClick:I,className:"px-2 py-1 text-[11px] rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:o("fileEditor.revert")}),h.jsx("button",{type:"button",onClick:()=>{Q()},disabled:!w||b,className:"px-2.5 py-1 text-[11px] font-medium rounded-md bg-brand-600 text-white hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:o(b?"saving":"save")})]}),i&&h.jsxs("div",{className:"shrink-0 flex items-center justify-end gap-2 px-2 py-1 border-b border-border-default",children:[m==="saved"&&h.jsx("span",{className:"text-[11px] text-green-600",children:o("fileEditor.saved")}),m==="error"&&h.jsx("span",{className:"text-[11px] text-red-500",children:o("fileEditor.saveFailed")}),w&&h.jsx("button",{type:"button",onClick:I,className:"px-2 py-1 text-[11px] rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:o("fileEditor.revert")}),h.jsx("button",{type:"button",onClick:()=>{Q()},disabled:!w||b,className:"px-2.5 py-1 text-[11px] font-medium rounded-md bg-brand-600 text-white hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:o(b?"saving":"save")})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(yy,{value:d,height:"100%",theme:l?by:"light",extensions:S,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!1},onChange:$=>{u($),(m==="saved"||m==="error")&&O("idle")},className:"h-full [&_.cm-editor]:h-full [&_.cm-editor]:outline-none"})})]})}function z1(s,e){return s?window.confirm(e):!0}function jA({path:s,content:e,format:t,basePath:i,onHtmlSelection:r,onDirtyChange:n,className:a=""}){const{t:o}=Pt("common"),[l,c]=C.useState("preview"),[d,u]=C.useState(e),[f,g]=C.useState(e),[b,v]=C.useState(!1);C.useEffect(()=>{u(e),g(e),c("preview"),v(!1)},[s,e]),C.useEffect(()=>{n?.(b)},[b,n]);const m=C.useCallback(p=>{if(p!==l){if(l==="edit"&&p==="preview"){if(!z1(b,o("fileEditor.discardConfirm")))return;b&&(u(f),v(!1))}c(p)}},[l,b,o,f]),O=Ep(s,t);return h.jsxs("div",{className:`flex flex-col min-h-0 flex-1 ${a}`,children:[h.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-2 py-1.5 border-b border-border-default bg-surface-elevated/60",children:[h.jsxs("div",{className:"inline-flex rounded-md border border-border-default overflow-hidden text-[11px]",children:[h.jsx("button",{type:"button",onClick:()=>m("preview"),className:`px-2.5 py-1 transition-colors ${l==="preview"?"bg-brand-600/20 text-brand-500 font-medium":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,children:o("fileEditor.preview")}),h.jsx("button",{type:"button",onClick:()=>m("edit"),className:`px-2.5 py-1 border-l border-border-default transition-colors ${l==="edit"?"bg-brand-600/20 text-brand-500 font-medium":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,children:o("edit")})]}),b&&l==="edit"&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500",title:o("fileEditor.unsaved")}),h.jsx("div",{className:"flex-1"})]}),l==="preview"?h.jsx("div",{className:"flex-1 min-h-0 overflow-auto px-1 py-2",children:h.jsx(du,{content:d,format:t,className:"text-fg-secondary text-sm",onHtmlSelection:r,basePath:i})}):h.jsx(q1,{path:s,initialContent:d,language:O,hideToolbar:!0,onDirtyChange:v,onSaved:p=>{u(p),g(p),v(!1)}})]})}function EA(s){const e=s.trim();return!e||e==="about:blank"?e:/^[a-z][a-z0-9+.-]*:/i.test(e)?/^file:/i.test(e)?AA(e):e:RA(e)?Z1(e):`https://${e}`}function RA(s){return!!(s.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(s)||s.startsWith("\\\\"))}function Z1(s){const e=s.replace(/\\/g,"/");return e.startsWith("//")?`file:${su(e)}`:/^[a-zA-Z]:\//.test(e)?`file:///${su(e)}`:`file://${su(e)}`}function AA(s){try{return new URL(s).href}catch{let e=s.replace(/^file:/i,"").replace(/\\/g,"/");return e.startsWith("//")&&(e=e.replace(/^\/\/(localhost)?/i,""),!e.startsWith("/")&&!/^[a-zA-Z]:\//.test(e)&&(e=`/${e}`)),/^\/[a-zA-Z]:\//.test(e)&&(e=e.slice(1)),!e.startsWith("/")&&!/^[a-zA-Z]:\//.test(e)&&(e=`/${e}`),Z1(e)}}function su(s){return encodeURI(s).replace(/#/g,"%23")}function MA({url:s,browserId:e,className:t,onMeta:i}){const{t:r}=Pt("common"),n=C.useId().replace(/:/g,""),a=e||`eb_${n}`,o=!e,l=C.useRef(null),c=C.useRef(null),d=C.useRef(null),[u,f]=C.useState(s==="about:blank"?"":s),[g,b]=C.useState(!1),[v,m]=C.useState(!1),[O,p]=C.useState(!1),[x,y]=C.useState(null),[_,k]=C.useState(null),[w,S]=C.useState(!1),Q=typeof window<"u"?window.markusDesktop?.browser:void 0,I=typeof window<"u"?window.markusDesktop?.platform:void 0;d.current=_;const D=r(I==="darwin"?"browserFolderAppFinder":I==="win32"?"browserFolderAppExplorer":"browserFolderAppGeneric");return C.useEffect(()=>{if(!Q)return;let $=!1;return(async()=>{const j=await Q.getState(a);if($)return;if(j.ok)s&&j.url!==s&&!j.directoryPath?(p(!0),await Q.navigate(a,s)):s&&j.directoryPath&&j.url!==s&&await Q.navigate(a,s);else{p(!0);const F=await Q.create(a,s);if($||!F.ok){$&&o&&Q.destroy(a);return}}if($)return;const B=await Q.getState(a);$||!B.ok||(document.activeElement!==c.current&&f(B.url&&B.url!=="about:blank"?B.url:s==="about:blank"?"":s),p(!!B.isLoading),y(B.loadError??null),k(B.directoryPath??null),(B.pageId!=null||B.url||B.title)&&i?.({pageId:B.pageId,url:B.url&&B.url!=="about:blank"?B.url:void 0,title:B.title||void 0}),s==="about:blank"&&requestAnimationFrame(()=>{$||(c.current?.focus({preventScroll:!0}),c.current?.select())}))})(),()=>{$=!0,o&&Q.destroy(a)}},[Q,a,s,o]),C.useEffect(()=>{if(s!=="about:blank")return;let $=!1;const j=()=>{if($)return;const V=c.current;V&&(V.focus({preventScroll:!0}),V.select())};j();const B=[0,50,150,300].map(V=>window.setTimeout(j,V)),F=requestAnimationFrame(j);return()=>{$=!0,cancelAnimationFrame(F);for(const V of B)clearTimeout(V)}},[s,a]),C.useEffect(()=>{if(Q?.onPageEvent)return Q.onPageEvent($=>{if($.browserId===a){if($.type==="directory"){k($.directoryPath||null),p(!1),y(null),$.url&&document.activeElement!==c.current&&f($.url);return}if($.type==="loading"){p(!0),y(null),k(null);return}if($.type==="loaded"){if(p(!1),d.current)return;$.url&&document.activeElement!==c.current&&f($.url==="about:blank"?"":$.url),window.dispatchEvent(new Event("markus:embedded-browser-resync"));return}if($.type==="load-failed"){if(p(!1),d.current)return;y($.error||"Load failed"),$.url&&document.activeElement!==c.current&&f($.url==="about:blank"?"":$.url);return}$.type==="navigated"&&$.url&&document.activeElement!==c.current&&(d.current||f($.url==="about:blank"?"":$.url))}})},[Q,a]),C.useEffect(()=>{if(!Q||!l.current)return;const $=l.current;let j=!0;const B=()=>{let T=$;for(;T;){const A=getComputedStyle(T);if(A.visibility==="hidden"||A.display==="none")return!1;T=T.parentElement}return!0},F=()=>{if(!j)return;if(!KS()||!B()||GS()||d.current||s==="about:blank"){Q.setBounds(a,{x:0,y:0,width:0,height:0},!1);return}const T=$.getBoundingClientRect();Q.setBounds(a,{x:Math.round(T.left),y:Math.round(T.top),width:Math.round(T.width),height:Math.round(T.height)},T.width>2&&T.height>2)};F();const V=new ResizeObserver(F);V.observe($),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),window.addEventListener("markus:embedded-browser-resync",F),window.addEventListener("markus:native-browser-overlay",F),window.addEventListener("markus:native-browser-page",F);const Z=setInterval(()=>{j&&Q.getState(a).then(T=>{if(!j||!T.ok)return;const A=T.directoryPath??null;k(A),T.url&&document.activeElement!==c.current&&(A||T.url!=="about:blank")&&f(T.url==="about:blank"?"":T.url),b(!!T.canGoBack),m(!!T.canGoForward),p(!!T.isLoading),T.loadError!==void 0&&y(A?null:T.loadError??null)})},800),se=()=>{Q.setBounds(a,{x:0,y:0,width:0,height:0},!1)};return window.addEventListener("pagehide",se),()=>{j=!1,V.disconnect(),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0),window.removeEventListener("markus:embedded-browser-resync",F),window.removeEventListener("markus:native-browser-overlay",F),window.removeEventListener("markus:native-browser-page",F),window.removeEventListener("pagehide",se),clearInterval(Z),Q.setBounds(a,{x:0,y:0,width:0,height:0},!1)}},[Q,a,s]),C.useEffect(()=>{window.dispatchEvent(new Event("markus:embedded-browser-resync"))},[_,s]),Q?h.jsxs("div",{className:`flex flex-col h-full min-h-0 min-w-0 w-full ${t??""}`,children:[h.jsxs("div",{className:"shrink-0 relative mb-2",children:[h.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border border-border-default rounded-lg bg-surface-elevated",children:[h.jsx("button",{disabled:!g,onClick:()=>{Q.action(a,"back")},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay disabled:opacity-30",title:"Back",children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("polyline",{points:"15 18 9 12 15 6"})})}),h.jsx("button",{disabled:!v,onClick:()=>{Q.action(a,"forward")},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay disabled:opacity-30",title:"Forward",children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("polyline",{points:"9 18 15 12 9 6"})})}),h.jsx("button",{onClick:()=>{O?Q.action(a,"stop"):Q.action(a,"reload")},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay",title:O?"Stop":"Reload",children:O?h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"animate-spin",children:h.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",strokeLinecap:"round"})}):h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("polyline",{points:"23 4 23 10 17 10"}),h.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),h.jsx("form",{className:"flex-1 min-w-0",onSubmit:$=>{$.preventDefault();let j=u.trim();j&&(j=EA(j),p(!0),y(null),k(null),Q.navigate(a,j),f(j))},children:h.jsx("input",{ref:c,value:u,onChange:$=>f($.target.value),placeholder:r("browserUrlPlaceholder"),spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoFocus:s==="about:blank",className:"w-full px-2 py-1 text-xs bg-surface-primary border border-border-default rounded-md text-fg-primary outline-none focus:border-brand-500"})}),O&&h.jsx("span",{className:"shrink-0 text-[10px] text-fg-tertiary px-1 select-none",children:r("browserLoading")}),Q.openDevTools&&h.jsx("button",{type:"button",onClick:()=>{Q.openDevTools?.(a)},className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:bg-surface-overlay shrink-0",title:r("browserGuestDevTools"),children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M12 20h9"}),h.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]})})]}),h.jsx("div",{className:`absolute left-2 right-2 bottom-0 h-0.5 overflow-hidden rounded-full transition-opacity ${O?"opacity-100":"opacity-0"}`,"aria-hidden":!O,children:h.jsx("div",{className:"h-full w-1/3 bg-brand-500 animate-[browser-load_1.1s_ease-in-out_infinite]"})})]}),x&&!O&&!_&&h.jsx("div",{className:"shrink-0 mb-2 px-2.5 py-1.5 text-[11px] text-amber-600 dark:text-amber-400 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:x}),h.jsx("div",{ref:l,className:"flex-1 min-h-0 min-w-0 w-full rounded-lg border border-border-default bg-surface-elevated/30 overflow-hidden",children:_&&h.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-4 px-6 text-center",children:[h.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-elevated border border-border-default flex items-center justify-center text-fg-secondary",children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:h.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z",strokeLinejoin:"round"})})}),h.jsxs("div",{className:"space-y-1.5 max-w-md",children:[h.jsx("p",{className:"text-sm font-medium text-fg-primary",children:r("browserFolderTitle")}),h.jsx("p",{className:"text-xs text-fg-tertiary break-all",children:_})]}),h.jsx("button",{type:"button",disabled:w,onClick:()=>{S(!0),J.system.openPath(_).catch(()=>J.files.reveal(_)).finally(()=>S(!1))},className:"px-3.5 py-2 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white transition-colors",children:w?r("browserFolderOpening"):r("browserFolderOpen",{app:D})})]})}),h.jsx("style",{children:`
|
|
36
|
-
@keyframes browser-load {
|
|
37
|
-
0% { transform: translateX(-120%); }
|
|
38
|
-
100% { transform: translateX(360%); }
|
|
39
|
-
}
|
|
40
|
-
`})]}):h.jsxs("div",{className:`space-y-3 ${t??""}`,children:[h.jsx("p",{className:"text-sm text-fg-secondary break-all",children:s}),h.jsx("button",{onClick:()=>window.open(s,"_blank","noopener,noreferrer"),className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",children:"Open in browser"})]})}var iu={exports:{}},N0;function LA(){return N0||(N0=1,(function(s,e){(function(t,i){s.exports=i()})(globalThis,(()=>(()=>{var t={4567:function(a,o,l){var c=this&&this.__decorate||function(p,x,y,_){var k,w=arguments.length,S=w<3?x:_===null?_=Object.getOwnPropertyDescriptor(x,y):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(p,x,y,_);else for(var Q=p.length-1;Q>=0;Q--)(k=p[Q])&&(S=(w<3?k(S):w>3?k(x,y,S):k(x,y))||S);return w>3&&S&&Object.defineProperty(x,y,S),S},d=this&&this.__param||function(p,x){return function(y,_){x(y,_,p)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const u=l(9042),f=l(9924),g=l(844),b=l(4725),v=l(2585),m=l(3656);let O=o.AccessibilityManager=class extends g.Disposable{constructor(p,x,y,_){super(),this._terminal=p,this._coreBrowserService=y,this._renderService=_,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let k=0;k<this._terminal.rows;k++)this._rowElements[k]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[k]);if(this._topBoundaryFocusListener=k=>this._handleBoundaryFocus(k,0),this._bottomBoundaryFocusListener=k=>this._handleBoundaryFocus(k,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new f.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((k=>this._handleResize(k.rows)))),this.register(this._terminal.onRender((k=>this._refreshRows(k.start,k.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((k=>this._handleChar(k)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
41
|
-
`)))),this.register(this._terminal.onA11yTab((k=>this._handleTab(k)))),this.register(this._terminal.onKey((k=>this._handleKey(k.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,m.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,g.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(p){for(let x=0;x<p;x++)this._handleChar(" ")}_handleChar(p){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==p&&(this._charsToAnnounce+=p):this._charsToAnnounce+=p,p===`
|
|
42
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=u.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(p){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(p)||this._charsToConsume.push(p)}_refreshRows(p,x){this._liveRegionDebouncer.refresh(p,x,this._terminal.rows)}_renderRows(p,x){const y=this._terminal.buffer,_=y.lines.length.toString();for(let k=p;k<=x;k++){const w=y.lines.get(y.ydisp+k),S=[],Q=w?.translateToString(!0,void 0,void 0,S)||"",I=(y.ydisp+k+1).toString(),D=this._rowElements[k];D&&(Q.length===0?(D.innerText=" ",this._rowColumns.set(D,[0,1])):(D.textContent=Q,this._rowColumns.set(D,S)),D.setAttribute("aria-posinset",I),D.setAttribute("aria-setsize",_))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(p,x){const y=p.target,_=this._rowElements[x===0?1:this._rowElements.length-2];if(y.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||p.relatedTarget!==_)return;let k,w;if(x===0?(k=y,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(k=this._rowElements.shift(),w=y,this._rowContainer.removeChild(k)),k.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),x===0){const S=this._createAccessibilityTreeNode();this._rowElements.unshift(S),this._rowContainer.insertAdjacentElement("afterbegin",S)}else{const S=this._createAccessibilityTreeNode();this._rowElements.push(S),this._rowContainer.appendChild(S)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(x===0?-1:1),this._rowElements[x===0?1:this._rowElements.length-2].focus(),p.preventDefault(),p.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;const p=document.getSelection();if(!p)return;if(p.isCollapsed)return void(this._rowContainer.contains(p.anchorNode)&&this._terminal.clearSelection());if(!p.anchorNode||!p.focusNode)return void console.error("anchorNode and/or focusNode are null");let x={node:p.anchorNode,offset:p.anchorOffset},y={node:p.focusNode,offset:p.focusOffset};if((x.node.compareDocumentPosition(y.node)&Node.DOCUMENT_POSITION_PRECEDING||x.node===y.node&&x.offset>y.offset)&&([x,y]=[y,x]),x.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(x={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(x.node))return;const _=this._rowElements.slice(-1)[0];if(y.node.compareDocumentPosition(_)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(y={node:_,offset:_.textContent?.length??0}),!this._rowContainer.contains(y.node))return;const k=({node:Q,offset:I})=>{const D=Q instanceof Text?Q.parentNode:Q;let $=parseInt(D?.getAttribute("aria-posinset"),10)-1;if(isNaN($))return console.warn("row is invalid. Race condition?"),null;const j=this._rowColumns.get(D);if(!j)return console.warn("columns is null. Race condition?"),null;let B=I<j.length?j[I]:j.slice(-1)[0]+1;return B>=this._terminal.cols&&(++$,B=0),{row:$,column:B}},w=k(x),S=k(y);if(w&&S){if(w.row>S.row||w.row===S.row&&w.column>=S.column)throw new Error("invalid range");this._terminal.select(w.column,w.row,(S.row-w.row)*this._terminal.cols-w.column+S.column)}}_handleResize(p){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let x=this._rowContainer.children.length;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);for(;this._rowElements.length>p;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const p=this._coreBrowserService.mainDocument.createElement("div");return p.setAttribute("role","listitem"),p.tabIndex=-1,this._refreshRowDimensions(p),p}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let p=0;p<this._terminal.rows;p++)this._refreshRowDimensions(this._rowElements[p])}}_refreshRowDimensions(p){p.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=O=c([d(1,v.IInstantiationService),d(2,b.ICoreBrowserService),d(3,b.IRenderService)],O)},3614:(a,o)=>{function l(f){return f.replace(/\r?\n/g,"\r")}function c(f,g){return g?"\x1B[200~"+f+"\x1B[201~":f}function d(f,g,b,v){f=c(f=l(f),b.decPrivateModes.bracketedPasteMode&&v.rawOptions.ignoreBracketedPasteMode!==!0),b.triggerDataEvent(f,!0),g.value=""}function u(f,g,b){const v=b.getBoundingClientRect(),m=f.clientX-v.left-10,O=f.clientY-v.top-10;g.style.width="20px",g.style.height="20px",g.style.left=`${m}px`,g.style.top=`${O}px`,g.style.zIndex="1000",g.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=l,o.bracketTextForPaste=c,o.copyHandler=function(f,g){f.clipboardData&&f.clipboardData.setData("text/plain",g.selectionText),f.preventDefault()},o.handlePasteEvent=function(f,g,b,v){f.stopPropagation(),f.clipboardData&&d(f.clipboardData.getData("text/plain"),g,b,v)},o.paste=d,o.moveTextAreaUnderMouseCursor=u,o.rightClickHandler=function(f,g,b,v,m){u(f,g,b),m&&v.rightClickSelect(f),g.value=v.selectionText,g.select()}},7239:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const c=l(1505);o.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(d,u,f){this._css.set(d,u,f)}getCss(d,u){return this._css.get(d,u)}setColor(d,u,f){this._color.set(d,u,f)}getColor(d,u){return this._color.get(d,u)}clear(){this._color.clear(),this._css.clear()}}},3656:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(l,c,d,u){l.addEventListener(c,d,u);let f=!1;return{dispose:()=>{f||(f=!0,l.removeEventListener(c,d,u))}}}},3551:function(a,o,l){var c=this&&this.__decorate||function(O,p,x,y){var _,k=arguments.length,w=k<3?p:y===null?y=Object.getOwnPropertyDescriptor(p,x):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(O,p,x,y);else for(var S=O.length-1;S>=0;S--)(_=O[S])&&(w=(k<3?_(w):k>3?_(p,x,w):_(p,x))||w);return k>3&&w&&Object.defineProperty(p,x,w),w},d=this&&this.__param||function(O,p){return function(x,y){p(x,y,O)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const u=l(3656),f=l(8460),g=l(844),b=l(2585),v=l(4725);let m=o.Linkifier=class extends g.Disposable{get currentLink(){return this._currentLink}constructor(O,p,x,y,_){super(),this._element=O,this._mouseService=p,this._renderService=x,this._bufferService=y,this._linkProviderService=_,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new f.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new f.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,g.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,g.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,u.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,u.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(O){this._lastMouseEvent=O;const p=this._positionFromMouseEvent(O,this._element,this._mouseService);if(!p)return;this._isMouseOut=!1;const x=O.composedPath();for(let y=0;y<x.length;y++){const _=x[y];if(_.classList.contains("xterm"))break;if(_.classList.contains("xterm-hover"))return}this._lastBufferCell&&p.x===this._lastBufferCell.x&&p.y===this._lastBufferCell.y||(this._handleHover(p),this._lastBufferCell=p)}_handleHover(O){if(this._activeLine!==O.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(O,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,O)||(this._clearCurrentLink(),this._askForLink(O,!0))}_askForLink(O,p){this._activeProviderReplies&&p||(this._activeProviderReplies?.forEach((y=>{y?.forEach((_=>{_.link.dispose&&_.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=O.y);let x=!1;for(const[y,_]of this._linkProviderService.linkProviders.entries())p?this._activeProviderReplies?.get(y)&&(x=this._checkLinkProviderResult(y,O,x)):_.provideLinks(O.y,(k=>{if(this._isMouseOut)return;const w=k?.map((S=>({link:S})));this._activeProviderReplies?.set(y,w),x=this._checkLinkProviderResult(y,O,x),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(O.y,this._activeProviderReplies)}))}_removeIntersectingLinks(O,p){const x=new Set;for(let y=0;y<p.size;y++){const _=p.get(y);if(_)for(let k=0;k<_.length;k++){const w=_[k],S=w.link.range.start.y<O?0:w.link.range.start.x,Q=w.link.range.end.y>O?this._bufferService.cols:w.link.range.end.x;for(let I=S;I<=Q;I++){if(x.has(I)){_.splice(k--,1);break}x.add(I)}}}}_checkLinkProviderResult(O,p,x){if(!this._activeProviderReplies)return x;const y=this._activeProviderReplies.get(O);let _=!1;for(let k=0;k<O;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(_=!0);if(!_&&y){const k=y.find((w=>this._linkAtPosition(w.link,p)));k&&(x=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!x)for(let k=0;k<this._activeProviderReplies.size;k++){const w=this._activeProviderReplies.get(k)?.find((S=>this._linkAtPosition(S.link,p)));if(w){x=!0,this._handleNewLink(w);break}}return x}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(O){if(!this._currentLink)return;const p=this._positionFromMouseEvent(O,this._element,this._mouseService);p&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,p)&&this._currentLink.link.activate(O,this._currentLink.link.text)}_clearCurrentLink(O,p){this._currentLink&&this._lastMouseEvent&&(!O||!p||this._currentLink.link.range.start.y>=O&&this._currentLink.link.range.end.y<=p)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,g.disposeArray)(this._linkCacheDisposables))}_handleNewLink(O){if(!this._lastMouseEvent)return;const p=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);p&&this._linkAtPosition(O.link,p)&&(this._currentLink=O,this._currentLink.state={decorations:{underline:O.link.decorations===void 0||O.link.decorations.underline,pointerCursor:O.link.decorations===void 0||O.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,O.link,this._lastMouseEvent),O.link.decorations={},Object.defineProperties(O.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:x=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==x&&(this._currentLink.state.decorations.pointerCursor=x,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",x))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:x=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==x&&(this._currentLink.state.decorations.underline=x,this._currentLink.state.isHovered&&this._fireUnderlineEvent(O.link,x))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((x=>{if(!this._currentLink)return;const y=x.start===0?0:x.start+1+this._bufferService.buffer.ydisp,_=this._bufferService.buffer.ydisp+1+x.end;if(this._currentLink.link.range.start.y>=y&&this._currentLink.link.range.end.y<=_&&(this._clearCurrentLink(y,_),this._lastMouseEvent)){const k=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);k&&this._askForLink(k,!1)}}))))}_linkHover(O,p,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(p,!0),this._currentLink.state.decorations.pointerCursor&&O.classList.add("xterm-cursor-pointer")),p.hover&&p.hover(x,p.text)}_fireUnderlineEvent(O,p){const x=O.range,y=this._bufferService.buffer.ydisp,_=this._createLinkUnderlineEvent(x.start.x-1,x.start.y-y-1,x.end.x,x.end.y-y-1,void 0);(p?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(_)}_linkLeave(O,p,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(p,!1),this._currentLink.state.decorations.pointerCursor&&O.classList.remove("xterm-cursor-pointer")),p.leave&&p.leave(x,p.text)}_linkAtPosition(O,p){const x=O.range.start.y*this._bufferService.cols+O.range.start.x,y=O.range.end.y*this._bufferService.cols+O.range.end.x,_=p.y*this._bufferService.cols+p.x;return x<=_&&_<=y}_positionFromMouseEvent(O,p,x){const y=x.getCoords(O,p,this._bufferService.cols,this._bufferService.rows);if(y)return{x:y[0],y:y[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(O,p,x,y,_){return{x1:O,y1:p,x2:x,y2:y,cols:this._bufferService.cols,fg:_}}};o.Linkifier=m=c([d(1,v.IMouseService),d(2,v.IRenderService),d(3,b.IBufferService),d(4,v.ILinkProviderService)],m)},9042:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(a,o,l){var c=this&&this.__decorate||function(v,m,O,p){var x,y=arguments.length,_=y<3?m:p===null?p=Object.getOwnPropertyDescriptor(m,O):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(v,m,O,p);else for(var k=v.length-1;k>=0;k--)(x=v[k])&&(_=(y<3?x(_):y>3?x(m,O,_):x(m,O))||_);return y>3&&_&&Object.defineProperty(m,O,_),_},d=this&&this.__param||function(v,m){return function(O,p){m(O,p,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const u=l(511),f=l(2585);let g=o.OscLinkProvider=class{constructor(v,m,O){this._bufferService=v,this._optionsService=m,this._oscLinkService=O}provideLinks(v,m){const O=this._bufferService.buffer.lines.get(v-1);if(!O)return void m(void 0);const p=[],x=this._optionsService.rawOptions.linkHandler,y=new u.CellData,_=O.getTrimmedLength();let k=-1,w=-1,S=!1;for(let Q=0;Q<_;Q++)if(w!==-1||O.hasContent(Q)){if(O.loadCell(Q,y),y.hasExtendedAttrs()&&y.extended.urlId){if(w===-1){w=Q,k=y.extended.urlId;continue}S=y.extended.urlId!==k}else w!==-1&&(S=!0);if(S||w!==-1&&Q===_-1){const I=this._oscLinkService.getLinkData(k)?.uri;if(I){const D={start:{x:w+1,y:v},end:{x:Q+(S||Q!==_-1?0:1),y:v}};let $=!1;if(!x?.allowNonHttpProtocols)try{const j=new URL(I);["http:","https:"].includes(j.protocol)||($=!0)}catch{$=!0}$||p.push({text:I,range:D,activate:(j,B)=>x?x.activate(j,B,D):b(0,B),hover:(j,B)=>x?.hover?.(j,B,D),leave:(j,B)=>x?.leave?.(j,B,D)})}S=!1,y.hasExtendedAttrs()&&y.extended.urlId?(w=Q,k=y.extended.urlId):(w=-1,k=-1)}}m(p)}};function b(v,m){if(confirm(`Do you want to navigate to ${m}?
|
|
43
|
-
|
|
44
|
-
WARNING: This link could potentially be dangerous`)){const O=window.open();if(O){try{O.opener=null}catch{}O.location.href=m}else console.warn("Opening link blocked as opener could not be cleared")}}o.OscLinkProvider=g=c([d(0,f.IBufferService),d(1,f.IOptionsService),d(2,f.IOscLinkService)],g)},6193:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.RenderDebouncer=void 0,o.RenderDebouncer=class{constructor(l,c){this._renderCallback=l,this._coreBrowserService=c,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(l){return this._refreshCallbacks.push(l),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(l,c,d){this._rowCount=d,l=l!==void 0?l:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,l):l,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const l=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(l,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const l of this._refreshCallbacks)l(0);this._refreshCallbacks=[]}}},3236:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Terminal=void 0;const c=l(3614),d=l(3656),u=l(3551),f=l(9042),g=l(3730),b=l(1680),v=l(3107),m=l(5744),O=l(2950),p=l(1296),x=l(428),y=l(4269),_=l(5114),k=l(8934),w=l(3230),S=l(9312),Q=l(4725),I=l(6731),D=l(8055),$=l(8969),j=l(8460),B=l(844),F=l(6114),V=l(8437),Z=l(2584),se=l(7399),T=l(5941),A=l(9074),N=l(2585),z=l(5435),U=l(4567),ne=l(779);class Se extends $.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(X={}){super(X),this.browser=F,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new j.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new j.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new j.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new j.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new j.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new j.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new j.EventEmitter),this._onBlur=this.register(new j.EventEmitter),this._onA11yCharEmitter=this.register(new j.EventEmitter),this._onA11yTabEmitter=this.register(new j.EventEmitter),this._onWillOpen=this.register(new j.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(A.DecorationService),this._instantiationService.setService(N.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ne.LinkProviderService),this._instantiationService.setService(Q.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(g.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((M,K)=>this.refresh(M,K)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((M=>this._reportWindowsOptions(M)))),this.register(this._inputHandler.onColor((M=>this._handleColorEvent(M)))),this.register((0,j.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,j.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,j.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,j.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((M=>this._afterResize(M.cols,M.rows)))),this.register((0,B.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(X){if(this._themeService)for(const M of X){let K,ie="";switch(M.index){case 256:K="foreground",ie="10";break;case 257:K="background",ie="11";break;case 258:K="cursor",ie="12";break;default:K="ansi",ie="4;"+M.index}switch(M.type){case 0:const oe=D.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[M.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${Z.C0.ESC}]${ie};${(0,T.toRgbString)(oe)}${Z.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((G=>G.ansi[M.index]=D.channels.toColor(...M.color)));else{const G=K;this._themeService.modifyColors(($e=>$e[G]=D.channels.toColor(...M.color)))}break;case 2:this._themeService.restoreColor(M.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(X){X?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(X){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const X=this.buffer.ybase+this.buffer.y,M=this.buffer.lines.get(X);if(!M)return;const K=Math.min(this.buffer.x,this.cols-1),ie=this._renderService.dimensions.css.cell.height,oe=M.getWidth(K),G=this._renderService.dimensions.css.cell.width*oe,$e=this.buffer.y*this._renderService.dimensions.css.cell.height,Ie=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=Ie+"px",this.textarea.style.top=$e+"px",this.textarea.style.width=G+"px",this.textarea.style.height=ie+"px",this.textarea.style.lineHeight=ie+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,d.addDisposableDomListener)(this.element,"copy",(M=>{this.hasSelection()&&(0,c.copyHandler)(M,this._selectionService)})));const X=M=>(0,c.handlePasteEvent)(M,this.textarea,this.coreService,this.optionsService);this.register((0,d.addDisposableDomListener)(this.textarea,"paste",X)),this.register((0,d.addDisposableDomListener)(this.element,"paste",X)),F.isFirefox?this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(M=>{M.button===2&&(0,c.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,d.addDisposableDomListener)(this.element,"contextmenu",(M=>{(0,c.rightClickHandler)(M,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),F.isLinux&&this.register((0,d.addDisposableDomListener)(this.element,"auxclick",(M=>{M.button===1&&(0,c.moveTextAreaUnderMouseCursor)(M,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,d.addDisposableDomListener)(this.textarea,"keyup",(X=>this._keyUp(X)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keydown",(X=>this._keyDown(X)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"keypress",(X=>this._keyPress(X)),!0)),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionupdate",(X=>this._compositionHelper.compositionupdate(X)))),this.register((0,d.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,d.addDisposableDomListener)(this.textarea,"input",(X=>this._inputEvent(X)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(X){if(!X)throw new Error("Terminal requires a parent element.");if(X.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=X.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),X.appendChild(this.element);const M=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),M.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,d.addDisposableDomListener)(this.screenElement,"mousemove",(K=>this.updateCursorStyle(K)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),M.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",f.promptLabel),F.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(_.CoreBrowserService,this.textarea,X.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Q.ICoreBrowserService,this._coreBrowserService),this.register((0,d.addDisposableDomListener)(this.textarea,"focus",(K=>this._handleTextAreaFocus(K)))),this.register((0,d.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(x.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(Q.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(I.ThemeService),this._instantiationService.setService(Q.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(y.CharacterJoinerService),this._instantiationService.setService(Q.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(w.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(Q.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((K=>this._onRender.fire(K)))),this.onResize((K=>this._renderService.resize(K.cols,K.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(O.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(Q.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(u.Linkifier,this.screenElement)),this.element.appendChild(M);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(b.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(S.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(Q.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((K=>this.scrollLines(K.amount,K.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((K=>this._renderService.handleSelectionChanged(K.start,K.end,K.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((K=>{this.textarea.value=K,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((K=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(v.BufferDecorationRenderer,this.screenElement)),this.register((0,d.addDisposableDomListener)(this.element,"mousedown",(K=>this._selectionService.handleMouseDown(K)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(K=>this._handleScreenReaderModeOptionChange(K)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(m.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(K=>{!this._overviewRulerRenderer&&K&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(m.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(p.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const X=this,M=this.element;function K(G){const $e=X._mouseService.getMouseReportCoords(G,X.screenElement);if(!$e)return!1;let Ie,We;switch(G.overrideType||G.type){case"mousemove":We=32,G.buttons===void 0?(Ie=3,G.button!==void 0&&(Ie=G.button<3?G.button:3)):Ie=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":We=0,Ie=G.button<3?G.button:3;break;case"mousedown":We=1,Ie=G.button<3?G.button:3;break;case"wheel":if(X._customWheelEventHandler&&X._customWheelEventHandler(G)===!1||X.viewport.getLinesScrolled(G)===0)return!1;We=G.deltaY<0?0:1,Ie=4;break;default:return!1}return!(We===void 0||Ie===void 0||Ie>4)&&X.coreMouseService.triggerMouseEvent({col:$e.col,row:$e.row,x:$e.x,y:$e.y,button:Ie,action:We,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const ie={mouseup:null,wheel:null,mousedrag:null,mousemove:null},oe={mouseup:G=>(K(G),G.buttons||(this._document.removeEventListener("mouseup",ie.mouseup),ie.mousedrag&&this._document.removeEventListener("mousemove",ie.mousedrag)),this.cancel(G)),wheel:G=>(K(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&K(G)},mousemove:G=>{G.buttons||K(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&G?ie.mousemove||(M.addEventListener("mousemove",oe.mousemove),ie.mousemove=oe.mousemove):(M.removeEventListener("mousemove",ie.mousemove),ie.mousemove=null),16&G?ie.wheel||(M.addEventListener("wheel",oe.wheel,{passive:!1}),ie.wheel=oe.wheel):(M.removeEventListener("wheel",ie.wheel),ie.wheel=null),2&G?ie.mouseup||(ie.mouseup=oe.mouseup):(this._document.removeEventListener("mouseup",ie.mouseup),ie.mouseup=null),4&G?ie.mousedrag||(ie.mousedrag=oe.mousedrag):(this._document.removeEventListener("mousemove",ie.mousedrag),ie.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,d.addDisposableDomListener)(M,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return K(G),ie.mouseup&&this._document.addEventListener("mouseup",ie.mouseup),ie.mousedrag&&this._document.addEventListener("mousemove",ie.mousedrag),this.cancel(G)}))),this.register((0,d.addDisposableDomListener)(M,"wheel",(G=>{if(!ie.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(G)===!1)return!1;if(!this.buffer.hasScrollback){const $e=this.viewport.getLinesScrolled(G);if($e===0)return;const Ie=Z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let We="";for(let Y=0;Y<Math.abs($e);Y++)We+=Ie;return this.coreService.triggerDataEvent(We,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,d.addDisposableDomListener)(M,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,d.addDisposableDomListener)(M,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(X,M){this._renderService?.refreshRows(X,M)}updateCursorStyle(X){this._selectionService?.shouldColumnSelect(X)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(X,M,K=0){K===1?(super.scrollLines(X,M,K),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(X)}paste(X){(0,c.paste)(X,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(X){this._customKeyEventHandler=X}attachCustomWheelEventHandler(X){this._customWheelEventHandler=X}registerLinkProvider(X){return this._linkProviderService.registerLinkProvider(X)}registerCharacterJoiner(X){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const M=this._characterJoinerService.register(X);return this.refresh(0,this.rows-1),M}deregisterCharacterJoiner(X){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(X)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(X){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+X)}registerDecoration(X){return this._decorationService.registerDecoration(X)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(X,M,K){this._selectionService.setSelection(X,M,K)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(X,M){this._selectionService?.selectLines(X,M)}_keyDown(X){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(X)===!1)return!1;const M=this.browser.isMac&&this.options.macOptionIsMeta&&X.altKey;if(!M&&!this._compositionHelper.keydown(X))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;M||X.key!=="Dead"&&X.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const K=(0,se.evaluateKeyboardEvent)(X,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(X),K.type===3||K.type===2){const ie=this.rows-1;return this.scrollLines(K.type===2?-ie:ie),this.cancel(X,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,X)||(K.cancel&&this.cancel(X,!0),!K.key||!!(X.key&&!X.ctrlKey&&!X.altKey&&!X.metaKey&&X.key.length===1&&X.key.charCodeAt(0)>=65&&X.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(K.key!==Z.C0.ETX&&K.key!==Z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:X}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||X.altKey||X.ctrlKey?this.cancel(X,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(X,M){const K=X.isMac&&!this.options.macOptionIsMeta&&M.altKey&&!M.ctrlKey&&!M.metaKey||X.isWindows&&M.altKey&&M.ctrlKey&&!M.metaKey||X.isWindows&&M.getModifierState("AltGraph");return M.type==="keypress"?K:K&&(!M.keyCode||M.keyCode>47)}_keyUp(X){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(X)===!1||((function(M){return M.keyCode===16||M.keyCode===17||M.keyCode===18})(X)||this.focus(),this.updateCursorStyle(X),this._keyPressHandled=!1)}_keyPress(X){let M;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(X)===!1)return!1;if(this.cancel(X),X.charCode)M=X.charCode;else if(X.which===null||X.which===void 0)M=X.keyCode;else{if(X.which===0||X.charCode===0)return!1;M=X.which}return!(!M||(X.altKey||X.ctrlKey||X.metaKey)&&!this._isThirdLevelShift(this.browser,X)||(M=String.fromCharCode(M),this._onKey.fire({key:M,domEvent:X}),this._showCursor(),this.coreService.triggerDataEvent(M,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(X){if(X.data&&X.inputType==="insertText"&&(!X.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const M=X.data;return this.coreService.triggerDataEvent(M,!0),this.cancel(X),!0}return!1}resize(X,M){X!==this.cols||M!==this.rows?super.resize(X,M):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(X,M){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let X=1;X<this.rows;X++)this.buffer.lines.push(this.buffer.getBlankLine(V.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(Z.C0.ESC+"[I"):this.coreService.triggerDataEvent(Z.C0.ESC+"[O")}_reportWindowsOptions(X){if(this._renderService)switch(X){case z.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const M=this._renderService.dimensions.css.canvas.width.toFixed(0),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[4;${K};${M}t`);break;case z.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const ie=this._renderService.dimensions.css.cell.width.toFixed(0),oe=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.C0.ESC}[6;${oe};${ie}t`)}}cancel(X,M){if(this.options.cancelEvents||M)return X.preventDefault(),X.stopPropagation(),!1}}o.Terminal=Se},9924:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.TimeBasedDebouncer=void 0,o.TimeBasedDebouncer=class{constructor(l,c=1e3){this._renderCallback=l,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(l,c,d){this._rowCount=d,l=l!==void 0?l:0,c=c!==void 0?c:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,l):l,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,c):c;const u=Date.now();if(u-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=u,this._innerRefresh();else if(!this._additionalRefreshRequested){const f=u-this._lastRefreshMs,g=this._debounceThresholdMS-f;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),g)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const l=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(l,c)}}},1680:function(a,o,l){var c=this&&this.__decorate||function(O,p,x,y){var _,k=arguments.length,w=k<3?p:y===null?y=Object.getOwnPropertyDescriptor(p,x):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(O,p,x,y);else for(var S=O.length-1;S>=0;S--)(_=O[S])&&(w=(k<3?_(w):k>3?_(p,x,w):_(p,x))||w);return k>3&&w&&Object.defineProperty(p,x,w),w},d=this&&this.__param||function(O,p){return function(x,y){p(x,y,O)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Viewport=void 0;const u=l(3656),f=l(4725),g=l(8460),b=l(844),v=l(2585);let m=o.Viewport=class extends b.Disposable{constructor(O,p,x,y,_,k,w,S){super(),this._viewportElement=O,this._scrollArea=p,this._bufferService=x,this._optionsService=y,this._charSizeService=_,this._renderService=k,this._coreBrowserService=w,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new g.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((Q=>this._activeBuffer=Q.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((Q=>this._renderDimensions=Q))),this._handleThemeChange(S.colors),this.register(S.onChangeColors((Q=>this._handleThemeChange(Q)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(O){this._viewportElement.style.backgroundColor=O.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(O){if(O)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const p=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==p&&(this._lastRecordedBufferHeight=p,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const O=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==O&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=O),this._refreshAnimationFrame=null}syncScrollArea(O=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(O);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(O)}_handleScroll(O){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const p=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:p,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const O=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(O*(this._smoothScrollState.target-this._smoothScrollState.origin)),O<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(O,p){const x=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(p<0&&this._viewportElement.scrollTop!==0||p>0&&x<this._lastRecordedBufferHeight)||(O.cancelable&&O.preventDefault(),!1)}handleWheel(O){const p=this._getPixelsScrolled(O);return p!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+p:this._smoothScrollState.target+=p,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=p,this._bubbleScroll(O,p))}scrollLines(O){if(O!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const p=O*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+p,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:O,suppressScrollEvent:!1})}_getPixelsScrolled(O){if(O.deltaY===0||O.shiftKey)return 0;let p=this._applyScrollModifier(O.deltaY,O);return O.deltaMode===WheelEvent.DOM_DELTA_LINE?p*=this._currentRowHeight:O.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(p*=this._currentRowHeight*this._bufferService.rows),p}getBufferElements(O,p){let x,y="";const _=[],k=p??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let S=O;S<k;S++){const Q=w.get(S);if(!Q)continue;const I=w.get(S+1)?.isWrapped;if(y+=Q.translateToString(!I),!I||S===w.length-1){const D=document.createElement("div");D.textContent=y,_.push(D),y.length>0&&(x=D),y=""}}return{bufferElements:_,cursorElement:x}}getLinesScrolled(O){if(O.deltaY===0||O.shiftKey)return 0;let p=this._applyScrollModifier(O.deltaY,O);return O.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(p/=this._currentRowHeight+0,this._wheelPartialScroll+=p,p=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):O.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(p*=this._bufferService.rows),p}_applyScrollModifier(O,p){const x=this._optionsService.rawOptions.fastScrollModifier;return x==="alt"&&p.altKey||x==="ctrl"&&p.ctrlKey||x==="shift"&&p.shiftKey?O*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:O*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(O){this._lastTouchY=O.touches[0].pageY}handleTouchMove(O){const p=this._lastTouchY-O.touches[0].pageY;return this._lastTouchY=O.touches[0].pageY,p!==0&&(this._viewportElement.scrollTop+=p,this._bubbleScroll(O,p))}};o.Viewport=m=c([d(2,v.IBufferService),d(3,v.IOptionsService),d(4,f.ICharSizeService),d(5,f.IRenderService),d(6,f.ICoreBrowserService),d(7,f.IThemeService)],m)},3107:function(a,o,l){var c=this&&this.__decorate||function(v,m,O,p){var x,y=arguments.length,_=y<3?m:p===null?p=Object.getOwnPropertyDescriptor(m,O):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(v,m,O,p);else for(var k=v.length-1;k>=0;k--)(x=v[k])&&(_=(y<3?x(_):y>3?x(m,O,_):x(m,O))||_);return y>3&&_&&Object.defineProperty(m,O,_),_},d=this&&this.__param||function(v,m){return function(O,p){m(O,p,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferDecorationRenderer=void 0;const u=l(4725),f=l(844),g=l(2585);let b=o.BufferDecorationRenderer=class extends f.Disposable{constructor(v,m,O,p,x){super(),this._screenElement=v,this._bufferService=m,this._coreBrowserService=O,this._decorationService=p,this._renderService=x,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((y=>this._removeDecoration(y)))),this.register((0,f.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const v of this._decorationService.decorations)this._renderDecoration(v);this._dimensionsChanged=!1}_renderDecoration(v){this._refreshStyle(v),this._dimensionsChanged&&this._refreshXPosition(v)}_createElement(v){const m=this._coreBrowserService.mainDocument.createElement("div");m.classList.add("xterm-decoration"),m.classList.toggle("xterm-decoration-top-layer",v?.options?.layer==="top"),m.style.width=`${Math.round((v.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,m.style.height=(v.options.height||1)*this._renderService.dimensions.css.cell.height+"px",m.style.top=(v.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",m.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const O=v.options.x??0;return O&&O>this._bufferService.cols&&(m.style.display="none"),this._refreshXPosition(v,m),m}_refreshStyle(v){const m=v.marker.line-this._bufferService.buffers.active.ydisp;if(m<0||m>=this._bufferService.rows)v.element&&(v.element.style.display="none",v.onRenderEmitter.fire(v.element));else{let O=this._decorationElements.get(v);O||(O=this._createElement(v),v.element=O,this._decorationElements.set(v,O),this._container.appendChild(O),v.onDispose((()=>{this._decorationElements.delete(v),O.remove()}))),O.style.top=m*this._renderService.dimensions.css.cell.height+"px",O.style.display=this._altBufferIsActive?"none":"block",v.onRenderEmitter.fire(O)}}_refreshXPosition(v,m=v.element){if(!m)return;const O=v.options.x??0;(v.options.anchor||"left")==="right"?m.style.right=O?O*this._renderService.dimensions.css.cell.width+"px":"":m.style.left=O?O*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(v){this._decorationElements.get(v)?.remove(),this._decorationElements.delete(v),v.dispose()}};o.BufferDecorationRenderer=b=c([d(1,g.IBufferService),d(2,u.ICoreBrowserService),d(3,g.IDecorationService),d(4,u.IRenderService)],b)},5871:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorZoneStore=void 0,o.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(l){if(l.options.overviewRulerOptions){for(const c of this._zones)if(c.color===l.options.overviewRulerOptions.color&&c.position===l.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,l.marker.line))return;if(this._lineAdjacentToZone(c,l.marker.line,l.options.overviewRulerOptions.position))return void this._addLineToZone(c,l.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=l.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=l.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=l.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=l.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:l.options.overviewRulerOptions.color,position:l.options.overviewRulerOptions.position,startBufferLine:l.marker.line,endBufferLine:l.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(l){this._linePadding=l}_lineIntersectsZone(l,c){return c>=l.startBufferLine&&c<=l.endBufferLine}_lineAdjacentToZone(l,c,d){return c>=l.startBufferLine-this._linePadding[d||"full"]&&c<=l.endBufferLine+this._linePadding[d||"full"]}_addLineToZone(l,c){l.startBufferLine=Math.min(l.startBufferLine,c),l.endBufferLine=Math.max(l.endBufferLine,c)}}},5744:function(a,o,l){var c=this&&this.__decorate||function(x,y,_,k){var w,S=arguments.length,Q=S<3?y:k===null?k=Object.getOwnPropertyDescriptor(y,_):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Q=Reflect.decorate(x,y,_,k);else for(var I=x.length-1;I>=0;I--)(w=x[I])&&(Q=(S<3?w(Q):S>3?w(y,_,Q):w(y,_))||Q);return S>3&&Q&&Object.defineProperty(y,_,Q),Q},d=this&&this.__param||function(x,y){return function(_,k){y(_,k,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OverviewRulerRenderer=void 0;const u=l(5871),f=l(4725),g=l(844),b=l(2585),v={full:0,left:0,center:0,right:0},m={full:0,left:0,center:0,right:0},O={full:0,left:0,center:0,right:0};let p=o.OverviewRulerRenderer=class extends g.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(x,y,_,k,w,S,Q){super(),this._viewportElement=x,this._screenElement=y,this._bufferService=_,this._decorationService=k,this._renderService=w,this._optionsService=S,this._coreBrowserService=Q,this._colorZoneStore=new u.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);const I=this._canvas.getContext("2d");if(!I)throw new Error("Ctx cannot be null");this._ctx=I,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,g.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const x=Math.floor(this._canvas.width/3),y=Math.ceil(this._canvas.width/3);m.full=this._canvas.width,m.left=x,m.center=y,m.right=x,this._refreshDrawHeightConstants(),O.full=0,O.left=0,O.center=m.left,O.right=m.left+m.center}_refreshDrawHeightConstants(){v.full=Math.round(2*this._coreBrowserService.dpr);const x=this._canvas.height/this._bufferService.buffer.lines.length,y=Math.round(Math.max(Math.min(x,12),6)*this._coreBrowserService.dpr);v.left=y,v.center=y,v.right=y}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*v.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*v.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*v.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*v.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const y of this._decorationService.decorations)this._colorZoneStore.addDecoration(y);this._ctx.lineWidth=1;const x=this._colorZoneStore.zones;for(const y of x)y.position!=="full"&&this._renderColorZone(y);for(const y of x)y.position==="full"&&this._renderColorZone(y);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(x){this._ctx.fillStyle=x.color,this._ctx.fillRect(O[x.position||"full"],Math.round((this._canvas.height-1)*(x.startBufferLine/this._bufferService.buffers.active.lines.length)-v[x.position||"full"]/2),m[x.position||"full"],Math.round((this._canvas.height-1)*((x.endBufferLine-x.startBufferLine)/this._bufferService.buffers.active.lines.length)+v[x.position||"full"]))}_queueRefresh(x,y){this._shouldUpdateDimensions=x||this._shouldUpdateDimensions,this._shouldUpdateAnchor=y||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};o.OverviewRulerRenderer=p=c([d(2,b.IBufferService),d(3,b.IDecorationService),d(4,f.IRenderService),d(5,b.IOptionsService),d(6,f.ICoreBrowserService)],p)},2950:function(a,o,l){var c=this&&this.__decorate||function(v,m,O,p){var x,y=arguments.length,_=y<3?m:p===null?p=Object.getOwnPropertyDescriptor(m,O):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(v,m,O,p);else for(var k=v.length-1;k>=0;k--)(x=v[k])&&(_=(y<3?x(_):y>3?x(m,O,_):x(m,O))||_);return y>3&&_&&Object.defineProperty(m,O,_),_},d=this&&this.__param||function(v,m){return function(O,p){m(O,p,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CompositionHelper=void 0;const u=l(4725),f=l(2585),g=l(2584);let b=o.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(v,m,O,p,x,y){this._textarea=v,this._compositionView=m,this._bufferService=O,this._optionsService=p,this._coreService=x,this._renderService=y,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(v){this._compositionView.textContent=v.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(v){if(this._isComposing||this._isSendingComposition){if(v.keyCode===229||v.keyCode===16||v.keyCode===17||v.keyCode===18)return!1;this._finalizeComposition(!1)}return v.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(v){if(this._compositionView.classList.remove("active"),this._isComposing=!1,v){const m={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let O;this._isSendingComposition=!1,m.start+=this._dataAlreadySent.length,O=this._isComposing?this._textarea.value.substring(m.start,m.end):this._textarea.value.substring(m.start),O.length>0&&this._coreService.triggerDataEvent(O,!0)}}),0)}else{this._isSendingComposition=!1;const m=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(m,!0)}}_handleAnyTextareaChanges(){const v=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const m=this._textarea.value,O=m.replace(v,"");this._dataAlreadySent=O,m.length>v.length?this._coreService.triggerDataEvent(O,!0):m.length<v.length?this._coreService.triggerDataEvent(`${g.C0.DEL}`,!0):m.length===v.length&&m!==v&&this._coreService.triggerDataEvent(m,!0)}}),0)}updateCompositionElements(v){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const m=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),O=this._renderService.dimensions.css.cell.height,p=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,x=m*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=x+"px",this._compositionView.style.top=p+"px",this._compositionView.style.height=O+"px",this._compositionView.style.lineHeight=O+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const y=this._compositionView.getBoundingClientRect();this._textarea.style.left=x+"px",this._textarea.style.top=p+"px",this._textarea.style.width=Math.max(y.width,1)+"px",this._textarea.style.height=Math.max(y.height,1)+"px",this._textarea.style.lineHeight=y.height+"px"}v||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};o.CompositionHelper=b=c([d(2,f.IBufferService),d(3,f.IOptionsService),d(4,f.ICoreService),d(5,u.IRenderService)],b)},9806:(a,o)=>{function l(c,d,u){const f=u.getBoundingClientRect(),g=c.getComputedStyle(u),b=parseInt(g.getPropertyValue("padding-left")),v=parseInt(g.getPropertyValue("padding-top"));return[d.clientX-f.left-b,d.clientY-f.top-v]}Object.defineProperty(o,"__esModule",{value:!0}),o.getCoords=o.getCoordsRelativeToElement=void 0,o.getCoordsRelativeToElement=l,o.getCoords=function(c,d,u,f,g,b,v,m,O){if(!b)return;const p=l(c,d,u);return p?(p[0]=Math.ceil((p[0]+(O?v/2:0))/v),p[1]=Math.ceil(p[1]/m),p[0]=Math.min(Math.max(p[0],1),f+(O?1:0)),p[1]=Math.min(Math.max(p[1],1),g),p):void 0}},9504:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.moveToCellSequence=void 0;const c=l(2584);function d(m,O,p,x){const y=m-u(m,p),_=O-u(O,p),k=Math.abs(y-_)-(function(w,S,Q){let I=0;const D=w-u(w,Q),$=S-u(S,Q);for(let j=0;j<Math.abs(D-$);j++){const B=f(w,S)==="A"?-1:1;Q.buffer.lines.get(D+B*j)?.isWrapped&&I++}return I})(m,O,p);return v(k,b(f(m,O),x))}function u(m,O){let p=0,x=O.buffer.lines.get(m),y=x?.isWrapped;for(;y&&m>=0&&m<O.rows;)p++,x=O.buffer.lines.get(--m),y=x?.isWrapped;return p}function f(m,O){return m>O?"A":"B"}function g(m,O,p,x,y,_){let k=m,w=O,S="";for(;k!==p||w!==x;)k+=y?1:-1,y&&k>_.cols-1?(S+=_.buffer.translateBufferLineToString(w,!1,m,k),k=0,m=0,w++):!y&&k<0&&(S+=_.buffer.translateBufferLineToString(w,!1,0,m+1),k=_.cols-1,m=k,w--);return S+_.buffer.translateBufferLineToString(w,!1,m,k)}function b(m,O){const p=O?"O":"[";return c.C0.ESC+p+m}function v(m,O){m=Math.floor(m);let p="";for(let x=0;x<m;x++)p+=O;return p}o.moveToCellSequence=function(m,O,p,x){const y=p.buffer.x,_=p.buffer.y;if(!p.buffer.hasScrollback)return(function(S,Q,I,D,$,j){return d(Q,D,$,j).length===0?"":v(g(S,Q,S,Q-u(Q,$),!1,$).length,b("D",j))})(y,_,0,O,p,x)+d(_,O,p,x)+(function(S,Q,I,D,$,j){let B;B=d(Q,D,$,j).length>0?D-u(D,$):Q;const F=D,V=(function(Z,se,T,A,N,z){let U;return U=d(T,A,N,z).length>0?A-u(A,N):se,Z<T&&U<=A||Z>=T&&U<A?"C":"D"})(S,Q,I,D,$,j);return v(g(S,B,I,F,V==="C",$).length,b(V,j))})(y,_,m,O,p,x);let k;if(_===O)return k=y>m?"D":"C",v(Math.abs(y-m),b(k,x));k=_>O?"D":"C";const w=Math.abs(_-O);return v((function(S,Q){return Q.cols-S})(_>O?m:y,p)+(w-1)*p.cols+1+((_>O?y:m)-1),b(k,x))}},1296:function(a,o,l){var c=this&&this.__decorate||function(j,B,F,V){var Z,se=arguments.length,T=se<3?B:V===null?V=Object.getOwnPropertyDescriptor(B,F):V;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(j,B,F,V);else for(var A=j.length-1;A>=0;A--)(Z=j[A])&&(T=(se<3?Z(T):se>3?Z(B,F,T):Z(B,F))||T);return se>3&&T&&Object.defineProperty(B,F,T),T},d=this&&this.__param||function(j,B){return function(F,V){B(F,V,j)}};Object.defineProperty(o,"__esModule",{value:!0}),o.DomRenderer=void 0;const u=l(3787),f=l(2550),g=l(2223),b=l(6171),v=l(6052),m=l(4725),O=l(8055),p=l(8460),x=l(844),y=l(2585),_="xterm-dom-renderer-owner-",k="xterm-rows",w="xterm-fg-",S="xterm-bg-",Q="xterm-focus",I="xterm-selection";let D=1,$=o.DomRenderer=class extends x.Disposable{constructor(j,B,F,V,Z,se,T,A,N,z,U,ne,Se){super(),this._terminal=j,this._document=B,this._element=F,this._screenElement=V,this._viewportElement=Z,this._helperContainer=se,this._linkifier2=T,this._charSizeService=N,this._optionsService=z,this._bufferService=U,this._coreBrowserService=ne,this._themeService=Se,this._terminalClass=D++,this._rowElements=[],this._selectionRenderModel=(0,v.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new p.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(k),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(I),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,b.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((Pe=>this._injectCss(Pe)))),this._injectCss(this._themeService.colors),this._rowFactory=A.createInstance(u.DomRendererRowFactory,document),this._element.classList.add(_+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((Pe=>this._handleLinkHover(Pe)))),this.register(this._linkifier2.onHideLinkUnderline((Pe=>this._handleLinkLeave(Pe)))),this.register((0,x.toDisposable)((()=>{this._element.classList.remove(_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new f.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const j=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*j,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*j),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/j),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/j),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const F of this._rowElements)F.style.width=`${this.dimensions.css.canvas.width}px`,F.style.height=`${this.dimensions.css.cell.height}px`,F.style.lineHeight=`${this.dimensions.css.cell.height}px`,F.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const B=`${this._terminalSelector} .${k} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=B,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(j){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let B=`${this._terminalSelector} .${k} { color: ${j.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;B+=`${this._terminalSelector} .${k} .xterm-dim { color: ${O.color.multiplyOpacity(j.foreground,.5).css};}`,B+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;const F=`blink_underline_${this._terminalClass}`,V=`blink_bar_${this._terminalClass}`,Z=`blink_block_${this._terminalClass}`;B+=`@keyframes ${F} { 50% { border-bottom-style: hidden; }}`,B+=`@keyframes ${V} { 50% { box-shadow: none; }}`,B+=`@keyframes ${Z} { 0% { background-color: ${j.cursor.css}; color: ${j.cursorAccent.css}; } 50% { background-color: inherit; color: ${j.cursor.css}; }}`,B+=`${this._terminalSelector} .${k}.${Q} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${F} 1s step-end infinite;}${this._terminalSelector} .${k}.${Q} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${k}.${Q} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Z} 1s step-end infinite;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-block { background-color: ${j.cursor.css}; color: ${j.cursorAccent.css};}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${j.cursor.css} !important; color: ${j.cursorAccent.css} !important;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${j.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${j.cursor.css} inset;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${j.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,B+=`${this._terminalSelector} .${I} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${I} div { position: absolute; background-color: ${j.selectionBackgroundOpaque.css};}${this._terminalSelector} .${I} div { position: absolute; background-color: ${j.selectionInactiveBackgroundOpaque.css};}`;for(const[se,T]of j.ansi.entries())B+=`${this._terminalSelector} .${w}${se} { color: ${T.css}; }${this._terminalSelector} .${w}${se}.xterm-dim { color: ${O.color.multiplyOpacity(T,.5).css}; }${this._terminalSelector} .${S}${se} { background-color: ${T.css}; }`;B+=`${this._terminalSelector} .${w}${g.INVERTED_DEFAULT_COLOR} { color: ${O.color.opaque(j.background).css}; }${this._terminalSelector} .${w}${g.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${O.color.multiplyOpacity(O.color.opaque(j.background),.5).css}; }${this._terminalSelector} .${S}${g.INVERTED_DEFAULT_COLOR} { background-color: ${j.foreground.css}; }`,this._themeStyleElement.textContent=B}_setDefaultSpacing(){const j=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${j}px`,this._rowFactory.defaultSpacing=j}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(j,B){for(let F=this._rowElements.length;F<=B;F++){const V=this._document.createElement("div");this._rowContainer.appendChild(V),this._rowElements.push(V)}for(;this._rowElements.length>B;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(j,B){this._refreshRowElements(j,B),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Q),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Q),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(j,B,F){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(j,B,F),this.renderRows(0,this._bufferService.rows-1),!j||!B)return;this._selectionRenderModel.update(this._terminal,j,B,F);const V=this._selectionRenderModel.viewportStartRow,Z=this._selectionRenderModel.viewportEndRow,se=this._selectionRenderModel.viewportCappedStartRow,T=this._selectionRenderModel.viewportCappedEndRow;if(se>=this._bufferService.rows||T<0)return;const A=this._document.createDocumentFragment();if(F){const N=j[0]>B[0];A.appendChild(this._createSelectionElement(se,N?B[0]:j[0],N?j[0]:B[0],T-se+1))}else{const N=V===se?j[0]:0,z=se===Z?B[0]:this._bufferService.cols;A.appendChild(this._createSelectionElement(se,N,z));const U=T-se-1;if(A.appendChild(this._createSelectionElement(se+1,0,this._bufferService.cols,U)),se!==T){const ne=Z===T?B[0]:this._bufferService.cols;A.appendChild(this._createSelectionElement(T,0,ne))}}this._selectionContainer.appendChild(A)}_createSelectionElement(j,B,F,V=1){const Z=this._document.createElement("div"),se=B*this.dimensions.css.cell.width;let T=this.dimensions.css.cell.width*(F-B);return se+T>this.dimensions.css.canvas.width&&(T=this.dimensions.css.canvas.width-se),Z.style.height=V*this.dimensions.css.cell.height+"px",Z.style.top=j*this.dimensions.css.cell.height+"px",Z.style.left=`${se}px`,Z.style.width=`${T}px`,Z}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const j of this._rowElements)j.replaceChildren()}renderRows(j,B){const F=this._bufferService.buffer,V=F.ybase+F.y,Z=Math.min(F.x,this._bufferService.cols-1),se=this._optionsService.rawOptions.cursorBlink,T=this._optionsService.rawOptions.cursorStyle,A=this._optionsService.rawOptions.cursorInactiveStyle;for(let N=j;N<=B;N++){const z=N+F.ydisp,U=this._rowElements[N],ne=F.lines.get(z);if(!U||!ne)break;U.replaceChildren(...this._rowFactory.createRow(ne,z,z===V,T,A,Z,se,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${_}${this._terminalClass}`}_handleLinkHover(j){this._setCellUnderline(j.x1,j.x2,j.y1,j.y2,j.cols,!0)}_handleLinkLeave(j){this._setCellUnderline(j.x1,j.x2,j.y1,j.y2,j.cols,!1)}_setCellUnderline(j,B,F,V,Z,se){F<0&&(j=0),V<0&&(B=0);const T=this._bufferService.rows-1;F=Math.max(Math.min(F,T),0),V=Math.max(Math.min(V,T),0),Z=Math.min(Z,this._bufferService.cols);const A=this._bufferService.buffer,N=A.ybase+A.y,z=Math.min(A.x,Z-1),U=this._optionsService.rawOptions.cursorBlink,ne=this._optionsService.rawOptions.cursorStyle,Se=this._optionsService.rawOptions.cursorInactiveStyle;for(let Pe=F;Pe<=V;++Pe){const X=Pe+A.ydisp,M=this._rowElements[Pe],K=A.lines.get(X);if(!M||!K)break;M.replaceChildren(...this._rowFactory.createRow(K,X,X===N,ne,Se,z,U,this.dimensions.css.cell.width,this._widthCache,se?Pe===F?j:0:-1,se?(Pe===V?B:Z)-1:-1))}}};o.DomRenderer=$=c([d(7,y.IInstantiationService),d(8,m.ICharSizeService),d(9,y.IOptionsService),d(10,y.IBufferService),d(11,m.ICoreBrowserService),d(12,m.IThemeService)],$)},3787:function(a,o,l){var c=this&&this.__decorate||function(k,w,S,Q){var I,D=arguments.length,$=D<3?w:Q===null?Q=Object.getOwnPropertyDescriptor(w,S):Q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")$=Reflect.decorate(k,w,S,Q);else for(var j=k.length-1;j>=0;j--)(I=k[j])&&($=(D<3?I($):D>3?I(w,S,$):I(w,S))||$);return D>3&&$&&Object.defineProperty(w,S,$),$},d=this&&this.__param||function(k,w){return function(S,Q){w(S,Q,k)}};Object.defineProperty(o,"__esModule",{value:!0}),o.DomRendererRowFactory=void 0;const u=l(2223),f=l(643),g=l(511),b=l(2585),v=l(8055),m=l(4725),O=l(4269),p=l(6171),x=l(3734);let y=o.DomRendererRowFactory=class{constructor(k,w,S,Q,I,D,$){this._document=k,this._characterJoinerService=w,this._optionsService=S,this._coreBrowserService=Q,this._coreService=I,this._decorationService=D,this._themeService=$,this._workCell=new g.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,w,S){this._selectionStart=k,this._selectionEnd=w,this._columnSelectMode=S}createRow(k,w,S,Q,I,D,$,j,B,F,V){const Z=[],se=this._characterJoinerService.getJoinedCharacters(w),T=this._themeService.colors;let A,N=k.getNoBgTrimmedLength();S&&N<D+1&&(N=D+1);let z=0,U="",ne=0,Se=0,Pe=0,X=!1,M=0,K=!1,ie=0;const oe=[],G=F!==-1&&V!==-1;for(let $e=0;$e<N;$e++){k.loadCell($e,this._workCell);let Ie=this._workCell.getWidth();if(Ie===0)continue;let We=!1,Y=$e,ee=this._workCell;if(se.length>0&&$e===se[0][0]){We=!0;const xt=se.shift();ee=new O.JoinedCellData(this._workCell,k.translateToString(!0,xt[0],xt[1]),xt[1]-xt[0]),Y=xt[1]-1,Ie=ee.getWidth()}const le=this._isCellInSelection($e,w),ke=S&&$e===D,Ce=G&&$e>=F&&$e<=V;let dt=!1;this._decorationService.forEachDecorationAtCell($e,w,void 0,(xt=>{dt=!0}));let ht=ee.getChars()||f.WHITESPACE_CELL_CHAR;if(ht===" "&&(ee.isUnderline()||ee.isOverline())&&(ht=" "),ie=Ie*j-B.get(ht,ee.isBold(),ee.isItalic()),A){if(z&&(le&&K||!le&&!K&&ee.bg===ne)&&(le&&K&&T.selectionForeground||ee.fg===Se)&&ee.extended.ext===Pe&&Ce===X&&ie===M&&!ke&&!We&&!dt){ee.isInvisible()?U+=f.WHITESPACE_CELL_CHAR:U+=ht,z++;continue}z&&(A.textContent=U),A=this._document.createElement("span"),z=0,U=""}else A=this._document.createElement("span");if(ne=ee.bg,Se=ee.fg,Pe=ee.extended.ext,X=Ce,M=ie,K=le,We&&D>=$e&&D<=Y&&(D=$e),!this._coreService.isCursorHidden&&ke&&this._coreService.isCursorInitialized){if(oe.push("xterm-cursor"),this._coreBrowserService.isFocused)$&&oe.push("xterm-cursor-blink"),oe.push(Q==="bar"?"xterm-cursor-bar":Q==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(I)switch(I){case"outline":oe.push("xterm-cursor-outline");break;case"block":oe.push("xterm-cursor-block");break;case"bar":oe.push("xterm-cursor-bar");break;case"underline":oe.push("xterm-cursor-underline")}}if(ee.isBold()&&oe.push("xterm-bold"),ee.isItalic()&&oe.push("xterm-italic"),ee.isDim()&&oe.push("xterm-dim"),U=ee.isInvisible()?f.WHITESPACE_CELL_CHAR:ee.getChars()||f.WHITESPACE_CELL_CHAR,ee.isUnderline()&&(oe.push(`xterm-underline-${ee.extended.underlineStyle}`),U===" "&&(U=" "),!ee.isUnderlineColorDefault()))if(ee.isUnderlineColorRGB())A.style.textDecorationColor=`rgb(${x.AttributeData.toColorRGB(ee.getUnderlineColor()).join(",")})`;else{let xt=ee.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ee.isBold()&&xt<8&&(xt+=8),A.style.textDecorationColor=T.ansi[xt].css}ee.isOverline()&&(oe.push("xterm-overline"),U===" "&&(U=" ")),ee.isStrikethrough()&&oe.push("xterm-strikethrough"),Ce&&(A.style.textDecoration="underline");let yt=ee.getFgColor(),ss=ee.getFgColorMode(),Lt=ee.getBgColor(),zs=ee.getBgColorMode();const vs=!!ee.isInverse();if(vs){const xt=yt;yt=Lt,Lt=xt;const $i=ss;ss=zs,zs=$i}let bs,si,Zs,Ps=!1;switch(this._decorationService.forEachDecorationAtCell($e,w,void 0,(xt=>{xt.options.layer!=="top"&&Ps||(xt.backgroundColorRGB&&(zs=50331648,Lt=xt.backgroundColorRGB.rgba>>8&16777215,bs=xt.backgroundColorRGB),xt.foregroundColorRGB&&(ss=50331648,yt=xt.foregroundColorRGB.rgba>>8&16777215,si=xt.foregroundColorRGB),Ps=xt.options.layer==="top")})),!Ps&&le&&(bs=this._coreBrowserService.isFocused?T.selectionBackgroundOpaque:T.selectionInactiveBackgroundOpaque,Lt=bs.rgba>>8&16777215,zs=50331648,Ps=!0,T.selectionForeground&&(ss=50331648,yt=T.selectionForeground.rgba>>8&16777215,si=T.selectionForeground)),Ps&&oe.push("xterm-decoration-top"),zs){case 16777216:case 33554432:Zs=T.ansi[Lt],oe.push(`xterm-bg-${Lt}`);break;case 50331648:Zs=v.channels.toColor(Lt>>16,Lt>>8&255,255&Lt),this._addStyle(A,`background-color:#${_((Lt>>>0).toString(16),"0",6)}`);break;default:vs?(Zs=T.foreground,oe.push(`xterm-bg-${u.INVERTED_DEFAULT_COLOR}`)):Zs=T.background}switch(bs||ee.isDim()&&(bs=v.color.multiplyOpacity(Zs,.5)),ss){case 16777216:case 33554432:ee.isBold()&&yt<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(yt+=8),this._applyMinimumContrast(A,Zs,T.ansi[yt],ee,bs,void 0)||oe.push(`xterm-fg-${yt}`);break;case 50331648:const xt=v.channels.toColor(yt>>16&255,yt>>8&255,255&yt);this._applyMinimumContrast(A,Zs,xt,ee,bs,si)||this._addStyle(A,`color:#${_(yt.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(A,Zs,T.foreground,ee,bs,si)||vs&&oe.push(`xterm-fg-${u.INVERTED_DEFAULT_COLOR}`)}oe.length&&(A.className=oe.join(" "),oe.length=0),ke||We||dt?A.textContent=U:z++,ie!==this.defaultSpacing&&(A.style.letterSpacing=`${ie}px`),Z.push(A),$e=Y}return A&&z&&(A.textContent=U),Z}_applyMinimumContrast(k,w,S,Q,I,D){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,p.treatGlyphAsBackgroundColor)(Q.getCode()))return!1;const $=this._getContrastCache(Q);let j;if(I||D||(j=$.getColor(w.rgba,S.rgba)),j===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(Q.isDim()?2:1);j=v.color.ensureContrastRatio(I||w,D||S,B),$.setColor((I||w).rgba,(D||S).rgba,j??null)}return!!j&&(this._addStyle(k,`color:${j.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,w){k.setAttribute("style",`${k.getAttribute("style")||""}${w};`)}_isCellInSelection(k,w){const S=this._selectionStart,Q=this._selectionEnd;return!(!S||!Q)&&(this._columnSelectMode?S[0]<=Q[0]?k>=S[0]&&w>=S[1]&&k<Q[0]&&w<=Q[1]:k<S[0]&&w>=S[1]&&k>=Q[0]&&w<=Q[1]:w>S[1]&&w<Q[1]||S[1]===Q[1]&&w===S[1]&&k>=S[0]&&k<Q[0]||S[1]<Q[1]&&w===Q[1]&&k<Q[0]||S[1]<Q[1]&&w===S[1]&&k>=S[0])}};function _(k,w,S){for(;k.length<S;)k=w+k;return k}o.DomRendererRowFactory=y=c([d(1,m.ICharacterJoinerService),d(2,b.IOptionsService),d(3,m.ICoreBrowserService),d(4,b.ICoreService),d(5,b.IDecorationService),d(6,m.IThemeService)],y)},2550:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WidthCache=void 0,o.WidthCache=class{constructor(l,c){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=l.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const d=l.createElement("span");d.classList.add("xterm-char-measure-element");const u=l.createElement("span");u.classList.add("xterm-char-measure-element"),u.style.fontWeight="bold";const f=l.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontStyle="italic";const g=l.createElement("span");g.classList.add("xterm-char-measure-element"),g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[d,u,f,g],this._container.appendChild(d),this._container.appendChild(u),this._container.appendChild(f),this._container.appendChild(g),c.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(l,c,d,u){l===this._font&&c===this._fontSize&&d===this._weight&&u===this._weightBold||(this._font=l,this._fontSize=c,this._weight=d,this._weightBold=u,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${d}`,this._measureElements[1].style.fontWeight=`${u}`,this._measureElements[2].style.fontWeight=`${d}`,this._measureElements[3].style.fontWeight=`${u}`,this.clear())}get(l,c,d){let u=0;if(!c&&!d&&l.length===1&&(u=l.charCodeAt(0))<256){if(this._flat[u]!==-9999)return this._flat[u];const b=this._measure(l,0);return b>0&&(this._flat[u]=b),b}let f=l;c&&(f+="B"),d&&(f+="I");let g=this._holey.get(f);if(g===void 0){let b=0;c&&(b|=1),d&&(b|=2),g=this._measure(l,b),g>0&&this._holey.set(f,g)}return g}_measure(l,c){const d=this._measureElements[c];return d.textContent=l.repeat(32),d.offsetWidth/32}}},2223:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.TEXT_BASELINE=o.DIM_OPACITY=o.INVERTED_DEFAULT_COLOR=void 0;const c=l(6114);o.INVERTED_DEFAULT_COLOR=257,o.DIM_OPACITY=.5,o.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(a,o)=>{function l(d){return 57508<=d&&d<=57558}function c(d){return d>=128512&&d<=128591||d>=127744&&d<=128511||d>=128640&&d<=128767||d>=9728&&d<=9983||d>=9984&&d<=10175||d>=65024&&d<=65039||d>=129280&&d<=129535||d>=127462&&d<=127487}Object.defineProperty(o,"__esModule",{value:!0}),o.computeNextVariantOffset=o.createRenderDimensions=o.treatGlyphAsBackgroundColor=o.allowRescaling=o.isEmoji=o.isRestrictedPowerlineGlyph=o.isPowerlineGlyph=o.throwIfFalsy=void 0,o.throwIfFalsy=function(d){if(!d)throw new Error("value must not be falsy");return d},o.isPowerlineGlyph=l,o.isRestrictedPowerlineGlyph=function(d){return 57520<=d&&d<=57527},o.isEmoji=c,o.allowRescaling=function(d,u,f,g){return u===1&&f>Math.ceil(1.5*g)&&d!==void 0&&d>255&&!c(d)&&!l(d)&&!(function(b){return 57344<=b&&b<=63743})(d)},o.treatGlyphAsBackgroundColor=function(d){return l(d)||(function(u){return 9472<=u&&u<=9631})(d)},o.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},o.computeNextVariantOffset=function(d,u,f=0){return(d-(2*Math.round(u)-f))%(2*Math.round(u))}},6052:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createSelectionRenderModel=void 0;class l{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(d,u,f,g=!1){if(this.selectionStart=u,this.selectionEnd=f,!u||!f||u[0]===f[0]&&u[1]===f[1])return void this.clear();const b=d.buffers.active.ydisp,v=u[1]-b,m=f[1]-b,O=Math.max(v,0),p=Math.min(m,d.rows-1);O>=d.rows||p<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=g,this.viewportStartRow=v,this.viewportEndRow=m,this.viewportCappedStartRow=O,this.viewportCappedEndRow=p,this.startCol=u[0],this.endCol=f[0])}isCellSelected(d,u,f){return!!this.hasSelection&&(f-=d.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?u>=this.startCol&&f>=this.viewportCappedStartRow&&u<this.endCol&&f<=this.viewportCappedEndRow:u<this.startCol&&f>=this.viewportCappedStartRow&&u>=this.endCol&&f<=this.viewportCappedEndRow:f>this.viewportStartRow&&f<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&f===this.viewportStartRow&&u>=this.startCol&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportEndRow&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&f===this.viewportStartRow&&u>=this.startCol)}}o.createSelectionRenderModel=function(){return new l}},456:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.SelectionModel=void 0,o.SelectionModel=class{constructor(l){this._bufferService=l,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const l=this.selectionStart[0]+this.selectionStartLength;return l>this._bufferService.cols?l%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)-1]:[l%this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)]:[l,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const l=this.selectionStart[0]+this.selectionStartLength;return l>this._bufferService.cols?[l%this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)]:[Math.max(l,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const l=this.selectionStart,c=this.selectionEnd;return!(!l||!c)&&(l[1]>c[1]||l[1]===c[1]&&l[0]>c[0])}handleTrim(l){return this.selectionStart&&(this.selectionStart[1]-=l),this.selectionEnd&&(this.selectionEnd[1]-=l),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(a,o,l){var c=this&&this.__decorate||function(p,x,y,_){var k,w=arguments.length,S=w<3?x:_===null?_=Object.getOwnPropertyDescriptor(x,y):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(p,x,y,_);else for(var Q=p.length-1;Q>=0;Q--)(k=p[Q])&&(S=(w<3?k(S):w>3?k(x,y,S):k(x,y))||S);return w>3&&S&&Object.defineProperty(x,y,S),S},d=this&&this.__param||function(p,x){return function(y,_){x(y,_,p)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CharSizeService=void 0;const u=l(2585),f=l(8460),g=l(844);let b=o.CharSizeService=class extends g.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(p,x,y){super(),this._optionsService=y,this.width=0,this.height=0,this._onCharSizeChange=this.register(new f.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new O(this._optionsService))}catch{this._measureStrategy=this.register(new m(p,x,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const p=this._measureStrategy.measure();p.width===this.width&&p.height===this.height||(this.width=p.width,this.height=p.height,this._onCharSizeChange.fire())}};o.CharSizeService=b=c([d(2,u.IOptionsService)],b);class v extends g.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(x,y){x!==void 0&&x>0&&y!==void 0&&y>0&&(this._result.width=x,this._result.height=y)}}class m extends v{constructor(x,y,_){super(),this._document=x,this._parentElement=y,this._optionsService=_,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class O extends v{constructor(x){super(),this._optionsService=x,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const y=this._ctx.measureText("W");if(!("width"in y&&"fontBoundingBoxAscent"in y&&"fontBoundingBoxDescent"in y))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const x=this._ctx.measureText("W");return this._validateAndSet(x.width,x.fontBoundingBoxAscent+x.fontBoundingBoxDescent),this._result}}},4269:function(a,o,l){var c=this&&this.__decorate||function(O,p,x,y){var _,k=arguments.length,w=k<3?p:y===null?y=Object.getOwnPropertyDescriptor(p,x):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(O,p,x,y);else for(var S=O.length-1;S>=0;S--)(_=O[S])&&(w=(k<3?_(w):k>3?_(p,x,w):_(p,x))||w);return k>3&&w&&Object.defineProperty(p,x,w),w},d=this&&this.__param||function(O,p){return function(x,y){p(x,y,O)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CharacterJoinerService=o.JoinedCellData=void 0;const u=l(3734),f=l(643),g=l(511),b=l(2585);class v extends u.AttributeData{constructor(p,x,y){super(),this.content=0,this.combinedData="",this.fg=p.fg,this.bg=p.bg,this.combinedData=x,this._width=y}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(p){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.JoinedCellData=v;let m=o.CharacterJoinerService=class V1{constructor(p){this._bufferService=p,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new g.CellData}register(p){const x={id:this._nextCharacterJoinerId++,handler:p};return this._characterJoiners.push(x),x.id}deregister(p){for(let x=0;x<this._characterJoiners.length;x++)if(this._characterJoiners[x].id===p)return this._characterJoiners.splice(x,1),!0;return!1}getJoinedCharacters(p){if(this._characterJoiners.length===0)return[];const x=this._bufferService.buffer.lines.get(p);if(!x||x.length===0)return[];const y=[],_=x.translateToString(!0);let k=0,w=0,S=0,Q=x.getFg(0),I=x.getBg(0);for(let D=0;D<x.getTrimmedLength();D++)if(x.loadCell(D,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==Q||this._workCell.bg!==I){if(D-k>1){const $=this._getJoinedRanges(_,S,w,x,k);for(let j=0;j<$.length;j++)y.push($[j])}k=D,S=w,Q=this._workCell.fg,I=this._workCell.bg}w+=this._workCell.getChars().length||f.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const D=this._getJoinedRanges(_,S,w,x,k);for(let $=0;$<D.length;$++)y.push(D[$])}return y}_getJoinedRanges(p,x,y,_,k){const w=p.substring(x,y);let S=[];try{S=this._characterJoiners[0].handler(w)}catch(Q){console.error(Q)}for(let Q=1;Q<this._characterJoiners.length;Q++)try{const I=this._characterJoiners[Q].handler(w);for(let D=0;D<I.length;D++)V1._mergeRanges(S,I[D])}catch(I){console.error(I)}return this._stringRangesToCellRanges(S,_,k),S}_stringRangesToCellRanges(p,x,y){let _=0,k=!1,w=0,S=p[_];if(S){for(let Q=y;Q<this._bufferService.cols;Q++){const I=x.getWidth(Q),D=x.getString(Q).length||f.WHITESPACE_CELL_CHAR.length;if(I!==0){if(!k&&S[0]<=w&&(S[0]=Q,k=!0),S[1]<=w){if(S[1]=Q,S=p[++_],!S)break;S[0]<=w?(S[0]=Q,k=!0):k=!1}w+=D}}S&&(S[1]=this._bufferService.cols)}}static _mergeRanges(p,x){let y=!1;for(let _=0;_<p.length;_++){const k=p[_];if(y){if(x[1]<=k[0])return p[_-1][1]=x[1],p;if(x[1]<=k[1])return p[_-1][1]=Math.max(x[1],k[1]),p.splice(_,1),p;p.splice(_,1),_--}else{if(x[1]<=k[0])return p.splice(_,0,x),p;if(x[1]<=k[1])return k[0]=Math.min(x[0],k[0]),p;x[0]<k[1]&&(k[0]=Math.min(x[0],k[0]),y=!0)}}return y?p[p.length-1][1]=x[1]:p.push(x),p}};o.CharacterJoinerService=m=c([d(0,b.IBufferService)],m)},5114:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreBrowserService=void 0;const c=l(844),d=l(8460),u=l(3656);class f extends c.Disposable{constructor(v,m,O){super(),this._textarea=v,this._window=m,this.mainDocument=O,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new g(this._window),this._onDprChange=this.register(new d.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new d.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((p=>this._screenDprMonitor.setWindow(p)))),this.register((0,d.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(v){this._window!==v&&(this._window=v,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}o.CoreBrowserService=f;class g extends c.Disposable{constructor(v){super(),this._parentWindow=v,this._windowResizeListener=this.register(new c.MutableDisposable),this._onDprChange=this.register(new d.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,c.toDisposable)((()=>this.clearListener())))}setWindow(v){this._parentWindow=v,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,u.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.LinkProviderService=void 0;const c=l(844);class d extends c.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,c.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(f){return this.linkProviders.push(f),{dispose:()=>{const g=this.linkProviders.indexOf(f);g!==-1&&this.linkProviders.splice(g,1)}}}}o.LinkProviderService=d},8934:function(a,o,l){var c=this&&this.__decorate||function(b,v,m,O){var p,x=arguments.length,y=x<3?v:O===null?O=Object.getOwnPropertyDescriptor(v,m):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(b,v,m,O);else for(var _=b.length-1;_>=0;_--)(p=b[_])&&(y=(x<3?p(y):x>3?p(v,m,y):p(v,m))||y);return x>3&&y&&Object.defineProperty(v,m,y),y},d=this&&this.__param||function(b,v){return function(m,O){v(m,O,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.MouseService=void 0;const u=l(4725),f=l(9806);let g=o.MouseService=class{constructor(b,v){this._renderService=b,this._charSizeService=v}getCoords(b,v,m,O,p){return(0,f.getCoords)(window,b,v,m,O,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,p)}getMouseReportCoords(b,v){const m=(0,f.getCoordsRelativeToElement)(window,b,v);if(this._charSizeService.hasValidSize)return m[0]=Math.min(Math.max(m[0],0),this._renderService.dimensions.css.canvas.width-1),m[1]=Math.min(Math.max(m[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(m[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(m[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(m[0]),y:Math.floor(m[1])}}};o.MouseService=g=c([d(0,u.IRenderService),d(1,u.ICharSizeService)],g)},3230:function(a,o,l){var c=this&&this.__decorate||function(p,x,y,_){var k,w=arguments.length,S=w<3?x:_===null?_=Object.getOwnPropertyDescriptor(x,y):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(p,x,y,_);else for(var Q=p.length-1;Q>=0;Q--)(k=p[Q])&&(S=(w<3?k(S):w>3?k(x,y,S):k(x,y))||S);return w>3&&S&&Object.defineProperty(x,y,S),S},d=this&&this.__param||function(p,x){return function(y,_){x(y,_,p)}};Object.defineProperty(o,"__esModule",{value:!0}),o.RenderService=void 0;const u=l(6193),f=l(4725),g=l(8460),b=l(844),v=l(7226),m=l(2585);let O=o.RenderService=class extends b.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(p,x,y,_,k,w,S,Q){super(),this._rowCount=p,this._charSizeService=_,this._renderer=this.register(new b.MutableDisposable),this._pausedResizeTask=new v.DebouncedIdleTask,this._observerDisposable=this.register(new b.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new g.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new g.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new g.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new g.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new u.RenderDebouncer(((I,D)=>this._renderRows(I,D)),S),this.register(this._renderDebouncer),this.register(S.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(w.onResize((()=>this._fullRefresh()))),this.register(w.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(y.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(k.onDecorationRegistered((()=>this._fullRefresh()))),this.register(k.onDecorationRemoved((()=>this._fullRefresh()))),this.register(y.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(w.cols,w.rows),this._fullRefresh()}))),this.register(y.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(w.buffer.y,w.buffer.y,!0)))),this.register(Q.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(S.window,x),this.register(S.onWindowChange((I=>this._registerIntersectionObserver(I,x))))}_registerIntersectionObserver(p,x){if("IntersectionObserver"in p){const y=new p.IntersectionObserver((_=>this._handleIntersectionChange(_[_.length-1])),{threshold:0});y.observe(x),this._observerDisposable.value=(0,b.toDisposable)((()=>y.disconnect()))}}_handleIntersectionChange(p){this._isPaused=p.isIntersecting===void 0?p.intersectionRatio===0:!p.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(p,x,y=!1){this._isPaused?this._needsFullRefresh=!0:(y||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(p,x,this._rowCount))}_renderRows(p,x){this._renderer.value&&(p=Math.min(p,this._rowCount-1),x=Math.min(x,this._rowCount-1),this._renderer.value.renderRows(p,x),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:p,end:x}),this._onRender.fire({start:p,end:x}),this._isNextRenderRedrawOnly=!0)}resize(p,x){this._rowCount=x,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(p){this._renderer.value=p,this._renderer.value&&(this._renderer.value.onRequestRedraw((x=>this.refreshRows(x.start,x.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(p){return this._renderDebouncer.addRefreshCallback(p)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(p,x){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(p,x))):this._renderer.value.handleResize(p,x),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(p,x,y){this._selectionState.start=p,this._selectionState.end=x,this._selectionState.columnSelectMode=y,this._renderer.value?.handleSelectionChanged(p,x,y)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};o.RenderService=O=c([d(2,m.IOptionsService),d(3,f.ICharSizeService),d(4,m.IDecorationService),d(5,m.IBufferService),d(6,f.ICoreBrowserService),d(7,f.IThemeService)],O)},9312:function(a,o,l){var c=this&&this.__decorate||function(S,Q,I,D){var $,j=arguments.length,B=j<3?Q:D===null?D=Object.getOwnPropertyDescriptor(Q,I):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(S,Q,I,D);else for(var F=S.length-1;F>=0;F--)($=S[F])&&(B=(j<3?$(B):j>3?$(Q,I,B):$(Q,I))||B);return j>3&&B&&Object.defineProperty(Q,I,B),B},d=this&&this.__param||function(S,Q){return function(I,D){Q(I,D,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.SelectionService=void 0;const u=l(9806),f=l(9504),g=l(456),b=l(4725),v=l(8460),m=l(844),O=l(6114),p=l(4841),x=l(511),y=l(2585),_=" ",k=new RegExp(_,"g");let w=o.SelectionService=class extends m.Disposable{constructor(S,Q,I,D,$,j,B,F,V){super(),this._element=S,this._screenElement=Q,this._linkifier=I,this._bufferService=D,this._coreService=$,this._mouseService=j,this._optionsService=B,this._renderService=F,this._coreBrowserService=V,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new x.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new v.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new v.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new v.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new v.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=Z=>this._handleMouseMove(Z),this._mouseUpListener=Z=>this._handleMouseUp(Z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((Z=>this._handleTrim(Z))),this.register(this._bufferService.buffers.onBufferActivate((Z=>this._handleBufferActivate(Z)))),this.enable(),this._model=new g.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,m.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const S=this._model.finalSelectionStart,Q=this._model.finalSelectionEnd;return!(!S||!Q||S[0]===Q[0]&&S[1]===Q[1])}get selectionText(){const S=this._model.finalSelectionStart,Q=this._model.finalSelectionEnd;if(!S||!Q)return"";const I=this._bufferService.buffer,D=[];if(this._activeSelectionMode===3){if(S[0]===Q[0])return"";const $=S[0]<Q[0]?S[0]:Q[0],j=S[0]<Q[0]?Q[0]:S[0];for(let B=S[1];B<=Q[1];B++){const F=I.translateBufferLineToString(B,!0,$,j);D.push(F)}}else{const $=S[1]===Q[1]?Q[0]:void 0;D.push(I.translateBufferLineToString(S[1],!0,S[0],$));for(let j=S[1]+1;j<=Q[1]-1;j++){const B=I.lines.get(j),F=I.translateBufferLineToString(j,!0);B?.isWrapped?D[D.length-1]+=F:D.push(F)}if(S[1]!==Q[1]){const j=I.lines.get(Q[1]),B=I.translateBufferLineToString(Q[1],!0,0,Q[0]);j&&j.isWrapped?D[D.length-1]+=B:D.push(B)}}return D.map(($=>$.replace(k," "))).join(O.isWindows?`\r
|
|
45
|
-
`:`
|
|
46
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(S){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),O.isLinux&&S&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(S){const Q=this._getMouseBufferCoords(S),I=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!!(I&&D&&Q)&&this._areCoordsInSelection(Q,I,D)}isCellInSelection(S,Q){const I=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!I||!D)&&this._areCoordsInSelection([S,Q],I,D)}_areCoordsInSelection(S,Q,I){return S[1]>Q[1]&&S[1]<I[1]||Q[1]===I[1]&&S[1]===Q[1]&&S[0]>=Q[0]&&S[0]<I[0]||Q[1]<I[1]&&S[1]===I[1]&&S[0]<I[0]||Q[1]<I[1]&&S[1]===Q[1]&&S[0]>=Q[0]}_selectWordAtCursor(S,Q){const I=this._linkifier.currentLink?.link?.range;if(I)return this._model.selectionStart=[I.start.x-1,I.start.y-1],this._model.selectionStartLength=(0,p.getRangeLength)(I,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const D=this._getMouseBufferCoords(S);return!!D&&(this._selectWordAt(D,Q),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(S,Q){this._model.clearSelection(),S=Math.max(S,0),Q=Math.min(Q,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,S],this._model.selectionEnd=[this._bufferService.cols,Q],this.refresh(),this._onSelectionChange.fire()}_handleTrim(S){this._model.handleTrim(S)&&this.refresh()}_getMouseBufferCoords(S){const Q=this._mouseService.getCoords(S,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(Q)return Q[0]--,Q[1]--,Q[1]+=this._bufferService.buffer.ydisp,Q}_getMouseEventScrollAmount(S){let Q=(0,u.getCoordsRelativeToElement)(this._coreBrowserService.window,S,this._screenElement)[1];const I=this._renderService.dimensions.css.canvas.height;return Q>=0&&Q<=I?0:(Q>I&&(Q-=I),Q=Math.min(Math.max(Q,-50),50),Q/=50,Q/Math.abs(Q)+Math.round(14*Q))}shouldForceSelection(S){return O.isMac?S.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:S.shiftKey}handleMouseDown(S){if(this._mouseDownTimeStamp=S.timeStamp,(S.button!==2||!this.hasSelection)&&S.button===0){if(!this._enabled){if(!this.shouldForceSelection(S))return;S.stopPropagation()}S.preventDefault(),this._dragScrollAmount=0,this._enabled&&S.shiftKey?this._handleIncrementalClick(S):S.detail===1?this._handleSingleClick(S):S.detail===2?this._handleDoubleClick(S):S.detail===3&&this._handleTripleClick(S),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(S){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(S))}_handleSingleClick(S){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(S)?3:0,this._model.selectionStart=this._getMouseBufferCoords(S),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const Q=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);Q&&Q.length!==this._model.selectionStart[0]&&Q.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(S){this._selectWordAtCursor(S,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(S){const Q=this._getMouseBufferCoords(S);Q&&(this._activeSelectionMode=2,this._selectLineAt(Q[1]))}shouldColumnSelect(S){return S.altKey&&!(O.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(S){if(S.stopImmediatePropagation(),!this._model.selectionStart)return;const Q=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(S),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(S),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const I=this._bufferService.buffer;if(this._model.selectionEnd[1]<I.lines.length){const D=I.lines.get(this._model.selectionEnd[1]);D&&D.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}Q&&Q[0]===this._model.selectionEnd[0]&&Q[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const S=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(S.ydisp+this._bufferService.rows,S.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=S.ydisp),this.refresh()}}_handleMouseUp(S){const Q=S.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&Q<500&&S.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const I=this._mouseService.getCoords(S,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(I&&I[0]!==void 0&&I[1]!==void 0){const D=(0,f.moveToCellSequence)(I[0]-1,I[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(D,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const S=this._model.finalSelectionStart,Q=this._model.finalSelectionEnd,I=!(!S||!Q||S[0]===Q[0]&&S[1]===Q[1]);I?S&&Q&&(this._oldSelectionStart&&this._oldSelectionEnd&&S[0]===this._oldSelectionStart[0]&&S[1]===this._oldSelectionStart[1]&&Q[0]===this._oldSelectionEnd[0]&&Q[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(S,Q,I)):this._oldHasSelection&&this._fireOnSelectionChange(S,Q,I)}_fireOnSelectionChange(S,Q,I){this._oldSelectionStart=S,this._oldSelectionEnd=Q,this._oldHasSelection=I,this._onSelectionChange.fire()}_handleBufferActivate(S){this.clearSelection(),this._trimListener.dispose(),this._trimListener=S.activeBuffer.lines.onTrim((Q=>this._handleTrim(Q)))}_convertViewportColToCharacterIndex(S,Q){let I=Q;for(let D=0;Q>=D;D++){const $=S.loadCell(D,this._workCell).getChars().length;this._workCell.getWidth()===0?I--:$>1&&Q!==D&&(I+=$-1)}return I}setSelection(S,Q,I){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[S,Q],this._model.selectionStartLength=I,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(S){this._isClickInSelection(S)||(this._selectWordAtCursor(S,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(S,Q,I=!0,D=!0){if(S[0]>=this._bufferService.cols)return;const $=this._bufferService.buffer,j=$.lines.get(S[1]);if(!j)return;const B=$.translateBufferLineToString(S[1],!1);let F=this._convertViewportColToCharacterIndex(j,S[0]),V=F;const Z=S[0]-F;let se=0,T=0,A=0,N=0;if(B.charAt(F)===" "){for(;F>0&&B.charAt(F-1)===" ";)F--;for(;V<B.length&&B.charAt(V+1)===" ";)V++}else{let ne=S[0],Se=S[0];j.getWidth(ne)===0&&(se++,ne--),j.getWidth(Se)===2&&(T++,Se++);const Pe=j.getString(Se).length;for(Pe>1&&(N+=Pe-1,V+=Pe-1);ne>0&&F>0&&!this._isCharWordSeparator(j.loadCell(ne-1,this._workCell));){j.loadCell(ne-1,this._workCell);const X=this._workCell.getChars().length;this._workCell.getWidth()===0?(se++,ne--):X>1&&(A+=X-1,F-=X-1),F--,ne--}for(;Se<j.length&&V+1<B.length&&!this._isCharWordSeparator(j.loadCell(Se+1,this._workCell));){j.loadCell(Se+1,this._workCell);const X=this._workCell.getChars().length;this._workCell.getWidth()===2?(T++,Se++):X>1&&(N+=X-1,V+=X-1),V++,Se++}}V++;let z=F+Z-se+A,U=Math.min(this._bufferService.cols,V-F+se+T-A-N);if(Q||B.slice(F,V).trim()!==""){if(I&&z===0&&j.getCodePoint(0)!==32){const ne=$.lines.get(S[1]-1);if(ne&&j.isWrapped&&ne.getCodePoint(this._bufferService.cols-1)!==32){const Se=this._getWordAt([this._bufferService.cols-1,S[1]-1],!1,!0,!1);if(Se){const Pe=this._bufferService.cols-Se.start;z-=Pe,U+=Pe}}}if(D&&z+U===this._bufferService.cols&&j.getCodePoint(this._bufferService.cols-1)!==32){const ne=$.lines.get(S[1]+1);if(ne?.isWrapped&&ne.getCodePoint(0)!==32){const Se=this._getWordAt([0,S[1]+1],!1,!1,!0);Se&&(U+=Se.length)}}return{start:z,length:U}}}_selectWordAt(S,Q){const I=this._getWordAt(S,Q);if(I){for(;I.start<0;)I.start+=this._bufferService.cols,S[1]--;this._model.selectionStart=[I.start,S[1]],this._model.selectionStartLength=I.length}}_selectToWordAt(S){const Q=this._getWordAt(S,!0);if(Q){let I=S[1];for(;Q.start<0;)Q.start+=this._bufferService.cols,I--;if(!this._model.areSelectionValuesReversed())for(;Q.start+Q.length>this._bufferService.cols;)Q.length-=this._bufferService.cols,I++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?Q.start:Q.start+Q.length,I]}}_isCharWordSeparator(S){return S.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(S.getChars())>=0}_selectLineAt(S){const Q=this._bufferService.buffer.getWrappedRangeForLine(S),I={start:{x:0,y:Q.first},end:{x:this._bufferService.cols-1,y:Q.last}};this._model.selectionStart=[0,Q.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,p.getRangeLength)(I,this._bufferService.cols)}};o.SelectionService=w=c([d(3,y.IBufferService),d(4,y.ICoreService),d(5,b.IMouseService),d(6,y.IOptionsService),d(7,b.IRenderService),d(8,b.ICoreBrowserService)],w)},4725:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ILinkProviderService=o.IThemeService=o.ICharacterJoinerService=o.ISelectionService=o.IRenderService=o.IMouseService=o.ICoreBrowserService=o.ICharSizeService=void 0;const c=l(8343);o.ICharSizeService=(0,c.createDecorator)("CharSizeService"),o.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),o.IMouseService=(0,c.createDecorator)("MouseService"),o.IRenderService=(0,c.createDecorator)("RenderService"),o.ISelectionService=(0,c.createDecorator)("SelectionService"),o.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),o.IThemeService=(0,c.createDecorator)("ThemeService"),o.ILinkProviderService=(0,c.createDecorator)("LinkProviderService")},6731:function(a,o,l){var c=this&&this.__decorate||function(w,S,Q,I){var D,$=arguments.length,j=$<3?S:I===null?I=Object.getOwnPropertyDescriptor(S,Q):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(w,S,Q,I);else for(var B=w.length-1;B>=0;B--)(D=w[B])&&(j=($<3?D(j):$>3?D(S,Q,j):D(S,Q))||j);return $>3&&j&&Object.defineProperty(S,Q,j),j},d=this&&this.__param||function(w,S){return function(Q,I){S(Q,I,w)}};Object.defineProperty(o,"__esModule",{value:!0}),o.ThemeService=o.DEFAULT_ANSI_COLORS=void 0;const u=l(7239),f=l(8055),g=l(8460),b=l(844),v=l(2585),m=f.css.toColor("#ffffff"),O=f.css.toColor("#000000"),p=f.css.toColor("#ffffff"),x=f.css.toColor("#000000"),y={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};o.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const w=[f.css.toColor("#2e3436"),f.css.toColor("#cc0000"),f.css.toColor("#4e9a06"),f.css.toColor("#c4a000"),f.css.toColor("#3465a4"),f.css.toColor("#75507b"),f.css.toColor("#06989a"),f.css.toColor("#d3d7cf"),f.css.toColor("#555753"),f.css.toColor("#ef2929"),f.css.toColor("#8ae234"),f.css.toColor("#fce94f"),f.css.toColor("#729fcf"),f.css.toColor("#ad7fa8"),f.css.toColor("#34e2e2"),f.css.toColor("#eeeeec")],S=[0,95,135,175,215,255];for(let Q=0;Q<216;Q++){const I=S[Q/36%6|0],D=S[Q/6%6|0],$=S[Q%6];w.push({css:f.channels.toCss(I,D,$),rgba:f.channels.toRgba(I,D,$)})}for(let Q=0;Q<24;Q++){const I=8+10*Q;w.push({css:f.channels.toCss(I,I,I),rgba:f.channels.toRgba(I,I,I)})}return w})());let _=o.ThemeService=class extends b.Disposable{get colors(){return this._colors}constructor(w){super(),this._optionsService=w,this._contrastCache=new u.ColorContrastCache,this._halfContrastCache=new u.ColorContrastCache,this._onChangeColors=this.register(new g.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:m,background:O,cursor:p,cursorAccent:x,selectionForeground:void 0,selectionBackgroundTransparent:y,selectionBackgroundOpaque:f.color.blend(O,y),selectionInactiveBackgroundTransparent:y,selectionInactiveBackgroundOpaque:f.color.blend(O,y),ansi:o.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(w={}){const S=this._colors;if(S.foreground=k(w.foreground,m),S.background=k(w.background,O),S.cursor=k(w.cursor,p),S.cursorAccent=k(w.cursorAccent,x),S.selectionBackgroundTransparent=k(w.selectionBackground,y),S.selectionBackgroundOpaque=f.color.blend(S.background,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundTransparent=k(w.selectionInactiveBackground,S.selectionBackgroundTransparent),S.selectionInactiveBackgroundOpaque=f.color.blend(S.background,S.selectionInactiveBackgroundTransparent),S.selectionForeground=w.selectionForeground?k(w.selectionForeground,f.NULL_COLOR):void 0,S.selectionForeground===f.NULL_COLOR&&(S.selectionForeground=void 0),f.color.isOpaque(S.selectionBackgroundTransparent)&&(S.selectionBackgroundTransparent=f.color.opacity(S.selectionBackgroundTransparent,.3)),f.color.isOpaque(S.selectionInactiveBackgroundTransparent)&&(S.selectionInactiveBackgroundTransparent=f.color.opacity(S.selectionInactiveBackgroundTransparent,.3)),S.ansi=o.DEFAULT_ANSI_COLORS.slice(),S.ansi[0]=k(w.black,o.DEFAULT_ANSI_COLORS[0]),S.ansi[1]=k(w.red,o.DEFAULT_ANSI_COLORS[1]),S.ansi[2]=k(w.green,o.DEFAULT_ANSI_COLORS[2]),S.ansi[3]=k(w.yellow,o.DEFAULT_ANSI_COLORS[3]),S.ansi[4]=k(w.blue,o.DEFAULT_ANSI_COLORS[4]),S.ansi[5]=k(w.magenta,o.DEFAULT_ANSI_COLORS[5]),S.ansi[6]=k(w.cyan,o.DEFAULT_ANSI_COLORS[6]),S.ansi[7]=k(w.white,o.DEFAULT_ANSI_COLORS[7]),S.ansi[8]=k(w.brightBlack,o.DEFAULT_ANSI_COLORS[8]),S.ansi[9]=k(w.brightRed,o.DEFAULT_ANSI_COLORS[9]),S.ansi[10]=k(w.brightGreen,o.DEFAULT_ANSI_COLORS[10]),S.ansi[11]=k(w.brightYellow,o.DEFAULT_ANSI_COLORS[11]),S.ansi[12]=k(w.brightBlue,o.DEFAULT_ANSI_COLORS[12]),S.ansi[13]=k(w.brightMagenta,o.DEFAULT_ANSI_COLORS[13]),S.ansi[14]=k(w.brightCyan,o.DEFAULT_ANSI_COLORS[14]),S.ansi[15]=k(w.brightWhite,o.DEFAULT_ANSI_COLORS[15]),w.extendedAnsi){const Q=Math.min(S.ansi.length-16,w.extendedAnsi.length);for(let I=0;I<Q;I++)S.ansi[I+16]=k(w.extendedAnsi[I],o.DEFAULT_ANSI_COLORS[I+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(w){this._restoreColor(w),this._onChangeColors.fire(this.colors)}_restoreColor(w){if(w!==void 0)switch(w){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[w]=this._restoreColors.ansi[w]}else for(let S=0;S<this._restoreColors.ansi.length;++S)this._colors.ansi[S]=this._restoreColors.ansi[S]}modifyColors(w){w(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(w,S){if(w!==void 0)try{return f.css.toColor(w)}catch{}return S}o.ThemeService=_=c([d(0,v.IOptionsService)],_)},6349:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CircularList=void 0;const c=l(8460),d=l(844);class u extends d.Disposable{constructor(g){super(),this._maxLength=g,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(g){if(this._maxLength===g)return;const b=new Array(g);for(let v=0;v<Math.min(g,this.length);v++)b[v]=this._array[this._getCyclicIndex(v)];this._array=b,this._maxLength=g,this._startIndex=0}get length(){return this._length}set length(g){if(g>this._length)for(let b=this._length;b<g;b++)this._array[b]=void 0;this._length=g}get(g){return this._array[this._getCyclicIndex(g)]}set(g,b){this._array[this._getCyclicIndex(g)]=b}push(g){this._array[this._getCyclicIndex(this._length)]=g,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(g,b,...v){if(b){for(let m=g;m<this._length-b;m++)this._array[this._getCyclicIndex(m)]=this._array[this._getCyclicIndex(m+b)];this._length-=b,this.onDeleteEmitter.fire({index:g,amount:b})}for(let m=this._length-1;m>=g;m--)this._array[this._getCyclicIndex(m+v.length)]=this._array[this._getCyclicIndex(m)];for(let m=0;m<v.length;m++)this._array[this._getCyclicIndex(g+m)]=v[m];if(v.length&&this.onInsertEmitter.fire({index:g,amount:v.length}),this._length+v.length>this._maxLength){const m=this._length+v.length-this._maxLength;this._startIndex+=m,this._length=this._maxLength,this.onTrimEmitter.fire(m)}else this._length+=v.length}trimStart(g){g>this._length&&(g=this._length),this._startIndex+=g,this._length-=g,this.onTrimEmitter.fire(g)}shiftElements(g,b,v){if(!(b<=0)){if(g<0||g>=this._length)throw new Error("start argument out of range");if(g+v<0)throw new Error("Cannot shift elements in list beyond index 0");if(v>0){for(let O=b-1;O>=0;O--)this.set(g+O+v,this.get(g+O));const m=g+b+v-this._length;if(m>0)for(this._length+=m;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let m=0;m<b;m++)this.set(g+m+v,this.get(g+m))}}_getCyclicIndex(g){return(this._startIndex+g)%this._maxLength}}o.CircularList=u},1439:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.clone=void 0,o.clone=function l(c,d=5){if(typeof c!="object")return c;const u=Array.isArray(c)?[]:{};for(const f in c)u[f]=d<=1?c[f]:c[f]&&l(c[f],d-1);return u}},8055:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.contrastRatio=o.toPaddedHex=o.rgba=o.rgb=o.css=o.color=o.channels=o.NULL_COLOR=void 0;let l=0,c=0,d=0,u=0;var f,g,b,v,m;function O(x){const y=x.toString(16);return y.length<2?"0"+y:y}function p(x,y){return x<y?(y+.05)/(x+.05):(x+.05)/(y+.05)}o.NULL_COLOR={css:"#00000000",rgba:0},(function(x){x.toCss=function(y,_,k,w){return w!==void 0?`#${O(y)}${O(_)}${O(k)}${O(w)}`:`#${O(y)}${O(_)}${O(k)}`},x.toRgba=function(y,_,k,w=255){return(y<<24|_<<16|k<<8|w)>>>0},x.toColor=function(y,_,k,w){return{css:x.toCss(y,_,k,w),rgba:x.toRgba(y,_,k,w)}}})(f||(o.channels=f={})),(function(x){function y(_,k){return u=Math.round(255*k),[l,c,d]=m.toChannels(_.rgba),{css:f.toCss(l,c,d,u),rgba:f.toRgba(l,c,d,u)}}x.blend=function(_,k){if(u=(255&k.rgba)/255,u===1)return{css:k.css,rgba:k.rgba};const w=k.rgba>>24&255,S=k.rgba>>16&255,Q=k.rgba>>8&255,I=_.rgba>>24&255,D=_.rgba>>16&255,$=_.rgba>>8&255;return l=I+Math.round((w-I)*u),c=D+Math.round((S-D)*u),d=$+Math.round((Q-$)*u),{css:f.toCss(l,c,d),rgba:f.toRgba(l,c,d)}},x.isOpaque=function(_){return(255&_.rgba)==255},x.ensureContrastRatio=function(_,k,w){const S=m.ensureContrastRatio(_.rgba,k.rgba,w);if(S)return f.toColor(S>>24&255,S>>16&255,S>>8&255)},x.opaque=function(_){const k=(255|_.rgba)>>>0;return[l,c,d]=m.toChannels(k),{css:f.toCss(l,c,d),rgba:k}},x.opacity=y,x.multiplyOpacity=function(_,k){return u=255&_.rgba,y(_,u*k/255)},x.toColorRGB=function(_){return[_.rgba>>24&255,_.rgba>>16&255,_.rgba>>8&255]}})(g||(o.color=g={})),(function(x){let y,_;try{const k=document.createElement("canvas");k.width=1,k.height=1;const w=k.getContext("2d",{willReadFrequently:!0});w&&(y=w,y.globalCompositeOperation="copy",_=y.createLinearGradient(0,0,1,1))}catch{}x.toColor=function(k){if(k.match(/#[\da-f]{3,8}/i))switch(k.length){case 4:return l=parseInt(k.slice(1,2).repeat(2),16),c=parseInt(k.slice(2,3).repeat(2),16),d=parseInt(k.slice(3,4).repeat(2),16),f.toColor(l,c,d);case 5:return l=parseInt(k.slice(1,2).repeat(2),16),c=parseInt(k.slice(2,3).repeat(2),16),d=parseInt(k.slice(3,4).repeat(2),16),u=parseInt(k.slice(4,5).repeat(2),16),f.toColor(l,c,d,u);case 7:return{css:k,rgba:(parseInt(k.slice(1),16)<<8|255)>>>0};case 9:return{css:k,rgba:parseInt(k.slice(1),16)>>>0}}const w=k.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(w)return l=parseInt(w[1]),c=parseInt(w[2]),d=parseInt(w[3]),u=Math.round(255*(w[5]===void 0?1:parseFloat(w[5]))),f.toColor(l,c,d,u);if(!y||!_)throw new Error("css.toColor: Unsupported css format");if(y.fillStyle=_,y.fillStyle=k,typeof y.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(y.fillRect(0,0,1,1),[l,c,d,u]=y.getImageData(0,0,1,1).data,u!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:f.toRgba(l,c,d,u),css:k}}})(b||(o.css=b={})),(function(x){function y(_,k,w){const S=_/255,Q=k/255,I=w/255;return .2126*(S<=.03928?S/12.92:Math.pow((S+.055)/1.055,2.4))+.7152*(Q<=.03928?Q/12.92:Math.pow((Q+.055)/1.055,2.4))+.0722*(I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4))}x.relativeLuminance=function(_){return y(_>>16&255,_>>8&255,255&_)},x.relativeLuminance2=y})(v||(o.rgb=v={})),(function(x){function y(k,w,S){const Q=k>>24&255,I=k>>16&255,D=k>>8&255;let $=w>>24&255,j=w>>16&255,B=w>>8&255,F=p(v.relativeLuminance2($,j,B),v.relativeLuminance2(Q,I,D));for(;F<S&&($>0||j>0||B>0);)$-=Math.max(0,Math.ceil(.1*$)),j-=Math.max(0,Math.ceil(.1*j)),B-=Math.max(0,Math.ceil(.1*B)),F=p(v.relativeLuminance2($,j,B),v.relativeLuminance2(Q,I,D));return($<<24|j<<16|B<<8|255)>>>0}function _(k,w,S){const Q=k>>24&255,I=k>>16&255,D=k>>8&255;let $=w>>24&255,j=w>>16&255,B=w>>8&255,F=p(v.relativeLuminance2($,j,B),v.relativeLuminance2(Q,I,D));for(;F<S&&($<255||j<255||B<255);)$=Math.min(255,$+Math.ceil(.1*(255-$))),j=Math.min(255,j+Math.ceil(.1*(255-j))),B=Math.min(255,B+Math.ceil(.1*(255-B))),F=p(v.relativeLuminance2($,j,B),v.relativeLuminance2(Q,I,D));return($<<24|j<<16|B<<8|255)>>>0}x.blend=function(k,w){if(u=(255&w)/255,u===1)return w;const S=w>>24&255,Q=w>>16&255,I=w>>8&255,D=k>>24&255,$=k>>16&255,j=k>>8&255;return l=D+Math.round((S-D)*u),c=$+Math.round((Q-$)*u),d=j+Math.round((I-j)*u),f.toRgba(l,c,d)},x.ensureContrastRatio=function(k,w,S){const Q=v.relativeLuminance(k>>8),I=v.relativeLuminance(w>>8);if(p(Q,I)<S){if(I<Q){const j=y(k,w,S),B=p(Q,v.relativeLuminance(j>>8));if(B<S){const F=_(k,w,S);return B>p(Q,v.relativeLuminance(F>>8))?j:F}return j}const D=_(k,w,S),$=p(Q,v.relativeLuminance(D>>8));if($<S){const j=y(k,w,S);return $>p(Q,v.relativeLuminance(j>>8))?D:j}return D}},x.reduceLuminance=y,x.increaseLuminance=_,x.toChannels=function(k){return[k>>24&255,k>>16&255,k>>8&255,255&k]}})(m||(o.rgba=m={})),o.toPaddedHex=O,o.contrastRatio=p},8969:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreTerminal=void 0;const c=l(844),d=l(2585),u=l(4348),f=l(7866),g=l(744),b=l(7302),v=l(6975),m=l(8460),O=l(1753),p=l(1480),x=l(7994),y=l(9282),_=l(5435),k=l(5981),w=l(2660);let S=!1;class Q extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new m.EventEmitter),this._onScroll.event((D=>{this._onScrollApi?.fire(D.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(D){for(const $ in D)this.optionsService.options[$]=D[$]}constructor(D){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new m.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new m.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new m.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new m.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new m.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new m.EventEmitter),this._instantiationService=new u.InstantiationService,this.optionsService=this.register(new b.OptionsService(D)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(g.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(f.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(v.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(O.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(p.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(x.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(w.OscLinkService),this._instantiationService.setService(d.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new _.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,m.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,m.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,m.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,m.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll(($=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll(($=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer((($,j)=>this._inputHandler.parse($,j)))),this.register((0,m.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(D,$){this._writeBuffer.write(D,$)}writeSync(D,$){this._logService.logLevel<=d.LogLevelEnum.WARN&&!S&&(this._logService.warn("writeSync is unreliable and will be removed soon."),S=!0),this._writeBuffer.writeSync(D,$)}input(D,$=!0){this.coreService.triggerDataEvent(D,$)}resize(D,$){isNaN(D)||isNaN($)||(D=Math.max(D,g.MINIMUM_COLS),$=Math.max($,g.MINIMUM_ROWS),this._bufferService.resize(D,$))}scroll(D,$=!1){this._bufferService.scroll(D,$)}scrollLines(D,$,j){this._bufferService.scrollLines(D,$,j)}scrollPages(D){this.scrollLines(D*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(D){const $=D-this._bufferService.buffer.ydisp;$!==0&&this.scrollLines($)}registerEscHandler(D,$){return this._inputHandler.registerEscHandler(D,$)}registerDcsHandler(D,$){return this._inputHandler.registerDcsHandler(D,$)}registerCsiHandler(D,$){return this._inputHandler.registerCsiHandler(D,$)}registerOscHandler(D,$){return this._inputHandler.registerOscHandler(D,$)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let D=!1;const $=this.optionsService.rawOptions.windowsPty;$&&$.buildNumber!==void 0&&$.buildNumber!==void 0?D=$.backend==="conpty"&&$.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(D=!0),D?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const D=[];D.push(this.onLineFeed(y.updateWindowsModeWrappedState.bind(null,this._bufferService))),D.push(this.registerCsiHandler({final:"H"},(()=>((0,y.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const $ of D)$.dispose()}))}}}o.CoreTerminal=Q},8460:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.runAndSubscribe=o.forwardEvent=o.EventEmitter=void 0,o.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.push(l),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===l)return void this._listeners.splice(c,1)}}})),this._event}fire(l,c){const d=[];for(let u=0;u<this._listeners.length;u++)d.push(this._listeners[u]);for(let u=0;u<d.length;u++)d[u].call(void 0,l,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},o.forwardEvent=function(l,c){return l((d=>c.fire(d)))},o.runAndSubscribe=function(l,c){return c(void 0),l((d=>c(d)))}},5435:function(a,o,l){var c=this&&this.__decorate||function(se,T,A,N){var z,U=arguments.length,ne=U<3?T:N===null?N=Object.getOwnPropertyDescriptor(T,A):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ne=Reflect.decorate(se,T,A,N);else for(var Se=se.length-1;Se>=0;Se--)(z=se[Se])&&(ne=(U<3?z(ne):U>3?z(T,A,ne):z(T,A))||ne);return U>3&&ne&&Object.defineProperty(T,A,ne),ne},d=this&&this.__param||function(se,T){return function(A,N){T(A,N,se)}};Object.defineProperty(o,"__esModule",{value:!0}),o.InputHandler=o.WindowsOptionsReportType=void 0;const u=l(2584),f=l(7116),g=l(2015),b=l(844),v=l(482),m=l(8437),O=l(8460),p=l(643),x=l(511),y=l(3734),_=l(2585),k=l(1480),w=l(6242),S=l(6351),Q=l(5941),I={"(":0,")":1,"*":2,"+":3,"-":1,".":2},D=131072;function $(se,T){if(se>24)return T.setWinLines||!1;switch(se){case 1:return!!T.restoreWin;case 2:return!!T.minimizeWin;case 3:return!!T.setWinPosition;case 4:return!!T.setWinSizePixels;case 5:return!!T.raiseWin;case 6:return!!T.lowerWin;case 7:return!!T.refreshWin;case 8:return!!T.setWinSizeChars;case 9:return!!T.maximizeWin;case 10:return!!T.fullscreenWin;case 11:return!!T.getWinState;case 13:return!!T.getWinPosition;case 14:return!!T.getWinSizePixels;case 15:return!!T.getScreenSizePixels;case 16:return!!T.getCellSizePixels;case 18:return!!T.getWinSizeChars;case 19:return!!T.getScreenSizeChars;case 20:return!!T.getIconTitle;case 21:return!!T.getWinTitle;case 22:return!!T.pushTitle;case 23:return!!T.popTitle;case 24:return!!T.setWinLines}return!1}var j;(function(se){se[se.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",se[se.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(j||(o.WindowsOptionsReportType=j={}));let B=0;class F extends b.Disposable{getAttrData(){return this._curAttrData}constructor(T,A,N,z,U,ne,Se,Pe,X=new g.EscapeSequenceParser){super(),this._bufferService=T,this._charsetService=A,this._coreService=N,this._logService=z,this._optionsService=U,this._oscLinkService=ne,this._coreMouseService=Se,this._unicodeService=Pe,this._parser=X,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new v.StringToUtf32,this._utf8Decoder=new v.Utf8ToUtf32,this._workCell=new x.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=m.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=m.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new O.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new O.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new O.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new O.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new O.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new O.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new O.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new O.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new O.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new O.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new O.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new O.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new O.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new V(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((M=>this._activeBuffer=M.activeBuffer))),this._parser.setCsiHandlerFallback(((M,K)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(M),params:K.toArray()})})),this._parser.setEscHandlerFallback((M=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(M)})})),this._parser.setExecuteHandlerFallback((M=>{this._logService.debug("Unknown EXECUTE code: ",{code:M})})),this._parser.setOscHandlerFallback(((M,K,ie)=>{this._logService.debug("Unknown OSC code: ",{identifier:M,action:K,data:ie})})),this._parser.setDcsHandlerFallback(((M,K,ie)=>{K==="HOOK"&&(ie=ie.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(M),action:K,payload:ie})})),this._parser.setPrintHandler(((M,K,ie)=>this.print(M,K,ie))),this._parser.registerCsiHandler({final:"@"},(M=>this.insertChars(M))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(M=>this.scrollLeft(M))),this._parser.registerCsiHandler({final:"A"},(M=>this.cursorUp(M))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(M=>this.scrollRight(M))),this._parser.registerCsiHandler({final:"B"},(M=>this.cursorDown(M))),this._parser.registerCsiHandler({final:"C"},(M=>this.cursorForward(M))),this._parser.registerCsiHandler({final:"D"},(M=>this.cursorBackward(M))),this._parser.registerCsiHandler({final:"E"},(M=>this.cursorNextLine(M))),this._parser.registerCsiHandler({final:"F"},(M=>this.cursorPrecedingLine(M))),this._parser.registerCsiHandler({final:"G"},(M=>this.cursorCharAbsolute(M))),this._parser.registerCsiHandler({final:"H"},(M=>this.cursorPosition(M))),this._parser.registerCsiHandler({final:"I"},(M=>this.cursorForwardTab(M))),this._parser.registerCsiHandler({final:"J"},(M=>this.eraseInDisplay(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(M=>this.eraseInDisplay(M,!0))),this._parser.registerCsiHandler({final:"K"},(M=>this.eraseInLine(M,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(M=>this.eraseInLine(M,!0))),this._parser.registerCsiHandler({final:"L"},(M=>this.insertLines(M))),this._parser.registerCsiHandler({final:"M"},(M=>this.deleteLines(M))),this._parser.registerCsiHandler({final:"P"},(M=>this.deleteChars(M))),this._parser.registerCsiHandler({final:"S"},(M=>this.scrollUp(M))),this._parser.registerCsiHandler({final:"T"},(M=>this.scrollDown(M))),this._parser.registerCsiHandler({final:"X"},(M=>this.eraseChars(M))),this._parser.registerCsiHandler({final:"Z"},(M=>this.cursorBackwardTab(M))),this._parser.registerCsiHandler({final:"`"},(M=>this.charPosAbsolute(M))),this._parser.registerCsiHandler({final:"a"},(M=>this.hPositionRelative(M))),this._parser.registerCsiHandler({final:"b"},(M=>this.repeatPrecedingCharacter(M))),this._parser.registerCsiHandler({final:"c"},(M=>this.sendDeviceAttributesPrimary(M))),this._parser.registerCsiHandler({prefix:">",final:"c"},(M=>this.sendDeviceAttributesSecondary(M))),this._parser.registerCsiHandler({final:"d"},(M=>this.linePosAbsolute(M))),this._parser.registerCsiHandler({final:"e"},(M=>this.vPositionRelative(M))),this._parser.registerCsiHandler({final:"f"},(M=>this.hVPosition(M))),this._parser.registerCsiHandler({final:"g"},(M=>this.tabClear(M))),this._parser.registerCsiHandler({final:"h"},(M=>this.setMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(M=>this.setModePrivate(M))),this._parser.registerCsiHandler({final:"l"},(M=>this.resetMode(M))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(M=>this.resetModePrivate(M))),this._parser.registerCsiHandler({final:"m"},(M=>this.charAttributes(M))),this._parser.registerCsiHandler({final:"n"},(M=>this.deviceStatus(M))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(M=>this.deviceStatusPrivate(M))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(M=>this.softReset(M))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(M=>this.setCursorStyle(M))),this._parser.registerCsiHandler({final:"r"},(M=>this.setScrollRegion(M))),this._parser.registerCsiHandler({final:"s"},(M=>this.saveCursor(M))),this._parser.registerCsiHandler({final:"t"},(M=>this.windowOptions(M))),this._parser.registerCsiHandler({final:"u"},(M=>this.restoreCursor(M))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(M=>this.insertColumns(M))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(M=>this.deleteColumns(M))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(M=>this.selectProtected(M))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(M=>this.requestMode(M,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(M=>this.requestMode(M,!1))),this._parser.setExecuteHandler(u.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(u.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(u.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(u.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(u.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(u.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(u.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(u.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(u.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(u.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(u.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(u.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new w.OscHandler((M=>(this.setTitle(M),this.setIconName(M),!0)))),this._parser.registerOscHandler(1,new w.OscHandler((M=>this.setIconName(M)))),this._parser.registerOscHandler(2,new w.OscHandler((M=>this.setTitle(M)))),this._parser.registerOscHandler(4,new w.OscHandler((M=>this.setOrReportIndexedColor(M)))),this._parser.registerOscHandler(8,new w.OscHandler((M=>this.setHyperlink(M)))),this._parser.registerOscHandler(10,new w.OscHandler((M=>this.setOrReportFgColor(M)))),this._parser.registerOscHandler(11,new w.OscHandler((M=>this.setOrReportBgColor(M)))),this._parser.registerOscHandler(12,new w.OscHandler((M=>this.setOrReportCursorColor(M)))),this._parser.registerOscHandler(104,new w.OscHandler((M=>this.restoreIndexedColor(M)))),this._parser.registerOscHandler(110,new w.OscHandler((M=>this.restoreFgColor(M)))),this._parser.registerOscHandler(111,new w.OscHandler((M=>this.restoreBgColor(M)))),this._parser.registerOscHandler(112,new w.OscHandler((M=>this.restoreCursorColor(M)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const M in f.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:M},(()=>this.selectCharset("("+M))),this._parser.registerEscHandler({intermediates:")",final:M},(()=>this.selectCharset(")"+M))),this._parser.registerEscHandler({intermediates:"*",final:M},(()=>this.selectCharset("*"+M))),this._parser.registerEscHandler({intermediates:"+",final:M},(()=>this.selectCharset("+"+M))),this._parser.registerEscHandler({intermediates:"-",final:M},(()=>this.selectCharset("-"+M))),this._parser.registerEscHandler({intermediates:".",final:M},(()=>this.selectCharset("."+M))),this._parser.registerEscHandler({intermediates:"/",final:M},(()=>this.selectCharset("/"+M)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((M=>(this._logService.error("Parsing error: ",M),M))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new S.DcsHandler(((M,K)=>this.requestStatusString(M,K))))}_preserveStack(T,A,N,z){this._parseStack.paused=!0,this._parseStack.cursorStartX=T,this._parseStack.cursorStartY=A,this._parseStack.decodedLength=N,this._parseStack.position=z}_logSlowResolvingAsync(T){this._logService.logLevel<=_.LogLevelEnum.WARN&&Promise.race([T,new Promise(((A,N)=>setTimeout((()=>N("#SLOW_TIMEOUT")),5e3)))]).catch((A=>{if(A!=="#SLOW_TIMEOUT")throw A;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(T,A){let N,z=this._activeBuffer.x,U=this._activeBuffer.y,ne=0;const Se=this._parseStack.paused;if(Se){if(N=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,A))return this._logSlowResolvingAsync(N),N;z=this._parseStack.cursorStartX,U=this._parseStack.cursorStartY,this._parseStack.paused=!1,T.length>D&&(ne=this._parseStack.position+D)}if(this._logService.logLevel<=_.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof T=="string"?` "${T}"`:` "${Array.prototype.map.call(T,(M=>String.fromCharCode(M))).join("")}"`),typeof T=="string"?T.split("").map((M=>M.charCodeAt(0))):T),this._parseBuffer.length<T.length&&this._parseBuffer.length<D&&(this._parseBuffer=new Uint32Array(Math.min(T.length,D))),Se||this._dirtyRowTracker.clearRange(),T.length>D)for(let M=ne;M<T.length;M+=D){const K=M+D<T.length?M+D:T.length,ie=typeof T=="string"?this._stringDecoder.decode(T.substring(M,K),this._parseBuffer):this._utf8Decoder.decode(T.subarray(M,K),this._parseBuffer);if(N=this._parser.parse(this._parseBuffer,ie))return this._preserveStack(z,U,ie,M),this._logSlowResolvingAsync(N),N}else if(!Se){const M=typeof T=="string"?this._stringDecoder.decode(T,this._parseBuffer):this._utf8Decoder.decode(T,this._parseBuffer);if(N=this._parser.parse(this._parseBuffer,M))return this._preserveStack(z,U,M,0),this._logSlowResolvingAsync(N),N}this._activeBuffer.x===z&&this._activeBuffer.y===U||this._onCursorMove.fire();const Pe=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),X=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);X<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(X,this._bufferService.rows-1),Math.min(Pe,this._bufferService.rows-1))}print(T,A,N){let z,U;const ne=this._charsetService.charset,Se=this._optionsService.rawOptions.screenReaderMode,Pe=this._bufferService.cols,X=this._coreService.decPrivateModes.wraparound,M=this._coreService.modes.insertMode,K=this._curAttrData;let ie=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&N-A>0&&ie.getWidth(this._activeBuffer.x-1)===2&&ie.setCellFromCodepoint(this._activeBuffer.x-1,0,1,K);let oe=this._parser.precedingJoinState;for(let G=A;G<N;++G){if(z=T[G],z<127&&ne){const Y=ne[String.fromCharCode(z)];Y&&(z=Y.charCodeAt(0))}const $e=this._unicodeService.charProperties(z,oe);U=k.UnicodeService.extractWidth($e);const Ie=k.UnicodeService.extractShouldJoin($e),We=Ie?k.UnicodeService.extractWidth(oe):0;if(oe=$e,Se&&this._onA11yChar.fire((0,v.stringFromCodePoint)(z)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+U-We>Pe){if(X){const Y=ie;let ee=this._activeBuffer.x-We;for(this._activeBuffer.x=We,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),ie=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),We>0&&ie instanceof m.BufferLine&&ie.copyCellsFrom(Y,ee,0,We,!1);ee<Pe;)Y.setCellFromCodepoint(ee++,0,1,K)}else if(this._activeBuffer.x=Pe-1,U===2)continue}if(Ie&&this._activeBuffer.x){const Y=ie.getWidth(this._activeBuffer.x-1)?1:2;ie.addCodepointToCell(this._activeBuffer.x-Y,z,U);for(let ee=U-We;--ee>=0;)ie.setCellFromCodepoint(this._activeBuffer.x++,0,0,K)}else if(M&&(ie.insertCells(this._activeBuffer.x,U-We,this._activeBuffer.getNullCell(K)),ie.getWidth(Pe-1)===2&&ie.setCellFromCodepoint(Pe-1,p.NULL_CELL_CODE,p.NULL_CELL_WIDTH,K)),ie.setCellFromCodepoint(this._activeBuffer.x++,z,U,K),U>0)for(;--U;)ie.setCellFromCodepoint(this._activeBuffer.x++,0,0,K)}this._parser.precedingJoinState=oe,this._activeBuffer.x<Pe&&N-A>0&&ie.getWidth(this._activeBuffer.x)===0&&!ie.hasContent(this._activeBuffer.x)&&ie.setCellFromCodepoint(this._activeBuffer.x,0,1,K),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(T,A){return T.final!=="t"||T.prefix||T.intermediates?this._parser.registerCsiHandler(T,A):this._parser.registerCsiHandler(T,(N=>!$(N.params[0],this._optionsService.rawOptions.windowOptions)||A(N)))}registerDcsHandler(T,A){return this._parser.registerDcsHandler(T,new S.DcsHandler(A))}registerEscHandler(T,A){return this._parser.registerEscHandler(T,A)}registerOscHandler(T,A){return this._parser.registerOscHandler(T,new w.OscHandler(A))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);T.hasWidth(this._activeBuffer.x)&&!T.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const T=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-T),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(T=this._bufferService.cols-1){this._activeBuffer.x=Math.min(T,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(T,A){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=T,this._activeBuffer.y=this._activeBuffer.scrollTop+A):(this._activeBuffer.x=T,this._activeBuffer.y=A),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(T,A){this._restrictCursor(),this._setCursor(this._activeBuffer.x+T,this._activeBuffer.y+A)}cursorUp(T){const A=this._activeBuffer.y-this._activeBuffer.scrollTop;return A>=0?this._moveCursor(0,-Math.min(A,T.params[0]||1)):this._moveCursor(0,-(T.params[0]||1)),!0}cursorDown(T){const A=this._activeBuffer.scrollBottom-this._activeBuffer.y;return A>=0?this._moveCursor(0,Math.min(A,T.params[0]||1)):this._moveCursor(0,T.params[0]||1),!0}cursorForward(T){return this._moveCursor(T.params[0]||1,0),!0}cursorBackward(T){return this._moveCursor(-(T.params[0]||1),0),!0}cursorNextLine(T){return this.cursorDown(T),this._activeBuffer.x=0,!0}cursorPrecedingLine(T){return this.cursorUp(T),this._activeBuffer.x=0,!0}cursorCharAbsolute(T){return this._setCursor((T.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(T){return this._setCursor(T.length>=2?(T.params[1]||1)-1:0,(T.params[0]||1)-1),!0}charPosAbsolute(T){return this._setCursor((T.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(T){return this._moveCursor(T.params[0]||1,0),!0}linePosAbsolute(T){return this._setCursor(this._activeBuffer.x,(T.params[0]||1)-1),!0}vPositionRelative(T){return this._moveCursor(0,T.params[0]||1),!0}hVPosition(T){return this.cursorPosition(T),!0}tabClear(T){const A=T.params[0];return A===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:A===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let A=T.params[0]||1;for(;A--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(T){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let A=T.params[0]||1;for(;A--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(T){const A=T.params[0];return A===1&&(this._curAttrData.bg|=536870912),A!==2&&A!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(T,A,N,z=!1,U=!1){const ne=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);ne.replaceCells(A,N,this._activeBuffer.getNullCell(this._eraseAttrData()),U),z&&(ne.isWrapped=!1)}_resetBufferLine(T,A=!1){const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);N&&(N.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),A),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+T),N.isWrapped=!1)}eraseInDisplay(T,A=!1){let N;switch(this._restrictCursor(this._bufferService.cols),T.params[0]){case 0:for(N=this._activeBuffer.y,this._dirtyRowTracker.markDirty(N),this._eraseInBufferLine(N++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,A);N<this._bufferService.rows;N++)this._resetBufferLine(N,A);this._dirtyRowTracker.markDirty(N);break;case 1:for(N=this._activeBuffer.y,this._dirtyRowTracker.markDirty(N),this._eraseInBufferLine(N,0,this._activeBuffer.x+1,!0,A),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(N+1).isWrapped=!1);N--;)this._resetBufferLine(N,A);this._dirtyRowTracker.markDirty(0);break;case 2:for(N=this._bufferService.rows,this._dirtyRowTracker.markDirty(N-1);N--;)this._resetBufferLine(N,A);this._dirtyRowTracker.markDirty(0);break;case 3:const z=this._activeBuffer.lines.length-this._bufferService.rows;z>0&&(this._activeBuffer.lines.trimStart(z),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-z,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-z,0),this._onScroll.fire(0))}return!0}eraseInLine(T,A=!1){switch(this._restrictCursor(this._bufferService.cols),T.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,A);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,A);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,A)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(T){this._restrictCursor();let A=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=this._activeBuffer.ybase+this._activeBuffer.y,z=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-z+1;for(;A--;)this._activeBuffer.lines.splice(U-1,1),this._activeBuffer.lines.splice(N,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(T){this._restrictCursor();let A=T.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=this._activeBuffer.ybase+this._activeBuffer.y;let z;for(z=this._bufferService.rows-1-this._activeBuffer.scrollBottom,z=this._bufferService.rows-1+this._activeBuffer.ybase-z;A--;)this._activeBuffer.lines.splice(N,1),this._activeBuffer.lines.splice(z,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(T){this._restrictCursor();const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return A&&(A.insertCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(T){this._restrictCursor();const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return A&&(A.deleteCells(this._activeBuffer.x,T.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(T){let A=T.params[0]||1;for(;A--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(T){let A=T.params[0]||1;for(;A--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(m.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=T.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const z=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);z.deleteCells(0,A,this._activeBuffer.getNullCell(this._eraseAttrData())),z.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=T.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const z=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);z.insertCells(0,A,this._activeBuffer.getNullCell(this._eraseAttrData())),z.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=T.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const z=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);z.insertCells(this._activeBuffer.x,A,this._activeBuffer.getNullCell(this._eraseAttrData())),z.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(T){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=T.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const z=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);z.deleteCells(this._activeBuffer.x,A,this._activeBuffer.getNullCell(this._eraseAttrData())),z.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(T){this._restrictCursor();const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return A&&(A.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(T.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(T){const A=this._parser.precedingJoinState;if(!A)return!0;const N=T.params[0]||1,z=k.UnicodeService.extractWidth(A),U=this._activeBuffer.x-z,ne=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(U),Se=new Uint32Array(ne.length*N);let Pe=0;for(let M=0;M<ne.length;){const K=ne.codePointAt(M)||0;Se[Pe++]=K,M+=K>65535?2:1}let X=Pe;for(let M=1;M<N;++M)Se.copyWithin(X,0,Pe),X+=Pe;return this.print(Se,0,X),!0}sendDeviceAttributesPrimary(T){return T.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(u.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(u.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(T){return T.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(u.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(u.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(T.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(u.C0.ESC+"[>83;40003;0c")),!0}_is(T){return(this._optionsService.rawOptions.termName+"").indexOf(T)===0}setMode(T){for(let A=0;A<T.length;A++)switch(T.params[A]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(T){for(let A=0;A<T.length;A++)switch(T.params[A]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),this._charsetService.setgCharset(1,f.DEFAULT_CHARSET),this._charsetService.setgCharset(2,f.DEFAULT_CHARSET),this._charsetService.setgCharset(3,f.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(T){for(let A=0;A<T.length;A++)switch(T.params[A]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(T){for(let A=0;A<T.length;A++)switch(T.params[A]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),T.params[A]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(T,A){const N=this._coreService.decPrivateModes,{activeProtocol:z,activeEncoding:U}=this._coreMouseService,ne=this._coreService,{buffers:Se,cols:Pe}=this._bufferService,{active:X,alt:M}=Se,K=this._optionsService.rawOptions,ie=Ie=>Ie?1:2,oe=T.params[0];return G=oe,$e=A?oe===2?4:oe===4?ie(ne.modes.insertMode):oe===12?3:oe===20?ie(K.convertEol):0:oe===1?ie(N.applicationCursorKeys):oe===3?K.windowOptions.setWinLines?Pe===80?2:Pe===132?1:0:0:oe===6?ie(N.origin):oe===7?ie(N.wraparound):oe===8?3:oe===9?ie(z==="X10"):oe===12?ie(K.cursorBlink):oe===25?ie(!ne.isCursorHidden):oe===45?ie(N.reverseWraparound):oe===66?ie(N.applicationKeypad):oe===67?4:oe===1e3?ie(z==="VT200"):oe===1002?ie(z==="DRAG"):oe===1003?ie(z==="ANY"):oe===1004?ie(N.sendFocus):oe===1005?4:oe===1006?ie(U==="SGR"):oe===1015?4:oe===1016?ie(U==="SGR_PIXELS"):oe===1048?1:oe===47||oe===1047||oe===1049?ie(X===M):oe===2004?ie(N.bracketedPasteMode):0,ne.triggerDataEvent(`${u.C0.ESC}[${A?"":"?"}${G};${$e}$y`),!0;var G,$e}_updateAttrColor(T,A,N,z,U){return A===2?(T|=50331648,T&=-16777216,T|=y.AttributeData.fromColorRGB([N,z,U])):A===5&&(T&=-50331904,T|=33554432|255&N),T}_extractColor(T,A,N){const z=[0,0,-1,0,0,0];let U=0,ne=0;do{if(z[ne+U]=T.params[A+ne],T.hasSubParams(A+ne)){const Se=T.getSubParams(A+ne);let Pe=0;do z[1]===5&&(U=1),z[ne+Pe+1+U]=Se[Pe];while(++Pe<Se.length&&Pe+ne+1+U<z.length);break}if(z[1]===5&&ne+U>=2||z[1]===2&&ne+U>=5)break;z[1]&&(U=1)}while(++ne+A<T.length&&ne+U<z.length);for(let Se=2;Se<z.length;++Se)z[Se]===-1&&(z[Se]=0);switch(z[0]){case 38:N.fg=this._updateAttrColor(N.fg,z[1],z[3],z[4],z[5]);break;case 48:N.bg=this._updateAttrColor(N.bg,z[1],z[3],z[4],z[5]);break;case 58:N.extended=N.extended.clone(),N.extended.underlineColor=this._updateAttrColor(N.extended.underlineColor,z[1],z[3],z[4],z[5])}return ne}_processUnderline(T,A){A.extended=A.extended.clone(),(!~T||T>5)&&(T=1),A.extended.underlineStyle=T,A.fg|=268435456,T===0&&(A.fg&=-268435457),A.updateExtended()}_processSGR0(T){T.fg=m.DEFAULT_ATTR_DATA.fg,T.bg=m.DEFAULT_ATTR_DATA.bg,T.extended=T.extended.clone(),T.extended.underlineStyle=0,T.extended.underlineColor&=-67108864,T.updateExtended()}charAttributes(T){if(T.length===1&&T.params[0]===0)return this._processSGR0(this._curAttrData),!0;const A=T.length;let N;const z=this._curAttrData;for(let U=0;U<A;U++)N=T.params[U],N>=30&&N<=37?(z.fg&=-50331904,z.fg|=16777216|N-30):N>=40&&N<=47?(z.bg&=-50331904,z.bg|=16777216|N-40):N>=90&&N<=97?(z.fg&=-50331904,z.fg|=16777224|N-90):N>=100&&N<=107?(z.bg&=-50331904,z.bg|=16777224|N-100):N===0?this._processSGR0(z):N===1?z.fg|=134217728:N===3?z.bg|=67108864:N===4?(z.fg|=268435456,this._processUnderline(T.hasSubParams(U)?T.getSubParams(U)[0]:1,z)):N===5?z.fg|=536870912:N===7?z.fg|=67108864:N===8?z.fg|=1073741824:N===9?z.fg|=2147483648:N===2?z.bg|=134217728:N===21?this._processUnderline(2,z):N===22?(z.fg&=-134217729,z.bg&=-134217729):N===23?z.bg&=-67108865:N===24?(z.fg&=-268435457,this._processUnderline(0,z)):N===25?z.fg&=-536870913:N===27?z.fg&=-67108865:N===28?z.fg&=-1073741825:N===29?z.fg&=2147483647:N===39?(z.fg&=-67108864,z.fg|=16777215&m.DEFAULT_ATTR_DATA.fg):N===49?(z.bg&=-67108864,z.bg|=16777215&m.DEFAULT_ATTR_DATA.bg):N===38||N===48||N===58?U+=this._extractColor(T,U,z):N===53?z.bg|=1073741824:N===55?z.bg&=-1073741825:N===59?(z.extended=z.extended.clone(),z.extended.underlineColor=-1,z.updateExtended()):N===100?(z.fg&=-67108864,z.fg|=16777215&m.DEFAULT_ATTR_DATA.fg,z.bg&=-67108864,z.bg|=16777215&m.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",N);return!0}deviceStatus(T){switch(T.params[0]){case 5:this._coreService.triggerDataEvent(`${u.C0.ESC}[0n`);break;case 6:const A=this._activeBuffer.y+1,N=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[${A};${N}R`)}return!0}deviceStatusPrivate(T){if(T.params[0]===6){const A=this._activeBuffer.y+1,N=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[?${A};${N}R`)}return!0}softReset(T){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=m.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(T){const A=T.params[0]||1;switch(A){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const N=A%2==1;return this._optionsService.options.cursorBlink=N,!0}setScrollRegion(T){const A=T.params[0]||1;let N;return(T.length<2||(N=T.params[1])>this._bufferService.rows||N===0)&&(N=this._bufferService.rows),N>A&&(this._activeBuffer.scrollTop=A-1,this._activeBuffer.scrollBottom=N-1,this._setCursor(0,0)),!0}windowOptions(T){if(!$(T.params[0],this._optionsService.rawOptions.windowOptions))return!0;const A=T.length>1?T.params[1]:0;switch(T.params[0]){case 14:A!==2&&this._onRequestWindowsOptionsReport.fire(j.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(j.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${u.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:A!==0&&A!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),A!==0&&A!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:A!==0&&A!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),A!==0&&A!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(T){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(T){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(T){return this._windowTitle=T,this._onTitleChange.fire(T),!0}setIconName(T){return this._iconName=T,!0}setOrReportIndexedColor(T){const A=[],N=T.split(";");for(;N.length>1;){const z=N.shift(),U=N.shift();if(/^\d+$/.exec(z)){const ne=parseInt(z);if(Z(ne))if(U==="?")A.push({type:0,index:ne});else{const Se=(0,Q.parseColor)(U);Se&&A.push({type:1,index:ne,color:Se})}}}return A.length&&this._onColor.fire(A),!0}setHyperlink(T){const A=T.split(";");return!(A.length<2)&&(A[1]?this._createHyperlink(A[0],A[1]):!A[0]&&this._finishHyperlink())}_createHyperlink(T,A){this._getCurrentLinkId()&&this._finishHyperlink();const N=T.split(":");let z;const U=N.findIndex((ne=>ne.startsWith("id=")));return U!==-1&&(z=N[U].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:z,uri:A}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(T,A){const N=T.split(";");for(let z=0;z<N.length&&!(A>=this._specialColors.length);++z,++A)if(N[z]==="?")this._onColor.fire([{type:0,index:this._specialColors[A]}]);else{const U=(0,Q.parseColor)(N[z]);U&&this._onColor.fire([{type:1,index:this._specialColors[A],color:U}])}return!0}setOrReportFgColor(T){return this._setOrReportSpecialColor(T,0)}setOrReportBgColor(T){return this._setOrReportSpecialColor(T,1)}setOrReportCursorColor(T){return this._setOrReportSpecialColor(T,2)}restoreIndexedColor(T){if(!T)return this._onColor.fire([{type:2}]),!0;const A=[],N=T.split(";");for(let z=0;z<N.length;++z)if(/^\d+$/.exec(N[z])){const U=parseInt(N[z]);Z(U)&&A.push({type:2,index:U})}return A.length&&this._onColor.fire(A),!0}restoreFgColor(T){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(T){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(T){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,f.DEFAULT_CHARSET),!0}selectCharset(T){return T.length!==2?(this.selectDefaultCharset(),!0):(T[0]==="/"||this._charsetService.setgCharset(I[T[0]],f.CHARSETS[T[1]]||f.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const T=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,T,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=m.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=m.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(T){return this._charsetService.setgLevel(T),!0}screenAlignmentPattern(){const T=new x.CellData;T.content=4194373,T.fg=this._curAttrData.fg,T.bg=this._curAttrData.bg,this._setCursor(0,0);for(let A=0;A<this._bufferService.rows;++A){const N=this._activeBuffer.ybase+this._activeBuffer.y+A,z=this._activeBuffer.lines.get(N);z&&(z.fill(T),z.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(T,A){const N=this._bufferService.buffer,z=this._optionsService.rawOptions;return(U=>(this._coreService.triggerDataEvent(`${u.C0.ESC}${U}${u.C0.ESC}\\`),!0))(T==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:T==='"p'?'P1$r61;1"p':T==="r"?`P1$r${N.scrollTop+1};${N.scrollBottom+1}r`:T==="m"?"P1$r0m":T===" q"?`P1$r${{block:2,underline:4,bar:6}[z.cursorStyle]-(z.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(T,A){this._dirtyRowTracker.markRangeDirty(T,A)}}o.InputHandler=F;let V=class{constructor(se){this._bufferService=se,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(se){se<this.start?this.start=se:se>this.end&&(this.end=se)}markRangeDirty(se,T){se>T&&(B=se,se=T,T=B),se<this.start&&(this.start=se),T>this.end&&(this.end=T)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Z(se){return 0<=se&&se<256}V=c([d(0,_.IBufferService)],V)},844:(a,o)=>{function l(c){for(const d of c)d.dispose();c.length=0}Object.defineProperty(o,"__esModule",{value:!0}),o.getDisposeArrayDisposable=o.disposeArray=o.toDisposable=o.MutableDisposable=o.Disposable=void 0,o.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const d=this._disposables.indexOf(c);d!==-1&&this._disposables.splice(d,1)}},o.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){this._isDisposed||c===this._value||(this._value?.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},o.toDisposable=function(c){return{dispose:c}},o.disposeArray=l,o.getDisposeArrayDisposable=function(c){return{dispose:()=>l(c)}}},1505:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.FourKeyMap=o.TwoKeyMap=void 0;class l{constructor(){this._data={}}set(d,u,f){this._data[d]||(this._data[d]={}),this._data[d][u]=f}get(d,u){return this._data[d]?this._data[d][u]:void 0}clear(){this._data={}}}o.TwoKeyMap=l,o.FourKeyMap=class{constructor(){this._data=new l}set(c,d,u,f,g){this._data.get(c,d)||this._data.set(c,d,new l),this._data.get(c,d).set(u,f,g)}get(c,d,u,f){return this._data.get(c,d)?.get(u,f)}clear(){this._data.clear()}}},6114:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.isChromeOS=o.isLinux=o.isWindows=o.isIphone=o.isIpad=o.isMac=o.getSafariVersion=o.isSafari=o.isLegacyEdge=o.isFirefox=o.isNode=void 0,o.isNode=typeof process<"u"&&"title"in process;const l=o.isNode?"node":navigator.userAgent,c=o.isNode?"node":navigator.platform;o.isFirefox=l.includes("Firefox"),o.isLegacyEdge=l.includes("Edge"),o.isSafari=/^((?!chrome|android).)*safari/i.test(l),o.getSafariVersion=function(){if(!o.isSafari)return 0;const d=l.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},o.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),o.isIpad=c==="iPad",o.isIphone=c==="iPhone",o.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),o.isLinux=c.indexOf("Linux")>=0,o.isChromeOS=/\bCrOS\b/.test(l)},6106:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.SortedList=void 0;let l=0;o.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(l=this._search(this._getKey(c)),this._array.splice(l,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const d=this._getKey(c);if(d===void 0||(l=this._search(d),l===-1)||this._getKey(this._array[l])!==d)return!1;do if(this._array[l]===c)return this._array.splice(l,1),!0;while(++l<this._array.length&&this._getKey(this._array[l])===d);return!1}*getKeyIterator(c){if(this._array.length!==0&&(l=this._search(c),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===c))do yield this._array[l];while(++l<this._array.length&&this._getKey(this._array[l])===c)}forEachByKey(c,d){if(this._array.length!==0&&(l=this._search(c),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===c))do d(this._array[l]);while(++l<this._array.length&&this._getKey(this._array[l])===c)}values(){return[...this._array].values()}_search(c){let d=0,u=this._array.length-1;for(;u>=d;){let f=d+u>>1;const g=this._getKey(this._array[f]);if(g>c)u=f-1;else{if(!(g<c)){for(;f>0&&this._getKey(this._array[f-1])===c;)f--;return f}d=f+1}}return d}}},7226:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DebouncedIdleTask=o.IdleTaskQueue=o.PriorityTaskQueue=void 0;const c=l(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(g){this._tasks.push(g),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(g){this._idleCallback=void 0;let b=0,v=0,m=g.timeRemaining(),O=0;for(;this._i<this._tasks.length;){if(b=Date.now(),this._tasks[this._i]()||this._i++,b=Math.max(1,Date.now()-b),v=Math.max(b,v),O=g.timeRemaining(),1.5*v>O)return m-b<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(m-b))}ms`),void this._start();m=O}this.clear()}}class u extends d{_requestCallback(g){return setTimeout((()=>g(this._createDeadline(16))))}_cancelCallback(g){clearTimeout(g)}_createDeadline(g){const b=Date.now()+g;return{timeRemaining:()=>Math.max(0,b-Date.now())}}}o.PriorityTaskQueue=u,o.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(f){return requestIdleCallback(f)}_cancelCallback(f){cancelIdleCallback(f)}}:u,o.DebouncedIdleTask=class{constructor(){this._queue=new o.IdleTaskQueue}set(f){this._queue.clear(),this._queue.enqueue(f)}flush(){this._queue.flush()}}},9282:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.updateWindowsModeWrappedState=void 0;const c=l(643);o.updateWindowsModeWrappedState=function(d){const u=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),f=u?.get(d.cols-1),g=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);g&&f&&(g.isWrapped=f[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&f[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ExtendedAttrs=o.AttributeData=void 0;class l{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(u){return[u>>>16&255,u>>>8&255,255&u]}static fromColorRGB(u){return(255&u[0])<<16|(255&u[1])<<8|255&u[2]}clone(){const u=new l;return u.fg=this.fg,u.bg=this.bg,u.extended=this.extended.clone(),u}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}o.AttributeData=l;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(u){this._ext=u}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(u){this._ext&=-469762049,this._ext|=u<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(u){this._ext&=-67108864,this._ext|=67108863&u}get urlId(){return this._urlId}set urlId(u){this._urlId=u}get underlineVariantOffset(){const u=(3758096384&this._ext)>>29;return u<0?4294967288^u:u}set underlineVariantOffset(u){this._ext&=536870911,this._ext|=u<<29&3758096384}constructor(u=0,f=0){this._ext=0,this._urlId=0,this._ext=u,this._urlId=f}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}o.ExtendedAttrs=c},9092:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Buffer=o.MAX_BUFFER_SIZE=void 0;const c=l(6349),d=l(7226),u=l(3734),f=l(8437),g=l(4634),b=l(511),v=l(643),m=l(4863),O=l(7116);o.MAX_BUFFER_SIZE=4294967295,o.Buffer=class{constructor(p,x,y){this._hasScrollback=p,this._optionsService=x,this._bufferService=y,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=f.DEFAULT_ATTR_DATA.clone(),this.savedCharset=O.DEFAULT_CHARSET,this.markers=[],this._nullCell=b.CellData.fromCharData([0,v.NULL_CELL_CHAR,v.NULL_CELL_WIDTH,v.NULL_CELL_CODE]),this._whitespaceCell=b.CellData.fromCharData([0,v.WHITESPACE_CELL_CHAR,v.WHITESPACE_CELL_WIDTH,v.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(p){return p?(this._nullCell.fg=p.fg,this._nullCell.bg=p.bg,this._nullCell.extended=p.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new u.ExtendedAttrs),this._nullCell}getWhitespaceCell(p){return p?(this._whitespaceCell.fg=p.fg,this._whitespaceCell.bg=p.bg,this._whitespaceCell.extended=p.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new u.ExtendedAttrs),this._whitespaceCell}getBlankLine(p,x){return new f.BufferLine(this._bufferService.cols,this.getNullCell(p),x)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const p=this.ybase+this.y-this.ydisp;return p>=0&&p<this._rows}_getCorrectBufferLength(p){if(!this._hasScrollback)return p;const x=p+this._optionsService.rawOptions.scrollback;return x>o.MAX_BUFFER_SIZE?o.MAX_BUFFER_SIZE:x}fillViewportRows(p){if(this.lines.length===0){p===void 0&&(p=f.DEFAULT_ATTR_DATA);let x=this._rows;for(;x--;)this.lines.push(this.getBlankLine(p))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(p,x){const y=this.getNullCell(f.DEFAULT_ATTR_DATA);let _=0;const k=this._getCorrectBufferLength(x);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<p)for(let S=0;S<this.lines.length;S++)_+=+this.lines.get(S).resize(p,y);let w=0;if(this._rows<x)for(let S=this._rows;S<x;S++)this.lines.length<x+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new f.BufferLine(p,y)):this.ybase>0&&this.lines.length<=this.ybase+this.y+w+1?(this.ybase--,w++,this.ydisp>0&&this.ydisp--):this.lines.push(new f.BufferLine(p,y)));else for(let S=this._rows;S>x;S--)this.lines.length>x+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const S=this.lines.length-k;S>0&&(this.lines.trimStart(S),this.ybase=Math.max(this.ybase-S,0),this.ydisp=Math.max(this.ydisp-S,0),this.savedY=Math.max(this.savedY-S,0)),this.lines.maxLength=k}this.x=Math.min(this.x,p-1),this.y=Math.min(this.y,x-1),w&&(this.y+=w),this.savedX=Math.min(this.savedX,p-1),this.scrollTop=0}if(this.scrollBottom=x-1,this._isReflowEnabled&&(this._reflow(p,x),this._cols>p))for(let w=0;w<this.lines.length;w++)_+=+this.lines.get(w).resize(p,y);this._cols=p,this._rows=x,this._memoryCleanupQueue.clear(),_>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let p=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,p=!1);let x=0;for(;this._memoryCleanupPosition<this.lines.length;)if(x+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),x>100)return!0;return p}get _isReflowEnabled(){const p=this._optionsService.rawOptions.windowsPty;return p&&p.buildNumber?this._hasScrollback&&p.backend==="conpty"&&p.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(p,x){this._cols!==p&&(p>this._cols?this._reflowLarger(p,x):this._reflowSmaller(p,x))}_reflowLarger(p,x){const y=(0,g.reflowLargerGetLinesToRemove)(this.lines,this._cols,p,this.ybase+this.y,this.getNullCell(f.DEFAULT_ATTR_DATA));if(y.length>0){const _=(0,g.reflowLargerCreateNewLayout)(this.lines,y);(0,g.reflowLargerApplyNewLayout)(this.lines,_.layout),this._reflowLargerAdjustViewport(p,x,_.countRemoved)}}_reflowLargerAdjustViewport(p,x,y){const _=this.getNullCell(f.DEFAULT_ATTR_DATA);let k=y;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<x&&this.lines.push(new f.BufferLine(p,_))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-y,0)}_reflowSmaller(p,x){const y=this.getNullCell(f.DEFAULT_ATTR_DATA),_=[];let k=0;for(let w=this.lines.length-1;w>=0;w--){let S=this.lines.get(w);if(!S||!S.isWrapped&&S.getTrimmedLength()<=p)continue;const Q=[S];for(;S.isWrapped&&w>0;)S=this.lines.get(--w),Q.unshift(S);const I=this.ybase+this.y;if(I>=w&&I<w+Q.length)continue;const D=Q[Q.length-1].getTrimmedLength(),$=(0,g.reflowSmallerGetNewLineLengths)(Q,this._cols,p),j=$.length-Q.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+j):Math.max(0,this.lines.length-this.lines.maxLength+j);const F=[];for(let N=0;N<j;N++){const z=this.getBlankLine(f.DEFAULT_ATTR_DATA,!0);F.push(z)}F.length>0&&(_.push({start:w+Q.length+k,newLines:F}),k+=F.length),Q.push(...F);let V=$.length-1,Z=$[V];Z===0&&(V--,Z=$[V]);let se=Q.length-j-1,T=D;for(;se>=0;){const N=Math.min(T,Z);if(Q[V]===void 0)break;if(Q[V].copyCellsFrom(Q[se],T-N,Z-N,N,!0),Z-=N,Z===0&&(V--,Z=$[V]),T-=N,T===0){se--;const z=Math.max(se,0);T=(0,g.getWrappedLineTrimmedLength)(Q,z,this._cols)}}for(let N=0;N<Q.length;N++)$[N]<p&&Q[N].setCell($[N],y);let A=j-B;for(;A-- >0;)this.ybase===0?this.y<x-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-x&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+j,this.ybase+x-1)}if(_.length>0){const w=[],S=[];for(let V=0;V<this.lines.length;V++)S.push(this.lines.get(V));const Q=this.lines.length;let I=Q-1,D=0,$=_[D];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let j=0;for(let V=Math.min(this.lines.maxLength-1,Q+k-1);V>=0;V--)if($&&$.start>I+j){for(let Z=$.newLines.length-1;Z>=0;Z--)this.lines.set(V--,$.newLines[Z]);V++,w.push({index:I+1,amount:$.newLines.length}),j+=$.newLines.length,$=_[++D]}else this.lines.set(V,S[I--]);let B=0;for(let V=w.length-1;V>=0;V--)w[V].index+=B,this.lines.onInsertEmitter.fire(w[V]),B+=w[V].amount;const F=Math.max(0,Q+k-this.lines.maxLength);F>0&&this.lines.onTrimEmitter.fire(F)}}translateBufferLineToString(p,x,y=0,_){const k=this.lines.get(p);return k?k.translateToString(x,y,_):""}getWrappedRangeForLine(p){let x=p,y=p;for(;x>0&&this.lines.get(x).isWrapped;)x--;for(;y+1<this.lines.length&&this.lines.get(y+1).isWrapped;)y++;return{first:x,last:y}}setupTabStops(p){for(p!=null?this.tabs[p]||(p=this.prevStop(p)):(this.tabs={},p=0);p<this._cols;p+=this._optionsService.rawOptions.tabStopWidth)this.tabs[p]=!0}prevStop(p){for(p==null&&(p=this.x);!this.tabs[--p]&&p>0;);return p>=this._cols?this._cols-1:p<0?0:p}nextStop(p){for(p==null&&(p=this.x);!this.tabs[++p]&&p<this._cols;);return p>=this._cols?this._cols-1:p<0?0:p}clearMarkers(p){this._isClearing=!0;for(let x=0;x<this.markers.length;x++)this.markers[x].line===p&&(this.markers[x].dispose(),this.markers.splice(x--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let p=0;p<this.markers.length;p++)this.markers[p].dispose(),this.markers.splice(p--,1);this._isClearing=!1}addMarker(p){const x=new m.Marker(p);return this.markers.push(x),x.register(this.lines.onTrim((y=>{x.line-=y,x.line<0&&x.dispose()}))),x.register(this.lines.onInsert((y=>{x.line>=y.index&&(x.line+=y.amount)}))),x.register(this.lines.onDelete((y=>{x.line>=y.index&&x.line<y.index+y.amount&&x.dispose(),x.line>y.index&&(x.line-=y.amount)}))),x.register(x.onDispose((()=>this._removeMarker(x)))),x}_removeMarker(p){this._isClearing||this.markers.splice(this.markers.indexOf(p),1)}}},8437:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLine=o.DEFAULT_ATTR_DATA=void 0;const c=l(3734),d=l(511),u=l(643),f=l(482);o.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let g=0;class b{constructor(m,O,p=!1){this.isWrapped=p,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*m);const x=O||d.CellData.fromCharData([0,u.NULL_CELL_CHAR,u.NULL_CELL_WIDTH,u.NULL_CELL_CODE]);for(let y=0;y<m;++y)this.setCell(y,x);this.length=m}get(m){const O=this._data[3*m+0],p=2097151&O;return[this._data[3*m+1],2097152&O?this._combined[m]:p?(0,f.stringFromCodePoint)(p):"",O>>22,2097152&O?this._combined[m].charCodeAt(this._combined[m].length-1):p]}set(m,O){this._data[3*m+1]=O[u.CHAR_DATA_ATTR_INDEX],O[u.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[m]=O[1],this._data[3*m+0]=2097152|m|O[u.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*m+0]=O[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|O[u.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(m){return this._data[3*m+0]>>22}hasWidth(m){return 12582912&this._data[3*m+0]}getFg(m){return this._data[3*m+1]}getBg(m){return this._data[3*m+2]}hasContent(m){return 4194303&this._data[3*m+0]}getCodePoint(m){const O=this._data[3*m+0];return 2097152&O?this._combined[m].charCodeAt(this._combined[m].length-1):2097151&O}isCombined(m){return 2097152&this._data[3*m+0]}getString(m){const O=this._data[3*m+0];return 2097152&O?this._combined[m]:2097151&O?(0,f.stringFromCodePoint)(2097151&O):""}isProtected(m){return 536870912&this._data[3*m+2]}loadCell(m,O){return g=3*m,O.content=this._data[g+0],O.fg=this._data[g+1],O.bg=this._data[g+2],2097152&O.content&&(O.combinedData=this._combined[m]),268435456&O.bg&&(O.extended=this._extendedAttrs[m]),O}setCell(m,O){2097152&O.content&&(this._combined[m]=O.combinedData),268435456&O.bg&&(this._extendedAttrs[m]=O.extended),this._data[3*m+0]=O.content,this._data[3*m+1]=O.fg,this._data[3*m+2]=O.bg}setCellFromCodepoint(m,O,p,x){268435456&x.bg&&(this._extendedAttrs[m]=x.extended),this._data[3*m+0]=O|p<<22,this._data[3*m+1]=x.fg,this._data[3*m+2]=x.bg}addCodepointToCell(m,O,p){let x=this._data[3*m+0];2097152&x?this._combined[m]+=(0,f.stringFromCodePoint)(O):2097151&x?(this._combined[m]=(0,f.stringFromCodePoint)(2097151&x)+(0,f.stringFromCodePoint)(O),x&=-2097152,x|=2097152):x=O|4194304,p&&(x&=-12582913,x|=p<<22),this._data[3*m+0]=x}insertCells(m,O,p){if((m%=this.length)&&this.getWidth(m-1)===2&&this.setCellFromCodepoint(m-1,0,1,p),O<this.length-m){const x=new d.CellData;for(let y=this.length-m-O-1;y>=0;--y)this.setCell(m+O+y,this.loadCell(m+y,x));for(let y=0;y<O;++y)this.setCell(m+y,p)}else for(let x=m;x<this.length;++x)this.setCell(x,p);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,p)}deleteCells(m,O,p){if(m%=this.length,O<this.length-m){const x=new d.CellData;for(let y=0;y<this.length-m-O;++y)this.setCell(m+y,this.loadCell(m+O+y,x));for(let y=this.length-O;y<this.length;++y)this.setCell(y,p)}else for(let x=m;x<this.length;++x)this.setCell(x,p);m&&this.getWidth(m-1)===2&&this.setCellFromCodepoint(m-1,0,1,p),this.getWidth(m)!==0||this.hasContent(m)||this.setCellFromCodepoint(m,0,1,p)}replaceCells(m,O,p,x=!1){if(x)for(m&&this.getWidth(m-1)===2&&!this.isProtected(m-1)&&this.setCellFromCodepoint(m-1,0,1,p),O<this.length&&this.getWidth(O-1)===2&&!this.isProtected(O)&&this.setCellFromCodepoint(O,0,1,p);m<O&&m<this.length;)this.isProtected(m)||this.setCell(m,p),m++;else for(m&&this.getWidth(m-1)===2&&this.setCellFromCodepoint(m-1,0,1,p),O<this.length&&this.getWidth(O-1)===2&&this.setCellFromCodepoint(O,0,1,p);m<O&&m<this.length;)this.setCell(m++,p)}resize(m,O){if(m===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const p=3*m;if(m>this.length){if(this._data.buffer.byteLength>=4*p)this._data=new Uint32Array(this._data.buffer,0,p);else{const x=new Uint32Array(p);x.set(this._data),this._data=x}for(let x=this.length;x<m;++x)this.setCell(x,O)}else{this._data=this._data.subarray(0,p);const x=Object.keys(this._combined);for(let _=0;_<x.length;_++){const k=parseInt(x[_],10);k>=m&&delete this._combined[k]}const y=Object.keys(this._extendedAttrs);for(let _=0;_<y.length;_++){const k=parseInt(y[_],10);k>=m&&delete this._extendedAttrs[k]}}return this.length=m,4*p*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const m=new Uint32Array(this._data.length);return m.set(this._data),this._data=m,1}return 0}fill(m,O=!1){if(O)for(let p=0;p<this.length;++p)this.isProtected(p)||this.setCell(p,m);else{this._combined={},this._extendedAttrs={};for(let p=0;p<this.length;++p)this.setCell(p,m)}}copyFrom(m){this.length!==m.length?this._data=new Uint32Array(m._data):this._data.set(m._data),this.length=m.length,this._combined={};for(const O in m._combined)this._combined[O]=m._combined[O];this._extendedAttrs={};for(const O in m._extendedAttrs)this._extendedAttrs[O]=m._extendedAttrs[O];this.isWrapped=m.isWrapped}clone(){const m=new b(0);m._data=new Uint32Array(this._data),m.length=this.length;for(const O in this._combined)m._combined[O]=this._combined[O];for(const O in this._extendedAttrs)m._extendedAttrs[O]=this._extendedAttrs[O];return m.isWrapped=this.isWrapped,m}getTrimmedLength(){for(let m=this.length-1;m>=0;--m)if(4194303&this._data[3*m+0])return m+(this._data[3*m+0]>>22);return 0}getNoBgTrimmedLength(){for(let m=this.length-1;m>=0;--m)if(4194303&this._data[3*m+0]||50331648&this._data[3*m+2])return m+(this._data[3*m+0]>>22);return 0}copyCellsFrom(m,O,p,x,y){const _=m._data;if(y)for(let w=x-1;w>=0;w--){for(let S=0;S<3;S++)this._data[3*(p+w)+S]=_[3*(O+w)+S];268435456&_[3*(O+w)+2]&&(this._extendedAttrs[p+w]=m._extendedAttrs[O+w])}else for(let w=0;w<x;w++){for(let S=0;S<3;S++)this._data[3*(p+w)+S]=_[3*(O+w)+S];268435456&_[3*(O+w)+2]&&(this._extendedAttrs[p+w]=m._extendedAttrs[O+w])}const k=Object.keys(m._combined);for(let w=0;w<k.length;w++){const S=parseInt(k[w],10);S>=O&&(this._combined[S-O+p]=m._combined[S])}}translateToString(m,O,p,x){O=O??0,p=p??this.length,m&&(p=Math.min(p,this.getTrimmedLength())),x&&(x.length=0);let y="";for(;O<p;){const _=this._data[3*O+0],k=2097151&_,w=2097152&_?this._combined[O]:k?(0,f.stringFromCodePoint)(k):u.WHITESPACE_CELL_CHAR;if(y+=w,x)for(let S=0;S<w.length;++S)x.push(O);O+=_>>22||1}return x&&x.push(O),y}}o.BufferLine=b},4841:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.getRangeLength=void 0,o.getRangeLength=function(l,c){if(l.start.y>l.end.y)throw new Error(`Buffer range end (${l.end.x}, ${l.end.y}) cannot be before start (${l.start.x}, ${l.start.y})`);return c*(l.end.y-l.start.y)+(l.end.x-l.start.x+1)}},4634:(a,o)=>{function l(c,d,u){if(d===c.length-1)return c[d].getTrimmedLength();const f=!c[d].hasContent(u-1)&&c[d].getWidth(u-1)===1,g=c[d+1].getWidth(0)===2;return f&&g?u-1:u}Object.defineProperty(o,"__esModule",{value:!0}),o.getWrappedLineTrimmedLength=o.reflowSmallerGetNewLineLengths=o.reflowLargerApplyNewLayout=o.reflowLargerCreateNewLayout=o.reflowLargerGetLinesToRemove=void 0,o.reflowLargerGetLinesToRemove=function(c,d,u,f,g){const b=[];for(let v=0;v<c.length-1;v++){let m=v,O=c.get(++m);if(!O.isWrapped)continue;const p=[c.get(v)];for(;m<c.length&&O.isWrapped;)p.push(O),O=c.get(++m);if(f>=v&&f<m){v+=p.length-1;continue}let x=0,y=l(p,x,d),_=1,k=0;for(;_<p.length;){const S=l(p,_,d),Q=S-k,I=u-y,D=Math.min(Q,I);p[x].copyCellsFrom(p[_],k,y,D,!1),y+=D,y===u&&(x++,y=0),k+=D,k===S&&(_++,k=0),y===0&&x!==0&&p[x-1].getWidth(u-1)===2&&(p[x].copyCellsFrom(p[x-1],u-1,y++,1,!1),p[x-1].setCell(u-1,g))}p[x].replaceCells(y,u,g);let w=0;for(let S=p.length-1;S>0&&(S>x||p[S].getTrimmedLength()===0);S--)w++;w>0&&(b.push(v+p.length-w),b.push(w)),v+=p.length-1}return b},o.reflowLargerCreateNewLayout=function(c,d){const u=[];let f=0,g=d[f],b=0;for(let v=0;v<c.length;v++)if(g===v){const m=d[++f];c.onDeleteEmitter.fire({index:v-b,amount:m}),v+=m-1,b+=m,g=d[++f]}else u.push(v);return{layout:u,countRemoved:b}},o.reflowLargerApplyNewLayout=function(c,d){const u=[];for(let f=0;f<d.length;f++)u.push(c.get(d[f]));for(let f=0;f<u.length;f++)c.set(f,u[f]);c.length=d.length},o.reflowSmallerGetNewLineLengths=function(c,d,u){const f=[],g=c.map(((O,p)=>l(c,p,d))).reduce(((O,p)=>O+p));let b=0,v=0,m=0;for(;m<g;){if(g-m<u){f.push(g-m);break}b+=u;const O=l(c,v,d);b>O&&(b-=O,v++);const p=c[v].getWidth(b-1)===2;p&&b--;const x=p?u-1:u;f.push(x),m+=x}return f},o.getWrappedLineTrimmedLength=l},5295:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferSet=void 0;const c=l(8460),d=l(844),u=l(9092);class f extends d.Disposable{constructor(b,v){super(),this._optionsService=b,this._bufferService=v,this._onBufferActivate=this.register(new c.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new u.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new u.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(b){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(b),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(b,v){this._normal.resize(b,v),this._alt.resize(b,v),this.setupTabStops(b)}setupTabStops(b){this._normal.setupTabStops(b),this._alt.setupTabStops(b)}}o.BufferSet=f},511:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CellData=void 0;const c=l(482),d=l(643),u=l(3734);class f extends u.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new u.ExtendedAttrs,this.combinedData=""}static fromCharData(b){const v=new f;return v.setFromCharData(b),v}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(b){this.fg=b[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let v=!1;if(b[d.CHAR_DATA_CHAR_INDEX].length>2)v=!0;else if(b[d.CHAR_DATA_CHAR_INDEX].length===2){const m=b[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=m&&m<=56319){const O=b[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=O&&O<=57343?this.content=1024*(m-55296)+O-56320+65536|b[d.CHAR_DATA_WIDTH_INDEX]<<22:v=!0}else v=!0}else this.content=b[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|b[d.CHAR_DATA_WIDTH_INDEX]<<22;v&&(this.combinedData=b[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|b[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.CellData=f},643:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WHITESPACE_CELL_CODE=o.WHITESPACE_CELL_WIDTH=o.WHITESPACE_CELL_CHAR=o.NULL_CELL_CODE=o.NULL_CELL_WIDTH=o.NULL_CELL_CHAR=o.CHAR_DATA_CODE_INDEX=o.CHAR_DATA_WIDTH_INDEX=o.CHAR_DATA_CHAR_INDEX=o.CHAR_DATA_ATTR_INDEX=o.DEFAULT_EXT=o.DEFAULT_ATTR=o.DEFAULT_COLOR=void 0,o.DEFAULT_COLOR=0,o.DEFAULT_ATTR=256|o.DEFAULT_COLOR<<9,o.DEFAULT_EXT=0,o.CHAR_DATA_ATTR_INDEX=0,o.CHAR_DATA_CHAR_INDEX=1,o.CHAR_DATA_WIDTH_INDEX=2,o.CHAR_DATA_CODE_INDEX=3,o.NULL_CELL_CHAR="",o.NULL_CELL_WIDTH=1,o.NULL_CELL_CODE=0,o.WHITESPACE_CELL_CHAR=" ",o.WHITESPACE_CELL_WIDTH=1,o.WHITESPACE_CELL_CODE=32},4863:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Marker=void 0;const c=l(8460),d=l(844);class u{get id(){return this._id}constructor(g){this.line=g,this.isDisposed=!1,this._disposables=[],this._id=u._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(g){return this._disposables.push(g),g}}o.Marker=u,u._nextId=1},7116:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DEFAULT_CHARSET=o.CHARSETS=void 0,o.CHARSETS={},o.DEFAULT_CHARSET=o.CHARSETS.B,o.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},o.CHARSETS.A={"#":"£"},o.CHARSETS.B=void 0,o.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},o.CHARSETS.C=o.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},o.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},o.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},o.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},o.CHARSETS.E=o.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},o.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},o.CHARSETS.H=o.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},o.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(a,o)=>{var l,c,d;Object.defineProperty(o,"__esModule",{value:!0}),o.C1_ESCAPED=o.C1=o.C0=void 0,(function(u){u.NUL="\0",u.SOH="",u.STX="",u.ETX="",u.EOT="",u.ENQ="",u.ACK="",u.BEL="\x07",u.BS="\b",u.HT=" ",u.LF=`
|
|
47
|
-
`,u.VT="\v",u.FF="\f",u.CR="\r",u.SO="",u.SI="",u.DLE="",u.DC1="",u.DC2="",u.DC3="",u.DC4="",u.NAK="",u.SYN="",u.ETB="",u.CAN="",u.EM="",u.SUB="",u.ESC="\x1B",u.FS="",u.GS="",u.RS="",u.US="",u.SP=" ",u.DEL=""})(l||(o.C0=l={})),(function(u){u.PAD="",u.HOP="",u.BPH="",u.NBH="",u.IND="",u.NEL="
",u.SSA="",u.ESA="",u.HTS="",u.HTJ="",u.VTS="",u.PLD="",u.PLU="",u.RI="",u.SS2="",u.SS3="",u.DCS="",u.PU1="",u.PU2="",u.STS="",u.CCH="",u.MW="",u.SPA="",u.EPA="",u.SOS="",u.SGCI="",u.SCI="",u.CSI="",u.ST="",u.OSC="",u.PM="",u.APC=""})(c||(o.C1=c={})),(function(u){u.ST=`${l.ESC}\\`})(d||(o.C1_ESCAPED=d={}))},7399:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.evaluateKeyboardEvent=void 0;const c=l(2584),d={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};o.evaluateKeyboardEvent=function(u,f,g,b){const v={type:0,cancel:!1,key:void 0},m=(u.shiftKey?1:0)|(u.altKey?2:0)|(u.ctrlKey?4:0)|(u.metaKey?8:0);switch(u.keyCode){case 0:u.key==="UIKeyInputUpArrow"?v.key=f?c.C0.ESC+"OA":c.C0.ESC+"[A":u.key==="UIKeyInputLeftArrow"?v.key=f?c.C0.ESC+"OD":c.C0.ESC+"[D":u.key==="UIKeyInputRightArrow"?v.key=f?c.C0.ESC+"OC":c.C0.ESC+"[C":u.key==="UIKeyInputDownArrow"&&(v.key=f?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:v.key=u.ctrlKey?"\b":c.C0.DEL,u.altKey&&(v.key=c.C0.ESC+v.key);break;case 9:if(u.shiftKey){v.key=c.C0.ESC+"[Z";break}v.key=c.C0.HT,v.cancel=!0;break;case 13:v.key=u.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,v.cancel=!0;break;case 27:v.key=c.C0.ESC,u.altKey&&(v.key=c.C0.ESC+c.C0.ESC),v.cancel=!0;break;case 37:if(u.metaKey)break;m?(v.key=c.C0.ESC+"[1;"+(m+1)+"D",v.key===c.C0.ESC+"[1;3D"&&(v.key=c.C0.ESC+(g?"b":"[1;5D"))):v.key=f?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(u.metaKey)break;m?(v.key=c.C0.ESC+"[1;"+(m+1)+"C",v.key===c.C0.ESC+"[1;3C"&&(v.key=c.C0.ESC+(g?"f":"[1;5C"))):v.key=f?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(u.metaKey)break;m?(v.key=c.C0.ESC+"[1;"+(m+1)+"A",g||v.key!==c.C0.ESC+"[1;3A"||(v.key=c.C0.ESC+"[1;5A")):v.key=f?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(u.metaKey)break;m?(v.key=c.C0.ESC+"[1;"+(m+1)+"B",g||v.key!==c.C0.ESC+"[1;3B"||(v.key=c.C0.ESC+"[1;5B")):v.key=f?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:u.shiftKey||u.ctrlKey||(v.key=c.C0.ESC+"[2~");break;case 46:v.key=m?c.C0.ESC+"[3;"+(m+1)+"~":c.C0.ESC+"[3~";break;case 36:v.key=m?c.C0.ESC+"[1;"+(m+1)+"H":f?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:v.key=m?c.C0.ESC+"[1;"+(m+1)+"F":f?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:u.shiftKey?v.type=2:u.ctrlKey?v.key=c.C0.ESC+"[5;"+(m+1)+"~":v.key=c.C0.ESC+"[5~";break;case 34:u.shiftKey?v.type=3:u.ctrlKey?v.key=c.C0.ESC+"[6;"+(m+1)+"~":v.key=c.C0.ESC+"[6~";break;case 112:v.key=m?c.C0.ESC+"[1;"+(m+1)+"P":c.C0.ESC+"OP";break;case 113:v.key=m?c.C0.ESC+"[1;"+(m+1)+"Q":c.C0.ESC+"OQ";break;case 114:v.key=m?c.C0.ESC+"[1;"+(m+1)+"R":c.C0.ESC+"OR";break;case 115:v.key=m?c.C0.ESC+"[1;"+(m+1)+"S":c.C0.ESC+"OS";break;case 116:v.key=m?c.C0.ESC+"[15;"+(m+1)+"~":c.C0.ESC+"[15~";break;case 117:v.key=m?c.C0.ESC+"[17;"+(m+1)+"~":c.C0.ESC+"[17~";break;case 118:v.key=m?c.C0.ESC+"[18;"+(m+1)+"~":c.C0.ESC+"[18~";break;case 119:v.key=m?c.C0.ESC+"[19;"+(m+1)+"~":c.C0.ESC+"[19~";break;case 120:v.key=m?c.C0.ESC+"[20;"+(m+1)+"~":c.C0.ESC+"[20~";break;case 121:v.key=m?c.C0.ESC+"[21;"+(m+1)+"~":c.C0.ESC+"[21~";break;case 122:v.key=m?c.C0.ESC+"[23;"+(m+1)+"~":c.C0.ESC+"[23~";break;case 123:v.key=m?c.C0.ESC+"[24;"+(m+1)+"~":c.C0.ESC+"[24~";break;default:if(!u.ctrlKey||u.shiftKey||u.altKey||u.metaKey)if(g&&!b||!u.altKey||u.metaKey)!g||u.altKey||u.ctrlKey||u.shiftKey||!u.metaKey?u.key&&!u.ctrlKey&&!u.altKey&&!u.metaKey&&u.keyCode>=48&&u.key.length===1?v.key=u.key:u.key&&u.ctrlKey&&(u.key==="_"&&(v.key=c.C0.US),u.key==="@"&&(v.key=c.C0.NUL)):u.keyCode===65&&(v.type=1);else{const O=d[u.keyCode],p=O?.[u.shiftKey?1:0];if(p)v.key=c.C0.ESC+p;else if(u.keyCode>=65&&u.keyCode<=90){const x=u.ctrlKey?u.keyCode-64:u.keyCode+32;let y=String.fromCharCode(x);u.shiftKey&&(y=y.toUpperCase()),v.key=c.C0.ESC+y}else if(u.keyCode===32)v.key=c.C0.ESC+(u.ctrlKey?c.C0.NUL:" ");else if(u.key==="Dead"&&u.code.startsWith("Key")){let x=u.code.slice(3,4);u.shiftKey||(x=x.toLowerCase()),v.key=c.C0.ESC+x,v.cancel=!0}}else u.keyCode>=65&&u.keyCode<=90?v.key=String.fromCharCode(u.keyCode-64):u.keyCode===32?v.key=c.C0.NUL:u.keyCode>=51&&u.keyCode<=55?v.key=String.fromCharCode(u.keyCode-51+27):u.keyCode===56?v.key=c.C0.DEL:u.keyCode===219?v.key=c.C0.ESC:u.keyCode===220?v.key=c.C0.FS:u.keyCode===221&&(v.key=c.C0.GS)}return v}},482:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Utf8ToUtf32=o.StringToUtf32=o.utf32ToString=o.stringFromCodePoint=void 0,o.stringFromCodePoint=function(l){return l>65535?(l-=65536,String.fromCharCode(55296+(l>>10))+String.fromCharCode(l%1024+56320)):String.fromCharCode(l)},o.utf32ToString=function(l,c=0,d=l.length){let u="";for(let f=c;f<d;++f){let g=l[f];g>65535?(g-=65536,u+=String.fromCharCode(55296+(g>>10))+String.fromCharCode(g%1024+56320)):u+=String.fromCharCode(g)}return u},o.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(l,c){const d=l.length;if(!d)return 0;let u=0,f=0;if(this._interim){const g=l.charCodeAt(f++);56320<=g&&g<=57343?c[u++]=1024*(this._interim-55296)+g-56320+65536:(c[u++]=this._interim,c[u++]=g),this._interim=0}for(let g=f;g<d;++g){const b=l.charCodeAt(g);if(55296<=b&&b<=56319){if(++g>=d)return this._interim=b,u;const v=l.charCodeAt(g);56320<=v&&v<=57343?c[u++]=1024*(b-55296)+v-56320+65536:(c[u++]=b,c[u++]=v)}else b!==65279&&(c[u++]=b)}return u}},o.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(l,c){const d=l.length;if(!d)return 0;let u,f,g,b,v=0,m=0,O=0;if(this.interim[0]){let y=!1,_=this.interim[0];_&=(224&_)==192?31:(240&_)==224?15:7;let k,w=0;for(;(k=63&this.interim[++w])&&w<4;)_<<=6,_|=k;const S=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,Q=S-w;for(;O<Q;){if(O>=d)return 0;if(k=l[O++],(192&k)!=128){O--,y=!0;break}this.interim[w++]=k,_<<=6,_|=63&k}y||(S===2?_<128?O--:c[v++]=_:S===3?_<2048||_>=55296&&_<=57343||_===65279||(c[v++]=_):_<65536||_>1114111||(c[v++]=_)),this.interim.fill(0)}const p=d-4;let x=O;for(;x<d;){for(;!(!(x<p)||128&(u=l[x])||128&(f=l[x+1])||128&(g=l[x+2])||128&(b=l[x+3]));)c[v++]=u,c[v++]=f,c[v++]=g,c[v++]=b,x+=4;if(u=l[x++],u<128)c[v++]=u;else if((224&u)==192){if(x>=d)return this.interim[0]=u,v;if(f=l[x++],(192&f)!=128){x--;continue}if(m=(31&u)<<6|63&f,m<128){x--;continue}c[v++]=m}else if((240&u)==224){if(x>=d)return this.interim[0]=u,v;if(f=l[x++],(192&f)!=128){x--;continue}if(x>=d)return this.interim[0]=u,this.interim[1]=f,v;if(g=l[x++],(192&g)!=128){x--;continue}if(m=(15&u)<<12|(63&f)<<6|63&g,m<2048||m>=55296&&m<=57343||m===65279)continue;c[v++]=m}else if((248&u)==240){if(x>=d)return this.interim[0]=u,v;if(f=l[x++],(192&f)!=128){x--;continue}if(x>=d)return this.interim[0]=u,this.interim[1]=f,v;if(g=l[x++],(192&g)!=128){x--;continue}if(x>=d)return this.interim[0]=u,this.interim[1]=f,this.interim[2]=g,v;if(b=l[x++],(192&b)!=128){x--;continue}if(m=(7&u)<<18|(63&f)<<12|(63&g)<<6|63&b,m<65536||m>1114111)continue;c[v++]=m}}return v}}},225:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const c=l(1480),d=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],u=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;o.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let g=0;g<d.length;++g)f.fill(0,d[g][0],d[g][1]+1)}}wcwidth(g){return g<32?0:g<127?1:g<65536?f[g]:(function(b,v){let m,O=0,p=v.length-1;if(b<v[0][0]||b>v[p][1])return!1;for(;p>=O;)if(m=O+p>>1,b>v[m][1])O=m+1;else{if(!(b<v[m][0]))return!0;p=m-1}return!1})(g,u)?0:g>=131072&&g<=196605||g>=196608&&g<=262141?2:1}charProperties(g,b){let v=this.wcwidth(g),m=v===0&&b!==0;if(m){const O=c.UnicodeService.extractWidth(b);O===0?m=!1:O>v&&(v=O)}return c.UnicodeService.createPropertyValue(0,v,m)}}},5981:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WriteBuffer=void 0;const c=l(8460),d=l(844);class u extends d.Disposable{constructor(g){super(),this._action=g,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(g,b){if(b!==void 0&&this._syncCalls>b)return void(this._syncCalls=0);if(this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let v;for(this._isSyncWriting=!0;v=this._writeBuffer.shift();){this._action(v);const m=this._callbacks.shift();m&&m()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(g,b){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(b),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=g.length,this._writeBuffer.push(g),this._callbacks.push(b)}_innerWrite(g=0,b=!0){const v=g||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const m=this._writeBuffer[this._bufferOffset],O=this._action(m,b);if(O){const x=y=>Date.now()-v>=12?setTimeout((()=>this._innerWrite(0,y))):this._innerWrite(v,y);return void O.catch((y=>(queueMicrotask((()=>{throw y})),Promise.resolve(!1)))).then(x)}const p=this._callbacks[this._bufferOffset];if(p&&p(),this._bufferOffset++,this._pendingData-=m.length,Date.now()-v>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}o.WriteBuffer=u},5941:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.toRgbString=o.parseColor=void 0;const l=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,c=/^[\da-f]+$/;function d(u,f){const g=u.toString(16),b=g.length<2?"0"+g:g;switch(f){case 4:return g[0];case 8:return b;case 12:return(b+b).slice(0,3);default:return b+b}}o.parseColor=function(u){if(!u)return;let f=u.toLowerCase();if(f.indexOf("rgb:")===0){f=f.slice(4);const g=l.exec(f);if(g){const b=g[1]?15:g[4]?255:g[7]?4095:65535;return[Math.round(parseInt(g[1]||g[4]||g[7]||g[10],16)/b*255),Math.round(parseInt(g[2]||g[5]||g[8]||g[11],16)/b*255),Math.round(parseInt(g[3]||g[6]||g[9]||g[12],16)/b*255)]}}else if(f.indexOf("#")===0&&(f=f.slice(1),c.exec(f)&&[3,6,9,12].includes(f.length))){const g=f.length/3,b=[0,0,0];for(let v=0;v<3;++v){const m=parseInt(f.slice(g*v,g*v+g),16);b[v]=g===1?m<<4:g===2?m:g===3?m>>4:m>>8}return b}},o.toRgbString=function(u,f=16){const[g,b,v]=u;return`rgb:${d(g,f)}/${d(b,f)}/${d(v,f)}`}},5770:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.PAYLOAD_LIMIT=void 0,o.PAYLOAD_LIMIT=1e7},6351:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DcsHandler=o.DcsParser=void 0;const c=l(482),d=l(8742),u=l(5770),f=[];o.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=f,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=f}registerHandler(b,v){this._handlers[b]===void 0&&(this._handlers[b]=[]);const m=this._handlers[b];return m.push(v),{dispose:()=>{const O=m.indexOf(v);O!==-1&&m.splice(O,1)}}}clearHandler(b){this._handlers[b]&&delete this._handlers[b]}setHandlerFallback(b){this._handlerFb=b}reset(){if(this._active.length)for(let b=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;b>=0;--b)this._active[b].unhook(!1);this._stack.paused=!1,this._active=f,this._ident=0}hook(b,v){if(this.reset(),this._ident=b,this._active=this._handlers[b]||f,this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].hook(v);else this._handlerFb(this._ident,"HOOK",v)}put(b,v,m){if(this._active.length)for(let O=this._active.length-1;O>=0;O--)this._active[O].put(b,v,m);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(b,v,m))}unhook(b,v=!0){if(this._active.length){let m=!1,O=this._active.length-1,p=!1;if(this._stack.paused&&(O=this._stack.loopPosition-1,m=v,p=this._stack.fallThrough,this._stack.paused=!1),!p&&m===!1){for(;O>=0&&(m=this._active[O].unhook(b),m!==!0);O--)if(m instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=O,this._stack.fallThrough=!1,m;O--}for(;O>=0;O--)if(m=this._active[O].unhook(!1),m instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=O,this._stack.fallThrough=!0,m}else this._handlerFb(this._ident,"UNHOOK",b);this._active=f,this._ident=0}};const g=new d.Params;g.addParam(0),o.DcsHandler=class{constructor(b){this._handler=b,this._data="",this._params=g,this._hitLimit=!1}hook(b){this._params=b.length>1||b.params[0]?b.clone():g,this._data="",this._hitLimit=!1}put(b,v,m){this._hitLimit||(this._data+=(0,c.utf32ToString)(b,v,m),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(b){let v=!1;if(this._hitLimit)v=!1;else if(b&&(v=this._handler(this._data,this._params),v instanceof Promise))return v.then((m=>(this._params=g,this._data="",this._hitLimit=!1,m)));return this._params=g,this._data="",this._hitLimit=!1,v}}},2015:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.EscapeSequenceParser=o.VT500_TRANSITION_TABLE=o.TransitionTable=void 0;const c=l(844),d=l(8742),u=l(6242),f=l(6351);class g{constructor(O){this.table=new Uint8Array(O)}setDefault(O,p){this.table.fill(O<<4|p)}add(O,p,x,y){this.table[p<<8|O]=x<<4|y}addMany(O,p,x,y){for(let _=0;_<O.length;_++)this.table[p<<8|O[_]]=x<<4|y}}o.TransitionTable=g;const b=160;o.VT500_TRANSITION_TABLE=(function(){const m=new g(4095),O=Array.apply(null,Array(256)).map(((w,S)=>S)),p=(w,S)=>O.slice(w,S),x=p(32,127),y=p(0,24);y.push(25),y.push.apply(y,p(28,32));const _=p(0,14);let k;for(k in m.setDefault(1,0),m.addMany(x,0,2,0),_)m.addMany([24,26,153,154],k,3,0),m.addMany(p(128,144),k,3,0),m.addMany(p(144,152),k,3,0),m.add(156,k,0,0),m.add(27,k,11,1),m.add(157,k,4,8),m.addMany([152,158,159],k,0,7),m.add(155,k,11,3),m.add(144,k,11,9);return m.addMany(y,0,3,0),m.addMany(y,1,3,1),m.add(127,1,0,1),m.addMany(y,8,0,8),m.addMany(y,3,3,3),m.add(127,3,0,3),m.addMany(y,4,3,4),m.add(127,4,0,4),m.addMany(y,6,3,6),m.addMany(y,5,3,5),m.add(127,5,0,5),m.addMany(y,2,3,2),m.add(127,2,0,2),m.add(93,1,4,8),m.addMany(x,8,5,8),m.add(127,8,5,8),m.addMany([156,27,24,26,7],8,6,0),m.addMany(p(28,32),8,0,8),m.addMany([88,94,95],1,0,7),m.addMany(x,7,0,7),m.addMany(y,7,0,7),m.add(156,7,0,0),m.add(127,7,0,7),m.add(91,1,11,3),m.addMany(p(64,127),3,7,0),m.addMany(p(48,60),3,8,4),m.addMany([60,61,62,63],3,9,4),m.addMany(p(48,60),4,8,4),m.addMany(p(64,127),4,7,0),m.addMany([60,61,62,63],4,0,6),m.addMany(p(32,64),6,0,6),m.add(127,6,0,6),m.addMany(p(64,127),6,0,0),m.addMany(p(32,48),3,9,5),m.addMany(p(32,48),5,9,5),m.addMany(p(48,64),5,0,6),m.addMany(p(64,127),5,7,0),m.addMany(p(32,48),4,9,5),m.addMany(p(32,48),1,9,2),m.addMany(p(32,48),2,9,2),m.addMany(p(48,127),2,10,0),m.addMany(p(48,80),1,10,0),m.addMany(p(81,88),1,10,0),m.addMany([89,90,92],1,10,0),m.addMany(p(96,127),1,10,0),m.add(80,1,11,9),m.addMany(y,9,0,9),m.add(127,9,0,9),m.addMany(p(28,32),9,0,9),m.addMany(p(32,48),9,9,12),m.addMany(p(48,60),9,8,10),m.addMany([60,61,62,63],9,9,10),m.addMany(y,11,0,11),m.addMany(p(32,128),11,0,11),m.addMany(p(28,32),11,0,11),m.addMany(y,10,0,10),m.add(127,10,0,10),m.addMany(p(28,32),10,0,10),m.addMany(p(48,60),10,8,10),m.addMany([60,61,62,63],10,0,11),m.addMany(p(32,48),10,9,12),m.addMany(y,12,0,12),m.add(127,12,0,12),m.addMany(p(28,32),12,0,12),m.addMany(p(32,48),12,9,12),m.addMany(p(48,64),12,0,11),m.addMany(p(64,127),12,12,13),m.addMany(p(64,127),10,12,13),m.addMany(p(64,127),9,12,13),m.addMany(y,13,13,13),m.addMany(x,13,13,13),m.add(127,13,0,13),m.addMany([27,156,24,26],13,14,0),m.add(b,0,2,0),m.add(b,8,5,8),m.add(b,6,0,6),m.add(b,11,0,11),m.add(b,13,13,13),m})();class v extends c.Disposable{constructor(O=o.VT500_TRANSITION_TABLE){super(),this._transitions=O,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(p,x,y)=>{},this._executeHandlerFb=p=>{},this._csiHandlerFb=(p,x)=>{},this._escHandlerFb=p=>{},this._errorHandlerFb=p=>p,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new u.OscParser),this._dcsParser=this.register(new f.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(O,p=[64,126]){let x=0;if(O.prefix){if(O.prefix.length>1)throw new Error("only one byte as prefix supported");if(x=O.prefix.charCodeAt(0),x&&60>x||x>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(O.intermediates){if(O.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let _=0;_<O.intermediates.length;++_){const k=O.intermediates.charCodeAt(_);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");x<<=8,x|=k}}if(O.final.length!==1)throw new Error("final must be a single byte");const y=O.final.charCodeAt(0);if(p[0]>y||y>p[1])throw new Error(`final must be in range ${p[0]} .. ${p[1]}`);return x<<=8,x|=y,x}identToString(O){const p=[];for(;O;)p.push(String.fromCharCode(255&O)),O>>=8;return p.reverse().join("")}setPrintHandler(O){this._printHandler=O}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(O,p){const x=this._identifier(O,[48,126]);this._escHandlers[x]===void 0&&(this._escHandlers[x]=[]);const y=this._escHandlers[x];return y.push(p),{dispose:()=>{const _=y.indexOf(p);_!==-1&&y.splice(_,1)}}}clearEscHandler(O){this._escHandlers[this._identifier(O,[48,126])]&&delete this._escHandlers[this._identifier(O,[48,126])]}setEscHandlerFallback(O){this._escHandlerFb=O}setExecuteHandler(O,p){this._executeHandlers[O.charCodeAt(0)]=p}clearExecuteHandler(O){this._executeHandlers[O.charCodeAt(0)]&&delete this._executeHandlers[O.charCodeAt(0)]}setExecuteHandlerFallback(O){this._executeHandlerFb=O}registerCsiHandler(O,p){const x=this._identifier(O);this._csiHandlers[x]===void 0&&(this._csiHandlers[x]=[]);const y=this._csiHandlers[x];return y.push(p),{dispose:()=>{const _=y.indexOf(p);_!==-1&&y.splice(_,1)}}}clearCsiHandler(O){this._csiHandlers[this._identifier(O)]&&delete this._csiHandlers[this._identifier(O)]}setCsiHandlerFallback(O){this._csiHandlerFb=O}registerDcsHandler(O,p){return this._dcsParser.registerHandler(this._identifier(O),p)}clearDcsHandler(O){this._dcsParser.clearHandler(this._identifier(O))}setDcsHandlerFallback(O){this._dcsParser.setHandlerFallback(O)}registerOscHandler(O,p){return this._oscParser.registerHandler(O,p)}clearOscHandler(O){this._oscParser.clearHandler(O)}setOscHandlerFallback(O){this._oscParser.setHandlerFallback(O)}setErrorHandler(O){this._errorHandler=O}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(O,p,x,y,_){this._parseStack.state=O,this._parseStack.handlers=p,this._parseStack.handlerPos=x,this._parseStack.transition=y,this._parseStack.chunkPos=_}parse(O,p,x){let y,_=0,k=0,w=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,w=this._parseStack.chunkPos+1;else{if(x===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const S=this._parseStack.handlers;let Q=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(x===!1&&Q>-1){for(;Q>=0&&(y=S[Q](this._params),y!==!0);Q--)if(y instanceof Promise)return this._parseStack.handlerPos=Q,y}this._parseStack.handlers=[];break;case 4:if(x===!1&&Q>-1){for(;Q>=0&&(y=S[Q](),y!==!0);Q--)if(y instanceof Promise)return this._parseStack.handlerPos=Q,y}this._parseStack.handlers=[];break;case 6:if(_=O[this._parseStack.chunkPos],y=this._dcsParser.unhook(_!==24&&_!==26,x),y)return y;_===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(_=O[this._parseStack.chunkPos],y=this._oscParser.end(_!==24&&_!==26,x),y)return y;_===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,w=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let S=w;S<p;++S){switch(_=O[S],k=this._transitions.table[this.currentState<<8|(_<160?_:b)],k>>4){case 2:for(let j=S+1;;++j){if(j>=p||(_=O[j])<32||_>126&&_<b){this._printHandler(O,S,j),S=j-1;break}if(++j>=p||(_=O[j])<32||_>126&&_<b){this._printHandler(O,S,j),S=j-1;break}if(++j>=p||(_=O[j])<32||_>126&&_<b){this._printHandler(O,S,j),S=j-1;break}if(++j>=p||(_=O[j])<32||_>126&&_<b){this._printHandler(O,S,j),S=j-1;break}}break;case 3:this._executeHandlers[_]?this._executeHandlers[_]():this._executeHandlerFb(_),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:S,code:_,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const Q=this._csiHandlers[this._collect<<8|_];let I=Q?Q.length-1:-1;for(;I>=0&&(y=Q[I](this._params),y!==!0);I--)if(y instanceof Promise)return this._preserveStack(3,Q,I,k,S),y;I<0&&this._csiHandlerFb(this._collect<<8|_,this._params),this.precedingJoinState=0;break;case 8:do switch(_){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(_-48)}while(++S<p&&(_=O[S])>47&&_<60);S--;break;case 9:this._collect<<=8,this._collect|=_;break;case 10:const D=this._escHandlers[this._collect<<8|_];let $=D?D.length-1:-1;for(;$>=0&&(y=D[$](),y!==!0);$--)if(y instanceof Promise)return this._preserveStack(4,D,$,k,S),y;$<0&&this._escHandlerFb(this._collect<<8|_),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|_,this._params);break;case 13:for(let j=S+1;;++j)if(j>=p||(_=O[j])===24||_===26||_===27||_>127&&_<b){this._dcsParser.put(O,S,j),S=j-1;break}break;case 14:if(y=this._dcsParser.unhook(_!==24&&_!==26),y)return this._preserveStack(6,[],0,k,S),y;_===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let j=S+1;;j++)if(j>=p||(_=O[j])<32||_>127&&_<b){this._oscParser.put(O,S,j),S=j-1;break}break;case 6:if(y=this._oscParser.end(_!==24&&_!==26),y)return this._preserveStack(5,[],0,k,S),y;_===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&k}}}o.EscapeSequenceParser=v},6242:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OscHandler=o.OscParser=void 0;const c=l(5770),d=l(482),u=[];o.OscParser=class{constructor(){this._state=0,this._active=u,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(f,g){this._handlers[f]===void 0&&(this._handlers[f]=[]);const b=this._handlers[f];return b.push(g),{dispose:()=>{const v=b.indexOf(g);v!==-1&&b.splice(v,1)}}}clearHandler(f){this._handlers[f]&&delete this._handlers[f]}setHandlerFallback(f){this._handlerFb=f}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=u}reset(){if(this._state===2)for(let f=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;f>=0;--f)this._active[f].end(!1);this._stack.paused=!1,this._active=u,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||u,this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].start();else this._handlerFb(this._id,"START")}_put(f,g,b){if(this._active.length)for(let v=this._active.length-1;v>=0;v--)this._active[v].put(f,g,b);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(f,g,b))}start(){this.reset(),this._state=1}put(f,g,b){if(this._state!==3){if(this._state===1)for(;g<b;){const v=f[g++];if(v===59){this._state=2,this._start();break}if(v<48||57<v)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+v-48}this._state===2&&b-g>0&&this._put(f,g,b)}}end(f,g=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let b=!1,v=this._active.length-1,m=!1;if(this._stack.paused&&(v=this._stack.loopPosition-1,b=g,m=this._stack.fallThrough,this._stack.paused=!1),!m&&b===!1){for(;v>=0&&(b=this._active[v].end(f),b!==!0);v--)if(b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=v,this._stack.fallThrough=!1,b;v--}for(;v>=0;v--)if(b=this._active[v].end(!1),b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=v,this._stack.fallThrough=!0,b}else this._handlerFb(this._id,"END",f);this._active=u,this._id=-1,this._state=0}}},o.OscHandler=class{constructor(f){this._handler=f,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(f,g,b){this._hitLimit||(this._data+=(0,d.utf32ToString)(f,g,b),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(f){let g=!1;if(this._hitLimit)g=!1;else if(f&&(g=this._handler(this._data),g instanceof Promise))return g.then((b=>(this._data="",this._hitLimit=!1,b)));return this._data="",this._hitLimit=!1,g}}},8742:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Params=void 0;const l=2147483647;class c{static fromArray(u){const f=new c;if(!u.length)return f;for(let g=Array.isArray(u[0])?1:0;g<u.length;++g){const b=u[g];if(Array.isArray(b))for(let v=0;v<b.length;++v)f.addSubParam(b[v]);else f.addParam(b)}return f}constructor(u=32,f=32){if(this.maxLength=u,this.maxSubParamsLength=f,f>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(u),this.length=0,this._subParams=new Int32Array(f),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(u),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const u=new c(this.maxLength,this.maxSubParamsLength);return u.params.set(this.params),u.length=this.length,u._subParams.set(this._subParams),u._subParamsLength=this._subParamsLength,u._subParamsIdx.set(this._subParamsIdx),u._rejectDigits=this._rejectDigits,u._rejectSubDigits=this._rejectSubDigits,u._digitIsSub=this._digitIsSub,u}toArray(){const u=[];for(let f=0;f<this.length;++f){u.push(this.params[f]);const g=this._subParamsIdx[f]>>8,b=255&this._subParamsIdx[f];b-g>0&&u.push(Array.prototype.slice.call(this._subParams,g,b))}return u}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(u){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(u<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=u>l?l:u}}addSubParam(u){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(u<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=u>l?l:u,this._subParamsIdx[this.length-1]++}}hasSubParams(u){return(255&this._subParamsIdx[u])-(this._subParamsIdx[u]>>8)>0}getSubParams(u){const f=this._subParamsIdx[u]>>8,g=255&this._subParamsIdx[u];return g-f>0?this._subParams.subarray(f,g):null}getSubParamsAll(){const u={};for(let f=0;f<this.length;++f){const g=this._subParamsIdx[f]>>8,b=255&this._subParamsIdx[f];b-g>0&&(u[f]=this._subParams.slice(g,b))}return u}addDigit(u){let f;if(this._rejectDigits||!(f=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const g=this._digitIsSub?this._subParams:this.params,b=g[f-1];g[f-1]=~b?Math.min(10*b+u,l):u}}o.Params=c},5741:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.AddonManager=void 0,o.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let l=this._addons.length-1;l>=0;l--)this._addons[l].instance.dispose()}loadAddon(l,c){const d={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(d),c.dispose=()=>this._wrappedAddonDispose(d),c.activate(l)}_wrappedAddonDispose(l){if(l.isDisposed)return;let c=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===l){c=d;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");l.isDisposed=!0,l.dispose.apply(l.instance),this._addons.splice(c,1)}}},8771:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferApiView=void 0;const c=l(3785),d=l(511);o.BufferApiView=class{constructor(u,f){this._buffer=u,this.type=f}init(u){return this._buffer=u,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(u){const f=this._buffer.lines.get(u);if(f)return new c.BufferLineApiView(f)}getNullCell(){return new d.CellData}}},3785:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLineApiView=void 0;const c=l(511);o.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,u){if(!(d<0||d>=this._line.length))return u?(this._line.loadCell(d,u),u):this._line.loadCell(d,new c.CellData)}translateToString(d,u,f){return this._line.translateToString(d,u,f)}}},8285:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferNamespaceApi=void 0;const c=l(8771),d=l(8460),u=l(844);class f extends u.Disposable{constructor(b){super(),this._core=b,this._onBufferChange=this.register(new d.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}o.BufferNamespaceApi=f},7975:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ParserApi=void 0,o.ParserApi=class{constructor(l){this._core=l}registerCsiHandler(l,c){return this._core.registerCsiHandler(l,(d=>c(d.toArray())))}addCsiHandler(l,c){return this.registerCsiHandler(l,c)}registerDcsHandler(l,c){return this._core.registerDcsHandler(l,((d,u)=>c(d,u.toArray())))}addDcsHandler(l,c){return this.registerDcsHandler(l,c)}registerEscHandler(l,c){return this._core.registerEscHandler(l,c)}addEscHandler(l,c){return this.registerEscHandler(l,c)}registerOscHandler(l,c){return this._core.registerOscHandler(l,c)}addOscHandler(l,c){return this.registerOscHandler(l,c)}}},7090:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeApi=void 0,o.UnicodeApi=class{constructor(l){this._core=l}register(l){this._core.unicodeService.register(l)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(l){this._core.unicodeService.activeVersion=l}}},744:function(a,o,l){var c=this&&this.__decorate||function(m,O,p,x){var y,_=arguments.length,k=_<3?O:x===null?x=Object.getOwnPropertyDescriptor(O,p):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(m,O,p,x);else for(var w=m.length-1;w>=0;w--)(y=m[w])&&(k=(_<3?y(k):_>3?y(O,p,k):y(O,p))||k);return _>3&&k&&Object.defineProperty(O,p,k),k},d=this&&this.__param||function(m,O){return function(p,x){O(p,x,m)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferService=o.MINIMUM_ROWS=o.MINIMUM_COLS=void 0;const u=l(8460),f=l(844),g=l(5295),b=l(2585);o.MINIMUM_COLS=2,o.MINIMUM_ROWS=1;let v=o.BufferService=class extends f.Disposable{get buffer(){return this.buffers.active}constructor(m){super(),this.isUserScrolling=!1,this._onResize=this.register(new u.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new u.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(m.rawOptions.cols||0,o.MINIMUM_COLS),this.rows=Math.max(m.rawOptions.rows||0,o.MINIMUM_ROWS),this.buffers=this.register(new g.BufferSet(m,this))}resize(m,O){this.cols=m,this.rows=O,this.buffers.resize(m,O),this._onResize.fire({cols:m,rows:O})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(m,O=!1){const p=this.buffer;let x;x=this._cachedBlankLine,x&&x.length===this.cols&&x.getFg(0)===m.fg&&x.getBg(0)===m.bg||(x=p.getBlankLine(m,O),this._cachedBlankLine=x),x.isWrapped=O;const y=p.ybase+p.scrollTop,_=p.ybase+p.scrollBottom;if(p.scrollTop===0){const k=p.lines.isFull;_===p.lines.length-1?k?p.lines.recycle().copyFrom(x):p.lines.push(x.clone()):p.lines.splice(_+1,0,x.clone()),k?this.isUserScrolling&&(p.ydisp=Math.max(p.ydisp-1,0)):(p.ybase++,this.isUserScrolling||p.ydisp++)}else{const k=_-y+1;p.lines.shiftElements(y+1,k-1,-1),p.lines.set(_,x.clone())}this.isUserScrolling||(p.ydisp=p.ybase),this._onScroll.fire(p.ydisp)}scrollLines(m,O,p){const x=this.buffer;if(m<0){if(x.ydisp===0)return;this.isUserScrolling=!0}else m+x.ydisp>=x.ybase&&(this.isUserScrolling=!1);const y=x.ydisp;x.ydisp=Math.max(Math.min(x.ydisp+m,x.ybase),0),y!==x.ydisp&&(O||this._onScroll.fire(x.ydisp))}};o.BufferService=v=c([d(0,b.IOptionsService)],v)},7994:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CharsetService=void 0,o.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(l){this.glevel=l,this.charset=this._charsets[l]}setgCharset(l,c){this._charsets[l]=c,this.glevel===l&&(this.charset=c)}}},1753:function(a,o,l){var c=this&&this.__decorate||function(x,y,_,k){var w,S=arguments.length,Q=S<3?y:k===null?k=Object.getOwnPropertyDescriptor(y,_):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Q=Reflect.decorate(x,y,_,k);else for(var I=x.length-1;I>=0;I--)(w=x[I])&&(Q=(S<3?w(Q):S>3?w(y,_,Q):w(y,_))||Q);return S>3&&Q&&Object.defineProperty(y,_,Q),Q},d=this&&this.__param||function(x,y){return function(_,k){y(_,k,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreMouseService=void 0;const u=l(2585),f=l(8460),g=l(844),b={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:x=>x.button!==4&&x.action===1&&(x.ctrl=!1,x.alt=!1,x.shift=!1,!0)},VT200:{events:19,restrict:x=>x.action!==32},DRAG:{events:23,restrict:x=>x.action!==32||x.button!==3},ANY:{events:31,restrict:x=>!0}};function v(x,y){let _=(x.ctrl?16:0)|(x.shift?4:0)|(x.alt?8:0);return x.button===4?(_|=64,_|=x.action):(_|=3&x.button,4&x.button&&(_|=64),8&x.button&&(_|=128),x.action===32?_|=32:x.action!==0||y||(_|=3)),_}const m=String.fromCharCode,O={DEFAULT:x=>{const y=[v(x,!1)+32,x.col+32,x.row+32];return y[0]>255||y[1]>255||y[2]>255?"":`\x1B[M${m(y[0])}${m(y[1])}${m(y[2])}`},SGR:x=>{const y=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${v(x,!0)};${x.col};${x.row}${y}`},SGR_PIXELS:x=>{const y=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${v(x,!0)};${x.x};${x.y}${y}`}};let p=o.CoreMouseService=class extends g.Disposable{constructor(x,y){super(),this._bufferService=x,this._coreService=y,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new f.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const _ of Object.keys(b))this.addProtocol(_,b[_]);for(const _ of Object.keys(O))this.addEncoding(_,O[_]);this.reset()}addProtocol(x,y){this._protocols[x]=y}addEncoding(x,y){this._encodings[x]=y}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(x){if(!this._protocols[x])throw new Error(`unknown protocol "${x}"`);this._activeProtocol=x,this._onProtocolChange.fire(this._protocols[x].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(x){if(!this._encodings[x])throw new Error(`unknown encoding "${x}"`);this._activeEncoding=x}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(x){if(x.col<0||x.col>=this._bufferService.cols||x.row<0||x.row>=this._bufferService.rows||x.button===4&&x.action===32||x.button===3&&x.action!==32||x.button!==4&&(x.action===2||x.action===3)||(x.col++,x.row++,x.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,x,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(x))return!1;const y=this._encodings[this._activeEncoding](x);return y&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(y):this._coreService.triggerDataEvent(y,!0)),this._lastEvent=x,!0}explainEvents(x){return{down:!!(1&x),up:!!(2&x),drag:!!(4&x),move:!!(8&x),wheel:!!(16&x)}}_equalEvents(x,y,_){if(_){if(x.x!==y.x||x.y!==y.y)return!1}else if(x.col!==y.col||x.row!==y.row)return!1;return x.button===y.button&&x.action===y.action&&x.ctrl===y.ctrl&&x.alt===y.alt&&x.shift===y.shift}};o.CoreMouseService=p=c([d(0,u.IBufferService),d(1,u.ICoreService)],p)},6975:function(a,o,l){var c=this&&this.__decorate||function(p,x,y,_){var k,w=arguments.length,S=w<3?x:_===null?_=Object.getOwnPropertyDescriptor(x,y):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(p,x,y,_);else for(var Q=p.length-1;Q>=0;Q--)(k=p[Q])&&(S=(w<3?k(S):w>3?k(x,y,S):k(x,y))||S);return w>3&&S&&Object.defineProperty(x,y,S),S},d=this&&this.__param||function(p,x){return function(y,_){x(y,_,p)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreService=void 0;const u=l(1439),f=l(8460),g=l(844),b=l(2585),v=Object.freeze({insertMode:!1}),m=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let O=o.CoreService=class extends g.Disposable{constructor(p,x,y){super(),this._bufferService=p,this._logService=x,this._optionsService=y,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new f.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new f.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new f.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new f.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,u.clone)(v),this.decPrivateModes=(0,u.clone)(m)}reset(){this.modes=(0,u.clone)(v),this.decPrivateModes=(0,u.clone)(m)}triggerDataEvent(p,x=!1){if(this._optionsService.rawOptions.disableStdin)return;const y=this._bufferService.buffer;x&&this._optionsService.rawOptions.scrollOnUserInput&&y.ybase!==y.ydisp&&this._onRequestScrollToBottom.fire(),x&&this._onUserInput.fire(),this._logService.debug(`sending data "${p}"`,(()=>p.split("").map((_=>_.charCodeAt(0))))),this._onData.fire(p)}triggerBinaryEvent(p){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${p}"`,(()=>p.split("").map((x=>x.charCodeAt(0))))),this._onBinary.fire(p))}};o.CoreService=O=c([d(0,b.IBufferService),d(1,b.ILogService),d(2,b.IOptionsService)],O)},9074:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DecorationService=void 0;const c=l(8055),d=l(8460),u=l(844),f=l(6106);let g=0,b=0;class v extends u.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new f.SortedList((p=>p?.marker.line)),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,u.toDisposable)((()=>this.reset())))}registerDecoration(p){if(p.marker.isDisposed)return;const x=new m(p);if(x){const y=x.marker.onDispose((()=>x.dispose()));x.onDispose((()=>{x&&(this._decorations.delete(x)&&this._onDecorationRemoved.fire(x),y.dispose())})),this._decorations.insert(x),this._onDecorationRegistered.fire(x)}return x}reset(){for(const p of this._decorations.values())p.dispose();this._decorations.clear()}*getDecorationsAtCell(p,x,y){let _=0,k=0;for(const w of this._decorations.getKeyIterator(x))_=w.options.x??0,k=_+(w.options.width??1),p>=_&&p<k&&(!y||(w.options.layer??"bottom")===y)&&(yield w)}forEachDecorationAtCell(p,x,y,_){this._decorations.forEachByKey(x,(k=>{g=k.options.x??0,b=g+(k.options.width??1),p>=g&&p<b&&(!y||(k.options.layer??"bottom")===y)&&_(k)}))}}o.DecorationService=v;class m extends u.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(p){super(),this.options=p,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=p.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.InstantiationService=o.ServiceCollection=void 0;const c=l(2585),d=l(8343);class u{constructor(...g){this._entries=new Map;for(const[b,v]of g)this.set(b,v)}set(g,b){const v=this._entries.get(g);return this._entries.set(g,b),v}forEach(g){for(const[b,v]of this._entries.entries())g(b,v)}has(g){return this._entries.has(g)}get(g){return this._entries.get(g)}}o.ServiceCollection=u,o.InstantiationService=class{constructor(){this._services=new u,this._services.set(c.IInstantiationService,this)}setService(f,g){this._services.set(f,g)}getService(f){return this._services.get(f)}createInstance(f,...g){const b=(0,d.getServiceDependencies)(f).sort(((O,p)=>O.index-p.index)),v=[];for(const O of b){const p=this._services.get(O.id);if(!p)throw new Error(`[createInstance] ${f.name} depends on UNKNOWN service ${O.id}.`);v.push(p)}const m=b.length>0?b[0].index:g.length;if(g.length!==m)throw new Error(`[createInstance] First service dependency of ${f.name} at position ${m+1} conflicts with ${g.length} static arguments`);return new f(...g,...v)}}},7866:function(a,o,l){var c=this&&this.__decorate||function(m,O,p,x){var y,_=arguments.length,k=_<3?O:x===null?x=Object.getOwnPropertyDescriptor(O,p):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(m,O,p,x);else for(var w=m.length-1;w>=0;w--)(y=m[w])&&(k=(_<3?y(k):_>3?y(O,p,k):y(O,p))||k);return _>3&&k&&Object.defineProperty(O,p,k),k},d=this&&this.__param||function(m,O){return function(p,x){O(p,x,m)}};Object.defineProperty(o,"__esModule",{value:!0}),o.traceCall=o.setTraceLogger=o.LogService=void 0;const u=l(844),f=l(2585),g={trace:f.LogLevelEnum.TRACE,debug:f.LogLevelEnum.DEBUG,info:f.LogLevelEnum.INFO,warn:f.LogLevelEnum.WARN,error:f.LogLevelEnum.ERROR,off:f.LogLevelEnum.OFF};let b,v=o.LogService=class extends u.Disposable{get logLevel(){return this._logLevel}constructor(m){super(),this._optionsService=m,this._logLevel=f.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),b=this}_updateLogLevel(){this._logLevel=g[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(m){for(let O=0;O<m.length;O++)typeof m[O]=="function"&&(m[O]=m[O]())}_log(m,O,p){this._evalLazyOptionalParams(p),m.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+O,...p)}trace(m,...O){this._logLevel<=f.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,m,O)}debug(m,...O){this._logLevel<=f.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,m,O)}info(m,...O){this._logLevel<=f.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,m,O)}warn(m,...O){this._logLevel<=f.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,m,O)}error(m,...O){this._logLevel<=f.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,m,O)}};o.LogService=v=c([d(0,f.IOptionsService)],v),o.setTraceLogger=function(m){b=m},o.traceCall=function(m,O,p){if(typeof p.value!="function")throw new Error("not supported");const x=p.value;p.value=function(...y){if(b.logLevel!==f.LogLevelEnum.TRACE)return x.apply(this,y);b.trace(`GlyphRenderer#${x.name}(${y.map((k=>JSON.stringify(k))).join(", ")})`);const _=x.apply(this,y);return b.trace(`GlyphRenderer#${x.name} return`,_),_}}},7302:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OptionsService=o.DEFAULT_OPTIONS=void 0;const c=l(8460),d=l(844),u=l(6114);o.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:u.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const f=["normal","bold","100","200","300","400","500","600","700","800","900"];class g extends d.Disposable{constructor(v){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const m={...o.DEFAULT_OPTIONS};for(const O in v)if(O in m)try{const p=v[O];m[O]=this._sanitizeAndValidateOption(O,p)}catch(p){console.error(p)}this.rawOptions=m,this.options={...m},this._setupOptions(),this.register((0,d.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(v,m){return this.onOptionChange((O=>{O===v&&m(this.rawOptions[v])}))}onMultipleOptionChange(v,m){return this.onOptionChange((O=>{v.indexOf(O)!==-1&&m()}))}_setupOptions(){const v=O=>{if(!(O in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${O}"`);return this.rawOptions[O]},m=(O,p)=>{if(!(O in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${O}"`);p=this._sanitizeAndValidateOption(O,p),this.rawOptions[O]!==p&&(this.rawOptions[O]=p,this._onOptionChange.fire(O))};for(const O in this.rawOptions){const p={get:v.bind(this,O),set:m.bind(this,O)};Object.defineProperty(this.options,O,p)}}_sanitizeAndValidateOption(v,m){switch(v){case"cursorStyle":if(m||(m=o.DEFAULT_OPTIONS[v]),!(function(O){return O==="block"||O==="underline"||O==="bar"})(m))throw new Error(`"${m}" is not a valid value for ${v}`);break;case"wordSeparator":m||(m=o.DEFAULT_OPTIONS[v]);break;case"fontWeight":case"fontWeightBold":if(typeof m=="number"&&1<=m&&m<=1e3)break;m=f.includes(m)?m:o.DEFAULT_OPTIONS[v];break;case"cursorWidth":m=Math.floor(m);case"lineHeight":case"tabStopWidth":if(m<1)throw new Error(`${v} cannot be less than 1, value: ${m}`);break;case"minimumContrastRatio":m=Math.max(1,Math.min(21,Math.round(10*m)/10));break;case"scrollback":if((m=Math.min(m,4294967295))<0)throw new Error(`${v} cannot be less than 0, value: ${m}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(m<=0)throw new Error(`${v} cannot be less than or equal to 0, value: ${m}`);break;case"rows":case"cols":if(!m&&m!==0)throw new Error(`${v} must be numeric, value: ${m}`);break;case"windowsPty":m=m??{}}return m}}o.OptionsService=g},2660:function(a,o,l){var c=this&&this.__decorate||function(g,b,v,m){var O,p=arguments.length,x=p<3?b:m===null?m=Object.getOwnPropertyDescriptor(b,v):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(g,b,v,m);else for(var y=g.length-1;y>=0;y--)(O=g[y])&&(x=(p<3?O(x):p>3?O(b,v,x):O(b,v))||x);return p>3&&x&&Object.defineProperty(b,v,x),x},d=this&&this.__param||function(g,b){return function(v,m){b(v,m,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkService=void 0;const u=l(2585);let f=o.OscLinkService=class{constructor(g){this._bufferService=g,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(g){const b=this._bufferService.buffer;if(g.id===void 0){const y=b.addMarker(b.ybase+b.y),_={data:g,id:this._nextId++,lines:[y]};return y.onDispose((()=>this._removeMarkerFromLink(_,y))),this._dataByLinkId.set(_.id,_),_.id}const v=g,m=this._getEntryIdKey(v),O=this._entriesWithId.get(m);if(O)return this.addLineToLink(O.id,b.ybase+b.y),O.id;const p=b.addMarker(b.ybase+b.y),x={id:this._nextId++,key:this._getEntryIdKey(v),data:v,lines:[p]};return p.onDispose((()=>this._removeMarkerFromLink(x,p))),this._entriesWithId.set(x.key,x),this._dataByLinkId.set(x.id,x),x.id}addLineToLink(g,b){const v=this._dataByLinkId.get(g);if(v&&v.lines.every((m=>m.line!==b))){const m=this._bufferService.buffer.addMarker(b);v.lines.push(m),m.onDispose((()=>this._removeMarkerFromLink(v,m)))}}getLinkData(g){return this._dataByLinkId.get(g)?.data}_getEntryIdKey(g){return`${g.id};;${g.uri}`}_removeMarkerFromLink(g,b){const v=g.lines.indexOf(b);v!==-1&&(g.lines.splice(v,1),g.lines.length===0&&(g.data.id!==void 0&&this._entriesWithId.delete(g.key),this._dataByLinkId.delete(g.id)))}};o.OscLinkService=f=c([d(0,u.IBufferService)],f)},8343:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createDecorator=o.getServiceDependencies=o.serviceRegistry=void 0;const l="di$target",c="di$dependencies";o.serviceRegistry=new Map,o.getServiceDependencies=function(d){return d[c]||[]},o.createDecorator=function(d){if(o.serviceRegistry.has(d))return o.serviceRegistry.get(d);const u=function(f,g,b){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(v,m,O){m[l]===m?m[c].push({id:v,index:O}):(m[c]=[{id:v,index:O}],m[l]=m)})(u,f,b)};return u.toString=()=>d,o.serviceRegistry.set(d,u),u}},2585:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.IDecorationService=o.IUnicodeService=o.IOscLinkService=o.IOptionsService=o.ILogService=o.LogLevelEnum=o.IInstantiationService=o.ICharsetService=o.ICoreService=o.ICoreMouseService=o.IBufferService=void 0;const c=l(8343);var d;o.IBufferService=(0,c.createDecorator)("BufferService"),o.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),o.ICoreService=(0,c.createDecorator)("CoreService"),o.ICharsetService=(0,c.createDecorator)("CharsetService"),o.IInstantiationService=(0,c.createDecorator)("InstantiationService"),(function(u){u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.OFF=5]="OFF"})(d||(o.LogLevelEnum=d={})),o.ILogService=(0,c.createDecorator)("LogService"),o.IOptionsService=(0,c.createDecorator)("OptionsService"),o.IOscLinkService=(0,c.createDecorator)("OscLinkService"),o.IUnicodeService=(0,c.createDecorator)("UnicodeService"),o.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeService=void 0;const c=l(8460),d=l(225);class u{static extractShouldJoin(g){return(1&g)!=0}static extractWidth(g){return g>>1&3}static extractCharKind(g){return g>>3}static createPropertyValue(g,b,v=!1){return(16777215&g)<<3|(3&b)<<1|(v?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const g=new d.UnicodeV6;this.register(g),this._active=g.version,this._activeProvider=g}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(g){if(!this._providers[g])throw new Error(`unknown Unicode version "${g}"`);this._active=g,this._activeProvider=this._providers[g],this._onChange.fire(g)}register(g){this._providers[g.version]=g}wcwidth(g){return this._activeProvider.wcwidth(g)}getStringCellWidth(g){let b=0,v=0;const m=g.length;for(let O=0;O<m;++O){let p=g.charCodeAt(O);if(55296<=p&&p<=56319){if(++O>=m)return b+this.wcwidth(p);const _=g.charCodeAt(O);56320<=_&&_<=57343?p=1024*(p-55296)+_-56320+65536:b+=this.wcwidth(_)}const x=this.charProperties(p,v);let y=u.extractWidth(x);u.extractShouldJoin(x)&&(y-=u.extractWidth(v)),b+=y,v=x}return b}charProperties(g,b){return this._activeProvider.charProperties(g,b)}}o.UnicodeService=u}},i={};function r(a){var o=i[a];if(o!==void 0)return o.exports;var l=i[a]={exports:{}};return t[a].call(l.exports,l,l.exports,r),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.Terminal=void 0;const o=r(9042),l=r(3236),c=r(844),d=r(5741),u=r(8285),f=r(7975),g=r(7090),b=["cols","rows"];class v extends c.Disposable{constructor(O){super(),this._core=this.register(new l.Terminal(O)),this._addonManager=this.register(new d.AddonManager),this._publicOptions={...this._core.options};const p=y=>this._core.options[y],x=(y,_)=>{this._checkReadonlyOptions(y),this._core.options[y]=_};for(const y in this._core.options){const _={get:p.bind(this,y),set:x.bind(this,y)};Object.defineProperty(this._publicOptions,y,_)}}_checkReadonlyOptions(O){if(b.includes(O))throw new Error(`Option "${O}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new f.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new g.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new u.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const O=this._core.coreService.decPrivateModes;let p="none";switch(this._core.coreMouseService.activeProtocol){case"X10":p="x10";break;case"VT200":p="vt200";break;case"DRAG":p="drag";break;case"ANY":p="any"}return{applicationCursorKeysMode:O.applicationCursorKeys,applicationKeypadMode:O.applicationKeypad,bracketedPasteMode:O.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:p,originMode:O.origin,reverseWraparoundMode:O.reverseWraparound,sendFocusMode:O.sendFocus,wraparoundMode:O.wraparound}}get options(){return this._publicOptions}set options(O){for(const p in O)this._publicOptions[p]=O[p]}blur(){this._core.blur()}focus(){this._core.focus()}input(O,p=!0){this._core.input(O,p)}resize(O,p){this._verifyIntegers(O,p),this._core.resize(O,p)}open(O){this._core.open(O)}attachCustomKeyEventHandler(O){this._core.attachCustomKeyEventHandler(O)}attachCustomWheelEventHandler(O){this._core.attachCustomWheelEventHandler(O)}registerLinkProvider(O){return this._core.registerLinkProvider(O)}registerCharacterJoiner(O){return this._checkProposedApi(),this._core.registerCharacterJoiner(O)}deregisterCharacterJoiner(O){this._checkProposedApi(),this._core.deregisterCharacterJoiner(O)}registerMarker(O=0){return this._verifyIntegers(O),this._core.registerMarker(O)}registerDecoration(O){return this._checkProposedApi(),this._verifyPositiveIntegers(O.x??0,O.width??0,O.height??0),this._core.registerDecoration(O)}hasSelection(){return this._core.hasSelection()}select(O,p,x){this._verifyIntegers(O,p,x),this._core.select(O,p,x)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(O,p){this._verifyIntegers(O,p),this._core.selectLines(O,p)}dispose(){super.dispose()}scrollLines(O){this._verifyIntegers(O),this._core.scrollLines(O)}scrollPages(O){this._verifyIntegers(O),this._core.scrollPages(O)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(O){this._verifyIntegers(O),this._core.scrollToLine(O)}clear(){this._core.clear()}write(O,p){this._core.write(O,p)}writeln(O,p){this._core.write(O),this._core.write(`\r
|
|
48
|
-
`,p)}paste(O){this._core.paste(O)}refresh(O,p){this._verifyIntegers(O,p),this._core.refresh(O,p)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(O){this._addonManager.loadAddon(this,O)}static get strings(){return o}_verifyIntegers(...O){for(const p of O)if(p===1/0||isNaN(p)||p%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...O){for(const p of O)if(p&&(p===1/0||isNaN(p)||p%1!=0||p<0))throw new Error("This API only accepts positive integers")}}a.Terminal=v})(),n})()))})(iu)),iu.exports}var NA=LA(),ru={exports:{}},D0;function DA(){return D0||(D0=1,(function(s,e){(function(t,i){s.exports=i()})(self,(()=>(()=>{var t={};return(()=>{var i=t;Object.defineProperty(i,"__esModule",{value:!0}),i.FitAddon=void 0,i.FitAddon=class{activate(r){this._terminal=r}dispose(){}fit(){const r=this.proposeDimensions();if(!r||!this._terminal||isNaN(r.cols)||isNaN(r.rows))return;const n=this._terminal._core;this._terminal.rows===r.rows&&this._terminal.cols===r.cols||(n._renderService.clear(),this._terminal.resize(r.cols,r.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const r=this._terminal._core,n=r._renderService.dimensions;if(n.css.cell.width===0||n.css.cell.height===0)return;const a=this._terminal.options.scrollback===0?0:r.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(o.getPropertyValue("height")),c=Math.max(0,parseInt(o.getPropertyValue("width"))),d=window.getComputedStyle(this._terminal.element),u=l-(parseInt(d.getPropertyValue("padding-top"))+parseInt(d.getPropertyValue("padding-bottom"))),f=c-(parseInt(d.getPropertyValue("padding-right"))+parseInt(d.getPropertyValue("padding-left")))-a;return{cols:Math.max(2,Math.floor(f/n.css.cell.width)),rows:Math.max(1,Math.floor(u/n.css.cell.height))}}}})(),t})()))})(ru)),ru.exports}var IA=DA(),nu={exports:{}},I0;function BA(){return I0||(I0=1,(function(s,e){(function(t,i){s.exports=i()})(self,(()=>(()=>{var t={345:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.runAndSubscribe=o.forwardEvent=o.EventEmitter=void 0,o.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.push(l),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===l)return void this._listeners.splice(c,1)}}})),this._event}fire(l,c){const d=[];for(let u=0;u<this._listeners.length;u++)d.push(this._listeners[u]);for(let u=0;u<d.length;u++)d[u].call(void 0,l,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},o.forwardEvent=function(l,c){return l((d=>c.fire(d)))},o.runAndSubscribe=function(l,c){return c(void 0),l((d=>c(d)))}},859:(a,o)=>{function l(c){for(const d of c)d.dispose();c.length=0}Object.defineProperty(o,"__esModule",{value:!0}),o.getDisposeArrayDisposable=o.disposeArray=o.toDisposable=o.MutableDisposable=o.Disposable=void 0,o.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const d=this._disposables.indexOf(c);d!==-1&&this._disposables.splice(d,1)}},o.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){this._isDisposed||c===this._value||(this._value?.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},o.toDisposable=function(c){return{dispose:c}},o.disposeArray=l,o.getDisposeArrayDisposable=function(c){return{dispose:()=>l(c)}}}},i={};function r(a){var o=i[a];if(o!==void 0)return o.exports;var l=i[a]={exports:{}};return t[a](l,l.exports,r),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.SearchAddon=void 0;const o=r(345),l=r(859),c=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?";class d extends l.Disposable{constructor(f){super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new l.MutableDisposable),this._linesCacheTimeoutId=0,this._linesCacheDisposables=new l.MutableDisposable,this._onDidChangeResults=this.register(new o.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=f?.highlightLimit??1e3}activate(f){this._terminal=f,this.register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this.register(this._terminal.onResize((()=>this._updateMatches()))),this.register((0,l.toDisposable)((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&this._lastSearchOptions?.decorations&&(this._highlightTimeout=setTimeout((()=>{const f=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(f,{...this._lastSearchOptions,incremental:!0,noScroll:!0})}),200))}clearDecorations(f){this._selectedDecoration.clear(),(0,l.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),f||(this._cachedSearchTerm=void 0)}clearActiveDecoration(){this._selectedDecoration.clear()}findNext(f,g){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const b=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,g);this._lastSearchOptions=g,g?.decorations&&(this._cachedSearchTerm===void 0||f!==this._cachedSearchTerm||b)&&this._highlightAllMatches(f,g);const v=this._findNextAndSelect(f,g);return this._fireResults(g),this._cachedSearchTerm=f,v}_highlightAllMatches(f,g){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!f||f.length===0)return void this.clearDecorations();g=g||{},this.clearDecorations(!0);const b=[];let v,m=this._find(f,0,0,g);for(;m&&(v?.row!==m.row||v?.col!==m.col)&&!(b.length>=this._highlightLimit);)v=m,b.push(v),m=this._find(f,v.col+v.term.length>=this._terminal.cols?v.row+1:v.row,v.col+v.term.length>=this._terminal.cols?0:v.col+1,g);for(const O of b){const p=this._createResultDecoration(O,g.decorations);p&&(this._highlightedLines.add(p.marker.line),this._highlightDecorations.push({decoration:p,match:O,dispose(){p.dispose()}}))}}_find(f,g,b,v){if(!this._terminal||!f||f.length===0)return this._terminal?.clearSelection(),void this.clearDecorations();if(b>this._terminal.cols)throw new Error(`Invalid col: ${b} to search in terminal of ${this._terminal.cols} cols`);let m;this._initLinesCache();const O={startRow:g,startCol:b};if(m=this._findInLine(f,O,v),!m)for(let p=g+1;p<this._terminal.buffer.active.baseY+this._terminal.rows&&(O.startRow=p,O.startCol=0,m=this._findInLine(f,O,v),!m);p++);return m}_findNextAndSelect(f,g){if(!this._terminal||!f||f.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;const b=this._terminal.getSelectionPosition();this._terminal.clearSelection();let v=0,m=0;b&&(this._cachedSearchTerm===f?(v=b.end.x,m=b.end.y):(v=b.start.x,m=b.start.y)),this._initLinesCache();const O={startRow:m,startCol:v};let p=this._findInLine(f,O,g);if(!p)for(let x=m+1;x<this._terminal.buffer.active.baseY+this._terminal.rows&&(O.startRow=x,O.startCol=0,p=this._findInLine(f,O,g),!p);x++);if(!p&&m!==0)for(let x=0;x<m&&(O.startRow=x,O.startCol=0,p=this._findInLine(f,O,g),!p);x++);return!p&&b&&(O.startRow=b.start.y,O.startCol=0,p=this._findInLine(f,O,g)),this._selectResult(p,g?.decorations,g?.noScroll)}findPrevious(f,g){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");const b=!this._lastSearchOptions||this._didOptionsChange(this._lastSearchOptions,g);this._lastSearchOptions=g,g?.decorations&&(this._cachedSearchTerm===void 0||f!==this._cachedSearchTerm||b)&&this._highlightAllMatches(f,g);const v=this._findPreviousAndSelect(f,g);return this._fireResults(g),this._cachedSearchTerm=f,v}_didOptionsChange(f,g){return!!g&&(f.caseSensitive!==g.caseSensitive||f.regex!==g.regex||f.wholeWord!==g.wholeWord)}_fireResults(f){if(f?.decorations){let g=-1;if(this._selectedDecoration.value){const b=this._selectedDecoration.value.match;for(let v=0;v<this._highlightDecorations.length;v++){const m=this._highlightDecorations[v].match;if(m.row===b.row&&m.col===b.col&&m.size===b.size){g=v;break}}}this._onDidChangeResults.fire({resultIndex:g,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(f,g){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!f||f.length===0)return this._terminal?.clearSelection(),this.clearDecorations(),!1;const b=this._terminal.getSelectionPosition();this._terminal.clearSelection();let v=this._terminal.buffer.active.baseY+this._terminal.rows-1,m=this._terminal.cols;const O=!0;this._initLinesCache();const p={startRow:v,startCol:m};let x;if(b&&(p.startRow=v=b.start.y,p.startCol=m=b.start.x,this._cachedSearchTerm!==f&&(x=this._findInLine(f,p,g,!1),x||(p.startRow=v=b.end.y,p.startCol=m=b.end.x))),x||(x=this._findInLine(f,p,g,O)),!x){p.startCol=Math.max(p.startCol,this._terminal.cols);for(let y=v-1;y>=0&&(p.startRow=y,x=this._findInLine(f,p,g,O),!x);y--);}if(!x&&v!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let y=this._terminal.buffer.active.baseY+this._terminal.rows-1;y>=v&&(p.startRow=y,x=this._findInLine(f,p,g,O),!x);y--);return this._selectResult(x,g?.decorations,g?.noScroll)}_initLinesCache(){const f=this._terminal;this._linesCache||(this._linesCache=new Array(f.buffer.active.length),this._linesCacheDisposables.value=(0,l.getDisposeArrayDisposable)([f.onLineFeed((()=>this._destroyLinesCache())),f.onCursorMove((()=>this._destroyLinesCache())),f.onResize((()=>this._destroyLinesCache()))])),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(f,g,b){return(f===0||c.includes(g[f-1]))&&(f+b.length===g.length||c.includes(g[f+b.length]))}_findInLine(f,g,b={},v=!1){const m=this._terminal,O=g.startRow,p=g.startCol;if(m.buffer.active.getLine(O)?.isWrapped)return v?void(g.startCol+=m.cols):(g.startRow--,g.startCol+=m.cols,this._findInLine(f,g,b));let y=this._linesCache?.[O];y||(y=this._translateBufferLineToStringWithWrap(O,!0),this._linesCache&&(this._linesCache[O]=y));const[_,k]=y,w=this._bufferColsToStringOffset(O,p),S=b.caseSensitive?f:f.toLowerCase(),Q=b.caseSensitive?_:_.toLowerCase();let I=-1;if(b.regex){const D=RegExp(S,"g");let $;if(v)for(;$=D.exec(Q.slice(0,w));)I=D.lastIndex-$[0].length,f=$[0],D.lastIndex-=f.length-1;else $=D.exec(Q.slice(w)),$&&$[0].length>0&&(I=w+(D.lastIndex-$[0].length),f=$[0])}else v?w-S.length>=0&&(I=Q.lastIndexOf(S,w-S.length)):I=Q.indexOf(S,w);if(I>=0){if(b.wholeWord&&!this._isWholeWord(I,Q,f))return;let D=0;for(;D<k.length-1&&I>=k[D+1];)D++;let $=D;for(;$<k.length-1&&I+f.length>=k[$+1];)$++;const j=I-k[D],B=I+f.length-k[$],F=this._stringLengthToBufferSize(O+D,j);return{term:f,col:F,row:O+D,size:this._stringLengthToBufferSize(O+$,B)-F+m.cols*($-D)}}}_stringLengthToBufferSize(f,g){const b=this._terminal.buffer.active.getLine(f);if(!b)return 0;for(let v=0;v<g;v++){const m=b.getCell(v);if(!m)break;const O=m.getChars();O.length>1&&(g-=O.length-1);const p=b.getCell(v+1);p&&p.getWidth()===0&&g++}return g}_bufferColsToStringOffset(f,g){const b=this._terminal;let v=f,m=0,O=b.buffer.active.getLine(v);for(;g>0&&O;){for(let p=0;p<g&&p<b.cols;p++){const x=O.getCell(p);if(!x)break;x.getWidth()&&(m+=x.getCode()===0?1:x.getChars().length)}if(v++,O=b.buffer.active.getLine(v),O&&!O.isWrapped)break;g-=b.cols}return m}_translateBufferLineToStringWithWrap(f,g){const b=this._terminal,v=[],m=[0];let O=b.buffer.active.getLine(f);for(;O;){const p=b.buffer.active.getLine(f+1),x=!!p&&p.isWrapped;let y=O.translateToString(!x&&g);if(x&&p){const _=O.getCell(O.length-1);_&&_.getCode()===0&&_.getWidth()===1&&p.getCell(0)?.getWidth()===2&&(y=y.slice(0,-1))}if(v.push(y),!x)break;m.push(m[m.length-1]+y.length),f++,O=p}return[v.join(""),m]}_selectResult(f,g,b){const v=this._terminal;if(this._selectedDecoration.clear(),!f)return v.clearSelection(),!1;if(v.select(f.col,f.row,f.size),g){const m=v.registerMarker(-v.buffer.active.baseY-v.buffer.active.cursorY+f.row);if(m){const O=v.registerDecoration({marker:m,x:f.col,width:f.size,backgroundColor:g.activeMatchBackground,layer:"top",overviewRulerOptions:{color:g.activeMatchColorOverviewRuler}});if(O){const p=[];p.push(m),p.push(O.onRender((x=>this._applyStyles(x,g.activeMatchBorder,!0)))),p.push(O.onDispose((()=>(0,l.disposeArray)(p)))),this._selectedDecoration.value={decoration:O,match:f,dispose(){O.dispose()}}}}}if(!b&&(f.row>=v.buffer.active.viewportY+v.rows||f.row<v.buffer.active.viewportY)){let m=f.row-v.buffer.active.viewportY;m-=Math.floor(v.rows/2),v.scrollLines(m)}return!0}_applyStyles(f,g,b){f.classList.contains("xterm-find-result-decoration")||(f.classList.add("xterm-find-result-decoration"),g&&(f.style.outline=`1px solid ${g}`)),b&&f.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(f,g){const b=this._terminal,v=b.registerMarker(-b.buffer.active.baseY-b.buffer.active.cursorY+f.row);if(!v)return;const m=b.registerDecoration({marker:v,x:f.col,width:f.size,backgroundColor:g.matchBackground,overviewRulerOptions:this._highlightedLines.has(v.line)?void 0:{color:g.matchOverviewRuler,position:"center"}});if(m){const O=[];O.push(v),O.push(m.onRender((p=>this._applyStyles(p,g.matchBorder,!1)))),O.push(m.onDispose((()=>(0,l.disposeArray)(O))))}return m}}a.SearchAddon=d})(),n})()))})(nu)),nu.exports}var WA=BA(),ou={exports:{}},B0;function XA(){return B0||(B0=1,(function(s,e){(function(t,i){s.exports=i()})(self,(()=>(()=>{var t={6:(a,o)=>{function l(d){try{const u=new URL(d),f=u.password&&u.username?`${u.protocol}//${u.username}:${u.password}@${u.host}`:u.username?`${u.protocol}//${u.username}@${u.host}`:`${u.protocol}//${u.host}`;return d.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(o,"__esModule",{value:!0}),o.LinkComputer=o.WebLinkProvider=void 0,o.WebLinkProvider=class{constructor(d,u,f,g={}){this._terminal=d,this._regex=u,this._handler=f,this._options=g}provideLinks(d,u){const f=c.computeLink(d,this._regex,this._terminal,this._handler);u(this._addCallbacks(f))}_addCallbacks(d){return d.map((u=>(u.leave=this._options.leave,u.hover=(f,g)=>{if(this._options.hover){const{range:b}=u;this._options.hover(f,g,b)}},u)))}};class c{static computeLink(u,f,g,b){const v=new RegExp(f.source,(f.flags||"")+"g"),[m,O]=c._getWindowedLineStrings(u-1,g),p=m.join("");let x;const y=[];for(;x=v.exec(p);){const _=x[0];if(!l(_))continue;const[k,w]=c._mapStrIdx(g,O,0,x.index),[S,Q]=c._mapStrIdx(g,k,w,_.length);if(k===-1||w===-1||S===-1||Q===-1)continue;const I={start:{x:w+1,y:k+1},end:{x:Q,y:S+1}};y.push({range:I,text:_,activate:b})}return y}static _getWindowedLineStrings(u,f){let g,b=u,v=u,m=0,O="";const p=[];if(g=f.buffer.active.getLine(u)){const x=g.translateToString(!0);if(g.isWrapped&&x[0]!==" "){for(m=0;(g=f.buffer.active.getLine(--b))&&m<2048&&(O=g.translateToString(!0),m+=O.length,p.push(O),g.isWrapped&&O.indexOf(" ")===-1););p.reverse()}for(p.push(x),m=0;(g=f.buffer.active.getLine(++v))&&g.isWrapped&&m<2048&&(O=g.translateToString(!0),m+=O.length,p.push(O),O.indexOf(" ")===-1););}return[p,b]}static _mapStrIdx(u,f,g,b){const v=u.buffer.active,m=v.getNullCell();let O=g;for(;b;){const p=v.getLine(f);if(!p)return[-1,-1];for(let x=O;x<p.length;++x){p.getCell(x,m);const y=m.getChars();if(m.getWidth()&&(b-=y.length||1,x===p.length-1&&y==="")){const _=v.getLine(f+1);_&&_.isWrapped&&(_.getCell(0,m),m.getWidth()===2&&(b+=1))}if(b<0)return[f,x]}f++,O=0}return[f,O]}}o.LinkComputer=c}},i={};function r(a){var o=i[a];if(o!==void 0)return o.exports;var l=i[a]={exports:{}};return t[a](l,l.exports,r),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.WebLinksAddon=void 0;const o=r(6),l=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function c(d,u){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=u}else console.warn("Opening link blocked as opener could not be cleared")}a.WebLinksAddon=class{constructor(d=c,u={}){this._handler=d,this._options=u}activate(d){this._terminal=d;const u=this._options,f=u.urlRegex||l;this._linkProvider=this._terminal.registerLinkProvider(new o.WebLinkProvider(this._terminal,f,this._handler,u))}dispose(){this._linkProvider?.dispose()}}})(),n})()))})(ou)),ou.exports}var qA=XA();function au(s,e){try{return getComputedStyle(document.documentElement).getPropertyValue(s).trim()||e}catch{return e}}function W0(s){return typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC")?s.metaKey:s.ctrlKey}function F1(s){return!s||s.includes(" ")||/^https?:\/\//i.test(s)?!1:/^[a-zA-Z]:[\\/]/.test(s)||s.startsWith("/")||s.startsWith("~/")||s.startsWith("./")||s.startsWith("../")?!0:/^[\w./\\-]+\.[a-zA-Z0-9]{1,8}$/.test(s)}function X0(s,e){const t=s.trim().replace(/\\/g,"/");return!t||!F1(t)?null:/^[a-zA-Z]:\//.test(t)||t.startsWith("~/")?t:t.startsWith("/")?/^\/packages\//.test(t)?!e||e==="/"?null:ym(t.slice(1),e):t:!e||e==="/"?null:ym(t,e)}function q0(s){return s.clientWidth>=16&&s.clientHeight>=16}function zA({terminalId:s,title:e,cwd:t,active:i=!0,onMeta:r,onSelection:n,onOpenUrl:a,onOpenPath:o,apiRef:l}){const c=C.useRef(null),d=C.useRef(null),u=C.useRef(null),f=C.useRef(null),g=C.useRef(r),b=C.useRef(n),v=C.useRef(a),m=C.useRef(o),O=C.useRef(t);g.current=r,b.current=n,v.current=a,m.current=o,C.useEffect(()=>{t&&t!=="/"&&(O.current=t)},[t]);const[p,x]=C.useState(null),[y,_]=C.useState(!1),[k,w]=C.useState(""),[S,Q]=C.useState(!1),I=C.useRef(!0),D=C.useCallback(()=>{const j=c.current,B=d.current,F=u.current;if(!j||!B||!F||!q0(j))return!1;try{return F.fit(),!0}catch{return!1}},[]),$=C.useCallback(()=>{const j=d.current;j&&(j.scrollToBottom(),I.current=!0,Q(!1))},[]);return C.useEffect(()=>{JS(s);const j=c.current,B=window.markusDesktop?.terminal;if(!j)return;if(!B){x("Embedded terminal requires Markus Desktop.");return}let F=!1,V=null,Z=null,se,T,A,N=null,z=null,U=null,ne=null;const Se=async()=>{if(F||!c.current)return;if(!q0(c.current)){ne=window.setTimeout(()=>{Se()},50);return}const Pe=au("--color-surface-primary","#0f1419"),X=au("--color-fg-primary","#e7e9ea");V=new NA.Terminal({cursorBlink:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,lineHeight:1.25,allowProposedApi:!0,theme:{background:Pe,foreground:X,cursor:au("--color-brand-500","#3b82f6"),selectionBackground:"rgba(59, 130, 246, 0.35)"}});const M=new IA.FitAddon,K=new WA.SearchAddon,ie=new qA.WebLinksAddon((oe,G)=>{W0(oe)&&v.current?.(G)});if(V.loadAddon(M),V.loadAddon(K),V.loadAddon(ie),V.open(c.current),d.current=V,u.current=M,f.current=K,!D())try{M.fit()}catch{}V.registerLinkProvider({provideLinks:(oe,G)=>{const $e=V.buffer.active.getLine(oe-1);if(!$e){G(void 0);return}const Ie=$e.translateToString(!0),We=/(?:(?:[A-Za-z]:|\/|~\/)[\w./\\-]+|(?:\.\.?\/)?[\w./\\-]+\.[a-zA-Z0-9]{1,8})/g,Y=[];let ee;for(;ee=We.exec(Ie);){const le=ee[0];F1(le)&&X0(le,O.current)&&Y.push({range:{start:{x:ee.index+1,y:oe},end:{x:ee.index+le.length,y:oe}},text:le,decorations:{pointerCursor:!0,underline:!0},activate:ke=>{if(!W0(ke))return;const Ce=X0(le,O.current);Ce&&m.current?.(Ce)}})}G(Y.length?Y:void 0)}});try{const oe=Math.max(V.cols||80,2),G=Math.max(V.rows||24,1);let $e=t||O.current;if(!$e||$e==="/")try{$e=await window.markusDesktop?.getDefaultCwd?.()}catch{}$e==="/"&&($e=void 0),$e&&(O.current=$e);const Ie=await B.create(s,{cwd:$e,title:e,cols:oe,rows:G});if(F)return;if(!Ie.ok){x(Ie.error||"Failed to create terminal");return}Ie.info&&(Ie.info.cwd&&(O.current=Ie.info.cwd),g.current?.(s,{title:Ie.info.title,cwd:Ie.info.cwd}));const We=await B.getBuffer(s,{maxChars:12e4});if(F)return;We.ok&&We.content&&V.write(We.content),D(),B.resize(s,V.cols,V.rows),V.focus()}catch(oe){F||x(oe instanceof Error?oe.message:String(oe));return}se=B.onData?.(oe=>{oe.id!==s||!d.current||(d.current.write(oe.data),I.current||Q(!0))}),A=B.onEvent?.(oe=>{oe.id!==s||oe.type!=="cwd"||!oe.cwd||(O.current=oe.cwd,g.current?.(s,{cwd:oe.cwd}))}),T=B.onExit?.(()=>{}),N=V.onData(oe=>{B.write(s,oe)}),z=V.onScroll(()=>{const oe=d.current;if(!oe)return;const G=oe.buffer.active,$e=G.viewportY>=G.baseY-1;I.current=$e,$e&&Q(!1)}),U=V.onSelectionChange(()=>{const oe=d.current,G=c.current;if(!oe||!G)return;if(!oe.getSelection().trim()){b.current?.(null);return}requestAnimationFrame(()=>{const Ie=d.current,We=c.current;if(!Ie||!We)return;const Y=Ie.getSelection().trim();if(!Y){b.current?.(null);return}let ee,le;const ke=We.querySelectorAll(".xterm-selection div");let Ce=1/0,dt=1/0,ht=-1/0;if(ke.forEach(yt=>{const ss=yt.getBoundingClientRect();ss.width<1&&ss.height<1||(Ce=Math.min(Ce,ss.top),dt=Math.min(dt,ss.left),ht=Math.max(ht,ss.right))}),Ce<1/0)ee=(dt+ht)/2,le=Ce;else{const yt=Ie.getSelectionPosition?.(),Lt=(We.querySelector(".xterm-screen")??We).getBoundingClientRect(),zs=Math.max(Ie.cols,1),vs=Math.max(Ie.rows,1),bs=Lt.width/zs,si=Lt.height/vs;if(yt){const Zs=Ie.buffer.active.viewportY,Ps=Math.max(0,yt.start.y-Zs);ee=Lt.left+(yt.start.x+.5)*bs,le=Lt.top+Ps*si}else ee=Lt.left+Lt.width/2,le=Lt.top+12}b.current?.({text:Y,x:ee,y:le})})}),Z=new ResizeObserver(()=>{!D()||!d.current||B.resize(s,d.current.cols,d.current.rows)}),Z.observe(c.current),l&&(l.current={getSelection:()=>d.current?.getSelection()??"",getRecentOutput:async(oe=80)=>{const G=await B.getBuffer(s,{maxLines:oe});return G.ok&&G.content||""},focus:()=>d.current?.focus(),findNext:oe=>{f.current?.findNext(oe)},clearSelection:()=>d.current?.clearSelection()})};return Se(),()=>{F=!0,ne!=null&&window.clearTimeout(ne),se?.(),T?.(),A?.(),N?.dispose(),z?.dispose(),U?.dispose(),Z?.disconnect(),l&&(l.current=null);try{V?.dispose()}catch{}d.current=null,u.current=null,f.current=null}},[s]),C.useEffect(()=>{if(!i)return;const j=window.requestAnimationFrame(()=>{D();const B=d.current;B&&(window.markusDesktop?.terminal?.resize(s,B.cols,B.rows),B.focus())});return()=>window.cancelAnimationFrame(j)},[i,s,D]),C.useEffect(()=>{const j=B=>{if(!i)return;if((navigator.platform.toUpperCase().includes("MAC")?B.metaKey&&!B.ctrlKey:B.ctrlKey&&!B.metaKey)&&!B.altKey&&!B.shiftKey&&B.key.toLowerCase()==="f"){const Z=B.target;Z instanceof HTMLElement&&(c.current?.contains(Z)||Z.closest(".xterm"))&&(B.preventDefault(),_(!0))}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[i]),h.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col rounded-lg overflow-hidden border border-border-default bg-surface-primary",children:[y&&h.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 px-2 py-1.5 border-b border-border-default bg-surface-elevated",children:[h.jsx("input",{autoFocus:!0,value:k,onChange:j=>w(j.target.value),onKeyDown:j=>{j.key==="Enter"?(j.preventDefault(),f.current?.findNext(k)):j.key==="Escape"&&_(!1)},placeholder:"Find in terminal…",className:"flex-1 min-w-0 text-xs bg-transparent outline-none text-fg-primary placeholder:text-fg-muted"}),h.jsx("button",{type:"button",className:"text-[11px] px-2 py-0.5 rounded text-fg-secondary hover:bg-surface-overlay",onClick:()=>f.current?.findNext(k),children:"Next"}),h.jsx("button",{type:"button",className:"text-[11px] px-2 py-0.5 rounded text-fg-tertiary hover:bg-surface-overlay",onClick:()=>_(!1),children:"Esc"})]}),p?h.jsx("div",{className:"flex-1 flex items-center justify-center p-4 text-sm text-red-500",children:p}):h.jsx("div",{ref:c,className:"flex-1 min-h-0 w-full h-full [&_.xterm]:h-full [&_.xterm]:w-full [&_.xterm-viewport]:overflow-auto"}),S&&h.jsx("button",{type:"button",onClick:$,className:"absolute bottom-3 right-3 z-10 text-[11px] px-2.5 py-1 rounded-md bg-brand-600 text-white shadow-lg hover:bg-brand-500",children:"↓ Jump to bottom"})]})}function z0(s){return/^(https?|file):\/\//i.test(s)?s:/^[a-zA-Z]:[\\/]/.test(s)?`file:///${s.replace(/\\/g,"/")}`:`file://${s.startsWith("/")?s:`/${s}`}`}function lu(s){return/^https?:\/\//i.test(s)}function ZA(s){return s.kind==="deliverable"?s.deliverable.reference??"":s.kind==="url"?s.url:s.kind==="terminal"?s.terminalId:s.path}function VA(s){return s.kind==="deliverable"?s.deliverable.title||s.deliverable.reference||"":s.kind==="url"?s.title||s.url:s.kind==="terminal"?s.title||"Terminal":s.title||s.path.split(/[/\\]/).pop()||s.path}function FA(s,e){if(s.kind==="file")return`file:${s.path}:${e??""}`;if(s.kind==="url")return`url:${s.browserId||s.url}:${e??""}`;if(s.kind==="terminal")return`terminal:${s.terminalId}:${e??""}`;const t=s.deliverable;return`deliverable:${t.id||t.reference||t.title||"unknown"}:${e??""}`}function cu(s){return s==null||!Number.isFinite(s)?"":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function YA({payload:s,onClose:e,width:t,onResizeStart:i,onAddToChat:r,tabs:n,activeTabId:a,onSelectTab:o,onCloseTab:l,onNewTab:c,fullscreen:d,onToggleFullscreen:u,onBrowserMeta:f,panelMode:g="browser",onPanelModeChange:b,onTerminalMeta:v,onOpenUrlFromTerminal:m,onOpenPathFromTerminal:O}){const{t:p}=Pt(["deliverables","agent","common"]),[x,y]=C.useState({mode:"loading"}),[_,k]=C.useState(!1),[w,S]=C.useState(null),[Q,I]=C.useState({}),[D,$]=C.useState({}),[j,B]=C.useState(!1),F=C.useRef(null),V=C.useRef(null),Z=C.useRef(null),se=C.useRef(null),T=C.useRef(!1);T.current=j;const A=C.useCallback(()=>z1(T.current,p("common:fileEditor.discardConfirm",{defaultValue:"Discard unsaved changes?"})),[p]);C.useEffect(()=>{let Y=!1;J.browser.tabOwnership().then(le=>{if(Y)return;const ke={};for(const Ce of le.ownership??[])ke[Ce.pageId]={agentId:Ce.agentId,agentName:Ce.agentName||Ce.agentId};I(ke)}).catch(()=>{});const ee=gt.on("ui:browser_ownership",le=>{const ke=le.payload;typeof ke.pageId=="number"&&I(Ce=>{if(ke.action==="released"||!ke.agentId){if(!(ke.pageId in Ce))return Ce;const dt={...Ce};return delete dt[ke.pageId],dt}return{...Ce,[ke.pageId]:{agentId:ke.agentId,agentName:ke.agentName||ke.agentId}}})});return()=>{Y=!0,ee()}},[]),C.useEffect(()=>{let Y=!1;J.terminal?.sessionOwnership?.().then(le=>{if(Y)return;const ke={};for(const Ce of le.ownership??[])ke[Ce.terminalId]={agentId:Ce.agentId,agentName:Ce.agentName||Ce.agentId};$(ke)}).catch(()=>{});const ee=gt.on("ui:terminal_ownership",le=>{const ke=le.payload;typeof ke.terminalId=="string"&&$(Ce=>{if(ke.action==="released"||!ke.agentId){if(!(ke.terminalId in Ce))return Ce;const dt={...Ce};return delete dt[ke.terminalId],dt}return{...Ce,[ke.terminalId]:{agentId:ke.agentId,agentName:ke.agentName||ke.agentId}}})});return()=>{Y=!0,ee()}},[]);const N=ZA(s),z=VA(s),U=(n?.length??0)>=1,ne=FA(s,a);C.useEffect(()=>{if(!a)return;const Y=Z.current,ee=V.current;if(!Y||!ee)return;const le=requestAnimationFrame(()=>{Y.scrollIntoView({behavior:"smooth",inline:"nearest",block:"nearest"})});return()=>cancelAnimationFrame(le)},[a,n?.length]),C.useEffect(()=>{const Y=ee=>{if(ee.key==="Escape"){if(!A())return;d&&u?u():e()}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[e,d,u,A]),C.useEffect(()=>{let Y=!1;return S(null),B(!1),s.kind==="url"?(y({mode:"url",url:s.url,browserId:s.browserId}),()=>{Y=!0}):s.kind==="terminal"?(y({mode:"terminal",terminalId:s.terminalId,title:s.title,cwd:s.cwd}),()=>{Y=!0}):lu(N)?(y({mode:"url",url:N}),()=>{Y=!0}):(y({mode:"loading"}),s.kind==="deliverable"&&s.deliverable.artifactType&&s.deliverable.artifactData?(y({mode:"artifact",summary:s.deliverable.summary||s.deliverable.title||""}),()=>{Y=!0}):N?s.kind==="deliverable"&&s.deliverable.type==="directory"?(y({mode:"unpreviewable",reference:N,isDirectory:!0}),()=>{Y=!0}):(J.files.preview(N).then(le=>{if(Y)return;if(le.type==="image"){const Ce=le.content?`data:${le.mimeType||"image/png"};base64,${le.content}`:le.streamUrl||(le.path?J.files.streamUrl(le.path):J.files.streamUrl(N));y({mode:"image",src:Ce,name:le.name||z});return}if(le.type==="audio"){const Ce=le.streamUrl||(le.path?J.files.streamUrl(le.path):J.files.streamUrl(N));y({mode:"audio",src:Ce,name:le.name||z,mimeType:le.mimeType||"audio/mpeg",size:le.size});return}if(le.type==="video"){const Ce=le.streamUrl||(le.path?J.files.streamUrl(le.path):J.files.streamUrl(N));y({mode:"video",src:Ce,name:le.name||z,mimeType:le.mimeType||"video/mp4",size:le.size});return}if(le.type==="binary"){y({mode:"binary",name:le.name||z,reference:le.path||N,size:le.size,extension:le.extension});return}if(typeof le.content!="string"){y({mode:"unpreviewable",reference:N,isDirectory:!1});return}const ke=k_({format:s.kind==="deliverable"?s.deliverable.format:void 0,reference:N,content:le.content});y({mode:"content",content:le.content,format:ke})}).catch(()=>{Y||y({mode:"unpreviewable",reference:N,isDirectory:!1})}),()=>{Y=!0}):(y({mode:"unpreviewable",reference:"",isDirectory:!1}),()=>{Y=!0}))},[ne,s,N,z]);const Se=z||N,Pe=C.useCallback((Y,ee)=>{const le=Y.length>40?`${Y.slice(0,24)}…${Y.slice(-12)}`:Y;return ee?{label:`🌐 ${le}`,content:["[html-selection]",`Text: "${Y}"`,`CSS Selector: ${ee.cssSelector}`,`XPath: ${ee.xpath}`,N?`File: ${N}`:""].filter(Boolean).join(`
|
|
49
|
-
`)}:s.kind==="terminal"?{label:`⌘ ${le}`,content:["[terminal-selection]",`Terminal: ${s.title||"Terminal"} (${s.terminalId})`,s.cwd?`Cwd: ${s.cwd}`:"",'"""',Y,'"""'].filter(Boolean).join(`
|
|
50
|
-
`)}:{label:`“${le}”`,content:`${p("deliverables:chat.selectedFrom",{defaultValue:"Selected from"})} ${Se}:
|
|
51
|
-
|
|
52
|
-
"""
|
|
53
|
-
${Y}
|
|
54
|
-
"""`}},[N,Se,p,s]),X=C.useCallback((Y,ee)=>{!Y.trim()||!r||(r(Pe(Y.trim(),ee)),S(null),window.getSelection()?.removeAllRanges(),se.current?.clearSelection())},[r,Pe]),M=C.useCallback(async()=>{if(!r||s.kind!=="terminal")return;const Y=(await se.current?.getRecentOutput(80))?.trim();if(!Y)return;const ee=Y.length>40?`${Y.slice(0,24)}…${Y.slice(-12)}`:Y;r({label:`⌘ ${ee}`,content:["[terminal-output]",`Terminal: ${s.title||"Terminal"} (${s.terminalId})`,s.cwd?`Cwd: ${s.cwd}`:"",'"""',Y,'"""'].filter(Boolean).join(`
|
|
55
|
-
`)})},[r,s]);C.useEffect(()=>{if(s.kind!=="terminal"||!r)return;const Y=navigator.platform.toUpperCase().includes("MAC"),ee=le=>{if(!(Y?le.metaKey&&!le.ctrlKey:le.ctrlKey&&!le.metaKey)||!le.shiftKey||le.altKey||le.key.toLowerCase()!=="a")return;const Ce=se.current?.getSelection()?.trim();Ce&&(le.preventDefault(),X(Ce))};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[s.kind,r,X]);const K=C.useCallback(Y=>{if(!Y.text.trim()||!r)return;const ee=F.current?.querySelector("iframe")?.getBoundingClientRect(),le=(ee?.left??0)+Y.rect.x+Y.rect.width/2,ke=(ee?.top??0)+Y.rect.y;S({x:le,y:ke,text:Y.text,htmlMeta:{xpath:Y.xpath,cssSelector:Y.cssSelector}})},[r]);C.useEffect(()=>{const Y=F.current;if(!Y||!r)return;const ee=()=>{requestAnimationFrame(()=>{const ke=window.getSelection(),Ce=ke?.toString().trim();if(!Ce||!ke?.rangeCount){S(null);return}const dt=ke.getRangeAt(0);if(!Y.contains(dt.commonAncestorContainer)){S(null);return}const ht=dt.getBoundingClientRect();S({x:ht.left+ht.width/2,y:ht.top,text:Ce})})},le=ke=>{const Ce=document.getElementById("right-panel-selection-toolbar");Ce&&Ce.contains(ke.target)||S(null)};return Y.addEventListener("mouseup",ee),document.addEventListener("mousedown",le),()=>{Y.removeEventListener("mouseup",ee),document.removeEventListener("mousedown",le)}},[r,x.mode]);const ie=()=>{J.files.reveal(N).catch(()=>{})},oe=()=>{navigator.clipboard?.writeText(N).then(()=>{k(!0),setTimeout(()=>k(!1),1500)}).catch(()=>{})},G=C.useCallback(async()=>{if(s.kind==="deliverable"){Or.navigate(Ht.DELIVERABLES,{openDeliverable:s.deliverable.id});return}if(s.kind==="url"){let ee=s.url;if(s.browserId&&window.markusDesktop?.browser)try{const le=await window.markusDesktop.browser.getState(s.browserId);if(le.ok){if(le.directoryPath){await J.system.openPath(le.directoryPath).catch(()=>J.files.reveal(le.directoryPath));return}le.url&&le.url!=="about:blank"&&(ee=le.url)}}catch{}if(!ee||ee==="about:blank")return;if(/^https?:\/\//i.test(ee)||/^file:\/\//i.test(ee)){Sl(ee);return}await J.system.openPath(ee).catch(()=>Sl(z0(ee)));return}if(s.kind!=="file")return;const Y=s.path;if(Y){if(/^https?:\/\//i.test(Y)||/^file:\/\//i.test(Y)){Sl(Y);return}await J.system.openPath(Y).catch(()=>Sl(z0(Y)))}},[s]),$e=s.kind==="deliverable"?!!s.deliverable.id:s.kind==="url"?!!(s.url&&s.url!=="about:blank")||!!s.browserId:s.kind==="file"?!!s.path:!1,Ie=s.kind==="deliverable"?p("agent:deliverables.openInPage",{defaultValue:"Open in Output"}):p("common:openInSystemBrowser"),We=!!N&&!lu(N)&&(s.kind==="file"||s.kind==="deliverable");return h.jsxs(h.Fragment,{children:[!d&&h.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative z-10 flex items-center justify-center",onMouseDown:i,children:h.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),h.jsxs("div",{className:`bg-surface-primary flex flex-col overflow-hidden ${d?"flex-1 min-w-0":"shrink-0"}`,style:d?void 0:{width:t},"data-right-panel":!0,children:[h.jsxs("header",{"data-electron-drag":!0,className:"relative z-20 h-10 shrink-0 flex items-center gap-1 pl-1.5 pr-1.5 border-b border-border-default bg-surface-primary",children:[b&&h.jsxs("div",{"data-no-drag":!0,className:"shrink-0 flex items-center gap-0.5 pr-1 border-r border-border-default/60",children:[h.jsx("button",{type:"button",onClick:()=>b("browser"),title:p("common:browserMode",{defaultValue:"Browser"}),"aria-label":p("common:browserMode",{defaultValue:"Browser"}),"aria-pressed":g==="browser",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${g==="browser"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),h.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}),h.jsx("button",{type:"button",onClick:()=>b("terminal"),title:p("common:terminalMode",{defaultValue:"Terminal"}),"aria-label":p("common:terminalMode",{defaultValue:"Terminal"}),"aria-pressed":g==="terminal",className:`w-7 h-7 flex items-center justify-center rounded-md transition-colors ${g==="terminal"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"4 17 10 11 4 5"}),h.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})})]}),U||c?h.jsxs("div",{"data-no-drag":!0,ref:V,role:"tablist",className:"flex-1 min-w-0 flex flex-nowrap items-center gap-0.5 overflow-x-auto overflow-y-hidden overscroll-x-contain scrollbar-thin",onWheel:Y=>{const ee=Y.currentTarget;ee.scrollWidth<=ee.clientWidth||Math.abs(Y.deltaY)<=Math.abs(Y.deltaX)||(ee.scrollLeft+=Y.deltaY,Y.preventDefault())},children:[n?.map(Y=>{const ee=Y.id===a,le=Y.payload.kind==="url"?Y.payload.pageId:void 0,ke=Y.payload.kind==="terminal"?Y.payload.terminalId:void 0,Ce=le!=null?Q[le]:ke?D[ke]:void 0,dt=Ce?`${Y.title} — ${p("common:browserTabControlledBy",{name:Ce.agentName})}`:Y.title;return h.jsxs("div",{className:`group shrink-0 flex items-center max-w-[200px] rounded-md text-[11px] border transition-colors ${ee?Ce?"bg-brand-500/10 border-brand-500/35 text-fg-primary":"bg-surface-elevated border-border-default text-fg-primary":Ce?"border-brand-500/25 text-fg-secondary hover:bg-brand-500/8":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[h.jsxs("button",{type:"button",role:"tab","aria-selected":ee,ref:ee?Z:void 0,className:"min-w-0 flex-1 truncate pl-2.5 pr-1 py-1 text-left cursor-pointer flex items-center gap-1",title:dt,onPointerDown:ht=>{ht.button===0&&(Y.id!==a&&!A()||o?.(Y.id))},onClick:()=>{Y.id!==a&&!A()||o?.(Y.id)},children:[Ce&&h.jsxs("span",{className:"shrink-0 inline-flex items-center gap-0.5 max-w-[72px] px-1 py-px rounded text-[9px] font-semibold tracking-wide bg-brand-500/20 text-brand-500",title:p("common:browserTabControlledBy",{name:Ce.agentName}),children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500 animate-pulse shrink-0","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:Ce.agentName})]}),h.jsx("span",{className:"truncate min-w-0",children:Y.title})]}),l&&h.jsx("button",{type:"button",onPointerDown:ht=>{ht.button===0&&(ht.preventDefault(),ht.stopPropagation(),!(Y.id===a&&!A())&&l(Y.id))},onClick:ht=>{ht.preventDefault(),ht.stopPropagation(),!(Y.id===a&&!A())&&l(Y.id)},className:`shrink-0 mr-1 p-0.5 rounded hover:bg-surface-overlay transition-colors ${ee?"text-fg-tertiary hover:text-fg-secondary":"text-fg-muted hover:text-fg-secondary opacity-70 group-hover:opacity-100"}`,title:p("common:closeTab",{defaultValue:"Close tab"}),"aria-label":p("common:closeTab",{defaultValue:"Close tab"}),children:h.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},Y.id)}),c&&h.jsx("button",{type:"button",onClick:c,className:"shrink-0 w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/60 transition-colors",title:p("common:newTab",{defaultValue:"New Tab"}),"aria-label":p("common:newTab",{defaultValue:"New Tab"}),children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}):h.jsx("span",{className:"text-sm font-semibold text-fg-primary truncate flex-1 min-w-0 px-1.5",title:N||z,children:z}),h.jsxs("div",{"data-no-drag":!0,className:"shrink-0 flex items-center gap-0.5 pl-1 border-l border-border-default/60",children:[s.kind==="terminal"&&r&&h.jsx("button",{type:"button",onClick:()=>{M()},title:p("common:addRecentOutput",{defaultValue:"Add recent output to chat"}),"aria-label":p("common:addRecentOutput",{defaultValue:"Add recent output to chat"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),$e&&h.jsx("button",{type:"button",onClick:()=>{G()},title:Ie,"aria-label":Ie,className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),h.jsx("polyline",{points:"15 3 21 3 21 9"}),h.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}),We&&h.jsx("button",{onClick:ie,title:p("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"}),"aria-label":p("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),u&&h.jsx("button",{onClick:u,title:d?p("common:exitFullscreen",{defaultValue:"Exit fullscreen"}):p("common:fullscreen",{defaultValue:"Fullscreen"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:d?h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"4 14 10 14 10 20"}),h.jsx("polyline",{points:"20 10 14 10 14 4"}),h.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),h.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("polyline",{points:"15 3 21 3 21 9"}),h.jsx("polyline",{points:"9 21 3 21 3 15"}),h.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),h.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}),h.jsx("button",{onClick:()=>{A()&&e()},title:p("common:collapsePanel",{defaultValue:"Hide panel"}),"aria-label":p("common:collapsePanel",{defaultValue:"Hide panel"}),className:"w-7 h-7 flex items-center justify-center rounded-md transition-colors text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),h.jsxs("div",{className:`flex-1 min-w-0 min-h-0 ${x.mode==="url"||x.mode==="terminal"||x.mode==="content"&&["code","json","text","markdown","html"].includes(x.format)?"overflow-hidden p-2 flex flex-col":"overflow-auto p-4"}`,children:[x.mode==="loading"&&h.jsxs("div",{className:"animate-pulse space-y-3",children:[h.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),h.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),h.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),h.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"})]}),x.mode==="image"&&h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[h.jsx("img",{src:x.src,alt:x.name,className:"max-w-full rounded-lg object-contain"}),h.jsx("span",{className:"text-xs text-fg-tertiary",children:x.name})]}),x.mode==="audio"&&h.jsxs("div",{className:"flex flex-col items-stretch gap-3 py-6",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-12 h-12 rounded-xl bg-brand-500/15 text-brand-500 flex items-center justify-center shrink-0",children:h.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M9 18V5l12-2v13"}),h.jsx("circle",{cx:"6",cy:"18",r:"3"}),h.jsx("circle",{cx:"18",cy:"16",r:"3"})]})}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:x.name}),h.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[x.mimeType,x.size!=null?` · ${cu(x.size)}`:""]})]})]}),h.jsx("audio",{controls:!0,preload:"metadata",src:x.src,className:"w-full"})]}),x.mode==="video"&&h.jsxs("div",{className:"flex flex-col items-stretch gap-3",children:[h.jsx("video",{controls:!0,preload:"metadata",src:x.src,className:"w-full max-h-[70vh] rounded-lg bg-black"}),h.jsxs("span",{className:"text-xs text-fg-tertiary",children:[x.name,x.size!=null?` · ${cu(x.size)}`:""]})]}),x.mode==="binary"&&h.jsxs("div",{className:"space-y-4 py-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-12 h-12 rounded-xl bg-surface-elevated text-fg-tertiary flex items-center justify-center shrink-0 text-xs font-mono uppercase",children:(x.extension||"file").replace(/^\./,"")||"file"}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:x.name}),h.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[p("detail.cannotPreview",{type:"file",defaultValue:"This file type cannot be previewed."}),x.size!=null?` · ${cu(x.size)}`:""]})]})]}),x.reference&&h.jsx("div",{className:"flex items-center gap-2",children:h.jsx("button",{onClick:()=>{J.files.reveal(x.reference)},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",children:p("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"})})})]}),x.mode==="content"&&(()=>{const Y=N?N.replace(/[/\\][^/\\]+$/,""):void 0,ee=N&&!lu(N)?N:"",le=x.format;return ee&&(le==="code"||le==="json"||le==="text")?h.jsx("div",{ref:F,className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:h.jsx(q1,{path:ee,initialContent:x.content,language:Ep(ee,le),onDirtyChange:B})}):ee&&(le==="markdown"||le==="html")?h.jsx("div",{ref:F,className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:h.jsx(jA,{path:ee,content:x.content,format:le,basePath:Y,onHtmlSelection:K,onDirtyChange:B})}):h.jsx("div",{ref:F,className:"min-w-0 max-w-full overflow-auto break-words [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_table]:block [&_table]:max-w-full [&_table]:overflow-x-auto [&_img]:max-w-full",children:h.jsx(du,{content:x.content,format:le,className:"text-fg-secondary text-sm",onHtmlSelection:K,basePath:Y})})})(),x.mode==="artifact"&&h.jsx("div",{ref:F,className:"min-w-0 max-w-full break-words [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_table]:block [&_table]:max-w-full [&_table]:overflow-x-auto [&_img]:max-w-full",children:h.jsx(du,{content:x.summary,format:"markdown",className:"text-fg-secondary text-sm"})}),x.mode==="url"&&h.jsx("div",{className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:h.jsx(MA,{url:x.url,browserId:x.browserId,className:"flex-1 min-h-0",onMeta:x.browserId&&f?Y=>f(x.browserId,Y):void 0},x.browserId||x.url)}),x.mode==="terminal"&&h.jsx("div",{className:"flex-1 min-h-0 min-w-0 w-full flex flex-col",children:h.jsx(zA,{terminalId:x.terminalId,title:x.title,cwd:x.cwd,active:!0,apiRef:se,onMeta:v,onOpenUrl:m,onOpenPath:O,onSelection:Y=>{if(!Y||!r){S(null);return}S({x:Y.x,y:Y.y,text:Y.text})}},x.terminalId)}),x.mode==="unpreviewable"&&h.jsxs("div",{className:"space-y-3",children:[h.jsx("p",{className:"text-sm text-fg-secondary",children:x.isDirectory?p("detail.cannotPreview",{type:"directory",defaultValue:"This item cannot be previewed here."}):p("detail.cannotPreview",{type:"file",defaultValue:"This file cannot be previewed here."})}),x.reference&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:ie,className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:p("detail.openInFileBrowser",{defaultValue:"Reveal in file browser"}),children:x.reference}),h.jsx("button",{onClick:ie,className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:p("common:open",{defaultValue:"Open"})}),h.jsx("button",{onClick:oe,className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${_?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:_?p("common:copied",{defaultValue:"Copied"}):p("common:copy",{defaultValue:"Copy"})})]})]})]},ne)]}),w&&r&&h.jsx("div",{id:"right-panel-selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full rounded-lg shadow-xl overflow-hidden border border-brand-400/40 bg-brand-600",style:{left:w.x,top:w.y-8},children:h.jsxs("button",{onMouseDown:Y=>{Y.preventDefault(),Y.stopPropagation(),X(w.text,w.htmlMeta)},className:"px-3 py-1.5 text-xs font-medium text-white hover:bg-brand-500 transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[h.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),p("deliverables:contextMenu.addToConversation",{defaultValue:"Add to conversation"})]})})]})}const UA=C.lazy(()=>bx(()=>import("./index-BMzsi3-i.js").then(s=>s.aE),__vite__mapDeps([0,1])).then(s=>({default:s.MarkdownMessage}))),Rp=[{key:"overview",icon:"▦"},{key:"files",icon:"📄"},{key:"tools",icon:"⚒"},{key:"memory",icon:"🧠"},{key:"deliverables",icon:"📦"}];function bf(s,e){return e(`agent:profilePage.taskStatus.${s}`,{defaultValue:s.replace(/_/g," ")})}function Y1(s,e){const i={idle:"common:status.idle",working:"common:status.working",offline:"common:status.offline",error:"common:status.error"}[s];return i?e(i):s}const U1={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",paused:"bg-amber-400",offline:"bg-gray-500",error:"bg-red-400"};function Gn(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString()}function Z0({agentId:s,onBack:e,inline:t,defaultTab:i,onSwipeBack:r,highlightMailboxId:n,authUser:a,headless:o,activeTab:l}){const{t:c}=Pt(["agent","common"]),d=Sf(),[u,f]=C.useState(null),[g,b]=C.useState(null),[v,m]=C.useState(i??"overview"),O=o&&l?l:v,[p,x]=C.useState(null),y=C.useMemo(()=>Rp.map($=>({...$,label:c(`agent:tabs.${$.key}`)})),[c]),_=C.useMemo(()=>y.map($=>({id:$.key})),[y]),k=C.useMemo(()=>({onSwipeOutLeft:r}),[r]),w=mx(_,v,m,k),S=C.useRef(null);C.useEffect(()=>{const $=S.current;if(!$)return;$.querySelector('[data-active="true"]')?.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[v]);const Q=C.useCallback(()=>{J.agents.get(s).then(f).catch(()=>{})},[s]);if(C.useEffect(()=>(m(i??"overview"),x(null),Q(),J.externalAgents.list().then(j=>{const B=j.agents.find(F=>F.markusAgentId===s);x(B??null)}).catch(()=>{}),gt.on("agent:update",j=>{j.payload.agentId===s&&Q()})),[s,Q]),!u)return h.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:c("agent:profilePage.loadingAgent")});const I=U1[u.state.status]??"bg-gray-500",D=a?.role==="owner"||a?.role==="admin";return o?h.jsx("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:h.jsxs("div",{className:"p-5",children:[(O==="overview"||O==="mind")&&h.jsxs(h.Fragment,{children:[h.jsx(V0,{agent:u,onUpdate:Q,externalInfo:p,t:c,canManageAgents:D}),h.jsx("div",{className:"mt-6",children:h.jsx(ox,{agentId:s,highlightId:n,agentStatus:u.state.status,canManageAgents:D,onAgentStateChange:Q})})]}),O==="files"&&h.jsx(U0,{agentId:s}),O==="tools"&&h.jsx(H0,{tools:u.tools??[],agent:u}),O==="memory"&&h.jsxs(h.Fragment,{children:[h.jsx(K0,{agentId:s,initialData:u.heartbeat}),h.jsx("div",{className:"mt-6",children:h.jsx(G0,{agentId:s})})]}),O==="deliverables"&&h.jsx(ax,{agentId:s})]})}):h.jsxs("div",{className:"flex-1 overflow-y-auto bg-surface-primary",children:[h.jsxs("div",{className:"px-5 py-3.5 bg-surface-secondary sticky top-0 z-10",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(_s,{name:u.name,avatarUrl:u.avatarUrl,size:40,className:"rounded-xl"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("h2",{className:"text-base font-semibold",children:u.name}),h.jsx("span",{className:`w-2 h-2 rounded-full ${I}`}),h.jsx("span",{className:"text-xs text-fg-tertiary",children:Y1(u.state.status,c)}),p&&h.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:c("agent:profilePage.badges.external")}),u.agentRole==="manager"&&h.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/15 text-amber-600 rounded font-medium",children:c("agent:profilePage.badges.manager")})]}),h.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[u.role,u.roleDescription?` — ${u.roleDescription}`:""]})]}),h.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[!t&&h.jsxs("button",{onClick:()=>Or.navigate(Ht.TEAM,{agentId:s}),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors flex items-center gap-1",children:[h.jsx("span",{children:"◈"})," ",c("agent:profilePage.chat")]}),D&&h.jsxs("button",{onClick:async()=>{if(u)try{const{filesMap:$}=await J.agents.getFilesMap(s),j={type:"agent",name:gx(u.name,u.name),displayName:u.name,version:"1.0.0",description:u.roleDescription??u.role,author:"",category:"general",tags:[],agent:{roleName:u.role,agentRole:u.agentRole},dependencies:{skills:u.skills??[]}};await Ox.publishViaProxy({itemType:"agent",name:u.name,description:j.description,category:"general",config:j,files:$}),b({title:c("agent:profilePage.hub"),message:c("agent:profilePage.publishSuccess",{name:u.name}),variant:"primary"})}catch($){b({title:c("agent:profilePage.hub"),message:c("agent:profilePage.publishFailed",{error:String($)}),variant:"danger"})}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:c("agent:profilePage.publishTitle"),children:[h.jsx("span",{children:"↑"})," ",c("agent:profilePage.hub")]}),t&&h.jsx("button",{onClick:e,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),h.jsx("div",{ref:S,className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto scrollbar-hide",children:y.filter($=>!p||["overview","mind"].includes($.key)).map($=>h.jsxs("button",{onClick:()=>m($.key),"data-active":v===$.key,className:`px-3 py-1.5 text-xs rounded-t-lg border border-b-0 transition-colors whitespace-nowrap ${v===$.key?"bg-surface-primary text-fg-primary border-border-default":"text-fg-tertiary border-transparent hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[h.jsx("span",{className:"mr-1",children:$.icon}),$.label]},$.key))})]}),h.jsxs("div",{className:"p-5",onTouchStart:d?w.onTouchStart:void 0,onTouchEnd:d?w.onTouchEnd:void 0,children:[(v==="overview"||v==="mind")&&h.jsxs(h.Fragment,{children:[h.jsx(V0,{agent:u,onUpdate:Q,externalInfo:p,t:c,canManageAgents:D}),h.jsx("div",{className:"mt-6",children:h.jsx(ox,{agentId:s,highlightId:n,agentStatus:u.state.status,canManageAgents:D,onAgentStateChange:Q})})]}),v==="files"&&h.jsx(U0,{agentId:s}),v==="tools"&&h.jsx(H0,{tools:u.tools??[],agent:u}),v==="memory"&&h.jsxs(h.Fragment,{children:[h.jsx(K0,{agentId:s,initialData:u.heartbeat}),h.jsx("div",{className:"mt-6",children:h.jsx(G0,{agentId:s})})]}),v==="deliverables"&&h.jsx(ax,{agentId:s})]}),g&&h.jsx(Wa,{alertOnly:!0,variant:g.variant??"primary",title:g.title,message:g.message,onConfirm:()=>b(null),onCancel:()=>b(null)})]})}function V0({agent:s,onUpdate:e,externalInfo:t,t:i,canManageAgents:r}){const[n,a]=C.useState(null),[o,l]=C.useState([]),[c,d]=C.useState(null),[u,f]=C.useState(null),[g,b]=C.useState(""),[v,m]=C.useState([]);C.useEffect(()=>{J.usage.agents().then(w=>{const S=w.agents.find(Q=>Q.agentId===s.id);S&&a(S)}).catch(()=>{}),J.agents.getRecentActivities(s.id).then(w=>l(w.activities)).catch(()=>{}),J.system.storage().then(w=>{b(w.dataDir+"/agents/"+s.id);const S=w.agents.find(Q=>Q.id===s.id);S&&f(S)}).catch(()=>{}),s.state.activeTaskIds?.length&&J.tasks.list({assignedAgentId:s.id}).then(w=>{m(w.tasks.filter(S=>s.state.activeTaskIds?.includes(S.id)))}).catch(()=>{})},[s.id,s.state.activeTaskIds]);const O=()=>{s.state.status==="offline"?J.agents.start(s.id).then(e):J.agents.stop(s.id).then(e)},p=C.useMemo(()=>[{method:"POST",path:"/api/gateway/sync",desc:i("agent:profilePage.gateway.sync")},{method:"GET",path:"/api/gateway/manual",desc:i("agent:profilePage.gateway.manual")},{method:"GET",path:"/api/gateway/team",desc:i("agent:profilePage.gateway.team")},{method:"GET",path:"/api/gateway/projects",desc:i("agent:profilePage.gateway.projects")},{method:"GET",path:"/api/gateway/requirements",desc:i("agent:profilePage.gateway.requirements")}],[i]),x=C.useMemo(()=>[{field:"assignedTasks",desc:i("agent:profilePage.syncContext.assignedTasks")},{field:"inboxMessages",desc:i("agent:profilePage.syncContext.inboxMessages")},{field:"teamContext",desc:i("agent:profilePage.syncContext.teamContext")},{field:"projectContext",desc:i("agent:profilePage.syncContext.projectContext")}],[i]);if(t)return h.jsxs("div",{className:"space-y-4",children:[h.jsx(Gt,{title:i("agent:profilePage.overview.identity"),children:h.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[h.jsx(Ds,{label:i("agent:profilePage.overview.labels.name"),children:s.name}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.agentRole"),children:h.jsx("span",{className:s.agentRole==="manager"?"text-amber-600":"text-blue-600",children:s.agentRole==="manager"?i("agent:profilePage.roles.managerDisplay"):i("agent:profilePage.roles.workerDisplay")})}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.roleTemplate"),children:s.role}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.markusAgentId"),mono:!0,children:s.id}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.organization"),children:s.config?.orgId??"default"}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.created"),children:s.config?.createdAt?new Date(s.config.createdAt).toLocaleDateString():i("agent:profilePage.emDash")})]})}),h.jsx(Gt,{title:i("agent:profilePage.overview.connectionStatus"),children:h.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[h.jsx(as,{label:i("agent:profilePage.overview.labels.connection"),value:t.connected?i("common:status.online"):i("common:status.offline"),color:t.connected?"green":"gray"}),h.jsx(as,{label:i("agent:profilePage.overview.labels.platform"),value:i("agent:profilePage.overview.openClaw")}),h.jsx(as,{label:i("agent:profilePage.overview.labels.activeTasks"),value:String(s.state.activeTaskIds?.length??0)}),h.jsx(as,{label:i("agent:profilePage.overview.labels.lastSync"),value:t.lastHeartbeat?new Date(t.lastHeartbeat).toLocaleTimeString():i("agent:profilePage.never")})]})}),h.jsx(Gt,{title:i("agent:profilePage.overview.externalAgentDetails"),children:h.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[h.jsx(Ds,{label:i("agent:profilePage.overview.labels.externalAgentId"),mono:!0,children:t.externalAgentId}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.registered"),children:new Date(t.registeredAt).toLocaleString()}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.capabilities"),children:t.capabilities.length>0?t.capabilities.join(", "):i("agent:profilePage.overview.noneDeclared")}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.lastHeartbeat"),children:t.lastHeartbeat?new Date(t.lastHeartbeat).toLocaleString():i("agent:profilePage.never")})]})}),h.jsx(Gt,{title:i("agent:profilePage.overview.syncContextTitle"),children:h.jsx("div",{className:"space-y-1.5",children:x.map(w=>h.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated",children:[h.jsx("span",{className:"font-mono text-[10px] text-brand-500 shrink-0 pt-0.5",children:w.field}),h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:w.desc})]},w.field))})}),h.jsx(Gt,{title:i("agent:profilePage.overview.gatewayEndpoints"),children:h.jsx("div",{className:"space-y-1.5",children:p.map(w=>h.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2 rounded-lg bg-surface-elevated",children:[h.jsx("span",{className:`text-[10px] font-semibold shrink-0 pt-0.5 ${w.method==="POST"?"text-amber-600":"text-green-600"}`,children:w.method}),h.jsx("span",{className:"font-mono text-[10px] text-fg-secondary shrink-0 pt-0.5",children:w.path}),h.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:w.desc})]},w.path))})})]});const y=o.filter(w=>w.type==="heartbeat").length,_=o.filter(w=>w.type==="chat").length,k=s.state.activeTaskIds?.length??0;return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"bg-surface-elevated rounded-xl px-4 py-3 flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[h.jsx(Ds,{label:i("agent:profilePage.overview.labels.roleTemplate"),children:s.role}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.agentRole"),children:h.jsx("span",{className:s.agentRole==="manager"?"text-amber-600":"text-blue-600",children:s.agentRole==="manager"?i("agent:profilePage.roles.managerDisplay"):i("agent:profilePage.roles.workerDisplay")})}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.agentId"),mono:!0,children:s.id}),h.jsx(Ds,{label:i("agent:profilePage.overview.labels.created"),children:s.config?.createdAt?new Date(s.config.createdAt).toLocaleDateString():i("agent:profilePage.emDash")})]}),h.jsxs("div",{className:"bg-surface-elevated rounded-xl px-4 py-3 space-y-3",children:[h.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${U1[s.state.status]||"bg-gray-500"}`}),h.jsx("span",{className:`text-sm font-semibold ${s.state.status==="idle"?"text-green-500":s.state.status==="working"?"text-blue-400":s.state.status==="error"?"text-red-400":"text-fg-secondary"}`,children:Y1(s.state.status,i)})]}),h.jsx(as,{label:i("agent:profilePage.overview.labels.tokensToday"),value:Gn(s.state.tokensUsedToday)}),h.jsx(as,{label:i("agent:profilePage.overview.labels.activeTasks"),value:String(k),color:k>0?"blue":void 0}),h.jsx(as,{label:i("agent:profilePage.overview.labels.lastHeartbeat"),value:s.state.lastHeartbeat?new Date(s.state.lastHeartbeat).toLocaleTimeString():i("agent:profilePage.never")}),r&&h.jsx("button",{onClick:O,className:"ml-auto px-3 py-1 text-xs border border-border-default rounded-lg hover:border-brand-500 transition-colors shrink-0",children:s.state.status==="offline"?i("agent:profilePage.overview.startAgent"):i("agent:profilePage.overview.stopAgent")})]}),s.state.status==="error"&&h.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("span",{className:"text-xs font-medium text-red-500",children:i("agent:profilePage.overview.errorDetails")}),s.state.lastErrorAt&&h.jsx("span",{className:"text-[10px] text-red-500/50 ml-auto",children:new Date(s.state.lastErrorAt).toLocaleString()})]}),h.jsx("pre",{className:"text-[11px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono bg-red-500/5 rounded p-2",children:Oc(s.state.lastError,i)||s.state.lastError||i("agent:profilePage.overview.errorFallback")})]}),s.state.status==="working"&&k>0&&h.jsx("div",{className:"bg-brand-500/10 border border-brand-500/20 rounded-lg p-2.5",children:h.jsx("div",{className:"space-y-1",children:v.map(w=>h.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),h.jsx("span",{className:"text-fg-secondary truncate flex-1",children:w.title}),h.jsx("span",{className:"text-fg-tertiary capitalize shrink-0",children:bf(w.status,i)})]},w.id))})}),n&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"border-t border-border-default/40"}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[h.jsx(as,{label:i("agent:profilePage.overview.labels.totalTokens"),value:Gn(n.totalTokens)}),h.jsx(as,{label:i("agent:profilePage.overview.labels.requests"),value:String(n.requestCount)}),h.jsx(as,{label:i("agent:profilePage.overview.labels.toolCalls"),value:String(n.toolCalls)}),h.jsx(as,{label:i("agent:profilePage.overview.labels.promptTokens"),value:Gn(n.promptTokens)}),h.jsx(as,{label:i("agent:profilePage.overview.labels.completionTokens"),value:Gn(n.completionTokens)}),h.jsx(as,{label:"CU Used",value:Gn(n.cuUsed??0)})]})]}),u&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"border-t border-border-default/40"}),h.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-1.5",children:[h.jsx(as,{label:i("agent:profilePage.overview.storage"),value:sx(u.size)}),u.subItems.filter(w=>w.size>0).map(w=>h.jsx(as,{label:w.name,value:sx(w.size)},w.name)),h.jsxs("button",{onClick:()=>{J.system.openPath(g)},className:"text-[10px] text-fg-tertiary hover:text-fg-secondary ml-auto",children:[i("agent:profilePage.overview.openFolder")," →"]})]})]})]}),y>0&&h.jsx(Gt,{title:i("agent:profilePage.overview.recentHeartbeats"),action:h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:i("agent:profilePage.overview.heartbeatRuns",{count:y})}),children:h.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:o.filter(w=>w.type==="heartbeat").map(w=>{const S=c===w.id;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>d(S?null:w.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[h.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-green-400"}),h.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:w.label}),h.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(w.startedAt).toLocaleString()}),h.jsx("span",{className:"text-fg-tertiary text-[10px]",children:S?"▲":"▼"})]}),S&&h.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:h.jsx(Ba,{agentId:s.id,activityId:w.id})})]},w.id)})})}),_>0&&h.jsx(Gt,{title:i("agent:profilePage.overview.recentA2A"),action:h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:i("agent:profilePage.overview.conversations",{count:_})}),children:h.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:o.filter(w=>w.type==="chat").map(w=>{const S=c===w.id;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>d(S?null:w.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[h.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-blue-400"}),h.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:w.label}),h.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(w.startedAt).toLocaleString()}),h.jsx("span",{className:"text-fg-tertiary text-[10px]",children:S?"▲":"▼"})]}),S&&h.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:h.jsx(Ba,{agentId:s.id,activityId:w.id})})]},w.id)})})})]})}function HA(s,e){const t=s.split(`
|
|
56
|
-
`),i=e.split(`
|
|
57
|
-
`),r=t.length,n=i.length,a=Array.from({length:r+1},()=>new Array(n+1).fill(0));for(let f=r-1;f>=0;f--)for(let g=n-1;g>=0;g--)a[f][g]=t[f]===i[g]?a[f+1][g+1]+1:Math.max(a[f+1][g],a[f][g+1]);const o=[];let l=0,c=0,d=1,u=1;for(;l<r||c<n;)l<r&&c<n&&t[l]===i[c]?(o.push({type:"equal",content:t[l],oldLineNum:d++,lineNum:u++}),l++,c++):c<n&&(l>=r||a[l][c+1]>=a[l+1][c])?(o.push({type:"add",content:i[c],lineNum:u++}),c++):(o.push({type:"remove",content:t[l],oldLineNum:d++}),l++);return o}function F0(s){return s.match(/\S+|\s+/g)??[""]}function Y0({oldText:s,newText:e,mode:t}){const i=F0(s),r=F0(e),n=i.length,a=r.length,o=Array.from({length:n+1},()=>new Array(a+1).fill(0));for(let u=n-1;u>=0;u--)for(let f=a-1;f>=0;f--)o[u][f]=i[u]===r[f]?o[u+1][f+1]+1:Math.max(o[u+1][f],o[u][f+1]);const l=[];let c=0,d=0;for(;c<n||d<a;)c<n&&d<a&&i[c]===r[d]?(l.push({text:t==="remove"?i[c]:r[d],changed:!1}),c++,d++):d<a&&(c>=n||o[c][d+1]>=o[c+1][d])?(t==="add"&&l.push({text:r[d],changed:!0}),d++):(t==="remove"&&l.push({text:i[c],changed:!0}),c++);return h.jsx("span",{children:l.map((u,f)=>u.changed?h.jsx("span",{className:t==="add"?"bg-green-500/30 rounded-sm":"bg-red-500/30 rounded-sm",children:u.text},f):h.jsx("span",{children:u.text},f))})}function GA({agent:s,template:e,templateId:t}){const{t:i}=Pt(["agent","common"]),r=C.useMemo(()=>HA(s,e),[s,e]),[n,a]=C.useState(!0),o=3,l=C.useMemo(()=>{const g=r.map((O,p)=>O.type!=="equal"?p:-1).filter(O=>O>=0);if(g.length===0)return[];const b=[];let v=Math.max(0,g[0]-o),m=Math.min(r.length-1,g[0]+o);for(let O=1;O<g.length;O++){const p=Math.max(0,g[O]-o),x=Math.min(r.length-1,g[O]+o);p<=m+1||(b.push({start:v,end:m}),v=p),m=x}return b.push({start:v,end:m}),b},[r]),c=(g,b,v)=>{const m=g.type==="add"?"+":g.type==="remove"?"-":" ",O=g.type==="add"?"bg-green-500/8":g.type==="remove"?"bg-red-500/8":"",p=g.type==="add"?"text-green-600/90":g.type==="remove"?"text-red-500/80":"text-fg-tertiary",x=g.type==="add"?"text-green-500":g.type==="remove"?"text-red-500":"text-fg-muted",y=g.type==="remove"?g.oldLineNum:g.lineNum;let _=null;return g.type==="remove"&&b+1<v.length&&v[b+1].type==="add"?_=h.jsx(Y0,{oldText:g.content,newText:v[b+1].content,mode:"remove"}):g.type==="add"&&b>0&&v[b-1].type==="remove"&&(_=h.jsx(Y0,{oldText:v[b-1].content,newText:g.content,mode:"add"})),h.jsxs("div",{className:`flex ${O} hover:brightness-95 transition-colors`,children:[h.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-[10px] text-fg-muted/50 select-none leading-[20px]",children:y??""}),h.jsx("span",{className:`w-4 shrink-0 text-center text-[11px] font-mono ${x} select-none leading-[20px]`,children:m}),h.jsxs("span",{className:`flex-1 text-[11px] font-mono ${p} whitespace-pre-wrap break-words leading-[20px]`,children:[_??g.content,g.content===""&&" "]})]},b)},d=r.filter(g=>g.type==="add").length,u=r.filter(g=>g.type==="remove").length,f=n?l.flatMap(g=>{const b=[];for(let v=g.start;v<=g.end;v++)b.push({...r[v],_idx:v});return b}):r.map((g,b)=>({...g,_idx:b}));return h.jsxs("div",{className:"mb-3 bg-surface-elevated rounded-lg overflow-hidden",children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-elevated",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("span",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:i("agent:profilePage.diff.title",{templateId:t})}),h.jsxs("span",{className:"text-[10px] text-green-500 font-mono",children:["+",d]}),h.jsxs("span",{className:"text-[10px] text-red-500 font-mono",children:["-",u]})]}),h.jsx("button",{onClick:()=>a(g=>!g),className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:i(n?"agent:profilePage.diff.showFullFile":"agent:profilePage.diff.showChangesOnly")})]}),h.jsxs("div",{className:"max-h-72 overflow-y-auto bg-surface-primary/50",children:[n&&l.length>0&&l[0].start>0&&h.jsx("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-b border-border-default/30",children:i("agent:profilePage.diff.linesHidden",{count:l[0].start})}),f.map((g,b)=>{const v=b>0?f[b-1]:null,m=n&&v&&g._idx-v._idx>1;return h.jsxs("div",{children:[m&&h.jsx("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-y border-border-default/30",children:"···"}),c(g,g._idx,r)]},b)}),n&&l.length>0&&l[l.length-1].end<r.length-1&&h.jsx("div",{className:"text-[10px] text-fg-muted/50 text-center py-0.5 bg-surface-elevated/40 border-t border-border-default/30",children:i("agent:profilePage.diff.linesHidden",{count:r.length-1-l[l.length-1].end})}),l.length===0&&h.jsx("div",{className:"text-xs text-fg-tertiary text-center py-4",children:i("agent:profilePage.diff.identical")})]})]})}function KA(s,e){const t=s.split(`
|
|
58
|
-
`),i=e.split(`
|
|
59
|
-
`),r=[],n=Math.max(t.length,i.length);for(let a=0;a<n;a++){const o=t[a],l=i[a];if(o===l){r.push(` ${o??""}`);continue}o!==void 0&&(l===void 0||o!==l)&&r.push(`- ${o}`),l!==void 0&&(o===void 0||o!==l)&&r.push(`+ ${l}`)}if(r.length>80){const a=r.filter(o=>o.startsWith("+ ")||o.startsWith("- "));if(a.length>0)return a.join(`
|
|
60
|
-
`)}return r.join(`
|
|
61
|
-
`)}function U0({agentId:s}){const{t:e}=Pt(["agent","common"]),[t,i]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(null),[l,c]=C.useState(""),[d,u]=C.useState(""),[f,g]=C.useState(!1);C.useEffect(()=>{J.system.storage().then(V=>{u(V.dataDir+"/agents/"+s+"/role")}).catch(()=>{})},[s]);const[b,v]=C.useState(!1),[m,O]=C.useState(!1),[p,x]=C.useState(null),[y,_]=C.useState(null),k=C.useCallback(()=>{n(!0),Promise.all([J.agents.getFiles(s),J.agents.roleStatus(s).catch(()=>null)]).then(([V,Z])=>{i(V.files),x(Z),V.files.length>0&&!a&&(o(V.files[0].name),c(V.files[0].content))}).catch(()=>{}).finally(()=>n(!1))},[s]);C.useEffect(()=>{k()},[k]);const w=V=>{const Z=t.find(se=>se.name===V);Z&&(o(V),c(Z.content),O(!1),_(null))},S=async()=>{if(a){v(!0);try{await J.agents.updateFile(s,a,l),i(V=>V.map(Z=>Z.name===a?{...Z,content:l}:Z)),O(!1),a==="ROLE.md"&&await J.agents.updateSystemPrompt(s,l)}catch{}v(!1)}},Q=p?.files.filter(V=>V.status==="modified"||V.status==="added_in_template")??[],I=async V=>{const Z=V?Q.filter(A=>A.file===V):Q;if(Z.length===0)return;const se=[];for(const A of Z)try{const N=await J.agents.roleDiff(s,A.file);N.agentContent!=null&&N.templateContent!=null&&se.push(`## ${A.file}
|
|
62
|
-
|
|
63
|
-
**Template file path:** built-in template \`${p?.templateId??"unknown"}\`
|
|
64
|
-
|
|
65
|
-
**Key changes in the new template version:**
|
|
66
|
-
\`\`\`diff
|
|
67
|
-
`+KA(N.agentContent,N.templateContent)+"\n```\n")}catch{}if(se.length===0)return;const T=`Your role configuration files have been updated in the latest template (\`${p?.templateId??""}\`). Please review the following changes and decide whether to update your files accordingly.
|
|
68
|
-
|
|
69
|
-
`+se.join(`
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
`)+"\nPlease review each change and update your files if appropriate. You can use the `update_file` tool or ask me to apply the changes.";Or.navigate(Ht.TEAM,{agentId:s,prefillMessage:T})},D=async V=>{if(y?.file===V){_(null);return}try{const Z=await J.agents.roleDiff(s,V);Z.agentContent!=null&&Z.templateContent!=null&&_({file:V,agent:Z.agentContent,template:Z.templateContent})}catch{}};if(r)return h.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:e("agent:profilePage.filesTab.loading")});const $={"ROLE.md":"roleMd","HEARTBEAT.md":"heartbeatMd","POLICIES.md":"policiesMd","CONTEXT.md":"contextMd"},j=V=>{const Z=$[V];return Z?e(`agent:profilePage.filesTab.fileLabels.${Z}`):V},B=p?.hasTemplate&&!p.isUpToDate,F=a?Q.some(V=>V.file===a):!1;return h.jsxs("div",{className:"space-y-4",children:[B&&h.jsxs("div",{className:"bg-amber-500/8 border border-amber-500/25 rounded-xl p-4 flex items-start gap-3",children:[h.jsx("span",{className:"text-amber-600 text-sm mt-0.5",children:"↻"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-xs text-amber-600 font-medium",children:e("agent:profilePage.filesTab.templateUpdateAvailable")}),h.jsxs("div",{className:"text-[11px] text-amber-600/70 mt-0.5",children:[e("agent:profilePage.filesTab.filesDiffer",{count:Q.length,templateId:p.templateId})," ",Q.map(V=>V.file).join(", ")]})]}),h.jsx("button",{onClick:()=>I(),className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors shrink-0",children:e("agent:profilePage.filesTab.sendToAgent")})]}),h.jsxs(Gt,{title:e("agent:profilePage.filesTab.agentConfigFiles"),action:p?.hasTemplate?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${p.isUpToDate?"bg-green-400":"bg-amber-400"}`}),h.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[e("agent:profilePage.filesTab.templateLabel")," ",h.jsx("span",{className:"text-fg-secondary",children:p.templateId}),p.isUpToDate?e("agent:profilePage.filesTab.upToDate"):e("agent:profilePage.filesTab.updatesAvailable")]})]}):h.jsx("div",{className:"text-[10px] text-fg-tertiary",children:e("agent:profilePage.filesTab.customAgentNoTemplate")}),children:[h.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:t.map(V=>{const Z=Q.some(se=>se.file===V.name);return h.jsxs("button",{onClick:()=>w(V.name),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors relative ${a===V.name?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:[V.name,Z&&h.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-amber-400 rounded-full"})]},V.name)})}),a&&h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsx("div",{className:"text-xs text-fg-secondary",children:j(a)}),h.jsxs("div",{className:"flex gap-2 items-center",children:[F&&h.jsxs(h.Fragment,{children:[h.jsx("button",{onClick:()=>D(a),className:"px-2.5 py-1 text-[11px] text-amber-600 hover:text-amber-600 border border-amber-500/30 hover:border-amber-500/50 rounded-lg transition-colors",children:y?.file===a?e("agent:profilePage.filesTab.hideDiff"):e("agent:profilePage.filesTab.viewDiff")}),h.jsx("button",{onClick:()=>I(a),className:"px-2.5 py-1 text-[11px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",title:e("agent:profilePage.filesTab.sendToAgentTitle"),children:e("agent:profilePage.filesTab.sendToAgent")})]}),b&&h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e("common:saving")})]})]}),d&&h.jsxs("div",{className:"flex items-center gap-2 mb-3 bg-surface-elevated/40 rounded-lg px-3 py-2",children:[h.jsxs("code",{className:"text-[10px] text-fg-tertiary font-mono flex-1 truncate select-all",title:`${d}/${a}`,children:[d,"/",a]}),h.jsx("button",{onClick:()=>{navigator.clipboard.writeText(`${d}/${a}`),g(!0),setTimeout(()=>g(!1),2e3)},className:"shrink-0 px-2 py-1 text-[10px] text-fg-tertiary hover:text-fg-secondary border border-border-default hover:border-border-hover rounded-md transition-colors",title:e("agent:profilePage.filesTab.copyPath"),children:e(f?"agent:profilePage.filesTab.pathCopied":"agent:profilePage.filesTab.copyPath")}),h.jsx("button",{onClick:()=>{J.system.openPath(d)},className:"shrink-0 px-2 py-1 text-[10px] text-fg-tertiary hover:text-fg-secondary border border-border-default hover:border-border-hover rounded-md transition-colors",title:e("agent:profilePage.filesTab.openInFinder"),children:e("agent:profilePage.filesTab.openInFinder")})]}),y?.file===a&&h.jsx(GA,{agent:y.agent,template:y.template,templateId:p?.templateId??""}),h.jsx(JA,{content:t.find(V=>V.name===a)?.content??"",editContent:l,setEditContent:V=>{c(V),O(!0)},dirty:m,onSave:S}),a==="ROLE.md"&&h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-2",children:e("agent:profilePage.filesTab.roleMdHint")})]}),t.length===0&&h.jsx(Gc,{text:e("agent:profilePage.filesTab.noConfigFiles")})]})]})}function JA({content:s,editContent:e,setEditContent:t,dirty:i,onSave:r}){const[n,a]=C.useState(!1),o=C.useRef(null);return C.useEffect(()=>{n&&o.current?.focus()},[n]),C.useEffect(()=>{a(!1)},[s]),n||i?h.jsx("textarea",{ref:o,value:e,onChange:l=>t(l.target.value),onBlur:()=>{e!==s&&r(),a(!1)},onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),t(s),a(!1))},className:"w-full min-h-[60vh] bg-surface-elevated/60 border border-border-default rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y focus:border-brand-500 outline-none",spellCheck:!1}):h.jsxs("div",{className:"group relative cursor-pointer rounded-lg px-4 py-3 bg-surface-elevated hover:bg-surface-overlay transition-colors min-h-[200px]",onClick:()=>a(!0),role:"button",tabIndex:0,onKeyDown:l=>{l.key==="Enter"&&a(!0)},children:[h.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity text-[10px] text-fg-tertiary bg-surface-secondary/80 px-2 py-0.5 rounded",children:"Click to edit"}),e.trim()?h.jsx(C.Suspense,{fallback:h.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:h.jsx(UA,{content:e,className:"text-sm text-fg-secondary leading-relaxed"})}):h.jsx("div",{className:"text-sm text-fg-tertiary italic py-4 text-center",children:"Empty"})]})}const eM=[{id:"files",prefixes:["file_read","file_write","file_edit","apply_patch"]},{id:"search",prefixes:["grep_search","glob_find","list_directory"]},{id:"runtime",prefixes:["shell_execute","background_exec","process"]},{id:"terminal",prefixes:["terminal__","list_terminals","new_terminal","select_terminal","close_terminal","read_terminal","write_terminal","exec_terminal"]},{id:"web",prefixes:["web_search","web_fetch","web_extract"]},{id:"multimodal",prefixes:["generate_image","text_to_speech","speech_to_text","generate_video"]},{id:"browser",prefixes:["navigate_page","new_page","close_page","select_page","list_pages","open_page","resize_page","click","hover","fill","fill_form","type_text","press_key","take_screenshot","take_snapshot","evaluate_script","wait_for","list_console_messages","list_network_requests","get_console_message","get_network_request","lighthouse_audit","drag","upload_file","emulate","handle_dialog"]},{id:"tasks",prefixes:["task_create","task_list","task_update","task_get","task_assign","task_note","task_comment","task_submit_review","subtask_create","subtask_complete","subtask_cancel","subtask_list","task_check_duplicates","task_cleanup_duplicates","task_board_health","create_task","update_task","add_task_note","create_subtask"]},{id:"requirements",prefixes:["requirement_propose","requirement_list","requirement_get","requirement_update","requirement_update_status","requirement_resubmit","requirement_comment"]},{id:"projects",prefixes:["list_projects","get_project","create_project","update_project","delete_project","project_stats","project_structure","code_stats","git_"]},{id:"deliverables",prefixes:["deliverable_create","deliverable_search","deliverable_list","deliverable_update"]},{id:"packages",prefixes:["package_list","package_install","hub_search","hub_install","builder_list","builder_install","markus-hub__"]},{id:"communication",prefixes:["agent_send_message","agent_list_colleagues","agent_send_group_message","agent_create_group_chat","agent_list_group_chats","agent_broadcast_status","agent_delegate_task","feishu_"]},{id:"memory",prefixes:["memory_save","memory_search","memory_list","memory_update","memory_update_longterm","memory_delete","recall_context","recall_activity","update_working_memory","clear_working_memory","update_notebook","clear_notebook"]},{id:"mailbox",prefixes:["check_mailbox","defer_mailbox_item","drop_mailbox_item","prioritize_mailbox_item","delegate_message"]},{id:"planning",prefixes:["goal_create","goal_update","goal_status","workflow_"]},{id:"teamManager",prefixes:["team_list","team_status","team_update","team_start","team_stop","agent_update","agent_start","agent_stop"]},{id:"subagents",prefixes:["spawn_subagent","spawn_subagents","invoke_coding_tool","coding_tool_apply"]},{id:"system",prefixes:["discover_tools","notify_user","request_user_input","request_user_approval","schedule_wakeup","cancel_wakeup","set_heartbeat_interval"]},{id:"llm",prefixes:["llm_"]}];function tM(s,e){const t=new Map,i=new Set;for(const{id:a,prefixes:o}of eM){const l=e(`agent:toolCategories.${a}`),c=s.filter(d=>!i.has(d.name)&&o.some(u=>d.name.startsWith(u)));c.length>0&&(t.set(l,c),c.forEach(d=>i.add(d.name)))}const r=s.filter(a=>!i.has(a.name));for(const a of r){const o=a.name.indexOf("__");if(o>0){const l=a.name.slice(0,o),c=e("agent:toolCategories.mcp",{server:l});t.has(c)||t.set(c,[]),t.get(c).push(a),i.add(a.name)}}const n=s.filter(a=>!i.has(a.name));return n.length>0&&t.set(e("agent:toolCategories.other"),n),[...t.entries()].map(([a,o])=>({category:a,tools:o}))}function sM(s){return s.replace(/^\[MCP:[^\]]*\]\s*/i,"")}function iM({tools:s}){const{t:e}=Pt(["agent","common"]),t=tM(s,e);return h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"text-xs text-fg-tertiary",children:e("agent:profilePage.toolsTab.registeredCount",{count:s.length})}),t.map(i=>h.jsx(Gt,{title:`${i.category} (${i.tools.length})`,children:h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:i.tools.map(r=>{const n=n_(r.name),a=e(`common:execution.tools.${n.key}`,{defaultValue:n.label}),o=r.name.includes("__"),l=o?r.name.split("__").pop():r.name,c=sM(r.description||"");return h.jsxs("div",{className:"flex items-start gap-2.5 px-3 py-2.5 rounded-lg bg-surface-elevated min-w-0",children:[h.jsx(o_,{name:n.iconName,size:15,className:"shrink-0 mt-0.5 text-fg-secondary"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[h.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:a}),o&&h.jsx("span",{className:"text-[9px] px-1 py-px rounded bg-surface-secondary text-fg-tertiary border border-border-default/40 shrink-0",children:"MCP"})]}),l!==a&&h.jsx("div",{className:"text-[10px] font-mono text-fg-tertiary/70 truncate",children:l}),c&&h.jsx("div",{className:"text-[10px] text-fg-tertiary truncate mt-0.5",title:c,children:c})]})]},r.name)})})},i.category)),s.length===0&&h.jsx("div",{className:"text-center py-12 text-fg-tertiary text-sm",children:e("agent:profilePage.toolsTab.noToolsRegistered")})]})}function rM({agent:s}){const{t:e}=Pt(["agent","common"]),t=s.proficiency??{},[i,r]=C.useState(null),[n,a]=C.useState(null),[o,l]=C.useState(!1),c=s.availableSkills??[],d=new Map;for(const m of c){const O=m.category||"custom";d.has(O)||d.set(O,[]),d.get(O).push(m)}const u=async m=>{if(i===m){r(null),a(null);return}r(m),l(!0);try{const O=await fetch(`/api/skills/${encodeURIComponent(m)}`);if(O.ok){const p=await O.json();a(p.skill)}else a(null)}catch{a(null)}l(!1)},f={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",productivity:"bg-amber-500/15 text-amber-600",browser:"bg-blue-500/15 text-blue-600",custom:"bg-gray-500/15 text-fg-secondary",platform:"bg-purple-500/15 text-purple-500"},g=m=>{const O=t[m.name],p=O&&O.uses>0?Math.round(O.successes/O.uses*100):null,x=O&&h.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:[e("agent:profilePage.skillsTab.usesStats",{uses:O.uses,successes:O.successes}),O.lastUsed&&e("agent:profilePage.skillsTab.lastUsed",{date:new Date(O.lastUsed).toLocaleDateString()})]}),y=i===m.name;return h.jsxs("div",{children:[h.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-lg border cursor-pointer transition-all ${y?"bg-brand-500/10 border-brand-500/40":"bg-surface-elevated/30 border-border-default/30 hover:border-gray-600/50"}`,onClick:()=>u(m.name),children:[h.jsx("span",{className:`text-sm transition-transform ${y?"rotate-90":""}`,children:"▶"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-medium",children:m.name}),m.alwaysOn&&h.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-green-500/15 text-green-500",children:e("agent:profilePage.skillsTab.alwaysOn")}),m.builtIn&&!m.alwaysOn&&h.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-surface-overlay/40 text-fg-tertiary",children:e("agent:profilePage.skillsTab.builtIn")}),!m.builtIn&&h.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-medium bg-brand-500/15 text-brand-400",children:e("agent:profilePage.skillsTab.installed")})]}),h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 truncate",children:m.description}),x]}),p!==null&&h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[h.jsx("div",{className:"w-16 h-1.5 bg-surface-overlay rounded-full overflow-hidden",children:h.jsx("div",{className:`h-full rounded-full ${p>=80?"bg-green-400":p>=50?"bg-amber-400":"bg-red-400"}`,style:{width:`${p}%`}})}),h.jsxs("span",{className:"text-[10px] text-fg-tertiary w-8 text-right",children:[p,"%"]})]})]}),y&&h.jsx("div",{className:"ml-6 mt-1 mb-2 p-4 bg-surface-elevated/30 rounded-lg border border-border-default/20 space-y-3",children:o?h.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.skillsTab.loadingDetails")}):n?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${f[n.category]??f.custom}`,children:n.category}),h.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["v",n.version]}),n.author&&h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e("agent:profilePage.skillsTab.byAuthor",{author:n.author})}),n.requiredPermissions?.map(_=>h.jsx("span",{className:"px-1.5 py-0.5 bg-amber-500/10 text-amber-600 text-[10px] rounded",children:_},_))]}),n.description&&h.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed",children:n.description}),n.tags&&n.tags.length>0&&h.jsx("div",{className:"flex gap-1 flex-wrap",children:n.tags.map(_=>h.jsxs("span",{className:"px-1.5 py-0.5 bg-surface-overlay/40 text-fg-tertiary text-[10px] rounded",children:["#",_]},_))}),(n.toolDetails??n.tools??[]).length>0&&h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] text-fg-tertiary font-semibold uppercase tracking-wider mb-2",children:e("agent:profilePage.skillsTab.toolsHeading",{count:(n.toolDetails??n.tools??[]).length})}),h.jsx("div",{className:"space-y-1.5",children:(n.toolDetails??n.tools??[]).map(_=>h.jsxs("div",{className:"px-3 py-2 bg-surface-secondary/50 rounded border border-border-default/20",children:[h.jsx("div",{className:"text-xs font-medium text-brand-500",children:_.name}),_.description&&h.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:_.description})]},_.name))})]})]}):h.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.skillsTab.detailsUnavailable")})})]},m.name)},b=["development","productivity","browser","communication","devops","data","platform","custom"],v=[...d.entries()].sort((m,O)=>{const p=b.indexOf(m[0]),x=b.indexOf(O[0]);return(p===-1?999:p)-(x===-1?999:x)});return h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"flex items-center justify-between",children:h.jsx("div",{className:"text-xs text-fg-tertiary",children:e("agent:profilePage.skillsTab.installedCount",{count:c.length})})}),v.map(([m,O])=>h.jsx(Gt,{title:h.jsxs("span",{className:"capitalize",children:[m," ",h.jsxs("span",{className:"text-fg-tertiary font-normal",children:["(",O.length,")"]})]}),children:h.jsx("div",{className:"space-y-2",children:O.map(p=>g(p))})},m)),c.length===0&&h.jsx(Gc,{text:e("agent:profilePage.skillsTab.noSkills")})]})}function H0({tools:s,agent:e}){const{t}=Pt(["agent","common"]),[i,r]=C.useState("tools");return h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"flex items-center gap-2 mb-2",children:["tools","skills"].map(n=>h.jsx("button",{onClick:()=>r(n),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${i===n?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:n==="tools"?`${t("agent:profilePage.toolsTab.title",{defaultValue:"Tools"})} (${s.length})`:`${t("agent:tabs.skills")} (${e.availableSkills?.length??0})`},n))}),i==="tools"?h.jsx(iM,{tools:s}):h.jsx(rM,{agent:e})]})}function G0({agentId:s}){const{t:e}=Pt(["agent","common"]),[t,i]=C.useState(null),[r,n]=C.useState(!0),[a,o]=C.useState("longterm"),[l,c]=C.useState(""),[d,u]=C.useState(""),[f,g]=C.useState(!1),[b,v]=C.useState(null),[m,O]=C.useState(null),[p,x]=C.useState([]),[y,_]=C.useState(!1),k=C.useCallback(()=>{n(!0),J.agents.getMemory(s).then($=>{i($),c($.recentDailyLogs??""),u($.longTermMemory??"")}).catch(()=>{}).finally(()=>n(!1))},[s]);C.useEffect(()=>{k()},[k]);const w=async()=>{g(!0),await J.agents.updateDailyMemory(s,l).catch(()=>{}),g(!1),k()},S=async()=>{g(!0),await J.agents.updateLongTermMemory(s,e("agent:profilePage.memoryTab.userEditedSource"),d).catch(()=>{}),g(!1),k()},Q=l!==(t?.recentDailyLogs??""),I=d!==(t?.longTermMemory??"");if(r)return h.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:e("agent:profilePage.memoryTab.loading")});if(!t)return h.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:e("agent:profilePage.memoryTab.loadFailed")});const D=[{key:"longterm",label:"MEMORY.md"},{key:"entries",label:`Observations (${t.entries.length})`},{key:"sessions",label:e("agent:profilePage.memoryTab.sessions",{count:t.sessions.length})},{key:"daily",label:e("agent:profilePage.memoryTab.dailyLogs")}];return h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"flex gap-2",children:D.map($=>h.jsx("button",{onClick:()=>o($.key),className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${a===$.key?"bg-brand-600/15 border-brand-500/40 text-brand-500":"border-border-default text-fg-tertiary hover:text-fg-secondary"}`,children:$.label},$.key))}),a==="entries"&&h.jsx(Gt,{title:e("agent:profilePage.memoryTab.recentEntries"),children:t.entries.length===0?h.jsx(Gc,{text:e("agent:profilePage.memoryTab.noEntries")}):h.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:t.entries.map(($,j)=>{const B=b===j;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>v(B?null:j),className:"w-full flex gap-2 px-3 py-2 rounded-lg bg-surface-elevated/20 text-xs text-left hover:bg-surface-elevated/40 transition-colors cursor-pointer",children:[h.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 ${$.type==="fact"?"bg-blue-500/15 text-blue-600":$.type==="task"?"bg-green-500/15 text-green-600":$.type==="note"?"bg-brand-500/15 text-brand-500":"bg-surface-overlay text-fg-secondary"}`,children:$.type}),h.jsx("span",{className:`text-fg-secondary flex-1 min-w-0 ${B?"":"line-clamp-2"}`,children:$.content}),h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[$.importance!=null&&h.jsxs("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${$.importance>=7?"bg-red-500/15 text-red-500":$.importance>=4?"bg-amber-500/15 text-amber-600":"bg-surface-overlay text-fg-tertiary"}`,children:["P",$.importance]}),h.jsx("span",{className:"text-fg-tertiary text-[10px]",children:new Date($.timestamp).toLocaleTimeString()}),h.jsx("span",{className:"text-fg-tertiary text-[10px]",children:B?"▲":"▼"})]})]}),B&&h.jsxs("div",{className:"mx-3 mt-1 mb-2 p-3 bg-surface-elevated/30 rounded-lg border border-border-default/20",children:[h.jsx("pre",{className:"text-xs text-fg-secondary whitespace-pre-wrap font-mono leading-relaxed break-words",children:$.content}),h.jsxs("div",{className:"flex gap-3 mt-2 pt-2 border-t border-border-default/30 text-[10px] text-fg-tertiary",children:[h.jsxs("span",{children:[e("agent:profilePage.overview.labels.type"),": ",$.type]}),$.importance!=null&&h.jsxs("span",{children:[e("agent:profilePage.overview.labels.importance"),": ",$.importance]}),h.jsx("span",{children:new Date($.timestamp).toLocaleString()})]})]})]},j)})})}),a==="sessions"&&h.jsx(Gt,{title:e("agent:profilePage.memoryTab.chatSessions"),children:t.sessions.length===0?h.jsx(Gc,{text:e("agent:profilePage.memoryTab.noSessions")}):h.jsx("div",{className:"space-y-1.5 max-h-[600px] overflow-y-auto",children:t.sessions.map($=>{const j=m===$.id,B=async()=>{if(j){O(null),x([]);return}O($.id),_(!0);try{const F=await J.agents.getMemorySession(s,$.id);x(F.messages)}catch{x([])}_(!1)};return h.jsxs("div",{children:[h.jsxs("button",{onClick:B,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg bg-surface-elevated/20 hover:bg-surface-elevated/40 transition-colors cursor-pointer text-left",children:[h.jsx("div",{className:"text-xs text-fg-secondary font-mono flex-1 truncate",children:$.id}),h.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[$.messageCount," ",e("agent:profilePage.memoryTab.msgs")]}),h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date($.updatedAt).toLocaleDateString()}),h.jsx("span",{className:"text-fg-tertiary text-[10px]",children:j?"▲":"▼"})]}),j&&h.jsx("div",{className:"mx-3 mt-1 mb-2 bg-surface-elevated/30 rounded-lg border border-border-default/20 max-h-96 overflow-y-auto",children:y?h.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.memoryTab.loadingMessages")}):p.length===0?h.jsx("div",{className:"text-[10px] text-fg-tertiary py-3 text-center",children:e("agent:profilePage.memoryTab.noMessagesInSession")}):(()=>{const F=new Map;for(const V of p)V.role==="tool"&&V.toolCallId&&F.set(V.toolCallId,V.content);return h.jsx("div",{className:"divide-y divide-gray-700/30",children:p.filter(V=>V.role!=="tool").map((V,Z)=>h.jsxs("div",{className:"px-3 py-2",children:[(V.role==="user"||V.role==="system")&&h.jsxs("div",{children:[h.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 ${V.role==="user"?"bg-blue-500/15 text-blue-600":"bg-surface-overlay text-fg-secondary"}`,children:e(`agent:profilePage.memoryTab.roles.${V.role}`,{defaultValue:V.role})}),h.jsx("div",{className:"text-xs text-fg-secondary",children:h.jsx(ma,{content:V.content,className:"text-xs text-fg-secondary"})})]}),V.role==="assistant"&&h.jsxs("div",{className:"space-y-1",children:[V.content&&h.jsxs("div",{children:[h.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded text-[10px] font-medium mb-1 bg-green-500/15 text-green-600",children:e("agent:profilePage.memoryTab.roles.assistant")}),h.jsx("div",{className:"text-xs text-fg-secondary",children:h.jsx(ma,{content:V.content,className:"text-xs text-fg-secondary"})})]}),V.toolCalls&&V.toolCalls.length>0&&h.jsx("div",{className:"space-y-0.5",children:V.toolCalls.map(se=>{let T;try{T=JSON.parse(se.arguments)}catch{}const A={tool:se.name,status:"done",args:T,result:F.get(se.id)};return h.jsx(e_,{entry:{type:"tool",info:A}},se.id)})})]})]},Z))})})()})]},$.id)})})}),a==="daily"&&h.jsx(Gt,{title:e("agent:profilePage.memoryTab.dailyLogs"),action:Q?h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:()=>c(t?.recentDailyLogs??""),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:e("common:cancel")}),h.jsx("button",{onClick:w,disabled:f,className:"text-xs text-brand-500",children:e(f?"common:saving":"common:save")})]}):null,children:h.jsx("textarea",{value:l,onChange:$=>c($.target.value),placeholder:e("agent:profilePage.memoryTab.noDailyLogs"),className:"w-full min-h-[50vh] bg-surface-elevated/30 border border-border-default/50 hover:border-border-default focus:border-brand-500 rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y outline-none transition-colors"})}),a==="longterm"&&h.jsx(Gt,{title:e("agent:profilePage.memoryTab.longTermTitle"),action:I?h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:()=>u(t?.longTermMemory??""),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:e("common:cancel")}),h.jsx("button",{onClick:S,disabled:f,className:"text-xs text-brand-500",children:e(f?"common:saving":"common:save")})]}):null,children:h.jsx("textarea",{value:d,onChange:$=>u($.target.value),placeholder:e("agent:profilePage.memoryTab.noLongTerm"),className:"w-full min-h-[50vh] bg-surface-elevated/30 border border-border-default/50 hover:border-border-default focus:border-brand-500 rounded-lg p-4 text-xs font-mono text-fg-secondary leading-relaxed resize-y outline-none transition-colors"})})]})}function K0({agentId:s,initialData:e}){const{t}=Pt(["agent","common"]),[i,r]=C.useState(e??null),[n,a]=C.useState(!e),[o,l]=C.useState([]),[c,d]=C.useState(null),[u,f]=C.useState(!1),[g,b]=C.useState(null),v=C.useCallback(()=>Promise.all([J.agents.getHeartbeat(s).then(r).catch(()=>{}),J.agents.getRecentActivities(s).then(y=>{l(y.activities.filter(_=>_.type==="heartbeat"))}).catch(()=>{})]),[s]);C.useEffect(()=>{a(!0),v().finally(()=>a(!1))},[v]),C.useEffect(()=>gt.on("agent:update",_=>{_.payload?.agentId===s&&v()}),[s,v]);const m=async()=>{f(!0),b(null);try{const y=await J.agents.triggerHeartbeat(s);b(y.message),setTimeout(()=>b(null),4e3),setTimeout(v,2e3)}catch(y){b(String(y).replace("Error: ",""))}f(!1)},O=async y=>{try{await J.agents.cancelWakeup(s,y),v()}catch{}};if(n)return h.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:t("agent:profilePage.heartbeatTab.loading")});if(!i)return h.jsx("div",{className:"text-xs text-fg-tertiary py-8 text-center",children:t("agent:profilePage.heartbeatTab.noData")});const p=y=>y?y<1e3?`${y}ms`:y<6e4?`${(y/1e3).toFixed(1)}s`:`${(y/6e4).toFixed(1)}m`:null,x=y=>{if(!y)return null;const _=Date.now()-new Date(y).getTime();if(_<0){const k=Math.abs(_);return k<6e4?t("agent:profilePage.relative.inSeconds",{count:Math.ceil(k/1e3)}):k<36e5?t("agent:profilePage.relative.inMinutes",{count:Math.ceil(k/6e4)}):t("agent:profilePage.relative.inHours",{hours:(k/36e5).toFixed(1)})}return _<6e4?t("agent:profilePage.relative.secondsAgo",{count:Math.floor(_/1e3)}):_<36e5?t("agent:profilePage.relative.minutesAgo",{count:Math.floor(_/6e4)}):t("agent:profilePage.relative.hoursAgo",{hours:(_/36e5).toFixed(1)})};return h.jsxs("div",{className:"space-y-4",children:[h.jsxs(Gt,{title:t("agent:profilePage.heartbeatTab.scheduler"),action:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:v,className:"text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:t("common:refresh")}),h.jsx("button",{onClick:m,disabled:u||!i.running,className:"text-[10px] px-2.5 py-1 rounded-md bg-blue-600/20 text-blue-600 hover:bg-blue-600/30 border border-blue-500/30 transition-colors disabled:opacity-40",children:t(u?"agent:profilePage.heartbeatTab.triggering":"agent:profilePage.heartbeatTab.triggerNow")})]}),children:[h.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[h.jsx(as,{label:t("agent:profilePage.overview.labels.status"),value:i.running?t("agent:profilePage.heartbeatTab.running"):t("agent:profilePage.heartbeatTab.stopped"),color:i.running?"green":"gray"}),h.jsx(oM,{agentId:s,intervalMs:i.intervalMs,onChanged:v}),h.jsx(as,{label:t("agent:profilePage.heartbeatTab.lastRun"),value:i.lastHeartbeat?x(i.lastHeartbeat)??t("agent:profilePage.emDash"):t("agent:profilePage.never")}),h.jsx(as,{label:t("agent:profilePage.heartbeatTab.nextWake"),value:i.nextWakeAt?x(i.nextWakeAt)??t("agent:profilePage.emDash"):i.running?t("agent:profilePage.heartbeatTab.pending"):t("agent:profilePage.emDash")})]}),h.jsx("p",{className:"mt-2 text-[10px] text-fg-tertiary leading-relaxed",children:t("agent:profilePage.heartbeatTab.rhythmHint")}),g&&h.jsx("div",{className:"mt-3 text-[11px] text-blue-600 bg-blue-500/10 border border-blue-500/20 rounded-lg px-3 py-2",children:g})]}),i.wakeups&&i.wakeups.length>0&&h.jsx(Gt,{title:t("agent:profilePage.heartbeatTab.wakeupsTitle"),action:h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.heartbeatTab.wakeupsCount",{count:i.wakeups.length})}),children:h.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:i.wakeups.map(y=>h.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-2.5",children:[h.jsx("span",{className:"text-sm shrink-0 opacity-60",children:"⏰"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-xs text-fg-secondary truncate",children:y.note||t("agent:profilePage.heartbeatTab.wakeupNoNote")}),h.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[x(y.wakeAt)??new Date(y.wakeAt).toLocaleString(),y.recurringMs?` · ${t("agent:profilePage.heartbeatTab.recurring")}`:"",` · ${y.deliveryMode==="in_session"?t("agent:profilePage.heartbeatTab.deliveryInSession"):t("agent:profilePage.heartbeatTab.deliveryMailbox")}`]})]}),h.jsx("button",{onClick:()=>O(y.id),className:"text-[10px] px-2 py-0.5 rounded text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors shrink-0",children:t("agent:profilePage.heartbeatTab.cancelWakeup")})]},y.id))})}),i.pendingCallbacks&&i.pendingCallbacks.length>0&&h.jsx(Gt,{title:t("agent:profilePage.heartbeatTab.pendingOpsTitle"),action:h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.heartbeatTab.pendingOpsCount",{count:i.pendingCallbacks.length})}),children:h.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:i.pendingCallbacks.map(y=>h.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-2.5",children:[h.jsx("span",{className:"text-sm shrink-0 opacity-60",children:y.type==="background_exec"?"⚙":"↔"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-xs text-fg-secondary truncate font-mono",children:y.label}),h.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[t(`agent:profilePage.heartbeatTab.callbackType.${y.type}`),` · ${t("agent:profilePage.heartbeatTab.timesOut")} ${x(y.timeoutAt)??new Date(y.timeoutAt).toLocaleString()}`]})]})]},y.id))})}),i.lastSummary&&h.jsx(Gt,{title:t("agent:profilePage.heartbeatTab.lastSummary"),action:i.lastSummaryAt?h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(i.lastSummaryAt).toLocaleString()}):void 0,children:h.jsx("div",{className:"bg-surface-primary/50 rounded-lg px-4 py-3",children:h.jsx(ma,{content:i.lastSummary,className:"text-xs text-fg-secondary leading-relaxed"})})}),o.length>0?h.jsx(Gt,{title:t("agent:profilePage.heartbeatTab.recentRuns"),action:h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:t("agent:profilePage.heartbeatTab.runsThisSession",{count:o.length})}),children:h.jsx("div",{className:"divide-y divide-gray-800/50 -mx-5",children:[...o].reverse().map(y=>{const _=c===y.id;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>d(_?null:y.id),className:"w-full flex items-center gap-2.5 px-5 py-2.5 text-left transition-colors hover:bg-surface-elevated/40 cursor-pointer",children:[h.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 bg-blue-400"}),h.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:y.label}),h.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:t("agent:profilePage.heartbeatTab.actionsCount",{count:y.logCount})}),h.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(y.startedAt).toLocaleString()}),h.jsx("svg",{className:`w-3 h-3 text-fg-tertiary shrink-0 transition-transform ${_?"rotate-180":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:h.jsx("path",{d:"M3 4.5l3 3 3-3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})]}),_&&h.jsx("div",{className:"border-t border-border-default/60 bg-surface-primary/40",children:h.jsx(Ba,{agentId:s,activityId:y.id})})]},y.id)})})}):i.lastHeartbeat?null:h.jsx(Gt,{title:t("agent:profilePage.heartbeatTab.recentRuns"),children:h.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[h.jsx("div",{className:"text-xl mb-2 opacity-40",children:"♡"}),h.jsx("p",{className:"text-xs text-fg-tertiary",children:t("agent:profilePage.heartbeatTab.noRunsYet")}),h.jsx("p",{className:"text-[10px] text-fg-tertiary mt-1",children:i.running?t("agent:profilePage.heartbeatTab.firstHeartbeatSoon",{when:p(i.intervalMs-i.uptimeMs%i.intervalMs)??t("agent:profilePage.heartbeatTab.soon")}):t("agent:profilePage.heartbeatTab.schedulerStopped")}),i.running&&h.jsx("button",{onClick:m,disabled:u,className:"mt-3 text-[10px] px-3 py-1.5 rounded-md bg-blue-600/15 text-blue-600 hover:bg-blue-600/25 border border-blue-500/25 transition-colors disabled:opacity-40",children:t(u?"agent:profilePage.heartbeatTab.triggering":"agent:profilePage.heartbeatTab.runFirstNow")})]})})]})}function nM({taskId:s,isLive:e}){const{t}=Pt("agent"),[i,r]=C.useState([]),[n,a]=C.useState(""),[o,l]=C.useState(!0),[c,d]=C.useState("compact");if(C.useEffect(()=>{l(!0),a(""),J.tasks.getLogs(s).then(g=>{r(g.logs),l(!1)}).catch(()=>l(!1))},[s]),C.useEffect(()=>{if(!e)return;const g=gt.on("task:log",v=>{const m=v.payload;if(m.taskId!==s)return;const O={id:m.id,taskId:m.taskId,agentId:m.agentId,seq:m.seq,type:m.logType,content:m.content,metadata:m.metadata,createdAt:m.createdAt};r(p=>O.id&&p.some(x=>x.id===O.id)?p:[...p,O]),O.type==="text"&&a("")}),b=gt.on("task:log:delta",v=>{const m=v.payload;m.taskId===s&&a(O=>O+m.text)});return()=>{g(),b()}},[s,e]),o)return h.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:t("profilePage.taskLog.loading")});if(i.length===0&&!n)return h.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:t("profilePage.taskLog.noLogs")});const u=i.map(g=>r_(g)),f=new Set(u.filter(g=>g.executionRound!=null).map(g=>g.executionRound)).size>1;return h.jsx("div",{className:"px-3 py-2",children:c==="compact"?h.jsx(xx,{entries:u,streamingText:n,isActive:e,onExpand:()=>d("full"),showRounds:f}):h.jsx(vx,{entries:u,streamingText:n,isActive:e,onCollapse:()=>d("compact"),showRounds:f})})}function Ba({agentId:s,activityId:e,isLive:t=!1}){const{t:i}=Pt("agent"),[r,n]=C.useState([]),[a,o]=C.useState(!0),[l,c]=C.useState("compact");if(C.useEffect(()=>{o(!0),J.agents.getActivityLogs(s,e).then(u=>{n(u.logs),o(!1)}).catch(()=>o(!1))},[s,e]),C.useEffect(()=>t?gt.on("agent:activity_log",f=>{const g=f.payload;if(g.agentId!==s||g.activityId!==e)return;const b={seq:g.seq,type:g.type,content:g.content,metadata:g.metadata,createdAt:g.createdAt};n(v=>v.some(m=>m.seq===b.seq)?v:[...v,b])}):void 0,[s,e,t]),a)return h.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:i("profilePage.activityLog.loading")});if(r.length===0)return h.jsx("div",{className:"px-4 py-3 text-xs text-fg-tertiary",children:i("profilePage.activityLog.noLogs")});const d=r.map(u=>i_(u,e,s)).filter(u=>u!==null);return h.jsx("div",{className:"px-3 py-2",children:l==="compact"?h.jsx(xx,{entries:d,isActive:t,onExpand:()=>c("full")}):h.jsx(vx,{entries:d,isActive:t,onCollapse:()=>c("compact")})})}function Gt({title:s,action:e,children:t}){return h.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsx("h3",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider",children:s}),e]}),t]})}function Ds({label:s,mono:e,children:t}){return h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s}),h.jsx("span",{className:`text-xs text-fg-secondary ${e?"font-mono text-[10px]":""}`,children:t})]})}function as({label:s,value:e,color:t}){const i=t==="green"?"text-green-500":t==="blue"?"text-blue-400":t==="indigo"?"text-brand-500":t==="red"?"text-red-400":"text-fg-secondary";return h.jsxs("div",{className:"flex items-baseline gap-1.5",children:[h.jsx("span",{className:`text-sm font-semibold ${i}`,children:e}),h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s})]})}const J0=[1800*1e3,3600*1e3,10800*1e3,360*60*1e3,720*60*1e3,1440*60*1e3],ex=5,tx=1440;function oM({agentId:s,intervalMs:e,onChanged:t}){const{t:i}=Pt(["agent","common"]),[r,n]=C.useState(!1),[a,o]=C.useState(null),[l,c]=C.useState(!1),[d,u]=C.useState(String(Math.round(e/6e4))),f=p=>p%(3600*1e3)===0?i("agent:profilePage.heartbeatTab.intervalHours",{count:p/(3600*1e3)}):i("agent:profilePage.heartbeatTab.intervalMinutes",{count:Math.round(p/6e4)}),g=async p=>{n(!0),o(null);try{await J.agents.updateConfig(s,{heartbeatIntervalMs:p}),t()}catch(x){o(String(x).replace("Error: ",""))}n(!1)},b=p=>{if(p.target.value==="custom"){c(!0);return}c(!1),g(Number(p.target.value))},v=()=>{const p=Math.round(Number(d));if(!Number.isFinite(p)||p<ex||p>tx){o(i("agent:profilePage.heartbeatTab.intervalRangeHint"));return}g(p*60*1e3)},m=J0.includes(e),O=l||!m?"custom":String(e);return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:i("agent:profilePage.heartbeatTab.safetyNetInterval")}),h.jsxs("select",{value:O,onChange:b,disabled:r,className:"text-xs bg-bg-secondary border border-gray-700/50 rounded-md px-1.5 py-1 text-fg-secondary focus:outline-none focus:border-blue-500/50 disabled:opacity-40",children:[!m&&h.jsx("option",{value:String(e),children:f(e)}),J0.map(p=>h.jsx("option",{value:String(p),children:f(p)},p)),h.jsx("option",{value:"custom",children:i("agent:profilePage.heartbeatTab.intervalCustom")})]}),(l||!m)&&h.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[h.jsx("input",{type:"number",min:ex,max:tx,value:d,onChange:p=>u(p.target.value),disabled:r,className:"w-16 text-xs bg-bg-secondary border border-gray-700/50 rounded-md px-1.5 py-1 text-fg-secondary focus:outline-none focus:border-blue-500/50 disabled:opacity-40"}),h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:i("agent:profilePage.heartbeatTab.intervalCustomUnit")}),h.jsx("button",{onClick:v,disabled:r,className:"text-[10px] px-2 py-1 rounded-md bg-blue-600/20 text-blue-600 hover:bg-blue-600/30 border border-blue-500/30 transition-colors disabled:opacity-40",children:i(r?"agent:profilePage.heartbeatTab.intervalSaving":"agent:profilePage.heartbeatTab.intervalSave")})]}),a&&h.jsx("span",{className:"text-[10px] text-red-400",children:a})]})}function Gc({text:s}){return h.jsx("div",{className:"text-xs text-fg-tertiary py-6 text-center",children:s})}function sx(s){if(s===0)return"0 B";const e=["B","KB","MB","GB"],t=Math.min(Math.floor(Math.log(s)/Math.log(1024)),e.length-1),i=s/Math.pow(1024,t);return`${i<10?i.toFixed(1):Math.round(i)} ${e[t]}`}const ix={0:"0",1:"1",2:"2",3:"3",4:"4"},rx={0:"text-red-500",1:"text-amber-500",2:"text-fg-secondary",3:"text-fg-tertiary",4:"text-fg-tertiary/60"},aM={pick:"bg-brand-500/20 text-brand-500",continue:"bg-gray-500/20 text-gray-500",preempt:"bg-amber-500/20 text-amber-500",merge:"bg-blue-500/20 text-blue-500",defer:"bg-purple-500/20 text-purple-500",delegate:"bg-green-500/20 text-green-500",drop:"bg-red-500/20 text-red-500"},lM={idle:"bg-green-500/20 text-green-500",focused:"bg-brand-500/20 text-brand-500",deciding:"bg-amber-500/20 text-amber-500"},Hl={system_event:"⚙",human_chat:"💬",task_comment:"💬",mention:"@",session_reply:"↩",task_status_update:"📋",a2a_message:"🔗",review_request:"👀",requirement_update:"📝",requirement_comment:"💬",daily_report:"📊",heartbeat:"♡",memory_consolidation:"🧠"},cM=["all","interaction","task","notification","system"],hM={interaction:["human_chat","a2a_message","mention"],task:["task_status_update","task_comment","requirement_comment","review_request","session_reply"],notification:["requirement_update"],system:["system_event","heartbeat","daily_report","memory_consolidation"]},dM={completed:"bg-green-500",processing:"bg-blue-400 animate-pulse",deferred:"bg-purple-400",merged:"bg-brand-400",queued:"bg-amber-400",dropped:"bg-red-500"},uM={pending:"text-gray-400",assigned:"text-blue-400",in_progress:"text-brand-400",completed:"text-green-400",failed:"text-red-400",cancelled:"text-gray-500",review:"text-amber-400",approved:"text-green-500",rejected:"text-red-500",draft:"text-gray-400"};function hu(s){const e=s.match(/Comment from .+?:\s*(.+?)(?:\n\n\*\*MANDATORY|\n\n---|\n\n\[|$)/s);if(e?.[1]){const t=e[1].trim().replace(/\n/g," ");return t.length>80?t.slice(0,80)+"…":t}}function nx(s,e){const t=s.payload,i=t?.summary??"",r=t?.content??"",n=s.metadata?.senderName;switch(s.sourceType){case"task_status_update":{const a=i.match(/^Task "(.+?)" status:/),o=i.match(/status:\s*(\S+)\s*→\s*(\S+)/),l=a?.[1]??i;if(o){const d=o[1],u=o[2],f=bf(d,e),g=bf(u,e),b=uM[u]??"text-fg-secondary";return{title:l,subtitle:e("agent:profilePage.mind.mailbox.statusArrow",{from:f,to:g}),badge:{label:g,color:b}}}const c=i.match(/^Task:\s*(.+)/);return c?{title:c[1]}:{title:l}}case"task_comment":{const a=i.match(/^Comment on task "(.+?)" from (.+?)(\s*\(\+\d+\))?$/),o=hu(r);if(a){const l=o?e("agent:profilePage.mind.mailbox.commentFromAuthor",{author:a[2],text:o}):e("agent:profilePage.mind.mailbox.commentFrom",{name:a[2]});return{title:a[1],subtitle:l}}return{title:i}}case"requirement_update":{const a=i.match(/^Requirement "(.+?)"\s+(.*)/);return a?{title:a[1],subtitle:a[2]}:{title:i}}case"requirement_comment":{const a=i.match(/^Comment on requirement "(.+?)" from (.+?)(\s*\(\+\d+\))?$/),o=hu(r);if(a){const l=o?e("agent:profilePage.mind.mailbox.commentFromAuthor",{author:a[2],text:o}):e("agent:profilePage.mind.mailbox.commentFrom",{name:a[2]});return{title:a[1],subtitle:l}}return{title:i}}case"human_chat":{const a=r.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.chatFrom",{sender:n}):e("agent:profilePage.mind.mailbox.humanChat"),subtitle:a+(r.length>120?"…":"")}}case"a2a_message":{const a=r.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.messageFrom",{sender:n}):e("agent:profilePage.mind.mailbox.agentMessage"),subtitle:a+(r.length>120?"…":"")}}case"mention":{const a=i.match(/from (.+)$/),o=hu(r);return{title:a?e("agent:profilePage.mind.mailbox.mentionedBy",{name:a[1]}):e("agent:profilePage.mind.mailbox.mention"),subtitle:o||void 0}}case"review_request":{const a=r.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.reviewRequestFrom",{sender:n}):e("agent:profilePage.mind.mailbox.reviewRequest"),subtitle:a+(r.length>120?"…":"")}}case"session_reply":{const a=r.slice(0,120).replace(/\n/g," ");return{title:n?e("agent:profilePage.mind.mailbox.replyInSession",{sender:n}):e("agent:profilePage.mind.mailbox.sessionReply"),subtitle:a+(r.length>120?"…":"")}}case"heartbeat":return{title:e("agent:profilePage.mind.mailbox.scheduledHeartbeat")};case"daily_report":return{title:e("agent:profilePage.mind.mailbox.dailyReport")};case"memory_consolidation":return{title:e("agent:profilePage.mind.mailbox.memoryConsolidation")};case"system_event":{const a=i.match(/^\[Announcement]\s*(.+)/);return a?{title:a[1],subtitle:e("agent:profilePage.mind.mailbox.systemAnnouncement")}:{title:i||e("agent:profilePage.mind.mailbox.systemEvent")}}default:return{title:i||s.sourceType}}}function ox({agentId:s,highlightId:e,agentStatus:t,canManageAgents:i,onAgentStateChange:r}){const{t:n}=Pt(["agent","common","team"]),[a,o]=C.useState(null),[l,c]=C.useState(null),[d,u]=C.useState(!0),[f,g]=C.useState("all"),[b,v]=C.useState("all"),[m,O]=C.useState(e??null),[p,x]=C.useState(e??null),[y,_]=C.useState(!1),[k,w]=C.useState(!0),[S,Q]=C.useState(null),I=50,D=3,$=C.useCallback(async(T=!0)=>{T&&u(!0);try{const A=f==="all"?void 0:f,N=b==="all"?void 0:b,[z,U]=await Promise.all([J.agents.getMindState(s),J.agents.getMailbox(s,{limit:I,category:A,status:N})]);o(z),c(U),w((U.history?.length??0)>=I)}catch{}u(!1)},[s,f,b]),j=C.useCallback(async()=>{if(!l)return;const T=f==="all"?void 0:f,A=b==="all"?void 0:b;try{const N=await J.agents.getMailbox(s,{limit:I,offset:l.history.length,category:T,status:A});c(z=>z?{...z,history:[...z.history,...N.history]}:N),w((N.history?.length??0)>=I)}catch{}},[s,l,f,b]);C.useEffect(()=>{O(e??null),x(e??null),$()},[$,e]);const B=C.useRef(!1);if(C.useEffect(()=>{if(!p||d)return;if(l?.history?.some(A=>A.id===p)){B.current=!1;const A=document.getElementById(`mbx-${p}`);if(A){setTimeout(()=>A.scrollIntoView({behavior:"smooth",block:"center"}),100);const N=setTimeout(()=>x(null),3e3);return()=>clearTimeout(N)}}else k&&!B.current&&(B.current=!0,(async()=>{let A=l?.history??[],N=k;for(;N;)try{const z=await J.agents.getMailbox(s,{limit:I,offset:A.length}),U=[...A,...z.history];A=U,N=(z.history?.length??0)>=I;const ne=z.history.some(Se=>Se.id===p);if(c(Se=>Se?{...Se,history:U}:z),w(N),ne||!N)break}catch{break}B.current=!1})())},[p,d,l,k,s]),C.useEffect(()=>{let T=null;const A=z=>{z.payload?.agentId===s&&(T&&clearTimeout(T),T=setTimeout(()=>{T=null,$(!1)},500))},N=[gt.on("agent:mailbox",A),gt.on("agent:decision",A),gt.on("agent:attention",A),gt.on("agent:focus",A),gt.on("agent:update",A),gt.on("agent:triage",A)];return()=>{T&&clearTimeout(T),N.forEach(z=>z())}},[s,$]),d&&!a)return h.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("agent:profilePage.mind.loading")});const F=a?.mailboxDepth??a?.queuedItems?.length??0,V=(()=>{const T=a?.attentionState??"idle";return T==="deciding"||T==="idle"&&F>0?"deciding":T!=="idle"&&!a?.currentFocus?"idle":T})(),Z=V==="idle"&&l?.history?.some(T=>T.status==="processing"),se=(a?.attentionState??"idle")==="idle"&&F>0;return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[h.jsx("span",{className:`px-2.5 py-1 text-xs font-medium rounded-full ${lM[V]??"bg-gray-500/20 text-gray-500"}`,children:n(`agent:profilePage.mind.attention.${V}`)}),a?.currentFocus?(()=>{const T=nx({id:a.currentFocus.mailboxItemId,sourceType:a.currentFocus.type,payload:{summary:a.currentFocus.label,taskId:a.currentFocus.taskId},metadata:{},queuedAt:a.currentFocus.startedAt},n);return h.jsxs("span",{className:"text-sm text-fg-secondary inline-flex items-center gap-2",children:[h.jsxs("span",{children:[Hl[a.currentFocus.type]??"●"," ",h.jsx("span",{className:"text-fg-primary font-medium",children:T.title}),T.subtitle&&h.jsx("span",{className:"text-fg-tertiary ml-1.5 text-xs",children:T.subtitle}),h.jsx("span",{className:"text-fg-tertiary ml-2 text-xs",children:n("agent:profilePage.mind.since",{time:new Date(a.currentFocus.startedAt).toLocaleTimeString()})})]}),i&&h.jsxs("button",{onClick:()=>Q(a.currentFocus.mailboxItemId),className:"px-2 py-0.5 text-[10px] font-medium rounded-md bg-red-500/15 text-red-500 hover:bg-red-500/25 transition-colors shrink-0",children:["✕ ",n("agent:profilePage.mind.cancelCurrentBtn")]})]})})():se?h.jsx("span",{className:"text-sm text-amber-500",children:n("agent:profilePage.mind.queuedButIdle",{count:F,defaultValue:"Queue has {{count}} item(s) — attention loop should pick them up…"})}):V==="deciding"?h.jsx("span",{className:"text-sm text-amber-500",children:n("agent:profilePage.mind.decidingWaiting",{count:F})}):h.jsx("span",{className:"text-sm text-fg-tertiary",children:n("agent:profilePage.mind.idleWaiting")}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i&&t==="offline"&&h.jsxs("button",{onClick:()=>{J.agents.start(s).then(()=>{r?.(),$()})},className:"px-2.5 py-1 text-[11px] font-medium rounded-lg bg-green-500/15 text-green-500 hover:bg-green-500/25 transition-colors",children:["▶ ",n("agent:profilePage.mind.continueBtn")]}),i&&(t==="working"||t==="idle")&&h.jsxs("button",{onClick:()=>{J.agents.stop(s).then(()=>{r?.(),$()})},className:"px-2.5 py-1 text-[11px] font-medium rounded-lg bg-red-500/15 text-red-500 hover:bg-red-500/25 transition-colors",children:["■ ",n("team:contextMenu.stop")]}),h.jsx("button",{onClick:()=>{$()},className:"text-xs text-fg-tertiary hover:text-fg-secondary active:text-fg-primary transition-colors",children:n("agent:profilePage.mind.refresh")})]})]}),Z&&h.jsxs("div",{className:"mb-3 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30 flex items-center gap-2",children:[h.jsx("span",{className:"text-amber-500 text-sm",children:"⚠"}),h.jsx("span",{className:"text-[11px] text-amber-600",children:n("agent:profilePage.mind.staleProcessingWarning")})]}),(a?.queuedItems?.length??0)>0&&(()=>{const T=a.queuedItems,A=T.length>D,N=A&&!y?T.slice(0,D):T,z=T.reduce((U,ne)=>(U[ne.sourceType]=(U[ne.sourceType]??0)+1,U),{});return h.jsxs("div",{className:"mb-3",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[h.jsx("h4",{className:"text-xs font-medium text-amber-500 uppercase tracking-wider",children:n("agent:profilePage.mind.queue",{count:T.length})}),h.jsx("div",{className:"flex gap-1.5 flex-wrap",children:Object.entries(z).map(([U,ne])=>h.jsxs("span",{className:"text-[10px] text-fg-tertiary bg-amber-500/10 px-1.5 py-0.5 rounded",children:[Hl[U]??"●"," ",ne]},U))})]}),h.jsxs("div",{className:"space-y-1",children:[N.map((U,ne)=>h.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded bg-amber-500/5 border border-amber-500/20 text-sm",children:[h.jsx("span",{className:"text-fg-tertiary w-4 text-right text-xs",children:ne+1}),h.jsx("span",{className:"text-sm",children:Hl[U.sourceType]??"●"}),h.jsx("span",{className:`text-[10px] ${rx[U.priority]??"text-fg-tertiary"}`,children:n(`agent:profilePage.mind.priority.${ix[U.priority]??U.priority}`,{defaultValue:`P${U.priority}`})}),h.jsx("span",{className:"text-fg-secondary truncate flex-1 text-xs",children:U.summary}),h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:new Date(U.queuedAt).toLocaleTimeString()})]},U.id)),A&&h.jsx("button",{onClick:()=>_(!y),className:"w-full text-center text-[11px] text-amber-500 hover:text-amber-400 py-1 transition-colors",children:y?n("agent:profilePage.mind.collapseQueue"):n("agent:profilePage.mind.expandQueue",{count:T.length-D})})]})]})})()]}),(a?.notebook?.length??0)>0&&h.jsx("section",{className:"bg-surface-2 rounded-lg border border-border-subtle p-3",children:h.jsxs("details",{open:!0,children:[h.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[h.jsx("span",{className:"text-sm",children:"📓"}),h.jsx("h4",{className:"text-xs font-medium text-fg-secondary uppercase tracking-wider",children:"Notebook"}),h.jsxs("span",{className:"text-[10px] text-fg-quaternary ml-auto",children:[a.notebook.length," ",a.notebook.length===1?"entry":"entries"]})]}),h.jsx("div",{className:"mt-2 space-y-2",children:a.notebook.map(T=>{const A=Date.now()-T.updatedAt,N=A<6e4?`${Math.round(A/1e3)}s ago`:A<36e5?`${Math.round(A/6e4)}min ago`:`${(A/36e5).toFixed(1)}h ago`,z=T.managed==="system"?"text-blue-400":T.managed==="cpp"?"text-purple-400":"text-emerald-400";return h.jsxs("div",{className:"px-3 py-2 rounded bg-surface-3 border border-border-subtle",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("span",{className:"text-xs font-medium text-fg-primary",children:T.key}),h.jsxs("span",{className:`text-[10px] ${z}`,children:["[",T.managed,"]"]}),h.jsx("span",{className:"text-[10px] text-fg-quaternary ml-auto",children:N})]}),h.jsx("pre",{className:"text-[11px] text-fg-secondary whitespace-pre-wrap break-words leading-relaxed max-h-32 overflow-y-auto",children:T.text.length>500?T.text.slice(0,500)+"…":T.text})]},T.key)})})]})}),a?.deliberationActivity&&h.jsxs("section",{className:"bg-surface-2 rounded-lg border border-amber-500/20 p-3",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx("span",{className:"text-sm",children:"🧠"}),h.jsx("h4",{className:"text-xs font-medium text-amber-500 uppercase tracking-wider",children:n("agent:profilePage.mind.deliberationInProgress")}),h.jsx("span",{className:"text-[10px] text-fg-quaternary ml-auto",children:n("agent:profilePage.mind.since",{time:new Date(a.deliberationActivity.startedAt).toLocaleTimeString()})})]}),h.jsx(Ba,{agentId:s,activityId:a.deliberationActivity.activityId,isLive:!0})]}),a?.lastTriage&&(()=>{const A=Date.now()-new Date(a.lastTriage.timestamp).getTime()>6e4;return h.jsx("section",{className:`bg-surface-2 rounded-lg border p-3 transition-opacity ${A?"border-border-subtle opacity-60":"border-indigo-500/20"}`,children:h.jsxs("details",{open:!A,children:[h.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer list-none",children:[h.jsx("span",{className:"text-sm",children:"🧠"}),h.jsx("h4",{className:"text-xs font-medium text-indigo-400 uppercase tracking-wider",children:n("agent:profilePage.mind.triageDecision")}),h.jsx("span",{className:"text-[10px] text-fg-quaternary ml-auto",children:new Date(a.lastTriage.timestamp).toLocaleTimeString()})]}),h.jsx("p",{className:"text-xs text-fg-secondary leading-relaxed mt-2",children:a.lastTriage.reasoning}),h.jsxs("div",{className:"flex flex-wrap gap-2 mt-2 text-[10px]",children:[h.jsx("span",{className:"px-1.5 py-0.5 rounded bg-green-500/10 text-green-400",children:n("agent:profilePage.mind.processingItem",{id:a.lastTriage.processedItemId.slice(0,12)})}),a.lastTriage.deferredItemIds.length>0&&h.jsx("span",{className:"px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400",children:n("agent:profilePage.mind.deferred",{count:a.lastTriage.deferredItemIds.length})}),a.lastTriage.droppedItemIds.length>0&&h.jsx("span",{className:"px-1.5 py-0.5 rounded bg-red-500/10 text-red-400",children:n("agent:profilePage.mind.dropped",{count:a.lastTriage.droppedItemIds.length})}),(a.lastTriage.inlineCompletedIds?.length??0)>0&&h.jsx("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:n("agent:profilePage.mind.inlineCompleted",{count:a.lastTriage.inlineCompletedIds.length})})]})]})})})(),h.jsxs("section",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:n("agent:profilePage.mind.mailboxHistory")}),h.jsx("div",{className:"flex gap-1 ml-auto flex-wrap",children:cM.map(T=>{const A=l?.sourceTypeCounts,N=T==="all"?A?Object.values(A).reduce((z,U)=>z+U,0):void 0:A?(hM[T]??[]).reduce((z,U)=>z+(A[U]??0),0):void 0;return h.jsxs("button",{onClick:()=>g(T),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors ${f===T?"bg-brand-500/20 border-brand-500/40 text-brand-300":"bg-surface-2 border-border-subtle text-fg-secondary hover:bg-surface-3"}`,children:[n(`agent:profilePage.mind.categoryFilters.${T}`),N!=null&&N>0&&h.jsx("span",{className:"ml-1 opacity-60",children:N})]},T)})})]}),h.jsx("div",{className:"flex gap-1 mb-2 flex-wrap",children:[{key:"all",dot:""},{key:"queued",dot:"bg-amber-400"},{key:"processing",dot:"bg-blue-400"},{key:"completed",dot:"bg-green-500"},{key:"merged",dot:"bg-brand-400"},{key:"deferred",dot:"bg-purple-400"},{key:"dropped",dot:"bg-red-500"}].map(T=>{const A=l?.statusCounts,N=T.key==="all"?A?Object.values(A).reduce((z,U)=>z+U,0):void 0:A?.[T.key];return h.jsxs("button",{onClick:()=>v(T.key),className:`px-2 py-0.5 text-[10px] rounded-md border transition-colors flex items-center gap-1 ${b===T.key?"bg-brand-500/20 border-brand-500/40 text-brand-300":"bg-surface-2 border-border-subtle text-fg-secondary hover:bg-surface-3"}`,children:[T.dot&&h.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${T.dot}`}),n(`agent:profilePage.mind.statusFilters.${T.key}`),N!=null&&N>0&&h.jsx("span",{className:"ml-1 opacity-60",children:N})]},T.key)})}),(!l?.history||l.history.length===0)&&!d&&h.jsx("div",{className:"text-center text-fg-tertiary text-sm py-8",children:n("agent:profilePage.mind.noHistory")}),h.jsx("div",{className:"space-y-1",children:l?.history?.map(T=>{const A=m===T.id,N=Hl[T.sourceType]??"●",z=nx(T,n),U=T.metadata?.senderName,ne=T.metadata?.senderRole,Se=p===T.id;return h.jsxs("div",{id:`mbx-${T.id}`,className:`bg-surface-2 rounded-lg border transition-colors duration-1000 ${Se?"border-brand-500 ring-1 ring-brand-500/40":"border-border-subtle"}`,children:[h.jsxs("button",{className:"w-full px-3 py-2.5 flex items-start gap-2 text-left hover:bg-surface-3/50 transition-colors rounded-lg",onClick:()=>O(A?null:T.id),children:[h.jsx("span",{className:"text-xs mt-0.5 text-fg-tertiary",children:A?"▾":"▸"}),h.jsx("span",{className:`w-2 h-2 mt-1.5 rounded-full shrink-0 ${dM[T.status]??"bg-gray-400"}`}),h.jsx("span",{className:"text-sm",children:N}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:`text-xs font-medium text-fg-primary ${A?"":"truncate"}`,children:z.title}),z.badge&&h.jsx("span",{className:`text-[10px] font-medium shrink-0 ${z.badge.color}`,children:z.badge.label}),h.jsx("span",{className:`text-[10px] shrink-0 ${rx[T.priority]??"text-fg-tertiary"}`,children:n(`agent:profilePage.mind.priority.${ix[T.priority]??T.priority}`,{defaultValue:""})})]}),z.subtitle&&h.jsx("div",{className:`text-[11px] text-fg-secondary mt-0.5 ${A?"":"truncate"}`,children:z.subtitle}),h.jsxs("div",{className:"text-[10px] text-fg-tertiary mt-0.5 flex gap-2 flex-wrap",children:[h.jsx("span",{children:new Date(T.queuedAt).toLocaleString()}),T.completedAt&&h.jsxs("span",{children:["→ ",new Date(T.completedAt).toLocaleTimeString()]}),T.activity&&h.jsxs(h.Fragment,{children:[T.activity.totalTokens>0&&h.jsx("span",{children:n("agent:profilePage.mind.tokensCount",{count:Gn(T.activity.totalTokens)})}),T.activity.totalTools>0&&h.jsx("span",{children:n("agent:profilePage.mind.toolsCount",{count:T.activity.totalTools})})]})]})]}),h.jsx("span",{className:"text-[10px] text-fg-tertiary bg-surface-3 px-1.5 py-0.5 rounded shrink-0",children:T.sourceType}),i&&T.status==="processing"&&h.jsxs("button",{onClick:Pe=>{Pe.stopPropagation(),Q(T.id)},className:"px-2 py-0.5 text-[10px] font-medium rounded-md bg-red-500/15 text-red-500 hover:bg-red-500/25 transition-colors shrink-0",children:["✕ ",n("agent:profilePage.mind.cancelCurrentBtn")]})]}),A&&h.jsxs("div",{className:"border-t border-border-subtle px-3 py-3 space-y-3",children:[U&&h.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[n("agent:profilePage.mind.from")," ",h.jsx("span",{className:"text-fg-secondary",children:U}),ne&&h.jsxs("span",{className:"text-fg-tertiary",children:[" (",ne,")"]})]}),T.payload?.content&&["human_chat","a2a_message","task_comment","requirement_comment","review_request","session_reply","mention"].includes(T.sourceType)&&h.jsx("div",{className:"text-xs text-fg-secondary bg-surface-primary/50 rounded-md p-2.5 whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:T.payload.content}),T.decisions&&T.decisions.length>0&&h.jsxs("div",{children:[h.jsx("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:n("agent:profilePage.mind.decisions")}),h.jsx("div",{className:"space-y-1",children:T.decisions.map(Pe=>h.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[h.jsx("span",{className:`px-1.5 py-0.5 rounded shrink-0 ${aM[Pe.decisionType]??"bg-gray-500/20 text-gray-500"}`,children:Pe.decisionType}),h.jsx("span",{className:"text-fg-secondary flex-1",children:Pe.reasoning}),h.jsx("span",{className:"text-fg-tertiary shrink-0",children:new Date(Pe.createdAt).toLocaleTimeString()})]},Pe.id))})]}),T.activity?h.jsxs("div",{children:[h.jsxs("h5",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider mb-1",children:[n("agent:profilePage.mind.activityHeading",{label:T.activity.label}),h.jsx("span",{className:`ml-2 inline-block px-1 py-0 rounded text-[9px] ${T.activity.success?"bg-green-500/15 text-green-500":"bg-red-500/15 text-red-500"}`,children:T.activity.success?n("agent:profilePage.mind.success"):n("agent:profilePage.mind.failed")})]}),T.activity.type==="task"&&T.payload?.taskId?h.jsx(nM,{taskId:T.payload.taskId,isLive:!T.activity.endedAt}):h.jsx(Ba,{agentId:s,activityId:T.activity.id,isLive:!T.activity.endedAt})]}):T.status==="processing"?h.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2 animate-pulse",children:n("agent:profilePage.mind.processing")}):T.status==="completed"?h.jsx("div",{className:"text-xs text-fg-tertiary text-center py-2",children:n("agent:profilePage.mind.noActivityLog")}):null]})]},T.id)})}),k&&(l?.history?.length??0)>0&&h.jsx("div",{className:"text-center mt-3",children:h.jsx("button",{onClick:j,className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:n("agent:profilePage.mind.loadEarlier")})})]}),S&&h.jsx(Wa,{title:n("agent:profilePage.mind.cancelConfirmTitle"),message:n("agent:profilePage.mind.cancelConfirmMessage"),confirmLabel:n("agent:profilePage.mind.cancelCurrentBtn"),onConfirm:()=>{Q(null),J.agents.cancelProcessing(s).then(()=>{let T=0;const A=()=>{T+=1,$(),T<8&&window.setTimeout(A,750)};A()}).catch(()=>{$()})},onCancel:()=>Q(null)})]})}function ax({agentId:s}){const{t:e}=Pt(["agent","common"]),[t,i]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(null),l=C.useCallback(async()=>{n(!0);try{const{results:c}=await J.deliverables.search({agentId:s,limit:200});i(c)}catch{i([])}n(!1)},[s]);return C.useEffect(()=>{l()},[l]),C.useEffect(()=>{const c=gt.on("deliverable:created",()=>l()),d=gt.on("deliverable:updated",()=>l()),u=gt.on("deliverable:removed",()=>l());return()=>{c(),d(),u()}},[l]),r?h.jsx("div",{className:"space-y-3 py-4",children:[1,2,3].map(c=>h.jsxs("div",{className:"animate-pulse space-y-2",children:[h.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),h.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},c))}):t.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[h.jsx("span",{className:"text-3xl mb-3",children:"📦"}),h.jsx("p",{className:"text-sm text-fg-secondary",children:e("agent:deliverables.empty")}),h.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:e("agent:deliverables.emptyHint")})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:e("agent:deliverables.count",{count:t.length})}),t.map(c=>{const d=t_[c.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},u=Sm[c.status]??Sm.active;return h.jsxs("button",{onClick:()=>o(c),className:"w-full text-left rounded-xl border border-border-default bg-surface-elevated/30 overflow-hidden transition-colors hover:border-brand-500/40 hover:bg-surface-elevated/50 px-4 py-3 flex items-start gap-3",children:[h.jsx("span",{className:`inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 ${d.color}`,children:d.icon}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:c.title}),h.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${u.color}`,children:c.status})]}),c.summary&&h.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:c.summary}),h.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[10px] text-fg-tertiary",children:[h.jsx("span",{children:new Date(c.createdAt).toLocaleDateString()}),c.tags.length>0&&h.jsx("span",{children:c.tags.slice(0,3).join(", ")})]})]}),h.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]},c.id)})]}),a&&h.jsx(s_,{item:a,onClose:()=>o(null),onOpenInPage:c=>{o(null),Or.navigate(Ht.DELIVERABLES,{openDeliverable:c})}})]})}const fM=C.lazy(()=>bx(()=>import("./index-BMzsi3-i.js").then(s=>s.aE),__vite__mapDeps([0,1])).then(s=>({default:s.MarkdownMessage}))),Ap=[{key:"overview",labelKey:"teamProfile.overview",icon:"▦"},{key:"announcements",labelKey:"teamProfile.announcements",icon:"◈"},{key:"norms",labelKey:"teamProfile.norms",icon:"☰"},{key:"settings",labelKey:"teamProfile.settings",icon:"⚙"}],lx={idle:"bg-green-400",working:"bg-blue-400 animate-pulse",offline:"bg-gray-500",error:"bg-red-400"};function cx({teamId:s,onBack:e,inline:t,headless:i,activeTab:r,onSelectAgent:n}){const{t:a}=Pt("team"),[o,l]=C.useState(null),[c,d]=C.useState(null),[u,f]=C.useState("overview"),g=i&&r?r:u,[b,v]=C.useState(""),[m,O]=C.useState(""),[p,x]=C.useState(!1),[y,_]=C.useState(!1),[k,w]=C.useState(""),[S,Q]=C.useState(""),I=C.useRef(null),D=C.useRef(null),$=C.useRef(null),j=C.useRef(null),[B,F]=C.useState(!1),[V,Z]=C.useState(!1),[se,T]=C.useState(""),[A,N]=C.useState(""),[z,U]=C.useState(!1),[ne,Se]=C.useState([]),Pe=C.useRef(null),X=C.useCallback(async()=>{try{const ee=(await J.teams.list()).teams.find(ke=>ke.id===s);ee&&l(ee);const le=await J.teams.status(s);Se(le.agents)}catch{}},[s]),M=C.useCallback(async()=>{try{const Y=await J.teams.getFile(s,"ANNOUNCEMENT.md");v(Y.content)}catch{v("")}try{const Y=await J.teams.getFile(s,"NORMS.md");O(Y.content)}catch{O("")}},[s]);C.useEffect(()=>{f("overview"),X(),M()},[s,X,M]),C.useEffect(()=>{p&&D.current&&D.current.focus()},[p]),C.useEffect(()=>{y&&j.current&&j.current.focus()},[y]);const K=async(Y,ee)=>{F(!0);try{await J.teams.updateFile(s,Y,ee),Y==="ANNOUNCEMENT.md"?(v(ee),x(!1)):(O(ee),_(!1))}catch{}F(!1)},ie=async()=>{se.trim()&&(await J.teams.update(s,{name:se.trim()}),Z(!1),X())},oe=async()=>{await J.teams.update(s,{description:A}),U(!1),X()};if(!o)return h.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm",children:"Loading team..."});const G=o.members.find(Y=>Y.agentRole==="manager"),$e=ne.filter(Y=>Y.status!=="offline").length,Ie=g==="announcements"&&p||g==="norms"&&y;if(i)return h.jsx("div",{className:`flex-1 bg-surface-primary ${Ie?"flex flex-col overflow-hidden":"overflow-y-auto"}`,children:h.jsxs("div",{className:`${Ie?"flex-1 flex flex-col min-h-0 p-5":"p-5"}`,children:[g==="overview"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Manager"}),h.jsx("div",{className:"text-sm font-medium",children:G?.name??o.managerName??"None"})]}),h.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team ID"}),h.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:o.id})]})]}),h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:"text-xs text-fg-tertiary font-medium px-1",children:"Members"}),o.members.map(Y=>{const ee=ne.find(Ce=>Ce.id===Y.id),le=lx[ee?.status??"offline"]??"bg-gray-500",ke=Y.type==="agent";return h.jsxs("div",{onClick:()=>ke&&n?.(Y.id),className:`p-3 bg-surface-secondary rounded-xl border border-border-default flex items-center gap-3${ke&&n?" cursor-pointer hover:border-brand-500/40 transition-colors":""}`,children:[h.jsx(_s,{name:Y.name,avatarUrl:Y.avatarUrl,size:32,className:"rounded-lg"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-medium",children:Y.name}),h.jsx("span",{className:`w-2 h-2 rounded-full ${le}`}),h.jsx("span",{className:"text-xs text-fg-tertiary",children:ee?.status??"offline"}),Y.agentRole==="manager"&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),h.jsxs("div",{className:"text-xs text-fg-tertiary",children:[Y.role," · ",Y.type]})]}),ke&&n&&h.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("polyline",{points:"9 18 15 12 9 6"})})]},Y.id)}),o.members.length===0&&h.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]})]}),g==="announcements"&&h.jsx(Gl,{content:b,draft:k,setDraft:w,editing:p,setEditing:x,textareaRef:D,contentRef:I,saving:B,onSave:()=>K("ANNOUNCEMENT.md",k),placeholder:a("teamProfile.annPlaceholder"),emptyText:a("teamProfile.noAnnouncements")}),g==="norms"&&h.jsx(Gl,{content:m,draft:S,setDraft:Q,editing:y,setEditing:_,textareaRef:j,contentRef:$,saving:B,onSave:()=>K("NORMS.md",S),placeholder:a("teamProfile.normsPlaceholder"),emptyText:a("teamProfile.noNorms")}),g==="settings"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team Name"}),V?h.jsxs("div",{className:"flex gap-2 items-center",children:[h.jsx("input",{ref:Pe,value:se,onChange:Y=>T(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&ie(),className:"flex-1 bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary focus:outline-none focus:border-brand-500",autoFocus:!0}),h.jsx("button",{onClick:ie,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),h.jsx("button",{onClick:()=>Z(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]}):h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm",children:o.name}),h.jsx("button",{onClick:()=>{T(o.name),Z(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Description"}),z?h.jsxs("div",{className:"space-y-2",children:[h.jsx("textarea",{value:A,onChange:Y=>N(Y.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500",rows:3,autoFocus:!0}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:oe,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),h.jsx("button",{onClick:()=>U(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]})]}):h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-fg-secondary",children:o.description||"No description"}),h.jsx("button",{onClick:()=>{N(o.description??""),U(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),h.jsx(hx,{teamId:s,teamName:o.name,onDeleted:e})]})]})});const We=u==="announcements"&&p||u==="norms"&&y;return h.jsxs("div",{className:`flex-1 bg-surface-primary ${We?"flex flex-col overflow-hidden":"overflow-y-auto"}`,children:[h.jsxs("div",{className:"px-5 py-3.5 bg-surface-secondary sticky top-0 z-10 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand-600 text-white flex items-center justify-center text-lg font-bold shrink-0",children:h.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("h2",{className:"text-base font-semibold",children:o.name}),h.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-brand-500/15 text-brand-500 rounded font-medium",children:[o.members.length," members"]}),h.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] bg-green-500/15 text-green-600 rounded font-medium",children:[$e," online"]})]}),h.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:o.description||"No description"})]}),h.jsxs("button",{onClick:async()=>{if(o)try{const{files:Y}=await J.teams.getFilesMap(o.id),ee=o.members.filter(ke=>ke.type==="agent"),le={type:"team",name:gx(o.name,o.name),displayName:o.name,version:"1.0.0",description:o.description??"",author:"",category:"general",tags:[],team:{members:ee.map(ke=>({name:ke.name,roleName:ke.role,role:ke.agentRole??"worker",count:1,skills:[]}))}};await Ox.publishViaProxy({itemType:"team",name:o.name,description:o.description??"",category:"general",config:le,files:Y}),d({title:"Hub",message:`Published "${o.name}" to Markus Hub`,variant:"primary"})}catch(Y){d({title:"Hub",message:`Failed to publish: ${Y}`,variant:"danger"})}},className:"px-3 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg transition-colors flex items-center gap-1",title:"Publish to Markus Hub",children:[h.jsx("span",{children:"↑"})," Hub"]}),t&&h.jsx("button",{onClick:e,className:"p-1.5 text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]}),h.jsx("div",{className:"flex gap-1 mt-3 -mb-[1px] overflow-x-auto",children:Ap.map(Y=>h.jsxs("button",{onClick:()=>f(Y.key),className:`px-3 py-1.5 text-xs rounded-t-lg whitespace-nowrap transition-colors ${u===Y.key?"bg-surface-primary text-fg-primary border border-border-default border-b-gray-950":"text-fg-tertiary hover:text-fg-secondary"}`,children:[Y.icon," ",a(Y.labelKey)]},Y.key))})]}),h.jsxs("div",{className:`${We?"flex-1 flex flex-col min-h-0 p-5":"p-5"}`,children:[u==="overview"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Manager"}),h.jsx("div",{className:"text-sm font-medium",children:G?.name??o.managerName??"None"})]}),h.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default",children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team ID"}),h.jsx("div",{className:"text-sm font-mono text-fg-secondary truncate",children:o.id})]})]}),h.jsxs("div",{className:"space-y-3",children:[h.jsx("div",{className:"text-xs text-fg-tertiary font-medium px-1",children:"Members"}),o.members.map(Y=>{const ee=ne.find(Ce=>Ce.id===Y.id),le=lx[ee?.status??"offline"]??"bg-gray-500",ke=Y.type==="agent";return h.jsxs("div",{onClick:()=>ke&&n?.(Y.id),className:`p-3 bg-surface-secondary rounded-xl border border-border-default flex items-center gap-3${ke&&n?" cursor-pointer hover:border-brand-500/40 transition-colors":""}`,children:[h.jsx(_s,{name:Y.name,avatarUrl:Y.avatarUrl,size:32,className:"rounded-lg"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-medium",children:Y.name}),h.jsx("span",{className:`w-2 h-2 rounded-full ${le}`}),h.jsx("span",{className:"text-xs text-fg-tertiary",children:ee?.status??"offline"}),Y.agentRole==="manager"&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-amber-500/15 text-amber-600 rounded font-medium",children:"Manager"})]}),h.jsxs("div",{className:"text-xs text-fg-tertiary",children:[Y.role," · ",Y.type]})]}),ke&&n&&h.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("polyline",{points:"9 18 15 12 9 6"})})]},Y.id)}),o.members.length===0&&h.jsx("div",{className:"text-sm text-fg-tertiary text-center py-8",children:"No members"})]})]}),u==="announcements"&&h.jsx(Gl,{content:b,draft:k,setDraft:w,editing:p,setEditing:x,textareaRef:D,contentRef:I,saving:B,onSave:()=>K("ANNOUNCEMENT.md",k),placeholder:a("teamProfile.annPlaceholder"),emptyText:a("teamProfile.noAnnouncements")}),u==="norms"&&h.jsx(Gl,{content:m,draft:S,setDraft:Q,editing:y,setEditing:_,textareaRef:j,contentRef:$,saving:B,onSave:()=>K("NORMS.md",S),placeholder:a("teamProfile.normsPlaceholder"),emptyText:a("teamProfile.noNorms")}),u==="settings"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-border-default space-y-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Team Name"}),V?h.jsxs("div",{className:"flex gap-2 items-center",children:[h.jsx("input",{ref:Pe,value:se,onChange:Y=>T(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&ie(),className:"flex-1 bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary focus:outline-none focus:border-brand-500",autoFocus:!0}),h.jsx("button",{onClick:ie,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),h.jsx("button",{onClick:()=>Z(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]}):h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm",children:o.name}),h.jsx("button",{onClick:()=>{T(o.name),Z(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-xs text-fg-tertiary mb-1",children:"Description"}),z?h.jsxs("div",{className:"space-y-2",children:[h.jsx("textarea",{value:A,onChange:Y=>N(Y.target.value),className:"w-full bg-surface-elevated border border-border-default rounded-lg px-3 py-1.5 text-sm text-fg-primary resize-y focus:outline-none focus:border-brand-500",rows:3,autoFocus:!0}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:oe,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 rounded-lg text-white",children:"Save"}),h.jsx("button",{onClick:()=>U(!1),className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary",children:"Cancel"})]})]}):h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-fg-secondary",children:o.description||"No description"}),h.jsx("button",{onClick:()=>{N(o.description??""),U(!0)},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:"Edit"})]})]})]}),h.jsx(hx,{teamId:s,teamName:o.name,onDeleted:e})]})]}),c&&h.jsx(Wa,{alertOnly:!0,variant:c.variant??"primary",title:c.title,message:c.message,onConfirm:()=>d(null),onCancel:()=>d(null)})]})}function Gl({content:s,draft:e,setDraft:t,editing:i,setEditing:r,textareaRef:n,contentRef:a,saving:o,onSave:l,placeholder:c,emptyText:d}){return i?h.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[h.jsx("textarea",{ref:n,value:e,onChange:u=>t(u.target.value),onBlur:()=>{e!==s?l():r(!1)},onKeyDown:u=>{u.key==="Escape"&&(u.preventDefault(),t(s),r(!1))},className:"flex-1 w-full bg-transparent border border-brand-500/30 rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none resize-none px-3 py-2 font-mono",placeholder:c}),o&&h.jsx("div",{className:"text-xs text-fg-tertiary mt-1 shrink-0",children:"Saving..."})]}):h.jsx("div",{ref:a,className:"group relative cursor-pointer rounded-lg px-1 py-1 hover:bg-surface-elevated/50 transition-colors min-h-[80px]",onClick:()=>{t(s),r(!0)},role:"button",tabIndex:0,onKeyDown:u=>{u.key==="Enter"&&(t(s),r(!0))},children:s.trim()?h.jsx(C.Suspense,{fallback:h.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:h.jsx(fM,{content:s,className:"text-sm text-fg-secondary leading-relaxed"})}):h.jsx("div",{className:"text-sm text-fg-tertiary italic",children:d})})}function hx({teamId:s,teamName:e,onDeleted:t}){const[i,r]=C.useState(!1),[n,a]=C.useState(!1),[o,l]=C.useState(!1),[c,d]=C.useState(!1);return h.jsxs("div",{className:"p-4 bg-surface-secondary rounded-xl border border-red-900/30 space-y-3",children:[h.jsx("div",{className:"text-sm font-medium text-red-500",children:"Danger Zone"}),i?h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"text-xs text-fg-secondary",children:['Delete team "',e,'"? This removes the team record from the database.']}),h.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:o,onChange:u=>l(u.target.checked),className:"rounded"}),"Also delete all members in this team"]}),h.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-secondary cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:n,onChange:u=>a(u.target.checked),className:"rounded"}),"Also delete disk files (workspace, memory, logs)"]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{disabled:c,onClick:async()=>{d(!0);try{await J.teams.delete(s,o,{purgeFiles:n}),window.dispatchEvent(new CustomEvent("markus:data-changed")),t()}catch{d(!1)}},className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50",children:c?"Deleting...":"Confirm Delete"}),h.jsx("button",{onClick:()=>r(!1),className:"px-4 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary rounded-lg transition-colors border border-border-default",children:"Cancel"})]})]}):h.jsx("button",{onClick:()=>r(!0),className:"px-4 py-1.5 text-xs bg-red-600/20 hover:bg-red-600/30 text-red-500 rounded-lg transition-colors border border-red-500/30",children:"Delete Team"})]})}function Kl(s,e,t,i){return s==="channel"?`ch:${t}`:s==="dm"?`dm:${i??""}`:e||"_direct"}class mr{currentConvKey="";loadingSession=null;msgBuffers=new Map;sessionMsgCache=new Map;activeSession=new Map;actBuffers=new Map;sessionTabs=new Map;phase=new Map;sendCount=new Map;streamingSessions=new Map;sessionCacheOrder=[];static MAX_MESSAGES=500;static MAX_CONVERSATIONS=20;static MAX_SESSION_CACHE=30;static NEW_CHAT_ID="__new_chat__";getPhase(e){return this.phase.get(e)??"idle"}beginLoad(e){this.getPhase(e)!=="streaming"&&this.phase.set(e,"loading")}completeLoad(e){this.getPhase(e)==="loading"&&this.phase.set(e,"ready")}beginStream(e){this.phase.set(e,"streaming")}endStream(e){this.getPhase(e)==="streaming"&&this.phase.set(e,"ready")}resetConv(e){this.phase.set(e,"idle"),this.activeSession.delete(e)}updateMessages(e,t,i){const r=this.activeSession.get(e),n=!i||r===i||r===void 0,a=n?this.msgBuffers.get(e)??[]:this.sessionMsgCache.get(i)??[];let o=t(a);o.length>mr.MAX_MESSAGES&&(o=o.slice(-500));let l=!1;return n&&(this.msgBuffers.set(e,o),this.evictIfNeeded(e),l=this.currentConvKey===e),i&&i!==mr.NEW_CHAT_ID&&(this.sessionMsgCache.set(i,o),this.touchSessionCache(i)),{displayChanged:l,newMessages:l?o:void 0}}applyLoadResult(e,t,i){const r=this.isCacheFresher(t,i);r||(this.sessionMsgCache.set(t,i),this.touchSessionCache(t));const n=this.getPhase(e),a=this.activeSession.get(e);if(this.currentConvKey===e&&(this.loadingSession===t||a===t)&&n!=="streaming"){const l=r?this.sessionMsgCache.get(t):i;return this.msgBuffers.set(e,l),this.loadingSession=t,this.completeLoad(e),{displayChanged:!0,newMessages:l}}return{displayChanged:!1}}appendActivity(e,t,i){const r=i??e,n=[...this.actBuffers.get(r)??[],t];if(this.actBuffers.set(r,n),this.currentConvKey!==e)return{displayChanged:!1};const a=this.activeSession.get(e);return!i||!a||a===i?{displayChanged:!0,newActivities:n}:{displayChanged:!1}}getActiveSession(e){return this.activeSession.get(e)}setActiveSession(e,t){this.activeSession.set(e,t)}saveToCache(e,t){if(!t||t===mr.NEW_CHAT_ID)return;const i=this.msgBuffers.get(e);i&&i.length>0&&(this.sessionMsgCache.set(t,i),this.touchSessionCache(t))}restoreFromCache(e,t){const i=this.sessionMsgCache.get(t);if(i&&i.length>0)return this.msgBuffers.set(e,i),i;this.msgBuffers.delete(e)}isCacheFresher(e,t){const i=this.sessionMsgCache.get(e);if(!i||i.length===0)return!1;if(i.length>t.length)return!0;const r=i.reduce((l,c)=>l+c.text.length,0),n=t.reduce((l,c)=>l+c.text.length,0);if(r>n)return!0;const a=i.reduce((l,c)=>l+(c.segments?.length??0),0),o=t.reduce((l,c)=>l+(c.segments?.length??0),0);return a>o}incrementSend(e){this.sendCount.set(e,(this.sendCount.get(e)??0)+1)}decrementSend(e){const t=Math.max(0,(this.sendCount.get(e)??1)-1);return this.sendCount.set(e,t),t}resetSend(e){this.sendCount.set(e,0)}isSending(e){return(this.sendCount.get(e)??0)>0}addStreamSession(e,t){const i=this.streamingSessions.get(e)??new Set;i.add(t),this.streamingSessions.set(e,i)}removeStreamSession(e,t){if(t){const i=this.streamingSessions.get(e);i&&(i.delete(t),i.size===0&&this.streamingSessions.delete(e))}else this.streamingSessions.delete(e)}getStreamSessions(e){return this.streamingSessions.get(e)}getMessages(e){return this.msgBuffers.get(e)}getActivities(e){return this.actBuffers.get(e)??[]}deleteBuffer(e){this.msgBuffers.delete(e)}evictIfNeeded(e){if(this.msgBuffers.size<=mr.MAX_CONVERSATIONS)return;const t=[...this.msgBuffers.keys()],i=t.filter(r=>r!==e&&r!==this.currentConvKey).slice(0,t.length-mr.MAX_CONVERSATIONS);for(const r of i)this.msgBuffers.delete(r),this.actBuffers.delete(r),this.sessionTabs.delete(r),this.activeSession.delete(r)}touchSessionCache(e){const t=this.sessionCacheOrder.indexOf(e);for(t!==-1&&this.sessionCacheOrder.splice(t,1),this.sessionCacheOrder.push(e);this.sessionCacheOrder.length>mr.MAX_SESSION_CACHE;){const i=this.sessionCacheOrder.shift();if(new Set(this.activeSession.values()).has(i)){this.sessionCacheOrder.push(i);break}this.sessionMsgCache.delete(i)}}}const St=mr.NEW_CHAT_ID;function pM(s){const e=C.useRef(new mr),[t,i]=C.useState(s??[]),[r,n]=C.useState(!1),[a,o]=C.useState([]),l=C.useRef(null);C.useEffect(()=>()=>{l.current!==null&&cancelAnimationFrame(l.current)},[]);const c=C.useCallback((p,x,y)=>{const _=e.current.updateMessages(p,x,y);_.displayChanged&&_.newMessages&&i(_.newMessages)},[]),d=C.useCallback((p,x,y)=>{e.current.updateMessages(p,x,y).displayChanged&&l.current===null&&(l.current=requestAnimationFrame(()=>{l.current=null;const k=e.current.getMessages(p);k&&e.current.currentConvKey===p&&i([...k])}))},[]),u=C.useCallback((p,x,y)=>{const _=e.current.appendActivity(p,x,y);_.displayChanged&&_.newActivities&&o(_.newActivities)},[]),f=C.useCallback(p=>e.current.getPhase(p),[]),g=C.useCallback(p=>e.current.beginLoad(p),[]),b=C.useCallback(p=>e.current.beginStream(p),[]),v=C.useCallback(p=>e.current.endStream(p),[]),m=C.useCallback(p=>{e.current.resetConv(p),e.current.deleteBuffer(p)},[]),O=C.useCallback(async(p,x,y)=>{e.current.loadingSession=p,e.current.beginLoad(x);try{const _=await y(),k=e.current.applyLoadResult(x,p,_.messages);return k.displayChanged&&k.newMessages&&i(k.newMessages),{count:_.messages.length,hasMore:_.hasMore,oldestCursor:_.oldestCursor}}catch{return e.current.currentConvKey===x&&e.current.getPhase(x)!=="streaming"&&(i([]),e.current.completeLoad(x)),{count:0,hasMore:!1,oldestCursor:null}}},[]);return{manager:e.current,messages:t,setMessages:i,sending:r,setSending:n,activities:a,setActivities:o,get msgBuffers(){return e.current.msgBuffers},get sessionMsgCache(){return e.current.sessionMsgCache},get activeSessionBuffer(){return e.current.activeSession},get actBuffers(){return e.current.actBuffers},get sessionTabsBuffer(){return e.current.sessionTabs},get currentConvKeyRef(){return{get current(){return e.current.currentConvKey},set current(p){e.current.currentConvKey=p}}},get loadingSessionRef(){return{get current(){return e.current.loadingSession},set current(p){e.current.loadingSession=p}}},updateConvMsgs:c,updateConvMsgsRaf:d,appendConvActivity:u,getPhase:f,beginLoad:g,beginStream:b,endStream:v,resetConv:m,loadAndDisplay:O,incrementSending:p=>e.current.incrementSend(p),decrementSending:p=>e.current.decrementSend(p),resetSending:p=>e.current.resetSend(p),isSendingFor:p=>e.current.isSending(p),setStreamSession:(p,x)=>e.current.addStreamSession(p,x),clearStreamSession:(p,x)=>e.current.removeStreamSession(p,x),getStreamSession:p=>e.current.getStreamSessions(p),saveSessionToCache:(p,x)=>e.current.saveToCache(p,x),restoreSessionFromCache:(p,x)=>{const y=e.current.restoreFromCache(p,x);return i(y??[]),y},isSessionCacheFresherThanDb:(p,x)=>e.current.isCacheFresher(p,x)}}function mM({value:s,onSelect:e,disabled:t}){const{t:i}=Pt("team"),[r,n]=C.useState(!1),[a,o]=C.useState(!0),[l,c]=C.useState(""),[d,u]=C.useState(!1),[f,g]=C.useState([]),[b,v]=C.useState(null),m=C.useRef(null),O=C.useCallback(async()=>{u(!0);try{const w=await fetch("/api/settings/llm",{credentials:"include"});if(!w.ok)throw new Error(`HTTP ${w.status}`);const S=await w.json(),Q=S.providers?.markus;if(Q?.configured&&Q.enabled!==!1&&(!Q.models||Q.models.length===0))try{const j=await fetch("/api/models/live/markus",{credentials:"include"});if(j.ok){const B=await j.json();B.models?.length&&(Q.models=B.models)}}catch{}const I=[];for(const[j,B]of Object.entries(S.providers??{})){if(!B.configured||B.enabled===!1)continue;const F=(B.models??[]).map(V=>({id:V.id,name:V.name}));F.length!==0&&I.push({provider:j,displayName:B.displayName??j,models:F})}I.sort((j,B)=>j.displayName.localeCompare(B.displayName)),g(I);const D=j=>!j?.provider||!j.model?!1:!!I.find(F=>F.provider===j.provider)?.models.some(F=>F.id===j.model);let $=null;if(S.routingDefaultModel?.provider&&S.routingDefaultModel?.model)$={provider:S.routingDefaultModel.provider,model:S.routingDefaultModel.model};else if(S.defaultProvider){const j=S.providers?.[S.defaultProvider];j?.model&&($={provider:S.defaultProvider,model:j.model})}if($&&!D($)){const j=I.find(F=>F.provider==="markus"),B=j?.models[0]?{provider:"markus",model:j.models[0].id}:I[0]?.models[0]?{provider:I[0].provider,model:I[0].models[0].id}:null;B?($=B,J.settings.updateRouting({defaultProvider:B.provider,routingDefaultModel:B}).catch(()=>{})):$=null}v($)}catch{g([])}finally{u(!1)}},[]);C.useEffect(()=>{O()},[O]),C.useEffect(()=>{r&&(o(!0),c(""),O())},[r,O]),C.useEffect(()=>{if(!r)return;const w=S=>{m.current?.contains(S.target)||n(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[r]);const p=C.useMemo(()=>{const w=l.trim().toLowerCase();return f.map(S=>({...S,models:w?S.models.filter(Q=>Q.id.toLowerCase().includes(w)||(Q.name?.toLowerCase().includes(w)??!1)||S.displayName.toLowerCase().includes(w)||S.provider.toLowerCase().includes(w)):S.models})).filter(S=>S.models.length>0)},[f,l]),x=C.useCallback(w=>!w?.provider||!w.model?!1:f.length===0?!0:!!f.find(Q=>Q.provider===w.provider)?.models.some(Q=>Q.id===w.model),[f]);C.useEffect(()=>{if(!s||f.length===0||x(s))return;const w=b&&x(b)?b:(()=>{const S=f.find(Q=>Q.provider==="markus");return S?.models[0]?{provider:"markus",model:S.models[0].id}:f[0]?.models[0]?{provider:f[0].provider,model:f[0].models[0].id}:null})();w&&e(w,!1)},[s,f,b,x,e]);const y=s&&x(s)?s:b,k=(y?.model?y.model.includes("/")?y.model.split("/").pop():y.model:"")||i("chatModel.title",{defaultValue:"Model"});return h.jsxs("div",{ref:m,className:"relative shrink-0",children:[h.jsxs("button",{type:"button",disabled:t,onClick:()=>n(w=>!w),className:"max-w-[180px] px-1.5 py-1 text-[12px] text-fg-secondary hover:text-fg-primary disabled:opacity-40 rounded-md hover:bg-surface-elevated transition-colors flex items-center gap-1",title:y?`${y.provider}: ${y.model}`:i("chatModel.title",{defaultValue:"Model"}),children:[h.jsx("span",{className:"truncate",children:k}),h.jsx("svg",{className:"w-3 h-3 shrink-0 opacity-60",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M6 9l6 6 6-6",strokeLinecap:"round",strokeLinejoin:"round"})})]}),r&&h.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-[300px] max-h-[360px] flex flex-col rounded-xl border border-border-default bg-surface-elevated shadow-xl z-50 overflow-hidden",children:[h.jsxs("div",{className:"p-2 border-b border-border-default/60 space-y-2",children:[h.jsx("input",{autoFocus:!0,value:l,onChange:w=>c(w.target.value),placeholder:i("chatModel.search",{defaultValue:"Search models"}),className:"w-full px-2.5 py-1.5 text-xs rounded-lg bg-surface-base border border-border-default/50 outline-none focus:border-brand-500/50"}),h.jsxs("label",{className:"flex items-center justify-between gap-2 px-0.5 text-xs text-fg-secondary cursor-pointer select-none",children:[h.jsx("span",{children:i("chatModel.applyGlobal",{defaultValue:"Apply to global"})}),h.jsx("button",{type:"button",role:"switch","aria-checked":a,onClick:()=>o(w=>!w),className:`relative w-9 h-5 rounded-full transition-colors ${a?"bg-brand-600":"bg-fg-tertiary/30"}`,children:h.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${a?"translate-x-4":""}`})})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[d&&h.jsx("div",{className:"px-3 py-4 text-xs text-fg-tertiary",children:i("common:loading",{defaultValue:"Loading…"})}),!d&&p.length===0&&h.jsx("div",{className:"px-3 py-4 text-xs text-fg-tertiary",children:i("chatModel.empty",{defaultValue:"No enabled providers / models"})}),!d&&p.map(w=>h.jsxs("div",{className:"mb-1",children:[h.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-fg-tertiary",children:w.displayName}),w.models.slice(0,80).map(S=>{const Q=y?.provider===w.provider&&y?.model===S.id;return h.jsxs("button",{type:"button",onClick:()=>{e({provider:w.provider,model:S.id},a),a&&v({provider:w.provider,model:S.id}),n(!1)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 hover:bg-surface-base transition-colors ${Q?"text-fg-primary":"text-fg-secondary"}`,children:[h.jsx("span",{className:"truncate flex-1",children:S.id}),Q&&h.jsx("svg",{className:"w-3.5 h-3.5 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:h.jsx("path",{d:"M5 12l5 5L20 7",strokeLinecap:"round",strokeLinejoin:"round"})})]},`${w.provider}:${S.id}`)})]},w.provider))]})]})]})}async function gM(s,e,t){s&&!s.startsWith("new_")&&await J.sessions.setModelOverride(s,e),t&&await J.settings.updateRouting({defaultProvider:e.provider,routingDefaultModel:{provider:e.provider,model:e.model}})}const dx="markus_team_sidebars_c";function OM(s){const e=s.metadata??{};if(typeof e.sessionId=="string"&&e.sessionId)return e.sessionId;if(s.actionType==="open_chat"&&s.actionTarget)try{const t=typeof s.actionTarget=="string"?JSON.parse(s.actionTarget):s.actionTarget;if(t&&typeof t=="object"&&typeof t.sessionId=="string")return t.sessionId}catch{}}const xM=["chat","overview","files","tools","memory","deliverables"],vM=["chat","overview","announcements","norms","settings"];function bM(s,e){if(s==="chat")return e("page.chatTitle");if(Rp.find(r=>r.key===s))return e(`agent:tabs.${s}`);const i=Ap.find(r=>r.key===s);return i?e(i.labelKey):s}function yM(s){if(s==="chat")return"💬";const e=Rp.find(i=>i.key===s);if(e)return e.icon;const t=Ap.find(i=>i.key===s);return t?t.icon:""}function cr(s){return s!=="chat"}const yf=new Set;function SM(){return window.location.hash}function _M(s){return yf.add(s),()=>{yf.delete(s)}}typeof window<"u"&&window.addEventListener("hashchange",()=>yf.forEach(s=>s()));function NM({initialAgentId:s,authUser:e,previewMode:t,previewData:i}={}){const{t:r,i18n:n}=Pt(["team","common"]),a=C.useMemo(()=>({today:r("page.dateToday"),yesterday:r("page.dateYesterday")}),[r]),o=_f(Ht.TEAM),[l,c]=C.useState(i?.agents??[]),[d,u]=C.useState(i?.humans??[]),[f,g]=C.useState(!i),b=Sf(),v=C.useSyncExternalStore(_M,SM),m=b&&(v.startsWith(`#${Ht.TEAM}/`)||v.startsWith("#chat/")),O=b&&v.match(/^#team\/t\/(.+)$/),p=b?O?"team":m?"chat":"roster":"roster",x=O?O[1]:null,y=C.useRef(Ht.TEAM),_=C.useCallback(()=>{y.current=window.location.hash.slice(1)||Ht.TEAM,window.location.hash=`${Ht.TEAM}/d`},[]),k=C.useCallback(P=>{window.location.hash=`${Ht.TEAM}/t/${P}`},[]);C.useEffect(()=>{if(!b)return;const P=()=>{cr(Q.current)&&S("chat")};return window.addEventListener("popstate",P),()=>window.removeEventListener("popstate",P)},[b]);const[w,S]=C.useState("chat"),Q=C.useRef("chat");Q.current=w;const I=_m({side:"left",defaultWidth:280,minWidth:220,maxWidth:400,storageKey:"markus_chat_sidebar"}),[D,$]=C.useState(()=>{try{return localStorage.getItem(dx)==="1"}catch{return!1}}),j=C.useCallback(P=>{$(P);try{localStorage.setItem(dx,P?"1":"0")}catch{}},[]),B=wf(),F=B?.leftCollapsed??!1,V=B?.rightPanel??null,Z=B?.rightPanelTabs??[],se=B?.activeRightPanelTabId??null,T=B?.rightPanelFullscreen??!1,A=V?"2xl:pr-8":"2xl:pr-[280px]",N=B?.setHostAvailable,z=B?.collapseRightPanelOnly??B?.toggleRightPanel,U=B?.openRightPanel,ne=400,Se=320,Pe=6,[X,M]=C.useState(typeof window<"u"?window.innerWidth:1440),[K,ie]=C.useState("auto"),oe=C.useRef(F);C.useEffect(()=>{oe.current!==F&&(oe.current=F,$(F))},[F]);const G=B?.keyboardPane??"content",$e=C.useRef(!1),Ie=C.useRef(G);C.useEffect(()=>{if(t||b||!o)return;const P=Ie.current;Ie.current=G,(G==="l1"||G==="l2")&&P!==G&&D&&($(!1),B?.setLeftCollapsed(!1))},[G,t,b,o,D,B]),C.useEffect(()=>{if(t||b||!o)return;const P=E=>{const R=B?.keyboardPane??"content";if(R==="l0"||R==="l1"||R==="l2"||E.metaKey||E.ctrlKey||E.altKey)return;if(E.target instanceof HTMLElement){const H=E.target.tagName;if(H==="INPUT"||H==="TEXTAREA"||H==="SELECT"||E.target.isContentEditable||E.target.closest(".xterm"))return}const q=E.key.length===1?E.key.toLowerCase():E.key;q!=="h"&&q!=="ArrowLeft"||(E.preventDefault(),D&&(j(!1),B?.setLeftCollapsed(!1)),B?.setKeyboardPane($e.current?"l2":"l1"))};return document.addEventListener("keydown",P,!0),()=>document.removeEventListener("keydown",P,!0)},[t,b,o,B,D,j]),C.useEffect(()=>{if(N)return N(o&&!b),()=>N(!1)},[o,b,N]),C.useEffect(()=>t||b||!o?void 0:gt.on("ui:right_panel",E=>{const R=E.payload;if(R.action==="collapse"){z?.();return}if(R.action!=="open"||!R.panel||!U)return;const q=R.panel;if(q.kind==="url"&&q.url){const H=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;U({kind:"url",url:q.url,title:q.title||q.url,browserId:H});return}if(q.kind==="file"&&q.path){U({kind:"file",path:q.path,title:q.title});return}if(q.kind==="terminal"){const H=q.terminalId||`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;U({kind:"terminal",terminalId:H,title:q.title||"Terminal",cwd:q.cwd});return}q.kind==="deliverable"&&q.deliverableId&&J.deliverables.get(q.deliverableId).then(H=>{H.deliverable&&U({kind:"deliverable",deliverable:H.deliverable})}).catch(()=>{})}),[t,b,o,z,U]);const We=C.useCallback(P=>{const E=`ctx_${Date.now()}_${Math.random().toString(36).slice(2,7)}`;Ai(R=>[...R,{id:E,...P}]),requestAnimationFrame(()=>sr.current?.focus())},[]),[Y,ee]=C.useState(()=>{if(t)return!0;try{return localStorage.getItem("markus_team_panel_visible")==="true"}catch{return!1}}),le=_m({side:"left",defaultWidth:260,minWidth:200,maxWidth:400,storageKey:"markus_team_detail_panel"}),ke=C.useRef(null),[Ce,dt]=C.useState(!1),[ht,yt]=C.useState(!1),ss=C.useCallback(()=>{Ce?yt(P=>!P):ee(P=>{const E=!P;try{localStorage.setItem("markus_team_panel_visible",String(E))}catch{}return E})},[Ce]);C.useEffect(()=>{if(b)return;const P=ke.current;if(!P)return;const E=new ResizeObserver(([R])=>{if(!R)return;const q=R.contentRect.width;if(M(q),!t){const H=q-I.width-le.width;dt(H<400)}});return E.observe(P),()=>E.disconnect()},[b,t,I.width,le.width]);const Lt=Y&&!Ce&&!ht,zs=D?0:I.width+Pe+(Lt?le.width+Pe:0),vs=Math.max(0,X-zs-Pe-8),bs=Math.min(ne,Math.floor(vs*.4)),si=Math.max(0,vs-bs),Zs=Math.min(Math.round(vs/2),si),xt=Math.max(0,Math.min(K==="auto"?Zs:K,si)),$i=C.useRef(!1);C.useEffect(()=>{const P=(B?.rightPanel??null)!==null;P&&!$i.current&&($(!0),ie("auto")),$i.current=P},[B?.rightPanel]);const ji=C.useRef(xt);ji.current=xt;const Ga=C.useRef(si);Ga.current=si;const gh=C.useCallback(P=>{P.preventDefault();const E=P.clientX,R=ji.current,q=fe=>{const me=R+(E-fe.clientX),be=Ga.current,te=Math.min(Se,be);ie(Math.max(te,Math.min(be,me)))},H=()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",H),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",q),document.addEventListener("mouseup",H),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);C.useEffect(()=>{if(!ht)return;const P=E=>{E.target.closest("[data-l2-floating]")||yt(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[ht]);const[Hr,Ji]=C.useState(null),[Ka,Po]=C.useState(),[To,Gr]=C.useState(),[ii,xi]=C.useState(!1),[Ja,Qo]=C.useState(""),[An,$o]=C.useState(!1),[Ei,Kr]=C.useState(""),Mn=C.useRef(null),ri=C.useRef(null),Tr=C.useCallback((P,E)=>{Po(P),Gr(E),b?(S("profile"),history.pushState({mobileProfile:!0},"",window.location.hash)):S(P??"overview")},[b]),Jr=[{id:"chat"},{id:"profile"}],jo=C.useCallback(P=>{P==="profile"?Tr():cr(Q.current)?history.back():S("chat")},[Tr]),ni=mx(Jr,w,jo),Ts=C.useCallback((P,E)=>{ut("direct"),is(P),b&&_(),Tr(E?.tab,E?.highlightMailboxId),Ji(null)},[b,_,Tr]),vi=C.useCallback((P,E)=>{const R=l.find(q=>q.name.toLowerCase()===P.toLowerCase());if(R){const q=E.target.getBoundingClientRect();Ji({agentId:R.id,top:q.bottom,left:q.left})}},[l]),Eo=C.useMemo(()=>l.map(P=>P.name),[l]),[ce,ut]=C.useState(()=>i?.chatMode??(s?"direct":localStorage.getItem("markus_chat_mode")??"direct")),[ge,is]=C.useState(()=>s??localStorage.getItem("markus_chat_agent")??""),[lt,As]=C.useState(()=>i?.activeChannel??localStorage.getItem("markus_chat_channel")??"#general"),[Nt,en]=C.useState(""),Ms=500,tn=C.useRef(new Set),Ln=P=>{if(tn.current.add(P),tn.current.size>Ms){const E=Math.floor(Ms*.2),R=tn.current.values();for(let q=0;q<E;q++){const H=R.next().value;H&&tn.current.delete(H)}}},Oh=C.useMemo(()=>{if(i?.channelMessages){const P=i.activeChannel??"custom:general";return i.channelMessages.filter(E=>E.channel===P).map(E=>xn(E))}},[]),{manager:el,messages:At,setMessages:Qs,sending:Vs,setSending:rs,activities:xh,setActivities:bi,msgBuffers:hs,sessionMsgCache:sn,activeSessionBuffer:ds,actBuffers:oi,sessionTabsBuffer:tl,currentConvKeyRef:Ve,updateConvMsgs:rt,updateConvMsgsRaf:er,appendConvActivity:rn,beginLoad:sl,beginStream:nn,endStream:ai,resetConv:Ri,loadAndDisplay:W,incrementSending:he,decrementSending:ue,resetSending:Re,isSendingFor:Fe,setStreamSession:tt,clearStreamSession:vt,getStreamSession:mt,saveSessionToCache:Ye,restoreSessionFromCache:Yt}=pM(Oh),[Dt,Ut]=C.useState(""),[Ls,Zt]=C.useState(null),[us,Ai]=C.useState([]),[Nn,Rt]=C.useState([]),ns=C.useRef(null),[vh,il]=C.useState(!!i?.streamLastMessage),on=C.useRef(null),H1=400;C.useEffect(()=>(Vs?(on.current&&(clearTimeout(on.current),on.current=null),il(!0)):vh&&(on.current=setTimeout(()=>{il(!1),on.current=null},H1)),()=>{on.current&&clearTimeout(on.current)}),[Vs]);const Mp=Vs||vh||(()=>{for(let P=At.length-1;P>=Math.max(0,At.length-8);P--){const E=At[P];if(E.isStreaming&&!E.isStopped)return!0}return!1})(),bh=C.useRef({fullText:"",timers:[]});C.useEffect(()=>{if(!t||!i?.streamLastMessage||At.length===0)return;const P=At[At.length-1];if(!P||P.sender!=="agent")return;const E=P.text;bh.current.fullText=E;const R=bh.current.timers;function q(){let fe=0;Qs(be=>be.map((te,de)=>de===be.length-1?{...te,text:""}:te)),il(!0);const me=setInterval(()=>{if(fe+=1+Math.floor(Math.random()*2),fe>=E.length){clearInterval(me),Qs(de=>de.map((st,Ue)=>Ue===de.length-1?{...st,text:E}:st));const be=setTimeout(()=>il(!1),800);R.push(be);const te=setTimeout(q,6e3);R.push(te)}else Qs(be=>be.map((te,de)=>de===be.length-1?{...te,text:E.slice(0,fe)}:te))},30);R.push(me)}const H=setTimeout(q,1500);return R.push(H),()=>{R.forEach(fe=>clearTimeout(fe)),bh.current.timers=[]}},[]);const Qr=C.useRef(0),[Lp,Mi]=C.useState(!1),[yh,Np]=C.useState(!1),[Dp,tr]=C.useState(!1),[Fs,Sh]=C.useState([]),[Ip,Bp]=C.useState(null),_h=C.useRef(null),sr=C.useRef(null),[rl,nl]=C.useState(null),$r=C.useRef(null),wh=C.useRef(!1),Ro=C.useCallback(()=>{const P=sr.current;if(!P)return;const E=wh.current,R=E?36:52,q=E?160:120;P.style.height="auto";const H=Math.max(R,Math.min(P.scrollHeight,q));P.style.height=`${H}px`,P.style.overflowY=H>=q?"auto":"hidden"},[]);C.useEffect(()=>{const P=requestAnimationFrame(()=>Ro());return()=>cancelAnimationFrame(P)},[Dt,Fs.length,Ro]);const kh=P=>{try{const E=localStorage.getItem(`markus_closed_tabs_${P}`);return E?new Set(JSON.parse(E)):new Set}catch{return new Set}},G1=(P,E)=>{const R=kh(P);R.add(E);try{localStorage.setItem(`markus_closed_tabs_${P}`,JSON.stringify([...R]))}catch{}},K1=(P,E)=>{const R=kh(P);if(R.delete(E))try{localStorage.setItem(`markus_closed_tabs_${P}`,JSON.stringify([...R]))}catch{}},J1=P=>{try{return localStorage.getItem(`markus_active_session_${P}`)}catch{return null}},ol=(P,E)=>{if(P)try{E&&E!==St?localStorage.setItem(`markus_active_session_${P}`,E):localStorage.removeItem(`markus_active_session_${P}`)}catch{}},[Ch,an]=C.useState([]),[it,Li]=C.useState(null),[ln,cn]=C.useState(!1),[Wp,Ph]=C.useState([]),[Ao,Th]=C.useState(null),[eS,Xp]=C.useState(null),[al,Qh]=C.useState([]),[Dn,$h]=C.useState(null),[tS,qp]=C.useState(null),[zp,jh]=C.useState([]),[Mo,sS]=C.useState([]),Ns=P=>{sS(E=>{const R=typeof P=="function"?P(E):P,q=new Set;return R.filter(H=>q.has(H.id)?!1:(q.add(H.id),!0))})},ll=C.useRef(null),Eh=C.useRef(null),yi=C.useRef(null),[ys,Lo]=C.useState(i?.groupChats??[]),Rh=C.useRef(ys);Rh.current=ys;const Zp=C.useRef(null),[No,fs]=C.useState(!1),[hn,Do]=C.useState(!1),[Vp,In]=C.useState(""),[Ah,jr]=C.useState([]),[Fp,Yp]=C.useState(!1),Mh=C.useRef(void 0),[Si,Up]=C.useState(i?.teams??[]),[iS,rS]=C.useState([]),[cl,Hp]=C.useState([]),[nS,oS]=C.useState(null),[wM,kM]=C.useState(!1),[CM,PM]=C.useState(""),[Gp,Io]=C.useState(!1),[Kp,aS]=C.useState(""),[Bo,Bn]=C.useState(0),[lS,cS]=C.useState([]),Jp=C.useRef(!1),hS=C.useCallback(()=>{Jp.current||(Jp.current=!0,(async()=>{const P=[];try{const[E,R,q,H,fe]=await Promise.all([J.projects.list().catch(()=>({projects:[]})),J.requirements.list().catch(()=>({requirements:[]})),J.tasks.list({pageSize:100}).catch(()=>({tasks:[]})),J.deliverables.search({limit:100}).catch(()=>({results:[]})),J.teams.list().catch(()=>({teams:[],ungrouped:[]}))]);for(const me of E.projects)P.push({id:me.id,name:me.name,entityType:"project",role:me.status});for(const me of R.requirements)P.push({id:me.id,name:me.title,entityType:"requirement",role:me.priority});for(const me of q.tasks)P.push({id:me.id,name:me.title,entityType:"task",role:me.status});for(const me of H.results)P.push({id:me.id,name:me.title,entityType:"deliverable",role:me.type});for(const me of fe.teams)try{const be=await J.workflows.list(me.id);for(const te of be.workflows)P.push({id:te.name,name:te.displayName||te.name,entityType:"workflow",role:`v${te.version}`})}catch{}}catch{}cS(P)})())},[]),Vt=ce==="channel"?ys.find(P=>P.channelKey===lt)?.teamId:void 0,dS=C.useRef(null),Wn=C.useRef(null),Ss=C.useRef(null),em=C.useRef(void 0),hl=C.useRef(!1),ir=C.useRef(!0),tm=C.useRef(void 0);C.useEffect(()=>{if(!ln)return;const P=E=>{Eh.current&&!Eh.current.contains(E.target)&&ll.current&&!ll.current.contains(E.target)&&cn(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[ln]);const dl=(P,E)=>{if(!E||P===E)return`notes:${P}`;const[R,q]=[P,E].sort();return`dm:${R}:${q}`};C.useEffect(()=>{localStorage.setItem("markus_chat_mode",ce)},[ce]),C.useEffect(()=>{localStorage.setItem("markus_chat_agent",ge)},[ge]),C.useEffect(()=>{localStorage.setItem("markus_chat_channel",lt)},[lt]);const{counts:Lh,sessionAgentMap:Wo,markRead:Xo,setActiveKey:uS,clearActiveKey:fS}=a_({enabled:!t}),ul=C.useMemo(()=>{const P={};for(const[E,R]of Object.entries(Lh))E.startsWith("channel:")&&(P[E.slice(8)]=R);return P},[Lh]),Nh=l_(Wo,Lh);C.useEffect(()=>{let P=0;for(const E of Nh.values())P+=E;for(const E of Object.values(ul))P+=E;window.dispatchEvent(new CustomEvent("markus:team-unread-changed",{detail:{count:P}}))},[Nh,ul]);const fl=Nh,pS=C.useCallback(async P=>{for(const[E,R]of Object.entries(Wo))R===P&&Xo(`session:${E}`)},[Wo,Xo]);C.useEffect(()=>{if(t||!((!b||p==="chat")&&w==="chat"))return;if(ce==="direct"&&ge&&pS(ge),ce==="channel"&<)Xo(`channel:${lt}`);else if(ce==="direct"&&it)Xo(`session:${it}`);else if(ce==="dm"&&Nt){const R=`dm:${[e?.id,Nt].sort().join(":")}`;Xo(`channel:${R}`)}const E=[];if(ce==="direct"&&it){E.push(`session:${it}`);for(const[R,q]of Object.entries(Wo))q===ge&&E.push(`session:${R}`)}else ce==="channel"&<?E.push(`channel:${lt}`):ce==="dm"&&Nt&&e?.id&&E.push(`channel:dm:${[e.id,Nt].sort().join(":")}`);for(const R of E)uS(R);return()=>{for(const R of E)fS(R)}},[t,ce,lt,it,Nt,ge,p,w,Wo]);const li=C.useCallback(()=>J.agents.list().then(P=>c(P.agents)).catch(()=>{}),[]),Ys=C.useCallback(()=>J.teams.list().then(P=>Up(P.teams)).catch(()=>{}),[]),Xn=C.useCallback(()=>J.groupChats.list().then(P=>Lo(P.chats)).catch(()=>{}),[]),mS=C.useMemo(()=>ed(li,3e3),[li]),pl=C.useMemo(()=>ed(Ys,5e3),[Ys]),Dh=C.useMemo(()=>ed(Xn,3e3),[Xn]),qo=C.useCallback(()=>{J.users.list(e?.orgId).then(P=>u(P.users)).catch(()=>{})},[e?.orgId]);C.useEffect(()=>{t||(Promise.all([li(),Ys()]).finally(()=>g(!1)),qo(),J.tasks.list().then(P=>Hp(P.tasks)).catch(()=>{}),J.externalAgents.list().then(P=>rS(P.agents)).catch(()=>{}),Xn())},[t,qo]),C.useEffect(()=>{if(!(!t||!i)&&(c(i.agents??[]),u(i.humans??[]),Up(i.teams??[]),Lo(i.groupChats??[]),i.channelMessages)){const P=i.activeChannel??"custom:general";Qs(i.channelMessages.filter(E=>E.channel===P).map(E=>xn(E)))}},[t,i]),C.useEffect(()=>{if(t||!o)return;li(),Ys();const P=setInterval(li,3e4),E=setInterval(Ys,6e4),R=gt.on("agent:update",()=>{mS(),pl()}),q=gt.on("team:update",()=>{pl(),Dh()}),H=gt.on("agent:removed",pl),fe=gt.on("chat:group_created",()=>{Xn(),Ys(),li()}),me=gt.on("chat:group_updated",Dh),be=gt.on("chat:group_deleted",()=>{Dh(),pl()}),te=gt.on("task:update",st=>{const Ue=st?.payload;Ue?.taskId&&Hp(Xe=>Xe.map(Qe=>Qe.id===Ue.taskId?{...Qe,status:Ue.status??Qe.status}:Qe))}),de=()=>{li(),Ys(),qo()};return window.addEventListener("markus:data-changed",de),()=>{clearInterval(P),clearInterval(E),R(),q(),H(),fe(),me(),be(),te(),window.removeEventListener("markus:data-changed",de)}},[t,o,qo]),C.useEffect(()=>{if(t)return;const P=be=>{const te=be.detail;if(S_(te.page)===Ht.TEAM){if(te.params?.agentId){if(te.params.profileTab)Ts(te.params.agentId,{tab:te.params.profileTab});else if(ut("direct"),is(te.params.agentId),S("chat"),b&&_(),te.params.sessionId){const de=te.params.sessionId;setTimeout(async()=>{try{const{sessions:st}=await J.sessions.listByAgent(te.params.agentId,20),Ue=st.find(Xe=>Xe.id===de);Ue&&bl(Ue)}catch{}},300)}}if(te.params?.selectAgent&&(ut("direct"),is(te.params.selectAgent),S("chat"),b&&_()),te.params?.prefillMessage){const de=te.params.prefillMessage;localStorage.removeItem("markus_nav_prefillMessage"),localStorage.removeItem("markus_nav_autoSend"),S("chat"),te.params?.autoSend==="true"?setTimeout(()=>em.current?.(de),300):(Ut(de),setTimeout(()=>{const st=sr.current;st&&(st.focus(),st.setSelectionRange(st.value.length,st.value.length))},100))}if(te.params?.dm&&(ut("dm"),en(te.params.dm),S("chat"),b&&_()),te.params?.channel&&(ut("channel"),As(te.params.channel),S("chat"),b&&_()),te.params?.selectTeam){const de=te.params.selectTeam;if(b)k(de);else{const st=Rh.current.find(Ue=>Ue.type==="team"&&Ue.teamId===de);ut("channel"),As(st?.channelKey??`group:${de}`),S("chat"),fs(!1),ee(!0)}}te.params?.openHire}},E=localStorage.getItem("markus_nav_agentId");if(E){localStorage.removeItem("markus_nav_agentId");const be=localStorage.getItem("markus_nav_profileTab");localStorage.removeItem("markus_nav_profileTab"),ut("direct"),is(E),be?Ts(E,{tab:be}):(S("chat"),b&&_())}const R=localStorage.getItem("markus_nav_dm");R&&(localStorage.removeItem("markus_nav_dm"),ut("dm"),en(R),S("chat"),b&&_());const q=localStorage.getItem("markus_nav_channel");q&&(localStorage.removeItem("markus_nav_channel"),ut("channel"),As(q),S("chat"),b&&_());const H=localStorage.getItem("markus_nav_prefillMessage");H&&(localStorage.removeItem("markus_nav_prefillMessage"),localStorage.removeItem("markus_nav_autoSend"),S("chat"),Ut(H),setTimeout(()=>{const be=sr.current;be&&(be.focus(),be.setSelectionRange(be.value.length,be.value.length))},150));const fe=localStorage.getItem("markus_nav_selectAgent");fe&&(localStorage.removeItem("markus_nav_selectAgent"),ut("direct"),is(fe),S("chat"),b&&_());const me=localStorage.getItem("markus_nav_selectTeam");if(me)if(localStorage.removeItem("markus_nav_selectTeam"),b)k(me);else{const be=Rh.current.find(te=>te.type==="team"&&te.teamId===me);ut("channel"),As(be?.channelKey??`group:${me}`),S("chat"),fs(!1),ee(!0)}return window.addEventListener("markus:navigate",P),()=>window.removeEventListener("markus:navigate",P)},[t]),C.useEffect(()=>{const P=Zp.current;if(!P)return;const E=ys.find(R=>R.type==="team"&&R.teamId===P);Zp.current=null,ut("channel"),As(E?.channelKey??`group:${P}`),S("chat"),fs(!1),ee(!0)},[ys,Si]),C.useEffect(()=>{if(t&&i?.chatMode==="channel"||l.length===0||ge&&l.some(E=>E.id===ge))return;const P=l.find(E=>!E.teamId&&E.role?.toLowerCase()==="secretary")??l.find(E=>E.role?.toLowerCase()==="secretary")??l.find(E=>E.name?.toLowerCase().includes("secretary"));P?(ut("direct"),is(P.id),S("chat")):l.length>0&&(ut("direct"),is(l[0].id),S("chat"))},[l,ge]);const qn=C.useRef(!1),Ni=C.useRef(!1),ml=C.useRef(!1),gl=C.useRef(0),zn=C.useRef(0),[gS,rr]=C.useState(!1),Er=C.useRef(0),[sm,dn]=C.useState(0),nr=C.useCallback(()=>{Ni.current=!1,ml.current=!1,ir.current=!0},[]),Ih=C.useCallback(()=>{Ni.current=!0,ir.current=!1,zn.current+=1,qn.current=!1,rr(!0)},[]),un=C.useCallback(P=>{const E=Wn.current;if(!E)return;const R=E.scrollHeight-E.scrollTop-E.clientHeight,q=R<160,H=R<48,fe=gl.current,me=E.scrollTop<fe-2;if(gl.current=E.scrollTop,me&&R>20){ml.current=!0,Ih();return}if(ml.current){H?(nr(),rr(!1),Er.current=0,dn(0)):Ih();return}if(q&&!Ni.current){nr(),rr(!1),Er.current=0,dn(0);return}P?.fromProgrammatic||qn.current||!Ni.current&&ir.current||Ni.current&&(ir.current=!1,rr(!0))},[Ih,nr]);C.useEffect(()=>{const P=Wn.current;if(!P)return;const E=()=>{ml.current=!0},R=()=>{un({fromProgrammatic:qn.current})};P.addEventListener("wheel",E,{passive:!0}),P.addEventListener("touchmove",E,{passive:!0}),P.addEventListener("scroll",R,{passive:!0});const q=typeof ResizeObserver<"u"?new ResizeObserver(()=>un()):null;return q?.observe(P),gl.current=P.scrollTop,un(),()=>{P.removeEventListener("wheel",E),P.removeEventListener("touchmove",E),P.removeEventListener("scroll",R),q?.disconnect()}},[p,un]);const Bh=C.useMemo(()=>new Set(zp),[zp]),os=C.useMemo(()=>{const P=ce==="channel"?At:At.filter(E=>!E.isActivityLog);return Bh.size===0?P:P.filter(E=>!(E.isNotification&&Bh.has(E.id)))},[At,ce,Bh]);C.useEffect(()=>{wh.current=w==="chat"&&os.length>0,Ro()},[w,os.length,Ro]);const or=N_({count:os.length,getScrollElement:()=>Wn.current,getItemKey:P=>os[P]?.id??P,estimateSize:P=>{const E=os[P];return E?E.segments&&E.segments.length>0?300:E.text.length>500?200:120:120},overscan:8});or.shouldAdjustScrollPositionOnItemSizeChange=(P,E,R)=>wm()?!1:P.start<(R.scrollOffset??0);const Zn=C.useCallback((P="instant")=>{if(!ir.current||Ni.current)return;const E=++zn.current;qn.current=!0;const R=()=>E===zn.current&&ir.current&&!Ni.current,q=()=>{if(E!==zn.current)return;if(qn.current=!1,!R()){un();return}const H=Wn.current;H&&(gl.current=H.scrollTop,H.scrollHeight-H.scrollTop-H.clientHeight<160&&!Ni.current&&(nr(),rr(!1),Er.current=0,dn(0))),requestAnimationFrame(()=>{E===zn.current&&un({fromProgrammatic:!0})})};if(os.length>0)or.scrollToIndex(os.length-1,{align:"end",behavior:P}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!R()){E===zn.current&&(qn.current=!1);return}or.scrollToIndex(os.length-1,{align:"end",behavior:"instant"}),requestAnimationFrame(q)})});else{const H=Wn.current;H&&H.scrollTo({top:H.scrollHeight,behavior:P}),requestAnimationFrame(q)}},[os.length,or,un,nr]),im=C.useRef(o);C.useEffect(()=>{im.current=o},[o]),C.useLayoutEffect(()=>{if(hl.current){hl.current=!1;const P=xl.current;P>0&&(xl.current=0,or.scrollToIndex(P,{align:"start",behavior:"instant"}));return}im.current&&(!ir.current||Ni.current||wm()||Zn())},[At,Zn,or]);const rm=C.useRef(w);C.useEffect(()=>{const P=rm.current!=="chat";if(rm.current=w,w==="chat"&&P&&ir.current&&!Ni.current){const E=[],R=requestAnimationFrame(()=>Zn("instant"));for(const q of[60,160,320])E.push(setTimeout(()=>Zn("instant"),q));return()=>{cancelAnimationFrame(R);for(const q of E)clearTimeout(q)}}},[w,Vs,Zn]);const nm=C.useCallback(async(P,E)=>{const R=E??`ch:${P}`;Ve.current===R&&tr(!0);try{const q=await J.channels.getMessages(P,50),H=q.messages.map(fe=>xn(fe,e?.id));hs.set(R,H),Ve.current===R&&(Qs(H),Mi(q.hasMore),yi.current=q.messages[0]?new Date(q.messages[0].createdAt).toISOString():null)}catch{Ve.current===R&&(Qs([]),Mi(!1))}finally{Ve.current===R&&tr(!1)}},[]),Wh=C.useCallback(async(P,E)=>{const R=Ve.current===E&&(hs.get(E)?.length??0)===0;R&&tr(!0);try{const{count:q,hasMore:H,oldestCursor:fe}=await W(P,E,async()=>{const me=await J.sessions.getMessages(P,50);return{messages:c_(me.messages.map(td).filter(te=>te.sender!=="agent"||te.text||te.segments&&te.segments.length>0||te.isStreaming)),hasMore:me.hasMore,oldestCursor:me.messages[0]?new Date(me.messages[0].createdAt).toISOString():null}});return Mi(H),yi.current=fe,q}finally{R&&Ve.current===E&&tr(!1)}},[W,hs]),om=C.useRef(new Map),fn=C.useCallback(async(P,E,R)=>{if(!P||!E||E===St)return;let q=null;try{if(Ss.current&&!Ss.current.signal.aborted&&mt(R)?.has(E)){nn(R),Ve.current===R&&rs(!0);return}const H=`${P}:${E}`,fe=om.current.get(H)??0;if(Date.now()-fe<1500)return;const me=await J.sessions.streamStatus(P,E),te=[...hs.get(R)??[]].reverse().find(Oe=>Oe.sender==="agent"),de=me.status==="streaming",st=!!me.active&&(me.status==="done"||me.status==="error")&&!!te?.isStreaming;if(!de&&!st)return;om.current.set(H,Date.now()),$r.current?.abort(),q=new AbortController,$r.current=q,nn(R),rs(!0),tt(R,E);let Ue=te?.id;if(!te||te.isError)Ue=`reattach_${Date.now()}`,rt(R,Oe=>[...Oe,{id:Ue,sender:"agent",text:"",time:new Date().toLocaleTimeString(),isStreaming:!0,segments:[]}],E);else{const Oe=(te.segments??[]).filter(Be=>Be.type==="tool").map(Be=>Be.status==="stopped"||Be.status==="running"?{...Be,status:"running"}:Be);rt(R,Be=>Be.map(we=>we.id===te.id?{...we,text:"",isStreaming:!0,isStopped:!1,segments:Oe,committedSegments:void 0}:we),E)}let Xe=!1;const Qe=Oe=>{Ve.current===R&&(Qr.current=Date.now(),er(R,Be=>{const we=[...Be],Le=Ue?we.findIndex(pe=>pe.id===Ue):-1,Me=Le>=0?Le:we.map((pe,xe)=>({m:pe,j:xe})).reverse().find(pe=>pe.m.sender==="agent")?.j??-1;if(Me<0)return Be;const De=we[Me].segments??[],et=De[De.length-1],Ct=et?.type==="text"?et.thinking??"":"";let Xt="",$s="",ae=Oe;for(;ae.length>0;)if(Xe){const pe=ae.indexOf("</think>");pe>=0?(Xt+=ae.slice(0,pe),ae=ae.slice(pe+8),Xe=!1):(Xt+=ae,ae="")}else{const pe=ae.indexOf("<think>");pe>=0?($s+=ae.slice(0,pe),ae=ae.slice(pe+7),Xe=!0):($s+=ae,ae="")}const Ze=Ct+Xt||void 0,ye=et?.type==="text"?[...De.slice(0,-1),{type:"text",content:et.content+$s,thinking:Ze,createdAt:et.createdAt}]:[...De,{type:"text",content:$s,thinking:Ze,createdAt:new Date().toISOString()}];return we[Me]={...we[Me],text:(we[Me].text??"")+$s,segments:ye,isStreaming:!0},we},E))},ct=Oe=>{if(Ve.current===R&&(Qr.current=Date.now(),Oe.phase!=="heartbeat")){if((Oe.phase==="start"||Oe.phase==="end")&&rn(R,{...Oe,phase:Oe.phase,ts:Date.now()},E),Oe.phase==="start"){const Be=`${Oe.tool}_${Date.now()}`,we=new Date().toISOString(),Le=Me=>{const De=[...Me];for(let et=De.length-1;et>=0;et--){const Ct=De[et];if(Ct.type==="tool"&&Ct.tool===Oe.tool&&(Ct.status==="running"||Ct.status==="stopped"))return De[et]={...Ct,status:"running",args:Oe.arguments??Ct.args},De}return De.push({type:"tool",key:Be,tool:Oe.tool,status:"running",args:Oe.arguments,createdAt:we}),De};rt(R,Me=>{const De=[...Me],et=Ue?De.findIndex(ae=>ae.id===Ue):-1;if(et<0)return Me;const Ct=Le(De[et].segments??[]),Xt=De[et].committedSegments,$s=Xt&&Le(Xt);return De[et]={...De[et],segments:Ct,committedSegments:$s,isStreaming:!0},De},E)}else if(Oe.phase==="end"){const Be=new Date().toISOString(),we=Le=>{const Me=[...Le];for(let De=Me.length-1;De>=0;De--){const et=Me[De];if(et.type==="tool"&&et.tool===Oe.tool&&(et.status==="running"||et.status==="stopped")){Me[De]={...et,status:Oe.success===!1?"error":"done",args:Oe.arguments??et.args,result:Oe.result,error:Oe.error,durationMs:Oe.durationMs,liveOutput:void 0,createdAt:Be};break}}return Me};rt(R,Le=>{const Me=[...Le],De=Ue?Me.findIndex($s=>$s.id===Ue):-1;if(De<0)return Le;const et=we(Me[De].segments??[]),Ct=Me[De].committedSegments,Xt=Ct&&we(Ct);return Me[De]={...Me[De],segments:et,committedSegments:Xt,isStreaming:!0},Me},E)}else if(Oe.phase==="subagent_progress"&&Oe.subagentEvent){const Be=we=>{const Le=[...we];for(let Me=Le.length-1;Me>=0;Me--){const De=Le[Me];if(De.type==="tool"&&(De.tool==="spawn_subagent"||De.tool==="spawn_subagents")&&(De.status==="running"||De.status==="stopped")){Le[Me]={...De,status:"running",subagentLogs:km(De.subagentLogs,Oe.subagentEvent)};break}}return Le};er(R,we=>{const Le=[...we],Me=Ue?Le.findIndex(Xt=>Xt.id===Ue):-1;if(Me<0)return we;const De=Be(Le[Me].segments??[]),et=Le[Me].committedSegments,Ct=et&&Be(et);return Le[Me]={...Le[Me],segments:De,committedSegments:Ct,isStreaming:!0},Le},E)}}},Ne=Oe=>{Ve.current===R&&(Qr.current=Date.now(),rt(R,Be=>{const we=[...Be],Le=Ue?we.findIndex(De=>De.id===Ue):-1;if(Le<0)return Be;const Me=[...we[Le].committedSegments??[]];if(Oe.type==="thinking_commit")Me.push({type:"text",content:"",thinking:Oe.content,createdAt:Oe.createdAt});else if(Oe.type==="text_commit")Me.push({type:"text",content:Oe.content,createdAt:Oe.createdAt});else return Be;return we[Le]={...we[Le],committedSegments:Me,isStreaming:!0},we},E))},Ke=Oe=>{if(Ve.current!==R)return;Qr.current=Date.now();const Be=(Oe.segments??[]).map((we,Le)=>we.type==="tool"?{type:"tool",key:`${we.tool}_${Le}`,tool:we.tool??"tool",status:we.status==="error"?"error":we.status==="running"||we.status==="stopped"?"running":"done",args:we.arguments,result:we.result,error:we.error,durationMs:we.durationMs,createdAt:we.createdAt,...we.subagentLogs?.length?{subagentLogs:we.subagentLogs}:{}}:{type:"text",content:we.content??"",thinking:we.thinking,createdAt:we.createdAt});rt(R,we=>{const Le=[...we],Me=Ue?Le.findIndex(De=>De.id===Ue):-1;return Me<0?we:(Le[Me]={...Le[Me],text:Oe.content||Le[Me].text,segments:Be,committedSegments:Be,isStreaming:!0,isStopped:!1},Le)},E);for(const we of Be)we.type==="tool"&&rn(R,{tool:we.tool,phase:we.status==="running"||we.status==="stopped"?"start":"end",success:we.status!=="error",arguments:we.args,result:we.result,error:we.error,durationMs:we.durationMs,ts:Date.now()},E)},Je=await J.sessions.reattachStream(P,E,{onChunk:Qe,onActivity:ct,onCommit:Ne,onSnapshot:Ke},q.signal,0);if(!Je.attached){ai(R),Ve.current===R&&(rt(R,Oe=>{const Be=[...Oe],we=Ue?Be.findIndex(De=>De.id===Ue):-1,Le=we>=0?we:Be.map((De,et)=>({m:De,j:et})).reverse().find(De=>De.m.sender==="agent"&&De.m.isStreaming)?.j??-1;if(Le<0)return Oe;const Me=Be[Le];return Me.isStreaming?(Be[Le]={...Me,isStreaming:!1,isStopped:Me.isError?Me.isStopped:!0},Be):Oe},E),rs(!1));return}Ve.current===R&&(rt(R,Oe=>{const Be=[...Oe],we=Ue?Be.findIndex(et=>et.id===Ue):-1,Le=we>=0?we:Be.map((et,Ct)=>({m:et,j:Ct})).reverse().find(et=>et.m.sender==="agent")?.j??-1;if(Le<0)return Oe;const Me=Be[Le],De=Je.segments?.length?Cm(Je.segments,Me.segments):void 0;return Be[Le]={...Me,text:Je.content||Me.text,isStreaming:!1,isStopped:!1,...De?{segments:De,committedSegments:De}:{}},Be},E),rs(!1)),ai(R),$r.current===q&&($r.current=null)}catch(H){if($r.current===q&&($r.current=null),ai(R),Ve.current===R&&rs(!1),H instanceof Error&&H.name==="AbortError")return}},[rn,nn,ai,mt,hs,tt,rt,er]);C.useEffect(()=>{if(!o||t||ce!=="direct"||!ge)return;const P=it;!P||P===St||fn(ge,P,Ve.current)},[o,t,ce,ge,it,fn]);const Ol=C.useCallback(async P=>{if(!P)return an([]),[];try{const{sessions:E}=await J.sessions.listByAgent(P,10);return an(E),E}catch{return an([]),[]}},[]),xl=C.useRef(0),OS=C.useCallback(async()=>{if(!(yh||!Lp||!yi.current)){Np(!0);try{const P=Ve.current;if(ce==="channel"||ce==="dm"){const E=ce==="dm"?dl(e?.id??"",Nt):lt,R=await J.channels.getMessages(E,50,yi.current),q=R.messages.map(H=>xn(H,e?.id));xl.current=q.length,hl.current=!0,Qs(H=>{let fe=[...q,...H];return fe.length>500&&(fe=fe.slice(-500)),hs.set(P,fe),fe}),Mi(R.hasMore),R.messages[0]&&(yi.current=new Date(R.messages[0].createdAt).toISOString())}else if(it){const E=await J.sessions.getMessages(it,50,yi.current),R=E.messages.map(td);xl.current=R.length,hl.current=!0,Qs(q=>{let H=[...R,...q];return H.length>500&&(H=H.slice(-500)),hs.set(P,H),H}),Mi(E.hasMore),E.messages[0]&&(yi.current=new Date(E.messages[0].createdAt).toISOString())}}catch{}finally{Np(!1)}}},[yh,Lp,ce,lt,it,e?.id,Nt]);tm.current=OS;const Xh=C.useRef(!1),xS=C.useCallback(P=>{Xh.current||(Xh.current=!0,requestAnimationFrame(()=>{Xh.current=!1,P.target.scrollTop<100&&tm.current?.()}))},[]);C.useEffect(()=>{if(t)return;const P=Kl(ce,ge,lt,Nt),E=Ve.current;Ve.current=P,E&&E!==P&&(tl.set(E,Mo),it&&ds.set(E,it)),E!==P&&(nr(),rr(!1),Er.current=0,dn(0));const R=hs.get(P),q=tl.get(P),H=ds.get(P),fe=mt(P),me=H??it,be=Fe(P)&&(ce!=="direct"||!fe||!me||fe.has(me)),te=me??P,de=oi.get(te)??[];if(bi(be?de:[]),rs(be),ce==="direct"&&ge&&Ol(ge),q&&q.length>0&&Ns(q),cn(!1),R!==void 0&&R.length>0)if(be||el.completeLoad(P),tr(!1),Qs(R),Mi(!1),H!==void 0&&Li(H),(!q||q.length===0)&&Ns([]),ce==="channel"||ce==="dm"){const Ue=ce==="dm"?dl(e?.id??"",Nt):lt;nm(Ue,P)}else ce==="direct"&&ge&&H&&H!==St&&(be?fn(ge,H,P):Wh(H,P).then(()=>{Ve.current===P&&ge&&fn(ge,H,P)}));else if(sl(P),tr(!0),Qs([]),Mi(!1),yi.current=null,hs.delete(P),ce==="channel"||ce==="dm"){const Ue=ce==="dm"?dl(e?.id??"",Nt):lt;nm(Ue,P),(!q||q.length===0)&&Ns([])}else ce==="direct"&&ge?Ol(ge).then(Ue=>{if(Ve.current===P)if(Ue.length>0){const Xe=Ue.find(Le=>Le.isMain),Qe=kh(ge),ct=Xe?[Xe,...Ue.filter(Le=>!Le.isMain&&!Qe.has(Le.id)).slice(0,4)]:Ue.filter(Le=>!Qe.has(Le.id)).slice(0,5);let Ne=q&&q.length>0?q:ct;const Ke=J1(ge),Je=H!==void 0?H:Ke??Xe?.id??Ne[0].id;if(Je&&Je!==St&&!Ne.some(Le=>Le.id===Je)){const Le=Ue.find(Me=>Me.id===Je);Le&&(Ne=[...Ne,Le])}const Oe=Je&&Ne.some(Le=>Le.id===Je)?Je:Ne[0].id;Li(Oe),ds.set(P,Oe),ol(ge,Oe),Ns(Ne);const we=Ue.find(Le=>Le.id===Oe)?.metadata?.modelOverride;nl(we?.provider&&we?.model?{provider:we.provider,model:we.model}:null),Wh(Oe,P).then(()=>{Ve.current===P&&ge&&fn(ge,Oe,P)})}else Li(null),nl(null),tr(!1),(!q||q.length===0)&&Ns([])}).catch(()=>{Ve.current===P&&tr(!1)}):tr(!1)},[t,ce,ge,lt,Nt,n.language,r]),C.useEffect(()=>t?void 0:gt.on("chat:message",E=>{const R=E.payload,q=R.channel??"";if(!q)return;const H=R.senderType??"agent",fe=R.text??R.message??"",me=R.senderId??R.agentId??"",be=R.senderName??R.agentId??r("page.fallbackAgent"),te=R.metadata,de=R.messageId??R.id??"";if(de&&tn.current.has(de))return;const st=H==="human"&&me===(e?.id??""),Ue={id:de||`ws_${Date.now()}_${me}`,sender:st?"user":"agent",text:fe,time:new Date().toLocaleTimeString(),agentName:st?void 0:be,agentId:st?void 0:me,replyToId:R.replyToId??void 0,replyToSender:R.replyToSender??void 0,replyToText:R.replyToText??void 0};if(te&&H==="agent"){const Qe=[];if(te.thinking?.length&&Qe.push({type:"text",content:"",thinking:te.thinking.join(`
|
|
73
|
-
|
|
74
|
-
`)}),te.toolCalls?.length)for(let ct=0;ct<te.toolCalls.length;ct++){const Ne=te.toolCalls[ct];Qe.push({type:"tool",key:`${Ne.tool}_${ct}`,tool:Ne.tool,status:Ne.status==="error"?"error":"done",args:Ne.arguments,result:Ne.result,durationMs:Ne.durationMs})}Qe.length>0&&(Qe.push({type:"text",content:fe}),Ue.segments=Qe)}let Xe;if(q.startsWith("notes:"))Xe=`dm:${q.slice(6)}`;else if(q.startsWith("dm:")){const Qe=q.slice(3).split(":");Xe=`dm:${Qe.find(Ne=>Ne!==(e?.id??""))??Qe[0]??""}`}else Xe=`ch:${q}`;rt(Xe,Qe=>[...Qe,Ue]),Xe===Ve.current&&!ir.current&&(Er.current+=1,dn(Er.current),rr(!0)),H==="agent"&&Xe===`ch:${lt}`&&Rt(Qe=>{const ct=Qe.filter(Ne=>Ne.id!==me);return ct.length===0&&ns.current&&(clearTimeout(ns.current),ns.current=null),ct})}),[t,rt,e?.id,lt]),C.useEffect(()=>t?void 0:gt.on("chat:agent_no_response",E=>{const R=E.payload,q=R.channel??"",H=R.agentId??"";q&&H&&`ch:${lt}`==`ch:${q}`&&Rt(fe=>{const me=fe.filter(be=>be.id!==H);return me.length===0&&ns.current&&(clearTimeout(ns.current),ns.current=null),me})}),[t,lt]),C.useEffect(()=>t?void 0:gt.on("chat:proactive_message",E=>{const R=E.payload,q=R.targetUserId;if(q&&q!==e?.id)return;const H=R.agentId??"",fe=R.agentName??r("page.fallbackAgent"),me=R.message??"",be=R.sessionId??"",te=R.messageId??"",de=R.metadata??{};if(!H||!me||me==="[cancelled]"||me==="[Stream cancelled]")return;const st=de.role==="user",Ue=!st&&(!!de.activityLog||me.startsWith("[ACTIVITY:")),{cleaned:Xe,priority:Qe}=h_(me),ct=!st&&(!!de.notifyUser||Xe!==me),Ne=Kl("direct",H,"","");if(be&&Ve.current===Ne){const De=it;if(De&&De!==St&&De!==be)return}const Ke=!!de.isMainSession&&!st,Je=be||it,Oe=typeof de.userText=="string"?de.userText:"",Be=typeof de.userMessageId=="string"?de.userMessageId:"",we=typeof de.createdAt=="string"&&de.createdAt||(typeof E.timestamp=="string"?E.timestamp:void 0)||new Date().toISOString(),Le=(()=>{try{return new Date(we).toLocaleTimeString()}catch{return new Date().toLocaleTimeString()}})(),Me={id:te||`proactive_${Date.now()}`,sender:st?"user":"agent",text:Xe,time:Le,rawCreatedAt:we,...st?{}:{agentName:fe,agentId:H,...ct?{isNotification:!0,notifyPriority:de.priority??Qe}:{},...Ue?{isActivityLog:!0,activityType:de.activityType,outcome:de.outcome,mailboxItemId:de.mailboxItemId,taskId:de.taskId,requirementId:de.requirementId}:{},...!Ue&&de.taskId?{taskId:de.taskId}:{},...!Ue&&de.requirementId?{requirementId:de.requirementId}:{}}};ct&&Me.id&&jh(De=>De.includes(Me.id)?De:[...De,Me.id]),rt(Ne,De=>{if(De.some(Ct=>Ct.id===Me.id))return De;let et=De;if(!st&&Oe&&(et.some(Xt=>Be&&Xt.id===Be||Xt.sender==="user"&&Xt.text===Oe)||(et=[...et,{id:Be||`feishu_user_${Me.id}`,sender:"user",text:Oe,time:new Date().toLocaleTimeString()}])),Ke)for(let Ct=et.length-1;Ct>=0;Ct--){const Xt=et[Ct];if(Xt.sender==="agent"&&Xt.agentId===H&&Xt.isStopped){const $s=[...et];return $s[Ct]={...Me,id:Xt.id},$s}}return d_(et,Me)},Je||void 0)}),[t,rt,r,it]),cl.find(P=>P.id===nS),C.useEffect(()=>{oS(null)},[ge]);const vS=P=>w_(P),bS=()=>{const P=ce==="direct"?ge:null;P&&J.agents.cancelProcessing(P).catch(()=>{}),Ss.current?.abort(),Ss.current=null,$r.current?.abort(),$r.current=null;const E=Ve.current;Re(E),oi.delete(it??E),it&&vt(E,it),ai(E),rs(!1),bi([])},[pn,qh]=C.useState(null),[am,lm]=C.useState(!1),cm=C.useRef(null),mn=async(P,E)=>{const R=!P&&us.length>0?us.map(Xe=>Xe.content).join(`
|
|
75
|
-
|
|
76
|
-
`)+`
|
|
77
|
-
|
|
78
|
-
`:"",q=(P??R+Dt).trim();if(!q&&Fs.length===0||ce==="direct"&&!ge)return;nr();const H=Date.now(),fe=cm.current;if(!E?.isRetry&&!E?.isResume&&q&&fe&&fe.text===q&&H-fe.at<1500)return;if(cm.current={text:q,at:H},Vs&&ce==="direct"){if(it&&it!==St){const Qe=Ve.current;if([...hs.get(Qe)??[]].reverse().find(Ke=>Ke.sender==="user")?.text===q&&!E?.isRetry&&!E?.isResume)return Ss.current?.abort(),Ss.current=null,J.agents.cancelProcessing(ge).catch(()=>{}),Re(Qe),oi.delete(it??Qe),ai(Qe),rt(Qe,Ke=>{const Je=[...Ke];return Je.length>0&&Je[Je.length-1].sender==="agent"&&Je.pop(),Je.length>0&&Je[Je.length-1].sender==="user"&&Je[Je.length-1].text===q&&Je.pop(),Je}),rs(!1),bi([]),await new Promise(Ke=>setTimeout(Ke,50)),mn(q,{isRetry:!0});Ss.current?.abort(),Ss.current=null,J.agents.cancelProcessing(ge).catch(()=>{}),Re(Qe),oi.delete(it??Qe),ai(Qe),rt(Qe,Ke=>{const Je=[...Ke];for(let Oe=Je.length-1;Oe>=0;Oe--)if(Je[Oe].sender==="agent"&&!Je[Oe].isStopped&&!Je[Oe].isError){const Be=Je[Oe];if(!(Be.text?.trim()||(Be.segments??[]).some(Le=>Le.type==="text"&&(Le.content||Le.thinking)||Le.type==="tool")))Je.splice(Oe,1);else{const Le=(Be.segments??[]).map(Me=>Me.type==="tool"&&Me.status==="running"?{...Me,status:"stopped"}:Me);Je[Oe]={...Be,isStopped:!0,segments:Le}}break}return Je}),rs(!1),bi([]),await new Promise(Ke=>setTimeout(Ke,50))}}else if(Vs&&ce!=="direct"){Ss.current?.abort(),Ss.current=null;const Xe=Ve.current;Re(Xe),oi.delete(Xe),ai(Xe),rt(Xe,Qe=>{const ct=[...Qe];for(let Ne=ct.length-1;Ne>=0;Ne--)if(ct[Ne].sender==="agent"&&!ct[Ne].isStopped&&!ct[Ne].isError){const Ke=ct[Ne];if(!(Ke.text?.trim()||(Ke.segments??[]).some(Oe=>Oe.type==="text"&&(Oe.content||Oe.thinking)||Oe.type==="tool")))ct.splice(Ne,1);else{const Oe=(Ke.segments??[]).map(Be=>Be.type==="tool"&&Be.status==="running"?{...Be,status:"stopped"}:Be);ct[Ne]={...Ke,isStopped:!0,segments:Oe}}break}return ct}),rs(!1),bi([]),await new Promise(Qe=>setTimeout(Qe,50))}const me=Fs.length>0?Fs.map(Xe=>Xe.dataUrl):void 0,be=Fs.length>0?Fs.map(Xe=>Xe.name):void 0,te=Kl(ce,ge,lt,Nt),de=Ls;P||(Ut(""),Ai([])),Sh([]),Io(!1),Zt(null);const st=ce==="dm";he(te);const Ue=it??te;if(oi.set(Ue,[]),Ve.current===te&&!st&&(rs(!0),bi([])),ce==="dm"){const Xe=dl(e?.id??"",Nt),Qe=`opt_${Date.now()}`,ct={id:Qe,sender:"user",text:q,time:new Date().toLocaleTimeString(),rawCreatedAt:new Date().toISOString()};me?.length&&(ct.images=me),de&&(ct.replyToId=de.id,ct.replyToSender=de.sender,ct.replyToText=de.text),rt(te,Ne=>[...Ne,ct]);try{const Ne=await J.channels.sendMessage(Xe,{text:q,senderName:e?.name??r("page.fallbackYou"),senderId:e?.id,mentions:[],orgId:"default",humanOnly:!0,...me?.length?{images:me}:{}});Ne.userMessage&&Ln(Ne.userMessage.id),rt(te,Ke=>{const Je=Ke.filter(Be=>Be.id!==Qe),Oe=[];return Ne.userMessage&&Oe.push(xn(Ne.userMessage,e?.id)),Oe.length>0?[...Je,...Oe]:Ke})}catch(Ne){Jl(Ne)&&ec(),rt(te,Ke=>[...Ke.filter(Oe=>Oe.id!==Qe),{id:`err_${Date.now()}`,sender:"agent",text:r("page.errorWithMessage",{message:String(Ne)}),time:new Date().toLocaleTimeString(),agentName:r("page.systemName"),isError:!0}])}ue(te),Ve.current===te&&rs(!1)}else if(ce==="channel"){const Xe=`opt_${Date.now()}`,Qe={id:Xe,sender:"user",text:q,time:new Date().toLocaleTimeString(),rawCreatedAt:new Date().toISOString()};de&&(Qe.replyToId=de.id,Qe.replyToSender=de.sender,Qe.replyToText=de.text),rt(te,Ke=>[...Ke,Qe]);const ct=vS(q),Ne=ys.find(Ke=>Ke.channelKey===lt);if(lt.startsWith("group:")){const Ke=[];if(Ne?.members){for(const Je of Ne.members)if(Je.type==="agent"){const Oe=l.find(Be=>Be.id===Je.id);Oe&&Ke.push({id:Oe.id,name:Oe.name,avatarUrl:Oe.avatarUrl})}}Ke.length>0&&(ns.current&&clearTimeout(ns.current),Rt(Ke),ns.current=setTimeout(()=>Rt([]),12e4))}try{const Ke=await J.channels.sendMessage(lt,{text:q,senderName:e?.name??r("page.fallbackYou"),mentions:ct,senderId:e?.id,orgId:"default",replyToId:de?.id});Ke.userMessage&&Ln(Ke.userMessage.id),Ke.agentMessage&&Ln(Ke.agentMessage.id),rt(te,Je=>{const Oe=Je.filter(we=>we.id!==Xe),Be=[];return Ke.userMessage&&Be.push(xn(Ke.userMessage,e?.id)),Ke.agentMessage&&Be.push(xn(Ke.agentMessage,e?.id)),Be.length>0?[...Oe,...Be]:Je})}catch(Ke){Jl(Ke)&&ec();const Je=Oc(Ke,r)||r("page.errorWithMessage",{message:String(Ke)});rt(te,Oe=>[...Oe,{id:`err_${Date.now()}`,sender:"agent",text:Je,time:new Date().toLocaleTimeString(),agentName:r("page.systemName"),isError:!0}]),ns.current&&(clearTimeout(ns.current),ns.current=null),Rt([])}ue(te),Ve.current===te&&rs(!1)}else{nn(te);const Xe=`${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,Qe=`a_${Xe}`,ct=`u_${Xe}`;let Ne=E?.sessionIdOverride??(it===St?null:it);if(E?.isResume){const ae=new Date().toISOString();rt(te,Ze=>[...Ze,{id:Qe,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:ae,segments:[]}],Ne)}else{const ae=new Date().toISOString(),Ze={id:ct,sender:"user",text:q,time:new Date().toLocaleTimeString(),rawCreatedAt:ae};me?.length&&(Ze.images=me),de&&(Ze.replyToId=de.id,Ze.replyToSender=de.sender,Ze.replyToText=de.text),rt(te,ye=>[...ye,Ze,{id:Qe,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:ae,segments:[]}],Ne)}let Ke=!1;const Je=ae=>{Qr.current=Date.now(),er(te,Ze=>{const ye=[...Ze],pe=ye.findIndex(ar=>ar.id===Qe);if(pe<0)return Ze;const xe=ye[pe].segments??[],je=xe[xe.length-1],Ge=je?.type==="text"?je.thinking??"":"";let Qt="",He="",at=ae;for(;at.length>0;)if(Ke){const ar=at.indexOf("</think>");ar>=0?(Qt+=at.slice(0,ar),at=at.slice(ar+8),Ke=!1):(Qt+=at,at="")}else{const ar=at.indexOf("<think>");ar>=0?(He+=at.slice(0,ar),at=at.slice(ar+7),Ke=!0):(He+=at,at="")}const Bt=Ge+Qt||void 0,FS=je?.type==="text"?[...xe.slice(0,-1),{type:"text",content:je.content+He,thinking:Bt,createdAt:je.createdAt}]:[...xe,{type:"text",content:He,thinking:Bt,createdAt:new Date().toISOString()}];return ye[pe]={...ye[pe],text:ye[pe].text+He,segments:FS},ye},Ne)},Oe=ae=>{if(Qr.current=Date.now(),ae.type==="session_start"&&ae.sessionId){const Ze=Ne;Ne=ae.sessionId,Ze&&Ze!==ae.sessionId&&vt(te,Ze),tt(te,ae.sessionId),rl&&J.sessions.setModelOverride(ae.sessionId,rl).catch(()=>{}),ae.userMessageId&&!E?.isResume&&rt(te,pe=>pe.map(xe=>xe.id===ct?{...xe,id:ae.userMessageId}:xe),ae.sessionId);const ye=hs.get(te);if(ye&&ye.length>0&&sn.set(ae.sessionId,ye),Ve.current===te){const pe=it;(!pe||pe===St||pe===ae.sessionId)&&(Li(ae.sessionId),ds.set(te,ae.sessionId),ge&&ol(ge,ae.sessionId),Ns(xe=>xe.some(je=>je.id===St)?xe.map(je=>je.id===St?{...je,id:ae.sessionId}:je):xe.some(je=>je.id===ae.sessionId)?xe:[...xe,{id:ae.sessionId,agentId:ge??"",userId:null,title:"",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()}]))}return}rt(te,Ze=>{const ye=[...Ze],pe=ye.findIndex(je=>je.id===Qe);if(pe<0)return Ze;const xe=[...ye[pe].committedSegments??[]];return ae.type==="thinking_commit"?xe.push({type:"text",content:"",thinking:ae.content,createdAt:ae.createdAt}):xe.push({type:"text",content:ae.content,createdAt:ae.createdAt}),ye[pe]={...ye[pe],committedSegments:xe},ye},Ne)},Be=ae=>{Qr.current=Date.now(),ae.phase!=="heartbeat"&&((ae.phase==="start"||ae.phase==="end")&&rn(te,{...ae,phase:ae.phase,ts:Date.now()},Ne),ae.phase==="start"?rt(te,Ze=>{const ye=[...Ze],pe=ye.findIndex(at=>at.id===Qe);if(pe<0)return Ze;const xe=[...ye[pe].segments??[]];let je=!1;if(ae.arguments)for(let at=xe.length-1;at>=0;at--){const Bt=xe[at];if(Bt.type==="tool"&&Bt.tool===ae.tool&&Bt.status==="running"){xe[at]={...Bt,args:ae.arguments},je=!0;break}}const Ge=`${ae.tool}_${Date.now()}`,Qt=new Date().toISOString();je||xe.push({type:"tool",key:Ge,tool:ae.tool,status:"running",args:ae.arguments,createdAt:Qt});const He=[...ye[pe].committedSegments??[]];return ae.arguments!==void 0&&He.push({type:"tool",key:Ge,tool:ae.tool,status:"running",args:ae.arguments,createdAt:Qt}),ye[pe]={...ye[pe],segments:xe,committedSegments:He},ye},Ne):ae.phase==="output"?er(te,Ze=>{const ye=[...Ze],pe=ye.findIndex(je=>je.id===Qe);if(pe<0)return Ze;const xe=[...ye[pe].segments??[]];for(let je=xe.length-1;je>=0;je--){const Ge=xe[je];if(Ge.type==="tool"&&Ge.tool===ae.tool&&Ge.status==="running"){xe[je]={...Ge,liveOutput:__(Ge.liveOutput,ae.output??"")};break}}return ye[pe]={...ye[pe],segments:xe},ye},Ne):ae.phase==="subagent_progress"&&ae.subagentEvent?er(te,Ze=>{const ye=[...Ze],pe=ye.findIndex(Qt=>Qt.id===Qe);if(pe<0)return Ze;const xe=Qt=>{const He=[...Qt];for(let at=He.length-1;at>=0;at--){const Bt=He[at];if(Bt.type==="tool"&&(Bt.tool==="spawn_subagent"||Bt.tool==="spawn_subagents")&&Bt.status==="running"){He[at]={...Bt,subagentLogs:km(Bt.subagentLogs,ae.subagentEvent)};break}}return He},je=xe(ye[pe].segments??[]),Ge=xe(ye[pe].committedSegments??[]);return ye[pe]={...ye[pe],segments:je,committedSegments:Ge},ye},Ne):rt(te,Ze=>{const ye=[...Ze],pe=ye.findIndex(He=>He.id===Qe);if(pe<0)return Ze;const xe=new Date().toISOString(),je=[...ye[pe].segments??[]];let Ge;for(let He=je.length-1;He>=0;He--){const at=je[He];if(at.type==="tool"&&at.tool===ae.tool&&at.status==="running"){Ge=at.subagentLogs,je[He]={...at,status:ae.success===!1?"error":"done",args:ae.arguments,result:ae.result,error:ae.error,durationMs:ae.durationMs,liveOutput:void 0,createdAt:xe};break}}const Qt=[...ye[pe].committedSegments??[]];for(let He=Qt.length-1;He>=0;He--){const at=Qt[He];if(at.type==="tool"&&at.tool===ae.tool&&at.status==="running"){Qt[He]={...at,status:ae.success===!1?"error":"done",args:ae.arguments,result:ae.result,error:ae.error,durationMs:ae.durationMs,liveOutput:void 0,createdAt:xe,subagentLogs:Ge??at.subagentLogs};break}}return ye[pe]={...ye[pe],segments:je,committedSegments:Qt},ye},Ne))},we=new AbortController;Ss.current=we;const Le=E?.sessionIdOverride??(it===St?null:it),Me=Le;Me&&tt(te,Me);try{Qr.current=Date.now();const ae=await J.agents.messageStream(ge,q,Je,Be,we.signal,me,Le,E?.isRetry,E?.isResume,Oe,be,de,rl);if(Ve.current===te){ae.merged&&rt(te,ye=>ye.filter(pe=>pe.id!==Qe&&pe.id!==ct),Ne),!ae.merged&&ae.segments?.length&&rt(te,ye=>{const pe=[...ye],xe=pe.findIndex(He=>He.id===Qe);if(xe<0)return ye;const je=Cm(ae.segments,pe[xe].segments);let Ge=ae.content||pe[xe].text;Ge||(Ge=je.filter(He=>He.type==="text").map(He=>He.content).join(""));const Qt=!Ge?.trim()&&!je.some(He=>He.type==="text"&&(He.content||He.thinking)||He.type==="tool");return pe[xe]={...pe[xe],text:Ge,segments:je,committedSegments:je,isStopped:ae.cancelled||pe[xe].isStopped,emptyReply:ae.emptyReply||Qt||void 0,isError:ae.emptyReply||Qt?!0:pe[xe].isError},pe},Ne),!ae.merged&&!ae.segments?.length&&rt(te,ye=>{const pe=[...ye],xe=pe.findIndex(Bt=>Bt.id===Qe);if(xe<0)return ye;const je=pe[xe],Ge=je.committedSegments??[],He=Ge.filter(Bt=>Bt.type==="text"&&!!Bt.content).map(Bt=>Bt.content).join("")||ae.content||je.text,at=!He?.trim()&&Ge.length===0;return(Ge.length>0||He||ae.cancelled||ae.emptyReply||at)&&(pe[xe]={...je,text:He,segments:Ge.length>0?Ge:je.segments,isStopped:ae.cancelled||je.isStopped,emptyReply:ae.emptyReply||at||void 0,isError:ae.emptyReply||at?!0:je.isError}),pe},Ne),ae.sessionId&&(Li(ye=>!ye||ye===St||ye===ae.sessionId?ae.sessionId:ye),Ns(ye=>ye.some(pe=>pe.id===St)?ye.map(pe=>pe.id===St?{...pe,id:ae.sessionId}:pe):ye.some(pe=>pe.id===ae.sessionId)?ye:[...ye,{id:ae.sessionId,agentId:ge??"",userId:null,title:"",createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()}])),Ol(ge).then(ye=>{if(Ve.current===te&&(an(ye),ae.sessionId)){const pe=ye.find(xe=>xe.id===ae.sessionId);pe&&Ns(xe=>xe.some(Ge=>Ge.id===pe.id)?xe.map(Ge=>Ge.id===pe.id?pe:Ge):[pe,...xe.filter(Ge=>Ge.id!==St)])}});const Ze=ae.sessionId??(Me&&Me!==St?Me:null);if(!we.signal.aborted&&!ae.merged&&ae.segments===void 0&&ce==="direct"&&ge&&Ze)try{if((await J.sessions.streamStatus(ge,Ze)).status==="streaming"){rt(te,pe=>pe.map(xe=>xe.id===Qe?{...xe,isStreaming:!0,isStopped:!1,segments:(xe.segments??[]).map(je=>je.type==="tool"&&(je.status==="stopped"||je.status==="running")?{...je,status:"running"}:je)}:xe),Ze),ue(te),Ss.current===we&&(Ss.current=null),tt(te,Ze),fn(ge,Ze,te);return}}catch{}}}catch(ae){const Ze=ae?.sessionId;Ze&&ce==="direct"&&Ve.current===te&&(Li(Ze),Ns(pe=>pe.map(xe=>xe.id===St?{...xe,id:Ze}:xe)),Ol(ge).then(pe=>{if(Ve.current!==te)return;an(pe);const xe=pe.find(je=>je.id===Ze);xe&&Ns(je=>je.some(Qt=>Qt.id===xe.id)?je.map(Qt=>Qt.id===xe.id?xe:Qt):[xe,...je])})),Jl(ae)&&ec();const ye=Oc(ae,r);ye?rt(te,pe=>{const xe=[...pe],je=xe.findIndex(Ge=>Ge.id===Qe);if(je>=0){const Ge=xe[je].segments??[];xe[je]={...xe[je],text:ye,isError:!0,segments:[...Ge,{type:"text",content:ye}]}}return xe},Ne):rt(te,pe=>{const xe=[...pe],je=xe.findIndex(Ge=>Ge.id===Qe);if(je>=0){const Ge=xe[je];if(!(Ge.text||Ge.segments&&Ge.segments.length>0&&Ge.segments.some(He=>He.type==="text"&&(He.content||He.thinking)||He.type==="tool")))return pe.filter(He=>He.id!==Qe);xe[je]={...Ge,isStopped:!0}}return xe},Ne)}rt(te,ae=>{const Ze=[...ae],ye=Ze.findIndex(pe=>pe.id===Qe);if(ye>=0){const pe=(Ze[ye].segments??[]).map(xe=>xe.type==="tool"&&xe.status==="running"?{...xe,status:"stopped"}:xe);Ze[ye]={...Ze[ye],segments:pe}}return Ze},Ne),we.signal.aborted&&rt(te,ae=>{const Ze=[...ae],ye=Ze.findIndex(pe=>pe.id===Qe);if(ye>=0){const pe=Ze[ye];if(!(pe.text||pe.segments&&pe.segments.length>0&&pe.segments.some(je=>je.type==="text"&&(je.content||je.thinking)||je.type==="tool")))return ae.filter(je=>je.id!==Qe);Ze[ye]={...pe,isStopped:!0}}return Ze},Ne);const et=(hs.get(te)??[]).find(ae=>ae.id===Qe),Ct=it&&it!==St?it:null,Xt=et?.text||et?.segments?.some(ae=>ae.type==="text"&&ae.content||ae.type==="tool");et&&!Xt&&ce==="direct"&&Ct&&!we.signal.aborted&&await(async(Ze,ye)=>{for(let pe=0;pe<Ze;pe++){await new Promise(xe=>setTimeout(xe,ye));try{const je=(await J.sessions.getMessages(Ct,2)).messages.find(Ge=>Ge.role==="assistant");if(je?.content){const Ge=td(je);rt(te,Qt=>{const He=[...Qt],at=He.findIndex(Bt=>Bt.id===Qe);return at>=0&&(He[at]={...He[at],text:Ge.text,segments:Ge.segments}),He},Ne);return}}catch{}}})(5,3e3);const $s=ue(te);Ne&&vt(te,Ne),ai(te),Ss.current===we||Ss.current===null?(Ss.current=null,oi.delete(Ne??te),Ve.current===te&&(rs($s>0),$s===0&&bi([]))):oi.delete(Ne??te)}};em.current=mn;const[yS,hm]=C.useState(null),[vl,zh]=C.useState(null),SS=C.useMemo(()=>{for(let P=At.length-1;P>=0;P--)if(At[P]?.sender==="agent"&&!At[P]?.isActivityLog)return At[P].id;return null},[At]),_S=C.useCallback(P=>{const E=P.segments?P.segments.filter(R=>R.type==="text").map(R=>R.content).join(`
|
|
79
|
-
`):P.text;navigator.clipboard.writeText(E),hm(P.id),setTimeout(()=>hm(R=>R===P.id?null:R),2e3)},[]),Zh=C.useCallback((P,E,R)=>{const q=Ve.current,H=hs.get(q)??At,fe=H.findIndex(be=>be.id===P.id);if(fe<0)return;const me=E&&fe>0&&H[fe-1]?.id===E.id;rt(q,be=>{const te=be.findIndex(de=>de.id===(me?E.id:P.id));return te>=0?be.slice(0,te):be}),mn(R,{isRetry:!0})},[At,rt]),wS=C.useCallback(P=>{const E=Ve.current,R=hs.get(E)??At,q=R.findIndex(be=>be.id===P.id);if(q<0)return;let H=null;for(let be=q-1;be>=0;be--)if(R[be]?.sender==="user"){H=R[be];break}const fe=H?.text??"";if(!fe)return;if(q<R.length-1){const be=R.length-1-q;zh({retryMsg:P,userMsg:H,retryText:fe,followCount:be});return}Zh(P,H,fe)},[At,Zh]),kS=C.useCallback(P=>{const E=Ve.current;(hs.get(E)??At).findIndex(H=>H.id===P.id)<0||(rt(E,H=>{const fe=[...H],me=fe.findIndex(de=>de.id===P.id);if(me<0)return H;const be=fe[me],te=[...be.segments??[]];for(;te.length>0;){const de=te[te.length-1];if(de.type==="tool"&&(de.status==="stopped"||de.status==="running"))te.pop();else if(de.type==="text"&&!de.content)te.pop();else break}return fe[me]={...be,segments:te,isStopped:!1,isError:!1},fe}),mn("[Continue from where you left off. Do not repeat content already generated.]",{isResume:!0}))},[At,rt]),CS=C.useCallback(P=>{const E=P.sender==="user"?e?.name??r("page.fallbackYou"):P.agentName??r("page.fallbackAgent");if(Zt({id:P.id,sender:E,text:P.text}),ce==="channel"&&P.sender==="agent"&&P.agentName){const R=`@${P.agentName} `;Ut(q=>q.startsWith(R)?q:R+q)}sr.current?.focus()},[e?.name,ce,r]),PS=async P=>{if(!pn||!ge||ce!=="direct")return;const E=it;if(!(!E||E===St)){lm(!0);try{const R=await J.agents.evolveFromMessage(ge,{parentSessionId:E,sourceMessageId:pn.id.startsWith("a_")||pn.id.startsWith("u_")?void 0:pn.id,sourceText:(pn.text||"").slice(0,500)||void 0,userNote:P.trim()||void 0}),q=new Date().toISOString(),H={id:R.sessionId,agentId:ge,userId:e?.id??null,title:"Remember / Evolution",isMain:!1,metadata:{kind:"evolution",parentSessionId:R.parentSessionId,sourceMessageId:pn.id,sourceAgentId:ge,createdFrom:"remember_button"},createdAt:q,lastMessageAt:q};qh(null),an(me=>[H,...me.filter(be=>be.id!==H.id)]),Ns(me=>me.some(be=>be.id===H.id)?me:[...me,H]),Li(H.id);const fe=Kl("direct",ge,lt,Nt);ds.set(fe,H.id),ol(ge,H.id),Ri(fe),Qs([]),Mi(!1),yi.current=null,await mn(R.seedPrompt,{sessionIdOverride:R.sessionId})}catch(R){console.error("evolve-from-message failed",R)}finally{lm(!1)}}},bl=async P=>{const E=it;Li(P.id),cn(!1),Mi(!1),yi.current=null,nr(),rr(!1),Er.current=0,dn(0);const R=Ve.current,q=mt(R),H=!!q&&(q.has(P.id)||q.has(St)),fe=Fe(R)&&H;rs(fe),bi(fe?oi.get(P.id)??[]:[]),ds.set(R,P.id),ge&&ol(ge,P.id),E&&E!==St&&Ye(R,E),Yt(R,P.id),Ns(be=>be.some(te=>te.id===P.id)?be:[...be,P]),ge&&K1(ge,P.id),await Wh(P.id,R);const me=P.metadata?.modelOverride;nl(me?.provider&&me?.model?{provider:me.provider,model:me.model}:null),ge&&!fe&&fn(ge,P.id,R)},TS=P=>{if(Ns(E=>E.filter(R=>R.id!==P)),ge&&P!==St&&G1(ge,P),it===P){const E=Mo.filter(R=>R.id!==P);E.length>0?bl(E[E.length-1]):Vh()}},dm=C.useCallback(async P=>{if(P.length<2){jr([]);return}Yp(!0);try{const E=ce==="channel"?"channel":ce==="direct"?"direct":"all",R=ce==="channel"?lt:void 0,{results:q}=await J.messages.search(P,{scope:E,channel:R,limit:30});jr(q)}catch{jr([])}Yp(!1)},[ce,lt]),QS=C.useCallback(P=>{In(P),Mh.current&&clearTimeout(Mh.current),Mh.current=setTimeout(()=>dm(P),300)},[dm]),$S=C.useCallback(P=>{Do(!1),In(""),jr([]),P.source==="channel"&&P.channel?(ut("channel"),As(P.channel)):P.source==="direct"&&P.agentId&&(ut("direct"),is(P.agentId)),setTimeout(()=>{const E=document.getElementById(`msg-${P.id}`);E&&(E.scrollIntoView({behavior:"smooth",block:"center"}),E.classList.add("bg-brand-500/10"),setTimeout(()=>E.classList.remove("bg-brand-500/10"),2e3))},500)},[]),Vh=()=>{Li(St);const P=Ve.current;Ri(P),Qs([]),Mi(!1),yi.current=null,cn(!1),Ns(E=>{const R=E.filter(q=>q.id!==St);return[{id:St,agentId:ge??"",userId:null,title:r("page.newChat"),createdAt:new Date().toISOString(),lastMessageAt:new Date().toISOString()},...R]})},jS=P=>{Ut(P);const E=sr.current?.selectionStart??P.length,R=P.slice(0,E),q=R.lastIndexOf("@");if(q>=0){const H=q===0?"":R[q-1];if(q===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(H)){const me=R.slice(q+1);if(!me.includes(" ")&&!me.includes(`
|
|
80
|
-
`)){hS(),Io(!0),aS(me.toLowerCase()),Bn(0);return}}}Io(!1)},yl=(P,E,R)=>{const q=sr.current?.selectionStart??Dt.length,fe=Dt.slice(0,q).lastIndexOf("@"),me=Dt.slice(q),be=E&&R?`@[${P}](${E}:${R})`:P.includes(" ")?`@[${P}]`:`@${P}`,te=Dt.slice(0,fe)+be+" "+me;Ut(te),Io(!1),Bn(0);const de=fe+be.length+1;requestAnimationFrame(()=>{const st=sr.current;st&&(st.focus(),st.setSelectionRange(de,de))})},ES=10*1024*1024,um=5,RS=new Set(["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.ms-excel","application/msword","text/csv","text/html","application/json","application/xml","text/xml","application/epub+zip"]),Vn=C.useCallback(P=>P.type.startsWith("image/")||RS.has(P.type),[]),Fh=P=>P.dataUrl.startsWith("data:image/"),AS=(P,E)=>{if(Fh({dataUrl:E}))return null;const R=P.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[R]??"📁"},zo=C.useCallback(P=>{const E=Array.from(P).filter(Vn);if(E.length!==0)for(const R of E){if(R.size>ES)continue;const q=new FileReader;q.onload=()=>{const H=q.result;Sh(fe=>fe.length>=um||fe.some(me=>me.dataUrl===H)?fe:[...fe,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:H,name:R.name}])},q.readAsDataURL(R)}},[Vn]),MS=C.useCallback(P=>{Sh(E=>E.filter(R=>R.id!==P))},[]),LS=C.useCallback(P=>{const E=P.clipboardData?.files;if(E&&E.length>0){const R=Array.from(E).filter(Vn);R.length>0&&(P.preventDefault(),zo(R))}},[zo,Vn]),NS=C.useCallback(P=>{P.preventDefault();const E=P.dataTransfer?.files;E&&E.length>0&&zo(Array.from(E).filter(Vn))},[zo,Vn]),DS=C.useCallback(P=>{P.preventDefault()},[]),It=l.find(P=>P.id===ge),gn=Vt??(ce==="direct"?It?.teamId:void 0),Zo=!!(!b&&!T&&gn&&Si.some(P=>P.id===gn)),fm=!!(Zo&&!D&&(Y&&!Ce||ht));$e.current=Zo,C.useEffect(()=>{if(G==="l2"){if(!Zo){B?.setKeyboardPane("l1");return}!D&&!Y&&!ht&&B?.setKeyboardPane("l1")}},[G,Zo,D,Y,ht,B]);const pm=C.useRef(G);C.useEffect(()=>{if(t||b||!o)return;const P=pm.current;if(pm.current=G,!(G!=="l2"||P==="l2")){if(!gn){B?.setKeyboardPane("l1");return}Ce?yt(!0):ee(!0)}},[G,t,b,o,gn,Ce,B]);const Yh=e?.name??r("page.fallbackYou"),mm=os[os.length-1],IS=Vs&&mm?.sender==="agent",BS=vh&&mm?.sender==="agent",gm=C.useMemo(()=>{if(ce!=="channel")return null;if(lt.startsWith("group:custom:")){const E=ys.find(R=>R.channelKey===lt);return E?.members?new Set(E.members.filter(R=>R.type==="agent").map(R=>R.id)):null}if(!Vt)return null;const P=Si.find(E=>E.id===Vt);return P?new Set(P.members.filter(E=>E.type==="agent").map(E=>E.id)):null},[ce,lt,Vt,Si,ys]),Om=l.filter(P=>gm?gm.has(P.id):!0).filter(P=>P.name.toLowerCase().includes(Kp)),xm=lS.filter(P=>P.name.toLowerCase().includes(Kp)),WS={workflow:"⚙️",project:"📁",requirement:"📋",task:"✅",deliverable:"📦"},On=C.useMemo(()=>[...Om.map(P=>({kind:"agent",agent:P})),...xm.map(P=>({kind:"entity",entity:P}))],[Om,xm]),Uh=d.find(P=>P.id===Nt),Hh=Nt===e?.id||!Nt,ci=ys.find(P=>P.channelKey===lt);C.useEffect(()=>{if(t||!lt.startsWith("group:custom:"))return;const P=ys.find(E=>E.channelKey===lt);!P||P.members||J.groupChats.getById(P.id).then(E=>{E.chat.members&&Lo(R=>R.map(q=>q.id===P.id?{...q,members:E.chat.members}:q))}).catch(()=>{})},[t,lt,ys]);const Gh=C.useCallback(async()=>{if(t||ce!=="direct"||!ge){Ph([]);return}try{Pm("/approvals");const{approvals:P}=await J.approvals.list("pending");Ph(P.filter(E=>E.status==="pending"&&Array.isArray(E.questions)&&E.questions.length>0&&(E.details?.agentId??E.agentId)===ge))}catch{}},[t,ce,ge]),Kh=C.useCallback(async()=>{if(t||ce!=="direct"||!ge||!it||it===St){Qh([]);return}try{Pm("/notifications");const{notifications:P}=await J.notifications.list(e?.id,!0,{type:"agent_report",limit:30}),E=P.filter(R=>!R.read&&R.type==="agent_report"&&!R.metadata?.creditExhausted&&R.metadata?.agentId===ge&&OM(R)===it).sort((R,q)=>new Date(q.createdAt).getTime()-new Date(R.createdAt).getTime()).slice(0,5);Qh(E),jh(E.map(R=>R.metadata?.messageId).filter(R=>typeof R=="string"&&R.length>0))}catch{}},[t,ce,ge,it,e?.id]);C.useEffect(()=>{Gh(),Kh();let P=null;const E=()=>{P||(P=setTimeout(()=>{P=null,Gh(),Kh()},400))},R=gt.on("approval:requested",E),q=gt.on("notification",E),H=()=>E();return window.addEventListener("markus:notifications-changed",H),()=>{P&&clearTimeout(P),R(),q(),window.removeEventListener("markus:notifications-changed",H)}},[Gh,Kh]);const XS=C.useCallback(async(P,E)=>{Xp(P);try{await J.approvals.respond(P,E.approved,e?.id,E.comment,E.selectedOption,E.answers),Ph(R=>R.filter(q=>q.id!==P)),Th(null),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}Xp(null)},[e?.id]),qS=C.useCallback(async P=>{qp(P);try{const E=al.find(q=>q.id===P)??Dn,R=typeof E?.metadata?.messageId=="string"?E.metadata.messageId:null;await J.notifications.markRead(P),Qh(q=>q.filter(H=>H.id!==P)),R&&jh(q=>q.filter(H=>H!==R)),$h(null),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{}qp(null)},[al,Dn]),vm=ce==="channel"?ci?.name??lt:ce==="direct"?It?.name??r("page.selectAgent"):ce==="dm"?Hh?r("chat.myNotes"):Uh?.name??r("page.directMessage"):r("page.chatTitle"),zS=C.useMemo(()=>Math.floor(Math.random()*5),[ge,it]),bm=ge?r(`page.placeholder.directOptions.${zS}`):"",Vo=ce==="direct"&&!!It&&It.status==="offline",ZS=ce==="channel"?ci?r("page.placeholder.channel",{name:ci.name}):r("page.placeholder.channelWithMention",{name:lt}):ce==="dm"?Hh?r("page.placeholder.dmSelf"):r("page.placeholder.dmOther",{name:Uh?.name??""}):r(Vo?"page.placeholder.agentOffline":ge?"page.placeholder.direct":"page.placeholder.noAgent"),VS=b&&p==="chat",Fo=w==="chat"&&os.length===0&&!Vs&&!Dp,hi=w==="chat"&&os.length>0;wh.current=hi;const Jh=!!(Dt.trim()||Fs.length>0);return h.jsxs("div",{ref:ke,className:"flex-1 overflow-hidden flex relative",children:[!T&&h.jsx(z_,{authUser:e,agents:l,teams:Si,humans:d,tasks:cl,externalAgents:iS,groupChats:ys,chatMode:ce,selectedAgent:ge,activeChannel:lt,activeDmUserId:Nt,previewMode:t,onSelectAgent:P=>{ut("direct"),is(P),S("chat"),fs(!1),b&&_()},onSelectChannel:P=>{ut("channel"),As(P),S("chat"),fs(!1),b&&_()},onSelectDm:P=>{ut("dm"),en(P),S("chat"),fs(!1),b&&_()},onSelectTeam:P=>{const E=ys.find(q=>q.type==="team"&&q.teamId===P),R=E?.channelKey??`group:${P}`;b?k(P):(ut("channel"),As(R),S("chat"),fs(!1),!Y&&!Ce&&ee(!0),E||(Xn(),Ys()))},selectedTeamId:Vt??(ce==="direct"&&It?.teamId?It.teamId:null),onRefreshTeams:Ys,onRefreshAgents:li,onRefreshHumans:qo,onRefreshGroupChats:Xn,onViewProfile:Ts,onManageGroupMembers:P=>{ut("channel"),As(P),S("chat"),fs(!0),b&&_()},unreadByAgent:fl,unreadByChannel:ul,width:b?void 0:I.width,onResizeStart:b?void 0:I.onResizeStart,hidden:b&&p!=="roster"||!b&&D,onCollapse:()=>j(!0),initialLoading:f,focused:!b&&!D&&G==="l1",l2Available:Zo}),b&&p==="team"&&x&&(()=>{const P=Si.find(q=>q.id===x);if(!P)return null;const E=l.filter(q=>q.teamId===x),R=ys.find(q=>q.type==="team"&&q.teamId===x);return h.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 shrink-0 border-b border-border-default",children:[h.jsx("button",{onClick:()=>{window.location.hash=Ht.TEAM},className:"p-1.5 -ml-1 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-secondary",children:h.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("polyline",{points:"15 18 9 12 15 6"})})}),h.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[h.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate",children:P.name}),h.jsx("p",{className:"text-[10px] text-fg-tertiary",children:r("chat.members_other",{count:P.members?.length||E.length})})]})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-1",children:[R&&(()=>{const q=ul[R.channelKey]??0;return h.jsxs("button",{onClick:()=>{ut("channel"),As(R.channelKey),S("chat"),_()},className:"w-full flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors",children:[h.jsx("div",{className:"w-9 h-9 rounded-xl bg-brand-500/15 flex items-center justify-center shrink-0",children:h.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:R.name}),h.jsx("div",{className:"text-[10px] text-fg-tertiary",children:r("chat.groupChat")})]}),q>0?h.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:q}):h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-tertiary shrink-0",children:h.jsx("polyline",{points:"9 18 15 12 9 6"})})]})})(),E.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider px-2.5 pt-2",children:r("chat.agents")}),E.map(q=>{const H=fl.get(q.id)??0,fe=q.status==="offline";return h.jsxs("button",{onClick:()=>{ut("direct"),is(q.id),S("chat"),_()},className:`w-full flex items-center gap-2.5 px-2.5 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors ${fe?"opacity-50":""}`,children:[h.jsx(_s,{name:q.name||"Agent",avatarUrl:q.avatarUrl,size:36}),h.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[h.jsxs("div",{className:"text-sm font-medium text-fg-primary truncate flex items-center gap-1.5",children:[q.name,fe&&h.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium leading-relaxed",children:r("common:status.offline")})]}),h.jsx("div",{className:"text-[10px] text-fg-tertiary truncate",children:q.role||q.status})]}),H>0?h.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:H}):h.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${q.status==="idle"?"bg-green-500":q.status==="working"?"bg-blue-500":"bg-gray-400"}`})]},q.id)})]})]})]})})(),!T&&Y&&!Ce&&!b&&!D&&(()=>{const P=Vt??(ce==="direct"?It?.teamId:void 0);if(!P)return null;const E=Si.find(q=>q.id===P);if(!E)return null;const R=ys.find(q=>q.type==="team"&&q.teamId===P);return h.jsx(Nm,{team:E,agents:l,humans:d,authUser:e,groupChat:R,chatMode:ce,selectedAgent:ge,activeChannel:lt,activeDmUserId:Nt,teams:Si,onSelectAgent:q=>{ut("direct"),is(q),S("chat"),fs(!1)},onSelectChannel:q=>{ut("channel"),As(q),S("chat"),fs(!1)},onSelectDm:q=>{ut("dm"),en(q),S("chat"),fs(!1)},onBack:()=>ee(!1),onViewProfile:Ts,onRefreshAgents:li,onRefreshTeams:Ys,unreadByAgent:fl,width:le.width,onResizeStart:le.onResizeStart,focused:G==="l2"&&fm})})(),!T&&ht&&!b&&!D&&(()=>{if(!gn)return null;const P=Si.find(R=>R.id===gn);if(!P)return null;const E=ys.find(R=>R.type==="team"&&R.teamId===gn);return h.jsxs("div",{"data-l2-floating":!0,className:"absolute z-30 inset-0",style:{left:I.width+6},children:[h.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:()=>yt(!1)}),h.jsx("div",{className:"relative h-full",style:{width:le.width+8},children:h.jsx(Nm,{team:P,agents:l,humans:d,authUser:e,groupChat:E,chatMode:ce,selectedAgent:ge,activeChannel:lt,activeDmUserId:Nt,teams:Si,onSelectAgent:R=>{ut("direct"),is(R),S("chat"),fs(!1),yt(!1)},onSelectChannel:R=>{ut("channel"),As(R),S("chat"),fs(!1),yt(!1)},onSelectDm:R=>{ut("dm"),en(R),S("chat"),fs(!1),yt(!1)},onBack:()=>yt(!1),onViewProfile:R=>{Ts(R),yt(!1)},onRefreshAgents:li,onRefreshTeams:Ys,unreadByAgent:fl,width:le.width,focused:G==="l2"&&fm})})]})})(),!T&&(!b||VS)&&h.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col ${b||V?"min-w-0":"min-w-[400px]"}`,children:[h.jsxs("div",{className:"shrink-0 relative pb-2",children:[b?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center px-3 h-11 gap-2",children:[h.jsx("button",{onClick:()=>{window.location.hash=y.current},className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1 shrink-0",children:h.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("polyline",{points:"15 18 9 12 15 6"})})}),h.jsx("span",{className:"font-semibold text-sm truncate min-w-0 flex-1",children:vm}),ce==="direct"&&It&&h.jsx(ux,{agent:It,tasks:cl,onViewProfile:Ts,streamActive:Mp})]}),h.jsxs("div",{className:"flex items-center px-3 h-9 gap-1 border-t border-border-default/40",children:[h.jsx("button",{onClick:()=>{cr(w)?history.back():S("chat")},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${w==="chat"?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:r("page.chatTitle")}),h.jsx("button",{onClick:()=>{cr(w)||Tr()},className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${cr(w)?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:r(ce==="channel"?"page.teamTab":"page.profileTab")}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{onClick:()=>{Do(!hn),hn||(In(""),jr([]))},className:`p-1 rounded-md transition-colors shrink-0 ${hn?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})})}),ce==="channel"&&ci?.type==="custom"&&h.jsxs("button",{onClick:()=>fs(!No),className:`text-[11px] px-2 py-1 rounded-md font-medium shrink-0 flex items-center gap-1 ${No?"bg-brand-500/15 text-brand-500":"text-fg-tertiary"}`,children:[h.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),ci.members?.length??ci.memberCount??0]}),ce==="direct"&&!cr(w)&&h.jsxs(h.Fragment,{children:[h.jsx("button",{onClick:Vh,className:"text-[11px] text-brand-500 px-2 py-1 rounded-md bg-brand-500/10 font-medium shrink-0",children:r("page.newChatPlus")}),h.jsx("button",{ref:ll,onClick:()=>cn(!ln),className:`p-1 rounded-md transition-colors shrink-0 ${ln?"bg-surface-overlay text-fg-primary":"text-fg-tertiary"}`,title:r("page.historyTitle"),children:h.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})]})]}):(()=>{const P=Vt?Si.find(de=>de.id===Vt):void 0,E=ce==="direct"&&ge?xM:ce==="channel"&&Vt?vM:["chat"],R=async()=>{const de=Ja.trim();if(!de){xi(!1);return}try{ce==="direct"&&ge?(await J.agents.updateConfig(ge,{name:de}),li()):ce==="channel"&&Vt&&(await J.teams.update(Vt,{name:de}),Ys())}catch{}xi(!1)},q=async()=>{try{ce==="direct"&&ge?(await J.agents.updateConfig(ge,{roleDescription:Ei}),li()):ce==="channel"&&Vt&&(await J.teams.update(Vt,{description:Ei}),Ys())}catch{}$o(!1)},H=ce==="direct"?It?.name:ce==="channel"?P?.name??ci?.name:Uh?.name??"",fe=ce==="direct"?It?.role||"":ce==="channel"&&P?.description||"",me=ce==="direct"?It?.avatarUrl:void 0,be=H||"U",te=ce==="direct"&&ge||ce==="channel"&&Vt;return h.jsxs("div",{className:"flex flex-col",children:[h.jsxs("div",{"data-electron-drag":!0,className:"flex items-center px-4 h-14 gap-2.5",children:[D&&!b&&h.jsx("button",{onClick:()=>j(!1),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:r("page.toggleSidebar"),children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),h.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),(!Y||Ce)&&(ce==="channel"&&Vt||ce==="direct"&&It?.teamId)&&h.jsx("button",{onClick:ss,className:`w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 ${ht?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:"Toggle team panel",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),h.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),te&&h.jsx("div",{"data-no-drag":!0,className:"shrink-0",children:ce==="channel"&&Vt?h.jsx("div",{className:"w-9 h-9 rounded-xl bg-brand-600 text-white flex items-center justify-center text-sm font-bold",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}):h.jsx(_s,{name:be,avatarUrl:me,size:36,className:"rounded-xl shrink-0"})}),te?h.jsxs("div",{"data-no-drag":!0,className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[ii?h.jsx("input",{ref:Mn,value:Ja,onChange:de=>Qo(de.target.value),onBlur:R,onKeyDown:de=>{de.key==="Enter"&&R(),de.key==="Escape"&&xi(!1)},className:"text-sm font-semibold bg-transparent border-b border-brand-500 outline-none py-0 px-0 min-w-[80px] max-w-[240px]",autoFocus:!0}):h.jsx("span",{className:"text-sm font-semibold truncate cursor-pointer hover:text-brand-500 transition-colors",onClick:()=>{Qo(H??""),xi(!0)},title:"Click to edit name",children:H}),ce==="direct"&&It&&h.jsx(ux,{agent:It,tasks:cl,onViewProfile:Ts,streamActive:Mp})]}),(ce==="direct"||ce==="channel"&&Vt)&&(An?h.jsx("input",{ref:ri,value:Ei,onChange:de=>Kr(de.target.value),onBlur:q,onKeyDown:de=>{de.key==="Enter"&&q(),de.key==="Escape"&&$o(!1)},className:"text-[11px] text-fg-tertiary bg-transparent border-b border-brand-500/50 outline-none py-0 px-0 w-full max-w-[400px] mt-0.5",placeholder:"Add description...",autoFocus:!0}):h.jsx("div",{className:"text-[11px] text-fg-tertiary truncate cursor-pointer hover:text-fg-secondary transition-colors mt-0.5",onClick:()=>{Kr(fe),$o(!0)},title:"Click to edit description",children:fe||"No description"}))]}):h.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[h.jsx("span",{className:"font-semibold text-sm truncate",children:vm}),ce==="dm"&&h.jsx("span",{className:"text-xs text-fg-tertiary",children:Hh?r("page.privateNotepad"):""})]}),h.jsxs("div",{"data-no-drag":!0,className:"ml-auto flex items-center gap-2 shrink-0",children:[h.jsx("button",{onClick:()=>{Do(!hn),hn||(In(""),jr([]))},className:`p-1.5 rounded-md transition-colors ${hn?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:r("page.searchMessages"),children:h.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})})}),ce==="channel"&&ci?.type==="custom"&&h.jsxs("button",{onClick:()=>fs(!No),className:`text-xs px-2.5 py-1 rounded-md border transition-colors flex items-center gap-1.5 ${No?"bg-brand-500/15 text-brand-500 border-brand-500/30":"text-fg-secondary hover:text-fg-primary border-border-default hover:bg-surface-elevated"}`,children:[h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),ci.members?.length??ci.memberCount??0]}),ce==="direct"&&It&&w==="chat"&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("button",{onClick:Vh,className:"text-xs text-brand-500 hover:text-brand-500 px-2.5 py-1 rounded-md hover:bg-brand-500/10 border border-brand-500/20 transition-colors flex items-center gap-1",children:r("page.newChatButton")}),h.jsx("button",{ref:ll,onClick:()=>cn(!ln),className:`p-1.5 rounded-md transition-colors ${ln?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:r("page.historyTitle"),children:h.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})})})]}),!b&&B&&h.jsx("button",{onClick:()=>B.toggleRightPanel(),className:`p-1.5 rounded-md transition-colors ${V?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,title:r("page.rightPanelToggle",{defaultValue:"Toggle side panel"}),children:h.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[h.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),h.jsx("path",{d:"M15 4v16"})]})})]})]}),E.length>1&&h.jsx("div",{className:"flex items-center gap-1 px-4 pb-1.5 overflow-x-auto scrollbar-hide",children:E.map(de=>h.jsxs("button",{onClick:()=>S(de),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors whitespace-nowrap flex items-center gap-1 ${w===de?"bg-brand-500/15 text-brand-500":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:[h.jsx("span",{children:yM(de)}),bM(de,r)]},de))})]})})(),hn&&h.jsxs("div",{className:"border-b border-border-default bg-surface-secondary/50 px-4 py-2 space-y-2 animate-in slide-in-from-top-2 duration-200",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("div",{className:"flex-1 relative",children:[h.jsx("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-tertiary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),h.jsx("input",{autoFocus:!0,value:Vp,onChange:P=>QS(P.target.value),onKeyDown:P=>{P.key==="Escape"&&(Do(!1),In(""),jr([]))},placeholder:r("page.searchPlaceholder"),className:"w-full pl-8 pr-3 py-1.5 text-xs bg-surface-primary border border-border-default rounded-lg outline-none focus:border-brand-500/50 transition-colors"})]}),h.jsx("button",{onClick:()=>{Do(!1),In(""),jr([])},className:"text-fg-tertiary hover:text-fg-secondary text-xs px-1",children:"✕"})]}),Fp&&h.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary py-1",children:[h.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[h.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),h.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r("page.searching")]}),!Fp&&Vp.length>=2&&Ah.length===0&&h.jsx("div",{className:"text-xs text-fg-tertiary py-1",children:r("page.noSearchResults")}),Ah.length>0&&h.jsx("div",{className:"max-h-60 overflow-y-auto space-y-0.5",children:Ah.map(P=>h.jsxs("button",{onClick:()=>$S(P),className:"w-full text-left px-3 py-2 rounded-lg hover:bg-surface-elevated transition-colors group",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-tertiary mb-0.5",children:[h.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${P.source==="channel"?"bg-blue-500/10 text-blue-500":"bg-emerald-500/10 text-emerald-500"}`,children:P.source==="channel"?"#":"1:1"}),P.senderName&&h.jsx("span",{children:P.senderName}),h.jsx("span",{children:new Date(P.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),h.jsx("div",{className:"text-xs text-fg-secondary line-clamp-2 group-hover:text-fg-primary transition-colors",children:P.text.length>200?P.text.slice(0,200)+"…":P.text})]},P.id))})]}),ce==="direct"&&ge&&w==="chat"&&Mo.length>1&&h.jsx("div",{className:"flex items-center gap-0 px-3 overflow-x-auto scrollbar-hide",children:Mo.map(P=>h.jsxs("div",{className:`group flex items-center gap-1.5 px-3 py-1.5 text-xs cursor-pointer rounded-md transition-colors shrink-0 max-w-[180px] ${P.id===it?"text-brand-500 bg-brand-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,onClick:()=>{if(P.id===St){Li(St);const E=Ve.current;Ri(E),Qs([])}else bl(P)},children:[P.isMain&&h.jsx("span",{className:"text-[10px] opacity-50 shrink-0",children:"●"}),h.jsx("span",{className:"truncate",children:P.id===St?r("page.newChat"):P.isMain?r("page.sessionMain"):P.title||r("page.sessionConversation")}),!P.isMain&&h.jsx("button",{onClick:E=>{E.stopPropagation(),TS(P.id)},className:"opacity-0 group-hover:opacity-100 text-fg-tertiary hover:text-fg-secondary transition-opacity shrink-0",children:"✕"})]},P.id))}),ce==="direct"&&w==="chat"&&(Mo.find(P=>P.id===it)??Ch.find(P=>P.id===it))?.metadata?.kind==="evolution"&&h.jsx("div",{className:"px-4 py-1.5 text-[11px] text-fg-tertiary border-b border-border-default bg-surface-secondary/40",children:r("page.messageActions.evolvedFrom")}),ce==="channel"&&ci?.type==="custom"&&No&&(()=>{const P=ci,E=P.members??[],R=[];for(const q of l)E.some(H=>H.id===q.id)||R.push({id:q.id,name:q.name,type:"agent",subtitle:q.role||"Agent"});for(const q of d)E.some(H=>H.id===q.id)||R.push({id:q.id,name:q.name,type:"human",subtitle:q.email||q.role||""});return h.jsxs("div",{className:"bg-surface-secondary/80 px-4 py-3 flex flex-col gap-2",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("span",{className:"text-xs font-semibold text-fg-secondary",children:[r("page.members")," (",E.length,")"]}),h.jsx("button",{onClick:()=>fs(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:E.map(q=>h.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-full text-[11px] font-medium ${q.type==="agent"?"bg-brand-500/10 text-brand-500":"bg-green-500/10 text-green-600"}`,children:[h.jsx(_s,{name:q.name,size:16,bgClass:q.type==="agent"?"bg-brand-500/15 text-brand-500":"bg-green-500/15 text-green-600"}),q.name,q.id!==e?.id&&h.jsx("button",{onClick:async()=>{try{await J.groupChats.removeMember(P.id,q.id),Lo(H=>H.map(fe=>fe.id===P.id?{...fe,members:(fe.members??[]).filter(me=>me.id!==q.id),memberCount:(fe.memberCount??1)-1}:fe))}catch{}},className:"ml-0.5 hover:text-red-500 transition-colors",title:r("common:remove"),children:h.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},q.id))}),R.length>0&&h.jsx("div",{className:"mt-1",children:h.jsxs("select",{className:"w-full bg-surface-primary border border-border-default rounded-lg px-2.5 py-1.5 text-xs text-fg-primary outline-none focus:ring-1 focus:ring-brand-500/50",value:"",onChange:async q=>{const H=q.target.value;if(!H)return;const fe=R.find(me=>me.id===H);if(fe)try{await J.groupChats.addMember(P.id,fe.id,fe.type,fe.name),Lo(me=>me.map(be=>be.id===P.id?{...be,members:[...be.members??[],{id:fe.id,name:fe.name,type:fe.type}],memberCount:(be.memberCount??0)+1}:be))}catch{}},children:[h.jsx("option",{value:"",children:r("page.addMemberPlaceholder")}),R.map(q=>h.jsxs("option",{value:q.id,children:["[",q.type==="agent"?"Agent":"Human","] ",q.name]},q.id))]})})]})})(),ce==="direct"&&ge&&ln&&h.jsxs("div",{ref:Eh,className:"absolute right-4 top-full mt-1 w-72 max-h-[420px] bg-surface-secondary border border-border-default rounded-xl shadow-2xl shadow-black/40 z-50 flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"px-4 py-3 border-b border-border-default flex items-center justify-between",children:[h.jsx("span",{className:"text-xs font-semibold text-fg-secondary uppercase tracking-wider",children:r("page.historyTitle")}),h.jsx("button",{onClick:()=>cn(!1),className:"text-fg-tertiary hover:text-fg-secondary text-xs",children:"✕"})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[Ch.length===0&&h.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6",children:r("page.noConversationsYet")}),(()=>{const P=new Date,E=new Date(P.getFullYear(),P.getMonth(),P.getDate()).getTime(),R=E-864e5,q=E-7*864e5,H=[],fe=[],me=[],be=[],te=[];for(const de of Ch){const st=new Date(de.lastMessageAt).getTime();st>=E?fe.push(de):st>=R?me.push(de):st>=q?be.push(de):te.push(de)}return fe.length>0&&H.push({label:r("page.dateToday"),items:fe}),me.length>0&&H.push({label:r("page.dateYesterday"),items:me}),be.length>0&&H.push({label:r("page.datePrevious7Days"),items:be}),te.length>0&&H.push({label:r("page.dateOlder"),items:te}),H.map(de=>h.jsxs("div",{className:"mb-2",children:[h.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider px-3 py-1.5",children:de.label}),de.items.map(st=>h.jsxs("button",{onClick:()=>{bl(st)},className:`w-full text-left px-3 py-2.5 rounded-lg text-xs mb-0.5 transition-colors ${st.id===it?"bg-brand-600/20 text-brand-500":"text-fg-secondary hover:bg-surface-elevated"}`,children:[h.jsxs("div",{className:"truncate font-medium flex items-center gap-1",children:[st.isMain&&h.jsx("span",{className:"text-[10px] text-brand-500 opacity-80",children:"●"}),st.isMain?r("page.sessionMain"):st.title||r("page.sessionConversation")]}),h.jsx("div",{className:"text-fg-tertiary text-[10px] mt-0.5",children:new Date(st.lastMessageAt).toLocaleString()})]},st.id))]},de.label))})()]})]})]}),b&&w==="profile"&&ce==="direct"&&ge&&h.jsx("div",{className:"flex-1 overflow-y-auto",children:h.jsx(Z0,{agentId:ge,onBack:()=>S("chat"),inline:!0,defaultTab:Ka,highlightMailboxId:To,onSwipeBack:()=>{cr(Q.current)?history.back():S("chat")},authUser:e})}),b&&w==="profile"&&ce==="channel"&&Vt&&h.jsx("div",{className:"flex-1 overflow-y-auto",onTouchStart:b?ni.onTouchStart:void 0,onTouchEnd:b?ni.onTouchEnd:void 0,children:h.jsx(cx,{teamId:Vt,onBack:()=>S("chat"),inline:!0,onSelectAgent:P=>{ut("direct"),is(P),S("chat")}})}),!b&&cr(w)&&ce==="direct"&&ge&&h.jsx("div",{className:"flex-1 overflow-y-auto",children:h.jsx(Z0,{agentId:ge,onBack:()=>S("chat"),inline:!0,headless:!0,activeTab:w,highlightMailboxId:To,authUser:e})}),!b&&cr(w)&&ce==="channel"&&Vt&&h.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:h.jsx(cx,{teamId:Vt,onBack:()=>S("chat"),inline:!0,headless:!0,activeTab:w,onSelectAgent:P=>{ut("direct"),is(P),S("chat")}})}),h.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col relative ${Fo?"justify-center":""} ${w!=="chat"?"hidden":""}`,children:[Dp&&os.length===0&&h.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[h.jsxs("svg",{className:"animate-spin h-6 w-6 text-brand-400",viewBox:"0 0 24 24",fill:"none",children:[h.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),h.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),h.jsx("span",{className:"text-xs text-fg-tertiary animate-pulse",children:r("page.loadingChat",{defaultValue:"Loading conversation…"})})]}),yh&&h.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 flex justify-center items-center gap-2 py-2 bg-gradient-to-b from-surface-primary/90 to-transparent pointer-events-none",children:[h.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 text-brand-400",viewBox:"0 0 24 24",fill:"none",children:[h.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),h.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),h.jsx("span",{className:"text-xs text-fg-tertiary",children:r("page.loadingEarlierMessages")})]}),h.jsxs("div",{ref:Wn,className:`${Fo?"hidden":"flex-1"} overflow-y-auto ${b?"p-2.5":`p-5 ${A}`}`,onScroll:xS,onTouchStart:b?ni.onTouchStart:void 0,onTouchEnd:b?ni.onTouchEnd:void 0,children:[os.length>0&&h.jsx("div",{style:{height:or.getTotalSize(),width:"100%",position:"relative"},children:or.getVirtualItems().map(P=>{const E=P.index,R=os[E],q=E>0?os[E-1]:null,H=Tm(R.rawCreatedAt),fe=q?Tm(q.rawCreatedAt):"",me=!!(H&&fe&&H!==fe),be=E===os.length-1,de=IS&&be&&Vs||!!R.isStreaming,st=BS&&be||de,Ue=ce==="channel"||!de||R.isStopped;return h.jsx("div",{"data-index":E,ref:or.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${P.start}px)`},children:h.jsxs("div",{className:"pb-3",children:[me&&h.jsxs("div",{className:"flex items-center gap-3 py-2 my-1",children:[h.jsx("div",{className:"flex-1 h-px bg-border-default"}),h.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider shrink-0",children:u_(R.rawCreatedAt,a)}),h.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),h.jsxs("div",{id:`msg-${R.id}`,className:"group/msg flex gap-3 transition-colors rounded-lg",children:[ce==="channel"?h.jsx("div",{className:"shrink-0 cursor-pointer",onClick:Xe=>{if(R.sender==="agent"&&R.agentId){const Qe=Xe.currentTarget.getBoundingClientRect();Ji({agentId:R.agentId,top:Qe.top,left:Qe.right+8})}},children:h.jsx(_s,{name:R.sender==="user"?Yh:R.agentName??r("page.fallbackAgent"),avatarUrl:R.sender==="user"?e?.avatarUrl:l.find(Xe=>Xe.id===R.agentId)?.avatarUrl,size:32,bgClass:R.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:R.sender==="agent"?"hover:ring-1 hover:ring-brand-500/40 rounded-lg":"rounded-lg"})}):h.jsx("div",{className:"shrink-0",children:h.jsx(_s,{name:R.sender==="user"?Yh:R.agentName??(ce==="direct"?It?.name??r("page.fallbackAgent"):r("page.fallbackAgent")),avatarUrl:R.sender==="user"?e?.avatarUrl:l.find(Xe=>Xe.id===(R.agentId??(ce==="direct"?It?.id:void 0)))?.avatarUrl,size:32,bgClass:R.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:"rounded-lg"})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-baseline gap-2",children:[h.jsx("span",{className:"text-sm font-medium text-fg-primary",children:R.sender==="user"?Yh:ce==="channel"?R.agentName??r("page.fallbackAgent"):h.jsx(f_,{name:R.agentName??(ce==="direct"?It?.name??r("page.fallbackAgent"):r("page.fallbackAgent")),agentId:R.agentId??(ce==="direct"?It?.id:void 0),agents:l,onViewProfile:Ts})}),h.jsx("span",{className:"text-xs text-fg-tertiary",title:R.rawCreatedAt?new Date(R.rawCreatedAt).toLocaleString():"",children:p_(R.time,R.rawCreatedAt,a)})]}),R.replyToId&&R.replyToSender&&h.jsxs("button",{onClick:()=>{const Xe=document.getElementById(`msg-${R.replyToId}`);Xe&&(Xe.scrollIntoView({behavior:"smooth",block:"center"}),Xe.classList.add("bg-brand-500/10"),setTimeout(()=>Xe.classList.remove("bg-brand-500/10"),1500))},className:"flex items-center gap-1.5 mt-0.5 mb-1 pl-2 py-0.5 border-l-2 border-brand-500/40 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors cursor-pointer",children:[h.jsx("span",{className:"font-medium text-brand-500",children:R.replyToSender}),h.jsx("span",{className:"truncate max-w-[250px]",children:R.replyToText??"..."})]}),h.jsxs("div",{className:`mt-0.5 ${R.sender==="agent"?"py-1":"bg-surface-secondary rounded-2xl px-3.5 py-2.5 w-fit max-w-full"} ${st&&R.sender==="agent"?"streaming-bubble":""}`,children:[R.sender==="user"?h.jsxs("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:[R.images&&R.images.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:R.images.map((Xe,Qe)=>h.jsx("img",{src:Xe,alt:"",className:"max-w-[200px] max-h-[150px] rounded-lg object-cover cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>Bp(Xe)},Qe))}),ce==="channel"?$m(R.text,l,(Xe,Qe)=>{const ct=Qe.currentTarget.getBoundingClientRect();Ji({agentId:Xe.id,top:ct.bottom,left:ct.left})}):R.text&&h.jsx("span",{className:"leading-relaxed",children:$m(R.text,l,(Xe,Qe)=>{const ct=Qe.currentTarget.getBoundingClientRect();Ji({agentId:Xe.id,top:ct.bottom,left:ct.left})})})]}):R.sender==="agent"&&ce==="channel"&&!(R.segments&&R.segments.length>0)?h.jsx(Qm,{resetKeys:[R.text],fallback:h.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-fg-secondary",children:R.text}),children:h.jsx(ma,{content:R.text,className:"text-sm text-fg-secondary",onMentionClick:vi,knownNames:Eo})}):h.jsx(Qm,{resetKeys:[R.id,R.text,R.segments?.length,de],fallback:h.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-fg-secondary",children:R.text}),children:h.jsx(m_,{msg:R,isStreaming:de,liveActivities:de?xh:[],onMentionClick:vi,knownNames:Eo})}),R.isNotification&&h.jsx(g_,{priority:R.notifyPriority})]}),Ue&&!t&&h.jsx("div",{className:`transition-opacity ${R.isStopped||R.isError||R.emptyReply||b?"opacity-100":"opacity-0 group-hover/msg:opacity-100"}`,children:h.jsx(O_,{msg:R,onCopy:_S,onRetry:wS,onResume:kS,onReply:CS,onRemember:ce==="direct"?qh:void 0,showRemember:ce==="direct",isCopied:yS===R.id,isLastAgentMsg:R.id===SS})})]})]})]})},R.id)})}),ce==="channel"&&Nn.length>0&&h.jsx("div",{className:"flex flex-col gap-1.5 py-2",children:Nn.map(P=>h.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-1.5 rounded-lg cursor-pointer hover:bg-surface-elevated/60 transition-colors group/think",onClick:()=>{ut("direct"),is(P.id),S("chat")},children:[h.jsxs("div",{className:"relative shrink-0",children:[h.jsx(_s,{name:P.name,avatarUrl:P.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),h.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-blue-500 animate-pulse ring-2 ring-surface-primary"})]}),h.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[h.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:P.name}),h.jsxs("span",{className:"flex items-center gap-0.5",children:[h.jsx("span",{className:"w-1 h-1 rounded-full bg-blue-400 animate-bounce"}),h.jsx("span",{className:"w-1 h-1 rounded-full bg-blue-400 animate-bounce",style:{animationDelay:"0.15s"}}),h.jsx("span",{className:"w-1 h-1 rounded-full bg-blue-400 animate-bounce",style:{animationDelay:"0.3s"}})]}),h.jsx("span",{className:"text-xs text-fg-tertiary",children:r("page.agentThinking")})]}),h.jsx("span",{className:"ml-auto text-[10px] text-fg-tertiary opacity-0 group-hover/think:opacity-100 transition-opacity",children:"→"})]},P.id))}),h.jsx("div",{ref:dS})]}),gS&&w==="chat"&&h.jsx("div",{className:`absolute ${b?"bottom-4":"bottom-28"} inset-x-0 z-10 pointer-events-none ${b?"px-3":`px-5 ${A}`}`,children:h.jsx("div",{className:`${b?"":"max-w-3xl mx-auto"} flex justify-center`,children:h.jsxs("button",{onClick:()=>{nr(),Zn("smooth"),rr(!1),Er.current=0,dn(0)},className:"pointer-events-auto flex items-center gap-1.5 px-3.5 py-2 bg-surface-secondary/95 backdrop-blur-sm border border-border-default rounded-full shadow-lg hover:bg-surface-elevated transition-colors text-xs text-fg-secondary",children:[h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("polyline",{points:"6 9 12 15 18 9"})}),sm>0?r("page.newMessages",{count:sm}):r("page.scrollToBottom")]})})}),Hr&&(()=>{const P=l.find(E=>E.id===Hr.agentId);return P?h.jsx(x_,{agent:P,anchorRect:{top:Hr.top,left:Hr.left},onClose:()=>Ji(null),onViewProfile:Ts}):null})(),Fo&&bm&&h.jsx("div",{className:"text-center mb-4",children:h.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:bm})}),ce==="direct"&&(Wp.length>0||al.length>0)&&h.jsx("div",{className:`${b?"px-3":"px-5"} pb-1 shrink-0 ${Fo?"":A}`,children:h.jsxs("div",{className:`${b?"":"max-w-3xl mx-auto"} flex flex-col gap-1.5`,children:[Wp.map(P=>h.jsxs("button",{onClick:()=>Th(P),className:"w-full text-left px-3.5 py-2.5 rounded-xl border border-amber-500/40 bg-amber-500/10 hover:bg-amber-500/15 transition-colors flex items-center gap-3",children:[h.jsx("span",{className:"w-8 h-8 rounded-lg bg-amber-500/20 text-amber-500 flex items-center justify-center shrink-0",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),h.jsx("path",{d:"M12 8v4"}),h.jsx("path",{d:"M12 16h.01"})]})}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:"block text-sm font-medium text-fg-primary truncate",children:P.title}),h.jsx("span",{className:"block text-xs text-fg-tertiary truncate",children:r("page.userInputPrompt",{count:P.questions?.length??1,defaultValue:`${P.questions?.length??1} question(s) awaiting your response`})})]}),h.jsxs("span",{className:"text-xs font-medium text-amber-500 shrink-0 inline-flex items-center gap-1",children:[r("page.userInputRespond",{defaultValue:"Respond"}),h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M9 18l6-6-6-6"})})]})]},P.id)),al.map(P=>{const E=P.priority==="high"||P.priority==="urgent";return h.jsxs("button",{onClick:()=>$h(P),className:`w-full text-left px-3.5 py-2.5 rounded-xl border transition-colors flex items-center gap-3 ${E?"border-amber-500/40 bg-amber-500/10 hover:bg-amber-500/15":"border-blue-500/40 bg-blue-500/10 hover:bg-blue-500/15"}`,children:[h.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${E?"bg-amber-500/20 text-amber-500":"bg-blue-500/20 text-blue-500"}`,children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),h.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:"block text-sm font-medium text-fg-primary truncate",children:P.title}),h.jsx("span",{className:"block text-xs text-fg-tertiary truncate",children:P.body?.replace(/\s+/g," ").trim()||r("page.notifyUserPrompt",{defaultValue:"Agent notification awaiting your attention"})})]}),h.jsxs("span",{className:`text-xs font-medium shrink-0 inline-flex items-center gap-1 ${E?"text-amber-500":"text-blue-500"}`,children:[r("page.notifyUserView",{defaultValue:"View"}),h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h.jsx("path",{d:"M9 18l6-6-6-6"})})]})]},P.id)})]})}),Ao&&h.jsx(v_,{approval:Ao,submitting:eS===Ao.id,readOnly:Ao.status!=="pending",onClose:()=>Th(null),onSubmit:P=>XS(Ao.id,P)}),Dn&&h.jsx(D_,{notification:Dn,agentName:It?.name,acknowledging:tS===Dn.id,onClose:()=>$h(null),onAcknowledge:()=>qS(Dn.id)}),vl&&h.jsx(Wa,{variant:"primary",title:r("page.retry",{defaultValue:"Retry"}),message:vl.followCount===1?r("page.retryConfirmSingular"):r("page.retryConfirmPlural",{count:vl.followCount}),confirmLabel:r("common:confirm"),onConfirm:()=>{const P=vl;zh(null),Zh(P.retryMsg,P.userMsg,P.retryText)},onCancel:()=>zh(null)}),pn&&h.jsx(b_,{busy:am,onConfirm:P=>{PS(P)},onCancel:()=>{am||qh(null)}}),h.jsx("div",{"data-keep-edit-focus":!0,className:`${b?"px-3 py-2":"px-5 py-3"} relative shrink-0 ${Fo?"":A}`,onDrop:NS,onDragOver:DS,children:h.jsxs("div",{className:`bg-surface-primary border border-border-default shadow-lg shadow-black/10 ${b?`${hi?"rounded-2xl p-2":"rounded-2xl p-3"}`:`${hi?"rounded-2xl p-2":"rounded-2xl p-3"} max-w-3xl mx-auto`}`,children:[Gp&&On.length>0&&h.jsxs("div",{className:"absolute bottom-full left-4 mb-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden z-10 max-h-64 max-w-xs w-72 overflow-y-auto",children:[h.jsx("div",{className:"px-3 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:r("page.mentionAgent")}),On.map((P,E)=>P.kind==="agent"?h.jsxs("button",{ref:R=>{E===Bo&&R&&R.scrollIntoView({block:"nearest"})},onClick:()=>yl(P.agent.name),onMouseEnter:()=>Bn(E),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${E===Bo?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[h.jsx(_s,{name:P.agent.name,avatarUrl:P.agent.avatarUrl,size:24,bgClass:"bg-brand-500/20 text-brand-500"}),h.jsx("span",{className:"flex-1 min-w-0 truncate",children:P.agent.name}),h.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:P.agent.role})]},`agt-${P.agent.id}`):h.jsxs("button",{ref:R=>{E===Bo&&R&&R.scrollIntoView({block:"nearest"})},onClick:()=>yl(P.entity.name,P.entity.entityType,P.entity.id),onMouseEnter:()=>Bn(E),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${E===Bo?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[h.jsx("span",{className:"w-6 h-6 flex items-center justify-center text-sm shrink-0",children:WS[P.entity.entityType]??"📄"}),h.jsx("span",{className:"flex-1 min-w-0 truncate",children:P.entity.name}),h.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:P.entity.role})]},`${P.entity.entityType}-${P.entity.id}`))]}),us.length>0&&h.jsx("div",{className:"flex items-center gap-1.5 mb-2 flex-wrap",children:us.map(P=>h.jsxs("span",{className:"inline-flex items-center gap-1 max-w-[240px] pl-2 pr-1 py-1 rounded-lg bg-brand-500/10 text-brand-500 text-xs border border-brand-500/20",title:P.content,children:[h.jsx("span",{className:"truncate",children:P.label}),h.jsx("button",{onClick:()=>Ai(E=>E.filter(R=>R.id!==P.id)),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-brand-500/20 shrink-0","aria-label":r("common:remove",{defaultValue:"Remove"}),children:h.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},P.id))}),Fs.length>0&&h.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[Fs.map(P=>h.jsxs("div",{className:"relative group/img shrink-0",children:[Fh(P)?h.jsx("img",{src:P.dataUrl,alt:P.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}):h.jsxs("div",{className:"w-16 h-16 rounded-lg border border-border-default bg-surface-elevated flex flex-col items-center justify-center gap-0.5",title:P.name,children:[h.jsx("span",{className:"text-xl leading-none",children:AS(P.name,P.dataUrl)}),h.jsx("span",{className:"text-[9px] text-fg-tertiary truncate max-w-[56px] px-0.5",children:P.name.split(".").pop()?.toUpperCase()})]}),h.jsx("button",{onClick:()=>MS(P.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-xs opacity-0 group-hover/img:opacity-100 transition-opacity",children:"×"})]},P.id)),Fs.length<um&&h.jsx("button",{onClick:()=>_h.current?.click(),className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:r("page.addMoreFiles"),children:h.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),Fs.length>0&&Fs.some(P=>Fh(P))&&It&&It.modelSupportsVision===!1&&h.jsxs("div",{className:"text-[10px] text-amber-500/80 mb-1.5 flex items-center gap-1",children:[h.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M12 9v4m0 4h.01M12 2L2 22h20L12 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),r("page.visionWarning")]}),h.jsx("input",{ref:_h,type:"file",accept:"image/*,.pdf,.docx,.xlsx,.pptx,.xls,.doc,.csv,.json,.xml,.html,.epub",multiple:!0,className:"hidden",onChange:P=>{P.target.files&&zo(P.target.files),P.target.value=""}}),Ls&&h.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[h.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[h.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:Ls.sender}),h.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:Ls.text})]}),h.jsx("button",{onClick:()=>Zt(null),className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),h.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h.jsxs("div",{className:Jh?"flex flex-col gap-2 min-w-0":"flex gap-2 items-end min-w-0",children:[h.jsxs("div",{className:Jh?"flex gap-2 items-end min-w-0":"contents",children:[h.jsx("button",{onClick:()=>_h.current?.click(),disabled:ce==="direct"&&(!ge||Vo),className:`${hi?"p-1.5":"px-2.5 py-2.5"} text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated shrink-0 self-end mb-0.5`,title:r("page.attachFilesTitle"),children:h.jsx("svg",{className:hi?"w-[18px] h-[18px]":"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:h.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48",strokeLinecap:"round",strokeLinejoin:"round"})})}),h.jsx("textarea",{ref:sr,value:Dt,onChange:P=>{jS(P.target.value),Ro()},onKeyDown:P=>{if(Gp&&On.length>0){const E=P.key==="ArrowUp"||P.ctrlKey&&P.key==="p",R=P.key==="ArrowDown"||P.ctrlKey&&P.key==="n",q=P.key==="Enter"||P.key==="Tab",H=P.key==="Escape";if(E){P.preventDefault(),Bn(fe=>(fe-1+On.length)%On.length);return}if(R){P.preventDefault(),Bn(fe=>(fe+1)%On.length);return}if(q){P.preventDefault();const fe=On[Bo];fe&&(fe.kind==="agent"?yl(fe.agent.name):yl(fe.entity.name,fe.entity.entityType,fe.entity.id));return}if(H){P.preventDefault(),Io(!1);return}}if(P.key==="Escape"){P.preventDefault(),P.currentTarget.blur();return}P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),mn())},onPaste:LS,placeholder:ZS,disabled:ce==="direct"&&(!ge||Vo),rows:hi?1:2,className:`flex-1 min-w-0 w-full bg-transparent rounded-xl text-sm outline-none disabled:opacity-40 transition-colors resize-none overflow-y-auto leading-relaxed placeholder:text-fg-secondary ${hi?"px-2 py-1.5":"px-4 py-3"}`,style:{minHeight:hi?"36px":"52px",maxHeight:hi?"160px":"120px"}})]}),h.jsxs("div",{className:`flex items-center gap-1.5 shrink-0 ${Jh?"justify-end":""}`,children:[ce==="direct"&&h.jsx(mM,{value:rl,disabled:!ge||Vo,onSelect:(P,E)=>{nl(P);const R=it&&it!==St?it:null;gM(R,P,E).catch(()=>{}),R&&an(q=>q.map(H=>H.id===R?{...H,metadata:{...H.metadata??{},modelOverride:P}}:H))}}),Vs&&ce!=="dm"?h.jsx("button",{onClick:bS,className:`${hi?"w-8 h-8 rounded-full flex items-center justify-center":"px-3 py-2.5 rounded-xl"} bg-red-600 hover:bg-red-500 text-white text-sm transition-colors`,title:r("page.stopAgent"),children:h.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}):h.jsx("button",{onClick:()=>{mn()},disabled:ce==="direct"&&(!ge||Vo)||!Dt.trim()&&Fs.length===0,className:hi?"w-8 h-8 rounded-full flex items-center justify-center bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors":"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",title:r("common:send"),children:hi?h.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:h.jsx("path",{d:"M12 19V5M5 12l7-7 7 7",strokeLinecap:"round",strokeLinejoin:"round"})}):r("common:send")})]})]})]})})]})]}),!b&&V&&z&&h.jsx(YA,{payload:V,onClose:z,width:T?X:xt,onResizeStart:gh,onAddToChat:We,tabs:Z,activeTabId:se,onSelectTab:B?.setActiveRightPanelTab,onCloseTab:B?.closeRightPanelTab,onNewTab:()=>{if(!U)return;if(B?.rightPanelMode==="terminal"){const E=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;U({kind:"terminal",terminalId:E,title:"Terminal"});return}const P=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;U({kind:"url",url:"about:blank",title:"New Tab",browserId:P})},fullscreen:T,onToggleFullscreen:B?.toggleRightPanelFullscreen,onBrowserMeta:B?.updateRightPanelBrowserTab?(P,E)=>B.updateRightPanelBrowserTab(P,E):void 0,panelMode:B?.rightPanelMode??"browser",onPanelModeChange:P=>B?.switchRightPanelMode(P),onTerminalMeta:B?.updateRightPanelTerminalTab?(P,E)=>B.updateRightPanelTerminalTab(P,E):void 0,onOpenUrlFromTerminal:P=>{if(!U)return;const E=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;U({kind:"url",url:P,title:P,browserId:E})},onOpenPathFromTerminal:P=>{U?.({kind:"file",path:P,title:P.split(/[/\\]/).pop()||P})}}),Ip&&h.jsx(y_,{src:Ip,onClose:()=>Bp(null)})]})}function ux({agent:s,tasks:e,onViewProfile:t,streamActive:i}){const{t:r}=Pt(["team","common"]),[n,a]=C.useState(!1),o=C.useRef(null),l=C.useRef(null),c=s.status==="working"||!!i,d=s.status==="error",u=c?e.find(m=>m.assignedAgentId===s.id&&m.status==="in_progress"):null,f=s.currentActivity;C.useEffect(()=>{d&&s.lastError&&Jl(s.lastError)&&ec()},[d,s.lastError]),C.useEffect(()=>{if(!n)return;const m=O=>{o.current&&!o.current.contains(O.target)&&a(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n]),C.useLayoutEffect(()=>{if(!n||!l.current)return;const m=l.current,O=m.getBoundingClientRect(),p=window.innerWidth;O.right>p-8&&(m.style.left="auto",m.style.right="0"),O.left<8&&(m.style.left="0",m.style.right="auto");const x=p-16;O.width>x&&(m.style.width=`${x}px`)},[n]);const g=d?"bg-red-400 animate-pulse":c?"bg-blue-400 animate-pulse":"bg-green-400",b=r(d?"common:status.error":c?"common:status.working":"common:status.idle"),v=f?f.type==="heartbeat"?r("page.activityHeartbeat",{name:f.heartbeatName??f.label}):f.type==="chat"?f.label:f.type==="task"?r("page.activityTask",{label:f.label}):f.label:r("page.processing");return h.jsxs("div",{className:"relative",ref:o,children:[h.jsxs("button",{onClick:()=>a(m=>!m),className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${c?"bg-blue-500/10 border border-blue-500/20 hover:bg-blue-500/20":d?"bg-red-500/10 border border-red-500/20 hover:bg-red-500/20":"bg-green-500/10 border border-green-500/20 hover:bg-green-500/20"}`,children:[h.jsx("span",{className:`w-2 h-2 rounded-full ${g}`}),h.jsx("span",{className:`text-xs ${d?"text-red-500":c?"text-blue-500":"text-green-600"}`,children:b}),s.mailboxDepth!=null&&s.mailboxDepth>0&&h.jsx("span",{className:"text-[9px] bg-fg-tertiary/20 text-fg-tertiary rounded-full px-1.5",children:s.mailboxDepth})]}),n&&d&&h.jsxs("div",{ref:l,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-red-500/30 rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[h.jsx("p",{className:"text-[10px] text-red-500 uppercase font-semibold",children:r("page.errorDetails")}),h.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-2.5",children:[h.jsx("pre",{className:"text-[10px] text-red-500/80 leading-relaxed whitespace-pre-wrap break-all font-mono line-clamp-6",children:Oc(s.lastError,r)||s.lastError||r("page.agentErrorFallback")}),s.lastErrorAt&&h.jsx("div",{className:"text-[9px] text-red-500/50 mt-1.5 border-t border-red-500/10 pt-1",children:new Date(s.lastErrorAt).toLocaleString()})]}),h.jsx("button",{onClick:()=>{a(!1),t?.(s.id)},className:"w-full text-center text-[10px] text-red-500 hover:text-red-500 border border-red-500/30 hover:border-red-500/50 rounded-lg py-1 transition-colors",children:r("page.viewAgentProfileArrow")})]}),n&&c&&h.jsxs("div",{ref:l,className:"absolute top-full left-0 mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-30 w-80 max-w-[calc(100vw-1rem)] p-3 space-y-2",children:[h.jsx("p",{className:"text-[10px] text-fg-tertiary uppercase font-semibold",children:r("page.currentActivity")}),u?h.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-brand-500/10 border border-brand-500/30 cursor-pointer hover:bg-brand-500/10 transition-colors",onClick:()=>{a(!1),Or.navigate(Ht.WORK,{openTask:u.id})},children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-400 animate-pulse shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-xs text-brand-500 truncate",children:u.title}),h.jsx("div",{className:"text-[10px] text-fg-tertiary",children:r("page.workingOnTaskHint")})]}),h.jsx("span",{className:"text-[10px] text-fg-tertiary",children:"→"})]}):h.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-surface-elevated/50",children:[h.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${f?.type==="heartbeat"||f?.type==="chat","bg-blue-400 animate-pulse"}`}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-xs text-fg-secondary",children:v}),h.jsx("div",{className:"text-[10px] text-fg-tertiary",children:f?.type==="heartbeat"?r("page.activityDescHeartbeat"):f?.type==="chat"?r("page.activityDescChat"):r("page.activityDescFallback")})]})]}),h.jsx("button",{onClick:()=>{a(!1),t?.(s.id,{tab:"overview"})},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1.5 transition-colors",children:r("page.viewMindArrow")})]})]})}export{NM as TeamPage};
|