1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-hc4XHDSJ.js","assets/index-De2MrmCP.js","assets/index-BQ7Snm_6.js","assets/CreditContext-Bonqshly.js","assets/jsx-runtime-CAOzMBF_.js","assets/KeycloakProvider-DigRWCYO.js","assets/KeycloakProvider-DhvGObjL.css","assets/index-CRMP0OmD.js","assets/Footer-DCWQBxYR.js","assets/components-BUbx0Fcg.js","assets/stripe-CYOYbF8H.js","assets/Footer-CILxjN2f.css","assets/ChatContext-C2vMbLCy.js","assets/index-DlZHNr6H.js","assets/index-BOF-_YYA.js","assets/index-Cc4AK8HP.js","assets/index-VAyR_Yvo.js","assets/index-BfxWlnhC.js","assets/index-DA2-whxV.js","assets/index-D63OCojq.js"])))=>i.map(i=>d[i]); 2import{r as A,j as m,R as ke,a as _a,c as fs,g as En,b as zC}from"./jsx-runtime-CAOzMBF_.js";import{u as Ve,p as qt,t as Rc,l as dr,a as at,c as yo,d as Rx,C as Vs,e as WC}from"./CreditContext-Bonqshly.js";import{P as UC,Q as ue,R as VC,S as fg,T as KC,U as qC,V as GC,W as XC,X as YC,Y as ZC,Z as JC,$ as Mx,a0 as QC,a1 as e2,a2 as t2,a3 as r2,a4 as i2,a5 as s2,a6 as n2,a7 as o2,a8 as a2,a9 as l2,aa as Mc,ab as c2,ac as h2,ad as u2,ae as d2,af as pg,ag as f2,ah as kl,ai as p2,aj as Dx,ak as bu,al as xu,am as m2,an as g2,ao as v2,ap as b2,aq as x2,ar as _2,as as ya,at as Px,au as y2,av as w2,aw as Lx,ax as Zt,ay as yh,az as xp,aA as _p,c as ce,m as Ae,aB as Ss,aC as S2,aD as Nx,aE as yp,aF as Ox,aG as An,aH as Ix,aI as k2,aJ as C2,aK as fr,aL as wp,aM as jx,aN as E2,aO as A2,aP as T2,aQ as R2,aR as M2,aS as D2,aT as P2,aU as L2,aV as N2,aW as O2,aX as I2,aY as j2,aZ as B2,a_ as F2,a$ as $2,b0 as H2,b1 as Io,d as he,b2 as Sp,b3 as kp,b4 as Ui,b5 as Cp,b6 as Ep,b7 as z2,b8 as un,b9 as jt,ba as Bx,bb as mg,bc as wh,bd as _s,be as W2,bf as U2,bg as V2,bh as K2,bi as Kn,bj as Fx,B as wa,e as Ut,bk as Ks,bl as sn,bm as nn,bn as on,bo as Sa,bp as Ap,bq as gg,br as q2,bs as G2,bt as X2,bu as $x,bv as Y2,bw as Hx,bx as zx,by as Z2,bz as J2,bA as Q2,bB as eE,bC as tE,bD as rE,bE as iE,bF as sE,bG as nE,bH as Dc,bI as Nd,bJ as oE,bK as aE,bL as lE,bM as vg,bN as Pi,bO as cE,bP as hE,K as Wx,L as Ux,bQ as uc,O as Vx,bR as uE,bS as _u,bT as dE,bU as fE,bV as Ht,bW as Se,J as Kx,bX as Sh,bY as qx,bZ as os,M as pE,A as mE,b_ as gE,b$ as Gx,N as vE,c0 as bg,c1 as bE,I as xE,c2 as _E,c3 as yE,c4 as wE,c5 as Xx,c6 as SE,c7 as Cl,c8 as xg,c9 as On,ca as jo,cb as kE,cc as CE,cd as EE,ce as AE,cf as _g}from"./Footer-DCWQBxYR.js";import{c as Xi,r as wo,u as yi,L as TE}from"./KeycloakProvider-DigRWCYO.js";import{r as Pc,q as RE,w as ME,b as DE}from"./components-BUbx0Fcg.js";import{C as PE}from"./ChatContext-C2vMbLCy.js";import{b as LE}from"./stripe-CYOYbF8H.js";const El="<exkaliburArtifact",yg="</exkaliburArtifact>",NE="<exkaliburAction",wg="</exkaliburAction>",In=Xi("MessageParser");function Sg(r){const e=/^\s*```\w*\n([\s\S]*?)\n\s*```\s*$/,t=r.match(e);return t?t[1]:r}function kg(r){return r.replace(/</g,"<").replace(/>/g,">")}class OE{constructor(e={}){this._options=e}#e=new Map;parse(e,t){let i=this.#e.get(e);i||(i={position:0,insideAction:!1,insideArtifact:!1,currentAction:{content:""},actionId:0},this.#e.set(e,i));let s="",n=i.position,a=!1;for(;n<t.length;){if(i.insideArtifact){const o=i.currentArtifact;if(o===void 0&&UC("Artifact not initialized"),i.insideAction){const l=t.indexOf(wg,n),c=i.currentAction;if(l!==-1){c.content+=t.slice(n,l);let h=c.content.trim();"type"in c&&c.type==="file"&&(c.filePath.endsWith(".md")||(h=Sg(h),h=kg(h)),h+=` 3`),c.content=h,this._options.callbacks?.onActionClose?.({artifactId:o.id,messageId:e,actionId:String(i.actionId-1),action:c}),i.insideAction=!1,i.currentAction={content:""},n=l+wg.length}else{if("type"in c&&c.type==="file"){let h=t.slice(n);c.filePath.endsWith(".md")||(h=Sg(h),h=kg(h)),this._options.callbacks?.onActionStream?.({artifactId:o.id,messageId:e,actionId:String(i.actionId-1),action:{...c,content:h,filePath:c.filePath}})}break}}else{const l=t.indexOf(NE,n),c=t.indexOf(yg,n);if(l!==-1&&(c===-1||l<c)){const h=t.indexOf(">",l);if(h!==-1)i.insideAction=!0,i.currentAction=this.#r(t,l,h),this._options.callbacks?.onActionOpen?.({artifactId:o.id,messageId:e,actionId:String(i.actionId++),action:i.currentAction}),n=h+1;else break}else if(c!==-1)this._options.callbacks?.onArtifactClose?.({messageId:e,...o}),i.insideArtifact=!1,i.currentArtifact=void 0,n=c+yg.length;else break}}
3else if(t[n]==="<"&&t[n+1]!=="/"){let o=n,l="";for(;o<t.length&&l.length<El.length;){if(l+=t[o],l===El){const c=t[o+1];if(c&&c!==">"&&c!==" "){s+=t.slice(n,o+1),n=o+1;break}const h=t.indexOf(">",o);if(h!==-1){const u=t.slice(n,h+1),d=this.#t(u,"title"),f=this.#t(u,"type"),_=this.#t(u,"id");d||In.warn("Artifact title missing"),_||In.warn("Artifact id missing"),i.insideArtifact=!0;const b={id:_,title:d,type:f};i.currentArtifact=b,this._options.callbacks?.onArtifactOpen?.({messageId:e,...b});const p=this._options.artifactElement??IE;s+=p({messageId:e}),n=h+1}else a=!0;break}else if(!El.startsWith(l)){s+=t.slice(n,o+1),n=o+1;break}o++}if(o===t.length&&El.startsWith(l))break}else s+=t[n],n++;if(a)break}return i.position=n,s}reset(){this.#e.clear()}#r(e,t,i){const s=e.slice(t,i+1),n=this.#t(s,"type"),a={type:n,content:""};if(n==="supabase"){const o=this.#t(s,"operation");if(!o||!["migration","query"].includes(o))throw In.warn(`Invalid or missing operation for Supabase action: ${o}`),new Error(`Invalid Supabase operation: ${o}`);if(a.operation=o,o==="migration"){const l=this.#t(s,"filePath");if(!l)throw In.warn("Migration requires a filePath"),new Error("Migration requires a filePath");a.filePath=l}}else if(n==="file"){const o=this.#t(s,"filePath");o||In.debug("File path not specified"),a.filePath=o}else["shell","start"].includes(n)||In.warn(`Unknown action type '${n}'`);return a}#t(e,t){const i=e.match(new RegExp(`${t}="([^"]*)"`,"i"));return i?i[1]:void 0}}const IE=r=>`<div ${['class="__exkaliburArtifact__"',...Object.entries(r).map(([t,i])=>`data-${jE(t)}=${JSON.stringify(i)}`)].join(" ")}></div>`;function jE(r){return r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}const Bo=Xi("useMessageParser"),BE=new OE({callbacks:{onArtifactOpen:r=>{Bo.trace("onArtifactOpen",r),ue.showWorkbench.set(!0),ue.addArtifact(r)},onArtifactClose:r=>{Bo.trace("onArtifactClose"),ue.updateArtifact(r,{closed:!0})},onActionOpen:r=>{Bo.trace("onActionOpen",r.action),r.action.type==="file"&&ue.addAction(r)},onActionClose:r=>{Bo.trace("onActionClose",r.action),r.action.type!=="file"&&ue.addAction(r),ue.runAction(r)},onActionStream:r=>{Bo.trace("onActionStream",r.action),ue.runAction(r,!0)}}}),FE=r=>Array.isArray(r.content)?r.content.find(e=>e.type==="text")?.text||"":r.content;function $E(){const[r,e]=A.useState({}),t=A.useCallback((i,s)=>{for(const[n,a]of i.entries())if(a.role==="assistant"||a.role==="user"){const o=BE.parse(a.id,FE(a));e(l=>({...l,[n]:(l[n]||"")+o}))}},[]);return{parsedMessages:r,parseMessages:t}}const Cg=Xi("usePromptEnhancement");function HE(){const[r,e]=A.useState(!1),[t,i]=A.useState(!1);return{enhancingPrompt:r,promptEnhanced:t,enhancePrompt:async(a,o,l,c,h)=>{e(!0),i(!1);const u={message:a,model:l,provider:c};h&&(u.apiKeys=h);const f=(await fetch("/api/enhancer",{method:"POST",body:JSON.stringify(u)})).body?.getReader(),_=a;if(f){const b=new TextDecoder;let p="",g;try{for(o("");;){const{value:v,done:x}=await f.read();if(x)break;p+=b.decode(v),Cg.trace("Set input",p),o(p)}}catch(v){g=v,o(_)}finally{g&&Cg.error(g),e(!1),i(!0),setTimeout(()=>{o(p)})}}},resetEnhancer:()=>{e(!1),i(!1)}}}const zE=["input","textarea"];class WE{#e=new EventTarget;dispatch(e){this.#e.dispatchEvent(new Event(e))}on(e,t){return this.#e.addEventListener(e,t),()=>{this.#e.removeEventListener(e,t)}}}const Yx=new WE;function UE(){const r=Ve(VC);A.useEffect(()=>{const e=t=>{if(!(document.activeElement&&zE.includes(document.activeElement.tagName.toLowerCase())&&!t.altKey&&!t.metaKey&&!t.ctrlKey))for(const[i,s]of Object.entries(r)){const n=s.key.toLowerCase()===t.key.toLowerCase()||`Key${s.key.toUpperCase()}`===t.code,o=(s.ctrlOrMetaKey?fg&&t.metaKey||!fg&&t.ctrlKey:!0)&&(s.ctrlKey===void 0||s.ctrlKey===t.ctrlKey)&&(s.metaKey===void 0||s.metaKey===t.metaKey)&&(s.shiftKey===void 0||s.shiftKey===t.shiftKey)&&(s.altKey===void 0||s.altKey===t.altKey);if(n&&o){s.isPreventDefault&&(t.preventDefault(),t.stopPropagation()),Yx.dispatch(i),s.action();break}}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[r])}const VE={damping:.7,stiffness:.05,mass:1.25},KE=70,qE=1e3/60,GE=350;let kh=!1;globalThis.document?.addEventListener("mousedown",()=>{kh=!0});globalThis.document?.addEventListener("mouseup",()=>{kh=!1});globalThis.document?.addEventListener("click",()=>{kh=!1});const XE=(r={})=>{const[e,t]=A.useState(!1),[i,s]=A.useState(r.initial!==!1),[n,a]=A.useState(!1),o=A.useRef(null);o.current=r;const l=A.useCallback(()=>
vendor: 4,061 bytes, line 3
3{if(!kh)return!1;const v=window.getSelection();if(!v||!v.rangeCount)return!1;const x=v.getRangeAt(0);return x.commonAncestorContainer.contains(p.current)||p.current?.contains(x.commonAncestorContainer)},[]),c=A.useCallback(v=>{u.isAtBottom=v,s(v)},[]),h=A.useCallback(v=>{u.escapedFromLock=v,t(v)},[]),u=A.useMemo(()=>{let v;return{escapedFromLock:e,isAtBottom:i,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return p.current?.scrollTop??0},set scrollTop(x){p.current&&(p.current.scrollTop=x,u.ignoreScrollToTop=p.current.scrollTop)},get targetScrollTop(){return!p.current||!g.current?0:p.current.scrollHeight-1-p.current.clientHeight},get calculatedTargetScrollTop(){if(!p.current||!g.current)return 0;const{targetScrollTop:x}=this;if(!r.targetScrollTop)return x;if(v?.targetScrollTop===x)return v.calculatedScrollTop;const w=Math.max(Math.min(r.targetScrollTop(x,{scrollElement:p.current,contentElement:g.current}),x),0);return v={targetScrollTop:x,calculatedScrollTop:w},requestAnimationFrame(()=>{v=void 0}),w},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=KE}}},[]),d=A.useCallback((v={})=>{typeof v=="string"&&(v={animation:v}),v.preserveScrollPosition||c(!0);const x=Date.now()+(Number(v.wait)||0),w=wu(o.current,v.animation),{ignoreEscapes:S=!1}=v;let k,C=u.calculatedTargetScrollTop;v.duration instanceof Promise?v.duration.finally(()=>{k=Date.now()}):k=x+(v.duration??0);const y=async()=>{const E=new Promise(requestAnimationFrame).then(()=>{if(!u.isAtBottom)return u.animation=void 0,!1;const{scrollTop:D}=u,T=performance.now(),M=(T-(u.lastTick??T))/qE;if(u.animation||={behavior:w,promise:E,ignoreEscapes:S},u.animation.behavior===w&&(u.lastTick=T),l()||x>Date.now())return y();if(D<Math.min(C,u.calculatedTargetScrollTop)){if(u.animation?.behavior===w){if(w==="instant")return u.scrollTop=u.calculatedTargetScrollTop,y();u.velocity=(w.damping*u.velocity+w.stiffness*u.scrollDifference)/w.mass,u.accumulated+=u.velocity*M,u.scrollTop+=u.accumulated,u.scrollTop!==D&&(u.accumulated=0)}return y()}return k>Date.now()?(C=u.calculatedTargetScrollTop,y()):(u.animation=void 0,u.scrollTop<u.calculatedTargetScrollTop?d({animation:wu(o.current,o.current.resize),ignoreEscapes:S,duration:Math.max(0,k-Date.now())||void 0}):u.isAtBottom)});return E.then(D=>(requestAnimationFrame(()=>{u.animation||(u.lastTick=void 0,u.velocity=0)}),D))};return v.wait!==!0&&(u.animation=void 0),u.animation?.behavior===w?u.animation.promise:y()},[c,l,u]),f=A.useCallback(()=>{h(!0),c(!1)},[h,c]),_=A.useCallback(({target:v})=>{if(v!==p.current)return;const{scrollTop:x,ignoreScrollToTop:w}=u;let{lastScrollTop:S=x}=u;u.lastScrollTop=x,u.ignoreScrollToTop=void 0,w&&w>x&&(S=w),a(u.isNearBottom),setTimeout(()=>{if(u.resizeDifference||x===w)return;if(l()){h(!0),c(!1);return}const k=x>S,C=x<S;if(u.animation?.ignoreEscapes){u.scrollTop=S;return}C&&(h(!0),c(!1)),k&&h(!1),!u.escapedFromLock&&u.isNearBottom&&c(!0)},1)},[h,c,l,u]),b=A.useCallback(({target:v,deltaY:x})=>{let w=v;for(;!["scroll","auto"].includes(getComputedStyle(w).overflow);){if(!w.parentElement)return;w=w.parentElement}w===p.current&&x<0&&p.current.scrollHeight>p.current.clientHeight&&!u.animation?.ignoreEscapes&&(h(!0),c(!1))},[h,c,u]),p=Eg(v=>{p.current?.removeEventListener("scroll",_),p.current?.removeEventListener("wheel",b),v?.addEventListener("scroll",_,{passive:!0}),v?.addEventListener("wheel",b,{passive:!0})},[]),g=Eg(v=>{if(u.resizeObserver?.disconnect(),!v)return;let x;u.resizeObserver=new ResizeObserver(([w])=>{const{height:S}=w.contentRect,k=S-(x??S);if(u.resizeDifference=k,u.scrollTop>u.targetScrollTop&&(u.scrollTop=u.targetScrollTop),a(u.isNearBottom),k>=0){const C=wu(o.current,x?o.current.resize:o.current.initial);d({animation:C,wait:!0,preserveScrollPosition:!0,duration:C==="instant"?void 0:GE})}else u.isNearBottom&&(h(!1),c(!0));x=S,requestAnimationFrame(()=>{setTimeout(()=>{u.resizeDifference===k&&(u.resizeDifference=0)},1)})}),u.resizeObserver?.observe(v)},[]);
3return{contentRef:g,scrollRef:p,scrollToBottom:d,stopScroll:f,isAtBottom:i||n,isNearBottom:n,escapedFromLock:e,state:u}};function Eg(r,e){const t=A.useCallback(i=>(t.current=i,r(i)),e);return t}const yu=new Map;function wu(...r){const e={...VE};let t=!1;for(const s of r){if(s==="instant"){t=!0;continue}typeof s=="object"&&(t=!1,e.damping=s.damping??e.damping,e.stiffness=s.stiffness??e.stiffness,e.mass=s.mass??e.mass)}const i=JSON.stringify(e);return yu.has(i)||yu.set(i,Object.freeze(e)),t?"instant":yu.get(i)}const Zx=A.createContext(null),YE=typeof window<"u"?A.useLayoutEffect:A.useEffect;function Od({instance:r,children:e,resize:t,initial:i,mass:s,damping:n,stiffness:a,targetScrollTop:o,contextRef:l,...c}){const h=A.useRef(null),u=A.useCallback((S,k)=>(w?.targetScrollTop??o)?.(S,k)??S,[o]),d=XE({mass:s,damping:n,stiffness:a,resize:t,initial:i,targetScrollTop:u}),{scrollRef:f,contentRef:_,scrollToBottom:b,stopScroll:p,isAtBottom:g,escapedFromLock:v,state:x}=r??d,w=A.useMemo(()=>({scrollToBottom:b,stopScroll:p,scrollRef:f,isAtBottom:g,escapedFromLock:v,contentRef:_,state:x,get targetScrollTop(){return h.current},set targetScrollTop(S){h.current=S}}),[b,g,_,f,p,v,x]);return A.useImperativeHandle(l,()=>w,[w]),YE(()=>{f.current&&getComputedStyle(f.current).overflow==="visible"&&(f.current.style.overflow="auto")},[]),m.jsx(Zx.Provider,{value:w,children:m.jsx("div",{...c,children:typeof e=="function"?e(w):e})})}function ZE({children:r,...e}){const t=Jx();return m.jsx("div",{ref:t.scrollRef,className:"w-full h-auto",children:m.jsx("div",{...e,ref:t.contentRef,children:typeof r=="function"?r(t):r})})}Od.Content=ZE;function Jx(){const r=A.useContext(Zx);if(!r)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return r}function JE(r,e=100,t){const i=t({...r,keyframes:[0,e]}),s=Math.min(KC(i),qC);return{type:"keyframes",ease:n=>i.next(s*n).value/e,duration:GC(s)}}function QE(r){return A.useEffect(()=>()=>r(),[])}const eA=(r,e,t)=>{const i=e-r;return((t-r)%i+i)%i+r};function Qx(r,e){return XC(r)?r[eA(0,r.length,e)]:r}function Tp(r){return typeof r=="object"&&!Array.isArray(r)}function e_(r,e,t,i){return typeof r=="string"&&Tp(e)?YC(r,t,i):r instanceof NodeList?Array.from(r):Array.isArray(r)?r:[r]}function tA(r,e,t){return r*(e+1)}function Ag(r,e,t,i){var s;return typeof e=="number"?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,r+parseFloat(e)):e==="<"?t:(s=i.get(e))!==null&&s!==void 0?s:r}function rA(r,e,t){for(let i=0;i<r.length;i++){const s=r[i];s.at>e&&s.at<t&&(JC(r,s),i--)}}function iA(r,e,t,i,s,n){rA(r,s,n);for(let a=0;a<e.length;a++)r.push({value:e[a],at:ZC(s,n,i[a]),easing:Qx(t,a)})}function sA(r,e){for(let t=0;t<r.length;t++)r[t]=r[t]/(e+1)}function nA(r,e){return r.at===e.at?r.value===null?1:e.value===null?-1:0:r.at-e.at}const oA="easeInOut";function aA(r,{defaultTransition:e={},...t}={},i,s){const n=e.duration||.3,a=new Map,o=new Map,l={},c=new Map;let h=0,u=0,d=0;for(let f=0;f<r.length;f++){const _=r[f];if(typeof _=="string"){c.set(_,u);continue}else if(!Array.isArray(_)){c.set(_.name,Ag(u,_.at,h,c));continue}let[b,p,g={}]=_;g.at!==void 0&&(u=Ag(u,g.at,h,c));let v=0;const x=(w,S,k,C=0,y=0)=>{const E=lA(w),{delay:D=0,times:T=QC(E),type:M="keyframes",repeat:R,repeatType:O,repeatDelay:$=0,...G}=S;let{ease:V=e.ease||"easeOut",duration:q}=S;const L=typeof D=="function"?D(C,y):D,N=E.length,I=t2(M)?M:s?.[M];if(N<=2&&I){let Z=100;if(N===2&&uA(E)){const P=E[1]-E[0];Z=Math.abs(P)}const X={...G};q!==void 0&&(X.duration=r2(q));const F=JE(X,Z,I);V=F.ease,q=F.duration}q??(q=n);const H=u+L;T.length===1&&T[0]===0&&(T[1]=1);const W=T.length-E.length;if(W>0&&e2(T,W),E.length===1&&E.unshift(null),R){q=tA(q,R);const Z=[...E],X=[...T];V=Array.isArray(V)?[...V]:[V];const F=[...V];for(let P=0;P<R;P++){E.push(...Z);for(let j=0;j<Z.length;j++)T.push(X[j]+(P+1)),V.push(j===0?"linear":Qx(F,j-1))}sA(T,R)}const J=H+q;iA(k,E,V,T,H,J),v=Math.max(L+q,v),d=Math.max(J,d)};if(Mx(b)){const w=Tg(b,o);x(p,g,Rg("default",w))}else{const w=e_(b,p,i,l),S=w.length;for(let k=0;k<S;k++){p=p,g=g;const C=w[k],y=Tg(C,o);for(const E in p)x(p[E],cA(g,E),Rg(E,y),k,S)}}h=u,u+=v}return o.forEach((f,_)=>{for(const b in f){const p=f[b];p.sort(nA);const g=[],v=[],x=[];for(let S=0;S<p.length;S++){const{at:k,value:C,easing:y}=p[S];g.push(C),v.push(i2(0,d,k)),x.push(y||"easeOut")}v[0]!==0&&(v.unshift(0),g.unshift(g[0]),x.unshift(oA)),v[v.length-1]!==1&&(v.push(1),g.push(null)),a.has(_)||a.set(_,{keyframes:{},transition:{}});const w=a.get(_);w.keyframes[b]=g,w.transition[b]={...e,duration:d,ease:x,times:v,...t}}}),a}function Tg(r,e){return!e.has(r)&&e.set(r,{}),e.get(r)}function Rg(r,e){return e[r]||(e[r]=[]),e[r]}function lA(r){return Array.isArray(r)?r:[r]}function cA(r,e){return r&&r[e]?{...r,...r[e]}:{...r}}const hA=r=>typeof r=="number",uA=r=>r.every(hA);function dA(r,e){return r in e}class fA extends s2{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,t){if(dA(t,e)){const i=e[t];if(typeof i=="string"||typeof i=="number")return i}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return n2()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}}function pA(r){const e={presenceContext:null,props:{}
3,visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},t=o2(r)?new a2(e):new l2(e);t.mount(r),Mc.set(r,t)}function mA(r){const e={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},t=new fA(e);t.mount(r),Mc.set(r,t)}function gA(r,e){return Mx(r)||typeof r=="number"||typeof r=="string"&&!Tp(e)}function t_(r,e,t,i){const s=[];if(gA(r,e))s.push(c2(r,Tp(e)&&e.default||e,t&&(t.default||t)));else{const n=e_(r,e,i),a=n.length;for(let o=0;o<a;o++){const l=n[o],c=l instanceof Element?pA:mA;Mc.has(l)||c(l);const h=Mc.get(l),u={...t};"delay"in u&&typeof u.delay=="function"&&(u.delay=u.delay(o,a)),s.push(...h2(h,{...e,transition:u},{}))}}return s}function vA(r,e,t){const i=[];return aA(r,e,t,{spring:u2}).forEach(({keyframes:n,transition:a},o)=>{i.push(...t_(o,n,a))}),i}function bA(r){return Array.isArray(r)&&r.some(Array.isArray)}function xA(r){function e(t,i,s){let n=[];bA(t)?n=vA(t,i,r):n=t_(t,i,s,r);const a=new d2(n);return r&&r.animations.push(a),a}return e}function _A(){const r=pg(()=>({current:null,animations:[]})),e=pg(()=>xA(r));return QE(()=>{r.animations.forEach(t=>t.stop())}),[r,e]}const r_=typeof document<"u"?ke.useLayoutEffect:()=>{};function yA(r){const e=A.useRef(null);return r_(()=>{e.current=r},[r]),A.useCallback((...t)=>{const i=e.current;return i?.(...t)},[])}const Ya=r=>{var e;return(e=r?.ownerDocument)!==null&&e!==void 0?e:document},qs=r=>r&&"window"in r&&r.window===r?r:Ya(r).defaultView||window;function wA(r){var e;return typeof window>"u"||window.navigator==null?!1:((e=window.navigator.userAgentData)===null||e===void 0?void 0:e.brands.some(t=>r.test(t.brand)))||r.test(window.navigator.userAgent)}function SA(r){var e;return typeof window<"u"&&window.navigator!=null?r.test(((e=window.navigator.userAgentData)===null||e===void 0?void 0:e.platform)||window.navigator.platform):!1}function i_(r){let e=null;return()=>(e==null&&(e=r()),e)}const kA=i_(function(){return SA(/^Mac/i)}),CA=i_(function(){return wA(/Android/i)});function EA(r){return r.mozInputSource===0&&r.isTrusted?!0:CA()&&r.pointerType?r.type==="click"&&r.buttons===1:r.detail===0&&!r.pointerType}class AA{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(e,t){this.nativeEvent=t,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget,this.bubbles=t.bubbles,this.cancelable=t.cancelable,this.defaultPrevented=t.defaultPrevented,this.eventPhase=t.eventPhase,this.isTrusted=t.isTrusted,this.timeStamp=t.timeStamp,this.type=e}}function s_(r){let e=A.useRef({isFocused:!1,observer:null});r_(()=>{const i=e.current;return()=>{i.observer&&(i.observer.disconnect(),i.observer=null)}},[]);let t=yA(i=>{r?.(i)});return A.useCallback(i=>{if(i.target instanceof HTMLButtonElement||i.target instanceof HTMLInputElement||i.target instanceof HTMLTextAreaElement||i.target instanceof HTMLSelectElement){e.current.isFocused=!0;let s=i.target,n=a=>{e.current.isFocused=!1,s.disabled&&t(new AA("blur",a)),e.current.observer&&(e.current.observer.disconnect(),e.current.observer=null)};s.addEventListener("focusout",n,{once:!0}),e.current.observer=new MutationObserver(()=>{if(e.current.isFocused&&s.disabled){var a;(a=e.current.observer)===null||a===void 0||a.disconnect();let o=s===document.activeElement?null:document.activeElement;s.dispatchEvent(new FocusEvent("blur",{relatedTarget:o})),s.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:o}))}}),e.current.observer.observe(s,{attributes:!0,attributeFilter:["disabled"]})}},[t])}function TA(r){let{isDisabled:e,onFocus:t,onBlur:i,onFocusChange:s}=r;const n=A.useCallback(l=>{if(l.target===l.currentTarget)return i&&i(l),s&&s(!1),!0},[i,s]),a=s_(n),o=A.useCallback(l=>{const c=Ya(l.target);l.target===l.currentTarget&&c.activeElement===l.target&&(t&&t(l),s&&s(!0),a(l))},[s,t,a]);return{focusProps:{onFocus:!e&&(t||s||i)?o:void 0,onBlur:!e&&(i||s)?n:void 0}}}let Za=null,Id=new Set,na=new Map,dn=!1,jd=!1;const RA={Tab:!0,Escape:!0};function Rp(r,e){for(let t of Id)t(r,e)}function MA(r){return!(r.metaKey||!kA()&&r.altKey||r.ctrlKey||r.key==="Control"||r.key==="Shift"||r.key==="Meta")}function Lc(r){dn=!0,MA(r)&&(Za="keyboard",Rp("keyboard",r))}function Er(r){Za="pointer",(r.type==="mousedown"||r.type==="pointerdown")&&(
3dn=!0,Rp("pointer",r))}function n_(r){EA(r)&&(dn=!0,Za="virtual")}function o_(r){r.target===window||r.target===document||(!dn&&!jd&&(Za="virtual",Rp("virtual",r)),dn=!1,jd=!1)}function a_(){dn=!1,jd=!0}function Bd(r){if(typeof window>"u"||na.get(qs(r)))return;const e=qs(r),t=Ya(r);let i=e.HTMLElement.prototype.focus;e.HTMLElement.prototype.focus=function(){dn=!0,i.apply(this,arguments)},t.addEventListener("keydown",Lc,!0),t.addEventListener("keyup",Lc,!0),t.addEventListener("click",n_,!0),e.addEventListener("focus",o_,!0),e.addEventListener("blur",a_,!1),typeof PointerEvent<"u"?(t.addEventListener("pointerdown",Er,!0),t.addEventListener("pointermove",Er,!0),t.addEventListener("pointerup",Er,!0)):(t.addEventListener("mousedown",Er,!0),t.addEventListener("mousemove",Er,!0),t.addEventListener("mouseup",Er,!0)),e.addEventListener("beforeunload",()=>{l_(r)},{once:!0}),na.set(e,{focus:i})}const l_=(r,e)=>{const t=qs(r),i=Ya(r);e&&i.removeEventListener("DOMContentLoaded",e),na.has(t)&&(t.HTMLElement.prototype.focus=na.get(t).focus,i.removeEventListener("keydown",Lc,!0),i.removeEventListener("keyup",Lc,!0),i.removeEventListener("click",n_,!0),t.removeEventListener("focus",o_,!0),t.removeEventListener("blur",a_,!1),typeof PointerEvent<"u"?(i.removeEventListener("pointerdown",Er,!0),i.removeEventListener("pointermove",Er,!0),i.removeEventListener("pointerup",Er,!0)):(i.removeEventListener("mousedown",Er,!0),i.removeEventListener("mousemove",Er,!0),i.removeEventListener("mouseup",Er,!0)),na.delete(t))};function DA(r){const e=Ya(r);let t;return e.readyState!=="loading"?Bd(r):(t=()=>{Bd(r)},e.addEventListener("DOMContentLoaded",t)),()=>l_(r,t)}typeof document<"u"&&DA();function c_(){return Za!=="pointer"}const PA=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function LA(r,e,t){var i;const s=typeof window<"u"?qs(t?.target).HTMLInputElement:HTMLInputElement,n=typeof window<"u"?qs(t?.target).HTMLTextAreaElement:HTMLTextAreaElement,a=typeof window<"u"?qs(t?.target).HTMLElement:HTMLElement,o=typeof window<"u"?qs(t?.target).KeyboardEvent:KeyboardEvent;return r=r||t?.target instanceof s&&!PA.has(t==null||(i=t.target)===null||i===void 0?void 0:i.type)||t?.target instanceof n||t?.target instanceof a&&t?.target.isContentEditable,!(r&&e==="keyboard"&&t instanceof o&&!RA[t.key])}function NA(r,e,t){Bd(),A.useEffect(()=>{let i=(s,n)=>{LA(!!t?.isTextInput,s,n)&&r(c_())};return Id.add(i),()=>{Id.delete(i)}},e)}function OA(r){let{isDisabled:e,onBlurWithin:t,onFocusWithin:i,onFocusWithinChange:s}=r,n=A.useRef({isFocusWithin:!1}),a=A.useCallback(c=>{n.current.isFocusWithin&&!c.currentTarget.contains(c.relatedTarget)&&(n.current.isFocusWithin=!1,t&&t(c),s&&s(!1))},[t,s,n]),o=s_(a),l=A.useCallback(c=>{!n.current.isFocusWithin&&document.activeElement===c.target&&(i&&i(c),s&&s(!0),n.current.isFocusWithin=!0,o(c))},[i,s,o]);return e?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:l,onBlur:a}}}let Nc=!1,Su=0;function Fd(){Nc=!0,setTimeout(()=>{Nc=!1},50)}function Mg(r){r.pointerType==="touch"&&Fd()}function IA(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Mg):document.addEventListener("touchend",Fd),Su++,()=>{Su--,!(Su>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",Mg):document.removeEventListener("touchend",Fd))}}function jA(r){let{onHoverStart:e,onHoverChange:t,onHoverEnd:i,isDisabled:s}=r,[n,a]=A.useState(!1),o=A.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;A.useEffect(IA,[]);let{hoverProps:l,triggerHoverEnd:c}=A.useMemo(()=>{let h=(f,_)=>{if(o.pointerType=_,s||_==="touch"||o.isHovered||!f.currentTarget.contains(f.target))return;o.isHovered=!0;let b=f.currentTarget;o.target=b,e&&e({type:"hoverstart",target:b,pointerType:_}),t&&t(!0),a(!0)},u=(f,_)=>{if(o.pointerType="",o.target=null,_==="touch"||!o.isHovered)return;o.isHovered=!1;let b=f.currentTarget;i&&i({type:"hoverend",target:b,pointerType:_}),t&&t(!1),a(!1)},d={};return typeof PointerEvent<"u"?(d.onPointerEnter=f=>{Nc&&f.pointerType==="mouse"||h(f,f.pointerType)},d.onPointerLeave=f=>{!s&&f.currentTarget.contains(f.target)&&u(f,f.pointerType)}):(d.onTouchStart=()=>{o.ignoreEmulatedMouseEvents=!0},d.onMouseEnter=f=>{!o.ignoreEmulatedMouseEvents&&!Nc&&h(f,"mouse"),o.ignoreEmulatedMouseEvents=!1},d.onMouseLeave=f=>{!s&&f.currentTarget.contains(f.target)&&u(f,"mouse")}),{hoverProps:d,triggerHoverEnd:u}}
vendor: 5,073 bytes, line 3
3,[e,t,i,s,o]);return A.useEffect(()=>{s&&c({currentTarget:o.target},o.pointerType)},[s]),{hoverProps:l,isHovered:n}}function BA(r={}){let{autoFocus:e=!1,isTextInput:t,within:i}=r,s=A.useRef({isFocused:!1,isFocusVisible:e||c_()}),[n,a]=A.useState(!1),[o,l]=A.useState(()=>s.current.isFocused&&s.current.isFocusVisible),c=A.useCallback(()=>l(s.current.isFocused&&s.current.isFocusVisible),[]),h=A.useCallback(f=>{s.current.isFocused=f,a(f),c()},[c]);NA(f=>{s.current.isFocusVisible=f,c()},[],{isTextInput:t});let{focusProps:u}=TA({isDisabled:i,onFocusChange:h}),{focusWithinProps:d}=OA({isDisabled:!i,onFocusWithinChange:h});return{isFocused:n,isFocusVisible:o,focusProps:i?d:u}}var FA=Object.defineProperty,$A=(r,e,t)=>e in r?FA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ku=(r,e,t)=>($A(r,typeof e!="symbol"?e+"":e,t),t);let HA=class{constructor(){ku(this,"current",this.detect()),ku(this,"handoffState","pending"),ku(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},an=new HA;function Ja(r){return an.isServer?null:r instanceof Node?r.ownerDocument:r!=null&&r.hasOwnProperty("current")&&r.current instanceof Node?r.current.ownerDocument:document}function h_(r){typeof queueMicrotask=="function"?queueMicrotask(r):Promise.resolve().then(r).catch(e=>setTimeout(()=>{throw e}))}function Tn(){let r=[],e={addEventListener(t,i,s,n){return t.addEventListener(i,s,n),e.add(()=>t.removeEventListener(i,s,n))},requestAnimationFrame(...t){let i=requestAnimationFrame(...t);return e.add(()=>cancelAnimationFrame(i))},nextFrame(...t){return e.requestAnimationFrame(()=>e.requestAnimationFrame(...t))},setTimeout(...t){let i=setTimeout(...t);return e.add(()=>clearTimeout(i))},microTask(...t){let i={current:!0};return h_(()=>{i.current&&t[0]()}),e.add(()=>{i.current=!1})},style(t,i,s){let n=t.style.getPropertyValue(i);return Object.assign(t.style,{[i]:s}),this.add(()=>{Object.assign(t.style,{[i]:n})})},group(t){let i=Tn();return t(i),this.add(()=>i.dispose())},add(t){return r.includes(t)||r.push(t),()=>{let i=r.indexOf(t);if(i>=0)for(let s of r.splice(i,1))s()}},dispose(){for(let t of r.splice(0))t()}};return e}function Ch(){let[r]=A.useState(Tn);return A.useEffect(()=>()=>r.dispose(),[r]),r}let kt=(r,e)=>{an.isServer?A.useEffect(r,e):A.useLayoutEffect(r,e)};function Vi(r){let e=A.useRef(r);return kt(()=>{e.current=r},[r]),e}let Be=function(r){let e=Vi(r);return ke.useCallback((...t)=>e.current(...t),[e])};function zA(r){let e=r.width/2,t=r.height/2;return{top:r.clientY-t,right:r.clientX+e,bottom:r.clientY+t,left:r.clientX-e}}function WA(r,e){return!(!r||!e||r.right<e.left||r.left>e.right||r.bottom<e.top||r.top>e.bottom)}function UA({disabled:r=!1}={}){let e=A.useRef(null),[t,i]=A.useState(!1),s=Ch(),n=Be(()=>{e.current=null,i(!1),s.dispose()}),a=Be(o=>{if(s.dispose(),e.current===null){e.current=o.currentTarget,i(!0);{let l=Ja(o.currentTarget);s.addEventListener(l,"pointerup",n,!1),s.addEventListener(l,"pointermove",c=>{if(e.current){let h=zA(c);i(WA(h,e.current.getBoundingClientRect()))}},!1),s.addEventListener(l,"pointercancel",n,!1)}}});return{pressed:t,pressProps:r?{}:{onPointerDown:a,onPointerUp:n,onClick:n}}}function $d(...r){return Array.from(new Set(r.flatMap(e=>typeof e=="string"?e.split(" "):[]))).filter(Boolean).join(" ")}function Nr(r,e,...t){if(r in e){let s=e[r];return typeof s=="function"?s(...t):s}let i=new Error(`Tried to handle "${r}" but there is no handler defined. Only defined handlers are: ${Object.keys(e).map(s=>`"${s}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(i,Nr),i}var co=(r=>(r[r.None=0]="None",r[r.RenderStrategy=1]="RenderStrategy",r[r.Static=2]="Static",r))(co||{}),ps=(r=>(r[r.Unmount=0]="Unmount",r[r.Hidden=1]="Hidden",r))(ps||{});function Gr(){let r=KA();return A.useCallback(e=>VA({mergeRefs:r,...e}),[r])}function VA({ourProps:r,theirProps:e,slot:t,defaultTag:i,features:s,visible:n=!0,name:a,mergeRefs:o}){o=o??qA;let l=u_(e,r);if(n)return Al(l,t,i,a,o);let c=s??0;if(c&2){let{static:h=!1,...u}=l;if(h)return Al(u,t,i,a,o)}if(c&1){let{unmount:h=!0,...u}=l;return Nr(h?0:1,{0(){return null},1(){return Al({...u,hidden:!0,style:{display:"none"}},t,i,a,o)}})}return Al(l,t,i,a,o)}function Al(r,e={},t,i,s){let{as:n=t,children:a,refName:o="ref",...l}=Cu(r,["unmount","static"]),c=r.ref!==void 0?{[o]:r.ref}:{},h=typeof a=="function"?a(e):a;"className"in l&&l.className&&typeof l.className=="function"&&(l.className=l.className(e)),l["aria-labelledby"]&&l["aria-labelledby"]===l.id&&(l["aria-labelledby"]=void 0);let u={};if(e){let d=!1,f=[];for(let[_,b]of Object.entries(e))typeof b=="boolean"&&(d=!0),b===!0&&f.push(_.replace(/([A-Z])/g,p=>
3`-${p.toLowerCase()}`));if(d){u["data-headlessui-state"]=f.join(" ");for(let _ of f)u[`data-${_}`]=""}}if(n===A.Fragment&&(Object.keys(zs(l)).length>0||Object.keys(zs(u)).length>0))if(!A.isValidElement(h)||Array.isArray(h)&&h.length>1){if(Object.keys(zs(l)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${i} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(zs(l)).concat(Object.keys(zs(u))).map(d=>` - ${d}`).join(` 4`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(d=>` - ${d}`).join(` 5`)].join(` 6`))}else{let d=h.props,f=d?.className,_=typeof f=="function"?(...g)=>$d(f(...g),l.className):$d(f,l.className),b=_?{className:_}:{},p=u_(h.props,zs(Cu(l,["ref"])));for(let g in u)g in p&&delete u[g];return A.cloneElement(h,Object.assign({},p,u,c,{ref:s(GA(h),c.ref)},b))}return A.createElement(n,Object.assign({},Cu(l,["ref"]),n!==A.Fragment&&c,n!==A.Fragment&&u),h)}function KA(){let r=A.useRef([]),e=A.useCallback(t=>{for(let i of r.current)i!=null&&(typeof i=="function"?i(t):i.current=t)},[]);return(...t)=>{if(!t.every(i=>i==null))return r.current=t,e}}function qA(...r){return r.every(e=>e==null)?void 0:e=>{for(let t of r)t!=null&&(typeof t=="function"?t(e):t.current=e)}}function u_(...r){if(r.length===0)return{};if(r.length===1)return r[0];let e={},t={};for(let i of r)for(let s in i)s.startsWith("on")&&typeof i[s]=="function"?(t[s]!=null||(t[s]=[]),t[s].push(i[s])):e[s]=i[s];if(e.disabled||e["aria-disabled"])for(let i in t)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(i)&&(t[i]=[s=>{var n;return(n=s?.preventDefault)==null?void 0:n.call(s)}]);for(let i in t)Object.assign(e,{[i](s,...n){let a=t[i];for(let o of a){if((s instanceof Event||s?.nativeEvent instanceof Event)&&s.defaultPrevented)return;o(s,...n)}}});return e}function Hd(...r){if(r.length===0)return{};if(r.length===1)return r[0];let e={},t={};for(let i of r)for(let s in i)s.startsWith("on")&&typeof i[s]=="function"?(t[s]!=null||(t[s]=[]),t[s].push(i[s])):e[s]=i[s];for(let i in t)Object.assign(e,{[i](...s){let n=t[i];for(let a of n)a?.(...s)}});return e}function br(r){var e;return Object.assign(A.forwardRef(r),{displayName:(e=r.displayName)!=null?e:r.name})}function zs(r){let e=Object.assign({},r);for(let t in e)e[t]===void 0&&delete e[t];return e}function Cu(r,e=[]){let t=Object.assign({},r);for(let i of e)i in t&&delete t[i];return t}function GA(r){return ke.version.split(".")[0]>="19"?r.props.ref:r.ref}let XA="span";var ka=(r=>(r[r.None=1]="None",r[r.Focusable=2]="Focusable",r[r.Hidden=4]="Hidden",r))(ka||{});function YA(r,e){var t;let{features:i=1,...s}=r,n={ref:e,"aria-hidden":(i&2)===2?!0:(t=s["aria-hidden"])!=null?t:void 0,hidden:(i&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(i&4)===4&&(i&2)!==2&&{display:"none"}}};return Gr()({ourProps:n,theirProps:s,slot:{},defaultTag:XA,name:"Hidden"})}let Oc=br(YA);function d_(r){let e=r.parentElement,t=null;for(;e&&!(e instanceof HTMLFieldSetElement);)e instanceof HTMLLegendElement&&(t=e),e=e.parentElement;let i=e?.getAttribute("disabled")==="";return i&&ZA(t)?!1:i}function ZA(r){if(!r)return!1;let e=r.previousElementSibling;for(;e!==null;){if(e instanceof HTMLLegendElement)return!1;e=e.previousElementSibling}return!0}let f_=Symbol();function p_(r,e=!0){return Object.assign(r,{[f_]:e})}function Vr(...r){let e=A.useRef(r);A.useEffect(()=>{e.current=r},[r]);let t=Be(i=>{for(let s of e.current)s!=null&&(typeof s=="function"?s(i):s.current=i)});return r.every(i=>i==null||i?.[f_])?void 0:t}var as=(r=>(r.Space=" ",r.Enter="Enter",r.Escape="Escape",r.Backspace="Backspace",r.Delete="Delete",r.ArrowLeft="ArrowLeft",r.ArrowUp="ArrowUp",r.ArrowRight="ArrowRight",r.ArrowDown="ArrowDown",r.Home="Home",r.End="End",r.PageUp="PageUp",r.PageDown="PageDown",r.Tab="Tab",r))(as||{});let JA=A.createContext(()=>{});function QA({value:r,children:e}){return ke.createElement(JA.Provider,{value:r},e)}function eT(r){if(r===null)return{width:0,height:0};let{width:e,height:t}=r.getBoundingClientRect();return{width:e,height:t}}function tT(r,e=!1){let[t,i]=A.useReducer(()=>({}),{}),s=A.useMemo(()=>eT(r),[r,t]);return kt(()=>{if(!r)return;let n=new ResizeObserver(i);return n.observe(r),()=>{n.disconnect()}},[r]),e?{width:`${s.width}px`,height:`${s.height}px`}:s}let rT=class extends Map{constructor(e){super(),this.factory=e}get(e){let t=super.get(e);return t===void 0&&(t=this.factory(e),this.set(e,t)),t}};function m_(r,e){let t=r(),i=new Set;return{getSnapshot(){return t},subscribe(s){return i.add(s),()=>i.delete(s)}
6,dispatch(s,...n){let a=e[s].call(t,...n);a&&(t=a,i.forEach(o=>o()))}}}function g_(r){return A.useSyncExternalStore(r.subscribe,r.getSnapshot,r.getSnapshot)}let iT=new rT(()=>m_(()=>[],{ADD(r){return this.includes(r)?this:[...this,r]},REMOVE(r){let e=this.indexOf(r);if(e===-1)return this;let t=this.slice();return t.splice(e,1),t}}));function v_(r,e){let t=iT.get(e),i=A.useId(),s=g_(t);if(kt(()=>{if(r)return t.dispatch("ADD",i),()=>t.dispatch("REMOVE",i)},[t,r]),!r)return!1;let n=s.indexOf(i),a=s.length;return n===-1&&(n=a,a+=1),n===a-1}function sT(r,e,t){let i=Vi(s=>{let n=s.getBoundingClientRect();n.x===0&&n.y===0&&n.width===0&&n.height===0&&t()});A.useEffect(()=>{if(!r)return;let s=e===null?null:e instanceof HTMLElement?e:e.current;if(!s)return;let n=Tn();if(typeof ResizeObserver<"u"){let a=new ResizeObserver(()=>i.current(s));a.observe(s),n.add(()=>a.disconnect())}if(typeof IntersectionObserver<"u"){let a=new IntersectionObserver(()=>i.current(s));a.observe(s),n.add(()=>a.disconnect())}return()=>n.dispose()},[e,i,r])}let zd=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(r=>`${r}:not([tabindex='-1'])`).join(","),nT=["[data-autofocus]"].map(r=>`${r}:not([tabindex='-1'])`).join(",");var $i=(r=>(r[r.First=1]="First",r[r.Previous=2]="Previous",r[r.Next=4]="Next",r[r.Last=8]="Last",r[r.WrapAround=16]="WrapAround",r[r.NoScroll=32]="NoScroll",r[r.AutoFocus=64]="AutoFocus",r))($i||{}),Ic=(r=>(r[r.Error=0]="Error",r[r.Overflow=1]="Overflow",r[r.Success=2]="Success",r[r.Underflow=3]="Underflow",r))(Ic||{}),oT=(r=>(r[r.Previous=-1]="Previous",r[r.Next=1]="Next",r))(oT||{});function Eh(r=document.body){return r==null?[]:Array.from(r.querySelectorAll(zd)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}function aT(r=document.body){return r==null?[]:Array.from(r.querySelectorAll(nT)).sort((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var Mp=(r=>(r[r.Strict=0]="Strict",r[r.Loose=1]="Loose",r))(Mp||{});function b_(r,e=0){var t;return r===((t=Ja(r))==null?void 0:t.body)?!1:Nr(e,{0(){return r.matches(zd)},1(){let i=r;for(;i!==null;){if(i.matches(zd))return!0;i=i.parentElement}return!1}})}var lT=(r=>(r[r.Keyboard=0]="Keyboard",r[r.Mouse=1]="Mouse",r))(lT||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",r=>{r.metaKey||r.altKey||r.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",r=>{r.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:r.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));let cT=["textarea","input"].join(",");function hT(r){var e,t;return(t=(e=r?.matches)==null?void 0:e.call(r,cT))!=null?t:!1}function uT(r,e=t=>t){return r.slice().sort((t,i)=>{let s=e(t),n=e(i);if(s===null||n===null)return 0;let a=s.compareDocumentPosition(n);return a&Node.DOCUMENT_POSITION_FOLLOWING?-1:a&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function Gs(r,e,{sorted:t=!0,relativeTo:i=null,skipElements:s=[]}={}){let n=Array.isArray(r)?r.length>0?r[0].ownerDocument:document:r.ownerDocument,a=Array.isArray(r)?t?uT(r):r:e&64?aT(r):Eh(r);s.length>0&&a.length>1&&(a=a.filter(f=>!s.some(_=>_!=null&&"current"in _?_?.current===f:_===f))),i=i??n.activeElement;let o=(()=>{if(e&5)return 1;if(e&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),l=(()=>{if(e&1)return 0;if(e&2)return Math.max(0,a.indexOf(i))-1;if(e&4)return Math.max(0,a.indexOf(i))+1;if(e&8)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),c=e&32?{preventScroll:!0}:{},h=0,u=a.length,d;do{if(h>=u||h+u<=0)return 0;let f=l+h;if(e&16)f=(f+u)%u;else{if(f<0)return 3;if(f>=u)return 1}d=a[f],d?.focus(c),h+=o}while(d!==n.activeElement);return e&6&&hT(d)&&d.select(),2}function x_(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function dT(){return/Android/gi.test(window.navigator.userAgent)}function fT(){return x_()||dT()}function Fo(r,e,t,i){let s=Vi(t);A.useEffect(()=>{if(!r)return;function n(a){s.current(a)}return document.addEventListener(e,n,i),()=>document.removeEventListener(e,n,i)},[r,e,i])}function __(r,e,t,i){let s=Vi(t);A.useEffect(()=>{if(!r)return;function n(a){s.current(a)}return window.addEventListener(e,n,i),()=>window.removeEventListener(e,n,i)},[r,e,i])}const Dg=30;function pT(r,e,t){let i=v_(r,"outside-click"),s=Vi(t),n=A.useCallback(function(l,c){if
6(l.defaultPrevented)return;let h=c(l);if(h===null||!h.getRootNode().contains(h)||!h.isConnected)return;let u=function d(f){return typeof f=="function"?d(f()):Array.isArray(f)||f instanceof Set?f:[f]}(e);for(let d of u)if(d!==null&&(d.contains(h)||l.composed&&l.composedPath().includes(d)))return;return!b_(h,Mp.Loose)&&h.tabIndex!==-1&&l.preventDefault(),s.current(l,h)},[s,e]),a=A.useRef(null);Fo(i,"pointerdown",l=>{var c,h;a.current=((h=(c=l.composedPath)==null?void 0:c.call(l))==null?void 0:h[0])||l.target},!0),Fo(i,"mousedown",l=>{var c,h;a.current=((h=(c=l.composedPath)==null?void 0:c.call(l))==null?void 0:h[0])||l.target},!0),Fo(i,"click",l=>{fT()||a.current&&(n(l,()=>a.current),a.current=null)},!0);let o=A.useRef({x:0,y:0});Fo(i,"touchstart",l=>{o.current.x=l.touches[0].clientX,o.current.y=l.touches[0].clientY},!0),Fo(i,"touchend",l=>{let c={x:l.changedTouches[0].clientX,y:l.changedTouches[0].clientY};if(!(Math.abs(c.x-o.current.x)>=Dg||Math.abs(c.y-o.current.y)>=Dg))return n(l,()=>l.target instanceof HTMLElement?l.target:null)},!0),__(i,"blur",l=>n(l,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function So(...r){return A.useMemo(()=>Ja(...r),[...r])}function mT(r,e,t,i){let s=Vi(t);A.useEffect(()=>{r=r??window;function n(a){s.current(a)}return r.addEventListener(e,n,i),()=>r.removeEventListener(e,n,i)},[r,e,i])}function gT(r,e){return A.useMemo(()=>{var t;if(r.type)return r.type;let i=(t=r.as)!=null?t:"button";if(typeof i=="string"&&i.toLowerCase()==="button"||e?.tagName==="BUTTON"&&!e.hasAttribute("type"))return"button"},[r.type,r.as,e])}function vT(){let r;return{before({doc:e}){var t;let i=e.documentElement,s=(t=e.defaultView)!=null?t:window;r=Math.max(0,s.innerWidth-i.clientWidth)},after({doc:e,d:t}){let i=e.documentElement,s=Math.max(0,i.clientWidth-i.offsetWidth),n=Math.max(0,r-s);t.style(i,"paddingRight",`${n}px`)}}}function bT(){return x_()?{before({doc:r,d:e,meta:t}){function i(s){return t.containers.flatMap(n=>n()).some(n=>n.contains(s))}e.microTask(()=>{var s;if(window.getComputedStyle(r.documentElement).scrollBehavior!=="auto"){let o=Tn();o.style(r.documentElement,"scrollBehavior","auto"),e.add(()=>e.microTask(()=>o.dispose()))}let n=(s=window.scrollY)!=null?s:window.pageYOffset,a=null;e.addEventListener(r,"click",o=>{if(o.target instanceof HTMLElement)try{let l=o.target.closest("a");if(!l)return;let{hash:c}=new URL(l.href),h=r.querySelector(c);h&&!i(h)&&(a=h)}catch{}},!0),e.addEventListener(r,"touchstart",o=>{if(o.target instanceof HTMLElement)if(i(o.target)){let l=o.target;for(;l.parentElement&&i(l.parentElement);)l=l.parentElement;e.style(l,"overscrollBehavior","contain")}else e.style(o.target,"touchAction","none")}),e.addEventListener(r,"touchmove",o=>{if(o.target instanceof HTMLElement){if(o.target.tagName==="INPUT")return;if(i(o.target)){let l=o.target;for(;l.parentElement&&l.dataset.headlessuiPortal!==""&&!(l.scrollHeight>l.clientHeight||l.scrollWidth>l.clientWidth);)l=l.parentElement;l.dataset.headlessuiPortal===""&&o.preventDefault()}else o.preventDefault()}},{passive:!1}),e.add(()=>{var o;let l=(o=window.scrollY)!=null?o:window.pageYOffset;n!==l&&window.scrollTo(0,n),a&&a.isConnected&&(a.scrollIntoView({block:"nearest"}),a=null)})})}}:{}}function xT(){return{before({doc:r,d:e}){e.style(r.documentElement,"overflow","hidden")}}}function _T(r){let e={};for(let t of r)Object.assign(e,t(e));return e}let Xs=m_(()=>new Map,{PUSH(r,e){var t;let i=(t=this.get(r))!=null?t:{doc:r,count:0,d:Tn(),meta:new Set};return i.count++,i.meta.add(e),this.set(r,i),this},POP(r,e){let t=this.get(r);return t&&(t.count--,t.meta.delete(e)),this},SCROLL_PREVENT({doc:r,d:e,meta:t}){let i={doc:r,d:e,meta:_T(t)},s=[bT(),vT(),xT()];s.forEach(({before:n})=>n?.(i)),s.forEach(({after:n})=>n?.(i))},SCROLL_ALLOW({d:r}){r.dispose()},TEARDOWN({doc:r}){this.delete(r)}});Xs.subscribe(()=>{let r=Xs.getSnapshot(),e=new Map;for(let[t]of r)e.set(t,t.documentElement.style.overflow);for(let t of r.values()){let i=e.get(t.doc)==="hidden",s=t.count!==0;(s&&!i||!s&&i)&&Xs.dispatch(t.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",t),t.count===0&&Xs.dispatch("TEARDOWN",t)}});function yT(r,e,t=()=>({containers:[]})){let i=g_(Xs),s=e?i.get(e):void 0,n=s?s.count>0:!1;return kt(()=>{if(!(!e||!r))return Xs.dispatch("PUSH",e,t),()=>Xs.dispatch("POP",e,t)},[r,e]),n}function wT(r,e,t=()=>[document.body]){let i=v_(r,"scroll-lock");yT(i,e,s=>{var n;
6return{containers:[...(n=s.containers)!=null?n:[],t]}})}function ST(r=0){let[e,t]=A.useState(r),i=A.useCallback(l=>t(l),[e]),s=A.useCallback(l=>t(c=>c|l),[e]),n=A.useCallback(l=>(e&l)===l,[e]),a=A.useCallback(l=>t(c=>c&~l),[t]),o=A.useCallback(l=>t(c=>c^l),[t]);return{flags:e,setFlag:i,addFlag:s,hasFlag:n,removeFlag:a,toggleFlag:o}}var kT={},Pg,Lg;typeof qt<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Pg=qt==null?void 0:kT)==null?void 0:Pg.NODE_ENV)==="test"&&typeof((Lg=Element?.prototype)==null?void 0:Lg.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(` 7`)),[]});var CT=(r=>(r[r.None=0]="None",r[r.Closed=1]="Closed",r[r.Enter=2]="Enter",r[r.Leave=4]="Leave",r))(CT||{});function Dp(r){let e={};for(let t in r)r[t]===!0&&(e[`data-${t}`]="");return e}function Pp(r,e,t,i){let[s,n]=A.useState(t),{hasFlag:a,addFlag:o,removeFlag:l}=ST(r&&s?3:0),c=A.useRef(!1),h=A.useRef(!1),u=Ch();return kt(()=>{var d;if(r){if(t&&n(!0),!e){t&&o(3);return}return(d=i?.start)==null||d.call(i,t),ET(e,{inFlight:c,prepare(){h.current?h.current=!1:h.current=c.current,c.current=!0,!h.current&&(t?(o(3),l(4)):(o(4),l(2)))},run(){h.current?t?(l(3),o(4)):(l(4),o(3)):t?l(1):o(1)},done(){var f;h.current&&typeof e.getAnimations=="function"&&e.getAnimations().length>0||(c.current=!1,l(7),t||n(!1),(f=i?.end)==null||f.call(i,t))}})}},[r,t,e,u]),r?[s,{closed:a(1),enter:a(2),leave:a(4),transition:a(2)||a(4)}]:[t,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function ET(r,{prepare:e,run:t,done:i,inFlight:s}){let n=Tn();return TT(r,{prepare:e,inFlight:s}),n.nextFrame(()=>{t(),n.requestAnimationFrame(()=>{n.add(AT(r,i))})}),n.dispose}function AT(r,e){var t,i;let s=Tn();if(!r)return s.dispose;let n=!1;s.add(()=>{n=!0});let a=(i=(t=r.getAnimations)==null?void 0:t.call(r).filter(o=>o instanceof CSSTransition))!=null?i:[];return a.length===0?(e(),s.dispose):(Promise.allSettled(a.map(o=>o.finished)).then(()=>{n||e()}),s.dispose)}function TT(r,{inFlight:e,prepare:t}){if(e!=null&&e.current){t();return}let i=r.style.transition;r.style.transition="none",t(),r.offsetHeight,r.style.transition=i}function RT(){const r=navigator.userAgentData;return r&&Array.isArray(r.brands)?r.brands.map(e=>{let{brand:t,version:i}=e;return t+"/"+i}).join(" "):navigator.userAgent}const y_={..._a},MT=y_.useInsertionEffect,DT=MT||(r=>r());function w_(r){const e=A.useRef(()=>{});return DT(()=>{e.current=r}),A.useCallback(function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.current==null?void 0:e.current(...i)},[])}var Wd=typeof document<"u"?A.useLayoutEffect:A.useEffect;let Ng=!1,PT=0;const Og=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+PT++;function LT(){const[r,e]=A.useState(()=>Ng?Og():void 0);return Wd(()=>{r==null&&e(Og())},[]),A.useEffect(()=>{Ng=!0},[]),r}const NT=y_.useId,OT=NT||LT;function IT(){const r=new Map;return{emit(e,t){var i;(i=r.get(e))==null||i.forEach(s=>s(t))},on(e,t){r.set(e,[...r.get(e)||[],t])},off(e,t){var i;r.set(e,((i=r.get(e))==null?void 0:i.filter(s=>s!==t))||[])}}}const jT=A.createContext(null),BT=A.createContext(null),FT=()=>{var r;return((r=A.useContext(jT))==null?void 0:r.id)||null},$T=()=>A.useContext(BT),HT="data-floating-ui-focusable";function zT(r){const{open:e=!1,onOpenChange:t,elements:i}=r,s=OT(),n=A.useRef({}),[a]=A.useState(()=>IT()),o=FT()!=null,[l,c]=A.useState(i.reference),h=w_((f,_,b)=>{n.current.openEvent=f?_:void 0,a.emit("openchange",{open:f,event:_,reason:b,nested:o}),t?.(f,_,b)}),u=A.useMemo(()=>({setPositionReference:c}),[]),d=A.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return A.useMemo(()=>({dataRef:n,open:e,onOpenChange:h,elements:d,events:a,floatingId:s,refs:u}),[e,h,d,a,s,u])}function WT(r){r===void 0&&(r={});const{nodeId:e}=r,t=zT({...r,elements:{reference:null,floating:null,...r.elements}}),i=r.rootContext||t,s=i.elements,[n,a]=A.useState(null),[o,l]=A.useState(null),h=s?.domReference||n,u=A.useRef(null),d=$T();Wd(()=>{h&&(u.current=h)},[h]);const f=f2({...r,elements:{...s,...o&&{reference:o}}}),_=A.useCallback(x=>{const w=kl(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),contextElement:x}:x;l(w),f.refs.setReference(w)},[f.refs]),b=A.useCallback(x=>{(kl(x)||x===null)&&(u.current=x,a(x)),(kl(f.refs.reference.current)||f.refs.reference.current===null||x!==null&&!kl(x))&&f.refs.setReference(x)},[f.refs]),p=A.useMemo(()=>({...f.refs,setReference:b,setPositionReference:_,domReference:u}),[f.refs,b,_]),g=A.useMemo(()=>({...f.elements,domReference:h}),[f.elements,h]),v=A.useMemo(()=>({...f,...i,refs:p,elements:g,nodeId:e}),[f,p,g,e,i]);return Wd(()=>{i.dataRef.current.floatingContext=v;const x=d?.nodesRef.current.find(w=>w.id===e);x&&(x.context=v)}),A.useMemo(()=>({...f,context:v,refs:p,elements:g}),[f,p,g,v])}const Ig="active",jg="selected";function Eu(r,e,t){const i=new Map,s=t==="item";let n=r;if(s&&r){const{[Ig]:a,[jg]:o,...l}=r;n=l}return{...t==="floating"&&{tabIndex:-1,[HT]:""},...n,...e.map(a=>{const o=a?a[t]:null;return typeof o=="function"?r?o(r):null:o}).concat(r).reduce((a,o)=>
7(o&&Object.entries(o).forEach(l=>{let[c,h]=l;if(!(s&&[Ig,jg].includes(c)))if(c.indexOf("on")===0){if(i.has(c)||i.set(c,[]),typeof h=="function"){var u;(u=i.get(c))==null||u.push(h),a[c]=function(){for(var d,f=arguments.length,_=new Array(f),b=0;b<f;b++)_[b]=arguments[b];return(d=i.get(c))==null?void 0:d.map(p=>p(..._)).find(p=>p!==void 0)}}}else a[c]=h}),a),{})}}function UT(r){r===void 0&&(r=[]);const e=r.map(o=>o?.reference),t=r.map(o=>o?.floating),i=r.map(o=>o?.item),s=A.useCallback(o=>Eu(o,r,"reference"),e),n=A.useCallback(o=>Eu(o,r,"floating"),t),a=A.useCallback(o=>Eu(o,r,"item"),i);return A.useMemo(()=>({getReferenceProps:s,getFloatingProps:n,getItemProps:a}),[s,n,a])}function Bg(r,e){return{...r,rects:{...r.rects,floating:{...r.rects.floating,height:e}}}}const VT=r=>({name:"inner",options:r,async fn(e){const{listRef:t,overflowRef:i,onFallbackChange:s,offset:n=0,index:a=0,minItemsVisible:o=4,referenceOverflowThreshold:l=0,scrollRef:c,...h}=p2(r,e),{rects:u,elements:{floating:d}}=e,f=t.current[a],_=c?.current||d,b=d.clientTop||_.clientTop,p=d.clientTop!==0,g=_.clientTop!==0,v=d===_;if(!f)return{};const x={...e,...await Dx(-f.offsetTop-d.clientTop-u.reference.height/2-f.offsetHeight/2-n).fn(e)},w=await bu(Bg(x,_.scrollHeight+b+d.clientTop),h),S=await bu(x,{...h,elementContext:"reference"}),k=xu(0,w.top),C=x.y+k,D=(_.scrollHeight>_.clientHeight?T=>T:m2)(xu(0,_.scrollHeight+(p&&v||g?b*2:0)-k-xu(0,w.bottom)));if(_.style.maxHeight=D+"px",_.scrollTop=k,s){const T=_.offsetHeight<f.offsetHeight*g2(o,t.current.length)-1||S.top>=-l||S.bottom>=-l;Pc.flushSync(()=>s(T))}return i&&(i.current=await bu(Bg({...x,y:C},_.offsetHeight+b+d.clientTop),h)),{y:C}}});function KT(r,e){const{open:t,elements:i}=r,{enabled:s=!0,overflowRef:n,scrollRef:a,onChange:o}=e,l=w_(o),c=A.useRef(!1),h=A.useRef(null),u=A.useRef(null);A.useEffect(()=>{if(!s)return;function f(b){if(b.ctrlKey||!_||n.current==null)return;const p=b.deltaY,g=n.current.top>=-.5,v=n.current.bottom>=-.5,x=_.scrollHeight-_.clientHeight,w=p<0?-1:1,S=p<0?"max":"min";_.scrollHeight<=_.clientHeight||(!g&&p>0||!v&&p<0?(b.preventDefault(),Pc.flushSync(()=>{l(k=>k+Math[S](p,x*w))})):/firefox/i.test(RT())&&(_.scrollTop+=p))}const _=a?.current||i.floating;if(t&&_)return _.addEventListener("wheel",f),requestAnimationFrame(()=>{h.current=_.scrollTop,n.current!=null&&(u.current={...n.current})}),()=>{h.current=null,u.current=null,_.removeEventListener("wheel",f)}},[s,t,i.floating,n,a,l]);const d=A.useMemo(()=>({onKeyDown(){c.current=!0},onWheel(){c.current=!1},onPointerMove(){c.current=!1},onScroll(){const f=a?.current||i.floating;if(!(!n.current||!f||!c.current)){if(h.current!==null){const _=f.scrollTop-h.current;(n.current.bottom<-.5&&_<-1||n.current.top<-.5&&_>1)&&Pc.flushSync(()=>l(b=>b+_))}requestAnimationFrame(()=>{h.current=f.scrollTop})}}}),[i.floating,l,n,a]);return A.useMemo(()=>s?{floating:d}:{},[s,d])}let Qa=A.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Qa.displayName="FloatingContext";let Lp=A.createContext(null);Lp.displayName="PlacementContext";function qT(r){return A.useMemo(()=>r?typeof r=="string"?{to:r}:r:null,[r])}function GT(){return A.useContext(Qa).setReference}function XT(){let{getFloatingProps:r,slot:e}=A.useContext(Qa);return A.useCallback((...t)=>Object.assign({},r(...t),{"data-anchor":e.anchor}),[r,e])}function YT(r=null){r===!1&&(r=null),typeof r=="string"&&(r={to:r});let e=A.useContext(Lp),t=A.useMemo(()=>r,[JSON.stringify(r,(s,n)=>{var a;return(a=n?.outerHTML)!=null?a:n})]);kt(()=>{e?.(t??null)},[e,t]);let i=A.useContext(Qa);return A.useMemo(()=>[i.setFloating,r?i.styles:{}],[i.setFloating,r,i.styles])}let Fg=4;function ZT({children:r,enabled:e=!0}){let[t,i]=A.useState(null),[s,n]=A.useState(0),a=A.useRef(null),[o,l]=A.useState(null);JT(o);let c=e&&t!==null&&o!==null,{to:h="bottom",gap:u=0,offset:d=0,padding:f=0,inner:_}=QT(t,o),[b,p="center"]=h.split(" ");kt(()=>{c&&n(0)},[c]);let{refs:g,floatingStyles:v,context:x}=WT({open:c,placement:b==="selection"?p==="center"?"bottom":`bottom-${p}`:p==="center"?`${b}`:`${b}-${p}`,strategy:"absolute",transform:!1,middleware:[Dx({mainAxis:b==="selection"?0:u,crossAxis:d}),v2({padding:f}),b!=="selection"&&b2({padding:f}),b==="selection"&&_?VT({..._,padding:f,overflowRef:a,offset:s,minItemsVisible:Fg,referenceOverflowThreshold:f,onFallbackChange(T){var M,R;if(!T)return;let O=x.elements.floating;if(!O)return;
vendor: 6,170 bytes, line 7
7let $=parseFloat(getComputedStyle(O).scrollPaddingBottom)||0,G=Math.min(Fg,O.childElementCount),V=0,q=0;for(let L of(R=(M=x.elements.floating)==null?void 0:M.childNodes)!=null?R:[])if(L instanceof HTMLElement){let N=L.offsetTop,I=N+L.clientHeight+$,H=O.scrollTop,W=H+O.clientHeight;if(N>=H&&I<=W)G--;else{q=Math.max(0,Math.min(I,W)-Math.max(N,H)),V=L.clientHeight;break}}G>=1&&n(L=>{let N=V*G-q+$;return L>=N?L:N})}}):null,x2({padding:f,apply({availableWidth:T,availableHeight:M,elements:R}){Object.assign(R.floating.style,{overflow:"auto",maxWidth:`${T}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${M}px)`})}})].filter(Boolean),whileElementsMounted:_2}),[w=b,S=p]=x.placement.split("-");b==="selection"&&(w="selection");let k=A.useMemo(()=>({anchor:[w,S].filter(Boolean).join(" ")}),[w,S]),C=KT(x,{overflowRef:a,onChange:n}),{getReferenceProps:y,getFloatingProps:E}=UT([C]),D=Be(T=>{l(T),g.setFloating(T)});return A.createElement(Lp.Provider,{value:i},A.createElement(Qa.Provider,{value:{setFloating:D,setReference:g.setReference,styles:v,getReferenceProps:y,getFloatingProps:E,slot:k}},r))}function JT(r){kt(()=>{if(!r)return;let e=new MutationObserver(()=>{let t=window.getComputedStyle(r).maxHeight,i=parseFloat(t);if(isNaN(i))return;let s=parseInt(t);isNaN(s)||i!==s&&(r.style.maxHeight=`${Math.ceil(i)}px`)});return e.observe(r,{attributes:!0,attributeFilter:["style"]}),()=>{e.disconnect()}},[r])}function QT(r,e){var t,i,s;let n=Au((t=r?.gap)!=null?t:"var(--anchor-gap, 0)",e),a=Au((i=r?.offset)!=null?i:"var(--anchor-offset, 0)",e),o=Au((s=r?.padding)!=null?s:"var(--anchor-padding, 0)",e);return{...r,gap:n,offset:a,padding:o}}function Au(r,e,t=void 0){let i=Ch(),s=Be((l,c)=>{if(l==null)return[t,null];if(typeof l=="number")return[l,null];if(typeof l=="string"){if(!c)return[t,null];let h=$g(l,c);return[h,u=>{let d=S_(l);{let f=d.map(_=>window.getComputedStyle(c).getPropertyValue(_));i.requestAnimationFrame(function _(){i.nextFrame(_);let b=!1;for(let[g,v]of d.entries()){let x=window.getComputedStyle(c).getPropertyValue(v);if(f[g]!==x){f[g]=x,b=!0;break}}if(!b)return;let p=$g(l,c);h!==p&&(u(p),h=p)})}return i.dispose}]}return[t,null]}),n=A.useMemo(()=>s(r,e)[0],[r,e]),[a=n,o]=A.useState();return kt(()=>{let[l,c]=s(r,e);if(o(l),!!c)return c(o)},[r,e]),a}function S_(r){let e=/var\((.*)\)/.exec(r);if(e){let t=e[1].indexOf(",");if(t===-1)return[e[1]];let i=e[1].slice(0,t).trim(),s=e[1].slice(t+1).trim();return s?[i,...S_(s)]:[i]}return[]}function $g(r,e){let t=document.createElement("div");e.appendChild(t),t.style.setProperty("margin-top","0px","important"),t.style.setProperty("margin-top",r,"important");let i=parseFloat(window.getComputedStyle(t).marginTop)||0;return e.removeChild(t),i}let Ah=A.createContext(null);Ah.displayName="OpenClosedContext";var pr=(r=>(r[r.Open=1]="Open",r[r.Closed=2]="Closed",r[r.Closing=4]="Closing",r[r.Opening=8]="Opening",r))(pr||{});function Th(){return A.useContext(Ah)}function k_({value:r,children:e}){return ke.createElement(Ah.Provider,{value:r},e)}function eR({children:r}){return ke.createElement(Ah.Provider,{value:null},r)}function tR(r){let e=Be(r),t=A.useRef(!1);A.useEffect(()=>(t.current=!1,()=>{t.current=!0,h_(()=>{t.current&&e()})}),[e])}function rR(){let r=typeof document>"u";return"useSyncExternalStore"in _a?(e=>e.useSyncExternalStore)(_a)(()=>()=>{},()=>!1,()=>!r):!1}function Np(){let r=rR(),[e,t]=A.useState(an.isHandoffComplete);return e&&an.isHandoffComplete===!1&&t(!1),A.useEffect(()=>{e!==!0&&t(!0)},[e]),A.useEffect(()=>an.handoff(),[]),r?!1:e}let iR=A.createContext(!1);function sR(){return A.useContext(iR)}function nR(r){let e=sR(),t=A.useContext(E_),i=So(r),[s,n]=A.useState(()=>{var a;if(!e&&t!==null)return(a=t.current)!=null?a:null;if(an.isServer)return null;let o=i?.getElementById("headlessui-portal-root");if(o)return o;if(i===null)return null;let l=i.createElement("div");return l.setAttribute("id","headlessui-portal-root"),i.body.appendChild(l)});return A.useEffect(()=>{s!==null&&(i!=null&&i.body.contains(s)||i==null||i.body.appendChild(s))},[s,i]),A.useEffect(()=>{e||t!==null&&n(t.current)},[t,n,e]),s}let C_=A.Fragment,oR=br(function(r,e){let t=r,i=A.useRef(null),s=Vr(p_(u=>{i.current=u}),e),n=So(i),a=nR(i),[o]=A.useState(()=>{var u;return an.isServer?null:(u=n?.createElement("div"))!=null?u:null}),l=A.useContext(Ud),c=Np();kt(()=>{!a||!o||a.contains(o)||(o.setAttribute("data-headlessui-portal",""),a.appendChild(o))},[a,o]),kt(()=>{if(o&&l)return l.register(o)},[l,o]),tR(()=>{var u;!a||!o||(o instanceof Node&&a.contains(o)&&a.removeChild(o),a.childNodes.length<=0&&((u=a.parentElement)==null||u.removeChild(a)))});let h=Gr();return c?!a||!o?null:Pc.createPortal(h({ourProps:{ref:s},theirProps:t,slot:{},defaultTag:C_,name:"Portal"}),o):null});function aR(r,e){let t=Vr(e),{enabled:i=!0,...s}=r,n=Gr();return i?ke.createElement(oR,{...s,ref:t}):n({ourProps:{ref:t},theirProps:s,slot:{},defaultTag:C_,name:"Portal"})}let lR=A.Fragment,E_=A.createContext(null);function cR(r,e){let{target:t,...i}=r,s={ref:Vr(e)},n=Gr();return ke.createElement(E_.Provider,{value:t},n({ourProps:s,theirProps:i,defaultTag:lR,name:"Popover.Group"}))}let Ud=A.createContext(null);function hR(){let r=A.useContext(Ud),e=A.useRef([]),t=Be(n=>(e.current.push(n),r&&r.register(n),()=>i(n))),i=Be(n=>{let a=e.current.indexOf(n);a!==-1&&e.current.splice(a,1),r&&r.unregister(n)}),s=A.useMemo(()=>({register:t,unregister:i,portals:e}),[t,i,e]);return[e,A.useMemo(()=>function({children:n}){return ke.createElement(Ud.Provider,{value:s},n)},[s])]}let uR=br(aR),dR=br(cR),fR=Object.assign(uR,{Group:dR});function pR({defaultContainers:r=[],portals:e,mainTreeNode:t}={}){let i=So(t),s=Be(()=>{var n,a;let o=[];for(let l of r)l!==null&&(l instanceof HTMLElement?o.push(l):"current"in l&&l.current instanceof HTMLElement&&o.push(l.current));if(e!=null&&e.current)for(let l of e.current)o.push(l);for(let l of(n=i?.querySelectorAll("html > *, body > *"))!=null?n:[])l!==document.body&&l!==document.head&&l instanceof HTMLElement&&l.id!=="headlessui-portal-root"&&(t&&(l.contains(t)||l.contains((a=t?.getRootNode())==null?void 0:a.host))||o.some(c=>l.contains(c))||o.push(l));return o}
7);return{resolveContainers:s,contains:Be(n=>s().some(a=>a.contains(n)))}}let A_=A.createContext(null);function T_({children:r,node:e}){let[t,i]=A.useState(null),s=R_(e??t);return ke.createElement(A_.Provider,{value:s},r,s===null&&ke.createElement(Oc,{features:ka.Hidden,ref:n=>{var a,o;if(n){for(let l of(o=(a=Ja(n))==null?void 0:a.querySelectorAll("html > *, body > *"))!=null?o:[])if(l!==document.body&&l!==document.head&&l instanceof HTMLElement&&l!=null&&l.contains(n)){i(l);break}}}}))}function R_(r=null){var e;return(e=A.useContext(A_))!=null?e:r}function mR(){let r=A.useRef(!1);return kt(()=>(r.current=!0,()=>{r.current=!1}),[]),r}var Hi=(r=>(r[r.Forwards=0]="Forwards",r[r.Backwards=1]="Backwards",r))(Hi||{});function M_(){let r=A.useRef(0);return __(!0,"keydown",e=>{e.key==="Tab"&&(r.current=e.shiftKey?1:0)},!0),r}function D_(r){var e;return!!(r.enter||r.enterFrom||r.enterTo||r.leave||r.leaveFrom||r.leaveTo)||((e=r.as)!=null?e:L_)!==A.Fragment||ke.Children.count(r.children)===1}let Rh=A.createContext(null);Rh.displayName="TransitionContext";var gR=(r=>(r.Visible="visible",r.Hidden="hidden",r))(gR||{});function vR(){let r=A.useContext(Rh);if(r===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return r}function bR(){let r=A.useContext(Mh);if(r===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return r}let Mh=A.createContext(null);Mh.displayName="NestingContext";function Dh(r){return"children"in r?Dh(r.children):r.current.filter(({el:e})=>e.current!==null).filter(({state:e})=>e==="visible").length>0}function P_(r,e){let t=Vi(r),i=A.useRef([]),s=mR(),n=Ch(),a=Be((f,_=ps.Hidden)=>{let b=i.current.findIndex(({el:p})=>p===f);b!==-1&&(Nr(_,{[ps.Unmount](){i.current.splice(b,1)},[ps.Hidden](){i.current[b].state="hidden"}}),n.microTask(()=>{var p;!Dh(i)&&s.current&&((p=t.current)==null||p.call(t))}))}),o=Be(f=>{let _=i.current.find(({el:b})=>b===f);return _?_.state!=="visible"&&(_.state="visible"):i.current.push({el:f,state:"visible"}),()=>a(f,ps.Unmount)}),l=A.useRef([]),c=A.useRef(Promise.resolve()),h=A.useRef({enter:[],leave:[]}),u=Be((f,_,b)=>{l.current.splice(0),e&&(e.chains.current[_]=e.chains.current[_].filter(([p])=>p!==f)),e?.chains.current[_].push([f,new Promise(p=>{l.current.push(p)})]),e?.chains.current[_].push([f,new Promise(p=>{Promise.all(h.current[_].map(([g,v])=>v)).then(()=>p())})]),_==="enter"?c.current=c.current.then(()=>e?.wait.current).then(()=>b(_)):b(_)}),d=Be((f,_,b)=>{Promise.all(h.current[_].splice(0).map(([p,g])=>g)).then(()=>{var p;(p=l.current.shift())==null||p()}).then(()=>b(_))});return A.useMemo(()=>({children:i,register:o,unregister:a,onStart:u,onStop:d,wait:c,chains:h}),[o,a,i,u,d,h,c])}let L_=A.Fragment,N_=co.RenderStrategy;function xR(r,e){var t,i;
7let{transition:s=!0,beforeEnter:n,afterEnter:a,beforeLeave:o,afterLeave:l,enter:c,enterFrom:h,enterTo:u,entered:d,leave:f,leaveFrom:_,leaveTo:b,...p}=r,[g,v]=A.useState(null),x=A.useRef(null),w=D_(r),S=Vr(...w?[x,e,v]:e===null?[]:[e]),k=(t=p.unmount)==null||t?ps.Unmount:ps.Hidden,{show:C,appear:y,initial:E}=vR(),[D,T]=A.useState(C?"visible":"hidden"),M=bR(),{register:R,unregister:O}=M;kt(()=>R(x),[R,x]),kt(()=>{if(k===ps.Hidden&&x.current){if(C&&D!=="visible"){T("visible");return}return Nr(D,{hidden:()=>O(x),visible:()=>R(x)})}},[D,x,R,O,C,k]);let $=Np();kt(()=>{if(w&&$&&D==="visible"&&x.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[x,D,$,w]);let G=E&&!y,V=y&&C&&E,q=A.useRef(!1),L=P_(()=>{q.current||(T("hidden"),O(x))},M),N=Be(F=>{q.current=!0;let P=F?"enter":"leave";L.onStart(x,P,j=>{j==="enter"?n?.():j==="leave"&&o?.()})}),I=Be(F=>{let P=F?"enter":"leave";q.current=!1,L.onStop(x,P,j=>{j==="enter"?a?.():j==="leave"&&l?.()}),P==="leave"&&!Dh(L)&&(T("hidden"),O(x))});A.useEffect(()=>{w&&s||(N(C),I(C))},[C,w,s]);let H=!(!s||!w||!$||G),[,W]=Pp(H,g,C,{start:N,end:I}),J=zs({ref:S,className:((i=$d(p.className,V&&c,V&&h,W.enter&&c,W.enter&&W.closed&&h,W.enter&&!W.closed&&u,W.leave&&f,W.leave&&!W.closed&&_,W.leave&&W.closed&&b,!W.transition&&C&&d))==null?void 0:i.trim())||void 0,...Dp(W)}),Z=0;D==="visible"&&(Z|=pr.Open),D==="hidden"&&(Z|=pr.Closed),W.enter&&(Z|=pr.Opening),W.leave&&(Z|=pr.Closing);let X=Gr();return ke.createElement(Mh.Provider,{value:L},ke.createElement(k_,{value:Z},X({ourProps:J,theirProps:p,defaultTag:L_,features:N_,visible:D==="visible",name:"Transition.Child"})))}function _R(r,e){let{show:t,appear:i=!1,unmount:s=!0,...n}=r,a=A.useRef(null),o=D_(r),l=Vr(...o?[a,e]:e===null?[]:[e]);Np();let c=Th();if(t===void 0&&c!==null&&(t=(c&pr.Open)===pr.Open),t===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[h,u]=A.useState(t?"visible":"hidden"),d=P_(()=>{t||u("hidden")}),[f,_]=A.useState(!0),b=A.useRef([t]);kt(()=>{f!==!1&&b.current[b.current.length-1]!==t&&(b.current.push(t),_(!1))},[b,t]);let p=A.useMemo(()=>({show:t,appear:i,initial:f}),[t,i,f]);kt(()=>{t?u("visible"):!Dh(d)&&a.current!==null&&u("hidden")},[t,d]);let g={unmount:s},v=Be(()=>{var S;f&&_(!1),(S=r.beforeEnter)==null||S.call(r)}),x=Be(()=>{var S;f&&_(!1),(S=r.beforeLeave)==null||S.call(r)}),w=Gr();return ke.createElement(Mh.Provider,{value:d},ke.createElement(Rh.Provider,{value:p},w({ourProps:{...g,as:A.Fragment,children:ke.createElement(O_,{ref:l,...g,...n,beforeEnter:v,beforeLeave:x})},theirProps:{},defaultTag:A.Fragment,features:N_,visible:h==="visible",name:"Transition"})))}function yR(r,e){let t=A.useContext(Rh)!==null,i=Th()!==null;return ke.createElement(ke.Fragment,null,!t&&i?ke.createElement(Vd,{ref:e,...r}):ke.createElement(O_,{ref:e,...r}))}let Vd=br(_R),O_=br(xR),wR=br(yR),SR=Object.assign(Vd,{Child:wR,Root:Vd});var kR=(r=>(r[r.Open=0]="Open",r[r.Closed=1]="Closed",r))(kR||{}),CR=(r=>(r[r.TogglePopover=0]="TogglePopover",r[r.ClosePopover=1]="ClosePopover",r[r.SetButton=2]="SetButton",r[r.SetButtonId=3]="SetButtonId",r[r.SetPanel=4]="SetPanel",r[r.SetPanelId=5]="SetPanelId",r))(CR||{});let ER={0:r=>({...r,popoverState:Nr(r.popoverState,{0:1,1:0}),__demoMode:!1}),1(r){return r.popoverState===1?r:{...r,popoverState:1,__demoMode:!1}},2(r,e){return r.button===e.button?r:{...r,button:e.button}},3(r,e){return r.buttonId===e.buttonId?r:{...r,buttonId:e.buttonId}},4(r,e){return r.panel===e.panel?r:{...r,panel:e.panel}},5(r,e){return r.panelId===e.panelId?r:{...r,panelId:e.panelId}}},Op=A.createContext(null);Op.displayName="PopoverContext";function Ph(r){let e=A.useContext(Op);if(e===null){let t=new Error(`<${r} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Ph),t}return e}let Lh=A.createContext(null);Lh.displayName="PopoverAPIContext";function Ip(r){let e=A.useContext(Lh);if(e===null){let t=new Error(`<${r} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Ip),t}return e}let jp=A.createContext(null);jp.displayName="PopoverGroupContext";function I_(){return A.useContext(jp)}let Nh=A.createContext(null);Nh.displayName="PopoverPanelContext";function AR(){return A.useContext(Nh)}function TR(r,e){return Nr(e.type,ER,r,e)}let RR="div";function MR(r,e){var t;let{__demoMode:i=!1,...s}=r,n=A.useRef(null),a=Vr(e,p_(L=>{n.current=L})),o=A.useRef([]),l=A.useReducer(TR,{__demoMode:i,popoverState:i?0:1,buttons:o,button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:A.createRef(),afterPanelSentinel:A.createRef(),afterButtonSentinel:A.createRef()}),[{popoverState:c,button:h,buttonId:u,panel:d,panelId:f,beforePanelSentinel:_,afterPanelSentinel:b,afterButtonSentinel:p},g]=l,v=So((t=n.current)!=null?t:h),x=A.useMemo(()=>
7{if(!h||!d)return!1;for(let Z of document.querySelectorAll("body > *"))if(Number(Z?.contains(h))^Number(Z?.contains(d)))return!0;let L=Eh(),N=L.indexOf(h),I=(N+L.length-1)%L.length,H=(N+1)%L.length,W=L[I],J=L[H];return!d.contains(W)&&!d.contains(J)},[h,d]),w=Vi(u),S=Vi(f),k=A.useMemo(()=>({buttonId:w,panelId:S,close:()=>g({type:1})}),[w,S,g]),C=I_(),y=C?.registerPopover,E=Be(()=>{var L;return(L=C?.isFocusWithinPopoverGroup())!=null?L:v?.activeElement&&(h?.contains(v.activeElement)||d?.contains(v.activeElement))});A.useEffect(()=>y?.(k),[y,k]);let[D,T]=hR(),M=R_(h),R=pR({mainTreeNode:M,portals:D,defaultContainers:[h,d]});mT(v?.defaultView,"focus",L=>{var N,I,H,W,J,Z;L.target!==window&&L.target instanceof HTMLElement&&c===0&&(E()||h&&d&&(R.contains(L.target)||(I=(N=_.current)==null?void 0:N.contains)!=null&&I.call(N,L.target)||(W=(H=b.current)==null?void 0:H.contains)!=null&&W.call(H,L.target)||(Z=(J=p.current)==null?void 0:J.contains)!=null&&Z.call(J,L.target)||g({type:1})))},!0),pT(c===0,R.resolveContainers,(L,N)=>{g({type:1}),b_(N,Mp.Loose)||(L.preventDefault(),h?.focus())});let O=Be(L=>{g({type:1});let N=L?L instanceof HTMLElement?L:"current"in L&&L.current instanceof HTMLElement?L.current:h:h;N?.focus()}),$=A.useMemo(()=>({close:O,isPortalled:x}),[O,x]),G=A.useMemo(()=>({open:c===0,close:O}),[c,O]),V={ref:a},q=Gr();return ke.createElement(T_,{node:M},ke.createElement(ZT,null,ke.createElement(Nh.Provider,{value:null},ke.createElement(Op.Provider,{value:l},ke.createElement(Lh.Provider,{value:$},ke.createElement(QA,{value:O},ke.createElement(k_,{value:Nr(c,{0:pr.Open,1:pr.Closed})},ke.createElement(T,null,q({ourProps:V,theirProps:s,slot:G,defaultTag:RR,name:"Popover"})))))))))}let DR="button";function PR(r,e){let t=A.useId(),{id:i=`headlessui-popover-button-${t}`,disabled:s=!1,autoFocus:n=!1,...a}=r,[o,l]=Ph("Popover.Button"),{isPortalled:c}=Ip("Popover.Button"),h=A.useRef(null),u=`headlessui-focus-sentinel-${A.useId()}`,d=I_(),f=d?.closeOthers,_=AR()!==null;A.useEffect(()=>{if(!_)return l({type:3,buttonId:i}),()=>{l({type:3,buttonId:null})}},[_,i,l]);let[b]=A.useState(()=>Symbol()),p=Vr(h,e,GT(),Be(N=>{if(!_){if(N)o.buttons.current.push(b);else{let I=o.buttons.current.indexOf(b);I!==-1&&o.buttons.current.splice(I,1)}o.buttons.current.length>1&&console.warn("You are already using a <Popover.Button /> but only 1 <Popover.Button /> is supported."),N&&l({type:2,button:N})}})),g=Vr(h,e),v=So(h),x=Be(N=>{var I,H,W;if(_){if(o.popoverState===1)return;switch(N.key){case as.Space:case as.Enter:N.preventDefault(),(H=(I=N.target).click)==null||H.call(I),l({type:1}),(W=o.button)==null||W.focus();break}}else switch(N.key){case as.Space:case as.Enter:N.preventDefault(),N.stopPropagation(),o.popoverState===1&&f?.(o.buttonId),l({type:0});break;case as.Escape:if(o.popoverState!==0)return f?.(o.buttonId);if(!h.current||v!=null&&v.activeElement&&!h.current.contains(v.activeElement))return;N.preventDefault(),N.stopPropagation(),l({type:1});break}}),w=Be(N=>{_||N.key===as.Space&&N.preventDefault()}),S=Be(N=>{var I,H;d_(N.currentTarget)||s||(_?(l({type:1}),(I=o.button)==null||I.focus()):(N.preventDefault(),N.stopPropagation(),o.popoverState===1&&f?.(o.buttonId),l({type:0}),(H=o.button)==null||H.focus()))}),k=Be(N=>{N.preventDefault(),N.stopPropagation()}),{isFocusVisible:C,focusProps:y}
vendor: 5,702 bytes, line 7
7=BA({autoFocus:n}),{isHovered:E,hoverProps:D}=jA({isDisabled:s}),{pressed:T,pressProps:M}=UA({disabled:s}),R=o.popoverState===0,O=A.useMemo(()=>({open:R,active:T||R,disabled:s,hover:E,focus:C,autofocus:n}),[R,E,C,T,s,n]),$=gT(r,o.button),G=Hd(_?{ref:g,type:$,onKeyDown:x,onClick:S,disabled:s||void 0,autoFocus:n}:{ref:p,id:o.buttonId,type:$,"aria-expanded":o.popoverState===0,"aria-controls":o.panel?o.panelId:void 0,disabled:s||void 0,autoFocus:n,onKeyDown:x,onKeyUp:w,onClick:S,onMouseDown:k},y,D,M),V=M_(),q=Be(()=>{let N=o.panel;if(!N)return;function I(){Nr(V.current,{[Hi.Forwards]:()=>Gs(N,$i.First),[Hi.Backwards]:()=>Gs(N,$i.Last)})===Ic.Error&&Gs(Eh().filter(H=>H.dataset.headlessuiFocusGuard!=="true"),Nr(V.current,{[Hi.Forwards]:$i.Next,[Hi.Backwards]:$i.Previous}),{relativeTo:o.button})}I()}),L=Gr();return ke.createElement(ke.Fragment,null,L({ourProps:G,theirProps:a,slot:O,defaultTag:DR,name:"Popover.Button"}),R&&!_&&c&&ke.createElement(Oc,{id:u,ref:o.afterButtonSentinel,features:ka.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:q}))}let LR="div",NR=co.RenderStrategy|co.Static;function j_(r,e){let t=A.useId(),{id:i=`headlessui-popover-backdrop-${t}`,transition:s=!1,...n}=r,[{popoverState:a},o]=Ph("Popover.Backdrop"),[l,c]=A.useState(null),h=Vr(e,c),u=Th(),[d,f]=Pp(s,l,u!==null?(u&pr.Open)===pr.Open:a===0),_=Be(g=>{if(d_(g.currentTarget))return g.preventDefault();o({type:1})}),b=A.useMemo(()=>({open:a===0}),[a]),p={ref:h,id:i,"aria-hidden":!0,onClick:_,...Dp(f)};return Gr()({ourProps:p,theirProps:n,slot:b,defaultTag:LR,features:NR,visible:d,name:"Popover.Backdrop"})}let OR="div",IR=co.RenderStrategy|co.Static;function jR(r,e){let t=A.useId(),{id:i=`headlessui-popover-panel-${t}`,focus:s=!1,anchor:n,portal:a=!1,modal:o=!1,transition:l=!1,...c}=r,[h,u]=Ph("Popover.Panel"),{close:d,isPortalled:f}=Ip("Popover.Panel"),_=`headlessui-focus-sentinel-before-${t}`,b=`headlessui-focus-sentinel-after-${t}`,p=A.useRef(null),g=qT(n),[v,x]=YT(g),w=XT();g&&(a=!0);let[S,k]=A.useState(null),C=Vr(p,e,g?v:null,Be(N=>u({type:4,panel:N})),k),y=So(p);kt(()=>(u({type:5,panelId:i}),()=>{u({type:5,panelId:null})}),[i,u]);let E=Th(),[D,T]=Pp(l,S,E!==null?(E&pr.Open)===pr.Open:h.popoverState===0);sT(D,h.button,()=>{u({type:1})});let M=h.__demoMode?!1:o&&D;wT(M,y);let R=Be(N=>{var I;switch(N.key){case as.Escape:if(h.popoverState!==0||!p.current||y!=null&&y.activeElement&&!p.current.contains(y.activeElement))return;N.preventDefault(),N.stopPropagation(),u({type:1}),(I=h.button)==null||I.focus();break}});A.useEffect(()=>{var N;r.static||h.popoverState===1&&((N=r.unmount)==null||N)&&u({type:4,panel:null})},[h.popoverState,r.unmount,r.static,u]),A.useEffect(()=>{if(h.__demoMode||!s||h.popoverState!==0||!p.current)return;let N=y?.activeElement;p.current.contains(N)||Gs(p.current,$i.First)},[h.__demoMode,s,p.current,h.popoverState]);let O=A.useMemo(()=>({open:h.popoverState===0,close:d}),[h.popoverState,d]),$=Hd(g?w():{},{ref:C,id:i,onKeyDown:R,onBlur:s&&h.popoverState===0?N=>{var I,H,W,J,Z;let X=N.relatedTarget;X&&p.current&&((I=p.current)!=null&&I.contains(X)||(u({type:1}),((W=(H=h.beforePanelSentinel.current)==null?void 0:H.contains)!=null&&W.call(H,X)||(Z=(J=h.afterPanelSentinel.current)==null?void 0:J.contains)!=null&&Z.call(J,X))&&X.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...c.style,...x,"--button-width":tT(h.button,!0).width},...Dp(T)}),G=M_(),V=Be(()=>{let N=p.current;if(!N)return;function I(){Nr(G.current,{[Hi.Forwards]:()=>{var H;Gs(N,$i.First)===Ic.Error&&((H=h.afterPanelSentinel.current)==null||H.focus())},[Hi.Backwards]:()=>{var H;(H=h.button)==null||H.focus({preventScroll:!0})}})}I()}),q=Be(()=>{let N=p.current;if(!N)return;function I(){Nr(G.current,{[Hi.Forwards]:()=>{if(!h.button)return;let H=Eh(),W=H.indexOf(h.button),J=H.slice(0,W+1),Z=[...H.slice(W+1),...J];for(let X of Z.slice())if(X.dataset.headlessuiFocusGuard==="true"||S!=null&&S.contains(X)){let F=Z.indexOf(X);F!==-1&&Z.splice(F,1)}Gs(Z,$i.First,{sorted:!1})},[Hi.Backwards]:()=>{var H;Gs(N,$i.Previous)===Ic.Error&&((H=h.button)==null||H.focus())}})}I()}),L=Gr();return ke.createElement(eR,null,ke.createElement(Nh.Provider,{value:i},ke.createElement(Lh.Provider,{value:{close:d,isPortalled:f}},ke.createElement(fR,{enabled:a?r.static||D:!1},D&&f&&ke.createElement(Oc,{id:_,ref:h.beforePanelSentinel,features:ka.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:V}),L({ourProps:$,theirProps:c,slot:O,defaultTag:OR,features:IR,visible:D,name:"Popover.Panel"}),D&&f&&ke.createElement(Oc,{id:b,ref:h.afterPanelSentinel,features:ka.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:q})))))}let BR="div";function FR(r,e){let t=A.useRef(null),i=Vr(t,e),[s,n]=A.useState([]),a=Be(b=>{n(p=>{let g=p.indexOf(b);if(g!==-1){let v=p.slice();return v.splice(g,1),v}return p})}),o=Be(b=>(n(p=>[...p,b]),()=>a(b))),l=Be(()=>{var b;let p=Ja(t);if(!p)return!1;let g=p.activeElement;return(b=t.current)!=null&&b.contains(g)?!0:s.some(v=>{var x,w;return((x=p.getElementById(v.buttonId.current))==null?void 0:x.contains(g))||((w=p.getElementById(v.panelId.current))==null?void 0:w.contains(g))})}),c=Be(b=>{for(let p of s)p.buttonId.current!==b&&p.close()}),h=A.useMemo(()=>({registerPopover:o,unregisterPopover:a,isFocusWithinPopoverGroup:l,closeOthers:c}),[o,a,l,c]),u=A.useMemo(()=>({}),[]),d=r,f={ref:i},_=Gr();return ke.createElement(T_,null,ke.createElement(jp.Provider,{value:h},_({ourProps:f,theirProps:d,slot:u,defaultTag:BR,name:"Popover.Group"})))}let $R=br(MR),HR=br(PR),zR=br(j_),WR=br(j_),UR=br(jR),VR=br(FR),Hg=Object.assign($R,{Button:HR,Backdrop:WR,Overlay:zR,Panel:UR,Group:VR});const B_=r=>
7({js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",json:"json",html:"html",css:"css",py:"python",java:"java",rb:"ruby",cpp:"cpp",c:"c",cs:"csharp",go:"go",rs:"rust",php:"php",swift:"swift",md:"plaintext",sh:"bash"})[r]||"typescript",KR=A.memo(({onClick:r,isFullscreen:e})=>m.jsx("button",{onClick:r,className:"ml-4 p-1 rounded hover:bg-exkalibur-elements-background-depth-3 text-exkalibur-elements-textTertiary hover:text-exkalibur-elements-textPrimary transition-colors",title:e?"Exit Fullscreen":"Enter Fullscreen",children:m.jsx("div",{className:e?"i-ph:corners-in":"i-ph:corners-out"})})),qR=A.memo(({isFullscreen:r,children:e})=>r?m.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/50 flex items-center justify-center p-6",children:m.jsx("div",{className:"w-full h-full max-w-[90vw] max-h-[90vh] bg-exkalibur-elements-background-depth-2 rounded-lg border border-exkalibur-elements-borderColor shadow-xl overflow-hidden",children:e})}):m.jsx(m.Fragment,{children:e})),GR=1024*1024,XR=/[\x00-\x08\x0E-\x1F]/,zg=r=>r.length>GR||XR.test(r),YR=(r,e)=>{try{if(zg(r)||zg(e))return{beforeLines:[],afterLines:[],hasChanges:!1,lineChanges:{before:new Set,after:new Set},unifiedBlocks:[],isBinary:!0};const t=h=>h.replace(/\r\n/g,` 8`).split(` 9`).map(u=>u.trimEnd()),i=t(r),s=t(e);if(i.join(` 10`)===s.join(` 11`))return{beforeLines:i,afterLines:s,hasChanges:!1,lineChanges:{before:new Set,after:new Set},unifiedBlocks:[],isBinary:!1};const n={before:new Set,after:new Set},a=[];let o=0,l=0;for(;o<i.length||l<s.length;)if(o<i.length&&l<s.length&&i[o]===s[l])a.push({lineNumber:l,content:s[l],type:"unchanged",correspondingLine:o}),o++,l++;else{let h=!1;const u=3;for(let d=1;d<=u&&o+d<i.length&&l+d<s.length;d++)if(i[o+d]===s[l]){for(let f=0;f<d;f++)n.before.add(o+f),a.push({lineNumber:o+f,content:i[o+f],type:"removed",correspondingLine:l,charChanges:[{value:i[o+f],type:"removed"}]});o+=d,h=!0;break}else if(i[o]===s[l+d]){for(let f=0;f<d;f++)n.after.add(l+f),a.push({lineNumber:l+f,content:s[l+f],type:"added",correspondingLine:o,charChanges:[{value:s[l+f],type:"added"}]});l+=d,h=!0;break}if(!h)if(o<i.length&&l<s.length){const d=i[o],f=s[l];let _=0;for(;_<d.length&&_<f.length&&d[_]===f[_];)_++;let b=0;for(;b<d.length-_&&b<f.length-_&&d[d.length-1-b]===f[f.length-1-b];)b++;const p=d.slice(0,_),g=d.slice(_,d.length-b),v=f.slice(_,f.length-b),x=d.slice(d.length-b);g||v?(g&&(n.before.add(o),a.push({lineNumber:o,content:d,type:"removed",correspondingLine:l,charChanges:[{value:p,type:"unchanged"},{value:g,type:"removed"},{value:x,type:"unchanged"}]}),o++),v&&(n.after.add(l),a.push({lineNumber:l,content:f,type:"added",correspondingLine:o-1,charChanges:[{value:p,type:"unchanged"},{value:v,type:"added"},{value:x,type:"unchanged"}]}),l++)):(o<i.length&&(n.before.add(o),a.push({lineNumber:o,content:i[o],type:"removed",correspondingLine:l,charChanges:[{value:i[o],type:"removed"}]}),o++),l<s.length&&(n.after.add(l),a.push({lineNumber:l,content:s[l],type:"added",correspondingLine:o-1,charChanges:[{value:s[l],type:"added"}]}),l++))}else o<i.length&&(n.before.add(o),a.push({lineNumber:o,content:i[o],type:"removed",correspondingLine:l,charChanges:[{value:i[o],type:"removed"}]}),o++),l<s.length&&(n.after.add(l),a.push({lineNumber:l,content:s[l],type:"added",correspondingLine:o-1,charChanges:[{value:s[l],type:"added"}]}),l++)}const c=a.sort((h,u)=>h.lineNumber-u.lineNumber);return{beforeLines:i,afterLines:s,hasChanges:n.before.size>0||n.after.size>0,lineChanges:n,unifiedBlocks:c,isBinary:!1}}catch(t){return console.error("Error processing changes:",t),{beforeLines:[],afterLines:[],hasChanges:!1,lineChanges:{before:new Set,after:new Set},unifiedBlocks:[],error:!0,isBinary:!1}}},F_="w-9 shrink-0 pl-2 py-1 text-left font-mono text-exkalibur-elements-textTertiary border-r border-exkalibur-elements-borderColor bg-exkalibur-elements-background-depth-1",$_="px-1 py-1 font-mono whitespace-pre flex-1 group-hover:bg-exkalibur-elements-background-depth-2 text-exkalibur-elements-textPrimary",ZR="h-full overflow-auto diff-panel-content",JR={added:"bg-green-500/10 dark:bg-green-500/20 border-l-4 border-green-500",removed:"bg-red-500/10 dark:bg-red-500/20 border-l-4 border-red-500",unchanged:""},QR={added:"text-green-700 dark:text-green-500 bg-green-500/10 dark:bg-green-500/20",removed:"text-red-700 dark:text-red-500 bg-red-500/10 dark:bg-red-500/20",unchanged:"text-exkalibur-elements-textPrimary"},eM=r=>m.jsx("div",{className:"h-full flex items-center justify-center p-4",children:m.jsxs("div",{className:"text-center text-exkalibur-elements-textTertiary",children:[m.jsx("div",{className:`i-ph:${r==="binary"?"file-x":"warning-circle"} text-4xl text-red-400 mb-2 mx-auto`}),m.jsx("p",{className:"font-medium text-exkalibur-elements-textPrimary",children:r==="binary"?"Binary f
11ile detected":"Error processing file"}),m.jsx("p",{className:"text-sm mt-1",children:r==="binary"?"Diff view is not available for binary files":"Could not generate diff preview"})]})}),tM=A.memo(({beforeCode:r,language:e,highlighter:t,theme:i})=>m.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-4",children:[m.jsxs("div",{className:"text-center text-exkalibur-elements-textTertiary",children:[m.jsx("div",{className:"i-ph:files text-4xl text-green-400 mb-2 mx-auto"}),m.jsx("p",{className:"font-medium text-exkalibur-elements-textPrimary",children:"Files are identical"}),m.jsx("p",{className:"text-sm mt-1",children:"Both versions match exactly"})]}),m.jsxs("div",{className:"mt-4 w-full max-w-2xl bg-dark/75 backdrop-blur-xl rounded-lg border border-exkalibur-elements-borderColor overflow-hidden",children:[m.jsx("div",{className:"p-2 text-xs font-bold text-white border-b border-exkalibur-elements-borderColor",children:"Current Content"}),m.jsx("div",{className:"overflow-auto max-h-96",children:r.split(` 12`).map((s,n)=>m.jsxs("div",{className:"flex group min-w-fit",children:[m.jsx("div",{className:F_,children:n+1}),m.jsxs("div",{className:$_,children:[m.jsx("span",{className:"mr-2",children:" "}),m.jsx("span",{dangerouslySetInnerHTML:{__html:t?t.codeToHtml(s,{lang:e,theme:i==="dark"?"github-dark":"github-light"}).replace(/<\/?pre[^>]*>/g,"").replace(/<\/?code[^>]*>/g,""):s}})]})]},n))})]})]})),rM=(r,e)=>A.useMemo(()=>YR(r,e),[r,e]),iM=A.memo(({lineNumber:r,content:e,type:t,highlighter:i,language:s,block:n,theme:a})=>{const o=JR[t],l=()=>{if(t==="unchanged"||!n.charChanges){const c=i?i.codeToHtml(e,{lang:s,theme:a==="dark"?"github-dark":"github-light"}).replace(/<\/?pre[^>]*>/g,"").replace(/<\/?code[^>]*>/g,""):e;return m.jsx("span",{dangerouslySetInnerHTML:{__html:c}})}return m.jsx(m.Fragment,{children:n.charChanges.map((c,h)=>{const u=QR[c.type],d=i?i.codeToHtml(c.value,{lang:s,theme:a==="dark"?"github-dark":"github-light"}).replace(/<\/?pre[^>]*>/g,"").replace(/<\/?code[^>]*>/g,""):c.value;return m.jsx("span",{className:u,dangerouslySetInnerHTML:{__html:d}},h)})})};return m.jsxs("div",{className:"flex group min-w-fit bg-dark/10 backdrop-blur-xl",children:[m.jsx("div",{className:F_,children:r+1}),m.jsxs("div",{className:`${$_} ${o}`,children:[m.jsxs("span",{className:"mr-2 text-exkalibur-elements-textTertiary",children:[t==="added"&&m.jsx("span",{className:"text-green-700 dark:text-green-500",children:"+"}),t==="removed"&&m.jsx("span",{className:"text-red-700 dark:text-red-500",children:"-"}),t==="unchanged"&&" "]}),l()]})]})}),sM=A.memo(({filename:r,hasChanges:e,onToggleFullscreen:t,isFullscreen:i,beforeCode:s,afterCode:n})=>{const{additions:a,deletions:o}=A.useMemo(()=>e?ya(s,n,{newlineIsToken:!1,ignoreWhitespace:!0,ignoreCase:!1}).reduce((h,u)=>(u.added&&(h.additions+=u.value.split(` 13`).length),u.removed&&(h.deletions+=u.value.split(` 14`).length),h),{additions:0,deletions:0}):{additions:0,deletions:0},[e,s,n]),l=a>0||o>0;return m.jsxs("div",{className:"flex items-center bg-white/10 backdrop-blur-xl p-2 text-sm text-white/90 shrink-0",children:[m.jsx("div",{className:"i-ph:file mr-2 h-4 w-4 shrink-0"}),m.jsx("span",{className:"truncate",children:r}),m.jsxs("span",{className:"ml-auto shrink-0 flex items-center gap-2",children:[e?m.jsxs(m.Fragment,{children:[l&&m.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[a>0&&m.jsxs("span",{className:"text-green-700 dark:text-green-500",children:["+",a]}),o>0&&m.jsxs("span",{className:"text-red-700 dark:text-red-500",children:["-",o]})]}),m.jsx("span",{className:"text-yellow-600 dark:text-yellow-400",children:"Modified"}),m.jsx("span",{className:"text-exkalibur-elements-textTertiary text-xs",children:new Date().toLocaleTimeString()})]}):m.jsx("span",{className:"text-green-700 dark:text-green-400",children:"No Changes"}),m.jsx(KR,{onClick:t,isFullscreen:i})]})]})});let Tl=null,$o=null;const nM=async()=>Tl||$o||($o=w2({themes:["github-dark","github-light"],langs:["typescript","javascript","json","html","css","jsx","tsx","python","php","java","c","cpp","csharp","go","ruby","rust","plaintext"]}),Tl=await $o,$o=null,Tl),oM=A.memo(({beforeCode:r,afterCode:e,filename:t,language:i})=>{const[s,n]=A.useState(!1),[a,o]=A.useState(null),l=Ve(Rc),c=A.useCallback(()=>{n(_=>!_)},[]),{unifiedBlocks:h,hasChanges:u,isBinary:d,error:f}=rM(r,e);return A.useEffect(()=>{nM().then(o)},[]),d||f?eM(d?"binary":"error"):a?m.jsx(qR,{isFullscreen:s,children:m.jsxs("div",{className:"w-full h-full flex flex-col ",children:[m.jsx(sM,{filename:t,hasChanges:u,onToggleFullscreen:c,isFullscreen:s,beforeCode:r,afterCode:e}),m.jsx("div",{className:ZR,children:u?m.jsx("div",{className:"overflow-x-auto min-w-full",children:h.map((_,b)=>m.jsx(iM,{lineNumber:_.lineNumber,content:_.content,type:_.type,highlighter:a,language:i,block:_,theme:l},`${_.lineNumber}-${b}`))}):m.jsx(tM,{beforeCode:r,language:i,highlighter:a,theme:l})})]})}):m.jsx("div",{className:"h-full flex items-center justify-center",children:m.jsx("div",{className:"text-exkalibur-elements-textTertiary",children:"Loading diff..."})})}),aM=A.memo(({fileHistory:r,setFileHistory:e})=>{const t=Ve(ue.files),i=Ve(ue.selectedFile),s=Ve(ue.currentDocument),n=Ve(ue.unsavedFiles);if(A.useEffect(()=>{if(i&&s){const d=t[i];if(!d||!("content"in d))return;const f=r[i],_=s.value,b=_.replace(/\r\n/g,` 15`).trim(),p=(f?.originalContent||d.content).replace(/\r\n/g,` 16`).trim();if(!f){if(b!==p){const S=ya(d.content,_);e(k=>({...k,[i]:{originalContent:d.content,lastModified:Date.now(),changes:S,versions:[{timestamp:Date.now(),content:_}],changeSource:"auto-save"}}
16))}return}const v=f.versions[f.versions.length-1]?.content.replace(/\r\n/g,` 17`).trim();if(b===v)return;const x=Px(i);if(y2(x,f.originalContent,_)){const S=ya(f.originalContent,_);if(S.some(C=>(C.added||C.removed)&&C.value.trim().length>0)){const C={originalContent:f.originalContent,lastModified:Date.now(),changes:[...f.changes,...S].slice(-100),versions:[...f.versions,{timestamp:Date.now(),content:_}].slice(-10),changeSource:"auto-save"};e(y=>({...y,[i]:C}))}}}},[i,s?.value,t,e,n]),!i||!s)return m.jsx("div",{className:"flex w-full h-full justify-center items-center bg-exkalibur-elements-background-depth-1 text-exkalibur-elements-textPrimary",children:"Select a file to view differences"});const a=t[i],o=a&&"content"in a?a.content:"",l=s.value,h=r[i]?.originalContent||o,u=B_(i.split(".").pop()||"");try{return m.jsx("div",{className:"h-full overflow-hidden",children:m.jsx(oM,{beforeCode:h,afterCode:l,language:u,filename:i,lightTheme:"github-light",darkTheme:"github-dark"})})}catch(d){return console.error("DiffView render error:",d),m.jsx("div",{className:"flex w-full h-full justify-center items-center bg-exkalibur-elements-background-depth-1 text-red-400",children:m.jsxs("div",{className:"text-center",children:[m.jsx("div",{className:"i-ph:warning-circle text-4xl mb-2"}),m.jsx("p",{children:"Failed to render diff view"})]})})}});let Kd=[],H_=[];(()=>{let r="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<r.length;e++)(e%2?H_:Kd).push(t=t+r[e])})();function lM(r){if(r<768)return!1;for(let e=0,t=Kd.length;;){let i=e+t>>1;if(r<Kd[i])t=i;else if(r>=H_[i])e=i+1;else return!0;if(e==t)return!1}}function Wg(r){return r>=127462&&r<=127487}const Ug=8205;function cM(r,e,t=!0,i=!0){return(t?z_:hM)(r,e,i)}function z_(r,e,t){if(e==r.length)return e;e&&W_(r.charCodeAt(e))&&U_(r.charCodeAt(e-1))&&e--;let i=Tu(r,e);for(e+=Vg(i);e<r.length;){let s=Tu(r,e);if(i==Ug||s==Ug||t&&lM(s))e+=Vg(s),i=s;else if(Wg(s)){let n=0,a=e-2;for(;a>=0&&Wg(Tu(r,a));)n++,a-=2;if(n%2==0)break;e+=2}else break}return e}function hM(r,e,t){for(;e>0;){let i=z_(r,e-2,t);if(i<e)return i;e--}return 0}function Tu(r,e){let t=r.charCodeAt(e);if(!U_(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return W_(i)?(t-55296<<10)+(i-56320)+65536:t}function W_(r){return r>=56320&&r<57344}function U_(r){return r>=55296&&r<56320}function Vg(r){return r<65536?1:2}let Ge=class V_{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]=ho(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),li.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ho(this,e,t);let i=[];return this.decompose(e,t,i,0),li.from(i,t-e)}eq(e){if(e==this)return!0;
vendor: 49,979 bytes, lines 17-23
17if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new oa(this),n=new oa(e);for(let a=t,o=t;;){if(s.next(a),n.next(a),a=0,s.lineBreak!=n.lineBreak||s.done!=n.done||s.value!=n.value)return!1;if(o+=s.value.length,s.done||o>=i)return!0}}iter(e=1){return new oa(this,e)}iterRange(e,t=this.length){return new K_(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new q_(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]?V_.empty:e.length<=32?new pt(e):li.from(pt.split(e,[]))}};class pt extends Ge{constructor(e,t=uM(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let n=0;;n++){let a=this.text[n],o=s+a.length;if((t?i:o)>=e)return new dM(s,o,i,a);s=o+1,i++}}decompose(e,t,i,s){let n=e<=0&&t>=this.length?this:new pt(Kg(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let a=i.pop(),o=dc(n.text,a.text.slice(),0,n.length);if(o.length<=32)i.push(new pt(o,a.length+n.length));else{let l=o.length>>1;i.push(new pt(o.slice(0,l)),new pt(o.slice(l)))}}else i.push(n)}replace(e,t,i){if(!(i instanceof pt))return super.replace(e,t,i);[e,t]=ho(this,e,t);let s=dc(this.text,dc(i.text,Kg(this.text,0,e)),t),n=this.length+i.length-(t-e);return s.length<=32?new pt(s,n):li.from(pt.split(s,[]),n)}sliceString(e,t=this.length,i=` 18`){[e,t]=ho(this,e,t);let s="";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&&(s+=i),e<l&&t>n&&(s+=o.slice(Math.max(0,e-n),t-n)),n=l+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let n of e)i.push(n),s+=n.length+1,i.length==32&&(t.push(new pt(i,s)),i=[],s=-1);return s>-1&&t.push(new pt(i,s)),t}}class li extends Ge{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,s){for(let n=0;;n++){let a=this.children[n],o=s+a.length,l=i+a.lines-1;if((t?l:o)>=e)return a.lineInner(e,t,i,s);s=o+1,i=l+1}}decompose(e,t,i,s){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=s&((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]=ho(this,e,t),i.lines<this.lines)for(let s=0,n=0;s<this.children.length;s++){let a=this.children[s],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 h=this.children.slice();return h[s]=l,new li(h,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=` 19`){[e,t]=ho(this,e,t);let s="";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&&(s+=i),e<l&&t>a&&(s+=o.sliceString(e-a,t-a,i)),a=l+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof li))return 0;let i=0,[s,n,a,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,n+=t){if(s==a||n==o)return i;let l=this.children[s],c=e.children[n];if(l!=c)return i+l.scanIdentical(c,t);i+=l.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let f of e)i+=f.lines;if(i<32){let f=[];for(let _ of e)_.flatten(f);return new pt(f,t)}let s=Math.max(32,i>>5),n=s<<1,a=s>>1,o=[],l=0,c=-1,h=[];function u(f){let _;if(f.lines>n&&f instanceof li)for(let b of f.children)u(b);else f.lines>a&&(l>a||!l)?(d(),o.push(f)):f instanceof pt&&l&&(_=h[h.length-1])instanceof pt&&f.lines+_.lines<=32?(l+=f.lines,c+=f.length+1,h[h.length-1]=new pt(_.text.concat(f.text),_.length+1+f.length)):(l+f.lines>s&&d(),l+=f.lines,c+=f.length+1,h.push(f))}function d(){l!=0&&(o.push(h.length==1?h[0]:li.from(h,c)),c=-1,l=h.length=0)}for(let f of e)u(f);return d(),o.length==1?o[0]:new li(o,t)}}Ge.empty=new pt([""],0);function uM(r){let e=-1;for(let t of r)e+=t.length+1;return e}function dc(r,e,t=0,i=1e9){for(let s=0,n=0,a=!0;n<r.length&&s<=i;n++){let o=r[n],l=s+o.length;l>=t&&(l>i&&(o=o.slice(0,i-s)),s<t&&(o=o.slice(t-s)),a?(e[e.length-1]+=o,a=!1):e.push(o)),s=l+1}return e}function Kg(r,e,t){return dc(r,[""],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 pt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],n=this.offsets[i],a=n>>1,o=s instanceof pt?s.text.length:s.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=` 20`,this;e--}else if(s instanceof pt){let l=s.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=s.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 pt?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 K_{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:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.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 q_{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=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=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Ge.prototype[Symbol.iterator]=function(){return this.iter()},oa.prototype[Symbol.iterator]=K_.prototype[Symbol.iterator]=q_.prototype[Symbol.iterator]=function(){return this});class dM{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function ho(r,e,t){return e=Math.max(0,Math.min(r.length,e)),[e,Math.max(e,Math.min(r.length,t))]}function Dt(r,e,t=!0,i=!0){return cM(r,e,t,i)}function fM(r){return r>=56320&&r<57344}function pM(r){return r>=55296&&r<56320}function $r(r,e){let t=r.charCodeAt(e);if(!pM(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return fM(i)?(t-55296<<10)+(i-56320)+65536:t}function Bp(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function Ii(r){return r<65536?1:2}const qd=/\r\n?|\n/;var Ft=function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r}(Ft||(Ft={}));class bi{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,s=0;t<this.sections.length;){let n=this.sections[t++],a=this.sections[t++];a<0?(e(i,s,n),s+=n):s+=a,i+=n}}iterChangedRanges(e,t=!1){Gd(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new bi(e)}composeDesc(e){return this.empty?e:e.empty?this:G_(this,e)}mapDesc(e,t=!1){return e.empty?this:Xd(this,e,t)}mapPos(e,t=-1,i=Ft.Simple){let s=0,n=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],l=this.sections[a++],c=s+o;if(l<0){if(c>e)return n+(e-s);n+=o}else{if(i!=Ft.Simple&&c>=e&&(i==Ft.TrackDel&&s<e&&c>e||i==Ft.TrackBefore&&s<e||i==Ft.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==s||t<0?n:n+l;n+=l}s=c}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return n}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let n=this.sections[i++],a=this.sections[i++],o=s+n;if(a>=0&&s<=t&&o>=e)return s<e&&o>t?"cover":!0;s=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}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 bi(e)}static create(e){return new bi(e)}}class bt extends bi{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 Gd(this,(t,i,s,n,a)=>e=e.replace(s,s+(i-t),a),!1),e}mapDesc(e,t=!1){return Xd(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,n=0;s<t.length;s+=2){let a=t[s],o=t[s+1];if(o>=0){t[s]=o,t[s+1]=a;let l=s>>1;for(;i.length<l;)i.push(Ge.empty);i.push(a?e.slice(n,n+a):Ge.empty)}n+=a}return new bt(t,i)}compose(e){return this.empty?e:e.empty?this:G_(this,e,!0)}map(e,t=!1){return e.empty?this:Xd(this,e,t,!0)}iterChanges(e,t=!1){Gd(this,e,t)}get desc(){return bi.create(this.sections)}filter(e){let t=[],i=[],s=[],n=new Ca(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 h=Math.min(n.len,l-o);Bt(s,h,-1);let u=n.ins==-1?-1:n.off==0?n.ins:0;Bt(t,h,u),u>0&&ms(i,t,n.text),n.forward(h),o+=h}let c=e[a++];for(;o<c;){if(n.done)break e;let h=Math.min(n.len,c-o);Bt(t,h,-1),Bt(s,h,n.ins==-1?-1:n.off==0?n.ins:0),n.forward(h),o+=h}}return{changes:new bt(t,i),filtered:bi.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],n=[],a=0,o=null;function l(h=!1){if(!h&&!s.length)return;a<t&&Bt(s,t-a,-1);let u=new bt(s,n);o=o?o.compose(u.map(o)):u,s=[],n=[],a=0}function c(h){if(Array.isArray(h))for(let u of h)c(u);else if(h instanceof bt){if(h.length!=t)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${t})`);l(),o=o?o.compose(h.map(o)):h}else{let{from:u,to:d=u,insert:f}=h;if(u>d||u<0||d>t)throw new RangeError(`Invalid change range ${u} to ${d} (in doc of length ${t})`);let _=f?typeof f=="string"?Ge.of(f.split(i||qd)):f:Ge.empty,b=_.length;if(u==d&&b==0)return;u<a&&l(),u>a&&Bt(s,u-a,-1),Bt(s,d-u,b),ms(n,s,_),a=d}}return c(e),l(!o),o}static empty(e){return new bt(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let n=e[s];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<s;)i.push(Ge.empty);i[s]=Ge.of(n.slice(1)),t.push(n[0],i[s].length)}}}return new bt(t,i)}static createSet(e,t){return new bt(e,t)}}function Bt(r,e,t,i=!1){if(e==0&&t<=0)return;let s=r.length-2;s>=0&&t<=0&&t==r[s+1]?r[s]+=e:s>=0&&e==0&&r[s]==0?r[s+1]+=t:i?(r[s]+=e,r[s+1]+=t):r.push(e,t)}function ms(r,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<i;)r.push(Ge.empty);r.push(t)}}function Gd(r,e,t){let i=r.inserted;for(let s=0,n=0,a=0;a<r.sections.length;){let o=r.sections[a++],l=r.sections[a++];if(l<0)s+=o,n+=o;else{let c=s,h=n,u=Ge.empty;for(;c+=o,h+=l,l&&i&&(u=u.append(i[a-2>>1])),!(t||a==r.sections.length||r.sections[a+1]<0);)o=r.sections[a++],l=r.sections[a++];e(s,c,n,h,u),s=c,n=h}}}function Xd(r,e,t,i=!1){let s=[],n=i?[]:null,a=new Ca(r),o=new Ca(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);Bt(s,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(Bt(s,o.ins,-1);c;){let h=Math.min(a.len,c);a.ins>=0&&l<a.i&&a.len<=h&&(Bt(s,0,a.ins),n&&ms(n,s,a.text),l=a.i),a.forward(h),c-=h}o.next()}else if(a.ins>=0){let c=0,h=a.len;for(;h;)if(o.ins==-1){let u=Math.min(h,o.len);c+=u,h-=u,o.forward(u)}else if(o.ins==0&&o.len<h)h-=o.len,o.next();else break;Bt(s,c,l<a.i?a.ins:0),n&&l<a.i&&ms(n,s,a.text),l=a.i,a.forward(a.len-h)}else{if(a.done&&o.done)return n?bt.createSet(s,n):bi.create(s);throw new Error("Mismatched change set lengths")}}}function G_(r,e,t=!1){let i=[],s=t?[]:null,n=new Ca(r),a=new Ca(e);for(let o=!1;;){if(n.done&&a.done)return s?bt.createSet(i,s):bi.create(i);if(n.ins==0)Bt(i,n.len,0,o),n.next();else if(a.len==0&&!a.done)Bt(i,0,a.ins,o),s&&ms(s,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 h=a.ins==-1?-1:a.off?0:a.ins;Bt(i,l,h,o),s&&h&&ms(s,i,a.text)}else a.ins==-1?(Bt(i,n.off?0:n.len,l,o),s&&ms(s,i,n.textBit(l))):(Bt(i,n.off?0:n.len,a.off?0:a.ins,o),s&&!a.off&&ms(s,i,a.text));o=(n.ins>l||a.ins>=0&&a.len>l)&&(o||i.length>c),n.forward2(l),a.forward(l)}}}}class Ca{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?Ge.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Ge.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 Ys{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}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 bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Ys(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return oe.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return oe.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!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 oe.range(e.anchor,e.head)}static create(e,t,i){return new Ys(e,t,i)}}class oe{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:oe.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 oe([this.main],0)}addRange(e,t=!0){return oe.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,oe.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 oe(e.ranges.map(t=>Ys.fromJSON(t)),e.main)}static single(e,t=e){return new oe([oe.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,s=0;s<e.length;s++){let n=e[s];if(n.empty?n.from<=i:n.from<i)return oe.normalized(e.slice(),t);i=n.to}return new oe(e,t)}static cursor(e,t=0,i,s){return Ys.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(s??16777215)<<6)}static range(e,t,i,s){let n=(i??16777215)<<6|(s==null?7:Math.min(6,s));return t<e?Ys.create(t,e,48|n):Ys.create(e,t,(t>e?8:0)|n)}static normalized(e,t=0){let i=e[t];e.sort((s,n)=>s.from-n.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let n=e[s],a=e[s-1];if(n.empty?n.from<=a.to:n.from<a.to){let o=a.from,l=Math.max(n.to,a.to);s<=t&&t--,e.splice(--s,2,n.anchor>n.head?oe.range(l,o):oe.range(o,l))}}return new oe(e,t)}}function X_(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Fp=0;class xe{constructor(e,t,i,s,n){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Fp++,this.default=e([]),this.extensions=typeof n=="function"?n(this):n}get reader(){return this}static define(e={}){return new xe(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:$p),!!e.static,e.enables)}of(e){return new fc([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fc(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fc(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function $p(r,e){return r==e||r.length==e.length&&r.every((t,i)=>t===e[i])}class fc{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Fp++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,n=this.id,a=e[n]>>1,o=this.type==2,l=!1,c=!1,h=[];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||h.push(e[u.id]);return{create(u){return u.values[a]=i(u),1},update(u,d){if(l&&d.docChanged||c&&(d.docChanged||d.selection)||Yd(u,h)){let f=i(u);if(o?!qg(f,u.values[a],s):!s(f,u.values[a]))return u.values[a]=f,1}return 0},reconfigure:(u,d)=>{let f,_=d.config.address[n];if(_!=null){let b=Bc(d,_);if(this.dependencies.every(p=>p instanceof xe?d.facet(p)===u.facet(p):p instanceof Et?d.field(p,!1)==u.field(p,!1):!0)||(o?qg(f=i(u),b,s):s(f=i(u),b)))return u.values[a]=b,0}else f=i(u);return u.values[a]=f,1}}}}function qg(r,e,t){if(r.length!=e.length)return!1;for(let i=0;i<r.length;i++)if(!t(r[i],e[i]))return!1;return!0}function Yd(r,e){let t=!1;for(let i of e)aa(r,i)&1&&(t=!0);return t}function mM(r,e,t){let i=t.map(l=>r[l.id]),s=t.map(l=>l.type),n=i.filter(l=>!(l&1)),a=r[e.id]>>1;function o(l){let c=[];for(let h=0;h<i.length;h++){let u=Bc(l,i[h]);if(s[h]==2)for(let d of u)c.push(d);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(!Yd(l,n))return 0;let h=o(l);return e.compare(h,l.values[a])?0:(l.values[a]=h,1)},reconfigure(l,c){let h=Yd(l,i),u=c.config.facets[e.id],d=c.facet(e);if(u&&!h&&$p(t,u))return l.values[a]=d,0;let f=o(l);return e.compare(f,d)?(l.values[a]=d,0):(l.values[a]=f,1)}}}const Rl=xe.define({static:!0});class Et{constructor(e,t,i,s,n){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=n,this.provides=void 0}static define(e){let t=new Et(Fp++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Rl).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,s)=>{let n=i.values[t],a=this.updateF(n,s);return this.compareF(n,a)?0:(i.values[t]=a,1)},reconfigure:(i,s)=>{let n=i.facet(Rl),a=s.facet(Rl),o;return(o=n.find(l=>l.field==this))&&o!=a.find(l=>l.field==this)?(i.values[t]=o.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Rl.of({field:this,create:e})]}get extension(){return this}}const Ws={lowest:4,low:3,default:2,high:1,highest:0};function Ho(r){return e=>new Y_(e,r)}const Ds={highest:Ho(Ws.highest),high:Ho(Ws.high),default:Ho(Ws.default),low:Ho(Ws.low),lowest:Ho(Ws.lowest)};class Y_{constructor(e,t){this.inner=e,this.prec=t}}class fn{of(e){return new Zd(this,e)}reconfigure(e){return fn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Zd{constructor(e,t){this.compartment=e,this.inner=t}}class jc{constructor(e,t,i,s,n,a){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,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 s=[],n=Object.create(null),a=new Map;for(let d of gM(e,t,a))d instanceof Et?s.push(d):(n[d.facet.id]||(n[d.facet.id]=[])).push(d);let o=Object.create(null),l=[],c=[];for(let d of s)o[d.id]=c.length<<1,c.push(f=>d.slot(f));let h=i?.config.facets;for(let d in n){let f=n[d],_=f[0].facet,b=h&&h[d]||[];if(f.every(p=>p.type==0))if(o[_.id]=l.length<<1|1,$p(b,f))l.push(i.facet(_));else{let p=_.combine(f.map(g=>g.value));l.push(i&&_.compare(p,i.facet(_))?i.facet(_):p)}else{for(let p of f)p.type==0?(o[p.id]=l.length<<1|1,l.push(p.value)):(o[p.id]=c.length<<1,c.push(g=>p.dynamicSlot(g)));o[_.id]=c.length<<1,c.push(p=>mM(p,_,f))}}let u=c.map(d=>d(o));return new jc(e,a,u,o,l,n)}}function gM(r,e,t){let i=[[],[],[],[],[]],s=new Map;function n(a,o){let l=s.get(a);if(l!=null){if(l<=o)return;let c=i[l].indexOf(a);c>-1&&i[l].splice(c,1),a instanceof Zd&&t.delete(a.compartment)}if(s.set(a,o),Array.isArray(a))for(let c of a)n(c,o);else if(a instanceof Zd){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 Y_)n(a.inner,a.prec);else if(a instanceof Et)i[o].push(a),a.provides&&n(a.provides,o);else if(a instanceof fc)i[o].push(a),a.facet.extensions&&n(a.facet.extensions,Ws.default);else{let c=a.extension;if(!c)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(r,Ws.default),i.reduce((a,o)=>a.concat(o))}function aa(r,e){if(e&1)return 2;let t=e>>1,i=r.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;r.status[t]=4;let s=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|s}function Bc(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}const Z_=xe.define(),Jd=xe.define({combine:r=>r.some(e=>e),static:!0}),J_=xe.define({combine:r=>r.length?r[0]:void 0,static:!0}),Q_=xe.define(),ey=xe.define(),ty=xe.define(),ry=xe.define({combine:r=>r.length?r[0]:!1});class Yi{constructor(e,t){this.type=e,this.value=t}static define(){return new vM}}class vM{of(e){return new Yi(this,e)}}class bM{constructor(e){this.map=e}of(e){return new Pe(this,e)}}class Pe{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 Pe(this.type,t)}is(e){return this.type==e}static define(e={}){return new bM(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let n=s.map(t);n&&i.push(n)}return i}}Pe.reconfigure=Pe.define();Pe.appendConfig=Pe.define();class gt{constructor(e,t,i,s,n,a){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=n,this.scrollIntoView=a,this._doc=null,this._state=null,i&&X_(i,t.newLength),n.some(o=>o.type==gt.time)||(this.annotations=n.concat(gt.time.of(Date.now())))}static create(e,t,i,s,n,a){return new gt(e,t,i,s,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(gt.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}gt.time=Yi.define();gt.userEvent=Yi.define();gt.addToHistory=Yi.define();gt.remote=Yi.define();function xM(r,e){let t=[];for(let i=0,s=0;;){let n,a;if(i<r.length&&(s==e.length||e[s]>=r[i]))n=r[i++],a=r[i++];else if(s<e.length)n=e[s++],a=e[s++];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 iy(r,e,t){var i;let s,n,a;return t?(s=e.changes,n=bt.empty(e.changes.length),a=r.changes.compose(e.changes)):(s=e.changes.map(r.changes),n=r.changes.mapDesc(e.changes,!0),a=r.changes.compose(s)),{changes:a,selection:e.selection?e.selection.map(n):(i=r.selection)===null||i===void 0?void 0:i.map(s),effects:Pe.mapEffects(r.effects,s).concat(Pe.mapEffects(e.effects,n)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function Qd(r,e,t){let i=e.selection,s=Jn(e.annotations);return e.userEvent&&(s=s.concat(gt.userEvent.of(e.userEvent))),{changes:e.changes instanceof bt?e.changes:bt.of(e.changes||[],t,r.facet(J_)),selection:i&&(i instanceof oe?i:oe.single(i.anchor,i.head)),effects:Jn(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function sy(r,e,t){let i=Qd(r,e.length?e[0]:{},r.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=iy(i,Qd(r,e[n],a?i.changes.newLength:r.doc.length),a)}let s=gt.create(r,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return yM(t?_M(s):s)}function _M(r){let e=r.startState,t=!0;for(let s of e.facet(Q_)){let n=s(r);if(n===!1){t=!1;break}Array.isArray(n)&&(t=t===!0?n:xM(t,n))}if(t!==!0){let s,n;if(t===!1)n=r.changes.invertedDesc,s=bt.empty(e.doc.length);else{let a=r.changes.filter(t);s=a.changes,n=a.filtered.mapDesc(a.changes).invertedDesc}r=gt.create(e,s,r.selection&&r.selection.map(n),Pe.mapEffects(r.effects,n),r.annotations,r.scrollIntoView)}let i=e.facet(ey);for(let s=i.length-1;s>=0;s--){let n=i[s](r);n instanceof gt?r=n:Array.isArray(n)&&n.length==1&&n[0]instanceof gt?r=n[0]:r=sy(e,Jn(n),!1)}return r}function yM(r){let e=r.startState,t=e.facet(ty),i=r;for(let s=t.length-1;s>=0;s--){let n=t[s](r);n&&Object.keys(n).length&&(i=iy(i,Qd(e,n,r.changes.newLength),!0))}return i==r?r:gt.create(e,r.changes,r.selection,i.effects,i.annotations,i.scrollIntoView)}const wM=[];function Jn(r){return r==null?wM:Array.isArray(r)?r:[r]}var vt=function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r}(vt||(vt={}));const SM=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ef;try{ef=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function kM(r){if(ef)return ef.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>"Â"&&(t.toUpperCase()!=t.toLowerCase()||SM.test(t)))return!0}return!1}function CM(r){return e=>{if(!/\S/.test(e))return vt.Space;if(kM(e))return vt.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return vt.Word;return vt.Other}}class He{constructor(e,t,i,s,n,a){this.config=e,this.doc=t,this.selection=i,this.values=s,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),Bc(this,i)}update(...e){return sy(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let o of e.effects)o.is(fn.reconfigure)?(t&&(s=new Map,t.compartments.forEach((l,c)=>s.set(c,l)),t=null),s.set(o.value.compartment,o.value.extension)):o.is(Pe.reconfigure)?(t=null,i=o.value):o.is(Pe.appendConfig)&&(t=null,i=Jn(i).concat(o.value));let n;t?n=e.startState.values.slice():(t=jc.resolve(i,s,this),n=new He(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let a=e.startState.facet(Jd)?e.newSelection:e.newSelection.asSingle();new He(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:oe.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),n=[i.range],a=Jn(i.effects);for(let o=1;o<t.ranges.length;o++){let l=e(t.ranges[o]),c=this.changes(l.changes),h=c.map(s);for(let d=0;d<o;d++)n[d]=n[d].map(h);let u=s.mapDesc(c,!0);n.push(l.range.map(u)),s=s.compose(h),a=Pe.mapEffects(a,h).concat(Pe.mapEffects(Jn(l.effects),u))}return{changes:s,selection:oe.create(n,t.mainIndex),effects:a}}changes(e=[]){return e instanceof bt?e:bt.of(e,this.doc.length,this.facet(He.lineSeparator))}toText(e){return Ge.of(e.split(this.facet(He.lineSeparator)||qd))}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),Bc(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof Et&&this.config.address[s.id]!=null&&(t[i]=s.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 s=[];if(i){for(let n in i)if(Object.prototype.hasOwnProperty.call(e,n)){let a=i[n],o=e[n];s.push(a.init(l=>a.spec.fromJSON(o,l)))}}return He.create({doc:e.doc,selection:oe.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=jc.resolve(e.extensions||[],new Map),i=e.doc instanceof Ge?e.doc:Ge.of((e.doc||"").split(t.staticFacet(He.lineSeparator)||qd)),s=e.selection?e.selection instanceof oe?e.selection:oe.single(e.selection.anchor,e.selection.head):oe.single(0);return X_(s,i.length),t.staticFacet(Jd)||(s=s.asSingle()),new He(t,i,s,t.dynamicSlots.map(()=>null),(n,a)=>a.create(n),null)}get tabSize(){return this.facet(He.tabSize)}get lineBreak(){return this.facet(He.lineSeparator)||` 21`}get readOnly(){return this.facet(ry)}phrase(e,...t){for(let i of this.facet(He.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let n=+(s||1);return!n||n>t.length?i:t[n-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let n of this.facet(Z_))for(let a of n(this,t,i))Object.prototype.hasOwnProperty.call(a,e)&&s.push(a[e]);return s}charCategorizer(e){return CM(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),n=this.charCategorizer(e),a=e-i,o=e-i;for(;a>0;){let l=Dt(t,a,!1);if(n(t.slice(l,a))!=vt.Word)break;a=l}for(;o<s;){let l=Dt(t,o);if(n(t.slice(o,l))!=vt.Word)break;o=l}return a==o?null:oe.range(a+i,o+i)}}He.allowMultipleSelections=Jd;He.tabSize=xe.define({combine:r=>r.length?r[0]:4});He.lineSeparator=J_;He.readOnly=ry;He.phrases=xe.define({compare(r,e){let t=Object.keys(r),i=Object.keys(e);return t.length==i.length&&t.every(s=>r[s]==e[s])}});He.languageData=Z_;He.changeFilter=Q_;He.transactionFilter=ey;He.transactionExtender=ty;fn.reconfigure=Pe.define();function Rn(r,e,t={}){let i={};for(let s of r)for(let n of Object.keys(s)){let a=s[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 s in e)i[s]===void 0&&(i[s]=e[s]);return i}class pn{eq(e){return this==e}range(e,t=e){return tf.create(e,t,this)}}pn.prototype.startSide=pn.prototype.endSide=0;pn.prototype.point=!1;pn.prototype.mapMode=Ft.TrackDel;let tf=class ny{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new ny(e,t,i)}};function rf(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}class Hp{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let n=i?this.to:this.from;for(let a=s,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,s){for(let n=this.findIndex(t,-1e9,!0),a=this.findIndex(i,1e9,!1,n);n<a;n++)if(s(this.from[n]+e,this.to[n]+e,this.value[n])===!1)return!1}map(e,t){let i=[],s=[],n=[],a=-1,o=-1;for(let l=0;l<this.value.length;l++){let c=this.value[l],h=this.from[l]+e,u=this.to[l]+e,d,f;if(h==u){let _=t.mapPos(h,c.startSide,c.mapMode);if(_==null||(d=f=_,c.startSide!=c.endSide&&(f=t.mapPos(h,c.endSide),f<d)))continue}else if(d=t.mapPos(h,c.startSide),f=t.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(a<0&&(a=d),c.point&&(o=Math.max(o,f-d)),i.push(c),s.push(d-a),n.push(f-a))}return{mapped:i.length?new Hp(s,n,i,o):null,pos:a}}}class Ue{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new Ue(e,t,i,s)}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:s=0,filterTo:n=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(i&&(t=t.slice().sort(rf)),this.isEmpty)return t.length?Ue.of(t):this;let o=new oy(this,null,-1).goto(0),l=0,c=[],h=new mn;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++];h.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||s>this.chunkEnd(o.chunkIndex)||n<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!a||s>o.to||n<o.from||a(o.from,o.to,o.value))&&(h.addInner(o.from,o.to,o.value)||c.push(tf.create(o.from,o.to,o.value))),o.next());return h.finishInner(this.nextLayer.isEmpty&&!c.length?Ue.empty:this.nextLayer.update({add:c,filter:a,filterFrom:s,filterTo:n}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],s=-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)s=Math.max(s,l.maxPoint),t.push(l),i.push(e.mapPos(o));else if(c===!0){let{mapped:h,pos:u}=l.map(o,e);h&&(s=Math.max(s,h.maxPoint),t.push(h),i.push(u))}}let n=this.nextLayer.map(e);return t.length==0?n:new Ue(i,t,n||Ue.empty,s)}between(e,t,i){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let n=this.chunkPos[s],a=this.chunk[s];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 Ea.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ea.from(e).goto(t)}static compare(e,t,i,s,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=Gg(a,o,i),c=new zo(a,l,n),h=new zo(o,l,n);i.iterGaps((u,d,f)=>Xg(c,u,h,d,f,s)),i.empty&&i.length==0&&Xg(c,0,h,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=999999999);let n=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),a=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(n.length!=a.length)return!1;if(!n.length)return!0;let o=Gg(n,a),l=new zo(n,o,0).goto(i),c=new zo(a,o,0).goto(i);for(;;){if(l.to!=c.to||!sf(l.active,c.active)||l.point&&(!c.point||!l.point.eq(c.point)))return!1;if(l.to>s)return!0;l.next(),c.next()}}static spans(e,t,i,s,n=-1){let a=new zo(e,null,n).goto(t),o=t,l=a.openStart;for(;;){let c=Math.min(a.to,i);if(a.point){let h=a.activeForPoint(a.to),u=a.pointFrom<t?h.length+1:a.point.startSide<0?h.length:Math.min(h.length,l);s.point(o,c,a.point,h,u,a.pointRank),l=Math.min(a.openEnd(c),h.length)}else c>o&&(s.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 mn;for(let s of e instanceof tf?[e]:t?EM(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return Ue.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=Ue.empty;s=s.nextLayer)t=new Ue(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}Ue.empty=new Ue([],[],null,-1);function EM(r){if(r.length>1)for(let e=r[0],t=1;t<r.length;t++){let i=r[t];if(rf(e,i)>0)return r.slice().sort(rf);e=i}return r}Ue.empty.nextLayer=Ue.empty;class mn{finishChunk(e){this.chunks.push(new Hp(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 mn)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<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(Ue.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Ue.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Gg(r,e,t){let i=new Map;for(let n of r)for(let a=0;a<n.chunk.length;a++)n.chunk[a].maxPoint<=0&&i.set(n.chunk[a],n.chunkPos[a]);let s=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)&&s.add(n.chunk[a])}return s}class oy{constructor(e,t,i,s=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=s}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 s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<s)&&this.setRangeIndex(s)}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 Ea{constructor(e){this.heap=e}static from(e,t=null,i=-1){let s=[];for(let n=0;n<e.length;n++)for(let a=e[n];!a.isEmpty;a=a.nextLayer)a.maxPoint>=i&&s.push(new oy(a,t,i,n));return s.length==1?s[0]:new Ea(s)}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--)Ru(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--)Ru(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(),Ru(this.heap,0)}}}function Ru(r,e){for(let t=r[e];;){let i=(e<<1)+1;if(i>=r.length)break;let s=r[i];if(i+1<r.length&&s.compare(r[i+1])>=0&&(s=r[i+1],i++),t.compare(s)<0)break;r[i]=t,r[e]=s,e=i}}class zo{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=Ea.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){Ml(this.active,e),Ml(this.activeTo,e),Ml(this.activeRank,e),this.minActive=Yg(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:n}=this.cursor;for(;t<this.activeRank.length&&(n-this.activeRank[t]||s-this.activeTo[t])>0;)t++;Dl(this.active,t,i),Dl(this.activeTo,t,s),Dl(this.activeRank,t,n),e&&Dl(e,t,this.cursor.from),this.minActive=Yg(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&Ml(i,s)}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 s=i.length-1;s>=0&&i[s]<e;s--)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 Xg(r,e,t,i,s,n){r.goto(e),t.goto(i);let a=i+s,o=i,l=i-e;for(;;){let c=r.to+l-t.to,h=c||r.endSide-t.endSide,u=h<0?r.to+l:t.to,d=Math.min(u,a);if(r.point||t.point?r.point&&t.point&&(r.point==t.point||r.point.eq(t.point))&&sf(r.activeForPoint(r.to),t.activeForPoint(t.to))||n.comparePoint(o,d,r.point,t.point):d>o&&!sf(r.active,t.active)&&n.compareRange(o,d,r.active,t.active),u>a)break;(c||r.openEnd!=t.openEnd)&&n.boundChange&&n.boundChange(u),o=u,h<=0&&r.next(),h>=0&&t.next()}}function sf(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!=e[t]&&!r[t].eq(e[t]))return!1;return!0}function Ml(r,e){for(let t=e,i=r.length-1;t<i;t++)r[t]=r[t+1];r.pop()}function Dl(r,e,t){for(let i=r.length-1;i>=e;i--)r[i+1]=r[i];r[e]=t}function Yg(r,e){let t=-1,i=1e9;for(let s=0;s<e.length;s++)(e[s]-i||r[s].endSide-r[t].endSide)<0&&(t=s,i=e[s]);return t}function Oh(r,e,t=r.length){let i=0;for(let s=0;s<t&&s<r.length;)r.charCodeAt(s)==9?(i+=e-i%e,s++):(i++,s=Dt(r,s));return i}function AM(r,e,t,i){for(let s=0,n=0;;){if(n>=e)return s;if(s==r.length)break;n+=r.charCodeAt(s)==9?t-n%t:1,s=Dt(r,s)}return r.length}const nf="ͼ",Zg=typeof Symbol>"u"?"__"+nf:Symbol.for(nf),of=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Jg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ks{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function n(a,o,l,c){let h=[],u=/^@(\w+)\b/.exec(a[0]),d=u&&u[1]=="keyframes";if(u&&o==null)return l.push(a[0]+";");for(let f in o){let _=o[f];if(/&/.test(f))n(f.split(/,\s*/).map(b=>a.map(p=>b.replace(/&/,p))).reduce((b,p)=>b.concat(p)),_,l);else if(_&&typeof _=="object"){if(!u)throw new RangeError("The value of a property ("+f+") should be a primitive value.");n(s(f),_,h,d)}else _!=null&&h.push(f.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+_+";")}(h.length||d)&&l.push((i&&!u&&!c?a.map(i):a).join(", ")+" {"+h.join(" ")+"}")}for(let a in e)n(s(a),e[a],this.rules)}getRules(){return this.rules.join(` 22`)}static newName(){let e=Jg[Zg]||1;return Jg[Zg]=e+1,nf+e.toString(36)}static mount(e,t,i){let s=e[of],n=i&&i.nonce;s?n&&s.setNonce(n):s=new TM(e,n),s.mount(Array.isArray(t)?t:[t],e)}}let Qg=new Map;class TM{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let n=Qg.get(i);if(n)return e[of]=n;this.sheet=new s.CSSStyleSheet,Qg.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[of]=this}mount(e,t){let i=this.sheet,s=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],s++)}else{for(;n<l;)s+=this.modules[n++].rules.length;s+=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()+` 23`;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 Cs={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:"'"},Aa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},RM=typeof navigator<"u"&&/Mac/.test(navigator.platform),MM=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Mt=0;Mt<10;Mt++)Cs[48+Mt]=Cs[96+Mt]=String(Mt);for(var Mt=1;Mt<=24;Mt++)Cs[Mt+111]="F"+Mt;for(var Mt=65;Mt<=90;Mt++)Cs[Mt]=String.fromCharCode(Mt+32),Aa[Mt]=String.fromCharCode(Mt);for(var Mu in Cs)Aa.hasOwnProperty(Mu)||(Aa[Mu]=Cs[Mu]);function DM(r){var e=RM&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||MM&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Aa:Cs)[r.keyCode]||r.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 Ta(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function af(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function pc(r,e){if(!e.anchorNode)return!1;try{return af(r,e.anchorNode)}catch{return!1}}function Ra(r){return r.nodeType==3?vn(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function la(r,e,t,i){return t?e0(r,e,t,i,-1)||e0(r,e,t,i,1):!1}function gn(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function Fc(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}function e0(r,e,t,i,s){for(;;){if(r==t&&e==i)return!0;
vendor: 4,223 bytes, line 23
23if(e==(s<0?0:xi(r))){if(r.nodeName=="DIV")return!1;let n=r.parentNode;if(!n||n.nodeType!=1)return!1;e=gn(r)+(s<0?0:1),r=n}else if(r.nodeType==1){if(r=r.childNodes[e+(s<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=s<0?xi(r):0}else return!1}}function xi(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Ih(r,e){let t=e?r.left:r.right;return{left:t,right:t,top:r.top,bottom:r.bottom}}function PM(r){let e=r.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function ay(r,e){let t=e.width/r.offsetWidth,i=e.height/r.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-r.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-r.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function LM(r,e,t,i,s,n,a,o){let l=r.ownerDocument,c=l.defaultView||window;for(let h=r,u=!1;h&&!u;)if(h.nodeType==1){let d,f=h==l.body,_=1,b=1;if(f)d=PM(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let v=h.getBoundingClientRect();({scaleX:_,scaleY:b}=ay(h,v)),d={left:v.left,right:v.left+h.clientWidth*_,top:v.top,bottom:v.top+h.clientHeight*b}}let p=0,g=0;if(s=="nearest")e.top<d.top?(g=-(d.top-e.top+a),t>0&&e.bottom>d.bottom+g&&(g=e.bottom-d.bottom+g+a)):e.bottom>d.bottom&&(g=e.bottom-d.bottom+a,t<0&&e.top-g<d.top&&(g=-(d.top+g-e.top+a)));else{let v=e.bottom-e.top,x=d.bottom-d.top;g=(s=="center"&&v<=x?e.top+v/2-x/2:s=="start"||s=="center"&&t<0?e.top-a:e.bottom-x+a)-d.top}if(i=="nearest"?e.left<d.left?(p=-(d.left-e.left+n),t>0&&e.right>d.right+p&&(p=e.right-d.right+p+n)):e.right>d.right&&(p=e.right-d.right+n,t<0&&e.left<d.left+p&&(p=-(d.left+p-e.left+n))):p=(i=="center"?e.left+(e.right-e.left)/2-(d.right-d.left)/2:i=="start"==o?e.left-n:e.right-(d.right-d.left)+n)-d.left,p||g)if(f)c.scrollBy(p,g);else{let v=0,x=0;if(g){let w=h.scrollTop;h.scrollTop+=g/b,x=(h.scrollTop-w)*b}if(p){let w=h.scrollLeft;h.scrollLeft+=p/_,v=(h.scrollLeft-w)*_}e={left:e.left-v,top:e.top-x,right:e.right-v,bottom:e.bottom-x},v&&Math.abs(v-p)<1&&(i="nearest"),x&&Math.abs(x-g)<1&&(s="nearest")}if(f)break;h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function NM(r){let e=r.ownerDocument,t,i;for(let s=r.parentNode;s&&!(s==e.body||t&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),!t&&s.scrollWidth>s.clientWidth&&(t=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:t,y:i}}class OM{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?xi(t):0),i,Math.min(e.focusOffset,i?xi(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}let jn=null;function ly(r){if(r.setActive)return r.setActive();if(jn)return r.focus(jn);let e=[];for(let t=r;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(r.focus(jn==null?{get preventScroll(){return jn={preventScroll:!0},!0}}:void 0),!jn){jn=!1;for(let t=0;t<e.length;){let i=e[t++],s=e[t++],n=e[t++];i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=n&&(i.scrollLeft=n)}}}let t0;function vn(r,e,t=e){let i=t0||(t0=document.createRange());return i.setEnd(r,t),i.setStart(r,e),i}function Qn(r,e,t,i){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let n=new KeyboardEvent("keydown",s);n.synthetic=!0,r.dispatchEvent(n);let a=new KeyboardEvent("keyup",s);return a.synthetic=!0,r.dispatchEvent(a),n.defaultPrevented||a.defaultPrevented}function IM(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function cy(r){for(;r.attributes.length;)r.removeAttributeNode(r.attributes[0])}function jM(r,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,xi(t));;
vendor: 40,384 bytes, line 23
23)if(i){if(t.nodeType!=1)return!1;let s=t.childNodes[i-1];s.contentEditable=="false"?i--:(t=s,i=xi(t))}else{if(t==r)return!0;i=gn(t),t=t.parentNode}}function hy(r){return r.scrollTop>Math.max(1,r.scrollHeight-r.clientHeight-4)}function uy(r,e){for(let t=r,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=xi(t)}else if(t.parentNode&&!Fc(t))i=gn(t),t=t.parentNode;else return null}}function dy(r,e){for(let t=r,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&&!Fc(t))i=gn(t)+1,t=t.parentNode;else return null}}class $t{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new $t(e.parentNode,gn(e),t)}static after(e,t){return new $t(e.parentNode,gn(e)+1,t)}}const zp=[];class Je{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,s=null,n;for(let a of this.children){if(a.flags&7){if(!a.dom&&(n=s?s.nextSibling:i.firstChild)){let o=Je.get(n);(!o||!o.parent&&o.canReuseDOM(a))&&a.reuseDOM(n)}a.sync(e,t),a.flags&=-8}if(n=s?s.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&n!=a.dom&&(t.written=!0),a.dom.parentNode==i)for(;n&&n!=a.dom;)n=r0(n);else i.insertBefore(a.dom,n);s=a.dom}for(n=s?s.nextSibling:i.firstChild,n&&t&&t.node==i&&(t.written=!0);n;)n=r0(n)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let s=xi(e)==0?0:t==0?-1:1;for(;;){let n=e.parentNode;if(n==this.dom)break;s==0&&n.firstChild!=n.lastChild&&(e==n.firstChild?s=-1:s=1),e=n}s<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!Je.get(i);)i=i.nextSibling;if(!i)return this.length;for(let s=0,n=0;;s++){let a=this.children[s];if(a.dom==i)return n;n+=a.length+a.breakAfter}}domBoundsAround(e,t,i=0){let s=-1,n=-1,a=-1,o=-1;for(let l=0,c=i,h=i;l<this.children.length;l++){let u=this.children[l],d=c+u.length;if(c<e&&d>t)return u.domBoundsAround(e,t,c);if(d>=e&&s==-1&&(s=l,n=c),c>t&&u.dom.parentNode==this.dom){a=l,o=h;break}h=d,c=d+u.breakAfter}return{from:n,to:o<0?i+this.length:o,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:a<this.children.length&&a>=0?this.children[a].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=zp){this.markDirty();for(let s=e;s<t;s++){let n=this.children[s];n.parent==this&&i.indexOf(n)<0&&n.destroy()}i.length<250?this.children.splice(e,t-e,...i):this.children=[].concat(this.children.slice(0,e),i,this.children.slice(t));for(let s=0;s<i.length;s++)i[s].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new fy(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,s,n,a){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}Je.prototype.breakAfter=0;function r0(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class fy{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function py(r,e,t,i,s,n,a,o,l){let{children:c}=r,h=c.length?c[e]:null,u=n.length?n[n.length-1]:null,d=u?u.breakAfter:a;if(!(e==i&&h&&!a&&!d&&n.length<2&&h.merge(t,s,n.length?u:null,t==0,o,l))){if(i<c.length){let f=c[i];f&&(s<f.length||f.breakAfter&&u?.breakAfter)?(e==i&&(f=f.split(s),s=0),!d&&u&&f.merge(0,s,u,!0,0,l)?n[n.length-1]=f:((s||f.children.length&&!f.children[0].length)&&f.merge(0,s,null,!1,0,l),n.push(f))):f?.breakAfter&&(u?u.breakAfter=1:a=1),i++}for(h&&(h.breakAfter=a,t>0&&(!a&&n.length&&h.merge(t,h.length,n[0],!1,o,0)?h.breakAfter=n.shift().breakAfter:(t<h.length||h.children.length&&h.children[h.children.length-1].length==0)&&h.merge(t,h.length,null,!1,o,0),e++));e<i&&n.length;)if(c[i-1].become(n[n.length-1]))i--,n.pop(),l=n.length?0:o;else if(c[e].become(n[0]))e++,n.shift(),o=n.length?0:l;else break;!n.length&&e&&i<c.length&&!c[e-1].breakAfter&&c[i].merge(0,0,c[e-1],!1,o,l)&&e--,(e<i||n.length)&&r.replaceChildren(e,i,n)}}function my(r,e,t,i,s,n){let a=r.childCursor(),{i:o,off:l}=a.findPos(t,1),{i:c,off:h}=a.findPos(e,-1),u=e-t;for(let d of i)u+=d.length;r.length+=u,py(r,c,h,o,l,i,0,s,n)}let tr=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},lf=typeof document<"u"?document:{documentElement:{style:{}}};const cf=/Edge\/(\d+)/.exec(tr.userAgent),gy=/MSIE \d/.test(tr.userAgent),hf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tr.userAgent),jh=!!(gy||hf||cf),i0=!jh&&/gecko\/(\d+)/i.test(tr.userAgent),Du=!jh&&/Chrome\/(\d+)/.exec(tr.userAgent),s0="webkitFontSmoothing"in lf.documentElement.style,vy=!jh&&/Apple Computer/.test(tr.vendor),n0=vy&&(/Mobile\/\w+/.test(tr.userAgent)||tr.maxTouchPoints>2);var fe={mac:n0||/Mac/.test(tr.platform),windows:/Win/.test(tr.platform),linux:/Linux|X11/.test(tr.platform),ie:jh,ie_version:gy?lf.documentMode||6:hf?+hf[1]:cf?+cf[1]:0,gecko:i0,gecko_version:i0?+(/Firefox\/(\d+)/.exec(tr.userAgent)||[0,0])[1]:0,chrome:!!Du,chrome_version:Du?+Du[1]:0,ios:n0,android:/Android\b/.test(tr.userAgent),webkit:s0,safari:vy,webkit_version:s0?+(/\bAppleWebKit\/(\d+)/.exec(tr.userAgent)||[0,0])[1]:0,tabSize:lf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const BM=256;class Kr extends Je{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof Kr)||this.length-(t-e)+i.length>BM||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Kr(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new $t(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return FM(this.dom,e,t)}}class Ki extends Je{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let s of t)s.setParent(this)}setAttrs(e){if(cy(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,s,n,a){return i&&(!(i instanceof Ki&&i.mark.eq(this.mark))||e&&n<=0||t<this.length&&a<=0)?!1:(my(this,e,t,i?i.children.slice():[],n-1,a-1),this.markDirty(),!0)}split(e){let t=[],i=0,s=-1,n=0;for(let o of this.children){let l=i+o.length;l>e&&t.push(i<e?o.split(e-i):o),s<0&&i>=e&&(s=n),i=l,n++}let a=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new Ki(this.mark,t,a)}domAtPos(e){return by(this,e)}coordsAt(e,t){return _y(this,e,t)}}function FM(r,e,t){let i=r.nodeValue.length;e>i&&(e=i);let s=e,n=e,a=0;e==0&&t<0||e==i&&t>=0?fe.chrome||fe.gecko||(e?(s--,a=1):n<i&&(n++,a=-1)):t<0?s--:n<i&&n++;let o=vn(r,s,n).getClientRects();if(!o.length)return null;let l=o[(a?a<0:t>=0)?0:o.length-1];return fe.safari&&!a&&l.width==0&&(l=Array.prototype.find.call(o,c=>c.width)||l),a?Ih(l,a<0):l||null}class Zs extends Je{static create(e,t,i){return new Zs(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=Zs.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,s,n,a){return i&&(!(i instanceof Zs)||!this.widget.compare(i.widget)||e>0&&n<=0||t<this.length&&a<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof Zs&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Ge.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):Ge.empty}domAtPos(e){return(this.length?e==0:this.side>0)?$t.before(this.dom):$t.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let s=this.dom.getClientRects(),n=null;if(!s.length)return null;let a=this.side?this.side<0:e>0;for(let o=a?s.length-1:0;n=s[o],!(e>0?o==0:o==s.length-1||n.top<n.bottom);o+=a?-1:1);return Ih(n,!a)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class uo extends Je{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof uo&&e.side==this.side}split(){return new uo(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?$t.before(this.dom):$t.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Ge.empty}get isHidden(){return!0}}Kr.prototype.children=Zs.prototype.children=uo.prototype.children=zp;function by(r,e){let t=r.dom,{children:i}=r,s=0;for(let n=0;s<i.length;s++){let a=i[s],o=n+a.length;if(!(o==n&&a.getSide()<=0)){if(e>n&&e<o&&a.dom.parentNode==t)return a.domAtPos(e-n);if(e<=n)break;n=o}}for(let n=s;n>0;n--){let a=i[n-1];if(a.dom.parentNode==t)return a.domAtPos(a.length)}for(let n=s;n<i.length;n++){let a=i[n];if(a.dom.parentNode==t)return a.domAtPos(0)}return new $t(t,0)}function xy(r,e,t){let i,{children:s}=r;t>0&&e instanceof Ki&&s.length&&(i=s[s.length-1])instanceof Ki&&i.mark.eq(e.mark)?xy(i,e.children[0],t-1):(s.push(e),e.setParent(r)),r.length+=e.length}function _y(r,e,t){let i=null,s=-1,n=null,a=-1;function o(c,h){for(let u=0,d=0;u<c.children.length&&d<=h;u++){let f=c.children[u],_=d+f.length;_>=h&&(f.children.length?o(f,h-d):(!n||n.isHidden&&t>0)&&(_>h||d==_&&f.getSide()>0)?(n=f,a=h-d):(d<h||d==_&&f.getSide()<0&&!f.isHidden)&&(i=f,s=h-d)),d=_}}o(r,e);let l=(t<0?i:n)||i||n;return l?l.coordsAt(Math.max(0,l==i?s:a),t):$M(r)}function $M(r){let e=r.dom.lastChild;if(!e)return r.dom.getBoundingClientRect();let t=Ra(e);return t[t.length-1]||null}function uf(r,e){for(let t in r)t=="class"&&e.class?e.class+=" "+r.class:t=="style"&&e.style?e.style+=";"+r.style:e[t]=r[t];return e}const o0=Object.create(null);function $c(r,e,t){if(r==e)return!0;r||(r=o0),e||(e=o0);let i=Object.keys(r),s=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=s.length-(t&&s.indexOf(t)>-1?1:0))return!1;for(let n of i)if(n!=t&&(s.indexOf(n)==-1||r[n]!==e[n]))return!1;return!0}function df(r,e,t){let i=!1;if(e)for(let s in e)t&&s in t||(i=!0,s=="style"?r.style.cssText="":r.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(i=!0,s=="style"?r.style.cssText=t[s]:r.setAttribute(s,t[s]));return i}function HM(r){let e=Object.create(null);for(let t=0;t<r.attributes.length;t++){let i=r.attributes[t];e[i.name]=i.value}return e}class Mn{eq(e){return!1}updateDOM(e,t){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 Gt=function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r}(Gt||(Gt={}));class Ne extends pn{constructor(e,t,i,s){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(e){return new el(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 Es(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:n,end:a}=yy(e,t);i=(n?t?-3e8:-1:5e8)-1,s=(a?t?2e8:1:-6e8)+1}return new Es(e,i,s,t,e.widget||null,!0)}static line(e){return new tl(e)}static set(e,t=!1){return Ue.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Ne.none=Ue.empty;class el extends Ne{constructor(e){let{start:t,end:i}=yy(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof el&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&$c(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}el.prototype.point=!1;class tl extends Ne{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof tl&&this.spec.class==e.spec.class&&$c(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)}}tl.prototype.mapMode=Ft.TrackBefore;tl.prototype.point=!0;class Es extends Ne{constructor(e,t,i,s,n,a){super(t,i,n,e),this.block=s,this.isReplace=a,this.mapMode=s?t<=0?Ft.TrackBefore:Ft.TrackAfter:Ft.TrackDel}get type(){return this.startSide!=this.endSide?Gt.WidgetRange:this.startSide<=0?Gt.WidgetBefore:Gt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Es&&zM(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)}}Es.prototype.point=!0;function yy(r,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=r;return t==null&&(t=r.inclusive),i==null&&(i=r.inclusive),{start:t??e,end:i??e}}function zM(r,e){return r==e||!!(r&&e&&r.compare(e))}function mc(r,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=r?t[s]=Math.max(t[s],e):t.push(r,e)}class mt extends Je{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,s,n,a){if(i){if(!(i instanceof mt))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),my(this,e,t,i?i.children.slice():[],n,a),!0}split(e){let t=new mt;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:s}=this.childPos(e);s&&(t.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let n=i;n<this.children.length;n++)t.append(this.children[n],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){$c(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){xy(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=uf(t,this.attrs||{})),i&&(this.attrs=uf({class:i},this.attrs||{}))}domAtPos(e){return by(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(cy(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(df(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let s=this.dom.lastChild;for(;s&&Je.get(s)instanceof Ki;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((i=Je.get(s))===null||i===void 0?void 0:i.isEditable)==!1&&(!fe.ios||!this.children.some(n=>n instanceof Kr))){let n=document.createElement("BR");n.cmIgnore=!0,this.dom.appendChild(n)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Kr)||/[^ -~]/.test(i.text))return null;let s=Ra(i.dom);if(s.length!=1)return null;e+=s[0].width,t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=_y(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:s}=this.parent.view.viewState,n=i.bottom-i.top;if(Math.abs(n-s.lineHeight)<2&&s.textHeight<n){let a=(n-s.textHeight)/2;return{top:i.top+a,bottom:i.bottom-a,left:i.left,right:i.left}}}return i}become(e){return e instanceof mt&&this.children.length==0&&e.children.length==0&&$c(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let i=0,s=0;i<e.children.length;i++){let n=e.children[i],a=s+n.length;if(a>=t){if(n instanceof mt)return n;if(a>t)break}s=a+n.breakAfter}return null}}class zi extends Je{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,s,n,a){return i&&(!(i instanceof zi)||!this.widget.compare(i.widget)||e>0&&n<=0||t<this.length&&a<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?$t.before(this.dom):$t.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new zi(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return zp}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Ge.empty}domBoundsAround(){return null}become(e){return e instanceof zi&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);return i||(this.widget instanceof ff?null:Ih(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}}class ff extends Mn{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}}class ca{constructor(e,t,i,s){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof zi&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new mt),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Pl(new uo(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof zi)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:n,lineBreak:a,done:o}=this.cursor.next(this.skip);if(this.skip=0,o)throw new Error("Ran out of text content when drawing inline views");if(a){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=n,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(Pl(new Kr(this.text.slice(this.textOff,this.textOff+s)),t),i),this.atCursorPos=!0,this.textOff+=s,e-=s,i=0}}span(e,t,i,s){this.buildText(t-e,i,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,i,s,n,a){if(this.disallowBlockEffectsFor[a]&&i instanceof Es){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=t-e;if(i instanceof Es)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new zi(i.widget||fo.block,o,i));else{let l=Zs.create(i.widget||fo.inline,o,o?0:i.startSide),c=this.atCursorPos&&!l.isEditable&&n<=s.length&&(e<t||i.startSide>0),h=!l.isEditable&&(e<t||n>s.length||i.startSide<=0),u=this.getLine();this.pendingBuffer==2&&!c&&!l.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),c&&(u.append(Pl(new uo(1),s),n),n=s.length+Math.max(0,n-s.length)),u.append(Pl(l,s),n),this.atCursorPos=h,this.pendingBuffer=h?e<t||n>s.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=n)}static build(e,t,i,s,n){let a=new ca(e,t,i,n);return a.openEnd=Ue.spans(s,t,i,a),a.openStart<0&&(a.openStart=a.openEnd),a.finish(a.openEnd),a}}function Pl(r,e){for(let t of e)r=new Ki(t,[r],r.length);return r}class fo extends Mn{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}}fo.inline=new fo("span");fo.block=new fo("div");var it=function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r}(it||(it={}));const bn=it.LTR,Wp=it.RTL;function wy(r){let e=[];for(let t=0;t<r.length;t++)e.push(1<<+r[t]);return e}const WM=wy("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),UM=wy("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),pf=Object.create(null),Jr=[];for(let r of["()","[]","{}"]){let e=r.charCodeAt(0),t=r.charCodeAt(1);pf[e]=t,pf[t]=-e}function Sy(r){return r<=247?WM[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?UM[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8204?256:64336<=r&&r<=65023?4:1}const VM=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class gs{get dir(){return this.level%2?Wp:bn}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,s){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||(s!=0?s<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 ky(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++){let i=r[t],s=e[t];if(i.from!=s.from||i.to!=s.to||i.direction!=s.direction||!ky(i.inner,s.inner))return!1}return!0}const Ze=[];function KM(r,e,t,i,s){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:s;for(let c=a,h=l,u=l;c<o;c++){let d=Sy(r.charCodeAt(c));d==512?d=h:d==8&&u==4&&(d=16),Ze[c]=d==4?2:d,d&7&&(u=d),h=d}for(let c=a,h=l,u=l;c<o;c++){let d=Ze[c];if(d==128)c<o-1&&h==Ze[c+1]&&h&24?d=Ze[c]=h:Ze[c]=256;else if(d==64){let f=c+1;for(;f<o&&Ze[f]==64;)f++;let _=c&&h==8||f<t&&Ze[f]==8?u==1?1:8:256;for(let b=c;b<f;b++)Ze[b]=_;c=f-1}else d==8&&u==1&&(Ze[c]=1);h=d,d&7&&(u=d)}}}function qM(r,e,t,i,s){let n=s==1?2:1;for(let a=0,o=0,l=0;a<=i.length;a++){let c=a?i[a-1].to:e,h=a<i.length?i[a].from:t;for(let u=c,d,f,_;u<h;u++)if(f=pf[d=r.charCodeAt(u)])if(f<0){for(let b=o-3;b>=0;b-=3)if(Jr[b+1]==-f){let p=Jr[b+2],g=p&2?s:p&4?p&1?n:s:0;g&&(Ze[u]=Ze[Jr[b]]=g),o=b;break}}else{if(Jr.length==189)break;Jr[o++]=u,Jr[o++]=d,Jr[o++]=l}else if((_=Ze[u])==2||_==1){let b=_==s;l=b?0:1;for(let p=o-3;p>=0;p-=3){let g=Jr[p+2];if(g&2)break;if(b)Jr[p+2]|=2;else{if(g&4)break;Jr[p+2]|=4}}}}}function GM(r,e,t,i){for(let s=0,n=i;s<=t.length;s++){let a=s?t[s-1].to:r,o=s<t.length?t[s].from:e;for(let l=a;l<o;){let c=Ze[l];if(c==256){let h=l+1;for(;;)if(h==o){if(s==t.length)break;h=t[s++].to,o=s<t.length?t[s].from:e}else if(Ze[h]==256)h++;else break;let u=n==1,d=(h<e?Ze[h]:i)==1,f=u==d?u?1:2:i;for(let _=h,b=s,p=b?t[b-1].to:r;_>l;)_==p&&(_=t[--b].from,p=b?t[b-1].to:r),Ze[--_]=f;l=h}else n=c,l++}}}function mf(r,e,t,i,s,n,a){let o=i%2?2:1;if(i%2==s%2)for(let l=e,c=0;l<t;){let h=!0,u=!1;if(c==n.length||l<n[c].from){let b=Ze[l];b!=o&&(h=!1,u=b==16)}let d=!h&&o==1?[]:null,f=h?i:i+1,_=l;e:for(;;)if(c<n.length&&_==n[c].from){if(u)break e;let b=n[c];if(!h)for(let p=b.to,g=c+1;;){if(p==t)break e;if(g<n.length&&n[g].from==p)p=n[g++].to;else{if(Ze[p]==o)break e;break}}if(c++,d)d.push(b);else{b.from>l&&a.push(new gs(l,b.from,f));let p=b.direction==bn!=!(f%2);gf(r,p?i+1:i,s,b.inner,b.from,b.to,a),l=b.to}_=b.to}else{if(_==t||(h?Ze[_]!=o:Ze[_]==o))break;_++}d?mf(r,l,_,i+1,s,d,a):l<_&&a.push(new gs(l,_,f)),l=_}else for(let l=t,c=n.length;l>e;){let h=!0,u=!1;if(!c||l>n[c-1].to){let b=Ze[l-1];b!=o&&(h=!1,u=b==16)}let d=!h&&o==1?[]:null,f=h?i:i+1,_=l;e:for(;;)if(c&&_==n[c-1].to){if(u)break e;let b=n[--c];if(!h)for(let p=b.from,g=c;;){if(p==e)break e;if(g&&n[g-1].to==p)p=n[--g].from;else{if(Ze[p-1]==o)break e;break}}if(d)d.push(b);else{b.to<l&&a.push(new gs(b.to,l,f));let p=b.direction==bn!=!(f%2);gf(r,p?i+1:i,s,b.inner,b.from,b.to,a),l=b.from}_=b.from}else{if(_==e||(h?Ze[_-1]!=o:Ze[_-1]==o))break;_--}d?mf(r,_,l,i+1,s,d,a):_<l&&a.push(new gs(_,l,f)),l=_}}function gf(r,e,t,i,s,n,a){let o=e%2?2:1;KM(r,s,n,i,o),qM(r,s,n,i,o),GM(s,n,i,o),mf(r,s,n,e,t,i,a)}function XM(r,e,t){if(!r)return[new gs(0,0,e==Wp?1:0)];if(e==bn&&!t.length&&!VM.test(r))return Cy(r.length);if(t.length)for(;r.length>Ze.length;)Ze[Ze.length]=256;let i=[],s=e==bn?0:1;return gf(r,s,s,t,0,r.length,i),i}function Cy(r){return[new gs(0,r,0)]}let Ey="";function YM(r,e,t,i,s){var n;let a=i.head-r.from,o=gs.find(e,a,(n=i.bidiLevel)!==null&&n!==void 0?n:-1,i.assoc),l=e[o],c=l.side(s,t);if(a==c){let d=o+=s?1:-1;if(d<0||d>=e.length)return null;l=e[o=d],a=l.side(!s,t),c=l.side(s,t)}let h=Dt(r.text,a,l.forward(s,t));(h<l.from||h>l.to)&&(h=c),Ey=r.text.slice(Math.min(a,h),Math.max(a,h));let u=o==(s?e.length-1:0)?null:e[o+(s?1:-1)];return u&&h==c&&u.level+(s?0:1)<l.level?oe.cursor(u.side(!s,t)+r.from,u.forward(s,t)?1:-1,u.level):oe.cursor(h+r.from,l.forward(s,t)?-1:1,l.level)}function ZM(r,e,t){for(let i=e;i<t;i++){let s=Sy(r.charCodeAt(i));if(s==1)return bn;if(s==2||s==4)return Wp}return bn}const Ay=xe.define(),Ty=xe.define(),Ry=xe.define(),My=xe.define(),vf=xe.define(),Dy=xe.define(),Py=xe.define(),Up=xe.define(),Vp=xe.define(),Ly=xe.define({combine:r=>r.some(e=>e)}),Ny=xe.define({combine:r=>r.some(e=>e)}),Oy=xe.define();class eo{constructor(e,t="nearest",i="nearest",s=5,n=5,a=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=n,this.isSnapshot=a}map(e){return e.empty?this:new eo(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 eo(oe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ll=Pe.define({map:(r,e)=>r.map(e)}),Iy=Pe.define();function mr(r,e,t){let i=r.facet(My);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 ji=xe.define({combine:r=>r.length?r[0]:!0});let JM=0;const Zo=xe.define();class Ct{constructor(e,t,i,s,n){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=s,this.extension=n(this)}static define(e,t){const{eventHandlers:i,eventObservers:s,provide:n,decorations:a}=t||{};return new Ct(JM++,e,i,s,o=>{let l=[Zo.of(o)];return a&&l.push(Ma.of(c=>{let h=c.plugin(o);return h?a(h):Ne.none})),n&&l.push(n(o)),l})}static fromClass(e,t){return Ct.define(i=>new e(i),t)}}class Pu{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}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(mr(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.create(e)}catch(t){mr(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){mr(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jy=xe.define(),Bh=xe.define(),Ma=xe.define(),By=xe.define(),Kp=xe.define(),Fy=xe.define();function a0(r,e){let t=r.state.facet(Fy);if(!t.length)return t;let i=t.map(n=>n instanceof Function?n(r):n),s=[];return Ue.spans(i,e.from,e.to,{point(){},span(n,a,o,l){let c=n-e.from,h=a-e.from,u=s;for(let d=o.length-1;d>=0;d--,l--){let f=o[d].spec.bidiIsolate,_;if(f==null&&(f=ZM(e.text,c,h)),l>0&&u.length&&(_=u[u.length-1]).to==c&&_.direction==f)_.to=h,u=_.inner;else{let b={from:c,to:h,direction:f,inner:[]};u.push(b),u=b.inner}}}}),s}const $y=xe.define();function qp(r){let e=0,t=0,i=0,s=0;for(let n of r.state.facet($y)){let a=n(r);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&&(s=Math.max(s,a.bottom)))}return{left:e,right:t,top:i,bottom:s}}const Jo=xe.define();class Dr{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new Dr(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 s=e[t-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),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 s=0,n=0,a=0,o=0;;s++){let l=s==e.length?null:e[s],c=a-o,h=l?l.fromB:1e9;for(;n<t.length&&t[n]<h;){let u=t[n],d=t[n+1],f=Math.max(o,u),_=Math.min(h,d);if(f<=_&&new Dr(f+c,_+c,f,_).addToSet(i),d>h)break;n+=2}if(!l)return i;new Dr(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),a=l.toA,o=l.toB}}}class Hc{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=bt.empty(this.startState.doc.length);for(let n of i)this.changes=this.changes.compose(n.changes);let s=[];this.changes.iterChangedRanges((n,a,o,l)=>s.push(new Dr(n,a,o,l))),this.changedRanges=s}static create(e,t,i){return new Hc(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}}class l0 extends Je{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Ne.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.setDOM(e.contentDOM),this.children=[new mt],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Dr(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:h})=>h<this.minWidthFrom||c>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 s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!nD(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let n=s>-1?eD(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:c,to:h}=this.hasComposition;i=new Dr(c,h,e.changes.mapPos(c,-1),e.changes.mapPos(h,1)).addToSet(i.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(fe.ie||fe.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,o=this.updateDeco(),l=iD(a,o,e.changes);return i=Dr.extendWithRanges(i,l),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:s}=this.view;s.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=fe.chrome||fe.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,a),this.flags&=-8,a&&(a.written||s.selectionRange.focusNode!=a.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(a=>a.flags&=-9);let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let a of this.children)a instanceof zi&&a.widget instanceof ff&&n.push(a.dom);s.updateGaps(n)}updateChildren(e,t,i){let s=i?i.range.addToSet(e.slice()):e,n=this.childCursor(t);for(let a=s.length-1;;a--){let o=a>=0?s[a]:null;if(!o)break;let{fromA:l,toA:c,fromB:h,toB:u}=o,d,f,_,b;if(i&&i.range.fromB<u&&i.range.toB>h){let w=ca.build(this.view.state.doc,h,i.range.fromB,this.decorations,this.dynamicDecorationMap),S=ca.build(this.view.state.doc,i.range.toB,u,this.decorations,this.dynamicDecorationMap);f=w.breakAtStart,_=w.openStart,b=S.openEnd;let k=this.compositionView(i);S.breakAtStart?k.breakAfter=1:S.content.length&&k.merge(k.length,k.length,S.content[0],!1,S.openStart,0)&&(k.breakAfter=S.content[0].breakAfter,S.content.shift()),w.content.length&&k.merge(0,0,w.content[w.content.length-1],!0,0,w.openEnd)&&w.content.pop(),d=w.content.concat(k).concat(S.content)}else({content:d,breakAtStart:f,openStart:_,openEnd:b}=ca.build(this.view.state.doc,h,u,this.decorations,this.dynamicDecorationMap));let{i:p,off:g}=n.findPos(c,1),{i:v,off:x}=n.findPos(l,-1);py(this,v,x,p,g,d,f,_,b)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(Iy)&&(this.editContextFormatting=i.value)}compositionView(e){let t=new Kr(e.text.nodeValue);t.flags|=8;for(let{deco:s}of e.marks)t=new Ki(s,[t],t.length);let i=new mt;return i.append(t,0),i}fixCompositionDOM(e){let t=(n,a)=>{a.flags|=8|(a.children.some(l=>l.flags&7)?1:0),this.markedForComposition.add(a);let o=Je.get(n);o&&o!=a&&(o.dom=null),a.setDOM(n)},i=this.childPos(e.range.fromB,1),s=this.children[i.i];t(e.line,s);for(let n=e.marks.length-1;n>=-1;n--)i=s.childPos(i.off,1),s=s.children[i.i],t(n>=0?e.marks[n].node:e.text,s)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,s=i==this.dom,n=!s&&!(this.view.state.facet(ji)||this.dom.tabIndex>-1)&&pc(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(s||t||n))return;let a=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(o.anchor)),c=o.empty?l:this.moveToLine(this.domAtPos(o.head));if(fe.gecko&&o.empty&&!this.hasComposition&&QM(l)){let u=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(u,l.node.childNodes[l.offset]||null)),l=c=new $t(u,0),a=!0}let h=this.view.observer.selectionRange;(a||!h.focusNode||(!la(l.node,l.offset,h.anchorNode,h.anchorOffset)||!la(c.node,c.offset,h.focusNode,h.focusOffset))&&!this.suppressWidgetCursorChange(h,o))&&(this.view.observer.ignore(()=>{fe.android&&fe.chrome&&this.dom.contains(h.focusNode)&&sD(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let u=Ta(this.view.root);if(u)if(o.empty){if(fe.gecko){let d=tD(l.node,l.offset);if(d&&d!=3){let f=(d==1?uy:dy)(l.node,l.offset);f&&(l=new $t(f.node,f.offset))}}u.collapse(l.node,l.offset),o.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=o.bidiLevel)}else if(u.extend){u.collapse(l.node,l.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();o.anchor>o.head&&([l,c]=[c,l]),d.setEnd(c.node,c.offset),d.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(d)}n&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(l,c)),this.impreciseAnchor=l.precise?null:new $t(h.anchorNode,h.anchorOffset),this.impreciseHead=c.precise?null:new $t(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&la(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}
vendor: 4,089 bytes, line 23
23=this,t=e.state.selection.main,i=Ta(e.root),{anchorNode:s,anchorOffset:n}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let a=mt.find(this,t.head);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 h=this.domAtPos(t.head+t.assoc);i.collapse(h.node,h.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(s,n)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let s=e.offset;!i&&s<t.childNodes.length;s++){let n=Je.get(t.childNodes[s]);n instanceof mt&&(i=n.domAtPos(0))}for(let s=e.offset-1;!i&&s>=0;s--){let n=Je.get(t.childNodes[s]);n instanceof mt&&(i=n.domAtPos(n.length))}return i?new $t(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=Je.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let s=this.children[t];if(i<s.length||s instanceof mt)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,s=0;for(let n=this.length,a=this.children.length-1;a>=0;a--){let o=this.children[a],l=n-o.breakAfter,c=l-o.length;if(l<e)break;if(c<=e&&(c<e||o.covers(-1))&&(l>e||o.covers(1))&&(!i||o instanceof mt&&!(i instanceof mt&&t>=0)))i=o,s=c;else if(i&&c==e&&l==e&&o instanceof zi&&Math.abs(t)<2){if(o.deco.startSide<0)break;a&&(i=null)}n=c}return i?i.coordsAt(e-s,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),s=this.children[t];if(!(s instanceof mt))return null;for(;s.children.length;){let{i:o,off:l}=s.childPos(i,1);for(;;o++){if(o==s.children.length)return null;if((s=s.children[o]).length)break}i=l}if(!(s instanceof Kr))return null;let n=Dt(s.text,i);if(n==i)return null;let a=vn(s.dom,i,n).getClientRects();for(let o=0;o<a.length;o++){let l=a[o];if(o==a.length-1||l.top<l.bottom&&l.left<l.right)return l}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:s}=e,n=this.view.contentDOM.clientWidth,a=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==it.LTR;for(let c=0,h=0;h<this.children.length;h++){let u=this.children[h],d=c+u.length;if(d>s)break;if(c>=i){let f=u.dom.getBoundingClientRect();if(t.push(f.height),a){let _=u.dom.lastChild,b=_?Ra(_):[];if(b.length){let p=b[b.length-1],g=l?p.right-f.left:f.right-p.left;g>o&&(o=g,this.minWidth=n,this.minWidthFrom=c,this.minWidthTo=d)}}}c=d+u.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?it.RTL:it.LTR}measureTextSize(){for(let n of this.children)if(n instanceof mt){let a=n.measureTextSize();if(a)return a}let e=document.createElement("div"),t,i,s;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let n=Ra(e.firstChild)[0];t=e.getBoundingClientRect().height,i=n?n.width/27:7,s=n?n.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:s}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new fy(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let n=s==t.viewports.length?null:t.viewports[s],a=n?n.from-1:this.length;if(a>i){let o=(t.lineBlockAt(a).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Ne.replace({widget:new ff(o),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!n)break;i=n.to+1}return Ne.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Ma).map(n=>(this.dynamicDecorationMap[e++]=typeof n=="function")?n(this.view):n),i=!1,s=this.view.state.facet(By).map((n,a)=>{let o=typeof n=="function";return o&&(i=!0),o?n(this.view):n});
vendor: 79,370 bytes, lines 23-26
23for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(Ue.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}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(Oy))try{if(c(this.view,e.range,e))return!0}catch(h){mr(this.view.state,h,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let n=qp(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;LM(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==it.LTR)}}function QM(r){return r.node.nodeType==1&&r.node.firstChild&&(r.offset==0||r.node.childNodes[r.offset-1].contentEditable=="false")&&(r.offset==r.node.childNodes.length||r.node.childNodes[r.offset].contentEditable=="false")}function Hy(r,e){let t=r.observer.selectionRange;if(!t.focusNode)return null;let i=uy(t.focusNode,t.focusOffset),s=dy(t.focusNode,t.focusOffset),n=i||s;if(s&&i&&s.node!=i.node){let o=Je.get(s.node);if(!o||o instanceof Kr&&o.text!=s.node.nodeValue)n=s;else if(r.docView.lastCompositionAfterCursor){let l=Je.get(i.node);!l||l instanceof Kr&&l.text!=i.node.nodeValue||(n=s)}}if(r.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 eD(r,e,t){let i=Hy(r,t);if(!i)return null;let{node:s,from:n,to:a}=i,o=s.nodeValue;if(/[\n\r]/.test(o)||r.state.doc.sliceString(i.from,i.to)!=o)return null;let l=e.invertedDesc,c=new Dr(l.mapPos(n),l.mapPos(a),n,a),h=[];for(let u=s.parentNode;;u=u.parentNode){let d=Je.get(u);if(d instanceof Ki)h.push({node:u,deco:d.mark});else{if(d instanceof mt||u.nodeName=="DIV"&&u.parentNode==r.contentDOM)return{range:c,text:s,marks:h,line:u};if(u!=r.contentDOM)h.push({node:u,deco:new el({inclusive:!0,attributes:HM(u),tagName:u.tagName.toLowerCase()})});else return null}}}function tD(r,e){return r.nodeType!=1?0:(e&&r.childNodes[e-1].contentEditable=="false"?1:0)|(e<r.childNodes.length&&r.childNodes[e].contentEditable=="false"?2:0)}let rD=class{constructor(){this.changes=[]}compareRange(e,t){mc(e,t,this.changes)}comparePoint(e,t){mc(e,t,this.changes)}boundChange(e){mc(e,e,this.changes)}};function iD(r,e,t){let i=new rD;return Ue.compare(r,e,t,i),i.changes}function sD(r,e){for(let t=r;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function nD(r,e){let t=!1;return e&&r.iterChangedRanges((i,s)=>{i<e.to&&s>e.from&&(t=!0)}),t}function oD(r,e,t=1){let i=r.charCategorizer(e),s=r.doc.lineAt(e),n=e-s.from;if(s.length==0)return oe.cursor(e);n==0?t=1:n==s.length&&(t=-1);let a=n,o=n;t<0?a=Dt(s.text,n,!1):o=Dt(s.text,n);let l=i(s.text.slice(a,o));for(;a>0;){let c=Dt(s.text,a,!1);if(i(s.text.slice(c,a))!=l)break;a=c}for(;o<s.length;){let c=Dt(s.text,o);if(i(s.text.slice(o,c))!=l)break;o=c}return oe.range(a+s.from,o+s.from)}function aD(r,e){return e.left>r?e.left-r:Math.max(0,r-e.right)}function lD(r,e){return e.top>r?e.top-r:Math.max(0,r-e.bottom)}function Lu(r,e){return r.top<e.bottom-1&&r.bottom>e.top+1}function c0(r,e){return e<r.top?{top:e,left:r.left,right:r.right,bottom:r.bottom}:r}function h0(r,e){return e>r.bottom?{top:r.top,left:r.left,right:r.right,bottom:e}:r}function bf(r,e,t){let i,s,n,a,o=!1,l,c,h,u;for(let _=r.firstChild;_;_=_.nextSibling){let b=Ra(_);for(let p=0;p<b.length;p++){let g=b[p];s&&Lu(s,g)&&(g=c0(h0(g,s.bottom),s.top));let v=aD(e,g),x=lD(t,g);if(v==0&&x==0)return _.nodeType==3?u0(_,e,t):bf(_,e,t);if(!i||a>x||a==x&&n>v){i=_,s=g,n=v,a=x;let w=x?t<g.top?-1:1:v?e<g.left?-1:1:0;o=!w||(w>0?p<b.length-1:p>0)}v==0?t>g.bottom&&(!h||h.bottom<g.bottom)?(l=_,h=g):t<g.top&&(!u||u.top>g.top)&&(c=_,u=g):h&&Lu(h,g)?h=h0(h,g.bottom):u&&Lu(u,g)&&(u=c0(u,g.top))}}if(h&&h.bottom>=t?(i=l,s=h):u&&u.top<=t&&(i=c,s=u),!i)return{node:r,offset:0};let d=Math.max(s.left,Math.min(s.right,e));if(i.nodeType==3)return u0(i,d,t);if(o&&i.contentEditable!="false")return bf(i,d,t);let f=Array.prototype.indexOf.call(r.childNodes,i)+(e>=(s.left+s.right)/2?1:0);return{node:r,offset:f}}function u0(r,e,t){let i=r.nodeValue.length,s=-1,n=1e9,a=0;for(let o=0;o<i;o++){let l=vn(r,o,o+1).getClientRects();for(let c=0;c<l.length;c++){let h=l[c];if(h.top==h.bottom)continue;a||(a=e-h.left);let u=(h.top>t?h.top-t:t-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&u<n){let d=e>=(h.left+h.right)/2,f=d;if((fe.chrome||fe.gecko)&&vn(r,o).getBoundingClientRect().left==h.right&&(f=!d),u<=0)return{node:r,offset:o+(f?1:0)};s=o+(f?1:0),n=u}}}return{node:r,offset:s>-1?s:a>0?r.nodeValue.length:0}}function zy(r,e,t,i=-1){var s,n;let a=r.contentDOM.getBoundingClientRect(),o=a.top+r.viewState.paddingTop,l,{docHeight:c}=r.viewState,{x:h,y:u}=e,d=u-o;if(d<0)return 0;if(d>c)return r.state.doc.length;for(let w=r.viewState.heightOracle.textHeight/2,S=!1;l=r.elementAtHeight(d),l.type!=Gt.Text;)for(;d=i>0?l.bottom+w:l.top-w,!(d>=0&&d<=c);){if(S)return t?null:0;S=!0,i=-i}u=o+d;let f=l.from;if(f<r.viewport.from)return r.viewport.from==0?0:t?null:d0(r,a,l,h,u);if(f>r.viewport.to)return r.viewport.to==r.state.doc.length?r.state.doc.length:t?null:d0(r,a,l,h,u);let _=r.dom.ownerDocument,b=r.root.elementFromPoint?r.root:_,p=b.elementFromPoint(h,u);p&&!r.contentDOM.contains(p)&&(p=null),p||(h=Math.max(a.left+1,Math.min(a.right-1,h)),p=b.elementFromPoint(h,u),p&&!r.contentDOM.contains(p)&&(p=null));let g,v=-1;if(p&&((s=r.docView.nearest(p))===null||s===void 0?void 0:s.isEditable)!=!1){if(_.caretPositionFromPoint){let w=_.caretPositionFromPoint(h,u);w&&({offsetNode:g,offset:v}=w)}else if(_.caretRangeFromPoint){let w=_.caretRangeFromPoint(h,u);w&&({startContainer:g,startOffset:v}=w,(!r.contentDOM.contains(g)||fe.safari&&cD(g,v,h)||fe.chrome&&hD(g,v,h))&&(g=void 0))}g&&(v=Math.min(xi(g),v))}if(!g||!r.docView.dom.contains(g)){let w=mt.find(r.docView,f);if(!w)return d>l.top+l.height/2?l.to:l.from;({node:g,offset:v}=bf(w.dom,h,u))}let x=r.docView.nearest(g);if(!x)return null;if(x.isWidget&&((n=x.dom)===null||n===void 0?void 0:n.nodeType)==1){let w=x.dom.getBoundingClientRect();return e.y<w.top||e.y<=w.bottom&&e.x<=(w.left+w.right)/2?x.posAtStart:x.posAtEnd}else return x.localPosFromDOM(g,v)+x.posAtStart}function d0(r,e,t,i,s){let n=Math.round((i-e.left)*r.defaultCharacterWidth);if(r.lineWrapping&&t.height>r.defaultLineHeight*1.5){let o=r.viewState.heightOracle.textHeight,l=Math.floor((s-t.top-(r.defaultLineHeight-o)*.5)/o);n+=l*r.viewState.heightOracle.lineLength}let a=r.state.sliceDoc(t.from,t.to);return t.from+AM(a,n,r.state.tabSize)}function cD(r,e,t){let i;if(r.nodeType!=3||e!=(i=r.nodeValue.length))return!1;for(let s=r.nextSibling;s;s=s.nextSibling)if(s.nodeType!=1||s.nodeName!="BR")return!1;return vn(r,i-1,i).getBoundingClientRect().left>t}function hD(r,e,t){if(e!=0)return!1;for(let s=r;;){let n=s.parentNode;if(!n||n.nodeType!=1||n.firstChild!=s)return!1;if(n.classList.contains("cm-line"))break;s=n}let i=r.nodeType==1?r.getBoundingClientRect():vn(r,0,Math.max(r.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function xf(r,e){let t=r.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Gt.Text))return i}return t}function uD(r,e,t,i){let s=xf(r,e.head),n=!i||s.type!=Gt.Text||!(r.lineWrapping||s.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(n){let a=r.dom.getBoundingClientRect(),o=r.textDirectionAt(s.from),l=r.posAtCoords({x:t==(o==it.LTR)?a.right-1:a.left+1,y:(n.top+n.bottom)/2});if(l!=null)return oe.cursor(l,t?-1:1)}return oe.cursor(t?s.to:s.from,t?-1:1)}function f0(r,e,t,i){let s=r.state.doc.lineAt(e.head),n=r.bidiSpans(s),a=r.textDirectionAt(s.from);for(let o=e,l=null;;){let c=YM(s,n,a,o,t),h=Ey;if(!c){if(s.number==(t?r.state.doc.lines:1))return o;h=` 24`,s=r.state.doc.line(s.number+(t?1:-1)),n=r.bidiSpans(s),c=r.visualLineSide(s,!t)}if(l){if(!l(h))return o}else{if(!i)return c;l=i(h)}o=c}}function dD(r,e,t){let i=r.state.charCategorizer(e),s=i(t);return n=>{let a=i(n);return s==vt.Space&&(s=a),s==a}}function fD(r,e,t,i){let s=e.head,n=t?1:-1;if(s==(t?r.state.doc.length:0))return oe.cursor(s,e.assoc);let a=e.goalColumn,o,l=r.contentDOM.getBoundingClientRect(),c=r.coordsAtPos(s,e.assoc||-1),h=r.documentTop;if(c)a==null&&(a=c.left-l.left),o=n<0?c.top:c.bottom;else{let f=r.viewState.lineBlockAt(s);a==null&&(a=Math.min(l.right-l.left,r.defaultCharacterWidth*(s-f.from))),o=(n<0?f.top:f.bottom)+h}let u=l.left+a,d=i??r.viewState.heightOracle.textHeight>>1;for(let f=0;;f+=10){let _=o+(d+f)*n,b=zy(r,{x:u,y:_},!1,n);if(_<l.top||_>l.bottom||(n<0?b<s:b>s)){let p=r.docView.coordsForChar(b),g=!p||_<p.top?-1:1;return oe.cursor(b,g,void 0,a)}}}function gc(r,e,t){for(;;){let i=0;for(let s of r)s.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 Nu(r,e,t){let i=gc(r.state.facet(Kp).map(s=>s(r)),t.from,e.head>t.from?-1:1);return i==t.from?t:oe.cursor(i,i<t.from?1:-1)}const Qo="ï¿¿";class pD{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(He.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Qo}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let n=this.text.length;this.readNode(s);let a=s.nextSibling;if(a==t)break;let o=Je.get(s),l=Je.get(a);(o&&l?o.breakAfter:(o?o.breakAfter:Fc(s))||Fc(a)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>n)&&this.lineBreak(),s=a}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,s=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=s.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){if(e.cmIgnore)return;let t=Je.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.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+(mD(e,i.node,i.offset)?t:0))}}function mD(r,e,t){for(;;){if(!e||t<xi(e))return!1;if(e==r)return!0;t=gn(e)+1,e=e.parentNode}}class p0{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class gD{constructor(e,t,i,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:n,impreciseAnchor:a}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let o=n||a?[]:xD(e),l=new pD(o,e.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=_D(o,this.bounds.from)}else{let o=e.observer.selectionRange,l=n&&n.node==o.focusNode&&n.offset==o.focusOffset||!af(e.contentDOM,o.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(o.focusNode,o.focusOffset),c=a&&a.node==o.anchorNode&&a.offset==o.anchorOffset||!af(e.contentDOM,o.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(o.anchorNode,o.anchorOffset),h=e.viewport;if((fe.ios||fe.chrome)&&e.state.selection.main.empty&&l!=c&&(h.from>0||h.to<e.state.doc.length)){let u=Math.min(l,c),d=Math.max(l,c),f=h.from-u,_=h.to-d;(f==0||f==1||u==0)&&(_==0||_==-1||d==e.state.doc.length)&&(l=0,c=e.state.doc.length)}this.newSel=oe.single(c,l)}}}function Wy(r,e){let t,{newSel:i}=e,s=r.state.selection.main,n=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:a,to:o}=e.bounds,l=s.from,c=null;(n===8||fe.android&&e.text.length<o-a)&&(l=s.to,c="end");let h=bD(r.state.doc.sliceString(a,o,Qo),e.text,l-a,c);h&&(fe.chrome&&n==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Qo+Qo&&h.toB--,t={from:a+h.from,to:a+h.toA,insert:Ge.of(e.text.slice(h.from,h.toB).split(Qo))})}else i&&(!r.hasFocus&&r.state.facet(ji)||i.main.eq(s))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!s.empty&&i&&i.main.empty?t={from:s.from,to:s.to,insert:r.state.doc.slice(s.from,s.to)}:(fe.mac||fe.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=oe.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:Ge.of([t.insert.toString().replace("."," ")])}):t&&t.from>=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:r.state.doc.slice(s.from,t.from).append(t.insert).append(r.state.doc.slice(t.to,s.to))}:fe.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` 25 `&&r.lineWrapping&&(i&&(i=oe.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:Ge.of([" "])}),t)return Gp(r,t,i,n);if(i&&!i.main.eq(s)){let a=!1,o="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(a=!0),o=r.inputState.lastSelectionOrigin),r.dispatch({selection:i,scrollIntoView:a,userEvent:o}),!0}else return!1}function Gp(r,e,t,i=-1){if(fe.ios&&r.inputState.flushIOSKey(e))return!0;let s=r.state.selection.main;if(fe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&r.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Qn(r.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&Qn(r.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Qn(r.contentDOM,"Delete",46)))return!0;let n=e.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let a,o=()=>a||(a=vD(r,e,t));return r.state.facet(Dy).some(l=>l(r,e.from,e.to,n,o))||r.dispatch(o()),!0}function vD(r,e,t){let i,s=r.state,n=s.selection.main;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)&&r.inputState.composing<0){let o=n.from<e.from?s.sliceDoc(n.from,e.from):"",l=n.to>e.to?s.sliceDoc(e.to,n.to):"";i=s.replaceSelection(r.state.toText(o+e.insert.sliceString(0,void 0,r.state.lineBreak)+l))}else{let o=s.changes(e),l=t&&t.main.to<=o.newLength?t.main:void 0;if(s.selection.ranges.length>1&&r.inputState.composing>=0&&e.to<=n.to&&e.to>=n.to-10){let c=r.state.sliceDoc(e.from,e.to),h,u=t&&Hy(r,t.main.head);if(u){let _=e.insert.length-(e.to-e.from);h={from:u.from,to:u.to-_}}else h=r.state.doc.lineAt(n.head);let d=n.to-e.to,f=n.to-n.from;i=s.changeByRange(_=>{if(_.from==n.from&&_.to==n.to)return{changes:o,range:l||_.map(o)};let b=_.to-d,p=b-c.length;if(_.to-_.from!=f||r.state.sliceDoc(p,b)!=c||_.to>=h.from&&_.from<=h.to)return{range:_};let g=s.changes({from:p,to:b,insert:e.insert}),v=_.to-n.to;return{changes:g,range:l?oe.range(Math.max(0,l.anchor+v),Math.max(0,l.head+v)):_.map(g)}})}else i={changes:o,selection:l&&s.selection.replaceRange(l)}}let a="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,a+=".compose",r.inputState.compositionFirstChange&&(a+=".start",r.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:a,scrollIntoView:!0})}function bD(r,e,t,i){let s=Math.min(r.length,e.length),n=0;for(;n<s&&r.charCodeAt(n)==e.charCodeAt(n);)n++;if(n==s&&r.length==e.length)return null;let a=r.length,o=e.length;for(;a>0&&o>0&&r.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&&r.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 xD(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:n}=r.observer.selectionRange;return t&&(e.push(new p0(t,i)),(s!=t||n!=i)&&e.push(new p0(s,n))),e}function _D(r,e){if(r.length==0)return null;let t=r[0].pos,i=r.length==2?r[1].pos:t;return t>-1&&i>-1?oe.single(t+e,i+e):null}class yD{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 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.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,fe.safari&&e.contentDOM.addEventListener("input",()=>null),fe.gecko&&jD(e.contentDOM.ownerDocument)}handleEvent(e){!RD(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let s of i.observers)s(this.view,t);for(let s of i.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=wD(e),i=this.handlers,s=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&&(s.removeEventListener(n,this.handleEvent),o=null),o||s.addEventListener(n,this.handleEvent,{passive:a})}for(let n in i)n!="scroll"&&!t[n]&&s.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&&Vy.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),fe.android&&fe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return fe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Uy.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||SD.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(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,Qn(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:fe.safari&&!fe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!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 m0(r,e){return(t,i)=>{try{return e.call(r,i,t)}catch(s){mr(t.state,s)}}}function wD(r){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of r){let s=i.spec;if(s&&s.domEventHandlers)for(let n in s.domEventHandlers){let a=s.domEventHandlers[n];a&&t(n).handlers.push(m0(i.value,a))}if(s&&s.domEventObservers)for(let n in s.domEventObservers){let a=s.domEventObservers[n];a&&t(n).observers.push(m0(i.value,a))}}for(let i in qr)t(i).handlers.push(qr[i]);for(let i in Or)t(i).observers.push(Or[i]);return e}const Uy=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],SD="dthko",Vy=[16,17,18,20,91,92,224,225],Nl=6;function Ol(r){return Math.max(0,r)*.7+8}function kD(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}class CD{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=NM(e.contentDOM),this.atoms=e.state.facet(Kp).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(He.allowMultipleSelections)&&ED(e,t),this.dragging=TD(e,t)&&Gy(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&&kD(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,s=0,n=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:n,bottom:o}=this.scrollParents.y.getBoundingClientRect());let l=qp(this.view);e.clientX-l.left<=s+Nl?t=-Ol(s-e.clientX):e.clientX+l.right>=a-Nl&&(t=Ol(e.clientX-a)),e.clientY-l.top<=n+Nl?i=-Ol(n-e.clientY):e.clientY+l.bottom>=o-Nl&&(i=Ol(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)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let s=e.ranges[i],n=null;if(s.empty){let a=gc(this.atoms,s.from,0);a!=s.from&&(n=oe.cursor(a,-1))}else{let a=gc(this.atoms,s.from,-1),o=gc(this.atoms,s.to,1);(a!=s.from||o!=s.to)&&(n=oe.range(s.from==s.anchor?a:o,s.from==s.head?a:o))}n&&(t||(t=e.ranges.slice()),t[i]=n)}return t?oe.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(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 ED(r,e){let t=r.state.facet(Ay);return t.length?t[0](e):fe.mac?e.metaKey:e.ctrlKey}function AD(r,e){let t=r.state.facet(Ty);return t.length?t[0](e):fe.mac?!e.altKey:!e.ctrlKey}function TD(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let i=Ta(r.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let n=0;n<s.length;n++){let a=s[n];if(a.left<=e.clientX&&a.right>=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function RD(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Je.get(t))&&i.ignoreEvent(e))return!1;return!0}const qr=Object.create(null),Or=Object.create(null),Ky=fe.ie&&fe.ie_version<15||fe.ios&&fe.webkit_version<604;function MD(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),qy(r,t.value)},50)}function Fh(r,e,t){for(let i of r.facet(e))t=i(t,r);return t}function qy(r,e){e=Fh(r.state,Up,e);let{state:t}=r,i,s=1,n=t.toText(e),a=n.lines==t.selection.ranges.length;if(_f!=null&&t.selection.ranges.every(l=>l.empty)&&_f==n.toString()){let l=-1;i=t.changeByRange(c=>{let h=t.doc.lineAt(c.from);if(h.from==l)return{range:c};l=h.from;let u=t.toText((a?n.line(s++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:u},range:oe.cursor(c.from+u.length)}})}else a?i=t.changeByRange(l=>{let c=n.line(s++);return{changes:{from:l.from,to:l.to,insert:c.text},range:oe.cursor(l.from+c.length)}}):i=t.replaceSelection(n);r.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Or.scroll=r=>{r.inputState.lastScrollTop=r.scrollDOM.scrollTop,r.inputState.lastScrollLeft=r.scrollDOM.scrollLeft};qr.keydown=(r,e)=>(r.inputState.setSelectionOrigin("select"),e.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);Or.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")};Or.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};qr.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of r.state.facet(Ry))if(t=i(r,e),t)break;if(!t&&e.button==0&&(t=LD(r,e)),t){let i=!r.hasFocus;r.inputState.startMouseSelection(new CD(r,e,t,i)),i&&r.observer.ignore(()=>{ly(r.contentDOM);let n=r.root.activeElement;n&&!n.contains(r.contentDOM)&&n.blur()});let s=r.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}return!1};function g0(r,e,t,i){if(i==1)return oe.cursor(e,t);if(i==2)return oD(r.state,e,t);{let s=mt.find(r.docView,e),n=r.state.doc.lineAt(s?s.posAtEnd:e),a=s?s.posAtStart:n.from,o=s?s.posAtEnd:n.to;return o<r.state.doc.length&&o==n.to&&o++,oe.range(a,o)}}let v0=(r,e,t)=>e>=t.top&&e<=t.bottom&&r>=t.left&&r<=t.right;function DD(r,e,t,i){let s=mt.find(r.docView,e);if(!s)return 1;let n=e-s.posAtStart;if(n==0)return 1;if(n==s.length)return-1;let a=s.coordsAt(n,-1);if(a&&v0(t,i,a))return-1;let o=s.coordsAt(n,1);return o&&v0(t,i,o)?1:a&&a.bottom>=i?-1:1}function b0(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:DD(r,t,e.clientX,e.clientY)}}const PD=fe.ie&&fe.ie_version<=11;let x0=null,_0=0,y0=0;function Gy(r){if(!PD)return r.detail;let e=x0,t=y0;return x0=r,y0=Date.now(),_0=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(_0+1)%3:1}function LD(r,e){let t=b0(r,e),i=Gy(e),s=r.state.selection;return{update(n){n.docChanged&&(t.pos=n.changes.mapPos(t.pos),s=s.map(n.changes))},get(n,a,o){let l=b0(r,n),c,h=g0(r,l.pos,l.bias,i);if(t.pos!=l.pos&&!a){let u=g0(r,t.pos,t.bias,i),d=Math.min(u.from,h.from),f=Math.max(u.to,h.to);h=d<h.from?oe.range(d,f):oe.range(f,d)}return a?s.replaceRange(s.main.extend(h.from,h.to)):o&&i==1&&s.ranges.length>1&&(c=ND(s,l.pos))?c:o?s.addRange(h):oe.create([h])}}}function ND(r,e){for(let t=0;t<r.ranges.length;t++){let{from:i,to:s}=r.ranges[t];if(i<=e&&s>=e)return oe.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}qr.dragstart=(r,e)=>{let{selection:{main:t}}=r.state;if(e.target.draggable){let s=r.docView.nearest(e.target);if(s&&s.isWidget){let n=s.posAtStart,a=n+s.length;(n>=t.to||a<=t.from)&&(t=oe.range(n,a))}}let{inputState:i}=r;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Fh(r.state,Vp,r.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};qr.dragend=r=>(r.inputState.draggedContent=null,!1);function w0(r,e,t,i){if(t=Fh(r.state,Up,t),!t)return;let s=r.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:n}=r.inputState,a=i&&n&&AD(r,e)?{from:n.from,to:n.to}:null,o={from:s,insert:t},l=r.state.changes(a?[a,o]:o);r.focus(),r.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:a?"move.drop":"input.drop"}),r.inputState.draggedContent=null}qr.drop=(r,e)=>{if(!e.dataTransfer)return!1;if(r.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),s=0,n=()=>{++s==t.length&&w0(r,e,i.filter(a=>a!=null).join(r.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 w0(r,e,i,!0),!0}return!1};qr.paste=(r,e)=>{if(r.state.readOnly)return!0;r.observer.flush();let t=Ky?null:e.clipboardData;return t?(qy(r,t.getData("text/plain")||t.getData("text/uri-list")),!0):(MD(r),!1)};function OD(r,e){let t=r.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(),r.focus()},50)}function ID(r){let e=[],t=[],i=!1;for(let s of r.selection.ranges)s.empty||(e.push(r.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:n}of r.selection.ranges){let a=r.doc.lineAt(n);a.number>s&&(e.push(a.text),t.push({from:a.from,to:Math.min(r.doc.length,a.to+1)})),s=a.number}i=!0}return{text:Fh(r,Vp,e.join(r.lineBreak)),ranges:t,linewise:i}}let _f=null;qr.copy=qr.cut=(r,e)=>{let{text:t,ranges:i,linewise:s}=ID(r.state);if(!t&&!s)return!1;_f=s?t:null,e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let n=Ky?null:e.clipboardData;return n?(n.clearData(),n.setData("text/plain",t),!0):(OD(r,t),!1)};const Xy=Yi.define();function Yy(r,e){let t=[];for(let i of r.facet(Py)){let s=i(r,e);s&&t.push(s)}return t?r.update({effects:t,annotations:Xy.of(!0)}):null}function Zy(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Yy(r.state,e);t?r.dispatch(t):r.update([])}},10)}Or.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),Zy(r)};Or.blur=r=>{r.observer.clearSelectionRange(),Zy(r)};Or.compositionstart=Or.compositionupdate=r=>{r.observer.editContext||(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0))};Or.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,fe.chrome&&fe.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};Or.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};qr.beforeinput=(r,e)=>{var t,i;if(e.inputType=="insertReplacementText"&&r.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=r.posAtDOM(o.startContainer,o.startOffset),c=r.posAtDOM(o.endContainer,o.endOffset);return Gp(r,{from:l,to:c,insert:r.state.toText(n)},null),!0}}let s;if(fe.chrome&&fe.android&&(s=Uy.find(n=>n.inputType==e.inputType))&&(r.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.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&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return fe.ios&&e.inputType=="deleteContentForward"&&r.observer.flushSoon(),fe.safari&&e.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>Or.compositionend(r,e),20),!1};const S0=new Set;function jD(r){S0.has(r)||(S0.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const k0=["pre-wrap","normal","pre-line","break-spaces"];let po=!1;function C0(){po=!1}class BD{constructor(e){this.lineWrapping=e,this.doc=Ge.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)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return k0.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let s=e[i];s<0?i++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,i,s,n,a){let o=k0.indexOf(e)>-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=n,l){this.heightSamples={};for(let c=0;c<a.length;c++){let h=a[c];h<0?c++:this.heightSamples[Math.floor(h*10)]=!0}}return l}}class FD{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class ci{constructor(e,t,i,s,n){this.from=e,this.length=t,this.top=i,this.height=s,this._content=n}get type(){return typeof this._content=="number"?Gt.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 Es?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 ci(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var tt=function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r}(tt||(tt={}));const vc=.001;class Xt{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)>vc&&(po=!0),this.height=e)}replace(e,t,i){return Xt.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let n=this,a=i.doc;for(let o=s.length-1;o>=0;o--){let{fromA:l,toA:c,fromB:h,toB:u}=s[o],d=n.lineAt(l,tt.ByPosNoHeight,i.setDoc(t),0,0),f=d.to>=c?d:n.lineAt(c,tt.ByPosNoHeight,i,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=s[o-1].toA;)l=s[o-1].fromA,h=s[o-1].fromB,o--,l<d.from&&(d=n.lineAt(l,tt.ByPosNoHeight,i,0,0));h+=d.from-l,l=d.from;let _=Xp.build(i.setDoc(a),e,h,u);n=zc(n,n.replace(l,c,_))}return n.updateHeight(i,0)}static empty(){return new hr(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,s=0,n=0;for(;;)if(t==i)if(s>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,s-=o.size}else if(n>s*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(s<n){let o=e[t++];o&&(s+=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 $D(Xt.of(e.slice(0,t)),a,Xt.of(e.slice(i)))}}function zc(r,e){return r==e?r:(r.constructor!=e.constructor&&(po=!0),e)}Xt.prototype.size=1;class Jy extends Xt{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,s){return new ci(s,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,s,n){return this.blockAt(0,i,s,n)}forEachLine(e,t,i,s,n,a){e<=n+this.length&&t>=n&&a(this.blockAt(0,i,s,n))}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class hr extends Jy{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,s){return new ci(s,this.length,i,this.height,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof hr||s instanceof Rt&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Rt?s=new hr(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):Xt.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setHeight(s.heights[s.index++]):(i||this.outdated)&&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 Rt extends Xt{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,n=s-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:s,perLine:a,perChar:o}}blockAt(e,t,i,s){let{firstLine:n,lastLine:a,perLine:o,perChar:l}=this.heightMetrics(t,s);if(t.lineWrapping){let c=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),h=t.doc.lineAt(c),u=o+h.length*l,d=Math.max(i,e-u/2);return new ci(h.from,h.length,d,u,0)}else{let c=Math.max(0,Math.min(a-n,Math.floor((e-i)/o))),{from:h,length:u}=t.doc.line(n+c);return new ci(h,u,i+o*c,o,0)}}lineAt(e,t,i,s,n){if(t==tt.ByHeight)return this.blockAt(e,i,s,n);if(t==tt.ByPosNoHeight){let{from:f,to:_}=i.doc.lineAt(e);return new ci(f,_-f,0,0,0)}let{firstLine:a,perLine:o,perChar:l}=this.heightMetrics(i,n),c=i.doc.lineAt(e),h=o+c.length*l,u=c.number-a,d=s+o*u+l*(c.from-n-u);return new ci(c.from,c.length,Math.max(s,Math.min(d,s+this.height-h)),h,0)}forEachLine(e,t,i,s,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 h=e,u=s;h<=t;){let d=i.doc.lineAt(h);if(h==e){let _=d.number-o;u+=l*_+c*(e-n-_)}let f=l+c*d.length;a(new ci(d.from,d.length,u,f,0)),u+=f,h=d.to+1}}replace(e,t,i){let s=this.length-t;if(s>0){let n=i[i.length-1];n instanceof Rt?i[i.length-1]=new Rt(n.length+s):i.push(null,new Rt(s-1))}if(e>0){let n=i[0];n instanceof Rt?i[0]=new Rt(e+n.length):i.unshift(new Rt(e-1),null)}return Xt.of(i)}decomposeLeft(e,t){t.push(new Rt(e-1),null)}decomposeRight(e,t){t.push(null,new Rt(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let n=t+this.length;if(s&&s.from<=t+this.length&&s.more){let a=[],o=Math.max(t,s.from),l=-1;for(s.from>t&&a.push(new Rt(s.from-t-1).updateHeight(e,t));o<=n&&s.more;){let h=e.doc.lineAt(o).length;a.length&&a.push(null);let u=s.heights[s.index++];l==-1?l=u:Math.abs(u-l)>=vc&&(l=-2);let d=new hr(h,u);d.outdated=!1,a.push(d),o+=h+1}o<=n&&a.push(null,new Rt(n-o).updateHeight(e,o));let c=Xt.of(a);return(l<0||Math.abs(c.height-this.height)>=vc||Math.abs(l-this.heightMetrics(e,t).perLine)>=vc)&&(po=!0),zc(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 $D extends Xt{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,s){let n=i+this.left.height;return e<n?this.left.blockAt(e,t,i,s):this.right.blockAt(e,t,n,s+this.left.length+this.break)}lineAt(e,t,i,s,n){let a=s+this.left.height,o=n+this.left.length+this.break,l=t==tt.ByHeight?e<a:e<o,c=l?this.left.lineAt(e,t,i,s,n):this.right.lineAt(e,t,i,a,o);if(this.break||(l?c.to<o:c.from>o))return c;let h=t==tt.ByPosNoHeight?tt.ByPosNoHeight:tt.ByPos;return l?c.join(this.right.lineAt(o,h,i,a,o)):this.left.lineAt(o,h,i,s,n).join(c)}forEachLine(e,t,i,s,n,a){let o=s+this.left.height,l=n+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,i,s,n,a),t>=l&&this.right.forEachLine(e,t,i,o,l,a);else{let c=this.lineAt(l,tt.ByPos,i,s,n);e<c.from&&this.left.forEachLine(e,c.from-1,i,s,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 s=this.left.length+this.break;if(t<s)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-s,t-s,i));let n=[];e>0&&this.decomposeLeft(e,n);let a=n.length;for(let o of i)n.push(o);if(e>0&&E0(n,a-1),t<this.length){let o=n.length;this.decomposeRight(t,n),E0(n,o)}return Xt.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,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Xt.of(this.break?[e,null,t]:[e,t]):(this.left=zc(this.left,e),this.right=zc(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,s){let{left:n,right:a}=this,o=t+n.length+this.break,l=null;return s&&s.from<=t+n.length&&s.more?l=n=n.updateHeight(e,t,i,s):n.updateHeight(e,t,i),s&&s.from<=o+a.length&&s.more?l=a=a.updateHeight(e,o,i,s):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 E0(r,e){let t,i;r[e]==null&&(t=r[e-1])instanceof Rt&&(i=r[e+1])instanceof Rt&&r.splice(e-1,3,new Rt(t.length+1+i.length))}const HD=5;class Xp{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),s=this.nodes[this.nodes.length-1];s instanceof hr?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new hr(i-this.pos,-1)),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 s=i.widget?i.widget.estimatedHeight:0,n=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let a=t-e;i.block?this.addBlock(new Jy(a,s,i)):(a||n||s>=HD)&&this.addLineDeco(s,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 hr(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Rt(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 hr)return e;let t=new hr(0,-1);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 s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.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 hr)&&!this.isCovered?this.nodes.push(new hr(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let s of this.nodes)s instanceof hr&&s.updateHeight(this.oracle,i),i+=s?s.length:1;return this.nodes}static build(e,t,i,s){let n=new Xp(i,e);return Ue.spans(t,i,s,n,0),n.finish(i)}}function zD(r,e,t){let i=new WD;return Ue.compare(r,e,t,i,0),i.changes}class WD{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,s){(e<t||i&&i.heightRelevant||s&&s.heightRelevant)&&mc(e,t,this.changes,5)}}function UD(r,e){let t=r.getBoundingClientRect(),i=r.ownerDocument,s=i.defaultView||window,n=Math.max(0,t.left),a=Math.min(s.innerWidth,t.right),o=Math.max(0,t.top),l=Math.min(s.innerHeight,t.bottom);for(let c=r.parentNode;c&&c!=i.body;)if(c.nodeType==1){let h=c,u=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&u.overflow!="visible"){let d=h.getBoundingClientRect();n=Math.max(n,d.left),a=Math.min(a,d.right),o=Math.max(o,d.top),l=Math.min(c==r.parentNode?s.innerHeight:l,d.bottom)}c=u.position=="absolute"||u.position=="fixed"?h.offsetParent:h.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 VD(r){let e=r.getBoundingClientRect(),t=r.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function KD(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ou{constructor(e,t,i,s){this.from=e,this.to=t,this.size=i,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let s=e[i],n=t[i];if(s.from!=n.from||s.to!=n.to||s.size!=n.size)return!1}return!0}draw(e,t){return Ne.replace({widget:new qD(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class qD extends Mn{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 A0{constructor(e){this.state=e,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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=T0,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=it.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Bh).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new BD(t),this.stateDeco=e.facet(Ma).filter(i=>typeof i!="function"),this.heightMap=Xt.empty().applyChanges(this.stateDeco,Ge.empty,this.heightOracle.setDoc(e.doc),[new Dr(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ne.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:n,to:a})=>s>=n&&s<=a)){let{from:n,to:a}=this.lineBlockAt(s);e.push(new Il(n,a))}}return this.viewports=e.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?T0:new Yp(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(ea(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Ma).filter(h=>typeof h!="function");let s=e.changedRanges,n=Dr.extendWithRanges(s,zD(i,this.stateDeco,e?e.changes:bt.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);C0(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),n),(this.heightMap.height!=a||po)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);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.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ny)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,n=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?it.RTL:it.LTR;let a=this.heightOracle.mustRefreshForWrapping(n),o=t.getBoundingClientRect(),l=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,h=0;if(o.width&&o.height){let{scaleX:w,scaleY:S}=ay(t,o);(w>.005&&Math.abs(this.scaleX-w)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=w,this.scaleY=S,c|=16,a=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=hy(e.scrollDOM);let _=(this.printing?KD:UD)(t,this.paddingTop),b=_.top-this.pixelViewport.top,p=_.bottom-this.pixelViewport.bottom;this.pixelViewport=_;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(l=!0)),!this.inView&&!this.scrollTarget&&!VD(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let w=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(w)&&(a=!0),a||s.lineWrapping&&Math.abs(v-this.contentDOMWidth)>s.charWidth){let{lineHeight:S,charWidth:k,textHeight:C}=e.docView.measureTextSize();a=S>0&&s.refresh(n,S,k,C,v/k,w),a&&(e.docView.minWidth=0,c|=16)}b>0&&p>0?h=Math.max(b,p):b<0&&p<0&&(h=Math.min(b,p)),C0();for(let S of this.viewports){let k=S.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(S);this.heightMap=(a?Xt.empty().applyChanges(this.stateDeco,Ge.empty,this.heightOracle,[new Dr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,a,new FD(S.from,k))}po&&(c|=2)}let x=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),c|=this.updateForViewport()),(c&2||x)&&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)),s=this.heightMap,n=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,l=new Il(s.lineAt(a-i*1e3,tt.ByHeight,n,0,0).from,s.lineAt(o+(1-i)*1e3,tt.ByHeight,n,0,0).to);if(t){let{head:c}=t.range;if(c<l.from||c>l.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=s.lineAt(c,tt.ByPos,n,0,0),d;t.y=="center"?d=(u.top+u.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&c<l.from?d=u.top:d=u.bottom-h,l=new Il(s.lineAt(d-1e3/2,tt.ByHeight,n,0,0).from,s.lineAt(d+h+1e3/2,tt.ByHeight,n,0,0).to)}}return l}mapViewport(e,t){let i=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new Il(this.heightMap.lineAt(i,tt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,tt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,tt.ByPos,this.heightOracle,0,0),{bottom:n}=this.heightMap.lineAt(t,tt.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||s<=a-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||n>=o+Math.max(10,Math.min(i,250)))&&s>a-2*1e3&&n<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let s of e)t.touchesRange(s.from,s.to)||i.push(new Ou(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,n=s>>1,a=s<<1;if(this.defaultTextDirection!=it.LTR&&!i)return[];let o=[],l=(h,u,d,f)=>{if(u-h<n)return;let _=this.state.selection.main,b=[_.from];_.empty||b.push(_.to);for(let g of b)if(g>h&&g<u){l(h,g-10,d,f),l(g+10,u,d,f);return}let p=XD(e,g=>g.from>=d.from&&g.to<=d.to&&Math.abs(g.from-h)<n&&Math.abs(g.to-u)<n&&!b.some(v=>g.from<v&&g.to>v));if(!p){if(u<d.to&&t&&i&&t.visibleRanges.some(x=>x.from<=u&&x.to>=u)){let x=t.moveToLineBoundary(oe.cursor(u),!1,!0).head;x>h&&(u=x)}let g=this.gapSize(d,h,u,f),v=i||g<2e6?g:2e6;p=new Ou(h,u,g,v)}o.push(p)},c=h=>{if(h.length<a||h.type!=Gt.Text)return;let u=GD(h.from,h.to,this.stateDeco);if(u.total<a)return;let d=this.scrollTarget?this.scrollTarget.range.head:null,f,_;if(i){let b=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,p,g;if(d!=null){let v=Bl(u,d),x=((this.visibleBottom-this.visibleTop)/2+b)/h.height;p=v-x,g=v+x}else p=(this.visibleTop-h.top-b)/h.height,g=(this.visibleBottom-h.top+b)/h.height;f=jl(u,p),_=jl(u,g)}else{let b=u.total*this.heightOracle.charWidth,p=s*this.heightOracle.charWidth,g=0;if(b>2e6)for(let k of e)k.from>=h.from&&k.from<h.to&&k.size!=k.displaySize&&k.from*this.heightOracle.charWidth+g<this.pixelViewport.left&&(g=k.size-k.displaySize);let v=this.pixelViewport.left+g,x=this.pixelViewport.right+g,w,S;if(d!=null){let k=Bl(u,d),C=((x-v)/2+p)/b;w=k-C,S=k+C}else w=(v-p)/b,S=(x+p)/b;f=jl(u,w),_=jl(u,S)}f>h.from&&l(h.from,f,h,u),_<h.to&&l(_,h.to,h,u)};for(let h of this.viewportLines)Array.isArray(h.type)?h.type.forEach(c):c(h);return o}gapSize(e,t,i,s){let n=Bl(s,i)-Bl(s,t);return this.heightOracle.lineWrapping?e.height*n:s.total*this.heightOracle.charWidth*n}updateLineGaps(e){Ou.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Ne.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=[];Ue.spans(t,this.viewport.from,this.viewport.to,{span(n,a){i.push({from:n,to:a})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let n=0;n<i.length&&!(s&8);n++){let a=this.visibleRanges[n],o=i[n];(a.from!=o.from||a.to!=o.to)&&(s|=4,e&&e.mapPos(a.from,-1)==o.from&&e.mapPos(a.to,1)==o.to||(s|=8))}return this.visibleRanges=i,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ea(this.heightMap.lineAt(e,tt.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)||ea(this.heightMap.lineAt(this.scaler.fromDOM(e),tt.ByHeight,this.heightOracle,0,0),this.scaler)}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 ea(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 Il{constructor(e,t){this.from=e,this.to=t}}function GD(r,e,t){let i=[],s=r,n=0;return Ue.spans(t,r,e,{span(){},point(a,o){a>s&&(i.push({from:s,to:a}),n+=a-s),s=o}},20),s<e&&(i.push({from:s,to:e}),n+=e-s),{total:n,ranges:i}}function jl({total:r,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(r*t);for(let s=0;;s++){let{from:n,to:a}=e[s],o=a-n;if(i<=o)return n+i;i-=o}}function Bl(r,e){let t=0;for(let{from:i,to:s}of r.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/r.total}function XD(r,e){for(let t of r)if(e(t))return t}const T0={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};class Yp{constructor(e,t,i){let s=0,n=0,a=0;this.viewports=i.map(({from:o,to:l})=>{let c=t.lineAt(o,tt.ByPos,e,0,0).top,h=t.lineAt(l,tt.ByPos,e,0,0).bottom;return s+=h-c,{from:o,to:l,top:c,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);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,s=0;;t++){let n=t<this.viewports.length?this.viewports[t]:null;if(!n||e<n.top)return s+(e-i)*this.scale;if(e<=n.bottom)return n.domTop+(e-n.top);i=n.bottom,s=n.domBottom}}fromDOM(e){for(let t=0,i=0,s=0;;t++){let n=t<this.viewports.length?this.viewports[t]:null;if(!n||e<n.domTop)return i+(e-s)/this.scale;if(e<=n.domBottom)return n.top+(e-n.domTop);i=n.bottom,s=n.domBottom}}eq(e){return e instanceof Yp?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 ea(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),i=e.toDOM(r.bottom);return new ci(r.from,r.length,t,i-t,Array.isArray(r._content)?r._content.map(s=>ea(s,e)):r._content)}const Fl=xe.define({combine:r=>r.join(" ")}),yf=xe.define({combine:r=>r.indexOf(!0)>-1}),wf=ks.newName(),Qy=ks.newName(),ew=ks.newName(),tw={"&light":"."+Qy,"&dark":"."+ew};function Sf(r,e,t){return new ks(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return r;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):r+" "+i}})}const YD=Sf("."+wf,{"&":{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":{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-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",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".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"},".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"}},tw),ZD={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Iu=fe.ie&&fe.ie_version<=11;class JD{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new OM,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);(fe.ie&&fe.ie_version<=11||fe.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&&e.constructor.EDIT_CONTEXT!==!1&&!(fe.chrome&&fe.chrome_version<126)&&(this.editContext=new eP(e),e.state.facet(ji)&&(e.contentDOM.editContext=this.editContext.editContext)),Iu&&(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,s=this.selectionRange;if(i.state.facet(ji)?i.root.activeElement!=this.dom:!pc(this.dom,s))return;let n=s.anchorNode&&i.docView.nearest(s.anchorNode);if(n&&n.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(fe.ie&&fe.ie_version<=11||fe.android&&fe.chrome)&&!i.state.selection.main.empty&&s.focusNode&&la(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ta(e.root);if(!t)return!1;let i=fe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&QD(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=pc(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&jM(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(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,ZD),Iu&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Iu&&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 s=()=>{let n=this.delayedAndroidKey;n&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=n.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&n.force&&Qn(this.dom,n.key,n.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!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,s=!1;for(let n of e){let a=this.readMutation(n);a&&(a.typeOver&&(s=!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:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&pc(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new gD(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,s=Wy(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=R0(t,e.previousSibling||e.target.previousSibling,-1),s=R0(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):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(ji)!=e.state.facet(ji)&&(e.view.contentDOM.editContext=e.state.facet(ji)?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 s of this.scrollTargets)s.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 R0(r,e,t){for(;e;){let i=Je.get(e);if(i&&i.parent==r)return i;let s=e.parentNode;e=s!=r.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function M0(r,e){let t=e.startContainer,i=e.startOffset,s=e.endContainer,n=e.endOffset,a=r.docView.domAtPos(r.state.selection.main.anchor);return la(a.node,a.offset,s,n)&&([t,i,s,n]=[s,n,t,i]),{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:n}}function QD(r,e){if(e.getComposedRanges){let s=e.getComposedRanges(r.root)[0];if(s)return M0(r,s)}let t=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",i,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",i,!0),t?M0(r,t):null}class eP{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 s=e.state.selection.main,{anchor:n,head:a}=s,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={from:o,to:l,insert:Ge.of(i.text.split(` 26`))};if(c.from==this.from&&n<this.from?c.from=n:c.to==this.to&&n>this.to&&(c.to=n),c.from==c.to&&!c.insert.length){let h=oe.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));h.main.eq(s)||e.dispatch({selection:h,userEvent:"select"});return}if((fe.mac||fe.android)&&c.from==a-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:o,to:l,insert:Ge.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let h=this.to-this.from+(c.to-c.from+c.insert.length);Gp(e,c,oe.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=i=>{let s=[],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,s.push(n)}t.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let n of i.getTextFormats()){let a=n.underlineStyle,o=n.underlineThickness;if(a!="None"&&o!="None"){let l=this.toEditorPos(n.rangeStart),c=this.toEditorPos(n.rangeEnd);if(l<c){let h=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${o=="Thin"?1:2}px`;s.push(Ne.mark({attributes:{style:h}}).range(l,c))}}}e.dispatch({effects:Iy.of(Ne.set(s))})},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=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let s=Ta(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,s=this.pendingContextChange;return e.changes.iterChanges((n,a,o,l,c)=>{if(i)return;let h=c.length-(a-n);if(s&&a>=s.to)if(s.from==n&&s.to==a&&s.insert.eq(c)){s=this.pendingContextChange=null,t+=h,this.to+=h;return}else s=null,this.revertPending(e.state);if(n+=t,a+=t,a<=this.from)this.from+=h,this.to+=h;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+=h}t+=h}),s&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange;this.composing&&(this.composing.drifted||e.transactions.some(i=>!i.isUserEvent("input.type")&&i.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))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}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 be{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.composing>0}get compositionStarted(){return 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="
26cm-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&&(s=>s.forEach(n=>i(n,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||IM(e.parent)||document,this.viewState=new A0(e.state||He.create(e)),e.scrollTo&&e.scrollTo.is(Ll)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Zo).map(s=>new Pu(s));for(let s of this.plugins)s.update(this);this.observer=new JD(this),this.inputState=new yD(this),this.inputState.ensureHandlers(this.plugins),this.docView=new l0(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof gt?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,s,n=this.state;for(let d of e){if(d.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=d.state}if(this.destroyed){this.viewState.state=n;return}let a=this.hasFocus,o=0,l=null;e.some(d=>d.annotation(Xy))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,l=Yy(n,a),l||(o=1));let c=this.observer.delayedAndroidKey,h=null;if(c?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(n.doc)||
vendor: 18,808 bytes, line 26
26!this.state.selection.eq(n.selection))&&(h=null)):this.observer.clear(),n.facet(He.phrases)!=this.state.facet(He.phrases))return this.setState(n);s=Hc.create(this,n,e),s.flags|=o;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(u&&(u=u.map(d.changes)),d.scrollIntoView){let{main:f}=d.state.selection;u=new eo(f.empty?f:oe.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(Ll)&&(u=f.value.clip(this.state))}this.viewState.update(s,u),this.bidiCache=Wc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Jo)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Fl)!=s.state.facet(Fl)&&(this.viewState.mustMeasureContent=!0),(t||i||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let d of this.state.facet(vf))try{d(s)}catch(f){mr(this.state,f,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!Wy(this,h)&&c.force&&Qn(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 A0(e),this.plugins=e.facet(Zo).map(i=>new Pu(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new l0(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(Zo),i=e.state.facet(Zo);if(t!=i){let s=[];for(let n of i){let a=t.indexOf(n);if(a<0)s.push(new Pu(n));else{let o=this.plugins[a];o.mustUpdate=e,s.push(o)}}for(let n of this.plugins)n.mustUpdate!=e&&n.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].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){mr(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.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:n,scrollAnchorHeight:a}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(a<0)if(hy(i))n=-1,a=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(s);n=f.from,a=f.top}this.updateState=1;let l=this.viewState.measure(this);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 h=c.map(f=>{try{return f.read(this)}catch(_){return mr(this.state,_),D0}}),u=Hc.create(this,this.state,[]),d=!1;u.flags|=l,t?t.flags|=l:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let f=0;f<c.length;f++)if(h[f]!=D0)try{let _=c[f];_.write&&_.write(h[f],this)}catch(_){mr(this.state,_)}if(d&&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 _=(n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)-a;if(_>1||_<-1){s=s+_,i.scrollTop=s/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let o of this.state.facet(vf))o(t)}get themeClasses(){return wf+" "+(this.state.facet(yf)?ew:Qy)+" "+this.state.facet(Fl)}updateAttrs(){let e=P0(this,jy,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ji)?"true":"false",class:"cm-content",style:`${fe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),P0(this,Bh,t);let i=this.observer.ignore(()=>{let s=df(this.contentDOM,this.contentAttrs,t),n=df(this.dom,this.editorAttrs,e);return s||n});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is(be.announce)){t&&(this.announceDOM.textContent=""),t=!1;let n=this.announceDOM.appendChild(document.createElement("div"));n.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Jo);let e=this.state.facet(be.cspNonce);ks.mount(this.root,this.styleModules.concat(YD).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.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.spec==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 Nu(this,e,f0(this,e,t,i))}moveByGroup(e,t){return Nu(this,e,f0(this,e,t,i=>dD(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),s=this.textDirectionAt(e.from),n=i[t?i.length-1:0];return oe.cursor(n.side(t,s)+e.from,n.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,i=!0){return uD(this,e,t,i)}moveVertically(e,t,i){return Nu(this,e,fD(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),zy(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(e),n=this.bidiSpans(s),a=n[gs.find(n,e-s.from,-1,t)];return Ih(i,a.dir==it.LTR==t>0)}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(Ly)||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>tP)return Cy(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||ky(n.isolates,i=a0(this,e))))return n.order;i||(i=a0(this,e));let s=XM(e.text,t,i);return this.bidiCache.push(new Wc(e.from,e.to,t,i,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||fe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ly(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={}){return Ll.of(new eo(typeof e=="number"?oe.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Ll.of(new eo(oe.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 Ct.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ct.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ks.newName(),s=[Fl.of(i),Jo.of(Sf(`.${i}`,e))];return t&&t.dark&&s.push(yf.of(!0)),s}static baseTheme(e){return Ds.lowest(Jo.of(Sf("."+wf,e,tw)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&Je.get(i)||Je.get(e);return((t=s?.rootView)===null||t===void 0?void 0:t.view)||null}}be.styleModule=Jo;be.inputHandler=Dy;be.clipboardInputFilter=Up;be.clipboardOutputFilter=Vp;be.scrollHandler=Oy;be.focusChangeEffect=Py;be.perLineTextDirection=Ly;be.exceptionSink=My;be.updateListener=vf;be.editable=ji;be.mouseSelectionStyle=Ry;be.dragMovesSelection=Ty;be.clickAddsSelectionRange=Ay;be.decorations=Ma;be.outerDecorations=By;be.atomicRanges=Kp;be.bidiIsolatedRanges=Fy;be.scrollMargins=$y;be.darkTheme=yf;be.cspNonce=xe.define({combine:r=>r.length?r[0]:""});be.contentAttributes=Bh;be.editorAttributes=jy;be.lineWrapping=be.contentAttributes.of({class:"cm-lineWrapping"});be.announce=Pe.define();const tP=4096,D0={};class Wc{constructor(e,t,i,s,n,a){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=n,this.order=a}static update(e,t){if(t.empty&&!e.some(n=>n.fresh))return e;let i=[],s=e.length?e[e.length-1].dir:it.LTR;for(let n=Math.max(0,e.length-10);n<e.length;n++){let a=e[n];a.dir==s&&!t.touchesRange(a.from,a.to)&&i.push(new Wc(t.mapPos(a.from,1),t.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return i}}function P0(r,e,t){for(let i=r.state.facet(e),s=i.length-1;s>=0;s--){let n=i[s],a=typeof n=="function"?n(r):n;a&&uf(a,t)}return t}const rP=fe.mac?"mac":fe.windows?"win":fe.linux?"linux":"key";function iP(r,e){const t=r.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,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))s=!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 s&&(i="Alt-"+i),n&&(i="Ctrl-"+i),o&&(i="Meta-"+i),a&&(i="Shift-"+i),i}function $l(r,e,t){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t!==!1&&e.shiftKey&&(r="Shift-"+r),r}const sP=Ds.default(be.domEventHandlers({keydown(r,e){return iw(rw(e.state),r,e,"editor")}})),$h=xe.define({enables:sP}),L0=new WeakMap;function rw(r){let e=r.facet($h),t=L0.get(e);return t||L0.set(e,t=aP(e.reduce((i,s)=>i.concat(s),[]))),t}function nP(r,e,t){return iw(rw(r.state),e,r,t)}let hs=null;const oP=4e3;function aP(r,e=rP){let t=Object.create(null),i=Object.create(null),s=(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,h)=>{var u,d;let f=t[a]||(t[a]=Object.create(null)),_=o.split(/ (?!$)/).map(g=>iP(g,e));for(let g=1;g<_.length;g++){let v=_.slice(0,g).join(" ");s(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[x=>{let w=hs={view:x,prefix:v,scope:a};return setTimeout(()=>{hs==w&&(hs=null)},oP),!0}]})}let b=_.join(" ");s(b,!1);let p=f[b]||(f[b]={preventDefault:!1,stopPropagation:!1,run:((d=(u=f._any)===null||u===void 0?void 0:u.run)===null||d===void 0?void 0:d.slice())||[]});l&&p.run.push(l),c&&(p.preventDefault=!0),h&&(p.stopPropagation=!0)};for(let a of r){let o=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let c of o){let h=t[c]||(t[c]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:u}=a;for(let d in h)h[d].run.push(f=>u(f,kf))}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 kf=null;function iw(r,e,t,i){kf=e;let s=DM(e),n=$r(s,0),a=Ii(n)==s.length&&s!=" ",o="",l=!1,c=!1,h=!1;hs&&hs.view==t&&hs.scope==i&&(o=hs.prefix+" ",Vy.indexOf(e.keyCode)<0&&(c=!0,hs=null));let u=new Set,d=p=>{if(p){for(let g of p.run)if(!u.has(g)&&(u.add(g),g(t)))return p.stopPropagation&&(h=!0),!0;p.preventDefault&&(p.stopPropagation&&(h=!0),c=!0)}return!1},f=r[i],_,b;return f&&(d(f[o+$l(s,e,!a)])?l=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(fe.windows&&e.ctrlKey&&e.altKey)&&(_=Cs[e.keyCode])&&_!=s?(d(f[o+$l(_,e,!0)])||e.shiftKey&&(b=Aa[e.keyCode])!=s&&b!=_&&d(f[o+$l(b,e,!1)]))&&(l=!0):a&&e.shiftKey&&d(f[o+$l(s,e,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&h&&e.stopPropagation(),kf=null,l}class rl{constructor(e,t,i,s,n){this.className=e,this.left=t,this.top=i,this.width=s,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 s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let n=sw(e);return[new rl(t,s.left-n.left,s.top-n.top,null,s.bottom-s.top)]}else return lP(e,t,i)}}function sw(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==it.LTR?e.left:e.right-r.scrollDOM.clientWidth*r.scaleX)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function N0(r,e,t,i){let s=r.coordsAtPos(e,t*2);if(!s)return i;let n=r.dom.getBoundingClientRect(),a=(s.top+s.bottom)/2,o=r.posAtCoords({x:n.left+1,y:a}),l=r.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 lP(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let i=Math.max(t.from,r.viewport.from),s=Math.min(t.to,r.viewport.to),n=r.textDirection==it.LTR,a=r.contentDOM,o=a.getBoundingClientRect(),l=sw(r),c=a.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=o.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=o.right-(h?parseInt(h.paddingRight):0),f=xf(r,i),_=xf(r,s),b=f.type==Gt.Text?f:null,p=_.type==Gt.Text?_:null;if(b&&(r.lineWrapping||f.widgetLineBreaks)&&(b=N0(r,i,1,b)),p&&(r.lineWrapping||_.widgetLineBreaks)&&(p=N0(r,s,-1,p)),b&&p&&b.from==p.from&&b.to==p.to)return v(x(t.from,t.to,b));{let S=b?x(t.from,null,b):w(f,!1),k=p?x(null,t.to,p):w(_,!0),C=[];return(b||f).to<(p||_).from-(b&&p?1:0)||f.widgetLineBreaks>1&&S.bottom+r.defaultLineHeight/2<k.top?C.push(g(u,S.bottom,d,k.top)):S.bottom<k.top&&r.elementAtHeight((S.bottom+k.top)/2).type==Gt.Text&&(S.bottom=k.top=(S.bottom+k.top)/2),v(S).concat(C).concat(v(k))}function g(S,k,C,y){return new rl(e,S-l.left,k-l.top,C-S,y-k)}function v({top:S,bottom:k,horizontal:C}){let y=[];for(let E=0;E<C.length;E+=2)y.push(g(C[E],S,C[E+1],k));return y}function x(S,k,C){let y=1e9,E=-1e9,D=[];function T(O,$,G,V,q){let L=r.coordsAtPos(O,O==C.to?-2:2),N=r.coordsAtPos(G,G==C.from?2:-2);!L||!N||(y=Math.min(L.top,N.top,y),E=Math.max(L.bottom,N.bottom,E),q==it.LTR?D.push(n&&$?u:L.left,n&&V?d:N.right):D.push(!n&&V?u:N.left,!n&&$?d:L.right))}let M=S??C.from,R=k??C.to;for(let O of r.visibleRanges)if(O.to>M&&O.from<R)for(let $=Math.max(O.from,M),G=Math.min(O.to,R);;){let V=r.state.doc.lineAt($);for(let q of r.bidiSpans(V)){let L=q.from+V.from,N=q.to+V.from;if(L>=G)break;N>$&&T(Math.max(L,$),S==null&&L<=M,Math.min(N,G),k==null&&N>=R,q.dir)}if($=V.to+1,$>=G)break}return D.length==0&&T(M,S==null,R,k==null,r.textDirection),{top:y,bottom:E,horizontal:D}}function w(S,k){let C=o.top+(k?S.top:S.bottom);return{top:C,bottom:C,horizontal:[]}}}function cP(r,e){return r.constructor==e.constructor&&r.eq(e)}class hP{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(bc)!=e.state.facet(bc)&&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(bc);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)=>!cP(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const bc=xe.define();function nw(r){return[Ct.define(e=>new hP(e,r)),bc.of(r)]}
26const ow=!(fe.ios&&fe.webkit&&fe.webkit_version<534),Da=xe.define({combine(r){return Rn(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function uP(r={}){return[Da.of(r),dP,fP,pP,Ny.of(!0)]}function aw(r){return r.startState.facet(Da)!=r.state.facet(Da)}const dP=nw({above:!0,markers(r){let{state:e}=r,t=e.facet(Da),i=[];for(let s of e.selection.ranges){let n=s==e.selection.main;if(s.empty?!n||ow:t.drawRangeCursor){let a=n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=s.empty?s:oe.cursor(s.head,s.head>s.anchor?-1:1);for(let l of rl.forRange(r,a,o))i.push(l)}}return i},update(r,e){r.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=aw(r);return t&&O0(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){O0(e.state,r)},class:"cm-cursorLayer"});function O0(r,e){e.style.animationDuration=r.facet(Da).cursorBlinkRate+"ms"}const fP=nw({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:rl.forRange(r,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||aw(r)},class:"cm-selectionLayer"}),Cf={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};ow&&(Cf[".cm-line"].caretColor=Cf[".cm-content"].caretColor="transparent !important");const pP=Ds.highest(be.theme(Cf)),lw=Pe.define({map(r,e){return r==null?null:e.mapPos(r)}}),ta=Et.define({create(){return null},update(r,e){return r!=null&&(r=e.changes.mapPos(r)),e.effects.reduce((t,i)=>i.is(lw)?i.value:t,r)}}),mP=Ct.fromClass(class{constructor(r){this.view=r,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(r){var e;let t=r.state.field(ta);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"),(r.startState.field(ta)!=t||r.docChanged||r.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:r}=this,e=r.state.field(ta),t=e!=null&&r.coordsAtPos(e);if(!t)return null;let i=r.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+r.scrollDOM.scrollLeft*r.scaleX,top:t.top-i.top+r.scrollDOM.scrollTop*r.scaleY,height:t.bottom-t.top}}drawCursor(r){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;r?(this.cursor.style.left=r.left/e+"px",this.cursor.style.top=r.top/t+"px",this.cursor.style.height=r.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(r){this.view.state.field(ta)!=r&&this.view.dispatch({effects:lw.of(r)})}},{eventObservers:{dragover(r){this.setDropPos(this.view.posAtCoords({x:r.clientX,y:r.clientY}))},dragleave(r){(r.target==this.view.contentDOM||!this.view.contentDOM.contains(r.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function gP(){return[ta,mP]}const I0=Ct.fromClass(class{constructor(){this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}update(r){let{view:e}=r,t=e.viewState.editorHeight-e.defaultLineHeight-e.documentPadding.top-.5;t>=0&&t!=this.height&&(this.height=t,this.attrs={style:`padding-bottom: ${t}px`})}});function vP(){return[I0,Bh.of(r=>{var e;return((e=r.plugin(I0))===null||e===void 0?void 0:e.attrs)||null})]}function bP(){return _P}const xP=Ne.line({class:"cm-activeLine"}),_P=Ct.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=-1,t=[];for(let i of r.state.selection.ranges){let s=r.lineBlockAt(i.head);s.from>e&&(t.push(xP.range(s.from)),e=s.from)}return Ne.set(t)}},{decorations:r=>r.decorations}),Wo="-10000px";class yP{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,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 s=e.state.facet(this.facet),n=s.filter(l=>l);if(s===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],h=-1;if(c){for(let u=0;u<this.tooltips.length;u++){let d=this.tooltips[u];d&&d.create==c.create&&(h=u)}if(h<0)a[l]=this.createTooltipView(c,l?a[l-1]:null),o&&(o[l]=!!c.above);else{let u=a[l]=this.tooltipViews[h];o&&(o[l]=t[h]),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));
vendor: 10,009 bytes, line 26
26return t&&(o.forEach((l,c)=>t[c]=l),t.length=o.length),this.input=s,this.tooltips=n,this.tooltipViews=a,!0}}function wP(r={}){return xc.of(r)}function SP(r){let{win:e}=r;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const xc=xe.define({combine:r=>{var e,t,i;return{position:fe.ios?"absolute":((e=r.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=r.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=r.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||SP}}}),j0=new WeakMap,cw=Ct.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=r.state.facet(xc);this.position=e.position,this.parent=e.parent,this.classes=r.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 yP(r,Zp,(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(),r.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 r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(r,this.above);e&&this.observeIntersection();let t=e||r.geometryChanged,i=r.state.facet(xc);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.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 s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(r,e){let t=r.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),r.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=Wo,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 r,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(r=i.destroy)===null||r===void 0||r.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 r=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:n}=this.manager.tooltipViews[0];if(fe.gecko)t=n.offsetParent!=this.container.ownerDocument.body;else if(n.style.top==Wo&&n.style.left=="0px"){let a=n.getBoundingClientRect();t=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}}if(t||this.position=="absolute")if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(r=n.width/this.parent.offsetWidth,e=n.height/this.parent.offsetHeight)}else({scaleX:r,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=qp(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.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(xc).tooltipSpace(this.view),scaleX:r,scaleY:e,makeAbsolute:t}}writeMeasure(r){var e;if(r.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:s,scaleY:n}=r,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let l=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:h}=c,u=r.pos[o],d=r.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)){h.style.top=Wo;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,_=f?7:0,b=d.right-d.left,p=(e=j0.get(c))!==null&&e!==void 0?e:d.bottom-d.top,g=c.offset||CP,v=this.view.textDirection==it.LTR,x=d.width>i.right-i.left?v?i.left:i.right-d.width:v?Math.max(i.left,Math.min(u.left-(f?14:0)+g.x,i.right-b)):Math.min(Math.max(i.left,u.left-b+(f?14:0)-g.x),i.right-b),w=this.above[o];!l.strictSide&&(w?u.top-p-_-g.y<i.top:u.bottom+p+_+g.y>i.bottom)&&w==i.bottom-u.bottom>u.top-i.top&&(w=this.above[o]=!w);let S=(w?u.top-i.top:i.bottom-u.bottom)-_;if(S<p&&c.resize!==!1){if(S<this.view.defaultLineHeight){h.style.top=Wo;continue}j0.set(c,p),h.style.height=(p=S)/n+"px"}else h.style.height&&(h.style.height="");let k=w?u.top-p-_-g.y:u.bottom+_+g.y,C=x+b;if(c.overlap!==!0)for(let y of a)y.left<C&&y.right>x&&y.top<k+p&&y.bottom>k&&(k=w?y.top-p-2-_:y.bottom+_+2);if(this.position=="absolute"?(h.style.top=(k-r.parent.top)/n+"px",B0(h,(x-r.parent.left)/s)):(h.style.top=k/n+"px",B0(h,x/s)),f){let y=u.left+(v?g.x:-g.x)-(x+14-7);f.style.left=y/s+"px"}c.overlap!==!0&&a.push({left:x,top:k,right:C,bottom:k+p}),h.classList.toggle("cm-tooltip-above",w),h.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(r.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 r of this.manager.tooltipViews)r.dom.style.top=Wo}},{eventObservers:{scroll(){this.maybeMeasure()}}});function B0(r,e){let t=parseInt(r.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(r.style.left=e+"px")}const kP=be.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:`${7*2}px`,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"}}}),CP={x:0,y:0},Zp=xe.define({enables:[cw,kP]});function hw(r,e){let t=r.plugin(cw);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const F0=xe.define({combine(r){let e,t;for(let i of r)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Uc(r,e){let t=r.plugin(uw),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const uw=Ct.fromClass(class{constructor(r){this.input=r.state.facet(Vc),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(r));let e=r.state.facet(F0);this.top=new Hl(r,!0,e.topContainer),this.bottom=new Hl(r,!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(r){let e=r.state.facet(F0);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Hl(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Hl(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=r.state.facet(Vc);if(t!=this.input){let i=t.filter(l=>l),s=[],n=[],a=[],o=[];for(let l of i){let c=this.specs.indexOf(l),h;c<0?(h=l(r.view),o.push(h)):(h=this.panels[c],h.update&&h.update(r)),s.push(h),(h.top?n:a).push(h)}this.specs=i,this.panels=s,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(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>be.scrollMargins.of(e=>{let t=e.plugin(r);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});let Hl=class{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",this.dom.style[this.top?"to
26p":"bottom"]="0";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=$0(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=$0(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 $0(r){let e=r.nextSibling;return r.remove(),e}const Vc=xe.define({enables:uw});class qi extends pn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}qi.prototype.elementClass="";qi.prototype.toDOM=void 0;qi.prototype.mapMode=Ft.TrackBefore;qi.prototype.startSide=qi.prototype.endSide=-1;qi.prototype.point=!0;const _c=xe.define(),EP=xe.define(),AP={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Ue.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},ha=xe.define();function TP(r){return[dw(),ha.of(Object.assign(Object.assign({},AP),r))]}const H0=xe.define({combine:r=>r.some(e=>e)});function dw(r){return[RP]}const RP=Ct.fromClass(class{constructor(r){this.view=r,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(ha).map(e=>new W0(r,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!r.state.facet(H0),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}update(r){if(this.updateGutters(r)){let e=this.prevViewport,t=r.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}r.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(H0)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&this.dom.remove();let t=Ue.iter(this.view.state.facet(_c),this.view.viewport.from),i=[],s=this.gutters.map(n=>new MP(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==Gt.Text&&a){Ef(t,i,o.from);for(let l of s)l.line(this.view,o,i);a=!1}else if(o.widget)for(let l of s)l.widget(this.view,o)}else if(n.type==Gt.Text){Ef(t,i,n.from);for(let a of s)a.line(this.view,n,i)}else if(n.widget)for(let a of s)a.widget(this.view,n);for(let n of s)n.finish();r&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(r){let e=r.startState.facet(ha),t=r.state.facet(ha),i=r.docChanged||r.heightChanged||r.viewportChanged||!Ue.eq(r.startState.facet(_c),r.state.facet(_c),r.view.viewport.from,r.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(r)&&(i=!0);else{i=!0;let s=[];for(let n of t){let a=e.indexOf(n);a<0?s.push(new W0(this.view,n)):(this.gutters[a].update(r),s.push(this.gutters[a]))}for(let n of this.gutters)n.dom.remove(),s.indexOf(n)<0&&n.destroy();for(let n of s)this.dom.appendChild(n.dom);this.gutters=s}return i}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove()}},{provide:r=>be.scrollMargins.of(e=>{let t=e.plugin(r);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==it.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function z0(r){return Array.isArray(r)?r:[r]}function Ef(r,e,t){for(;r.value&&r.from<=t;)r.from==t&&e.push(r.value),r.next()}class MP{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=Ue.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,n=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==s.elements.length){let o=new fw(e,a,n,i);s.elements.push(o),s.dom.appendChild(o.dom)}else s.elements[this.i].update(e,a,n,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Ef(this.cursor,s,t.from),i.length&&(s=s.concat(i));let n=this.gutter.config.lineMarker(e,t,s);n&&s.unshift(n);let a=this.gutter;s.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),s=i?[i]:null;for(let n of e.state.facet(EP)){let a=n(e,t.widget,t);a&&(s||(s=[])).push(a)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class W0{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="
26cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let n=s.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=s.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[i](e,o,s)&&s.preventDefault()});this.markers=z0(t.markers(e)),t.initialSpacer&&(this.spacer=new fw(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=z0(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!Ue.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 fw{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),DP(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let n=0,a=0;;){let o=a,l=n<t.length?t[n++]:null,c=!1;if(l){let h=l.elementClass;h&&(i+=" "+h);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 h=this.markers[a++];if(h.toDOM){h.destroy(s);let u=s.nextSibling;s.remove(),s=u}}if(!l)break;l.toDOM&&(c?s=s.nextSibling:this.dom.insertBefore(l.toDOM(e),s)),c&&a++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function DP(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].compare(e[t]))return!1;return!0}const PP=xe.define(),LP=xe.define(),qn=xe.define({combine(r){return Rn(r,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let s in t){let n=i[s],a=t[s];i[s]=n?(o,l,c)=>n(o,l,c)||a(o,l,c):a}return i}})}});class ju extends qi{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Bu(r,e){return r.state.facet(qn).formatNumber(e,r.state)}const NP=ha.compute([qn],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(PP)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new ju(Bu(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let s of e.state.facet(LP)){let n=s(e,t,i);if(n)return n}return null},lineMarkerChange:e=>e.startState.facet(qn)!=e.state.facet(qn),initialSpacer(e){return new ju(Bu(e,U0(e.state.doc.lines)))},updateSpacer(e,t){let i=Bu(t.view,U0(t.view.state.doc.lines));return i==e.number?e:new ju(i)},domEventHandlers:r.facet(qn).domEventHandlers}));function OP(r={}){return[qn.of(r),dw(),NP]}function U0(r){let e=9;for(;e<r;)e=e*10+9;return e}const IP=new class extends qi{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},jP=_c.compute(["selection"],r=>{let e=[],t=-1;for(let i of r.selection.ranges){let s=r.doc.lineAt(i.head).from;s>t&&(t=s,e.push(IP.range(s)))}return Ue.of(e)});function BP(){return jP}const FP=1024;let $P=0;class Tr{constructor(e,t){this.from=e,this.to=t}}class Oe{constructor(e={}){this.id=$P++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=nr.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}Oe.closedBy=new Oe({deserialize:r=>r.split(" ")});Oe.openedBy=new Oe({deserialize:r=>r.split(" ")});Oe.group=new Oe({deserialize:r=>r.split(" ")});Oe.isolate=new Oe({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});Oe.contextHash=new Oe({perNode:!0});Oe.lookAhead=new Oe({perNode:!0});Oe.mounted=new Oe({perNode:!0});class Pa{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[Oe.mounted.id]}}const HP=Object.create(null);class nr{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):HP,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new nr(e.name||"",t,e.id,i);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(s)),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 s}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(Oe.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 s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(Oe.group),n=-1;n<(s?s.length:0);n++){let a=t[n<0?i.name:s[n]];if(a)return a}}}}nr.none=new nr("",Object.create(null),0,8);class pw{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 s=null;for(let n of e){let a=n(i);a&&(s||(s=Object.assign({},i.props)),s[a[0].id]=a[1])}t.push(s?new nr(i.name,s,i.id,i.flags):i)}return new pw(t)}}const zl=new WeakMap,V0=new WeakMap;var lt;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays"})(lt||(lt={}));
vendor: 8,897 bytes, line 26
26class _t{constructor(e,t,i,s,n){if(this.type=e,this.children=t,this.positions=i,this.length=s,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=Pa.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let s=i.toString();s&&(t&&(t+=","),t+=s)}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 Kc(this.topNode,e)}cursorAt(e,t=0,i=0){let s=zl.get(this)||this.topNode,n=new Kc(s);return n.moveTo(e,t),zl.set(this,n._tree),n}get topNode(){return new zt(this,0,0,null)}resolve(e,t=0){let i=La(zl.get(this)||this.topNode,e,t,!1);return zl.set(this,i),i}resolveInner(e,t=0){let i=La(V0.get(this)||this.topNode,e,t,!0);return V0.set(this,i),i}resolveStack(e,t=0){return UP(this,e,t)}iterate(e){let{enter:t,leave:i,from:s=0,to:n=this.length}=e,a=e.mode||0,o=(a<.IncludeAnonymous)>0;for(let l=this.cursor(a|lt.IncludeAnonymous);;){let c=!1;if(l.from<=n&&l.to>=s&&(!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:em(nr.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new _t(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new _t(nr.none,t,i,s)))}static build(e){return VP(e)}}_t.empty=new _t(nr.none,[],[],0);class Jp{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 Jp(this.buffer,this.index)}}class As{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return nr.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],s=this.set.types[t],n=s.name;if(/\W/.test(n)&&!s.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,s,n){let{buffer:a}=this,o=-1;for(let l=e;l!=t&&!(mw(n,s,a[l+1],a[l+2])&&(o=l,i>0));l=a[l+3]);return o}slice(e,t,i){let s=this.buffer,n=new Uint16Array(t-e),a=0;for(let o=e,l=0;o<t;){n[l++]=s[o++],n[l++]=s[o++]-i;let c=n[l++]=s[o++]-i;n[l++]=s[o++]-e,a=Math.max(a,c)}return new As(n,a,this.set)}}function mw(r,e,t,i){switch(r){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 La(r,e,t,i){for(var s;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let a=!i&&r instanceof zt&&r.index<0?null:r.parent;if(!a)return r;r=a}let n=i?0:lt.IgnoreOverlays;if(i)for(let a=r,o=a.parent;o;a=o,o=a.parent)a instanceof zt&&a.index<0&&((s=o.enter(e,t,n))===null||s===void 0?void 0:s.from)!=a.from&&(r=o);for(;;){let a=r.enter(e,t,n);if(!a)return r;r=a}}class gw{cursor(e=0){return new Kc(this,e)}getChild(e,t=null,i=null){let s=K0(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return K0(this,e,t,i)}resolve(e,t=0){return La(this,e,t,!1)}resolveInner(e,t=0){return La(this,e,t,!0)}matchContext(e){return Af(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(i=t,t=s.prevSibling):t=s}return i}get node(){return this}get next(){return this.parent}}class zt extends gw{constructor(e,t,i,s){super(),this._tree=e,this.from=t,this.index=i,this._parent=s}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,s,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 h=o[e],u=l[e]+a.from;if(mw(s,i,u,u+h.length)){if(h instanceof As){if(n<.ExcludeBuffers)continue;let d=h.findChild(0,h.buffer.length,t,i-u,s);if(d>-1)return new pi(new zP(a,h,e,u),null,d)}else if(n<.IncludeAnonymous||!h.type.isAnonymous||Qp(h)){let d;if(!(n<.IgnoreMounts)&&(d=Pa.get(h))&&!d.overlay)return new zt(d.tree,u,e,a);let f=new zt(h,u,e,a);return n<.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(t<0?h.children.length-1:0,t,i,s)}}}if(n<.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)}enter(e,t,i=0){let s;if(!(i<.IgnoreOverlays)&&(s=Pa.get(this._tree))&&s.overlay){let n=e-this.from;for(let{from:a,to:o}of s.overlay)if((t>0?a<=n:a<n)&&(t<0?o>=n:o>n))return new zt(s.tree,s.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 K0(r,e,t,i){let s=r.cursor(),n=[];if(!s.firstChild())return n;if(t!=null){for(let a=!1;!a;)if(a=s.type.is(t),!s.nextSibling())return n}for(;;){if(i!=null&&s.type.is(i))return n;if(s.type.is(e)&&n.push(s.node),!s.nextSibling())return i==null?n:[]}}function Af(r,e,t=e.length-1){for(let i=r;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 zP{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class pi extends gw{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:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return n<0?null:new pi(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)}enter(e,t,i=0){if(i<.ExcludeBuffers)return null;let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return n<0?null:new pi(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 pi(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 pi(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,n=i.buffer[this.index+3];if(n>s){let a=i.buffer[this.index+1];e.push(i.slice(s,n,a)),t.push(0)}return new _t(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function vw(r){if(!r.length)return null;let e=0,t=r[0];for(let n=1;n<r.length;n++){let a=r[n];(a.from>t.from||a.to<t.to)&&(t=a,e=n)}let i=t instanceof zt&&t.index<0?null:t.parent,s=r.slice();return i?s[e]=i:s.splice(e,1),new WP(s,t)}class WP{constructor(e,t){this.heads=e,this.node=t}get next(){return vw(this.heads)}}function UP(r,e,t){let i=r.resolveInner(e,t),s=null;for(let n=i instanceof zt?i:i.context.parent;n;n=n.parent)if(n.index<0){let a=n.parent;(s||(s=[i])).push(a.resolve(e,t)),n=a}else{let a=Pa.get(n.tree);if(a&&a.overlay&&a.overlay[0].from<=e&&a.overlay[a.overlay.length-1].to>=e){let o=new zt(a.tree,a.overlay[0].from+n.from,-1,n);(s||(s=[i])).push(La(o,e,t,!1))}}return s?vw(s):i}class Kc{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof zt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;
vendor: 2,347 bytes, line 26
26for(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:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof zt?(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:s}=this.buffer,n=s.findChild(this.index+4,s.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<.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode<.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode<.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 s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}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:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let n=0;n<this.index;n++)if(s.buffer.buffer[n+3]<this.index)return!1;({index:t,parent:i}=s)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>
vendor: 36,578 bytes, line 26
26-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<.IncludeAnonymous||o instanceof As||!o.type.isAnonymous||Qp(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 s=this.index,n=this.stack.length;n>=0;){for(let a=e;a;a=a._parent)if(a.index==s){if(s==this.index)return a;t=a,i=n+1;break e}s=this.stack[--n]}for(let s=i;s<this.stack.length;s++)t=new pi(this.buffer,t,this.stack[s]);return this.bufferNode=new pi(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(e){if(!this.buffer)return Af(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let s=e.length-1,n=this.stack.length-1;s>=0;n--){if(n<0)return Af(this._tree,e,s);let a=i[t.buffer[this.stack[n]]];if(!a.isAnonymous){if(e[s]&&e[s]!=a.name)return!1;s--}}return!0}}function Qp(r){return r.children.some(e=>e instanceof As||!e.type.isAnonymous||Qp(e))}function VP(r){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=FP,reused:n=[],minRepeatType:a=i.types.length}=r,o=Array.isArray(t)?new Jp(t,t.length):t,l=i.types,c=0,h=0;function u(S,k,C,y,E,D){let{id:T,start:M,end:R,size:O}=o,$=h,G=c;for(;O<0;)if(o.next(),O==-1){let I=n[T];C.push(I),y.push(M-S);return}else if(O==-3){c=T;return}else if(O==-4){h=T;return}else throw new RangeError(`Unrecognized record size: ${O}`);let V=l[T],q,L,N=M-S;if(R-M<=s&&(L=p(o.pos-k,E))){let I=new Uint16Array(L.size-L.skip),H=o.pos-L.size,W=I.length;for(;o.pos>H;)W=g(L.start,I,W);q=new As(I,R-L.start,i),N=L.start-S}else{let I=o.pos-O;o.next();let H=[],W=[],J=T>=a?T:-1,Z=0,X=R;for(;o.pos>I;)J>=0&&o.id==J&&o.size>=0?(o.end<=X-s&&(_(H,W,M,Z,o.end,X,J,$,G),Z=H.length,X=o.end),o.next()):D>2500?d(M,I,H,W):u(M,I,H,W,J,D+1);if(J>=0&&Z>0&&Z<H.length&&_(H,W,M,Z,M,X,J,$,G),H.reverse(),W.reverse(),J>-1&&Z>0){let F=f(V,G);q=em(V,H,W,0,H.length,0,R-M,F,F)}else q=b(V,H,W,R-M,$-R,G)}C.push(q),y.push(N)}function d(S,k,C,y){let E=[],D=0,T=-1;for(;o.pos>k;){let{id:M,start:R,end:O,size:$}=o;if($>4)o.next();else{if(T>-1&&R<T)break;T<0&&(T=O-s),E.push(M,R,O),D++,o.next()}}if(D){let M=new Uint16Array(D*4),R=E[E.length-2];for(let O=E.length-3,$=0;O>=0;O-=3)M[$++]=E[O],M[$++]=E[O+1]-R,M[$++]=E[O+2]-R,M[$++]=$;C.push(new As(M,E[2]-R,i)),y.push(R-S)}}function f(S,k){return(C,y,E)=>{let D=0,T=C.length-1,M,R;if(T>=0&&(M=C[T])instanceof _t){if(!T&&M.type==S&&M.length==E)return M;(R=M.prop(Oe.lookAhead))&&(D=y[T]+M.length+R)}return b(S,C,y,E,D,k)}}function _(S,k,C,y,E,D,T,M,R){let O=[],$=[];for(;S.length>y;)O.push(S.pop()),$.push(k.pop()+C-E);S.push(b(i.types[T],O,$,D-E,M-D,R)),k.push(E-C)}function b(S,k,C,y,E,D,T){if(D){let M=[Oe.contextHash,D];T=T?[M].concat(T):[M]}if(E>25){let M=[Oe.lookAhead,E];T=T?[M].concat(T):[M]}return new _t(S,k,C,y,T)}function p(S,k){let C=o.fork(),y=0,E=0,D=0,T=C.end-s,M={size:0,start:0,skip:0};e:for(let R=C.pos-S;C.pos>R;){let O=C.size;if(C.id==k&&O>=0){M.size=y,M.start=E,M.skip=D,D+=4,y+=4,C.next();continue}let $=C.pos-O;if(O<0||$<R||C.start<T)break;let G=C.id>=a?4:0,V=C.start;for(C.next();C.pos>$;){if(C.size<0)if(C.size==-3)G+=4;else break e;else C.id>=a&&(G+=4);C.next()}E=V,y+=O,D+=G}return(k<0||y==S)&&(M.size=y,M.start=E,M.skip=D),M.size>4?M:void 0}function g(S,k,C){let{id:y,start:E,end:D,size:T}=o;if(o.next(),T>=0&&y<a){let M=C;if(T>4){let R=o.pos-(T-4);for(;o.pos>R;)C=g(S,k,C)}k[--C]=M,k[--C]=D-S,k[--C]=E-S,k[--C]=y}else T==-3?c=y:T==-4&&(h=y);return C}let v=[],x=[];for(;o.pos>0;)u(r.start||0,r.bufferStart||0,v,x,-1,0);let w=(e=r.length)!==null&&e!==void 0?e:v.length?x[0]+v[0].length:0;return new _t(l[r.topID],v.reverse(),x.reverse(),w)}const q0=new WeakMap;function yc(r,e){if(!r.isAnonymous||e instanceof As||e.type!=r)return 1;let t=q0.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=r||!(i instanceof _t)){t=1;break}t+=yc(r,i)}q0.set(e,t)}return t}function em(r,e,t,i,s,n,a,o,l){let c=0;for(let _=i;_<s;_++)c+=yc(r,e[_]);let h=Math.ceil(c*1.5/8),u=[],d=[];function f(_,b,p,g,v){for(let x=p;x<g;){let w=x,S=b[x],k=yc(r,_[x]);for(x++;x<g;x++){let C=yc(r,_[x]);if(k+C>=h)break;k+=C}if(x==w+1){if(k>h){let C=_[w];f(C.children,C.positions,0,C.children.length,b[w]+v);continue}u.push(_[w])}else{let C=b[x-1]+_[x-1].length-S;u.push(em(r,_,b,w,x,S,C,null,l))}d.push(S+v-n)}}return f(e,t,i,s,0),(o||l)(u,d,a)}class R${constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof pi?this.setBuffer(e.context.buffer,e.index,t):e instanceof zt&&this.map.set(e.tree,t)}get(e){return e instanceof pi?this.getBuffer(e.context.buffer,e.index):e instanceof zt?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 Wi{constructor(e,t,i,s,n=!1,a=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,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 s=[new Wi(0,e.length,e,0,!1,i)];for(let n of t)n.to>e.length&&s.push(n);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],n=1,a=e.length?e[0]:null;for(let o=0,l=0,c=0;;o++){let h=o<t.length?t[o]:null,u=h?h.fromA:1e9;if(u-l>=i)for(;a&&a.from<u;){let d=a;if(l>=d.from||u<=d.to||c){let f=Math.max(d.from,l)-c,_=Math.min(d.to,u)-c;d=f>=_?null:new Wi(f,_,d.tree,d.offset+c,o>0,!!h)}if(d&&s.push(d),a.to>u)break;a=n<e.length?e[n++]:null}if(!h)break;l=h.toA,c=h.toA-h.toB}return s}}class KP{startParse(e,t,i){return typeof e=="string"&&(e=new qP(e)),i=i?i.length?i.map(s=>new Tr(s.from,s.to)):[new Tr(0,0)]:[new Tr(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let n=s.advance();if(n)return n}}}class qP{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 M$(r){return(e,t,i,s)=>new XP(e,r,t,i,s)}class G0{constructor(e,t,i,s,n){this.parser=e,this.parse=t,this.overlay=i,this.target=s,this.from=n}}function X0(r){if(!r.length||r.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(r))}class GP{constructor(e,t,i,s,n,a,o){this.parser=e,this.predicate=t,this.mounts=i,this.index=s,this.start=n,this.target=a,this.prev=o,this.depth=0,this.ranges=[]}}const Tf=new Oe({perNode:!0});class XP{constructor(e,t,i,s,n){this.nest=t,this.input=i,this.fragments=s,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 s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new _t(i.type,i.children,i.positions,i.length,i.propValues.concat([[Tf,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[Oe.mounted.id]=new Pa(t,e.overlay,e.parser),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 JP(this.fragments),t=null,i=null,s=new Kc(new zt(this.baseTree,this.ranges[0].from,0,null),lt.IncludeAnonymous|lt.IgnoreMounts);e:for(let n,a;;){let o=!0,l;if(this.stoppedAt!=null&&s.from>=this.stoppedAt)o=!1;else if(e.hasNode(s)){if(t){let c=t.mounts.find(h=>h.frag.from<=s.from&&h.frag.to>=s.to&&h.mount.overlay);if(c)for(let h of c.mount.overlay){let u=h.from+c.pos,d=h.to+c.pos;u>=s.from&&d<=s.to&&!t.ranges.some(f=>f.from<d&&f.to>u)&&t.ranges.push({from:u,to:d})}}o=!1}else if(i&&(a=YP(i.ranges,s.from,s.to)))o=a!=2;else if(!s.type.isAnonymous&&(n=this.nest(s,this.input))&&(s.from<s.to||!n.overlay)){s.tree||ZP(s);let c=e.findMounts(s.from,n.parser);if(typeof n.overlay=="function")t=new GP(n.parser,n.overlay,c,this.inner.length,s.from,s.tree,t);else{let h=J0(this.ranges,n.overlay||(s.from<s.to?[new Tr(s.from,s.to)]:[]));h.length&&X0(h),(h.length||!n.overlay)&&this.inner.push(new G0(n.parser,h.length?n.parser.startParse(this.input,Q0(c,h),h):n.parser.startParse(""),n.overlay?n.overlay.map(u=>new Tr(u.from-s.from,u.to-s.from)):null,s.tree,h.length?h[0].from:s.from)),n.overlay?h.length&&(i={ranges:h,depth:0,prev:i}):o=!1}}else if(t&&(l=t.predicate(s))&&(l===!0&&(l=new Tr(s.from,s.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&&s.firstChild())t&&t.depth++,i&&i.depth++;else for(;!s.nextSibling();){if(!s.parent())break e;if(t&&!--t.depth){let c=J0(this.ranges,t.ranges);c.length&&(X0(c),this.inner.splice(t.index,0,new G0(t.parser,t.parser.startParse(this.input,Q0(t.mounts,c),c),t.ranges.map(h=>new Tr(h.from-t.start,h.to-t.start)),t.target,c[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function YP(r,e,t){for(let i of r){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function Y0(r,e,t,i,s,n){if(e<t){let a=r.buffer[e+1];i.push(r.slice(e,t,a)),s.push(a-n)}}function ZP(r){let{node:e}=r,t=[],i=e.context.buffer;do t.push(r.index),r.parent();while(!r.tree);let s=r.tree,n=s.children.indexOf(i),a=s.children[n],o=a.buffer,l=[n];function c(h,u,d,f,_,b){let p=t[b],g=[],v=[];Y0(a,h,p,g,v,f);let x=o[p+1],w=o[p+2];l.push(g.length);let S=b?c(p+4,o[p+3],a.set.types[o[p]],x,w-x,b-1):e.toTree();return g.push(S),v.push(x-f),Y0(a,o[p+3],u,g,v,f),new _t(d,g,v,_)}s.children[n]=c(0,o.length,nr.none,0,a.length,t.length-1);for(let h of l){let u=r.tree.children[h],d=r.tree.positions[h];r.yield(new zt(u,d+r.from,h,r._tree))}}class Z0{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(lt.IncludeAnonymous|lt.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)t.to>=e&&t.enter(i,1,lt.IgnoreOverlays|lt.ExcludeBuffers)||t.next(!1)||(this.done=!0)}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 _t)t=t.children[0];else break}return!1}}class JP{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(Tf))!==null&&t!==void 0?t:i.to,this.inner=new Z0(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(Tf))!==null&&e!==void 0?e:t.to,this.inner=new Z0(t.tree,-t.offset)}}findMounts(e,t){var i;let s=[];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(Oe.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&&s.push({frag:l,pos:n.from-l.offset,mount:a})}}}return s}}function J0(r,e){let t=null,i=e;for(let s=1,n=0;s<r.length;s++){let a=r[s-1].to,o=r[s].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 Tr(l.from,a),l.to>o&&t.splice(n+1,0,new Tr(o,l.to))):l.to>o?t[n--]=new Tr(o,l.to):t.splice(n--,1))}}return i}function QP(r,e,t,i){let s=0,n=0,a=!1,o=!1,l=-1e9,c=[];for(;;){let h=s==r.length?1e9:a?r[s].to:r[s].from,u=n==e.length?1e9:o?e[n].to:e[n].from;if(a!=o){let d=Math.max(l,t),f=Math.min(h,u,i);d<f&&c.push(new Tr(d,f))}if(l=Math.min(h,u),l==1e9)break;h==l&&(a?(a=!1,s++):a=!0),u==l&&(o?(o=!1,n++):o=!0)}return c}function Q0(r,e){let t=[];for(let{pos:i,mount:s,frag:n}of r){let a=i+(s.overlay?s.overlay[0].from:0),o=a+s.tree.length,l=Math.max(n.from,a),c=Math.min(n.to,o);if(s.overlay){let h=s.overlay.map(d=>new Tr(d.from+i,d.to+i)),u=QP(e,h,l,c);for(let d=0,f=l;;d++){let _=d==u.length,b=_?c:u[d].from;if(b>f&&t.push(new Wi(f,b,s.tree,-a,n.from>=f||n.openStart,n.to<=b||n.openEnd)),_)break;f=u[d].to}}else t.push(new Wi(l,c,s.tree,-a,n.from>=a||n.openStart,n.to<=o||n.openEnd))}return t}let eL=0;class Ar{constructor(e,t,i,s){this.name=e,this.set=t,this.base=i,this.modified=s,this.id=eL++}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 Ar&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let s=new Ar(i,[],null,[]);if(s.set.push(s),t)for(let n of t.set)s.set.push(n);return s}static defineModifier(e){let t=new qc(e);return i=>i.modified.indexOf(t)>-1?i:qc.get(i.base||i,i.modified.concat(t).sort((s,n)=>s.id-n.id))}}let tL=0;class qc{constructor(e){this.name=e,this.instances=[],this.id=tL++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(o=>o.base==e&&rL(t,o.modified));if(i)return i;let s=[],n=new Ar(e.name,s,e,t);for(let o of t)o.instances.push(n);let a=iL(t);for(let o of e.set)if(!o.modified.length)for(let l of a)s.push(qc.get(o,l));return n}}function rL(r,e){return r.length==e.length&&r.every((t,i)=>t==e[i])}function iL(r){let e=[[]];for(let t=0;t<r.length;t++)for(let i=0,s=e.length;i<s;i++)e.push(e[i].concat(r[t]));return e.sort((t,i)=>i.length-t.length)}function sL(r){let e=Object.create(null);for(let t in r){let i=r[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let n=[],a=2,o=s;for(let u=0;;){if(o=="..."&&u>0&&u+3==s.length){a=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!d)throw new RangeError("Invalid path: "+s);if(n.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),u+=d[0].length,u==s.length)break;let f=s[u++];if(u==s.length&&f=="!"){a=0;break}if(f!="/")throw new RangeError("Invalid path: "+s);o=s.slice(u)}let l=n.length-1,c=n[l];if(!c)throw new RangeError("Invalid path: "+s);let h=new Gc(i,a,l>0?n.slice(0,l):null);e[c]=h.sort(e[c])}}return bw.add(e)}const bw=new Oe;class Gc{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}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}}Gc.empty=new Gc([],2,null);function xw(r,e){let t=Object.create(null);for(let n of r)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:s=null}=e||{};return{style:n=>{let a=s;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 nL(r,e){let t=null;for(let i of r){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function oL(r,e,t,i=0,s=r.length){let n=new aL(i,Array.isArray(e)?e:[e],t);n.highlightRange(r.cursor(),i,s,"",n.highlighters),n.flush(s)}class aL{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,s,n){let{type:a,from:o,to:l}=e;if(o>=i||l<=t)return;a.isTop&&(n=this.highlighters.filter(f=>!f.scope||f.scope(a)));let c=s,h=lL(e)||Gc.empty,u=nL(n,h.tags);if(u&&(c&&(c+=" "),c+=u,h.mode==1&&(s+=(s?" ":"")+u)),this.startSpan(Math.max(t,o),c),h.opaque)return;let d=e.tree&&e.tree.prop(Oe.mounted);if(d&&d.overlay){let f=e.node.enter(d.overlay[0].from+o,1),_=this.highlighters.filter(p=>!p.scope||p.scope(d.tree.type)),b=e.firstChild();for(let p=0,g=o;;p++){let v=p<d.overlay.length?d.overlay[p]:null,x=v?v.from+o:l,w=Math.max(t,g),S=Math.min(i,x);if(w<S&&b)for(;e.from<S&&(this.highlightRange(e,w,S,s,n),this.startSpan(Math.min(S,e.to),c),!(e.to>=x||!e.nextSibling())););if(!v||x>i)break;g=v.to+o,g>t&&(this.highlightRange(f.cursor(),Math.max(t,v.from+o),Math.min(i,g),"",_),this.startSpan(Math.min(i,g),c))}b&&e.parent()}else if(e.firstChild()){d&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,n),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}}function lL(r){let e=r.type.prop(bw);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}const de=Ar.define,Wl=de(),ls=de(),ev=de(ls),tv=de(ls),cs=de(),Ul=de(cs),Fu=de(cs),oi=de(),Fs=de(oi),Qr=de(),ei=de(),Rf=de(),Uo=de(Rf),Vl=de(),te={comment:Wl,lineComment:de(Wl),blockComment:de(Wl),docComment:de(Wl),name:ls,variableName:de(ls),typeName:ev,tagName:de(ev),propertyName:tv,attributeName:de(tv),className:de(ls),labelName:de(ls),namespace:de(ls),macroName:de(ls),literal:cs,string:Ul,docString:de(Ul),character:de(Ul),attributeValue:de(Ul),number:Fu,integer:de(Fu),float:de(Fu),bool:de(cs),regexp:de(cs),escape:de(cs),color:de(cs),url:de(cs),keyword:Qr,self:de(Qr),null:de(Qr),atom:de(Qr),unit:de(Qr),modifier:de(Qr),operatorKeyword:de(Qr),controlKeyword:de(Qr),definitionKeyword:de(Qr),moduleKeyword:de(Qr),operator:ei,derefOperator:de(ei),arithmeticOperator:de(ei),logicOperator:de(ei),bitwiseOperator:de(ei),compareOperator:de(ei),updateOperator:de(ei),definitionOperator:de(ei),typeOperator:de(ei),controlOperator:de(ei),punctuation:Rf,separator:de(Rf),bracket:Uo,angleBracket:de(Uo),squareBracket:de(Uo),paren:de(Uo),brace:de(Uo),content:oi,heading:Fs,heading1:de(Fs),heading2:de(Fs),heading3:de(Fs),heading4:de(Fs),heading5:de(Fs),heading6:de(Fs),contentSeparator:de(oi),list:de(oi),quote:de(oi),emphasis:de(oi),strong:de(oi),link:de(oi),monospace:de(oi),strikethrough:de(oi),inserted:de(),deleted:de(),changed:de(),invalid:de(),meta:Vl,documentMeta:de(Vl),annotation:de(Vl),processingInstruction:de(Vl),definition:Ar.defineModifier("definition"),constant:Ar.defineModifier("constant"),function:Ar.defineModifier("function"),standard:Ar.defineModifier("standard"),local:Ar.defineModifier("local"),special:Ar.defineModifier("special")};for(let r in te){let e=te[r];e instanceof Ar&&(e.name=r)}xw([{tag:te.link,class:"tok-link"},{tag:te.heading,class:"tok-heading"},{tag:te.emphasis,class:"tok-emphasis"},{tag:te.strong,class:"tok-strong"},{tag:te.keyword,class:"tok-keyword"},{tag:te.atom,class:"tok-atom"},{tag:te.bool,class:"tok-bool"},{tag:te.url,class:"tok-url"},{tag:te.labelName,class:"tok-labelName"},{tag:te.inserted,class:"tok-inserted"},{tag:te.deleted,class:"tok-deleted"},{tag:te.literal,class:"tok-literal"},{tag:te.string,class:"tok-string"},{tag:te.number,class:"tok-number"},{tag:[te.regexp,te.escape,te.special(te.string)],class:"tok-string2"},{tag:te.variableName,class:"tok-variableName"},{tag:te.local(te.variableName),class:"tok-variableName tok-local"},{tag:te.definition(te.variableName),class:"tok-variableName tok-definition"},{tag:te.special(te.variableName),class:"tok-variableName2"},{tag:te.definition(te.propertyName),class:"tok-propertyName tok-definition"},{tag:te.typeName,class:"tok-typeName"},{tag:te.namespace,class:"tok-namespace"},{tag:te.className,class:"tok-className"},{tag:te.macroName,class:"tok-macroName"},{tag:te.propertyName,class:"tok-propertyName"},{tag:te.operator,class:"tok-operator"},{tag:te.comment,class:"tok-comment"},{tag:te.meta,class:"tok-meta"},{tag:te.invalid,class:"tok-invalid"},{tag:te.punctuation,class:"tok-punctuation"}]);var $u;const Gn=new Oe;function cL(r){return xe.define({combine:r?e=>e.concat(r):void 0})}const hL=new Oe;class Hr{constructor(e,t,i=[],s=""){this.data=e,this.name=s,He.prototype.hasOwnProperty("tree")||Object.defineProperty(He.prototype,"tree",{get(){return Lt(this)}}),this.parser=t,this.extension=[Ts.of(this),He.languageData.of((n,a,o)=>{let l=rv(n,a,o),c=l.type.prop(Gn);if(!c)return[];let h=n.facet(c),u=l.type.prop(hL);if(u){let d=l.resolve(a-l.from,o);for(let f of u)if(f.test(d,n)){let _=n.facet(f.facet);return f.type=="replace"?_:_.concat(h)}}return h})].concat(i)}isActiveAt(e,t,i=-1){return rv(e,t,i).type.prop(Gn)==this.data}findRegions(e){let t=e.facet(Ts);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(n,a)=>{if(n.prop(Gn)==this.data){i.push({from:a,to:a+n.length});return}let o=n.prop(Oe.mounted);if(o){if(o.tree.prop(Gn)==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(s(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 _t&&s(c,n.positions[l]+a)}};return s(Lt(e),0),i}get allowsNesting(){return!0}}Hr.setState=Pe.define();function rv(r,e,t){let i=r.facet(Ts),s=Lt(r).topNode;if(!i||i.allowsNesting)for(let n=s;n;n=n.enter(e,t,lt.ExcludeBuffers))n.type.isTop&&(s=n);return s}class Mf extends Hr{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=cL(e.languageData);return new Mf(t,e.parser.configure({props:[Gn.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new Mf(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Lt(r){let e=r.field(Hr.state,!1);return e?e.tree:_t.empty}class uL{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 Vo=null;class Xc{constructor(e,t,i=[],s,n,a,o,l){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=n,this.viewport=a,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Xc(e,t,[],_t.empty,0,i,[],null)}startParse(){return this.parser.startParse(new uL(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=_t.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}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 s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Wi.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,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(Wi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Vo;Vo=this;try{return e()}finally{Vo=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=iv(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:n,viewport:a,skipped:o}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,h,u,d)=>l.push({fromA:c,toA:h,fromB:u,toB:d})),i=Wi.applyChanges(i,l),s=_t.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 h=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);h<u&&o.push({from:h,to:u})}}}return new Xc(this.parser,t,i,s,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:s,to:n}=this.skipped[i];s<e.to&&n>e.from&&(this.fragments=iv(this.fragments,s,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 KP{createParse(t,i,s){let n=s[0].from,a=s[s.length-1].to;return{parsedPos:n,advance(){let l=Vo;if(l){for(let c of s)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=a,new _t(nr.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 Vo}}function iv(r,e,t){return Wi.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}class mo{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 mo(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Xc.create(e.facet(Ts).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new mo(i)}}Hr.state=Et.define({create:mo.init,update(r,e){for(let t of e.effects)if(t.is(Hr.setState))return t.value;return e.startState.facet(Ts)!=e.state.facet(Ts)?mo.init(e.state):r.apply(e)}});let _w=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(_w=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Hu=typeof navigator<"u"&&(!(($u=navigator.scheduling)===null||$u===void 0)&&$u.isInputPending)?()=>navigator.scheduling.isInputPending():null,dL=Ct.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(Hr.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(Hr.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=_w(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:s}}=this.view,n=i.field(Hr.state);if(n.tree==n.context.tree&&n.context.isDone(s+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Hu?Math.max(25,e.timeRemaining()-5):1e9),o=n.context.treeLen<s&&i.doc.length>s+1e3,l=n.context.work(()=>Hu&&Hu()||Date.now()>a,s+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:Hr.setState.of(new mo(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=>mr(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()}}}),Ts=xe.define({combine(r){return r.length?r[0]:null},enables:r=>[Hr.state,dL,be.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});class P${constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Tt{constructor(e,t,i,s,n,a=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=s,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 Tt(e.name,(e.alias||[]).concat(e.name).map(s=>s.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let s of e)if(s.filename&&s.filename.test(t))return s;let i=/\.([^.]+)$/.exec(t);if(i){for(let s of e)if(s.extensions.indexOf(i[1])>-1)return s}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let s of e)if(s.alias.some(n=>n==t))return s;if(i)for(let s of e)for(let n of s.alias){let a=t.indexOf(n);if(a>-1&&(n.length>2||!/\w/.test(t[a-1])&&!/\w/.test(t[a+n.length])))return s}return null}}const fL=xe.define(),ko=xe.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function Yc(r){let e=r.facet(ko);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function Na(r,e){let t="",i=r.tabSize,s=r.facet(ko)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let n=0;n<e;n++)t+=s;return t}function tm(r,e){r instanceof He&&(r=new Hh(r));for(let i of r.state.facet(fL)){let s=i(r,e);if(s!==void 0)return s}let t=Lt(r.state);return t.length>=e?mL(r,t,e):null}class Hh{constructor(e,t={}){this.state=e,this.options=t,this.unit=Yc(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:n}=this.options;return s!=null&&s>=i.from&&s<=i.to?n&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(e,t);return i.slice(e-s,Math.min(i.length,e+100-s))}column(e,t=1){let{text:i,from:s}=this.lineAt(e,t),n=this.countColumn(i,e-s),a=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return a>-1&&(n+=a-this.countColumn(i,i.search(/\S|$/))),n}countColumn(e,t=e.length){return Oh(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),n=this.options.overrideIndentation;if(n){let a=n(s);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const pL=new Oe;function mL(r,e,t){let i=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=i.node){let n=[];for(let a=s;a&&!(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 yw(i,r,t)}function yw(r,e,t){for(let i=r;i;i=i.next){let s=vL(i.node);if(s)return s(rm.create(e,t,i))}return 0}function gL(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function vL(r){let e=r.type.prop(pL);if(e)return e;let t=r.firstChild,i;if(t&&(i=t.type.prop(Oe.closedBy))){let s=r.lastChild,n=s&&i.indexOf(s.name)>-1;return a=>ww(a,!0,1,void 0,n&&!gL(a)?s.from:void 0)}return r.parent==null?bL:null}function bL(){return 0}class rm extends Hh{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 rm(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(xL(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return yw(this.context.next,this.base,this.pos)}}function xL(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function _L(r){let e=r.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=r.options.simulateBreak,n=r.state.doc.lineAt(t.from),a=s==null||s<=n.from?n.to:Math.min(n.to,s);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 L$({closing:r,align:e=!0,units:t=1}){return i=>ww(i,e,t,r)}function ww(r,e,t,i,s){let n=r.textAfter,a=n.match(/^\s*/)[0].length,o=i&&n.slice(a,a+i.length)==i||s==r.pos+a,l=e?_L(r):null;return l?o?r.column(l.from):r.column(l.to):r.baseIndent+(o?0:r.unit*t)}const N$=r=>r.baseIndent;function O$({except:r,units:e=1}={}){return t=>{let i=r&&r.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const yL=200;function wL(){return He.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:i}=r.newSelection.main,s=t.lineAt(i);if(i>s.from+yL)return r;let n=t.sliceString(s.from,i);if(!e.some(c=>c.test(n)))return r;let{state:a}=r,o=-1,l=[];for(let{head:c}of a.selection.ranges){let h=a.doc.lineAt(c);if(h.from==o)continue;o=h.from;let u=tm(a,h.from);if(u==null)continue;let d=/^\s*/.exec(h.text)[0],f=Na(a,u);d!=f&&l.push({from:h.from,to:h.from+d.length,insert:f})}return l.length?[r,{changes:l,sequential:!0}]:r})}const SL=xe.define(),kL=new Oe;function I$(r){let e=r.firstChild,t=r.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?r.to:t.from}:null}function CL(r,e,t){let i=Lt(r);if(i.length<t)return null;let s=i.resolveStack(t,1),n=null;for(let a=s;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(kL);if(l&&(o.to<i.length-50||i.length==r.doc.length||!EL(o))){let c=l(o,r);c&&c.from<=t&&c.from>=e&&c.to>t&&(n=c)}}return n}function EL(r){let e=r.lastChild;return e&&e.to==r.to&&e.type.isError}function sv(r,e,t){for(let i of r.facet(SL)){let s=i(r,e,t);if(s)return s}return CL(r,e,t)}function Sw(r,e){let t=e.mapPos(r.from,1),i=e.mapPos(r.to,-1);return t>=i?void 0:{from:t,to:i}}const kw=Pe.define({map:Sw}),im=Pe.define({map:Sw}),Zc=Et.define({create(){return Ne.none},update(r,e){r=r.map(e.changes);for(let t of e.effects)if(t.is(kw)&&!AL(r,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(Cw),s=i?Ne.replace({widget:new ML(i(e.state,t.value))}):nv;r=r.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(im)&&(r=r.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;r.between(i,i,(s,n)=>{s<i&&n>i&&(t=!0)}),t&&(r=r.update({filterFrom:i,filterTo:i,filter:(s,n)=>n<=i||s>=i}))}return r},provide:r=>be.decorations.from(r),toJSON(r,e){let t=[];return r.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<r.length;){let i=r[t++],s=r[t++];if(typeof i!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(nv.range(i,s))}return Ne.set(e,!0)}});function Df(r,e,t){var i;let s=null;return(i=r.field(Zc,!1))===null||i===void 0||i.between(e,t,(n,a)=>{(!s||s.from>n)&&(s={from:n,to:a})}),s}function AL(r,e,t){let i=!1;return r.between(e,e,(s,n)=>{s==e&&n==t&&(i=!0)}),i}const TL={placeholderDOM:null,preparePlaceholder:null,placeholderText:"â¦"},Cw=xe.define({combine(r){return Rn(r,TL)}});function RL(r){return[Zc,LL]}function Ew(r,e){let{state:t}=r,i=t.facet(Cw),s=a=>{let o=r.lineBlockAt(r.posAtDOM(a.target)),l=Df(r.state,o.from,o.to);l&&r.dispatch({effects:im.of(l)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(r,s,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="
26cm-foldPlaceholder",n.onclick=s,n}const nv=Ne.replace({widget:new class extends Mn{toDOM(r){return Ew(r,null)}}});class ML extends Mn{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Ew(e,this.value)}}const DL={openText:"â",closedText:"âº",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class zu extends qi{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 PL(r={}){let e=Object.assign(Object.assign({},DL),r),t=new zu(e,!0),i=new zu(e,!1),s=Ct.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(Ts)!=a.state.facet(Ts)||a.startState.field(Zc,!1)!=a.state.field(Zc,!1)||Lt(a.startState)!=Lt(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new mn;for(let l of a.viewportLineBlocks){let c=Df(a.state,l.from,l.to)?i:sv(a.state,l.from,l.to)?t:null;c&&o.add(l.from,l.from,c)}return o.finish()}}),{domEventHandlers:n}=e;return[s,TP({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(s))===null||o===void 0?void 0:o.markers)||Ue.empty},initialSpacer(){return new zu(e,!1)},domEventHandlers:Object.assign(Object.assign({},n),{click:(a,o,l)=>{if(n.click&&n.click(a,o,l))return!0;let c=Df(a.state,o.from,o.to);if(c)return a.dispatch({effects:im.of(c)}),!0;let h=sv(a.state,o.from,o.to);return h?(a.dispatch({effects:kw.of(h)}),!0):!1}})}),RL()]}const LL=be.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 zh{constructor(e,t){this.specs=e;let i;function s(o){let l=ks.newName();return(i||(i=Object.create(null)))["."+l]=o,l}const n=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,a=t.scope;this.scope=a instanceof Hr?o=>o.prop(Gn)==a.data:a?o=>o==a:void 0,this.style=xw(e.map(o=>({tag:o.tag,class:o.class||s(Object.assign({},o,{tag:null}))})),{all:n}).style,this.module=i?new ks(i):null,this.themeType=t.themeType}static define(e,t){return new zh(e,t||{})}}const Pf=xe.define(),NL=xe.define({combine(r){return r.length?[r[0]]:null}});function Wu(r){let e=r.facet(Pf);return e.length?e:r.facet(NL)}function OL(r,e){let t=[jL],i;return r instanceof zh&&(r.module&&t.push(be.styleModule.of(r.module)),i=r.themeType),i?t.push(Pf.computeN([be.darkTheme],s=>s.facet(be.darkTheme)==(i=="dark")?[r]:[])):t.push(Pf.of(r)),t}class IL{constructor(e){this.markCache=Object.create(null),this.tree=Lt(e.state),this.decorations=this.buildDeco(e,Wu(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Lt(e.state),i=Wu(e.state),s=i!=Wu(e.startState),{viewport:n}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<n.to&&!s&&t.type==this.tree.type&&a>=n.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=n.to)}buildDeco(e,t){if(!t||!this.tree.length)return Ne.none;let i=new mn;for(let{from:s,to:n}of e.visibleRanges)oL(this.tree,t,(a,o,l)=>{i.add(a,o,this.markCache[l]||(this.markCache[l]=Ne.mark({class:l})))},s,n);return i.finish()}}const jL=Ds.high(Ct.fromClass(IL,{decorations:r=>r.decorations})),BL=be.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Aw=1e4,Tw="()[]{}",Rw=xe.define({combine(r){return Rn(r,{afterCursor:!0,brackets:Tw,maxScanDistance:Aw,renderMatch:HL})}}),FL=Ne.mark({class:"cm-matchingBracket"}),$L=Ne.mark({class:"cm-nonmatchingBracket"});function HL(r){let e=[],t=r.matched?FL:$L;return e.push(t.range(r.start.from,r.start.to)),r.end&&e.push(t.range(r.end.from,r.end.to)),e}const zL=Et.define({create(){return Ne.none},update(r,e){if(!e.docChanged&&!e.selection)return r;let t=[],i=e.state.facet(Rw);for(let s of e.state.selection.ranges){if(!s.empty)continue;let n=mi(e.state,s.head,-1,i)||s.head>
vendor: 10,315 bytes, line 26
260&&mi(e.state,s.head-1,1,i)||i.afterCursor&&(mi(e.state,s.head,1,i)||s.head<e.state.doc.length&&mi(e.state,s.head+1,-1,i));n&&(t=t.concat(i.renderMatch(n,e.state)))}return Ne.set(t,!0)},provide:r=>be.decorations.from(r)}),WL=[zL,BL];function UL(r={}){return[Rw.of(r),WL]}const VL=new Oe;function Lf(r,e,t){let i=r.prop(e<0?Oe.openedBy:Oe.closedBy);if(i)return i;if(r.name.length==1){let s=t.indexOf(r.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function Nf(r){let e=r.type.prop(VL);return e?e(r.node):r}function mi(r,e,t,i={}){let s=i.maxScanDistance||Aw,n=i.brackets||Tw,a=Lt(r),o=a.resolveInner(e,t);for(let l=o;l;l=l.parent){let c=Lf(l.type,t,n);if(c&&l.from<l.to){let h=Nf(l);if(h&&(t>0?e>=h.from&&e<h.to:e>h.from&&e<=h.to))return KL(r,e,t,l,h,c,n)}}return qL(r,e,t,a,o.type,s,n)}function KL(r,e,t,i,s,n,a){let o=i.parent,l={from:s.from,to:s.to},c=0,h=o?.cursor();if(h&&(t<0?h.childBefore(i.from):h.childAfter(i.to)))do if(t<0?h.to<=i.from:h.from>=i.to){if(c==0&&n.indexOf(h.type.name)>-1&&h.from<h.to){let u=Nf(h);return{start:l,end:u?{from:u.from,to:u.to}:void 0,matched:!0}}else if(Lf(h.type,t,a))c++;else if(Lf(h.type,-t,a)){if(c==0){let u=Nf(h);return{start:l,end:u&&u.from<u.to?{from:u.from,to:u.to}:void 0,matched:!1}}c--}}while(t<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}function qL(r,e,t,i,s,n,a){let o=t<0?r.sliceDoc(e-1,e):r.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},h=r.doc.iterRange(e,t>0?r.doc.length:0),u=0;for(let d=0;!h.next().done&&d<=n;){let f=h.value;t<0&&(d+=f.length);let _=e+d*t;for(let b=t>0?0:f.length-1,p=t>0?f.length:-1;b!=p;b+=t){let g=a.indexOf(f[b]);if(!(g<0||i.resolveInner(_+b,1).type!=s))if(g%2==0==t>0)u++;else{if(u==1)return{start:c,end:{from:_+b,to:_+b+1},matched:g>>1==l>>1};u--}}t>0&&(d+=f.length)}return h.done?{start:c,matched:!1}:null}const GL=Object.create(null),ov=[nr.none],av=[],lv=Object.create(null),XL=Object.create(null);for(let[r,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"]])XL[r]=YL(GL,e);function Uu(r,e){av.indexOf(r)>-1||(av.push(r),console.warn(e))}function YL(r,e){let t=[];for(let o of e.split(" ")){let l=[];for(let c of o.split(".")){let h=r[c]||te[c];h?typeof h=="function"?l.length?l=l.map(h):Uu(c,`Modifier ${c} used at start of tag`):l.length?Uu(c,`Tag ${c} used as modifier`):l=Array.isArray(h)?h:[h]:Uu(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(o=>o.id),n=lv[s];if(n)return n.id;let a=lv[s]=nr.define({id:ov.length,name:i,props:[sL({[i]:t})]});return ov.push(a),a.id}it.RTL,it.LTR;class Mw{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Lt(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),s=t.text.slice(i-t.from,this.pos-t.from),n=s.search(Dw(e,!1));return n<0?null:{from:i+n,to:this.pos,text:s.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 cv(r){let e=Object.keys(r).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function ZL(r){let e=Object.create(null),t=Object.create(null);for(let{label:s}of r){e[s[0]]=!0;for(let n=1;n<s.length;n++)t[s[n]]=!0}let i=cv(e)+cv(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function JL(r){let e=r.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:ZL(e);return s=>{let n=s.matchBefore(i);return n||s.explicit?{from:n?n.from:s.pos,options:e,validFor:t}:null}}function j$(r,e){return t=>{for(let i=Lt(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(r.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class hv{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function ln(r){return r.selection.main.from}function Dw(r,e){var t;let{source:i}=r,s=e&&i[0]!="^",n=i[i.length-1]!="$";return!s&&!n?r:new RegExp(`${s?"^":""}(?:${i})${n?"$":""}`,(t=r.flags)!==null&&t!==void 0?t:r.ignoreCase?"i":"")}const sm=Yi.define();function QL(r,e,t,i){let{main:s}=r.selection,n=t-s.from,a=i-s.from;return Object.assign(Object.assign({},r.changeByRange(o=>{if(o!=s&&t!=i&&r.sliceDoc(o.from+n,o.from+a)!=r.sliceDoc(t,i))return{range:o};let l=r.toText(e);return{changes:{from:o.from+n,to:i==s.from?o.to:o.from+a,insert:l},range:oe.cursor(o.from+n+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const uv=new WeakMap;function e5(r){if(!Array.isArray(r))return r;let e=uv.get(r);return e||uv.set(r,e=JL(r)),e}const Jc=Pe.define(),Oa=Pe.define();class t5{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=$r(e,t),s=Ii(i);this.chars.push(i);let n=e.slice(t,t+s),a=n.toUpperCase();this.folded.push($r(a==n?n.toLowerCase():a,0)),t+=s}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:s,precise:n,byWord:a}=this;if(t.length==1){let v=$r(e,0),x=Ii(v),w=x==e.length?0:-100;if(v!=t[0])if(v==i[0])w+=-200;else return null;return this.ret(w,[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 v=0,x=Math.min(e.length,200);v<x&&c<l;){let w=$r(e,v);(w==t[c]||w==i[c])&&(s[c++]=v),v+=Ii(w)}if(c<l)return null}let h=0,u=0,d=!1,f=0,_=-1,b=-1,p=/[a-z]/.test(e),g=!0;for(let v=0,x=Math.min(e.length,200),w=0;v<x&&u<l;){let S=$r(e,v);o<0&&(h<l&&S==t[h]&&(n[h++]=v),f<l&&(S==t[f]||S==i[f]?(f==0&&(_=v),b=v+1,f++):f=0));let k,C=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(k=Bp(S))!=k.toLowerCase()?1:k!=k.toUpperCase()?2:0;(!v||C==1&&p||w==0&&C!=0)&&(t[u]==S||i[u]==S&&(d=!0)?a[u++]=v:a.length&&(g=!1)),w=C,v+=Ii(S)}return u==l&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==l&&_==0?this.ret(-200-e.length+(b==e.length?0:-100),[0,b]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==l?this.ret(-900-e.length,[_,b]):u==l?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],n=0;for(let a of t){let o=a+(this.astral?Ii($r(i,a)):1);n&&s[n-1]==a?s[n-1]=o:(s[n++]=a,s[n++]=o)}return this.ret(e-i.length,s)}}class r5{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 St=xe.define({combine(r){return Rn(r,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:i5,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(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=>dv(e(i),t(i)),optionClass:(e,t)=>i=>dv(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function dv(r,e){return r?e?r+" "+e:r:e}function i5(r,e,t,i,s,n){let a=r.textDirection==it.RTL,o=a,l=!1,c="top",h,u,d=e.left-s.left,f=s.right-e.right,_=i.right-i.left,b=i.bottom-i.top;if(o&&d<Math.min(_,f)?o=!1:!o&&f<Math.min(_,d)&&(o=!0),_<=(o?d:f))h=Math.max(s.top,Math.min(t.top,s.bottom-b))-e.top,u=Math.min(400,o?d:f);else{l=!0,u=Math.min(400,(a?e.right:s.right-e.left)-30);let v=s.bottom-e.bottom;v>=b||v>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let p=(e.bottom-e.top)/n.offsetHeight,g=(e.right-e.left)/n.offsetWidth;return{style:`${c}: ${h/p}px; max-width: ${u/g}px`,class:"cm-completionInfo-"+(l?a?"left-narrow":"right-narrow":o?"left":"right")}}function s5(r){let e=r.addToOptions.slice();return r.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(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,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 h=n[c++],u=n[c++];h>l&&a.appendChild(document.createTextNode(o.slice(l,h)));let d=a.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(o.slice(h,u))),d.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 Vu(r,e,t){if(r<=t)return{from:0,to:r};if(e<0&&(e=0),e<=r>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((r-e)/t);return{from:r-(i+1)*t,to:r-i*t}}class n5{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 s=e.state.field(t),{options:n,selected:a}=s.open,o=e.state.facet(St);this.optionContent=s5(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Vu(n.length,a,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="
26cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let h=l.target,u;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(u=/-(\d+)$/.exec(h.id))&&+u[1]<c.length){this.applyCompletion(e,c[+u[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(St).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Oa.of(null)})}),this.showOptions(n,s.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),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:n,selected:a,disabled:o}=i.open;(!s.open||s.open.options!=n)&&(this.range=Vu(n.length,a,e.state.facet(St).maxRenderedOptions),this.showOptions(n,i.id)),this.updateSel(),o!=((t=s.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;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Vu(t.options.length,t.selected,this.view.state.facet(St).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();
vendor: 43,704 bytes, line 26
26let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let n=typeof s=="string"?document.createTextNode(s):s(i);if(!n)return;"then"in n?n.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,i)}).catch(a=>mr(this.view.state,a,"completion info")):this.addInfoPane(n,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:n}=e;i.appendChild(s),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&a5(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(),s=e.getBoundingClientRect(),n=this.space;if(!n){let a=this.dom.ownerDocument.defaultView||window;n={left:0,top:0,right:a.innerWidth,bottom:a.innerHeight}}return s.top>Math.min(n.bottom,t.bottom)-10||s.bottom<Math.max(n.top,t.top)+10?null:this.view.state.facet(St).positionInfo(this.view,t,s,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 s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions"));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 d=typeof c=="string"?c:c.name;if(d!=n&&(a>i.from||i.from==0))if(n=d,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let f=s.appendChild(document.createElement("completion-section"));f.textContent=d}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+a,h.setAttribute("role","option");let u=this.optionClass(o);u&&(h.className=u);for(let d of this.optionContent){let f=d(o,this.view.state,this.view,l);f&&h.appendChild(f)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function o5(r,e){return t=>new n5(t,r,e)}function a5(r,e){let t=r.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/r.offsetHeight;i.top<t.top?r.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(r.scrollTop+=(i.bottom-t.bottom)/s)}function fv(r){return(r.boost||0)*100+(r.apply?10:0)+(r.info?5:0)+(r.type?1:0)}function l5(r,e){let t=[],i=null,s=c=>{t.push(c);let{section:h}=c.completion;if(h){i||(i=[]);let u=typeof h=="string"?h:h.name;i.some(d=>d.name==u)||i.push(typeof h=="string"?{name:u}:h)}},n=e.facet(St);for(let c of r)if(c.hasResult()){let h=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)s(new hv(u,c.source,h?h(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,f=n.filterStrict?new r5(u):new t5(u);for(let _ of c.result.options)if(d=f.match(_.label)){let b=_.displayLabel?h?h(_,d.matched):[]:d.matched;s(new hv(_,c.source,b,d.score+(_.boost||0)))}}}if(i){let c=Object.create(null),h=0,u=(d,f)=>{var _,b;return((_=d.rank)!==null&&_!==void 0?_:1e9)-((b=f.rank)!==null&&b!==void 0?b:1e9)||(d.name<f.name?-1:1)};for(let d of i.sort(u))h-=1e5,c[d.name]=h;for(let d of t){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.name])}}let a=[],o=null,l=n.compareCompletions;for(let c of t.sort((h,u)=>u.score-h.score||l(h.completion,u.completion))){let h=c.completion;!o||o.label!=h.label||o.detail!=h.detail||o.type!=null&&h.type!=null&&o.type!=h.type||o.apply!=h.apply||o.boost!=h.boost?a.push(c):fv(c.completion)>fv(o)&&(a[a.length-1]=c),o=c.completion}return a}class Xn{constructor(e,t,i,s,n,a){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=n,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Xn(this.options,pv(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,n,a){if(s&&!a&&e.some(c=>c.isPending))return s.setDisabled();let o=l5(e,t);if(!o.length)return s&&e.some(c=>c.isPending)?s.setDisabled():null;let l=t.facet(St).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let c=s.options[s.selected].completion;for(let h=0;h<o.length;h++)if(o[h].completion==c){l=h;break}}return new Xn(o,pv(i,l),{pos:e.reduce((c,h)=>h.hasResult()?Math.min(c,h.from):c,1e8),create:p5,above:n.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Xn(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Xn(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Qc{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Qc(d5,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(St),n=(i.override||t.languageDataAt("autocomplete",ln(t)).map(e5)).map(l=>(this.active.find(h=>h.source==l)||new Rr(l,this.active.some(h=>h.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(nm));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||n.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!c5(n,this.active)||o?a=Xn.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 Rr(l.source,0):l));for(let l of e.effects)l.is(Lw)&&(a=a&&a.setSelected(l.value,this.id));return n==this.active&&a==this.open?this:new Qc(n,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?h5:u5}}function c5(r,e){if(r==e)return!0;for(let t=0,i=0;;){for(;t<r.length&&!r[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let s=t==r.length,n=i==e.length;if(s||n)return s==n;if(r[t++].result!=e[i++].result)return!1}}const h5={"aria-autocomplete":"list"},u5={};function pv(r,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":r};return e>-1&&(t["aria-activedescendant"]=r+"-"+e),t}const d5=[];function Pw(r,e){if(r.isUserEvent("input.complete")){let i=r.annotation(sm);if(i&&e.activateOnCompletion(i))return 12}let t=r.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:r.isUserEvent("delete.backward")?2:r.selection?8:r.docChanged?16:0}class Rr{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=Pw(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new Rr(s.source,0)),i&4&&s.state==0&&(s=new Rr(this.source,1)),s=s.updateFor(e,i);for(let n of e.effects)if(n.is(Jc))s=new Rr(s.source,1,n.value);else if(n.is(Oa))s=new Rr(s.source,0);else if(n.is(nm))for(let a of n.value)a.source==s.source&&(s=a);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(ln(e.state))}}class to extends Rr{constructor(e,t,i,s,n,a){super(e,3,t),this.limit=i,this.result=s,this.from=n,this.to=a}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let n=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),o=ln(e.state);if(o>a||!s||t&2&&(ln(e.startState)==this.from||o<this.limit))return new Rr(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return f5(s.validFor,e.state,n,a)?new to(this.source,this.explicit,l,s,n,a):s.update&&(s=s.update(s,n,a,new Mw(e.state,o,!1)))?new to(this.source,this.explicit,l,s,s.from,(i=s.to)!==null&&i!==void 0?i:ln(e.state)):new Rr(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new to(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Rr(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function f5(r,e,t,i){if(!r)return!1;let s=e.sliceDoc(t,i);return typeof r=="function"?r(s,t,i,e):Dw(r,!0).test(s)}const nm=Pe.define({map(r,e){return r.map(t=>t.map(e))}}),Lw=Pe.define(),rr=Et.define({create(){return Qc.start()},update(r,e){return r.update(e)},provide:r=>[Zp.from(r,e=>e.tooltip),be.contentAttributes.from(r,e=>e.attrs)]});function om(r,e){const t=e.completion.apply||e.completion.label;let i=r.state.field(rr).active.find(s=>s.source==e.source);return i instanceof to?(typeof t=="string"?r.dispatch(Object.assign(Object.assign({},QL(r.state,t,i.from,i.to)),{annotations:sm.of(e.completion)})):t(r,e.completion,i.from,i.to),!0):!1}const p5=o5(rr,om);function Kl(r,e="option"){return t=>{let i=t.state.field(rr,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(St).interactionDelay)return!1;let s=1,n;e=="page"&&(n=hw(t,i.open.tooltip))&&(s=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+s*(r?1:-1):r?0:a-1;return o<0?o=e=="page"?0:a-1:o>=a&&(o=e=="page"?a-1:0),t.dispatch({effects:Lw.of(o)}),!0}}const Nw=r=>{let e=r.state.field(rr,!1);return r.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<r.state.facet(St).interactionDelay?!1:om(r,e.open.options[e.open.selected])},mv=r=>r.state.field(rr,!1)?(r.dispatch({effects:Jc.of(!0)}),!0):!1,m5=r=>{let e=r.state.field(rr,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(r.dispatch({effects:Oa.of(null)}),!0)};class g5{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const v5=50,b5=1e3,x5=Ct.fromClass(class{constructor(r){this.view=r,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of r.state.field(rr).active)e.isPending&&this.startQuery(e)}update(r){let e=r.state.field(rr),t=r.state.facet(St);if(!r.selectionSet&&!r.docChanged&&r.startState.field(rr)==e)return;let i=r.transactions.some(n=>{let a=Pw(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&&r.docChanged||a.updates.length+r.transactions.length>v5&&Date.now()-a.time>b5){for(let o of a.context.abortListeners)try{o()}catch(l){mr(this.view.state,l)}a.context.abortListeners=null,this.running.splice(n--,1)}else a.updates.push(...r.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),r.transactions.some(n=>n.effects.some(a=>a.is(Jc)))&&(this.pendingStart=!0);let s=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(),s):-1,this.composing!=0)for(let n of r.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:r}=this.view,e=r.field(rr);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(St).updateSyncTime))}startQuery(r){let{state:e}=this.view,t=ln(e),i=new Mw(e,t,r.explicit,this.view),s=new g5(r,i);this.running.push(s),Promise.resolve(r.source(i)).then(n=>{s.context.aborted||(s.done=n||null,this.scheduleAccept())},n=>{this.view.dispatch({effects:Oa.of(null)}),mr(this.view.state,n)})}scheduleAccept(){this.running.every(r=>r.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(St).updateSyncTime))}accept(){var r;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(St),i=this.view.state.field(rr);for(let s=0;s<this.running.length;s++){let n=this.running[s];if(n.done===void 0)continue;if(this.running.splice(s--,1),n.done){let o=ln(n.updates.length?n.updates[0].startState:this.view.state),l=Math.min(o,n.done.from+(n.active.explicit?0:1)),c=new to(n.active.source,n.active.explicit,l,n.done,n.done.from,(r=n.done.to)!==null&&r!==void 0?r:o);for(let h of n.updates)c=c.update(h,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 Rr(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:nm.of(e)})}},{eventHandlers:{blur(r){let e=this.view.state.field(rr,!1);if(e&&e.tooltip&&this.view.state.facet(St).closeOnBlur){let t=e.open&&hw(this.view,e.open.tooltip);(!t||!t.dom.contains(r.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Oa.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Jc.of(!1)}),20),this.composing=0}}}),_5=typeof navigator=="object"&&/Win/.test(navigator.platform),y5=Ds.highest(be.domEventHandlers({keydown(r,e){let t=e.state.field(rr,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||r.key.length>1||r.ctrlKey&&!(_5&&r.altKey)||r.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(a=>a.source==i.source),n=i.completion.commitCharacters||s.result.commitCharacters;return n&&n.indexOf(r.key)>-1&&om(e,i),!1}})),Ow=be.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"},".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 w5{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class am{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Ft.TrackDel),i=e.mapPos(this.to,1,Ft.TrackDel);return t==null||i==null?null:new am(this.field,t,i)}}class lm{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],n=e.doc.lineAt(t),a=/^\s*/.exec(n.text)[0];for(let l of this.lines){if(i.length){let c=a,h=/^\t*/.exec(l)[0].length;for(let u=0;u<h;u++)c+=e.facet(ko);s.push(t+c.length-h),l=c+l.slice(h)}i.push(l),t+=l.length+1}let o=this.fieldPositions.map(l=>new am(l.field,s[l.line]+l.from,s[l.line]+l.to));return{text:i,ranges:o}}static parse(e){let t=[],i=[],s=[],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,h=l.replace(/\\[{}]/g,u=>u[1]);for(let u=0;u<t.length;u++)(o!=null?t[u].seq==o:h&&t[u].name==h)&&(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:h}),c=u;for(let d of s)d.field>=c&&d.field++}s.push(new w5(c,i.length,n.index,n.index+h.length)),a=a.slice(0,n.index)+l+a.slice(n.index+n[0].length)}a=a.replace(/\\([{}])/g,(o,l,c)=>{for(let h of s)h.line==i.length&&h.from>c&&(h.from--,h.to--);return l}),i.push(a)}return new lm(i,s)}}let S5=Ne.widget({widget:new class extends Mn{toDOM(){let r=document.createElement("span");return r.className="cm-snippetFieldPosition",r}ignoreEvent(){return!1}}}),k5=Ne.mark({class:"cm-snippetField"});class Co{constructor(e,t){this.ranges=e,this.active=t,this.deco=Ne.set(e.map(i=>(i.from==i.to?S5:k5).range(i.from,i.to)))}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}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 il=Pe.define({map(r,e){return r&&r.map(e)}}),C5=Pe.define(),Ia=Et.define({create(){return null},update(r,e){for(let t of e.effects){if(t.is(il))return t.value;if(t.is(C5)&&r)return new Co(r.ranges,t.value)}return r&&e.docChanged&&(r=r.map(e.changes)),r&&e.selection&&!r.selectionInsideField(e.selection)&&(r=null),r},provide:r=>be.decorations.from(r,e=>e?e.deco:Ne.none)});function cm(r,e){return oe.create(r.filter(t=>t.field==e).map(t=>oe.range(t.from,t.to)))}function E5(r){let e=lm.parse(r);return(t,i,s,n)=>{let{text:a,ranges:o}=e.instantiate(t.state,s),{main:l}=t.state.selection,c={changes:{from:s,to:n==l.from?l.to:n,insert:Ge.of(a)},scrollIntoView:!0,annotations:i?[sm.of(i),gt.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=cm(o,0)),o.some(h=>h.field>0)){let h=new Co(o,0),u=c.effects=[il.of(h)];t.state.field(Ia,!1)===void 0&&u.push(Pe.appendConfig.of([Ia,D5,P5,Ow]))}t.dispatch(t.state.update(c))}}function Iw(r){return({state:e,dispatch:t})=>{let i=e.field(Ia,!1);if(!i||r<0&&i.active==0)return!1;let s=i.active+r,n=r>0&&!i.ranges.some(a=>a.field==s+r);return t(e.update({selection:cm(i.ranges,s),effects:il.of(n?null:new Co(i.ranges,s)),scrollIntoView:!0})),!0}}const A5=({state:r,dispatch:e})=>r.field(Ia,!1)?(e(r.update({effects:il.of(null)})),!0):!1,T5=Iw(1),R5=Iw(-1),M5=[{key:"Tab",run:T5,shift:R5},{key:"Escape",run:A5}],gv=xe.define({combine(r){return r.length?r[0]:M5}}),D5=Ds.highest($h.compute([gv],r=>r.facet(gv)));function B$(r,e){return Object.assign(Object.assign({},e),{apply:E5(r)})}const P5=be.domEventHandlers({mousedown(r,e){let t=e.state.field(Ia,!1),i;if(!t||(i=e.posAtCoords({x:r.clientX,y:r.clientY}))==null)return!1;let s=t.ranges.find(n=>n.from<=i&&n.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:cm(t.ranges,s.field),effects:il.of(t.ranges.some(n=>n.field>s.field)?new Co(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),eh={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Js=Pe.define({map(r,e){let t=e.mapPos(r,-1,Ft.TrackAfter);return t??void 0}}),hm=new class extends pn{};hm.startSide=1;hm.endSide=-1;const jw=Et.define({create(){return Ue.empty},update(r,e){if(r=r.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);r=r.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Js)&&(r=r.update({add:[hm.range(t.value,t.value+1)]}));return r}});function L5(){return[j5,jw]}const Ku="()[]{}<>";function N5(r){for(let e=0;e<Ku.length;e+=2)if(Ku.charCodeAt(e)==r)return Ku.charAt(e+1);return Bp(r<128?r:r+1)}function O5(r,e){return r.languageDataAt("closeBrackets",e)[0]||eh}const I5=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),j5=be.inputHandler.of((r,e,t,i)=>{if((I5?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let s=r.state.selection.main;if(i.length>2||i.length==2&&Ii($r(i,0))==1||e!=s.from||t!=s.to)return!1;let n=B5(r.state,i);return n?(r.dispatch(n),!0):!1});function B5(r,e){let t=O5(r,r.selection.main.head),i=t.brackets||eh.brackets;for(let s of i){let n=N5($r(s,0));if(e==s)return n==s?H5(r,s,i.indexOf(s+s+s)>-1,t):F5(r,s,n,t.before||eh.before);if(e==n&&Bw(r,r.selection.main.from))return $5(r,s,n)}return null}function Bw(r,e){let t=!1;return r.field(jw).between(0,r.doc.length,i=>{i==e&&(t=!0)}),t}function um(r,e){let t=r.sliceString(e,e+2);return t.slice(0,Ii($r(t,0)))}function F5(r,e,t,i){let s=null,n=r.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:Js.of(a.to+e.length),range:oe.range(a.anchor+e.length,a.head+e.length)};let o=um(r.doc,a.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:e+t,from:a.head},effects:Js.of(a.head+e.length),range:oe.cursor(a.head+e.length)}:{range:s=a}});return s?null:r.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function $5(r,e,t){let i=null,s=r.changeByRange(n=>n.empty&&um(r.doc,n.head)==t?{changes:{from:n.head,to:n.head+t.length,insert:t},range:oe.cursor(n.head+t.length)}:i={range:n});return i?null:r.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function H5(r,e,t,i){let s=i.stringPrefixes||eh.stringPrefixes,n=null,a=r.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:e,from:o.to}],effects:Js.of(o.to+e.length),range:oe.range(o.anchor+e.length,o.head+e.length)};let l=o.head,c=um(r.doc,l),h;if(c==e){if(vv(r,l))return{changes:{insert:e+e,from:l},effects:Js.of(l+e.length),range:oe.cursor(l+e.length)};if(Bw(r,l)){let d=t&&r.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+d.length,insert:d},range:oe.cursor(l+d.length)}}}else{if(t&&r.sliceDoc(l-2*e.length,l)==e+e&&(h=bv(r,l-2*e.length,s))>-1&&vv(r,h))return{changes:{insert:e+e+e+e,from:l},effects:Js.of(l+e.length),range:oe.cursor(l+e.length)};if(r.charCategorizer(l)(c)!=vt.Word&&bv(r,l,s)>-1&&!z5(r,l,e,s))return{changes:{insert:e+e,from:l},effects:Js.of(l+e.length),range:oe.cursor(l+e.length)}}return{range:n=o}});return n?null:r.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function vv(r,e){let t=Lt(r).resolveInner(e+1);return t.parent&&t.from==e}function z5(r,e,t,i){let s=Lt(r).resolveInner(e,-1),n=i.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=r.sliceDoc(s.from,Math.min(s.to,s.from+t.length+n)),l=o.indexOf(t);if(!l||l>-1&&i.indexOf(o.slice(0,l))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+l;){if(r.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function bv(r,e,t){let i=r.charCategorizer(e);if(i(r.sliceDoc(e-1,e))!=vt.Word)return e;for(let s of t){let n=e-s.length;if(r.sliceDoc(n,e)==s&&i(r.sliceDoc(n-1,n))!=vt.Word)return n}return-1}function W5(r={}){return[y5,rr,St.of(r),x5,V5,Ow]}const U5=[{key:"Ctrl-Space",run:mv},{mac:"Alt-`",run:mv},{key:"Escape",run:m5},{key:"ArrowDown",run:Kl(!0)},{key:"ArrowUp",run:Kl(!1)},{key:"PageDown",run:Kl(!0,"page")},{key:"PageUp",run:Kl(!1,"page")},{key:"Enter",run:Nw}],V5=Ds.highest($h.computeN([St],r=>r.facet(St).defaultKeymap?[U5]:[])),K5=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),i=fm(r.state,t.from);return i.line?q5(r):i.block?X5(r):!1};function dm(r,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=r(e,t);return s?(i(t.update(s)),!0):!1}}const q5=dm(J5,0),G5=dm(Fw,0),X5=dm((r,e)=>Fw(r,e,Z5(e)),0);function fm(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const Ko=50;function Y5(r,{open:e,close:t},i,s){let n=r.sliceDoc(i-Ko,i),a=r.sliceDoc(s,s+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:s+l,margin:l&&1}};let h,u;s-i<=2*Ko?h=u=r.sliceDoc(i,s):(h=r.sliceDoc(i,i+Ko),u=r.sliceDoc(s-Ko,s));let d=/^\s*/.exec(h)[0].length,f=/\s*$/.exec(u)[0].length,_=u.length-f-t.length;return h.slice(d,d+e.length)==e&&u.slice(_,_+t.length)==t?{open:{pos:i+d+e.length,margin:/\s/.test(h.charAt(d+e.length))?1:0},close:{pos:s-f-t.length,margin:/\s/.test(u.charAt(_-1))?1:0}}:null}function Z5(r){let e=[];for(let t of r.selection.ranges){let i=r.doc.lineAt(t.from),s=t.to<=i.to?i:r.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:r.doc.lineAt(t.to-1));let n=e.length-1;n>=0&&e[n].to>i.from?e[n].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function Fw(r,e,t=e.selection.ranges){let i=t.map(n=>fm(e,n.from).block);if(!i.every(n=>n))return null;let s=t.map((n,a)=>Y5(e,i[a],n.from,n.to));if(r!=2&&!s.every(n=>n))return{changes:e.changes(t.map((n,a)=>s[a]?[]:[{from:n.from,insert:i[a].open+" "},{from:n.to,insert:" "+i[a].close}]))};if(r!=1&&s.some(n=>n)){let n=[];for(let a=0,o;a<s.length;a++)if(o=s[a]){let l=i[a],{open:c,close:h}=o;n.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+l.close.length})}return{changes:n}}return null}function J5(r,e,t=e.selection.ranges){let i=[],s=-1;for(let{from:n,to:a}of t){let o=i.length,l=1e9,c=fm(e,n).line;if(c){for(let h=n;h<=a;){let u=e.doc.lineAt(h);if(u.from>s&&(n==a||a>u.from)){s=u.from;let d=/^\s*/.exec(u.text)[0].length,f=d==u.length,_=u.text.slice(d,d+c.length)==c?d:-1;d<u.text.length&&d<l&&(l=d),i.push({line:u,comment:_,token:c,indent:d,empty:f,single:!1})}h=u.to+1}if(l<1e9)for(let h=o;h<i.length;h++)i[h].indent<i[h].line.text.length&&(i[h].indent=l);i.length==o+1&&(i[o].single=!0)}}if(r!=2&&i.some(n=>n.comment<0&&(!n.empty||n.single))){let n=[];for(let{line:o,token:l,indent:c,empty:h,single:u}of i)(u||!h)&&n.push({from:o.from+c,insert:l+" "});let a=e.changes(n);return{changes:a,selection:e.selection.map(a,1)}}else if(r!=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,h=c+l.length;a.text[h-a.from]==" "&&h++,n.push({from:c,to:h})}return{changes:n}}return null}const Of=Yi.define(),Q5=Yi.define(),eN=xe.define(),$w=xe.define({combine(r){return Rn(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),Hw=Et.define({create(){return gi.empty},update(r,e){let t=e.state.facet($w),i=e.annotation(Of);if(i){let l=ir.fromTransaction(e,i.selection),c=i.side,h=c==0?r.undone:r.done;return l?h=th(h,h.length,t.minDepth,l):h=Uw(h,e.startState.selection),new gi(c==0?i.rest:h,c==0?h:i.rest)}let s=e.annotation(Q5);if((s=="full"||s=="before")&&(r=r.isolate()),e.annotation(gt.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let n=ir.fromTransaction(e),a=e.annotation(gt.time),o=e.annotation(gt.userEvent);return n?r=r.addChanges(n,a,o,t,e):e.selection&&(r=r.addSelection(e.startState.selection,a,o,t.newGroupDelay)),(s=="full"||s=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new gi(r.done.map(ir.fromJSON),r.undone.map(ir.fromJSON))}});function tN(r={}){return[Hw,$w.of(r),be.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?zw:e.inputType=="historyRedo"?If:null;return i?(e.preventDefault(),i(t)):!1}})]}function Wh(r,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(Hw,!1);if(!s)return!1;let n=s.pop(r,t,e);return n?(i(n),!0):!1}}const zw=Wh(0,!1),If=Wh(1,!1),rN=Wh(0,!0),iN=Wh(1,!0);class ir{constructor(e,t,i,s,n){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=n}setSelAfter(e){return new ir(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(s=>s.toJSON())}}static fromJSON(e){return new ir(e.changes&&bt.fromJSON(e.changes),[],e.mapped&&bi.fromJSON(e.mapped),e.startSelection&&oe.fromJSON(e.startSelection),e.selectionsAfter.map(oe.fromJSON))}static fromTransaction(e,t){let i=Mr;for(let s of e.startState.facet(eN)){let n=s(e);n.length&&(i=i.concat(n))}return!i.length&&e.changes.empty?null:new ir(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Mr)}static selection(e){return new ir(void 0,Mr,void 0,void 0,e)}}function th(r,e,t,i){let s=e+1>t+20?e-t-1:0,n=r.slice(s,e);return n.push(i),n}function sN(r,e){let t=[],i=!1;return r.iterChangedRanges((s,n)=>t.push(s,n)),e.iterChangedRanges((s,n,a,o)=>{for(let l=0;l<t.length;){let c=t[l++],h=t[l++];o>=c&&a<=h&&(i=!0)}}),i}function nN(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Ww(r,e){return r.length?e.length?r.concat(e):r:e}const Mr=[],oN=200;function Uw(r,e){if(r.length){let t=r[r.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-oN));return i.length&&i[i.length-1].eq(e)?r:(i.push(e),th(r,r.length-1,1e9,t.setSelAfter(i)))}else return[ir.selection([e])]}function aN(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function qu(r,e){if(!r.length)return r;let t=r.length,i=Mr;for(;t;){let s=lN(r[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let n=r.slice(0,t);return n[t-1]=s,n}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[ir.selection(i)]:Mr}function lN(r,e,t){let i=Ww(r.selectionsAfter.length?r.selectionsAfter.map(o=>o.map(e)):Mr,t);if(!r.changes)return ir.selection(i);let s=r.changes.map(e),n=e.mapDesc(r.changes,!0),a=r.mapped?r.mapped.composeDesc(n):n;return new ir(s,Pe.mapEffects(r.effects,e),a,r.startSelection.map(n),i)}const cN=/^(input\.type|delete)($|\.)/;class gi{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new gi(this.done,this.undone):this}addChanges(e,t,i,s,n){let a=this.done,o=a[a.length-1];return o&&o.changes&&!o.changes.empty&&e.changes&&(!i||cN.test(i))&&(!o.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(n,sN(o.changes,e.changes))||i=="input.type.compose")?a=th(a,a.length-1,s.minDepth,new ir(e.changes.compose(o.changes),Ww(Pe.mapEffects(e.effects,o.changes),o.effects),o.mapped,o.startSelection,Mr)):a=th(a,a.length,s.minDepth,e),new gi(a,Mr,t,i)}addSelection(e,t,i,s){let n=this.done.length?this.done[this.done.length-1].selectionsAfter:Mr;return n.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&nN(n[n.length-1],e)?this:new gi(Uw(this.done,e),this.undone,t,i)}addMapping(e){return new gi(qu(this.done,e),qu(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let n=s[s.length-1],a=n.selectionsAfter[0]||t.selection;if(i&&n.selectionsAfter.length)return t.update({selection:n.selectionsAfter[n.selectionsAfter.length-1],annotations:Of.of({side:e,rest:aN(s),selection:a}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(n.changes){let o=s.length==1?Mr:s.slice(0,s.length-1);return n.mapped&&(o=qu(o,n.mapped)),t.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:Of.of({side:e,rest:o,selection:a}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}gi.empty=new gi(Mr,Mr);const hN=[{key:"Mod-z",run:zw,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:If,preventDefault:!0},{linux:"Ctrl-Shift-z",run:If,preventDefault:!0},{key:"Mod-u",run:rN,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:iN,preventDefault:!0}];function Eo(r,e){return oe.create(r.ranges.map(e),r.mainIndex)}function wi(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Xr({state:r,dispatch:e},t){let i=Eo(r.selection,t);return i.eq(r.selection,!0)?!1:(e(wi(r,i)),!0)}function Uh(r,e){return oe.cursor(e?r.to:r.from)}function Vw(r,e){return Xr(r,t=>t.empty?r.moveByChar(t,e):Uh(t,e))}function Wt(r){return r.textDirectionAt(r.state.selection.main.head)==it.LTR}const Kw=r=>Vw(r,!Wt(r)),qw=r=>Vw(r,Wt(r));function Gw(r,e){return Xr(r,t=>t.empty?r.moveByGroup(t,e):Uh(t,e))}const uN=r=>Gw(r,!Wt(r)),dN=r=>Gw(r,Wt(r));function fN(r,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function Vh(r,e,t){let i=Lt(r).resolveInner(e.head),s=t?Oe.closedBy:Oe.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;fN(r,c,s)?i=c:l=t?c.to:c.from}let n=i.type.prop(s),a,o;return n&&(a=t?mi(r,i.from,1):mi(r,i.to,-1))&&a.matched?o=t?a.end.to:a.end.from:o=t?i.to:i.from,oe.cursor(o,t?-1:1)}const pN=r=>Xr(r,e=>Vh(r.state,e,!Wt(r))),mN=r=>Xr(r,e=>Vh(r.state,e,Wt(r)));function Xw(r,e){return Xr(r,t=>{if(!t.empty)return Uh(t,e);let i=r.moveVertically(t,e);return i.head!=t.head?i:r.moveToLineBoundary(t,e)})}const Yw=r=>Xw(r,!1),Zw=r=>Xw(r,!0);function Jw(r){let e=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,t=0,i=0,s;if(e){for(let n of r.state.facet(be.scrollMargins)){let a=n(r);a?.top&&(t=Math.max(a?.top,t)),a?.bottom&&(i=Math.max(a?.bottom,i))}s=r.scrollDOM.clientHeight-t-i}else s=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(r.defaultLineHeight,s-5)}}function Qw(r,e){let t=Jw(r),{state:i}=r,s=Eo(i.selection,a=>a.empty?r.moveVertically(a,e,t.height):Uh(a,e));if(s.eq(i.selection))return!1;let n;if(t.selfScroll){let a=r.coordsAtPos(i.selection.main.head),o=r.scrollDOM.getBoundingClientRect(),l=o.top+t.marginTop,c=o.bottom-t.marginBottom;a&&a.top>l&&a.bottom<c&&(n=be.scrollIntoView(s.main.head,{y:"start",yMargin:a.top-l}))}return r.dispatch(wi(i,s),{effects:n}),!0}const xv=r=>Qw(r,!1),jf=r=>Qw(r,!0);function Ps(r,e,t){let i=r.lineBlockAt(e.head),s=r.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=r.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let n=/^\s*/.exec(r.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&e.head!=i.from+n&&(s=oe.cursor(i.from+n))}return s}const gN=r=>Xr(r,e=>Ps(r,e,!0)),vN=r=>Xr(r,e=>Ps(r,e,!1)),bN=r=>Xr(r,e=>Ps(r,e,!Wt(r))),xN=r=>Xr(r,e=>Ps(r,e,Wt(r))),_N=r=>Xr(r,e=>oe.cursor(r.lineBlockAt(e.head).from,1)),yN=r=>Xr(r,e=>oe.cursor(r.lineBlockAt(e.head).to,-1));function wN(r,e,t){let i=!1,s=Eo(r.selection,n=>{let a=mi(r,n.head,-1)||mi(r,n.head,1)||n.head>0&&mi(r,n.head-1,1)||n.head<r.doc.length&&mi(r,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 oe.cursor(o)});return i?(e(wi(r,s)),!0):!1}const SN=({state:r,dispatch:e})=>wN(r,e);function jr(r,e){let t=Eo(r.state.selection,i=>{let s=e(i);return oe.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(wi(r.state,t)),!0)}function e1(r,e){return jr(r,t=>r.moveByChar(t,e))}const t1=r=>e1(r,!Wt(r)),r1=r=>e1(r,Wt(r));function i1(r,e){return jr(r,t=>r.moveByGroup(t,e))}const kN=r=>i1(r,!Wt(r)),CN=r=>i1(r,Wt(r)),EN=r=>jr(r,e=>Vh(r.state,e,!Wt(r))),AN=r=>jr(r,e=>Vh(r.state,e,Wt(r)));function s1(r,e){return jr(r,t=>r.moveVertically(t,e))}const n1=r=>s1(r,!1),o1=r=>s1(r,!0);function a1(r,e){return jr(r,t=>r.moveVertically(t,e,Jw(r).height))}const _v=r=>a1(r,!1),yv=r=>a1(r,!0),TN=r=>jr(r,e=>Ps(r,e,!0)),RN=r=>jr(r,e=>Ps(r,e,!1)),MN=r=>jr(r,e=>Ps(r,e,!Wt(r))),DN=r=>jr(r,e=>Ps(r,e,Wt(r))),PN=r=>jr(r,e=>oe.cursor(r.lineBlockAt(e.head).from)),LN=r=>jr(r,e=>oe.cursor(r.lineBlockAt(e.head).to)),wv=({state:r,dispatch:e})=>(e(wi(r,{anchor:0})),!0),Sv=({state:r,dispatch:e})=>(e(wi(r,{anchor:r.doc.length})),!0),kv=({state:r,dispatch:e})=>(e(wi(r,{anchor:r.selection.main.anchor,head:0})),!0),Cv=({state:r,dispatch:e})=>(e(wi(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),NN=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),ON=({state:r,dispatch:e})=>{let t=Kh(r).map(({from:i,to:s})=>oe.range(i,Math.min(s+1,r.doc.length)));return e(r.update({selection:oe.create(t),userEvent:"select"})),!0},IN=({state:r,dispatch:e})=>{let t=Eo(r.selection,i=>{let s=Lt(r),n=s.resolveStack(i.from,1);if(i.empty){let a=s.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 oe.range(o.to,o.from)}return i});return t.eq(r.selection)?!1:(e(wi(r,t)),!0)},jN=({state:r,dispatch:e})=>{let t=r.selection,i=null;return t.ranges.length>1?i=oe.create([t.main]):t.main.empty||(i=oe.create([oe.cursor(t.main.head)])),i?(e(wi(r,i)),!0):!1};function sl(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:i}=r,s=i.changeByRange(n=>{let{from:a,to:o}=n;if(a==o){let l=e(n);l<a?(t="delete.backward",l=ql(r,l,!1)):l>a&&(t="delete.forward",l=ql(r,l,!0)),a=Math.min(a,l),o=Math.max(o,l)}else a=ql(r,a,!1),o=ql(r,o,!0);return a==o?{range:n}:{changes:{from:a,to:o},range:oe.cursor(a,a<n.head?-1:1)}});return s.changes.empty?!1:(r.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?be.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function ql(r,e,t){if(r instanceof be)for(let i of r.state.facet(be.atomicRanges).map(s=>s(r)))i.between(e,e,(s,n)=>{s<e&&n>e&&(e=t?n:s)});return e}const l1=(r,e,t)=>sl(r,i=>{let s=i.from,{state:n}=r,a=n.doc.lineAt(s),o,l;if(t&&!e&&s>a.from&&s<a.from+200&&!/[^ \t]/.test(o=a.text.slice(0,s-a.from))){if(o[o.length-1]==" ")return s-1;let c=Oh(o,n.tabSize),h=c%Yc(n)||Yc(n);for(let u=0;u<h&&o[o.length-1-u]==" ";u++)s--;l=s}else l=Dt(a.text,s-a.from,e,e)+a.from,l==s&&a.number!=(e?n.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(a.text.slice(l-a.from,s-a.from))&&(l=Dt(a.text,l-a.from,!1,!1)+a.from);return l}),Bf=r=>l1(r,!1,!0),c1=r=>l1(r,!0,!1),h1=(r,e)=>sl(r,t=>{let i=t.head,{state:s}=r,n=s.doc.lineAt(i),a=s.charCategorizer(i);for(let o=null;;){if(i==(e?n.to:n.from)){i==t.head&&n.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let l=Dt(n.text,i-n.from,e)+n.from,c=n.text.slice(Math.min(i,l)-n.from,Math.max(i,l)-n.from),h=a(c);if(o!=null&&h!=o)break;(c!=" "||i!=t.head)&&(o=h),i=l}return i}),u1=r=>h1(r,!1),BN=r=>h1(r,!0),FN=r=>sl(r,e=>{let t=r.lineBlockAt(e.head).to;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),$N=r=>sl(r,e=>{let t=r.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),HN=r=>sl(r,e=>{let t=r.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),zN=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Ge.of(["",""])},range:oe.cursor(i.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},WN=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(i=>{if(!i.empty||i.from==0||i.from==r.doc.length)return{range:i};let s=i.from,n=r.doc.lineAt(s),a=s==n.from?s-1:Dt(n.text,s-n.from,!1)+n.from,o=s==n.to?s+1:Dt(n.text,s-n.from,!0)+n.from;return{changes:{from:a,to:o,insert:r.doc.slice(s,o).append(r.doc.slice(a,s))},range:oe.cursor(o)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kh(r){let e=[],t=-1;for(let i of r.selection.ranges){let s=r.doc.lineAt(i.from),n=r.doc.lineAt(i.to);if(!i.empty&&i.to==n.from&&(n=r.doc.lineAt(i.to-1)),t>=s.number){let a=e[e.length-1];a.to=n.to,a.ranges.push(i)}else e.push({from:s.from,to:n.to,ranges:[i]});t=n.number+1}return e}function d1(r,e,t){if(r.readOnly)return!1;let i=[],s=[];for(let n of Kh(r)){if(t?n.to==r.doc.length:n.from==0)continue;let a=r.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+r.lineBreak});for(let l of n.ranges)s.push(oe.range(Math.min(r.doc.length,l.anchor+o),Math.min(r.doc.length,l.head+o)))}else{i.push({from:a.from,to:n.from},{from:n.to,insert:r.lineBreak+a.text});for(let l of n.ranges)s.push(oe.range(l.anchor-o,l.head-o))}}return i.length?(e(r.update({changes:i,scrollIntoView:!0,selection:oe.create(s,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}const UN=({state:r,dispatch:e})=>d1(r,e,!1),VN=({state:r,dispatch:e})=>d1(r,e,!0);function f1(r,e,t){if(r.readOnly)return!1;let i=[];for(let s of Kh(r))t?i.push({from:s.from,insert:r.doc.slice(s.from,s.to)+r.lineBreak}):i.push({from:s.to,insert:r.lineBreak+r.doc.slice(s.from,s.to)});return e(r.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const KN=({state:r,dispatch:e})=>f1(r,e,!1),qN=({state:r,dispatch:e})=>f1(r,e,!0),GN=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(Kh(e).map(({from:s,to:n})=>(s>0?s--:n<e.doc.length&&n++,{from:s,to:n}))),i=Eo(e.selection,s=>{let n;if(r.lineWrapping){let a=r.lineBlockAt(s.head),o=r.coordsAtPos(s.head,s.assoc||1);o&&(n=a.bottom+r.documentTop-o.bottom+r.defaultLineHeight/2)}return r.moveVertically(s,!0,n)}).map(t);return r.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function XN(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Lt(r).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),n;return i&&s&&i.to<=e&&s.from>=e&&(n=i.type.prop(Oe.closedBy))&&n.indexOf(s.name)>-1&&r.doc.lineAt(i.to).from==r.doc.lineAt(s.from).from&&!/\S/.test(r.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const Ev=p1(!1),YN=p1(!0);function p1(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:n,to:a}=s,o=e.doc.lineAt(n),l=!r&&n==a&&XN(e,n);r&&(n=a=(a<=o.to?o:e.doc.lineAt(a)).to);let c=new Hh(e,{simulateBreak:n,simulateDoubleBreak:!!l}),h=tm(c,n);for(h==null&&(h=Oh(/^\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=["",Na(e,h)];return l&&u.push(Na(e,c.lineIndent(o.from,-1))),{changes:{from:n,to:a,insert:Ge.of(u)},range:oe.cursor(n+1+u[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function pm(r,e){let t=-1;return r.changeByRange(i=>{let s=[];for(let a=i.from;a<=i.to;){let o=r.doc.lineAt(a);o.number>t&&(i.empty||i.to>o.from)&&(e(o,s,i),t=o.number),a=o.to+1}let n=r.changes(s);return{changes:s,range:oe.range(n.mapPos(i.anchor,1),n.mapPos(i.head,1))}})}const ZN=({state:r,dispatch:e})=>
26{if(r.readOnly)return!1;let t=Object.create(null),i=new Hh(r,{overrideIndentation:n=>{let a=t[n];return a??-1}}),s=pm(r,(n,a,o)=>{let l=tm(i,n.from);if(l==null)return;/\S/.test(n.text)||(l=0);let c=/^\s*/.exec(n.text)[0],h=Na(r,l);(c!=h||o.from<n.from+c.length)&&(t[n.from]=l,a.push({from:n.from,to:n.from+c.length,insert:h}))});return s.changes.empty||e(r.update(s,{userEvent:"indent"})),!0},JN=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(pm(r,(t,i)=>{i.push({from:t.from,insert:r.facet(ko)})}),{userEvent:"input.indent"})),!0),m1=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(pm(r,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let n=Oh(s,r.tabSize),a=0,o=Na(r,Math.max(0,n-Yc(r)));for(;a<s.length&&a<o.length&&s.charCodeAt(a)==o.charCodeAt(a);)a++;i.push({from:t.from+a,to:t.from+s.length,insert:o.slice(a)})}),{userEvent:"delete.dedent"})),!0),QN=r=>(r.setTabFocusMode(),!0),eO=[{key:"Ctrl-b",run:Kw,shift:t1,preventDefault:!0},{key:"Ctrl-f",run:qw,shift:r1},{key:"Ctrl-p",run:Yw,shift:n1},{key:"Ctrl-n",run:Zw,shift:o1},{key:"Ctrl-a",run:_N,shift:PN},{key:"Ctrl-e",run:yN,shift:LN},{key:"Ctrl-d",run:c1},{key:"Ctrl-h",run:Bf},{key:"Ctrl-k",run:FN},{key:"Ctrl-Alt-h",run:u1},{key:"Ctrl-o",run:zN},{key:"Ctrl-t",run:WN},{key:"Ctrl-v",run:jf}],tO=[{key:"ArrowLeft",run:Kw,shift:t1,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:uN,shift:kN,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:bN,shift:MN,preventDefault:!0},{key:"ArrowRight",run:qw,shift:r1,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:dN,shift:CN,preventDefault:!0},{mac:"Cmd-ArrowRight",run:xN,shift:DN,preventDefault:!0},{key:"ArrowUp",run:Yw,shift:n1,preventDefault:!0},{mac:"Cmd-ArrowUp",run:wv,shift:kv},{mac:"Ctrl-ArrowUp",run:xv,shift:_v},{key:"ArrowDown",run:Zw,shift:o1,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Sv,shift:Cv},{mac:"Ctrl-ArrowDown",run:jf,shift:yv},{key:"PageUp",run:xv,shift:_v},{key:"PageDown",run:jf,shift:yv},{key:"Home",run:vN,shift:RN,preventDefault:!0},{key:"Mod-Home",run:wv,shift:kv},{key:"End",run:gN,shift:TN,preventDefault:!0},{key:"Mod-End",run:Sv,shift:Cv},{key:"Enter",run:Ev,shift:Ev},{key:"Mod-a",run:NN},{key:"Backspace",run:Bf,shift:Bf},{key:"Delete",run:c1},{key:"Mod-Backspace",mac:"Alt-Backspace",run:u1},{key:"Mod-Delete",mac:"Alt-Delete",run:BN},{mac:"Mod-Backspace",run:$N},{mac:"Mod-Delete",run:HN}].concat(eO.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),rO=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:pN,shift:EN},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:mN,shift:AN},{key:"Alt-ArrowUp",run:UN},{key:"Shift-Alt-ArrowUp",run:KN},{key:"Alt-ArrowDown",run:VN},{key:"Shift-Alt-ArrowDown",run:qN},{key:"Escape",run:jN},{key:"Mod-Enter",run:YN},{key:"Alt-l",mac:"Ctrl-l",run:ON},{key:"Mod-i",run:IN,preventDefault:!0},{key:"Mod-[",run:m1},{key:"Mod-]",run:JN},{key:"Mod-Alt-\\",run:ZN},{key:"Shift-Mod-k",run:GN},{key:"Shift-Mod-\\",run:SN},{key:"Mod-/",run:K5},{key:"Alt-A",run:G5},{key:"Ctrl-m",mac:"Shift-Alt-m",run:QN}].concat(tO);function It(){var r=arguments[0];typeof r=="string"&&(r=document.createElement(r));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 s=t[i];typeof s=="string"?r.setAttribute(i,s):s!=null&&(r[i]=s)}e++}for(;e<arguments.length;e++)g1(r,arguments[e]);return r}function g1(r,e){if(typeof e=="string")r.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)r.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)g1(r,e[t]);else throw new RangeError("Unsupported child node: "+e)}const Av=typeof String.prototype.normalize=="function"?r=>r.normalize("NFKD"):r=>r;class ja{constructor(e,t,i=0,s=e.length,n,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=n?o=>n(Av(o)):Av,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 $r(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=Bp(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Ii(e);let s=this.normalize(t);if(s.length)for(let n=0,a=i;;n++){let o=s.charCodeAt(n),l=this.match(o,a,this.bufferPos+this.bufferStart);if(n==s.length-1){if(l)return this.value=l,this;break}a==i&&n<t.length&&t.charCodeAt(n)==o&&a++}}}match(e,t,i){let s=null;for(let n=0;n<this.matches.length;n+=2){let a=this.matches[n],o=!1;
26this.query.charCodeAt(a)==e&&(a==this.query.length-1?s={from:this.matches[n+1],to:i}:(this.matches[n]++,o=!0)),o||(this.matches.splice(n,2),n-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(ja.prototype[Symbol.iterator]=function(){return this});const v1={from:-1,to:-1,match:/.*/.exec("")},mm="gm"+(/x/.unicode==null?"":"u");class b1{constructor(e,t,i,s=0,n=e.length){if(this.text=e,this.to=n,this.curLine="",this.done=!1,this.value=v1,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new x1(e,t,i,s,n);this.re=new RegExp(t,mm+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let a=e.lineAt(s);this.curLineStart=a.from,this.matchPos=rh(e,s),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,s=i+t[0].length;if(this.matchPos=rh(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,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 Gu=new WeakMap;class ro{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=Gu.get(e);if(!s||s.from>=i||s.to<=t){let o=new ro(t,e.sliceString(t,i));return Gu.set(e,o),o}if(s.from==t&&s.to==i)return s;let{text:n,from:a}=s;return a>t&&(n=e.sliceString(t,a)+n,a=t),s.to<i&&(n+=e.sliceString(s.to,i)),Gu.set(e,new ro(a,n)),new ro(t,n.slice(t-a,i-a))}}class x1{constructor(e,t,i,s,n){this.text=e,this.to=n,this.done=!1,this.value=v1,this.matchPos=rh(e,s),this.re=new RegExp(t,mm+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=ro.get(e,s,this.chunkEnd(s+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,s=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,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=rh(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ro.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(b1.prototype[Symbol.iterator]=x1.prototype[Symbol.iterator]=function(){return this});function iO(r){try{return new RegExp(r,mm),!0}catch{return!1}}function rh(r,e){if(e>=r.length)return e;let t=r.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function Ff(r){let e=String(r.state.doc.lineAt(r.state.selection.main.head).number),t=It("input",{class:"cm-textfield",name:"line",value:e}),i=It("form",{class:"cm-gotoLine",onkeydown:n=>{n.keyCode==27?(n.preventDefault(),r.dispatch({effects:ih.of(!1)}),r.focus()):n.keyCode==13&&(n.preventDefault(),s())},onsubmit:n=>{n.preventDefault(),s()}},It("label",r.state.phrase("Go to line"),": ",t)," ",It("button",{class:"cm-button",type:"submit"},r.state.phrase("go")));function s(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:a}=r,o=a.doc.lineAt(a.selection.main.head),[,l,c,h,u]=n,d=h?+h.slice(1):0,f=c?+c:o.number;if(c&&u){let p=f/100;l&&(p=p*(l=="-"?-1:1)+o.number/a.doc.lines),f=Math.round(a.doc.lines*p)}else c&&l&&(f=f*(l=="-"?-1:1)+o.number);let _=a.doc.line(Math.max(1,Math.min(a.doc.lines,f))),b=oe.cursor(_.from+Math.max(0,Math.min(d,_.length)));r.dispatch({effects:[ih.of(!1),be.scrollIntoView(b.from,{y:"center"})],selection:b}),r.focus()}return{dom:i}}const ih=Pe.define(),Tv=Et.define({create(){return!0},update(r,e){for(let t of e.effects)t.is(ih)&&(r=t.value);return r},provide:r=>Vc.from(r,e=>e?Ff:null)}),sO=r=>{let e=Uc(r,Ff);if(!e){let t=[ih.of(!0)];r.state.field(Tv,!1)==null&&t.push(Pe.appendConfig.of([Tv,nO])),r.dispatch({effects:t}),e=Uc(r,Ff)}return e&&e.dom.querySelector("input").select(),!0},nO=be.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),oO=({state:r,dispatch:e})=>{let{selection:t}=r,i=oe.create(t.ranges.map(s=>r.wordAt(s.head)||oe.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(r.update({selection:i})),!0)};function aO(r,e){let{main:t,ranges:i}=r.selection,s=r.wordAt(t.head),n=s&&s.from==t.from&&s.to==t.to;for(let a=!1,o=new ja(r.doc,e,i[i.length-1].to);;)if(o.next(),o.done){if(a)return null;o=new ja(r.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=r.wordAt(o.value.from);if(!l||l.from!=o.value.from||l.to!=o.value.to)continue}return o.value}}const lO=({state:r,dispatch:e})=>{let{ranges:t}=r.selection;if(t.some(n=>n.from===n.to))return oO({state:r,dispatch:e});let i=r.sliceDoc(t[0].from,t[0].to);if(r.selection.ranges.some(n=>r.sliceDoc(n.from,n.to)!=i))return!1;let s=aO(r,i);return s?(e(r.update({selection:r.selection.addRange(oe.range(s.from,s.to),!1),effects:be.scrollIntoView(s.to)})),!0):!1},Ao=xe.define({combine(r){return Rn(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new _O(e),scrollToMatch:e=>be.scrollIntoView(e)})}});class _1{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||iO(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` 27`: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}create(){return this.regexp?new dO(this):new hO(this)}getCursor(e,t=0,i){let s=e.doc?e:He.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?Un(this,s,t,i):Wn(this,s,t,i)}}class y1{constructor(e){this.spec=e}}function Wn(r,e,t,i){return new ja(e.doc,r.unquoted,t,i,r.caseSensitive?void 0:s=>s.toLowerCase(),r.wholeWord?cO(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function cO(r,e){return(t,i,s,n)=>((n>t||n+s.length<i)&&(n=Math.max(0,t-2),s=r.sliceString(n,Math.min(r.length,i+2))),(e(sh(s,t-n))!=vt.Word||e(nh(s,t-n))!=vt.Word)&&(e(nh(s,i-n))!=vt.Word||e(sh(s,i-n))!=vt.Word))}class hO extends y1{constructor(e){super(e)}nextMatch(e,t,i){let s=Wn(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);s=Wn(this.spec,e,0,n).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let n=Math.max(t,s-1e4-this.spec.unquoted.length),a=Wn(this.spec,e,n,s),o=null;for(;!a.nextOverlapping().done;)o=a.value;if(o)return o;if(n==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=i)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Wn(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let n=Wn(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;)s(n.value.from,n.value.to)}}function Un(r,e,t,i){return new b1(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:r.wholeWord?uO(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function sh(r,e){return r.slice(Dt(r,e,!1),e)}function nh(r,e){return r.slice(e,Dt(r,e))}function uO(r){return(e,t,i)=>!i[0].length||(r(sh(i.input,i.index))!=vt.Word||r(nh(i.input,i.index))!=vt.Word)&&(r(nh(i.input,i.index+i[0].length))!=vt.Word||r(sh(i.input,i.index+i[0].length))!=vt.Word)}class dO extends y1{nextMatch(e,t,i){let s=Un(this.spec,e,i,e.doc.length).next();return s.done&&(s=Un(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let n=Math.max(t,i-s*1e4),a=Un(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)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t)}matchAll(e,t){let i=Un(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let n=Un(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!n.next().done;)s(n.value.from,n.value.to)}}const Ba=Pe.define(),gm=Pe.define(),ys=Et.define({create(r){return new Xu($f(r).create(),null)},update(r,e){for(let t of e.effects)t.is(Ba)?r=new Xu(t.value.create(),r.panel):t.is(gm)&&(r=new Xu(r.query,t.value?vm:null));return r},provide:r=>Vc.from(r,e=>e.panel)});class Xu{constructor(e,t){this.query=e,this.panel=t}}const fO=Ne.mark({class:"cm-searchMatch"}),pO=Ne.mark({class:"cm-searchMatch cm-searchMatch-selected"}),mO=Ct.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(ys))}update(r){let e=r.state.field(ys);(e!=r.startState.field(ys)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:r,panel:e}){if(!e||!r.spec.valid)return Ne.none;let{view:t}=this,i=new mn;for(let s=0,n=t.visibleRanges,a=n.length;s<a;s++){let{from:o,to:l}=n[s];for(;s<a-1&&l>n[s+1].from-2*250;)l=n[++s].to;r.highlight(t.state,o,l,(c,h)=>{let u=t.state.selection.ranges.some(d=>d.from==c&&d.to==h);i.add(c,h,u?pO:fO)})}return i.finish()}},{decorations:r=>r.decorations});function nl(r){return e=>{let t=e.state.field(ys,!1);return t&&t.query.spec.valid?r(e,t):k1(e)}}const oh=nl((r,{query:e})=>{let{to:t}=r.state.selection.main,i=e.nextMatch(r.state,t,t);if(!i)return!1;let s=oe.single(i.from,i.to),n=r.state.facet(Ao);return r.dispatch({selection:s,effects:[bm(r,i),n.scrollToMatch(s.main,r)],userEvent:"select.search"}),S1(r),!0}),ah=nl((r,{query:e})=>{let{state:t}=r,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let n=oe.single(s.from,s.to),a=r.state.facet(Ao);return r.dispatch({selection:n,effects:[bm(r,s),a.scrollToMatch(n.main,r)],userEvent:"select.search"}),S1(r),!0}),gO=nl((r,{query:e})=>{let t=e.matchAll(r.state,1e3);return!t||!t.length?!1:(r.dispatch({selection:oe.create(t.map(i=>
27oe.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),vO=({state:r,dispatch:e})=>{let t=r.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,n=[],a=0;for(let o=new ja(r.doc,r.sliceDoc(i,s));!o.next().done;){if(n.length>1e3)return!1;o.value.from==i&&(a=n.length),n.push(oe.range(o.value.from,o.value.to))}return e(r.update({selection:oe.create(n,a),userEvent:"select.search.matches"})),!0},Rv=nl((r,{query:e})=>{let{state:t}=r,{from:i,to:s}=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,h=[];if(a.from==i&&a.to==s&&(c=t.toText(e.getReplacement(a)),o.push({from:a.from,to:a.to,insert:c}),a=e.nextMatch(t,a.from,a.to),h.push(be.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),a){let u=o.length==0||o[0].from>=n.to?0:n.to-n.from-c.length;l=oe.single(a.from-u,a.to-u),h.push(bm(r,a)),h.push(t.facet(Ao).scrollToMatch(l.main,r))}return r.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),bO=nl((r,{query:e})=>{if(r.state.readOnly)return!1;let t=e.matchAll(r.state,1e9).map(s=>{let{from:n,to:a}=s;return{from:n,to:a,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=r.state.phrase("replaced $ matches",t.length)+".";return r.dispatch({changes:t,effects:be.announce.of(i),userEvent:"input.replace.all"}),!0});function vm(r){return r.state.facet(Ao).createPanel(r)}function $f(r,e){var t,i,s,n,a;let o=r.selection.main,l=o.empty||o.to>o.from+100?"":r.sliceDoc(o.from,o.to);if(e&&!l)return e;let c=r.facet(Ao);return new _1({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:(s=e?.literal)!==null&&s!==void 0?s: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 w1(r){let e=Uc(r,vm);return e&&e.dom.querySelector("[main-field]")}function S1(r){let e=w1(r);e&&e==r.root.activeElement&&e.select()}const k1=r=>{let e=r.state.field(ys,!1);if(e&&e.panel){let t=w1(r);if(t&&t!=r.root.activeElement){let i=$f(r.state,e.query.spec);i.valid&&r.dispatch({effects:Ba.of(i)}),t.focus(),t.select()}}else r.dispatch({effects:[gm.of(!0),e?Ba.of($f(r.state,e.query.spec)):Pe.appendConfig.of(wO)]});return!0},C1=r=>{let e=r.state.field(ys,!1);if(!e||!e.panel)return!1;let t=Uc(r,vm);return t&&t.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:gm.of(!1)}),!0},xO=[{key:"Mod-f",run:k1,scope:"editor search-panel"},{key:"F3",run:oh,shift:ah,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:oh,shift:ah,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:C1,scope:"editor search-panel"},{key:"Mod-Shift-l",run:vO},{key:"Mod-Alt-g",run:sO},{key:"Mod-d",run:lO,preventDefault:!0}];class _O{constructor(e){this.view=e;let t=this.query=e.state.field(ys).query.spec;this.commit=this.commit.bind(this),this.searchField=It("input",{value:t.search,placeholder:cr(e,"Find"),"aria-label":cr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=It("input",{value:t.replace,placeholder:cr(e,"Replace"),"aria-label":cr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=It("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=It("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=It("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,n,a){return It("button",{class:"cm-button",name:s,onclick:n,type:"button"},a)}this.dom=It("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>oh(e),[cr(e,"next")]),i("prev",()=>ah(e),[cr(e,"previous")]),i("select",()=>gO(e),[cr(e,"all")]),It("label",null,[this.caseField,cr(e,"match case")]),It("label",null,[this.reField,cr(e,"regexp")]),It("label",null,[this.wordField,cr(e,"by word")]),...e.state.readOnly?[]:[It("br"),this.replaceField,i("replace",()=>Rv(e),[cr(e,"replace")]),i("replaceAll",()=>bO(e),[cr(e,"replace all")])],It("button",{name:"close",onclick:()=>C1(e),"aria-label":cr(e,"close"),type:"button"},["Ã"])])}commit(){let e=new _1({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:Ba.of(e)}))}keydown(e){nP(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ah:oh)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Rv(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Ba)&&!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(Ao).top}}function cr(r,e){return r.state.phrase(e)}const Gl=30,Xl=/[\s\.,:;?!]/;function bm(r,{from:e,to:t}){let i=r.state.doc.lineAt(e),s=r.state.doc.lineAt(t).to,n=Math.max(i.from,e-Gl),a=Math.min(s,t+Gl),o=r.state.sliceDoc(n,a);if(n!=i.from){for(let l=0;l<Gl;l++)if(!Xl.test(o[l+1])&&Xl.test(o[l])){o=o.slice(l);break}}if(a!=s){for(let l=o.length-1;l>o.length-Gl;l--)if(!Xl.test(o[l-1])&&Xl.test(o[l])){o=o.slice(0,l);break}}return be.announce.of(`${r.state.phrase("current match")}. ${o} ${r.state.phrase("on line")} ${i.number}.`)}const yO=be.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"}}),wO=[ys,Ds.low(mO),yO];function SO(){return m.jsx("div",{className:"flex items-center justify-center absolute inset-0 z-10 text-sm bg-tk-elements-app-backgroundColor text-tk-elements-app-textColor",children:"File format cannot be displayed."})}var E1=r=>{var{theme:e,settings:t={},styles:i=[]}=r,s={".cm-gutters":{}},n={};t.background&&(n.backgroundColor=t.background),t.backgroundImage&&(n.backgroundImage=t.backgroundImage),t.foreground&&(n.color=t.foreground),t.fontSize&&(n.fontSize=t.fontSize),(t.background||t.foreground)&&
27(s["&"]=n),t.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:t.fontFamily}),t.gutterBackground&&(s[".cm-gutters"].backgroundColor=t.gutterBackground),t.gutterForeground&&(s[".cm-gutters"].color=t.gutterForeground),t.gutterBorder&&(s[".cm-gutters"].borderRightColor=t.gutterBorder),t.caret&&(s[".cm-content"]={caretColor:t.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:t.caret});var a={};t.gutterActiveForeground&&(a.color=t.gutterActiveForeground),t.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:t.lineHighlight},a.backgroundColor=t.lineHighlight),s[".cm-activeLineGutter"]=a,t.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:t.selection+" !important"}),t.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:t.selectionMatch});var o=be.theme(s,{dark:e==="dark"}),l=zh.define(i),c=[o,OL(l)];return c},kO={background:"#ffffff",foreground:"#383a42",caret:"#000",selection:"#add6ff",selectionMatch:"#a8ac94",lineHighlight:"#99999926",gutterBackground:"#fff",gutterForeground:"#237893",gutterActiveForeground:"#0b216f",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace'},CO=[{tag:[te.keyword,te.operatorKeyword,te.modifier,te.color,te.constant(te.name),te.standard(te.name),te.standard(te.tagName),te.special(te.brace),te.atom,te.bool,te.special(te.variableName)],color:"#0000ff"},{tag:[te.moduleKeyword,te.controlKeyword],color:"#af00db"},{tag:[te.name,te.deleted,te.character,te.macroName,te.propertyName,te.variableName,te.labelName,te.definition(te.name)],color:"#0070c1"},{tag:te.heading,fontWeight:"bold",color:"#0070c1"},{tag:[te.typeName,te.className,te.tagName,te.number,te.changed,te.annotation,te.self,te.namespace],color:"#267f99"},{tag:[te.function(te.variableName),te.function(te.propertyName)],color:"#795e26"},{tag:[te.number],color:"#098658"},{tag:[te.operator,te.punctuation,te.separator,te.url,te.escape,te.regexp],color:"#383a42"},{tag:[te.regexp],color:"#af00db"},{tag:[te.special(te.string),te.processingInstruction,te.string,te.inserted],color:"#a31515"},{tag:[te.angleBracket],color:"#383a42"},{tag:te.strong,fontWeight:"bold"},{tag:te.emphasis,fontStyle:"italic"},{tag:te.strikethrough,textDecoration:"line-through"},{tag:[te.meta,te.comment],color:"#008000"},{tag:te.link,color:"#4078f2",textDecoration:"underline"},{tag:te.invalid,color:"#e45649"}];function EO(r){var{theme:e="light",settings:t={},styles:i=[]}={};return E1({theme:e,settings:Lx({},kO,t),styles:[...CO,...i]})}var AO=EO(),TO={background:"#1e1e1e",foreground:"#9cdcfe",caret:"#c6c6c6",selection:"#6199ff2f",selectionMatch:"#72a1ff59",lineHighlight:"#ffffff0f",gutterBackground:"#1e1e1e",gutterForeground:"#838383",gutterActiveForeground:"#fff",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace'},RO=[{tag:[te.keyword,te.operatorKeyword,te.modifier,te.color,te.constant(te.name),te.standard(te.name),te.standard(te.tagName),te.special(te.brace),te.atom,te.bool,te.special(te.variableName)],color:"#569cd6"},{tag:[te.controlKeyword,te.moduleKeyword],color:"#c586c0"},{tag:[te.name,te.deleted,te.character,te.macroName,te.propertyName,te.variableName,te.labelName,te.definition(te.name)],color:"#9cdcfe"},{tag:te.heading,fontWeight:"bold",color:"#9cdcfe"},{tag:[te.typeName,te.className,te.tagName,te.number,te.changed,te.annotation,te.self,te.namespace],color:"#4ec9b0"},{tag:[te.function(te.variableName),te.function(te.propertyName)],color:"#dcdcaa"},{tag:[te.number],color:"#b5cea8"},{tag:[te.operator,te.punctuation,te.separator,te.url,te.escape,te.regexp],color:"#d4d4d4"},{tag:[te.regexp],color:"#d16969"},{tag:[te.special(te.string),te.processingInstruction,te.string,te.inserted],color:"#ce9178"},{tag:[te.angleBracket],color:"#808080"},{tag:te.strong,fontWeight:"bold"},{tag:te.emphasis,fontStyle:"italic"},{tag:te.strikethrough,textDecoration:"line-through"},{tag:[te.meta,te.comment],color:"#6a9955"},{tag:te.link,color:"#6a9955",textDecoration:"underline"}
27,{tag:te.invalid,color:"#ff0000"}];function MO(r){var{theme:e="dark",settings:t={},styles:i=[]}={};return E1({theme:e,settings:Lx({},TO,t),styles:[...RO,...i]})}var DO=MO();be.theme({},{dark:!0});const Hf=new fn;function PO(r,e={}){return[LO(e),r==="dark"?Hf.of([R1()]):Hf.of([T1()])]}function A1(r){return Hf.reconfigure(r==="dark"?R1():T1())}function LO(r){return be.theme({"&":{fontSize:r.fontSize??"12px"},"&.cm-editor":{height:"100%",background:"rgba(0, 0, 0, 0.75)",backdropFilter:"blur(24px)",color:"var(--cm-textColor)"},".cm-cursor":{borderLeft:"var(--cm-cursor-width) solid var(--cm-cursor-backgroundColor)"},".cm-scroller":{lineHeight:"1.5","&:focus-visible":{outline:"none"}},".cm-line":{padding:"0 0 0 4px"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{backgroundColor:"var(--cm-selection-backgroundColorFocused) !important",opacity:"var(--cm-selection-backgroundOpacityFocused, 0.3)"},"&:not(.cm-focused) > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{backgroundColor:"var(--cm-selection-backgroundColorBlured)",opacity:"var(--cm-selection-backgroundOpacityBlured, 0.3)"},"&.cm-focused > .cm-scroller .cm-matchingBracket":{backgroundColor:"var(--cm-matching-bracket)"},".cm-activeLine":{background:"var(--cm-activeLineBackgroundColor)"},".cm-gutters":{borderRight:0,color:"var(--cm-gutter-textColor)",background:"transparent"},".cm-gutter":{"&.cm-lineNumbers":{fontFamily:"Roboto Mono, monospace",fontSize:r.gutterFontSize??r.fontSize??"12px",minWidth:"40px",background:"transparent"},"& .cm-activeLineGutter":{color:"var(--cm-gutter-activeLineTextColor)"},"&.cm-foldGutter .cm-gutterElement > .fold-icon":{cursor:"pointer",color:"var(--cm-foldGutter-textColor)",transform:"translateY(2px)","&:hover":{color:"var(--cm-foldGutter-textColorHover)"}}},".cm-foldGutter .cm-gutterElement":{padding:"0 4px"},".cm-tooltip-autocomplete > ul > li":{minHeight:"18px"},".cm-panel.cm-search label":{marginLeft:"2px",fontSize:"12px"},".cm-panel.cm-search .cm-button":{fontSize:"12px"},".cm-panel.cm-search .cm-textfield":{fontSize:"12px"},".cm-panel.cm-search input[type=checkbox]":{position:"relative",transform:"translateY(2px)",marginRight:"4px"},".cm-panels":{borderColor:"var(--cm-panels-borderColor)"},".cm-panels-bottom":{borderTop:"1px solid var(--cm-panels-borderColor)",backgroundColor:"transparent"},".cm-panel.cm-search":{background:"var(--cm-search-backgroundColor)",color:"var(--cm-search-textColor)",padding:"8px"},".cm-search .cm-button":{background:"var(--cm-search-button-backgroundColor)",borderColor:"var(--cm-search-button-borderColor)",color:"var(--cm-search-button-textColor)",borderRadius:"4px","&:hover":{color:"var(--cm-search-button-textColorHover)"},"&:focus-visible":{outline:"none",borderColor:"var(--cm-search-button-borderColorFocused)"},"&:hover:not(:focus-visible)":{background:"var(--cm-search-button-backgroundColorHover)",borderColor:"var(--cm-search-button-borderColorHover)"},"&:hover:focus-visible":{background:"var(--cm-search-button-backgroundColorHover)",borderColor:"var(--cm-search-button-borderColorFocused)"}},".cm-panel.cm-search [name=close]":{top:"6px",right:"6px",padding:"0 6px",fontSize:"1rem",backgroundColor:"var(--cm-search-closeButton-backgroundColor)",color:"var(--cm-search-closeButton-textColor)","&:hover":{"border-radius":"6px",color:"var(--cm-search-closeButton-textColorHover)",backgroundColor:"var(--cm-search-closeButton-backgroundColorHover)"}},".cm-search input":{background:"var(--cm-search-input-backgroundColor)",borderColor:"var(--cm-search-input-borderColor)",color:"var(--cm-search-input-textColor)",outline:"none",borderRadius:"4px","&:focus-visible":{borderColor:"var(--cm-search-input-borderColorFocused)"}},".cm-tooltip":{background:"var(--cm-tooltip-backgroundColor)",border:"1px solid transparent",borderColor:"var(--cm-tooltip-borderColor)",color:"var(--cm-tooltip-textColor)"},".cm-tooltip.cm-tooltip-autocomplete ul li[aria-selected]":{background:"var(--cm-tooltip-backgroundColorSelected)",color:"var(--cm-tooltip-textColorSelected)"},".cm-searchMatch":{backgroundColor:"var(--cm-searchMatch-backgroundColor)"},".cm-tooltip.cm-readonly-tooltip":{padding:"4px",whiteSpace:"nowrap",backgroundColor:"var(--exkalibur-elements-bg-depth-2)",borderColor:"var(--exkalibur-elements-borderColorActive)","& .cm
27-tooltip-arrow:before":{borderTopColor:"var(--exkalibur-elements-borderColorActive)"},"& .cm-tooltip-arrow:after":{borderTopColor:"transparent"}}})}function T1(){return AO}function R1(){return DO}const NO={key:"Tab",run:OO,shift:m1};function OO({state:r,dispatch:e}){return r.readOnly?!1:(e(r.update(IO(r,(t,i,s)=>{s.push({from:t,to:i,insert:r.facet(ko)})}),{userEvent:"input.indent"})),!0)}function IO(r,e){return r.changeByRange(t=>{const i=[],s=r.doc.lineAt(t.from);if(t.from===t.to)e(t.from,void 0,i,s);else if(t.from<t.to&&t.to<=s.to)e(t.from,t.to,i,s);else{let a=-1;for(let o=t.from;o<=t.to;){const l=r.doc.lineAt(o);l.number>a&&(t.empty||t.to>l.from)&&(e(l.from,void 0,i,l),a=l.number),o=l.to+1}}const n=r.changes(i);return{changes:i,range:oe.range(n.mapPos(t.anchor,1),n.mapPos(t.head,1))}})}const jO=[Tt.of({name:"VUE",extensions:["vue"],async load(){return Zt(()=>import("./index-hc4XHDSJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(r=>r.vue())}}),Tt.of({name:"TS",extensions:["ts"],async load(){return Zt(()=>import("./index-DlZHNr6H.js"),__vite__mapDeps([13,2,3,4,5,6,8,9,10,11,12])).then(r=>r.javascript({typescript:!0}))}}),Tt.of({name:"JS",extensions:["js","mjs","cjs"],async load(){return Zt(()=>import("./index-DlZHNr6H.js"),__vite__mapDeps([13,2,3,4,5,6,8,9,10,11,12])).then(r=>r.javascript())}}),Tt.of({name:"TSX",extensions:["tsx"],async load(){return Zt(()=>import("./index-DlZHNr6H.js"),__vite__mapDeps([13,2,3,4,5,6,8,9,10,11,12])).then(r=>r.javascript({jsx:!0,typescript:!0}))}}),Tt.of({name:"JSX",extensions:["jsx"],async load(){return Zt(()=>import("./index-DlZHNr6H.js"),__vite__mapDeps([13,2,3,4,5,6,8,9,10,11,12])).then(r=>r.javascript({jsx:!0}))}}),Tt.of({name:"HTML",extensions:["html"],async load(){return Zt(()=>import("./index-De2MrmCP.js"),__vite__mapDeps([1,2,3,4,5,6,7,8,9,10,11,12,13])).then(r=>r.html())}}),Tt.of({name:"CSS",extensions:["css"],async load(){return Zt(()=>import("./index-CRMP0OmD.js"),__vite__mapDeps([7,2,3,4,5,6,8,9,10,11,12])).then(r=>r.css())}}),Tt.of({name:"SASS",extensions:["sass"],async load(){return Zt(()=>import("./index-BOF-_YYA.js"),__vite__mapDeps([14,2,3,4,5,6,7,8,9,10,11,12])).then(r=>r.sass({indented:!0}))}}),Tt.of({name:"SCSS",extensions:["scss"],async load(){return Zt(()=>import("./index-BOF-_YYA.js"),__vite__mapDeps([14,2,3,4,5,6,7,8,9,10,11,12])).then(r=>r.sass({indented:!1}))}}),Tt.of({name:"JSON",extensions:["json"],async load(){return Zt(()=>import("./index-Cc4AK8HP.js"),__vite__mapDeps([15,2,3,4,5,6,8,9,10,11,12])).then(r=>r.json())}}),Tt.of({name:"Markdown",extensions:["md"],async load(){return Zt(()=>import("./index-VAyR_Yvo.js"),__vite__mapDeps([16,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(r=>r.markdown())}}),Tt.of({name:"Wasm",extensions:["wat"],async load(){return Zt(()=>import("./index-BfxWlnhC.js"),__vite__mapDeps([17,2,3,4,5,6,8,9,10,11,12])).then(r=>r.wast())}}),Tt.of({name:"Python",extensions:["py"],async load(){return Zt(()=>import("./index-DA2-whxV.js"),__vite__mapDeps([18,2,3,4,5,6,8,9,10,11,12])).then(r=>r.python())}}),Tt.of({name:"C++",extensions:["cpp"],async load(){return Zt(()=>import("./index-D63OCojq.js"),__vite__mapDeps([19,2,3,4,5,6,8,9,10,11,12])).then(r=>r.cpp())}})];async function BO(r){const e=Tt.matchFilename(jO,r);if(e)return await e.load()}class FO extends Mn{constructor(e){super(),this._value=e}eq(e){return e._value===this._value}toDOM(){const e=document.createElement("span");return e.textContent="*".repeat(this._value.length),e.className="cm-masked-text",e}ignoreEvent(){return!1}}function $O(r){return Ct.fromClass(class{decorations;constructor(e){this.decorations=this.buildDecorations(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.buildDecorations(e.view))}buildDecorations(e){const t=r();if(!(t?.endsWith(".env")||t?.includes(".env.")||t?.includes("/.env")))return Ne.none;const s=[],n=e.state.doc;for(let a=1;a<=n.lines;a++){const o=n.line(a),l=o.text,c=l.match(/^([^=]+)=(.+)$/);if(c&&!l.trim().startsWith("#")){const[,h,u]=c,d=o.from+h.length+1;s.push(Ne.replace({inclusive:!0,widget:new FO(u)}).range(d,o.to))}}return Ne.set(s)}},{decorations:e=>e.decorations})}const ua=Xi("CodeMirrorEditor");let M1;const D1=Pe.define(),HO=Et.define({create:()=>[],update(r,e){if(!e.state.readOnly)return[];for(const t of e.effects)if(t.is(D1)&&t.value)return UO(e.state);return[]},provide:r=>Zp.computeN([r],e=>e.field(r))}),xm=Pe.define(),Mv=Et.define({create(){return!0},update(r,e){for(const t of e.effects)if(t.is(xm))return t.value;return r}}),P1=A.memo(({id:r,doc:e,debounceScroll:t=100,debounceChange:i=150,autoFocusOnDocumentChange:s=!1,editable:n=!0,onScroll:a,onChange:o,onSave:l,theme:c,settings:h,className:u=""})=>{wo.trace("CodeMirrorEditor");const[d]=A.useState(new fn),[f]=A.useState(new fn),_=A.useRef(null),b=A.useRef(),p=A.useRef(),g=A.useRef(),v=A.useRef(),x=A.useRef(a),w=A.useRef(o),S=A.useRef(l);return A.useEffect(()=>{x.current=a,w.current=o,S.current=l,g.current=e,M1=e,p.current=c}),A.useEffect(()=>{if(!(!b.current||!e||e.isBinary))if(typeof e.scroll?.line=="number"){const k=e.scroll.line,C=e.scroll.column??0;try{const y=b.current.state.doc.lines;if(k<y){const E=b.current.state.doc.line(k+1).from+C;b.current.dispatch({selection:{anchor:E},scrollIntoView:!0}),b.current.focus()}else ua.warn(`Invalid line number ${k+1} in ${y}-line document`)}catch(y){ua.error("Error scrolling to line:",y)}}else(typeof e.scroll?.top=="number"||typeof e.scroll?.left=="number")&&b.current.scrollDOM.scrollTo(e.scroll.left??0,e.scroll.top??0)},[e?.scroll?.line,e?.scroll?.column,e?.scroll?.top,e?.scroll?.left]),A.useEffect(()=>{const k=yh(y=>{w.current?.(y)},i),C=new be({parent:_.current,dispatchTransactions(y){const E=C.state.selection;C.update(y);const D=C.state.selection,T=D!==E&&(D===void 0||E===void 0||!D.eq(E));g.current&&(y.some(M=>M.docChanged)||T)&&(k({selection:C.state.selection,content:C.state.doc.toString()}),v.current.set(g.current.filePath,C.state))}});return b.current=C,()=>{b.current?.destroy(),b.current=void 0}},[]),A.useEffect(()=>{b.current&&b.current.dispatch({effects:[A1(c)]})},[c]),A.useEffect(()=>
27{v.current=new Map},[r]),A.useEffect(()=>{const k=v.current,C=b.current,y=p.current;if(!e){const M=Dv("",y,h,x,t,S,[d.of([]),f.of([])]);C.setState(M),zO(C);return}if(e.isBinary)return;e.filePath===""&&ua.warn("File path should not be empty");let E=k.get(e.filePath);E||(E=Dv(e.value,y,h,x,t,S,[d.of([]),f.of([$O(()=>g.current?.filePath)])]),k.set(e.filePath,E)),C.setState(E),WO(C,y,n,d,s,e);const D=xp(),{locked:T}=_p(e.filePath,D);T&&C.dispatch({effects:[xm.of(!1)]})},[e?.value,n,e?.filePath,s]),m.jsxs("div",{className:ce("relative h-full",u),children:[e?.isBinary&&m.jsx(SO,{}),m.jsx("div",{className:"h-full overflow-hidden",ref:_})]})});P1.displayName="CodeMirrorEditor";function Dv(r,e,t,i,s,n,a){return He.create({doc:r,extensions:[be.domEventHandlers({scroll:yh((o,l)=>{o.target===l.scrollDOM&&i.current?.({left:l.scrollDOM.scrollLeft,top:l.scrollDOM.scrollTop})},s),keydown:(o,l)=>l.state.readOnly?(l.dispatch({effects:[D1.of(o.key!=="Escape")]}),!0):!1}),PO(e,t),tN(),$h.of([...rO,...hN,...xO,{key:"Tab",run:Nw},{key:"Mod-s",preventDefault:!0,run:()=>(n.current?.(),!0)},NO]),ko.of(" "),W5({closeOnBlur:!1}),wP({position:"absolute",parent:document.body,tooltipSpace:o=>{const l=o.dom.getBoundingClientRect();return{top:l.top-50,left:l.left,bottom:l.bottom,right:l.right+10}}}),L5(),OP(),vP(),gP(),uP(),UL(),He.tabSize.of(t?.tabSize??2),wL(),HO,Mv,He.readOnly.from(Mv,o=>!o),BP(),bP(),PL({markerDOM:o=>{const l=document.createElement("div");return l.className=`fold-icon ${o?"i-ph-caret-down-bold":"i-ph-caret-right-bold"}`,l}}),...a]})}function zO(r){r.dispatch({selection:{anchor:0},changes:{from:0,to:r.state.doc.length,insert:""}}),r.scrollDOM.scrollTo(0,0)}function WO(r,e,t,i,s,n){if(n.value!==r.state.doc.toString()){const l=r.state.selection,c=r.scrollDOM.scrollTop,h=r.scrollDOM.scrollLeft;r.dispatch({selection:l,changes:{from:0,to:r.state.doc.length,insert:n.value}}),requestAnimationFrame(()=>{r.scrollDOM.scrollTo(h,c)})}const a=xp(),{locked:o}=_p(n.filePath,a);r.dispatch({effects:[xm.of(t&&!n.isBinary&&!o)]}),BO(n.filePath).then(l=>{l&&(r.dispatch({effects:[i.reconfigure([l]),A1(e)]}),requestAnimationFrame(()=>{const c=r.scrollDOM.scrollLeft,h=r.scrollDOM.scrollTop,u=n.scroll?.left??0,d=n.scroll?.top??0;if(typeof n.scroll?.line=="number"){const _=n.scroll.line,b=n.scroll.column??0;try{const p=r.state.doc.lines;if(_<p){const g=r.state.doc.line(_+1).from+b;r.dispatch({selection:{anchor:g},scrollIntoView:!0}),r.focus()}else ua.warn(`Invalid line number ${_+1} in ${p}-line document`)}catch(p){ua.error("Error scrolling to line:",p)}return}s&&t&&(c!==u||h!==d?r.scrollDOM.addEventListener("scroll",()=>{r.focus()},{once:!0}):r.focus(),r.scrollDOM.scrollTo(u,d))}))})}function UO(r){if(!r.readOnly)return[];const e=M1;let t="Cannot edit file while AI response is being generated";if(e?.filePath){const i=xp(),{locked:s}=_p(e.filePath,i);s&&(t="This file is locked and cannot be edited")}return r.selection.ranges.filter(i=>i.empty).map(i=>({pos:i.head,above:!0,strictSide:!0,arrow:!0,create:()=>{const s=document.createElement("div");return s.className="cm-readonly-tooltip",s.textContent=t,{dom:s}}}))}const Pv=A.memo(({className:r,disabledClassName:e,disabled:t=!1,children:i,onClick:s})=>m.jsx("button",{className:ce("flex items-center shrink-0 gap-1.5 px-1.5 rounded-md py-0.5 text-exkalibur-elements-item-contentDefault bg-transparent enabled:hover:text-exkalibur-elements-item-contentActive enabled:hover:bg-exkalibur-elements-item-backgroundActive disabled:cursor-not-allowed",{[ce("opacity-30",e)]:t},r),disabled:t,onClick:n=>{t||s?.(n)},children:i})),VO=A.memo,KO=VO(({selected:r,options:e,setSelected:t,device:i})=>{const s=!!e.middle,n=r===e.left.value,a=s&&e.middle?r===e.middle.value:!1,o=i;return m.jsxs("div",{className:"flex border border-white items-center flex-wrap shrink-0 gap-1 bg-white/10 backdrop-blur-xl text-white overflow-hidden rounded-full p-1",children:[!o&&m.jsxs(m.Fragment,{children:[m.jsx(Yl,{selected:n,setSelected:()=>t?.(e.left.value),children:e.left.text}),e.middle&&m.jsx(Yl,{selected:a,setSelected:()=>t?.(e.middle.value),children:e.middle.text}),m.jsx(Yl,{selected:!n&&!a,setSelected:()=>t?.(e.right.value),children:e.right.text})]}),o&&m.jsx(Yl,{selected:!0,setSelected:()=>t?.(e.right.value),children:e.right.text})]})}),Yl=A.memo(({selected:r,children:e,setSelected:t})=>m.jsxs("button",{onClick:t,className:ce("bg-transparent text-sm px-2.5 py-0.5 rounded-full relative",r?"text-#ff99cc":"text-exkalibur-elements-item-contentDefault hover:text-exkalibur-elements-item-contentActive"),children:[m.jsx("span",{className:"relative z-10",children:e}
27),r&&m.jsx(Ae.span,{layoutId:"pill-tab",transition:{duration:.2,ease:Ss},className:"absolute inset-0 z-0 bg-white/5 rounded-full"})]})),{createElement:go,createContext:qO,forwardRef:L1,useCallback:Jt,useContext:N1,useEffect:cn,useImperativeHandle:O1,useLayoutEffect:GO,useMemo:XO,useRef:er,useState:io}=_a,Lv=_a[`useId${Math.random()}`.slice(0,5)],YO=GO,qh=qO(null);qh.displayName="PanelGroupContext";const hn=YO,ZO=typeof Lv=="function"?Lv:()=>null;let JO=0;function _m(r=null){const e=ZO(),t=er(r||e||null);return t.current===null&&(t.current=""+JO++),r??t.current}function I1({children:r,className:e="",collapsedSize:t,collapsible:i,defaultSize:s,forwardedRef:n,id:a,maxSize:o,minSize:l,onCollapse:c,onExpand:h,onResize:u,order:d,style:f,tagName:_="div",...b}){const p=N1(qh);if(p===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:g,expandPanel:v,getPanelSize:x,getPanelStyle:w,groupId:S,isPanelCollapsed:k,reevaluatePanelConstraints:C,registerPanel:y,resizePanel:E,unregisterPanel:D}=p,T=_m(a),M=er({callbacks:{onCollapse:c,onExpand:h,onResize:u},constraints:{collapsedSize:t,collapsible:i,defaultSize:s,maxSize:o,minSize:l},id:T,idIsFromProps:a!==void 0,order:d});er({didLogMissingDefaultSizeWarning:!1}),hn(()=>{const{callbacks:O,constraints:$}=M.current,G={...$};M.current.id=T,M.current.idIsFromProps=a!==void 0,M.current.order=d,O.onCollapse=c,O.onExpand=h,O.onResize=u,$.collapsedSize=t,$.collapsible=i,$.defaultSize=s,$.maxSize=o,$.minSize=l,(G.collapsedSize!==$.collapsedSize||G.collapsible!==$.collapsible||G.maxSize!==$.maxSize||G.minSize!==$.minSize)&&C(M.current,G)}),hn(()=>{const O=M.current;return y(O),()=>{D(O)}},[d,T,y,D]),O1(n,()=>({collapse:()=>{g(M.current)},expand:O=>{v(M.current,O)},getId(){return T},getSize(){return x(M.current)},isCollapsed(){return k(M.current)},isExpanded(){return!k(M.current)},resize:O=>{E(M.current,O)}}),[g,v,x,k,T,E]);const R=w(M.current,s);return go(_,{...b,children:r,className:e,id:a,style:{...R,...f},"data-panel":"","data-panel-collapsible":i||void 0,"data-panel-group-id":S,"data-panel-id":T,"data-panel-size":parseFloat(""+R.flexGrow).toFixed(1)})}const da=L1((r,e)=>go(I1,{...r,forwardedRef:e}));I1.displayName="Panel";da.displayName="forwardRef(Panel)";let zf=null,Qs=null;function QO(r,e){if(e){const t=(e&H1)!==0,i=(e&z1)!==0,s=(e&W1)!==0,n=(e&U1)!==0;if(t)return s?"se-resize":n?"ne-resize":"e-resize";if(i)return s?"sw-resize":n?"nw-resize":"w-resize";if(s)return"s-resize";if(n)return"n-resize"}switch(r){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function e3(){Qs!==null&&(document.head.removeChild(Qs),zf=null,Qs=null)}function Yu(r,e){const t=QO(r,e);zf!==t&&(zf=t,Qs===null&&(Qs=document.createElement("style"),document.head.appendChild(Qs)),Qs.innerHTML=`*{cursor: ${t}!important;}`)}function j1(r){return r.type==="keydown"}function B1(r){return r.type.startsWith("pointer")}function F1(r){return r.type.startsWith("mouse")}function Gh(r){if(B1(r)){if(r.isPrimary)return{x:r.clientX,y:r.clientY}}else if(F1(r))return{x:r.clientX,y:r.clientY};return{x:1/0,y:1/0}}function t3(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function r3(r,e,t){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function i3(r,e){if(r===e)throw new Error("Cannot compare node with itself");const t={a:Iv(r),b:Iv(e)};let i;for(;t.a.at(-1)===t.b.at(-1);)r=t.a.pop(),e=t.b.pop(),i=r;Me(i,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Ov(Nv(t.a)),b:Ov(Nv(t.b))};if(s.a===s.b){const n=i.childNodes,a={a:t.a.at(-1),b:t.b.at(-1)};let o=n.length;for(;o--;){const l=n[o];if(l===a.a)return 1;if(l===a.b)return-1}}return Math.sign(s.a-s.b)}const s3=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function n3(r){var e;const t=getComputedStyle((e=$1(r))!==null&&e!==void 0?e:r).display;return t==="flex"||t==="inline-flex"}function o3(r){const e=getComputedStyle(r);return!!(e.position==="fixed"||e.zIndex!=="auto"&&(e.position!=="static"||n3(r))||+e.opacity<1||"transform"in e&&e.transform!=="none"||"webkitTransform"in e&&e.webkitTransform!=="none"||"mixBlendMode"in e&&e.mixBlendMode!=="normal"||"filter"in e&&e.filter!=="none"||"webkitFilter"in e&&e.webkitFilter!=="none"||"isolation"in e&&e.
27isolation==="isolate"||s3.test(e.willChange)||e.webkitOverflowScrolling==="touch")}function Nv(r){let e=r.length;for(;e--;){const t=r[e];if(Me(t,"Missing node"),o3(t))return t}return null}function Ov(r){return r&&Number(getComputedStyle(r).zIndex)||0}function Iv(r){const e=[];for(;r;)e.push(r),r=$1(r);return e}function $1(r){const{parentNode:e}=r;return e&&e instanceof ShadowRoot?e.host:e}const H1=1,z1=2,W1=4,U1=8,a3=t3()==="coarse";let Wr=[],so=!1,us=new Map,Xh=new Map;const Fa=new Set;function l3(r,e,t,i,s){var n;const{ownerDocument:a}=e,o={direction:t,element:e,hitAreaMargins:i,setResizeHandlerState:s},l=(n=us.get(a))!==null&&n!==void 0?n:0;return us.set(a,l+1),Fa.add(o),lh(),function(){var h;Xh.delete(r),Fa.delete(o);const u=(h=us.get(a))!==null&&h!==void 0?h:1;if(us.set(a,u-1),lh(),u===1&&us.delete(a),Wr.includes(o)){const d=Wr.indexOf(o);d>=0&&Wr.splice(d,1),wm(),s("up",!0,null)}}}function jv(r){const{target:e}=r,{x:t,y:i}=Gh(r);so=!0,ym({target:e,x:t,y:i}),lh(),Wr.length>0&&(ch("down",r),r.preventDefault(),r.stopPropagation())}function qo(r){const{x:e,y:t}=Gh(r);if(so&&r.buttons===0&&(so=!1,ch("up",r)),!so){const{target:i}=r;ym({target:i,x:e,y:t})}ch("move",r),wm(),Wr.length>0&&r.preventDefault()}function Bn(r){const{target:e}=r,{x:t,y:i}=Gh(r);Xh.clear(),so=!1,Wr.length>0&&r.preventDefault(),ch("up",r),ym({target:e,x:t,y:i}),wm(),lh()}function ym({target:r,x:e,y:t}){Wr.splice(0);let i=null;(r instanceof HTMLElement||r instanceof SVGElement)&&(i=r),Fa.forEach(s=>{const{element:n,hitAreaMargins:a}=s,o=n.getBoundingClientRect(),{bottom:l,left:c,right:h,top:u}=o,d=a3?a.coarse:a.fine;if(e>=c-d&&e<=h+d&&t>=u-d&&t<=l+d){if(i!==null&&document.contains(i)&&n!==i&&!n.contains(i)&&!i.contains(n)&&i3(i,n)>0){let _=i,b=!1;for(;_&&!_.contains(n);){if(r3(_.getBoundingClientRect(),o)){b=!0;break}_=_.parentElement}if(b)return}Wr.push(s)}})}function Zu(r,e){Xh.set(r,e)}function wm(){let r=!1,e=!1;Wr.forEach(i=>{const{direction:s}=i;s==="horizontal"?r=!0:e=!0});let t=0;
27Xh.forEach(i=>{t|=i}),r&&e?Yu("intersection",t):r?Yu("horizontal",t):e?Yu("vertical",t):e3()}function lh(){us.forEach((r,e)=>{const{body:t}=e;t.removeEventListener("contextmenu",Bn),t.removeEventListener("pointerdown",jv),t.removeEventListener("pointerleave",qo),t.removeEventListener("pointermove",qo)}),window.removeEventListener("pointerup",Bn),window.removeEventListener("pointercancel",Bn),Fa.size>0&&(so?(Wr.length>0&&us.forEach((r,e)=>{const{body:t}=e;r>0&&(t.addEventListener("contextmenu",Bn),t.addEventListener("pointerleave",qo),t.addEventListener("pointermove",qo))}),window.addEventListener("pointerup",Bn),window.addEventListener("pointercancel",Bn)):us.forEach((r,e)=>{const{body:t}=e;r>0&&(t.addEventListener("pointerdown",jv,{capture:!0}),t.addEventListener("pointermove",qo))}))}function ch(r,e){Fa.forEach(t=>{const{setResizeHandlerState:i}=t,s=Wr.includes(t);i(r,s,e)})}function c3(){const[r,e]=io(0);return Jt(()=>e(t=>t+1),[])}function Me(r,e){if(!r)throw console.error(e),Error(e)}const Sm=10;function xn(r,e,t=Sm){return r.toFixed(t)===e.toFixed(t)?0:r>e?1:-1}function Bi(r,e,t=Sm){return xn(r,e,t)===0}function ur(r,e,t){return xn(r,e,t)===0}function h3(r,e,t){if(r.length!==e.length)return!1;for(let i=0;i<r.length;i++){const s=r[i],n=e[i];if(!ur(s,n,t))return!1}return!0}function Yn({panelConstraints:r,panelIndex:e,size:t}){const i=r[e];Me(i!=null,`Panel constraints not found for index ${e}`);let{collapsedSize:s=0,collapsible:n,maxSize:a=100,minSize:o=0}=i;if(xn(t,o)<0)if(n){const l=(s+o)/2;xn(t,l)<0?t=s:t=o}else t=o;return t=Math.min(a,t),t=parseFloat(t.toFixed(Sm)),t}function ra({delta:r,initialLayout:e,panelConstraints:t,pivotIndices:i,prevLayout:s,trigger:n}){if(ur(r,0))return e;const a=[...e],[o,l]=i;Me(o!=null,"Invalid first pivot index"),Me(l!=null,"Invalid second pivot index");let c=0;if(n==="keyboard"){{const u=r<0?l:o,d=t[u];Me(d,`Panel constraints not found for index ${u}`);const{collapsedSize:f=0,collapsible:_,minSize:b=0}=d;if(_){const p=e[u];if(Me(p!=null,`Previous layout not found for panel index ${u}`),ur(p,f)){const g=b-p;xn(g,Math.abs(r))>0&&(r=r<0?0-g:g)}}}{const u=r<0?o:l,d=t[u];Me(d,`No panel constraints found for index ${u}`);const{collapsedSize:f=0,collapsible:_,minSize:b=0}=d;if(_){const p=e[u];if(Me(p!=null,`Previous layout not found for panel index ${u}`),ur(p,b)){const g=p-f;xn(g,Math.abs(r))>0&&(r=r<0?0-g:g)}}}}{const u=r<0?1:-1;let d=r<0?l:o,f=0;for(;;){const b=e[d];Me(b!=null,`Previous layout not found for panel index ${d}`);const g=Yn({panelConstraints:t,panelIndex:d,size:100})-b;if(f+=g,d+=u,d<0||d>=t.length)break}const _=Math.min(Math.abs(r),Math.abs(f));r=r<0?0-_:_}{let d=r<0?o:l;for(;d>=0&&d<t.length;){const f=Math.abs(r)-Math.abs(c),_=e[d];Me(_!=null,`Previous layout not found for panel index ${d}`);const b=_-f,p=Yn({panelConstraints:t,panelIndex:d,size:b});if(!ur(_,p)&&(c+=_-p,a[d]=p,c.toPrecision(3).localeCompare(Math.abs(r).toPrecision(3),void 0,{numeric:!0})>=0))break;r<0?d--:d++}}if(h3(s,a))return s;{const u=r<0?l:o,d=e[u];Me(d!=null,`Previous layout not found for panel index ${u}`);const f=d+c,_=Yn({panelConstraints:t,panelIndex:u,size:f});if(a[u]=_,!ur(_,f)){let b=f-_,g=r<0?l:o;for(;g>=0&&g<t.length;){const v=a[g];Me(v!=null,`Previous layout not found for panel index ${g}`);const x=v+b,w=Yn({panelConstraints:t,panelIndex:g,size:x});if(ur(v,w)||(b-=w-v,a[g]=w),ur(b,0))break;r>0?g--:g++}}}const h=a.reduce((u,d)=>d+u,0);return ur(h,100)?a:s}function u3({layout:r,panelsArray:e,pivotIndices:t}){let i=0,s=100,n=0,a=0;const o=t[0];Me(o!=null,"No pivot index found"),e.forEach((u,d)=>{const{constraints:f}=u,{maxSize:_=100,minSize:b=0}=f;d===o?(i=b,s=_):(n+=b,a+=_)});const l=Math.min(s,100-n),c=Math.max(i,100-a),h=r[o];return{valueMax:l,valueMin:c,valueNow:h}}function $a(r,e=document){return Array.from(e.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${r}"]`))}function V1(r,e,t=document){const s=$a(r,t).findIndex(n=>n.getAttribute("data-panel-resize-handle-id")===e);return s??null}function K1(r,e,t){const i=V1(r,e,t);return i!=null?[i,i+1]:[-1,-1]}function q1(r,e=document){var t;if(e instanceof HTMLElement&&(e==null||(t=e.dataset)===null||t===void 0?void 0:t.panelGroupId)==r)return e;
27const i=e.querySelector(`[data-panel-group][data-panel-group-id="${r}"]`);return i||null}function Yh(r,e=document){const t=e.querySelector(`[data-panel-resize-handle-id="${r}"]`);return t||null}function d3(r,e,t,i=document){var s,n,a,o;const l=Yh(e,i),c=$a(r,i),h=l?c.indexOf(l):-1,u=(s=(n=t[h])===null||n===void 0?void 0:n.id)!==null&&s!==void 0?s:null,d=(a=(o=t[h+1])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null;return[u,d]}function f3({committedValuesRef:r,eagerValuesRef:e,groupId:t,layout:i,panelDataArray:s,panelGroupElement:n,setLayout:a}){er({didWarnAboutMissingResizeHandle:!1}),hn(()=>{if(!n)return;const o=$a(t,n);for(let l=0;l<s.length-1;l++){const{valueMax:c,valueMin:h,valueNow:u}=u3({layout:i,panelsArray:s,pivotIndices:[l,l+1]}),d=o[l];if(d!=null){const f=s[l];Me(f,`No panel data found for index "${l}"`),d.setAttribute("aria-controls",f.id),d.setAttribute("aria-valuemax",""+Math.round(c)),d.setAttribute("aria-valuemin",""+Math.round(h)),d.setAttribute("aria-valuenow",u!=null?""+Math.round(u):"")}}return()=>{o.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[t,i,s,n]),cn(()=>{if(!n)return;const o=e.current;Me(o,"Eager values not found");const{panelDataArray:l}=o,c=q1(t,n);Me(c!=null,`No group found for id "${t}"`);const h=$a(t,n);Me(h,`No resize handles found for group id "${t}"`);const u=h.map(d=>{const f=d.getAttribute("data-panel-resize-handle-id");Me(f,"Resize handle element has no handle id attribute");const[_,b]=d3(t,f,l,n);if(_==null||b==null)return()=>{};const p=g=>{if(!g.defaultPrevented)switch(g.key){case"Enter":{g.preventDefault();const v=l.findIndex(x=>x.id===_);if(v>=0){const x=l[v];Me(x,`No panel data found for index ${v}`);const w=i[v],{collapsedSize:S=0,collapsible:k,minSize:C=0}=x.constraints;if(w!=null&&k){const y=ra({delta:ur(w,S)?C-S:S-w,initialLayout:i,panelConstraints:l.map(E=>E.constraints),pivotIndices:K1(t,f,n),prevLayout:i,trigger:"keyboard"});i!==y&&a(y)}}break}}};return d.addEventListener("keydown",p),()=>{d.removeEventListener("keydown",p)}});return()=>{u.forEach(d=>d())}},[n,r,e,t,i,s,a])}function Bv(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function G1(r,e){const t=r==="horizontal",{x:i,y:s}=Gh(e);return t?i:s}function p3(r,e,t,i,s){const n=t==="horizontal",a=Yh(e,s);Me(a,`No resize handle element found for id "${e}"`);const o=a.getAttribute("data-panel-group-id");Me(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=i;const c=G1(t,r),h=q1(o,s);Me(h,`No group element found for id "${o}"`);const u=h.getBoundingClientRect(),d=n?u.width:u.height;return(c-l)/d*100}function m3(r,e,t,i,s,n){if(j1(r)){const a=t==="horizontal";let o=0;r.shiftKey?o=100:s!=null?o=s:o=10;let l=0;switch(r.key){case"ArrowDown":l=a?0:o;break;case"ArrowLeft":l=a?-o:0;break;case"ArrowRight":l=a?o:0;break;case"ArrowUp":l=a?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return i==null?0:p3(r,e,t,i,n)}function g3({panelDataArray:r}){const e=Array(r.length),t=r.map(n=>n.constraints);let i=0,s=100;for(let n=0;n<r.length;n++){const a=t[n];Me(a,`Panel constraints not found for index ${n}`);const{defaultSize:o}=a;o!=null&&(i++,e[n]=o,s-=o)}for(let n=0;n<r.length;n++){const a=t[n];Me(a,`Panel constraints not found for index ${n}`);const{defaultSize:o}=a;if(o!=null)continue;const l=r.length-i,c=s/l;i++,e[n]=c,s-=c}return e}function Fn(r,e,t){e.forEach((i,s)=>{const n=r[s];Me(n,`Panel data not found for index ${s}`);const{callbacks:a,constraints:o,id:l}=n,{collapsedSize:c=0,collapsible:h}=o,u=t[l];if(u==null||i!==u){t[l]=i;const{onCollapse:d,onExpand:f,onResize:_}=a;_&&_(i,u),h&&(d||f)&&(f&&(u==null||Bi(u,c))&&!Bi(i,c)&&f(),d&&(u==null||!Bi(u,c))&&Bi(i,c)&&d())}})}function Zl(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!=e[t])return!1;return!0}function v3({defaultSize:r,dragState:e,layout:t,panelData:i,panelIndex:s,precision:n=3}){const a=t[s];let o;return a==null?o=r!=null?r.toPrecision(n):"1":i.length===1?o="1":o=a.toPrecision(n),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:e!==null?"none":void 0}}function b3(r,e=10){let t=null;return(...s)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{r(...s)},e)}}function Fv(r){try{if(typeof localStorage<"u")r.getItem=e=>localStorage.getItem(e),r.setItem=(e,t)=>
27{localStorage.setItem(e,t)};else throw new Error("localStorage not supported in this environment")}catch(e){console.error(e),r.getItem=()=>null,r.setItem=()=>{}}}function X1(r){return`react-resizable-panels:${r}`}function Y1(r){return r.map(e=>{const{constraints:t,id:i,idIsFromProps:s,order:n}=e;return s?i:n?`${n}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((e,t)=>e.localeCompare(t)).join(",")}function Z1(r,e){try{const t=X1(r),i=e.getItem(t);if(i){const s=JSON.parse(i);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function x3(r,e,t){var i,s;const n=(i=Z1(r,t))!==null&&i!==void 0?i:{},a=Y1(e);return(s=n[a])!==null&&s!==void 0?s:null}function _3(r,e,t,i,s){var n;const a=X1(r),o=Y1(e),l=(n=Z1(r,s))!==null&&n!==void 0?n:{};l[o]={expandToSizes:Object.fromEntries(t.entries()),layout:i};try{s.setItem(a,JSON.stringify(l))}catch(c){console.error(c)}}function $v({layout:r,panelConstraints:e}){const t=[...r],i=t.reduce((n,a)=>n+a,0);if(t.length!==e.length)throw Error(`Invalid ${e.length} panel layout: ${t.map(n=>`${n}%`).join(", ")}`);if(!ur(i,100)&&t.length>0)for(let n=0;n<e.length;n++){const a=t[n];Me(a!=null,`No layout data found for index ${n}`);const o=100/i*a;t[n]=o}let s=0;for(let n=0;n<e.length;n++){const a=t[n];Me(a!=null,`No layout data found for index ${n}`);const o=Yn({panelConstraints:e,panelIndex:n,size:a});a!=o&&(s+=a-o,t[n]=o)}if(!ur(s,0))for(let n=0;n<e.length;n++){const a=t[n];Me(a!=null,`No layout data found for index ${n}`);const o=a+s,l=Yn({panelConstraints:e,panelIndex:n,size:o});if(a!==l&&(s-=l-a,t[n]=l,ur(s,0)))break}return t}const y3=100,ia={getItem:r=>(Fv(ia),ia.getItem(r)),setItem:(r,e)=>{Fv(ia),ia.setItem(r,e)}},Hv={};function J1({autoSaveId:r=null,children:e,className:t="",direction:i,forwardedRef:s,id:n=null,onLayout:a=null,keyboardResizeBy:o=null,storage:l=ia,style:c,tagName:h="div",...u}){const d=_m(n),f=er(null),[_,b]=io(null),[p,g]=io([]),v=c3(),x=er({}),w=er(new Map),S=er(0),k=er({autoSaveId:r,direction:i,dragState:_,id:d,keyboardResizeBy:o,onLayout:a,storage:l}),C=er({layout:p,panelDataArray:[],panelDataArrayChanged:!1});er({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),O1(s,()=>({getId:()=>k.current.id,getLayout:()=>{const{layout:W}=C.current;return W},setLayout:W=>{const{onLayout:J}=k.current,{layout:Z,panelDataArray:X}=C.current,F=$v({layout:W,panelConstraints:X.map(P=>P.constraints)});Bv(Z,F)||(g(F),C.current.layout=F,J&&J(F),Fn(X,F,x.current))}}),[]),hn(()=>{k.current.autoSaveId=r,k.current.direction=i,k.current.dragState=_,k.current.id=d,k.current.onLayout=a,k.current.storage=l}),f3({committedValuesRef:k,eagerValuesRef:C,groupId:d,layout:p,panelDataArray:C.current.panelDataArray,setLayout:g,panelGroupElement:f.current}),cn(()=>{const{panelDataArray:W}=C.current;if(r){if(p.length===0||p.length!==W.length)return;let J=Hv[r];J==null&&(J=b3(_3,y3),Hv[r]=J);const Z=[...W],X=new Map(w.current);J(r,Z,X,p,l)}},[r,p,l]),cn(()=>{});const y=Jt(W=>{const{onLayout:J}=k.current,{layout:Z,panelDataArray:X}=C.current;if(W.constraints.collapsible){const F=X.map(K=>K.constraints),{collapsedSize:P=0,panelSize:j,pivotIndices:B}=$s(X,W,Z);if(Me(j!=null,`Panel size not found for panel "${W.id}"`),!Bi(j,P)){w.current.set(W.id,j);const U=Vn(X,W)===X.length-1?j-P:P-j,Y=ra({delta:U,initialLayout:Z,panelConstraints:F,pivotIndices:B,prevLayout:Z,trigger:"imperative-api"});Zl(Z,Y)||(g(Y),C.current.layout=Y,J&&J(Y),Fn(X,Y,x.current))}}},[]),E=Jt((W,J)=>{const{onLayout:Z}=k.current,{layout:X,panelDataArray:F}=C.current;if(W.constraints.collapsible){const P=F.map(ee=>ee.constraints),{collapsedSize:j=0,panelSize:B=0,minSize:K=0,pivotIndices:U}=$s(F,W,X),Y=J??K;if(Bi(B,j)){const ee=w.current.get(W.id),ie=ee!=null&&ee>=Y?ee:Y,ne=Vn(F,W)===F.length-1?B-ie:ie-B,re=ra({delta:ne,initialLayout:X,panelConstraints:P,pivotIndices:U,prevLayout:X,trigger:"imperative-api"});Zl(X,re)||(g(re),C.current.layout=re,Z&&Z(re),Fn(F,re,x.current))}}},[]),D=Jt(W=>{const{layout:J,panelDataArray:Z}=C.current,{panelSize:X}=$s(Z,W,J);return Me(X!=null,`Panel size not found for panel "${W.id}"`),X},[]),T=Jt((W,J)=>{const{panelDataArray:Z}=C.current,X=Vn(Z,W);return v3({defaultSize:J,dragState:_,layout:p,panelData:Z,panelIndex:X})},[_,p]),M=Jt(W=>{const{layout:J,panelDataArray:Z}=C.current,{collapsedSize:X=0,collapsible:F,panelSize:P}=$s(Z,W,J);return Me(P!=null,`Panel size not found for panel "${W.id}"`),F===!0&&Bi(P,X)},[]),R=Jt(W=>{const{layout:J,panelDataArray:Z}=C.current,{collapsedSize:X=0,collapsible:F,panelSize:P}=$s(Z,W,J);return Me(P!=null,`Panel size not found for panel "${W.id}"`),!F||xn(P,X)>0},[]),O=Jt(W=>{const{panelDataArray:J}=C.current;J.push(W),J.sort((Z,X)=>{const F=Z.order,P=X.order;return F==null&&P==null?0:F==null?-1:P==null?1:F-P}),C.current.panelDataArrayChanged=!0,v()},[v]);hn(()=>
27{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:W,onLayout:J,storage:Z}=k.current,{layout:X,panelDataArray:F}=C.current;let P=null;if(W){const B=x3(W,F,Z);B&&(w.current=new Map(Object.entries(B.expandToSizes)),P=B.layout)}P==null&&(P=g3({panelDataArray:F}));const j=$v({layout:P,panelConstraints:F.map(B=>B.constraints)});Bv(X,j)||(g(j),C.current.layout=j,J&&J(j),Fn(F,j,x.current))}}),hn(()=>{const W=C.current;return()=>{W.layout=[]}},[]);const $=Jt(W=>{let J=!1;const Z=f.current;return Z&&window.getComputedStyle(Z,null).getPropertyValue("direction")==="rtl"&&(J=!0),function(F){F.preventDefault();const P=f.current;if(!P)return()=>null;const{direction:j,dragState:B,id:K,keyboardResizeBy:U,onLayout:Y}=k.current,{layout:ee,panelDataArray:ie}=C.current,{initialLayout:le}=B??{},ne=K1(K,W,P);let re=m3(F,W,j,B,U,P);const me=j==="horizontal";me&&J&&(re=-re);const pe=ie.map(Ee=>Ee.constraints),se=ra({delta:re,initialLayout:le??ee,panelConstraints:pe,pivotIndices:ne,prevLayout:ee,trigger:j1(F)?"keyboard":"mouse-or-touch"}),ge=!Zl(ee,se);(B1(F)||F1(F))&&S.current!=re&&(S.current=re,!ge&&re!==0?me?Zu(W,re<0?H1:z1):Zu(W,re<0?W1:U1):Zu(W,0)),ge&&(g(se),C.current.layout=se,Y&&Y(se),Fn(ie,se,x.current))}},[]),G=Jt((W,J)=>{const{onLayout:Z}=k.current,{layout:X,panelDataArray:F}=C.current,P=F.map(ee=>ee.constraints),{panelSize:j,pivotIndices:B}=$s(F,W,X);Me(j!=null,`Panel size not found for panel "${W.id}"`);const U=Vn(F,W)===F.length-1?j-J:J-j,Y=ra({delta:U,initialLayout:X,panelConstraints:P,pivotIndices:B,prevLayout:X,trigger:"imperative-api"});Zl(X,Y)||(g(Y),C.current.layout=Y,Z&&Z(Y),Fn(F,Y,x.current))},[]),V=Jt((W,J)=>{const{layout:Z,panelDataArray:X}=C.current,{collapsedSize:F=0,collapsible:P}=J,{collapsedSize:j=0,collapsible:B,maxSize:K=100,minSize:U=0}=W.constraints,{panelSize:Y}=$s(X,W,Z);Y!=null&&(P&&B&&Bi(Y,F)?Bi(F,j)||G(W,j):Y<U?G(W,U):Y>K&&G(W,K))},[G]),q=Jt((W,J)=>{const{direction:Z}=k.current,{layout:X}=C.current;if(!f.current)return;const F=Yh(W,f.current);Me(F,`Drag handle element not found for id "${W}"`);const P=G1(Z,J);b({dragHandleId:W,dragHandleRect:F.getBoundingClientRect(),initialCursorPosition:P,initialLayout:X})},[]),L=Jt(()=>{b(null)},[]),N=Jt(W=>{const{panelDataArray:J}=C.current,Z=Vn(J,W);Z>=0&&(J.splice(Z,1),delete x.current[W.id],C.current.panelDataArrayChanged=!0,v())},[v]),I=XO(()=>({collapsePanel:y,direction:i,dragState:_,expandPanel:E,getPanelSize:D,getPanelStyle:T,groupId:d,isPanelCollapsed:M,isPanelExpanded:R,reevaluatePanelConstraints:V,registerPanel:O,registerResizeHandle:$,resizePanel:G,startDragging:q,stopDragging:L,unregisterPanel:N,panelGroupElement:f.current}),[y,_,i,E,D,T,d,M,R,V,O,$,G,q,L,N]),H={display:"flex",flexDirection:i==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return go(qh.Provider,{value:I},go(h,{...u,children:e,className:t,id:n,ref:f,style:{...H,...c},"data-panel-group":"","data-panel-group-direction":i,"data-panel-group-id":d}))}const Wf=L1((r,e)=>go(J1,{...r,forwardedRef:e}));J1.displayName="PanelGroup";Wf.displayName="forwardRef(PanelGroup)";function Vn(r,e){return r.findIndex(t=>t===e||t.id===e.id)}function $s(r,e,t){const i=Vn(r,e),n=i===r.length-1?[i-1,i]:[i,i+1],a=t[i];return{...e.constraints,panelSize:a,pivotIndices:n}}function w3({disabled:r,handleId:e,resizeHandler:t,panelGroupElement:i}){cn(()=>{if(r||t==null||i==null)return;const s=Yh(e,i);if(s==null)return;const n=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),t(a);break}case"F6":{a.preventDefault();const o=s.getAttribute("data-panel-group-id");Me(o,`No group element found for id "${o}"`);const l=$a(o,i),c=V1(o,e,i);Me(c!==null,`No resize element found for id "${e}"`);const h=a.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[h].focus();break}}};return s.addEventListener("keydown",n),()=>{s.removeEventListener("keydown",n)}},[i,r,e,t])}function Uf({children:r=null,className:e="",disabled:t=!1,hitAreaMargins:i,id:s,onBlur:n,onDragging:a,onFocus:o,style:l={},tabIndex:c=0,tagName:h="div",...u}){var d,f;const _=er(null),b=er({onDragging:a});cn(()=>{b.current.onDragging=a});const p=N1(qh);if(p===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:g,groupId:v,registerResizeHandle:x,startDragging:w,stopDragging:S,panelGroupElement:k}=p,C=_m(s),[y,E]=io("inactive"),[D,T]=io(!1),[M,R]=io(null),O=er({state:y});hn(()=>{O.current.state=y}),cn(()=>
27{if(t)R(null);else{const q=x(C);R(()=>q)}},[t,C,x]);const $=(d=i?.coarse)!==null&&d!==void 0?d:15,G=(f=i?.fine)!==null&&f!==void 0?f:5;return cn(()=>{if(t||M==null)return;const q=_.current;return Me(q,"Element ref not attached"),l3(C,q,g,{coarse:$,fine:G},(N,I,H)=>{if(I)switch(N){case"down":{E("drag"),Me(H,'Expected event to be defined for "down" action'),w(C,H);const{onDragging:W}=b.current;W&&W(!0);break}case"move":{const{state:W}=O.current;W!=="drag"&&E("hover"),Me(H,'Expected event to be defined for "move" action'),M(H);break}case"up":{E("hover"),S();const{onDragging:W}=b.current;W&&W(!1);break}}else E("inactive")})},[$,g,t,G,x,C,M,w,S]),w3({disabled:t,handleId:C,resizeHandler:M,panelGroupElement:k}),go(h,{...u,children:r,className:e,id:s,onBlur:()=>{T(!1),n?.()},onFocus:()=>{T(!0),o?.()},ref:_,role:"separator",style:{...{touchAction:"none",userSelect:"none"},...l},tabIndex:c,"data-panel-group-direction":g,"data-panel-group-id":v,"data-resize-handle":"","data-resize-handle-active":y==="drag"?"pointer":D?"keyboard":void 0,"data-resize-handle-state":y,"data-panel-resize-handle-enabled":!t,"data-panel-resize-handle-id":C})}Uf.displayName="PanelResizeHandle";var km="Tabs",[S3,F$]=yp(km,[Ix]),Q1=Ix(),[k3,Cm]=S3(km),eS=A.forwardRef((r,e)=>{const{__scopeTabs:t,value:i,onValueChange:s,defaultValue:n,orientation:a="horizontal",dir:o,activationMode:l="automatic",...c}=r,h=S2(o),[u,d]=Nx({prop:i,onChange:s,defaultProp:n});return m.jsx(k3,{scope:t,baseId:Ox(),value:u,onValueChange:d,orientation:a,dir:h,activationMode:l,children:m.jsx(An.div,{dir:h,"data-orientation":a,...c,ref:e})})});eS.displayName=km;var tS="TabsList",rS=A.forwardRef((r,e)=>{const{__scopeTabs:t,loop:i=!0,...s}=r,n=Cm(tS,t),a=Q1(t);return m.jsx(k2,{asChild:!0,...a,orientation:n.orientation,dir:n.dir,loop:i,children:m.jsx(An.div,{role:"tablist","aria-orientation":n.orientation,...s,ref:e})})});rS.displayName=tS;var iS="TabsTrigger",sS=A.forwardRef((r,e)=>{const{__scopeTabs:t,value:i,disabled:s=!1,...n}=r,a=Cm(iS,t),o=Q1(t),l=aS(a.baseId,i),c=lS(a.baseId,i),h=i===a.value;return m.jsx(C2,{asChild:!0,...o,focusable:!s,active:h,children:m.jsx(An.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":c,"data-state":h?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:l,...n,ref:e,onMouseDown:fr(r.onMouseDown,u=>{!s&&u.button===0&&u.ctrlKey===!1?a.onValueChange(i):u.preventDefault()}),onKeyDown:fr(r.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&a.onValueChange(i)}),onFocus:fr(r.onFocus,()=>{const u=a.activationMode!=="manual";!h&&!s&&u&&a.onValueChange(i)})})})});sS.displayName=iS;var nS="TabsContent",oS=A.forwardRef((r,e)=>{const{__scopeTabs:t,value:i,forceMount:s,children:n,...a}=r,o=Cm(nS,t),l=aS(o.baseId,i),c=lS(o.baseId,i),h=i===o.value,u=A.useRef(h);return A.useEffect(()=>{const d=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(d)},[]),m.jsx(wp,{present:s||h,children:({present:d})=>m.jsx(An.div,{"data-state":h?"active":"inactive","data-orientation":o.orientation,role:"tabpanel","aria-labelledby":l,hidden:!d,id:c,tabIndex:0,...a,ref:e,style:{...r.style,animationDuration:u.current?"0s":void 0},children:d&&n})})});oS.displayName=nS;function aS(r,e){return`${r}-trigger-${e}`}function lS(r,e){return`${r}-content-${e}`}var C3=eS,E3=rS,Ju=sS,Qu=oS;const zv=A.memo(({className:r,children:e})=>m.jsx("div",{className:ce("flex items-center gap-2 bg-exkalibur-elements-background-depth-2 text-exkalibur-elements-textSecondary border-b border-exkalibur-elements-borderColor px-4 py-1 min-h-[34px] text-sm",r),children:e}));function A3(){return globalThis.innerWidth<640}var Em="ContextMenu",[T3,$$]=yp(Em,[jx]),Yt=jx(),[R3,cS]=T3(Em),hS=r=>{const{__scopeContextMenu:e,children:t,onOpenChange:i,dir:s,modal:n=!0}=r,[a,o]=A.useState(!1),l=Yt(e),c=E2(i),h=A.useCallback(u=>{o(u),c(u)},[c]);return m.jsx(R3,{scope:e,open:a,onOpenChange:h,modal:n,children:m.jsx(A2,{...l,dir:s,open:a,onOpenChange:h,modal:n,children:t})})};hS.displayName=Em;var uS="ContextMenuTrigger",dS=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,disabled:i=!1,...s}=r,n=cS(uS,t),a=Yt(t),o=A.useRef({x:0,y:0}),l=A.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...o.current})}),c=A.useRef(0),h=A.useCallback(()=>window.clearTimeout(c.current),[]),u=d=>{o.current={x:d.clientX,y:d.clientY},n.onOpenChange(!0)};return A.useEffect(()=>h,[h]),A.useEffect(()=>void(i&&h()),[i,h]),m.jsxs(m.Fragment,{children:[m.jsx(T2,{...a,virtualRef:l}),m.jsx(An.span,{"data-state":n.open?"open":"closed","data-disabled":i?"":void 0,...s,ref:e,style:{WebkitTouchCallout:"none",...r.style},onContextMenu:i?r.onContextMenu:fr(r.onContextMenu,d=>{h(),u(d),d.preventDefault()}),onPointerDown:i?r.onPointerDown:fr(r.onPointerDown,Jl(d=>{h(),c.current=window.setTimeout(()=>u(d),700)})),onPointerMove:i?r.onPointerMove:fr(r.onPointerMove,Jl(h)),onPointerCancel:i?r.onPointerCancel:fr(r.onPointerCancel,Jl(h)),onPointerUp:i?r.onPointerUp:fr(r.onPointerUp,Jl(h))})]})});dS.displayName=uS;var M3="ContextMenuPortal",fS=r=>{const{__scopeContextMenu:e,...t}
27=r,i=Yt(e);return m.jsx(R2,{...i,...t})};fS.displayName=M3;var pS="ContextMenuContent",mS=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=cS(pS,t),n=Yt(t),a=A.useRef(!1);return m.jsx(M2,{...n,...i,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:o=>{r.onCloseAutoFocus?.(o),!o.defaultPrevented&&a.current&&o.preventDefault(),a.current=!1},onInteractOutside:o=>{r.onInteractOutside?.(o),!o.defaultPrevented&&!s.modal&&(a.current=!0)},style:{...r.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});mS.displayName=pS;var D3="ContextMenuGroup",gS=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(D2,{...s,...i,ref:e})});gS.displayName=D3;var P3="ContextMenuLabel",L3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(L2,{...s,...i,ref:e})});L3.displayName=P3;var N3="ContextMenuItem",vS=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(P2,{...s,...i,ref:e})});vS.displayName=N3;var O3="ContextMenuCheckboxItem",I3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(N2,{...s,...i,ref:e})});I3.displayName=O3;var j3="ContextMenuRadioGroup",B3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(O2,{...s,...i,ref:e})});B3.displayName=j3;var F3="ContextMenuRadioItem",$3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(I2,{...s,...i,ref:e})});$3.displayName=F3;var H3="ContextMenuItemIndicator",z3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(j2,{...s,...i,ref:e})});z3.displayName=H3;var W3="ContextMenuSeparator",U3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(B2,{...s,...i,ref:e})});U3.displayName=W3;var V3="ContextMenuArrow",K3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(F2,{...s,...i,ref:e})});K3.displayName=V3;var q3="ContextMenuSubTrigger",G3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx($2,{...s,...i,ref:e})});G3.displayName=q3;var X3="ContextMenuSubContent",Y3=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...i}=r,s=Yt(t);return m.jsx(H2,{...s,...i,ref:e,style:{...r.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Y3.displayName=X3;function Jl(r){return e=>e.pointerType!=="mouse"?r(e):void 0}var Z3=hS,J3=dS,Q3=fS,eI=mS,Ql=gS,tI=vS;const Li=Xi("FileTree"),bS=8,rI=[/\/node_modules\//,/\/\.next/,/\/\.astro/],xS=A.memo(({files:r={},onFileSelect:e,selectedFile:t,rootFolder:i,hideRoot:s=!1,collapsed:n=!1,allowFolderSelection:a=!1,hiddenFiles:o,className:l,unsavedFiles:c,fileHistory:h={},streamingFile:u})=>{wo.trace("FileTree");const d=A.useMemo(()=>[...rI,...o??[]],[o]),f=A.useMemo(()=>nI(r,i,s,d),[r,i,s,d]),[_,b]=A.useState(()=>n?new Set(f.filter(w=>w.kind==="folder").map(w=>w.fullPath)):new Set);A.useEffect(()=>{if(n){b(new Set(f.filter(w=>w.kind==="folder").map(w=>w.fullPath)));return}b(w=>{const S=new Set;for(const k of f)k.kind==="folder"&&w.has(k.fullPath)&&S.add(k.fullPath);return S})},[f,n]);const p=A.useMemo(()=>{const w=[];let S=Number.MAX_SAFE_INTEGER;for(const k of f){const C=k.depth;S===C&&(S=Number.MAX_SAFE_INTEGER),_.has(k.fullPath)&&(S=Math.min(S,C)),!(S<C)&&w.push(k)}return w},[f,_]),g=w=>{b(S=>{const k=new Set(S);return k.has(w)?k.delete(w):k.add(w),k})},v=w=>{try{navigator.clipboard.writeText(w.fullPath)}catch(S){Li.error(S)}},x=w=>{try{navigator.clipboard.writeText(w.fullPath.substring((i||"").length))}catch(S){Li.error(S)}};return m.jsx("div",{className:ce("text-sm",l,"overflow-y-auto modern-scrollbar"),children:p.map(w=>{switch(w.kind){case"file":return m.jsx(sI,{selected:t===w.fullPath,file:w,unsavedChanges:c instanceof Set&&c.has(w.fullPath),fileHistory:h,isBeingModified:u===w.fullPath,onCopyPath:()=>{v(w)},onCopyRelativePath:()=>{x(w)},onClick:()=>{e?.(w.fullPath)}},w.id);case"folder":return m.jsx(iI,{folder:w,selected:a&&t===w.fullPath,collapsed:_.has(w.fullPath),onCopyPath:()=>{v(w)},onCopyRelativePath:()=>{x(w)},onClick:()=>{g(w.fullPath)}},w.id);default:return}})})});function Mi({onSelect:r,children:e}){return m.jsxs(tI,{onSelect:r,className:"flex items-center gap-2 px-2 py-1.5 outline-0 text-sm text-exkalibur-elements-textPrimary curs
27or-pointer ws-nowrap text-exkalibur-elements-item-contentDefault hover:text-exkalibur-elements-item-contentActive hover:bg-exkalibur-elements-item-backgroundActive rounded-md",children:[m.jsx("span",{className:"size-4 shrink-0"}),m.jsx("span",{children:e})]})}function Wv({depth:r,placeholder:e,initialValue:t="",onSubmit:i,onCancel:s}){const n=A.useRef(null);A.useEffect(()=>{const o=setTimeout(()=>{n.current&&(n.current.focus(),t&&(n.current.value=t,n.current.select()))},50);return()=>clearTimeout(o)},[t]);const a=o=>{if(o.key==="Enter"){const l=n.current?.value.trim();l&&i(l)}else o.key==="Escape"&&s()};return m.jsxs("div",{className:"flex items-center w-full px-2 bg-exkalibur-elements-background-depth-4 border border-exkalibur-elements-item-contentAccent py-0.5 text-exkalibur-elements-textPrimary",style:{paddingLeft:`${6+r*bS}px`},children:[m.jsx("div",{className:"scale-120 shrink-0 i-ph:file-plus text-exkalibur-elements-textTertiary"}),m.jsx("input",{ref:n,type:"text",className:"ml-2 flex-1 bg-transparent border-none outline-none py-0.5 text-sm text-exkalibur-elements-textPrimary placeholder:text-exkalibur-elements-textTertiary min-w-0",placeholder:e,onKeyDown:a,onBlur:()=>{setTimeout(()=>{document.activeElement!==n.current&&s()},100)}})]})}function _S({onCopyPath:r,onCopyRelativePath:e,fullPath:t,children:i}){const[s,n]=A.useState(!1),[a,o]=A.useState(!1),[l,c]=A.useState(!1),h=A.useMemo(()=>t.split("/").length,[t]),u=A.useMemo(()=>Io.basename(t),[t]),d=A.useMemo(()=>{const E=ue.files.get()[t];return!E||E.type==="folder"},[t]),f=A.useMemo(()=>d?t:Io.dirname(t),[t,d]),_=A.useCallback(y=>{y.preventDefault(),y.stopPropagation(),c(!0)},[]),b=A.useCallback(y=>{y.preventDefault(),y.stopPropagation(),c(!1)},[]),p=A.useCallback(async y=>{y.preventDefault(),y.stopPropagation();const D=Array.from(y.dataTransfer.items).filter(T=>T.kind==="file");for(const T of D){const M=T.getAsFile();if(M)try{const R=Io.join(t,M.name),O=await M.arrayBuffer(),$=new Uint8Array(O);await ue.createFile(R,$)?he.success(`File ${M.name} uploaded successfully`):he.error(`Failed to upload file ${M.name}`)}catch(R){he.error(`Error uploading ${M.name}`),Li.error(R)}}c(!1)},[t]),g=async y=>{const E=Io.join(f,y);await ue.createFile(E,"")?he.success("File created successfully"):he.error("Failed to create file"),n(!1)},v=async y=>{const E=Io.join(f,y);await ue.createFolder(E)?he.success("Folder created successfully"):he.error("Failed to create folder"),o(!1)},x=async()=>{try{if(!confirm(`Are you sure you want to delete ${d?"folder":"file"}: ${u}?`))return;let y;d?y=await ue.deleteFolder(t):y=await ue.deleteFile(t),y?he.success(`${d?"Folder":"File"} deleted successfully`):he.error(`Failed to delete ${d?"folder":"file"}`)}catch(y){he.error(`Error deleting ${d?"folder":"file"}`),Li.error(y)}},w=()=>{try{if(d)return;ue.lockFile(t)?he.success("File locked successfully"):he.error("Failed to lock file")}catch(y){he.error("Error locking file"),Li.error(y)}},S=()=>{try{if(d)return;ue.unlockFile(t)?he.success("File unlocked successfully"):he.error("Failed to unlock file")}catch(y){he.error("Error unlocking file"),Li.error(y)}},k=()=>{try{if(!d)return;ue.lockFolder(t)?he.success("Folder locked successfully"):he.error("Failed to lock folder")}catch(y){he.error("Error locking folder"),Li.error(y)}},C=()=>{try{if(!d)return;ue.unlockFolder(t)?he.success("Folder unlocked successfully"):he.error("Failed to unlock folder")}catch(y){he.error("Error unlocking folder"),Li.error(y)}};return m.jsxs(m.Fragment,{children:[m.jsxs(Z3,{children:[m.jsx(J3,{children:m.jsx("div",{onDragOver:_,onDragLeave:b,onDrop:p,className:ce("relative",{"bg-exkalibur-elements-background-depth-2 border border-dashed border-exkalibur-elements-item-contentAccent rounded-md":l}),children:i})}),m.jsx(Q3,{children:m.jsxs(eI,{style:{zIndex:998},className:"border border-exkalibur-elements-borderColor rounded-md z-context-menu bg-exkalibur-elements-background-depth-1 dark:bg-exkalibur-elements-background-depth-2 data-[state=open]:animate-in animate-duration-100 data-[state=open]:fade-in-0 data-[state=open]:zoom-in-98 w-56",children:[m.jsxs(Ql,{className:"p-1 border-b-px border-solid border-exkalibur-elements-borderColor",children:[m.jsx(Mi,{onSelect:()=>n(!0),children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:file-plus"}),"New File"]})}),m.jsx(Mi,{onSelect:()=>o(!0),children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:folder-plus"}),"New Folder"]})})]}),m.jsxs(Ql,{className:"p-1",children:[m.jsx(Mi,{onSelect:r,children:"Copy path"}),m.jsx(Mi,{onSelect:e,children:"Copy relative path"})]}),m.jsx(Ql,{className:"p-1 border-t-px border-solid border-exkalibur-elements-borderColor",children:d?m.jsxs(m.Fragment,{children:[m.jsx(Mi,{onSelect:k,children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:lock-simple"}),"Lock Folder"]})}),m.jsx(Mi,{onSelect:C,children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:lock-key-open"}),"Unlock Folder"]})})]}):m.jsxs(m.Fragment,{children:[m.jsx(Mi,{onSelect:w,children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:lock-simple"}),"Lock File"]})}),m.jsx(Mi,{onSelect:S,children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:lock-key-open"}),"Unlock File"]})})]})}),m.jsx(Ql,{className:"p-1 border-t-px border-solid border-exkalibur-elements-borderColor",children:m.jsx(Mi,{onSelect:x,children:m.jsxs("div",{className:"flex items-center gap-2 text-red-500",children:[m.jsx("div",{className:"i-ph:trash"}),"Delete ",d?"Folder":"File"]})})})]})})]}),s&&m.jsx(Wv,{depth:h,placeholder:"Enter file name...",onSubmit:g,onCancel:()=>n(!1)}),a&&m.jsx(Wv,{depth:h,placeholder:"Enter folder name...",onSubmit:v,onCancel:()=>o(!1)})]})}function iI({folder:r,collapsed:e,selected:t=!1,onCopyPath:i,onCopyRelativePath:s,onClick:n}){const{isLocked:a}
27=ue.isFolderLocked(r.fullPath);return m.jsx(_S,{onCopyPath:i,onCopyRelativePath:s,fullPath:r.fullPath,children:m.jsx(yS,{className:ce("group",{"bg-transparent text-exkalibur-elements-item-contentDefault hover:text-exkalibur-elements-item-contentActive hover:bg-exkalibur-elements-item-backgroundActive":!t,"bg-exkalibur-elements-item-backgroundAccent text-exkalibur-elements-item-contentAccent":t}),depth:r.depth,iconClasses:ce({"i-ph:caret-right scale-98":e,"i-ph:caret-down scale-98":!e}),onClick:n,children:m.jsxs("div",{className:"flex items-center w-full",children:[m.jsx("div",{className:"flex-1 truncate pr-2",children:r.name}),a&&m.jsx("span",{className:ce("shrink-0","i-ph:lock-simple scale-80 text-red-500"),title:"Folder is locked"})]})})})}function sI({file:r,onClick:e,onCopyPath:t,onCopyRelativePath:i,selected:s,unsavedChanges:n=!1,fileHistory:a={},isBeingModified:o=!1}){const{depth:l,name:c,fullPath:h}=r,{locked:u}=ue.isFileLocked(h),d=A.useCallback(()=>{e()},[e]),f=a[h],{additions:_,deletions:b}=A.useMemo(()=>{if(!f?.originalContent)return{additions:0,deletions:0};const g=f.originalContent.replace(/\r\n/g,` 28`),v=f.versions[f.versions.length-1]?.content.replace(/\r\n/g,` 29`)||"";return g===v?{additions:0,deletions:0}:ya(g,v,{newlineIsToken:!1,ignoreWhitespace:!0,ignoreCase:!1}).reduce((w,S)=>(S.added&&(w.additions+=S.value.split(` 30`).length),S.removed&&(w.deletions+=S.value.split(` 31`).length),w),{additions:0,deletions:0})},[f]),p=_>0||b>0;return m.jsx(_S,{onCopyPath:t,onCopyRelativePath:i,fullPath:h,children:m.jsx(yS,{className:ce("group",{"bg-transparent hover:bg-pink-600/20 text-white hover:text-pink-600":!s,"!text-#ff99cc bg-transparent":s}),depth:l,iconClasses:ce("i-ph:file-duotone scale-98",{"group-hover:text-exkalibur-elements-item-contentActive":!s}),onClick:e,children:m.jsxs("div",{className:ce("flex items-center",{"group-hover:text-exkalibur-elements-item-contentActive":!s}),onClick:d,style:{cursor:"pointer"},children:[m.jsx("div",{className:"flex-1 truncate pr-2",children:c}),m.jsxs("div",{className:"flex items-center gap-1",children:[p&&m.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[_>0&&m.jsxs("span",{className:"text-green-500",children:["+",_]}),b>0&&m.jsxs("span",{className:"text-red-500",children:["-",b]})]}),u&&m.jsx("span",{className:ce("shrink-0","i-ph:lock-simple scale-80 text-red-500"),title:"File is locked"}),o&&m.jsx("span",{className:ce("shrink-0","i-ph:circle-fill scale-68 text-yellow-400 animate-pulse"),title:"File being modified by AI"}),n&&m.jsx("span",{className:"i-ph:circle-fill scale-68 shrink-0 text-orange-500"})]})]})})})}function yS({depth:r,iconClasses:e,onClick:t,className:i,children:s}){return m.jsxs("button",{className:ce("flex items-center gap-1.5 w-full pr-2 border-2 border-transparent py-0.5","text-white",i),style:{paddingLeft:`${6+r*bS}px`},onClick:()=>t?.(),children:[m.jsx("div",{className:ce("scale-120 shrink-0",e)}),m.jsx("div",{className:"truncate w-full text-left",children:s})]})}function nI(r,e="/",t,i){const s=new Set,n=[];let a=0;e==="/"&&!t&&(a=1,n.push({kind:"folder",name:"/",depth:0,id:0,fullPath:"/"}));for(const[o,l]of Object.entries(r)){const c=o.split("/").filter(_=>_),h=c.at(-1);if(!h||oI(o,h,i))continue;let u="",d=0,f=0;for(;d<c.length;){const _=c[d],b=u+=`/${_}`;if(!b.startsWith(e)||t&&b===e){d++;continue}d===c.length-1&&l?.type==="file"?n.push({kind:"file",id:n.length,name:_,fullPath:b,depth:f+a}):s.has(b)||(s.add(b),n.push({kind:"folder",id:n.length,name:_,fullPath:b,depth:f+a})),d++,f++}}return aI(e,n,t)}function oI(r,e,t){return t.some(i=>typeof i=="string"?e===i:i.test(r))}function aI(r,e,t){Li.trace("sortFileList");const i=new Map,s=new Map;e.sort((o,l)=>lI(o,l));for(const o of e){i.set(o.fullPath,o);const l=o.fullPath.slice(0,o.fullPath.lastIndexOf("/"));l!==r.slice(0,r.lastIndexOf("/"))&&(s.has(l)||s.set(l,[]),s.get(l)?.push(o))}const n=[],a=o=>{const l=i.get(o);l&&n.push(l);const c=s.get(o);if(c)for(const h of c)h.kind==="folder"?a(h.fullPath):n.push(h)};if(t){const o=s.get(r)||[];for(const l of o)a(l.fullPath)}else a(r);return n}function lI(r,e){return r.kind!==e.kind?r.kind==="folder"?-1:1:r.name.localeCompare(e.name,void 0,{numeric:!0,sensitivity:"base"})}const cI=new RegExp(`^${un.split("/").slice(0,-1).join("/").replaceAll("/","\\/")}/`),hI={open:{y:0,opacity:1,transition:{duration:.15,ease:Ss}},close:{y:6,opacity:0,transition:{duration:.15,ease:Ss}}},uI=A.memo(({files:r,pathSegments:e=[],onFileSelect:t})=>{wo.trace("FileBreadcrumb");const[i,s]=A.useState(null),n=A.useRef(null),a=A.useRef([]),o=l=>{s(c=>c===l?null:l)};return A.useEffect(()=>{const l=c=>{i!==null&&!n.current?.contains(c.target)&&!a.current.some(h=>h?.contains(c.target))&&s(null)};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[i]),r===void 0||e.length===0?null:m.jsx("div",{className:"flex",children:e.map((l,c)=>{const h=c===e.length-1,u=e.slice(0,c).join("/");if(!cI.test(u))return null;const d=i===c;return m.jsx("div",{className:"relative flex items-center",children:m.jsxs(Sp,{open:d,modal:!1,children:[m.jsx(kp,{asChild:!0,children:m.jsxs("span",{ref:f=>{a.current[c]=f},className:ce("flex items-center gap-1.5 cursor-pointer shrink-0",{"text-white/90 hover:text-white":!d,"text-white underline":d,"pr-4":h}),onClick:()=>o(c),children:[h&&m.jsx("div",{className:"i-ph:file-duotone"}),l]})}),c>0&&!h&&m.jsx("span",{className:"i-ph:caret-right inline-block mx-1"}),m.jsx(Ui,{children:d&&m.jsx(Cp,{children:m.jsx(Ep,{className:"z-file-tree-breadcrumb",asChild:!0,align:"start",side:"bottom",avoidCollisions:!1,children:m.jsxs(Ae.div,{ref:n,initial:"close",animate:"open",exit:"close",variants:hI,children:[m.jsx("div",{className:"rounded-lg overflow-hidden",children:m.jsx("div",{className:"max-h-[50vh] min-w-[300px] overflow-scroll bg-exkalibur-elements-background-depth-1 border border-exkalibur-elements-borderColor shadow-sm rounded-lg",children:m.jsx(xS,{files:r,hideRoot:!0,rootFolder:u,collapsed:!0,allowFolderSelection:!0,selectedFile:`${u}/${l}`,onFileSelect:f=>{s(null),t?.(f)}})})}),m.jsx(z2,{className:"fill-exkalibur-elements-borderColor"})]})})})})]})},c)})})});var wS={exports:{}};(function(r,e){(function(t,i){r.exports=i()})(self,()=>(()=>{var t={};return(()=>{var i=t;Object.defineProperty(i,"__esModule",{value:!0}),i.FitAddon=void 0,i.FitAddon=class{activate(s){this._terminal=s}dispose(){}fit(){const s=this.proposeDimensions();if(!s||!this._terminal||isNaN(s.cols)||isNaN(s.rows))return;
31const n=this._terminal._core;this._terminal.rows===s.rows&&this._terminal.cols===s.cols||(n._renderService.clear(),this._terminal.resize(s.cols,s.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const s=this._terminal._core,n=s._renderService.dimensions;if(n.css.cell.width===0||n.css.cell.height===0)return;const a=this._terminal.options.scrollback===0?0:s.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(o.getPropertyValue("height")),c=Math.max(0,parseInt(o.getPropertyValue("width"))),h=window.getComputedStyle(this._terminal.element),u=l-(parseInt(h.getPropertyValue("padding-top"))+parseInt(h.getPropertyValue("padding-bottom"))),d=c-(parseInt(h.getPropertyValue("padding-right"))+parseInt(h.getPropertyValue("padding-left")))-a;return{cols:Math.max(2,Math.floor(d/n.css.cell.width)),rows:Math.max(1,Math.floor(u/n.css.cell.height))}}}})(),t})())})(wS);var dI=wS.exports,SS={exports:{}};(function(r,e){(function(t,i){r.exports=i()})(self,()=>(()=>{var t={6:(a,o)=>{function l(h){try{const u=new URL(h),d=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 h.toLocaleLowerCase().startsWith(d.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(o,"__esModule",{value:!0}),o.LinkComputer=o.WebLinkProvider=void 0,o.WebLinkProvider=class{constructor(h,u,d,f={}){this._terminal=h,this._regex=u,this._handler=d,this._options=f}provideLinks(h,u){const d=c.computeLink(h,this._regex,this._terminal,this._handler);u(this._addCallbacks(d))}_addCallbacks(h){return h.map(u=>(u.leave=this._options.leave,u.hover=(d,f)=>{if(this._options.hover){const{range:_}=u;this._options.hover(d,f,_)}},u))}};class c{static computeLink(u,d,f,_){const b=new RegExp(d.source,(d.flags||"")+"g"),[p,g]=c._getWindowedLineStrings(u-1,f),v=p.join("");let x;const w=[];for(;x=b.exec(v);){const S=x[0];if(!l(S))continue;const[k,C]=c._mapStrIdx(f,g,0,x.index),[y,E]=c._mapStrIdx(f,k,C,S.length);if(k===-1||C===-1||y===-1||E===-1)continue;const D={start:{x:C+1,y:k+1},end:{x:E,y:y+1}};w.push({range:D,text:S,activate:_})}return w}static _getWindowedLineStrings(u,d){let f,_=u,b=u,p=0,g="";const v=[];if(f=d.buffer.active.getLine(u)){const x=f.translateToString(!0);if(f.isWrapped&&x[0]!==" "){for(p=0;(f=d.buffer.active.getLine(--_))&&p<2048&&(g=f.translateToString(!0),p+=g.length,v.push(g),f.isWrapped&&g.indexOf(" ")===-1););v.reverse()}for(v.push(x),p=0;(f=d.buffer.active.getLine(++b))&&f.isWrapped&&p<2048&&(g=f.translateToString(!0),p+=g.length,v.push(g),g.indexOf(" ")===-1););}return[v,_]}static _mapStrIdx(u,d,f,_){const b=u.buffer.active,p=b.getNullCell();let g=f;for(;_;){const v=b.getLine(d);if(!v)return[-1,-1];for(let x=g;x<v.length;++x){v.getCell(x,p);const w=p.getChars();if(p.getWidth()&&(_-=w.length||1,x===v.length-1&&w==="")){const S=b.getLine(d+1);S&&S.isWrapped&&(S.getCell(0,p),p.getWidth()===2&&(_+=1))}if(_<0)return[d,x]}d++,g=0}return[d,g]}}o.LinkComputer=c}},i={};function s(a){var o=i[a];if(o!==void 0)return o.exports;var l=i[a]={exports:{}};return t[a](l,l.exports,s),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.WebLinksAddon=void 0;const o=s(6),l=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function c(h,u){const d=window.open();if(d){try{d.opener=null}catch{}d.location.href=u}else console.warn("Opening link blocked as opener could not be cleared")}a.WebLinksAddon=class{constructor(h=c,u={}){this._handler=h,this._options=u}activate(h){this._terminal=h;const u=this._options,d=u.urlRegex||l;this._linkProvider=this._terminal.registerLinkProvider(new o.WebLinkProvider(this._terminal,d,this._handler,u))}dispose(){this._linkProvider?.dispose()}}})(),n})())})(SS);var fI=SS.exports,kS={exports:{}};(function(r,e){(function(t,i){r.exports=i()})(globalThis,()=>(()=>{var t={4567:function(a,o,l){var c=this&&this.__decorate||function(v,x,w,S){var k,C=arguments.length,y=C<3?x:S===null?S=Object.getOwnPropertyDescriptor(x,w):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,x,w,S);else for(var E=v.length-1;E>=0;E--)(k=v[E])&&(y=(C<3?k(y):C>3?k(x,w,y):k(x,w))||y);return C>3&&y&&Object.defineProperty(x,w,y),y},h=this&&this.__param||function(v,x){return function(w,S){x(w,S,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const u=l(9042),d=l(9924),f=l(844),_=l(4725),b=l(2585),p=l(3656);let g=o.AccessibilityManager=class extends f.Disposable{constructor(v,x,w,S){super(),this._terminal=v,this._coreBrowserService=w,this._renderService=S,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce
31="",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 d.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(` 32`))),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,p.addDisposableDomListener)(document,"selectionchange",()=>this._handleSelectionChange())),this.register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,f.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(v){for(let x=0;x<v;x++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===` 33`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=u.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),/\p{Control}/u.test(v)||this._charsToConsume.push(v)}_refreshRows(v,x){this._liveRegionDebouncer.refresh(v,x,this._terminal.rows)}_renderRows(v,x){const w=this._terminal.buffer,S=w.lines.length.toString();for(let k=v;k<=x;k++){const C=w.lines.get(w.ydisp+k),y=[],E=C?.translateToString(!0,void 0,void 0,y)||"",D=(w.ydisp+k+1).toString(),T=this._rowElements[k];T&&(E.length===0?(T.innerText="Â ",this._rowColumns.set(T,[0,1])):(T.textContent=E,this._rowColumns.set(T,y)),T.setAttribute("aria-posinset",D),T.setAttribute("aria-setsize",S))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,x){const w=v.target,S=this._rowElements[x===0?1:this._rowElements.length-2];if(w.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==S)return;let k,C;if(x===0?(k=w,C=this._rowElements.pop(),this._rowContainer.removeChild(C)):(k=this._rowElements.shift(),C=w,this._rowContainer.removeChild(k)),k.removeEventListener("focus",this._topBoundaryFocusListener),C.removeEventListener("focus",this._bottomBoundaryFocusListener),x===0){const y=this._createAccessibilityTreeNode();this._rowElements.unshift(y),this._rowContainer.insertAdjacentElement("afterbegin",y)}else{const y=this._createAccessibilityTreeNode();this._rowElements.push(y),this._rowContainer.appendChild(y)}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(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let x={node:v.anchorNode,offset:v.anchorOffset},w={node:v.focusNode,offset:v.focusOffset};if((x.node.compareDocumentPosition(w.node)&Node.DOCUMENT_POSITION_PRECEDING||x.node===w.node&&x.offset>w.offset)&&([x,w]=[w,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 S=this._rowElements.slice(-1)[0];if(w.node.compareDocumentPosition(S)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(w={node:S,offset:S.textContent?.length??0}),!this._rowContainer.contains(w.node))return;const k=({node:E,offset:D})=>{const T=E instanceof Text?E.parentNode:E;let M=parseInt(T?.getAttribute("aria-posinset"),10)-1;
vendor: 23,803 bytes, lines 33-35
33if(isNaN(M))return console.warn("row is invalid. Race condition?"),null;const R=this._rowColumns.get(T);if(!R)return console.warn("columns is null. Race condition?"),null;let O=D<R.length?R[D]:R.slice(-1)[0]+1;return O>=this._terminal.cols&&(++M,O=0),{row:M,column:O}},C=k(x),y=k(w);if(C&&y){if(C.row>y.row||C.row===y.row&&C.column>=y.column)throw new Error("invalid range");this._terminal.select(C.column,C.row,(y.row-C.row)*this._terminal.cols-C.column+y.column)}}_handleResize(v){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>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_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 v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=g=c([h(1,b.IInstantiationService),h(2,_.ICoreBrowserService),h(3,_.IRenderService)],g)},3614:(a,o)=>{function l(d){return d.replace(/\r?\n/g,"\r")}function c(d,f){return f?"\x1B[200~"+d+"\x1B[201~":d}function h(d,f,_,b){d=c(d=l(d),_.decPrivateModes.bracketedPasteMode&&b.rawOptions.ignoreBracketedPasteMode!==!0),_.triggerDataEvent(d,!0),f.value=""}function u(d,f,_){const b=_.getBoundingClientRect(),p=d.clientX-b.left-10,g=d.clientY-b.top-10;f.style.width="20px",f.style.height="20px",f.style.left=`${p}px`,f.style.top=`${g}px`,f.style.zIndex="1000",f.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(d,f){d.clipboardData&&d.clipboardData.setData("text/plain",f.selectionText),d.preventDefault()},o.handlePasteEvent=function(d,f,_,b){d.stopPropagation(),d.clipboardData&&h(d.clipboardData.getData("text/plain"),f,_,b)},o.paste=h,o.moveTextAreaUnderMouseCursor=u,o.rightClickHandler=function(d,f,_,b,p){u(d,f,_),p&&b.rightClickSelect(d),f.value=b.selectionText,f.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(h,u,d){this._css.set(h,u,d)}getCss(h,u){return this._css.get(h,u)}setColor(h,u,d){this._color.set(h,u,d)}getColor(h,u){return this._color.get(h,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,h,u){l.addEventListener(c,h,u);let d=!1;return{dispose:()=>{d||(d=!0,l.removeEventListener(c,h,u))}}}},3551:function(a,o,l){var c=this&&this.__decorate||function(g,v,x,w){var S,k=arguments.length,C=k<3?v:w===null?w=Object.getOwnPropertyDescriptor(v,x):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(g,v,x,w);else for(var y=g.length-1;y>=0;y--)(S=g[y])&&(C=(k<3?S(C):k>3?S(v,x,C):S(v,x))||C);return k>3&&C&&Object.defineProperty(v,x,C),C},h=this&&this.__param||function(g,v){return function(x,w){v(x,w,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const u=l(3656),d=l(8460),f=l(844),_=l(2585),b=l(4725);let p=o.Linkifier=class extends f.Disposable{get currentLink(){return this._currentLink}constructor(g,v,x,w,S){super(),this._element=g,this._mouseService=v,this._renderService=x,this._bufferService=w,this._linkProviderService=S,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new d.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new d.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,f.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,f.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(g){this._lastMouseEvent=g;const v=this._positionFromMouseEvent(g,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const x=g.composedPath();for(let w=0;w<x.length;w++){const S=x[w];if(S.classList.contains("xterm"))break;if(S.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_handleHover(g){if(this._activeLine!==g.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(g,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,g)||(this._clearCurrentLink(),this._askForLink(g,!0))}_askForLink(g,v){this._activeProviderReplies&&v||(this._activeProviderReplies?.forEach(w=>{w?.forEach(S=>{S.link.dispose&&S.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=g.y);let x=!1;for(const[w,S]of this._linkProviderService.linkProviders.entries())v?this._activeProviderReplies?.get(w)&&(x=this._checkLinkProviderResult(w,g,x)):S.provideLinks(g.y,k=>{if(this._isMouseOut)return;const C=k?.map(y=>({link:y}));this._activeProviderReplies?.set(w,C),x=this._checkLinkProviderResult(w,g,x),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(g.y,this._activeProviderReplies)})}_removeIntersectingLinks(g,v){const x=new Set;for(let w=0;w<v.size;w++){const S=v.get(w);if(S)for(let k=0;k<S.length;k++){const C=S[k],y=C.link.range.start.y<g?0:C.link.range.start.x,E=C.link.range.end.y>g?this._bufferService.cols:C.link.range.end.x;for(let D=y;D<=E;D++){if(x.has(D)){S.splice(k--,1);break}x.add(D)}}}}_checkLinkProviderResult(g,v,x){if(!this._activeProviderReplies)return x;const w=this._activeProviderReplies.get(g);let S=!1;for(let k=0;k<g;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&w){const k=w.find(C=>this._linkAtPosition(C.link,v));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 C=this._activeProviderReplies.get(k)?.find(y=>this._linkAtPosition(y.link,v));if(C){x=!0,this._handleNewLink(C);break}}return x}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(g){if(!this._currentLink)return;const v=this._positionFromMouseEvent(g,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(g,this._currentLink.link.text)}_clearCurrentLink(g,v){this._currentLink&&this._lastMouseEvent&&(!g||!v||this._currentLink.link.range.start.y>=g&&this._currentLink.link.range.end.y<=v)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,f.disposeArray)(this._linkCacheDisposables))}_handleNewLink(g){if(!this._lastMouseEvent)return;const v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(g.link,v)&&(this._currentLink=g,this._currentLink.state={decorations:{underline:g.link.decorations===void 0||g.link.decorations.underline,pointerCursor:g.link.decorations===void 0||g.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,g.link,this._lastMouseEvent),g.link.decorations={},Object.defineProperties(g.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(g.link,x))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(x=>{if(!this._currentLink)return;const w=x.start===0?0:x.start+1+this._bufferService.buffer.ydisp,S=this._bufferService.buffer.ydisp+1+x.end;if(this._currentLink.link.range.start.y>=w&&this._currentLink.link.range.end.y<=S&&(this._clearCurrentLink(w,S),this._lastMouseEvent)){const k=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);k&&this._askForLink(k,!1)}})))}_linkHover(g,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&g.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(x,v.text)}_fireUnderlineEvent(g,v){const x=g.range,w=this._bufferService.buffer.ydisp,S=this._createLinkUnderlineEvent(x.start.x-1,x.start.y-w-1,x.end.x,x.end.y-w-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(S)}_linkLeave(g,v,x){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&g.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(x,v.text)}_linkAtPosition(g,v){const x=g.range.start.y*this._bufferService.cols+g.range.start.x,w=g.range.end.y*this._bufferService.cols+g.range.end.x,S=v.y*this._bufferService.cols+v.x;return x<=S&&S<=w}_positionFromMouseEvent(g,v,x){const w=x.getCoords(g,v,this._bufferService.cols,this._bufferService.rows);if(w)return{x:w[0],y:w[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(g,v,x,w,S){return{x1:g,y1:v,x2:x,y2:w,cols:this._bufferService.cols,fg:S}}};o.Linkifier=p=c([h(1,b.IMouseService),h(2,b.IRenderService),h(3,_.IBufferService),h(4,b.ILinkProviderService)],p)},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(b,p,g,v){var x,w=arguments.length,S=w<3?p:v===null?v=Object.getOwnPropertyDescriptor(p,g):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,p,g,v);else for(var k=b.length-1;k>=0;k--)(x=b[k])&&(S=(w<3?x(S):w>3?x(p,g,S):x(p,g))||S);return w>3&&S&&Object.defineProperty(p,g,S),S},h=this&&this.__param||function(b,p){return function(g,v){p(g,v,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const u=l(511),d=l(2585);let f=o.OscLinkProvider=class{constructor(b,p,g){this._bufferService=b,this._optionsService=p,this._oscLinkService=g}provideLinks(b,p){const g=this._bufferService.buffer.lines.get(b-1);if(!g)return void p(void 0);const v=[],x=this._optionsService.rawOptions.linkHandler,w=new u.CellData,S=g.getTrimmedLength();let k=-1,C=-1,y=!1;for(let E=0;E<S;E++)if(C!==-1||g.hasContent(E)){if(g.loadCell(E,w),w.hasExtendedAttrs()&&w.extended.urlId){if(C===-1){C=E,k=w.extended.urlId;continue}y=w.extended.urlId!==k}else C!==-1&&(y=!0);if(y||C!==-1&&E===S-1){const D=this._oscLinkService.getLinkData(k)?.uri;if(D){const T={start:{x:C+1,y:b},end:{x:E+(y||E!==S-1?0:1),y:b}};let M=!1;if(!x?.allowNonHttpProtocols)try{const R=new URL(D);["http:","https:"].includes(R.protocol)||(M=!0)}catch{M=!0}M||v.push({text:D,range:T,activate:(R,O)=>x?x.activate(R,O,T):_(0,O),hover:(R,O)=>x?.hover?.(R,O,T),leave:(R,O)=>x?.leave?.(R,O,T)})}y=!1,w.hasExtendedAttrs()&&w.extended.urlId?(C=E,k=w.extended.urlId):(C=-1,k=-1)}}p(v)}};function _(b,p){if(confirm(`Do you want to navigate to ${p}? 34 35WARNING: This link could potentially be dangerous`)){const g=window.open();if(g){try{g.opener=null}catch{}g.location.href=p}else console.warn("Opening link blocked as opener could not be cleared")}}o.OscLinkProvider=f=c([h(0,d.IBufferService),h(1,d.IOptionsService),h(2,d.IOscLinkService)],f)},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,h){this._rowCount=h,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),h=l(3656),u=l(3551),d=l(9042),f=l(3730),_=l(1680),b=l(3107),p=l(5744),g=l(2950),v=l(1296),x=l(428),w=l(4269),S=l(5114),k=l(8934),C=l(3230),y=l(9312),E=l(4725),D=l(6731),T=l(8055),M=l(8969),R=l(8460),O=l(844),$=l(6114),G=l(8437),V=l(2584),q=l(7399),L=l(5941),N=l(9074),I=l(2585),H=l(5435),W=l(4567),J=l(779);class Z extends M.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(F={}){super(F),this.browser=$,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new O.MutableDisposable),this._onCursorMove=this.register(new R.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new R.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new R.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new R.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new R.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new R.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new R.EventEmitter),this._onBlur=this.register(new R.EventEmitter),this._onA11yCharEmitter=this.register(new R.EventEmitter),this._onA11yTabEmitter=this.register(new R.EventEmitter),this._onWillOpen=this.register(new R.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(N.DecorationService),this._instantiationService.setService(I.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(J.LinkProviderService),this._instantiationService.setService(E.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(f.OscLinkProvider)),this.register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this.register(this._inputHandler.onRequestRefreshRows((P,j)=>this.refresh(P,j))),this.register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this.register(this._inputHandler.onRequestReset(()=>this.reset())),this.register(this._inputHandler.onRequestWindowsOptionsReport(P=>this._reportWindowsOptions(P))),this.register(this._inputHandler.onColor(P=>this._handleColorEvent(P))),this.register((0,R.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,R.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,R.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize(P=>this._afterResize(P.cols,P.rows))),this.register((0,O.toDisposable)(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}_handleColorEvent(F){if(this._themeService)for(const P of F){let j,B="";switch(P.index){case 256:j="foreground",B="10";break;case 257:j="background",B="11";break;case 258:j="cursor",B="12";break;default:j="ansi",B="4;"+P.index}switch(P.type){case 0:const K=T.color.toColorRGB(j==="ansi"?this._themeService.colors.ansi[P.index]:this._themeService.colors[j]);this.coreService.triggerDataEvent(`${V.C0.ESC}]${B};${(0,L.toRgbString)(K)}${V.C1_ESCAPED.ST}`);break;case 1:if(j==="ansi")this._themeService.modifyColors(U=>U.ansi[P.index]=T.channels.toColor(...P.color));else{const U=j;this._themeService.modifyColors(Y=>Y[U]=T.channels.toColor(...P.color))}break;case 2:this._themeService.restoreColor(P.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(F){F?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(W.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(F){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(V.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(V.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 F=this.buffer.ybase+this.buffer.y,P=this.buffer.lines.get(F);if(!P)return;const j=Math.min(this.buffer.x,this.cols-1),B=this._renderService.dimensions.css.cell.height,K=P.getWidth(j),U=this._renderService.dimensions.css.cell.width*K,Y=this.buffer.y*this._renderService.dimensions.css.cell.height,ee=j*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ee+"px",this.textarea.style.top=Y+"px",this.textarea.style.width=U+"px",this.textarea.style.height=B+"px",this.textarea.style.lineHeight=B+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,h.addDisposableDomListener)(this.element,"copy",P=>{this.hasSelection()&&(0,c.copyHandler)(P,this._selectionService)}));const F=P=>(0,c.handlePasteEvent)(P,this.textarea,this.coreService,this.optionsService);this.register((0,h.addDisposableDomListener)(this.textarea,"paste",F)),this.register((0,h.addDisposableDomListener)(this.element,"paste",F)),$.isFirefox?this.register((0,h.addDisposableDomListener)(this.element,"mousedown",P=>{P.button===2&&(0,c.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,h.addDisposableDomListener)(this.element,"contextmenu",P=>{(0,c.rightClickHandler)(P,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),$.isLinux&&this.register((0,h.addDisposableDomListener)(this.element,"auxclick",P=>{P.button===1&&(0,c.moveTextAreaUnderMouseCursor)(P,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,h.addDisposableDomListener)(this.textarea,"keyup",F=>this._keyUp(F),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keydown",F=>this._keyDown(F),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keypress",F=>this._keyPress(F),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionupdate",F=>this._compositionHelper.compositionupdate(F))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,h.addDisposableDomListener)(this.textarea,"input",F=>this._inputEvent(F),!0)),this.register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(F){if(!F)throw new Error("Terminal requires a parent element.");if(F.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=F.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"),F.appendChild(this.element);const P=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),P.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,h.addDisposableDomListener)(this.screenElement,"mousemove",j=>this.updateCursorStyle(j))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),P.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",d.promptLabel),$.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","fal
35se"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,F.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,h.addDisposableDomListener)(this.textarea,"focus",j=>this._handleTextAreaFocus(j))),this.register((0,h.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(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(D.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(w.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(C.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(j=>this._onRender.fire(j))),this.onResize(j=>this._renderService.resize(j.cols,j.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(g.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(u.Linkifier,this.screenElement)),this.element.appendChild(P);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(_.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines(j=>this.scrollLines(j.amount,j.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(y.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(j=>this.scrollLines(j.amount,j.suppressScrollEvent))),this.register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this.register(this._selectionService.onRequestRedraw(j=>this._renderService.handleSelectionChanged(j.start,j.end,j.columnSelectMode))),this.register(this._selectionService.onLinuxMouseSelection(j=>{this.textarea.value=j,this.textarea.focus(),this.textarea.select()}
35)),this.register(this._onScroll.event(j=>{this.viewport.syncScrollArea(),this._selectionService.refresh()})),this.register((0,h.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.register(this._instantiationService.createInstance(b.BufferDecorationRenderer,this.screenElement)),this.register((0,h.addDisposableDomListener)(this.element,"mousedown",j=>this._selectionService.handleMouseDown(j))),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(W.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",j=>this._handleScreenReaderModeOptionChange(j))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(p.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",j=>{!this._overviewRulerRenderer&&j&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(p.OverviewRulerRenderer,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(v.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const F=this,P=this.element;function j(U){const Y=F._mouseService.getMouseReportCoords(U,F.screenElement);if(!Y)return!1;let ee,ie;switch(U.overrideType||U.type){case"mousemove":ie=32,U.buttons===void 0?(ee=3,U.button!==void 0&&(ee=U.button<3?U.button:3)):ee=1&U.buttons?0:4&U.buttons?1:2&U.buttons?2:3;break;case"mouseup":ie=0,ee=U.button<3?U.button:3;break;case"mousedown":ie=1,ee=U.button<3?U.button:3;break;case"wheel":if(F._customWheelEventHandler&&F._customWheelEventHandler(U)===!1||F.viewport.getLinesScrolled(U)===0)return!1;ie=U.deltaY<0?0:1,ee=4;break;default:return!1}return!(ie===void 0||ee===void 0||ee>4)&&F.coreMouseService.triggerMouseEvent({col:Y.col,row:Y.row,x:Y.x,y:Y.y,button:ee,action:ie,ctrl:U.ctrlKey,alt:U.altKey,shift:U.shiftKey})}const B={mouseup:null,wheel:null,mousedrag:null,mousemove:null},K={mouseup:U=>(j(U),U.buttons||(this._document.removeEventListener("mouseup",B.mouseup),B.mousedrag&&this._document.removeEventListener("mousemove",B.mousedrag)),this.cancel(U)),wheel:U=>(j(U),this.cancel(U,!0)),mousedrag:U=>{U.buttons&&j(U)},mousemove:U=>{U.buttons||j(U)}};this.register(this.coreMouseService.onProtocolChange(U=>{U?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(U)),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&U?B.mousemove||(P.addEventListener("mousemove",K.mousemove),B.mousemove=K.mousemove):(P.removeEventListener("mousemove",B.mousemove),B.mousemove=null),16&U?B.wheel||(P.addEventListener("wheel",K.wheel,{passive:!1}),B.wheel=K.wheel):(P.removeEventListener("wheel",B.wheel),B.wheel=null),2&U?B.mouseup||(B.mouseup=K.mouseup):(this._document.removeEventListener("mouseup",B.mouseup),B.mouseup=null),4&U?B.mousedrag||(B.mousedrag=K.mousedrag):(this._document.removeEventListener("mousemove",B.mousedrag),B.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,h.addDisposableDomListener)(P,"mousedown",U=>{if(U.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(U))return j(U),B.mouseup&&this._document.addEventListener("mouseup",B.mouseup),B.mousedrag&&this._document.addEventListener("mousemove",B.mousedrag),this.cancel(U)})),this.register((0,h.addDisposableDomListener)(P,"wheel",U=>{if(!B.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(U)===!1)return!1;if(!this.buffer.hasScrollback){const Y=this.viewport.getLinesScrolled(U);if(Y===0)return;const ee=V.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(U.deltaY<0?"A":"B");let ie="";for(let le=0;le<Math.abs(Y);le++)ie+=ee;return this.coreService.triggerDataEvent(ie,!0),this.cancel(U,!0)}return this.viewport.handleWheel(U)?this.cancel(U):void 0}},{passive:!1})),this.register((0,h.addDisposableDomListener)(P,"touchstart",U=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(U),this.cancel(U)},{passive:!0})),this.register((0,h.addDisposableDomListener)(P,"touchmove",U=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(U)?void 0:this.cancel(U)},{passive:!1}))}refresh(F,P){this._renderService?.refreshRows(F,P)}updateCursorStyle(F){this._selectionService?.shouldColumnSelect(F)?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(F,P,j=0){j===1?(super.scrollLines(F,P,j),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(F)}paste(F){(0,c.paste)(F,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(F){this._customKeyEventHandler=F}attachCustomWheelEventHandler(F){this._customWheelEventHandler=F}registerLinkProvider(F){return this._linkProviderService.registerLinkProvider(F)}registerCharacterJoiner(F){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const P=this._characterJoinerService.register(F);return this.refresh(0,this.rows-1),P}deregisterCharacterJoiner(F){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(F)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(F){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+F)}registerDecoration(F){return this._decorationService.registerDecoration(F)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(F,P,j){this._selectionService.setSelection(F,P,j)}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(F,P){this._selectionService?.selectLines(F,P)}_keyDown(F){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(F)===!1)return!1;const P=this.browser.isMac&&this.options.macOptionIsMeta&&F.altKey;if(!P&&!this._compositionHelper.keydown(F))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;P||F.key!=="Dead"&&F.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const j=(0,q.evaluateKeyboardEvent)(F,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(F),j.type===3||j.type===2){const B=this.rows-1;return this.scrollLines(j.type===2?-B:B),this.cancel(F,!0)}return j.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,F)||(j.cancel&&this.cancel(F,!0),!j.key||!!(F.key&&!F.ctrlKey&&!F.altKey&&!F.metaKey&&F.key.length===1&&F.key.charCo
35deAt(0)>=65&&F.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(j.key!==V.C0.ETX&&j.key!==V.C0.CR||(this.textarea.value=""),this._onKey.fire({key:j.key,domEvent:F}),this._showCursor(),this.coreService.triggerDataEvent(j.key,!0),!this.optionsService.rawOptions.screenReaderMode||F.altKey||F.ctrlKey?this.cancel(F,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(F,P){const j=F.isMac&&!this.options.macOptionIsMeta&&P.altKey&&!P.ctrlKey&&!P.metaKey||F.isWindows&&P.altKey&&P.ctrlKey&&!P.metaKey||F.isWindows&&P.getModifierState("AltGraph");return P.type==="keypress"?j:j&&(!P.keyCode||P.keyCode>47)}_keyUp(F){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(F)===!1||(function(P){return P.keyCode===16||P.keyCode===17||P.keyCode===18}(F)||this.focus(),this.updateCursorStyle(F),this._keyPressHandled=!1)}_keyPress(F){let P;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(F)===!1)return!1;if(this.cancel(F),F.charCode)P=F.charCode;else if(F.which===null||F.which===void 0)P=F.keyCode;else{if(F.which===0||F.charCode===0)return!1;P=F.which}return!(!P||(F.altKey||F.ctrlKey||F.metaKey)&&!this._isThirdLevelShift(this.browser,F)||(P=String.fromCharCode(P),this._onKey.fire({key:P,domEvent:F}),this._showCursor(),this.coreService.triggerDataEvent(P,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(F){if(F.data&&F.inputType==="insertText"&&(!F.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const P=F.data;return this.coreService.triggerDataEvent(P,!0),this.cancel(F),!0}return!1}resize(F,P){F!==this.cols||P!==this.rows?super.resize(F,P):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(F,P){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 F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(G.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 F=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=F,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(V.C0.ESC+"[I"):this.coreService.triggerDataEvent(V.C0.ESC+"[O")}_reportWindowsOptions(F){if(this._renderService)switch(F){case H.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const P=this._renderService.dimensions.css.canvas.width.toFixed(0),j=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${V.C0.ESC}[4;${j};${P}t`);break;case H.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const B=this._renderService.dimensions.css.cell.width.toFixed(0),K=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${V.C0.ESC}[6;${K};${B}t`)}}cancel(F,P){if(this.options.cancelEvents||P)return F.preventDefault(),F.stopPropagation(),!1}}o.Terminal=Z},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,h){this._rowCount=h,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 d=u-this._lastRefreshMs,f=this._debounceThresholdMS-d;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},f)}}_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(g,v,x,w){var S,k=arguments.length,C=k<3?v:w===null?w=Object.getOwnPropertyDescriptor(v,x):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(g,v,x,w);else for(var y=g.length-1;y>=0;y--)(S=g[y])&&(C=(k<3?S(C):k>3?S(v,x,C):S(v,x))||C);return k>3&&C&&Object.defineProperty(v,x,C),C},h=this&&this.__param||function(g,v){return function(x,w){v(x,w,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Viewport=void 0;const u=l(3656),d=l(4725),f=l(8460),_=l(844),b=l(2585);let p=o.Viewport=class extends _.Disposable{constructor(g,v,x,w,S,k,C,y){super(),this._viewportElement=g,this._scrollArea=v,this._bufferService=x,this._optionsService=w,this._charSizeService=S,this._renderService=k,this._coreBrowserService=C,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHe
vendor: 4,253 bytes, line 35
35ight=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 f.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(E=>this._activeBuffer=E.activeBuffer)),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange(E=>this._renderDimensions=E)),this._handleThemeChange(y.colors),this.register(y.onChangeColors(E=>this._handleThemeChange(E))),this.register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.syncScrollArea())),setTimeout(()=>this.syncScrollArea())}_handleThemeChange(g){this._viewportElement.style.backgroundColor=g.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(g){if(g)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 v=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==v&&(this._lastRecordedBufferHeight=v,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const g=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==g&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=g),this._refreshAnimationFrame=null}syncScrollArea(g=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(g);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(g)}_handleScroll(g){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 v=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:v,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const g=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(g*(this._smoothScrollState.target-this._smoothScrollState.origin)),g<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(g,v){const x=this._viewportElement.scrollTop+this._lastRecordedViewportHe
35ight;return!(v<0&&this._viewportElement.scrollTop!==0||v>0&&x<this._lastRecordedBufferHeight)||(g.cancelable&&g.preventDefault(),!1)}handleWheel(g){const v=this._getPixelsScrolled(g);return v!==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+v:this._smoothScrollState.target+=v,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=v,this._bubbleScroll(g,v))}scrollLines(g){if(g!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const v=g*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+v,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:g,suppressScrollEvent:!1})}_getPixelsScrolled(g){if(g.deltaY===0||g.shiftKey)return 0;let v=this._applyScrollModifier(g.deltaY,g);return g.deltaMode===WheelEvent.DOM_DELTA_LINE?v*=this._currentRowHeight:g.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._currentRowHeight*this._bufferService.rows),v}getBufferElements(g,v){let x,w="";const S=[],k=v??this._bufferService.buffer.lines.length,C=this._bufferService.buffer.lines;for(let y=g;y<k;y++){const E=C.get(y);if(!E)continue;const D=C.get(y+1)?.isWrapped;if(w+=E.translateToString(!D),!D||y===C.length-1){const T=document.createElement("div");T.textContent=w,S.push(T),w.length>0&&(x=T),w=""}}return{bufferElements:S,cursorElement:x}}getLinesScrolled(g){if(g.deltaY===0||g.shiftKey)return 0;let v=this._applyScrollModifier(g.deltaY,g);return g.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(v/=this._currentRowHeight+0,this._wheelPartialScroll+=v,v=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):g.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._bufferService.rows),v}_applyScrollModifier(g,v){const x=this._optionsService.rawOptions.fastScrollModifier;return x==="alt"&&v.altKey||x==="ctrl"&&v.ctrlKey||x==="shift"&&v.shiftKey?g*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:g*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(g){this._lastTouchY=g.touches[0].pageY}handleTouchMove(g){const v=this._lastTouchY-g.touches[0].pageY;return this._lastTouchY=g.touches[0].pageY,v!==0&&(this._viewportElement.scrollTop+=v,this._bubbleScroll(g,v))}};o.Viewport=p=c([h(2,b.IBufferService),h(3,b.IOptionsService),h(4,d.ICharSizeService),h(5,d.IRenderService),h(6,d.ICoreBrowserService),h(7,d.IThemeService)],p)},3107:function(a,o,l){var c=this&&this.__decorate||function(b,p,g,v){var x,w=arguments.length,S=w<3?p:v===null?v=Object.getOwnPropertyDescriptor(p,g):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,p,g,v);else for(var k=b.length-1;k>=0;k--)(x=b[k])&&(S=(w<3?x(S):w>3?x(p,g,S):x(p,g))||S);return w>3&&S&&Object.defineProperty(p,g,S),S},h=this&&this.__param||function(b,p){return function(g,v){p(g,v,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferDecorationRenderer=void 0;const u=l(4725),d=l(844),f=l(2585);let _=o.BufferDecorationRenderer=class extends d.Disposable{constructor(b,p,g,v,x){super(),this._screenElement=b,this._bufferService=p,this._coreBrowserService=g,this._decorationService=v,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(()=>
vendor: 14,860 bytes, line 35
35this._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(w=>this._removeDecoration(w))),this.register((0,d.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 b of this._decorationService.decorations)this._renderDecoration(b);this._dimensionsChanged=!1}_renderDecoration(b){this._refreshStyle(b),this._dimensionsChanged&&this._refreshXPosition(b)}_createElement(b){const p=this._coreBrowserService.mainDocument.createElement("div");p.classList.add("xterm-decoration"),p.classList.toggle("xterm-decoration-top-layer",b?.options?.layer==="top"),p.style.width=`${Math.round((b.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,p.style.height=(b.options.height||1)*this._renderService.dimensions.css.cell.height+"px",p.style.top=(b.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",p.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const g=b.options.x??0;return g&&g>this._bufferService.cols&&(p.style.display="none"),this._refreshXPosition(b,p),p}_refreshStyle(b){const p=b.marker.line-this._bufferService.buffers.active.ydisp;if(p<0||p>=this._bufferService.rows)b.element&&(b.element.style.display="none",b.onRenderEmitter.fire(b.element));else{let g=this._decorationElements.get(b);g||(g=this._createElement(b),b.element=g,this._decorationElements.set(b,g),this._container.appendChild(g),b.onDispose(()=>{this._decorationElements.delete(b),g.remove()})),g.style.top=p*this._renderService.dimensions.css.cell.height+"px",g.style.display=this._altBufferIsActive?"none":"block",b.onRenderEmitter.fire(g)}}_refreshXPosition(b,p=b.element){if(!p)return;const g=b.options.x??0;(b.options.anchor||"left")==="right"?p.style.right=g?g*this._renderService.dimensions.css.cell.width+"px":"":p.style.left=g?g*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(b){this._decorationElements.get(b)?.remove(),this._decorationElements.delete(b),b.dispose()}};o.BufferDecorationRenderer=_=c([h(1,f.IBufferService),h(2,u.ICoreBrowserService),h(3,f.IDecorationService),h(4,u.IRenderService)],_)},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,h){return c>=l.startBufferLine-this._linePadding[h||"full"]&&c<=l.endBufferLine+this._linePadding[h||"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,w,S,k){var C,y=arguments.length,E=y<3?w:k===null?k=Object.getOwnPropertyDescriptor(w,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(x,w,S,k);else for(var D=x.length-1;D>=0;D--)(C=x[D])&&(E=(y<3?C(E):y>3?C(w,S,E):C(w,S))||E);return y>3&&E&&Object.defineProperty(w,S,E),E},h=this&&this.__param||function(x,w){return function(S,k){w(S,k,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OverviewRulerRenderer=void 0;const u=l(5871),d=l(4725),f=l(844),_=l(2585),b={full:0,left:0,center:0,right:0},p={full:0,left:0,center:0,right:0},g={full:0,left:0,center:0,right:0};let v=o.OverviewRulerRenderer=class extends f.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(x,w,S,k,C,y,E){super(),this._viewportElement=x,this._screenElement=w,this._bufferService=S,this._decorationService=k,this._renderService=C,this._optionsService=y,this._coreBrowserService=E,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 D=this._canvas.getContext("2d");if(!D)throw new Error("Ctx cannot be null");this._ctx=D,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,f.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),w=Math.ceil(this._canvas.width/3);p.full=this._canvas.width,p.left=x,p.center=w,p.right=x,this._refreshDrawHeightConstants(),g.full=0,g.left=0,g.center=p.left,g.right=p.left+p.center}_refreshDrawHeightConstants(){b.full=Math.round(2*this._coreBrowserService.dpr);const x=this._canvas.height/this._bufferService.buffer.lines.length,w=Math.round(Math.max(Math.min(x,12),6)*this._coreBrowserService.dpr);b.left=w,b.center=w,b.right=w}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*b.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 w of this._decorationService.decorations)this._colorZoneStore.addDecoration(w);this._ctx.lineWidth=1;const x=this._colorZoneStore.zones;for(const w of x)w.position!=="full"&&this._renderColorZone(w);for(const w of x)w.position==="full"&&this._renderColorZone(w);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(x){this._ctx.fillStyle=x.color,this._ctx.fillRect(g[x.position||"full"],Math.round((this._canvas.height-1)*(x.startBufferLine/this._bufferService.buffers.active.lines.length)-b[x.position||"full"]/2),p[x.position||"full"],Math.round((this._canvas.height-1)*((x.endBufferLine-x.startBufferLine)/this._bufferService.buffers.active.lines.length)+b[x.position||"full"]))}_queueRefresh(x,w){this._shouldUpdateDimensions=x||this._shouldUpdateDimensions,this._shouldUpdateAnchor=w||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};o.OverviewRulerRenderer=v=c([h(2,_.IBufferService),h(3,_.IDecorationService),h(4,d.IRenderService),h(5,_.IOptionsService),h(6,d.ICoreBrowserService)],v)},2950:function(a,o,l){var c=this&&this.__decorate||function(b,p,g,v){var x,w=arguments.length,S=w<3?p:v===null?v=Object.getOwnPropertyDescriptor(p,g):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(b,p,g,v);else for(var k=b.length-1;k>=0;k--)(x=b[k])&&(S=(w<3?x(S):w>3?x(p,g,S):x(p,g))||S);return w>3&&S&&Object.defineProperty(p,g,S),S},h=this&&this.__param||function(b,p){return function(g,v){p(g,v,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CompositionHelper=void 0;const u=l(4725),d=l(2585),f=l(2584);let _=o.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(b,p,g,v,x,w){this._textarea=b,this._compositionView=p,this._bufferService=g,this._optionsService=v,this._coreService=x,this._renderService=w,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(b){this._compositionView.textContent=b.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(b){if(this._isComposing||this._isSendingComposition){if(b.keyCode===229||b.keyCode===16||b.keyCode===17||b.keyCode===18)return!1;this._finalizeComposition(!1)}return b.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(b){if(this._compositionView.classList.remove("active"),this._isComposing=!1,b){const p={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let g;this._isSendingComposition=!1,p.start+=this._dataAlreadySent.length,g=this._isComposing?this._textarea.value.substring(p.start,p.end):this._textarea.value.substring(p.start),g.length>0&&this._coreService.triggerDataEvent(g,!0)}},0)}else{this._isSendingComposition=!1;const p=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(p,!0)}}_handleAnyTextareaChanges(){const b=this._textarea.value;setTimeout(()=>{if(!this._isComposing){const p=this._textarea.value,g=p.replace(b,"");this._dataAlreadySent=g,p.length>b.length?this._coreService.triggerDataEvent(g,!0):p.length<b.length?this._coreService.triggerDataEvent(`${f.C0.DEL}`,!0):p.length===b.length&&p!==b&&this._coreService.triggerDataEvent(p,!0)}},0)}updateCompositionElements(b){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const p=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),g=this._renderService.dimensions.css.cell.height,v=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,x=p*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=x+"px",this._compositionView.style.top=v+"px",this._compositionView.style.height=g+"px",this._compositionView.style.lineHeight=g+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const w=this._compositionView.getBoundingClientRect();this._textarea.style.left=x+"px",this._textarea.style.top=v+"px",this._textarea.style.width=Math.max(w.width,1)+"px",this._textarea.style.height=Math.max(w.height,1)+"px",this._textarea.style.lineHeight=w.height+"px"}b||setTimeout(()=>this.updateCompositionElements(!0),0)}}};o.CompositionHelper=_=c([h(2,d.IBufferService),h(3,d.IOptionsService),h(4,d.ICoreService),h(5,u.IRenderService)],_)},9806:(a,o)=>{function l(c,h,u){const d=u.getBoundingClientRect(),f=c.getComputedStyle(u),_=parseInt(f.getPropertyValue("padding-left")),b=parseInt(f.getPropertyValue("padding-top"));return[h.clientX-d.left-_,h.clientY-d.top-b]}Object.defineProperty(o,"__esModule",{value:!0}),o.getCoords=o.getCoordsRelativeToElement=void 0,o.getCoordsRelativeToElement=l,o.getCoords=function(c,h,u,d,f,_,b,p,g){if(!_)return;const v=l(c,h,u);return v?(v[0]=Math.ceil((v[0]+(g?b/2:0))/b),v[1]=Math.ceil(v[1]/p),v[0]=Math.min(Math.max(v[0],1),d+(g?1:0)),v[1]=Math.min(Math.max(v[1],1),f),v):void 0}},9504:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.moveToCellSequence=void 0;const c=l(2584);function h(p,g,v,x){const w=p-u(p,v),S=g-u(g,v),k=Math.abs(w-S)-function(C,y,E){let D=0;const T=C-u(C,E),M=y-u(y,E);for(let R=0;R<Math.abs(T-M);R++){const O=d(C,y)==="A"?-1:1;E.buffer.lines.get(T+O*R)?.isWrapped&&D++}return D}(p,g,v);return b(k,_(d(p,g),x))}function u(p,g){let v=0,x=g.buffer.lines.get(p),w=x?.isWrapped;for(;w&&p>=0&&p<g.rows;)v++,x=g.buffer.lines.get(--p),w=x?.isWrapped;return v}function d(p,g){return p>g?"A":"B"}function f(p,g,v,x,w,S){let k=p,C=g,y="";for(;k!==v||C!==x;)k+=w?1:-1,w&&k>
35S.cols-1?(y+=S.buffer.translateBufferLineToString(C,!1,p,k),k=0,p=0,C++):!w&&k<0&&(y+=S.buffer.translateBufferLineToString(C,!1,0,p+1),k=S.cols-1,p=k,C--);return y+S.buffer.translateBufferLineToString(C,!1,p,k)}function _(p,g){const v=g?"O":"[";return c.C0.ESC+v+p}function b(p,g){p=Math.floor(p);let v="";for(let x=0;x<p;x++)v+=g;return v}o.moveToCellSequence=function(p,g,v,x){const w=v.buffer.x,S=v.buffer.y;if(!v.buffer.hasScrollback)return function(y,E,D,T,M,R){return h(E,T,M,R).length===0?"":b(f(y,E,y,E-u(E,M),!1,M).length,_("D",R))}(w,S,0,g,v,x)+h(S,g,v,x)+function(y,E,D,T,M,R){let O;O=h(E,T,M,R).length>0?T-u(T,M):E;const $=T,G=function(V,q,L,N,I,H){let W;return W=h(L,N,I,H).length>0?N-u(N,I):q,V<L&&W<=N||V>=L&&W<N?"C":"D"}(y,E,D,T,M,R);return b(f(y,O,D,$,G==="C",M).length,_(G,R))}(w,S,p,g,v,x);let k;if(S===g)return k=w>p?"D":"C",b(Math.abs(w-p),_(k,x));k=S>g?"D":"C";const C=Math.abs(S-g);return b(function(y,E){return E.cols-y}(S>g?p:w,v)+(C-1)*v.cols+1+((S>g?w:p)-1),_(k,x))}},1296:function(a,o,l){var c=this&&this.__decorate||function(R,O,$,G){var V,q=arguments.length,L=q<3?O:G===null?G=Object.getOwnPropertyDescriptor(O,$):G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(R,O,$,G);else for(var N=R.length-1;N>=0;N--)(V=R[N])&&(L=(q<3?V(L):q>3?V(O,$,L):V(O,$))||L);return q>3&&L&&Object.defineProperty(O,$,L),L},h=this&&this.__param||function(R,O){return function($,G){O($,G,R)}};Object.defineProperty(o,"__esModule",{value:!0}),o.DomRenderer=void 0;const u=l(3787),d=l(2550),f=l(2223),_=l(6171),b=l(6052),p=l(4725),g=l(8055),v=l(8460),x=l(844),w=l(2585),S="xterm-dom-renderer-owner-",k="xterm-rows",C="xterm-fg-",y="xterm-bg-",E="xterm-focus",D="xterm-selection";let T=1,M=o.DomRenderer=class extends x.Disposable{constructor(R,O,$,G,V,q,L,N,I,H,W,J,Z){super(),this._terminal=R,this._document=O,this._element=$,this._screenElement=G,this._viewportElement=V,this._helperContainer=q,this._linkifier2=L,this._charSizeService=I,this._optionsService=H,this._bufferService=W,this._coreBrowserService=J,this._themeService=Z,this._terminalClass=T++,this._rowElements=[],this._selectionRenderModel=(0,b.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new v.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(D),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._themeService.onChangeColors(X=>this._injectCss(X))),this._injectCss(this._themeService.colors),this._rowFactory=N.createInstance(u.DomRendererRowFactory,document),this._element.classList.add(S+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(X=>this._handleLinkHover(X))),this.register(this._linkifier2.onHideLinkUnderline(X=>this._handleLinkLeave(X))),this.register((0,x.toDisposable)(()=>{this._element.classList.remove(S+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new d.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 R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),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.
vendor: 8,542 bytes, line 35
35canvas.width=Math.round(this.dimensions.device.canvas.width/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),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 $ of this._rowElements)$.style.width=`${this.dimensions.css.canvas.width}px`,$.style.height=`${this.dimensions.css.cell.height}px`,$.style.lineHeight=`${this.dimensions.css.cell.height}px`,$.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const O=`${this._terminalSelector} .${k} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=O,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(R){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let O=`${this._terminalSelector} .${k} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;O+=`${this._terminalSelector} .${k} .xterm-dim { color: ${g.color.multiplyOpacity(R.foreground,.5).css};}`,O+=`${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 $=`blink_underline_${this._terminalClass}`,G=`blink_bar_${this._terminalClass}`,V=`blink_block_${this._terminalClass}`;O+=`@keyframes ${$} { 50% { border-bottom-style: hidden; }}`,O+=`@keyframes ${G} { 50% { box-shadow: none; }}`,O+=`@keyframes ${V} { 0% { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css}; } 50% { background-color: inherit; color: ${R.cursor.css}; }}`,O+=`${this._terminalSelector} .${k}.${E} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${$} 1s step-end infinite;}${this._terminalSelector} .${k}.${E} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${G} 1s step-end infinite;}${this._terminalSelector} .${k}.${E} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${R.cursor.css} !important; color: ${R.cursorAccent.css} !important;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${k} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,O+=`${this._terminalSelector} .${D} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${D} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${D} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[q,L]of R.ansi.entries())O+=`${this._terminalSelector} .${C}${q} { color: ${L.css}; }${this._terminalSelector} .${C}${q}.xterm-dim { color: ${g.color.multiplyOpacity(L,.5).css}; }${this._terminalSelector} .${y}${q} { background-color: ${L.css}; }`;O+=`${this._terminalSelector} .${C}${f.INVERTED_DEFAULT_COLOR} { color: ${g.color.opaque(R.background).css}; }${this._terminalSelector} .${C}${f.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${g.color.multiplyOpacity(g.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${y}${f.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=O}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,O){for(let $=this._rowElements.length;$<=O;$++){const G=this._document.createElement("div");this._rowContainer.appendChild(G),this._rowElements.push(G)}for(;this._rowElements.length>O;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,O){this._refreshRowElements(R,O),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(E),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(E),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,O,$){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,O,$),this.renderRows(0,this._bufferService.rows-1),!R||!O)return;this._selectionRenderModel.update(this._terminal,R,O,$);const G=this._selectionRenderModel.viewportStartRow,V=this._selectionRenderModel.viewportEndRow,q=this._selectionRenderModel.viewportCappedStartRow,L=this._selectionRenderModel.viewportCappedEndRow;if(q>=this._bufferService.rows||L<0)return;const N=this._document.createDocumentFragment();if($){const I=R[0]>O[0];N.appendChild(this._createSelectionElement(q,I?O[0]:R[0],I?R[0]:O[0],L-q+1))}else{const I=G===q?R[0]:0,H=q===V?O[0]:this._bufferService.cols;N.appendChild(this._createSelectionElement(q,I,H));const W=L-q-1;if(N.appendChild(this._createSelectionElement(q+1,0,this._bufferService.cols,W)),q!==L){const J=V===L?O[0]:this._bufferService.cols;N.appendChild(this._createSelectionElement(L,0,J))}}this._selectionContainer.appendChild(N)}_createSelectionElement(R,O,$,G=1){const V=this._document.createElement("div"),q=O*this.dimensions.css.cell.width;let L=this.dimensions.css.cell.width*($-O);return q+L>this.dimensions.css.canvas.width&&(L=this.dimensions.css.canvas.width-q),V.style.height=G*this.dimensions.css.cell.height+"px",V.style.top=R*this.dimensions.css.cell.height+"px",V.style.left=`${q}px`,V.style.width=`${L}px`,V}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 R of this._rowElements)R.replaceChildren()}renderRows(R,O){const $=this._bufferService.buffer,G=$.ybase+$.y,V=Math.min($.x,this._bufferService.cols-1),q=this._optionsService.rawOptions.cursorBlink,L=this._optionsService.rawOptions.cursorStyle,N=this._optionsService.rawOptions.cursorInactiveStyle;for(let I=R;I<=O;I++){const H=I+$.ydisp,W=this._rowElements[I],J=$.lines.get(H);if(!W||!J)break;W.replaceChildren(...this._rowFactory.createRow(J,H,H===G,L,N,V,q,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${S}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,O,$,G,V,q){$<0&&(R=0),G<0&&(O=0);const L=this._bufferService.rows-1;$=Math.max(Math.min($,L),0),G=Math.max(Math.min(G,L),0),V=Math.min(V,this._bufferService.cols);const N=this._bufferService.buffer,I=N.ybase+N.y,H=Math.min(N.x,V-1),W=this._optionsService.rawOptions.cursorBlink,J=this._optionsService.rawOptions.cursorStyle,Z=this._optionsService.rawOptions.cursorInactiveStyle;for(let X=$;X<=G;++X){const F=X+N.ydisp,P=this._rowElements[X],j=N.lines.get(F);if(!P||!j)break;P.replaceChildren(...this._rowFactory.createRow(j,F,F===I,J,Z,H,W,this.dimensions.css.
35cell.width,this._widthCache,q?X===$?R:0:-1,q?(X===G?O:V)-1:-1))}}};o.DomRenderer=M=c([h(7,w.IInstantiationService),h(8,p.ICharSizeService),h(9,w.IOptionsService),h(10,w.IBufferService),h(11,p.ICoreBrowserService),h(12,p.IThemeService)],M)},3787:function(a,o,l){var c=this&&this.__decorate||function(k,C,y,E){var D,T=arguments.length,M=T<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,y):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(k,C,y,E);else for(var R=k.length-1;R>=0;R--)(D=k[R])&&(M=(T<3?D(M):T>3?D(C,y,M):D(C,y))||M);return T>3&&M&&Object.defineProperty(C,y,M),M},h=this&&this.__param||function(k,C){return function(y,E){C(y,E,k)}};Object.defineProperty(o,"__esModule",{value:!0}),o.DomRendererRowFactory=void 0;const u=l(2223),d=l(643),f=l(511),_=l(2585),b=l(8055),p=l(4725),g=l(4269),v=l(6171),x=l(3734);let w=o.DomRendererRowFactory=class{constructor(k,C,y,E,D,T,M){this._document=k,this._characterJoinerService=C,this._optionsService=y,this._coreBrowserService=E,this._coreService=D,this._decorationService=T,this._themeService=M,this._workCell=new f.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,C,y){this._selectionStart=k,this._selectionEnd=C,this._columnSelectMode=y}createRow(k,C,y,E,D,T,M,R,O,$,G){const V=[],q=this._characterJoinerService.getJoinedCharacters(C),L=this._themeService.colors;let N,I=k.getNoBgTrimmedLength();y&&I<T+1&&(I=T+1);let H=0,W="",J=0,Z=0,X=0,F=!1,P=0,j=!1,B=0;const K=[],U=$!==-1&&G!==-1;for(let Y=0;Y<I;Y++){k.loadCell(Y,this._workCell);let ee=this._workCell.getWidth();if(ee===0)continue;let ie=!1,le=Y,ne=this._workCell;if(q.length>0&&Y===q[0][0]){ie=!0;const $e=q.shift();ne=new g.JoinedCellData(this._workCell,k.translateToString(!0,$e[0],$e[1]),$e[1]-$e[0]),le=$e[1]-1,ee=ne.getWidth()}const re=this._isCellInSelection(Y,C),me=y&&Y===T,pe=U&&Y>=$&&Y<=G;let se=!1;this._decorationService.forEachDecorationAtCell(Y,C,void 0,$e=>{se=!0});let ge=ne.getChars()||d.WHITESPACE_CELL_CHAR;if(ge===" "&&(ne.isUnderline()||ne.isOverline())&&(ge="Â "),B=ee*R-O.get(ge,ne.isBold(),ne.isItalic()),N){if(H&&(re&&j||!re&&!j&&ne.bg===J)&&(re&&j&&L.selectionForeground||ne.fg===Z)&&ne.extended.ext===X&&pe===F&&B===P&&!me&&!ie&&!se){ne.isInvisible()?W+=d.WHITESPACE_CELL_CHAR:W+=ge,H++;continue}H&&(N.textContent=W),N=this._document.createElement("span"),H=0,W=""}else N=this._document.createElement("span");if(J=ne.bg,Z=ne.fg,X=ne.extended.ext,F=pe,P=B,j=re,ie&&T>=Y&&T<=le&&(T=Y),!this._coreService.isCursorHidden&&me&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&K.push("xterm-cursor-blink"),K.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(D)switch(D){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline")}}if(ne.isBold()&&K.push("xterm-bold"),ne.isItalic()&&K.push("xterm-italic"),ne.isDim()&&K.push("xterm-dim"),W=ne.isInvisible()?d.WHITESPACE_CELL_CHAR:ne.getChars()||d.WHITESPACE_CELL_CHAR,ne.isUnderline()&&(K.push(`xterm-underline-${ne.extended.underlineStyle}`),W===" "&&(W="Â "),!ne.isUnderlineColorDefault()))if(ne.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${x.AttributeData.toColorRGB(ne.getUnderlineColor()).join(",")})`;else{let $e=ne.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ne.isBold()&&$e<8&&($e+=8),N.style.textDecorationColor=L.ansi[$e].css}ne.isOverline()&&(K.push("xterm-overline"),W===" "&&(W="Â ")),ne.isStrikethrough()&&K.push("xterm-strikethrough"),pe&&(N.style.textDecoration="underline");let Ee=ne.getFgColor(),Ce=ne.getFgColorMode(),_e=ne.getBgColor(),Fe=ne.getBgColorMode();const Ke=!!ne.isInverse();if(Ke){const $e=Ee;Ee=_e,_e=$e;const ki=Ce;Ce=Fe,Fe=ki}let Le,Qe,Xe,yt=!1;switch(this._decorationService.forEachDecorationAtCell(Y,C,void 0,$e=>{$e.options.layer!=="top"&&yt||($e.backgroundColorRGB&&(Fe=50331648,_e=$e.backgroundColorRGB.rgba>>8&16777215,Le=$e.backgroundColorRGB),$e.foregroundColorRGB&&(Ce=50331648,Ee=$e.foregroundColorRGB.rgba>>8&16777215,Qe=$e.foregroundColorRGB),yt=$e.options.layer==="top")}),!yt&&re&&(Le=this._coreBrowserService.isFocused?L.selectionBackgroun
vendor: 4,370 bytes, line 35
35dOpaque:L.selectionInactiveBackgroundOpaque,_e=Le.rgba>>8&16777215,Fe=50331648,yt=!0,L.selectionForeground&&(Ce=50331648,Ee=L.selectionForeground.rgba>>8&16777215,Qe=L.selectionForeground)),yt&&K.push("xterm-decoration-top"),Fe){case 16777216:case 33554432:Xe=L.ansi[_e],K.push(`xterm-bg-${_e}`);break;case 50331648:Xe=b.channels.toColor(_e>>16,_e>>8&255,255&_e),this._addStyle(N,`background-color:#${S((_e>>>0).toString(16),"0",6)}`);break;default:Ke?(Xe=L.foreground,K.push(`xterm-bg-${u.INVERTED_DEFAULT_COLOR}`)):Xe=L.background}switch(Le||ne.isDim()&&(Le=b.color.multiplyOpacity(Xe,.5)),Ce){case 16777216:case 33554432:ne.isBold()&&Ee<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ee+=8),this._applyMinimumContrast(N,Xe,L.ansi[Ee],ne,Le,void 0)||K.push(`xterm-fg-${Ee}`);break;case 50331648:const $e=b.channels.toColor(Ee>>16&255,Ee>>8&255,255&Ee);this._applyMinimumContrast(N,Xe,$e,ne,Le,Qe)||this._addStyle(N,`color:#${S(Ee.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(N,Xe,L.foreground,ne,Le,Qe)||Ke&&K.push(`xterm-fg-${u.INVERTED_DEFAULT_COLOR}`)}K.length&&(N.className=K.join(" "),K.length=0),me||ie||se?N.textContent=W:H++,B!==this.defaultSpacing&&(N.style.letterSpacing=`${B}px`),V.push(N),Y=le}return N&&H&&(N.textContent=W),V}_applyMinimumContrast(k,C,y,E,D,T){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,v.treatGlyphAsBackgroundColor)(E.getCode()))return!1;const M=this._getContrastCache(E);let R;if(D||T||(R=M.getColor(C.rgba,y.rgba)),R===void 0){const O=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);R=b.color.ensureContrastRatio(D||C,T||y,O),M.setColor((D||C).rgba,(T||y).rgba,R??null)}return!!R&&(this._addStyle(k,`color:${R.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,C){k.setAttribute("style",`${k.getAttribute("style")||""}${C};`)}_isCellInSelection(k,C){const y=this._selectionStart,E=this._selectionEnd;return!(!y||!E)&&(this._columnSelectMode?y[0]<=E[0]?k>=y[0]&&C>=y[1]&&k<E[0]&&C<=E[1]:k<y[0]&&C>=y[1]&&k>=E[0]&&C<=E[1]:C>y[1]&&C<E[1]||y[1]===E[1]&&C===y[1]&&k>=y[0]&&k<E[0]||y[1]<E[1]&&C===E[1]&&k<E[0]||y[1]<E[1]&&C===y[1]&&k>=y[0])}};function S(k,C,y){for(;k.length<y;)k=C+k;return k}o.DomRendererRowFactory=w=c([h(1,p.ICharacterJoinerService),h(2,_.IOptionsService),h(3,p.ICoreBrowserService),h(4,_.ICoreService),h(5,_.IDecorationService),h(6,p.IThemeService)],w)},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 h=l.createElement("span");h.classList.add("xterm-char-measure-element");const u=l.createElement("span");u.classList.add("xterm-char-measure-element"),u.style.fontWeight="bold";const d=l.createElement("span");d.classList.add("xterm-char-measure-element"),d.style.fontStyle="italic";const f=l.createElement("span");f.classList.add("xterm-char-measure-element"),f.style.fontWeight="bold",f.style.fontStyle="italic",this._measureElements=[h,u,d,f],this._container.appendChild(h),this._container.appendChild(u),this._container.appendChild(d),this._container.appendChild(f),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,h,u){l===this._font&&c===this._fontSize&&h===this._weight&&u===this._weightBold||(this._font=l,this._fontSize=c,this._weight=h,this._weightBold=u,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${h}`,this._measureElements[1].style.fontWeight=`${u}`,this._measureElements[2].style.fontWeight=`${h}`,this._measureElements[3].style.fontWeight=`${u}`,this.clear())}get(l,c,h){let u=0;if(!c&&!h&&l.length===1&&(u=l.charCodeAt(0))<256){if(this._flat[u]!==-9999)return this._flat[u];const _=this._measure(l,0);return _>0&&(this._flat[u]=_),_}let d=l;
vendor: 5,049 bytes, line 35
35c&&(d+="B"),h&&(d+="I");let f=this._holey.get(d);if(f===void 0){let _=0;c&&(_|=1),h&&(_|=2),f=this._measure(l,_),f>0&&this._holey.set(d,f)}return f}_measure(l,c){const h=this._measureElements[c];return h.textContent=l.repeat(32),h.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(h){return 57508<=h&&h<=57558}function c(h){return h>=128512&&h<=128591||h>=127744&&h<=128511||h>=128640&&h<=128767||h>=9728&&h<=9983||h>=9984&&h<=10175||h>=65024&&h<=65039||h>=129280&&h<=129535||h>=127462&&h<=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(h){if(!h)throw new Error("value must not be falsy");return h},o.isPowerlineGlyph=l,o.isRestrictedPowerlineGlyph=function(h){return 57520<=h&&h<=57527},o.isEmoji=c,o.allowRescaling=function(h,u,d,f){return u===1&&d>Math.ceil(1.5*f)&&h!==void 0&&h>255&&!c(h)&&!l(h)&&!function(_){return 57344<=_&&_<=63743}(h)},o.treatGlyphAsBackgroundColor=function(h){return l(h)||function(u){return 9472<=u&&u<=9631}(h)},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(h,u,d=0){return(h-(2*Math.round(u)-d))%(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(h,u,d,f=!1){if(this.selectionStart=u,this.selectionEnd=d,!u||!d||u[0]===d[0]&&u[1]===d[1])return void this.clear();const _=h.buffers.active.ydisp,b=u[1]-_,p=d[1]-_,g=Math.max(b,0),v=Math.min(p,h.rows-1);g>=h.rows||v<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=f,this.viewportStartRow=b,this.viewportEndRow=p,this.viewportCappedStartRow=g,this.viewportCappedEndRow=v,this.startCol=u[0],this.endCol=d[0])}isCellSelected(h,u,d){return!!this.hasSelection&&(d-=h.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?u>=this.startCol&&d>=this.viewportCappedStartRow&&u<this.endCol&&d<=this.viewportCappedEndRow:u<this.startCol&&d>=this.viewportCappedStartRow&&u>=this.endCol&&d<=this.viewportCappedEndRow:d>this.viewportStartRow&&d<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&d===this.viewportStartRow&&u>=this.startCol&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&d===this.viewportEndRow&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&d===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(v,x,w,S){var k,
vendor: 9,897 bytes, line 35
35C=arguments.length,y=C<3?x:S===null?S=Object.getOwnPropertyDescriptor(x,w):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,x,w,S);else for(var E=v.length-1;E>=0;E--)(k=v[E])&&(y=(C<3?k(y):C>3?k(x,w,y):k(x,w))||y);return C>3&&y&&Object.defineProperty(x,w,y),y},h=this&&this.__param||function(v,x){return function(w,S){x(w,S,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CharSizeService=void 0;const u=l(2585),d=l(8460),f=l(844);let _=o.CharSizeService=class extends f.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(v,x,w){super(),this._optionsService=w,this.width=0,this.height=0,this._onCharSizeChange=this.register(new d.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new g(this._optionsService))}catch{this._measureStrategy=this.register(new p(v,x,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}measure(){const v=this._measureStrategy.measure();v.width===this.width&&v.height===this.height||(this.width=v.width,this.height=v.height,this._onCharSizeChange.fire())}};o.CharSizeService=_=c([h(2,u.IOptionsService)],_);class b extends f.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(x,w){x!==void 0&&x>0&&w!==void 0&&w>0&&(this._result.width=x,this._result.height=w)}}class p extends b{constructor(x,w,S){super(),this._document=x,this._parentElement=w,this._optionsService=S,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 g extends b{constructor(x){super(),this._optionsService=x,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const w=this._ctx.measureText("W");if(!("width"in w&&"fontBoundingBoxAscent"in w&&"fontBoundingBoxDescent"in w))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(g,v,x,w){var S,k=arguments.length,C=k<3?v:w===null?w=Object.getOwnPropertyDescriptor(v,x):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(g,v,x,w);else for(var y=g.length-1;y>=0;y--)(S=g[y])&&(C=(k<3?S(C):k>3?S(v,x,C):S(v,x))||C);return k>3&&C&&Object.defineProperty(v,x,C),C},h=this&&this.__param||function(g,v){return function(x,w){v(x,w,g)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CharacterJoinerService=o.JoinedCellData=void 0;const u=l(3734),d=l(643),f=l(511),_=l(2585);class b extends u.AttributeData{constructor(v,x,w){super(),this.content=0,this.combinedData="",this.fg=v.fg,this.bg=v.bg,this.combinedData=x,this._width=w}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(v){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.JoinedCellData=b;let p=o.CharacterJoinerService=class CS{constructor(v){this._bufferService=v,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new f.CellData}register(v){const x={id:this._nextCharacterJoinerId++,handler:v};return this._characterJoiners.push(x),x.id}deregister(v){for(let x=0;x<this._characterJoiners.length;x++)if(this._characterJoiners[x].id===v)return this._characterJoiners.splice(x,1),!0;return!1}getJoinedCharacters(v){if(this._characterJoiners.length===0)return[];const x=this._bufferService.buffer.lines.get(v);if(!x||x.length===0)return[];const w=[],S=x.translateToString(!0);let k=0,C=0,y=0,E=x.getFg(0),D=x.getBg(0);for(let T=0;T<x.getTrimmedLength();T++)if(x.loadCell(T,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==D){if(T-k>1){const M=this._getJoinedRanges(S,y,C,x,k);for(let R=0;R<M.length;R++)w.push(M[R])}k=T,y=C,E=this._workCell.fg,D=this._workCell.bg}C+=this._workCell.getChars().length||d.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const T=this._getJoinedRanges(S,y,C,x,k);for(let M=0;M<T.length;M++)w.push(T[M])}return w}_getJoinedRanges(v,x,w,S,k){const C=v.substring(x,w);let y=[];try{y=this._characterJoiners[0].handler(C)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const D=this._characterJoiners[E].handler(C);for(let T=0;T<D.length;T++)CS._mergeRanges(y,D[T])}catch(D){console.error(D)}return this._stringRangesToCellRanges(y,S,k),y}_stringRangesToCellRanges(v,x,w){let S=0,k=!1,C=0,y=v[S];if(y){for(let E=w;E<this._bufferService.cols;E++){const D=x.getWidth(E),T=x.getString(E).length||d.WHITESPACE_CELL_CHAR.length;if(D!==0){if(!k&&y[0]<=C&&(y[0]=E,k=!0),y[1]<=C){if(y[1]=E,y=v[++S],!y)break;y[0]<=C?(y[0]=E,k=!0):k=!1}C+=T}}y&&(y[1]=this._bufferService.cols)}}static _mergeRanges(v,x){let w=!1;for(let S=0;S<v.length;S++){const k=v[S];if(w){if(x[1]<=k[0])return v[S-1][1]=x[1],v;if(x[1]<=k[1])return v[S-1][1]=Math.max(x[1],k[1]),v.splice(S,1),v;v.splice(S,1),S--}else{if(x[1]<=k[0])return v.splice(S,0,x),v;if(x[1]<=k[1])return k[0]=Math.min(x[0],k[0]),v;x[0]<k[1]&&(k[0]=Math.min(x[0],k[0]),w=!0)}}return w?v[v.length-1][1]=x[1]:v.push(x),v}};o.CharacterJoinerService=p=c([h(0,_.IBufferService)],p)},5114:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreBrowserService=void 0;const c=l(844),h=l(8460),u=l(3656);class d extends c.Disposable{constructor(b,p,g){super(),this._textarea=b,this._window=p,this.mainDocument=g,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new f(this._window),this._onDprChange=this.register(new h.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new h.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange(v=>this._screenDprMonitor.setWindow(v))),this.register((0,h.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(b){this._window!==b&&(this._window=b,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=d;class f extends c.Disposable{constructor(b){super(),this._parentWindow=b,this._windowResizeListener=this.register(new c.MutableDisposable),this._onDprChange=this.register(new h.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(b){this._parentWindow=b,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 h extends c.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,c.toDisposable)(()=>this.linkProviders.length=0))}registerLinkProvider(d){return this.linkProviders.push(d),{dispose:()=>{const f=this.linkProviders.indexOf(d);f!==-1&&this.linkProviders.splice(f,1)}}}}o.LinkProviderService=h},8934:function(a,o,l){var c=this&&this.__decorate||function(_,b,p,g){var v,x=arguments.length,w=x<3?b:g===null?g=Object.getOwnPropertyDescriptor(b,p):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(_,b,p,g);else for(var S=_.length-1;S>=0;S--)(v=_[S])&&(w=(x<3?v(w):x>3?v(b,p,w):v(b,p))||w);return x>3&&w&&Object.defineProperty(b,p,w),w},h=this&&this.__param||function(_,b){return function(p,g){b(p,g,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.MouseService=void 0;const u=l(4725),d=l(9806);let f=o.MouseService=class{constructor(_,b){this._renderService=_,this._charSizeService=b}getCoords(_,b,p,g,v){return(0,d.getCoords)(window,_,b,p,g,this._charSizeService.hasValidSize,this._renderService.dimensions.css.
35cell.width,this._renderService.dimensions.css.cell.height,v)}getMouseReportCoords(_,b){const p=(0,d.getCoordsRelativeToElement)(window,_,b);if(this._charSizeService.hasValidSize)return p[0]=Math.min(Math.max(p[0],0),this._renderService.dimensions.css.canvas.width-1),p[1]=Math.min(Math.max(p[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(p[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(p[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(p[0]),y:Math.floor(p[1])}}};o.MouseService=f=c([h(0,u.IRenderService),h(1,u.ICharSizeService)],f)},3230:function(a,o,l){var c=this&&this.__decorate||function(v,x,w,S){var k,C=arguments.length,y=C<3?x:S===null?S=Object.getOwnPropertyDescriptor(x,w):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,x,w,S);else for(var E=v.length-1;E>=0;E--)(k=v[E])&&(y=(C<3?k(y):C>3?k(x,w,y):k(x,w))||y);return C>3&&y&&Object.defineProperty(x,w,y),y},h=this&&this.__param||function(v,x){return function(w,S){x(w,S,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.RenderService=void 0;const u=l(6193),d=l(4725),f=l(8460),_=l(844),b=l(7226),p=l(2585);let g=o.RenderService=class extends _.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(v,x,w,S,k,C,y,E){super(),this._rowCount=v,this._charSizeService=S,this._renderer=this.register(new _.MutableDisposable),this._pausedResizeTask=new b.DebouncedIdleTask,this._observerDisposable=this.register(new _.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 f.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new f.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new f.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new f.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new u.RenderDebouncer((D,T)=>this._renderRows(D,T),y),this.register(this._renderDebouncer),this.register(y.onDprChange(()=>this.handleDevicePixelRatioChange())),this.register(C.onResize(()=>
vendor: 7,564 bytes, lines 35-37
35this._fullRefresh())),this.register(C.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this.register(w.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this.register(k.onDecorationRegistered(()=>this._fullRefresh())),this.register(k.onDecorationRemoved(()=>this._fullRefresh())),this.register(w.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(C.cols,C.rows),this._fullRefresh()})),this.register(w.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(C.buffer.y,C.buffer.y,!0))),this.register(E.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(y.window,x),this.register(y.onWindowChange(D=>this._registerIntersectionObserver(D,x)))}_registerIntersectionObserver(v,x){if("IntersectionObserver"in v){const w=new v.IntersectionObserver(S=>this._handleIntersectionChange(S[S.length-1]),{threshold:0});w.observe(x),this._observerDisposable.value=(0,_.toDisposable)(()=>w.disconnect())}}_handleIntersectionChange(v){this._isPaused=v.isIntersecting===void 0?v.intersectionRatio===0:!v.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(v,x,w=!1){this._isPaused?this._needsFullRefresh=!0:(w||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(v,x,this._rowCount))}_renderRows(v,x){this._renderer.value&&(v=Math.min(v,this._rowCount-1),x=Math.min(x,this._rowCount-1),this._renderer.value.renderRows(v,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:v,end:x}),this._onRender.fire({start:v,end:x}),this._isNextRenderRedrawOnly=!0)}resize(v,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(v){this._renderer.value=v,this._renderer.value&&(this._renderer.value.onRequestRedraw(x=>this.refreshRows(x.start,x.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(v){return this._renderDebouncer.addRefreshCallback(v)}_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(v,x){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(v,x)):this._renderer.value.handleResize(v,x),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(v,x,w){this._selectionState.start=v,this._selectionState.end=x,this._selectionState.columnSelectMode=w,this._renderer.value?.handleSelectionChanged(v,x,w)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};o.RenderService=g=c([h(2,p.IOptionsService),h(3,d.ICharSizeService),h(4,p.IDecorationService),h(5,p.IBufferService),h(6,d.ICoreBrowserService),h(7,d.IThemeService)],g)},9312:function(a,o,l){var c=this&&this.__decorate||function(y,E,D,T){var M,R=arguments.length,O=R<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,D):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(y,E,D,T);else for(var $=y.length-1;$>=0;$--)(M=y[$])&&(O=(R<3?M(O):R>3?M(E,D,O):M(E,D))||O);return R>3&&O&&Object.defineProperty(E,D,O),O},h=this&&this.__param||function(y,E){return function(D,T){E(D,T,y)}};Object.defineProperty(o,"__esModule",{value:!0}),o.SelectionService=void 0;const u=l(9806),d=l(9504),f=l(456),_=l(4725),b=l(8460),p=l(844),g=l(6114),v=l(4841),x=l(511),w=l(2585),S="Â ",k=new RegExp(S,"g");let C=o.SelectionService=class extends p.Disposable{constructor(y,E,D,T,M,R,O,$,G){super(),this._element=y,this._screenElement=E,this._linkifier=D,this._bufferService=T,this._coreService=M,this._mouseService=R,this._optionsService=O,this._renderService=$,this._coreBrowserService=G,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 b.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new b.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new b.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=V=>this._handleMouseMove(V),this._mouseUpListener=V=>this._handleMouseUp(V),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(V=>this._handleTrim(V)),this.register(this._bufferService.buffers.onBufferActivate(V=>this._handleBufferActivate(V))),this.enable(),this._model=new f.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,p.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 y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!y||!E||y[0]===E[0]&&y[1]===E[1])}get selectionText(){const y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!y||!E)return"";const D=this._bufferService.buffer,T=[];if(this._activeSelectionMode===3){if(y[0]===E[0])return"";const M=y[0]<E[0]?y[0]:E[0],R=y[0]<E[0]?E[0]:y[0];for(let O=y[1];O<=E[1];O++){const $=D.translateBufferLineToString(O,!0,M,R);T.push($)}}else{const M=y[1]===E[1]?E[0]:void 0;T.push(D.translateBufferLineToString(y[1],!0,y[0],M));for(let R=y[1]+1;R<=E[1]-1;R++){const O=D.lines.get(R),$=D.translateBufferLineToString(R,!0);O?.isWrapped?T[T.length-1]+=$:T.push($)}if(y[1]!==E[1]){const R=D.lines.get(E[1]),O=D.translateBufferLineToString(E[1],!0,0,E[0]);R&&R.isWrapped?T[T.length-1]+=O:T.push(O)}}return T.map(M=>M.replace(k," ")).join(g.isWindows?`\r 36`:` 37`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(y){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>
vendor: 5,279 bytes, line 37
37this._refresh())),g.isLinux&&y&&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(y){const E=this._getMouseBufferCoords(y),D=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!!(D&&T&&E)&&this._areCoordsInSelection(E,D,T)}isCellInSelection(y,E){const D=this._model.finalSelectionStart,T=this._model.finalSelectionEnd;return!(!D||!T)&&this._areCoordsInSelection([y,E],D,T)}_areCoordsInSelection(y,E,D){return y[1]>E[1]&&y[1]<D[1]||E[1]===D[1]&&y[1]===E[1]&&y[0]>=E[0]&&y[0]<D[0]||E[1]<D[1]&&y[1]===D[1]&&y[0]<D[0]||E[1]<D[1]&&y[1]===E[1]&&y[0]>=E[0]}_selectWordAtCursor(y,E){const D=this._linkifier.currentLink?.link?.range;if(D)return this._model.selectionStart=[D.start.x-1,D.start.y-1],this._model.selectionStartLength=(0,v.getRangeLength)(D,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const T=this._getMouseBufferCoords(y);return!!T&&(this._selectWordAt(T,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(y,E){this._model.clearSelection(),y=Math.max(y,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,y],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(y){this._model.handleTrim(y)&&this.refresh()}_getMouseBufferCoords(y){const E=this._mouseService.getCoords(y,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(y){let E=(0,u.getCoordsRelativeToElement)(this._coreBrowserService.window,y,this._screenElement)[1];const D=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=D?0:(E>D&&(E-=D),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(y){return g.isMac?y.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:y.shiftKey}handleMouseDown(y){if(this._mouseDownTimeStamp=y.timeStamp,(y.button!==2||!this.hasSelection)&&y.button===0){if(!this._enabled){if(!this.shouldForceSelection(y))return;y.stopPropagation()}y.preventDefault(),this._dragScrollAmount=0,this._enabled&&y.shiftKey?this._handleIncrementalClick(y):y.detail===1?this._handleSingleClick(y):y.detail===2?this._handleDoubleClick(y):y.detail===3&&this._handleTripleClick(y),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(y){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(y))}_handleSingleClick(y){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(y)?3:0,this._model.selectionStart=this._getMouseBufferCoords(y),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const E=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);E&&E.length!==this._model.selectionStart[0]&&E.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(y){this._selectWordAtCursor(y,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(y){const E=this._getMouseBufferCoords(y);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(y){return y.altKey&&!(g.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(y){if(y.stopImmediatePropagation(),!this._model.selectionStart)return;const E=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(y),!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(y),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const D=this._bufferService.buffer;if(this._model.selectionEnd[1]<D.lines.length){const T=D.lines.get(this._model.selectionEnd[1]);T&&T.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}
37E&&E[0]===this._model.selectionEnd[0]&&E[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 y=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(y.ydisp+this._bufferService.rows,y.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=y.ydisp),this.refresh()}}_handleMouseUp(y){const E=y.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&y.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const D=this._mouseService.getCoords(y,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(D&&D[0]!==void 0&&D[1]!==void 0){const T=(0,d.moveToCellSequence)(D[0]-1,D[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(T,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,D=!(!y||!E||y[0]===E[0]&&y[1]===E[1]);D?y&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&y[0]===this._oldSelectionStart[0]&&y[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(y,E,D)):this._oldHasSelection&&this._fireOnSelectionChange(y,E,D)}_fireOnSelectionChange(y,E,D){this._oldSelectionStart=y,this._oldSelectionEnd=E,this._oldHasSelection=D,this._onSelectionChange.fire()}_handleBufferActivate(y){this.clearSelection(),this._trimListener.dispose(),this._trimListener=y.activeBuffer.lines.onTrim(E=>this._handleTrim(E))}_convertViewportColToCharacterIndex(y,E){let D=E;for(let T=0;E>=T;T++){const M=y.loadCell(T,this._workCell).getChars().length;this._workCell.getWidth()===0?D--:M>1&&E!==T&&(D+=M-1)}return D}setSelection(y,E,D){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[y,E],this._model.selectionStartLength=D,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(y){this._isClickInSelection(y)||(this._selectWordAtCursor(y,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(y,E,D=!0,T=!0){if(y[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,R=M.lines.get(y[1]);if(!R)return;const O=M.translateBufferLineToString(y[1],!1);let $=this._convertViewportColToCharacterIndex(R,y[0]),G=$;const V=y[0]-$;let q=0,L=0,N=0,I=0;if(O.charAt($)===" "){for(;$>0&&O.charAt($-1)===" ";)$--;for(;G<O.length&&O.charAt(G+1)===" ";)G++}else{let J=y[0],Z=y[0];R.getWidth(J)===0&&(q++,J--),R.getWidth(Z)===2&&(L++,Z++);const X=R.getString(Z).length;for(X>1&&(I+=X-1,G+=X-1);J>0&&$>0&&!this._isCharWordSeparator(R.loadCell(J-1,this._workCell));){R.loadCell(J-1,this._workCell);const F=this._workCell.getChars().length;this._workCell.getWidth()===0?(q++,J--):F>1&&(N+=F-1,$-=F-1),$--,J--}for(;Z<R.length&&G+1<O.length&&!this._isCharWordSeparator(R.loadCell(Z+1,this._workCell));){R.loadCell(Z+1,this._workCell);const F=this._workCell.getChars().length;this._workCell.getWidth()===2?(L++,Z++):F>1&&(I+=F-1,G+=F-1),G++,Z++}}G++;let H=$+V-q+N,W=Math.min(this._bufferService.cols,G-$+q+L-N-I);if(E||O.slice($,G).trim()!==""){if(D&&H===0&&R.getCodePoint(0)!==32){const J=M.lines.get(y[1]-1);if(J&&R.isWrapped&&J.getCodePoint(this._bufferService.cols-1)!==32){const Z=this._getWordAt([this._bufferService.cols-1,y[1]-1],!1,!0,!1);if(Z){const X=this._bufferService.cols-Z.start;H-=X,W+=X}}}if(T&&H+W===this._bufferService.cols&&R.getCodePoint(this._bufferService.cols-1)!==32){const J=M.lines.get(y[1]+1);if(J?.isWrapped&&J.getCodePoint(0)!==32){const Z=this._getWordAt([0,y[1]+1],!1,!1,!0);Z&&(W+=Z.length)}}return{start:H,length:W}}}_selectWordAt(y,E){const D=this._getWordAt(y,E);if(D){for(;D.start<0;)D.start+=this._bufferService.cols,y[1]--;this._model.selectionStart=[D.start,y[1]],this._model.selectionStartLength=D.length}}_selectToWordAt(y){const E=this._getWordAt(y,!0);if(E){let D=y[1];for(;E.start<0;)E.start+=this._bufferService.cols,D--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,D++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,D]}}_isCharWordSeparator(y){return y.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(y.getChars())>=0}
vendor: 19,552 bytes, line 37
37_selectLineAt(y){const E=this._bufferService.buffer.getWrappedRangeForLine(y),D={start:{x:0,y:E.first},end:{x:this._bufferService.cols-1,y:E.last}};this._model.selectionStart=[0,E.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,v.getRangeLength)(D,this._bufferService.cols)}};o.SelectionService=C=c([h(3,w.IBufferService),h(4,w.ICoreService),h(5,_.IMouseService),h(6,w.IOptionsService),h(7,_.IRenderService),h(8,_.ICoreBrowserService)],C)},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(C,y,E,D){var T,M=arguments.length,R=M<3?y:D===null?D=Object.getOwnPropertyDescriptor(y,E):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(C,y,E,D);else for(var O=C.length-1;O>=0;O--)(T=C[O])&&(R=(M<3?T(R):M>3?T(y,E,R):T(y,E))||R);return M>3&&R&&Object.defineProperty(y,E,R),R},h=this&&this.__param||function(C,y){return function(E,D){y(E,D,C)}};Object.defineProperty(o,"__esModule",{value:!0}),o.ThemeService=o.DEFAULT_ANSI_COLORS=void 0;const u=l(7239),d=l(8055),f=l(8460),_=l(844),b=l(2585),p=d.css.toColor("#ffffff"),g=d.css.toColor("#000000"),v=d.css.toColor("#ffffff"),x=d.css.toColor("#000000"),w={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};o.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const C=[d.css.toColor("#2e3436"),d.css.toColor("#cc0000"),d.css.toColor("#4e9a06"),d.css.toColor("#c4a000"),d.css.toColor("#3465a4"),d.css.toColor("#75507b"),d.css.toColor("#06989a"),d.css.toColor("#d3d7cf"),d.css.toColor("#555753"),d.css.toColor("#ef2929"),d.css.toColor("#8ae234"),d.css.toColor("#fce94f"),d.css.toColor("#729fcf"),d.css.toColor("#ad7fa8"),d.css.toColor("#34e2e2"),d.css.toColor("#eeeeec")],y=[0,95,135,175,215,255];for(let E=0;E<216;E++){const D=y[E/36%6|0],T=y[E/6%6|0],M=y[E%6];C.push({css:d.channels.toCss(D,T,M),rgba:d.channels.toRgba(D,T,M)})}for(let E=0;E<24;E++){const D=8+10*E;C.push({css:d.channels.toCss(D,D,D),rgba:d.channels.toRgba(D,D,D)})}return C})());let S=o.ThemeService=class extends _.Disposable{get colors(){return this._colors}constructor(C){super(),this._optionsService=C,this._contrastCache=new u.ColorContrastCache,this._halfContrastCache=new u.ColorContrastCache,this._onChangeColors=this.register(new f.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:p,background:g,cursor:v,cursorAccent:x,selectionForeground:void 0,selectionBackgroundTransparent:w,selectionBackgroundOpaque:d.color.blend(g,w),selectionInactiveBackgroundTransparent:w,selectionInactiveBackgroundOpaque:d.color.blend(g,w),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(C={}){const y=this._colors;if(y.foreground=k(C.foreground,p),y.background=k(C.background,g),y.cursor=k(C.cursor,v),y.cursorAccent=k(C.cursorAccent,x),y.selectionBackgroundTransparent=k(C.selectionBackground,w),y.selectionBackgroundOpaque=d.color.blend(y.background,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundTransparent=k(C.selectionInactiveBackground,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundOpaque=d.color.blend(y.background,y.selectionInactiveBackgroundTransparent),y.selectionForeground=C.selectionForeground?k(C.selectionForeground,d.NULL_COLOR):void 0,y.selectionForeground===d.NULL_COLOR&&(y.selectionForeground=void 0),d.color.isOpaque(y.selectionBackgroundTransparent)&&(y.selectionBackgroundTransparent=d.color.opacity(y.selectionBackgroundTransparent,.3)),d.color.isOpaque(y.selectionInactiveBackgroundTransparent)&&(y.selectionInactiveBackgroundTransparent=d.color.opacity(y.selectionInactiveBackgroundTransparent,.3)),y.ansi=o.DEFAULT_ANSI_COLORS.slice(),y.ansi[0]=k(C.black,o.DEFAULT_ANSI_COLORS[0]),y.ansi[1]=k(C.red,o.DEFAULT_ANSI_COLORS[1]),y.ansi[2]=k(C.green,o.DEFAULT_ANSI_COLORS[2]),y.ansi[3]=k(C.yellow,o.DEFAULT_ANSI_COLORS[3]),y.ansi[4]=k(C.blue,o.DEFAULT_ANSI_COLORS[4]),y.ansi[5]=k(C.magenta,o.DEFAULT_ANSI_COLORS[5]),y.ansi[6]=k(C.cyan,o.DEFAULT_ANSI_COLORS[6]),y.ansi[7]=k(C.white,o.DEFAULT_ANSI_COLORS[7]),y.ansi[8]=k(C.brightBlack,o.DEFAULT_ANSI_COLORS[8]),y.ansi[9]=k(C.brightRed,o.DEFAULT_ANSI_COLORS[9]),y.ansi[10]=k(C.brightGreen,o.DEFAULT_ANSI_COLORS[10]),y.ansi[11]=k(C.brightYellow,o.DEFAULT_ANSI_COLORS[11]),y.ansi[12]=k(C.brightBlue,o.DEFAULT_ANSI_COLORS[12]),y.ansi[13]=k(C.brightMagenta,o.DEFAULT_ANSI_COLORS[13]),y.ansi[14]=k(C.brightCyan,o.DEFAULT_ANSI_COLORS[14]),y.ansi[15]=k(C.brightWhite,o.DEFAULT_ANSI_COLORS[15]),C.extendedAnsi){const E=Math.min(y.ansi.length-16,C.extendedAnsi.length);for(let D=0;D<E;D++)y.ansi[D+16]=k(C.extendedAnsi[D],o.DEFAULT_ANSI_COLORS[D+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(C){this._restoreColor(C),this._onChangeColors.fire(this.colors)}_restoreColor(C){if(C!==void 0)switch(C){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[C]=this._restoreColors.ansi[C]}else for(let y=0;y<this._restoreColors.ansi.length;++y)this._colors.ansi[y]=this._restoreColors.ansi[y]}modifyColors(C){C(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(C,y){if(C!==void 0)try{return d.css.toColor(C)}catch{}return y}o.ThemeService=S=c([h(0,b.IOptionsService)],S)},6349:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CircularList=void 0;const c=l(8460),h=l(844);class u extends h.Disposable{constructor(f){super(),this._maxLength=f,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(f){if(this._maxLength===f)return;const _=new Array(f);for(let b=0;b<Math.min(f,this.length);b++)_[b]=this._array[this._getCyclicIndex(b)];this._array=_,this._maxLength=f,this._startIndex=0}get length(){return this._length}set length(f){if(f>this._length)for(let _=this._length;_<f;_++)this._array[_]=void 0;this._length=f}get(f){return this._array[this._getCyclicIndex(f)]}set(f,_){this._array[this._getCyclicIndex(f)]=_}push(f){this._array[this._getCyclicIndex(this._length)]=f,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(f,_,...b){if(_){for(let p=f;p<this._length-_;p++)this._array[this._getCyclicIndex(p)]=this._array[this._getCyclicIndex(p+_)];this._length-=_,this.onDeleteEmitter.fire({index:f,amount:_})}for(let p=this._length-1;p>=f;p--)this._array[this._getCyclicIndex(p+b.length)]=this._array[this._getCyclicIndex(p)];for(let p=0;p<b.length;p++)this._array[this._getCyclicIndex(f+p)]=b[p];if(b.length&&this.onInsertEmitter.fire({index:f,amount:b.length}),this._length+b.length>this._maxLength){const p=this._length+b.length-this._maxLength;this._startIndex+=p,this._length=this._maxLength,this.onTrimEmitter.fire(p)}else this._length+=b.length}trimStart(f){f>this._length&&(f=this._length),this._startIndex+=f,this._length-=f,this.onTrimEmitter.fire(f)}shiftElements(f,_,b){if(!(_<=0)){if(f<0||f>=this._length)throw new Error("start argument out of range");if(f+b<0)throw new Error("Cannot shift elements in list beyond index 0");if(b>0){for(let g=_-1;g>=0;g--)this.set(f+g+b,this.get(f+g));const p=f+_+b-this._length;if(p>0)for(this._length+=p;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let p=0;p<_;p++)this.set(f+p+b,this.get(f+p))}}_getCyclicIndex(f){return(this._startIndex+f)%this._maxLength}}o.CircularList=u},1439:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.clone=void 0,o.clone=function l(c,h=5){if(typeof c!="object")return c;const u=Array.isArray(c)?[]:{};for(const d in c)u[d]=h<=1?c[d]:c[d]&&l(c[d],h-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,h=0,u=0;var d,f,_,b,p;function g(x){const w=x.toString(16);return w.length<2?"0"+w:w}function v(x,w){return x<w?(w+.05)/(x+.05):(x+.05)/(w+.05)}o.NULL_COLOR={css:"#00000000",rgba:0},function(x){x.toCss=function(w,S,k,C){return C!==void 0?`#${g(w)}${g(S)}${g(k)}${g(C)}`:`#${g(w)}${g(S)}${g(k)}`},x.toRgba=function(w,S,k,C=255){return(w<<24|S<<16|k<<8|C)>>>0},x.toColor=function(w,S,k,C){return{css:x.toCss(w,S,k,C),rgba:x.toRgba(w,S,k,C)}}}(d||(o.channels=d={})),function(x){function w(S,k){return u=Math.round(255*k),[l,c,h]=p.toChannels(S.rgba),{css:d.toCss(l,c,h,u),rgba:d.toRgba(l,c,h,u)}}x.blend=function(S,k){if(u=(255&k.rgba)/255,u===1)return{css:k.css,rgba:k.rgba};const C=k.rgba>>24&255,y=k.rgba>>16&255,E=k.rgba>>8&255,D=S.rgba>>24&255,T=S.rgba>>16&255,M=S.rgba>>8&255;return l=D+Math.round((C-D)*u),c=T+Math.round((y-T)*u),h=M+Math.round((E-M)*u),{css:d.toCss(l,c,h),rgba:d.toRgba(l,c,h)}},x.isOpaque=function(S){return(255&S.rgba)==255},x.ensureContrastRatio=function(S,k,C){const y=p.ensureContrastRatio(S.rgba,k.rgba,C);if(y)return d.toColor(y>>24&255,y>>16&255,y>>8&255)},x.opaque=function(S){const k=(255|S.rgba)>>>0;return[l,c,h]=p.toChannels(k),{css:d.toCss(l,c,h),rgba:k}},x.opacity=w,x.multiplyOpacity=function(S,k){return u=255&S.rgba,w(S,u*k/255)},x.toColorRGB=function(S){return[S.rgba>>24&255,S.rgba>>16&255,S.rgba>>8&255]}}(f||(o.color=f={})),function(x){let w,S;try{const k=document.createElement("canvas");k.width=1,k.height=1;const C=k.getContext("2d",{willReadFrequently:!0});C&&(w=C,w.globalCompositeOperation="copy",S=w.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),h=parseInt(k.slice(3,4).repeat(2),16),d.toColor(l,c,h);case 5:return l=parseInt(k.slice(1,2).repeat(2),16),c=parseInt(k.slice(2,3).repeat(2),16),h=parseInt(k.slice(3,4).repeat(2),16),u=parseInt(k.slice(4,5).repeat(2),16),d.toColor(l,c,h,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 C=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(C)return l=parseInt(C[1]),c=parseInt(C[2]),h=parseInt(C[3]),u=Math.round(255*(C[5]===void 0?1:parseFloat(C[5]))),d.toColor(l,c,h,u);if(!w||!S)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=S,w.fillStyle=k,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[l,c,h,u]=w.getImageData(0,0,1,1).data,u!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:d.toRgba(l,c,h,u),css:k}}}(_||(o.css=_={})),function(x){function w(S,k,C){const y=S/255,E=k/255,D=C/255;return .2126*(y<=.03928?y/12.92:Math.pow((y+.055)/1.055,2.4))+.7152*(E<=.03928?E/12.92:Math.pow((E+.055)/1.055,2.4))+.0722*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))}x.relativeLuminance=function(S){return w(S>>16&255,S>>8&255,255&S)},x.relativeLuminance2=w}(b||(o.rgb=b={})),function(x){function w(k,C,y){const E=k>>24&255,D=k>>16&255,T=k>>8&255;let M=C>>24&255,R=C>>16&255,O=C>>8&255,$=v(b.relativeLuminance2(M,R,O),b.relativeLuminance2(E,D,T));for(;$<y&&(M>0||R>0||O>0);)M-=Math.max(0,Math.ceil(.1*M)),R-=Math.max(0,Math.ceil(.1*R)),O-=Math.max(0,Math.ceil(.1*O)),$=v(b.relativeLuminance2(M,R,O),b.relativeLuminance2(E,D,T));return(M<<24|R<<16|O<<8|255)>>>0}function S(k,C,y){const E=k>>24&255,D=k>>16&255,T=k>>8&255;let M=C>>24&255,R=C>>16&255,O=C>>8&255,$=v(b.relativeLuminance2(M,R,O),b.relativeLuminance2(E,D,T));for(;$<y&&(M<255||R<255||O<255);)M=Math.min(255,M+Math.ceil(.1*(255-M))),R=Math.min(255,R+Math.ceil(.1*(255-R))),O=Math.min(255,O+Math.ceil(.1*(255-O))),$=v(b.relativeLuminance2(M,R,O),b.relativeLuminance2(E,D,T));return(M<<24|R<<16|O<<8|255)>>>0}x.blend=function(k,C){if(u=(255&C)/255,u===1)return C;const y=C>>24&255,E=C>>16&255,D=C>>8&255,T=k>>24&255,M=k>>16&255,R=k>>8&255;return l=T+Math.round((y-T)*u),c=M+Math.round((E-M)*u),h=R+Math.round((D-R)*u),d.toRgba(l,c,h)},x.ensureContrastRatio=function(k,C,y){const E=b.relativeLuminance(k>>8),D=b.relativeLuminance(C>>8);if(v(E,D)<y){if(D<E){const R=w(k,C,y),O=v(E,b.relativeLuminance(R>>8));if(O<y){const $=S(k,C,y);return O>v(E,b.relativeLuminance($>>8))?R:$}return R}const T=S(k,C,y),M=v(E,b.relativeLuminance(T>>8));if(M<y){const R=w(k,C,y);return M>v(E,b.relativeLuminance(R>>8))?T:R}return T}},x.reduceLuminance=w,x.increaseLuminance=S,x.toChannels=function(k){return[k>>24&255,k>>16&255,k>>8&255,255&k]}}(p||(o.rgba=p={})),o.toPaddedHex=g,o.contrastRatio=v},8969:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CoreTerminal=void 0;const c=l(844),h=l(2585),u=l(4348),d=l(7866),f=l(744),_=l(7302),b=l(6975),p=l(8460),g=l(1753),v=l(1480),x=l(7994),w=l(9282),S=l(5435),k=l(5981),C=l(2660);let y=!1;class E extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new p.EventEmitter),this._onScroll.event(T=>{this._onScrollApi?.fire(T.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(T){for(const M in T)this.optionsService.options[M]=T[M]}constructor(T){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new p.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new p.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new p.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new p.EventEmitter),this._instantiationService=new u.InstantiationService,this.optionsService=this.register(new _.OptionsService(T)),this._instantiationService.setService(h.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(f.BufferService)),this._instantiationService.setService(h.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(d.LogService)),this._instantiationService.setService(h.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(b.CoreService)),this._instantiationService.setService(h.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(g.CoreMouseService)),this._instantiationService.setService(h.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(v.UnicodeService)),this._instantiationService.setService(h.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(x.CharsetService),this._instantiationService.setService(h.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(C.OscLinkService),this._instantiationService.setService(h.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,p.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,p.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,p.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,p.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(M=>{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(M=>{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((M,R)=>this._inputHandler.parse(M,R))),this.register((0,p.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(T,M){this._writeBuffer.write(T,M)}writeSync(T,M){this._logService.logLevel<=h.LogLevelEnum.WARN&&!y&&(this._logService.warn("writeSync is unreliable and will be removed soon."),y=!0),this._writeBuffer.writeSync(T,M)}input(T,M=!0){this.coreService.triggerDataEvent(T,M)}resize(T,M){isNaN(T)||isNaN(M)||(T=Math.max(T,f.MINIMUM_COLS),M=Math.max(M,f.MINIMUM_ROWS),this._bufferService.resize(T,M))}scroll(T,M=!1){this._bufferService.scroll(T,M)}scrollLines(T,M,R){this._bufferService.scrollLines(T,M,R)}scrollPages(T){this.scrollLines(T*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(T){const M=T-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(T,M){return this._inputHandler.registerEscHandler(T,M)}registerDcsHandler(T,M){return this._inputHandler.registerDcsHandler(T,M)}
37registerCsiHandler(T,M){return this._inputHandler.registerCsiHandler(T,M)}registerOscHandler(T,M){return this._inputHandler.registerOscHandler(T,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let T=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?T=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(T=!0),T?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const T=[];T.push(this.onLineFeed(w.updateWindowsModeWrappedState.bind(null,this._bufferService))),T.push(this.registerCsiHandler({final:"H"},()=>((0,w.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)(()=>{for(const M of T)M.dispose()})}}}o.CoreTerminal=E}
37,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 h=[];for(let u=0;u<this._listeners.length;u++)h.push(this._listeners[u]);for(let u=0;u<h.length;u++)h[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(h=>c.fire(h))},o.runAndSubscribe=function(l,c){return c(void 0),l(h=>c(h))}},5435:function(a,o,l){var c=this&&this.__decorate||function(q,L,N,I){var H,W=arguments.length,J=W<3?L:I===null?I=Object.getOwnPropertyDescriptor(L,N):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")J=Reflect.decorate(q,L,N,I);else for(var Z=q.length-1;Z>=0;Z--)(H=q[Z])&&(J=(W<3?H(J):W>3?H(L,N,J):H(L,N))||J);return W>3&&J&&Object.defineProperty(L,N,J),J},h=this&&this.__param||function(q,L){return function(N,I){L(N,I,q)}};Object.defineProperty(o,"__esModule",{value:!0}),o.InputHandler=o.WindowsOptionsReportType=void 0;const u=l(2584),d=l(7116),f=l(2015),_=l(844),b=l(482),p=l(8437),g=l(8460),v=l(643),x=l(511),w=l(3734),S=l(2585),k=l(1480),C=l(6242),y=l(6351),E=l(5941),D={"(":0,")":1,"*":2,"+":3,"-":1,".":2},T=131072;function M(q,L){if(q>24)return L.setWinLines||!1;switch(q){case 1:return!!L.restoreWin;case 2:return!!L.minimizeWin;case 3:return!!L.setWinPosition;case 4:return!!L.setWinSizePixels;case 5:return!!L.raiseWin;case 6:return!!L.lowerWin;case 7:return!!L.refreshWin;case 8:return!!L.setWinSizeChars;case 9:return!!L.maximizeWin;case 10:return!!L.fullscreenWin;case 11:return!!L.getWinState;case 13:return!!L.getWinPosition;case 14:return!!L.getWinSizePixels;case 15:return!!L.getScreenSizePixels;case 16:return!!L.getCellSizePixels;case 18:return!!L.getWinSizeChars;case 19:return!!L.getScreenSizeChars;case 20:return!!L.getIconTitle;case 21:return!!L.getWinTitle;case 22:return!!L.pushTitle;case 23:return!!L.popTitle;case 24:return!!L.setWinLines}return!1}var R;(function(q){q[q.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",q[q.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(o.WindowsOptionsReportType=R={}));let O=0;class $ extends _.Disposable{getAttrData(){return this._curAttrData}constructor(L,N,I,H,W,J,Z,X,F=new f.EscapeSequenceParser){super(),this._bufferService=L,this._charsetService=N,this._coreService=I,this._logService=H,this._optionsService=W,this._oscLinkService=J,this._coreMouseService=Z,this._unicodeService=X,this._parser=F,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new b.StringToUtf32,this._utf8Decoder=new b.Utf8ToUtf32,this._workCell=new x.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=p.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=p.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new g.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new g.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new g.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new g.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new g.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new g.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new g.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new g.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new g.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new g.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new g.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new g.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new g.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 G(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(P=>
vendor: 29,603 bytes, line 37
37this._activeBuffer=P.activeBuffer)),this._parser.setCsiHandlerFallback((P,j)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(P),params:j.toArray()})}),this._parser.setEscHandlerFallback(P=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(P)})}),this._parser.setExecuteHandlerFallback(P=>{this._logService.debug("Unknown EXECUTE code: ",{code:P})}),this._parser.setOscHandlerFallback((P,j,B)=>{this._logService.debug("Unknown OSC code: ",{identifier:P,action:j,data:B})}),this._parser.setDcsHandlerFallback((P,j,B)=>{j==="HOOK"&&(B=B.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(P),action:j,payload:B})}),this._parser.setPrintHandler((P,j,B)=>this.print(P,j,B)),this._parser.registerCsiHandler({final:"@"},P=>this.insertChars(P)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},P=>this.scrollLeft(P)),this._parser.registerCsiHandler({final:"A"},P=>this.cursorUp(P)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},P=>this.scrollRight(P)),this._parser.registerCsiHandler({final:"B"},P=>this.cursorDown(P)),this._parser.registerCsiHandler({final:"C"},P=>this.cursorForward(P)),this._parser.registerCsiHandler({final:"D"},P=>this.cursorBackward(P)),this._parser.registerCsiHandler({final:"E"},P=>this.cursorNextLine(P)),this._parser.registerCsiHandler({final:"F"},P=>this.cursorPrecedingLine(P)),this._parser.registerCsiHandler({final:"G"},P=>this.cursorCharAbsolute(P)),this._parser.registerCsiHandler({final:"H"},P=>this.cursorPosition(P)),this._parser.registerCsiHandler({final:"I"},P=>this.cursorForwardTab(P)),this._parser.registerCsiHandler({final:"J"},P=>this.eraseInDisplay(P,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},P=>this.eraseInDisplay(P,!0)),this._parser.registerCsiHandler({final:"K"},P=>this.eraseInLine(P,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},P=>this.eraseInLine(P,!0)),this._parser.registerCsiHandler({final:"L"},P=>this.insertLines(P)),this._parser.registerCsiHandler({final:"M"},P=>this.deleteLines(P)),this._parser.registerCsiHandler({final:"P"},P=>this.deleteChars(P)),this._parser.registerCsiHandler({final:"S"},P=>this.scrollUp(P)),this._parser.registerCsiHandler({final:"T"},P=>this.scrollDown(P)),this._parser.registerCsiHandler({final:"X"},P=>this.eraseChars(P)),this._parser.registerCsiHandler({final:"Z"},P=>this.cursorBackwardTab(P)),this._parser.registerCsiHandler({final:"`"},P=>this.charPosAbsolute(P)),this._parser.registerCsiHandler({final:"a"},P=>this.hPositionRelative(P)),this._parser.registerCsiHandler({final:"b"},P=>this.repeatPrecedingCharacter(P)),this._parser.registerCsiHandler({final:"c"},P=>this.sendDeviceAttributesPrimary(P)),this._parser.registerCsiHandler({prefix:">",final:"c"},P=>this.sendDeviceAttributesSecondary(P)),this._parser.registerCsiHandler({final:"d"},P=>this.linePosAbsolute(P)),this._parser.registerCsiHandler({final:"e"},P=>this.vPositionRelative(P)),this._parser.registerCsiHandler({final:"f"},P=>this.hVPosition(P)),this._parser.registerCsiHandler({final:"g"},P=>this.tabClear(P)),this._parser.registerCsiHandler({final:"h"},P=>this.setMode(P)),this._parser.registerCsiHandler({prefix:"?",final:"h"},P=>this.setModePrivate(P)),this._parser.registerCsiHandler({final:"l"},P=>this.resetMode(P)),this._parser.registerCsiHandler({prefix:"?",final:"l"},P=>this.resetModePrivate(P)),this._parser.registerCsiHandler({final:"m"},P=>this.charAttributes(P)),this._parser.registerCsiHandler({final:"n"},P=>this.deviceStatus(P)),this._parser.registerCsiHandler({prefix:"?",final:"n"},P=>this.deviceStatusPrivate(P)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},P=>this.softReset(P)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},P=>this.setCursorStyle(P)),this._parser.registerCsiHandler({final:"r"},P=>this.setScrollRegion(P)),this._parser.registerCsiHandler({final:"s"},P=>this.saveCursor(P)),this._parser.registerCsiHandler({final:"t"},P=>this.windowOptions(P)),this._parser.registerCsiHandler({final:"u"},P=>this.restoreCursor(P)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},P=>this.insertColumns(P)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},P=>this.deleteColumns(P)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},P=>this.selectProtected(P)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},P=>this.requestMode(P,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},P=>this.requestMode(P,!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 C.OscHandler(P=>(this.setTitle(P),this.setIconName(P),!0))),this._parser.registerOscHandler(1,new C.OscHandler(P=>this.setIconName(P))),this._parser.registerOscHandler(2,new C.OscHandler(P=>this.setTitle(P))),this._parser.registerOscHandler(4,new C.OscHandler(P=>this.setOrReportIndexedColor(P))),this._parser.registerOscHandler(8,new C.OscHandler(P=>this.setHyperlink(P))),this._parser.registerOscHandler(10,new C.OscHandler(P=>this.setOrReportFgColor(P))),this._parser.registerOscHandler(11,new C.OscHandler(P=>this.setOrReportBgColor(P))),this._parser.registerOscHandler(12,new C.OscHandler(P=>this.setOrReportCursorColor(P))),this._parser.registerOscHandler(104,new C.OscHandler(P=>this.restoreIndexedColor(P))),this._parser.registerOscHandler(110,new C.OscHandler(P=>this.restoreFgColor(P))),this._parser.registerOscHandler(111,new C.OscHandler(P=>this.restoreBgColor(P))),this._parser.registerOscHandler(112,new C.OscHandler(P=>this.restoreCursorColor(P))),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 P in d.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:P},()=>this.selectCharset("("+P)),this._parser.registerEscHandler({intermediates:")",final:P},()=>this.selectCharset(")"+P)),this._parser.registerEscHandler({intermediates:"*",final:P},()=>this.selectCharset("*"+P)),this._parser.registerEscHandler({intermediates:"+",final:P},()=>this.selectCharset("+"+P)),this._parser.registerEscHandler({intermediates:"-",final:P},()=>this.selectCharset("-"+P)),this._parser.registerEscHandler({intermediates:".",final:P},()=>this.selectCharset("."+P)),this._parser.registerEscHandler({intermediates:"/",final:P},()=>this.selectCharset("/"+P));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(P=>(this._logService.error("Parsing error: ",P),P)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new y.DcsHandler((P,j)=>this.requestStatusString(P,j)))}_preserveStack(L,N,I,H){this._parseStack.paused=!0,this._parseStack.cursorStartX=L,this._parseStack.cursorStartY=N,this._parseStack.decodedLength=I,this._parseStack.position=H}_logSlowResolvingAsync(L){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([L,new Promise((N,I)=>setTimeout(()=>I("#SLOW_TIMEOUT"),5e3))]).catch(N=>{if(N!=="#SLOW_TIMEOUT")throw N;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(L,N){let I,H=this._activeBuffer.x,W=this._activeBuffer.y,J=0;const Z=this._parseStack.paused;if(Z){if(I=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,N))return this._logSlowResolvingAsync(I),I;H=this._parseStack.cursorStartX,W=this._parseStack.cursorStartY,this._parseStack.paused=!1,L.length>T&&(J=this._parseStack.position+T)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof L=="string"?` "${L}"`:` "${Array.prototype.map.call(L,P=>String.fromCharCode(P)).join("")}"`),typeof L=="string"?L.split("").map(P=>P.charCodeAt(0)):L),this._parseBuffer.length<L.length&&this._parseBuffer.length<T&&(this._parseBuffer=new Uint32Array(Math.min(L.length,T))),Z||this._dirtyRowTracker.clearRange(),L.length>T)for(let P=J;P<L.length;P+=T){const j=P+T<L.length?P+T:L.length,B=typeof L=="string"?this._stringDecoder.decode(L.substring(P,j),this._parseBuffer):this._utf8Decoder.decode(L.subarray(P,j),this._parseBuffer);if(I=this._parser.parse(this._parseBuffer,B))return this._preserveStack(H,W,B,P),this._logSlowResolvingAsync(I),I}else if(!Z){const P=typeof L=="string"?this._stringDecoder.decode(L,this._parseBuffer):this._utf8Decoder.decode(L,this._parseBuffer);if(I=this._parser.parse(this._parseBuffer,P))return this._preserveStack(H,W,P,0),this._logSlowResolvingAsync(I),I}this._activeBuffer.x===H&&this._activeBuffer.y===W||this._onCursorMove.fire();const X=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),F=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);F<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(F,this._bufferService.rows-1),Math.min(X,this._bufferService.rows-1))}print(L,N,I){let H,W;const J=this._charsetService.charset,Z=this._optionsService.rawOptions.screenReaderMode,X=this._bufferService.cols,F=this._coreService.decPrivateModes.wraparound,P=this._coreService.modes.insertMode,j=this._curAttrData;let B=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&I-N>0&&B.getWidth(this._activeBuffer.x-1)===2&&B.setCellFromCodepoint(this._activeBuffer.x-1,0,1,j);let K=this._parser.precedingJoinState;for(let U=N;U<I;++U){if(H=L[U],H<127&&J){const le=J[String.fromCharCode(H)];le&&(H=le.charCodeAt(0))}const Y=this._unicodeService.charProperties(H,K);W=k.UnicodeService.extractWidth(Y);const ee=k.UnicodeService.extractShouldJoin(Y),ie=ee?k.UnicodeService.extractWidth(K):0;if(K=Y,Z&&this._onA11yChar.fire((0,b.stringFromCodePoint)(H)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+W-ie>X){if(F){const le=B;let ne=this._activeBuffer.x-ie;for(this._activeBuffer.x=ie,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),B=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),ie>0&&B instanceof p.BufferLine&&B.copyCellsFrom(le,ne,0,ie,!1);ne<X;)le.setCellFromCodepoint(ne++,0,1,j)}else if(this._activeBuffer.x=X-1,W===2)continue}if(ee&&this._activeBuffer.x){const le=B.getWidth(this._activeBuffer.x-1)?1:2;B.addCodepointToCell(this._activeBuffer.x-le,H,W);for(let ne=W-ie;--ne>=0;)B.setCellFromCodepoint(this._activeBuffer.x++,0,0,j)}else if(P&&(B.insertCells(this._activeBuffer.x,W-ie,this._activeBuffer.getNullCell(j)),B.getWidth(X-1)===2&&B.setCellFromCodepoint(X-1,v.NULL_CELL_CODE,v.NULL_CELL_WIDTH,j)),B.setCellFromCodepoint(this._activeBuffer.x++,H,W,j),W>0)for(;--W;)B.setCellFromCodepoint(this._activeBuffer.x++,0,0,j)}this._parser.precedingJoinState=K,this._activeBuffer.x<X&&I-N>0&&B.getWidth(this._activeBuffer.x)===0&&!B.hasContent(this._activeBuffer.x)&&B.setCellFromCodepoint(this._activeBuffer.x,0,1,j),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(L,N){return L.final!=="t"||L.prefix||L.intermediates?this._parser.registerCsiHandler(L,N):this._parser.registerCsiHandler(L,I=>!M(I.params[0],this._optionsService.rawOptions.windowOptions)||N(I))}registerDcsHandler(L,N){return this._parser.registerDcsHandler(L,new y.DcsHandler(N))}registerEscHandler(L,N){return this._parser.registerEscHandler(L,N)}registerOscHandler(L,N){return this._parser.registerOscHandler(L,new C.OscHandler(N))}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 L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);L.hasWidth(this._activeBuffer.x)&&!L.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const L=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-L),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(L=this._bufferService.cols-1){this._activeBuffer.x=Math.min(L,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(L,N){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=L,this._activeBuffer.y=this._activeBuffer.scrollTop+N):(this._activeBuffer.x=L,this._activeBuffer.y=N),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(L,N){this._restrictCursor(),this._setCursor(this._activeBuffer.x+L,this._activeBuffer.y+N)}cursorUp(L){const N=this._activeBuffer.y-this._activeBuffer.scrollTop;return N>=0?this._moveCursor(0,-Math.min(N,L.params[0]||1)):this._moveCursor(0,-(L.params[0]||1)),!0}cursorDown(L){const N=this._activeBuffer.scrollBottom-this._activeBuffer.y;return N>=0?this._moveCursor(0,Math.min(N,L.params[0]||1)):this._moveCursor(0,L.params[0]||1),!0}cursorForward(L){return this._moveCursor(L.params[0]||1,0),!0}cursorBackward(L){return this._moveCursor(-(L.params[0]||1),0),!0}cursorNextLine(L){return this.cursorDown(L),this._activeBuffer.x=0,!0}cursorPrecedingLine(L){return this.cursorUp(L),this._activeBuffer.x=0,!0}cursorCharAbsolute(L){return this._setCursor((L.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(L){return this._setCursor(L.length>=2?(L.params[1]||1)-1:0,(L.params[0]||1)-1),!0}charPosAbsolute(L){return this._setCursor((L.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(L){return this._moveCursor(L.params[0]||1,0),!0}linePosAbsolute(L){return this._setCursor(this._activeBuffer.x,(L.params[0]||1)-1),!0}vPositionRelative(L){return this._moveCursor(0,L.params[0]||1),!0}hVPosition(L){return this.cursorPosition(L),!0}tabClear(L){const N=L.params[0];return N===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:N===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(L){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let N=L.params[0]||1;for(;N--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(L){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let N=L.params[0]||1;for(;N--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(L){const N=L.params[0];return N===1&&(this._curAttrData.bg|=536870912),N!==2&&N!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(L,N,I,H=!1,W=!1){const J=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);J.replaceCells(N,I,this._activeBuffer.getNullCell(this._eraseAttrData()),W),H&&(J.isWrapped=!1)}_resetBufferLine(L,N=!1){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);I&&(I.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),N),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+L),I.isWrapped=!1)}eraseInDisplay(L,N=!1){let I;switch(this._restrictCursor(this._bufferService.cols),L.params[0]){case 0:for(I=this._activeBuffer.y,this._dirtyRowTracker.markDirty(I),this._eraseInBufferLine(I++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,N);I<this._bufferService.rows;I++)this._resetBufferLine(I,N);this._dirtyRowTracker.markDirty(I);break;case 1:for(I=this._activeBuffer.y,this._dirtyRowTracker.markDirty(I),this._eraseInBufferLine(I,0,this._activeBuffer.x+1,!0,N),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(I+1).isWrapped=!1);I--;)this._resetBufferLine(I,N);this._dirtyRowTracker.markDirty(0);break;case 2:for(I=this._bufferService.rows,this._dirtyRowTracker.markDirty(I-1);I--;)this._resetBufferLine(I,N);this._dirtyRowTracker.markDirty(0);break;case 3:const H=this._activeBuffer.lines.length-this._bufferService.rows;H>0&&(this._activeBuffer.lines.trimStart(H),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-H,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-H,0),this._onScroll.fire(0))}return!0}eraseInLine(L,N=!1){switch(this._restrictCursor(this._bufferService.cols),L.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,N);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,N);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,N)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(L){this._restrictCursor();let N=L.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=this._activeBuffer.ybase+this._activeBuffer.y,H=this._bufferService.rows-1-this._activeBuffer.scrollBottom,W=this._bufferService.rows-1+this._activeBuffer.ybase-H+1;for(;N--;)this._activeBuffer.lines.splice(W-1,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(L){this._restrictCursor();let N=L.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=this._activeBuffer.ybase+this._activeBuffer.y;let H;for(H=this._bufferService.rows-1-this._activeBuffer.scrollBottom,H=this._bufferService.rows-1+this._activeBuffer.ybase-H;N--;)this._activeBuffer.lines.splice(I,1),this._activeBuffer.lines.splice(H,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(L){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.insertCells(this._activeBuffer.x,L.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(L){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.deleteCells(this._activeBuffer.x,L.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(L){let N=L.params[0]||1;for(;N--;)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(L){let N=L.params[0]||1;for(;N--;)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(p.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=L.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const H=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);H.deleteCells(0,N,this._activeBuffer.getNullCell(this._eraseAttrData())),H.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=L.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const H=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);H.insertCells(0,N,this._activeBuffer.getNullCell(this._eraseAttrData())),H.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=L.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const H=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);H.insertCells(this._activeBuffer.x,N,this._activeBuffer.getNullCell(this._eraseAttrData())),H.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=L.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const H=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);H.deleteCells(this._activeBuffer.x,N,this._activeBuffer.getNullCell(this._eraseAttrData())),H.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(L){this._restrictCursor();const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return N&&(N.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(L.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(L){const N=this._parser.precedingJoinState;if(!N)return!0;const I=L.params[0]||1,H=k.UnicodeService.extractWidth(N),W=this._activeBuffer.x-H,J=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(W),Z=new Uint32Array(J.length*I);let X=0;for(let P=0;P<J.length;){const j=J.codePointAt(P)||0;Z[X++]=j,P+=j>65535?2:1}let F=X;for(let P=1;P<I;++P)Z.copyWithin(F,0,X),F+=X;return this.print(Z,0,F),!0}sendDeviceAttributesPrimary(L){return L.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(L){return L.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(L.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(u.C0.ESC+"[>83;40003;0c")),!0}_is(L){return(this._optionsService.rawOptions.termName+"").indexOf(L)===0}setMode(L){for(let N=0;N<L.length;N++)switch(L.params[N]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(L){for(let N=0;N<L.length;N++)switch(L.params[N]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,d.DEFAULT_CHARSET),this._charsetService.setgCharset(1,d.DEFAULT_CHARSET),this._charsetService.setgCharset(2,d.DEFAULT_CHARSET),this._charsetService.setgCharset(3,d.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(L){for(let N=0;N<L.length;N++)switch(L.params[N]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(L){for(let N=0;N<L.length;N++)switch(L.params[N]){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;
vendor: 5,051 bytes, line 37
37case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),L.params[N]===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(L,N){const I=this._coreService.decPrivateModes,{activeProtocol:H,activeEncoding:W}=this._coreMouseService,J=this._coreService,{buffers:Z,cols:X}=this._bufferService,{active:F,alt:P}=Z,j=this._optionsService.rawOptions,B=ee=>ee?1:2,K=L.params[0];return U=K,Y=N?K===2?4:K===4?B(J.modes.insertMode):K===12?3:K===20?B(j.convertEol):0:K===1?B(I.applicationCursorKeys):K===3?j.windowOptions.setWinLines?X===80?2:X===132?1:0:0:K===6?B(I.origin):K===7?B(I.wraparound):K===8?3:K===9?B(H==="X10"):K===12?B(j.cursorBlink):K===25?B(!J.isCursorHidden):K===45?B(I.reverseWraparound):K===66?B(I.applicationKeypad):K===67?4:K===1e3?B(H==="VT200"):K===1002?B(H==="DRAG"):K===1003?B(H==="ANY"):K===1004?B(I.sendFocus):K===1005?4:K===1006?B(W==="SGR"):K===1015?4:K===1016?B(W==="SGR_PIXELS"):K===1048?1:K===47||K===1047||K===1049?B(F===P):K===2004?B(I.bracketedPasteMode):0,J.triggerDataEvent(`${u.C0.ESC}[${N?"":"?"}${U};${Y}$y`),!0;var U,Y}_updateAttrColor(L,N,I,H,W){return N===2?(L|=50331648,L&=-16777216,L|=w.AttributeData.fromColorRGB([I,H,W])):N===5&&(L&=-50331904,L|=33554432|255&I),L}_extractColor(L,N,I){const H=[0,0,-1,0,0,0];let W=0,J=0;do{if(H[J+W]=L.params[N+J],L.hasSubParams(N+J)){const Z=L.getSubParams(N+J);let X=0;do H[1]===5&&(W=1),H[J+X+1+W]=Z[X];while(++X<Z.length&&X+J+1+W<H.length);break}if(H[1]===5&&J+W>=2||H[1]===2&&J+W>=5)break;H[1]&&(W=1)}while(++J+N<L.length&&J+W<H.length);for(let Z=2;Z<H.length;++Z)H[Z]===-1&&(H[Z]=0);switch(H[0]){case 38:I.fg=this._updateAttrColor(I.fg,H[1],H[3],H[4],H[5]);break;case 48:I.bg=this._updateAttrColor(I.bg,H[1],H[3],H[4],H[5]);break;case 58:I.extended=I.extended.clone(),I.extended.underlineColor=this._updateAttrColor(I.extended.underlineColor,H[1],H[3],H[4],H[5])}return J}_processUnderline(L,N){N.extended=N.extended.clone(),(!~L||L>5)&&(L=1),N.extended.underlineStyle=L,N.fg|=268435456,L===0&&(N.fg&=-268435457),N.updateExtended()}_processSGR0(L){L.fg=p.DEFAULT_ATTR_DATA.fg,L.bg=p.DEFAULT_ATTR_DATA.bg,L.extended=L.extended.clone(),L.extended.underlineStyle=0,L.extended.underlineColor&=-67108864,L.updateExtended()}charAttributes(L){if(L.length===1&&L.params[0]===0)return this._processSGR0(this._curAttrData),!0;const N=L.length;let I;const H=this._curAttrData;for(let W=0;W<N;W++)I=L.params[W],I>=30&&I<=37?(H.fg&=-50331904,H.fg|=16777216|I-30):I>=40&&I<=47?(H.bg&=-50331904,H.bg|=16777216|I-40):I>=90&&I<=97?(H.fg&=-50331904,H.fg|=16777224|I-90):I>=100&&I<=107?(H.bg&=-50331904,H.bg|=16777224|I-100):I===0?this._processSGR0(H):I===1?H.fg|=134217728:I===3?H.bg|=67108864:I===4?(H.fg|=268435456,this._processUnderline(L.hasSubParams(W)?L.getSubParams(W)[0]:1,H)):I===5?H.fg|=536870912:I===7?H.fg|=67108864:I===8?H.fg|=1073741824:I===9?H.fg|=2147483648:I===2?H.bg|=134217728:I===21?this._processUnderline(2,H):I===22?(H.fg&=-134217729,H.bg&=-134217729):I===23?H.bg&=-67108865:I===24?(H.fg&=-268435457,this._processUnderline(0,H)):I===25?H.fg&=-536870913:I===27?H.fg&=-67108865:I===28?H.fg&=-1073741825:I===29?H.fg&=2147483647:I===39?(H.fg&=-67108864,H.fg|=16777215&p.DEFAULT_ATTR_DATA.fg):I===49?(H.bg&=-67108864,H.bg|=16777215&p.DEFAULT_ATTR_DATA.bg):I===38||I===48||I===58?W+=this._extractColor(L,W,H):I===53?H.bg|=1073741824:I===55?H.bg&=-1073741825:I===59?(H.extended=H.extended.clone(),H.extended.underlineColor=-1,H.updateExtended()):I===100?(H.fg&=-67108864,H.fg|=16777215&p.DEFAULT_ATTR_DATA.fg,H.bg&=-67108864,H.bg|=16777215&p.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",I);return!0}deviceStatus(L){switch(L.params[0]){case 5:this._coreService.triggerDataEvent(`${u.C0.ESC}[0n`);break;case 6:const N=this._activeBuffer.y+1,I=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[${N};${I}R`)}return!0}deviceStatusPrivate(L){if(L.params[0]===6){const N=this._activeBuffer.y+1,I=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[?${N};${I}R`)}return!0}softReset(L){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=p.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(L){const N=L.params[0]||1;switch(N){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;
37case 5:case 6:this._optionsService.options.cursorStyle="bar"}const I=N%2==1;return this._optionsService.options.cursorBlink=I,!0}setScrollRegion(L){const N=L.params[0]||1;let I;return(L.length<2||(I=L.params[1])>this._bufferService.rows||I===0)&&(I=this._bufferService.rows),I>N&&(this._activeBuffer.scrollTop=N-1,this._activeBuffer.scrollBottom=I-1,this._setCursor(0,0)),!0}windowOptions(L){if(!M(L.params[0],this._optionsService.rawOptions.windowOptions))return!0;const N=L.length>1?L.params[1]:0;switch(L.params[0]){case 14:N!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.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:N!==0&&N!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),N!==0&&N!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:N!==0&&N!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),N!==0&&N!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(L){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(L){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(L){return this._windowTitle=L,this._onTitleChange.fire(L),!0}setIconName(L){return this._iconName=L,!0}setOrReportIndexedColor(L){const N=[],I=L.split(";");for(;I.length>1;){const H=I.shift(),W=I.shift();if(/^\d+$/.exec(H)){const J=parseInt(H);if(V(J))if(W==="?")N.push({type:0,index:J});else{const Z=(0,E.parseColor)(W);Z&&N.push({type:1,index:J,color:Z})}}}return N.length&&this._onColor.fire(N),!0}setHyperlink(L){const N=L.split(";");return!(N.length<2)&&(N[1]?this._createHyperlink(N[0],N[1]):!N[0]&&this._finishHyperlink())}_createHyperlink(L,N){this._getCurrentLinkId()&&this._finishHyperlink();const I=L.split(":");let H;const W=I.findIndex(J=>J.startsWith("id="));return W!==-1&&(H=I[W].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:H,uri:N}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(L,N){const I=L.split(";");for(let H=0;H<I.length&&!(N>=this._specialColors.length);++H,++N)if(I[H]==="?")this._onColor.fire([{type:0,index:this._specialColors[N]}]);else{const W=(0,E.parseColor)(I[H]);W&&this._onColor.fire([{type:1,index:this._specialColors[N],color:W}])}return!0}setOrReportFgColor(L){return this._setOrReportSpecialColor(L,0)}setOrReportBgColor(L){return this._setOrReportSpecialColor(L,1)}setOrReportCursorColor(L){return this._setOrReportSpecialColor(L,2)}restoreIndexedColor(L){if(!L)return this._onColor.fire([{type:2}]),!0;const N=[],I=L.split(";");for(let H=0;H<I.length;++H)if(/^\d+$/.exec(I[H])){const W=parseInt(I[H]);V(W)&&N.push({type:2,index:W})}return N.length&&this._onColor.fire(N),!0}restoreFgColor(L){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(L){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(L){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,d.DEFAULT_CHARSET),!0}selectCharset(L){return L.length!==2?(this.selectDefaultCharset(),!0):(L[0]==="/"||this._charsetService.setgCharset(D[L[0]],d.CHARSETS[L[1]]||d.DEFAULT_CHARSET),!0)}
vendor: 16,136 bytes, line 37
37index(){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 L=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,L,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=p.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=p.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(L){return this._charsetService.setgLevel(L),!0}screenAlignmentPattern(){const L=new x.CellData;L.content=4194373,L.fg=this._curAttrData.fg,L.bg=this._curAttrData.bg,this._setCursor(0,0);for(let N=0;N<this._bufferService.rows;++N){const I=this._activeBuffer.ybase+this._activeBuffer.y+N,H=this._activeBuffer.lines.get(I);H&&(H.fill(L),H.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(L,N){const I=this._bufferService.buffer,H=this._optionsService.rawOptions;return(W=>(this._coreService.triggerDataEvent(`${u.C0.ESC}${W}${u.C0.ESC}\\`),!0))(L==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:L==='"p'?'P1$r61;1"p':L==="r"?`P1$r${I.scrollTop+1};${I.scrollBottom+1}r`:L==="m"?"P1$r0m":L===" q"?`P1$r${{block:2,underline:4,bar:6}[H.cursorStyle]-(H.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(L,N){this._dirtyRowTracker.markRangeDirty(L,N)}}o.InputHandler=$;let G=class{constructor(q){this._bufferService=q,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(q){q<this.start?this.start=q:q>this.end&&(this.end=q)}markRangeDirty(q,L){q>L&&(O=q,q=L,L=O),q<this.start&&(this.start=q),L>this.end&&(this.end=L)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function V(q){return 0<=q&&q<256}G=c([h(0,S.IBufferService)],G)},844:(a,o)=>{function l(c){for(const h of c)h.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 h=this._disposables.indexOf(c);h!==-1&&this._disposables.splice(h,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(h,u,d){this._data[h]||(this._data[h]={}),this._data[h][u]=d}get(h,u){return this._data[h]?this._data[h][u]:void 0}clear(){this._data={}}}o.TwoKeyMap=l,o.FourKeyMap=class{constructor(){this._data=new l}set(c,h,u,d,f){this._data.get(c,h)||this._data.set(c,h,new l),this._data.get(c,h).set(u,d,f)}get(c,h,u,d){return this._data.get(c,h)?.get(u,d)}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 qt<"u"&&"title"in qt;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 h=l.match(/Version\/(\d+)/);return h===null||h.length<2?0:parseInt(h[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 h=this._getKey(c);if(h===void 0||(l=this._search(h),l===-1)||this._getKey(this._array[l])!==h)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])===h);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,h){if(this._array.length!==0&&(l=this._search(c),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===c))do h(this._array[l]);while(++l<this._array.length&&this._getKey(this._array[l])===c)}values(){return[...this._array].values()}_search(c){let h=0,u=this._array.length-1;for(;u>=h;){let d=h+u>>1;const f=this._getKey(this._array[d]);if(f>c)u=d-1;else{if(!(f<c)){for(;d>0&&this._getKey(this._array[d-1])===c;)d--;return d}h=d+1}}return h}}},7226:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DebouncedIdleTask=o.IdleTaskQueue=o.PriorityTaskQueue=void 0;const c=l(6114);class h{constructor(){this._tasks=[],this._i=0}enqueue(f){this._tasks.push(f),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(f){this._idleCallback=void 0;let _=0,b=0,p=f.timeRemaining(),g=0;for(;this._i<this._tasks.length;){if(_=Date.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,Date.now()-_),b=Math.max(_,b),g=f.timeRemaining(),1.5*b>g)return p-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(p-_))}ms`),void this._start();p=g}this.clear()}}class u extends h{_requestCallback(f){return setTimeout(()=>f(this._createDeadline(16)))}_cancelCallback(f){clearTimeout(f)}_createDeadline(f){const _=Date.now()+f;return{timeRemaining:()=>Math.max(0,_-Date.now())}}}o.PriorityTaskQueue=u,o.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends h{_requestCallback(d){return requestIdleCallback(d)}_cancelCallback(d){cancelIdleCallback(d)}}:u,o.DebouncedIdleTask=class{constructor(){this._queue=new o.IdleTaskQueue}set(d){this._queue.clear(),this._queue.enqueue(d)}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(h){const u=h.buffer.lines.get(h.buffer.ybase+h.buffer.y-1),d=u?.get(h.cols-1),f=h.buffer.lines.get(h.buffer.ybase+h.buffer.y);f&&d&&(f.isWrapped=d[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&d[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,d=0){this._ext=0,this._urlId=0,this._ext=u,this._urlId=d}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),h=l(7226),u=l(3734),d=l(8437),f=l(4634),_=l(511),b=l(643),p=l(4863),g=l(7116);o.MAX_BUFFER_SIZE=4294967295,o.Buffer=class{constructor(v,x,w){this._hasScrollback=v,this._optionsService=x,this._bufferService=w,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=d.DEFAULT_ATTR_DATA.clone(),this.savedCharset=g.DEFAULT_CHARSET,this.markers=[],this._nullCell=_.CellData.fromCharData([0,b.NULL_CELL_CHAR,b.NULL_CELL_WIDTH,b.NULL_CELL_CODE]),this._whitespaceCell=_.CellData.fromCharData([0,b.WHITESPACE_CELL_CHAR,b.WHITESPACE_CELL_WIDTH,b.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new h.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(v){return v?(this._nullCell.fg=v.fg,this._nullCell.bg=v.bg,this._nullCell.extended=v.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new u.ExtendedAttrs),this._nullCell}getWhitespaceCell(v){return v?(this._whitespaceCell.fg=v.fg,this._whitespaceCell.bg=v.bg,this._whitespaceCell.extended=v.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new u.ExtendedAttrs),this._whitespaceCell}getBlankLine(v,x){return new d.BufferLine(this._bufferService.cols,this.getNullCell(v),x)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const v=this.ybase+this.y-this.ydisp;return v>=0&&v<this._rows}_getCorrectBufferLength(v){if(!this._hasScrollback)return v;const x=v+this._optionsService.rawOptions.scrollback;return x>o.MAX_BUFFER_SIZE?o.MAX_BUFFER_SIZE:x}fillViewportRows(v){if(this.lines.length===0){v===void 0&&(v=d.DEFAULT_ATTR_DATA);let x=this._rows;for(;x--;)this.lines.push(this.getBlankLine(v))}}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(v,x){const w=this.getNullCell(d.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(x);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<v)for(let y=0;y<this.lines.length;y++)S+=+this.lines.get(y).resize(v,w);let C=0;if(this._rows<x)for(let y=this._rows;y<x;y++)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 d.BufferLine(v,w)):this.ybase>0&&this.lines.length<=this.ybase+this.y+C+1?(this.ybase--,C++,this.ydisp>0&&this.ydisp--):this.lines.push(new d.BufferLine(v,w)));else for(let y=this._rows;y>x;y--)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 y=this.lines.length-k;y>0&&(this.lines.trimStart(y),this.ybase=Math.max(this.ybase-y,0),this.ydisp=Math.max(this.ydisp-y,0),this.savedY=Math.max(this.savedY-y,0)),this.lines.maxLength=k}this.x=Math.min(this.x,v-1),this.y=Math.min(this.y,x-1),C&&(this.y+=C),this.savedX=Math.min(this.savedX,v-1),this.scrollTop=0}if(this.scrollBottom=x-1,this._isReflowEnabled&&(this._reflow(v,x),this._cols>v))for(let C=0;C<this.lines.length;C++)S+=+this.lines.get(C).resize(v,w);this._cols=v,this._rows=x,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let v=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,v=!1);let x=0;for(;this._memoryCleanupPosition<this.lines.length;)if(x+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),x>100)return!0;return v}get _isReflowEnabled(){const v=this._optionsService.rawOptions.windowsPty;return v&&v.buildNumber?this._hasScrollback&&v.backend==="conpty"&&v.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(v,x){this._cols!==v&&(v>this._cols?this._reflowLarger(v,x):this._reflowSmaller(v,x))}_reflowLarger(v,x){const w=(0,f.reflowLargerGetLinesToRemove)(this.lines,this._cols,v,this.ybase+this.y,this.getNull
37Cell(d.DEFAULT_ATTR_DATA));if(w.length>0){const S=(0,f.reflowLargerCreateNewLayout)(this.lines,w);(0,f.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(v,x,S.countRemoved)}}_reflowLargerAdjustViewport(v,x,w){const S=this.getNullCell(d.DEFAULT_ATTR_DATA);let k=w;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<x&&this.lines.push(new d.BufferLine(v,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-w,0)}_reflowSmaller(v,x){const w=this.getNullCell(d.DEFAULT_ATTR_DATA),S=[];let k=0;for(let C=this.lines.length-1;C>=0;C--){let y=this.lines.get(C);if(!y||!y.isWrapped&&y.getTrimmedLength()<=v)continue;const E=[y];for(;y.isWrapped&&C>0;)y=this.lines.get(--C),E.unshift(y);const D=this.ybase+this.y;if(D>=C&&D<C+E.length)continue;const T=E[E.length-1].getTrimmedLength(),M=(0,f.reflowSmallerGetNewLineLengths)(E,this._cols,v),R=M.length-E.length;let O;O=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+R):Math.max(0,this.lines.length-this.lines.maxLength+R);const $=[];for(let I=0;I<R;I++){const H=this.getBlankLine(d.DEFAULT_ATTR_DATA,!0);$.push(H)}$.length>0&&(S.push({start:C+E.length+k,newLines:$}),k+=$.length),E.push(...$);let G=M.length-1,V=M[G];V===0&&(G--,V=M[G]);let q=E.length-R-1,L=T;for(;q>=0;){const I=Math.min(L,V);if(E[G]===void 0)break;if(E[G].copyCellsFrom(E[q],L-I,V-I,I,!0),V-=I,V===0&&(G--,V=M[G]),L-=I,L===0){q--;const H=Math.max(q,0);L=(0,f.getWrappedLineTrimmedLength)(E,H,this._cols)}}for(let I=0;I<E.length;I++)M[I]<v&&E[I].setCell(M[I],w);let N=R-O;for(;N-- >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+R,this.ybase+x-1)}if(S.length>0){const C=[],y=[];for(let G=0;G<this.lines.length;G++)y.push(this.lines.get(G));const E=this.lines.length;let D=E-1,T=0,M=S[T];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let R=0;for(let G=Math.min(this.lines.maxLength-1,E+k-1);G>=0;G--)if(M&&M.start>D+R){for(let V=M.newLines.length-1;V>=0;V--)this.lines.set(G--,M.newLines[V]);G++,C.push({index:D+1,amount:M.newLines.length}),R+=M.newLines.length,M=S[++T]}else this.lines.set(G,y[D--]);let O=0;for(let G=C.length-1;G>=0;G--)C[G].index+=O,this.lines.onInsertEmitter.fire(C[G]),O+=C[G].amount;const $=Math.max(0,E+k-this.lines.maxLength);$>0&&this.lines.onTrimEmitter.fire($)}
vendor: 13,983 bytes, line 37
37}translateBufferLineToString(v,x,w=0,S){const k=this.lines.get(v);return k?k.translateToString(x,w,S):""}getWrappedRangeForLine(v){let x=v,w=v;for(;x>0&&this.lines.get(x).isWrapped;)x--;for(;w+1<this.lines.length&&this.lines.get(w+1).isWrapped;)w++;return{first:x,last:w}}setupTabStops(v){for(v!=null?this.tabs[v]||(v=this.prevStop(v)):(this.tabs={},v=0);v<this._cols;v+=this._optionsService.rawOptions.tabStopWidth)this.tabs[v]=!0}prevStop(v){for(v==null&&(v=this.x);!this.tabs[--v]&&v>0;);return v>=this._cols?this._cols-1:v<0?0:v}nextStop(v){for(v==null&&(v=this.x);!this.tabs[++v]&&v<this._cols;);return v>=this._cols?this._cols-1:v<0?0:v}clearMarkers(v){this._isClearing=!0;for(let x=0;x<this.markers.length;x++)this.markers[x].line===v&&(this.markers[x].dispose(),this.markers.splice(x--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].dispose(),this.markers.splice(v--,1);this._isClearing=!1}addMarker(v){const x=new p.Marker(v);return this.markers.push(x),x.register(this.lines.onTrim(w=>{x.line-=w,x.line<0&&x.dispose()})),x.register(this.lines.onInsert(w=>{x.line>=w.index&&(x.line+=w.amount)})),x.register(this.lines.onDelete(w=>{x.line>=w.index&&x.line<w.index+w.amount&&x.dispose(),x.line>w.index&&(x.line-=w.amount)})),x.register(x.onDispose(()=>this._removeMarker(x))),x}_removeMarker(v){this._isClearing||this.markers.splice(this.markers.indexOf(v),1)}}},8437:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLine=o.DEFAULT_ATTR_DATA=void 0;const c=l(3734),h=l(511),u=l(643),d=l(482);o.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let f=0;class _{constructor(p,g,v=!1){this.isWrapped=v,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*p);const x=g||h.CellData.fromCharData([0,u.NULL_CELL_CHAR,u.NULL_CELL_WIDTH,u.NULL_CELL_CODE]);for(let w=0;w<p;++w)this.setCell(w,x);this.length=p}get(p){const g=this._data[3*p+0],v=2097151&g;return[this._data[3*p+1],2097152&g?this._combined[p]:v?(0,d.stringFromCodePoint)(v):"",g>>22,2097152&g?this._combined[p].charCodeAt(this._combined[p].length-1):v]}set(p,g){this._data[3*p+1]=g[u.CHAR_DATA_ATTR_INDEX],g[u.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[p]=g[1],this._data[3*p+0]=2097152|p|g[u.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*p+0]=g[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|g[u.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(p){return this._data[3*p+0]>>22}hasWidth(p){return 12582912&this._data[3*p+0]}getFg(p){return this._data[3*p+1]}getBg(p){return this._data[3*p+2]}hasContent(p){return 4194303&this._data[3*p+0]}getCodePoint(p){const g=this._data[3*p+0];return 2097152&g?this._combined[p].charCodeAt(this._combined[p].length-1):2097151&g}isCombined(p){return 2097152&this._data[3*p+0]}getString(p){const g=this._data[3*p+0];return 2097152&g?this._combined[p]:2097151&g?(0,d.stringFromCodePoint)(2097151&g):""}isProtected(p){return 536870912&this._data[3*p+2]}loadCell(p,g){return f=3*p,g.content=this._data[f+0],g.fg=this._data[f+1],g.bg=this._data[f+2],2097152&g.content&&(g.combinedData=this._combined[p]),268435456&g.bg&&(g.extended=this._extendedAttrs[p]),g}setCell(p,g){2097152&g.content&&(this._combined[p]=g.combinedData),268435456&g.bg&&(this._extendedAttrs[p]=g.extended),this._data[3*p+0]=g.content,this._data[3*p+1]=g.fg,this._data[3*p+2]=g.bg}setCellFromCodepoint(p,g,v,x){268435456&x.bg&&(this._extendedAttrs[p]=x.extended),this._data[3*p+0]=g|v<<22,this._data[3*p+1]=x.fg,this._data[3*p+2]=x.bg}addCodepointToCell(p,g,v){let x=this._data[3*p+0];2097152&x?this._combined[p]+=(0,d.stringFromCodePoint)(g):2097151&x?(this._combined[p]=(0,d.stringFromCodePoint)(2097151&x)+(0,d.stringFromCodePoint)(g),x&=-2097152,x|=2097152):x=g|4194304,v&&(x&=-12582913,x|=v<<22),this._data[3*p+0]=x}insertCells(p,g,v){if((p%=this.length)&&this.getWidth(p-1)===2&&this.setCellFromCodepoint(p-1,0,1,v),g<this.length-p){const x=new h.CellData;for(let w=this.length-p-g-1;w>=0;--w)this.setCell(p+g+w,this.loadCell(p+w,x));for(let w=0;w<g;++w)this.setCell(p+w,v)}else for(let x=p;x<this.length;++x)this.setCell(x,v);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,v)}deleteCells(p,g,v){if(p%=this.length,g<this.length-p){const x=new h.CellData;for(let w=0;w<this.length-p-g;++w)this.setCell(p+w,this.loadCell(p+g+w,x));for(let w=this.length-g;w<this.length;++w)this.setCell(w,v)}else for(let x=p;x<this.length;++x)this.setCell(x,v);p&&this.getWidth(p-1)===2&&this.setCellFromCodepoint(p-1,0,1,v),this.getWidth(p)!==0||this.hasContent(p)||this.setCellFromCodepoint(p,0,1,v)}replaceCells(p,g,v,x=!1){if(x)for(p&&this.getWidth(p-1)===2&&!this.isProtected(p-1)&&this.setCellFromCodepoint(p-1,0,1,v),g<this.length&&this.getWidth(g-1)===2&&!this.isProtected(g)&&this.setCellFromCodepoint(g,0,1,v);p<g&&p<this.length;)this.isProtected(p)||this.setCell(p,v),p++;else for(p&&this.getWidth(p-1)===2&&this.setCellFromCodepoint(p-1,0,1,v),g<this.length&&this.getWidth(g-1)===2&&this.setCellFromCodepoint(g,0,1,v);p<g&&p<this.length;)this.setCell(p++,v)}resize(p,g){if(p===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const v=3*p;if(p>this.length){if(this._data.buffer.byteLength>=4*v)this._data=new Uint32Array(this._data.buffer,0,v);else{const x=new Uint32Array(v);x.set(this._data),this._data=x}for(let x=this.length;x<p;++x)this.setCell(x,g)}else{this._data=this._data.subarray(0,v);const x=Object.keys(this._combined);for(let S=0;S<x.length;S++){const k=parseInt(x[S],10);k>=p&&delete this._combined[k]}const w=Object.keys(this._extendedAttrs);for(let S=0;S<w.length;S++){const k=parseInt(w[S],10);k>=p&&delete this._extendedAttrs[k]}}return this.length=p,4*v*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const p=new Uint32Array(this._data.length);return p.set(this._data),this._data=p,1}return 0}fill(p,g=!1){if(g)for(let v=0;v<this.length;++v)this.isProtected(v)||this.setCell(v,p);else{this._combined={},this._extendedAttrs={};for(let v=0;v<this.length;++v)this.setCell(v,p)}}copyFrom(p){this.length!==p.length?this._data=new Uint32Array(p._data):this._data.set(p._data),this.length=p.length,this._combined={};for(const g in p._combined)this._combined[g]=p._combined[g];this._extendedAttrs={};for(const g in p._extendedAttrs)this._extendedAttrs[g]=p._extendedAttrs[g];this.isWrapped=p.isWrapped}clone(){const p=new _(0);p._data=new Uint32Array(this._data),p.length=this.length;for(const g in this._combined)p._combined[g]=this._combined[g];for(const g in this._extendedAttrs)p._extendedAttrs[g]=this._extendedAttrs[g];return p.isWrapped=this.isWrapped,p}getTrimmedLength(){for(let p=this.length-1;p>=0;--p)if(4194303&this._data[3*p+0])return p+(this._data[3*p+0]>>22);return 0}getNoBgTrimmedLength(){for(let p=this.length-1;p>=0;--p)if(4194303&this._data[3*p+0]||50331648&this._data[3*p+2])return p+(this._data[3*p+0]>>22);return 0}copyCellsFrom(p,g,v,x,w){const S=p._data;if(w)for(let C=x-1;C>=0;C--){for(let y=0;y<3;y++)this._data[3*(v+C)+y]=S[3*(g+C)+y];268435456&S[3*(g+C)+2]&&(this._extendedAttrs[v+C]=p._extendedAttrs[g+C])}else for(let C=0;C<x;C++){for(let y=0;y<3;y++)this._data[3*(v+C)+y]=S[3*(g+C)+y];268435456&S[3*(g+C)+2]&&(this._extendedAttrs[v+C]=p._extendedAttrs[g+C])}const k=Object.keys(p._combined);for(let C=0;C<k.length;C++){const y=parseInt(k[C],10);y>=g&&(this._combined[y-g+v]=p._combined[y])}}translateToString(p,g,v,x){g=g??0,v=v??this.length,p&&(v=Math.min(v,this.getTrimmedLength())),x&&(x.length=0);let w="";for(;g<v;){const S=this._data[3*g+0],k=2097151&S,C=2097152&S?this._combined[g]:k?(0,d.stringFromCodePoint)(k):u.WHITESPACE_CELL_CHAR;if(w+=C,x)for(let y=0;y<C.length;++y)x.push(g);g+=S>>22||1}return x&&x.push(g),w}}o.BufferLine=_},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,h,u){if(h===c.length-1)return c[h].getTrimmedLength();const d=!c[h].hasContent(u-1)&&c[h].getWidth(u-1)===1,f=c[h+1].getWidth(0)===2;return d&&f?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,h,u,d,f){const _=[];for(let b=0;b<c.length-1;b++){let p=b,g=c.get(++p);if(!g.isWrapped)continue;const v=[c.get(b)];for(;p<c.length&&g.isWrapped;)v.push(g),g=c.get(++p);if(d>=b&&d<p){b+=v.length-1;continue}let x=0,w=l(v,x,h),S=1,k=0;for(;S<v.length;){const y=l(v,S,h),E=y-k,D=u-w,T=Math.min(E,D);v[x].copyCellsFrom(v[S],k,w,T,!1),w+=T,w===u&&(x++,w=0),k+=T,k===y&&(S++,k=0),w===0&&x!==0&&v[x-1].getWidth(u-1)===2&&(v[x].copyCellsFrom(v[x-1],u-1,w++,1,!1),v[x-1].setCell(u-1,f))}v[x].replaceCells(w,u,f);let C=0;for(let y=v.length-1;y>0&&(y>x||v[y].getTrimmedLength()===0);y--)C++;C>0&&(_.push(b+v.length-C),_.push(C)),b+=v.length-1}return _},o.reflowLargerCreateNewLayout=function(c,h){const u=[];let d=0,f=h[d],_=0;for(let b=0;b<c.length;b++)if(f===b){const p=h[++d];c.onDeleteEmitter.fire({index:b-_,amount:p}),b+=p-1,_+=p,f=h[++d]}else u.push(b);return{layout:u,countRemoved:_}},o.reflowLargerApplyNewLayout=function(c,h){const u=[];for(let d=0;d<h.length;d++)u.push(c.get(h[d]));for(let d=0;d<u.length;d++)c.set(d,u[d]);c.length=h.length},o.reflowSmallerGetNewLineLengths=function(c,h,u){const d=[],f=c.map((g,v)=>l(c,v,h)).reduce((g,v)=>g+v);let _=0,b=0,p=0;for(;p<f;){if(f-p<u){d.push(f-p);break}_+=u;const g=l(c,b,h);_>g&&(_-=g,b++);const v=c[b].getWidth(_-1)===2;v&&_--;const x=v?u-1:u;d.push(x),p+=x}return d},o.getWrappedLineTrimmedLength=l},5295:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferSet=void 0;const c=l(8460),h=l(844),u=l(9092);class d extends h.Disposable{constructor(_,b){super(),this._optionsService=_,this._bufferService=b,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(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),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){this._normal.resize(_,b),this._alt.resize(_,b),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}o.BufferSet=d},511:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CellData=void 0;const c=l(482),h=l(643),u=l(3734);class d extends u.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new u.ExtendedAttrs,this.combinedData=""}static fromCharData(_){const b=new d;return b.setFromCharData(_),b}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(_){this.fg=_[h.CHAR_DATA_ATTR_INDEX],this.bg=0;let b=!1;if(_[h.CHAR_DATA_CHAR_INDEX].length>2)b=!0;else if(_[h.CHAR_DATA_CHAR_INDEX].length===2){const p=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=p&&p<=56319){const g=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=g&&g<=57343?this.content=1024*(p-55296)+g-56320+65536|_[h.CHAR_DATA_WIDTH_INDEX]<<22:b=!0}else b=!0}else this.content=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[h.CHAR_DATA_WIDTH_INDEX]<<22;b&&(this.combinedData=_[h.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[h.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}o.CellData=d},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),h=l(844);class u{get id(){return this._id}constructor(f){this.line=f,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,h.disposeArray)(this._disposables),this._disposables.length=0)}register(f){return this._disposables.push(f),f}}
37o.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,h;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=` 38`,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}\\`}(h||(o.C1_ESCAPED=h={}))},7399:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.evaluateKeyboardEvent=void 0;const c=l(2584),h={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,d,f,_){const b={type:0,cancel:!1,key:void 0},p=(u.shiftKey?1:0)|(u.altKey?2:0)|(u.ctrlKey?4:0)|(u.metaKey?8:0);switch(u.keyCode){case 0:u.key==="UIKeyInputUpArrow"?b.key=d?c.C0.ESC+"OA":c.C0.ESC+"[A":u.key==="UIKeyInputLeftArrow"?b.key=d?c.C0.ESC+"OD":c.C0.ESC+"[D":u.key==="UIKeyInputRightArrow"?b.key=d?c.C0.ESC+"OC":c.C0.ESC+"[C":u.key==="UIKeyInputDownArrow"&&(b.key=d?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:b.key=u.ctrlKey?"\b":c.C0.DEL,u.altKey&&(b.key=c.C0.ESC+b.key);break;case 9:if(u.shiftKey){b.key=c.C0.ESC+"[Z";break}b.key=c.C0.HT,b.cancel=!0;break;case 13:b.key=u.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,b.cancel=!0;break;case 27:b.key=c.C0.ESC,u.altKey&&(b.key=c.C0.ESC+c.C0.ESC),b.cancel=!0;break;case 37:if(u.metaKey)break;p?(b.key=c.C0.ESC+"[1;"+(p+1)+"D",b.key===c.C0.ESC+"[1;3D"&&(b.key=c.C0.ESC+(f?"b":"[1;5D"))):b.key=d?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(u.metaKey)break;p?(b.key=c.C0.ESC+"[1;"+(p+1)+"C",b.key===c.C0.ESC+"[1;3C"&&(b.key=c.C0.ESC+(f?"f":"[1;5C"))):b.key=d?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(u.metaKey)break;p?(b.key=c.C0.ESC+"[1;"+(p+1)+"A",f||b.key!==c.C0.ESC+"[1;3A"||(b.key=c.C0.ESC+"[1;5A")):b.key=d?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(u.metaKey)break;p?(b.key=c.C0.ESC+"[1;"+(p+1)+"B",f||b.key!==c.C0.ESC+"[1;3B"||(b.key=c.C0.ESC+"[1;5B")):b.key=d?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:u.shiftKey||u.ctrlKey||(b.key=c.C0.ESC+"[2~");break;case 46:b.key=p?c.C0.ESC+"[3;"+(p+1)+"~":c.C0.ESC+"[3~";break;case 36:b.key=p?c.C0.ESC+"[1;"+(p+1)+"H":d?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:b.key=p?c.C0.ESC+"[1;"+(p+1)+"F":d?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:u.shiftKey?b.type=2:u.ctrlKey?b.key=c.C0.ESC+"[5;"+(p+1)+"~":b.key=c.C0.ESC+"[5~";break;case 34:u.shiftKey?b.type=3:u.ctrlKey?b.key=c.C0.ESC+"[6;"+(p+1)+"~":b.key=c.C0.ESC+"[6~";break;case 112:b.key=p?c.C0.ESC+"[1;"+(p+1)+"P":c.C0.ESC+"OP";break;case 113:b.key=p?c.C0.ESC+"[1;"+(p+1)+"Q":c.C0.ESC+"OQ";break;case 114:b.key=p?c.C0.ESC+"[1;"+(p+1)+"R":c.C0.ESC+"OR";break;case 115:b.key=p?c.C0.ESC+"[1;"+(p+1)+"S":c.C0.ESC+"OS";break;case 116:b.key=p?c.C0.ESC+"[15;"+(p+1)+"~":c.C0.ESC+"[15~";break;case 117:b.key=p?c.C0.ESC+"[17;"+(p+1)+"~":c.C0.ESC+"[17~";break;case 118:b.key=p?c.C0.ESC+"[18;"+(p+1)+"~":c.C0.ESC+"[18~";break;case 119:b.key=p?c.C0.ESC+"[19;"+(p+1)+"~":c.C0.ESC+"[19~";break;case 120:b.key=p?c.C0.ESC+"[20;"+(p+1)+"~":c.C0.ESC+"[20~";break;case 121:b.key=p?c.C0.ESC+"[21;"+(p+1)+"~":c.C0.ESC+"[21~";break;case 122:b.key=p?c.C0.ESC+"[23;"+(p+1)+"~":c.C0.ESC+"[23~";break;case 123:b.key=p?c.C0.ESC+"[24;"+(p+1)+"~":c.C0.ESC+"[24~";break;default:if(!u.ctrlKey||u.shiftKey||u.altKey||u.metaKey)if(f&&!_||!u.altKey||u.metaKey)!f||u.altKey||u.ctrlKey||u.shiftKey||!u.metaKey?u.key&&!u.ctrlKey&&!u.altKey&&!u.metaKey&&u.keyCode>=48&&u.key.length===1?b.key=u.key:u.key&&u.ctrlKey&&(u.key==="_"&&(b.key=c.C0.US),u.key==="@"&&(b.key=c.C0.NUL)):u.keyCode===65&&(b.type=1);else{const g=h[u.keyCode],v=g?.[u.shiftKey?1:0];if(v)b.key=c.C0.ESC+v;else if(u.keyCode>=65&&u.keyCode<=90){const x=u.ctrlKey?u.keyCode-64:u.keyCode+32;let w=String.fromCharCode(x);
vendor: 4,949 bytes, line 38
38u.shiftKey&&(w=w.toUpperCase()),b.key=c.C0.ESC+w}else if(u.keyCode===32)b.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()),b.key=c.C0.ESC+x,b.cancel=!0}}else u.keyCode>=65&&u.keyCode<=90?b.key=String.fromCharCode(u.keyCode-64):u.keyCode===32?b.key=c.C0.NUL:u.keyCode>=51&&u.keyCode<=55?b.key=String.fromCharCode(u.keyCode-51+27):u.keyCode===56?b.key=c.C0.DEL:u.keyCode===219?b.key=c.C0.ESC:u.keyCode===220?b.key=c.C0.FS:u.keyCode===221&&(b.key=c.C0.GS)}return b}},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,h=l.length){let u="";for(let d=c;d<h;++d){let f=l[d];f>65535?(f-=65536,u+=String.fromCharCode(55296+(f>>10))+String.fromCharCode(f%1024+56320)):u+=String.fromCharCode(f)}return u},o.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(l,c){const h=l.length;if(!h)return 0;let u=0,d=0;if(this._interim){const f=l.charCodeAt(d++);56320<=f&&f<=57343?c[u++]=1024*(this._interim-55296)+f-56320+65536:(c[u++]=this._interim,c[u++]=f),this._interim=0}for(let f=d;f<h;++f){const _=l.charCodeAt(f);if(55296<=_&&_<=56319){if(++f>=h)return this._interim=_,u;const b=l.charCodeAt(f);56320<=b&&b<=57343?c[u++]=1024*(_-55296)+b-56320+65536:(c[u++]=_,c[u++]=b)}else _!==65279&&(c[u++]=_)}return u}},o.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(l,c){const h=l.length;if(!h)return 0;let u,d,f,_,b=0,p=0,g=0;if(this.interim[0]){let w=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,C=0;for(;(k=63&this.interim[++C])&&C<4;)S<<=6,S|=k;const y=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=y-C;for(;g<E;){if(g>=h)return 0;if(k=l[g++],(192&k)!=128){g--,w=!0;break}this.interim[C++]=k,S<<=6,S|=63&k}w||(y===2?S<128?g--:c[b++]=S:y===3?S<2048||S>=55296&&S<=57343||S===65279||(c[b++]=S):S<65536||S>1114111||(c[b++]=S)),this.interim.fill(0)}const v=h-4;let x=g;for(;x<h;){for(;!(!(x<v)||128&(u=l[x])||128&(d=l[x+1])||128&(f=l[x+2])||128&(_=l[x+3]));)c[b++]=u,c[b++]=d,c[b++]=f,c[b++]=_,x+=4;if(u=l[x++],u<128)c[b++]=u;else if((224&u)==192){if(x>=h)return this.interim[0]=u,b;if(d=l[x++],(192&d)!=128){x--;continue}if(p=(31&u)<<6|63&d,p<128){x--;continue}c[b++]=p}else if((240&u)==224){if(x>=h)return this.interim[0]=u,b;if(d=l[x++],(192&d)!=128){x--;continue}if(x>=h)return this.interim[0]=u,this.interim[1]=d,b;if(f=l[x++],(192&f)!=128){x--;continue}if(p=(15&u)<<12|(63&d)<<6|63&f,p<2048||p>=55296&&p<=57343||p===65279)continue;c[b++]=p}else if((248&u)==240){if(x>=h)return this.interim[0]=u,b;if(d=l[x++],(192&d)!=128){x--;continue}if(x>=h)return this.interim[0]=u,this.interim[1]=d,b;if(f=l[x++],(192&f)!=128){x--;continue}if(x>=h)return this.interim[0]=u,this.interim[1]=d,this.interim[2]=f,b;if(_=l[x++],(192&_)!=128){x--;continue}if(p=(7&u)<<18|(63&d)<<12|(63&f)<<6|63&_,p<65536||p>1114111)continue;c[b++]=p}}return b}}},225:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const c=l(1480),h=[[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
vendor: 10,768 bytes, line 38
38],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let d;o.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let f=0;f<h.length;++f)d.fill(0,h[f][0],h[f][1]+1)}}wcwidth(f){return f<32?0:f<127?1:f<65536?d[f]:function(_,b){let p,g=0,v=b.length-1;if(_<b[0][0]||_>b[v][1])return!1;for(;v>=g;)if(p=g+v>>1,_>b[p][1])g=p+1;else{if(!(_<b[p][0]))return!0;v=p-1}return!1}(f,u)?0:f>=131072&&f<=196605||f>=196608&&f<=262141?2:1}charProperties(f,_){let b=this.wcwidth(f),p=b===0&&_!==0;if(p){const g=c.UnicodeService.extractWidth(_);g===0?p=!1:g>b&&(b=g)}return c.UnicodeService.createPropertyValue(0,b,p)}}},5981:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WriteBuffer=void 0;const c=l(8460),h=l(844);class u extends h.Disposable{constructor(f){super(),this._action=f,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(f,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=f.length,this._writeBuffer.push(f),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let b;for(this._isSyncWriting=!0;b=this._writeBuffer.shift();){this._action(b);const p=this._callbacks.shift();p&&p()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(f,_){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+=f.length,this._writeBuffer.push(f),this._callbacks.push(_),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=f.length,this._writeBuffer.push(f),this._callbacks.push(_)}_innerWrite(f=0,_=!0){const b=f||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const p=this._writeBuffer[this._bufferOffset],g=this._action(p,_);if(g){const x=w=>Date.now()-b>=12?setTimeout(()=>this._innerWrite(0,w)):this._innerWrite(b,w);return void g.catch(w=>(queueMicrotask(()=>{throw w}),Promise.resolve(!1))).then(x)}const v=this._callbacks[this._bufferOffset];if(v&&v(),this._bufferOffset++,this._pendingData-=p.length,Date.now()-b>=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 h(u,d){const f=u.toString(16),_=f.length<2?"0"+f:f;switch(d){case 4:return f[0];case 8:return _;case 12:return(_+_).slice(0,3);default:return _+_}}o.parseColor=function(u){if(!u)return;let d=u.toLowerCase();if(d.indexOf("rgb:")===0){d=d.slice(4);const f=l.exec(d);if(f){const _=f[1]?15:f[4]?255:f[7]?4095:65535;return[Math.round(parseInt(f[1]||f[4]||f[7]||f[10],16)/_*255),Math.round(parseInt(f[2]||f[5]||f[8]||f[11],16)/_*255),Math.round(parseInt(f[3]||f[6]||f[9]||f[12],16)/_*255)]}}else if(d.indexOf("#")===0&&(d=d.slice(1),c.exec(d)&&[3,6,9,12].includes(d.length))){const f=d.length/3,_=[0,0,0];for(let b=0;b<3;++b){const p=parseInt(d.slice(f*b,f*b+f),16);_[b]=f===1?p<<4:f===2?p:f===3?p>>4:p>>8}return _}},o.toRgbString=function(u,d=16){const[f,_,b]=u;return`rgb:${h(f,d)}/${h(_,d)}/${h(b,d)}`}},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),h=l(8742),u=l(5770),d=[];o.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=d,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}registerHandler(_,b){this._handlers[_]===void 0&&(this._handlers[_]=[]);const p=this._handlers[_];return p.push(b),{dispose:()=>{const g=p.indexOf(b);g!==-1&&p.splice(g,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}reset(){if(this._active.length)for(let _=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;_>=0;--_)this._active[_].unhook(!1);this._stack.paused=!1,this._active=d,this._ident=0}hook(_,b){if(this.reset(),this._ident=_,this._active=this._handlers[_]||d,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(_,b,p){if(this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].put(_,b,p);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(_,b,p))}unhook(_,b=!0){if(this._active.length){let p=!1,g=this._active.length-1,v=!1;if(this._stack.paused&&(g=this._stack.loopPosition-1,p=b,v=this._stack.fallThrough,this._stack.paused=!1),!v&&p===!1){for(;g>=0&&(p=this._active[g].unhook(_),p!==!0);g--)if(p instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!1,p;g--}for(;g>=0;g--)if(p=this._active[g].unhook(!1),p instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=g,this._stack.fallThrough=!0,p}else this._handlerFb(this._ident,"UNHOOK",_);this._active=d,this._ident=0}};const f=new h.Params;f.addParam(0),o.DcsHandler=class{constructor(_){this._handler=_,this._data="",this._params=f,this._hitLimit=!1}hook(_){this._params=_.length>1||_.params[0]?_.clone():f,this._data="",this._hitLimit=!1}put(_,b,p){this._hitLimit||(this._data+=(0,c.utf32ToString)(_,b,p),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(_){let b=!1;if(this._hitLimit)b=!1;else if(_&&(b=this._handler(this._data,this._params),b instanceof Promise))return b.then(p=>(this._params=f,this._data="",this._hitLimit=!1,p));return this._params=f,this._data="",this._hitLimit=!1,b}}},2015:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.EscapeSequenceParser=o.VT500_TRANSITION_TABLE=o.TransitionTable=void 0;const c=l(844),h=l(8742),u=l(6242),d=l(6351);class f{constructor(g){this.table=new Uint8Array(g)}setDefault(g,v){this.table.fill(g<<4|v)}add(g,v,x,w){this.table[v<<8|g]=x<<4|w}addMany(g,v,x,w){for(let S=0;S<g.length;S++)this.table[v<<8|g[S]]=x<<4|w}}o.TransitionTable=f;const _=160;o.VT500_TRANSITION_TABLE=function(){const p=new f(4095),g=Array.apply(null,Array(256)).map((C,y)=>y),v=(C,y)=>g.slice(C,y),x=v(32,127),w=v(0,24);w.push(25),w.push.apply(w,v(28,32));const S=v(0,14);let k;for(k in p.setDefault(1,0),p.addMany(x,0,2,0),S)p.addMany([24,26,153,154],k,3,0),p.addMany(v(128,144),k,3,0),p.addMany(v(144,152),k,3,0),p.add(156,k,0,0),p.add(27,k,11,1),p.add(157,k,4,8),p.addMany([152,158,159],k,0,7),p.add(155,k,11,3),p.add(144,k,11,9);return p.addMany(w,0,3,0),p.addMany(w,1,3,1),p.add(127,1,0,1),p.addMany(w,8,0,8),p.addMany(w,3,3,3),p.add(127,3,0,3),p.addMany(w,4,3,4),p.add(127,4,0,4),p.addMany(w,6,3,6),p.addMany(w,5,3,5),p.add(127,5,0,5),p.addMany(w,2,3,2),p.add(127,2,0,2),p.add(93,1,4,8),p.addMany(x,8,5,8),p.add(127,8,5,8),p.addMany([156,27,24,26,7],8,6,0),p.addMany(v(28,32),8,0,8),p.addMany([88,94,95],1,0,7),p.addMany(x,7,0,7),p.addMany(w,7,0,7),p.add(156,7,0,0),p.add(127,7,0,7),p.add(91,1,11,3),p.addMany(v(64,127),3,7,0),p.addMany(v(48,60),3,8,4),p.addMany([60,61,62,63],3,9,4),p.addMany(v(48,60),4,8,4),p.addMany(v(64,127),4,7,0),p.addMany([60,61,62,63],4,0,6),p.addMany(v(32,64),6,0,6),p.add(127,6,0,6),p.addMany(v(64,127),6,0,0),p.addMany(v(32,48),3,9,5),p.addMany(v(32,48),5,9,5),p.addMany(v(48,64),5,0,6),p.addMany(v(64,127),5,7,0),p.addMany(v(32,48),4,9,5),p.addMany(v(32,48),1,9,2),p.addMany(v(32,48),2,9,2),p.addMany(v(48,127),2,10,0),p.addMany(v(48,80),1,10,0),p.addMany(v(81,88),1,10,0),p.addMany([89,90,92],1,10,0),p.addMany(v(96,127),1,10,0),p.add(80,1,11,9),p.addMany(w,9,0,9),p.add(127,9,0,9),p.addMany(v(28,32),9,0,9),p.addMany(v(32,48),9,9,12),p.addMany(v(48,60),9,8,10),p.addMany([60,61,62,63],9,9,10),p.addMany(w,11,0,11),p.addMany(v(32,128),11,0,11),p.addMany(v(28,32),11,0,11),p.addMany(w,10,0,10),p.add(127,10,0,10),p.addMany(v(28,32),10,0,10),p.addMany(v(48,60),10,8,10),p.addMany([60,61,62,63],10,0,11),p.addMany(v(32,48),10,9,12),p.addMany(w,12,0,12),p.add(127,12,0,12),p.addMany(v(28,32),12,0,12),p.addMany(v(32,48),12,9,12),p.addMany(v(48,64),12,0,11),p.addMany(v(64,127),12,12,13),p.addMany(v(64,127),10,12,13),p.addMany(v(64,127),9,12,13),p.addMany(w,13,13,13),p.addMany(x,13,13,13),p.add(127,13,0,13),p.addMany([27,156,24,26],13,14,0),p.add(_,0,2,0),p.add(_,8,5,8),p.add(_,6,0,6),p.add(_,11,0,11),p.add(_,13,13,13),p}();class b extends c.Disposable{constructor(g=o.VT500_TRANSITION_TABLE){super(),this._transitions=g,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new h.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(v,x,w)=>{},this._executeHandlerFb=v=>{},this._csiHandlerFb=(v,x)=>{},this._escHandlerFb=v=>{},this._errorHandlerFb=v=>v,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 d.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(g,v=[64,126]){let x=0;if(g.prefix){if(g.prefix.length>1)throw new Error("only one byte as prefix supported");if(x=g.prefix.charCodeAt(0),x&&60>x||x>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(g.intermediates){if(g.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<g.intermediates.length;
38++S){const k=g.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");x<<=8,x|=k}}if(g.final.length!==1)throw new Error("final must be a single byte");const w=g.final.charCodeAt(0);if(v[0]>w||w>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return x<<=8,x|=w,x}identToString(g){const v=[];for(;g;)v.push(String.fromCharCode(255&g)),g>>=8;return v.reverse().join("")}setPrintHandler(g){this._printHandler=g}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(g,v){const x=this._identifier(g,[48,126]);this._escHandlers[x]===void 0&&(this._escHandlers[x]=[]);const w=this._escHandlers[x];return w.push(v),{dispose:()=>{const S=w.indexOf(v);S!==-1&&w.splice(S,1)}}}clearEscHandler(g){this._escHandlers[this._identifier(g,[48,126])]&&delete this._escHandlers[this._identifier(g,[48,126])]}setEscHandlerFallback(g){this._escHandlerFb=g}setExecuteHandler(g,v){this._executeHandlers[g.charCodeAt(0)]=v}clearExecuteHandler(g){this._executeHandlers[g.charCodeAt(0)]&&delete this._executeHandlers[g.charCodeAt(0)]}setExecuteHandlerFallback(g){this._executeHandlerFb=g}registerCsiHandler(g,v){const x=this._identifier(g);this._csiHandlers[x]===void 0&&(this._csiHandlers[x]=[]);const w=this._csiHandlers[x];return w.push(v),{dispose:()=>{const S=w.indexOf(v);S!==-1&&w.splice(S,1)}}}clearCsiHandler(g){this._csiHandlers[this._identifier(g)]&&delete this._csiHandlers[this._identifier(g)]}setCsiHandlerFallback(g){this._csiHandlerFb=g}registerDcsHandler(g,v){return this._dcsParser.registerHandler(this._identifier(g),v)}clearDcsHandler(g){this._dcsParser.clearHandler(this._identifier(g))}setDcsHandlerFallback(g){this._dcsParser.setHandlerFallback(g)}registerOscHandler(g,v){return this._oscParser.registerHandler(g,v)}clearOscHandler(g){this._oscParser.clearHandler(g)}setOscHandlerFallback(g){this._oscParser.setHandlerFallback(g)}setErrorHandler(g){this._errorHandler=g}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(g,v,x,w,S){this._parseStack.state=g,this._parseStack.handlers=v,this._parseStack.handlerPos=x,this._parseStack.transition=w,this._parseStack.chunkPos=S}parse(g,v,x){let w,S=0,k=0,C=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,C=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 y=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(x===!1&&E>-1){for(;E>=0&&(w=y[E](this._params),w!==!0);E--)if(w instanceof Promise)return this._parseStack.handlerPos=E,w}this._parseStack.handlers=[];break;case 4:if(x===!1&&E>-1){for(;E>=0&&(w=y[E](),w!==!0);E--)if(w instanceof Promise)return this._parseStack.handlerPos=E,w}this._parseStack.handlers=[];break;case 6:if(S=g[this._parseStack.chunkPos],w=this._dcsParser.unhook(S!==24&&S!==26,x),w)return w;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=g[this._parseStack.chunkPos],w=this._oscParser.end(S!==24&&S!==26,x),w)return w;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,C=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let y=C;y<v;++y){switch(S=g[y],k=this._transitions.table[this.currentState<<8|(S<160?S:_)],k>>4){case 2:for(let R=y+1;;++R){if(R>=v||(S=g[R])<32||S>126&&S<_){this._printHandler(g,y,R),y=R-1;break}if(++R>=v||(S=g[R])<32||S>126&&S<_){this._printHandler(g,y,R),y=R-1;break}if(++R>=v||(S=g[R])<32||S>126&&S<_){this._printHandler(g,y,R),y=R-1;break}if(++R>=v||(S=g[R])<32||S>126&&S<_){this._printHandler(g,y,R),y=R-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:y,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|S];let D=E?E.length-1:-1;for(;D>
38=0&&(w=E[D](this._params),w!==!0);D--)if(w instanceof Promise)return this._preserveStack(3,E,D,k,y),w;D<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingJoinState=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++y<v&&(S=g[y])>47&&S<60);y--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const T=this._escHandlers[this._collect<<8|S];let M=T?T.length-1:-1;for(;M>=0&&(w=T[M](),w!==!0);M--)if(w instanceof Promise)return this._preserveStack(4,T,M,k,y),w;M<0&&this._escHandlerFb(this._collect<<8|S),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|S,this._params);break;case 13:for(let R=y+1;;++R)if(R>=v||(S=g[R])===24||S===26||S===27||S>127&&S<_){this._dcsParser.put(g,y,R),y=R-1;break}break;case 14:if(w=this._dcsParser.unhook(S!==24&&S!==26),w)return this._preserveStack(6,[],0,k,y),w;S===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 R=y+1;;R++)if(R>=v||(S=g[R])<32||S>127&&S<_){this._oscParser.put(g,y,R),y=R-1;break}break;case 6:if(w=this._oscParser.end(S!==24&&S!==26),w)return this._preserveStack(5,[],0,k,y),w;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&k}}}o.EscapeSequenceParser=b},6242:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OscHandler=o.OscParser=void 0;const c=l(5770),h=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(d,f){this._handlers[d]===void 0&&(this._handlers[d]=[]);const _=this._handlers[d];return _.push(f),{dispose:()=>{const b=_.indexOf(f);b!==-1&&_.splice(b,1)}}}clearHandler(d){this._handlers[d]&&delete this._handlers[d]}setHandlerFallback(d){this._handlerFb=d}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=u}reset(){if(this._state===2)for(let d=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;d>=0;--d)this._active[d].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 d=this._active.length-1;d>=0;d--)this._active[d].start();else this._handlerFb(this._id,"START")}_put(d,f,_){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(d,f,_);else this._handlerFb(this._id,"PUT",(0,h.utf32ToString)(d,f,_))}start(){this.reset(),this._state=1}put(d,f,_){if(this._state!==3){if(this._state===1)for(;f<_;){const b=d[f++];if(b===59){this._state=2,this._start();break}if(b<48||57<b)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+b-48}this._state===2&&_-f>0&&this._put(d,f,_)}}end(d,f=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let _=!1,b=this._active.length-1,p=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,_=f,p=this._stack.fallThrough,this._stack.paused=!1),!p&&_===!1){for(;b>=0&&(_=this._active[b].end(d),_!==!0);b--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,_;b--}for(;b>=0;b--)if(_=this._active[b].end(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,_}else this._handlerFb(this._id,"END",d);this._active=u,this._id=-1,this._state=0}}},o.OscHandler=class{constructor(d){this._handler=d,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(d,f,_){this._hitLimit||(this._data+=(0,h.utf32ToString)(d,f,_),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(d){let f=!1;if(this._hitLimit)f=!1;else if(d&&(f=this._handler(this._data),f instanceof Promise))return f.then(_=>(this._data="",this._hitLimit=!1,_));return this._data="",this._hitLimit=!1,f}}},8742:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}
vendor: 5,112 bytes, line 38
38),o.Params=void 0;const l=2147483647;class c{static fromArray(u){const d=new c;if(!u.length)return d;for(let f=Array.isArray(u[0])?1:0;f<u.length;++f){const _=u[f];if(Array.isArray(_))for(let b=0;b<_.length;++b)d.addSubParam(_[b]);else d.addParam(_)}return d}constructor(u=32,d=32){if(this.maxLength=u,this.maxSubParamsLength=d,d>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(u),this.length=0,this._subParams=new Int32Array(d),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 d=0;d<this.length;++d){u.push(this.params[d]);const f=this._subParamsIdx[d]>>8,_=255&this._subParamsIdx[d];_-f>0&&u.push(Array.prototype.slice.call(this._subParams,f,_))}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 d=this._subParamsIdx[u]>>8,f=255&this._subParamsIdx[u];return f-d>0?this._subParams.subarray(d,f):null}getSubParamsAll(){const u={};for(let d=0;d<this.length;++d){const f=this._subParamsIdx[d]>>8,_=255&this._subParamsIdx[d];_-f>0&&(u[d]=this._subParams.slice(f,_))}return u}addDigit(u){let d;if(this._rejectDigits||!(d=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const f=this._digitIsSub?this._subParams:this.params,_=f[d-1];f[d-1]=~_?Math.min(10*_+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 h={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(h),c.dispose=()=>this._wrappedAddonDispose(h),c.activate(l)}_wrappedAddonDispose(l){if(l.isDisposed)return;let c=-1;for(let h=0;h<this._addons.length;h++)if(this._addons[h]===l){c=h;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),h=l(511);o.BufferApiView=class{constructor(u,d){this._buffer=u,this.type=d}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 d=this._buffer.lines.get(u);if(d)return new c.BufferLineApiView(d)}getNullCell(){return new h.CellData}}},3785:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLineApiView=void 0;const c=l(511);o.BufferLineApiView=class{constructor(h){this._line=h}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(h,u){if(!(h<0||h>=this._line.length))return u?(this._line.loadCell(h,u),u):this._line.loadCell(h,new c.CellData)}translateToString(h,u,d){return this._line.translateToString(h,u,d)}}},8285:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferNamespaceApi=void 0;const c=l(8771),h=l(8460),u=l(844);class d extends u.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this.register(new h.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=d},7975:(a,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ParserApi=void 0,o.ParserApi=class{constructor(l){this._core=l}
38registerCsiHandler(l,c){return this._core.registerCsiHandler(l,h=>c(h.toArray()))}addCsiHandler(l,c){return this.registerCsiHandler(l,c)}registerDcsHandler(l,c){return this._core.registerDcsHandler(l,(h,u)=>c(h,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(p,g,v,x){var w,S=arguments.length,k=S<3?g:x===null?x=Object.getOwnPropertyDescriptor(g,v):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(p,g,v,x);else for(var C=p.length-1;C>=0;C--)(w=p[C])&&(k=(S<3?w(k):S>3?w(g,v,k):w(g,v))||k);return S>3&&k&&Object.defineProperty(g,v,k),k},h=this&&this.__param||function(p,g){return function(v,x){g(v,x,p)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferService=o.MINIMUM_ROWS=o.MINIMUM_COLS=void 0;const u=l(8460),d=l(844),f=l(5295),_=l(2585);
38o.MINIMUM_COLS=2,o.MINIMUM_ROWS=1;let b=o.BufferService=class extends d.Disposable{get buffer(){return this.buffers.active}constructor(p){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(p.rawOptions.cols||0,o.MINIMUM_COLS),this.rows=Math.max(p.rawOptions.rows||0,o.MINIMUM_ROWS),this.buffers=this.register(new f.BufferSet(p,this))}resize(p,g){this.cols=p,this.rows=g,this.buffers.resize(p,g),this._onResize.fire({cols:p,rows:g})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(p,g=!1){const v=this.buffer;let x;x=this._cachedBlankLine,x&&x.length===this.cols&&x.getFg(0)===p.fg&&x.getBg(0)===p.bg||(x=v.getBlankLine(p,g),this._cachedBlankLine=x),x.isWrapped=g;const w=v.ybase+v.scrollTop,S=v.ybase+v.scrollBottom;if(v.scrollTop===0){const k=v.lines.isFull;S===v.lines.length-1?k?v.lines.recycle().copyFrom(x):v.lines.push(x.clone()):v.lines.splice(S+1,0,x.clone()),k?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const k=S-w+1;v.lines.shiftElements(w+1,k-1,-1),v.lines.set(S,x.clone())}this.isUserScrolling||(v.ydisp=v.ybase),this._onScroll.fire(v.ydisp)}scrollLines(p,g,v){const x=this.buffer;if(p<0){if(x.ydisp===0)return;this.isUserScrolling=!0}else p+x.ydisp>=x.ybase&&(this.isUserScrolling=!1);const w=x.ydisp;x.ydisp=Math.max(Math.min(x.ydisp+p,x.ybase),0),w!==x.ydisp&&(g||this._onScroll.fire(x.ydisp))}};o.BufferService=b=c([h(0,_.IOptionsService)],b)},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,w,S,k){var C,y=arguments.length,E=y<3?w:k===null?k=Object.getOwnPropertyDescriptor(w,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(x,w,S,k);else for(var D=x.length-1;D>=0;D--)(C=x[D])&&(E=(y<3?C(E):y>3?C(w,S,E):C(w,S))||E);return y>3&&E&&Object.defineProperty(w,S,E),E},h=this&&this.__param||function(x,w){return function(S,k){w(S,k,x)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreMouseService=void 0;const u=l(2585),d=l(8460),f=l(844),_={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 b(x,w){let S=(x.ctrl?16:0)|(x.shift?4:0)|(x.alt?8:0);return x.button===4?(S|=64,S|=x.action):(S|=3&x.button,4&x.button&&(S|=64),8&x.button&&(S|=128),x.action===32?S|=32:x.action!==0||w||(S|=3)),S}const p=String.fromCharCode,g={DEFAULT:x=>{const w=[b(x,!1)+32,x.col+32,x.row+32];return w[0]>255||w[1]>255||w[2]>255?"":`\x1B[M${p(w[0])}${p(w[1])}${p(w[2])}`},SGR:x=>{const w=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${b(x,!0)};${x.col};${x.row}${w}`},SGR_PIXELS:x=>{const w=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${b(x,!0)};${x.x};${x.y}${w}`}};let v=o.CoreMouseService=class extends f.Disposable{constructor(x,w){super(),this._bufferService=x,this._coreService=w,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new d.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(_))this.addProtocol(S,_[S]);for(const S of Object.keys(g))this.addEncoding(S,g[S]);this.reset()}addProtocol(x,w){this._protocols[x]=w}addEncoding(x,w){this._encodings[x]=w}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 w=this._encodings[this._activeEncoding](x);return w&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(w):this._coreService.triggerDataEvent(w,!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,w,S){if(S){if(x.x!==w.x||x.y!==w.y)return!1}else if(x.col!==w.col||x.row!==w.row)return!1;return x.button===w.button&&x.action===w.action&&x.ctrl===w.ctrl&&x.alt===w.alt&&x.shift===w.shift}};o.CoreMouseService=v=c([h(0,u.IBufferService),h(1,u.ICoreService)],v)},6975:function(a,o,l){var c=this&&this.__decorate||function(v,x,w,S){var k,
38C=arguments.length,y=C<3?x:S===null?S=Object.getOwnPropertyDescriptor(x,w):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(v,x,w,S);else for(var E=v.length-1;E>=0;E--)(k=v[E])&&(y=(C<3?k(y):C>3?k(x,w,y):k(x,w))||y);return C>3&&y&&Object.defineProperty(x,w,y),y},h=this&&this.__param||function(v,x){return function(w,S){x(w,S,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreService=void 0;const u=l(1439),d=l(8460),f=l(844),_=l(2585),b=Object.freeze({insertMode:!1}),p=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let g=o.CoreService=class extends f.Disposable{constructor(v,x,w){super(),this._bufferService=v,this._logService=x,this._optionsService=w,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new d.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new d.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new d.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new d.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,u.clone)(b),this.decPrivateModes=(0,u.clone)(p)}reset(){this.modes=(0,u.clone)(b),this.decPrivateModes=(0,u.clone)(p)}triggerDataEvent(v,x=!1){if(this._optionsService.rawOptions.disableStdin)return;const w=this._bufferService.buffer;x&&this._optionsService.rawOptions.scrollOnUserInput&&w.ybase!==w.ydisp&&this._onRequestScrollToBottom.f
vendor: 10,724 bytes, line 38
38ire(),x&&this._onUserInput.fire(),this._logService.debug(`sending data "${v}"`,()=>v.split("").map(S=>S.charCodeAt(0))),this._onData.fire(v)}triggerBinaryEvent(v){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${v}"`,()=>v.split("").map(x=>x.charCodeAt(0))),this._onBinary.fire(v))}};o.CoreService=g=c([h(0,_.IBufferService),h(1,_.ILogService),h(2,_.IOptionsService)],g)},9074:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DecorationService=void 0;const c=l(8055),h=l(8460),u=l(844),d=l(6106);let f=0,_=0;class b extends u.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new d.SortedList(v=>v?.marker.line),this._onDecorationRegistered=this.register(new h.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new h.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,u.toDisposable)(()=>this.reset()))}registerDecoration(v){if(v.marker.isDisposed)return;const x=new p(v);if(x){const w=x.marker.onDispose(()=>x.dispose());x.onDispose(()=>{x&&(this._decorations.delete(x)&&this._onDecorationRemoved.fire(x),w.dispose())}),this._decorations.insert(x),this._onDecorationRegistered.fire(x)}return x}reset(){for(const v of this._decorations.values())v.dispose();this._decorations.clear()}*getDecorationsAtCell(v,x,w){let S=0,k=0;for(const C of this._decorations.getKeyIterator(x))S=C.options.x??0,k=S+(C.options.width??1),v>=S&&v<k&&(!w||(C.options.layer??"bottom")===w)&&(yield C)}forEachDecorationAtCell(v,x,w,S){this._decorations.forEachByKey(x,k=>{f=k.options.x??0,_=f+(k.options.width??1),v>=f&&v<_&&(!w||(k.options.layer??"bottom")===w)&&S(k)})}}o.DecorationService=b;class p 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(v){super(),this.options=v,this.onRenderEmitter=this.register(new h.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=v.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),h=l(8343);class u{constructor(...f){this._entries=new Map;for(const[_,b]of f)this.set(_,b)}set(f,_){const b=this._entries.get(f);return this._entries.set(f,_),b}forEach(f){for(const[_,b]of this._entries.entries())f(_,b)}has(f){return this._entries.has(f)}get(f){return this._entries.get(f)}}o.ServiceCollection=u,o.InstantiationService=class{constructor(){this._services=new u,this._services.set(c.IInstantiationService,this)}setService(d,f){this._services.set(d,f)}getService(d){return this._services.get(d)}createInstance(d,...f){const _=(0,h.getServiceDependencies)(d).sort((g,v)=>g.index-v.index),b=[];for(const g of _){const v=this._services.get(g.id);if(!v)throw new Error(`[createInstance] ${d.name} depends on UNKNOWN service ${g.id}.`);b.push(v)}const p=_.length>0?_[0].index:f.length;if(f.length!==p)throw new Error(`[createInstance] First service dependency of ${d.name} at position ${p+1} conflicts with ${f.length} static arguments`);return new d(...f,...b)}}},7866:function(a,o,l){var c=this&&this.__decorate||function(p,g,v,x){var w,S=arguments.length,k=S<3?g:x===null?x=Object.getOwnPropertyDescriptor(g,v):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(p,g,v,x);else for(var C=p.length-1;C>=0;C--)(w=p[C])&&(k=(S<3?w(k):S>3?w(g,v,k):w(g,v))||k);return S>3&&k&&Object.defineProperty(g,v,k),k},h=this&&this.__param||function(p,g){return function(v,x){g(v,x,p)}};Object.defineProperty(o,"__esModule",{value:!0}),o.traceCall=o.setTraceLogger=o.LogService=void 0;const u=l(844),d=l(2585),f={trace:d.LogLevelEnum.TRACE,debug:d.LogLevelEnum.DEBUG,info:d.LogLevelEnum.INFO,warn:d.LogLevelEnum.WARN,error:d.LogLevelEnum.ERROR,off:d.LogLevelEnum.OFF};let _,b=o.LogService=class extends u.Disposable{get logLevel(){return this._logLevel}constructor(p){super(),this._optionsService=p,this._logLevel=d.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),_=this}_updateLogLevel(){this._logLevel=f[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(p){for(let g=0;g<p.length;g++)typeof p[g]=="function"&&(p[g]=p[g]())}_log(p,g,v){this._evalLazyOptionalParams(v),p.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+g,...v)}trace(p,...g){this._logLevel<=d.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,p,g)}debug(p,...g){this._logLevel<=d.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,p,g)}info(p,...g){this._logLevel<=d.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,p,g)}warn(p,...g){this._logLevel<=d.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,p,g)}error(p,...g){this._logLevel<=d.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,p,g)}};o.LogService=b=c([h(0,d.IOptionsService)],b),o.setTraceLogger=function(p){_=p},o.traceCall=function(p,g,v){if(typeof v.value!="function")throw new Error("not supported");const x=v.value;v.value=function(...w){if(_.logLevel!==d.LogLevelEnum.TRACE)return x.apply(this,w);_.trace(`GlyphRenderer#${x.name}(${w.map(k=>JSON.stringify(k)).join(", ")})`);const S=x.apply(this,w);return _.trace(`GlyphRenderer#${x.name} return`,S),S}}},7302:(a,o,l)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OptionsService=o.DEFAULT_OPTIONS=void 0;const c=l(8460),h=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 d=["normal","bold","100","200","300","400","500","600","700","800","900"];class f extends h.Disposable{constructor(b){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const p={...o.DEFAULT_OPTIONS};for(const g in b)if(g in p)try{const v=b[g];p[g]=this._sanitizeAndValidateOption(g,v)}catch(v){console.error(v)}this.rawOptions=p,this.options={...p},this._setupOptions(),this.register((0,h.toDisposable)(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(b,p){return this.onOptionChange(g=>{g===b&&p(this.rawOptions[b])})}onMultipleOptionChange(b,p){return this.onOptionChange(g=>{b.indexOf(g)!==-1&&p()})}_setupOptions(){const b=g=>{if(!(g in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${g}"`);return this.rawOptions[g]},p=(g,v)=>{if(!(g in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${g}"`);v=this._sanitizeAndValidateOption(g,v),this.rawOptions[g]!==v&&(this.rawOptions[g]=v,this._onOptionChange.fire(g))};for(const g in this.rawOptions){const v={get:b.bind(this,g),set:p.bind(this,g)};Object.defineProperty(this.options,g,v)}}_sanitizeAndValidateOption(b,p){switch(b){case"cursorStyle":if(p||(p=o.DEFAULT_OPTIONS[b]),!function(g){return g==="block"||g==="underline"||g==="bar"}(p))throw new Error(`"${p}" is not a valid value for ${b}`);break;case"wordSeparator":p||(p=o.DEFAULT_OPTIONS[b]);break;case"fontWeight":case"fontWeightBold":if(typeof p=="number"&&1<=p&&p<=1e3)break;p=d.includes(p)?p:o.DEFAULT_OPTIONS[b];break;case"cursorWidth":p=Math.floor(p);case"lineHeight":case"tabStopWidth":if(p<1)throw new Error(`${b} cannot be less than 1, value: ${p}`);break;case"minimumContrastRatio":p=Math.max(1,Math.min(21,Math.round(10*p)/10));break;case"scrollback":if((p=Math.min(p,4294967295))<0)throw new Error(`${b} cannot be less than 0, value: ${p}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(p<=0)throw new Error(`${b} cannot be less than or equal to 0, value: ${p}`);break;case"rows":case"cols":if(!p&&p!==0)throw new Error(`${b} must be numeric, value: ${p}`);break;case"windowsPty":p=p??{}}return p}}o.OptionsService=f},2660:function(a,o,l){var c=this&&this.__decorate||function(f,_,b,p){var g,v=arguments.length,x=v<3?_:p===null?p=Object.getOwnPropertyDescriptor(_,b):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(f,_,b,p);else for(var w=f.length-1;w>=0;w--)(g=f[w])&&(x=(v<3?g(x):v>3?g(_,b,x):g(_,b))||x);return v>3&&x&&Object.defineProperty(_,b,x),x},h=this&&this.__param||function(f,_){return function(b,p){_(b,p,f)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkService=void 0;const u=l(2585);let d=o.OscLinkService=class{constructor(f){this._bufferService=f,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(f){const _=this._bufferService.buffer;if(f.id===void 0){const w=_.addMarker(_.ybase+_.y),S={data:f,id:this._nextId++,lines:[w]};return w.onDispose(()=>this._removeMarkerFromLink(S,w)),this._dataByLinkId.set(S.id,S),S.id}const b=f,p=this._getEntryIdKey(b),g=this._entriesWithId.get(p);if(g)return this.addLineToLink(g.id,_.ybase+_.y),g.id;const v=_.addMarker(_.ybase+_.y),x={id:this._nextId++,key:this._getEntryIdKey(b),data:b,lines:[v]};return v.onDispose(()=>
38this._removeMarkerFromLink(x,v)),this._entriesWithId.set(x.key,x),this._dataByLinkId.set(x.id,x),x.id}addLineToLink(f,_){const b=this._dataByLinkId.get(f);if(b&&b.lines.every(p=>p.line!==_)){const p=this._bufferService.buffer.addMarker(_);b.lines.push(p),p.onDispose(()=>this._removeMarkerFromLink(b,p))}}getLinkData(f){return this._dataByLinkId.get(f)?.data}_getEntryIdKey(f){return`${f.id};;${f.uri}`}_removeMarkerFromLink(f,_){const b=f.lines.indexOf(_);b!==-1&&(f.lines.splice(b,1),f.lines.length===0&&(f.data.id!==void 0&&this._entriesWithId.delete(f.key),this._dataByLinkId.delete(f.id)))}};o.OscLinkService=d=c([h(0,u.IBufferService)],d)},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(h){return h[c]||[]},o.createDecorator=function(h){if(o.serviceRegistry.has(h))return o.serviceRegistry.get(h);const u=function(d,f,_){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(b,p,g){p[l]===p?p[c].push({id:b,index:g}):(p[c]=[{id:b,index:g}],p[l]=p)})(u,d,_)};return u.toString=()=>h,o.serviceRegistry.set(h,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 h;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"}(h||(o.LogLevelEnum=h={})),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),h=l(225);class u{static extractShouldJoin(f){return(1&f)!=0}static extractWidth(f){return f>>1&3}static extractCharKind(f){return f>>3}static createPropertyValue(f,_,b=!1){return(16777215&f)<<3|(3&_)<<1|(b?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const f=new h.UnicodeV6;this.register(f),this._active=f.version,this._activeProvider=f}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(f){if(!this._providers[f])throw new Error(`unknown Unicode version "${f}"`);this._active=f,this._activeProvider=this._providers[f],this._onChange.fire(f)}register(f){this._providers[f.version]=f}wcwidth(f){return this._activeProvider.wcwidth(f)}getStringCellWidth(f){let _=0,b=0;const p=f.length;for(let g=0;g<p;++g){let v=f.charCodeAt(g);if(55296<=v&&v<=56319){if(++g>=p)return _+this.wcwidth(v);const S=f.charCodeAt(g);56320<=S&&S<=57343?v=1024*(v-55296)+S-56320+65536:_+=this.wcwidth(S)}const x=this.charProperties(v,b);let w=u.extractWidth(x);u.extractShouldJoin(x)&&(w-=u.extractWidth(b)),_+=w,b=x}return _}charProperties(f,_){return this._activeProvider.charProperties(f,_)}}o.UnicodeService=u}},i={};function s(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,s),l.exports}var n={};return(()=>{var a=n;Object.defineProperty(a,"__esModule",{value:!0}),a.Terminal=void 0;const o=s(9042),l=s(3236),c=s(844),h=s(5741),u=s(8285),d=s(7975),f=s(7090),_=["cols","rows"];class b extends c.Disposable{constructor(g){super(),this._core=this.register(new l.Terminal(g)),this._addonManager=this.register(new h.AddonManager),this._publicOptions={...this._core.options};const v=w=>this._core.options[w],x=(w,S)=>{this._checkReadonlyOptions(w),this._core.options[w]=S};for(const w in this._core.options){const S={get:v.bind(this,w),set:x.bind(this,w)};Object.defineProperty(this._publicOptions,w,S)}}_checkReadonlyOptions(g){if(_.includes(g))throw new Error(`Option "${g}" 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}
38get 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 d.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new f.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 g=this._core.coreService.decPrivateModes;let v="none";switch(this._core.coreMouseService.activeProtocol){case"X10":v="x10";break;case"VT200":v="vt200";break;case"DRAG":v="drag";break;case"ANY":v="any"}return{applicationCursorKeysMode:g.applicationCursorKeys,applicationKeypadMode:g.applicationKeypad,bracketedPasteMode:g.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:v,originMode:g.origin,reverseWraparoundMode:g.reverseWraparound,sendFocusMode:g.sendFocus,wraparoundMode:g.wraparound}}get options(){return this._publicOptions}set options(g){for(const v in g)this._publicOptions[v]=g[v]}blur(){this._core.blur()}focus(){this._core.focus()}input(g,v=!0){this._core.input(g,v)}resize(g,v){this._verifyIntegers(g,v),this._core.resize(g,v)}open(g){this._core.open(g)}attachCustomKeyEventHandler(g){this._core.attachCustomKeyEventHandler(g)}attachCustomWheelEventHandler(g){this._core.attachCustomWheelEventHandler(g)}registerLinkProvider(g){return this._core.registerLinkProvider(g)}registerCharacterJoiner(g){return this._checkProposedApi(),this._core.registerCharacterJoiner(g)}deregisterCharacterJoiner(g){this._checkProposedApi(),this._core.deregisterCharacterJoiner(g)}registerMarker(g=0){return this._verifyIntegers(g),this._core.registerMarker(g)}registerDecoration(g){return this._checkProposedApi(),this._verifyPositiveIntegers(g.x??0,g.width??0,g.height??0),this._core.registerDecoration(g)}hasSelection(){return this._core.hasSelection()}select(g,v,x){this._verifyIntegers(g,v,x),this._core.select(g,v,x)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(g,v){this._verifyIntegers(g,v),this._core.selectLines(g,v)}dispose(){super.dispose()}scrollLines(g){this._verifyIntegers(g),this._core.scrollLines(g)}scrollPages(g){this._verifyIntegers(g),this._core.scrollPages(g)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(g){this._verifyIntegers(g),this._core.scrollToLine(g)}clear(){this._core.clear()}write(g,v){this._core.write(g,v)}writeln(g,v){this._core.write(g),this._core.write(`\r 39`,v)}paste(g){this._core.paste(g)}refresh(g,v){this._verifyIntegers(g,v),this._core.refresh(g,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(g){this._addonManager.loadAddon(this,g)}static get strings(){return o}_verifyIntegers(...g){for(const v of g)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...g){for(const v of g)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}a.Terminal=b})(),n})())})(kS);var pI=kS.exports;const mI=getComputedStyle(document.documentElement),ot=r=>mI.getPropertyValue(r)||void 0;function ed(r){return{cursor:ot("--exkalibur-elements-terminal-cursorColor"),cursorAccent:ot("--exkalibur-elements-terminal-cursorColorAccent"),foreground:ot("--exkalibur-elements-terminal-textColor"),background:ot("--exkalibur-elements-terminal-backgroundColor"),selectionBackground:ot("--exkalibur-elements-terminal-selection-backgroundColor"),selectionForeground:ot("--exkalibur-elements-terminal-selection-textColor"),selectionInactiveBackground:ot("--exkalibur-elements-terminal-selection-backgroundColorInactive"),black:ot("--exkalibur-elements-terminal-color-black"),red:ot("--exkalibur-elements-terminal-color-red"),green:ot("--exkalibur-elements-terminal-color-green"),yellow:ot("--exkalibur-elements-terminal-color-yellow"),blue:ot("--exkalibur-elements-terminal-color-blue"),magenta:ot("--exkalibur-elements-terminal-color-magenta"),cyan:ot("--exkalibur-elements-terminal-color-cyan"),white:ot("--exkalibur-elements-terminal-color-white"),brightBlack:ot("--exkalibur-elements-terminal-color-brightBlack"),brightRed:ot("--exkalibur-elements-terminal-color-brightRed"),brightGreen:ot("--exkalibur-elements-terminal-color-brightGreen"),brightYellow:ot("--exkalibur-elements-terminal-color-brightYellow"),brightBlue:ot("--exkalibur-elements-terminal-color-brightBlue"),brightMagenta:ot("--exkalibur-elements-terminal-color-brightMagenta"),brightCyan:ot("--exkalibur-elements-terminal-color-brightCyan"),brightWhite:ot("--exkalibur-elements-terminal-color-brightWhite"),...r}}const gI=Xi("Terminal"),Uv=A.memo(A.forwardRef(({className:r,theme:e,readonly:t,id:i,onTerminalReady:s,onTerminalResize:n},a)=>{const o=A.useRef(null),l=A.useRef();return A.useEffect(()=>{const c=o.current,h=new dI.FitAddon,u=new fI.WebLinksAddon,d=new pI.Terminal({cursorBlink:!0,convertEol:!0,disableStdin:t,theme:ed(t?{cursor:"#00000000"}:{}),fontSize:12,fontFamily:"Menlo, courier-new, courier, monospace"});l.current=d,d.loadAddon(h),d.loadAddon(u),d.open(c);const f=new ResizeObserver(()=>{h.fit(),n?.(d.cols,d.rows)});return f.observe(c),gI.debug(`Attach [${i}]`),s?.(d),()=>{f.disconnect(),d.dispose()}},[]),A.useEffect(()=>{const c=l.current;c.options.theme=ed(t?{cursor:"#00000000"}:{}),c.options.disableStdin=t},[e,t]),A.useImperativeHandle(a,()=>({reloadStyles:()=>{const c=l.current;c.options.theme=ed(t?{cursor:"#00000000"}:{})}}),[]),m.jsx("div",{className:r,ref:o})})),vI=Xi("Terminal"),Vv=3,Vf=25,bI=A.memo(()=>{const r=Ve(ue.showTerminal),e=Ve(Rc),t=A.useRef([]),i=A.useRef(null),s=A.useRef(!1),[n,a]=A.useState(0),[o,l]=A.useState(0),c=()=>{o<Vv&&(l(o+1),a(o))};return A.useEffect(()=>{const{current:h}=i;if(!h)return;const u=h.isCollapsed();!r&&!u?h.collapse():r&&u&&h.resize(Vf),s.current=!1},[r]),A.useEffect(()=>{const h=Yx.on("toggleTerminal",()=>{s.current=!0}),u=Rc.subscribe(()=>{for(const d of Object.values(t.current))d?.reloadStyles()});return()=>{h(),u()}},[]),m.jsx(da,{ref:i,defaultSize:r?Vf:0,minSize:10,collapsible:!0,onExpand:()=>{s.current||ue.toggleTerminal(!0)},onCollapse:()=>{s.current||ue.toggleTerminal(!1)},children:m.jsx("div",{className:"h-full",children:m.jsxs("div",{className:"bg-exkalibur-elements-terminals-background h-full flex flex-col",children:[m.jsxs("div",{className:"flex items-center bg-exkalibur-elements-background-depth-2 border-y border-exkalibur-elements-borderColor gap-1.5 min-h-[34px] p-2",children:[Array.from({length:o+1},(h,u)=>{const d=n===u;return m.jsx(ke.Fragment,{children:u==0?m.jsxs("button",{className:ce("flex items-center text-sm cursor-pointer gap-1.5 px-3 py-2 h-full whitespace-nowrap rounded-full",{"bg-exkalibur-elements-terminals-buttonBackgroun
39d text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary":d,"bg-exkalibur-elements-background-depth-2 text-exkalibur-elements-textSecondary hover:bg-exkalibur-elements-terminals-buttonBackground":!d}),onClick:()=>a(u),children:[m.jsx("div",{className:"i-ph:terminal-window-duotone text-lg"}),"exkalibur Terminal"]},u):m.jsx(ke.Fragment,{children:m.jsxs("button",{className:ce("flex items-center text-sm cursor-pointer gap-1.5 px-3 py-2 h-full whitespace-nowrap rounded-full",{"bg-exkalibur-elements-terminals-buttonBackground text-exkalibur-elements-textPrimary":d,"bg-exkalibur-elements-background-depth-2 text-exkalibur-elements-textSecondary hover:bg-exkalibur-elements-terminals-buttonBackground":!d}),onClick:()=>a(u),children:[m.jsx("div",{className:"i-ph:terminal-window-duotone text-lg"}),"Terminal ",o>1&&u]},u)})},u)}),o<Vv&&m.jsx(jt,{icon:"i-ph:plus",size:"md",onClick:c}),m.jsx(jt,{className:"ml-auto",icon:"i-ph:caret-down",title:"Close",size:"md",onClick:()=>ue.toggleTerminal(!1)})]}),Array.from({length:o+1},(h,u)=>{const d=n===u;return vI.debug(`Starting exkalibur terminal [${u}]`),u==0?m.jsx(Uv,{id:`terminal_${u}`,className:ce("h-full overflow-hidden modern-scrollbar-invert",{hidden:!d}),ref:f=>{t.current.push(f)},onTerminalReady:f=>ue.attachexkaliburTerminal(f),onTerminalResize:(f,_)=>ue.onTerminalResize(f,_),theme:e},u):m.jsx(Uv,{id:`terminal_${u}`,className:ce("modern-scrollbar h-full overflow-hidden",{hidden:!d}),ref:f=>{t.current.push(f)},onTerminalReady:f=>ue.attachTerminal(f),onTerminalResize:(f,_)=>ue.onTerminalResize(f,_),theme:e},u)})]})})})});async function xI(r,e,t,i){if(!r||typeof r.internal?.textSearch!="function"){console.error("WebContainer instance not available or internal searchText method is missing/not a function.");return}const s={...t,folders:[un]},n=(a,o)=>{const l=[];o.forEach(c=>{const h=c.preview.text.split(` 40`);c.ranges.forEach(u=>{let d="(Preview line not found)",f=-1;if(c.preview.matches.length>0){const _=c.preview.matches[0].startLineNumber;f=u.startLineNumber-_}f>=0&&f<h.length?d=h[f]:d=h[0]??"(Preview unavailable)",l.push({path:a,lineNumber:u.startLineNumber,previewText:d,matchCharStart:u.startColumn,matchCharEnd:u.endColumn})})}),l.length>0&&i(l)};try{await r.internal.textSearch(e,s,n)}catch(a){console.error("Error during internal text search:",a)}}function _I(r){return r.reduce((e,t)=>(e[t.path]||(e[t.path]=[]),e[t.path].push(t),e),{})}function yI(){const[r,e]=A.useState(""),[t,i]=A.useState([]),[s,n]=A.useState(!1),[a,o]=A.useState({}),[l,c]=A.useState(!1),h=A.useMemo(()=>_I(t),[t]);A.useEffect(()=>{if(t.length>0){const _={};Object.keys(h).forEach(b=>{_[b]=!0}),o(_)}},[h,t]);const u=A.useCallback(async _=>{if(!_.trim()){i([]),n(!1),o({}),c(!1);return}n(!0),i([]),o({}),c(!0);const b=300,p=Date.now();try{const g=await Bx;await xI(g,_,{homeDir:un,includes:["**/*.*"],excludes:["**/node_modules/**","**/package-lock.json","**/.git/**","**/dist/**","**/*.lock"],gitignore:!0,requireGit:!1,globalIgnoreFiles:!0,ignoreSymlinks:!1,resultLimit:500,isRegex:!1,caseSensitive:!1,isWordMatch:!1},w=>{i(S=>[...S,...w])})}catch(g){console.error("Failed to initiate search:",g)}finally{const g=Date.now()-p;g<b?setTimeout(()=>n(!1),b-g):n(!1)}},[]),d=A.useCallback(yh(u,300),[u]);A.useEffect(()=>{d(r)},[r,d]);const f=(_,b)=>{ue.setSelectedFile(_);const p=typeof b=="number"?Math.max(0,b-1):void 0;ue.setCurrentDocumentScrollPosition({line:p,column:0})};return m.jsxs("div",{className:"flex flex-col h-full bg-white/10 backdrop-blur-xl",children:[m.jsx("div",{className:"flex items-center py-3 px-3",children:m.jsx("div",{className:"relative flex-1",children:m.jsx("input",{type:"text",value:r,onChange:_=>e(_.target.value),placeholder:"Search",className:"w-full px-2 py-1 rounded-md bg-white/20 backdrop-blur-xl text-white placeholder-exkalibur-white focus:outline-none transition-all"})})}),m.jsxs("div",{className:"flex-1 overflow-auto py-2",children:[s&&m.jsxs("div",{className:"flex items-center justify-center text-white",children:[m.jsx("div",{className:"i-ph:circle-notch animate-spin mr-2"})," Searching..."]}),!s&&l&&t.length===0&&r.trim()!==""&&m.jsx("div",{className:"flex items-center justify-center text-white",children:"No results found."}),!s&&Object.keys(h).map(_=>m.jsxs("div",{className:"mb-2",children:[m.jsxs("button",{className:"flex gap-2 items-center w-full text-left py-1 px-2 text-white/80 bg-transparent hover:bg-white/15 group",onClick:()=>o(b=>({...b,[_]:!b[_]})),children:[m.jsx("span",{className:" i-ph:caret-down-thin w-3 text-white/80 transition-transform",style:{transform:a[_]?"rotate(180deg)":void 0}}),m.jsx("span",{className:"font-normal text-sm",children:_.split("/").pop()}),m.jsx("span",{className:"w-5.5 flex items-center justify-center text-xs ml-auto bg-white/3 text-#ff99cc rounded-full",children:h[_].length})]}),a[_]&&m.jsx("div",{className:"",children:h[_].map((b,p)=>{const v=b.matchCharStart<=7,x=v?0:b.matchCharStart-7,w=b.previewText.slice(x),S=v?b.matchCharStart:7,k=v?b.matchCharEnd:7+(b.matchCharEnd-b.matchCharStart);return m.jsx("div",{className:"hover:bg-white/10 cursor-pointer transition-colors pl-6 py-1",onClick:()=>f(b.path,b.lineNumber),children:m.jsxs("pre",{className:"font-mono text-xs text-white/70 truncate",children:[!v&&m.jsx("span",{children:"..."}),w.slice(0,S),m.jsx("span",{className:"bg-exkalibur-elements-item-backgroundAccent text-#ff99cc rounded px-1",children:w.slice(S,k)}),w.slice(k)]})},p)})})]},_))]})]})}function wI(){const[r,e]=A.useState([]),[t,i]=A.useState(new Set),[s,n]=A.useState("all"),[a,o]=A.useState("");A.useEffect(()=>{const b=()=>{const g=[],v=ue.files.get();Object.entries(v).forEach(([x,w])=>
40{w&&(w.type==="file"&&w.isLocked?g.push({path:x,type:"file"}):w.type==="folder"&&w.isLocked&&g.push({path:x,type:"folder"}))}),e(g)};b();const p=setInterval(b,5e3);return()=>clearInterval(p)},[]);const l=r.filter(b=>!(s==="files"&&b.type!=="file"||s==="folders"&&b.type!=="folder"||a&&!b.path.toLowerCase().includes(a.toLowerCase()))).sort((b,p)=>b.path.localeCompare(p.path)),c=b=>{const p=new Set(t);p.has(b)?p.delete(b):p.add(b),i(p)},h=b=>{if(b===!0){const p=new Set(l.map(g=>g.path));i(p)}else i(new Set)},u=()=>{if(t.size===0){he.error("No items selected to unlock.");return}let b=0;t.forEach(p=>{const g=r.find(v=>v.path===p);g&&(g.type==="file"?ue.unlockFile(p):ue.unlockFolder(p),b++)}),b>0&&(he.success(`Unlocked ${b} selected item(s).`),i(new Set))},d=l.length>0&&t.size===l.length,f=t.size>0&&t.size<l.length,_=d?!0:f?"indeterminate":!1;return m.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[m.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-exkalibur-elements-borderColor",children:[m.jsxs("div",{className:"relative flex-1",children:[m.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary i-ph:magnifying-glass text-xs pointer-events-none"}),m.jsx("input",{type:"text",placeholder:"Search...",className:"w-full text-xs pl-6 pr-2 py-0.5 bg-white/10 backdrop-blur-xl placeholder:text-white text-white rounded border backdrop-blur-xl focus:outline-none",value:a,onChange:b=>o(b.target.value),style:{minWidth:0}})]}),m.jsxs("select",{className:"text-xs px-1 py-0.5 h-6 bg-white/10 backdrop-blur-xl text-white rounded border border-white/10 backdrop-blur-xl focus:outline-none",value:s,onChange:b=>n(b.target.value),children:[m.jsx("option",{value:"all",children:"All"}),m.jsx("option",{value:"files",children:"Files"}),m.jsx("option",{value:"folders",children:"Folders"})]})]}),m.jsxs("div",{className:"flex items-center justify-between px-2 py-1 text-xs text-white",children:[m.jsxs("div",{children:[m.jsx(mg,{checked:_,onCheckedChange:h,className:"w-3 h-3 rounded bg-white/10 backdrop-blur-xl mr-2","aria-label":"Select all items",disabled:l.length===0}),m.jsx("span",{children:"All"})]}),t.size>0&&m.jsx("button",{className:"ml-auto px-2 py-0.5 rounded bg-white/10 backdrop-blur-xl hover:bg-white/10 text-white text-xs flex items-center gap-1",onClick:u,title:"Unlock all selected items",children:"Unlock all"}),m.jsx("div",{})]}),m.jsx("div",{className:"flex-1 overflow-auto modern-scrollbar px-1 py-1",children:l.length===0?m.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-white text-xs gap-2",children:[m.jsx("span",{className:"i-ph:lock-open-duotone text-lg"}),m.jsx("span",{children:"No locked items found"})]}):m.jsx("ul",{className:"space-y-1",children:l.map(b=>m.jsxs("li",{className:ce("text-white/80 flex items-center gap-2 px-2 py-1 rounded hover:bg-white/10 transition-colors group",t.has(b.path)?"bg-white/5":""),children:[m.jsx(mg,{checked:t.has(b.path),onCheckedChange:()=>c(b.path),className:"w-3 h-3 rounded border-exkalibur-elements-borderColor","aria-labelledby":`item-label-${b.path}`}),m.jsx("span",{className:ce("shrink-0 text-exkalibur-elements-textTertiary text-xs",b.type==="file"?"i-ph:file-text-duotone":"i-ph:folder-duotone")}),m.jsx("span",{id:`item-label-${b.path}`,className:"truncate flex-1 text-xs",title:b.path,children:b.path.replace("/home/project/","")}),m.jsx("span",{className:ce("inline-flex items-center px-1 rounded-sm text-xs","bg-red-500/10 text-red-500")}),m.jsx("button",{className:"flex items-center px-1 py-0.5 text-xs rounded bg-transparent hover:bg-exkalibur-elements-background-depth-3",onClick:()=>{b.type==="file"?ue.unlockFile(b.path):ue.unlockFolder(b.path),he.success(`${b.path.replace("/home/project/","")} unlocked`)},title:"Unlock",children:m.jsx("span",{className:"i-ph:lock-open text-xs"})})]},b.path))})}),m.jsx("div",{className:"px-2 py-1 border-t border-exkalibur-elements-borderColor bg-exkalibur-elements-background-depth-2 text-xs text-exkalibur-elements-textTertiary flex justify-between items-center",children:m.jsxs("div",{children:[l.length," item(s) ⢠",t.size," selected"]})})]})}const SI=100-Vf,kI={tabSize:2},CI=A.memo(({files:r,unsavedFiles:e,editorDocument:t,selectedFile:i,isStreaming:s,fileHistory:n,onFileSelect:a,onEditorChange:o,onEditorScroll:l,onFileSave:c,onFileReset:h})=>{wo.trace("EditorPanel");const u=Ve(Rc),d=Ve(ue.showTerminal),f=A.useMemo(()=>!s||!i||!t?!1:i===t.filePath,[s,i,t]),_=!f,b=A.useMemo(()=>
40{if(t)return t.filePath.split("/")},[t]),p=A.useMemo(()=>!t||!e?!1:e instanceof Set&&e.has(t.filePath),[t,e]);return m.jsxs(Wf,{direction:"vertical",children:[m.jsx(da,{defaultSize:d?SI:100,minSize:20,children:m.jsxs(Wf,{direction:"horizontal",children:[m.jsx(da,{defaultSize:20,minSize:15,collapsible:!0,className:"border-r border-exkalibur-elements-borderColor",children:m.jsx("div",{className:"h-full",children:m.jsxs(C3,{defaultValue:"files",className:"flex flex-col h-full",children:[m.jsx(zv,{className:"w-full text-sm font-medium text-exkalibur-elements-textSecondary px-1 bg-white/10 backdrop-blur-xl",children:m.jsx("div",{className:"h-full flex-shrink-0 flex items-center justify-between w-full",children:m.jsxs(E3,{className:"h-full flex-shrink-0 flex items-center",children:[m.jsx(Ju,{value:"files",className:ce("h-full bg-transparent hover:bg-white/10 py-0.5 px-2 rounded-lg text-sm font-medium text-white data-[state=active]:text-#ff99cc"),children:"Files"}),m.jsx(Ju,{value:"search",className:ce("h-full bg-transparent hover:bg-white/10 py-0.5 px-2 rounded-lg text-sm font-medium text-white data-[state=active]:text-#ff99cc"),children:"Search"}),m.jsx(Ju,{value:"locks",className:ce("h-full bg-transparent hover:bg-white/10 py-0.5 px-2 rounded-lg text-sm font-medium text-white data-[state=active]:text-#ff99cc"),children:"Locks"})]})})}),m.jsx(Qu,{value:"files",className:"flex-grow overflow-auto focus-visible:outline-none",children:m.jsx(xS,{className:"h-full",files:r,hideRoot:!0,unsavedFiles:e,fileHistory:n,rootFolder:un,selectedFile:i,onFileSelect:a,streamingFile:s?t?.filePath:void 0})}),m.jsx(Qu,{value:"search",className:"flex-grow overflow-auto focus-visible:outline-none",children:m.jsx(yI,{})}),m.jsx(Qu,{value:"locks",className:"flex-grow overflow-auto focus-visible:outline-none",children:m.jsx(wI,{})})]})})}),m.jsx(Uf,{}),m.jsxs(da,{className:"flex flex-col",defaultSize:80,minSize:20,children:[m.jsx(zv,{className:"overflow-x-auto bg-white/10 backdrop-blur-xl",children:b?.length&&m.jsxs("div",{className:"flex items-center flex-1 text-sm text-white bg-transparent",children:[m.jsx(uI,{pathSegments:b,files:r,onFileSelect:a}),p&&m.jsxs("div",{className:"flex gap-1 ml-auto -mr-1.5",children:[m.jsxs(Pv,{onClick:c,children:[m.jsx("div",{className:"i-ph:floppy-disk-duotone text-white/90"}),"Save"]}),m.jsxs(Pv,{onClick:h,children:[m.jsx("div",{className:"i-ph:clock-counter-clockwise-duotone text-white/90"}),"Reset"]})]})]})}),m.jsx("div",{className:"h-full flex-1 overflow-hidden modern-scrollbar",children:m.jsx(P1,{theme:u,editable:_&&t!==void 0,settings:kI,doc:t,autoFocusOnDocumentChange:!A3()&&!f,onScroll:l,onCh
40ange:o,onSave:c})})]})]})}),m.jsx(Uf,{}),m.jsx(bI,{})]})}),EI=A.memo(({isSelectionMode:r,setIsSelectionMode:e,containerRef:t})=>{const[i,s]=A.useState(!1),[n,a]=A.useState(null),[o,l]=A.useState(null),c=A.useRef(null),h=A.useRef(null);A.useEffect(()=>()=>{h.current&&(h.current.pause(),h.current.srcObject=null,h.current.remove(),h.current=null),c.current&&(c.current.getTracks().forEach(b=>b.stop()),c.current=null)},[]);const u=async()=>{if(!c.current)try{const b=await navigator.mediaDevices.getDisplayMedia({audio:!1,video:{displaySurface:"window",preferCurrentTab:!0,surfaceSwitching:"include",systemAudio:"exclude"}});if(b.addEventListener("inactive",()=>{h.current&&(h.current.pause(),h.current.srcObject=null,h.current.remove(),h.current=null),c.current&&(c.current.getTracks().forEach(p=>p.stop()),c.current=null),e(!1),a(null),l(null),s(!1)}),c.current=b,!h.current){const p=document.createElement("video");p.style.opacity="0",p.style.position="fixed",p.style.pointerEvents="none",p.style.zIndex="-1",document.body.appendChild(p),h.current=p}h.current.srcObject=b,await h.current.play()}catch(b){console.error("Failed to initialize stream:",b),e(!1),he.error("Failed to initialize screen capture")}return c.current},d=A.useCallback(async()=>{if(!(!r||!n||!o||!t.current)){s(!0);try{if(!await u()||!h.current)return;await new Promise(V=>setTimeout(V,300));const p=document.createElement("canvas");p.width=h.current.videoWidth,p.height=h.current.videoHeight;const g=p.getContext("2d");if(!g)throw new Error("Failed to get temporary canvas context");g.drawImage(h.current,0,0);const v=h.current.videoWidth/window.innerWidth,x=h.current.videoHeight/window.innerHeight,w=window.scrollX,S=window.scrollY+40,k=t.current.getBoundingClientRect(),C=-9,y=-14,E=Math.round((k.left+Math.min(n.x,o.x)+w+C)*v),D=Math.round((k.top+Math.min(n.y,o.y)+S+y)*x),T=Math.round(Math.abs(o.x-n.x)*v),M=Math.round(Math.abs(o.y-n.y)*x),R=document.createElement("canvas");R.width=Math.round(Math.abs(o.x-n.x)),R.height=Math.round(Math.abs(o.y-n.y));const O=R.getContext("2d");if(!O)throw new Error("Failed to get canvas context");O.drawImage(p,E,D,T,M,0,0,R.width,R.height);const $=await new Promise((V,q)=>{R.toBlob(L=>{L?V(L):q(new Error("Failed to create blob"))},"image/png")}),G=new FileReader;G.onload=V=>{const q=V.target?.result;if(document.querySelector("textarea")){const N=window.__exkalibur_SET_UPLOADED_FILES__,I=window.__exkalibur_SET_IMAGE_DATA_LIST__,H=window.__exkalibur_UPLOADED_FILES__||[],W=window.__exkalibur_IMAGE_DATA_LIST__||[];if(N&&I){const J=new File([$],"screenshot.png",{type:"image/png"});N([...H,J]),I([...W,q]),he.success("Screenshot captured and added to chat")}else he.error("Could not add screenshot to chat")}},G.readAsDataURL($)}catch(b){console.error("Failed to capture screenshot:",b),he.error("Failed to capture screenshot"),c.current&&(c.current.getTracks().forEach(p=>p.stop()),c.current=null)}finally{s(!1),a(null),l(null),e(!1)}}},[r,n,o,t,e]),f=A.useCallback(b=>{if(b.preventDefault(),b.stopPropagation(),!r)return;const p=b.currentTarget.getBoundingClientRect(),g=b.clientX-p.left,v=b.clientY-p.top;a({x:g,y:v}),l({x:g,y:v})},[r]),_=A.useCallback(b=>{if(b.preventDefault(),b.stopPropagation(),!r||!n)return;const p=b.currentTarget.getBoundingClientRect(),g=b.clientX-p.left,v=b.clientY-p.top;l({x:g,y:v})},[r,n]);return r?m.jsx("div",{className:"absolute inset-0 cursor-crosshair",onMouseDown:f,onMouseMove:_,onMouseUp:d,onMouseLeave:()=>{n&&a(null)},style:{backgroundColor:i?"transparent":"rgba(0, 0, 0, 0.1)",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"all",opacity:i?0:1,zIndex:50,transition:"opacity 0.1s ease-in-out"},children:n&&o&&!i&&m.jsx("div",{className:"absolute border-2 border-blue-500 bg-blue-200 bg-opacity-20",style:{left:Math.min(n.x,o.x),top:Math.min(n.y,o.y),width:Math.abs(o.x-n.x),height:Math.abs(o.y-n.y)}})}):null});var Am={},hh={exports:{}};hh.exports;(function(r,e){var t=200,i="__lodash_hash_undefined__",s=1,n=2,a=9007199254740991,o="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",h="[object Boolean]",u="[object Date]",d="[object Error]",f="[object Function]",_="[object GeneratorFunction]",b="[object Map]",p="[object Number]",g="[object Null]",v="[object Object]",x="[object Promise]",w="[object Proxy]",S="[object RegExp]",k="[object Set]",C="[object String]",y="[object Symbol]",E="[object Undef
40ined]",D="[object WeakMap]",T="[object ArrayBuffer]",M="[object DataView]",R="[object Float32Array]",O="[object Float64Array]",$="[object Int8Array]",G="[object Int16Array]",V="[object Int32Array]",q="[object Uint8Array]",L="[object Uint8ClampedArray]",N="[object Uint16Array]",I="[object Uint32Array]",H=/[\\^$.*+?()[\]{}|]/g,W=/^\[object .+?Constructor\]$/,J=/^(?:0|[1-9]\d*)$/,Z={};Z[R]=Z[O]=Z[$]=Z[G]=Z[V]=Z[q]=Z[L]=Z[N]=Z[I]=!0,Z[o]=Z[l]=Z[T]=Z[h]=Z[M]=Z[u]=Z[d]=Z[f]=Z[b]=Z[p]=Z[v]=Z[S]=Z[k]=Z[C]=Z[D]=!1;var X=typeof fs=="object"&&fs&&fs.Object===Object&&fs,F=typeof self=="object"&&self&&self.Object===Object&&self,P=X||F||Function("return this")(),j=e&&!e.nodeType&&e,B=j&&!0&&r&&!r.nodeType&&r,K=B&&B.exports===j,U=K&&X.process,Y=function(){try{return U&&U.binding&&U.binding("util")}catch{}}(),ee=Y&&Y.isTypedArray;function ie(z,Q){for(var ae=-1,ve=z==null?0:z.length,et=0,Re=[];++ae<ve;){var ht=z[ae];Q(ht,ae,z)&&(Re[et++]=ht)}return Re}function le(z,Q){for(var ae=-1,ve=Q.length,et=z.length;++ae<ve;)z[et+ae]=Q[ae];return z}function ne(z,Q){for(var ae=-1,ve=z==null?0:z.length;++ae<ve;)if(Q(z[ae],ae,z))return!0;return!1}function re(z,Q){for(var ae=-1,ve=Array(z);++ae<z;)ve[ae]=Q(ae);return ve}function me(z){return function(Q){return z(Q)}}function pe(z,Q){return z.has(Q)}function se(z,Q){return z?.[Q]}function ge(z){var Q=-1,ae=Array(z.size);return z.forEach(function(ve,et){ae[++Q]=[et,ve]}),ae}function Ee(z,Q){return function(ae){return z(Q(ae))}}function Ce(z){var Q=-1,ae=Array(z.size);return z.forEach(function(ve){ae[++Q]=ve}),ae}var _e=Array.prototype,Fe=Function.prototype,Ke=Object.prototype,Le=P["__core-js_shared__"],Qe=Fe.toString,Xe=Ke.hasOwnProperty,yt=function(){var z=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||"");return z?"Symbol(src)_1."+z:""}(),$e=Ke.toString,ki=RegExp("^"+Qe.call(Xe).replace(H,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),or=K?P.Buffer:void 0,Br=P.Symbol,Ci=P.Uint8Array,Ei=Ke.propertyIsEnumerable,Ns=_e.splice,Nt=Br?Br.toStringTag:void 0,Zr=Object.getOwnPropertySymbols,xr=or?or.isBuffer:void 0,Ai=Ee(Object.keys,Object),_r=Nn(P,"DataView"),yr=Nn(P,"Map"),Ti=Nn(P,"Promise"),Os=Nn(P,"Set"),Ji=Nn(P,"WeakMap"),wr=Nn(Object,"create"),Do=js(_r),Po=js(yr),Lo=js(Ti),ye=js(Os),Ye=js(Ji),ut=Br?Br.prototype:void 0,ct=ut?ut.valueOf:void 0;function we(z){var Q=-1,ae=z==null?0:z.length;for(this.clear();++Q<ae;){var ve=z[Q];this.set(ve[0],ve[1])}}function Te(){this.__data__=wr?wr(null):{},this.size=0}function st(z){var Q=this.has(z)&&delete this.__data__[z];return this.size-=Q?1:0,Q}function dt(z){var Q=this.__data__;if(wr){var ae=Q[z];return ae===i?void 0:ae}return Xe.call(Q,z)?Q[z]:void 0}function Sr(z){var Q=this.__data__;return wr?Q[z]!==void 0:Xe.call(Q,z)}function Ln(z,Q){var ae=this.__data__;return this.size+=this.has(z)?0:1,ae[z]=wr&&Q===void 0?i:Q,this}we.prototype.clear=Te,we.prototype.delete=st,we.prototype.get=dt,we.prototype.has=Sr,we.prototype.set=Ln;function ar(z){var Q=-1,ae=z==null?0:z.length;for(this.clear();++Q<ae;){var ve=z[Q];this.set(ve[0],ve[1])}}function mu(){this.__data__=[],this.size=0}function vl(z){var Q=this.__data__,ae=xl(Q,z);if(ae<0)return!1;var ve=Q.length-1;return ae==ve?Q.pop():Ns.call(Q,ae,1),--this.size,!0}function gu(z){var Q=this.__data__,ae=xl(Q,z);return ae<0?void 0:Q[ae][1]}function aC(z){return xl(this.__data__,z)>-1}function lC(z,Q){var ae=this.__data__,ve=xl(ae,z);return ve<0?(++this.size,ae.push([z,Q])):ae[ve][1]=Q,this}ar.prototype.clear=mu,ar.prototype.delete=vl,ar.prototype.get=gu,ar.prototype.has=aC,ar.prototype.set=lC;function Is(z){var Q=-1,ae=z==null?0:z.length;for(this.clear();++Q<ae;){var ve=z[Q];this.set(ve[0],ve[1])}}function cC(){this.size=0,this.__data__={hash:new we,map:new(yr||ar),string:new we}}function hC(z){var Q=_l(this,z).delete(z);return this.size-=Q?1:0,Q}function uC(z){return _l(this,z).get(z)}function dC(z){return _l(this,z).has(z)}function fC(z,Q){var ae=_l(this,z),ve=ae.size;return ae.set(z,Q),this.size+=ae.size==ve?0:1,this}Is.prototype.clear=cC,Is.prototype.delete=hC,Is.prototype.get=uC,Is.prototype.has=dC,Is.prototype.set=fC;function bl(z){var Q=-1,ae=z==null?0:z.length;for(this.__data__=new Is;++Q<ae;)this.add(z[Q])}function pC(z){return this.__data__.set(z,i),this}function mC(z){return this.__data__.has(z)}bl.prototype.add=bl.prototype.push=pC,bl.prototype.has=mC;function Qi(z){var Q=this.__data__=new ar(z);this.size=Q.size}function gC(){this.__data__=new ar,this.size=0}function vC(z){var Q=this.__data__,ae=Q.delete(z);return this.size=Q.size,ae}function bC(z){return this.__data__.get(z)}function xC(z){return this.__data__.has(z)}function _C(z,Q){var ae=this.__data__;if(ae instanceof ar){var ve=ae.__data__;if(!yr||ve.length<t-1)return ve.push([z,Q]),this.size=++ae.size,this;ae=this.__data__=new Is(ve)}return ae.set(z,Q),this.size=ae.size,this}Qi.prototype.clear=gC,Qi.prototype.delete=vC,Qi.prototype.get=bC,Qi.prototype.has=xC,Qi.prototype.set=_C;function yC(z,Q){var ae=yl(z),ve=!ae&&IC(z),et=!ae&&!ve&&vu(z),Re=!ae&&!ve&&!et&&ug(z),ht=ae||ve||et||Re,wt=ht?re(z.length,String):[],At=wt.length;for(var nt in z)Xe.call(z,nt)&&!(ht&&(nt=="length"||et&&(nt=="offset"||nt=="parent")||Re&&(nt=="buffer"||nt=="byteLength"||nt=="byteOffset")||DC(nt,At)))&&wt.push(nt);return wt}function xl(z,Q){for(var ae=z.length;ae--;)if(ag(z[ae][0],Q))return ae;return-1}function wC(z,Q,ae){var ve=Q(z);return yl(z)?ve:le(ve,ae(z))}function No(z){return z==null?z===void 0?E:g:Nt&&Nt in Object(z)?RC(z):OC(z)}function ig(z){return Oo(z)&&No(z)==o}function sg(z,Q,ae,ve,et){return z===Q?!0:z==null||Q==null||!Oo(z)&&!Oo(Q)?z!==z&&Q!==Q:SC(z,Q,ae,ve,sg,et)}function SC(z,Q,ae,ve,et,Re){var ht=yl(z),wt=yl(Q),At=ht?l:es(z),nt=wt?l:es(Q);At=At==o?v:At,nt=nt==o?v:nt;var lr=At==v,Fr=nt==v,Ot=At==nt;if(Ot&&vu(z)){if(!vu(Q))return!1;ht=!0,lr=!1}if(Ot&&!lr)return Re||(Re=new Qi),ht||ug(z)?ng(z,Q,ae,ve,et,Re):AC(z,Q,At,ae,ve,et,Re);if(!(ae&s)){var kr=lr&&Xe.call(z,"__wrapped__"),Cr=Fr&&Xe.call(Q,"__wrapped__");
40if(kr||Cr){var ts=kr?z.value():z,Ri=Cr?Q.value():Q;return Re||(Re=new Qi),et(ts,Ri,ae,ve,Re)}}return Ot?(Re||(Re=new Qi),TC(z,Q,ae,ve,et,Re)):!1}function kC(z){if(!hg(z)||LC(z))return!1;var Q=lg(z)?ki:W;return Q.test(js(z))}function CC(z){return Oo(z)&&cg(z.length)&&!!Z[No(z)]}function EC(z){if(!NC(z))return Ai(z);var Q=[];for(var ae in Object(z))Xe.call(z,ae)&&ae!="constructor"&&Q.push(ae);return Q}function ng(z,Q,ae,ve,et,Re){var ht=ae&s,wt=z.length,At=Q.length;if(wt!=At&&!(ht&&At>wt))return!1;var nt=Re.get(z);if(nt&&Re.get(Q))return nt==Q;var lr=-1,Fr=!0,Ot=ae&n?new bl:void 0;for(Re.set(z,Q),Re.set(Q,z);++lr<wt;){var kr=z[lr],Cr=Q[lr];if(ve)var ts=ht?ve(Cr,kr,lr,Q,z,Re):ve(kr,Cr,lr,z,Q,Re);if(ts!==void 0){if(ts)continue;Fr=!1;break}if(Ot){if(!ne(Q,function(Ri,Bs){if(!pe(Ot,Bs)&&(kr===Ri||et(kr,Ri,ae,ve,Re)))return Ot.push(Bs)})){Fr=!1;break}}else if(!(kr===Cr||et(kr,Cr,ae,ve,Re))){Fr=!1;break}}return Re.delete(z),Re.delete(Q),Fr}function AC(z,Q,ae,ve,et,Re,ht){switch(ae){case M:if(z.byteLength!=Q.byteLength||z.byteOffset!=Q.byteOffset)return!1;z=z.buffer,Q=Q.buffer;case T:return!(z.byteLength!=Q.byteLength||!Re(new Ci(z),new Ci(Q)));case h:case u:case p:return ag(+z,+Q);case d:return z.name==Q.name&&z.message==Q.message;case S:case C:return z==Q+"";case b:var wt=ge;case k:var At=ve&s;if(wt||(wt=Ce),z.size!=Q.size&&!At)return!1;var nt=ht.get(z);if(nt)return nt==Q;ve|=n,ht.set(z,Q);var lr=ng(wt(z),wt(Q),ve,et,Re,ht);return ht.delete(z),lr;case y:if(ct)return ct.call(z)==ct.call(Q)}return!1}function TC(z,Q,ae,ve,et,Re){var ht=ae&s,wt=og(z),At=wt.length,nt=og(Q),lr=nt.length;if(At!=lr&&!ht)return!1;for(var Fr=At;Fr--;){var Ot=wt[Fr];if(!(ht?Ot in Q:Xe.call(Q,Ot)))return!1}var kr=Re.get(z);if(kr&&Re.get(Q))return kr==Q;var Cr=!0;Re.set(z,Q),Re.set(Q,z);for(var ts=ht;++Fr<At;){Ot=wt[Fr];var Ri=z[Ot],Bs=Q[Ot];if(ve)var dg=ht?ve(Bs,Ri,Ot,Q,z,Re):ve(Ri,Bs,Ot,z,Q,Re);if(!(dg===void 0?Ri===Bs||et(Ri,Bs,ae,ve,Re):dg)){Cr=!1;break}ts||(ts=Ot=="constructor")}if(Cr&&!ts){var wl=z.constructor,Sl=Q.constructor;wl!=Sl&&"constructor"in z&&"constructor"in Q&&!(typeof wl=="function"&&wl instanceof wl&&typeof Sl=="function"&&Sl instanceof Sl)&&(Cr=!1)}return Re.delete(z),Re.delete(Q),Cr}function og(z){return wC(z,FC,MC)}function _l(z,Q){var ae=z.__data__;return PC(Q)?ae[typeof Q=="string"?"string":"hash"]:ae.map}function Nn(z,Q){var ae=se(z,Q);return kC(ae)?ae:void 0}function RC(z){var Q=Xe.call(z,Nt),ae=z[Nt];try{z[Nt]=void 0;var ve=!0}catch{}var et=$e.call(z);return ve&&(Q?z[Nt]=ae:delete z[Nt]),et}var MC=Zr?function(z){return z==null?[]:(z=Object(z),ie(Zr(z),function(Q){return Ei.call(z,Q)}))}:$C,es=No;(_r&&es(new _r(new ArrayBuffer(1)))!=M||yr&&es(new yr)!=b||Ti&&es(Ti.resolve())!=x||Os&&es(new Os)!=k||Ji&&es(new Ji)!=D)&&(es=function(z){var Q=No(z),ae=Q==v?z.constructor:void 0,ve=ae?js(ae):"";if(ve)switch(ve){case Do:return M;case Po:return b;case Lo:return x;case ye:return k;case Ye:return D}return Q});function DC(z,Q){return Q=Q??a,!!Q&&(typeof z=="number"||J.test(z))&&z>-1&&z%1==0&&z<Q}function PC(z){var Q=typeof z;return Q=="string"||Q=="number"||Q=="symbol"||Q=="boolean"?z!=="__proto__":z===null}function LC(z){return!!yt&&yt in z}function NC(z){var Q=z&&z.constructor,ae=typeof Q=="function"&&Q.prototype||Ke;return z===ae}function OC(z){return $e.call(z)}function js(z){if(z!=null){try{return Qe.call(z)}catch{}try{return z+""}catch{}}return""}function ag(z,Q){return z===Q||z!==z&&Q!==Q}var IC=ig(function(){return arguments}())?ig:function(z){return Oo(z)&&Xe.call(z,"callee")&&!Ei.call(z,"callee")},yl=Array.isArray;function jC(z){return z!=null&&cg(z.length)&&!lg(z)}var vu=xr||HC;function BC(z,Q){return sg(z,Q)}function lg(z){if(!hg(z))return!1;var Q=No(z);return Q==f||Q==_||Q==c||Q==w}function cg(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=a}function hg(z){var Q=typeof z;return z!=null&&(Q=="object"||Q=="function")}function Oo(z){return z!=null&&typeof z=="object"}var ug=ee?me(ee):CC;function FC(z){return jC(z)?yC(z):EC(z)}function $C(){return[]}function HC(){return!1}r.exports=BC})(hh,hh.exports);var AI=hh.exports,ES={exports:{}};(function(r,e){var t=function(){var i=function(S,k){var C=236,y=17,E=S,D=n[k],T=null,M=0,R=null,O=[],$={},G=function(P,j){M=E*4+17,T=function(B){for(var K=new Array(B),U=0;U<B;U+=1){K[U]=new Array(B);for(var Y=0;Y<B;Y+=1)K[U][Y]=null}return K}(M),V(0,0),V(M-7,0),V(0,M-7),N(),L(),H(P,j),E>=7&&I(P),R==null&&(R=Z(E,D,O)),W(R,j)},V=function(P,j){for(var B=-1;B<=7;B+=1)if(!(P+B<=-1||M<=P+B))for(var K=-1;K<=7;K+=1)j+K<=-1||M<=j+K||(0<=B&&B<=6&&(K==0||K==6)||0<=K&&K<=6&&(B==0||B==6)||2<=B&&B<=4&&2<=K&&K<=4?T[P+B][j+K]=!0:T[P+B][j+K]=!1)},q=function(){for(var P=0,j=0,B=0;B<8;B+=1){G(!0,B);var K=o.getLostPoint($);(B==0||P>K)&&(P=K,j=B)}return j},L=function(){for(var P=8;P<M-8;P+=1)T[P][6]==null&&(T[P][6]=P%2==0);for(var j=8;j<M-8;j+=1)T[6][j]==null&&(T[6][j]=j%2==0)},N=function(){for(var P=o.getPatternPosition(E),j=0;j<P.length;j+=1)for(var B=0;B<P.length;B+=1){var K=P[j],U=P[B];if(T[K][U]==null)for(var Y=-2;Y<=2;Y+=1)for(var ee=-2;ee<=2;ee+=1)Y==-2||Y==2||ee==-2||ee==2||Y==0&&ee==0?T[K+Y][U+ee]=!0:T[K+Y][U+ee]=!1}},I=function(P){for(var j=o.getBCHTypeNumber(E),B=0;B<18;B+=1){var K=!P&&(j>>B&1)==1;T[Math.floor(B/3)][B%3+M-8-3]=K}for(var B=0;B<18;B+=1){var K=!P&&(j>>B&1)==1;T[B%3+M-8-3][Math.floor(B/3)]=K}},H=function(P,j){for(var B=D<<3|j,K=o.getBCHTypeInfo(B),U=0;U<15;U+=1){var Y=!P&&(K>>U&1)==1;U<6?T[U][8]=Y:U<8?T[U+1][8]=Y:T[M-15+U][8]=Y}for(var U=0;U<15;U+=1){var Y=!P&&(K>>U&1)==1;U<8?T[8][M-U-1]=Y:U<9?T[8][15-U-1+1]=Y:T[8][15-U-1]=Y}T[M-8][8]=!P},W=function(P,j){for(var B=-1,K=M-1,U=7,Y=0,ee=o.getMaskFunction(j),ie=M-1;ie>0;ie-=2)for(ie==6&&(ie-=1);;){for(var le=0;le<2;le+=1)if(T[K][ie-le]==null){var ne=!1;Y<P.length&&(ne=(P[Y]>>>U&1)==1);var re=ee(K,ie-le);re&&(ne=!ne),T[K][ie-le]=ne,U-=1,U==-1&&(Y+=1,U=7)}if(K+=B,K<0||M<=K){K-=B,B=-B;break}}},J=function(P,j){for(var B=0,K=0,U=0,Y=new Array(j.length),ee=new Array(j.length),ie=0;ie<j.length;ie+=1){var le=j[ie].dataCount,ne=j[ie].totalCount-le;K=Math.max(K,le),U=Math.max(U,ne),Y[ie]=new Array(le);for(var re=0;re<Y[ie].length;re+=1)Y[ie][re]=255&P.getBuffer()[re+B];B+=le;var me=o.getErrorCorrectPolynomial(ne),pe=c(Y[ie],me.getLength()-1),se=pe.mod(me);ee[ie]=new Array(me.getLength()-1);for(var re=0;re<ee[ie].length;re+=1){var ge=re+se.getLength()-ee[ie].length;ee[ie][re]=ge>=0?se.getAt(ge):0}}for(var Ee=0,re=0;re<j.length;re+=1)Ee+=j[re].totalCount;for(var Ce=new Array(Ee),_e=0,re=0;re<K;re+=1)for(var ie=0;ie<j.length;ie+=1)re<Y[ie].length&&(Ce[_e]=Y[ie][re],_e+=1);for(var re=0;re<U;re+=1)for(var ie=0;ie<j.length;ie+=1)re<ee[ie].length&&(Ce[_e]=ee[ie][re],_e+=1);return Ce},Z=function(P,j,B){for(var K=h.getRSBlocks(P,j),U=u(),Y=0;Y<B.length;Y+=1){var ee=B[Y];U.put(ee.getMode(),4),U.put(ee.getLength(),o.getLengthInBits(ee.getMode(),P)),ee.
40write(U)}for(var ie=0,Y=0;Y<K.length;Y+=1)ie+=K[Y].dataCount;if(U.getLengthInBits()>ie*8)throw"code length overflow. ("+U.getLengthInBits()+">"+ie*8+")";for(U.getLengthInBits()+4<=ie*8&&U.put(0,4);U.getLengthInBits()%8!=0;)U.putBit(!1);for(;!(U.getLengthInBits()>=ie*8||(U.put(C,8),U.getLengthInBits()>=ie*8));)U.put(y,8);return J(U,K)};$.addData=function(P,j){j=j||"Byte";var B=null;switch(j){case"Numeric":B=d(P);break;case"Alphanumeric":B=f(P);break;case"Byte":B=_(P);break;case"Kanji":B=b(P);break;default:throw"mode:"+j}O.push(B),R=null},$.isDark=function(P,j){if(P<0||M<=P||j<0||M<=j)throw P+","+j;return T[P][j]},$.getModuleCount=function(){return M},$.make=function(){if(E<1){for(var P=1;P<40;P++){for(var j=h.getRSBlocks(P,D),B=u(),K=0;K<O.length;K++){var U=O[K];B.put(U.getMode(),4),B.put(U.getLength(),o.getLengthInBits(U.getMode(),P)),U.write(B)}for(var Y=0,K=0;K<j.length;K++)Y+=j[K].dataCount;if(B.getLengthInBits()<=Y*8)break}E=P}G(!1,q())},$.createTableTag=function(P,j){P=P||2,j=typeof j>"u"?P*4:j;var B="";B+='<table style="',B+=" border-width: 0px; border-style: none;",B+=" border-collapse: collapse;",B+=" padding: 0px; margin: "+j+"px;",B+='">',B+="<tbody>";for(var K=0;K<$.getModuleCount();K+=1){B+="<tr>";for(var U=0;U<$.getModuleCount();U+=1)B+='<td style="',B+=" border-width: 0px; border-style: none;",B+=" border-collapse: collapse;",B+=" padding: 0px; margin: 0px;",B+=" width: "+P+"px;",B+=" height: "+P+"px;",B+=" background-color: ",B+=$.isDark(K,U)?"#000000":"#ffffff",B+=";",B+='"/>';B+="</tr>"}return B+="</tbody>",B+="</table>",B},$.createSvgTag=function(P,j,B,K){var U={};typeof arguments[0]=="object"&&(U=arguments[0],P=U.cellSize,j=U.margin,B=U.alt,K=U.title),P=P||2,j=typeof j>"u"?P*4:j,B=typeof B=="string"?{text:B}:B||{},B.text=B.text||null,B.id=B.text?B.id||"qrcode-description":null,K=typeof K=="string"?{text:K}:K||{},K.text=K.text||null,K.id=K.text?K.id||"qrcode-title":null;var Y=$.getModuleCount()*P+j*2,ee,ie,le,ne,re="",me;for(me="l"+P+",0 0,"+P+" -"+P+",0 0,-"+P+"z ",re+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',re+=U.scalable?"":' width="'+Y+'px" height="'+Y+'px"',re+=' viewBox="0 0 '+Y+" "+Y+'" ',re+=' preserveAspectRatio="xMinYMin meet"',re+=K.text||B.text?' role="img" aria-labelledby="'+X([K.id,B.id].join(" ").trim())+'"':"",re+=">",re+=K.text?'<title id="'+X(K.id)+'">'+X(K.text)+"</title>":"",re+=B.text?'<description id="'+X(B.id)+'">'+X(B.text)+"</description>":"",re+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',re+='<path d="',le=0;le<$.getModuleCount();le+=1)for(ne=le*P+j,ee=0;ee<$.getModuleCount();ee+=1)$.isDark(le,ee)&&(ie=ee*P+j,re+="M"+ie+","+ne+me);return re+='" stroke="transparent" fill="black"/>',re+="</svg>",re},$.createDataURL=function(P,j){P=P||2,j=typeof j>"u"?P*4:j;var B=$.getModuleCount()*P+j*2,K=j,U=B-j;return w(B,B,function(Y,ee){if(K<=Y&&Y<U&&K<=ee&&ee<U){var ie=Math.floor((Y-K)/P),le=Math.floor((ee-K)/P);return $.isDark(le,ie)?0:1}else return 1})},$.createImgTag=function(P,j,B){P=P||2,j=typeof j>"u"?P*4:j;var K=$.getModuleCount()*P+j*2,U="";return U+="<img",U+=' src="',U+=$.createDataURL(P,j),U+='"',U+=' width="',U+=K,U+='"',U+=' height="',U+=K,U+='"',B&&(U+=' alt="',U+=X(B),U+='"'),U+="/>",U};var X=function(P){for(var j="",B=0;B<P.length;B+=1){var K=P.charAt(B);switch(K){case"<":j+="<";break;case">":j+=">";break;case"&":j+="&";break;case'"':j+=""";break;default:j+=K;break}}return j},F=function(P){var j=1;P=typeof P>"u"?j*2:P;var B=$.getModuleCount()*j+P*2,K=P,U=B-P,Y,ee,ie,le,ne,re={"ââ":"â","â ":"â"," â":"â"," ":" "},me={"ââ":"â","â ":"â"," â":" "," ":" "},pe="";for(Y=0;Y<B;Y+=2){for(ie=Math.floor((Y-K)/j),le=Math.floor((Y+1-K)/j),ee=0;ee<B;ee+=1)ne="â",K<=ee&&ee<U&&K<=Y&&Y<U&&$.isDark(ie,Math.floor((ee-K)/j))&&(ne=" "),K<=ee&&ee<U&&K<=Y+1&&Y+1<U&&$.isDark(le,Math.floor((ee-K)/j))?ne+=" ":ne+="â",pe+=P<1&&Y+1>=U?me[ne]:re[ne];pe+=` 41`}return B%2&&P>0?pe.substring(0,pe.length-B-1)+Array(B+1).join("â"):pe.substring(0,pe.length-1)};return $.createASCII=function(P,j){if(P=P||1,P<2)return F(j);P-=1,j=typeof j>"u"?P*2:j;var B=$.getModuleCount()*P+j*2,K=j,U=B-j,Y,ee,ie,le,ne=Array(P+1).join("ââ"),re=Array(P+1).join(" "),me="",pe="";for(Y=0;Y<B;Y+=1){for(ie=Math.floor((Y-K)/P),pe="",ee=0;ee<B;ee+=1)le=1,K<=ee&&ee<U&&K<=Y&&Y<U&&$.isDark(ie,Math.floor((ee-K)/P))&&(le=0),pe+=le?ne:re;
41for(ie=0;ie<P;ie+=1)me+=pe+` 42`}return me.substring(0,me.length-1)},$.renderTo2dContext=function(P,j){j=j||2;for(var B=$.getModuleCount(),K=0;K<B;K++)for(var U=0;U<B;U++)P.fillStyle=$.isDark(K,U)?"black":"white",P.fillRect(K*j,U*j,j,j)},$};i.stringToBytesFuncs={default:function(S){for(var k=[],C=0;C<S.length;C+=1){var y=S.charCodeAt(C);k.push(y&255)}return k}},i.stringToBytes=i.stringToBytesFuncs.default,i.createStringToBytes=function(S,k){var C=function(){for(var E=v(S),D=function(){var L=E.read();if(L==-1)throw"eof";return L},T=0,M={};;){var R=E.read();if(R==-1)break;var O=D(),$=D(),G=D(),V=String.fromCharCode(R<<8|O),q=$<<8|G;M[V]=q,T+=1}if(T!=k)throw T+" != "+k;return M}(),y=63;return function(E){for(var D=[],T=0;T<E.length;T+=1){var M=E.charCodeAt(T);if(M<128)D.push(M);else{var R=C[E.charAt(T)];typeof R=="number"?(R&255)==R?D.push(R):(D.push(R>>>8),D.push(R&255)):D.push(y)}}return D}};var s={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},o=function(){var S=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],k=1335,C=7973,y=21522,E={},D=function(T){for(var M=0;T!=0;)M+=1,T>>>=1;return M};return E.getBCHTypeInfo=function(T){for(var M=T<<10;D(M)-D(k)>=0;)M^=k<<D(M)-D(k);return(T<<10|M)^y},E.getBCHTypeNumber=function(T){for(var M=T<<12;D(M)-D(C)>=0;)M^=C<<D(M)-D(C);return T<<12|M},E.getPatternPosition=function(T){return S[T-1]},E.getMaskFunction=function(T){switch(T){case a.PATTERN000:return function(M,R){return(M+R)%2==0};case a.PATTERN001:return function(M,R){return M%2==0};case a.PATTERN010:return function(M,R){return R%3==0};case a.PATTERN011:return function(M,R){return(M+R)%3==0};case a.PATTERN100:return function(M,R){return(Math.floor(M/2)+Math.floor(R/3))%2==0};case a.PATTERN101:return function(M,R){return M*R%2+M*R%3==0};case a.PATTERN110:return function(M,R){return(M*R%2+M*R%3)%2==0};case a.PATTERN111:return function(M,R){return(M*R%3+(M+R)%2)%2==0};default:throw"bad maskPattern:"+T}},E.getErrorCorrectPolynomial=function(T){for(var M=c([1],0),R=0;R<T;R+=1)M=M.multiply(c([1,l.gexp(R)],0));return M},E.getLengthInBits=function(T,M){if(1<=M&&M<10)switch(T){case s.MODE_NUMBER:return 10;case s.MODE_ALPHA_NUM:return 9;case s.MODE_8BIT_BYTE:return 8;case s.MODE_KANJI:return 8;default:throw"mode:"+T}else if(M<27)switch(T){case s.MODE_NUMBER:return 12;case s.MODE_ALPHA_NUM:return 11;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 10;default:throw"mode:"+T}else if(M<41)switch(T){case s.MODE_NUMBER:return 14;case s.MODE_ALPHA_NUM:return 13;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 12;default:throw"mode:"+T}else throw"type:"+M},E.getLostPoint=function(T){for(var M=T.getModuleCount(),R=0,O=0;O<M;O+=1)for(var $=0;$<M;$+=1){for(var G=0,V=T.isDark(O,$),q=-1;q<=1;q+=1)if(!(O+q<0||M<=O+q))for(var L=-1;L<=1;L+=1)$+L<0||M<=$+L||q==0&&L==0||V==T.isDark(O+q,$+L)&&(G+=1);G>5&&(R+=3+G-5)}for(var O=0;O<M-1;O+=1)for(var $=0;$<M-1;$+=1){var N=0;T.isDark(O,$)&&(N+=1),T.isDark(O+1,$)&&(N+=1),T.isDark(O,$+1)&&(N+=1),T.isDark(O+1,$+1)&&(N+=1),(N==0||N==4)&&(R+=3)}for(var O=0;O<M;O+=1)for(var $=0;$<M-6;$+=1)T.isDark(O,$)&&!T.isDark(O,$+1)&&T.isDark(O,$+2)&&T.isDark(O,$+3)&&T.isDark(O,$+4)&&!T.isDark(O,$+5)&&T.isDark(O,$+6)&&(R+=40);for(var $=0;$<M;$+=1)for(var O=0;O<M-6;O+=1)T.isDark(O,$)&&!T.isDark(O+1,$)&&T.isDark(O+2,$)&&T.isDark(O+3,$)&&T.isDark(O+4,$)&&!T.isDark(O+5,$)&&T.isDark(O+6,$)&&(R+=40);for(var I=0,$=0;$<M;$+=1)for(var O=0;O<M;O+=1)T.isDark(O,$)&&(I+=1);var H=Math.abs(100*I/M/M-50)/5;return R+=H*10,R},E}(),l=function(){for(var S=new Array(256),k=new Array(256),C=0;C<8;C+=1)S[C]=1<<C;for(var C=8;C<256;C+=1)S[C]=S[C-4]^S[C-5]^S[C-6]^S[C-8];for(var C=0;C<255;C+=1)k[S[C]]=C;var y={};return y.glog=function(E){if(E<1)throw"glog("+E+")";return k[E]},y.gexp=function(E){for(;E<0;)E+=255;for(;E>=256;)E-=255;return S[E]},y}();function c(S,k){if(typeof S.length>"u")throw S.length+"/"+k;var C=function(){for(var E=0;E<S.length&&S[E]==0;)E+=1;for(var D=new Array(S.length-E+k),T=0;T<S.length-E;T+=1)D[T]=S[T+E];return D}(),y={};return y.getAt=function(E){return C[E]},y.getLength=function(){return C.length},y.multiply=function(E){for(var D=new Array(y.getLength()+E.getLength()-1),T=0;T<y.getLength();T+=1)for(var M=0;M<E.getLength();M+=1)D[T+M]^=l.gexp(l.glog(y.getAt(T))+l.glog(E.getAt(M)));return c(D,0)},y.mod=function(E){if(y.getLength()-E.getLength()<0)return y;for(var D=l.glog(y.getAt(0))-l.glog(E.getAt(0)),T=new Array(y.getLength()),M=0;M<y.getLength();M+=1)T[M]=y.getAt(M);for(var M=0;M<E.getLength();M+=1)T[M]^=l.gexp(l.glog(E.getAt(M))+D);return c(T,0).mod(E)},y}var h=function(){var S=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37
42],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],k=function(E,D){var T={};return T.totalCount=E,T.dataCount=D,T},C={},y=function(E,D){switch(D){case n.L:return S[(E-1)*4+0];case n.M:return S[(E-1)*4+1];case n.Q:return S[(E-1)*4+2];case n.H:return S[(E-1)*4+3];default:return}};return C.getRSBlocks=function(E,D){var T=y(E,D);if(typeof T>"u")throw"bad rs block @ typeNumber:"+E+"/errorCorrectionLevel:"+D;for(var M=T.length/3,R=[],O=0;O<M;O+=1)for(var $=T[O*3+0],G=T[O*3+1],V=T[O*3+2],q=0;q<$;q+=1)R.push(k(G,V));return R},C}(),u=function(){var S=[],k=0,C={};return C.getBuffer=function(){return S},C.getAt=function(y){var E=Math.floor(y/8);return(S[E]>>>7-y%8&1)==1},C.put=function(y,E){for(var D=0;D<E;D+=1)C.putBit((y>>>E-D-1&1)==1)},C.getLengthInBits=function(){return k},C.putBit=function(y){var E=Math.floor(k/8);S.length<=E&&S.push(0),y&&(S[E]|=128>>>k%8),k+=1},C},d=function(S){var k=s.MODE_NUMBER,C=S,y={};y.getMode=function(){return k},y.getLength=function(T){return C.length},y.write=function(T){for(var M=C,R=0;R+2<M.length;)T.put(E(M.substring(R,R+3)),10),R+=3;R<M.length&&(M.length-R==1?T.put(E(M.substring(R,R+1)),4):M.length-R==2&&T.put(E(M.substring(R,R+2)),7))};var E=function(T){for(var M=0,R=0;R<T.length;R+=1)M=M*10+D(T.charAt(R));return M},D=function(T){if("0"<=T&&T<="9")return T.charCodeAt(0)-48;throw"illegal char :"+T};return y},f=function(S){var k=s.MODE_ALPHA_NUM,C=S,y={};y.getMode=function(){return k},y.getLength=function(D){return C.length},y.write=function(D){for(var T=C,M=0;M+1<T.length;)D.put(E(T.charAt(M))*45+E(T.charAt(M+1)),11),M+=2;M<T.length&&D.put(E(T.charAt(M)),6)};var E=function(D){if("0"<=D&&D<="9")return D.charCodeAt(0)-48;if("A"<=D&&D<="Z")return D.charCodeAt(0)-65+10;switch(D){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+D}};return y},_=function(S){var k=s.MODE_8BIT_BYTE,C=i.stringToBytes(S),y={};return y.getMode=function(){return k},y.getLength=function(E){return C.length},y.write=function(E){for(var D=0;D<C.length;D+=1)E.put(C[D],8)},y},b=function(S){var k=s.MODE_KANJI,C=i.stringToBytesFuncs.SJIS;if(!C)throw"sjis not supported.";(function(D,T){var M=C(D);if(M.length!=2||(M[0]<<8|M[1])!=T)throw"sjis not supported."})("å",38726);var y=C(S),E={};return E.getMode=function(){return k},E.getLength=function(D){return~~(y.length/2)},E.write=function(D){for(var T=y,M=0;M+1<T.length;){var R=(255&T[M])<<8|255&T[M+1];if(33088<=R&&R<=40956)R-=33088;else if(57408<=R&&R<=60351)R-=49472;else throw"illegal char at "+(M+1)+"/"+R;R=(R>>>8&255)*192+(R&255),D.put(R,13),M+=2}if(M<T.length)throw"illegal char at "+(M+1)},E},p=function(){var S=[],k={};return k.writeByte=function(C){S.push(C&255)},k.writeShort=function(C){k.writeByte(C),k.writeByte(C>>>8)},k.writeBytes=function(C,y,E){y=y||0,E=E||C.length;for(var D=0;D<E;D+=1)k.writeByte(C[D+y])},k.writeString=function(C){for(var y=0;y<C.length;
42y+=1)k.writeByte(C.charCodeAt(y))},k.toByteArray=function(){return S},k.toString=function(){var C="";C+="[";for(var y=0;y<S.length;y+=1)y>0&&(C+=","),C+=S[y];return C+="]",C},k},g=function(){var S=0,k=0,C=0,y="",E={},D=function(M){y+=String.fromCharCode(T(M&63))},T=function(M){if(!(M<0)){if(M<26)return 65+M;if(M<52)return 97+(M-26);if(M<62)return 48+(M-52);if(M==62)return 43;if(M==63)return 47}throw"n:"+M};return E.writeByte=function(M){for(S=S<<8|M&255,k+=8,C+=1;k>=6;)D(S>>>k-6),k-=6},E.flush=function(){if(k>0&&(D(S<<6-k),S=0,k=0),C%3!=0)for(var M=3-C%3,R=0;R<M;R+=1)y+="="},E.toString=function(){return y},E},v=function(S){var k=S,C=0,y=0,E=0,D={};D.read=function(){for(;E<8;){if(C>=k.length){if(E==0)return-1;throw"unexpected end of file./"+E}var M=k.charAt(C);if(C+=1,M=="=")return E=0,-1;if(M.match(/^\s$/))continue;y=y<<6|T(M.charCodeAt(0)),E+=6}var R=y>>>E-8&255;return E-=8,R};var T=function(M){if(65<=M&&M<=90)return M-65;if(97<=M&&M<=122)return M-97+26;if(48<=M&&M<=57)return M-48+52;if(M==43)return 62;if(M==47)return 63;throw"c:"+M};return D},x=function(S,k){var C=S,y=k,E=new Array(S*k),D={};D.setPixel=function(O,$,G){E[$*C+O]=G},D.write=function(O){O.writeString("GIF87a"),O.writeShort(C),O.writeShort(y),O.writeByte(128),O.writeByte(0),O.writeByte(0),O.writeByte(0),O.writeByte(0),O.writeByte(0),O.writeByte(255),O.writeByte(255),O.writeByte(255),O.writeString(","),O.writeShort(0),O.writeShort(0),O.writeShort(C),O.writeShort(y),O.writeByte(0);var $=2,G=M($);O.writeByte($);for(var V=0;G.length-V>255;)O.writeByte(255),O.writeBytes(G,V,255),V+=255;O.writeByte(G.length-V),O.writeBytes(G,V,G.length-V),O.writeByte(0),O.writeString(";")};var T=function(O){var $=O,G=0,V=0,q={};return q.write=function(L,N){if(L>>>N)throw"length over";for(;G+N>=8;)$.writeByte(255&(L<<G|V)),N-=8-G,L>>>=8-G,V=0,G=0;V=L<<G|V,G=G+N},q.flush=function(){G>0&&$.writeByte(V)},q},M=function(O){for(var $=1<<O,G=(1<<O)+1,V=O+1,q=R(),L=0;L<$;L+=1)q.add(String.fromCharCode(L));q.add(String.fromCharCode($)),q.add(String.fromCharCode(G));var N=p(),I=T(N);I.write($,V);var H=0,W=String.fromCharCode(E[H]);for(H+=1;H<E.length;){var J=String.fromCharCode(E[H]);H+=1,q.contains(W+J)?W=W+J:(I.write(q.indexOf(W),V),q.size()<4095&&(q.size()==1<<V&&(V+=1),q.add(W+J)),W=J)}return I.write(q.indexOf(W),V),I.write(G,V),I.flush(),N.toByteArray()},R=function(){var O={},$=0,G={};return G.add=function(V){if(G.contains(V))throw"dup key:"+V;O[V]=$,$+=1},G.size=function(){return $},G.indexOf=function(V){return O[V]},G.contains=function(V){return typeof O[V]<"u"},G};return D},w=function(S,k,C){for(var y=x(S,k),E=0;E<k;E+=1)for(var D=0;D<S;D+=1)y.setPixel(D,E,C(D,E));var T=p();y.write(T);for(var M=g(),R=T.toByteArray(),O=0;O<R.length;O+=1)M.writeByte(R[O]);return M.flush(),"data:image/gif;base64,"+M};return i}();(function(){t.stringToBytesFuncs["UTF-8"]=function(i){function s(n){for(var a=[],o=0;o<n.length;o++){var l=n.charCodeAt(o);l<128?a.push(l):l<2048?a.push(192|l>>6,128|l&63):l<55296||l>=57344?a.push(224|l>>12,128|l>>6&63,128|l&63):(o++,l=65536+((l&1023)<<10|n.charCodeAt(o)&1023),a.push(240|l>>18,128|l>>12&63,128|l>>6&63,128|l&63))}return a}return s(i)}})(),function(i){r.exports=i()}(function(){return t})})(ES);var TI=ES.exports,RI=fs&&fs.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,s){i.__proto__=s}||function(i,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(i[n]=s[n])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}}(),Kf=fs&&fs.__assign||function(){return Kf=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=e[s])}return r},Kf.apply(this,arguments)};Object.defineProperty(Am,"__esModule",{value:!0});var AS=Am.QRCode=void 0,MI=AI,DI=TI,td=A,PI=function(r){RI(e,r);function e(t){var i=r.call(this,t)||this;return i.canvasRef=td.createRef(),i}return e.prototype.download=function(t,i){if(this.canvasRef.current){var s=void 0;switch(t){case"jpg":s="image/jpeg";break;case"webp":s="image/webp";break;case"png":default:s="image/png";break}var n=this.canvasRef.current.toDataURL(s,1),a=document.createElement("a");a.download=i??"react-qrcode-logo",a.href=n,a.click()}},e.prototype.utf16to8=function(t){var i="",s,n,a=t.length;for(s=0;s<a;s++)n=t.charCodeAt(s),n>=1&&n<=127?i+=t.charAt(s):n>2047?(i+=String.fromCharCode(224|n>>12&15),i+=String.fromCharCode(128|n>>6&63),i+=String.fromCharCode(128|n>>0&63)):(i+=String.fromCharCode(192|n>>6&31),i+=String.fromCharCode(128|n>>0&63));return i},e.prototype.drawRoundedSquare=function(t,i,s,n,a,o,l,c){c.lineWidth=t,c.fillStyle=a,c.strokeStyle=a,s+=t/2,i+=t/2,n-=t,Array.isArray(o)||(o=[o,o,o,o]),o=o.map(function(_){return _=Math.min(_,n/2),_<0?0:_});
42var h=o[0]||0,u=o[1]||0,d=o[2]||0,f=o[3]||0;c.beginPath(),c.moveTo(i+h,s),c.lineTo(i+n-u,s),u&&c.quadraticCurveTo(i+n,s,i+n,s+u),c.lineTo(i+n,s+n-d),d&&c.quadraticCurveTo(i+n,s+n,i+n-d,s+n),c.lineTo(i+f,s+n),f&&c.quadraticCurveTo(i,s+n,i,s+n-f),c.lineTo(i,s+h),h&&c.quadraticCurveTo(i,s,i+h,s),c.closePath(),c.stroke(),l&&c.fill()},e.prototype.drawPositioningPattern=function(t,i,s,n,a,o,l){l===void 0&&(l=[0,0,0,0]);var c=Math.ceil(i),h,u;typeof l!="number"&&!Array.isArray(l)?(h=l.outer||0,u=l.inner||0):(h=l,u=h);var d,f;typeof o!="string"?(d=o.outer,f=o.inner):(d=o,f=o);var _=n*i+s,b=a*i+s,p=i*7;this.drawRoundedSquare(c,b,_,p,d,h,!1,t),p=i*3,_+=i*2,b+=i*2,this.drawRoundedSquare(c,b,_,p,f,u,!0,t)},e.prototype.isInPositioninZone=function(t,i,s){return s.some(function(n){return i>=n.row&&i<=n.row+7&&t>=n.col&&t<=n.col+7})},e.prototype.transformPixelLengthIntoNumberOfCells=function(t,i){return t/i},e.prototype.isCoordinateInImage=function(t,i,s,n,a,o,l,c){if(c){var h=2,u=this.transformPixelLengthIntoNumberOfCells(a,l),d=this.transformPixelLengthIntoNumberOfCells(o,l),f=this.transformPixelLengthIntoNumberOfCells(s,l)-1,_=this.transformPixelLengthIntoNumberOfCells(n,l)-1;return i>=u-h&&i<=u+f+h&&t>=d-h&&t<=d+_+h}else return!1},e.prototype.shouldComponentUpdate=function(t){return!MI(this.props,t)},e.prototype.componentDidMount=function(){this.update()},e.prototype.componentDidUpdate=function(){this.update()},e.prototype.update=function(){var t,i=this.props,s=i.value,n=i.ecLevel,a=i.enableCORS,o=i.bgColor,l=i.fgColor,c=i.logoImage,h=i.logoOpacity,u=i.logoOnLoad,d=i.removeQrCodeBehindLogo,f=i.qrStyle,_=i.eyeRadius,b=i.eyeColor,p=i.logoPaddingStyle,g=+this.props.size,v=+this.props.quietZone,x=this.props.logoWidth?+this.props.logoWidth:0,w=this.props.logoHeight?+this.props.logoHeight:0,S=this.props.logoPadding?+this.props.logoPadding:0,k=DI(0,n);k.addData(this.utf16to8(s)),k.make();var C=(t=this.canvasRef)===null||t===void 0?void 0:t.current,y=C.getContext("2d"),E=g+2*v,D=k.getModuleCount(),T=g/D,M=window.devicePixelRatio||1;C.height=C.width=E*M,y.scale(M,M),y.fillStyle=o,y.fillRect(0,0,E,E);var R=v,O=[{row:0,col:0},{row:0,col:D-7},{row:D-7,col:0}];if(y.strokeStyle=l,f==="dots"){y.fillStyle=l;for(var $=T/2,G=0;G<D;G++)for(var V=0;V<D;V++)k.isDark(G,V)&&!this.isInPositioninZone(G,V,O)&&(y.beginPath(),y.arc(Math.round(V*T)+$+R,Math.round(G*T)+$+R,$/100*75,0,2*Math.PI,!1),y.closePath(),y.fill())}else if(f==="fluid"){for(var $=Math.ceil(T/2),G=0;G<D;G++)for(var V=0;V<D;V++)if(k.isDark(G,V)&&!this.isInPositioninZone(G,V,O)){var q=[!1,!1,!1,!1];G>0&&!k.isDark(G-1,V)&&V>0&&!k.isDark(G,V-1)&&(q[0]=!0),G>0&&!k.isDark(G-1,V)&&V<D-1&&!k.isDark(G,V+1)&&(q[1]=!0),G<D-1&&!k.isDark(G+1,V)&&V<D-1&&!k.isDark(G,V+1)&&(q[2]=!0),G<D-1&&!k.isDark(G+1,V)&&V>0&&!k.isDark(G,V-1)&&(q[3]=!0);var L=Math.ceil((V+1)*T)-Math.floor(V*T),N=Math.ceil((G+1)*T)-Math.floor(G*T);y.fillStyle=l,y.beginPath(),y.arc(Math.round(V*T)+$+R,Math.round(G*T)+$+R,$,0,2*Math.PI,!1),y.closePath(),y.fill(),q[0]||y.fillRect(Math.round(V*T)+R,Math.round(G*T)+R,L/2,N/2),q[1]||y.fillRect(Math.round(V*T)+R+Math.floor(L/2),Math.round(G*T)+R,L/2,N/2),q[2]||y.fillRect(Math.round(V*T)+R+Math.floor(L/2),Math.round(G*T)+R+Math.floor(N/2),L/2,N/2),q[3]||y.fillRect(Math.round(V*T)+R,Math.round(G*T)+R+Math.floor(N/2),L/2,N/2)}}else for(var G=0;G<D;G++)for(var V=0;V<D;V++)if(k.isDark(G,V)&&!this.isInPositioninZone(G,V,O)){y.fillStyle=l;var L=Math.ceil((V+1)*T)-Math.floor(V*T),N=Math.ceil((G+1)*T)-Math.floor(G*T);y.fillRect(Math.round(V*T)+R,Math.round(G*T)+R,L,N)}for(var I=0;I<3;I++){var H=O[I],G=H.row,V=H.col,W=_,J=void 0;Array.isArray(W)&&(W=W[I]),typeof W=="number"&&(W=[W,W,W,W]),b?Array.isArray(b)?J=b[I]:J=b:J=l,this.drawPositioningPattern(y,T,R,G,V,J,W)}if(c){var Z=new Image;a&&(Z.crossOrigin="Anonymous"),Z.onload=function(X){y.save();var F=x||g*.2,P=w||F,j=(g-F)/2,B=(g-P)/2;if(d||S){y.beginPath(),y.strokeStyle=o,y.fillStyle=o;var K=F+2*S,U=P+2*S,Y=j+R-S,ee=B+R-S;if(p==="circle"){var ie=Y+K/2,le=ee+U/2;y.ellipse(ie,le,K/2,U/2,0,0,2*Math.PI),y.stroke(),y.fill()}else y.fillRect(Y,ee,K,U)}
42y.globalAlpha=h,y.drawImage(Z,j+R,B+R,F,P),y.restore(),u&&u(X)},Z.src=c}},e.prototype.render=function(){var t,i=+this.props.size+2*+this.props.quietZone;return td.createElement("canvas",{id:(t=this.props.id)!==null&&t!==void 0?t:"react-qrcode-logo",height:i,width:i,style:Kf({height:i+"px",width:i+"px"},this.props.style),ref:this.canvasRef})},e.defaultProps={value:"https://reactjs.org/",ecLevel:"M",enableCORS:!1,size:150,quietZone:10,bgColor:"#FFFFFF",fgColor:"#000000",logoOpacity:1,qrStyle:"squares",eyeRadius:[0,0,0],logoPaddingStyle:"square"},e}(td.Component);AS=Am.QRCode=PI;const TS=({open:r,onClose:e})=>{const t=Ve(wh);return m.jsx(_s,{open:r,onOpenChange:i=>!i&&e(),children:m.jsx(W2,{className:"text-center !flex-col !mx-auto !text-center !max-w-md",showCloseButton:!0,onClose:e,children:m.jsxs("div",{className:"border !border-exkalibur-elements-borderColor flex flex-col gap-5 justify-center items-center p-6 bg-exkalibur-elements-background-depth-2 rounded-md",children:[m.jsx("div",{className:"i-exkalibur:expo-brand h-10 w-full invert dark:invert-none"}),m.jsx(U2,{className:"text-exkalibur-elements-textTertiary text-lg font-semibold leading-6",children:"Preview on your own mobile device"}),m.jsx(V2,{className:"bg-exkalibur-elements-background-depth-3 max-w-sm rounded-md p-1 border border-exkalibur-elements-borderColor",children:"Scan this QR code with the Expo Go app on your mobile device to open your project."}),m.jsx("div",{className:"my-6 flex flex-col items-center",children:t?m.jsx(AS,{logoImage:"/icone-app.jpg",removeQrCodeBehindLogo:!0,logoPadding:3,logoHeight:50,logoWidth:50,logoPaddingStyle:"square",style:{borderRadius:16,padding:2,backgroundColor:"#8a5fff"},value:t,size:200}):m.jsx("div",{className:"text-gray-500 text-center",children:"No Expo URL detected."})})]})})})},Kv=[{name:"iPhone SE",width:375,height:667,icon:"i-ph:device-mobile",hasFrame:!0,frameType:"mobile"},{name:"iPhone 12/13",width:390,height:844,icon:"i-ph:device-mobile",hasFrame:!0,frameType:"mobile"},{name:"iPhone 12/13 Pro Max",width:428,height:926,icon:"i-ph:device-mobile",hasFrame:!0,frameType:"mobile"},{name:"iPad Mini",width:768,height:1024,icon:"i-ph:device-tablet",hasFrame:!0,frameType:"tablet"},{name:"iPad Air",width:820,height:1180,icon:"i-ph:device-tablet",hasFrame:!0,frameType:"tablet"},{name:'iPad Pro 11"',width:834,height:1194,icon:"i-ph:device-tablet",hasFrame:!0,frameType:"tablet"},{name:'iPad Pro 12.9"',width:1024,height:1366,icon:"i-ph:device-tablet",hasFrame:!0,frameType:"tablet"},{name:"Small Laptop",width:1280,height:800,icon:"i-ph:laptop",hasFrame:!0,frameType:"laptop"},{name:"Laptop",width:1366,height:768,icon:"i-ph:laptop",hasFrame:!0,frameType:"laptop"},{name:"Large Laptop",width:1440,height:900,icon:"i-ph:laptop",hasFrame:!0,frameType:"laptop"},{name:"Desktop",width:1920,height:1080,icon:"i-ph:monitor",hasFrame:!0,frameType:"desktop"},{name:"4K Display",width:3840,height:2160,icon:"i-ph:monitor",hasFrame:!0,frameType:"desktop"}],LI=A.memo(()=>{const r=A.useRef(null),e=A.useRef(null);A.useRef(null);const[t,i]=A.useState(0),[s,n]=A.useState(!1),[a,o]=A.useState(!1),l=A.useRef(!1),c=Ve(ue.previews),h=c[t],[u,d]=A.useState("/"),[f,_]=A.useState(),[b,p]=A.useState(!1),[g,v]=A.useState(!1),[x,w]=A.useState(37.5),[S,k]=A.useState(0),C=A.useRef({isResizing:!1,side:null,startX:0,startWidthPercent:37.5,windowWidth:window.innerWidth,pointerId:null}),y=1,[E,D]=A.useState(!1),[T,M]=A.useState(Kv[0]),[R,O]=A.useState(!1),[$,G]=A.useState(!0),[V,q]=A.useState(!1),L=Ve(wh),[N,I]=A.useState(!1),[H,W]=A.useState(!1),J=Ve(K2),[Z,X]=A.useState(window.innerWidth<=768),[F,P]=A.useState(null),j=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1";A.useEffect(()=>{(async()=>{try{const Ee=await(await fetch("/mediasUrls.json")).json();P(Ee)}catch(ge){console.error("Erreur:",ge)}})()},[]),A.useEffect(()=>{if(!h){_(void 0),d("/");return}const{baseUrl:se}=h;_(se),d("/")},[h]);const B=A.useCallback((se,ge,Ee,Ce)=>ge.port<Ce[se].port?Ee:se,[]);A.useEffect(()=>{if(c.length>1&&!l.current){const se=c.reduce(B,0);i(se)}},[c,B]);const K=()=>{r.current&&(r.current.src=r.current.src)},U=async()=>{!a&&e.current?await e.current.requestFullscreen():document.fullscreenElement&&await document.exitFullscreen()};A.useEffect(()=>{const se=()=>{o(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",se),()=>{document.removeEventListener("fullscreenchange",se)}},[]);const Y=()=>{v(se=>!se)};A.useEffect(()=>{const se=()=>X(window.innerWidth<=768);return window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]);const ee=(se,ge)=>{if(!g)return;se.currentTarget.setPointerCapture(se.pointerId),document.body.style.userSelect="none",document.body.style.cursor="ew-resize",C.current={isResizing:!0,side:ge,startX:se.clientX,startWidthPercent:x,windowWidth:window.innerWidth,pointerId:se.pointerId}},ie=({side:se})=>se?m.jsx("div",{className:`resize-handle-${se}`,onPointerDown:ge=>
42ee(ge,se),style:{position:"absolute",top:0,...se==="left"?{left:0,marginLeft:"-7px"}:{right:0,marginRight:"-7px"},width:"15px",height:"100%",cursor:"ew-resize",background:"bg-white/10 backdrop-blur-xl",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s",userSelect:"none",touchAction:"none",zIndex:10},onMouseOver:ge=>ge.currentTarget.style.background="var(--exkalibur-elements-background-depth-4, rgba(0,0,0,.3))",onMouseOut:ge=>ge.currentTarget.style.background="var(--exkalibur-elements-background-depth-3, rgba(0,0,0,.15))",title:"Drag to resize width",children:m.jsx(le,{})}):null;A.useEffect(()=>{if(!g)return;const se=Ce=>{const _e=C.current;if(!_e.isResizing||Ce.pointerId!==_e.pointerId)return;const Ke=(Ce.clientX-_e.startX)/_e.windowWidth*100*y;let Le=_e.startWidthPercent;if(_e.side==="right"?Le=_e.startWidthPercent+Ke:_e.side==="left"&&(Le=_e.startWidthPercent-Ke),Le=Math.max(10,Math.min(Le,90)),w(Le),e.current){const Qe=e.current.clientWidth,Xe=Math.round(Qe*Le/100);k(Xe);const yt=e.current.querySelector('div[style*="width"]');yt&&(yt.style.width=`${Le}%`)}},ge=Ce=>{const _e=C.current;if(!_e.isResizing||Ce.pointerId!==_e.pointerId)return;document.querySelectorAll(".resize-handle-left, .resize-handle-right").forEach(Ke=>{Ke.hasPointerCapture?.(Ce.pointerId)&&Ke.releasePointerCapture(Ce.pointerId)}),C.current={...C.current,isResizing:!1,side:null,pointerId:null},document.body.style.userSelect="",document.body.style.cursor=""};document.addEventListener("pointermove",se,{passive:!1}),document.addEventListener("pointerup",ge),document.addEventListener("pointercancel",ge);function Ee(){document.removeEventListener("pointermove",se),document.removeEventListener("pointerup",ge),document.removeEventListener("pointercancel",ge),C.current.pointerId!==null&&(document.querySelectorAll(".resize-handle-left, .resize-handle-right").forEach(_e=>{_e.hasPointerCapture?.(C.current.pointerId)&&_e.releasePointerCapture(C.current.pointerId)}),C.current={...C.current,isResizing:!1,side:null,pointerId:null},document.body.style.userSelect="",document.body.style.cursor="")}return Ee},[g,y]),A.useEffect(()=>{const se=()=>{if(C.current.windowWidth=window.innerWidth,e.current&&g){const ge=e.current.clientWidth;k(Math.round(ge*x/100))}};if(window.addEventListener("resize",se),e.current&&g){const ge=e.current.clientWidth;k(Math.round(ge*x/100))}return()=>{window.removeEventListener("resize",se)}},[g,x]),A.useEffect(()=>{if(e.current&&g){const se=e.current.clientWidth;k(Math.round(se*x/100))}},[g]);const le=()=>m.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",pointerEvents:"none"},children:m.jsx("div",{style:{color:"var(--exkalibur-elements-textSecondary, rgba(0,0,0,0.5))",fontSize:"10px",lineHeight:"5px",userSelect:"none",marginLeft:"1px"},children:"â¢â¢â¢ â¢â¢â¢"})}),ne=se=>{if(h?.baseUrl){const ge=h.baseUrl.match(/^https?:\/\/([^.]+)\.local-credentialless\.webcontainer-api\.io/);if(ge){const Ce=`/webcontainer/preview/${ge[1]}`;let _e=se.width,Fe=se.height;if(R&&(se.frameType==="mobile"||se.frameType==="tablet")&&(_e=se.height,Fe=se.width),$&&se.hasFrame){const Ke=se.frameType==="mobile"?R?120:40:60,Le=se.frameType==="mobile"?80:R?60:100,Qe=window.open("","_blank",`width=${_e+Ke},height=${Fe+Le+40},menubar=no,toolbar=no,location=no,status=no`);if(!Qe){console.error("Failed to open new window");return}const Xe=pe(),yt=se.frameType==="mobile"?"36px":"20px",$e=se.frameType==="mobile"?R?"40px 60px":"40px 20px":R?"30px 50px":"50px 30px",ki=R?"50%":"20px",or=R?"30px":"50%",Br=R?"translateY(-50%)":"translateX(-50%)",Ci=R?"8px":se.frameType==="mobile"?"60px":"80px",Ei=R?se.frameType==="mobile"?"60px":"80px":"8px",Ns=R?"50%":"15px",Nt=R?"30px":"50%",Zr=R?"translateY(50%)":"translateX(50%)",xr=R?"4px":"40px",Ai=R?"40px":"4px",_r=` 43 <!DOCTYPE html> 44 <html> 45 <head> 46 <meta charset="utf-8"> 47 <title>${se.name} Preview</title> 48 <style> 49 body { 50 margin: 0; 51 padding: 0; 52 display: flex; 53 justify-content: center; 54 align-items: center; 55 height: 100vh; 56 background: #f0f0f0; 57 overflow: hidden; 58 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 59 } 60 61 .device-container { 62 position: relative; 63 } 64 65 .device-name { 66 position: absolute; 67 top: -30px; 68 left: 0; 69 right: 0; 70 text-align: center; 71 font-size: 14px; 72 color: #333; 73 } 74 75 .device-frame { 76 position: relative; 77 border-radius: ${yt}; 78 background: ${Xe}; 79 padding: ${$e}; 80 box-shadow: 0 10px 30px rgba(0,0,0,0.2); 81 overflow: hidden; 82 } 83 84 /* Notch */ 85 .device-frame:before { 86 content: ''; 87 position: absolute; 88 top: ${ki}; 89 left: ${or}; 90 transform: ${Br}; 91 width: ${Ci}; 92 height: ${Ei}; 93 background: #333; 94 border-radius: 4px; 95 z-index: 2; 96 } 97 98 /* Home button */ 99 .device-frame:after { 100 content: ''; 101 position: absolute; 102 bottom: ${Ns}; 103 right: ${Nt}; 104 transform: ${Zr}; 105 width: ${xr}; 106 height: ${Ai}; 107 background: #333; 108 border-radius: 50%; 109 z-index: 2; 110 } 111 112 iframe { 113 border: none; 114 width: ${_e}px; 115 height: ${Fe}px; 116 background: white; 117 display: block; 118 } 119 </style> 120 </head> 121 <body> 122 <div class="device-container"> 123 <div class="device-name">${se.name} ${R?"(Landscape)":"(Portrait)"}</div> 124 <div class="device-frame"> 125 <iframe src="${h.baseUrl}" sandbox="allow-scripts allow-forms allow-popups allow-modals allow-storage-access-by-user-activation allow-same-origin" allow="cross-origin-isolated"></iframe> 126 </div> 127 </div> 128 </body> 129 </html> 130 `;Qe.document.open(),Qe.document.write(_r),Qe.document.close()}else{const Ke=window.open(Ce,"_blank",`width=${_e},height=${Fe},menubar=no,toolbar=no,location=no,status=no`);
130Ke&&Ke.focus()}}else console.warn("[Preview] Invalid WebContainer URL:",h.baseUrl)}},re=A.useCallback(()=>{if(!T)return"40px 20px";const se=T.frameType==="mobile";return R?se?"40px 60px":"30px 50px":se?"40px 20px":"50px 30px"},[R,T]),me=A.useCallback(()=>1,[R,T,x]);A.useEffect(()=>()=>{},[g,V,me,R,T]);const pe=A.useCallback(()=>document.documentElement.classList.contains("dark")||document.documentElement.getAttribute("data-theme")==="dark"||window.matchMedia("(prefers-color-scheme: dark)").matches?"#555":"#111",[]);return A.useEffect(()=>{const se=window.matchMedia("(prefers-color-scheme: dark)"),ge=()=>{V&&q(!0)};return se.addEventListener("change",ge),()=>{se.removeEventListener("change",ge)}},[V]),m.jsxs("div",{ref:e,className:"w-full h-full flex flex-col relative",children:[s&&m.jsx("div",{className:"z-iframe-overlay w-full h-full absolute",onClick:()=>n(!1)}),m.jsxs("div",{className:"bg-white/10 backdrop-blur-xl p-2 flex items-center gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[!Z&&m.jsx(jt,{icon:"i-ph:arrow-clockwise",onClick:K}),!Z&&m.jsx(jt,{icon:"i-ph:selection",onClick:()=>p(!b),className:b?"bg-exkalibur-elements-background-depth-3":""})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[!Z&&m.jsx(jt,{icon:"i-ph:devices",onClick:Y,title:g?"Switch to Responsive Mode":"Switch to Device Mode"}),L&&m.jsx(jt,{icon:"i-ph:qr-code",onClick:()=>I(!0),title:"Show QR"}),m.jsx(TS,{open:N,onClose:()=>I(!1)}),g&&!Z&&m.jsxs(m.Fragment,{children:[m.jsx(jt,{icon:"i-ph:device-rotate",onClick:()=>O(!R),title:R?"Switch to Portrait":"Switch to Landscape"}),m.jsx(jt,{icon:V?"i-ph:device-mobile":"i-ph:device-mobile-slash",onClick:()=>q(!V),title:V?"Hide Device Frame":"Show Device Frame"})]}),!Z&&m.jsx(jt,{icon:a?"i-ph:arrows-in":"i-ph:arrows-out",onClick:U,title:a?"Exit Full Screen":"Full Screen"}),m.jsx("div",{className:"flex items-center relative",children:!Z&&m.jsxs(Sp,{children:[m.jsx(kp,{asChild:!0,children:m.jsx("button",{className:"text-xl rounded-lg bg-transparent hover:bg-white/10 items-center",children:m.jsx("div",{className:"i-ph:browser bg-#FFFFFF80 hover:text-white"})})}),m.jsx(Cp,{children:m.jsxs(Ep,{className:"min-w-[240px] max-h-[400px] overflow-y-auto bg-exkalibur-elements-background-depth-2 rounded-xl border border-exkalibur-elements-borderColor shadow-2xl p-1 z-[9999] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",sideOffset:5,align:"start",children:[m.jsxs("div",{className:"p-3 border-b border-exkalibur-elements-borderColor",children:[m.jsx("div",{className:"flex items-center justify-between mb-2",children:m.jsx("span",{className:"text-sm font-medium text-exkalibur-elements-textPrimary",children:"Window Options Menu"})}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs(Kn,{className:"flex w-full justify-between items-center text-start bg-transparent text-xs text-exkalibur-elements-textTertiary hover:text-exkalibur-elements-textPrimary outline-none cursor-pointer",onClick:()=>{if(!h?.baseUrl){console.warn("[Preview] No active preview available");return}const se=h.baseUrl.match(/^https?:\/\/([^.]+)\.local-credentialless\.webcontainer-api\.io/);if(!se){console.warn("[Preview] Invalid WebContainer URL:",h.baseUrl);return}const ge=se[1],Ee=`${window.location.origin}/webcontainer/preview/${ge}`;window.open(Ee,`preview-${ge}`,"width=1280,height=720,menubar=no,toolbar=no,location=no,status=no,resizable=yes")},children:[m.jsx("span",{children:"Open in new window"}),m.jsx("div",{className:"i-ph:browser h-5 w-4"})]}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-xs text-exkalibur-elements-textTertiary",children:"Show Device Frame"}),m.jsx("button",{className:`w-10 h-5 rounded-full transition-colors duration-200 ${$?"bg-[#6D28D9]":"bg-gray-300 dark:bg-gray-700"} relative`,onClick:se=>{se.stopPropagation(),G(!$)},children:m.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform duration-200 ${$?"transform translate-x-5":""}`})})]}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-xs text-exkalibur-elements-textTertiary",children:"Landscape Mode"}),m.jsx("button",{className:`w-10 h-5 rounded-full transition-colors duration-200 ${R?"bg-[#6D28D9]":"bg-gray-300 dark:bg-gray-700"} relative`,onClick:se=>{se.stopPropagation(),O(!R)},children:m.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform duration-200 ${R?"transform translate-x-5":""}`})})]})]})]}),Kv.map(se=>m.jsxs(Kn,{className:"w-full px-4 py-3.5 text-left text-exkalibur-elements-textPrimary text-sm whitespace-nowrap flex items-center gap-3 group hover:bg-exkalibur-elements-background-depth-1 cursor-pointer outline-none focus:bg-exkalibur-elements-background-depth-1",onClick:()=>{M(se),ne(se)},children:[m.jsx("div",{className:`${se.icon} w-5 h-5 text-exkalibur-elements-textTertiary group-hover:text-[#6D28D9] transition-colors duration-200`}),m.jsxs("div",{className:"flex-grow flex flex-col",children:[m.jsx("span",{className:"font-medium group-hover:text-[#6D28D9] transition-colors duration-200",children:se.name}),m.jsxs("span",{className:"text-xs text-exkalibur-elements-textTertiary group-hover:text-[#6D28D9] transition-colors duration-200",children:[R&&(se.frameType==="mobile"||se.frameType==="tablet")?`${se.height} Ã ${se.width}`:`${se.width} Ã ${se.height}`,se.hasFrame&&$?" (with frame)":""]})]}),T.name===se.name&&m.jsx("div",{className:"text-[#6D28D9]",children:m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:m.jsx("polyline",{points:"20 6 9 17 4 12"})})})]},se.name))]})})]})})]}),m.jsx("div",{className:"flex-1"}),Z&&m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(jt,{icon:"i-ph:arrow-clockwise",onClick:K}),m.jsx(jt,{icon:a?"i-ph:arrows-in":"i-ph:arrows-out",onClick:U,title:a?"Exit Full Screen":"Full Screen"})]})]}),m.jsx("div",{className:"flex-1 border-t border-exkalibur-elements-borderColor flex justify-center items-center overflow-auto",children:m.jsxs("div",{style:{width:g?V?"100%":`${x}%`:"100%",height:"100%",overflow:"auto",background:"",position:"relative",display:"flex",justifyContent:"center",alignItems:"center"},children:[h?m.jsxs(m.Fragment,{children:[g&&V?m.jsx("div",{className:"device-wrapper",style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%",padding:"0",overflow:"auto",transition:"all 0.3s ease",position:"relative"},children:m.jsxs("div",{className:"device-frame-container",style:{position:"relative",borderRadius:T.frameType==="mobile"?"36px":"20px",background:pe(),padding:re(),boxSh
130adow:"0 10px 30px rgba(0,0,0,0.2)",overflow:"hidden",transform:"scale(1)",transformOrigin:"center center",transition:"all 0.3s ease",margin:"40px",width:R?`${T.height+(T.frameType==="mobile"?120:60)}px`:`${T.width+(T.frameType==="mobile"?40:60)}px`,height:R?`${T.width+(T.frameType==="mobile"?80:60)}px`:`${T.height+(T.frameType==="mobile"?80:100)}px`},children:[m.jsx("div",{style:{position:"absolute",top:R?"50%":"20px",left:R?"30px":"50%",transform:R?"translateY(-50%)":"translateX(-50%)",width:R?"8px":T.frameType==="mobile"?"60px":"80px",height:R?T.frameType==="mobile"?"60px":"80px":"8px",background:"#333",borderRadius:"4px",zIndex:2}}),m.jsx("div",{style:{position:"absolute",bottom:R?"50%":"15px",right:R?"30px":"50%",transform:R?"translateY(50%)":"translateX(50%)",width:R?"4px":"40px",height:R?"40px":"4px",background:"#333",borderRadius:"50%",zIndex:2}}),m.jsx("iframe",{ref:r,title:"preview",style:{border:"none",width:R?`${T.height}px`:`${T.width}px`,height:R?`${T.width}px`:`${T.height}px`,background:"white",display:"block"},src:f,sandbox:"allow-scripts allow-forms allow-popups allow-modals allow-storage-access-by-user-activation allow-same-origin",allow:"cross-origin-isolated"})]})}):m.jsx("iframe",{ref:r,title:"preview",className:"border-none w-full h-full bg-white/10 backdrop-blur-xl",src:f,sandbox:"allow-scripts allow-forms allow-popups allow-modals allow-storage-access-by-user-activation allow-same-origin",allow:"geolocation; ch-ua-full-version-list; cross-origin-isolated; screen-wake-lock; publickey-credentials-get; shared-storage-select-url; ch-ua-arch; bluetooth; compute-pressure; ch-prefers-reduced-transparency; deferred-fetch; usb; ch-save-data; publickey-credentials-create; shared-storage; deferred-fetch-minimal; run-ad-auction; ch-ua-form-factors; ch-downlink; otp-credentials; payment; ch-ua; ch-ua-model; ch-ect; autoplay; camera; private-state-token-issuance; accelerometer; ch-ua-platform-version; idle-detection; private-aggregation; interest-cohort; ch-viewport-height; local-fonts; ch-ua-platform; midi; ch-ua-full-version; xr-spatial-tracking; clipboard-read; gamepad; display-capture; keyboard-map; join-ad-interest-group; ch-width; ch-prefers-reduced-motion; browsing-topics; encrypted-media; gyroscope; serial; ch-rtt; ch-ua-mobile; window-management; unload; ch-dpr; ch-prefers-color-scheme; ch-ua-wow64; attribution-reporting; fullscreen; identity-credentials-get; private-state-token-redemption; hid; ch-ua-bitness; storage-access; sync-xhr; ch-device-memory; ch-viewport-width; picture-in-picture; magnetometer; clipboard-write; microphone"}),m.jsx(EI,{isSelectionMode:b,setIsSelectionMode:p,containerRef:r})]}):m.jsxs("div",{className:"w-full h-full",children:[m.jsx("video",{src:J===Fx.building?(j?"/building.webm":F?.BUILDING)||"/building.webm":(j?"/coding.webm":F?.CODING)||"/coding.webm",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"w-full h-full object-cover"}),m.jsx("div",{className:` 131 absolute top-0 left-0 w-full h-full z-10 bg-transparent 132 flex items-end justify-center pb-6 select-none 133 text-white text-lg md:text-xl lg:text-2xl 134 text-center 135 `,style:{fontFamily:"IBrand, sans-serif"},children:"Your project is being created. This may take between 3 and 10 minutes."})]}),g&&!V&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{style:{position:"absolute",top:"-25px",left:"50%",transform:"translateX(-50%)",background:"var(--exkalibur-elements-background-depth-3, rgba(0,0,0,0.7))",color:"var(--exkalibur-elements-textPrimary, white)",padding:"2px 8px",borderRadius:"4px",fontSize:"12px",pointerEvents:"none",opacity:C.current.isResizing?1:0,transition:"opacity 0.3s"},children:[S,"px"]}),m.jsx(ie,{side:"left"}),m.jsx(ie,{side:"right"})]})]})})]})});function uh(r){const e=["B","KB","MB","GB","TB"];let t=r,i=0;for(;t>=1024&&i<e.length-1;)t/=1024,i++;return`${t.toFixed(1)} ${e[i]}`}const Tm=A.forwardRef(({className:r,type:e,...t},i)=>m.jsx("input",{type:e,className:ce("flex h-10 w-full rounded-md border border-exkalibur-elements-border bg-exkalibur-elements-background px-3 py-2 text-sm r
135ing-offset-exkalibur-elements-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-exkalibur-elements-textSecondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-exkalibur-elements-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),ref:i,...t}));Tm.displayName="Input";const NI=({message:r="Loading...",progress:e,progressText:t})=>m.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/80 z-50 backdrop-blur-sm",children:m.jsxs("div",{className:"relative flex flex-col items-center gap-4 p-8 rounded-lg bg-exkalibur-elements-background-depth-2 shadow-lg",children:[m.jsx("div",{className:"i-svg-spinners:90-ring-with-bg text-exkalibur-elements-loader-progress",style:{fontSize:"2rem"}}),m.jsx("p",{className:"text-lg text-exkalibur-elements-textTertiary",children:r}),e!==void 0&&m.jsxs("div",{className:"w-64 flex flex-col gap-2",children:[m.jsx("div",{className:"w-full h-2 bg-exkalibur-elements-background-depth-1 rounded-full overflow-hidden",children:m.jsx("div",{className:"h-full bg-exkalibur-elements-loader-progress transition-all duration-300 ease-out rounded-full",style:{width:`${Math.min(100,Math.max(0,e))}%`}})}),t&&m.jsx("p",{className:"text-sm text-exkalibur-elements-textTertiary text-center",children:t})]})]})}),OI={default:{container:"py-8 p-6",icon:{container:"w-12 h-12 mb-3",size:"w-6 h-6"},title:"text-base",description:"text-sm mt-1",actions:"mt-4",buttonSize:"default"},compact:{container:"py-4 p-4",icon:{container:"w-10 h-10 mb-2",size:"w-5 h-5"},title:"text-sm",description:"text-xs mt-0.5",actions:"mt-3",buttonSize:"sm"}};function dh({icon:r="i-ph:folder-simple-dashed",title:e,description:t,actionLabel:i,onAction:s,secondaryActionLabel:n,onSecondaryAction:a,className:o,variant:l="default"}){const c=OI[l],h={whileHover:{scale:1.02},whileTap:{scale:.98}};return m.jsxs("div",{className:ce("flex flex-col items-center justify-center","text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark","bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 rounded-lg",c.container,o),children:[m.jsx("div",{className:ce("rounded-full bg-exkalibur-elements-background-depth-3 dark:bg-exkalibur-elements-background-depth-4 flex items-center justify-center",c.icon.container),children:m.jsx("span",{className:ce(r,c.icon.size,"text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark")})}),m.jsx("p",{className:ce("font-medium",c.title),children:e}),t&&m.jsx("p",{className:ce("text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark text-center max-w-xs",c.description),children:t}),(i||n)&&m.jsxs("div",{className:ce("flex items-center gap-2",c.actions),children:[i&&s&&m.jsx(Ae.div,{...h,children:m.jsx(wa,{onClick:s,variant:"default",size:c.buttonSize,className:"bg-purple-500 hover:bg-purple-600 text-white",children:i})}),n&&a&&m.jsx(Ae.div,{...h,children:m.jsx(wa,{onClick:a,variant:"outline",size:c.buttonSize,children:n})})]})]})}function rd({label:r,value:e,onRemove:t,active:i=!1,icon:s,className:n}){const a={initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9}};return m.jsxs(Ae.div,{initial:"initial",animate:"animate",exit:"exit",variants:a,transition:{duration:.2},className:ce("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all",i?"bg-purple-500/15 text-purple-600 dark:text-purple-400 border border-purple-500/30":"bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",t&&"pr-1",n),children:[s&&m.jsx("span",{className:ce(s,"text-inherit")}),m.jsxs("span",{children:[r,e!==void 0&&": ",e!==void 0&&m.jsx("span",{className:i?"text-purple-700 dark:text-purple-300 font-semibold":"text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:e})]}),t&&m.jsx("button",{type:"button",onClick:t,className:ce("ml-1 p-0.5 rounded-full hover:bg-exkalibur-elements-background-depth-3 dark:hover:bg-exkalibur-elements-background-depth-4 transition-colors",i?"text-purple-600 dar
135k:text-purple-400":"text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark"),"aria-label":`Remove ${r} filter`,children:m.jsx("span",{className:"i-ph:x w-3 h-3"})})]})}function II({stats:r,className:e,compact:t=!1}){const{totalFiles:i,totalSize:s,languages:n,hasPackageJson:a,hasDependencies:o}=r;return m.jsxs("div",{className:ce("space-y-3",e),children:[!t&&m.jsx("p",{className:"text-sm font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:"Repository Statistics:"}),m.jsxs("div",{className:ce("grid gap-3",t?"grid-cols-2":"grid-cols-2 md:grid-cols-3"),children:[i!==void 0&&m.jsxs("div",{className:"flex items-center gap-2 text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:[m.jsx("span",{className:"i-ph:files text-purple-500 w-4 h-4"}),m.jsxs("span",{className:t?"text-xs":"text-sm",children:["Total Files: ",i.toLocaleString()]})]}),s!==void 0&&m.jsxs("div",{className:"flex items-center gap-2 text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:[m.jsx("span",{className:"i-ph:database text-purple-500 w-4 h-4"}),m.jsxs("span",{className:t?"text-xs":"text-sm",children:["Total Size: ",uh(s)]})]})]}),n&&Object.keys(n).length>0&&m.jsxs("div",{className:t?"pt-1":"pt-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark mb-2",children:[m.jsx("span",{className:"i-ph:code text-purple-500 w-4 h-4"}),m.jsx("span",{className:t?"text-xs":"text-sm",children:"Languages:"})]}),m.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(n).sort(([,l],[,c])=>c-l).slice(0,t?3:5).map(([l,c])=>m.jsxs(Ut,{variant:"subtle",size:t?"sm":"md",children:[l," (",uh(c),")"]},l)),Object.keys(n).length>(t?3:5)&&m.jsxs(Ut,{variant:"subtle",size:t?"sm":"md",children:["+",Object.keys(n).length-(t?3:5)," more"]})]})]}),(a||o)&&m.jsx("div",{className:t?"pt-1":"pt-2",children:m.jsxs("div",{className:"flex flex-wrap gap-2",children:[a&&m.jsx(Ut,{variant:"primary",size:t?"sm":"md",icon:"i-ph:package w-3.5 h-3.5",children:"package.json"}),o&&m.jsx(Ut,{variant:"primary",size:t?"sm":"md",icon:"i-ph:tree-structure w-3.5 h-3.5",children:"Dependencies"})]})})]})}const Rm=A.forwardRef(({className:r,onClear:e,showClearButton:t=!0,iconClassName:i,containerClassName:s,loading:n=!1,...a},o)=>{const l=!!a.value;return m.jsxs("div",{className:ce("relative flex items-center w-full",s),children:[m.jsx("div",{className:ce("absolute left-3 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary",i),children:n?m.jsx("span",{className:"i-ph:spinner-gap animate-spin w-4 h-4"}):m.jsx("span",{className:"i-ph:magnifying-glass w-4 h-4"})}),m.jsx(Tm,{ref:o,className:ce("pl-10",l&&t?"pr-10":"",r),...a}),m.jsx(Ui,{children:l&&t&&m.jsx(Ae.button,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},type:"button",onClick:e,className:"absolute right-3 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary hover:text-exkalibur-elements-textSecondary p-1 rounded-full hover:bg-exkalibur-elements-background-depth-2","aria-label":"Clear search",children:m.jsx("span",{className:"i-ph:x w-3.5 h-3.5"})})})]})});Rm.displayName="SearchInput";const jI={online:"bg-green-500",success:"bg-green-500",offline:"bg-red-500",error:"bg-red-500",away:"bg-yellow-500",warning:"bg-yellow-500",busy:"bg-red-500",info:"bg-blue-500",loading:"bg-purple-500"},BI={sm:"w-2 h-2",md:"w-3 h-3",lg:"w-4 h-4"},FI={sm:"text-xs",md:"text-sm",lg:"text-base"};function RS({status:r,size:e="md",pulse:t=!1,label:i,className:s}){const n=jI[r]||"bg-gray-500",a=BI[e],o=FI[e];return m.jsxs("div",{className:ce("flex items-center gap-2",s),children:[m.jsx("span",{className:ce("rounded-full relative",n,a),children:t&&m.jsx("span",{className:ce("absolute inset-0 rounded-full animate-ping opacity-75",n)})}),i&&m.jsx("span",{className:ce("text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",o),children:i})]})}function $I({isOpen:r,onClose:e,onPush:t}){const{keycloak:i}=yi(),[s,n]=A.useState(""),[a,o]=A.useState(!1),[l,c]=A.useState(!1),[h,u]=A.useState(null),[d,f]=A.useState([]),[_,b]=A.useState([]),[p,g]=A.useState(""),[v,x]=A.useState(!1),[w,S]=A.useState(!1),[k,C]=A.useState(""),[y,E]=A.useState([]),[D,T]=A.useState(""),[M,R]=A.useState(!1);A.useEffect(()=>{if(r){const q=Ks("github_connection");q?.user&&q?.token&&(u(q.user),q.token.trim()&&O(q.token))}},[r]),A.useEffect(()=>{if(d.length===0){b([]);return}if(!p.trim()){b(d);return}const q=p.toLowerCase().trim(),L=d.filter(N=>N.name.toLowerCase().includes(q)||N.description&&N.description.toLowerCase().includes(q)||N.language&&N.language.toLowerCase().includes(q));b(L)},[d,p]);const O=A.useCallback(async q=>{if(!q){dr.logError("No GitHub token available"),he.error("GitHub authentication required");return}try{x(!0);let L=[],N=1,I=!0;for(;I;){const H=`https://api.github.com/user/repos?sort=updated&per_page=100&page=${N}&affiliation=owner,organization_member`,W=await fetch(H,{headers:{Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${q.trim()}`}});if(!W.ok){let J={};try{J=await W.json(),console.error("Error response data:",J)}
135catch(Z){J={message:"Could not parse error response"},console.error("Could not parse error response:",Z)}if(W.status===401)he.error("GitHub token expired. Please reconnect your account."),Ks("github_connection")&&(localStorage.removeItem("github_connection"),u(null));else if(W.status===403&&W.headers.get("x-ratelimit-remaining")==="0"){const Z=W.headers.get("x-ratelimit-reset"),X=Z?new Date(parseInt(Z)*1e3).toLocaleTimeString():"soon";he.error(`GitHub API rate limit exceeded. Limit resets at ${X}`)}else dr.logError("Failed to fetch GitHub repositories",{status:W.status,statusText:W.statusText,error:J}),he.error(`Failed to fetch repositories: ${J.message||W.statusText}`);return}try{const J=await W.json();L=L.concat(J),J.length<100?I=!1:N+=1}catch(J){console.error("Error parsing JSON response:",J),dr.logError("Failed to parse GitHub repositories response",{parseError:J}),he.error("Failed to parse repository data"),f([]);return}}f(L)}catch(L){console.error("Exception while fetching GitHub repositories:",L),dr.logError("Failed to fetch GitHub repositories",{error:L}),he.error("Failed to fetch recent repositories")}finally{x(!1)}},[]);async function $(q){q.preventDefault();const L=Ks("github_connection");if(!L?.token||!L?.user){he.error("Please connect your GitHub account in Settings > Connections first");return}if(!s.trim()){he.error("Repository name is required");return}c(!0);try{const N=new gg({auth:L.token});let I=!1;try{const{data:Z}=await N.repos.get({owner:L.user.login,repo:s});I=!0;let X=`Repository "${s}" already exists. Do you want to update it? This will add or modify files in the repository.`;Z.private!==a&&(X+=` 136 137${a?"This will also change the repository from public to private.":"This will also change the repository from private to public."}`);const F=window.confirm(X);if(q2(0,1,i.token),!F){c(!1);return}if(Z.private!==a)try{await N.repos.update({owner:L.user.login,repo:s,private:a}),he.info(`Repository visibility updated to ${a?"private":"public"}`)}catch(P){console.error("Error updating repository visibility:",P),he.warning("Failed to update repository visibility, but will continue with push")}}catch(Z){if(Z?.status&&Z.status!==404){console.error("Error checking repository:",Z),he.error(`Failed to check repository: ${Z.message||"Unknown error"}`),c(!1);return}}const H=await t(s,L.user.login,L.token,a);C(H);const W=ue.files.get(),J=Object.entries(W).filter(([,Z])=>Z?.type==="file"&&!Z.isBinary).map(([Z,X])=>({path:Px(Z),size:new TextEncoder().encode(X.content||"").length}));E(J),S(!0)}catch(N){console.error("Error pushing to GitHub:",N),he.error("Failed to push to GitHub. Please check your repository name and try again.")}finally{c(!1)}}const G=()=>{n(""),o(!1),S(!1),C(""),e()},V=async()=>{if(!D.trim()){he.error("Please provide a valid GitHub token");return}try{R(!0);const q=new gg({auth:D.trim()}),{data:L}=await q.users.getAuthenticated(),I=(await fetch("https://api.github.com/user",{headers:{Authorization:`Bearer ${D.trim()}`}})).headers.get("x-oauth-scopes")||"";if(!(I.includes("repo")||I.includes("public_repo"))){he.error('Token must have "repo" scope to create and push to repositories (both public and private)'),R(!1);return}I.includes("public_repo")&&!I.includes("repo")&&he.warning("Token only has public_repo scope. You can only push to public repositories."),localStorage.setItem("github_connection",JSON.stringify({user:L,token:D.trim()})),u(L),O(D.trim()),he.success("GitHub account connected successfully!")}catch(q){console.error(q),he.error("Invalid token or connection failed")}finally{R(!1)}};return w?m.jsx(_s,{open:r,onOpenChange:q=>!q&&G(),children:m.jsxs(sn,{children:[m.jsx(nn,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[9999]"}),m.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[9999]",children:m.jsx(Ae.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"w-[95vw] max-w-[600px] max-h-[90vh] overflow-y-auto mx-4",children:m.jsx(on,{className:"bg-white dark:bg-exkalibur-elements-background-depth-1 rounded-lg border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark shadow-xl max-h-[90vh] overflow-y-auto","aria-describedby":"push-dialog-description",children:m.jsxs("div",{className:"p-4 sm:p-6 pb-safe",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"w-10 h-10 rounded-xl bg-green-500/10 flex items-center justify-center text-green-500",children:m.jsx("div",{className:"i-ph:check-circle w-5 h-5"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:"Successfully pushed to GitHub"}),m.jsx("p",{id:"success-dialog-description",className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:"Your code is now available on GitHub"})]})]}),m.jsx(Sa,{asChild:!0,children:m.jsxs("button",{onClick:G,className:"p-2 rounded-lg transition-all duration-200 ease-in-out bg-transparent text-exkalibur-elements-textTertiary hover:text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textTertiary-dark dark:hover:text-exkalibur-elements-textPrimary-dark hover:bg-exkalibur-elements-background-depth-2 dark:hover:bg-exkalibur-elements-background-depth-3 focus:outline-none focus:ring-2 focus:ring-exkalibur-elements-borderColor dark:focus:ring-exkalibur-elements-borderColor-dark",children:[m.jsx("span",{className:"i-ph:x block w-5 h-5","aria-hidden":"true"}),m.jsx("span",{className:"sr-only",children:"Close dialog"})]})})]}),m.jsxs("div",{className:"bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 rounded-lg p-4 text-left border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("p",{className:"text-sm font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark mb-2 flex items-center gap-2",children:[m.jsx("span",{className:"i-ph:github-logo w-4 h-4 text-purple-500"}),"Repository URL"]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("code",{className:"flex-1 text-sm bg-exkalibur-elements-background-depth-1 dark:bg-exkalibur-elements-background-depth-4 px-3 py-2 rounded border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark font-mono",children:k}),m.jsx(Ae.button,{onClick:()=>{navigator.clipboard.writeText(k),he.success("URL copied to clipboard")},className:"p-2 text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textSecondary-dark dark:hover:text-exkalibur-elements-textPrimary-dark bg-exkalibur-elements-background-depth-1 dark:bg-exkalibur-elements-background-depth-4 rounded-lg border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",whileHover:{scale:1.05},whileTap:{scale:.95},children:m.jsx("div",{className:"i-ph:copy w-4 h-4"})})]})]}),m.jsxs("div",{className:"bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 rounded-lg p-4 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("p",{className:"text-sm font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark mb-2 flex items-center gap-2",children:[m.jsx("span",{className:"i-ph:files w-4 h-4 text-purple-500"}),"Pushed Files (",y.length,")"]}),m.jsx("div",{className:"max-h-[200px] overflow-y-auto custom-scrollbar pr-2",children:y.map(q=>m.jsxs("div",{className:"flex items-center justify-between py-1.5 text-sm text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark border-b border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30 last:border-0",children:[m.jsx("span",{className:"font-mono truncate flex-1 text-xs",children:q.path}),m.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-exkalibur-elements-background-depth-3 dark:bg-exkalibur-elements-background-depth-4 text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark ml-2",children:uh(q.size)})]},q.path))})]}),m.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[m.jsxs(Ae.a,{href:k,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 rounded-lg bg-purple-500 text-white hover:bg-purple-600 text-sm inline-flex items-center gap-2",whileHover:{scale:1.02},whileTap:{scale:.98},children:[m.jsx("div",{className:"i-ph:github-logo w-4 h-4"}),"View Repository"]}),m.jsxs(Ae.button,{onClick:()=>{navigator.clipboard.writeText(k),he.success("URL copied to clipboard")},className:"px-4 py-2 rounded-lg bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark hover:bg-exkalibur-elements-background-depth-3 dark:hover:bg-exkalibur-elements-background-depth-4 text-sm inline-flex items-center gap-2 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",whileHover:{scale:1.02},whileTap:{scale:.98},children:[m.jsx("div",{className:"i-ph:copy w-4 h-4"}),"Copy URL"]}),m.jsx(Ae.button,{onClick:G,className:"px-4 py-2 rounded-lg bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark hover:bg-exkalibur-elements-background-depth-3 dark:hover:bg-exkalibur-elements-background-depth-4 text-sm border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",whileHover:{scale:1.02},whileTap:{scale:.98},children:"Close"})]})]})})})})]})}):h?m.jsx(_s,{open:r,onOpenChange:q=>!q&&G(),children:m.jsxs(sn,{children:[m.jsx(nn,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[9999]"}),m.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[9999]",children:m.jsx(Ae.div,{initial:{opacity:0,scale:.95}
137,animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"w-[95vw] max-w-[500px] max-h-[90vh] overflow-y-auto mx-4",children:m.jsx(on,{className:"bg-white dark:bg-exkalibur-elements-background-depth-1 rounded-lg border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark shadow-xl max-h-[90vh] overflow-y-auto","aria-describedby":"push-dialog-description",children:m.jsxs("div",{className:"p-4 sm:p-6 pb-safe",children:[m.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[m.jsx(Ae.div,{initial:{scale:.8},animate:{scale:1},transition:{delay:.1},className:"w-10 h-10 rounded-xl bg-exkalibur-elements-background-depth-3 flex items-center justify-center text-purple-500",children:m.jsx("div",{className:"i-ph:github-logo w-5 h-5"})}),m.jsxs("div",{children:[m.jsx(Ap,{className:"text-lg font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:"Push to GitHub"}),m.jsx("p",{id:"push-dialog-description",className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:"Push your code to a new or existing GitHub repository"})]}),m.jsx(Sa,{asChild:!0,children:m.jsxs("button",{onClick:G,className:"ml-auto p-2 rounded-lg transition-all duration-200 ease-in-out bg-transparent text-exkalibur-elements-textTertiary hover:text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textTertiary-dark dark:hover:text-exkalibur-elements-textPrimary-dark hover:bg-exkalibur-elements-background-depth-2 dark:hover:bg-exkalibur-elements-background-depth-3 focus:outline-none focus:ring-2 focus:ring-exkalibur-elements-borderColor dark:focus:ring-exkalibur-elements-borderColor-dark",children:[m.jsx("span",{className:"i-ph:x block w-5 h-5","aria-hidden":"true"}),m.jsx("span",{className:"sr-only",children:"Close dialog"})]})})]}),m.jsxs("div",{className:"flex items-center gap-3 mb-6 p-4 bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 rounded-lg border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("div",{className:"relative",children:[m.jsx("img",{src:h.avatar_url,alt:h.login,className:"w-10 h-10 rounded-full"}),m.jsx("div",{className:"absolute -bottom-1 -right-1 w-5 h-5 rounded-full bg-purple-500 flex items-center justify-center text-white",children:m.jsx("div",{className:"i-ph:github-logo w-3 h-3"})})]}),m.jsxs("div",{children:[m.jsx("p",{className:"text-sm font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:h.name||h.login}),m.jsxs("p",{className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:["@",h.login]})]}),m.jsx(Ae.button,{type:"button",onClick:()=>{localStorage.removeItem("github_connection"),u(null),he.info("Disconnected from GitHub")},className:"px-3 py-1 text-xs rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 border border-red-500/30 transition",whileHover:{scale:1.05},whileTap:{scale:.95},children:"Disconnect"})]}),m.jsxs("form",{onSubmit:$,className:"space-y-4",children:[m.jsxs("div",{className:"space-y-2",children:[m.jsx("label",{htmlFor:"repoName",className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:"Repository Name"}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:m.jsx("span",{className:"i-ph:git-branch w-4 h-4"})}),m.jsx("input",{id:"repoName",type:"text",value:s,onChange:q=>n(q.target.value),placeholder:"my-awesome-project",className:"w-full pl-10 px-4 py-2 rounded-lg bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark placeholder-exkalibur-elements-textTertiary dark:placeholder-exkalibur-elements-textTertiary-dark focus:outline-none focus:ring-2 focus:ring-purple-500",required:!0})]})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between mb-2",children:[m.jsx("label",{className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:"Recent Repositories"}),m.jsxs("span",{className:"text-xs text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:[_.length," of ",d.length]})]}),m.jsx("div",{className:"mb-2",children:m.jsx(Rm,{placeholder:"Search repositories...",value:p,onChange:q=>g(q.target.value),onClear:()=>g(""),className:"bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark text-sm"})}),d.length===0&&!v?m.jsx(dh,{icon:"i-ph:github-logo",title:"No repositories found",description:"We couldn't find any repositories in your GitHub account.",variant:"compact"}):m.jsx("div",{className:"space-y-2 max-h-[120px] sm:max-h-[200px] overflow-y-auto pr-2 custom-scrollbar",children:_.length===0&&p.trim()!==""?m.jsx(dh,{icon:"i-ph:magnifying-glass",title:"No matching repositories",description:"Try a different search term",variant:"compact"}):_.map(q=>m.jsxs(Ae.button,{type:"button",onClick:()=>n(q.name),className:"w-full p-3 text-left rounded-lg bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 hover:bg-exkalibur-elements-background-depth-3 dark:hover:bg-exkalibur-elements-background-depth-4 transition-colors group border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark hover:border-purple-500/30",whileHover:{scale:1.01},whileTap:{scale:.99},children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:git-branch w-4 h-4 text-purple-500"}),m.jsx("span",{className:"text-sm font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark group-hover:text-purple-500",children:q.name})]}),q.private&&m.jsx(Ut,{variant:"primary",size:"sm",icon:"i-ph:lock
137w-3 h-3",children:"Private"})]}),q.description&&m.jsx("p",{className:"mt-1 text-xs text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark line-clamp-2",children:q.description}),m.jsxs("div",{className:"mt-2 flex items-center gap-2 flex-wrap",children:[q.language&&m.jsx(Ut,{variant:"subtle",size:"sm",icon:"i-ph:code w-3 h-3",children:q.language}),m.jsx(Ut,{variant:"subtle",size:"sm",icon:"i-ph:star w-3 h-3",children:q.stargazers_count.toLocaleString()}),m.jsx(Ut,{variant:"subtle",size:"sm",icon:"i-ph:git-fork w-3 h-3",children:q.forks_count.toLocaleString()}),m.jsx(Ut,{variant:"subtle",size:"sm",icon:"i-ph:clock w-3 h-3",children:new Date(q.updated_at).toLocaleDateString()})]})]},q.full_name))})]}),v&&m.jsx("div",{className:"flex items-center justify-center py-4",children:m.jsx(RS,{status:"loading",pulse:!0,label:"Loading repositories..."})}),m.jsxs("div",{className:"p-3 bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 rounded-lg border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"checkbox",id:"private",checked:a,onChange:q=>o(q.target.checked),className:"rounded border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark text-purple-500 focus:ring-purple-500 dark:bg-exkalibur-elements-background-depth-3"}),m.jsx("label",{htmlFor:"private",className:"text-sm text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark cursor-pointer",children:"Make repository private"}),a&&m.jsx(Ut,{variant:"primary",size:"sm",icon:"i-ph:lock w-3 h-3",children:"Private"}),!a&&m.jsx(Ut,{variant:"subtle",size:"sm",icon:"i-ph:globe w-3 h-3",children:"Public"})]}),m.jsx("p",{className:"text-xs text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark mt-2 ml-6",children:a?"Private repositories are only visible to you and people you share them with":"Public repositories are visible to everyone on GitHub"})]}),m.jsxs("div",{className:"pt-4 flex gap-2 sticky bottom-0 bg-white dark:bg-exkalibur-elements-background-depth-1 pb-2 -mb-2",children:[m.jsx(Ae.button,{type:"button",onClick:G,className:"px-4 py-2 rounded-lg bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark hover:bg-exkalibur-elements-background-depth-3 dark:hover:bg-exkalibur-elements-background-depth-4 text-sm border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",whileHover:{scale:1.02},whileTap:{scale:.98},children:"Cancel"}),m.jsx(Ae.button,{type:"submit",disabled:l,className:ce("flex-1 px-4 py-2 bg-purple-500 text-white rounded-lg hover:bg-purple-600 text-sm inline-flex items-center justify-center gap-2",l?"opacity-50 cursor-not-allowed":""),whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},children:l?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"i-ph:spinner-gap animate-spin w-4 h-4"}),"Pushing..."]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"i-ph:github-logo w-4 h-4"}),"Push to GitHub"]})})]})]})]})})})})]})}):m.jsx(_s,{open:r,onOpenChange:q=>!q&&G(),children:m.jsxs(sn,{children:[m.jsx(nn,{className:"fixed inset-0 bg-black bg-opacity-80 flex items-center justify-center z-[9999]"}),m.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[9999]",children:m.jsx(Ae.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"w-[95vw] max-w-[400px] mx-4",children:m.jsxs(on,{className:"bg-black rounded-lg shadow-xl w-full p-4 sm:p-6 border-2 border-white",children:[m.jsxs("div",{className:"flex items-center justify-between mb-4",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"i-ph:github-logo w-6 h-6 text-white"}),m.jsx("h3",{className:"text-lg font-medium text-white",children:"Connect to GitHub"})]}),m.jsx("button",{onClick:G,className:"text-gray-400 hover:text-white",children:m.jsx("div",{className:"i-ph:x w-5 h-5"})})]}),m.jsxs("div",{className:"space-y-4",children:[m.jsx("p",{className:"text-sm text-gray-300",children:"Enter your GitHub Personal Access Token (with repo scope) to connect your account."}),m.jsxs("div",{className:"bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-3 text-sm text-yellow-200",children:[m.jsx("p",{className:"font-medium mb-1",children:"â ï¸ Required permissions for private repositories:"}),m.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs",children:[m.jsxs("li",{children:[m.jsx("strong",{children:"repo"})," - Full control of private repositories (REQUIRED for private repos)"]}),m.jsx("li",{children:"Includes: repo:status, repo_deployment, public_repo, repo:invite, security_events"})]}),m.jsxs("p",{className:"mt-2 text-xs",children:["Note: For public repositories only, you can use ",m.jsx("strong",{children:"public_repo"})," scope instead."]})]}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-sm text-gray-300 mb-2",children:"Personal Access Token"}),m.jsx("input",{type:"password",placeholder:"ghp_xxxxxxxxxxxxxxxxx",value:D,onChange:q=>T(q.target.value),disabled:M,className:ce("w-full px-3 py-2 rounded-lg text-sm","bg-gray-900 border border-gray-700","text-white placeholder-gray-500","focus:outline-none focus:ring-1 focus:ring-white focus:border-white","disabled:opacity-50")}),m.jsx("div",{className:"mt-2 text-sm text-gray-400",children:m.jsxs("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline inline-flex items-center gap-1",children:["Get your token",m.jsx("div",{className:"i-ph:arrow-square-out w-4 h-4"})]})})]}),m.jsx("button",{onClick:V,disabled:M,className:ce("w-full px-4 py-2 rounded-lg text-sm bg-white text-black hover:bg-gray-200 flex items-center justify-center gap-2",M?"opacity-50 cursor-not-allowed":""),children:M?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"i-ph:spinner-gap animate-spin w-4 h-4"}),"Connecting..."]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"i-ph:github-logo w-4 h-4"}),"Connect GitHub"]})})]})]})})})]})})}let qv=!1;const id={ease:Ss,duration:.3},HI={left:{value:"code",text:"Code"},middle:{value:"diff",text:"Updates"},right:{value:"preview",text:"Preview"}},zI={closed:{width:0,transition:{duration:.2,ease:Ss}},open:{width:"var(--workbench-width)",transition:{duration:.2,ease:Ss}}},WI=A.memo(({fileHistory:r,onSelectFile:e})=>{const t=Object.entries(r),i=t.length>0,[s,n]=A.useState(""),a=A.useMemo(()=>t.filter(([o])=>o.toLowerCase().includes(s.toLowerCase())),[t,s]);return m.jsx("div",{className:"flex items-right gap-2 bg-white/10 backdrop-blur-xl",children:m.jsx(Hg,{className:"relative",children:({open:o})=>m.jsx(m.Fragment,{children:m.jsx(SR,{show:o,enter:"transition duration-100 ease-out",enterFrom:"transform scale-95 opacity-0",enterTo:"transform scale-100 opacity-100",leave:"transition duration-75 ease-out",leaveFrom:"transform scale-100 opacity-100",leaveTo:"transform scale-95 opacity-0",children:m.jsxs(Hg.Panel,{className:"absolute right-0 mt-2 w-80 origin-top-right rounded-2xl bg-exkalibur-elements-background-depth-2 shadow-xl border border-exkalibur-elements-borderColor z-[9999]",children:[m.jsxs("div",{className:"p-2",children:[m.jsxs("div",{className:"relative mx-2 mb-2",children:[m.jsx("input",{type:"text",placeholder:"Search f
137iles...",value:s,onChange:l=>n(l.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm rounded-lg bg-exkalibur-elements-background-depth-1 border border-exkalibur-elements-borderColor focus:outline-none focus:ring-2 focus:ring-blue-500/50"}),m.jsx("div",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary",children:m.jsx("div",{className:"i-ph:magnifying-glass"})})]}),m.jsx("div",{className:"max-h-60 overflow-y-auto",children:a.length>0?a.map(([l,c])=>{const h=l.split(".").pop()||"",u=B_(h);return m.jsx("button",{onClick:()=>e(l),className:"w-full px-3 py-2 text-left rounded-md hover:bg-exkalibur-elements-background-depth-1 transition-colors group bg-transparent",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"shrink-0 w-5 h-5 text-exkalibur-elements-textTertiary",children:[["typescript","javascript","jsx","tsx"].includes(u)&&m.jsx("div",{className:"i-ph:file-js"}),["css","scss","less"].includes(u)&&m.jsx("div",{className:"i-ph:paint-brush"}),u==="html"&&m.jsx("div",{className:"i-ph:code"}),u==="json"&&m.jsx("div",{className:"i-ph:brackets-curly"}),u==="python"&&m.jsx("div",{className:"i-ph:file-text"}),u==="markdown"&&m.jsx("div",{className:"i-ph:article"}),["yaml","yml"].includes(u)&&m.jsx("div",{className:"i-ph:file-text"}),u==="sql"&&m.jsx("div",{className:"i-ph:database"}),u==="dockerfile"&&m.jsx("div",{className:"i-ph:cube"}),u==="shell"&&m.jsx("div",{className:"i-ph:terminal"}),!["typescript","javascript","css","html","json","python","markdown","yaml","yml","sql","dockerfile","shell","jsx","tsx","scss","less"].includes(u)&&m.jsx("div",{className:"i-ph:file-text"})]}),m.jsx("div",{className:"flex-1 min-w-0",children:m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex flex-col min-w-0",children:[m.jsx("span",{className:"truncate text-sm font-medium text-exkalibur-elements-textPrimary",children:l.split("/").pop()}),m.jsx("span",{className:"truncate text-xs text-exkalibur-elements-textTertiary",children:l})]}),(()=>{const{additions:d,deletions:f}=(()=>{if(!c.originalContent)return{additions:0,deletions:0};const b=c.originalContent.replace(/\r\n/g,` 138`),p=c.versions[c.versions.length-1]?.content.replace(/\r\n/g,` 139`)||"";return b===p?{additions:0,deletions:0}:ya(b,p,{newlineIsToken:!1,ignoreWhitespace:!0,ignoreCase:!1}).reduce((v,x)=>(x.added&&(v.additions+=x.value.split(` 140`).length),x.removed&&(v.deletions+=x.value.split(` 141`).length),v),{additions:0,deletions:0})})();return(d>0||f>0)&&m.jsxs("div",{className:"flex items-center gap-1 text-xs shrink-0",children:[d>0&&m.jsxs("span",{className:"text-green-500",children:["+",d]}),f>0&&m.jsxs("span",{className:"text-red-500",children:["-",f]})]})})()]})})]})},l)}):m.jsxs("div",{className:"flex flex-col items-center justify-center p-4 text-center",children:[m.jsx("div",{className:"w-12 h-12 mb-2 text-exkalibur-elements-textTertiary",children:m.jsx("div",{className:"i-ph:file-dashed"})}),m.jsx("p",{className:"text-sm font-medium text-exkalibur-elements-textPrimary",children:s?"No matching files":"No modified files"}),m.jsx("p",{className:"text-xs text-exkalibur-elements-textTertiary mt-1",children:s?"Try another search":"Changes will appear here as you edit"})]})})]}),i&&m.jsx("div",{className:"border-t border-exkalibur-elements-borderColor p-2",children:m.jsx("button",{onClick:()=>{navigator.clipboard.writeText(a.map(([l])=>l).join(` 142`)),he("File list copied to clipboard",{icon:m.jsx("div",{className:"i-ph:check-circle text-accent-500"})})},className:"w-full flex items-center justify-center gap-2 px-3 py-1.5 text-sm rounded-lg bg-exkalibur-elements-background-depth-1 hover:bg-exkalibur-elements-background-depth-3 transition-colors text-exkalibur-elements-textTertiary hover:text-exkalibur-elements-textPrimary",children:"Copy File List"})})]})})})})})}),UI=A.memo(({chatStarted:r,isStreaming:e,actionRunner:t,isSmallViewport:i,isMobilePreviewMode:s,onMobilePreviewToggle:n,metadata:a,updateChatMestaData:o})=>{wo.trace("Workbench");const{keycloak:l}=yi(),[c,h]=A.useState(!1),[u,d]=A.useState(!1),[f,_]=A.useState({}),b=A.useRef(null),[p,g]=A.useState("code"),v=Ve(G2(ue.previews,N=>N.length>0)),x=Ve(ue.showWorkbench),w=Ve(ue.selectedFile),S=Ve(ue.currentDocument),k=Ve(ue.unsavedFiles),C=Ve(ue.files),y=Ve(ue.currentView),E=A.useCallback(N=>{b.current=N,g(N),ue.currentView.set(N)},[]);A.useEffect(()=>{!e&&y!==p&&g(y)},[y,e,p]),A.useEffect(()=>{v&&!qv&&!b.current&&(E("preview"),qv=!0)},[v,E]),A.useEffect(()=>{ue.setDocuments(C)},[C]);const D=A.useCallback(N=>{ue.setCurrentDocumentContent(N.content)},[]),T=A.useCallback(N=>{ue.setCurrentDocumentScrollPosition(N)},[]);A.useCallback(N=>{ue.setSelectedFile(N)},[]);const M=A.useCallback(N=>{ue.setSelectedFile(N),e&&S&&ue.saveCurrentDocument().catch(()=>{console.warn("Failed to save current document during navigation")})},[e,S]),R=A.useCallback(()=>{ue.saveCurrentDocument().catch(()=>{he.error("Failed to update file content")})},[]),O=A.useCallback(()=>{ue.resetCurrentDocument()},[]),$=A.useCallback(async()=>{h(!0);try{const N=await window.showDirectoryPicker();await ue.syncFiles(N),he.success("Files synced successfully")}catch(N){console.error("Error syncing files:",N),he.error("Failed to sync files")}finally{h(!1)}},[]),G=A.useCallback(N=>{ue.setSelectedFile(N),E("diff")},[E]),V=()=>p==="code"?"0%":"-100%",q=()=>p==="diff"?"0%":p==="code"?"100%":"-100%",L=()=>p==="preview"?"0%":"100%";return r&&m.jsxs(Ae.div,{initial:"closed",animate:x?"open":"closed",variants:zI,className:"z-workbench",children:[m.jsx("div",{className:ce("fixed z-1000 transition-[left,width] duration-200 exkalibur-ease-cubic-bezier",{"top-0 left-0 right-0 bottom-0 w-full h-screen":i&&x,"left-[100%] top-[calc(var(--header-height)+1.5rem)] bottom-6 w-full mr-4":i&&!x,"top-[calc(var(--header-height)+1.5rem)] bottom-6 w-[var(--workbench-inner-width)] mr-4 left-[var(--workbench-left)]":!i&&x,"top-[calc(var(--header-height)+1.5rem)] bottom-6 w-[var(--workbench-inner-width)] mr-4 left-[100%]":!i&&!x}),children:m.jsx("div",{className:"absolute inset-0 px-2 lg:px-6",children:m.jsxs("div",{className:"h-full flex flex-col bg-white/10 backdrop-blur-xl border border-white/20 shadow-2xl rounded-lg overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-center px-3 py-2 border-b border-white/20 relative backdrop-blur-sm",style:{background:` 143 linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 30%, transparent 100%), 144 linear-gradient(to right, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 30%, transparent 100%), 145 linear-gradient(to left, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 30%, transparent 100%), 146 rgba(255, 255, 255, 0.05) 147 `,backgroundSize:"100% 50px, 50px 100%, 50px 100%, 100% 100%",backgroundPosition:"top, left, right, center",backgroundRepeat:"no-repeat, no-repeat, no-repeat, no-repeat"},children:[i&&m.jsx("div",{className:"absolute left-3 flex items-center",children:m.jsx(jt,{icon:"i-ph:x-circle",className:"text-white hover:text-gray-200",size:"lg",onClick:()=>{n?n(!1):ue.showWorkbench.set(!1)}})}),m.jsx(KO,{selected:p,options:HI,setSelected:E,device:i}),m.jsx("div",{className:"absolute right-3 flex items-center",children:p==="code"&&m.jsx("div",{className:"flex items-center",children:m.jsxs(Sp,{children:[m.jsx(kp,{asChild:!0,children:m.jsxs("button",{className:`mr-1 text-sm px-3 py-1.5 rounded-lg bg-white/10 backdrop-blur-xl hover:bg-white/5 transition-colors text-white flex items-center gap-2 ${i?"px-2 py-1":"px-3 py-1.5"}`,children:[m.jsx("div",{className:"i-ph:dots-three-vertical"}),!i&&m.jsx("span",{children:"Actions"})]})}),m.jsx(Cp,{children:m.jsxs(Ep,{className:"min-w-48 bg-exkalibur-elements-background-depth-2 rounded-lg border border-exkalibur-elements-borderColor shadow-xl p-1 z-[9999] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
147de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",sideOffset:5,align:"end",children:[m.jsxs(Kn,{className:"flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-exkalibur-elements-background-depth-1 cursor-pointer text-exkalibur-elements-textPrimary outline-none focus:bg-exkalibur-elements-background-depth-1",onClick:()=>ue.downloadZip(l.token),children:[m.jsx("div",{className:"i-ph:code"}),"Download code"]}),m.jsxs(Kn,{className:`flex items-center gap-2 px-3 py-2 text-sm rounded-md cursor-pointer outline-none ${c?"text-exkalibur-elements-textTertiary cursor-not-allowed":"hover:bg-exkalibur-elements-background-depth-1 focus:bg-exkalibur-elements-background-depth-1 text-exkalibur-elements-textPrimary"}`,onClick:c?void 0:$,onSelect:c?N=>N.preventDefault():void 0,children:[c?m.jsx("div",{className:"i-ph:spinner animate-spin"}):m.jsx("div",{className:"i-ph:cloud-arrow-down"}),c?"Syncing...":"Sync files"]}),m.jsxs(Kn,{className:"flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-exkalibur-elements-background-depth-1 cursor-pointer text-exkalibur-elements-textPrimary outline-none focus:bg-exkalibur-elements-background-depth-1",onClick:()=>ue.toggleTerminal(!ue.showTerminal.get()),children:[m.jsx("div",{className:"i-ph:terminal"}),"Terminal"]}),m.jsx(X2,{className:"h-px bg-exkalibur-elements-borderColor my-1"}),m.jsxs(Kn,{className:"flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-exkalibur-elements-background-depth-1 cursor-pointer text-exkalibur-elements-textPrimary outline-none focus:bg-exkalibur-elements-background-depth-1",onClick:()=>d(!0),children:[m.jsx("div",{className:"i-ph:git-branch"}),"Push to GitHub"]})]})})]})})}),p==="diff"&&m.jsx("div",{className:"absolute right-3",children:m.jsx(WI,{fileHistory:f,onSelectFile:G})})]}),m.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[m.jsx(sd,{initial:{x:"0%"},animate:{x:V()},transition:id,children:m.jsx(CI,{editorDocument:S,isStreaming:e,selectedFile:w,files:C,unsavedFiles:k,fileHistory:f,onFileSelect:M,onEditorScroll:T,onEditorChange:D,onFileSave:R,onFileReset:O})},"code-view"),m.jsx(sd,{initial:{x:"100%"},animate:{x:q()},transition:id,children:m.jsx(aM,{fileHistory:f,setFileHistory:_,actionRunner:t})},"diff-view"),m.jsx(sd,{initial:{x:"100%"},animate:{x:L()},transition:id,children:m.jsx(LI,{})},"preview-view")]})]})})}),m.jsx($I,{isOpen:u,onClose:()=>d(!1),onPush:async(N,I,H)=>{try{const W=prompt("Please enter a commit message:","Initial commit")||"Initial commit";await ue.pushToGitHub(N,W,I,H);const J=`https://github.com/${I}/${N}`;return o&&!a?.gitUrl&&o({...a||{},gitUrl:J}),J}catch(W){throw console.error("Error pushing to GitHub:",W),he.error("Failed to push to GitHub"),W}}})]})}),sd=A.memo(({children:r,...e})=>m.jsx(Ae.div,{className:"absolute inset-0",...e,children:r}));var Mm="Popover",[MS,H$]=yp(Mm,[$x]),ol=$x(),[VI,Ls]=MS(Mm),DS=r=>{const{__scopePopover:e,children:t,open:i,defaultOpen:s,onOpenChange:n,modal:a=!1}=r,o=ol(e),l=A.useRef(null),[c,h]=A.useState(!1),[u=!1,d]=Nx({prop:i,defaultProp:s,onChange:n});return m.jsx(Y2,{...o,children:m.jsx(VI,{scope:e,contentId:Ox(),triggerRef:l,open:u,onOpenChange:d,onOpenToggle:A.useCallback(()=>d(f=>!f),[d]),hasCustomAnchor:c,onCustomAnchorAdd:A.useCallback(()=>h(!0),[]),onCustomAnchorRemove:A.useCallback(()=>h(!1),[]),modal:a,children:t})})};DS.displayName=Mm;var PS="PopoverAnchor",LS=A.forwardRef((r,e)=>{const{__scopePopover:t,...i}=r,s=Ls(PS,t),n=ol(t),{onCustomAnchorAdd:a,onCustomAnchorRemove:o}=s;return A.useEffect(()=>(a(),()=>o()),[a,o]),m.jsx(zx,{...n,...i,ref:e})});LS.displayName=PS;var NS="PopoverTrigger",OS=A.forwardRef((r,e)=>{const{__scopePopover:t,...i}=r,s=Ls(NS,t),n=ol(t),a=Hx(e,s.triggerRef),o=m.jsx(An.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":HS(s.open),...i,ref:a,onClick:fr(r.onClick,s.onOpenToggle)});return s.hasCustomAnchor?o:m.jsx(zx,{asChild:!0,...n,children:o})});OS.displayName=NS;var Dm="PopoverPortal",[KI,qI]=MS(Dm,{forceMount:void 0}),IS=r=>{const{__scopePopover:e,forceMount:t,children:i,container:s}=r,n=Ls(Dm,e);return m.jsx(KI,{scope:e,forceMount:t,children:m.jsx(wp,{present:t||n.open,children:m.jsx(Z2,{asChild:!0,container:s,children:i})})})};IS.displayName=Dm;var vo="PopoverContent",jS=A.forwardRef((r,e)=>{const t=qI(vo,r.__scopePopover),{forceMount:i=t.forceMount,...s}=r,n=Ls(vo,r.__scopePopover);return m.jsx(wp,{present:i||n.open,children:n.modal?m.jsx(GI,{...s,ref:e}):m.jsx(XI,{...s,ref:e})})});jS.displayName=vo;var GI=A.forwardRef((r,e)=>{const t=Ls(vo,r.__scopePopover),i=A.useRef(null),s=Hx(e,i),n=A.useRef(!1);return A.useEffect(()=>{const a=i.current;if(a)return Q2(a)},[]),m.jsx(eE,{as:tE,allowPinchZoom:!0,children:m.jsx(BS,{...r,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fr(r.onCloseAutoFocus,a=>{a.preventDefault(),n.current||t.triggerRef.current?.focus()}),onPointerDownOutside:fr(r.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0,c=o.button===2||l;n.current=c},{checkForDefaultPrevented:!1}
147),onFocusOutside:fr(r.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),XI=A.forwardRef((r,e)=>{const t=Ls(vo,r.__scopePopover),i=A.useRef(!1),s=A.useRef(!1);return m.jsx(BS,{...r,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:n=>{r.onCloseAutoFocus?.(n),n.defaultPrevented||(i.current||t.triggerRef.current?.focus(),n.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:n=>{r.onInteractOutside?.(n),n.defaultPrevented||(i.current=!0,n.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const a=n.target;t.triggerRef.current?.contains(a)&&n.preventDefault(),n.detail.originalEvent.type==="focusin"&&s.current&&n.preventDefault()}})}),BS=A.forwardRef((r,e)=>{const{__scopePopover:t,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:n,disableOutsidePointerEvents:a,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:h,...u}=r,d=Ls(vo,t),f=ol(t);return rE(),m.jsx(iE,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:n,children:m.jsx(sE,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:h,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>d.onOpenChange(!1),children:m.jsx(nE,{"data-state":HS(d.open),role:"dialog",id:d.contentId,...f,...u,ref:e,style:{...u.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),FS="PopoverClose",YI=A.forwardRef((r,e)=>{const{__scopePopover:t,...i}=r,s=Ls(FS,t);return m.jsx(An.button,{type:"button",...i,ref:e,onClick:fr(r.onClick,()=>s.onOpenChange(!1))})});YI.displayName=FS;var ZI="PopoverArrow",$S=A.forwardRef((r,e)=>{const{__scopePopover:t,...i}=r,s=ol(t);return m.jsx(J2,{...s,...i,ref:e})});$S.displayName=ZI;function HS(r){return r?"open":"closed"}var JI=DS,QI=LS,ej=OS,tj=IS,rj=jS,ij=$S;const sj=({children:r,trigger:e,side:t,align:i})=>m.jsxs(JI,{children:[m.jsx(ej,{asChild:!0,children:e}),m.jsx(QI,{}),m.jsx(tj,{children:m.jsxs(rj,{sideOffset:10,side:t,align:i,className:"bg-exkalibur-elements-background-depth-2 text-exkalibur-elements-item-contentAccent p-2 rounded-md shadow-xl z-workbench",children:[r,m.jsx(ij,{className:"bg-exkalibur-elements-item-background-depth-2"})]})})]});function nj(r){r=zS(r),ue.currentView.get()!=="code"&&ue.currentView.set("code"),ue.setSelectedFile(`${un}/${r}`)}function zS(r){let e=r;return e.startsWith(un)&&(e=r.replace(un,"")),e.startsWith("/")&&(e=e.slice(1)),e}const oj=A.memo(({content:r,annotations:e,messageId:t,onRewind:i,onFork:s})=>{const n=e?.filter(l=>l&&typeof l=="object"&&Object.keys(l).includes("type"))||[];let a;n.find(l=>l.type==="chatSummary")&&(a=n.find(l=>l.type==="chatSummary")?.summary);let o;return n.find(l=>l.type==="codeContext")&&(o=n.find(l=>l.type==="codeContext")?.files),n.find(l=>l.type==="usage")?.value,m.jsxs("div",{className:"overflow-hidden w-full",children:[m.jsx(m.Fragment,{children:m.jsxs("div",{className:" flex gap-2 items-center text-sm text-exkalibur-elements-textSecondary mb-2",children:[(o||a)&&m.jsxs(sj,{side:"right",align:"start",trigger:m.jsx("div",{className:"i-ph:info"}),children:[a&&m.jsxs("div",{className:"max-w-chat",children:[m.jsxs("div",{className:"summary max-h-96 flex flex-col",children:[m.jsx("h2",{className:"border border-exkalibur-elements-borderColor rounded-md p4",children:"Summary"}),m.jsx("div",{style:{zoom:.7},className:"overflow-y-auto m4",children:m.jsx(Dc,{children:a})})]}),o&&m.jsxs("div",{className:"code-context flex flex-col p4 border border-exkalibur-elements-borderColor rounded-md",children:[m.jsx("h2",{children:"Context"}),m.jsx("div",{className:"flex gap-4 mt-4 exkalibur",style:{zoom:.6},children:o.map(l=>{const c=zS(l);return m.jsx(A.Fragment,{children:m.jsx("code",{className:"bg-exkalibur-elements-artifacts-inlineCode-background text-exkalibur-elements-artifacts-inlineCode-text px-1.5 py-1 rounded-md text-exkalibur-elements-item-contentAccent hover:underline cursor-pointer",onClick:h=>{h.preventDefault(),h.stopPropagation(),nj(c)},children:c})},c)})})]})]}),m.jsx("div",{className:"context"})]}),m.jsx("div",{className:"flex w-full items-center justify-between",children:(i||s)&&t&&m.jsxs("div",{className:"flex gap-2 flex-col lg:flex-row ml-auto",children:[i&&m.jsx(Nd,{tooltip:"Revert to this message",children:m.jsx("button",{onClick:()=>i(t),className:"i-ph:arrow-u-up-left text-xl text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary transition-colors"},"i-ph:arrow-u-up-left")}),s&&m.jsx(Nd,{tooltip:"Fork chat from this message",children:m.jsx("button",{onClick:()=>s(t),className:"i-ph:git-fork text-xl text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary transition-colors"},"i-ph:git-fork")})]})})]})}),m.jsx(Dc,{html:!0,children:r})]})});function aj({content:r}){if(Array.isArray(r)){const t=r.find(n=>n.type==="text"),i=Gv(t?.text||""),s=r.filter(n=>n.type==="image"&&n.image);return m.jsx("div",{className:"overflow-hidden flex items-center",children:m.jsxs("div",{className:"flex flex-col gap-4",children:[i&&m.jsx(Dc,{html:!0,children:i}),s.map((n,a)=>m.jsx("img",{src:n.image,alt:`Image ${a+1}`,className:"max-w-full h-auto rounded-lg",style:{maxHeight:"512px",objectFit:"contain"}},a))]})})}const e=Gv(r);return m.jsx("div",{className:"overflow-hidden pt-[4px]",children:m.jsx(Dc,{html:!0,children:e})})}function Gv(r){const e=/<exkaliburArtifact\s+[^>]*>[\s\S]*?<\/exkaliburArtifact>/gm;return r.replace(oE,"").replace(aE,"").replace(e,"")}const lj=A.forwardRef((r,e)=>{const{id:t,isStreaming:i=!1,messages:s=[]}=r,n=RE(),a=Ve(lE),o=c=>{const h=new URLSearchParams(n.search);h.set("rewindTo",c),window.location.search=h.toString()},l=async c=>{try{if(!vg||!Pi.get()){he.error("Chat persistence is not available");return}const h=await cE(vg,Pi.get(),c);window.location.href=`/chat/${h}`}catch(h){he.error("Failed to fork chat: "+h.message)}};return m.jsx("div",{id:t,className:ce(r.className,"overflow-y-auto modern-scrollbar"),ref:e,children:m.jsxs("div",{className:"space-y-3",children:[s.length>0?s.map((c,h)=>{const{role:u,content:d,id:f,annotations:_}=c,b=u==="user";return _?.includes("hidden")?m.jsx(A.Fragment,{},h):m.jsxs("div",{className:"flex gap-3 p-4 w-full rounded-2xl relative bg-white/10 backdrop-blur-xl",style:{background:` 148 linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 30%, transparent 100%), 149 linear-gradient(to right, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 30%, transparent 100%), 150 linear-gradient(to left, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 30%, transparent 100%), 151 rgba(255, 255, 255, 0.1) 152 `,backgroundSize:"100% 50px, 50px 100%, 50px 100%, 100% 100%",backgroundPosition:"top, left, right, center",backgroundRepeat:"no-repeat, no-repeat, no-repeat, no-repeat"},children:[b&&m.jsx("div",{className:"flex items-center justify-center w-8 h-8 overflow-hidden bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-500 rounded-full shrink-0 self-start",children:a?.avatar?m.jsx("img",{src:a.avatar,alt:a?.username||"User",className:"w-full h-full object-cover",loading:"eager",decoding:"sync"}):m.jsx("div",{className:"i-ph:user-fill text-lg"})}),m.jsx("div",{className:"flex-1",children:b?m.jsx(aj,{content:d}):m.jsx(oj,{content:d,annotations:c.annotations,messageId:f,onRewind:o,onFork:l})})]},h)}):null,i&&m.jsx("div",{className:"text-center w-full text-exkalibur-elements-item-contentAccent i-svg-spinners:3-dots-fade text-3xl pt-2"})]})})}),cj=hE(.4,0,.2,1),hj=({show:r,isStreaming:e,disabled:t,onClick:i})=>{const[s,n]=A.useState(!1);A.useEffect(()=>{(t||e===!1)&&n(!1)},[t,e]);const a=l=>{l.preventDefault(),!(t||s)&&(n(!0),i?.(l),setTimeout(()=>{n(!1)},5e3))},o=t||s;return m.jsx(Ui,{children:r?m.jsx(Ae.button,{className:"flex bg-[#00A7FF] justify-center items-center p-1 color-white rounded-md w-[34px] h-[34px] transition-theme disabled:opacity-0 disabled:cursor-not-allowed",onMouseEnter:l=>{if(!o){const c=l.currentTarget.querySelector(".i-ph\\:pause-circle");c?c.style.color="white":l.currentTarget.style.backgroundColor="#B335FF"}},onMouseLeave:l=>{if(!o){const c=l.currentTarget.querySelector(".i-ph\\:pause-circle");c?c.style.color="":l.currentTarget.style.backgroundColor="#00A7FF"}},transition:{ease:cj,duration:.17},initial:{opacity:0,y:10}
152,animate:{opacity:1,y:0},exit:{opacity:0,y:10},disabled:o,onClick:a,children:m.jsx("div",{className:"text-2xl",children:e?m.jsx("div",{className:"i-ph:pause-circle"}):m.jsx("div",{className:"i-ph:arrow-up-bold"})})}):null})},Xv={};function Yv(){const r=at.get("apiKeys");let e={};return r&&(e=Xv[r],e||(e=Xv[r]=JSON.parse(r))),e}const uj="_",dj="a",fj="e",pj="f",mj="i",gj="j",vj="k",bj="l",zr={BaseChat:uj,Chat:dj,onlyInter:fj,onlyiBrand:pj,CreditsLimitAlertEffectContainer:mj,CreditsLimitAlertEffectLine:gj,CreditsLimitAlertShine:vj,CreditsLimitAlertText:bj},xj=({exportChat:r})=>m.jsx(Nd,{tooltip:"Export Chat",children:m.jsx(jt,{title:"Export Chat",onClick:()=>r?.(),children:m.jsx("div",{className:"i-ph:download-simple text-xl"})})}),_j=async(r,e,t)=>{const i=await Promise.all(r.map(async h=>new Promise((u,d)=>{const f=new FileReader;f.onload=()=>{const _=f.result,b=h.webkitRelativePath.split("/").slice(1).join("/");u({content:_,path:b})},f.onerror=d,f.readAsText(h)}))),s=await Wx(i),n=Ux(s),a=e.length>0?` 153 154Skipped ${e.length} binary files: 155${e.map(h=>`- ${h}`).join(` 156`)}`:"",o={role:"assistant",content:`I've imported the contents of the "${t}" folder.${a} 157 158<exkaliburArtifact id="imported-files" title="Imported Files" type="bundled" > 159${i.map(h=>`<exkaliburAction type="file" filePath="${h.path}"> 160${Vx(h.content)} 161</exkaliburAction>`).join(` 162 163`)} 164</exkaliburArtifact>`,id:uc(),createdAt:new Date},c=[{role:"user",id:uc(),content:`Import the "${t}" folder`,createdAt:new Date},o];return n&&(c.push({role:"user",id:uc(),content:"Setup the codebase and Start the application"}),c.push(n)),c},yj=({className:r,importChat:e})=>{const[t,i]=A.useState(!1),{keycloak:s}=yi(),{total_available_credits:n}=yo(),a=n<9,o=async l=>{const h=Array.from(l.target.files||[]).filter(f=>{const _=f.webkitRelativePath.split("/").slice(1).join("/");return uE(_)});if(h.length===0){const f=new Error("No valid files found");dr.logError("File import failed - no valid files",f,{folderName:"Unknown Folder"}),he.error("No files found in the selected folder");return}if(h.length>_u){const f=new Error(`Too many files: ${h.length}`);dr.logError("File import failed - too many files",f,{fileCount:h.length,maxFiles:_u}),he.error(`This folder contains ${h.length.toLocaleString()} files. This product is not yet optimized for very large projects. Please select a folder with fewer than ${_u.toLocaleString()} files.`);return}const u=h[0]?.webkitRelativePath.split("/")[0]||"Unknown Folder";i(!0);const d=he.loading(`Importing ${u}...`);try{const f=await Promise.all(h.map(async g=>({file:g,isBinary:await dE(g)}))),_=f.filter(g=>!g.isBinary).map(g=>g.file),b=f.filter(g=>g.isBinary).map(g=>g.file.webkitRelativePath.split("/").slice(1).join("/"));if(_.length===0){const g=new Error("No text files found");dr.logError("File import failed - no text files",g,{folderName:u}),he.error("No text files found in the selected folder");return}b.length>0&&(dr.logWarning("Skipping binary files during import",{folderName:u,binaryCount:b.length}),he.info(`Skipping ${b.length} binary files`));const p=await _j(_,b,u);e&&await e(u,[...p]),dr.logSystem("Folder imported successfully",{folderName:u,textFileCount:_.length,binaryFileCount:b.length}),he.success("Folder imported successfully")}catch(f){dr.logError("Failed to import folder",f,{folderName:u}),console.error("Failed to import folder:",f),he.error("Failed to import folder")}finally{i(!1),he.dismiss(d),l.target.value=""}};return m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"file",id:"folder-import",className:"hidden",webkitdirectory:"",directory:"",onCh
164ange:o})," ",m.jsxs(wa,{onClick:()=>{document.getElementById("folder-import")?.click()},title:"Import Folder",variant:"default",className:ce("gap-1 sm:gap-2 bg-exkalibur-elements-background-depth-1","text-exkalibur-elements-textPrimary","hover:bg-exkalibur-elements-background-depth-2","border border-exkalibur-elements-borderColor","h-8 px-2 py-1 sm:h-10 sm:px-4 sm:py-2 min-w-[80px] sm:min-w-[120px] justify-center","transition-all duration-200 ease-in-out","text-xs sm:text-sm","rounded-lg",r),disabled:t||!s?.authenticated||s.tokenParsed?.billingPlan==="free"||a,children:[m.jsx("span",{className:"i-ph:upload-simple w-3 h-3 sm:w-4 sm:h-4 flex-shrink-0"}),m.jsx("span",{className:"hidden sm:inline",children:t?"Importing...":"Import Folder"}),m.jsx("span",{className:"sm:hidden",children:t?"Loading...":"Folder"})]})]})};function wj(r){const{keycloak:e}=yi(),{total_available_credits:t}=yo(),i=t<9;return m.jsxs("div",{className:"flex flex-col items-center justify-center w-auto",children:[m.jsx("input",{type:"file",id:"chat-import",className:"hidden",accept:".json",onChange:async s=>{const n=s.target.files?.[0];if(n&&r){try{const a=new FileReader;a.onload=async o=>{try{const l=o.target?.result,c=JSON.parse(l);if(Array.isArray(c.messages)){await r(c.description||"Imported Chat",c.messages),he.success("Chat imported successfully");return}he.error("Invalid chat file format")}catch(l){l instanceof Error?he.error("Failed to parse chat file: "+l.message):he.error("Failed to parse chat file")}},a.onerror=()=>he.error("Failed to read chat file"),a.readAsText(n)}catch(a){he.error(a instanceof Error?a.message:"Failed to import chat")}s.target.value=""}else he.error("Something went wrong")}}),m.jsx("div",{className:"flex flex-col items-center gap-4 max-w-2xl text-center",children:m.jsxs("div",{className:"flex flex-row gap-2 flex-wrap justify-center",children:[" ",m.jsxs(wa,{onClick:()=>{document.getElementById("chat-import")?.click()},variant:"default",size:"lg",disabled:!e?.authenticated||e.tokenParsed?.billingPlan==="free"||i,className:ce("gap-1 sm:gap-2 bg-exkalibur-elements-background-depth-1","text-exkalibur-elements-textPrimary","hover:bg-exkalibur-elements-background-depth-2","border border-exkalibur-elements-borderColor","h-8 px-2 py-1 sm:h-10 sm:px-4 sm:py-2 min-w-[80px] sm:min-w-[120px] justify-center","transition-all duration-200 ease-in-out","text-xs sm:text-sm","rounded-lg"),children:[m.jsx("span",{className:"i-ph:upload-simple w-3 h-3 sm:w-4 sm:h-4 flex-shrink-0"}),m.jsx("span",{className:"hidden sm:inline",children:"Import Chat"}),m.jsx("span",{className:"sm:hidden",children:"Import"})]}),m.jsx(yj,{importChat:r,className:ce("gap-1 sm:gap-2 bg-exkalibur-elements-background-depth-1","text-exkalibur-elements-textPrimary","hover:bg-exkalibur-elements-background-depth-2","border border-[rgba(0,0,0,0.08)] dark:border-[rgba(255,255,255,0.08)]","h-8 px-2 py-1 sm:h-10 sm:px-4 sm:py-2 min-w-[80px] sm:min-w-[120px] justify-center","transition-all duration-200 ease-in-out rounded-lg","text-xs sm:text-sm")})]})})]})}function Sj(r){const{keycloak:e}=yi(),{total_available_credits:t}=yo(),i=t<9,s=[{text:"Start a blog",disabled:!e?.authenticated||e.tokenParsed?.billingPlan==="free"||i},{text:"Generate a website",disabled:!e?.authenticated||e.tokenParsed?.billingPlan==="free"||i},{text:"Build an app",disabled:!e?.authenticated||e.tokenParsed?.billingPlan==="free"||i}];return m.jsx("div",{id:"examples",className:"relative flex flex-col gap-9 w-full max-w-3xl mx-auto flex justify-center mt-6",children:m.jsx("div",{className:"flex flex-wrap justify-center gap-2",style:{animation:".25s ease-out 0s 1 _fade-and-move-in_g2ptj_1 forwards"},children:s.map((n,a)=>m.jsx("button",{onClick:o=>{n.disabled||r?.(o,n.text)},disabled:n.disabled,className:`border border-white/20 rounded-full bg-transparent hover:bg-white/10 hover:backdrop-blur-sm hover:border-white/30 text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary px-3 py-1 text-xs transition-theme ${n.disabled?"opacity-50 cursor-not-allowed":""}`,children:n.text},a))})})}var gr=function(r){if(r=r||{},this.Promise=r.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=r.domainReentrant||!1,this.domainReentrant){if(typeof qt>"u"||typeof qt.domain>"u")throw new Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=r.timeout||gr.DEFAULT_TIMEOUT,this.maxOccupationTime=r.maxOccupationTime||gr.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=r.maxExecutionTime||gr.DEFAULT_MAX_EXECUTION_TIME,r.maxPending===1/0||Number.isInteger(r.maxPending)&&r.maxPending>=0?this.maxPending=r.maxPending:this.maxPending=gr.DEFAULT_MAX_PENDING};gr.DEFAULT_TIMEOUT=0;gr.DEFAULT_MAX_OCCUPATION_TIME=0;gr.DEFAULT_MAX_EXECUTION_TIME=0;gr.DEFAULT_MAX_PENDING=1e3;gr.prototype.acquire=function(r,e,t,i){if(Array.isArray(r))return this._acquireBatch(r,e,t,i);if(typeof e!="function")throw new Error("You must pass a function to execute");var s=null,n=null,a=null;typeof t!="function"&&(i=t,t=null,a=new this.Promise(function(v,x){s=v,n=x})),i=i||{};var o=!1,l=null,c=null,h=null,u=this,d=function(v,x,w){c&&(clearTimeout(c),c=null),h&&(clearTimeout(h),h=null),v&&(u.queues[r]&&u.queues[r].length===0&&delete u.queues[r],u.domainReentrant&&delete u.domains[r]),o||(a?x?n(x):s(w):typeof t=="function"&&t(x,w),o=!0),v&&u.queues[r]&&u.queues[r].length>0&&u.queues[r].shift()()},f=function(v){if(o)return d(v);l&&(clearTimeout(l),l=null),u.domainReentrant&&v&&(u.domains[r]=qt.domain);var x=i.maxExecutionTime||u.maxExecutionTime;if(x&&(h=setTimeout(function(){u.queues[r]&&d(v,new Error("Maximum execution time is exceeded "+r))},x)),e.length===1){var w=!1;try{e(function(S,k){w||(w=!0,d(v,S,k))})}catch(S){w||(w=!0,d(v,S))}}else u._promiseTry(function(){return e()}).then(function(S){d(v,void 0,S)},function(S){d(v,S)})};u.domainReentrant&&qt.domain&&(f=qt.domain.bind(f));var _=i.maxPending||u.maxPending;if(!u.queues[r])u.queues[r]=[],f(!0);else if(u.domainReentrant&&qt.domain&&qt.domain===u.domains[r])f(!1);else if(u.queues[r].length>
164=_)d(!1,new Error("Too many pending tasks in queue "+r));else{var b=function(){f(!0)};i.skipQueue?u.queues[r].unshift(b):u.queues[r].push(b);var p=i.timeout||u.timeout;p&&(l=setTimeout(function(){l=null,d(!1,new Error("async-lock timed out in queue "+r))},p))}var g=i.maxOccupationTime||u.maxOccupationTime;if(g&&(c=setTimeout(function(){u.queues[r]&&d(!1,new Error("Maximum occupation time is exceeded in queue "+r))},g)),a)return a};gr.prototype._acquireBatch=function(r,e,t,i){typeof t!="function"&&(i=t,t=null);var s=this,n=function(o,l){return function(c){s.acquire(o,l,c,i)}},a=r.reduceRight(function(o,l){return n(l,o)},e);if(typeof t=="function")a(t);else return new this.Promise(function(o,l){a.length===1?a(function(c,h){c?l(c):o(h)}):o(a())})};gr.prototype.isBusy=function(r){return r?!!this.queues[r]:Object.keys(this.queues).length>0};gr.prototype._promiseTry=function(r){try{return this.Promise.resolve(r())}catch(e){return this.Promise.reject(e)}};var kj=gr,Cj=kj;const fh=En(Cj);var qf={exports:{}};typeof Object.create=="function"?qf.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:qf.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}};var Ej=qf.exports,Gf={exports:{}};const Aj=zC(fE);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,e){var t=Aj,i=t.Buffer;function s(a,o){for(var l in a)o[l]=a[l]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?r.exports=t:(s(t,e),e.Buffer=n);function n(a,o,l){return i(a,o,l)}n.prototype=Object.create(i.prototype),s(i,n),n.from=function(a,o,l){if(typeof a=="number")throw new TypeError("Argument must not be a number");return i(a,o,l)},n.alloc=function(a,o,l){if(typeof a!="number")throw new TypeError("Argument must be a number");var c=i(a);return o!==void 0?typeof l=="string"?c.fill(o,l):c.fill(o):c.fill(0),c},n.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return i(a)},n.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(a)}})(Gf,Gf.exports);var WS=Gf.exports,US=WS.Buffer;function Zh(r,e){this._block=US.alloc(r),this._finalSize=e,this._blockSize=r,this._len=0}Zh.prototype.update=function(r,e){typeof r=="string"&&(e=e||"utf8",r=US.from(r,e));for(var t=this._block,i=this._blockSize,s=r.length,n=this._len,a=0;a<s;){for(var o=n%i,l=Math.min(s-a,i-o),c=0;c<l;c++)t[o+c]=r[a+c];n+=l,a+=l,n%i===0&&this._update(t)}return this._len+=s,this};Zh.prototype.digest=function(r){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var t=this._len*8;if(t<=4294967295)this._block.writeUInt32BE(t,this._blockSize-4);else{var i=(t&4294967295)>>>0,s=(t-i)/4294967296;this._block.writeUInt32BE(s,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var n=this._hash();return r?n.toString(r):n};Zh.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Tj=Zh,Rj=Ej,VS=Tj,Mj=WS.Buffer,Dj=[1518500249,1859775393,-1894007588,-899497514],Pj=new Array(80);function al(){this.init(),this._w=Pj,VS.call(this,64,56)}Rj(al,VS);al.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Lj(r){return r<<1|r>>>31}function Nj(r){return r<<5|r>>>27}function Oj(r){return r<<30|r>>>2}function Ij(r,e,t,i){return r===0?e&t|~e&i:r===2?e&t|e&i|t&i:e^t^i}al.prototype._update=function(r){for(var e=this._w,t=this._a|0,i=this._b|0,s=this._c|0,n=this._d|0,a=this._e|0,o=0;o<16;++o)e[o]=r.readInt32BE(o*4);for(;o<80;++o)e[o]=Lj(e[o-3]^e[o-8]^e[o-14]^e[o-16]);for(var l=0;l<80;++l){var c=~~(l/20),h=Nj(t)+Ij(c,i,s,n)+a+e[l]+Dj[c]|0;a=n,n=s,s=Oj(i),i=t,t=h}this._a=t+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=n+this._d|0,this._e=a+this._e|0};al.prototype._hash=function(){var r=Mj.allocUnsafe(20);return r.writeInt32BE(this._a|0,0),r.writeInt32BE(this._b|0,4),r.writeInt32BE(this._c|0,8),r.writeInt32BE(this._d|0,12),r.writeInt32BE(this._e|0,16),r};var jj=al;const Bj=En(jj);var KS={};/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */(function(r){(function(e){e(typeof DO_NOT_EXPORT_CRC>"u"?r:{})})(function(e){e.version="1.2.2";function t(){for(var y=0,E=new Array(256),D=0;D!=256;++D)y=D,y=y&1?-306674912^y>>>1:y>>>1,y=y&1?-306674912^y>>>1:y>>>1,y=y&1?-306674912^y>>>1:y>>>1,y=y&1?-306674912^y>>>1:y>>>1,y=y&1?-306674912^y>>>1:y>>>1,y=y&1?-306674912^y>>>1:y>>>1,y=y&1?-306674912^y>>>1:y>>>1,y=y&1?-306674912^y>>>1:y>>>1,E[D]=y;return typeof Int32Array<"u"?new Int32Array(E):E}var i=t();function s(y){var E=0,D=0,T=0,M=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(T=0;T!=256;++T)M[T]=y[T];for(T=0;T!=256;++T)for(D=y[T],E=256+T;E<4096;E+=256)D=M[E]=D>>>8^y[D&255];var R=[];for(T=1;T!=16;++T)R[T-1]=typeof Int32Array<"u"?M.subarray(T*256,T*256+256):M.slice(T*256,T*256+256);return R}var n=s(i),a=n[0],o=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],f=n[7],_=n[8],b=n[9],p=n[10],g=n[11],v=n[12],x=n[13],w=n[14];function S(y,E){for(var D=E^-1,T=0,M=y.length;T<M;)D=D>>>
1648^i[(D^y.charCodeAt(T++))&255];return~D}function k(y,E){for(var D=E^-1,T=y.length-15,M=0;M<T;)D=w[y[M++]^D&255]^x[y[M++]^D>>8&255]^v[y[M++]^D>>16&255]^g[y[M++]^D>>>24]^p[y[M++]]^b[y[M++]]^_[y[M++]]^f[y[M++]]^d[y[M++]]^u[y[M++]]^h[y[M++]]^c[y[M++]]^l[y[M++]]^o[y[M++]]^a[y[M++]]^i[y[M++]];for(T+=15;M<T;)D=D>>>8^i[(D^y[M++])&255];return~D}function C(y,E){for(var D=E^-1,T=0,M=y.length,R=0,O=0;T<M;)R=y.charCodeAt(T++),R<128?D=D>>>8^i[(D^R)&255]:R<2048?(D=D>>>8^i[(D^(192|R>>6&31))&255],D=D>>>8^i[(D^(128|R&63))&255]):R>=55296&&R<57344?(R=(R&1023)+64,O=y.charCodeAt(T++)&1023,D=D>>>8^i[(D^(240|R>>8&7))&255],D=D>>>8^i[(D^(128|R>>2&63))&255],D=D>>>8^i[(D^(128|O>>6&15|(R&3)<<4))&255],D=D>>>8^i[(D^(128|O&63))&255]):(D=D>>>8^i[(D^(224|R>>12&15))&255],D=D>>>8^i[(D^(128|R>>6&63))&255],D=D>>>8^i[(D^(128|R&63))&255]);return~D}e.table=i,e.bstr=S,e.buf=k,e.str=C})})(KS);const Fj=En(KS);var Zi={};(function(r){var e=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function t(n,a){return Object.prototype.hasOwnProperty.call(n,a)}r.assign=function(n){for(var a=Array.prototype.slice.call(arguments,1);a.length;){var o=a.shift();if(o){if(typeof o!="object")throw new TypeError(o+"must be non-object");for(var l in o)t(o,l)&&(n[l]=o[l])}}return n},r.shrinkBuf=function(n,a){return n.length===a?n:n.subarray?n.subarray(0,a):(n.length=a,n)};var i={arraySet:function(n,a,o,l,c){if(a.subarray&&n.subarray){n.set(a.subarray(o,o+l),c);return}for(var h=0;h<l;h++)n[c+h]=a[o+h]},flattenChunks:function(n){var a,o,l,c,h,u;for(l=0,a=0,o=n.length;a<o;a++)l+=n[a].length;for(u=new Uint8Array(l),c=0,a=0,o=n.length;a<o;a++)h=n[a],u.set(h,c),c+=h.length;return u}},s={arraySet:function(n,a,o,l,c){for(var h=0;h<l;h++)n[c+h]=a[o+h]},flattenChunks:function(n){return[].concat.apply([],n)}};r.setTyped=function(n){n?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,i)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,s))},r.setTyped(e)})(Zi);var ll={},Si={},To={},$j=Zi,Hj=4,Zv=0,Jv=1,zj=2;function Ro(r){for(var e=r.length;--e>=0;)r[e]=0}var Wj=0,qS=1,Uj=2,Vj=3,Kj=258,Pm=29,cl=256,Ha=cl+1+Pm,no=30,Lm=19,GS=2*Ha+1,en=15,nd=16,qj=7,Nm=256,XS=16,YS=17,ZS=18,Xf=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],wc=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Gj=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],JS=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Xj=512,Ni=new Array((Ha+2)*2);Ro(Ni);var fa=new Array(no*2);Ro(fa);var za=new Array(Xj);Ro(za);var Wa=new Array(Kj-Vj+1);Ro(Wa);var Om=new Array(Pm);Ro(Om);var ph=new Array(no);Ro(ph);function od(r,e,t,i,s){this.static_tree=r,this.extra_bits=e,this.extra_base=t,this.elems=i,this.max_length=s,this.has_stree=r&&r.length}var QS,ek,tk;function ad(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}function rk(r){return r<256?za[r]:za[256+(r>>>7)]}function Ua(r,e){r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255}function sr(r,e,t){r.bi_valid>nd-t?(r.bi_buf|=e<<r.bi_valid&65535,Ua(r,r.bi_buf),r.bi_buf=e>>nd-r.bi_valid,r.bi_valid+=t-nd):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)}function hi(r,e,t){sr(r,t[e*2],t[e*2+1])}function ik(r,e){var t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1}function Yj(r){r.bi_valid===16?(Ua(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)}function Zj(r,e){var t=e.dyn_tree,i=e.max_code,s=e.stat_desc.static_tree,n=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,l=e.stat_desc.max_length,c,h,u,d,f,_,b=0;for(d=0;d<=en;d++)r.bl_count[d]=0;for(t[r.heap[r.heap_max]*2+1]=0,c=r.heap_max+1;c<GS;c++)h=r.heap[c],d=t[t[h*2+1]*2+1]+1,d>l&&(d=l,b++),t[h*2+1]=d,!(h>i)&&(r.bl_count[d]++,f=0,h>=o&&(f=a[h-o]),_=t[h*2],r.opt_len+=_*(d+f),n&&(r.static_len+=_*(s[h*2+1]+f)));if(b!==0){do{for(d=l-1;r.bl_count[d]===0;)d--;r.bl_count[d]--,r.bl_count[d+1]+=2,r.bl_count[l]--,b-=2}while(b>0);for(d=l;d!==0;d--)for(h=r.bl_count[d];h!==0;)u=r.heap[--c],!(u>i)&&(t[u*2+1]!==d&&(r.opt_len+=(d-t[u*2+1])*t[u*2],t[u*2+1]=d),h--)}}function sk(r,e,t){var i=new Array(en+1),s=0,n,a;for(n=1;n<=en;n++)i[n]=s=s+t[n-1]<<1;for(a=0;a<=e;a++){var o=r[a*2+1];o!==0&&(r[a*2]=ik(i[o]++,o))}}function Jj(){var r,e,t,i,s,n=new Array(en+1);for(t=0,i=0;i<Pm-1;i++)for(Om[i]=t,r=0;r<1<<Xf[i];r++)Wa[t++]=i;for(Wa[t-1]=i,s=0,i=0;i<16;i++)for(ph[i]=s,r=0;r<1<<wc[i];r++)za[s++]=i;for(s>>=7;i<no;i++)for(ph[i]=s<<7,r=0;r<1<<wc[i]-7;r++)za[256+s++]=i;for(e=0;e<=en;e++)n[e]=0;for(r=0;r<=143;)Ni[r*2+1]=8,r++,n[8]++;for(;r<=255;)Ni[r*2+1]=9,r++,n[9]++;for(;r<=279;)Ni[r*2+1]=7,r++,n[7]++;for(;r<=287;)Ni[r*2+1]=8,r++,n[8]++;
vendor: 18,729 bytes, line 164
164for(sk(Ni,Ha+1,n),r=0;r<no;r++)fa[r*2+1]=5,fa[r*2]=ik(r,5);QS=new od(Ni,Xf,cl+1,Ha,en),ek=new od(fa,wc,0,no,en),tk=new od(new Array(0),Gj,0,Lm,qj)}function nk(r){var e;for(e=0;e<Ha;e++)r.dyn_ltree[e*2]=0;for(e=0;e<no;e++)r.dyn_dtree[e*2]=0;for(e=0;e<Lm;e++)r.bl_tree[e*2]=0;r.dyn_ltree[Nm*2]=1,r.opt_len=r.static_len=0,r.last_lit=r.matches=0}function ok(r){r.bi_valid>8?Ua(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0}function Qj(r,e,t,i){ok(r),Ua(r,t),Ua(r,~t),$j.arraySet(r.pending_buf,r.window,e,t,r.pending),r.pending+=t}function Qv(r,e,t,i){var s=e*2,n=t*2;return r[s]<r[n]||r[s]===r[n]&&i[e]<=i[t]}function ld(r,e,t){for(var i=r.heap[t],s=t<<1;s<=r.heap_len&&(s<r.heap_len&&Qv(e,r.heap[s+1],r.heap[s],r.depth)&&s++,!Qv(e,i,r.heap[s],r.depth));)r.heap[t]=r.heap[s],t=s,s<<=1;r.heap[t]=i}function eb(r,e,t){var i,s,n=0,a,o;if(r.last_lit!==0)do i=r.pending_buf[r.d_buf+n*2]<<8|r.pending_buf[r.d_buf+n*2+1],s=r.pending_buf[r.l_buf+n],n++,i===0?hi(r,s,e):(a=Wa[s],hi(r,a+cl+1,e),o=Xf[a],o!==0&&(s-=Om[a],sr(r,s,o)),i--,a=rk(i),hi(r,a,t),o=wc[a],o!==0&&(i-=ph[a],sr(r,i,o)));while(n<r.last_lit);hi(r,Nm,e)}function Yf(r,e){var t=e.dyn_tree,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,n=e.stat_desc.elems,a,o,l=-1,c;for(r.heap_len=0,r.heap_max=GS,a=0;a<n;a++)t[a*2]!==0?(r.heap[++r.heap_len]=l=a,r.depth[a]=0):t[a*2+1]=0;for(;r.heap_len<2;)c=r.heap[++r.heap_len]=l<2?++l:0,t[c*2]=1,r.depth[c]=0,r.opt_len--,s&&(r.static_len-=i[c*2+1]);for(e.max_code=l,a=r.heap_len>>1;a>=1;a--)ld(r,t,a);c=n;do a=r.heap[1],r.heap[1]=r.heap[r.heap_len--],ld(r,t,1),o=r.heap[1],r.heap[--r.heap_max]=a,r.heap[--r.heap_max]=o,t[c*2]=t[a*2]+t[o*2],r.depth[c]=(r.depth[a]>=r.depth[o]?r.depth[a]:r.depth[o])+1,t[a*2+1]=t[o*2+1]=c,r.heap[1]=c++,ld(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],Zj(r,e),sk(t,l,r.bl_count)}function tb(r,e,t){var i,s=-1,n,a=e[0*2+1],o=0,l=7,c=4;for(a===0&&(l=138,c=3),e[(t+1)*2+1]=65535,i=0;i<=t;i++)n=a,a=e[(i+1)*2+1],!(++o<l&&n===a)&&(o<c?r.bl_tree[n*2]+=o:n!==0?(n!==s&&r.bl_tree[n*2]++,r.bl_tree[XS*2]++):o<=10?r.bl_tree[YS*2]++:r.bl_tree[ZS*2]++,o=0,s=n,a===0?(l=138,c=3):n===a?(l=6,c=3):(l=7,c=4))}function rb(r,e,t){var i,s=-1,n,a=e[0*2+1],o=0,l=7,c=4;for(a===0&&(l=138,c=3),i=0;i<=t;i++)if(n=a,a=e[(i+1)*2+1],!(++o<l&&n===a)){if(o<c)do hi(r,n,r.bl_tree);while(--o!==0);else n!==0?(n!==s&&(hi(r,n,r.bl_tree),o--),hi(r,XS,r.bl_tree),sr(r,o-3,2)):o<=10?(hi(r,YS,r.bl_tree),sr(r,o-3,3)):(hi(r,ZS,r.bl_tree),sr(r,o-11,7));o=0,s=n,a===0?(l=138,c=3):n===a?(l=6,c=3):(l=7,c=4)}}function e4(r){var e;for(tb(r,r.dyn_ltree,r.l_desc.max_code),tb(r,r.dyn_dtree,r.d_desc.max_code),Yf(r,r.bl_desc),e=Lm-1;e>=3&&r.bl_tree[JS[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e}function t4(r,e,t,i){var s;for(sr(r,e-257,5),sr(r,t-1,5),sr(r,i-4,4),s=0;s<i;s++)sr(r,r.bl_tree[JS[s]*2+1],3);rb(r,r.dyn_ltree,e-1),rb(r,r.dyn_dtree,t-1)}function r4(r){var e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return Zv;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return Jv;for(t=32;t<cl;t++)if(r.dyn_ltree[t*2]!==0)return Jv;return Zv}var ib=!1;function i4(r){ib||(Jj(),ib=!0),r.l_desc=new ad(r.dyn_ltree,QS),r.d_desc=new ad(r.dyn_dtree,ek),r.bl_desc=new ad(r.bl_tree,tk),r.bi_buf=0,r.bi_valid=0,nk(r)}function ak(r,e,t,i){sr(r,(Wj<<1)+(i?1:0),3),Qj(r,e,t)}function s4(r){sr(r,qS<<1,3),hi(r,Nm,Ni),Yj(r)}function n4(r,e,t,i){var s,n,a=0;r.level>0?(r.strm.data_type===zj&&(r.strm.data_type=r4(r)),Yf(r,r.l_desc),Yf(r,r.d_desc),a=e4(r),s=r.opt_len+3+7>>>3,n=r.static_len+3+7>>>3,n<=s&&(s=n)):s=n=t+5,t+4<=s&&e!==-1?ak(r,e,t,i):r.strategy===Hj||n===s?(sr(r,(qS<<1)+(i?1:0),3),eb(r,Ni,fa)):(sr(r,(Uj<<1)+(i?1:0),3),t4(r,r.l_desc.max_code+1,r.d_desc.max_code+1,a+1),eb(r,r.dyn_ltree,r.dyn_dtree)),nk(r),i&&ok(r)}function o4(r,e,t){return r.pending_buf[r.d_buf+r.last_lit*2]=e>>>8&255,r.pending_buf[r.d_buf+r.last_lit*2+1]=e&255,r.pending_buf[r.l_buf+r.last_lit]=t&255,r.last_lit++,e===0?r.dyn_ltree[t*2]++:(r.matches++,e--,r.dyn_ltree[(Wa[t]+cl+1)*2]++,r.dyn_dtree[rk(e)*2]++),r.last_lit===r.lit_bufsize-1}To._tr_init=i4;To._tr_stored_block=ak;To._tr_flush_block=n4;To._tr_tally=o4;To._tr_align=s4;function a4(r,e,t,i){for(var s=r&65535|0,n=r>>>16&65535|0,a=0;t!==0;){a=t>2e3?2e3:t,t-=a;do s=s+e[i++]|0,n=n+s|0;while(--a);s%=65521,n%=65521}return s|n<<16|0}var lk=a4;function l4(){for(var r,e=[],t=0;t<256;t++){r=t;for(var i=0;i<8;i++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e}var c4=l4();function h4(r,e,t,i){var s=c4,n=i+t;r^=-1;for(var a=i;a<n;a++)r=r>>>8^s[(r^e[a])&255];return r^-1}var ck=h4,Im={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Vt=Zi,Pr=To,hk=lk,ss=ck,u4=Im,Dn=0,d4=1,f4=3,ws=4,sb=5,ui=0,nb=1,Lr=-2,p4=-3,cd=-5,m4=-1,g4=1,ec=2,v4=3,b4=4,x4=0,_4=2,Jh=8,y4=9,w4=15,S4=8,k4=29,C4=256,Zf=C4+1+k4,E4=30,A4=19,T4=2*Zf+1,R4=15,je=3,vs=258,Ur=vs+je+1,M4=32,Qh=42,Jf=69,Sc=73,kc=91,Cc=103,tn=113,sa=666,xt=1,hl=2,_n=3,Mo=4,D4=3;function bs(r,e){return r.msg=u4[e],e}function ob(r){return(r<<1)-(r>4?9:0)}function ds(r){for(var e=r.length;--e>=0;)r[e]=0}function ns(r){var e=r.state,t=e.pending;t>r.avail_out&&(t=r.avail_out),t!==0&&(Vt.arraySet(r.output,e.pending_buf,e.pending_out,t,r.next_out),r.next_out+=t,e.pending_out+=t,r.total_out+=t,r.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))}function Pt(r,e){Pr._tr_flush_block(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,ns(r.strm)}function qe(r,e){r.pending_buf[r.pending++]=e}function Go(r,e){r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255}function P4(r,e,t,i){var s=r.avail_in;return s>i&&(s=i),s===0?0:(r.avail_in-=s,Vt.arraySet(e,r.input,r.next_in,s,t),r.state.wrap===1?r.adler=hk(r.adler,e,s,t):r.state.wrap===2&&(r.adler=ss(r.adler,e,s,t)),r.next_in+=s,r.total_in+=s,s)}function uk(r,e){var t=r.max_chain_length,i=r.strstart,s,n,a=r.prev_length,o=r.nice_match,l=r.strstart>r.w_size-Ur?r.strstart-(r.w_size-Ur):0,c=r.window,h=r.w_mask,u=r.prev,d=r.strstart+vs,f=c[i+a-1],_=c[i+a];r.prev_length>=r.good_match&&(t>>=2),o>r.lookahead&&(o=r.lookahead);do if(s=e,!(c[s+a]!==_||c[s+a-1]!==f||c[s]!==c[i]||c[++s]!==c[i+1])){i+=2,s++;do;while(c[++i]===c[++s]&&c[++i]===c[++s]&&c[++i]===c[++s]&&c[++i]===c[++s]&&c[++i]===c[++s]&&c[++i]===c[++s]&&c[++i]===c[++s]&&c[++i]===c[++s]&&i<d);if(n=vs-(d-i),i=d-vs,n>a){if(r.match_start=e,a=n,n>=o)break;f=c[i+a-1],_=c[i+a]}}while((e=u[e&h])>l&&--t!==0);return a<=r.lookahead?a:r.lookahead}function yn(r){var e=r.w_size,t,i,s,n,a;do{if(n=r.window_size-r.lookahead-r.strstart,r.strstart>=e+(e-Ur)){Vt.arraySet(r.window,r.window,e,e,0),r.match_start-=e,r.strstart-=e,r.block_start-=e,i=r.hash_size,t=i;do s=r.head[--t],r.head[t]=s>=e?s-e:0;while(--i);i=e,t=i;do s=r.prev[--t],r.prev[t]=s>=e?s-e:0;while(--i);n+=e}if(r.strm.avail_in===0)break;if(i=P4(r.strm,r.window,r.strstart+r.lookahead,n),r.lookahead+=i,r.lookahead+r.insert>=je)for(a=r.strstart-r.insert,r.ins_h=r.window[a],r.ins_h=(r.ins_h<<r.hash_shift^r.window[a+1])&r.hash_mask;r.insert&&(r.ins_h=(r.ins_h<<r.hash_shift^r.window[a+je-1])&r.hash_mask,r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++,r.insert--,!(r.lookahead+r.insert<je)););}while(r.lookahead<Ur&&r.strm.avail_in!==0)}function L4(r,e){var t=65535;for(t>r.pending_buf_size-5&&(t=r.pending_buf_size-5);;){if(r.lookahead<=1){if(yn(r),r.lookahead===0&&e===Dn)return xt;if(r.lookahead===0)break}r.strstart+=r.lookahead,r.lookahead=0;var i=r.block_start+t;if((r.strstart===0||r.strstart>=i)&&(r.lookahead=r.strstart-i,r.strstart=i,Pt(r,!1),r.strm.avail_out===0)||r.strstart-r.block_start>=r.w_size-Ur&&(Pt(r,!1),r.strm.avail_out===0))return xt}return r.insert=0,e===ws?(Pt(r,!0),r.strm.avail_out===0?_n:Mo):(r.strstart>r.block_start&&(Pt(r,!1),r.strm.avail_out===0),xt)}function hd(r,e){for(var t,i;;){if(r.lookahead<Ur){if(yn(r),r.lookahead<Ur&&e===Dn)return xt;if(r.lookahead===0)break}if(t=0,r.lookahead>=je&&(r.ins_h=(r.ins_h<<r.hash_shift^r.window[r.strstart+je-1])&r.hash_mask,t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),t!==0&&r.strstart-t<=r.w_size-Ur&&(r.match_length=uk(r,t)),r.match_length>=je)if(i=Pr._tr_tally(r,r.strstart-r.match_start,r.match_length-je),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=je){r.match_length--;do r.strstart++,r.ins_h=(r.ins_h<<r.hash_shift^r.window[r.strstart+je-1])&r.hash_mask,t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=(r.ins_h<<r.hash_shift^r.window[r.strstart+1])&r.hash_mask;else i=Pr._tr_tally(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(i&&(Pt(r,!1),r.strm.avail_out===0))return xt}return r.insert=r.strstart<je-1?r.strstart:je-1,e===ws?(Pt(r,!0),r.strm.avail_out===0?_n:Mo):r.last_lit&&(Pt(r,!1),r.strm.avail_out===0)?xt:hl}function $n(r,e){for(var t,i,s;;){if(r.lookahead<Ur){if(yn(r),r.lookahead<Ur&&e===Dn)return xt;if(r.lookahead===0)break}if(t=0,r.lookahead>=je&&(r.ins_h=(r.ins_h<<r.hash_shift^r.window[r.strstart+je-1])&r.hash_mask,t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=je-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-Ur&&(r.match_length=uk(r,t),r.match_length<=5&&(r.strategy===g4||r.match_length===je&&r.strstart-r.match_start>4096)&&(r.match_length=je-1)),r.prev_length>=je&&r.match_length<=r.prev_length){s=r.strstart+r.lookahead-je,i=Pr._tr_tally(r,r.strstart-1-r.prev_match,r.prev_length-je),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=s&&(r.ins_h=(r.ins_h<<r.hash_shift^r.window[r.strstart+je-1])&r.hash_mask,t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=je-1,r.strstart++,i&&(Pt(r,!1),r.strm.avail_out===0))return xt}else if(r.match_available){if(i=Pr._tr_tally(r,0,r.window[r.strstart-1]),i&&Pt(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return xt}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(i=Pr._tr_tally(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<je-1?r.strstart:je-1,e===ws?(Pt(r,!0),r.strm.avail_out===0?_n:Mo):r.last_lit&&(Pt(r,!1),r.strm.avail_out===0)?xt:hl}function N4(r,e){for(var t,i,s,n,a=r.window;;){if(r.lookahead<=vs){if(yn(r),r.lookahead<=vs&&e===Dn)return xt;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=je&&r.strstart>0&&(s=r.strstart-1,i=a[s],i===a[++s]&&i===a[++s]&&i===a[++s])){n=r.strstart+vs;do;while(i===a[++s]&&i===a[++s]&&i===a[++s]&&i===a[++s]&&i===a[++s]&&i===a[++s]&&i===a[++s]&&i===a[++s]&&s<n);r.match_length=vs-(n-s),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=je?(t=Pr._tr_tally(r,1,r.match_length-je),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=Pr._tr_tally(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&(Pt(r,!1),r.strm.avail_out===0))return xt}return r.insert=0,e===ws?(Pt(r,!0),r.strm.avail_out===0?_n:Mo):r.last_lit&&(Pt(r,!1),r.strm.avail_out===0)?xt:hl}function O4(r,e){for(var t;;){if(r.lookahead===0&&(yn(r),r.lookahead===0)){if(e===Dn)return xt;break}if(r.match_length=0,t=Pr._tr_tally(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&(Pt(r,!1),r.strm.avail_out===0))return xt}return r.insert=0,e===ws?(Pt(r,!0),r.strm.avail_out===0?_n:Mo):r.last_lit&&(Pt(r,!1),r.strm.avail_out===0)?xt:hl}function ti(r,e,t,i,s){this.good_length=r,this.max_lazy=e,this.nice_length=t,this.max_chain=i,this.func=s}var Zn;Zn=[new ti(0,0,0,0,L4),new ti(4,4,8,4,hd),new ti(4,5,16,8,hd),new ti(4,6,32,32,hd),new ti(4,4,16,16,$n),new ti(8,16,32,32,$n),new ti(8,16,128,128,$n),new ti(8,32,128,256,$n),new ti(32,128,258,1024,$n),new ti(32,258,258,4096,$n)];function I4(r){r.window_size=2*r.w_size,ds(r.head),r.max_lazy_match=Zn[r.level].max_lazy,r.good_match=Zn[r.level].good_length,r.nice_match=Zn[r.level].nice_length,r.max_chain_length=Zn[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=je-1,r.match_available=0,r.ins_h=0}function j4(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Jh,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Vt.Buf16(T4*2),this.dyn_dtree=new Vt.Buf16((2*E4+1)*2),this.bl_tree=new Vt.Buf16((2*A4+1)*2),ds(this.dyn_ltree),ds(this.dyn_dtree),ds(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Vt.Buf16(R4+1),this.heap=new Vt.Buf16(2*Zf+1),ds(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Vt.Buf16(2*Zf+1),ds(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function dk(r){var e;return!r||!r.state?bs(r,Lr):(r.total_in=r.total_out=0,r.data_type=_4,e=r.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?Qh:tn,r.adler=e.wrap===2?0:1,e.last_flush=Dn,Pr._tr_init(e),ui)}function fk(r){var e=dk(r);return e===ui&&I4(r.state),e}function B4(r,e){return!r||!r.state||r.state.wrap!==2?Lr:(r.state.gzhead=e,ui)}function pk(r,e,t,i,s,n){if(!r)return Lr;var a=1;if(e===m4&&(e=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),s<1||s>y4||t!==Jh||i<8||i>15||e<0||e>9||n<0||n>b4)return bs(r,Lr);i===8&&(i=9);var o=new j4;return r.state=o,o.strm=r,o.wrap=a,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=s+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+je-1)/je),o.window=new Vt.Buf8(o.w_size*2),o.head=new Vt.Buf16(o.hash_size),o.prev=new Vt.Buf16(o.w_size),o.lit_bufsize=1<<s+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Vt.Buf8(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=n,o.method=t,fk(r)}function F4(r,e){return pk(r,e,Jh,w4,S4,x4)}function $4(r,e){var t,i,s,n;if(!r||!r.state||e>sb||e<0)return r?bs(r,Lr):Lr;if(i=r.state,!r.output||!r.input&&r.avail_in!==0||i.status===sa&&e!==ws)return bs(r,r.avail_out===0?cd:Lr);if(i.strm=r,t=i.last_flush,i.last_flush=e,i.status===Qh)if(i.wrap===2)r.adler=0,qe(i,31),qe(i,139),qe(i,8),i.gzhead?(qe(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),qe(i,i.gzhead.time&255),qe(i,i.gzhead.time>>8&255),qe(i,i.gzhead.time>>16&255),qe(i,i.gzhead.time>>24&255),qe(i,i.level===9?2:i.strategy>=ec||i.level<2?4:0),qe(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(qe(i,i.gzhead.extra.length&255),qe(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(r.adler=ss(r.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Jf):(qe(i,0),qe(i,0),qe(i,0),qe(i,0),qe(i,0),qe(i,i.level===9?2:i.strategy>=ec||i.level<2?4:0),qe(i,D4),i.status=tn);else{var a=Jh+(i.w_bits-8<<4)<<8,o=-1;i.strategy>=ec||i.level<2?o=0:i.level<6?o=1:i.level===6?o=2:o=3,a|=o<<6,i.strstart!==0&&(a|=M4),a+=31-a%31,i.status=tn,Go(i,a),i.strstart!==0&&(Go(i,r.adler>>>16),Go(i,r.adler&65535)),r.adler=1}if(i.status===Jf)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(r.adler=ss(r.adler,i.pending_buf,i.pending-s,s)),ns(r),s=i.pending,i.pending===i.pending_buf_size));)qe(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(r.adler=ss(r.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Sc)}else i.status=Sc;if(i.status===Sc)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(r.adler=ss(r.adler,i.pending_buf,i.pending-s,s)),ns(r),s=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindex<i.gzhead.name.length?n=i.gzhead.name.charCodeAt(i.gzindex++)&255:n=0,qe(i,n)}while(n!==0);i.gzhead.hcrc&&i.pending>s&&(r.adler=ss(r.adler,i.pending_buf,i.pending-s,s)),n===0&&(i.gzindex=0,i.status=kc)}else i.status=kc;if(i.status===kc)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(r.adler=ss(r.adler,i.pending_buf,i.pending-s,s)),ns(r),s=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindex<i.gzhead.comment.length?n=i.gzhead.comment.charCodeAt(i.gzindex++)&255:n=0,qe(i,n)}while(n!==0);i.gzhead.hcrc&&i.pending>s&&(r.adler=ss(r.adler,i.pending_buf,i.pending-s,s)),n===0&&(i.status=Cc)}else i.status=Cc;if(i.status===Cc&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&ns(r),i.pending+2<=i.pending_buf_size&&(qe(i,r.adler&255),qe(i,r.adler>>8&255),r.adler=0,i.status=tn)):i.status=tn),i.pending!==0){if(ns(r),r.avail_out===0)return i.last_flush=-1,ui}else if(r.avail_in===0&&ob(e)<=ob(t)&&e!==ws)return bs(r,cd);if(i.status===sa&&r.avail_in!==0)return bs(r,cd);if(r.avail_in!==0||i.lookahead!==0||e!==Dn&&i.status!==sa){var l=i.strategy===ec?O4(i,e):i.strategy===v4?N4(i,e):Zn[i.level].func(i,e);if((l===_n||l===Mo)&&(i.status=sa),l===xt||l===_n)return r.avail_out===0&&(i.last_flush=-1),ui;if(l===hl&&(e===d4?Pr._tr_align(i):e!==sb&&(Pr._tr_stored_block(i,0,0,!1),e===f4&&(ds(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),ns(r),r.avail_out===0))return i.last_flush=-1,ui}return e!==ws?ui:i.wrap<=0?nb:(i.wrap===2?(qe(i,r.adler&255),qe(i,r.adler>>8&255),qe(i,r.adler>>16&255),qe(i,r.adler>>24&255),qe(i,r.total_in&255),qe(i,r.total_in>>8&255),qe(i,r.total_in>>16&255),qe(i,r.total_in>>24&255)):(Go(i,r.adler>>>16),Go(i,r.adler&65535)),ns(r),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?ui:nb)}function H4(r){var e;return!r||!r.state?Lr:(e=r.state.status,e!==Qh&&e!==Jf&&e!==Sc&&e!==kc&&e!==Cc&&e!==tn&&e!==sa?bs(r,Lr):(r.state=null,e===tn?bs(r,p4):ui))}function z4(r,e){var t=e.length,i,s,n,a,o,l,c,h;if(!r||!r.state||(i=r.state,a=i.wrap,a===2||a===1&&i.status!==Qh||i.lookahead))return Lr;for(a===1&&(r.adler=hk(r.adler,e,t,0)),i.wrap=0,t>=i.w_size&&(a===0&&(ds(i.head),i.strstart=0,i.block_start=0,i.insert=0),h=new Vt.Buf8(i.w_size),Vt.arraySet(h,e,t-i.w_size,i.w_size,0),e=h,t=i.w_size),o=r.avail_in,l=r.next_in,
vendor: 19,993 bytes, line 164
164c=r.input,r.avail_in=t,r.next_in=0,r.input=e,yn(i);i.lookahead>=je;){s=i.strstart,n=i.lookahead-(je-1);do i.ins_h=(i.ins_h<<i.hash_shift^i.window[s+je-1])&i.hash_mask,i.prev[s&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=s,s++;while(--n);i.strstart=s,i.lookahead=je-1,yn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=je-1,i.match_available=0,r.next_in=l,r.input=c,r.avail_in=o,i.wrap=a,ui}Si.deflateInit=F4;Si.deflateInit2=pk;Si.deflateReset=fk;Si.deflateResetKeep=dk;Si.deflateSetHeader=B4;Si.deflate=$4;Si.deflateEnd=H4;Si.deflateSetDictionary=z4;Si.deflateInfo="pako deflate (from Nodeca project)";var Pn={},eu=Zi,mk=!0,gk=!0;try{String.fromCharCode.apply(null,[0])}catch{mk=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{gk=!1}var Va=new eu.Buf8(256);for(var rs=0;rs<256;rs++)Va[rs]=rs>=252?6:rs>=248?5:rs>=240?4:rs>=224?3:rs>=192?2:1;Va[254]=Va[254]=1;Pn.string2buf=function(r){var e,t,i,s,n,a=r.length,o=0;for(s=0;s<a;s++)t=r.charCodeAt(s),(t&64512)===55296&&s+1<a&&(i=r.charCodeAt(s+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),s++)),o+=t<128?1:t<2048?2:t<65536?3:4;for(e=new eu.Buf8(o),n=0,s=0;n<o;s++)t=r.charCodeAt(s),(t&64512)===55296&&s+1<a&&(i=r.charCodeAt(s+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),s++)),t<128?e[n++]=t:t<2048?(e[n++]=192|t>>>6,e[n++]=128|t&63):t<65536?(e[n++]=224|t>>>12,e[n++]=128|t>>>6&63,e[n++]=128|t&63):(e[n++]=240|t>>>18,e[n++]=128|t>>>12&63,e[n++]=128|t>>>6&63,e[n++]=128|t&63);return e};function vk(r,e){if(e<65534&&(r.subarray&&gk||!r.subarray&&mk))return String.fromCharCode.apply(null,eu.shrinkBuf(r,e));for(var t="",i=0;i<e;i++)t+=String.fromCharCode(r[i]);return t}Pn.buf2binstring=function(r){return vk(r,r.length)};Pn.binstring2buf=function(r){for(var e=new eu.Buf8(r.length),t=0,i=e.length;t<i;t++)e[t]=r.charCodeAt(t);return e};Pn.buf2string=function(r,e){var t,i,s,n,a=e||r.length,o=new Array(a*2);for(i=0,t=0;t<a;){if(s=r[t++],s<128){o[i++]=s;continue}if(n=Va[s],n>4){o[i++]=65533,t+=n-1;continue}for(s&=n===2?31:n===3?15:7;n>1&&t<a;)s=s<<6|r[t++]&63,n--;if(n>1){o[i++]=65533;continue}s<65536?o[i++]=s:(s-=65536,o[i++]=55296|s>>10&1023,o[i++]=56320|s&1023)}return vk(o,i)};Pn.utf8border=function(r,e){var t;for(e=e||r.length,e>r.length&&(e=r.length),t=e-1;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+Va[r[t]]>e?t:e};function W4(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var bk=W4,pa=Si,ma=Zi,Qf=Pn,ep=Im,U4=bk,xk=Object.prototype.toString,V4=0,ud=4,oo=0,ab=1,lb=2,K4=-1,q4=0,G4=8;function wn(r){if(!(this instanceof wn))return new wn(r);this.options=ma.assign({level:K4,method:G4,chunkSize:16384,windowBits:15,memLevel:8,strategy:q4,to:""},r||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new U4,this.strm.avail_out=0;var t=pa.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==oo)throw new Error(ep[t]);if(e.header&&pa.deflateSetHeader(this.strm,e.header),e.dictionary){var i;if(typeof e.dictionary=="string"?i=Qf.string2buf(e.dictionary):xk.call(e.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(e.dictionary):i=e.dictionary,t=pa.deflateSetDictionary(this.strm,i),t!==oo)throw new Error(ep[t]);this._dict_set=!0}}wn.prototype.push=function(r,e){var t=this.strm,i=this.options.chunkSize,s,n;if(this.ended)return!1;n=e===~~e?e:e===!0?ud:V4,typeof r=="string"?t.input=Qf.string2buf(r):xk.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;do{if(t.avail_out===0&&(t.output=new ma.Buf8(i),t.next_out=0,t.avail_out=i),s=pa.deflate(t,n),s!==ab&&s!==oo)return this.onEnd(s),this.ended=!0,!1;(t.avail_out===0||t.avail_in===0&&(n===ud||n===lb))&&(this.options.to==="string"?this.onData(Qf.buf2binstring(ma.shrinkBuf(t.output,t.next_out))):this.onData(ma.shrinkBuf(t.output,t.next_out)))}while((t.avail_in>0||t.avail_out===0)&&s!==ab);return n===ud?(s=pa.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===oo):(n===lb&&(this.onEnd(oo),t.avail_out=0),!0)};wn.prototype.onData=function(r){this.chunks.push(r)};wn.prototype.onEnd=function(r){r===oo&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ma.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function jm(r,e){var t=new wn(e);if(t.push(r,!0),t.err)throw t.msg||ep[t.err];return t.result}function X4(r,e){return e=e||{},e.raw=!0,jm(r,e)}function Y4(r,e){return e=e||{},e.gzip=!0,jm(r,e)}ll.Deflate=wn;ll.deflate=jm;ll.deflateRaw=X4;ll.gzip=Y4;var ul={},Yr={},tc=30,Z4=12,J4=function(e,t){var i,s,n,a,o,l,c,h,u,d,f,_,b,p,g,v,x,w,S,k,C,y,E,D,T;i=e.state,s=e.next_in,D=e.input,n=s+(e.avail_in-5),a=e.next_out,T=e.output,o=a-(t-e.avail_out),l=a+(e.avail_out-257),c=i.dmax,h=i.wsize,u=i.whave,d=i.wnext,f=i.window,_=i.hold,b=i.bits,p=i.lencode,g=i.distcode,v=(1<<i.lenbits)-1,x=(1<<i.distbits)-1;e:do{b<15&&(_+=D[s++]<<b,b+=8,_+=D[s++]<<b,b+=8),w=p[_&v];t:for(;;){if(S=w>>>24,_>>>=S,b-=S,S=w>>>16&255,S===0)T[a++]=w&65535;else if(S&16){k=w&65535,S&=15,S&&(b<S&&(_+=D[s++]<<b,b+=8),k+=_&(1<<S)-1,_>>>=S,b-=S),b<15&&(_+=D[s++]<<b,b+=8,_+=D[s++]<<b,b+=8),w=g[_&x];r:for(;;){if(S=w>>>24,_>>>=S,b-=S,S=w>>>16&255,S&16){if(C=w&65535,S&=15,b<S&&(_+=D[s++]<<b,b+=8,b<S&&(_+=D[s++]<<b,b+=8)),C+=_&(1<<S)-1,C>c){e.msg="invalid distance too far back",i.mode=tc;break e}if(_>>>=S,b-=S,S=a-o,C>S){if(S=C-S,S>u&&i.sane){e.msg="invalid distance too far back",i.mode=tc;break e}if(y=0,E=f,d===0){if(y+=h-S,S<k){k-=S;do T[a++]=f[y++];while(--S);y=a-C,E=T}}else if(d<S){if(y+=h+d-S,S-=d,S<k){k-=S;do T[a++]=f[y++];while(--S);if(y=0,d<k){S=d,k-=S;do T[a++]=f[y++];while(--S);y=a-C,E=T}}}else if(y+=d-S,S<k){k-=S;do T[a++]=f[y++];while(--S);y=a-C,E=T}for(;k>2;)T[a++]=E[y++],T[a++]=E[y++],T[a++]=E[y++],k-=3;k&&(T[a++]=E[y++],k>1&&(T[a++]=E[y++]))}else{y=a-C;do T[a++]=T[y++],T[a++]=T[y++],T[a++]=T[y++],k-=3;while(k>2);k&&(T[a++]=T[y++],k>1&&(T[a++]=T[y++]))}}else if(S&64){e.msg="invalid distance code",i.mode=tc;break e}else{w=g[(w&65535)+(_&(1<<S)-1)];continue r}break}}else if(S&64)if(S&32){i.mode=Z4;break e}else{e.msg="invalid literal/length code",i.mode=tc;break e}else{w=p[(w&65535)+(_&(1<<S)-1)];continue t}break}}while(s<n&&a<l);k=b>>3,s-=k,b-=k<<3,_&=(1<<b)-1,e.next_in=s,e.next_out=a,e.avail_in=s<n?5+(n-s):5-(s-n),e.avail_out=a<l?257+(l-a):257-(a-l),i.hold=_,i.bits=b},cb=Zi,Hn=15,hb=852,ub=592,db=0,dd=1,fb=2,Q4=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],eB=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],tB=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],rB=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],iB=function(e,t,i,s,n,a,o,l){var c=l.bits,h=0,u=0,d=0,f=0,_=0,b=0,p=0,g=0,v=0,x=0,w,S,k,C,y,E=null,D=0,T,M=new cb.Buf16(Hn+1),R=new cb.Buf16(Hn+1),O=null,$=0,G,V,q;for(h=0;h<=Hn;h++)M[h]=0;for(u=0;u<s;u++)M[t[i+u]]++;for(_=c,f=Hn;f>=1&&M[f]===0;f--);if(_>f&&(_=f),f===0)return n[a++]=1<<24|64<<16|0,n[a++]=1<<24|64<<16|0,l.bits=1,0;for(d=1;d<f&&M[d]===0;d++);for(_<d&&(_=d),g=1,h=1;h<=Hn;h++)if(g<<=1,g-=M[h],g<0)return-1;if(g>0&&(e===db||f!==1))return-1;for(R[1]=0,h=1;h<Hn;h++)R[h+1]=R[h]+M[h];for(u=0;u<s;u++)t[i+u]!==0&&(o[R[t[i+u]]++]=u);if(e===db?(E=O=o,T=19):e===dd?(E=Q4,D-=257,O=eB,$-=257,T=256):(E=tB,O=rB,T=-1),x=0,u=0,h=d,y=a,b=_,p=0,k=-1,v=1<<_,C=v-1,e===dd&&v>hb||e===fb&&v>ub)return 1;for(;;){G=h-p,o[u]<T?(V=0,q=o[u]):o[u]>T?(V=O[$+o[u]],q=E[D+o[u]]):(V=96,q=0),w=1<<h-p,S=1<<b,d=S;do S-=w,n[y+(x>>p)+S]=G<<24|V<<16|q|0;while(S!==0);for(w=1<<h-1;x&w;)w>>=1;if(w!==0?(x&=w-1,x+=w):x=0,u++,--M[h]===0){if(h===f)break;h=t[i+o[u]]}if(h>_&&(x&C)!==k){for(p===0&&(p=_),y+=d,b=h-p,g=1<<b;b+p<f&&(g-=M[b+p],!(g<=0));)b++,g<<=1;if(v+=1<<b,e===dd&&v>hb||e===fb&&v>ub)return 1;k=x&C,n[k]=_<<24|b<<16|y-a|0}}return x!==0&&(n[y+x]=h-p<<24|64<<16|0),l.bits=_,0},vr=Zi,tp=lk,ri=ck,sB=J4,ga=iB,nB=0,_k=1,yk=2,pb=4,oB=5,rc=6,Sn=0,aB=1,lB=2,Ir=-2,wk=-3,Sk=-4,cB=-5,mb=8,kk=1,gb=2,vb=3,bb=4,xb=5,_b=6,yb=7,wb=8,Sb=9,kb=10,mh=11,Di=12,fd=13,Cb=14,pd=15,Eb=16,Ab=17,Tb=18,Rb=19,ic=20,sc=21,Mb=22,Db=23,Pb=24,Lb=25,Nb=26,md=27,Ob=28,Ib=29,rt=30,Ck=31,hB=32,uB=852,dB=592,fB=15,pB=fB;function jb(r){return(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24)}function mB(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new vr.Buf16(320),this.work=new vr.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Ek(r){var e;return!r||!r.state?Ir:(e=r.state,r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=kk,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new vr.Buf32(uB),e.distcode=e.distdyn=new vr.Buf32(dB),e.sane=1,e.back=-1,Sn)}function Ak(r){var e;return!r||!r.state?Ir:(e=r.state,e.wsize=0,e.whave=0,e.wnext=0,Ek(r))}function Tk(r,e){var t,i;return!r||!r.state||(i=r.state,e<0?(t=0,e=-e):(t=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?Ir:(i.window!==null&&i.wbits!==e&&(i.window=null),i.wrap=t,i.wbits=e,Ak(r))}function Rk(r,e){var t,i;return r?(i=new mB,r.state=i,i.window=null,t=Tk(r,e),t!==Sn&&(r.state=null),t):Ir}function gB(r){return Rk(r,pB)}var Bb=!0,gd,vd;function vB(r){if(Bb){var e;for(gd=new vr.Buf32(512),vd=new vr.Buf32(32),e=0;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(ga(_k,r.lens,0,288,gd,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;ga(yk,r.lens,0,32,vd,0,r.work,{bits:5}),Bb=!1}r.lencode=gd,r.lenbits=9,r.distcode=vd,r.distbits=5}function Mk(r,e,t,i){var s,n=r.state;return n.window===null&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new vr.Buf8(n.wsize)),i>=n.wsize?(vr.arraySet(n.window,e,t-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):(s=n.wsize-n.wnext,s>i&&(s=i),vr.arraySet(n.window,e,t-i,s,n.wnext),i-=s,i?(vr.arraySet(n.window,e,t-i,i,0),n.wnext=i,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=s))),0}function bB(r,e){var t,i,s,n,a,o,l,c,h,u,d,f,_,b,p=0,g,v,x,w,S,k,C,y,E=new vr.Buf8(4),D,T,M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!r||!r.state||!r.output||!r.input&&r.avail_in!==0)return Ir;t=r.state,t.mode===Di&&(t.mode=fd),a=r.next_out,s=r.output,l=r.avail_out,n=r.next_in,i=r.input,o=r.avail_in,c=t.hold,h=t.bits,u=o,d=l,y=Sn;e:for(;;)switch(t.mode){case kk:if(t.wrap===0){t.mode=fd;break}for(;h<16;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(t.wrap&2&&c===35615){t.check=0,E[0]=c&255,E[1]=c>>>8&255,t.check=ri(t.check,E,2,0),c=0,h=0,t.mode=gb;break}if(t.flags=0,t.head&&(t.head.done=!1),!(t.wrap&1)||(((c&255)<<8)+(c>>8))%31){r.msg="incorrect header check",t.mode=rt;break}if((c&15)!==mb){r.msg="unknown compression method",t.mode=rt;break}if(c>>>=4,h-=4,C=(c&15)+8,t.wbits===0)t.wbits=C;else if(C>t.wbits){r.msg="invalid window size",t.mode=rt;break}t.dmax=1<<C,r.adler=t.check=1,t.mode=c&512?kb:Di,c=0,h=0;break;case gb:for(;h<16;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(t.flags=c,(t.flags&255)!==mb){r.msg="unknown compression method",t.mode=rt;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=rt;break}t.head&&(t.head.text=c>>8&1),t.flags&512&&(E[0]=c&255,E[1]=c>>>8&255,t.check=ri(t.check,E,2,0)),c=0,h=0,t.mode=vb;case vb:for(;h<32;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}t.head&&(t.head.time=c),t.flags&512&&(E[0]=c&255,E[1]=c>>>8&255,E[2]=c>>>16&255,E[3]=c>>>24&255,t.check=ri(t.check,E,4,0)),c=0,h=0,t.mode=bb;case bb:for(;h<16;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}t.head&&(t.head.xflags=c&255,t.head.os=c>>8),t.flags&512&&(E[0]=c&255,E[1]=c>>>8&255,t.check=ri(t.check,E,2,0)),c=0,h=0,t.mode=xb;case xb:if(t.flags&1024){for(;h<16;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}t.length=c,t.head&&(t.head.extra_len=c),t.flags&512&&(E[0]=c&255,E[1]=c>>>8&255,t.check=ri(t.check,E,2,0)),c=0,h=0}else t.head&&(t.head.extra=null);t.mode=_b;case _b:if(t.flags&1024&&(f=t.length,f>o&&(f=o),f&&(t.head&&(C=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Array(t.head.extra_len)),vr.arraySet(t.head.extra,i,n,f,C)),t.flags&512&&(t.check=ri(t.check,i,f,n)),o-=f,n+=f,t.length-=f),t.length))break e;t.length=0,t.mode=yb;case yb:if(t.flags&2048){if(o===0)break e;f=0;do C=i[n+f++],t.head&&C&&t.length<65536&&(t.head.name+=String.fromCharCode(C));while(C&&f<o);if(t.flags&512&&(t.check=ri(t.check,i,f,n)),o-=f,n+=f,C)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=wb;case wb:if(t.flags&4096){if(o===0)break e;f=0;do C=i[n+f++],t.head&&C&&t.length<65536&&(t.head.comment+=String.fromCharCode(C));while(C&&f<o);if(t.flags&512&&(t.check=ri(t.check,i,f,n)),o-=f,n+=f,C)break e}else t.head&&(t.head.comment=null);t.mode=Sb;case Sb:if(t.flags&512){for(;h<16;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(c!==(t.check&65535)){r.msg="header crc mismatch",t.mode=rt;break}c=0,h=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=Di;break;case kb:for(;h<32;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}r.adler=t.check=jb(c),c=0,h=0,t.mode=mh;case mh:if(t.havedict===0)return r.next_out=a,r.avail_out=l,r.next_in=n,r.avail_in=o,t.hold=c,t.bits=h,lB;r.adler=t.check=1,t.mode=Di;case Di:if(e===oB||e===rc)break e;case fd:if(t.last){c>>>=h&7,h-=h&7,t.mode=md;break}for(;h<3;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}switch(t.last=c&1,c>>>=1,h-=1,c&3){case 0:t.mode=Cb;break;case 1:if(vB(t),t.mode=ic,e===rc){c>>>=2,h-=2;break e}break;case 2:t.mode=Ab;break;case 3:r.msg="invalid block type",t.mode=rt}c>>>=2,h-=2;break;case Cb:for(c>>>=h&7,h-=h&7;h<32;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if((c&65535)!==(c>>>16^65535)){r.msg="invalid stored block lengths",t.mode=rt;break}if(t.length=c&65535,c=0,h=0,t.mode=pd,e===rc)break e;case pd:t.mode=Eb;case Eb:if(f=t.length,f){if(f>o&&(f=o),f>l&&(f=l),f===0)break e;vr.arraySet(s,i,n,f,a),o-=f,n+=f,l-=f,a+=f,t.length-=f;break}t.mode=Di;break;case Ab:for(;h<14;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(t.nlen=(c&31)+257,c>>>=5,h-=5,t.ndist=(c&31)+1,c>>>=5,h-=5,t.ncode=(c&15)+4,c>>>=4,h-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=rt;break}t.have=0,t.mode=Tb;case Tb:for(;t.have<t.ncode;){for(;h<3;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}t.lens[M[t.have++]]=c&7,c>>>=3,h-=3}for(;t.have<19;)t.lens[M[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,D={bits:t.lenbits},y=ga(nB,t.lens,0,19,t.lencode,0,t.work,D),t.lenbits=D.bits,y){r.msg="invalid code lengths set",t.mode=rt;break}t.have=0,t.mode=Rb;case Rb:for(;t.have<t.nlen+t.ndist;){for(;p=t.lencode[c&(1<<t.lenbits)-1],g=p>>>24,v=p>>>16&255,x=p&65535,!(g<=h);){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(x<16)c>>>=g,h-=g,t.lens[t.have++]=x;else{if(x===16){for(T=g+2;h<T;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(c>>>=g,h-=g,t.have===0){r.msg="invalid bit length repeat",t.mode=rt;break}C=t.lens[t.have-1],f=3+(c&3),c>>>=2,h-=2}else if(x===17){for(T=g+3;h<T;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}c>>>=g,h-=g,C=0,f=3+(c&7),c>>>=3,h-=3}else{for(T=g+7;h<T;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}c>>>=g,h-=g,C=0,f=11+(c&127),c>>>=7,h-=7}if(t.have+f>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=rt;break}for(;f--;)t.lens[t.have++]=C}}if(t.mode===rt)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=rt;break}if(t.lenbits=9,D={bits:t.lenbits},y=ga(_k,t.lens,0,t.nlen,t.lencode,0,t.work,D),t.lenbits=D.bits,y){r.msg="invalid literal/lengths set",t.mode=rt;break}if(t.distbits=6,t.distcode=t.distdyn,D={bits:t.distbits},y=ga(yk,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,D),t.distbits=D.bits,y){r.msg="invalid distances set",t.mode=rt;break}if(t.mode=ic,e===rc)break e;case ic:t.mode=sc;case sc:if(o>=6&&l>=258){r.next_out=a,r.avail_out=l,r.next_in=n,r.avail_in=o,t.hold=c,t.bits=h,sB(r,d),a=r.next_out,s=r.output,l=r.avail_out,n=r.next_in,i=r.input,o=r.avail_in,c=t.hold,h=t.bits,t.mode===Di&&(t.back=-1);break}for(t.back=0;p=t.lencode[c&(1<<t.lenbits)-1],g=p>>>24,v=p>>>16&255,x=p&65535,!(g<=h);){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(v&&!(v&240)){for(w=g,S=v,k=x;p=t.lencode[k+((c&(1<<w+S)-1)>>w)],g=p>>>24,v=p>>>16&255,x=p&65535,!(w+g<=h);){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}c>>>=w,h-=w,t.back+=w}if(c>>>=g,h-=g,t.back+=g,t.length=x,v===0){t.mode=Nb;break}if(v&32){t.back=-1,t.mode=Di;break}if(v&64){r.msg="invalid literal/length code",t.mode=rt;break}t.extra=v&15,t.mode=Mb;case Mb:if(t.extra){for(T=t.extra;h<T;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}t.length+=c&(1<<t.extra)-1,c>>>=t.extra,h-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=Db;case Db:for(;p=t.distcode[c&(1<<t.distbits)-1],g=p>>>24,v=p>>>16&255,x=p&65535,!(g<=h);){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(!(v&240)){for(w=g,S=v,k=x;p=t.distcode[k+((c&(1<<w+S)-1)>>w)],g=p>>>24,v=p>>>16&255,x=p&65535,!(w+g<=h);){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}c>>>=w,h-=w,t.back+=w}if(c>>>=g,h-=g,t.back+=g,v&64){r.msg="invalid distance code",t.mode=rt;break}t.offset=x,t.extra=v&15,t.mode=Pb;case Pb:if(t.extra){for(T=t.extra;h<T;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}t.offset+=c&(1<<t.extra)-1,c>>>=t.extra,h-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=rt;break}t.mode=Lb;case Lb:if(l===0)break e;if(f=d-l,t.offset>f){if(f=t.offset-f,f>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=rt;break}f>t.wnext?(f-=t.wnext,_=t.wsize-f):_=t.wnext-f,f>t.length&&(f=t.length),b=t.window}else b=s,_=a-t.offset,f=t.length;f>l&&(f=l),l-=f,t.length-=f;do s[a++]=b[_++];while(--f);t.length===0&&(t.mode=sc);break;case Nb:if(l===0)break e;s[a++]=t.length,l--,t.mode=sc;break;case md:if(t.wrap){for(;h<32;){if(o===0)break e;o--,c|=i[n++]<<h,h+=8}if(d-=l,r.total_out+=d,t.total+=d,d&&(r.adler=t.check=t.flags?ri(t.check,s,d,a-d):tp(t.check,s,d,a-d)),d=l,(t.flags?c:jb(c))!==t.check){r.msg="incorrect data check",t.mode=rt;break}c=0,h=0}t.mode=Ob;case Ob:if(t.wrap&&t.flags){for(;h<32;){if(o===0)break e;o--,c+=i[n++]<<h,h+=8}if(c!==(t.total&4294967295)){r.msg="incorrect length check",t.mode=rt;break}c=0,h=0}t.mode=Ib;case Ib:y=aB;break e;case rt:y=wk;break e;case Ck:return Sk;case hB:default:return Ir}return r.next_out=a,r.avail_out=l,r.next_in=n,r.avail_in=o,t.hold=c,t.bits=h,(t.wsize||d!==r.avail_out&&t.mode<rt&&(t.mode<md||e!==pb))&&Mk(r,r.output,r.next_out,d-r.avail_out),u-=r.avail_in,d-=r.avail_out,r.total_in+=u,r.total_out+=d,t.total+=d,t.wrap&&d&&(r.adler=t.check=t.flags?ri(t.check,s,d,r.next_out-d):tp(t.check,s,d,r.next_out-d)),r.data_type=t.bits+(t.last?64:0)+(t.mode===Di?128:0)+(t.mode===ic||t.mode===pd?256:0),(u===0&&d===0||e===pb)&&y===Sn&&(y=cB),y}function xB(r){if(!r||!r.state)return Ir;var e=r.state;return e.window&&(e.window=null),r.state=null,Sn}function _B(r,e){var t;return!r||!r.state||(t=r.state,!(t.wrap&2))?Ir:(t.head=e,e.done=!1,Sn)}function yB(r,e){var t=e.length,i,s,n;return!r||!r.state||(i=r.state,i.wrap!==0&&i.mode!==mh)?Ir:i.mode===mh&&(s=1,s=tp(s,e,t,0),s!==i.check)?wk:(n=Mk(r,e,t,t),n?(i.mode=Ck,Sk):(i.havedict=1,Sn))}Yr.inflateReset=Ak;Yr.inflateReset2=Tk;Yr.inflateResetKeep=Ek;Yr.inflateInit=gB;Yr.inflateInit2=Rk;Yr.inflate=bB;Yr.inflateEnd=xB;Yr.inflateGetHeader=_B;Yr.inflateSetDictionary=yB;Yr.inflateInfo="pako inflate (from Nodeca project)";var Dk={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ER
164ROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function wB(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var SB=wB,ao=Yr,va=Zi,Ec=Pn,ft=Dk,rp=Im,kB=bk,CB=SB,Pk=Object.prototype.toString;function kn(r){if(!(this instanceof kn))return new kn(r);this.options=va.assign({chunkSize:16384,windowBits:0,to:""},r||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new kB,this.strm.avail_out=0;var t=ao.inflateInit2(this.strm,e.windowBits);if(t!==ft.Z_OK)throw new Error(rp[t]);if(this.header=new CB,ao.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Ec.string2buf(e.dictionary):Pk.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=ao.inflateSetDictionary(this.strm,e.dictionary),t!==ft.Z_OK)))throw new Error(rp[t])}kn.prototype.push=function(r,e){var t=this.strm,i=this.options.chunkSize,s=this.options.dictionary,n,a,o,l,c,h=!1;if(this.ended)return!1;a=e===~~e?e:e===!0?ft.Z_FINISH:ft.Z_NO_FLUSH,typeof r=="string"?t.input=Ec.binstring2buf(r):Pk.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;do{if(t.avail_out===0&&(t.output=new va.Buf8(i),t.next_out=0,t.avail_out=i),n=ao.inflate(t,ft.Z_NO_FLUSH),n===ft.Z_NEED_DICT&&s&&(n=ao.inflateSetDictionary(this.strm,s)),n===ft.Z_BUF_ERROR&&h===!0&&(n=ft.Z_OK,h=!1),n!==ft.Z_STREAM_END&&n!==ft.Z_OK)return this.onEnd(n),this.ended=!0,!1;t.next_out&&(t.avail_out===0||n===ft.Z_STREAM_END||t.avail_in===0&&(a===ft.Z_FINISH||a===ft.Z_SYNC_FLUSH))&&(this.options.to==="string"?(o=Ec.utf8border(t.output,t.next_out),l=t.next_out-o,c=Ec.buf2string(t.output,o),t.next_out=l,t.avail_out=i-l,l&&va.arraySet(t.output,t.output,o,l,0),this.onData(c)):this.onData(va.shrinkBuf(t.output,t.next_out))),t.avail_in===0&&t.avail_out===0&&(h=!0)}while((t.avail_in>0||t.avail_out===0)&&n!==ft.Z_STREAM_END);return n===ft.Z_STREAM_END&&(a=ft.Z_FINISH),a===ft.Z_FINISH?(n=ao.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===ft.Z_OK):(a===ft.Z_SYNC_FLUSH&&(this.onEnd(ft.Z_OK),t.avail_out=0),!0)};kn.prototype.onData=function(r){this.chunks.push(r)};kn.prototype.onEnd=function(r){r===ft.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=va.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Bm(r,e){var t=new kn(e);if(t.push(r,!0),t.err)throw t.msg||rp[t.err];return t.result}function EB(r,e){return e=e||{},e.raw=!0,Bm(r,e)}ul.Inflate=kn;ul.inflate=Bm;ul.inflateRaw=EB;ul.ungzip=Bm;var AB=Zi.assign,TB=ll,RB=ul,MB=Dk,Lk={};AB(Lk,TB,RB,MB);var DB=Lk;const Nk=En(DB),Fb=(r,e)=>function(...t){const i=e.promiseModule;return new i((s,n)=>{e.multiArgs?t.push((...a)=>{e.errorFirst?a[0]?n(a):(a.shift(),s(a)):s(a)}):e.errorFirst?t.push((a,o)=>{a?n(a):s(o)}):t.push(s),r.apply(this,t)})};var PB=(r,e)=>{e=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},e);const t=typeof r;if(!(r!==null&&(t==="object"||t==="function")))throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${r===null?"null":t}\``);const i=n=>{const a=o=>typeof o=="string"?n===o:o.test(n);return e.include?e.include.some(a):!e.exclude.some(a)};let s;t==="function"?s=function(...n){return e.excludeMain?r(...n):Fb(r,e).apply(this,n)}:s=Object.create(Object.getPrototypeOf(r));for(const n in r){const a=r[n];s[n]=typeof a=="function"&&i(n)?Fb(a,e):a}return s};const bd=En(PB);var $b={};function Hb(r){return Array.isArray(r)?r:[r]}const ip="",zb=" ",xd="\\",LB=/^\s+$/,NB=/(?:[^\\]|^)\\$/,OB=/^\\!/,IB=/^\\#/,jB=/\r?\n/g,BB=/^\.*\/|^\.+$/,_d="/";let Ok="node-ignore";typeof Symbol<"u"&&(Ok=Symbol.for("node-ignore"));const Wb=Ok,FB=(r,e,t)=>Object.defineProperty(r,e,{value:t}),$B=/([0-z])-([0-z])/g,Ik=()=>!1,HB=r=>r.replace($B,(e,t,i)=>t.charCodeAt(0)<=i.charCodeAt(0)?e:ip),zB=r=>{const{length:e}=r;return r.slice(0,e-e%2)},WB=[[/^\uFEFF/,()=>ip],[/((?:\\\\)*?)(\\?\s+)$/,(r,e,t)=>e+(t.indexOf("\\")===0?zb:ip)],[/(\\+?)\s/g,(r,e)=>{const{length:t}=e;return e.slice(0,t-t%2)+zb}],[/[\\$.|*+(){^]/g,r=>`\\${r}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(r,e,t)=>e+6<t.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(r,e,t)=>{const i=t.replace(/\\\*/g,"[^\\/]*");return e+i}],[/\\\\\\(?=[$.|*+(){^])/g,()=>xd],[/\\\\/g,()=>xd],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(r,e,t,i,s)=>e===xd?`\\[${t}${zB(i)}${s}`:s==="]"&&i.length%2===0?`[${HB(t)}${i}]`:"[]"],[/(?:[^*])$/,r=>/\/$/.test(r)?`${r}$`:`${r}(?=$|\\/$)`],[/(\^|\\\/)?\\\*$/,(r,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`]],Ub=Object.create(null),UB=(r,e)=>{let t=Ub[r];return t||(t=WB.reduce((i,[s,n])=>i.replace(s,n.bind(r)),r),Ub[r]=t),e?new RegExp(t,"i"):new RegExp(t)},Fm=r=>typeof r=="string",VB=r=>r&&Fm(r)&&!LB.test(r)&&!NB.test(r)&&r.indexOf("#")!==0,KB=r=>r.split(jB);class qB{constructor(e,t,i,s){this.origin=e,this.pattern=t,this.negative=i,this.regex=s}}const GB=(r,e)=>{const t=r;let i=!1;r.indexOf("!")===0&&(i=!0,r=r.substr(1)),r=r.replace(OB,"!").replace(IB,"#");const s=UB(r,e);return new qB(t,r,i,s)},XB=(r,e)=>{throw new e(r)},Gi=(r,e,t)=>Fm(r)?r?Gi.isNotRelative(r)?t(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:t("path must not be empty",TypeError):t(`path must be a string, but got \`${e}\``,TypeError),jk=r=>BB.test(r);Gi.isNotRelative=jk;
164Gi.convert=r=>r;class YB{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:i=!1}={}){FB(this,Wb,!0),this._rules=[],this._ignoreCase=t,this._allowRelativePaths=i,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}_addPattern(e){if(e&&e[Wb]){this._rules=this._rules.concat(e._rules),this._added=!0;return}if(VB(e)){const t=GB(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,Hb(Fm(e)?KB(e):e).forEach(this._addPattern,this),this._added&&this._initCache(),this}addPattern(e){return this.add(e)}_testOne(e,t){let i=!1,s=!1;return this._rules.forEach(n=>{const{negative:a}=n;if(s===a&&i!==s||a&&!i&&!s&&!t)return;n.regex.test(e)&&(i=!a,s=a)}),{ignored:i,unignored:s}}_test(e,t,i,s){const n=e&&Gi.convert(e);return Gi(n,e,this._allowRelativePaths?Ik:XB),this._t(n,t,i,s)}_t(e,t,i,s){if(e in t)return t[e];if(s||(s=e.split(_d)),s.pop(),!s.length)return t[e]=this._testOne(e,i);const n=this._t(s.join(_d)+_d,t,i,s);return t[e]=n.ignored?n:this._testOne(e,i)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return Hb(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}}const sp=r=>new YB(r),ZB=r=>Gi(r&&Gi.convert(r),r,Ik);sp.isPathValid=ZB;sp.default=sp;if(typeof qt<"u"&&($b&&$b.IGNORE_TEST_WIN32||qt.platform==="win32")){const r=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");Gi.convert=r;const e=/^[a-z]:\//i;Gi.isNotRelative=t=>e.test(t)||jk(t)}function JB(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ii(r,e,t){return e=e instanceof RegExp?e:new RegExp(JB(e),"g"),r.replace(e,t)}var QB={clean:function(e){if(typeof e!="string")throw new Error("Expected a string, received: "+e);return e=ii(e,"./","/"),e=ii(e,"..","."),e=ii(e," ","-"),e=ii(e,/^[~^:?*\\\-]/g,""),e=ii(e,/[~^:?*\\]/g,"-"),e=ii(e,/[~^:?*\\\-]$/g,""),e=ii(e,"@{","-"),e=ii(e,/\.$/g,""),e=ii(e,/\/$/g,""),e=ii(e,/\.lock$/g,""),e}},e6=QB;const Vb=En(e6);class ze extends Error{constructor(e){super(e),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(e){const t=new ze(e.message);return t.code=e.code,t.data=e.data,t.caller=e.caller,t.stack=e.stack,t}get isIsomorphicGitError(){return!0}}class tu extends ze{constructor(e){super(`Modifying the index is not possible because you have unmerged files: ${e.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`),this.code=this.name=tu.code,this.data={filepaths:e}}}tu.code="UnmergedPathsError";class De extends ze{constructor(e){super(`An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${e}`),this.code=this.name=De.code,this.data={message:e}}}De.code="InternalError";class dl extends ze{constructor(e){super(`The filepath "${e}" contains unsafe character sequences`),this.code=this.name=dl.code,this.data={filepath:e}}}dl.code="UnsafeFilepathError";class di{constructor(e){this.buffer=e,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(e){this._start=e}slice(e){const t=this.buffer.slice(this._start,this._start+e);return this._start+=e,t}toString(e,t){const i=this.buffer.toString(e,this._start,this._start+t);return this._start+=t,i}write(e,t,i){const s=this.buffer.write(e,this._start,t,i);return this._start+=t,s}copy(e,t,i){const s=e.copy(this.buffer,this._start,t,i);return this._start+=s,s}readUInt8(){const e=this.buffer.readUInt8(this._start);return this._start+=1,e}writeUInt8(e){const t=this.buffer.writeUInt8(e,this._start);return this._start+=1,t}readUInt16BE(){const e=this.buffer.readUInt16BE(this._start);return this._start+=2,e}writeUInt16BE(e){const t=this.buffer.writeUInt16BE(e,this._start);return this._start+=2,t}readUInt32BE(){const e=this.buffer.readUInt32BE(this._start);return this._start+=4,e}writeUInt32BE(e){const t=this.buffer.writeUInt32BE(e,this._start);return this._start+=4,t}}function ru(r,e){return-(r<e)||+(r>e)}function Bk(r,e){return ru(r.path,e.path)}function Fk(r){let e=r>0?r>>12:0;e!==4&&e!==8&&e!==10&&e!==14&&(e=8);let t=r&511;return t&73?t=493:t=420,e!==8&&(t=0),(e<<12)+t}const si=2**32;function Kb(r,e,t,i){if(r!==void 0&&e!==void 0)return[r,e];t===void 0&&(t=i.valueOf());const s=Math.floor(t/1e3),n=(t-s*1e3)*1e6;return[s,n]}function bo(r){const[e,t]=Kb(r.ctimeSeconds,r.ctimeNanoseconds,r.ctimeMs,r.ctime),[i,s]=Kb(r.mtimeSeconds,r.mtimeNanoseconds,r.mtimeMs,r.mtime);return{ctimeSeconds:e%si,ctimeNanoseconds:t%si,mtimeSeconds:i%si,mtimeNanoseconds:s%si,dev:r.dev%si,ino:r.ino%si,mode:Fk(r.mode%si),uid:r.uid%si,gid:r.gid%si,size:r.size>-1?r.size%si:0}}function t6(r){let e="";for(const t of new Uint8Array(r))t<16&&(e+="0"),e+=t.toString(16);return e}let yd=null;async function xo(r){return yd===null&&(yd=await i6()),yd?$k(r):r6(r)}function r6(r){return new Bj().update(r).digest("hex")}async function $k(r){const e=await crypto.subtle.digest("SHA-1",r);return t6(e)}async function i6(){try{if(await $k(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709")return!0}catch{}return!1}function s6(r){return{assumeValid:!!(r&32768),extended:!!(r&16384),stage:(r&12288)>>12,nameLength:r&4095}}function n6(r){const e=r.flags;return e.extended=!1,e.nameLength=Math.min(Se.from(r.path).length,4095),(e.assumeValid?32768:0)+(e.extended?16384:0)+((e.stage&3)<<12)+(e.nameLength&4095)}class Us{constructor(e,t){this._dirty=!1,this._unmergedPaths=t||new Set,this._entries=e||new Map}_addEntry(e){if(e.flags.stage===0)e.stages=[e],this._entries.set(e.path,e),this._unmergedPaths.delete(e.path);else{let t=this._entries.get(e.path);t||(this._entries.set(e.path,e),t=e),t.stages[e.flags.stage]=e,this._unmergedPaths.add(e.path)}}static async from(e){if(Se.isBuffer(e))return Us.fromBuffer(e);if(e===null)return new Us(null);throw new De("invalid type passed to GitIndex.from")}static async fromBuffer(e){if(e.length===0)throw new De("Index file is empty (.git/index)");const t=new Us,i=new di(e),s=i.toString("utf8",4);
164if(s!=="DIRC")throw new De(`Invalid dircache magic file number: ${s}`);const n=await xo(e.slice(0,-20)),a=e.slice(-20).toString("hex");if(a!==n)throw new De(`Invalid checksum in GitIndex buffer: expected ${a} but saw ${n}`);const o=i.readUInt32BE();if(o!==2)throw new De(`Unsupported dircache version: ${o}`);const l=i.readUInt32BE();let c=0;for(;!i.eof()&&c<l;){const h={};h.ctimeSeconds=i.readUInt32BE(),h.ctimeNanoseconds=i.readUInt32BE(),h.mtimeSeconds=i.readUInt32BE(),h.mtimeNanoseconds=i.readUInt32BE(),h.dev=i.readUInt32BE(),h.ino=i.readUInt32BE(),h.mode=i.readUInt32BE(),h.uid=i.readUInt32BE(),h.gid=i.readUInt32BE(),h.size=i.readUInt32BE(),h.oid=i.slice(20).toString("hex");const u=i.readUInt16BE();h.flags=s6(u);const d=e.indexOf(0,i.tell()+1)-i.tell();if(d<1)throw new De(`Got a path length of: ${d}`);if(h.path=i.toString("utf8",d),h.path.includes("..\\")||h.path.includes("../"))throw new dl(h.path);let f=8-(i.tell()-12)%8;for(f===0&&(f=8);f--;){const _=i.readUInt8();if(_!==0)throw new De(`Expected 1-8 null characters but got '${_}' after ${h.path}`);if(i.eof())throw new De("Unexpected end of file")}h.stages=[],t._addEntry(h),c++}return t}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(Bk)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(e=>e.stages.length>1?e.stages.filter(t=>t):e)}*[Symbol.iterator](){for(const e of this.entries)yield e}insert({filepath:e,stats:t,oid:i,stage:s=0}){t||(t={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0}),t=bo(t);const n=Se.from(e),a={ctimeSeconds:t.ctimeSeconds,ctimeNanoseconds:t.ctimeNanoseconds,mtimeSeconds:t.mtimeSeconds,mtimeNanoseconds:t.mtimeNanoseconds,dev:t.dev,ino:t.ino,mode:t.mode||33188,uid:t.uid,gid:t.gid,size:t.size,path:e,oid:i,flags:{assumeValid:!1,extended:!1,stage:s,nameLength:n.length<4095?n.length:4095},stages:[]};this._addEntry(a),this._dirty=!0}delete({filepath:e}){if(this._entries.has(e))this._entries.delete(e);else for(const t of this._entries.keys())t.startsWith(e+"/")&&this._entries.delete(t);this._unmergedPaths.has(e)&&this._unmergedPaths.delete(e),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:e}){return this._entries.has(e)}render(){return this.entries.map(e=>`${e.mode.toString(8)} ${e.oid} ${e.path}`).join(` 165`)}static async _entryToBuffer(e){const t=Se.from(e.path),i=Math.ceil((62+t.length+1)/8)*8,s=Se.alloc(i),n=new di(s),a=bo(e);return n.writeUInt32BE(a.ctimeSeconds),n.writeUInt32BE(a.ctimeNanoseconds),n.writeUInt32BE(a.mtimeSeconds),n.writeUInt32BE(a.mtimeNanoseconds),n.writeUInt32BE(a.dev),n.writeUInt32BE(a.ino),n.writeUInt32BE(a.mode),n.writeUInt32BE(a.uid),n.writeUInt32BE(a.gid),n.writeUInt32BE(a.size),n.write(e.oid,20,"hex"),n.writeUInt16BE(n6(e)),n.write(e.path,t.length,"utf8"),s}async toObject(){const e=Se.alloc(12),t=new di(e);t.write("DIRC",4,"utf8"),t.writeUInt32BE(2),t.writeUInt32BE(this.entriesFlat.length);let i=[];for(const o of this.entries)if(i.push(Us._entryToBuffer(o)),o.stages.length>1)for(const l of o.stages)l&&l!==o&&i.push(Us._entryToBuffer(l));i=await Promise.all(i);const s=Se.concat(i),n=Se.concat([e,s]),a=await xo(n);return Se.concat([n,Se.from(a,"hex")])}}function np(r,e,t=!0,i=!0){const s=bo(r),n=bo(e);return t&&s.mode!==n.mode||s.mtimeSeconds!==n.mtimeSeconds||s.ctimeSeconds!==n.ctimeSeconds||s.uid!==n.uid||s.gid!==n.gid||i&&s.ino!==n.ino||s.size!==n.size}let wd=null;const zn=Symbol("IndexCache");function o6(){return{map:new Map,stats:new Map}}async function a6(r,e,t){const i=await r.lstat(e),s=await r.read(e),n=await Us.from(s);t.map.set(e,n),t.stats.set(e,i)}async function l6(r,e,t){const i=t.stats.get(e);if(i===void 0)return!0;const s=await r.lstat(e);return i===null||s===null?!1:np(i,s)}class ba{static async acquire({fs:e,gitdir:t,cache:i,allowUnmerged:s=!0},n){i[zn]||(i[zn]=o6());const a=`${t}/index`;wd===null&&(wd=new fh({maxPending:1/0}));let o,l=[];return await wd.acquire(a,async()=>{await l6(e,a,i[zn])&&await a6(e,a,i[zn]);const c=i[zn].map.get(a);if(l=c.unmergedPaths,l.length&&!s)throw new tu(l);
165if(o=await n(c),c._dirty){const h=await c.toObject();await e.write(a,h),i[zn].stats.set(a,await e.lstat(a)),c._dirty=!1}}),o}}function qb(r){const e=Math.max(r.lastIndexOf("/"),r.lastIndexOf("\\"));return e>-1&&(r=r.slice(e+1)),r}function gh(r){const e=Math.max(r.lastIndexOf("/"),r.lastIndexOf("\\"));return e===-1?".":e===0?"/":r.slice(0,e)}function c6(r){const e=new Map,t=function(s){if(!e.has(s)){const n={type:"tree",fullpath:s,basename:qb(s),metadata:{},children:[]};e.set(s,n),n.parent=t(gh(s)),n.parent&&n.parent!==n&&n.parent.children.push(n)}return e.get(s)},i=function(s,n){if(!e.has(s)){const a={type:"blob",fullpath:s,basename:qb(s),metadata:n,parent:t(gh(s)),children:[]};a.parent&&a.parent.children.push(a),e.set(s,a)}return e.get(s)};t(".");for(const s of r)i(s.path,s);return e}function h6(r){switch(r){case 16384:return"tree";case 33188:return"blob";case 33261:return"blob";case 40960:return"blob";case 57344:return"commit"}throw new De(`Unexpected GitTree entry mode: ${r.toString(8)}`)}class u6{constructor({fs:e,gitdir:t,cache:i}){this.treePromise=ba.acquire({fs:e,gitdir:t,cache:i},async function(n){return c6(n.entries)});const s=this;this.ConstructEntry=class{constructor(a){this._fullpath=a,this._type=!1,this._mode=!1,this._stat=!1,this._oid=!1}async type(){return s.type(this)}async mode(){return s.mode(this)}async stat(){return s.stat(this)}async content(){return s.content(this)}async oid(){return s.oid(this)}}}async readdir(e){const t=e._fullpath,s=(await this.treePromise).get(t);if(!s||s.type==="blob")return null;if(s.type!=="tree")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);const n=s.children.map(a=>a.fullpath);return n.sort(ru),n}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){const i=(await this.treePromise).get(e._fullpath);if(!i)throw new Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);const s=i.type==="tree"?{}:bo(i.metadata);e._type=i.type==="tree"?"tree":h6(s.mode),e._mode=s.mode,i.type==="tree"?e._stat=void 0:e._stat=s}return e._stat}async content(e){}async oid(e){if(e._oid===!1){const i=(await this.treePromise).get(e._fullpath);e._oid=i.metadata.oid}return e._oid}}const iu=Symbol("GitWalkSymbol");function d6(){const r=Object.create(null);return Object.defineProperty(r,iu,{value:function({fs:e,gitdir:t,cache:i}){return new u6({fs:e,gitdir:t,cache:i})}}),Object.freeze(r),r}class vi extends ze{constructor(e){super(`Could not find ${e}.`),this.code=this.name=vi.code,this.data={what:e}}}vi.code="NotFoundError";class fl extends ze{constructor(e,t,i,s){super(`Object ${e} ${s?`at ${s}`:""}was anticipated to be a ${i} but it is a ${t}.`),this.code=this.name=fl.code,this.data={oid:e,actual:t,expected:i,filepath:s}}}fl.code="ObjectTypeError";class Cn extends ze{constructor(e){super(`Expected a 40-char hex object id but saw "${e}".`),this.code=this.name=Cn.code,this.data={value:e}}}Cn.code="InvalidOidError";class su extends ze{constructor(e){super(`Could not find a fetch refspec for remote "${e}". Make sure the config file has an entry like the following: 166[remote "${e}"] 167 fetch = +refs/heads/*:refs/remotes/origin/* 168`),this.code=this.name=su.code,this.data={remote:e}}}su.code="NoRefspecError";class vh{constructor(e){if(this.refs=new Map,this.parsedConfig=[],e){let t=null;this.parsedConfig=e.trim().split(` 169`).map(i=>{if(/^\s*#/.test(i))return{line:i,comment:!0};const s=i.indexOf(" ");if(i.startsWith("^")){const n=i.slice(1);return this.refs.set(t+"^{}",n),{line:i,ref:t,peeled:n}}else{const n=i.slice(0,s);return t=i.slice(s+1),this.refs.set(t,n),{line:i,ref:t,oid:n}}})}return this}static from(e){return new vh(e)}delete(e){this.parsedConfig=this.parsedConfig.filter(t=>t.ref!==e),this.refs.delete(e)}toString(){return this.parsedConfig.map(({line:e})=>e).join(` 170`)+` 171`}}class bh{constructor({remotePath:e,localPath:t,force:i,matchPrefix:s}){Object.assign(this,{remotePath:e,localPath:t,force:i,matchPrefix:s})}static from(e){const[t,i,s,n,a]=e.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),o=t==="+",l=s==="*";if(l!==(a==="*"))throw new De("Invalid refspec");return new bh({remotePath:i,localPath:n,force:o,matchPrefix:l})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,"")}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,"")}else if(e===this.localPath)return this.remotePath;return null}}class $m{constructor(e=[]){this.rules=e}static from(e){const t=[];for(const i of e)t.push(bh.from(i));return new $m(t)}add(e){const t=bh.from(e);this.rules.push(t)}translate(e){const t=[];for(const i of this.rules)for(const s of e){const n=i.translate(s);
171n&&t.push([s,n])}return t}translateOne(e){let t=null;for(const i of this.rules){const s=i.translate(e);s&&(t=s)}return t}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,""))}}function f6(r,e){const t=r.replace(/\^\{\}$/,""),i=e.replace(/\^\{\}$/,""),s=-(t<i)||+(t>i);return s===0?r.endsWith("^{}")?1:-1:s}const p6=r=>{r=r.toLowerCase();let e=parseInt(r);return r.endsWith("k")&&(e*=1024),r.endsWith("m")&&(e*=1024*1024),r.endsWith("g")&&(e*=1024*1024*1024),e},Xo=r=>{if(r=r.trim().toLowerCase(),r==="true"||r==="yes"||r==="on")return!0;if(r==="false"||r==="no"||r==="off")return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${r}`)},Gb={core:{filemode:Xo,bare:Xo,logallrefupdates:Xo,symlinks:Xo,ignorecase:Xo,bigFileThreshold:p6}},m6=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,g6=/^[A-Za-z0-9-.]+$/,v6=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,b6=/^[A-Za-z][A-Za-z-]*$/,x6=/^(.*?)( *[#;].*)$/,_6=r=>{const e=m6.exec(r);if(e!=null){const[t,i]=e.slice(1);return[t,i]}return null},y6=r=>{const e=v6.exec(r);if(e!=null){const[t,i="true"]=e.slice(1),s=w6(i),n=S6(s);return[t,n]}return null},w6=r=>{const e=x6.exec(r);if(e==null)return r;const[t,i]=e.slice(1);return Xb(t)&&Xb(i)?`${t}${i}`:t},Xb=r=>(r.match(/(?:^|[^\\])"/g)||[]).length%2!==0,S6=r=>r.split("").reduce((e,t,i,s)=>{const n=t==='"'&&s[i-1]!=="\\",a=t==="\\"&&s[i+1]==='"';return n||a?e:e+t},""),Yb=r=>r!=null?r.toLowerCase():null,op=(r,e,t)=>[Yb(r),e,Yb(t)].filter(i=>i!=null).join("."),Zb=r=>{const e=r.split("."),t=e.shift(),i=e.pop(),s=e.length?e.join("."):void 0;return{section:t,subsection:s,name:i,path:op(t,s,i),sectionPath:op(t,s,null)}},k6=(r,e)=>r.reduce((t,i,s)=>e(i)?s:t,-1);class Hm{constructor(e){let t=null,i=null;this.parsedConfig=e?e.split(` 172`).map(s=>{let n=null,a=null;const o=s.trim(),l=_6(o),c=l!=null;if(c)[t,i]=l;else{const u=y6(o);u!=null&&([n,a]=u)}const h=op(t,i,n);return{line:s,isSection:c,section:t,subsection:i,name:n,value:a,path:h}}):[]}static from(e){return new Hm(e)}async get(e,t=!1){const i=Zb(e).path,s=this.parsedConfig.filter(n=>n.path===i).map(({section:n,name:a,value:o})=>{const l=Gb[n]&&Gb[n][a];return l?l(o):o});return t?s:s.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(t=>t.section===e&&t.isSection).map(t=>t.subsection)}async deleteSection(e,t){this.parsedConfig=this.parsedConfig.filter(i=>!(i.section===e&&i.subsection===t))}async append(e,t){return this.set(e,t,!0)}async set(e,t,i=!1){const{section:s,subsection:n,name:a,path:o,sectionPath:l}=Zb(e),c=k6(this.parsedConfig,h=>h.path===o);if(t==null)c!==-1&&this.parsedConfig.splice(c,1);else if(c!==-1){const h=this.parsedConfig[c],u=Object.assign({},h,{name:a,value:t,modified:!0});i?this.parsedConfig.splice(c+1,0,u):this.parsedConfig[c]=u}else{const h=this.parsedConfig.findIndex(d=>d.path===l),u={section:s,subsection:n,name:a,value:t,modified:!0,path:o};if(g6.test(s)&&b6.test(a))if(h>=0)this.parsedConfig.splice(h+1,0,u);else{const d={section:s,subsection:n,modified:!0,path:l};this.parsedConfig.push(d,u)}}}toString(){return this.parsedConfig.map(({line:e,section:t,subsection:i,name:s,value:n,modified:a=!1})=>a?s!=null&&n!=null?typeof n=="string"&&/[#;]/.test(n)?` ${s} = "${n}"`:` ${s} = ${n}`:i!=null?`[${t} "${i}"]`:`[${t}]`:e).join(` 173`)}}class _i{static async get({fs:e,gitdir:t}){const i=await e.read(`${t}/config`,{encoding:"utf8"});return Hm.from(i)}static async save({fs:e,gitdir:t,config:i}){await e.write(`${t}/config`,i.toString(),{encoding:"utf8"})}}const nc=r=>[`${r}`,`refs/${r}`,`refs/tags/${r}`,`refs/heads/${r}`,`refs/remotes/${r}`,`refs/remotes/${r}/HEAD`],C6=["config","description","index","shallow","commondir"];let Sd;async function is(r,e){return Sd===void 0&&(Sd=new fh),Sd.acquire(r,e)}class Ie{static async updateRemoteRefs({fs:e,gitdir:t,remote:i,refs:s,symrefs:n,tags:a,refspecs:o=void 0,prune:l=!1,pruneTags:c=!1}){for(const p of s.values())if(!p.match(/[0-9a-f]{40}/))throw new Cn(p);const h=await _i.get({fs:e,gitdir:t});if(!o){if(o=await h.getall(`remote.${i}.fetch`),o.length===0)throw new su(i);o.unshift(`+HEAD:refs/remotes/${i}/HEAD`)}const u=$m.from(o),d=new Map;if(c){const p=await Ie.listRefs({fs:e,gitdir:t,filepath:"refs/tags"});await Ie.deleteRefs({fs:e,gitdir:t,refs:p.map(g=>`refs/tags/${g}`)})}if(a){for(const p of s.keys())if(p.startsWith("refs/tags")&&!p.endsWith("^{}")&&!await Ie.exists({fs:e,gitdir:t,ref:p})){const g=s.get(p);d.set(p,g)}}const f=u.translate([...s.keys()]);for(const[p,g]of f){const v=s.get(p);d.set(g,v)}const _=u.translate([...n.keys()]);for(const[p,g]of _){const v=n.get(p),x=u.translateOne(v);x&&d.set(g,`ref: ${x}`)}const b=[];if(l){for(const p of u.localNamespaces()){const g=(await Ie.listRefs({fs:e,gitdir:t,filepath:p})).map(v=>`${p}/${v}`);for(const v of g)d.has(v)||b.push(v)}b.length>0&&await Ie.deleteRefs({fs:e,gitdir:t,refs:b})}for(const[p,g]of d)await is(p,async()=>e.write(Ht.join(t,p),`${g.trim()} 174`,"utf8"));return{pruned:b}}static async writeRef({fs:e,gitdir:t,ref:i,value:s}){if(!s.match(/[0-9a-f]{40}/))throw new Cn(s);await is(i,async()=>e.write(Ht.join(t,i),`${s.trim()} 175`,"utf8"))}static async writeSymbolicRef({fs:e,gitdir:t,ref:i,value:s}){await is(i,async()=>e.write(Ht.join(t,i),`ref: ${s.trim()} 176`,"utf8"))}static async deleteRef({fs:e,gitdir:t,ref:i}){return Ie.deleteRefs({fs:e,gitdir:t,refs:[i]})}static async deleteRefs({fs:e,gitdir:t,refs:i}){await Promise.all(i.map(o=>e.rm(Ht.join(t,o))));let s=await is("packed-refs",async()=>e.read(`${t}/packed-refs`,{encoding:"utf8"}));const n=vh.from(s),a=n.refs.size;
176for(const o of i)n.refs.has(o)&&n.delete(o);n.refs.size<a&&(s=n.toString(),await is("packed-refs",async()=>e.write(`${t}/packed-refs`,s,{encoding:"utf8"})))}static async resolve({fs:e,gitdir:t,ref:i,depth:s=void 0}){if(s!==void 0&&(s--,s===-1))return i;if(i.startsWith("ref: "))return i=i.slice(5),Ie.resolve({fs:e,gitdir:t,ref:i,depth:s});if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;const n=await Ie.packedRefs({fs:e,gitdir:t}),a=nc(i).filter(o=>!C6.includes(o));for(const o of a){const l=await is(o,async()=>await e.read(`${t}/${o}`,{encoding:"utf8"})||n.get(o));if(l)return Ie.resolve({fs:e,gitdir:t,ref:l.trim(),depth:s})}throw new vi(i)}static async exists({fs:e,gitdir:t,ref:i}){try{return await Ie.expand({fs:e,gitdir:t,ref:i}),!0}catch{return!1}}static async expand({fs:e,gitdir:t,ref:i}){if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;const s=await Ie.packedRefs({fs:e,gitdir:t}),n=nc(i);for(const a of n)if(await is(a,async()=>e.exists(`${t}/${a}`))||s.has(a))return a;throw new vi(i)}static async expandAgainstMap({ref:e,map:t}){const i=nc(e);for(const s of i)if(await t.has(s))return s;throw new vi(e)}static resolveAgainstMap({ref:e,fullref:t=e,depth:i=void 0,map:s}){if(i!==void 0&&(i--,i===-1))return{fullref:t,oid:e};if(e.startsWith("ref: "))return e=e.slice(5),Ie.resolveAgainstMap({ref:e,fullref:t,depth:i,map:s});if(e.length===40&&/[0-9a-f]{40}/.test(e))return{fullref:t,oid:e};const n=nc(e);for(const a of n){const o=s.get(a);if(o)return Ie.resolveAgainstMap({ref:o.trim(),fullref:a,depth:i,map:s})}throw new vi(e)}static async packedRefs({fs:e,gitdir:t}){const i=await is("packed-refs",async()=>e.read(`${t}/packed-refs`,{encoding:"utf8"}));return vh.from(i).refs}static async listRefs({fs:e,gitdir:t,filepath:i}){const s=Ie.packedRefs({fs:e,gitdir:t});let n=null;try{n=await e.readdirDeep(`${t}/${i}`),n=n.map(a=>a.replace(`${t}/${i}/`,""))}catch{n=[]}for(let a of(await s).keys())a.startsWith(i)&&(a=a.replace(i+"/",""),n.includes(a)||n.push(a));return n.sort(f6),n}static async listBranches({fs:e,gitdir:t,remote:i}){return i?Ie.listRefs({fs:e,gitdir:t,filepath:`refs/remotes/${i}`}):Ie.listRefs({fs:e,gitdir:t,filepath:"refs/heads"})}static async listTags({fs:e,gitdir:t}){return(await Ie.listRefs({fs:e,gitdir:t,filepath:"refs/tags"})).filter(s=>!s.endsWith("^{}"))}}function E6(r,e){return ru(Jb(r),Jb(e))}function Jb(r){return r.mode==="040000"?r.path+"/":r.path}function Hk(r){switch(r){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new De(`Unexpected GitTree entry mode: ${r}`)}function A6(r){const e=[];let t=0;for(;t<r.length;){const i=r.indexOf(32,t);if(i===-1)throw new De(`GitTree: Error parsing buffer at byte location ${t}: Could not find the next space character.`);const s=r.indexOf(0,t);if(s===-1)throw new De(`GitTree: Error parsing buffer at byte location ${t}: Could not find the next null character.`);let n=r.slice(t,i).toString("utf8");n==="40000"&&(n="040000");const a=Hk(n),o=r.slice(i+1,s).toString("utf8");if(o.includes("\\")||o.includes("/"))throw new dl(o);const l=r.slice(s+1,s+21).toString("hex");t=s+21,e.push({mode:n,path:o,oid:l,type:a})}return e}function T6(r){if(typeof r=="number"&&(r=r.toString(8)),r.match(/^0?4.*/))return"040000";if(r.match(/^1006.*/))return"100644";if(r.match(/^1007.*/))return"100755";if(r.match(/^120.*/))return"120000";if(r.match(/^160.*/))return"160000";throw new De(`Could not understand file mode: ${r}`)}function R6(r){return!r.oid&&r.sha&&(r.oid=r.sha),r.mode=T6(r.mode),r.type||(r.type=Hk(r.mode)),r}class Ka{constructor(e){if(Se.isBuffer(e))this._entries=A6(e);else if(Array.isArray(e))this._entries=e.map(R6);else throw new De("invalid type passed to GitTree constructor");this._entries.sort(Bk)}static from(e){return new Ka(e)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(` 177`)}toObject(){const e=[...this._entries];return e.sort(E6),Se.concat(e.map(t=>{const i=Se.from(t.mode.replace(/^0/,"")),s=Se.from(" "),n=Se.from(t.path,"utf8"),a=Se.from([0]),o=Se.from(t.oid,"hex");return Se.concat([i,s,n,a,o])}))}entries(){return this._entries}*[Symbol.iterator](){for(const e of this._entries)yield e}}class zm{static wrap({type:e,object:t}){return Se.concat([Se.from(`${e} ${t.byteLength.toString()}\0`),Se.from(t)])}static unwrap(e){const t=e.indexOf(32),i=e.indexOf(0),s=e.slice(0,t).toString("utf8"),n=e.slice(t+1,i).toString("utf8"),a=e.length-(i+1);if(parseInt(n)!==a)throw new De(`Length mismatch: expected ${n} bytes but got ${a} instead.`);return{type:s,object:Se.from(e.slice(i+1))}}}async function M6({fs:r,gitdir:e,oid:t}){const i=`objects/${t.slice(0,2)}/${t.slice(2)}`,s=await r.read(`${e}/${i}`);return s?{object:s,format:"deflated",source:i}:null}function D6(r,e){const t=new di(r),i=Qb(t);if(i!==e.byteLength)throw new De(`applyDelta expected source buffer to be ${i} bytes but the provided buffer was ${e.length} bytes`);const s=Qb(t);let n;const a=tx(t,e);if(a.byteLength===s)n=a;else{n=Se.alloc(s);const o=new di(n);for(o.copy(a);!t.eof();)o.copy(tx(t,e));const l=o.tell();if(s!==l)throw new De(`applyDelta expected target buffer to be ${s} bytes but the resulting buffer was ${l} bytes`)}return n}function Qb(r){let e=0,t=0,i=null;do i=r.readUInt8(),e|=(i&127)<<t,t+=7;while(i&128);return e}function ex(r,e,t){let i=0,s=0;for(;t--;)e&1&&(i|=r.readUInt8()<<s),e>>=1,s+=8;return i}function tx(r,e){const t=r.readUInt8(),i=128,s=15,n=112;if(t&i){const a=ex(r,t&s,4);let o=ex(r,(t&n)>>4,3);return o===0&&(o=65536),e.slice(a,a+o)}else return r.slice(t)}function P6(r){let e=[r];return{next(){return Promise.resolve({done:e.length===0,value:e.pop()})},return(){return e=[],{}},[Symbol.asyncIterator](){return this}}}function zk(r){return r[Symbol.asyncIterator]?r[Symbol.asyncIterator]():r[Symbol.iterator]?r[Symbol.iterator]():r.next?r:P6(r)}class Wk{constructor(e){if(typeof Se>"u")throw new Error("Missing Buffer dependency");this.stream=zk(e),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:t}=await this.stream.next();return e&&(this._ended=!0,!t)?Se.alloc(0):(t&&(t=Se.from(t)),t)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;const t=[this.buffer];for(;this.cursor+e>L6(t);){const i=await this._next();if(this._ended)break;t.push(i)}this.buffer=Se.concat(t)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}}function L6(r){return r.reduce((e,t)=>
177e+t.length,0)}async function N6(r,e){const t=new Wk(r);let i=await t.read(4);if(i=i.toString("utf8"),i!=="PACK")throw new De(`Invalid PACK header '${i}'`);let s=await t.read(4);if(s=s.readUInt32BE(0),s!==2)throw new De(`Invalid packfile version: ${s}`);let n=await t.read(4);if(n=n.readUInt32BE(0),!(n<1))for(;!t.eof()&&n--;){const a=t.tell(),{type:o,length:l,ofs:c,reference:h}=await O6(t),u=new Nk.Inflate;for(;!u.result;){const d=await t.chunk();if(!d)break;if(u.push(d,!1),u.err)throw new De(`Pako error: ${u.msg}`);if(u.result){if(u.result.length!==l)throw new De("Inflated object size is different from that stated in packfile.");await t.undo(),await t.read(d.length-u.strm.avail_in);const f=t.tell();await e({data:u.result,type:o,num:n,offset:a,end:f,reference:h,ofs:c})}}}}async function O6(r){let e=await r.byte();const t=e>>4&7;let i=e&15;if(e&128){let a=4;do e=await r.byte(),i|=(e&127)<<a,a+=7;while(e&128)}let s,n;if(t===6){let a=0;s=0;const o=[];do e=await r.byte(),s|=(e&127)<<a,a+=7,o.push(e);while(e&128);n=Se.from(o)}return t===7&&(n=await r.read(20)),{type:t,length:i,ofs:s,reference:n}}async function Uk(r){return Nk.inflate(r)}function I6(r){const e=[];let t=0,i=0;do{t=r.readUInt8();const s=t&127;e.push(s),i=t&128}while(i);return e.reduce((s,n)=>s+1<<7|n,-1)}function j6(r,e){let t=e,i=4,s=null;do s=r.readUInt8(),t|=(s&127)<<i,i+=7;while(s&128);return t}class qa{constructor(e){Object.assign(this,e),this.offsetCache={}}static async fromIdx({idx:e,getExternalRefDelta:t}){const i=new di(e);if(i.slice(4).toString("hex")!=="ff744f63")return;const n=i.readUInt32BE();if(n!==2)throw new De(`Unable to read version ${n} packfile IDX. (Only version 2 supported)`);if(e.byteLength>2048*1024*1024)throw new De("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");i.seek(i.tell()+4*255);const a=i.readUInt32BE(),o=[];for(let h=0;h<a;h++){const u=i.slice(20).toString("hex");o[h]=u}i.seek(i.tell()+4*a);const l=new Map;for(let h=0;h<a;h++)l.set(o[h],i.readUInt32BE());const c=i.slice(20).toString("hex");return new qa({hashes:o,crcs:{},offsets:l,packfileSha:c,getExternalRefDelta:t})}static async fromPack({pack:e,getExternalRefDelta:t,onProgress:i}){const s={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},n={},a=e.slice(-20).toString("hex"),o=[],l={},c=new Map;let h=null,u=null;await N6([e],async({data:p,type:g,reference:v,offset:x,num:w})=>{h===null&&(h=w);const S=Math.floor((h-w)*100/h);S!==u&&i&&await i({phase:"Receiving objects",loaded:h-w,total:h}),u=S,g=s[g],["commit","tree","blob","tag"].includes(g)?n[x]={type:g,offset:x}:g==="ofs-delta"?n[x]={type:g,offset:x}:g==="ref-delta"&&(n[x]={type:g,offset:x})});const d=Object.keys(n).map(Number);for(const[p,g]of d.entries()){const v=p+1===d.length?e.byteLength-20:d[p+1],x=n[g],w=Fj.buf(e.slice(g,v))>>>0;x.end=v,x.crc=w}const f=new qa({pack:Promise.resolve(e),packfileSha:a,crcs:l,hashes:o,offsets:c,getExternalRefDelta:t});u=null;let _=0;const b=[0,0,0,0,0,0,0,0,0,0,0,0];for(let p in n){p=Number(p);const g=Math.floor(_*100/h);g!==u&&i&&await i({phase:"Resolving deltas",loaded:_,total:h}),_++,u=g;const v=n[p];if(!v.oid)try{f.readDepth=0,f.externalReadDepth=0;const{type:x,object:w}=await f.readSlice({start:p});b[f.readDepth]+=1;const S=await xo(zm.wrap({type:x,object:w}));v.oid=S,o.push(S),c.set(S,p),l[S]=v.crc}catch{continue}}return o.sort(),f}async toBuffer(){const e=[],t=(c,h)=>{e.push(Se.from(c,h))};t("ff744f63","hex"),t("00000002","hex");const i=new di(Se.alloc(256*4));for(let c=0;c<256;c++){let h=0;for(const u of this.hashes)parseInt(u.slice(0,2),16)<=c&&h++;i.writeUInt32BE(h)}e.push(i.buffer);for(const c of this.hashes)t(c,"hex");const s=new di(Se.alloc(this.hashes.length*4));for(const c of this.hashes)s.writeUInt32BE(this.crcs[c]);e.push(s.buffer);const n=new di(Se.alloc(this.hashes.length*4));for(const c of this.hashes)n.writeUInt32BE(this.offsets.get(c));e.push(n.buffer),t(this.packfileSha,"hex");const a=Se.concat(e),o=await xo(a),l=Se.alloc(20);return l.write(o,"hex"),Se.concat([a,l])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new De(`Could not read object ${e} from packfile`)}const t=this.offsets.get(e);return this.readSlice({start:t})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;const t={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"};if(!this.pack)throw new De("Tried to read from a GitPackIndex with
177no packfile loaded into memory");const i=(await this.pack).slice(e),s=new di(i),n=s.readUInt8(),a=n&112;let o=t[a];if(o===void 0)throw new De("Unrecognized type: 0b"+a.toString(2));const l=n&15;let c=l;n&128&&(c=j6(s,l));let u=null,d=null;if(o==="ofs_delta"){const _=I6(s),b=e-_;({object:u,type:o}=await this.readSlice({start:b}))}if(o==="ref_delta"){const _=s.slice(20).toString("hex");({object:u,type:o}=await this.read({oid:_}))}const f=i.slice(s.tell());if(d=Se.from(await Uk(f)),d.byteLength!==c)throw new De(`Packfile told us object would have length ${c} but it had length ${d.byteLength}`);return u&&(d=Se.from(D6(d,u))),this.readDepth>3&&(this.offsetCache[e]={type:o,object:d}),{type:o,format:"content",object:d}}}const oc=Symbol("PackfileCache");async function B6({fs:r,filename:e,getExternalRefDelta:t,emitter:i,emitterPrefix:s}){const n=await r.read(e);return qa.fromIdx({idx:n,getExternalRefDelta:t})}function Vk({fs:r,cache:e,filename:t,getExternalRefDelta:i,emitter:s,emitterPrefix:n}){e[oc]||(e[oc]=new Map);let a=e[oc].get(t);return a||(a=B6({fs:r,filename:t,getExternalRefDelta:i,emitter:s,emitterPrefix:n}),e[oc].set(t,a)),a}async function F6({fs:r,cache:e,gitdir:t,oid:i,format:s="content",getExternalRefDelta:n}){let a=await r.readdir(Ht.join(t,"objects/pack"));a=a.filter(o=>o.endsWith(".idx"));for(const o of a){const l=`${t}/objects/pack/${o}`,c=await Vk({fs:r,cache:e,filename:l,getExternalRefDelta:n});if(c.error)throw new De(c.error);if(c.offsets.has(i)){if(!c.pack){const u=l.replace(/idx$/,"pack");c.pack=r.read(u)}const h=await c.read({oid:i,getExternalRefDelta:n});return h.format="content",h.source=`objects/pack/${o.replace(/idx$/,"pack")}`,h}}return null}async function Rs({fs:r,cache:e,gitdir:t,oid:i,format:s="content"}){const n=h=>Rs({fs:r,cache:e,gitdir:t,oid:h});let a;if(i==="4b825dc642cb6eb9a060e54bf8d69288fbee4904"&&(a={format:"wrapped",object:Se.from("tree 0\0")}),a||(a=await M6({fs:r,gitdir:t,oid:i})),!a){if(a=await F6({fs:r,cache:e,gitdir:t,oid:i,getExternalRefDelta:n}),!a)throw new vi(i);return a}if(s==="deflated"||(a.format==="deflated"&&(a.object=Se.from(await Uk(a.object)),a.format="wrapped"),s==="wrapped"))return a;const o=await xo(a.object);if(o!==i)throw new De(`SHA check failed! Expected ${i}, computed ${o}`);const{object:l,type:c}=zm.unwrap(a.object);if(a.type=c,a.object=l,a.format="content",s==="content")return a;throw new De(`invalid requested format "${s}"`)}class nu extends ze{constructor(e,t,i=!0){super(`Failed to create ${e} at ${t} because it already exists.${i?` (Hint: use 'force: true' parameter to overwrite existing ${e}.)`:""}`),this.code=this.name=nu.code,this.data={noun:e,where:t,canForce:i}}}nu.code="AlreadyExistsError";class Wm extends ze{constructor(e,t,i){super(`Found multiple ${e} matching "${t}" (${i.join(", ")}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=Wm.code,this.data={nouns:e,short:t,matches:i}}}Wm.code="AmbiguousError";class ou extends ze{constructor(e){super(`Your local changes to the following files would be overwritten by checkout: ${e.join(", ")}`),this.code=this.name=ou.code,this.data={filepaths:e}}}ou.code="CheckoutConflictError";class au extends ze{constructor(e,t){super(`Failed to checkout "${e}" because commit ${t} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=au.code,this.data={ref:e,oid:t}}}au.code="CommitNotFetchedError";class lu extends ze{constructor(){super("Empty response from git server."),this.code=this.name=lu.code,this.data={}}}lu.code="EmptyServerResponseError";class Um extends ze{constructor(){super("A simple fast-forward merge was not possible."),this.code=this.name=Um.code,this.data={}}}Um.code="FastForwardError";class Vm extends ze{constructor(e,t){super(`One or more branches were not updated: ${e}`),this.code=this.name=Vm.code,this.data={prettyDetails:e,result:t}}}Vm.code="GitPushError";class Ga extends ze{constructor(e,t,i){super(`HTTP Error: ${e} ${t}`),this.code=this.name=Ga.code,this.data={statusCode:e,statusMessage:t,response:i}}}Ga.code="HttpError";class Km extends ze{constructor(e){let t="invalid filepath";e==="leading-slash"||e==="trailing-slash"?t='"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.':e==="directory"&&(t='"filepath" should not be a directory.'),super(t),this.code=this.name=Km.code,this.data={reason:e}}}Km.code="InvalidFilepathError";class cu extends ze{constructor(e,t){super(`"${e}
177" would be an invalid git reference. (Hint: a valid alternative would be "${t}".)`),this.code=this.name=cu.code,this.data={ref:e,suggestion:t}}}cu.code="InvalidRefNameError";class qm extends ze{constructor(e){super(`Maximum search depth of ${e} exceeded.`),this.code=this.name=qm.code,this.data={depth:e}}}qm.code="MaxDepthError";class Gm extends ze{constructor(){super("Merges with conflicts are not supported yet."),this.code=this.name=Gm.code,this.data={}}}Gm.code="MergeNotSupportedError";class Xm extends ze{constructor(e,t,i,s){super(`Automatic merge failed with one or more merge conflicts in the following files: ${e.toString()}. Fix conflicts then commit the result.`),this.code=this.name=Xm.code,this.data={filepaths:e,bothModified:t,deleteByUs:i,deleteByTheirs:s}}}Xm.code="MergeConflictError";class Ym extends ze{constructor(e){super(`No name was provided for ${e} in the argument or in the .git/config file.`),this.code=this.name=Ym.code,this.data={role:e}}}Ym.code="MissingNameError";class pl extends ze{constructor(e){super(`The function requires a "${e}" parameter but none was provided.`),this.code=this.name=pl.code,this.data={parameter:e}}}pl.code="MissingParameterError";class Zm extends ze{constructor(e){super('There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more'),this.code=this.name=Zm.code,this.data={errors:e},this.errors=e}}Zm.code="MultipleGitError";class ml extends ze{constructor(e,t){super(`Expected "${e}" but received "${t}".`),this.code=this.name=ml.code,this.data={expected:e,actual:t}}}ml.code="ParseError";class Jm extends ze{constructor(e){let t="";e==="not-fast-forward"?t=" because it was not a simple fast-forward":e==="tag-exists"&&(t=" because tag already exists"),super(`Push rejected${t}. Use "force: true" to override.`),this.code=this.name=Jm.code,this.data={reason:e}}}Jm.code="PushRejectedError";class rn extends ze{constructor(e,t){super(`Remote does not support the "${e}" so the "${t}" parameter cannot be used.`),this.code=this.name=rn.code,this.data={capability:e,parameter:t}}}rn.code="RemoteCapabilityError";class hu extends ze{constructor(e,t){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${e}`),this.code=this.name=hu.code,this.data={preview:e,response:t}}}hu.code="SmartHttpError";class uu extends ze{constructor(e,t,i){super(`Git remote "${e}" uses an unrecognized transport protocol: "${t}"`),this.code=this.name=uu.code,this.data={url:e,transport:t,suggestion:i}}}uu.code="UnknownTransportError";class du extends ze{constructor(e){super(`Cannot parse remote URL: "${e}"`),this.code=this.name=du.code,this.data={url:e}}}du.code="UrlParseError";class fu extends ze{constructor(){super("The operation was canceled."),this.code=this.name=fu.code,this.data={}}}fu.code="UserCanceledError";class Qm extends ze{constructor(e){super(`Could not merge index: Entry for '${e}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=Qm.code,this.data={filepath:e}}}Qm.code="IndexResetError";class eg extends ze{constructor(e){super(`"${e}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=eg.code,this.data={ref:e}}}eg.code="NoCommitError";function ap({name:r,email:e,timestamp:t,timezoneOffset:i}){return i=$6(i),`${r} <${e}> ${t} ${i}`}function $6(r){const e=H6(z6(r));r=Math.abs(r);const t=Math.floor(r/60);r-=t*60;let i=String(t),s=String(r);return i.length<2&&(i="0"+i),s.length<2&&(s="0"+s),(e===-1?"-":"+")+i+s}function H6(r){return Math.sign(r)||(Object.is(r,-0)?-1:1)}function z6(r){return r===0?r:-r}function Oi(r){return r=r.replace(/\r/g,""),r=r.replace(/^\n+/,""),r=r.replace(/\n+$/,"")+` 178`,r}function xh(r){const[,e,t,i,s]=r.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:e,email:t,timestamp:Number(i),timezoneOffset:W6(s)}}function W6(r){let[,e,t,i]=r.match(/(\+|-)(\d\d)(\d\d)/);return i=(e==="+"?1:-1)*(Number(t)*60+Number(i)),U6(i)}function U6(r){return r===0?r:-r}class xa{constructor(e){if(typeof e=="string")this._tag=e;else if(Se.isBuffer(e))this._tag=e.toString("utf8");else if(typeof e=="object")this._tag=xa.render(e);else throw new De("invalid type passed to GitAnnotatedTag constructor")}static from(e){return new xa(e)}static render(e){return`object ${e.object} 179type ${e.type} 180tag ${e.tag} 181tagger ${ap(e.tagger)} 182 183${e.message} 184${e.gpgsig?e.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(` 185 186`))}message(){const e=this.withoutSignature();return e.slice(e.indexOf(` 187 188`)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){const e=this.justHeaders().split(` 189`),t=[];for(const s of e)s[0]===" "?t[t.length-1]+=` 190`+s.slice(1):t.push(s);const i={};for(const s of t){const n=s.slice(0,s.indexOf(" ")),a=s.slice(s.indexOf(" ")+1);Array.isArray(i[n])?i[n].push(a):i[n]=a}return i.tagger&&(i.tagger=xh(i.tagger)),i.committer&&(i.committer=xh(i.committer)),i}withoutSignature(){const e=Oi(this._tag);return e.indexOf(` 191-----BEGIN PGP SIGNATURE-----`)===-1?e:e.slice(0,e.lastIndexOf(` 192-----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(` 193-----BEGIN PGP SIGNATURE-----`)===-1)return;const e=this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27);return Oi(e)}payload(){return this.withoutSignature()+` 194`}toObject(){return Se.from(this._tag,"utf8")}static async sign(e,t,i){const s=e.payload();let{signature:n}=await t({payload:s,secretKey:i});n=Oi(n);const a=s+n;return xa.from(a)}}function kd(r){return r.trim().split(` 195`).map(e=>" "+e).join(` 196`)+` 197`}function V6(r){return r.split(` 198`).map(e=>e.replace(/^ /,"")).join(` 199`)}class Qt{constructor(e){if(typeof e=="string")this._commit=e;else if(Se.isBuffer(e))this._commit=e.toString("utf8");else if(typeof e=="object")this._commit=Qt.render(e);else throw new De("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:e,signature:t}){const i=Qt.justHeaders(e),s=Qt.justMessage(e),n=Oi(i+` 200gpgsig`+kd(t)+` 201`+s);return new Qt(n)}static from(e){return new Qt(e)}toObject(){return Se.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return Qt.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(e){return Oi(e.slice(e.indexOf(` 202 203`)+2))}static justHeaders(e){return e.slice(0,e.indexOf(` 204 205`))}parseHeaders(){const e=Qt.justHeaders(this._commit).split(` 206`),t=[];for(const s of e)s[0]===" "?t[t.length-1]+=` 207`+s.slice(1):t.push(s);const i={parent:[]};for(const s of t){const n=s.slice(0,s.indexOf(" ")),a=s.slice(s.indexOf(" ")+1);Array.isArray(i[n])?i[n].push(a):i[n]=a}return i.author&&(i.author=xh(i.author)),i.committer&&(i.committer=xh(i.committer)),i}static renderHeaders(e){let t="";if(e.tree?t+=`tree ${e.tree} 208`:t+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 209`,e.parent){if(e.parent.length===void 0)throw new De("commit 'parent' property should be an array");for(const n of e.parent)t+=`parent ${n} 210`}const i=e.author;t+=`author ${ap(i)} 211`;const s=e.committer||e.author;return t+=`committer ${ap(s)} 212`,e.gpgsig&&(t+="gpgsig"+kd(e.gpgsig)),t}static render(e){return Qt.renderHeaders(e)+` 213`+Oi(e.message)}render(){return this._commit}withoutSignature(){const e=Oi(this._commit);if(e.indexOf(` 214gpgsig`)===-1)return e;const t=e.slice(0,e.indexOf(` 215gpgsig`)),i=e.slice(e.indexOf(`-----END PGP SIGNATURE----- 216`)+28);return Oi(t+` 217`+i)}isolateSignature(){const e=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return V6(e)}static async sign(e,t,i){const s=e.withoutSignature(),n=Qt.justMessage(e._commit);let{signature:a}=await t({payload:s,secretKey:i});a=Oi(a);const l=Qt.justHeaders(e._commit)+` 218gpgsig`+kd(a)+` 219`+n;return Qt.from(l)}}async function lp({fs:r,cache:e,gitdir:t,oid:i}){if(i==="4b825dc642cb6eb9a060e54bf8d69288fbee4904")return{tree:Ka.from([]),oid:i};const{type:s,object:n}=await Rs({fs:r,cache:e,gitdir:t,oid:i});if(s==="tag")return i=xa.from(n).parse().object,lp({fs:r,cache:e,gitdir:t,oid:i});if(s==="commit")return i=Qt.from(n).parse().tree,lp({fs:r,cache:e,gitdir:t,oid:i});if(s!=="tree")throw new fl(i,s,"tree");return{tree:Ka.from(n),oid:i}}class K6{constructor({fs:e,gitdir:t,ref:i,cache:s}){this.fs=e,this.cache=s,this.gitdir=t,this.mapPromise=(async()=>{const a=new Map;let o;try{o=await Ie.resolve({fs:e,gitdir:t,ref:i})}catch(c){c instanceof vi&&(o="4b825dc642cb6eb9a060e54bf8d69288fbee4904")}const l=await lp({fs:e,cache:this.cache,gitdir:t,oid:o});return l.type="tree",l.mode="40000",a.set(".",l),a})();const n=this;this.ConstructEntry=class{constructor(o){this._fullpath=o,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return n.type(this)}async mode(){return n.mode(this)}async stat(){return n.stat(this)}async content(){return n.content(this)}async oid(){return n.oid(this)}}}async readdir(e){const t=e._fullpath,{fs:i,cache:s,gitdir:n}=this,a=await this.mapPromise,o=a.get(t);if(!o)throw new Error(`No obj for ${t}`);const l=o.oid;if(!l)throw new Error(`No oid for obj ${JSON.stringify(o)}`);if(o.type!=="tree")return null;const{type:c,object:h}=await Rs({fs:i,cache:s,gitdir:n,oid:l});if(c!==o.type)throw new fl(l,c,o.type);const u=Ka.from(h);for(const d of u)a.set(Ht.join(t,d.path),d);return u.entries().map(d=>Ht.join(t,d.path))}async type(e){if(e._type===!1){const t=await this.mapPromise,{type:i}=t.get(e._fullpath);e._type=i}return e._type}async mode(e){if(e._mode===!1){const t=await this.mapPromise,{mode:i}=t.get(e._fullpath);e._mode=Fk(parseInt(i,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){const t=await this.mapPromise,{fs:i,cache:s,gitdir:n}=this,o=t.get(e._fullpath).oid,{type:l,object:c}=await Rs({fs:i,cache:s,gitdir:n,oid:o});l!=="blob"?e._content=void 0:e._content=new Uint8Array(c)}return e._content}async oid(e){if(e._oid===!1){const i=(await this.mapPromise).get(e._fullpath);e._oid=i.oid}return e._oid}}function q6({ref:r="HEAD"}={}){const e=Object.create(null);return Object.defineProperty(e,iu,{value:function({fs:t,gitdir:i,cache:s}){return new K6({fs:t,gitdir:i,ref:r,cache:s})}}),Object.freeze(e),e}class G6{constructor({fs:e,dir:t,gitdir:i,cache:s}){this.fs=e,this.cache=s,this.dir=t,this.gitdir=i;const n=this;this.ConstructEntry=class{constructor(o){this._fullpath=o,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return n.type(this)}async mode(){return n.mode(this)}async stat(){return n.stat(this)}async content(){return n.content(this)}async oid(){return n.oid(this)}}}async readdir(e){const t=e._fullpath,{fs:i,dir:s}=this,n=await i.readdir(Ht.join(s,t));return n===null?null:n.map(a=>Ht.join(t,a))}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){const{fs:t,dir:i}=this;let s=await t.lstat(`${i}/${e._fullpath}`);
219if(!s)throw new Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let n=s.isDirectory()?"tree":"blob";n==="blob"&&!s.isFile()&&!s.isSymbolicLink()&&(n="special"),e._type=n,s=bo(s),e._mode=s.mode,s.size===-1&&e._actualSize&&(s.size=e._actualSize),e._stat=s}return e._stat}async content(e){if(e._content===!1){const{fs:t,dir:i,gitdir:s}=this;if(await e.type()==="tree")e._content=void 0;else{const a=await(await _i.get({fs:t,gitdir:s})).get("core.autocrlf"),o=await t.read(`${i}/${e._fullpath}`,{autocrlf:a});e._actualSize=o.length,e._stat&&e._stat.size===-1&&(e._stat.size=e._actualSize),e._content=new Uint8Array(o)}}return e._content}async oid(e){if(e._oid===!1){const{fs:t,gitdir:i,cache:s}=this;let n;await ba.acquire({fs:t,gitdir:i,cache:s},async function(a){const o=a.entriesMap.get(e._fullpath),l=await e.stat(),h=await(await _i.get({fs:t,gitdir:i})).get("core.filemode"),u=typeof qt<"u"?qt.platform!=="win32":!0;!o||np(l,o,h,u)?await e.content()===void 0?n=void 0:(n=await xo(zm.wrap({type:"blob",object:await e.content()})),o&&n===o.oid&&(!h||l.mode===o.mode)&&np(l,o,h,u)&&a.insert({filepath:e._fullpath,stats:l,oid:n})):n=o.oid}),e._oid=n}return e._oid}}function X6(){const r=Object.create(null);return Object.defineProperty(r,iu,{value:function({fs:e,dir:t,gitdir:i,cache:s}){return new G6({fs:e,dir:t,gitdir:i,cache:s})}}),Object.freeze(r),r}function Y6(r,e){const t=e-r;return Array.from({length:t},(i,s)=>r+s)}const Kk=typeof Array.prototype.flat>"u"?r=>r.reduce((e,t)=>e.concat(t),[]):r=>r.flat();class Z6{constructor(){this.value=null}consider(e){e!=null&&(this.value===null?this.value=e:e<this.value&&(this.value=e))}reset(){this.value=null}}function*J6(r){const e=new Z6;let t;const i=[],s=r.length;for(let n=0;n<s;n++)i[n]=r[n].next().value,i[n]!==void 0&&e.consider(i[n]);if(e.value!==null)for(;;){const n=[];t=e.value,e.reset();for(let a=0;a<s;a++)i[a]!==void 0&&i[a]===t?(n[a]=i[a],i[a]=r[a].next().value):n[a]=null,i[a]!==void 0&&e.consider(i[a]);if(yield n,e.value===null)return}}async function Q6({fs:r,cache:e,dir:t,gitdir:i,trees:s,map:n=async(l,c)=>c,reduce:a=async(l,c)=>{const h=Kk(c);return l!==void 0&&h.unshift(l),h},iterate:o=(l,c)=>Promise.all([...c].map(l))}){const l=s.map(f=>f[iu]({fs:r,dir:t,gitdir:i,cache:e})),c=new Array(l.length).fill("."),h=Y6(0,l.length),u=async f=>{h.map(p=>{f[p]=f[p]&&new l[p].ConstructEntry(f[p])});const b=(await Promise.all(h.map(p=>f[p]?l[p].readdir(f[p]):[]))).map(p=>p===null?[]:p).map(p=>p[Symbol.iterator]());return{entries:f,children:J6(b)}},d=async f=>{const{entries:_,children:b}=await u(f),p=_.find(v=>v&&v._fullpath)._fullpath,g=await n(p,_);if(g!==null){let v=await o(d,b);return v=v.filter(x=>x!==void 0),a(g,v)}};return d(c)}async function cp(r,e){const t=await r.readdir(e);t==null?await r.rm(e):t.length?await Promise.all(t.map(i=>{const s=Ht.join(e,i);return r.lstat(s).then(n=>{if(n)return n.isDirectory()?cp(r,s):r.rm(s)})})).then(()=>r.rmdir(e)):await r.rmdir(e)}function eF(r){return tF(r)&&rx(r.then)&&rx(r.catch)}function tF(r){return r&&typeof r=="object"}function rx(r){return typeof r=="function"}function ix(r){return eF((t=>{try{return t.readFile().catch(i=>i)}catch(i){return i}})(r))}const sx=["readFile","writeFile","mkdir","rmdir","unlink","stat","lstat","readdir","readlink","symlink"];function nx(r,e){if(ix(e))for(const t of sx)r[`_${t}`]=e[t].bind(e);else for(const t of sx)r[`_${t}`]=bd(e[t].bind(e));ix(e)?e.rm?r._rm=e.rm.bind(e):e.rmdir.length>1?r._rm=e.rmdir.bind(e):r._rm=cp.bind(null,r):e.rm?r._rm=bd(e.rm.bind(e)):e.rmdir.length>2?r._rm=bd(e.rmdir.bind(e)):r._rm=cp.bind(null,r)}class rF{constructor(e){if(typeof e._original_unwrapped_fs<"u")return e;const t=Object.getOwnPropertyDescriptor(e,"promises");t&&t.enumerable?nx(this,e.promises):nx(this,e),this._original_unwrapped_fs=e}async exists(e,t={}){try{return await this._stat(e),!0}catch(i){if(i.code==="ENOENT"||i.code==="ENOTDIR"||(i.code||"").includes("ENS"))return!1;throw console.log('Unhandled error in "FileSystem.exists()" function',i),i}}async read(e,t={}){try{let i=await this._readFile(e,t);if(t.autocrlf==="true")try{i=new TextDecoder("utf8",{fatal:!0}).decode(i),i=i.replace(/\r\n/g,` 220`),i=new TextEncoder().encode(i)}catch{}
220return typeof i!="string"&&(i=Se.from(i)),i}catch{return null}}async write(e,t,i={}){try{await this._writeFile(e,t,i);return}catch{await this.mkdir(gh(e)),await this._writeFile(e,t,i)}}async mkdir(e,t=!1){try{await this._mkdir(e);return}catch(i){if(i===null||i.code==="EEXIST")return;if(t)throw i;if(i.code==="ENOENT"){const s=gh(e);if(s==="."||s==="/"||s===e)throw i;await this.mkdir(s),await this.mkdir(e,!0)}}}async rm(e){try{await this._unlink(e)}catch(t){if(t.code!=="ENOENT")throw t}}async rmdir(e,t){try{t&&t.recursive?await this._rm(e,t):await this._rmdir(e)}catch(i){if(i.code!=="ENOENT")throw i}}async readdir(e){try{const t=await this._readdir(e);return t.sort(ru),t}catch(t){return t.code==="ENOTDIR"?null:[]}}async readdirDeep(e){const t=await this._readdir(e);return(await Promise.all(t.map(async s=>{const n=e+"/"+s;return(await this._stat(n)).isDirectory()?this.readdirDeep(n):n}))).reduce((s,n)=>s.concat(n),[])}async lstat(e){try{return await this._lstat(e)}catch(t){if(t.code==="ENOENT"||(t.code||"").includes("ENS"))return null;throw t}}async readlink(e,t={encoding:"buffer"}){try{const i=await this._readlink(e,t);return Se.isBuffer(i)?i:Se.from(i)}catch(i){if(i.code==="ENOENT"||(i.code||"").includes("ENS"))return null;throw i}}async writelink(e,t){return this._symlink(t.toString("utf8"),e)}}function Yo(r,e){if(e===void 0)throw new pl(r)}async function iF({fs:r,gitdir:e,remote:t,url:i,force:s}){if(t!==Vb.clean(t))throw new cu(t,Vb.clean(t));const n=await _i.get({fs:r,gitdir:e});if((await n.getSubsections("remote")).includes(t)&&i!==await n.get(`remote.${t}.url`))throw new nu("remote",t);await n.set(`remote.${t}.url`,i),await n.set(`remote.${t}.fetch`,`+refs/heads/*:refs/remotes/${t}/*`),await _i.save({fs:r,gitdir:e,config:n})}const sF=(r,e)=>r==="."||e==null||e.length===0||e==="."?!0:e.length>=r.length?e.startsWith(r):r.startsWith(e);async function nF({fs:r,cache:e,onProgress:t,onPostCheckout:i,dir:s,gitdir:n,remote:a,ref:o,filepaths:l,noCheckout:c,noUpdateHead:h,dryRun:u,force:d,track:f=!0}){let _;if(i)try{_=await Ie.resolve({fs:r,gitdir:n,ref:"HEAD"})}catch{_="0000000000000000000000000000000000000000"}let b;try{b=await Ie.resolve({fs:r,gitdir:n,ref:o})}catch(p){if(o==="HEAD")throw p;const g=`${a}/${o}`;if(b=await Ie.resolve({fs:r,gitdir:n,ref:g}),f){const v=await _i.get({fs:r,gitdir:n});await v.set(`branch.${o}.remote`,a),await v.set(`branch.${o}.merge`,`refs/heads/${o}`),await _i.save({fs:r,gitdir:n,config:v})}await Ie.writeRef({fs:r,gitdir:n,ref:`refs/heads/${o}`,value:b})}if(!c){let p;try{p=await oF({fs:r,cache:e,onProgress:t,dir:s,gitdir:n,ref:o,force:d,filepaths:l})}catch(S){throw S instanceof vi&&S.data.what===b?new au(o,b):S}const g=p.filter(([S])=>S==="conflict").map(([S,k])=>k);if(g.length>0)throw new ou(g);const v=p.filter(([S])=>S==="error").map(([S,k])=>k);if(v.length>0)throw new De(v.join(", "));if(u){i&&await i({previousHead:_,newHead:b,type:l!=null&&l.length>0?"file":"branch"});return}let x=0;const w=p.length;await ba.acquire({fs:r,gitdir:n,cache:e},async function(S){await Promise.all(p.filter(([k])=>k==="delete"||k==="delete-index").map(async function([k,C]){const y=`${s}/${C}`;k==="delete"&&await r.rm(y),S.delete({filepath:C}),t&&await t({phase:"Updating workdir",loaded:++x,total:w})}))}),await ba.acquire({fs:r,gitdir:n,cache:e},async function(S){for(const[k,C]of p)if(k==="rmdir"||k==="rmdir-index"){const y=`${s}/${C}`;try{k==="rmdir-index"&&S.delete({filepath:C}),await r.rmdir(y),t&&await t({phase:"Updating workdir",loaded:++x,total:w})}catch(E){if(E.code==="ENOTEMPTY")console.log(`Did not delete ${C} because directory is not empty`);else throw E}}}),await Promise.all(p.filter(([S])=>S==="mkdir"||S==="mkdir-index").map(async function([S,k]){const C=`${s}/${k}`;await r.mkdir(C),t&&await t({phase:"Updating workdir",loaded:++x,total:w})})),await ba.acquire({fs:r,gitdir:n,cache:e},async function(S){await Promise.all(p.filter(([k])=>k==="create"||k==="create-index"||k==="update"||k==="mkdir-index").map(async function([k,C,y,E,D]){const T=`${s}/${C}`;try{if(k!=="create-index"&&k!=="mkdir-index"){const{object:R}=await Rs({fs:r,cache:e,gitdir:n,oid:y});if(D&&await r.rm(T),E===33188)await r.write(T,R);else if(E===33261)await r.write(T,R,{mode:511});else if(E===40960)await r.writelink(T,R);else throw new De(`Invalid mode 0o${E.toString(8)} detected in blob ${y}`)}const M=await r.lstat(T);E===33261&&(M.mode=493),k==="mkdir-index"&&(M.mode=57344),S.insert({filepath:C,stats:M,oid:y}),t&&await t({phase:"Updating workdir",loaded:++x,total:w})}catch(M){console.log(M)}}))}),i&&await i({previousHead:_,newHead:b,type:l!=null&&l.length>0?"file":"branch"})}if(!h){const p=await Ie.expand({fs:r,gitdir:n,ref:o});p.startsWith("refs/heads")?await Ie.writeSymbolicRef({fs:r,gitdir:n,ref:"HEAD",value:p}):await Ie.writeRef({fs:r,gitdir:n,ref:"HEAD",value:b})}}async function oF({fs:r,cache:e,onProgress:t,dir:i,gitdir:s,ref:n,force:a,filepaths:o}){let l=0;return Q6({fs:r,cache:e,dir:i,gitdir:s,trees:[q6({ref:n}),X6(),d6()],map:async function(c,[h,u,d]){if(c===".")return;if(o&&!o.some(_=>sF(c,_)))return null;switch(t&&await t({phase:"Analyzing workdir",loaded:++l}),[!!d,!!h,!!u].map(Number).join("")){case"000":return;case"001":return a&&o&&o.includes(c)?["delete",c]:void 0;
220case"010":switch(await h.type()){case"tree":return["mkdir",c];case"blob":return["create",c,await h.oid(),await h.mode()];case"commit":return["mkdir-index",c,await h.oid(),await h.mode()];default:return["error",`new entry Unhandled type ${await h.type()}`]}case"011":switch(`${await h.type()}-${await u.type()}`){case"tree-tree":return;case"tree-blob":case"blob-tree":return["conflict",c];case"blob-blob":return await h.oid()!==await u.oid()?a?["update",c,await h.oid(),await h.mode(),await h.mode()!==await u.mode()]:["conflict",c]:await h.mode()!==await u.mode()?a?["update",c,await h.oid(),await h.mode(),!0]:["conflict",c]:["create-index",c,await h.oid(),await h.mode()];case"commit-tree":return;case"commit-blob":return["conflict",c];default:return["error",`new entry Unhandled type ${h.type}`]}case"100":return["delete-index",c];case"101":switch(await d.type()){case"tree":return["rmdir",c];case"blob":return await d.oid()!==await u.oid()?a?["delete",c]:["conflict",c]:["delete",c];case"commit":return["rmdir-index",c];default:return["error",`delete entry Unhandled type ${await d.type()}`]}case"110":case"111":switch(`${await d.type()}
220-${await h.type()}`){case"tree-tree":return;case"blob-blob":{if(await d.oid()===await h.oid()&&await d.mode()===await h.mode()&&!a)return;if(u){if(await u.oid()!==await d.oid()&&await u.oid()!==await h.oid())return a?["update",c,await h.oid(),await h.mode(),await h.mode()!==await u.mode()]:["conflict",c]}else if(a)return["update",c,await h.oid(),await h.mode(),await h.mode()!==await d.mode()];return await h.mode()!==await d.mode()?["update",c,await h.oid(),await h.mode(),!0]:await h.oid()!==await d.oid()?["update",c,await h.oid(),await h.mode(),!1]:void 0}case"tree-blob":return["update-dir-to-blob",c,await h.oid()];case"blob-tree":return["update-blob-to-tree",c];case"commit-commit":return["mkdir-index",c,await h.oid(),await h.mode()];default:return["error",`update entry Unhandled type ${await d.type()}-${await h.type()}`]}}},reduce:async function(c,h){return h=Kk(h),c?c&&c[0]==="rmdir"?(h.push(c),h):(h.unshift(c),h):h}})}const aF=new RegExp("^refs/(heads/|tags/|remotes/)?(.*)");function qk(r){const e=aF.exec(r);return e?e[1]==="remotes/"&&r.endsWith("/HEAD")?e[2].slice(0,-5):e[2]:r}async function lF({fs:r,gitdir:e,fullname:t=!1,test:i=!1}){const s=await Ie.resolve({fs:r,gitdir:e,ref:"HEAD",depth:2});if(i)try{await Ie.resolve({fs:r,gitdir:e,ref:s})}catch{return}if(s.startsWith("refs/"))return t?s:qk(s)}function cF(r){return r=r.replace(/^git@([^:]+):/,"https://$1/"),r=r.replace(/^ssh:\/\//,"https://"),r}function Gk({username:r="",password:e=""}){return`Basic ${Se.from(`${r}:${e}`).toString("base64")}`}async function pu(r,e){const t=zk(r);for(;;){const{value:i,done:s}=await t.next();if(i&&await e(i),s)break}t.return&&t.return()}async function hp(r){let e=0;const t=[];await pu(r,n=>{t.push(n),e+=n.byteLength});const i=new Uint8Array(e);let s=0;for(const n of t)i.set(n,s),s+=n.byteLength;return i}function ox(r){let e=r.match(/^https?:\/\/([^/]+)@/);if(e==null)return{url:r,auth:{}};e=e[1];const[t,i]=e.split(":");return r=r.replace(`${e}@`,""),{url:r,auth:{username:t,password:i}}}function hF(r,e){const t=e.toString(16);return"0".repeat(r-t.length)+t}class ai{static flush(){return Se.from("0000","utf8")}static delim(){return Se.from("0001","utf8")}static encode(e){typeof e=="string"&&(e=Se.from(e));const t=e.length+4,i=hF(4,t);return Se.concat([Se.from(i,"utf8"),e])}static streamReader(e){const t=new Wk(e);return async function(){try{let s=await t.read(4);if(s==null)return!0;if(s=parseInt(s.toString("utf8"),16),s===0||s===1)return null;const n=await t.read(s-4);return n??!0}catch(s){return e.error=s,!0}}}}async function ax(r){const e={};let t;for(;t=await r(),t!==!0;){if(t===null)continue;t=t.toString("utf8").replace(/\n$/,"");const i=t.indexOf("=");if(i>-1){const s=t.slice(0,i),n=t.slice(i+1);e[s]=n}else e[t]=!0}return{protocolVersion:2,capabilities2:e}}async function lx(r,{service:e}){const t=new Set,i=new Map,s=new Map,n=ai.streamReader(r);let a=await n();for(;a===null;)a=await n();if(a===!0)throw new lu;if(a.includes("version 2"))return ax(n);if(a.toString("utf8").replace(/\n$/,"")!==`# service=${e}`)throw new ml(`# service=${e}\\n`,a.toString("utf8"));let o=await n();for(;o===null;)o=await n();if(o===!0)return{capabilities:t,refs:i,symrefs:s};if(o=o.toString("utf8"),o.includes("version 2"))return ax(n);const[l,c]=Cd(o,"\0","\\x00");if(c.split(" ").map(h=>t.add(h)),l!=="0000000000000000000000000000000000000000 capabilities^{}"){const[h,u]=Cd(l," "," ");for(i.set(u,h);;){const d=await n();if(d===!0)break;if(d!==null){const[f,_]=Cd(d.toString("utf8")," "," ");i.set(_,f)}}}for(const h of t)if(h.startsWith("symref=")){const u=h.match(/symref=([^:]+):(.*)/);u.length===3&&s.set(u[1],u[2])}return{protocolVersion:1,capabilities:t,refs:i,symrefs:s}}function Cd(r,e,t){const i=r.trim().split(e);if(i.length!==2)throw new ml(`Two strings separated by '${t}'`,r.toString("utf8"));return i}const cx=(r,e)=>r.endsWith("?")?`${r}${e}`:`${r}/${e.replace(/^https?:\/\//,"")}`,hx=(r,e)=>{(e.username||e.password)&&(r.Authorization=Gk(e)),e.headers&&Object.assign(r,e.headers)},Ed=async r=>{try{const e=Se.from(await hp(r.body)),t=e.toString("utf8");return{preview:t.length<256?t:t.slice(0,256)+"...",response:t,data:e}}catch{return{}}};class ux{static async capabilities(){return["discover","connect"]}static async discover({http:e,onProgress:t,onAuth:i,onAuthSuccess:s,onAuthFailure:n,corsProxy:a,service:o,url:l,headers:c,protocolVersion:h}){let{url:u,auth:d}=ox(l);const f=a?cx(a,u):u;(d.username||d.password)&&(c.Authorization=Gk(d)),h===2&&(c["Git-Protocol"]="version=2");let _,b,p=!1;do if(_=await e.request({onProgress:t,method:"GET",url:`${f}/info/refs?service=${o}`,headers:c}),b=!1,_.statusCode===401||_.statusCode===203){const g=p?n:i;
220if(g){if(d=await g(u,{...d,headers:{...c}}),d&&d.cancel)throw new fu;d&&(hx(c,d),p=!0,b=!0)}}else _.statusCode===200&&p&&s&&await s(u,d);while(b);if(_.statusCode!==200){const{response:g}=await Ed(_);throw new Ga(_.statusCode,_.statusMessage,g)}if(_.headers["content-type"]===`application/x-${o}-advertisement`){const g=await lx(_.body,{service:o});return g.auth=d,g}else{const{preview:g,response:v,data:x}=await Ed(_);try{const w=await lx([x],{service:o});return w.auth=d,w}catch{throw new hu(g,v)}}}static async connect({http:e,onProgress:t,corsProxy:i,service:s,url:n,auth:a,body:o,headers:l}){const c=ox(n);c&&(n=c.url),i&&(n=cx(i,n)),l["content-type"]=`application/x-${s}-request`,l.accept=`application/x-${s}-result`,hx(l,a);const h=await e.request({onProgress:t,method:"POST",url:`${n}/${s}`,body:o,headers:l});if(h.statusCode!==200){const{response:u}=Ed(h);throw new Ga(h.statusCode,h.statusMessage,u)}return h}}function uF({url:r}){if(r.startsWith("git@"))return{transport:"ssh",address:r};const e=r.match(/(\w+)(:\/\/|::)(.*)/);if(e!==null){if(e[2]==="://")return{transport:e[1],address:e[0]};if(e[2]==="::")return{transport:e[1],address:e[3]}}}class dF{static getRemoteHelperFor({url:e}){const t=new Map;t.set("http",ux),t.set("https",ux);const i=uF({url:e});if(!i)throw new du(e);if(t.has(i.transport))return t.get(i.transport);throw new uu(e,i.transport,i.transport==="ssh"?cF(e):void 0)}}let Hs=null;class dx{static async read({fs:e,gitdir:t}){Hs===null&&(Hs=new fh);const i=Ht.join(t,"shallow"),s=new Set;return await Hs.acquire(i,async function(){const n=await e.read(i,{encoding:"utf8"});if(n===null||n.trim()==="")return s;n.trim().split(` 221`).map(a=>s.add(a))}),s}static async write({fs:e,gitdir:t,oids:i}){Hs===null&&(Hs=new fh);const s=Ht.join(t,"shallow");if(i.size>0){const n=[...i].join(` 222`)+` 223`;await Hs.acquire(s,async function(){await e.write(s,n,{encoding:"utf8"})})}else await Hs.acquire(s,async function(){await e.rm(s)})}}async function fF({fs:r,gitdir:e,oid:t}){const i=`objects/${t.slice(0,2)}/${t.slice(2)}`;return r.exists(`${e}/${i}`)}async function pF({fs:r,cache:e,gitdir:t,oid:i,getExternalRefDelta:s}){let n=await r.readdir(Ht.join(t,"objects/pack"));n=n.filter(a=>a.endsWith(".idx"));for(const a of n){const o=`${t}/objects/pack/${a}`,l=await Vk({fs:r,cache:e,filename:o,getExternalRefDelta:s});if(l.error)throw new De(l.error);if(l.offsets.has(i))return!0}return!1}async function fx({fs:r,cache:e,gitdir:t,oid:i,format:s="content"}){const n=o=>Rs({fs:r,cache:e,gitdir:t,oid:o});let a=await fF({fs:r,gitdir:t,oid:i});return a||(a=await pF({fs:r,cache:e,gitdir:t,oid:i,getExternalRefDelta:n})),a}function mF(r){const s="5041434b"+"00000002"+"00000000";return r.slice(0,12).toString("hex")===s}function gF(r,e){const t=r.map(i=>i.split("=",1)[0]);return e.filter(i=>{const s=i.split("=",1)[0];return t.includes(s)})}const vF={agent:"git/[email protected]"};class Ac{constructor(){this._queue=[]}write(e){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){const t=this._waiting;this._waiting=null,t({value:e})}else this._queue.push(e)}end(){if(this._ended=!0,this._waiting){const e=this._waiting;this._waiting=null,e({done:!0})}}destroy(e){this.error=e,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(e=>{this._waiting=e})}}function bF(r){const e=r.indexOf("\r"),t=r.indexOf(` 224`);return e===-1&&t===-1?-1:e===-1?t+1:t===-1?e+1:t===e+1?t+1:Math.min(e,t)+1}function xF(r){const e=new Ac;let t="";return(async()=>(await pu(r,i=>{for(i=i.toString("utf8"),t+=i;;){const s=bF(t);if(s===-1)break;e.write(t.slice(0,s)),t=t.slice(s)}}),t.length>0&&e.write(t),e.end()))(),e}class _F{static demux(e){const t=ai.streamReader(e),i=new Ac,s=new Ac,n=new Ac,a=async function(){const o=await t();if(o===null)return a();if(o===!0){i.end(),n.end(),e.error?s.destroy(e.error):s.end();return}switch(o[0]){case 1:{s.write(o.slice(1));break}case 2:{n.write(o.slice(1));break}case 3:{const l=o.slice(1);n.write(l),i.end(),n.end(),s.destroy(new Error(l.toString("utf8")));return}default:i.write(o)}a()};return a(),{packetlines:i,packfile:s,progress:n}}}async function yF(r){const{packetlines:e,packfile:t,progress:i}=_F.demux(r),s=[],n=[],a=[];let o=!1,l=!1;return new Promise((c,h)=>{pu(e,u=>{const d=u.toString("utf8").trim();if(d.startsWith("shallow")){const f=d.slice(-41).trim();f.length!==40&&h(new Cn(f)),s.push(f)}else if(d.startsWith("unshallow")){const f=d.slice(-41).trim();f.length!==40&&h(new Cn(f)),n.push(f)}else if(d.startsWith("ACK")){const[,f,_]=d.split(" ");a.push({oid:f,status:_}),_||(l=!0)}else d.startsWith("NAK")?(o=!0,l=!0):(l=!0,o=!0);l&&(r.error?h(r.error):c({shallows:s,unshallows:n,acks:a,nak:o,packfile:t,progress:i}))}).finally(()=>{l||(r.error?h(r.error):c({shallows:s,unshallows:n,acks:a,nak:o,packfile:t,progress:i}))})})}function wF({capabilities:r=[],wants:e=[],haves:t=[],shallows:i=[],depth:s=null,since:n=null,exclude:a=[]}){const o=[];e=[...new Set(e)];let l=` ${r.join(" ")}`;for(const c of e)o.push(ai.encode(`want ${c}${l} 225`)),l="";for(const c of i)o.push(ai.encode(`shallow ${c} 226`));s!==null&&o.push(ai.encode(`deepen ${s} 227`)),n!==null&&o.push(ai.encode(`deepen-since ${Math.floor(n.valueOf()/1e3)} 228`));for(const c of a)o.push(ai.encode(`deepen-not ${c} 229`));o.push(ai.flush());for(const c of t)o.push(ai.encode(`have ${c} 230`));return o.push(ai.encode(`done 231`)),o}async function SF({fs:r,cache:e,http:t,onProgress:i,onMessage:s,onAuth:n,onAuthSuccess:a,onAuthFailure:o,gitdir:l,ref:c,remoteRef:h,remote:u,url:d,corsProxy:f,depth:_=null,since:b=null,exclude:p=[],relative:g=!1,tags:v=!1,singleBranch:x=!1,headers:w={},prune:S=!1,pruneTags:k=!1}){const C=c||await lF({fs:r,gitdir:l,test:!0}),y=await _i.get({fs:r,gitdir:l}),E=u||C&&await y.get(`branch.${C}.remote`)||"origin",D=d||await y.get(`remote.${E}.url`);if(typeof D>"u")throw new pl("remote OR url");const T=h||C&&await y.get(`branch.${C}.merge`)||c||"HEAD";f===void 0&&(f=await y.get("http.corsProxy"));const M=dF.getRemoteHelperFor({url:D}),R=await M.discover({http:t,onAuth:n,onAuthSuccess:a,onAuthFailure:o,corsProxy:f,service:"git-upload-pack",url:D,headers:w,protocolVersion:1}),O=R.auth,$=R.refs;if($.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(_!==null&&!R.capabilities.has("shallow"))throw new rn("shallow","depth");if(b!==null&&!R.capabilities.has("deepen-since"))throw new rn("deepen-since","since");if(p.length>0&&!R.capabilities.has("deepen-not"))throw new rn("deepen-not","exclude");if(g===!0&&!R.capabilities.has("deepen-relative"))throw new rn("deepen-relative","relative");const{oid:G,fullref:V}=Ie.resolveAgainstMap({ref:T,map:$});for(const U of $.keys())U===V||U==="HEAD"||U.startsWith("refs/heads/")||v&&U.startsWith("refs/tags/")||$.delete(U);const q=gF([...R.capabilities],["multi_ack_detailed","no-done","side-band-64k","ofs-delta",`agent=${vF.agent}`]);g&&q.push("deepen-relative");const L=x?[G]:$.values(),N=x?[C]:await Ie.listRefs({fs:r,gitdir:l,filepath:"refs"});let I=[];for(let U of N)try{U=await Ie.expand({fs:r,gitdir:l,ref:U});const Y=await Ie.resolve({fs:r,gitdir:l,ref:U});await fx({fs:r,cache:e,gitdir:l,oid:Y})&&I.push(Y)}catch{}I=[...new Set(I)];const H=await dx.read({fs:r,gitdir:l}),W=R.capabilities.has("shallow")?[...H]:[],J=wF({capabilities:q,wants:L,haves:I,shallows:W,depth:_,since:b,exclude:p}),Z=Se.from(await hp(J)),X=await M.connect({http:t,onProgress:i,corsProxy:f,service:"git-upload-pack",url:D,auth:O,body:[Z],headers:w}),F=await yF(X.body);X.headers&&(F.headers=X.headers);for(const U of F.shallows)if(!H.has(U))try{const{object:Y}=await Rs({fs:r,cache:e,gitdir:l,oid:U}),ee=new Qt(Y),ie=await Promise.all(ee.headers().parent.map(ne=>fx({fs:r,cache:e,gitdir:l,oid:ne})));ie.length===0||ie.every(ne=>ne)||H.add(U)}catch{H.add(U)}for(const U of F.unshallows)H.delete(U);if(await dx.write({fs:r,gitdir:l,oids:H}),x){const U=new Map([[V,G]]),Y=new Map;let ee=10,ie=V;for(;ee--;){const re=R.symrefs.get(ie);if(re===void 0)break;Y.set(ie,re),ie=re}const le=$.get(ie);le&&U.set(ie,le);const{pruned:ne}=await Ie.updateRemoteRefs({fs:r,gitdir:l,remote:E,refs:U,symrefs:Y,tags:v,prune:S});S&&(F.pruned=ne)}else{const{pruned:U}=await Ie.updateRemoteRefs({fs:r,gitdir:l,remote:E,refs:$,symrefs:R.symrefs,tags:v,prune:S,pruneTags:k});S&&(F.pruned=U)}if(F.HEAD=R.symrefs.get("HEAD"),F.HEAD===void 0){const{oid:U}=Ie.resolveAgainstMap({ref:"HEAD",map:$});for(const[Y,ee]of $.entries())if(Y!=="HEAD"&&ee===U){F.HEAD=Y;break}}const P=V.startsWith("refs/tags")?"tag":"branch";if(F.FETCH_HEAD={oid:G,description:`${P} '${qk(V)}' of ${D}`},i||s){const U=xF(F.progress);pu(U,async Y=>{if(s&&await s(Y),i){const ee=Y.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);ee&&await i({phase:ee[1].trim(),loaded:parseInt(ee[2],10),total:parseInt(ee[3],10)})}})}const j=Se.from(await hp(F.packfile));if(X.body.error)throw X.body.error;const B=j.slice(-20).toString("hex"),K={defaultBranch:F.HEAD,fetchHead:F.FETCH_HEAD.oid,fetchHeadDescription:F.FETCH_HEAD.description};if(F.headers&&(K.headers=F.headers),S&&(K.pruned=F.pruned),B!==""&&!mF(j)){K.packfile=`objects/pack/pack-${B}.pack`;const U=Ht.join(l,K.packfile);await r.write(U,j);const Y=ie=>Rs({fs:r,cache:e,gitdir:l,oid:ie}),ee=await qa.fromPack({pack:j,getExternalRefDelta:Y,onProgress:i});await r.write(U.replace(/\.pack$/,".idx"),await ee.toBuffer())}return K}async function kF({fs:r,bare:e=!1,dir:t,gitdir:i=e?t:Ht.join(t,".git"),defaultBranch:s="master"}){if(await r.exists(i+"/config"))return;let n=["hooks","info","objects/info","objects/pack","refs/heads","refs/tags"];n=n.map(a=>i+"/"+a);
231for(const a of n)await r.mkdir(a);await r.write(i+"/config",`[core] 232 repositoryformatversion = 0 233 filemode = false 234 bare = ${e} 235`+(e?"":` logallrefupdates = true 236`)+` symlinks = false 237 ignorecase = true 238`),await r.write(i+"/HEAD",`ref: refs/heads/${s} 239`)}async function CF({fs:r,cache:e,http:t,onProgress:i,onMessage:s,onAuth:n,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:l,dir:c,gitdir:h,url:u,corsProxy:d,ref:f,remote:_,depth:b,since:p,exclude:g,relative:v,singleBranch:x,noCheckout:w,noTags:S,headers:k}){try{if(await kF({fs:r,gitdir:h}),await iF({fs:r,gitdir:h,remote:_,url:u,force:!1}),d){const E=await _i.get({fs:r,gitdir:h});await E.set("http.corsProxy",d),await _i.save({fs:r,gitdir:h,config:E})}const{defaultBranch:C,fetchHead:y}=await SF({fs:r,cache:e,http:t,onProgress:i,onMessage:s,onAuth:n,onAuthSuccess:a,onAuthFailure:o,gitdir:h,ref:f,remote:_,corsProxy:d,depth:b,since:p,exclude:g,relative:v,singleBranch:x,headers:k,tags:!S});if(y===null)return;f=f||C,f=f.replace("refs/heads/",""),await nF({fs:r,cache:e,onProgress:i,onPostCheckout:l,dir:c,gitdir:h,ref:f,remote:_,noCheckout:w})}catch(C){throw await r.rmdir(h,{recursive:!0,maxRetries:10}).catch(()=>{}),C}}async function EF({fs:r,http:e,onProgress:t,onMessage:i,onAuth:s,onAuthSuccess:n,onAuthFailure:a,onPostCheckout:o,dir:l,gitdir:c=Ht.join(l,".git"),url:h,corsProxy:u=void 0,ref:d=void 0,remote:f="origin",depth:_=void 0,since:b=void 0,exclude:p=[],relative:g=!1,singleBranch:v=!1,noCheckout:x=!1,noTags:w=!1,headers:S={},cache:k={}}){try{return Yo("fs",r),Yo("http",e),Yo("gitdir",c),x||Yo("dir",l),Yo("url",h),await CF({fs:new rF(r),cache:k,http:e,onProgress:t,onMessage:i,onAuth:s,onAuthSuccess:n,onAuthFailure:a,onPostCheckout:o,dir:l,gitdir:c,url:h,corsProxy:u,ref:d,remote:f,depth:_,since:b,exclude:p,relative:g,singleBranch:v,noCheckout:x,noTags:w,headers:S})}catch(C){throw C.caller="git.clone",C}}var AF={clone:EF};function TF(r){let e=[r];return{next(){return Promise.resolve({done:e.length===0,value:e.pop()})},return(){return e=[],{}},[Symbol.asyncIterator](){return this}}}function RF(r){return r[Symbol.asyncIterator]?r[Symbol.asyncIterator]():r[Symbol.iterator]?r[Symbol.iterator]():r.next?r:TF(r)}async function MF(r,e){const t=RF(r);for(;;){const{value:i,done:s}=await t.next();if(i&&await e(i),s)break}t.return&&t.return()}async function DF(r){let e=0;const t=[];await MF(r,n=>{t.push(n),e+=n.byteLength});const i=new Uint8Array(e);let s=0;for(const n of t)i.set(n,s),s+=n.byteLength;return i}function PF(r){if(r[Symbol.asyncIterator])return r;const e=r.getReader();return{next(){return e.read()},return(){return e.releaseLock(),{}},[Symbol.asyncIterator](){return this}}}async function LF({onProgress:r,url:e,method:t="GET",headers:i={},body:s}){s&&(s=await DF(s));const n=await fetch(e,{method:t,headers:i,body:s}),a=n.body&&n.body.getReader?PF(n.body):[new Uint8Array(await n.arrayBuffer())];i={};for(const[o,l]of n.headers.entries())i[o]=l;return{url:n.url,method:n.method,statusCode:n.status,statusMessage:n.statusText,body:a,headers:i}}var NF={request:LF};const px=r=>{const e=r.split("/")[2],t=at.get(`git:${e}`);if(!t)return null;try{const{username:i,password:s}=JSON.parse(t||"{}");return{username:i,password:s}}catch(i){return console.log(`Failed to parse Git Cookie ${i}`),null}},OF=(r,e)=>{const t=r.split("/")[2];at.set(`git:${t}`,JSON.stringify(e))};function IF(){const[r,e]=A.useState(!1),[t,i]=A.useState(),[s,n]=A.useState(),a=A.useRef({});A.useEffect(()=>{Bx.then(l=>{a.current={},i(l),n(Xk(l,a)),e(!0)})},[]);const o=A.useCallback(async l=>{if(!t||!s||!r)throw"Webcontainer not initialized";a.current={};const c={"User-Agent":"exkalibur"},h=px(l);h&&(c.Authorization=`Basic ${Se.from(`${h.username}:${h.password}`).toString("base64")}`);try{await AF.clone({fs:s,http:NF,dir:t.workdir,url:l,depth:1,singleBranch:!0,corsProxy:"/api/git-proxy",headers:c,onAuth:d=>{let f=px(d);return f||(confirm("This repo is password protected. Ready to enter a username & password?")?(f={username:prompt("Enter username"),password:prompt("Enter password")},f):{cancel:!0})},onAuthFailure:(d,f)=>{throw he.error(`Error Authenticating with ${d.split("/")[2]}`),`Error Authenticating with ${d.split("/")[2]}`},onAuthSuccess:(d,f)=>{OF(d,f)}});const u={};for(const[d,f]of Object.entries(a.current))u[d]=f;return{workdir:t.workdir,data:u}}catch(u){throw console.error("Git clone error:",u),u}},[t,s,r]);return{ready:r,gitClone:o}}const Xk=(r,e)=>({promises:{readFile:async(t,i)=>{const s=i?.encoding,n=ni.relative(r.workdir,t);try{return await r.fs.readFile(n,s)}catch(a){throw a}},writeFile:async(t,i,s)=>{const n=s.encoding,a=ni.relative(r.workdir,t);e.current&&(e.current[a]={data:i,encoding:n});try{return await r.fs.writeFile(a,i,{...s,encoding:n})}catch(o){throw o}}
239,mkdir:async(t,i)=>{const s=ni.relative(r.workdir,t);try{return await r.fs.mkdir(s,{...i,recursive:!0})}catch(n){throw n}},readdir:async(t,i)=>{const s=ni.relative(r.workdir,t);try{return await r.fs.readdir(s,i)}catch(n){throw n}},rm:async(t,i)=>{const s=ni.relative(r.workdir,t);try{return await r.fs.rm(s,{...i||{}})}catch(n){throw n}},rmdir:async(t,i)=>{const s=ni.relative(r.workdir,t);try{return await r.fs.rm(s,{recursive:!0,...i})}catch(n){throw n}},unlink:async t=>{const i=ni.relative(r.workdir,t);try{return await r.fs.rm(i,{recursive:!1})}catch(s){throw s}},stat:async t=>{try{const i=ni.relative(r.workdir,t),s=await r.fs.readdir(ni.dirname(i),{withFileTypes:!0}),n=ni.basename(i),a=s.find(o=>o.name==n);if(!a)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);return{isFile:()=>a.isFile(),isDirectory:()=>a.isDirectory(),isSymbolicLink:()=>!1,size:1,mode:438,mtimeMs:Date.now(),uid:1e3,gid:1e3}}catch(i){console.log(i?.message);const s=new Error(`ENOENT: no such file or directory, stat '${t}'`);throw s.code="ENOENT",s.errno=-2,s.syscall="stat",s.path=t,s}},lstat:async t=>await Xk(r,e).promises.stat(t),readlink:async t=>{throw new Error(`EINVAL: invalid argument, readlink '${t}'`)},symlink:async(t,i)=>{throw new Error(`EPERM: operation not permitted, symlink '${t}' -> '${i}'`)},chmod:async(t,i)=>await Promise.resolve()}}),ni={dirname:r=>!r||!r.includes("/")?".":(r=r.replace(/\/+$/,""),r.split("/").slice(0,-1).join("/")||"/"),basename:(r,e)=>{r=r.replace(/\/+$/,"");const t=r.split("/").pop()||"";return e&&t.endsWith(e)?t.slice(0,-e.length):t},relative:(r,e)=>{if(!r||!e)return".";const t=h=>h.replace(/\/+$/,"").split("/").filter(Boolean),i=t(r),s=t(e);let n=0;const a=Math.min(i.length,s.length);for(let h=0;h<a&&i[h]===s[h];h++)n++;const o=i.length-n,l=s.slice(n),c=[...Array(o).fill(".."),...l];return c.length===0?".":c.join("/")}};function jF({repo:r,onSelect:e}){const t=()=>"from-exkalibur-elements-background-depth-1 to-exkalibur-elements-background-depth-1 dark:from-exkalibur-elements-background-depth-2-dark dark:to-exkalibur-elements-background-depth-2-dark",i=n=>{const a=new Date(n),l=Math.abs(new Date().getTime()-a.getTime()),c=Math.ceil(l/(1e3*60*60*24));return c<=1?"Today":c<=2?"Yesterday":c<=7?`${c} days ago`:c<=30?`${Math.floor(c/7)} weeks ago`:a.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},s=A.useMemo(()=>t(),[]);return m.jsxs(Ae.div,{className:`p-5 rounded-xl bg-gradient-to-br ${s} border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark hover:border-purple-500/40 transition-all duration-300 shadow-sm hover:shadow-md`,whileHover:{scale:1.02,y:-2,transition:{type:"spring",stiffness:400,damping:17}},whileTap:{scale:.98},initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.3},children:[m.jsxs("div",{className:"flex items-start justify-between mb-3 gap-3",children:[m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx("div",{className:"w-10 h-10 rounded-xl bg-exkalibur-elements-background-depth-1/80 dark:bg-exkalibur-elements-background-depth-4/80 backdrop-blur-sm flex items-center justify-center text-purple-500 shadow-sm",children:m.jsx("span",{className:"i-ph:git-branch w-5 h-5"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark text-base",children:r.name}),m.jsxs("p",{className:"text-xs text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark flex items-center gap-1",children:[m.jsx("span",{className:"i-ph:user w-3 h-3"}),r.full_name.split("/")[0]]})]})]}),m.jsxs(Ae.button,{onClick:e,className:"px-4 py-2 h-9 rounded-lg bg-purple-500 text-white hover:bg-purple-600 transition-all duration-200 flex items-center gap-2 min-w-[100px] justify-center text-sm shadow-sm hover:shadow-md",whileHover:{scale:1.05},whileTap:{scale:.95},children:[m.jsx("span",{className:"i-ph:git-pull-request w-3.5 h-3.5"}),"Import"]})]}),r.description&&m.jsx("div",{className:"mb-4 bg-exkalibur-elements-background-depth-1/50 dark:bg-exkalibur-elements-background-depth-4/50 backdrop-blur-sm p-3 rounded-lg border border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30",children:m.jsx("p",{className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark line-clamp-2",children:r.description})}),m.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.private&&m.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-purple-500/10 text-purple-600 dar
239k:text-purple-400 text-xs",children:[m.jsx("span",{className:"i-ph:lock w-3 h-3"}),"Private"]}),r.language&&m.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-exkalibur-elements-background-depth-1/50 dark:bg-exkalibur-elements-background-depth-4/50 backdrop-blur-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark text-xs border border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30",children:[m.jsx("span",{className:"i-ph:code w-3 h-3"}),r.language]}),m.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-exkalibur-elements-background-depth-1/50 dark:bg-exkalibur-elements-background-depth-4/50 backdrop-blur-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark text-xs border border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30",children:[m.jsx("span",{className:"i-ph:star w-3 h-3"}),r.stargazers_count.toLocaleString()]}),r.forks_count>0&&m.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-exkalibur-elements-background-depth-1/50 dark:bg-exkalibur-elements-background-depth-4/50 backdrop-blur-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark text-xs border border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30",children:[m.jsx("span",{className:"i-ph:git-fork w-3 h-3"}),r.forks_count.toLocaleString()]})]}),m.jsxs("div",{className:"mt-3 pt-3 border-t border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30 flex items-center justify-between",children:[m.jsxs("span",{className:"flex items-center gap-1 text-xs text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:[m.jsx("span",{className:"i-ph:clock w-3 h-3"}),"Updated ",i(r.updated_at)]}),r.topics&&r.topics.length>0&&m.jsxs("span",{className:"text-xs text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:[r.topics.slice(0,1).map(n=>m.jsx("span",{className:"px-1.5 py-0.5 rounded-full bg-exkalibur-elements-background-depth-1/50 dark:bg-exkalibur-elements-background-depth-4/50 text-xs",children:n},n)),r.topics.length>1&&m.jsxs("span",{className:"ml-1",children:["+",r.topics.length-1]})]})]})]})}const Yk=A.createContext({setShowAuthDialog:()=>{}});function BF({repos:r,isLoading:e,onSelect:t,activeTab:i}){const{setShowAuthDialog:s}=A.useContext(Yk);return e?m.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:[m.jsx(RS,{status:"loading",pulse:!0,size:"lg",label:"Loading repositories...",className:"mb-2"}),m.jsx("p",{className:"text-xs text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:"This may take a moment"})]}):r.length===0?i==="my-repos"?m.jsx(dh,{icon:"i-ph:folder-simple-dashed",title:"No repositories found",description:"Connect your GitHub account or create a new repository to get started",actionLabel:"Connect GitHub Account",onAction:()=>s(!0)}):m.jsx(dh,{icon:"i-ph:magnifying-glass",title:"No repositories found",description:"Try searching with different keywords or filters"}):m.jsx("div",{className:"space-y-3",children:r.map(n=>m.jsx(jF,{repo:n,onSelect:()=>t(n)},n.full_name))})}function FF({isOpen:r,onClose:e,onConfirm:t,stats:i,isLargeRepo:s}){return m.jsx(_s,{open:r,onOpenChange:n=>!n&&e(),children:m.jsxs(sn,{children:[m.jsx(nn,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[9999]"}),m.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[9999]",children:m.jsx(Ae.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"w-[90vw] md:w-[500px]",children:m.jsxs(on,{className:"bg-white dark:bg-exkalibur-elements-background-depth-1 rounded-lg border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark shadow-xl",children:[m.jsxs("div",{className:"p-6 space-y-4",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"w-10 h-10 rounded-xl bg-exkalibur-elements-background-depth-3 flex items-center justify-center text-purple-500",children:m.jsx("span",{className:"i-ph:git-branch w-5 h-5"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"text-lg font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:"Repository Overview"}),m.jsx("p",{className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:"Review repository details before importing"})]})]}),m.jsx("div",{className:"mt-4 bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 p-4 rounded-lg",children:m.jsx(II,{stats:i})}),s&&m.jsxs("div",{className:"p-3 bg-yellow-50 dark:bg-yellow-500/10 rounded-lg text-sm flex items-start gap-2",children:[m.jsx("span",{className:"i-ph:warning text-yellow-600 dark:text-yellow-500 w-4 h-4 flex-shrink-0 mt-0.5"}),m.jsxs("div",{className:"text-yellow-800 dark:text-yellow-500",children:["This repository is quite large (",uh(i.totalSize),"). Importing it might take a while and could impact performance."]})]})]}),m.jsxs("div",{className:"border-t border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark p-4 flex justify-end gap-3 bg-exkalibur-elements-background-depth-2 dark:bg-exkalibur-elements-background-depth-3 rounded-b-lg",children:[m.jsx(Ae.button,{onClick:e,className:"px-4 py-2 rounded-lg bg-exkalibur-elements-background-depth-3 dark:bg-exkalibur-elements-background-depth-4 text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textSecondary-dark dark:hover:text-exkalibur-elements-textPrimary-dark transition-colors",whileHover:{scale:1.02},whileTap:{scale:.98},children:"Cancel"}),m.jsx(Ae.button,{onClick:t,className:"px-4 py-2 rounded-lg bg-purple-500 text-white hover:bg-purple-600 transition-colors",whileHover:{scale:1.02},whileTap:{scale:.98},children:"Import Repository"})]})]})})})]})})}function $F({isOpen:r,onClose:e}){const[t,i]=A.useState(""),[s,n]=A.useState(!1),[a,o]=A.useState("classic"),l=async c=>{if(c.preventDefault(),!!t.trim()){n(!0);try{const h=await fetch("https://api.github.com/user",{headers:{Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${t}`}});if(h.ok){const u=await h.json(),d={token:t,tokenType:a,user:{login:u.login,avatar_url:u.avatar_url,name:u.name||u.login},connected_at:new Date().toISOString()};localStorage.setItem("github_connection",JSON.stringify(d)),at.set("githubToken",t),at.set("githubUsername",u.login),at.set("git:github.com",JSON.stringify({username:t,password:"x-oauth-basic"})),he.success(`Successfully connected as ${u.login}`),i(""),e()}else h.status===401?he.error("Invalid GitHub token. Please check and try again."):he.error(`GitHub API error: ${h.status} ${h.statusText}`)}catch(h){console.error("Error connecting to GitHub:",h),he.error("Failed to connect to GitHub. Please try again.")}finally{n(!1)}}};return m.jsx(_s,{open:r,onOpenChange:c=>!c&&e(),children:m.jsxs(sn,{children:[m.jsx(nn,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[9999]"}),m.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[9999]",children:m.jsx(Ae.div,{initial:{opacity:0,scale:.95}
239,animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},children:m.jsxs(on,{className:"bg-white dark:bg-[#1A1A1A] rounded-lg shadow-xl max-w-sm w-full mx-4 overflow-hidden",children:[m.jsxs("div",{className:"p-4 space-y-3",children:[m.jsx("h2",{className:"text-lg font-semibold text-[#111111] dark:text-white",children:"Access Private Repositories"}),m.jsx("p",{className:"text-sm text-[#666666] dark:text-[#999999]",children:"To access private repositories, you need to connect your GitHub account by providing a personal access token."}),m.jsxs("div",{className:"bg-[#F9F9F9] dark:bg-[#252525] p-4 rounded-lg space-y-3",children:[m.jsx("h3",{className:"text-base font-medium text-[#111111] dark:text-white",children:"Connect with GitHub Token"}),m.jsxs("form",{onSubmit:l,className:"space-y-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-sm text-[#666666] dark:text-[#999999] mb-1",children:"GitHub Personal Access Token"}),m.jsx("input",{type:"password",value:t,onChange:c=>i(c.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxx",className:"w-full px-3 py-1.5 rounded-lg border border-[#E5E5E5] dark:border-[#333333] bg-white dark:bg-[#1A1A1A] text-[#111111] dark:text-white placeholder-[#999999] text-sm"}),m.jsxs("div",{className:"mt-1 text-xs text-[#666666] dark:text-[#999999]",children:["Get your token at"," ",m.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-purple-500 hover:underline",children:"github.com/settings/tokens"})]})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("label",{className:"block text-sm text-[#666666] dark:text-[#999999]",children:"Token Type"}),m.jsxs("div",{className:"flex gap-4",children:[m.jsxs("label",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"radio",checked:a==="classic",onChange:()=>o("classic"),className:"w-3.5 h-3.5 accent-purple-500"}),m.jsx("span",{className:"text-sm text-[#111111] dark:text-white",children:"Classic"})]}),m.jsxs("label",{className:"flex items-center gap-2",children:[m.jsx("input",{type:"radio",checked:a==="fine-grained",onChange:()=>o("fine-grained"),className:"w-3.5 h-3.5 accent-purple-500"}),m.jsx("span",{className:"text-sm text-[#111111] dark:text-white",children:"Fine-grained"})]})]})]}),m.jsx("button",{type:"submit",disabled:s,className:"w-full py-2 bg-purple-500 hover:bg-purple-600 text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm",children:s?"Connecting...":"Connect to GitHub"})]})]}),m.jsxs("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-3 rounded-lg space-y-1.5",children:[m.jsxs("h3",{className:"text-sm text-amber-800 dark:text-amber-300 font-medium flex items-center gap-1.5",children:[m.jsx("span",{className:"i-ph:warning-circle w-4 h-4"}),"Accessing Private Repositories"]}),m.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400",children:"Important things to know about accessing private repositories:"}),m.jsxs("ul",{className:"list-disc pl-4 text-xs text-amber-700 dark:text-amber-400 space-y-0.5",children:[m.jsx("li",{children:"You must be granted access to the repository by its owner"}),m.jsx("li",{children:"Your GitHub token must have the 'repo' scope"}),m.jsx("li",{children:"For organization repositories, you may need additional permissions"}),m.jsx("li",{children:"No token can give you access to repositories you don't have permission for"})]})]})]}),m.jsx("div",{className:"border-t border-[#E5E5E5] dark:border-[#333333] p-3 flex justify-end",children:m.jsx(Sa,{asChild:!0,children:m.jsx("button",{onClick:e,className:"px-4 py-1.5 bg-transparent bg-[#F5F5F5] hover:bg-[#E5E5E5] dark:bg-[#252525] dark:hover:bg-[#333333] rounded-lg text-[#111111] dark:text-white transition-colors text-sm",children:"Close"})})})]})})})]})})}function HF({isOpen:r,onClose:e,onSelect:t}){const[i,s]=A.useState(null),[n,a]=A.useState(!1),[o,l]=A.useState([]),[c,h]=A.useState(""),[u,d]=A.useState([]),[f,_]=A.useState("my-repos"),[b,p]=A.useState(""),[g,v]=A.useState([]),[x,w]=A.useState(""),[S,k]=A.useState({}),[C,y]=A.useState(!1),[E,D]=A.useState(null),[T,M]=A.useState(""),[R,O]=A.useState(!1),$=()=>{O(!1),f==="my-repos"&&G()};A.useEffect(()=>{Ks("github_connection")},[r]),A.useEffect(()=>{r&&f==="my-repos"&&G()},[r,f]);const G=async()=>{const X=Ks("github_connection");if(!X?.token){he.error("Please connect your GitHub account first");return}a(!0);try{const F=await fetch("https://api.github.com/user/repos?sort=updated&per_page=100&type=all",{headers:{Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${X.token}`}});if(!F.ok)throw new Error("Failed to fetch repositories");const P=await F.json();if(Array.isArray(P)&&P.every(j=>typeof j=="object"&&j!==null&&"full_name"in j))l(P);else throw new Error("Invalid repository data format")}catch(F){console.error("Error fetching repos:",F),he.error("Failed to fetch your repositories")}finally{a(!1)}},V=async X=>{a(!0),d([]);try{let F=X;S.language&&(F+=` language:${S.language}`),S.stars&&(F+=` stars:>${S.stars}`),S.forks&&(F+=` forks:>${S.forks}`);const P=await fetch(`https://api.github.com/search/repositories?q=${encodeURIComponent(F)}&sort=stars&order=desc`,{headers:{Accept:"application/vnd.github.v3+json"}});if(!P.ok)throw new Error("Failed to search repositories");const j=await P.json();if(typeof j=="object"&&j!==null&&"items"in j&&Array.isArray(j.items))d(j.items);else throw new Error("Invalid search results format")}catch(F){console.error("Error searching repos:",F),he.error("Failed to search repositories")}finally{a(!1)}},q=async X=>{a(!0);try{const F=Ks("github_connection"),P=F?.token?{Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${F.token}`}:{},j=await fetch(`https://api.github.com/repos/${X.full_name}/branches`,{headers:P});if(!j.ok)throw new Error("Failed to fetch branches");const B=await j.json();if(Array.isArray(B)&&B.every(K=>typeof K=="object"&&K!==null&&"name"in K))v(B.map(K=>({name:K.name,default:K.name===X.default_branch})));else throw new Error("Invalid branch data format")}catch(F){console.error("Error fetching branches:",F),he.error("Failed to fetch branches")}finally{a(!1)}},L=async X=>{s(X),await q(X)},N=X=>`${X.replace(/\/tree\/[^/]+/,"").replace(/\/$/,"").replace(/\.git$/,"")}.git`,I=async X=>{try{let F=null,P=X;if(X.includes("#")){const Ce=X.split("#");P=Ce[0],F=Ce[1]}const[j,B]=P.replace(/\.git$/,"").split("/").slice(-2),K=Ks("github_connection");let U={};K?.token&&(U={Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${K.token}`});const Y=await fetch(`https://api.github.com/repos/${j}/${B}`,{headers:U});if(!Y.ok)throw Y.status===401||Y.status===403?new Error(`Authentication failed (${Y.status}). Your GitHub token may be invalid or missing the required permissions.`):Y.status===404?new Error(`Repository not found or is private (${Y.status}). To access private repositories, you need to connect your GitHub account or provide a valid token with appropriate permissions.`):new Error(`Failed to fetch repository information: ${Y.statusText} (${Y.status})`);let ie=(await Y.json()).default_branch||"main";F&&(ie=F);let le=await fetch(`https://api.github.com/repos/${j}/${B}/git/trees/${ie}?recursive=1`,{headers:U});if(!le.ok&&(le=await fetch(`https://api.github.com/repos/${j}/${B}/git/trees/master?recursive=1`,{headers:U}),le.ok||(le=await fetch(`https://api.github.com/repos/${j}/${B}/git/trees/main?recursive=1`,{headers:U})),!le.ok))throw new Error("Failed to fetch repository structure. Please check the repository URL and your access permissions.");const ne=await le.json();let re=0,me=0;const pe={};let se=!1,ge=!1;for(const Ce of ne.tree)if(Ce.type==="blob"){if(me++,Ce.size&&(re+=Ce.size),Ce.path==="package.json"){se=!0;const Fe=await fetch(`https://api.github.com/repos/${j}/${B}/contents/package.json`,{headers:U});if(Fe.ok){const Ke=await Fe.json(),Le=JSON.parse(Se.from(Ke.content,"base64").toString());
239ge=!!(Le.dependencies||Le.devDependencies||Le.peerDependencies)}}const _e=Ce.path.split(".").pop()?.toLowerCase();_e&&(pe[_e]=(pe[_e]||0)+(Ce.size||0))}return{totalFiles:me,totalSize:re,languages:pe,hasPackageJson:se,hasDependencies:ge}}catch(F){console.error("Error verifying repository:",F);const P=F instanceof Error?F.message:"Failed to verify repository";return(P.includes("Authentication failed")||P.includes("may be private")||P.includes("Repository not found or is private")||P.includes("Unauthorized")||P.includes("401")||P.includes("403")||P.includes("404")||P.includes("access permissions"))&&O(!0),he.error(P),null}},H=async()=>{try{let X;if(f==="url"&&b)X=N(b);else if(i)X=N(i.html_url),x&&(X=`${X}#${x}`);else return;const F=await I(X);if(!F)return;D(F),M(X),y(!0)}catch(X){console.error("Error preparing repository:",X);const F=X instanceof Error?X.message:"Failed to prepare repository. Please try again.";F.includes("Authentication failed")||F.includes("may be private")||F.includes("Repository not found or is private")||F.includes("Unauthorized")||F.includes("401")||F.includes("403")||F.includes("404")||F.includes("access permissions")?(O(!0),he.error(m.jsxs("div",{className:"space-y-2",children:[m.jsx("p",{children:F}),m.jsx("button",{onClick:()=>O(!0),className:"underline font-medium block text-purple-500",children:"Learn how to access private repositories"})]}),{autoClose:1e4})):he.error(F)}},W=()=>{y(!1),T&&(t(T),e())},J=(X,F)=>{let P=F;(X==="stars"||X==="forks")&&(P=F?parseInt(F,10):void 0),k(j=>({...j,[X]:P})),V(c)},Z=()=>{a(!1),h(""),d([]),e()};return m.jsx(Yk.Provider,{value:{setShowAuthDialog:O},children:m.jsxs(_s,{open:r,onOpenChange:X=>{X||Z()},children:[m.jsxs(sn,{children:[m.jsx(nn,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50"}),m.jsxs(on,{className:"fixed top-[50%] left-[50%] -translate-x-1/2 -translate-y-1/2 w-[90vw] md:w-[650px] max-h-[85vh] overflow-hidden bg-white dark:bg-exkalibur-elements-background-depth-1 rounded-xl shadow-xl z-[51] border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("div",{className:"p-5 border-b border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-purple-500/20 to-blue-500/10 flex items-center justify-center text-purple-500 shadow-sm",children:m.jsx("span",{className:"i-ph:github-logo w-5 h-5"})}),m.jsxs("div",{children:[m.jsx(Ap,{className:"text-lg font-semibold text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:"Import GitHub Repository"}),m.jsx("p",{className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:"Clone a repository from GitHub to your workspace"})]})]}),m.jsxs(Sa,{onClick:Z,className:ce("p-2 rounded-lg transition-all duration-200 ease-in-out bg-transparent","text-exkalibur-elements-textTertiary hover:text-exkalibur-elements-textPrimary","dark:text-exkalibur-elements-textTertiary-dark dark:hover:text-exkalibur-elements-textPrimary-dark","hover:bg-exkalibur-elements-background-depth-2 dark:hover:bg-exkalibur-elements-background-depth-3","focus:outline-none focus:ring-2 focus:ring-exkalibur-elements-borderColor dark:focus:ring-exkalibur-elements-borderColor-dark"),children:[m.jsx("span",{className:"i-ph:x block w-5 h-5","aria-hidden":"true"}),m.jsx("span",{className:"sr-only",children:"Close dialog"})]})]}),m.jsxs("div",{className:"p-4 border-b border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark flex items-center justify-between bg-gradient-to-r from-exkalibur-elements-background-depth-2 to-exkalibur-elements-background-depth-1 dark:from-exkalibur-elements-background-depth-3 dark:to-exkalibur-elements-background-depth-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"i-ph:info text-blue-500"}),m.jsx("span",{className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:"Need to access private repositories?"})]}),m.jsxs(Ae.button,{onClick:()=>O(!0),className:"px-3 py-1.5 rounded-lg bg-purple-500 hover:bg-purple-600 text-white text-sm transition-colors flex items-center gap-1.5 shadow-sm",whileHover:{scale:1.02,boxShadow:"0 4px 8px rgba(124, 58, 237, 0.2)"},whileTap:{scale:.98},children:[m.jsx("span",{className:"i-ph:github-logo w-4 h-4"}),"Connect GitHub Account"]})]}),m.jsxs("div",{className:"p-5",children:[m.jsx("div",{className:"mb-6",children:m.jsx("div",{className:"bg-[#f0f0f0] dark:bg-[#1e1e1e] rounded-lg overflow-hidden border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:m.jsxs("div",{className:"flex",children:[m.jsx("button",{onClick:()=>
239_("my-repos"),className:ce("flex-1 py-3 px-4 text-center text-sm font-medium transition-colors",f==="my-repos"?"bg-[#e6e6e6] dark:bg-[#2a2a2a] text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark":"bg-[#f0f0f0] dark:bg-[#1e1e1e] text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark hover:bg-[#e6e6e6] dark:hover:bg-[#2a2a2a]/50"),children:"My Repos"}),m.jsx("button",{onClick:()=>_("search"),className:ce("flex-1 py-3 px-4 text-center text-sm font-medium transition-colors",f==="search"?"bg-[#e6e6e6] dark:bg-[#2a2a2a] text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark":"bg-[#f0f0f0] dark:bg-[#1e1e1e] text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark hover:bg-[#e6e6e6] dark:hover:bg-[#2a2a2a]/50"),children:"Search"}),m.jsx("button",{onClick:()=>_("url"),className:ce("flex-1 py-3 px-4 text-center text-sm font-medium transition-colors",f==="url"?"bg-[#e6e6e6] dark:bg-[#2a2a2a] text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark":"bg-[#f0f0f0] dark:bg-[#1e1e1e] text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark hover:bg-[#e6e6e6] dark:hover:bg-[#2a2a2a]/50"),children:"From URL"})]})})}),f==="url"?m.jsxs("div",{className:"space-y-5",children:[m.jsxs("div",{className:"bg-gradient-to-br from-exkalibur-elements-background-depth-1 to-exkalibur-elements-background-depth-1 dark:from-exkalibur-elements-background-depth-2-dark dark:to-exkalibur-elements-background-depth-2-dark p-5 rounded-xl border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("h3",{className:"text-base font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark mb-3 flex items-center gap-2",children:[m.jsx("span",{className:"i-ph:link-simple w-4 h-4 text-purple-500"}),"Repository URL"]}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-purple-500",children:m.jsx("span",{className:"i-ph:github-logo w-5 h-5"})}),m.jsx(Tm,{type:"text",placeholder:"Enter GitHub repository URL (e.g., https://github.com/user/repo)",value:b,onChange:X=>p(X.target.value),className:"w-full pl-10 py-3 border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark focus:ring-2 focus:ring-purple-500 focus:border-transparent"})]}),m.jsx("div",{className:"mt-3 text-xs text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark bg-white/50 dark:bg-exkalibur-elements-background-depth-4/50 p-3 rounded-lg border border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30 backdrop-blur-sm",children:m.jsxs("p",{className:"flex items-start gap-2",children:[m.jsx("span",{className:"i-ph:info w-3.5 h-3.5 flex-shrink-0 mt-0.5 text-blue-500"}),m.jsxs("span",{children:["You can paste any GitHub repository URL, including specific branches or tags.",m.jsx("br",{}),m.jsx("span",{className:"text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:"Example: https://github.com/username/repository/tree/branch-name"})]})]})})]}),m.jsxs("div",{className:"flex items-center gap-3 text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:[m.jsx("div",{className:"h-px flex-grow bg-exkalibur-elements-borderColor dark:bg-exkalibur-elements-borderColor-dark"}),m.jsx("span",{children:"Ready to import?"}),m.jsx("div",{className:"h-px flex-grow bg-exkalibur-elements-borderColor dark:bg-exkalibur-elements-borderColor-dark"})]}),m.jsxs(Ae.button,{onClick:H,disabled:!b,className:ce("w-full h-12 px-4 py-2 rounded-xl text-white transition-all duration-200 flex items-center gap-2 justify-center",b?"bg-gradient-to-r from-purple-500 to-purple-600 hover:from-purple-600 hover:to-purple-700 shadow-md":"bg-gray-300 dark:bg-gray-700 cursor-not-allowed"),whileHover:b?{scale:1.02,boxShadow:"0 4px 12px rgba(124, 58, 237, 0.3)"}:{},whileTap:b?{scale:.98}:{},children:[m.jsx("span",{className:"i-ph:git-pull-request w-5 h-5"}),"Import Repository"]})]}):m.jsxs(m.Fragment,{children:[f==="search"&&m.jsx("div",{className:"space-y-5 mb-5",children:m.jsxs("div",{className:"bg-gradient-to-br from-blue-500/5 to-cyan-500/5 p-5 rounded-xl border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("h3",{className:"text-base font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark mb-3 flex items-center gap-2",children:[m.jsx("span",{className:"i-ph:magnifying-glass w-4 h-4 text-blue-500"}
239),"Search GitHub"]}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("div",{className:"flex-1",children:m.jsx(Rm,{placeholder:"Search GitHub repositories...",value:c,onChange:X=>{h(X.target.value),X.target.value.length>2&&V(X.target.value)},onKeyDown:X=>{X.key==="Enter"&&c.length>2&&V(c)},onClear:()=>{h(""),d([])},iconClassName:"text-blue-500",className:"py-3 bg-white dark:bg-exkalibur-elements-background-depth-4 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark focus:outline-none focus:ring-2 focus:ring-blue-500 shadow-sm",loading:n})}),m.jsx(Ae.button,{onClick:()=>k({}),className:"px-3 py-2 rounded-lg bg-white dark:bg-exkalibur-elements-background-depth-4 text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},title:"Clear filters",children:m.jsx("span",{className:"i-ph:funnel-simple w-4 h-4"})})]}),m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"text-xs text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark mb-2",children:"Filters"}),(S.language||S.stars||S.forks)&&m.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:m.jsxs(Ui,{children:[S.language&&m.jsx(rd,{label:"Language",value:S.language,icon:"i-ph:code",active:!0,onRemove:()=>{const X={...S};delete X.language,k(X),c.length>2&&V(c)}}),S.stars&&m.jsx(rd,{label:"Stars",value:`>${S.stars}`,icon:"i-ph:star",active:!0,onRemove:()=>{const X={...S};delete X.stars,k(X),c.length>2&&V(c)}}),S.forks&&m.jsx(rd,{label:"Forks",value:`>${S.forks}`,icon:"i-ph:git-fork",active:!0,onRemove:()=>{const X={...S};delete X.forks,k(X),c.length>2&&V(c)}})]})}),m.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[m.jsxs("div",{className:"relative col-span-3 md:col-span-1",children:[m.jsx("div",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:m.jsx("span",{className:"i-ph:code w-3.5 h-3.5"})}),m.jsx("input",{type:"text",placeholder:"Language (e.g., javascript)",value:S.language||"",onChange:X=>{k({...S,language:X.target.value}),c.length>2&&V(c)},className:"w-full pl-8 px-3 py-2 text-sm rounded-lg bg-white dark:bg-exkalibur-elements-background-depth-4 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:m.jsx("span",{className:"i-ph:star w-3.5 h-3.5"})}),m.jsx("input",{type:"number",placeholder:"Min stars",value:S.stars||"",onChange:X=>J("stars",X.target.value),className:"w-full pl-8 px-3 py-2 text-sm rounded-lg bg-white dark:bg-exkalibur-elements-background-depth-4 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark",children:m.jsx("span",{className:"i-ph:git-fork w-3.5 h-3.5"})}),m.jsx("input",{type:"number",placeholder:"Min forks",value:S.forks||"",onChange:X=>J("forks",X.target.value),className:"w-full pl-8 px-3 py-2 text-sm rounded-lg bg-white dark:bg-exkalibur-elements-background-depth-4 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]})]}),m.jsx("div",{className:"mt-3 text-xs text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark bg-white/50 dark:bg-exkalibur-elements-background-depth-4/50 p-3 rounded-lg border border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30 backdrop-blur-sm",children:m.jsxs("p",{className:"flex items-start gap-2",children:[m.jsx("span",{className:"i-ph:info w-3.5 h-3.5 flex-shrink-0 mt-0.5 text-blue-500"}),m.jsx("span",{children:"Search for repositories by name, description, or topics. Use filters to narrow down results."})]})})]})}),m.jsx("div",{className:"space-y-3 max-h-[400px] overflow-y-auto pr-2 custom-scrollbar",children:i?m.jsxs("div",{className:"space-y-5 bg-gradient-to-br from-purple-500/5 to-blue-500/5 p-5 rounded-xl border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(Ae.button,{onClick:()=>s(null),className:"p-2 rounded-lg hover:bg-white dark:hover:bg-exkalibur-elements-background-depth-4 text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary shadow-sm",whileHover:{scale:1.1},whileTap:{scale:.9},children:m.jsx("span",{className:"i-ph:arrow-left w-4 h-4"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark text-lg",children:i.name}),m.jsxs("p",{className:"text-xs text-exkalibur-elements-textTertiary dark:text-exkalibur-elements-textTertiary-dark flex items-center gap-1",children:[m.jsx("span",{className:"i-ph:user w-3 h-3"}),i.full_name.split("/")[0]]})]})]}),i.private&&m.jsx(Ut,{variant:"primary",size:"md",icon:"i-ph:lock
239w-3 h-3",children:"Private"})]}),i.description&&m.jsx("div",{className:"bg-white/50 dark:bg-exkalibur-elements-background-depth-4/50 p-3 rounded-lg border border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30 backdrop-blur-sm",children:m.jsx("p",{className:"text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:i.description})}),m.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.language&&m.jsx(Ut,{variant:"subtle",size:"md",icon:"i-ph:code w-3 h-3",children:i.language}),m.jsx(Ut,{variant:"subtle",size:"md",icon:"i-ph:star w-3 h-3",children:i.stargazers_count.toLocaleString()}),i.forks_count>0&&m.jsx(Ut,{variant:"subtle",size:"md",icon:"i-ph:git-fork w-3 h-3",children:i.forks_count.toLocaleString()})]}),m.jsxs("div",{className:"pt-3 border-t border-exkalibur-elements-borderColor/30 dark:border-exkalibur-elements-borderColor-dark/30",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[m.jsx("span",{className:"i-ph:git-branch w-4 h-4 text-purple-500"}),m.jsx("label",{className:"text-sm font-medium text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:"Select Branch"})]}),m.jsx("select",{value:x,onChange:X=>w(X.target.value),className:"w-full px-3 py-3 rounded-lg bg-white dark:bg-exkalibur-elements-background-depth-4 border border-exkalibur-elements-borderColor dark:border-exkalibur-elements-borderColor-dark text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark focus:outline-none focus:ring-2 focus:ring-purple-500 shadow-sm",children:g.map(X=>m.jsxs("option",{value:X.name,className:"bg-white dark:bg-exkalibur-elements-background-depth-4 text-exkalibur-elements-textPrimary dark:text-exkalibur-elements-textPrimary-dark",children:[X.name," ",X.default?"(default)":""]},X.name))})]}),m.jsxs("div",{className:"flex items-center gap-3 text-sm text-exkalibur-elements-textSecondary dark:text-exkalibur-elements-textSecondary-dark",children:[m.jsx("div",{className:"h-px flex-grow bg-exkalibur-elements-borderColor/30 dark:bg-exkalibur-elements-borderColor-dark/30"}),m.jsx("span",{children:"Ready to import?"}),m.jsx("div",{className:"h-px flex-grow bg-exkalibur-elements-borderColor/30 dark:bg-exkalibur-elements-borderColor-dark/30"})]}),m.jsxs(Ae.button,{onClick:H,className:"w-full h-12 px-4 py-2 rounded-xl bg-gradient-to-r from-purple-500 to-purple-600 hover:from-purple-600 hover:to-purple-700 text-white transition-all duration-200 flex items-center gap-2 justify-center shadow-md",whileHover:{scale:1.02,boxShadow:"0 4px 12px rgba(124, 58, 237, 0.3)"},whileTap:{scale:.98},children:[m.jsx("span",{className:"i-ph:git-pull-request w-5 h-5"}),"Import ",i.name]})]}):m.jsx(BF,{repos:f==="my-repos"?o:u,isLoading:n,onSelect:L,activeTab:f})})]})]})]})]}),m.jsx($F,{isOpen:R,onClose:$}),E&&m.jsx(FF,{isOpen:C,onClose:()=>y(!1),onConfirm:W,stats:E,isLargeRepo:E.totalSize>50*1024*1024})]})})}
239const zF=["node_modules/**",".git/**",".github/**",".vscode/**","dist/**","build/**",".next/**","coverage/**",".cache/**",".idea/**","**/*.log","**/.DS_Store","**/npm-debug.log*","**/yarn-debug.log*","**/yarn-error.log*","**/*lock.json","**/*lock.yaml"],WF=Kx().add(zF),UF=100*1024,VF=500*1024;function KF({importChat:r,className:e}){const{ready:t,gitClone:i}=IF(),[s,n]=A.useState(!1),[a,o]=A.useState(!1),{keycloak:l}=yi(),{total_available_credits:c}=yo(),[h,u]=A.useState(!1),d=c<9,f=async _=>{if(t){n(!0),u(!0);try{const{workdir:b,data:p}=await i(_);if(r){const g=Object.keys(p).filter(D=>!WF.ignores(D)),v=new TextDecoder("utf-8");let x=0;const w=[],S=[];for(const D of g){const{data:T,encoding:M}=p[D];if(T instanceof Uint8Array&&!D.match(/\.(txt|md|astro|mjs|js|jsx|ts|tsx|json|html|css|scss|less|yml|yaml|xml|svg|vue|svelte)$/i)){w.push(D);continue}try{const R=M==="utf8"?T:T instanceof Uint8Array?v.decode(T):"";if(!R)continue;const O=new TextEncoder().encode(R).length;if(O>UF){w.push(`${D} (too large: ${Math.round(O/1024)}KB)`);continue}if(x+O>VF){w.push(`${D} (would exceed total size limit)`);continue}x+=O,S.push({path:D,content:R})}catch(R){w.push(`${D} (error: ${R.message})`)}}const k=await Wx(S),C=Ux(k),E=[{role:"assistant",content:`Cloning the repo ${_} into ${b} 240${w.length>0?` 241Skipped files (${w.length}): 242${w.map(D=>`- ${D}`).join(` 243`)}`:""} 244 245<exkaliburArtifact id="imported-files" title="Git Cloned Files" type="bundled"> 246${S.map(D=>`<exkaliburAction type="file" filePath="${D.path}"> 247${Vx(D.content)} 248</exkaliburAction>`).join(` 249`)} 250</exkaliburArtifact>`,id:uc(),createdAt:new Date}];C&&E.push(C),await r(`Git Project:${_.split("/").slice(-1)[0]}`,E)}}catch(b){console.error("Error during import:",b),he.error("Failed to import repository")}finally{n(!1)}}};return m.jsxs(m.Fragment,{children:[m.jsxs(wa,{onClick:()=>o(!0),title:"Clone a Git Repo",variant:"default",className:ce("gap-1 sm:gap-2 bg-exkalibur-elements-background-depth-1","text-exkalibur-elements-textPrimary","hover:bg-exkalibur-elements-background-depth-2","border border-exkalibur-elements-borderColor","h-8 px-2 py-1 sm:h-10 sm:px-4 sm:py-2 min-w-[80px] sm:min-w-[120px] justify-center","transition-all duration-200 ease-in-out","text-xs sm:text-sm","rounded-lg",e),disabled:h||!l?.authenticated||l.tokenParsed?.billingPlan==="free"||d,children:[m.jsx("span",{className:"i-ph:git-branch w-3 h-3 sm:w-4 sm:h-4 flex-shrink-0"}),m.jsx("span",{className:"hidden sm:inline",children:"Clone a Git Repo"}),m.jsx("span",{className:"sm:hidden",children:"Clone"})]}),m.jsx(HF,{isOpen:a,onClose:()=>o(!1),onSelect:f}),s&&m.jsx(NI,{message:"Please wait while we clone the repository..."})]})}const qF=({files:r,imageDataList:e,onRemove:t})=>!r||r.length===0?null:m.jsx("div",{className:"flex flex-row overflow-hidden mx-2 -mt-1 p-2 bg-exkalibur-elements-background-depth-3 border border-b-none border-exkalibur-elements-borderColor rounded-lg rounded-b-none",children:r.map((i,s)=>m.jsx("div",{className:"mr-2 relative",children:e[s]&&m.jsxs("div",{className:"relative",children:[m.jsx("img",{src:e[s],alt:i.name,className:"max-h-20 rounded-lg"}),m.jsx("button",{onClick:()=>t(s),className:"absolute -top-1 -right-1 z-10 bg-black rounded-full w-5 h-5 shadow-md hover:bg-gray-900 transition-colors flex items-center justify-center",children:m.jsx("div",{className:"i-ph:x w-3 h-3 text-gray-200"})}),m.jsx("div",{className:"absolute bottom-0 w-full h-5 flex items-center px-2 rounded-b-lg text-exkalibur-elements-textTertiary font-thin text-xs bg-exkalibur-elements-background-depth-2",children:m.jsx("span",{className:"truncate",children:i.name})})]})},i.name+i.size))}),GF=({isListening:r,onStart:e,onStop:t,disabled:i})=>m.jsx(jt,{title:r?"Stop listening":"Start speech recognition",disabled:i,className:ce("transition-all",{"text-exkalibur-elements-item-contentAccent":r}),onClick:r?t:e,children:r?m.jsx("div",{className:"i-ph:microphone-slash text-xl"}):m.jsx("div",{className:"i-ph:microphone text-xl"})}),XF=({setUploadedFiles:r,setImageDataList:e,uploadedFiles:t,imageDataList:i})=>(A.useEffect(()=>(r&&e&&(window.__exkalibur_SET_UPLOADED_FILES__=r,window.__exkalibur_SET_IMAGE_DATA_LIST__=e,window.__exkalibur_UPLOADED_FILES__=t,window.__exkalibur_IMAGE_DATA_LIST__=i),()=>{delete window.__exkalibur_SET_UPLOADED_FILES__,delete window.__exkalibur_SET_IMAGE_DATA_LIST__,delete window.__exkalibur_UPLOADED_FILES__,delete window.__exkalibur_IMAGE_DATA_LIST__}),[r,e,t,i]),null),YF=({template:r})=>{const{keycloak:e}=yi(),{total_available_credits:t}=yo(),i=t<9;return`${r.githubRepo}`,!e?.authenticated||e.tokenParsed?.billingPlan==="free"||i?m.jsx("div",{className:"items-center justify-center cursor-not-allowed",title:`${r.label} (Disabled)`,children:m.jsx("div",{className:`inline-block ${r.icon} w-8 h-8 text-4xl transition-theme opacity-15 grayscale pointer-events-none dark:text-white dark:opacity-20 transition-all`})}):m.jsx("a",{href:`/git?url=https://github.com/${r.githubRepo}.git`,"data-state":"closed","data-discover":"true",className:"items-center justify-center",children:m.jsx("div",{className:`inline-block ${r.icon} w-8 h-8 text-4xl transition-theme opacity-25 hover:opacity-100 hover:text-purple-500 dark:text-white dark:opacity-50 dark:hover:opacity-100 dark:hover:text-purple-400 transition-all`,title:r.label})})},ZF=()=>m.jsxs("div",{className:"flex flex-col items-center gap-4",children:[m.jsx("span",{className:"text-sm text-gray-500",children:"or start a blank app with your favorite stack"}),m.jsx("div",{className:"flex justify-center",children:m.jsx("div",{className:"flex flex-wrap justify-center items-center gap-4 max-w-sm",children:Sh.filter(r=>r.icon).map(r=>m.jsx(YF,{template:r},r.name))})})]});function JF({alert:r,clearAlert:e,postMessage:t}){const{type:i,title:s,description:n,content:a,url:o,stage:l,buildStatus:c,deployStatus:h}=r,u=l&&(c||h);return m.jsx(Ui,{children:m.jsxs(Ae.div,{initial:{opacity:0,y:-20}
250,animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:"relative rounded-lg border border-exkalibur-elements-borderColor bg-exkalibur-elements-background-depth-2 p-4 mb-2",children:[m.jsx("button",{onClick:e,className:"absolute top-3 right-3 hover:opacity-70 transition-opacity","aria-label":"Close alert",children:m.jsx("div",{className:"i-ph:x text-lg text-exkalibur-elements-textSecondary hover:text-exkalibur-elements-textPrimary"})}),m.jsxs("div",{className:"flex items-start pr-8",children:[m.jsx(Ae.div,{className:"flex-shrink-0",initial:{scale:0},animate:{scale:1},transition:{delay:.2},children:m.jsx("div",{className:ce("text-xl",i==="success"?"i-ph:check-circle-duotone text-exkalibur-elements-icon-success":i==="error"?"i-ph:warning-duotone text-exkalibur-elements-button-danger-text":"i-ph:info-duotone text-exkalibur-elements-loader-progress")})}),m.jsxs("div",{className:"ml-3 flex-1",children:[m.jsx(Ae.h3,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.1},className:"text-sm font-medium text-exkalibur-elements-textPrimary",children:s}),m.jsxs(Ae.div,{initial:{opacity:0}
250,animate:{opacity:1},transition:{delay:.2},className:"mt-2 text-sm text-exkalibur-elements-textSecondary",children:[m.jsx("p",{children:n}),u&&m.jsx("div",{className:"mt-4 mb-2",children:m.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[m.jsxs("div",{className:"flex items-center",children:[m.jsx("div",{className:ce("w-6 h-6 rounded-full flex items-center justify-center",c==="running"?"bg-exkalibur-elements-loader-progress":c==="complete"?"bg-exkalibur-elements-icon-success":c==="failed"?"bg-exkalibur-elements-button-danger-background":"bg-exkalibur-elements-textTertiary"),children:c==="running"?m.jsx("div",{className:"i-svg-spinners:90-ring-with-bg text-white text-xs"}):c==="complete"?m.jsx("div",{className:"i-ph:check text-white text-xs"}):c==="failed"?m.jsx("div",{className:"i-ph:x text-white text-xs"}):m.jsx("span",{className:"text-white text-xs",children:"1"})}),m.jsx("span",{className:"ml-2",children:"Build"})]}),m.jsx("div",{className:ce("h-0.5 w-8",c==="complete"?"bg-exkalibur-elements-icon-success":"bg-exkalibur-elements-textTertiary")}),m.jsxs("div",{className:"flex items-center",children:[m.jsx("div",{className:ce("w-6 h-6 rounded-full flex items-center justify-center",h==="running"?"bg-exkalibur-elements-loader-progress":h==="complete"?"bg-exkalibur-elements-icon-success":h==="failed"?"bg-exkalibur-elements-button-danger-background":"bg-exkalibur-elements-textTertiary"),children:h==="running"?m.jsx("div",{className:"i-svg-spinners:90-ring-with-bg text-white text-xs"}):h==="complete"?m.jsx("div",{className:"i-ph:check text-white text-xs"}):h==="failed"?m.jsx("div",{className:"i-ph:x text-white text-xs"}):m.jsx("span",{className:"text-white text-xs",children:"2"})}),m.jsx("span",{className:"ml-2",children:"Deploy"})]})]})}),a&&m.jsx("div",{className:"text-xs text-exkalibur-elements-textSecondary p-2 bg-exkalibur-elements-background-depth-3 rounded mt-4 mb-4",children:a}),o&&i==="success"&&m.jsx("div",{className:"mt-2",children:m.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-exkalibur-elements-item-contentAccent hover:underline flex items-center",children:[m.jsx("span",{className:"mr-1",children:"View deployed site"}),m.jsx("div",{className:"i-ph:arrow-square-out"})]})})]}),m.jsx(Ae.div,{className:"mt-4",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},children:m.jsx("div",{className:ce("flex gap-2"),children:m.jsx("button",{onClick:e,className:ce("px-2 py-1.5 rounded-md text-sm font-medium","bg-exkalibur-elements-button-secondary-background","hover:bg-exkalibur-elements-button-secondary-backgroundHover","focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-exkalibur-elements-button-secondary-background","text-exkalibur-elements-button-secondary-text"),children:"Dismiss"})})})]})]})]})})}function QF({alert:r,clearAlert:e,postMessage:t,isStreaming:i}){const{description:s,content:n,source:a}=r,[o,l]=A.useState(!1),[c,h]=A.useState(!1),u=a==="preview",d=u?"Preview Error":"Terminal Error",f=u?"We encountered an error while running the preview. Would you like exkalibur to analyze and help resolve this issue?":"We encountered an error while running terminal commands. Would you like exkalibur to analyze and help resolve this issue?";return A.useEffect(()=>{if(i)h(!0),l(!1);else if(c&&!i){const _=setTimeout(()=>{l(!0)},500);return()=>clearTimeout(_)}},[i,c]),A.useEffect(()=>{i||l(!0)},[r,i]),i||!o?null:m.jsx(Ui,{children:m.jsxs(Ae.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:"rounded-lg border border-exkalibur-elements-borderColor bg-exkalibur-elements-background-depth-2 p-4 mb-2 relative",children:[m.jsx("button",{onClick:e,className:"absolute top-3 right-3","aria-label":"Close alert",children:m.jsx("div",{className:"i-ph:x text-lg"})}),m.jsxs("div",{className:"flex items-start pr-6",children:[m.jsx(Ae.div,{className:"flex-shrink-0",initial:{scale:0},animate:{scale:1},transition:{delay:.2},children:m.jsx("div",{className:"i-ph:warning-duotone text-xl text-exkalibur-elements-button-danger-text"})}),m.jsxs("div",{className:"ml-3 flex-1",children:[m.jsx(Ae.h3,{initial:{opacity:0}
250,animate:{opacity:1},transition:{delay:.1},className:"text-sm font-medium text-exkalibur-elements-textPrimary",children:d}),m.jsxs(Ae.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"mt-2 text-sm text-exkalibur-elements-textSecondary",children:[m.jsx("p",{children:f}),s&&m.jsxs("div",{className:"text-xs text-exkalibur-elements-textSecondary p-2 bg-exkalibur-elements-background-depth-3 rounded mt-4 mb-4",children:["Error: ",s]})]}),m.jsx(Ae.div,{className:"mt-4",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},children:m.jsxs("div",{className:ce(" flex gap-2"),children:[m.jsxs("button",{onClick:()=>t(`*Fix this ${u?"preview":"terminal"} error* 251\`\`\`${u?"js":"sh"} 252${n} 253\`\`\` 254`),className:ce("px-2 py-1.5 rounded-md text-sm font-medium","bg-exkalibur-elements-button-primary-background","hover:bg-exkalibur-elements-button-primary-backgroundHover","focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-exkalibur-elements-button-danger-background","text-exkalibur-elements-button-primary-text","flex items-center gap-1.5"),children:[m.jsx("div",{className:"i-ph:chat-circle-duotone"}),"Ask to exkalibur."]}),m.jsx("button",{onClick:e,className:ce("px-2 py-1.5 rounded-md text-sm font-medium","bg-exkalibur-elements-button-secondary-background","hover:bg-exkalibur-elements-button-secondary-backgroundHover","focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-exkalibur-elements-button-secondary-background","text-exkalibur-elements-button-secondary-text"),children:"Dismiss"})]})})]})]})]})})}function e8({data:r}){const[e,t]=ke.useState([]),[i,s]=A.useState(!1);return ke.useEffect(()=>{if(!r||r.length==0){t([]);return}const n=new Map;r.forEach(o=>{const l=n.get(o.label);l&&l.status==="complete"||n.set(o.label,o)});const a=Array.from(n.values());a.sort((o,l)=>o.order-l.order),t(a)},[r]),e.length===0?m.jsx(m.Fragment,{}):m.jsx(Ui,{children:m.jsx("div",{className:ce("bg-exkalibur-elements-background-depth-2","border border-exkalibur-elements-borderColor","shadow-lg rounded-lg relative w-full max-w-chat mx-auto z-prompt","p-1"),children:m.jsxs("div",{className:ce("bg-exkalibur-elements-item-backgroundAccent","p-1 rounded-lg text-exkalibur-elements-item-contentAccent","flex "),children:[m.jsx("div",{className:"flex-1",children:m.jsx(Ui,{children:i?m.jsx(Ae.div,{className:"actions",initial:{height:0},animate:{height:"auto"},exit:{height:"0px"},transition:{duration:.15},children:e.map((n,a)=>m.jsx(mx,{progress:n},a))}):m.jsx(mx,{progress:e.slice(-1)[0]})})}),m.jsx(Ae.button,{initial:{width:0},animate:{width:"auto"},exit:{width:0},transition:{duration:.15,ease:Ss},className:" p-1 rounded-lg bg-exkalibur-elements-item-backgroundAccent hover:bg-exkalibur-elements-artifacts-backgroundHover",onClick:()=>s(n=>!n),children:m.jsx("div",{className:i?"i-ph:caret-up-bold":"i-ph:caret-down-bold"})})]})})})}const mx=({progress:r})=>m.jsxs(Ae.div,{className:ce("flex text-sm gap-3"),initial:{opacity:0}
254,animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[m.jsx("div",{className:"flex items-center gap-1.5 ",children:m.jsx("div",{children:r.status==="in-progress"?m.jsx("div",{className:"i-svg-spinners:90-ring-with-bg"}):r.status==="complete"?m.jsx("div",{className:"i-ph:check"}):null})}),r.message]}),gx=typeof localStorage<"u"?localStorage.getItem("supabase_connection"):null,vx=typeof localStorage<"u"?localStorage.getItem("supabaseCredentials"):null,lo=gx?JSON.parse(gx):{user:null,token:"",stats:void 0,selectedProjectId:void 0,isConnected:!1,project:void 0};if(vx&&!lo.credentials)try{lo.credentials=JSON.parse(vx)}catch(r){console.error("Failed to parse saved credentials:",r)}const _h=Rx(lo);lo.token&&!lo.stats&&r8(lo.token).catch(console.error);const bx=Rx(!1);function t8(r){const e=_h.get();if(r.user!==void 0||r.token!==void 0){const i=r.user!==void 0?r.user:e.user,s=r.token!==void 0?r.token:e.token;r.isConnected=!!(i&&s)}if(r.selectedProjectId!==void 0)if(r.selectedProjectId&&e.stats?.projects){const i=e.stats.projects.find(s=>s.id===r.selectedProjectId);i?r.project=i:r.project={id:r.selectedProjectId,name:`Project ${r.selectedProjectId.substring(0,8)}...`,region:"unknown",organization_id:"",status:"active",created_at:new Date().toISOString()}}else r.selectedProjectId===""&&(r.project=void 0,r.credentials=void 0);const t={...e,...r};_h.set(t),r.user||r.token||r.selectedProjectId!==void 0||r.credentials?(localStorage.setItem("supabase_connection",JSON.stringify(t)),t.credentials?localStorage.setItem("supabaseCredentials",JSON.stringify(t.credentials)):localStorage.removeItem("supabaseCredentials")):(localStorage.removeItem("supabase_connection"),localStorage.removeItem("supabaseCredentials"))}async function r8(r){bx.set(!0);try{const e=await fetch("/api/supabase",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r})});if(!e.ok)throw new Error("Failed to fetch projects");const t=await e.json();t8({user:t.user,stats:t.stats})}catch(e){throw console.error("Failed to fetch Supabase stats:",e),e}finally{bx.set(!1)}}function i8({alert:r,clearAlert:e,postMessage:t}){const{content:i}=r,s=Ve(_h),[n,a]=A.useState(!1),[o,l]=A.useState(!0),c=!!(s.token&&s.selectedProjectId),h=c?"Supabase Query":"Supabase Connection Required",u=c?"Execute database query":"Supabase connection required",d=c?"Please review the proposed changes and apply them to your database.":"Please connect to Supabase to continue with this operation.",f=()=>{document.dispatchEvent(new CustomEvent("open-supabase-connection"))},_=!c,b=async g=>{if(!s.token||!s.selectedProjectId){console.error("No Supabase token or project selected");return}a(!0);try{const v=await fetch("/api/supabase/query",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.token}`},body:JSON.stringify({projectId:s.selectedProjectId,query:g})});if(!v.ok){const w=await v.json();throw new Error(`Supabase query failed: ${w.error?.message||v.statusText}`)}const x=await v.json();console.log("Supabase query executed successfully:",x),e()}catch(v){console.error("Failed to execute Supabase action:",v),t(`*Error executing Supabase query please fix and return the query again* 255\`\`\` 256${v instanceof Error?v.message:String(v)} 257\`\`\` 258`)}finally{a(!1)}},p=g=>{if(!g)return"";let v=g.replace(/\/\*[\s\S]*?\*\//g,"");return v=v.replace(/(--).*$/gm,"").replace(/(#).*$/gm,""),v.split(";").map(w=>w.trim()).filter(w=>w.length>0).join(`; 259 260`)};return m.jsx(Ui,{children:m.jsxs(Ae.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:"max-w-chat rounded-lg border-l-2 border-l-[#098F5F] border border-exkalibur-elements-borderColor bg-exkalibur-elements-background-depth-2",children:[m.jsx("div",{className:"p-4 pb-2",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("img",{height:"10",width:"18",crossOrigin:"anonymous",src:"https://cdn.simpleicons.org/supabase"}),m.jsx("h3",{className:"text-sm font-medium text-[#3DCB8F]",children:h})]})}),m.jsx("div",{className:"px-4",children:c?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center p-2 rounded-md bg-exkalibur-elements-background-depth-3 cursor-pointer",onClick:()=>l(!o),children:[m.jsx("div",{className:"i-ph:database text-exkalibur-elements-textPrimary mr-2"}),m.jsx("span",{className:"text-sm text-exkalibur-elements-textPrimary flex-grow",children:u||"Create table and setup auth"}),m.jsx("div",{className:`i-ph:caret-up text-exkalibur-elements-textPrimary transition-transform ${o?"rotate-180":""}`})]}),!o&&i&&m.jsx("div",{className:"mt-2 p-3 bg-exkalibur-elements-background-depth-4 rounded-md overflow-auto max-h-60 font-mono text-xs text-exkalibur-elements-textSecondary",children:m.jsx("pre",{children:p(i)})})]}):m.jsx("div",{className:"p-3 rounded-md bg-exkalibur-elements-background-depth-3",children:m.jsx("span",{className:"text-sm text-exkalibur-elements-textPrimary",children:"You must first connect to Supabase and select a project."})})}),m.jsxs("div",{className:"p-4",children:[m.jsx("p",{className:"text-sm text-exkalibur-elements-textSecondary mb-4",children:d}),m.jsxs("div",{className:"flex gap-2",children:[_?m.jsx("button",{onClick:f,className:ce("px-3 py-2 rounded-md text-sm font-medium","bg-[#098F5F]","hover:bg-[#0aa06c]","focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500","text-white","flex items-center gap-1.5"),children:"Connect to Supabase"}):m.jsx("button",{onClick:()=>b(i),disabled:n,className:ce("px-3 py-2 rounded-md text-sm font-medium","bg-[#098F5F]","hover:bg-[#0aa06c]","focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500","text-white","flex items-center gap-1.5",n?"opacity-70 cursor-not-allowed":""),children:n?"Applying...":"Apply Changes"}),m.jsx("button",{onClick:e,disabled:n,className:ce("px-3 py-2 rounded-md text-sm font-medium","bg-[#503B26]","hover:bg-[#774f28]","focus:outline-none","text-[#F79007]",n?"opacity-70 cursor-not-allowed":""),children:"Dismiss"})]})]})]})})}const s8=()=>(A.useEffect(()=>{if(!document.querySelector('script[src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"]')){const r=document.createElement("script");r.src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js",r.async=!0,document.body.appendChild(r)}},[]),m.jsx(m.Fragment,{children:m.jsxs("div",{className:`relative p-3 rounded-lg border border-yellow-600 border-dashed 261 w-full max-w-chat mx-auto bg-white/5 backdrop-blur-md border-white/15 shadow-lg`,children:[m.jsxs("h3",{className:`text-[25px] font-semibold uppercase tracking-wide mb-1 text-yellow-400 ${zr.onlyiBrand}
261`,children:["Limited browser support",m.jsx("lottie-player",{src:"app\\components\\chat\\public\\warning_icon.json",background:"transparent",speed:"1",style:{width:"40px",height:"40px",display:"inline-block",verticalAlign:"middle"},loop:!0,autoplay:!0})]}),m.jsxs("p",{className:` ${zr.onlyInter} text-[15px] text-yellow-500`,children:["Due to browser-specific limitations in Safari, some core functionalities are not available for the moment. For full access, we recommend using ",m.jsx("a",{className:"font-bold",href:"https://www.google.com/chrome/what-you-make-of-it/",children:"Chrome"})," or ",m.jsx("a",{className:"font-bold",href:"https://www.microsoft.com/en-us/edge/download",children:"Edge"})]})]})})),n8={operational:"Operational",degraded_performance:"Degraded performance",partial_outage:"Partial outage",major_outage:"Major outage"},xx=r=>{switch(r){case"Operational":return"text-green-600";case"Degraded performance":return"text-yellow-600";case"Partial outage":return"text-orange-600";case"Major outage":return"text-red-600";default:return"text-gray-600"}},o8=({textareaRef:r,showPopup:e,showedPopup:t,setShowPopup:i,setShowedPopup:s})=>{const[n,a]=A.useState(""),[o,l]=A.useState(""),c=A.useRef(n),h=A.useRef(e),u=A.useRef(null),d=A.useCallback(f=>{h.current&&!t&&u.current&&!u.current.contains(f.target)&&(i(!1),s(!0),document.removeEventListener("mousedown",d))},[t]);return A.useEffect(()=>{c.current=n},[n]),A.useEffect(()=>{h.current=e},[e]),A.useEffect(()=>{function f(_){(c.current==="Partial outage"||c.current==="Major outage")&&(i(!0),setTimeout(()=>{document.addEventListener("mousedown",d)},0))}return t||r?.current?.addEventListener("mousedown",f),()=>{r?.current?.removeEventListener("mousedown",f)}},[r,t]),A.useEffect(()=>{async function f(){try{const p=await(async w=>{try{return await(await fetch(w)).json()}catch(S){return console.error(`Error checking ${w}:`,S),"unreachable"}})("https://status.claude.com/api/v2/components.json"),g=new Date(p.page.updated_at),v=`${g.toLocaleTimeString()} (${g.toLocaleDateString()})`,x=n8[p.components.find(w=>w.name==="Claude API (api.anthropic.com)").status]||"Unknown status";a(x),l(v)}catch{a(""),l("")}}f();const _=setInterval(f,10*60*1e3);return()=>clearInterval(_)},[]),A.useEffect(()=>{if(!document.querySelector('script[src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"]')){const f=document.createElement("script");f.src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js",f.async=!0,document.body.appendChild(f)}},[]),m.jsx(m.Fragment,{children:e&&!t&&n!==""&&m.jsx("div",{className:"fixed top-1/2 left-1/2 z-[9999] -translate-x-1/2 -translate-y-1/2",children:m.jsxs("div",{className:`md:pb-[50px] sm:pb-[70px] w-full sm:max-w-[750px] max-w-[350px] min-w-[350px] h-full sm:max-h-[500px] max-h-[450px] z-[10000] relative p-10 rounded-lg border w-full mx-auto bg-black/60 backdrop-blur-md border-white/15 shadow-lg ${zr.onlyInter} dark:text-white`,ref:u,children:[m.jsx("h2",{className:`sm:text-[30px] text-[22px] font-semibold mb-1 ${zr.onlyiBrand} ${xx(n)}`,children:n==="Partial outage"?m.jsxs(m.Fragment,{children:["Degraded performance",m.jsx("lottie-player",{src:"app\\components\\chat\\public\\warning_icon.json",background:"transparent",speed:"1",style:{width:"40px",height:"40px",display:"inline-block",verticalAlign:"middle"},loop:!0,autoplay:!0})," "]}):n==="Major outage"?m.jsxs(m.Fragment,{children:["Service unavailable",m.jsx("lottie-player",{src:"app\\components\\chat\\public\\alert_icon.json",background:"transparent",speed:"1",style:{width:"40px",height:"40px",display:"inline-block",verticalAlign:"middle"},loop:!0,autoplay:!0})," "]}):""}),m.jsx("h3",{className:"text-[12px] sm:text-sm text-white/70 mb-4",children:n==="Partial outage"||n==="Major outage"?"Cause: External issue with Anthropic":""}),n==="Partial outage"&&m.jsxs("p",{className:"text-[14px] sm:text-[16px] leading-relaxed",children:["We're currently experiencing degraded performance due to an external issue with Anthropic's API.",m.jsx("br",{}),"Core features still work, but responses may be slower or less consistent.",m.jsx("br",{}),"We're monitoring the situation and will update you as soon as it's resolved."]}),n==="Major outage"&&m.jsxs("p",{className:"text-[15px] sm:text-[16
261px] leading-relaxed",children:["Our application is currently impacted by a significant external service outage at Anthropic.",m.jsx("br",{}),"Weâre actively monitoring the situation and will restore functionality as soon as itâs resolved."]}),m.jsxs("p",{className:`relative ${xx(n)} text-[10px] sm:text-[12px] mt-4 text-white/60`,children:["Anthropic status: ",n," - Updated at ",o]}),m.jsx("button",{id:"serverStatus",onClick:()=>{i(!1),s(!0),document.removeEventListener("mousedown",d)},className:"text-[14px] sm:text-[16px] absolute right-3 bottom-3 inline-flex items-center justify-center whitespace-nowrap rounded-[50px] font-medium transition-colors bg-[#00A7FF] text-exkalibur-elements-textPrimary hover:bg-[#B335FF] hover:backdrop-blur-sm hover:border hover:border-white/20 h-10 px-4 py-2 min-w-[120px] border border-exkalibur-elements-borderColor",children:"I understand"})]})})})},ac=({show:r,type:e="insufficient",daysUntilExpiration:t=0})=>{if(!r)return null;const i=e==="expiration",s=e==="lowSubscription",n=e==="veryLowCredits",a=i||s||n?"#f1c232":"#f15e32",o=i||s||n?"line-gradient-warning":"line-gradient-red",l=i||s||n?"shine-gradient-warning":"shine-gradient-red",c=()=>{if(i){const h=t===1?"day":"days";return m.jsxs("a",{href:"/billingPlan",children:[m.jsx("span",{className:"font-semibold",children:"Warning :"})," Your purchased credits expire in ",t," ",h,".",m.jsx("br",{}),m.jsx("u",{children:"Purchase"})," new credits or ",m.jsx("u",{children:"subscribe"})," to a plan to continue."]})}else return s?m.jsxs("a",{href:"/billingPlan",children:[m.jsx("span",{className:"font-semibold",children:"Warning :"})," Your subscription credits are running low (⤠50 remaining).",m.jsx("br",{}),m.jsx("u",{children:"Consider upgrading"})," your plan to ensure uninterrupted service."]}):n?m.jsxs("a",{href:"/billingPlan",children:[m.jsx("span",{className:"font-semibold",children:"Warning :"})," Your Purchased credits are very low (⤠25 remaining).",m.jsx("br",{}),m.jsx("u",{children:"Purchase"})," new credits or ",m.jsx("u",{children:"subscribe"})," to a plan to continue."]}):m.jsxs("a",{href:"/billingPlan",children:["Your credit balance is insufficient to create a new project.",m.jsx("br",{}),"Please ",m.jsx("u",{children:"upgrade"})," your plan to continue using the service."]})};return m.jsxs("div",{className:ce("relative p-3 rounded-lg border w-full max-w-chat mx-auto z-prompt bg-white/10 backdrop-blur-md border-white/20 shadow-lg"),children:[m.jsxs("svg",{className:ce(zr.CreditsLimitAlertEffectContainer),children:[m.jsxs("defs",{children:[m.jsxs("linearGradient",{id:o,x1:"20%",y1:"0%",x2:"-14%",y2:"10%",gradientUnits:"userSpaceOnUse",gradientTransform:"rotate(-45)",children:[m.jsx("stop",{offset:"0%",stopColor:a,stopOpacity:"0%"}),m.jsx("stop",{offset:"40%",stopColor:a,stopOpacity:"80%"}),m.jsx("stop",{offset:"50%",stopColor:a,stopOpacity:"80%"}),m.jsx("stop",{offset:"100%",stopColor:a,stopOpacity:"0%"})]}),m.jsxs("linearGradient",{id:l,children:[m.jsx("stop",{offset:"0%",stopColor:a,stopOpacity:"0%"}),m.jsx("stop",{offset:"40%",stopColor:a,stopOpacity:"80%"}),m.jsx("stop",{offset:"50%",stopColor:a,stopOpacity:"80%"}),m.jsx("stop",{offset:"100%",stopColor:a,stopOpacity:"0%"})]})]}),m.jsx("rect",{className:ce(zr.CreditsLimitAlertEffectLine),pathLength:"20",strokeLinecap:"round",stroke:`url(#${o})`}),m.jsx("rect",{className:ce(zr.CreditsLimitAlertShine),x:"48",y:"24",width:"70",height:"1",fill:`url(#${l})`})]}),m.jsx("div",{className:ce("relative shadow-xs border border-exkalibur-elements-borderColor backdrop-blur rounded-lg"),children:m.jsx("div",{className:ce("p-1 rounded-lg text-exkalibur-elements-textPrimary",zr.CreditsLimitAlertText),children:c()})})]})},a8=({isPreviewMode:r,onToggle:e,className:t=""})=>{const i=A.useRef(0),s=A.useRef(0),n=A.useRef(null),a=h=>{i.current=h.changedTouches[0].screenX},o=h=>{s.current=h.changedTouches[0].screenX,l()},l=()=>{const u=i.current-s.current;Math.abs(u)>50&&(u>0?e(!0):e(!1))},c=()=>{e(!r)};return A.useEffect(()=>{const h=n.current;if(h)return h.addEventListener("touchstart",a,{passive:!0}),h.addEventListener("touchend",o,{passive:!0}),()=>{h.removeEventListener("touchstart",a),h.removeEventListener("touchend",o)}},[]),m.jsx("div",{className:ce("flex justify-center",t),children:m.jsxs("button",{ref:n,onClick:c,className:ce("flex items-center gap-2 px-4 py-3 rounded-lg border cursor-pointer transition-all duration-200","bg-white/10 backdrop-blur-md border-white/20 shadow-sm hover:shadow-md","active:scale-95 touch-pan-x select-none","text-blue-600 dar
261k:text-blue-400 border-blue-500/30"),children:[m.jsx("div",{className:"i-ph:device-mobile text-lg"}),m.jsx("span",{className:"text-sm font-medium",children:"Preview"})]})})},l8=76,c8=({isVisible:r,checkInterval:e=5e3,onKeysAvailable:t})=>{const i=ME();return A.useEffect(()=>{r&&i.load("/api/redis/check-keys")},[r]),A.useEffect(()=>{if(!r)return;if(i.data?.available){t?.();return}const s=setInterval(()=>{i.load("/api/redis/check-keys")},e);return()=>clearInterval(s)},[r,i.data,e,t]),r?m.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:[m.jsx("div",{className:"bg-exkalibur-elements-background-depth-2 border border-exkalibur-elements-borderColor rounded-2xl p-8 max-w-lg w-full mx-4 shadow-2xl",children:m.jsxs("div",{className:"flex flex-col items-center gap-6",children:[m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"w-20 h-20 border-4 border-white/20 rounded-full"}),m.jsx("div",{className:"absolute top-0 left-0 w-20 h-20 border-4 border-transparent border-t-#ff99cc rounded-full animate-spin"}),m.jsx("div",{className:"absolute top-2 left-2 w-16 h-16 border-4 border-transparent border-t-#cc66ff rounded-full animate-spin",style:{animationDuration:"1.5s"}})]}),m.jsxs("div",{className:"text-center",children:[m.jsx("h3",{className:"text-2xl font-semibold text-white mb-3",children:"ð API key allocation in progress"}),m.jsx("p",{className:"text-exkalibur-elements-textPrimary text-base leading-relaxed",children:"We are generating and assigning an API key for you."})]}),m.jsx("div",{className:"w-full bg-gradient-to-r from-#ff99cc/10 to-#cc66ff/10 rounded-lg p-4 border border-#ff99cc/20",children:m.jsxs("div",{className:"text-center text-sm text-exkalibur-elements-textPrimary space-y-2",children:[m.jsx("p",{className:"font-medium",children:"Why wait?"}),m.jsx("p",{className:"text-xs leading-relaxed",children:"To ensure the best quality of service, we automatically generate new API keys when the pool is empty. This page will update automatically as soon as a key becomes available."})]})}),m.jsxs("div",{className:"w-full",children:[m.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:m.jsx("div",{className:"h-full bg-gradient-to-r from-#ff99cc via-#cc66ff to-#ff99cc",style:{animation:"progress 2s ease-in-out infinite",backgroundSize:"200% 100%"}})}),m.jsx("p",{className:"text-xs text-center text-exkalibur-elements-textSecondary mt-2",children:"Do not close this page, you will be redirected automatically."})]})]})}),m.jsx("style",{children:` 262 @keyframes progress { 263 0% { background-position: 200% 0; } 264 100% { background-position: -200% 0; } 265 } 266 `})]}):null},h8=({isModelSettingsCollapsed:r,setIsModelSettingsCollapsed:e,providerList:t,showCreditsLimitAlert:i})=>{const[s,n]=A.useState(!1),a=A.useRef(null);return A.useEffect(()=>{const o=l=>{a.current&&!a.current.contains(l.target)&&n(!1)};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[]),m.jsxs("div",{className:"relative",ref:a,children:[m.jsx(jt,{title:"More Options",className:"transition-all flex items-center gap-1",onClick:()=>n(!s),disabled:!t||t.length===0||i,children:m.jsx("div",{className:"i-ph:sliders text-lg"})}),s&&m.jsx("div",{className:"absolute bottom-full mb-2 left-0 bg-exkalibur-elements-background-depth-2 border border-exkalibur-elements-borderColor rounded-lg shadow-lg min-w-[160px] z-50",children:m.jsxs("div",{className:"py-1",children:[m.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-white bg-exkalibur-elements-background-depth-2 hover:bg-#ff99cc/20 transition-all flex items-center gap-2",onClick:()=>{e(!r),n(!1)},children:["Settings",m.jsx("div",{className:`i-ph:caret-${r?"right":"down"} text-sm ml-auto`})]}),m.jsx("div",{className:"h-px bg-exkalibur-elements-borderColor my-1"})]})})]})},u8=({textareaRef:r,chatStarted:e=!1,isStreaming:t=!1,input:i="",provider:s,providerList:n,handleStop:a,sendMessage:o,handleInputChange:l,exportChat:c,uploadedFiles:h=[],setUploadedFiles:u,imageDataList:d=[],setImageDataList:f,apiKeys:_,onApiKeysChange:b,onProviderChange:p,onModelChange:g,recognition:v,isListening:x,startListening:w,stopListening:S,transcript:k,showCreditsLimitAlert:C,showPopup:y,showedPopup:E,userHasTyped:D,userHasFocused:T,setUserHasTyped:M,setUserHasFocused:R,textValue:O,isTyping:$,setTextValue:G,setIsTyping:V,isMobilePreviewMode:q,setIsMobilePreviewMode:L,isModelSettingsCollapsed:N,setIsModelSettingsCollapsed:I,actionRunner:H})=>{const W=e?400:200,J=qx(1024),Z=Ve(wh),[X,F]=A.useState(!1),[P,j]=A.useState(!1);A.useEffect(()=>{Z&&F(!0)}
266,[Z]);const B=(re,me)=>{o&&(o(re,me),v&&(v.abort(),V(!1),l&&l({target:{value:""}})))},K=async(re,me)=>{try{const se=await(await fetch("/api/redis/check-keys")).json();se.available&&se.activeKeys>0?B(re,me):j(!0)}catch(pe){console.error("Error checking keys:",pe),B(re,me)}},U=()=>{j(!1),setTimeout(()=>{if(r?.current){const re=new Event("submit");B(re)}},1e3)},Y=()=>{const re=document.createElement("input");re.type="file",re.accept="image/*",re.onchange=async me=>{const pe=me.target.files?.[0];if(pe){const se=new FileReader;se.onload=ge=>{const Ee=ge.target?.result;u?.([...h,pe]),f?.([...d,Ee])},se.readAsDataURL(pe)}},re.click()},ee=async re=>{const me=re.clipboardData?.items;if(me){for(const pe of me)if(pe.type.startsWith("image/")){re.preventDefault();const se=pe.getAsFile();if(se){const ge=new FileReader;ge.onload=Ee=>{const Ce=Ee.target?.result;u?.([...h,se]),f?.([...d,Ce])},ge.readAsDataURL(se)}break}}},ie=re=>{const me=re.target.value;me.length>0?M(!0):me.length===0&&M(!1)},le=()=>{r?.current&&!e&&(r.current.placeholder=""),$&&(G(""),V(!1)),R(!0)},ne=()=>{R(!1),r?.current&&r.current.value.length>0&&M(!0),r?.current&&!e&&(r.current.placeholder="")};return m.jsxs(m.Fragment,{children:[m.jsx(Vs,{children:()=>m.jsx(c8,{isVisible:P,checkInterval:5e3,onKeysAvailable:U})}),m.jsxs("div",{className:ce("relative p-3 rounded-2xl border w-full max-w-chat mx-auto bg-white/10 backdrop-blur-md border-white/20 shadow-lg","border-white/30"),style:{zIndex:45},children:[J&&e&&m.jsx(a8,{isPreviewMode:q,onToggle:L,className:"mb-3"}),m.jsx(qF,{files:h,imageDataList:d,onRemove:re=>{u?.(h.filter((me,pe)=>pe!==re)),f?.(d.filter((me,pe)=>pe!==re))}}),m.jsx(Vs,{children:()=>m.jsx(XF,{setUploadedFiles:u,setImageDataList:f,uploadedFiles:h,imageDataList:d})}),m.jsxs("div",{className:"relative",children:[m.jsx("textarea",{disabled:C,ref:r,readOnly:y&&!E,className:ce("w-full pl-4 pt-4 pr-16 outline-none resize-none text-exkalibur-elements-textPrimary placeholder-exkalibur-elements-textPrimary bg-transparent text-sm","transition-all duration-200","hover:border-exkalibur-elements-focus","styles.border-gradient-white"),onDragEnter:re=>{re.preventDefault()},onDragOver:re=>{re.preventDefault(),re.currentTarget.style.border="2px solid #1488fc"},onDragLeave:re=>{re.preventDefault()},onDrop:re=>{re.preventDefault(),Array.from(re.dataTransfer.files).forEach(pe=>{if(pe.type.startsWith("image/")){const se=new FileReader;se.onload=ge=>{const Ee=ge.target?.result;u?.([...h,pe]),f?.([...d,Ee])},se.readAsDataURL(pe)}})},onKeyDown:re=>{if(re.key==="Enter"){if(re.shiftKey||(re.preventDefault(),C))return;if(t){a?.();return}if(re.nativeEvent.isComposing)return;_[s.name]===void 0||_[s.name]===""?(console.log("checkKeysAndSend"),K(re)):(console.log("handleSendMessage"),j(!1),B(re))}},value:$?O:i,onChange:re=>{l?.(re),ie?.(re)},onFocus:le,onPaste:ee,onBlur:ne,spellCheck:D,style:{minHeight:l8,maxHeight:W},translate:"no",maxLength:600}),m.jsxs("div",{className:"flex justify-between items-center text-sm mt-2",children:[m.jsxs("div",{className:"flex items-center mb-1 mt-1",children:[m.jsx(jt,{disabled:C,title:"Upload file",className:"transition-all",onClick:()=>Y(),children:m.jsx("div",{className:"i-ph:plus text-xl"})}),m.jsx(GF,{isListening:x,onStart:w,onStop:S,disabled:t||C}),m.jsx(h8,{isModelSettingsCollapsed:N,setIsModelSettingsCollapsed:I,providerList:n,showCreditsLimitAlert:C}),e&&m.jsx(Vs,{children:()=>m.jsx(xj,{exportChat:c})}),m.jsxs("div",{className:`${C?"hidden":""}`,style:{fontSize:"0.9rem",color:i.length/255>=.8?"#99322b":"#C5DFF7"},children:[600-i.length," characters left"]})]}),m.jsx("div",{children:m.jsx(Vs,{children:()=>m.jsx(hj,{show:(i.length>0||t||h.length>0)&&!C,isStreaming:t,disabled:!n||n.length===0||C,onClick:re=>{if(r?.current&&(r.current.placeholder=""),R(!1),t){a?.();return}(i.length>0||h.length>0)&&(_[s.name]===void 0||_[s.name]===""?(console.log("checkKeysAndSend"),K(re)):(console.log("handleSendMessage"),j(!1),B(re)))}})})}),m.jsx(TS,{open:X,onClose:()=>F(!1)})]})]})]})]})},d8=Xi("BaseChat"),_x=["web application","restaurant menu","e-commerce","website","booking app","marketplace","dropshipping","configurator","action app","project manager","todo list","event planner","calendar","team chat","forum","social network","invoicing app","job board","support tickets","quiz app","course platform","student portal","personal blog","newsletter","podcast manager","video app","expense tracker","subscription list","crypto tracker","donations app","fitness app","meal planner","meditation app","habit tracker","health booking","snippet manager","log viewer","form builder"],f8=()=>{const[r,e]=A.useState(0);return A.useEffect(()=>{const t=setInterval(()=>{e(i=>(i+1)%_x.length)},1500);return()=>clearInterval(t)},[]),m.jsx("span",{className:"inline-block absolute overflow-hidden text-left pl-1 lg:pl-2 min-w-[30vw]",style:{height:"1.2em"},children:m.jsx("span",{className:"absolute animate-slide-down-pause text-color-[#F798CB]",children:_x[r]},r)})},p8=ke.forwardRef(({textareaRef:r,showChat:e=!0,chatStarted:t=!1,isStreaming:i=!1,onStreamingChange:s,model:n,setModel:a,provider:o,setProvider:l,providerList:c,input:h="",enhancingPrompt:u,handleInputChange:d,enhancePrompt:f,sendMessage:_,handleStop:b,importChat:p,exportChat:g,uploadedFiles:v=[],setUploadedFiles:x,imageDataList:w=[],setImageDataList:S,messages:k,actionAlert:C,clearAlert:y,deployAlert:E,clearDeployAlert:D,supabaseAlert:T,clearSupabaseAlert:M,data:R,actionRunner:O},$)=>{const G="Write here, what do you want to build?",V=qx(1024),q=110,L=2750,N=750,[I,H]=A.useState(Yv()),[W,J]=A.useState([]),[Z,X]=A.useState(!0),[F,P]=A.useState(!1),[j,B]=A.useState(null),[K,U]=A.useState(""),[Y,ee]=A.useState("all"),[ie,le]=A.useState([]),{initialized:ne,keycloak:re,user:me}=yi(),[pe,se]=A.useState(!1),[ge,Ee]=A.useState(!1),[Ce,_e]=A.useState(""),[Fe,Ke]=A.useState(""),[Le,Qe]=A.useState(!0),[Xe,yt]=A.useState(!1),[$e,ki]=A.useState(!1);A.useRef(!1);const{showCreditsError:or,fetchCredits:Br}=yo(),Ci=Ve(wh),[Ei,Ns]=A.useState(!1),[Nt,Zr]=A.useState(!1),[xr,Ai]=A.useState(null),_r=xr?.show_expiration_warning||!1,yr=xr?.show_low_subscription_warning||!1,Ti=xr?.show_very_low_credits_warning||!1,Os=xr?.days_until_expiration||0,[Ji,wr]=A.useState(!0);A.useEffect(()=>{Ci&&Ns(!0)},[Ci]),A.useEffect(()=>{if(!ne||!re?.token){wr(!0);return}(async()=>
266{if(!me?.billingPlan||me.billingPlan==="Free"){d8.debug("Free user dosen't need to get credits "),Ai({remaining_subscription_credits:0,remaining_purchased_credits:0,last_subscription_credits_value:0,current_deficit_credits:0,total_remaining_credits:0,total_available_credits:0,show_expiration_warning:!1,days_until_expiration:0,show_low_subscription_warning:!1,show_very_low_credits_warning:!1}),wr(!1);return}try{const Te=await fetch("/api/redis/remaining-credits",{headers:{Authorization:`Bearer ${re.token}`}});if(Te.ok){const st=await Te.json();Ai(st),setTimeout(()=>{wr(!1)},2e3)}}catch(Te){console.error("Error fetching credits data:",Te),setTimeout(()=>{wr(!1)},2e3)}})()},[ne,re?.token]),A.useEffect(()=>{if(R){const we=R.filter(Te=>typeof Te=="object"&&Te.type==="progress");le(we)}},[R]),A.useEffect(()=>{console.log(K)},[K]),A.useEffect(()=>{const we=navigator.userAgent;/CriOS/i.test(we)?_e("Chrome iOS"):/FxiOS/i.test(we)?_e("Firefox iOS"):/EdgiOS/i.test(we)?_e("Edge iOS"):/safari/i.test(we)&&!/chrome|crios|fxios|edgios/i.test(we)?_e("Safari"):_e("Other")},[]),A.useEffect(()=>{if(typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)){const we=window.SpeechRecognition||window.webkitSpeechRecognition,Te=new we;Te.continuous=!0,Te.interimResults=!0,Te.onresult=st=>{const dt=Array.from(st.results).map(Sr=>Sr[0]).map(Sr=>Sr.transcript).join("");U(dt),d&&d({target:{value:dt}})},Te.onerror=st=>{console.error("Speech recognition error:",st.error),P(!1)},B(Te)}},[]),A.useEffect(()=>{if(ne&&re?.token&&typeof window<"u"){let we={};try{we=Yv(),H(we)}catch(Te){console.error("Error loading API keys from cookies:",Te),at.remove("apiKeys")}ee("all"),fetch("/api/models",{method:"GET",headers:{"Content-Type":"application/json",userKeycloakToken:re?.token||""}}).then(Te=>Te.json()).then(Te=>{J(Te.modelList)}).catch(Te=>{console.error("Error fetching model list:",Te)}).finally(()=>{ee(void 0)})}},[ne,re?.token,c,o]),A.useEffect(()=>{if(!t&&at.get(os)&&r?.current){r.current.placeholder=at.get(os)||"";return}},[]),A.useEffect(()=>{if(!ne)return;if(or&&re?.token){r?.current&&(r.current.placeholder="");return}if(t){r?.current&&(r.current.placeholder=G),Ke(G);return}if(r?.current&&r?.current.placeholder!==""&&r?.current||Xe||$e)return;r?.current&&(r.current.placeholder="");let we,Te;if(Le){let st=0,dt="";Te=setInterval(()=>{dt+=G.charAt(st),Ke(dt),st++,st===G.length&&(clearInterval(Te),we=setTimeout(()=>{setTimeout(()=>{Ke(""),Qe(!1)},2e3)},L))},q)}else we=setTimeout(()=>{Qe(!0)},N);return()=>{clearInterval(Te),clearTimeout(we)}},[Le,Xe,$e,t,ne,or]),A.useEffect(()=>{Br()},[]);const Do=async we=>{l(we),at.set("selectedProvider",we)},Po=async we=>{const Te=Gx[(we||"").trim()==="Google"?"Google":"Anthropic"];a(Te),at.set("selectedModel",Te)},Lo=async(we,Te)=>{at.set("apiKeys",JSON.stringify(Te)),H(Te),ee(we);let st=[];try{st=(await(await fetch(`/api/models/${encodeURIComponent(we)}`,{method:"GET",headers:{"Content-Type":"application/json",userKeycloakToken:re?.token||""}})).json()).modelList}catch(dt){console.error("Error loading dynamic models for:",we,dt)}J(dt=>[...dt.filter(Ln=>Ln.provider!==we),...st]),ee(void 0)},ye=()=>{j&&(j.start(),P(!0))},Ye=()=>{j&&(j.stop(),P(!1))},ut=(we,Te)=>{_&&(Br(),_(we,Te),j&&(j.abort(),U(""),P(!1),d&&d({target:{value:""}})))};if(re?.authenticated&&(Ji||!xr)&&me?.billingPlan&&me.billingPlan!=="Free")return m.jsx(TE,{message:"Loading your workspace..."});const ct=m.jsxs("div",{ref:$,className:ce(zr.BaseChat,"relative flex h-full w-full"),"data-chat-visible":e,children:[re?.authenticated&&m.jsx(o8,{textareaRef:r,setShowPopup:se,setShowedPopup:Ee,showPopup:pe,showedPopup:ge}),(!pe||ge)&&m.jsx(Vs,{children:()=>m.jsx(pE,{})}),m.jsxs("div",{className:`flex w-full h-full modern-scrollbar ${re?.authenticated&&pe&&!ge?"":"overflow-hidden"}`,children:[m.jsxs("div",{className:ce(zr.Chat,"flex flex-col h-full"),children:[!t&&m.jsxs("div",{id:"intro",className:`${Ce==="Safari"?"mt-[2vh]":"mt-[16vh]"} mx-auto text-center px-4 lg:px-0`,children:[Ce==="Safari"&&m.jsx(s8,{}),m.jsx("div",{className:`${Ce==="Safari"?"h-8":"h-1"}`}),m.jsx("img",{src:"/logo-dark-styled.png",className:"hidden dark:block mx-auto w-32 sm:w-48 md:w-60 lg:w-72 xl:w-80 h-auto",alt:"exkalibur. Logo Light Mode"}),m.jsx("img",{src:"/logo-light-styled.png",className:"dark:hidden mx-auto w-32 sm:w-48 md:w-60 lg:w-72 xl:w-80 h-auto",alt:"exkalibur. Logo Dark Mode"}),m.jsx("div",{className:"flex",children:m.jsxs("span",{className:"relative font-ibrand font-normal text-[clamp(1rem,4vw,2.5rem)] pl-[10vw] md:pl-[1vw] text-gray-900 dark:text-white mt-6 sm:mt-8 lg:mt-10 mb-6 sm:mb-8 animate-fade-in animation-delay-200",style:{fontFamily:"IBrand, sans-serif"},children:["Speak your idea, get your",m.jsx(f8,{})]})}),m.jsx("p",{children:m.jsxs("span",{className:`${zr.ibrand} text-xs sm:text-sm md:text-base lg:text-lg text-gray-900 dark:text-white animate-fade-in animation-delay-200 mx-auto text-center mt-3 sm:mt-6 mb-3 sm:mb-6 px-2`,children:["The first AI-powered web application builder 100% Swiss Made. Real support by your ",m.jsx("br",{className:"hidden sm:block"})," side at every step to turn your ideas into success."]})})]}),m.jsxs(Od,{className:ce("px-2 sm:px-6 relative w-auto",{"flex flex-col modern-scrollbar":t,"h-[calc(100vh-4rem)] mt-20":t}),resize:"smooth",initial:"smooth",children:[m.jsx(Od.Content,{className:"flex flex-col gap-4",children:m.jsx(Vs,{children:()=>t?m.jsx(lj,{className:"flex flex-col w-full flex-1 max-w-chat pb-6 mx-auto z-1 overflow-y-auto",messages:k,isStreaming:i}):null})}),m.jsxs("div",{className:ce("my-auto flex flex-col gap-2 w-full max-w-chat mx-auto z-prompt mb-6",{"sticky bottom-2":t,"mt-8":!t}),children:[m.jsxs("div",{className:"flex flex-col gap-2",children:[E&&m.jsx(JF,{alert:E,clearAlert:()=>D?.(),postMessage:we=>{_?.({},we),M?.()}}),T&&m.jsx(i8,{alert:T,clearAlert:()=>M?.(),postMessage:we=>{_?.({},we),M?.()}}),C&&m.jsx(QF,{alert:C,clearAlert:()=>y?.(),postMessage:we=>{_?.({},we),y?.()},isStreaming:i})]}),m.jsx(m8,{}),ie&&m.jsx(e8,{data:ie}),!Ji&&xr&&(_r||yr||Ti||or)&&(_r?m.jsx(ac,{show:_r,type:"expiration",daysUntilExpiration:Os}):yr?m.jsx(ac,{show:yr,type:"lowSubscription"}):Ti?m.jsx(ac,{show:Ti,type:"veryLowCredits"}):or?m.jsx(ac,{show:or,type:"insufficient"}):null),m.jsx(u8,{textareaRef:r,chatStarted:t,isStreaming:i,input:h,provider:o,providerList:c,handleStop:b,sendMessage:ut,handleInputChange:d,exportChat:g,uploadedFiles:v,setUploadedFiles:x,imageDataList:w,setImageDataList:S,apiKeys:I,onApiKeysChange:Lo,onModelChange:Po,onProviderChange:Do,recognition:j,isListening:F,startListening:ye,stopListening:Ye,transcript:K,showCreditsLimitAlert:or,showPopup:pe,showedPopup:ge,userHasTyped:Xe,userHasFocused:$e,setUserHasTyped:yt,setUserHasFocused:ki,textValue:Fe,isTyping:Le,setTextValue:Ke,setIsTyping:Qe,isMobilePreviewMode:Nt,setIsMobilePreviewMode:Zr,isModelSettingsCollapsed:Z,setIsModelSettingsCollapsed:X,actionRunner:O})]})]}),m.jsxs("div",{className:"flex flex-col justify-center",children:[!t&&m.jsxs("div",{className:"flex justify-center gap-2",children:[wj(p
266),m.jsx(KF,{importChat:p})]}),m.jsxs("div",{className:"flex flex-col gap-5",children:[!t&&Sj((we,Te)=>{if(i){b?.();return}ut?.(we,Te)}),!t&&m.jsx(ZF,{})]}),!t&&m.jsx("div",{className:"mt-50",children:m.jsx(mE,{})})]})]}),m.jsx(Vs,{children:()=>(!V||Nt)&&m.jsx(UI,{actionRunner:O??{},chatStarted:t,isStreaming:i,isSmallViewport:V,isMobilePreviewMode:Nt,onMobilePreviewToggle:Zr})})]})]});return m.jsx(gE,{delayDuration:200,children:ct})});function m8(){const{isAtBottom:r,scrollToBottom:e}=Jx();return!r&&m.jsxs("button",{className:"absolute z-50 top-[0%] translate-y-[-100%] text-4xl rounded-lg left-[50%] translate-x-[-50%] px-1.5 py-0.5 flex items-center gap-2 bg-exkalibur-elements-background-depth-3 border border-exkalibur-elements-borderColor text-exkalibur-elements-textPrimary text-sm",onClick:()=>e(),children:["Go to last message",m.jsx("span",{className:"i-ph:arrow-down animate-bounce"})]})}var Zk={exports:{}},Jk={};/** 267 * @license React 268 * use-sync-external-store-shim.production.js 269 * 270 * Copyright (c) Meta Platforms, Inc. and affiliates. 271 * 272 * This source code is licensed under the MIT license found in the 273 * LICENSE file in the root directory of this source tree. 274 */var _o=A;function g8(r,e){return r===e&&(r!==0||1/r===1/e)||r!==r&&e!==e}var v8=typeof Object.is=="function"?Object.is:g8,b8=_o.useState,x8=_o.useEffect,_8=_o.useLayoutEffect,y8=_o.useDebugValue;function w8(r,e){var t=e(),i=b8({inst:{value:t,getSnapshot:e}}),s=i[0].inst,n=i[1];return _8(function(){s.value=t,s.getSnapshot=e,Ad(s)&&n({inst:s})},[r,t,e]),x8(function(){return Ad(s)&&n({inst:s}),r(function(){Ad(s)&&n({inst:s})})},[r]),y8(t),t}function Ad(r){var e=r.getSnapshot;r=r.value;try{var t=e();return!v8(r,t)}catch{return!0}}function S8(r,e){return e()}var k8=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?S8:w8;Jk.useSyncExternalStore=_o.useSyncExternalStore!==void 0?_o.useSyncExternalStore:k8;Zk.exports=Jk;var C8=Zk.exports;const Qk=0,eC=1,tC=2,yx=3;var wx=Object.prototype.hasOwnProperty;function up(r,e){var t,i;if(r===e)return!0;if(r&&e&&(t=r.constructor)===e.constructor){if(t===Date)return r.getTime()===e.getTime();if(t===RegExp)return r.toString()===e.toString();if(t===Array){if((i=r.length)===e.length)for(;i--&&up(r[i],e[i]););return i===-1}if(!t||typeof r=="object"){i=0;for(t in r)if(wx.call(r,t)&&++i&&!wx.call(e,t)||!(t in e)||!up(r[t],e[t]))return!1;return Object.keys(e).length===i}}return r!==r&&e!==e}const Fi=new WeakMap,xs=()=>{},Kt=xs(),dp=Object,We=r=>r===Kt,fi=r=>typeof r=="function",Ms=(r,e)=>({...r,...e}),rC=r=>fi(r.then),Td={},lc={},tg="undefined",gl=typeof window!=tg,fp=typeof document!=tg,E8=gl&&"Deno"in window,A8=()=>gl&&typeof window.requestAnimationFrame!=tg,iC=(r,e)=>{const t=Fi.get(r);return[()=>!We(e)&&r.get(e)||Td,i=>{if(!We(e)){const s=r.get(e);e in lc||(lc[e]=s),t[5](e,Ms(s,i),s||Td)}},t[6],()=>!We(e)&&e in lc?lc[e]:!We(e)&&r.get(e)||Td]};let pp=!0;const T8=()=>pp,[mp,gp]=gl&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[xs,xs],R8=()=>{const r=fp&&document.visibilityState;return We(r)||r!=="hidden"},M8=r=>(fp&&document.addEventListener("visibilitychange",r),mp("focus",r),()=>{fp&&document.removeEventListener("visibilitychange",r),gp("focus",r)}),D8=r=>{const e=()=>{pp=!0,r()},t=()=>{pp=!1};return mp("online",e),mp("offline",t),()=>{gp("online",e),gp("offline",t)}},P8={isOnline:T8,isVisible:R8},L8={initFocus:M8,initReconnect:D8},Sx=!ke.useId,Xa=!gl||E8,N8=r=>A8()?window.requestAnimationFrame(r):setTimeout(r,1),Rd=Xa?A.useEffect:A.useLayoutEffect,Md=typeof navigator<"u"&&navigator.connection,kx=!Xa&&Md&&(["slow-2g","2g"].includes(Md.effectiveType)||Md.saveData),cc=new WeakMap,Dd=(r,e)=>dp.prototype.toString.call(r)===`[object ${e}]`;let O8=0;const vp=r=>{const e=typeof r,t=Dd(r,"Date"),i=Dd(r,"RegExp"),s=Dd(r,"Object");let n,a;if(dp(r)===r&&!t&&!i){if(n=cc.get(r),n)return n;if(n=++O8+"~",cc.set(r,n),Array.isArray(r)){for(n="@",a=0;a<r.length;a++)n+=vp(r[a])+",";cc.set(r,n)}if(s){n="#";const o=dp.keys(r).sort();for(;!We(a=o.pop());
274)We(r[a])||(n+=a+":"+vp(r[a])+",");cc.set(r,n)}}else n=t?r.toJSON():e=="symbol"?r.toString():e=="string"?JSON.stringify(r):""+r;return n},rg=r=>{if(fi(r))try{r=r()}catch{r=""}const e=r;return r=typeof r=="string"?r:(Array.isArray(r)?r.length:r)?vp(r):"",[r,e]};let I8=0;const bp=()=>++I8;async function sC(...r){const[e,t,i,s]=r,n=Ms({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let a=n.populateCache;const o=n.rollbackOnError;let l=n.optimisticData;const c=d=>typeof o=="function"?o(d):o!==!1,h=n.throwOnError;if(fi(t)){const d=t,f=[],_=e.keys();for(const b of _)!/^\$(inf|sub)\$/.test(b)&&d(e.get(b)._k)&&f.push(b);return Promise.all(f.map(u))}return u(t);async function u(d){const[f]=rg(d);if(!f)return;const[_,b]=iC(e,f),[p,g,v,x]=Fi.get(e),w=()=>{const R=p[f];return(fi(n.revalidate)?n.revalidate(_().data,d):n.revalidate!==!1)&&(delete v[f],delete x[f],R&&R[0])?R[0](tC).then(()=>_().data):_().data};if(r.length<3)return w();let S=i,k;const C=bp();g[f]=[C,0];const y=!We(l),E=_(),D=E.data,T=E._c,M=We(T)?D:T;if(y&&(l=fi(l)?l(M,D):l,b({data:l,_c:M})),fi(S))try{S=S(M)}catch(R){k=R}if(S&&rC(S))if(S=await S.catch(R=>{k=R}),C!==g[f][0]){if(k)throw k;return S}else k&&y&&c(k)&&(a=!0,b({data:M,_c:Kt}));if(a&&!k)if(fi(a)){const R=a(S,M);b({data:R,error:Kt,_c:Kt})}else b({data:S,error:Kt,_c:Kt});if(g[f][1]=bp(),Promise.resolve(w()).then(()=>{b({_c:Kt})}),k){if(h)throw k;return}return S}}const Cx=(r,e)=>{for(const t in r)r[t][0]&&r[t][0](e)},j8=(r,e)=>{if(!Fi.has(r)){const t=Ms(L8,e),i=Object.create(null),s=sC.bind(Kt,r);let n=xs;const a=Object.create(null),o=(h,u)=>{const d=a[h]||[];return a[h]=d,d.push(u),()=>d.splice(d.indexOf(u),1)},l=(h,u,d)=>{r.set(h,u);const f=a[h];if(f)for(const _ of f)_(u,d)},c=()=>{if(!Fi.has(r)&&(Fi.set(r,[i,Object.create(null),Object.create(null),Object.create(null),s,l,o]),!Xa)){const h=t.initFocus(setTimeout.bind(Kt,Cx.bind(Kt,i,Qk))),u=t.initReconnect(setTimeout.bind(Kt,Cx.bind(Kt,i,eC)));n=()=>{h&&h(),u&&u(),Fi.delete(r)}}};return c(),[r,s,c,n]}return[r,Fi.get(r)[4]]},B8=(r,e,t,i,s)=>{const n=t.errorRetryCount,a=s.retryCount,o=~~((Math.random()+.5)*(1<<(a<8?a:8)))*t.errorRetryInterval;!We(n)&&a>n||setTimeout(i,o,s)},F8=up,[nC,$8]=j8(new Map),H8=Ms({onLoadingSlow:xs,onSuccess:xs,onError:xs,onErrorRetry:B8,onDiscarded:xs,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:kx?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:kx?5e3:3e3,compare:F8,isPaused:()=>!1,cache:nC,mutate:$8,fallback:{}},P8),z8=(r,e)=>{const t=Ms(r,e);if(e){const{use:i,fallback:s}=r,{use:n,fallback:a}=e;i&&n&&(t.use=i.concat(n)),s&&a&&(t.fallback=Ms(s,a))}return t},W8=A.createContext({}),U8="$inf$",oC=gl&&window.__SWR_DEVTOOLS_USE__,V8=oC?window.__SWR_DEVTOOLS_USE__:[],K8=()=>{oC&&(window.__SWR_DEVTOOLS_REACT__=ke)},q8=r=>fi(r[1])?[r[0],r[1],r[2]||{}]:[r[0],null,(r[1]===null?r[2]:r[1])||{}],G8=()=>Ms(H8,A.useContext(W8)),X8=r=>(e,t,i)=>r(e,t&&((...n)=>{const[a]=rg(e),[,,,o]=Fi.get(nC);if(a.startsWith(U8))return t(...n);const l=o[a];return We(l)?t(...n):(delete o[a],l)}),i),Y8=V8.concat(X8),Z8=r=>function(...t){const i=G8(),[s,n,a]=q8(t),o=z8(i,a);let l=r;const{use:c}=o,h=(c||[]).concat(Y8);for(let u=h.length;u--;)l=h[u](l);return l(s,n||o.fetcher||null,o)},J8=(r,e,t)=>{const i=e[r]||(e[r]=[]);return i.push(t),()=>{const s=i.indexOf(t);s>=0&&(i[s]=i[i.length-1],i.pop())}};K8();const Pd=ke.use||(r=>{switch(r.status){case"pending":throw r;case"fulfilled":return r.value;case"rejected":throw r.reason;default:throw r.status="pending",r.then(e=>{r.status="fulfilled",r.value=e},e=>{r.status="rejected",r.reason=e}),r}}),Ld={dedupe:!0},Q8=(r,e,t)=>{const{cache:i,compare:s,suspense:n,fallbackData:a,revalidateOnMount:o,revalidateIfStale:l,refreshInterval:c,refreshWhenHidden:h,refreshWhenOffline:u,keepPreviousData:d}=t,[f,_,b,p]=Fi.get(i),[g,v]=rg(r),x=A.useRef(!1),w=A.useRef(!1),S=A.useRef(g),k=A.useRef(e),C=A.useRef(t),y=()=>C.current,E=()=>y().isVisible()&&y().isOnline(),[D,T,M,R]=iC(i,g),O=A.useRef({}).current,$=We(a)?We(t.fallback)?Kt:t.fallback[g]:a,G=(Y,ee)=>{for(const ie in O){const le=ie;if(le==="data"){if(!s(Y[le],ee[le])&&(!We(Y[le])||!s(Z,ee[le])))return!1}else if(ee[le]!==Y[le])return!1}return!0},V=A.useMemo(()=>{const Y=!g||!e?!1:We(o)?y().isPaused()||n?!1:l!==!1:o,ee=pe=>{const se=Ms(pe);return delete se._k,Y?{isValidating:!0,isLoading:!0,...se}:se},ie=D(),le=R(),ne=ee(ie),re=ie===le?ne:ee(le);let me=ne;return[()=>{const pe=ee(D());return G(pe,me)?(me.data=pe.data,me.isLoading=pe.isLoading,me.isValidating=pe.isValidating,me.error=pe.error,me):(me=pe,pe)},()=>re]},[i,g]),q=C8.useSyncExternalStore(A.useCallback(Y=>M(g,(ee,ie)=>{G(ie,ee)||Y()}),[i,g]),V[0],V[1]),L=!x.current,N=f[g]&&f[g].length>0,I=q.data,H=We(I)?$&&rC($)?Pd($):$:I,W=q.error,J=A.useRef(H),Z=d?We(I
274)?We(J.current)?H:J.current:I:H,X=N&&!We(W)?!1:L&&!We(o)?o:y().isPaused()?!1:n?We(H)?!1:l:We(H)||l,F=!!(g&&e&&L&&X),P=We(q.isValidating)?F:q.isValidating,j=We(q.isLoading)?F:q.isLoading,B=A.useCallback(async Y=>{const ee=k.current;if(!g||!ee||w.current||y().isPaused())return!1;let ie,le,ne=!0;const re=Y||{},me=!b[g]||!re.dedupe,pe=()=>Sx?!w.current&&g===S.current&&x.current:g===S.current,se={isValidating:!1,isLoading:!1},ge=()=>{T(se)},Ee=()=>{const _e=b[g];_e&&_e[1]===le&&delete b[g]},Ce={isValidating:!0};We(D().data)&&(Ce.isLoading=!0);try{if(me&&(T(Ce),t.loadingTimeout&&We(D().data)&&setTimeout(()=>{ne&&pe()&&y().onLoadingSlow(g,t)},t.loadingTimeout),b[g]=[ee(v),bp()]),[ie,le]=b[g],ie=await ie,me&&setTimeout(Ee,t.dedupingInterval),!b[g]||b[g][1]!==le)return me&&pe()&&y().onDiscarded(g),!1;se.error=Kt;const _e=_[g];if(!We(_e)&&(le<=_e[0]||le<=_e[1]||_e[1]===0))return ge(),me&&pe()&&y().onDiscarded(g),!1;const Fe=D().data;se.data=s(Fe,ie)?Fe:ie,me&&pe()&&y().onSuccess(ie,g,t)}catch(_e){Ee();const Fe=y(),{shouldRetryOnError:Ke}=Fe;Fe.isPaused()||(se.error=_e,me&&pe()&&(Fe.onError(_e,g,Fe),(Ke===!0||fi(Ke)&&Ke(_e))&&(!y().revalidateOnFocus||!y().revalidateOnReconnect||E())&&Fe.onErrorRetry(_e,g,Fe,Le=>{const Qe=f[g];Qe&&Qe[0]&&Qe[0](yx,Le)},{retryCount:(re.retryCount||0)+1,dedupe:!0})))}return ne=!1,ge(),!0},[g,i]),K=A.useCallback((...Y)=>sC(i,S.current,...Y),[]);if(Rd(()=>{k.current=e,C.current=t,We(I)||(J.current=I)}),Rd(()=>{if(!g)return;const Y=B.bind(Kt,Ld);let ee=0;y().revalidateOnFocus&&(ee=Date.now()+y().focusThrottleInterval);const le=J8(g,f,(ne,re={})=>{if(ne==Qk){const me=Date.now();y().revalidateOnFocus&&me>ee&&E()&&(ee=me+y().focusThrottleInterval,Y())}else if(ne==eC)y().revalidateOnReconnect&&E()&&Y();else{if(ne==tC)return B();if(ne==yx)return B(re)}});return w.current=!1,S.current=g,x.current=!0,T({_k:v}),X&&(We(H)||Xa?Y():N8(Y)),()=>{w.current=!0,le()}},[g]),Rd(()=>{let Y;function ee(){const le=fi(c)?c(D().data):c;le&&Y!==-1&&(Y=setTimeout(ie,le))}function ie(){!D().error&&(h||y().isVisible())&&(u||y().isOnline())?B(Ld).then(ee):ee()}return ee(),()=>{Y&&(clearTimeout(Y),Y=-1)}},[c,h,u,g]),A.useDebugValue(Z),n&&We(H)&&g){if(!Sx&&Xa)throw new Error("Fallback data is required when using Suspense in SSR.");k.current=e,C.current=t,w.current=!1;const Y=p[g];if(!We(Y)){const ee=K(Y);Pd(ee)}if(We(W)){const ee=B(Ld);We(Z)||(ee.status="fulfilled",ee.value=!0),Pd(ee)}else throw W}return{mutate:K,get data(){return O.data=!0,Z},get error(){return O.error=!0,W},get isValidating(){return O.isValidating=!0,P},get isLoading(){return O.isLoading=!0,j}}},hc=Z8(Q8);function e$(r,e){if(typeof r!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof r}\`.`);let t,i=0;return function(...n){clearTimeout(t);const a=Date.now(),o=a-i,l=e-o;l<=0?(i=a,r.apply(this,n)):t=setTimeout(()=>{i=Date.now(),r.apply(this,n)},l)}}var t$=e$;const r$=En(t$);function Ex(r,e){return e!=null?r$(r,e):r}var i$=async(r,e,t,i,s,n,a,o,l,c,h,u,d,f,_,b,p,g)=>{var v;const x=a.current;t(e.messages,!1);const w=f?e.messages:e.messages.map(({role:k,content:C,experimental_attachments:y,data:E,annotations:D,toolInvocations:T})=>({role:k,content:C,...y!==void 0&&{experimental_attachments:y},...E!==void 0&&{data:E},...D!==void 0&&{annotations:D},...T!==void 0&&{toolInvocations:T}})),S=s.current;return await bE({api:r,body:(v=_?.({id:g,messages:e.messages,requestData:e.data,requestBody:e.body}))!=null?v:{id:g,messages:w,data:e.data,...n.current.body,...e.body},streamProtocol:c,credentials:n.current.credentials,headers:{...n.current.headers,...e.headers},abortController:()=>o.current,restoreMessagesOnFailure(){p||t(x,!1)},onResponse:u,onUpdate(k,C){t([...e.messages,...k],!1),C?.length&&i([...S??[],...C],!1)},onToolCall:d,onFinish:h,generateId:l,fetch:b})};function s$({api:r="/api/chat",id:e,initialMessages:t,initialInput:i="",sendExtraMessageFields:s,onToolCall:n,experimental_prepareRequestBody:a,maxSteps:o=1,streamProtocol:l="data",onResponse:c,onFinish:h,onError:u,credentials:d,headers:f,body:_,generateId:b=vE,fetch:p,keepLastMessageOnError:g=!0,experimental_throttle:v}={}){const[x]=A.useState(b),w=e??x,S=typeof r=="string"?[r,w]:w,[k]=A.useState([]),{data:C,mutate:y}=hc([S,"messages"],null,{fallbackData:t??k}),E=A.useRef(C||[]);A.useEffect(()=>{E.current=C||[]},[C]);const{data:D,mutate:T}=hc([S,"streamData"],null),M=A.useRef(D);A.useEffect(()=>
274{M.current=D},[D]);const{data:R=!1,mutate:O}=hc([S,"loading"],null),{data:$=void 0,mutate:G}=hc([S,"error"],null),V=A.useRef(null),q=A.useRef({credentials:d,headers:f,body:_});A.useEffect(()=>{q.current={credentials:d,headers:f,body:_}},[d,f,_]);const L=A.useCallback(async B=>{const K=E.current.length;try{O(!0),G(void 0);const ee=new AbortController;V.current=ee,await i$(r,B,Ex(y,v),Ex(T,v),M,q,E,V,b,l,h,c,n,s,a,p,g,w),V.current=null}catch(ee){if(ee.name==="AbortError")return V.current=null,null;u&&ee instanceof Error&&u(ee),G(ee)}finally{O(!1)}const U=E.current,Y=U[U.length-1];U.length>K&&Y!=null&&o>1&&Ax(Y)&&n$(U)<o&&await L({messages:U})},[y,O,r,q,c,h,u,G,T,M,l,s,a,n,o,E,V,b,p,g,v,w]),N=A.useCallback(async(B,{data:K,headers:U,body:Y,experimental_attachments:ee}={})=>{var ie,le;const ne=await bg(ee),re=E.current.concat({...B,id:(ie=B.id)!=null?ie:b(),createdAt:(le=B.createdAt)!=null?le:new Date,experimental_attachments:ne.length>0?ne:void 0});return L({messages:re,headers:U,body:Y,data:K})},[L,b]),I=A.useCallback(async({data:B,headers:K,body:U}={})=>{const Y=E.current;if(Y.length===0)return null;const ee=Y[Y.length-1];return L({messages:ee.role==="assistant"?Y.slice(0,-1):Y,headers:K,body:U,data:B})},[L]),H=A.useCallback(()=>{V.current&&(V.current.abort(),V.current=null)},[]),W=A.useCallback(B=>{typeof B=="function"&&(B=B(E.current)),y(B,!1),E.current=B},[y]),J=A.useCallback(B=>{typeof B=="function"&&(B=B(M.current)),T(B,!1),M.current=B},[T]),[Z,X]=A.useState(i),F=A.useCallback(async(B,K={},U)=>{var Y;if((Y=B?.preventDefault)==null||Y.call(B),!Z&&!K.allowEmptySubmit)return;U&&(q.current={...q.current,...U});const ee=await bg(K.experimental_attachments),le={messages:!Z&&!ee.length&&K.allowEmptySubmit?E.current:E.current.concat({id:b(),createdAt:new Date,role:"user",content:Z,experimental_attachments:ee.length>0?ee:void 0}),headers:K.headers,body:K.body,data:K.data};L(le),X("")},[Z,b,L]),P=B=>{X(B.target.value)},j=A.useCallback(({toolCallId:B,result:K})=>{const U=E.current.map((ee,ie,le)=>ie===le.length-1&&ee.role==="assistant"&&ee.toolInvocations?{...ee,toolInvocations:ee.toolInvocations.map(ne=>ne.toolCallId===B?{...ne,result:K,state:"result"}:ne)}:ee);y(U,!1);const Y=U[U.length-1];Ax(Y)&&L({messages:U})},[y,L]);return{messages:C||[],id:w,setMessages:W,data:D,setData:J,error:$,append:N,reload:I,stop:H,input:Z,setInput:X,handleInputChange:P,handleSubmit:F,isLoading:R,addToolResult:j}}function Ax(r){return r.role==="assistant"&&r.toolInvocations&&r.toolInvocations.length>0&&r.toolInvocations.every(e=>"result"in e)}function n$(r){let e=0;for(let t=r.length-1;t>=0&&r[t].role==="assistant";t--)e++;return e}var o$=s$;const a$=r=>` 275You are an experienced developer who helps people choose the best starter template for their projects, Vite is preferred. 276 277Available templates: 278<template> 279 <name>blank</name> 280 <description>Empty starter for simple scripts and trivial tasks that don't require a full template setup</description> 281 <tags>basic, script</tags> 282</template> 283${r.map(e=>` 284<template> 285 <name>${e.name}</name> 286 <description>${e.description}</description> 287 ${e.tags?`<tags>${e.tags.join(", ")}</tags>`:""} 288</template> 289`).join(` 290`)} 291 292Types of ambiances: 293- professional 294- playful 295- minimalist 296- impacting 297- elegant 298 299Response Format: 300<selection> 301 <templateName>{selected template name}</templateName> 302 <title>{a proper title for the project}</title> 303 <ambiance>{selected ambiance between the 5 types}</ambiance> 304</selection> 305 306Examples: 307 308<example> 309User: I need to build a todo app 310Response: 311<selection> 312 <templateName>react-basic-starter</templateName> 313 <title>Simple React todo application</title> 314</selection> 315</example> 316 317<example> 318User: Write a script to generate numbers from 1 to 100 319Response: 320<selection> 321 <templateName>blank</templateName> 322 <title>script to generate numbers from 1 to 100</title> 323</selection> 324</example> 325 326Instructions: 3271. For trivial tasks and simple scripts, always recommend the blank template 3282. For more complex projects, recommend templates from the provided list 3293. Follow the exact XML format 3304. Consider both technical requirements and tags 3315. If no perfect match exists, recommend the closest option 332 333Important: Provide only the selection tags in your response, no additional text. 334MOST IMPORTANT: YOU DONT HAVE TIME TO THINK JUST START RESPONDING BASED ON HUNCH 335`;function l$(){return!!navigator.userAgent.includes("Chrome")}var Tc=Sh;
335l$()||(Tc=Sh.filter(r=>!r.name.includes("Shadcn")),Tc=Tc.filter(r=>!r.githubRepo.includes("dev-digitalsolutions/exkalibur-vite-react-ts")));const c$=r=>{try{const e=r.match(/<templateName>(.*?)<\/templateName>/),t=r.match(/<title>(.*?)<\/title>/),i=r.match(/<ambiance>(.*?)<\/ambiance>/);return e?{template:e[1].trim(),title:t?.[1]?.trim()||"Untitled Project",ambiance:i?.[1]?.trim()||"professional"}:null}catch{return null}},h$=async r=>{const{message:e,model:t,provider:i,keycloakToken:s,isCustomApiKey:n}=r,a={message:e,model:t,provider:i,system:a$(Tc),keycloakToken:s,isCustomApiKey:n},l=await(await fetch("/api/llmcall",{method:"POST",body:JSON.stringify(a)})).json(),{text:c}=l,h=c$(c);return h||{template:"blank",title:"Blank Project",ambiance:"professional"}},u$=async r=>{try{const e=await fetch(`/api/github-template?repo=${encodeURIComponent(r)}`);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return await e.json()}catch(e){throw e}};async function d$(r,e){return f$({template:r.template,title:r.title},e)}async function f$(r,e,t){let i,s;typeof r=="object"&&r!==null&&"template"in r&&"title"in r?(i=r.template,s=r.title||"Untitled Project"):(i=r,s="Untitled Project");const n=Sh.find(b=>b.name==i);if(!n)return null;const a=n.githubRepo,o=await u$(a);let l=o;l=l.filter(b=>b.path.startsWith(".git")==!1);const c=["TEMPLATE_VERSION"];l=l.filter(b=>c.includes(b.name)==!1),l=l.filter(b=>b.path.startsWith(".exkalibur")==!1);const h=o.find(b=>b.path.startsWith(".exkalibur")&&b.name=="ignore"),u={files:l,ignoreFile:[]};if(h){const b=h.content.split(` 336`).map(v=>v.trim()),p=Kx().add(b),g=l.filter(v=>p.ignores(v.path));u.files=l,u.ignoreFile=g}const d=` 337exkalibur is initializing your project with the required files using the ${n.name} template. 338<exkaliburArtifact id="${e}" title="${s}" type="bundled"> 339 340${u.files.map(b=>`<exkaliburAction type="file" filePath="${b.path}"> 341${b.content} 342</exkaliburAction>`).join(` 343`)} 344</exkaliburArtifact> 345`;let f="";const _=o.filter(b=>b.path.startsWith(".exkalibur")).find(b=>b.name=="prompt");return _&&(f=` 346TEMPLATE INSTRUCTIONS: 347${_.content} 348 349--- 350`),u.ignoreFile.length>0&&(f=f+` 351STRICT FILE ACCESS RULES - READ CAREFULLY: 352 353The following files are READ-ONLY and must never be modified: 354${u.ignoreFile.map(b=>`- ${b.path}`).join(` 355`)} 356 357Permitted actions: 358â Import these files as dependencies 359â Read from these files 360â Reference these files 361 362Strictly forbidden actions: 363â Modify any content within these files 364â Delete these files 365â Rename these files 366â Move these files 367â Create new versions of these files 368â Suggest changes to these files 369 370Any attempt to modify these protected files will result in immediate termination of the operation. 371 372If you need to make changes to functionality, create new files instead of modifying the protected ones listed above. 373--- 374`),f+=` 375--- 376template import is done, and you can now use the imported files,
377edit only the files that need to be changed, and you can create new files as needed. 378NO NOT EDIT/WRITE ANY FILES THAT ALREADY EXIST IN THE PROJECT AND DOES NOT NEED TO BE MODIFIED 379--- 380Now that the Template is imported please continue with my original request 381 382IMPORTANT: Dont Forget to install the dependencies before running the app by using \`npm install && npm run dev\` 383`,{assistantMessage:d,userMessage:f}}function p$({open:r,onClose:e,onValid:t}){return A.useEffect(()=>{if(!document.querySelector('script[src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"]')){const i=document.createElement("script");i.src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js",i.async=!0,document.body.appendChild(i)}if(!document.querySelector('style[data-font="ibrand"]')){const i=document.createElement("style");i.setAttribute("data-font","ibrand"),i.textContent=` 384 @font-face { 385 font-family: 'IBrand'; 386 src: url('/public/fonts/ibrand-webfont.woff') format('woff'); 387 font-weight: normal; 388 font-style: normal; 389 } 390 `,document.head.appendChild(i)}},[]),m.jsx(_s,{open:r,onOpenChange:i=>{},children:m.jsxs(sn,{children:[m.jsx(nn,{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50"}),m.jsxs(on,{onInteractOutside:i=>i.preventDefault(),onEscapeKeyDown:i=>i.preventDefault(),className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[83vw] sm:w-[81vw] md:w-[720px] max-h-[81vh] overflow-y-auto bg-white/70 dark:bg-[#000000]/40 backdrop-blur-md rounded-xl shadow-xl z-[51] border border-[#000000]/50 dark:border-[#000000]/50 flex flex-col",children:[m.jsx("div",{className:"w-full flex items-center justify-end p-2",children:m.jsxs(Sa,{onClick:()=>{t(),e()},className:"rounded-lg bg-transparent text-gray-800 dark:text-white hover:bg-[#000000]/20 focus:outline-none transition-colors duration-200",children:[m.jsx("span",{className:"i-ph:x block w-5 h-5","aria-hidden":"true"}),m.jsx("span",{className:"sr-only",children:"Close"})]})}),m.jsx("div",{className:"flex-1 flex flex-col items-center justify-center text-center w-full px-4 sm:px-6 md:px-8 pb-6 sm:pb-8",children:m.jsxs("div",{className:"flex flex-col items-center justify-center w-full max-w-2xl",children:[m.jsx("img",{src:"/logo-dark-styled.png",alt:"Exkalibur Icon",className:"mx-auto mb-2 max-w-[180px] sm:max-w-[216px] h-auto",style:{objectFit:"contain"}}),m.jsx(Ap,{className:"text-xl sm:text-3xl font-extrabold mb--30",style:{color:"#F798CB",fontFamily:"IBrand, sans-serif"},children:"You're in!"}),m.jsx("div",{className:"flex justify-center mb-6 sm:mb-8 w-full",children:m.jsx("lottie-player",{src:"/Animation - exkalibur_sorti.json",background:"transparent",speed:"1",style:{width:"90%",maxWidth:"288px",height:"auto"},loop:!0,autoplay:!0})}),m.jsx("div",{className:"w-full h-px bg-gray-300 dark:bg-gray-600 mb-6 sm:mb-8 relative z-10"}),m.jsxs("div",{className:"space-y-4 sm:space-y-2 text-gray-700 dark:text-gray-200 font-size:0.9em",children:[m.jsx("p",{className:"font-normal leading-relaxed",style:{fontFamily:"Inter, sans-serif"},children:"Thank you for joining the adventure."}),m.jsxs("p",{className:"font-normal leading-relaxed",style:{fontFamily:"Inter, sans-serif"},children:["The journey begins soon and your account is already forged and ready.",m.jsx("br",{}),"You'll be among the very first to enter ",m.jsx("a",{rel:"noopener noreferrer",onClick:()=>{t(),e()},className:"font-semibold underline",children:"exkalibur.ai"})," when the gates open."]}),m.jsx("p",{className:"font-normal leading-relaxed",style:{fontFamily:"Inter, sans-serif"},children:"While you wait, here's how to get ahead:"}),m.jsxs("p",{className:"font-normal leading-relaxed",style:{fontFamily:"Inter, sans-serif"},children:[m.jsx("span",{className:"color: white",children:"⢠"}),m.jsx("a",{href:"https://site.exkalibur.ai/newsletter/",className:"font-semibold underline",children:"Subscribe to our newsletter"})," for early access and exclusive sneak peeks",m.jsx("br",{}),m.jsx("span",{className:"color: white",children:"⢠"}),m.jsx("span",{className:"font-semibold",children:"Follow us on social media"})," for updates, behind-the-scenes, and inspiration"]}),m.jsx("p",{className:"font-normal leading-relaxed",style:{fontFamily:"Inter, sans-serif"},children:"Let's connect:"}),m.jsxs("div",{className:"flex justify-center items-center space-x-3",children:[m.jsx("a",{href:"https://www.facebook.com/people/Exkalibur/61576273954400/",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/facebook_32px.png",alt:"Facebook",className:"w-7 h-7"})}),m.jsx("a",{href:"https://www.instagram.com/exkalibur.ai/",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/instagram_32px.png",alt:"Instagram",className:"w-7 h-7"})}),m.jsx("a",{href:"https://www.linkedin.com/company/exkalibur/",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/l
390inkedin_32px.png",alt:"LinkedIn",className:"w-7 h-7"})}),m.jsx("a",{href:"https://www.tiktok.com/@exkalibur.ai",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/tiktok_32px.png",alt:"TikTok",className:"w-7 h-7"})}),m.jsx("a",{href:"https://x.com/@exkalibur_ai",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/twitter_32px.png",alt:"X",className:"w-7 h-7"})}),m.jsx("a",{href:"https://www.youtube.com/@exkalibur_ai",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/youtube_32px.png",alt:"YouTube",className:"w-7 h-7"})}),m.jsx("a",{href:"https://discord.gg/ZWpwG5mD69",target:"_blank",rel:"noopener noreferrer",children:m.jsx("img",{src:"/discord_32px.png",alt:"Discord",className:"w-7 h-7"})})]}),m.jsxs("p",{className:"font-normal leading-relaxed",style:{fontFamily:"Inter, sans-serif"},children:[m.jsx("span",{className:"font-semibold",children:"Take a first tour of the app"})," and see what's coming..."]})]})]})}),m.jsx("div",{className:"flex justify-center",children:m.jsxs("button",{onClick:()=>{t()},className:`flex flex-col items-center justify-center px-12 bg-[#00A7FF] text-white rounded-full sm:text-lg font-semibold 391 space-y-1 hover:bg-[#0090e0] transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[#B335FF] focus:ring-opacity-50`,style:{fontFamily:"Inter, sans-serif"},children:[m.jsx("img",{src:"/fav-blanc.png",className:"w-7 relative top-2",alt:"Logo"}),m.jsx("span",{className:"relative -top-1",children:"Enter now"})]})}),m.jsx("br",{})]})]})})}const m$=yE({enter:"animated fadeInRight",exit:"animated fadeOutRight"}),Tx=Xi("Chat");function V$(){wo.trace("Chat");const{keycloak:r,initialized:e,user:t}=yi(),[i,s]=A.useState(!1),[n,a]=A.useState({userName:"",firstName:"",lastName:"",email:"",billingPlan:"",newsletterDisabled:"false",isNotFirstConnection:"false",isEmailVerify:"true"});A.useEffect(()=>{t&&a({userName:t.username||"",firstName:t.firstName||"",lastName:t.lastName||"",email:t.email||"",billingPlan:t.billingPlan||"",newsletterDisabled:t.newsletterDisabled||"false",isNotFirstConnection:t.isNotFirstConnection||"false",isEmailVerify:t.isEmailVerify||"true"})},[t]);const{ready:o,initialMessages:l,storeMessageHistory:c,importChat:h,exportChat:u,saveSnapshotToMongo:d,wcRunCodeCall:f}=xE(),_=Ve(Xx);A.useEffect(()=>{ue.setReloadedMessages(l.map(g=>g.id))},[l]),A.useEffect(()=>{(async()=>{!r||!e||!r.authenticated||wE(r.token)})()},[e]),A.useEffect(()=>{(async()=>{!r||!e||!n||!n.email||n.email===""||n.isNotFirstConnection!=="true"&&(n.isEmailVerify="true",n.emailVerified=!0,p(),s(!0))})()},[e,n]);function b(){n.isNotFirstConnection="true",p(),s(!1)}function p(){(async()=>{if(!(await LE(n,r.token)).ok)throw new Error("Failed to update profile");await r.updateToken(0)})()}return m.jsxs(m.Fragment,{children:[m.jsx(p$,{open:i,onClose:()=>s(!1),onValid:b}),o&&m.jsx(v$,{description:_,initialMessages:l,exportChat:u,storeMessageHistory:c,importChat:h,saveSnapshotToMongo:d,wcRunCodeCall:f}),m.jsx(_E,{closeButton:({closeToast:g})=>m.jsx("button",{className:"Toastify__close-button",onClick:g,children:m.jsx("div",{className:"i-ph:x text-lg"})}),icon:({type:g})=>{switch(g){case"success":return m.jsx("div",{className:"i-ph:check-bold text-exkalibur-elements-icon-success text-2xl"});case"error":return m.jsx("div",{className:"i-ph:warning-circle-bold text-exkalibur-elements-icon-error text-2xl"});case"warning":return m.jsx("div",{className:"i-ph:warning-bold text-exkalibur-elements-icon-warning text-2xl"})}},position:"bottom-right",pauseOnFocusLoss:!0,transition:m$,autoClose:3e3})]})}const g$=kE(r=>{const{keycloak:e,messages:t,initialMessages:i,isLoading:s,parseMessages:n,storeMessageHistory:a}=r;n(t,s),t.length>i.length&&a(e,t).catch(o=>he.error("Error : "+o.message))},50),v$=A.memo(({description:r,initialMessages:e,storeMessageHistory:t,importChat:i,exportChat:s,saveSnapshotToMongo:n,wcRunCodeCall:a})=>{UE();const o=Ve(Xx),l=A.useRef(o);A.useEffect(()=>{l.current=o},[o]);const c=A.useRef(null),[h,u]=A.useState(e.length>0),[d,f]=A.useState([]),[_,b]=A.useState([]),[p,g]=DE(),[v,x]=A.useState(!1),w=Ve(ue.files),S=Ve(ue.alert),k=Ve(ue.deployAlert),C=Ve(_h),y=C.stats?.projects?.find(ye=>ye.id===C.selectedProjectId),E=Ve(ue.supabaseAlert),{activeProviders:D,promptId:T,autoSelectTemplate:M,contextOptimizationEnabled:R}=SE(),{keycloak:O,login:$,user:G}=yi(),[V,q]=A.useState(O?.token);A.useEffect(()=>{if(!O?.authenticated&&h){$();return}});const[L,N]=A.useState(0),[I,H]=A.useState(!1),[W,J]=A.useState(null),[Z,X]=A.useState(null),[F,P]=A.useState(!1),[j,B]=A.useState(()=>at.get("selectedModel")||Gx[(Cl.name||"").trim().toLowerCase()==="anthropic"?"Anthropic":"Google"]);A.useEffect(()=>{G&&q(O.token)},[G]);const[K,U]=A.useState(()=>{const ye=at.get("selectedProvider");if(ye){const Ye=ye.replace('["',"").replace('"]',"");return xg.find(ut=>ut.name===Ye)||Cl}else return Cl}),{showChat:Y}=Ve(On),[ee,ie]=_A(),[le,ne]=A.useState({}),[re,me]=A.useState(null),[pe,se]=A.useState(!1);A.useEffect(()=>{le[K.name]===void 0||le[K.name]===""?se(!1):se(!0)});const{messages:ge,isLoading:Ee,input:Ce,handleInputChange:_e,setInput:Fe,stop:Ke,append:Le,setMessages:Qe,reload:Xe,error:yt,data:$e,setData:ki}=o$({api:"/api/chat",body:{apiKeys:le[K.name],files:w,promptId:T,contextOptimization:R,supabase:{isConnected:C.isConnected,hasSelectedProject:!!y,credentials:{supabaseUrl:C?.credentials?.supabaseUrl,anonKey:C?.credentials?.anonKey}},keycloakToken:V,ambiance:re,isCustomApiKey:pe},sendExtraMessageFields:!0,onError:ye=>{Tx.error(`Request failed 392 393`,ye,yt),dr.logError("Chat request failed",ye,{component:"Chat",action:"request",error:ye.message}),he.error("There was an error processing your request: "+(ye.message?ye.message:"No details were returned"))},onFinish:async(ye,Ye)=>{const ut=Ye.usage;ki(void 0),WC(),ut&&dr.logProvider("Chat response completed",{component:"Chat",action:"response",model:j,provider:K.name,usage:ut,messageLength:ye.content.length});const ct=Pi.get();
393await jo(ct,[ye],V,l.current),n(ct,ye.id,V).then(we=>{}).catch(console.error),Tx.debug("Finished streaming")},initialMessages:e,initialInput:at.get(os)||""});A.useEffect(()=>{const ye=p.get("prompt");if(ye){g({}),_r();const Ye={role:"user",content:[{type:"text",text:`[Model: ${j}] 394 395[Provider: ${K.name}] 396 397${ye}`}]};Le(Ye);const ut=Pi.get();jo(ut,[Ye],V,r)}},[j,K,p]);const{enhancingPrompt:or,promptEnhanced:Br,enhancePrompt:Ci,resetEnhancer:Ei}=HE(),{parsedMessages:Ns,parseMessages:Nt}=$E(),Zr=h?400:200;A.useEffect(()=>{On.setKey("started",e.length>0)},[]),A.useEffect(()=>{g$({keycloak:O,messages:ge,initialMessages:e,isLoading:Ee,parseMessages:Nt,storeMessageHistory:t})},[ge,Ee,Nt]);const xr=()=>{const ye=c.current;ye&&(ye.scrollTop=ye.scrollHeight)},Ai=()=>{Ke(),On.setKey("aborted",!0),ue.abortAllActions(),dr.logProvider("Chat response aborted",{component:"Chat",action:"abort",model:j,provider:K.name})};A.useEffect(()=>{const ye=c.current;if(ye){ye.style.height="auto";const Ye=ye.scrollHeight;ye.style.height=`${Math.min(Ye,Zr)}px`,ye.style.overflowY=Ye>Zr?"auto":"hidden"}},[Ce,c]);const _r=async()=>{h||(await Promise.all([ie("#examples",{opacity:0,display:"none"},{duration:.1}),ie("#intro",{opacity:0,flex:1},{duration:.2,ease:Ss})]),On.setKey("started",!0),u(!0))},yr=(ye,Ye=[])=>{if(I){J({content:ye,images:Ye});return}const ut=ue.getModifiedFiles();if(On.setKey("aborted",!1),ut!==void 0){const ct=_g(ut,`${Date.now()}`),we={role:"user",content:[{type:"text",text:`[Model: ${j}] 398 399[Provider: ${K.name}] 400 401${ct}${ye}`},...Ye.map(st=>({type:"image",image:st}))]};Le(we);const Te=Pi.get();jo(Te,[we],V,r),ue.resetAllFileModifications()}else{const ct={role:"user",content:[{type:"text",text:`[Model: ${j}] 402 403[Provider: ${K.name}] 404 405${ye}`},...Ye.map(Te=>({type:"image",image:Te}))]};Le(ct);const we=Pi.get();jo(we,[ct],V,r)}},Ti=async(ye,Ye)=>{const ut=Ye||Ce;if(!ut?.trim())return;if(Ee){Ai();return}if(at.set(os,ut,{expires:30}),!O?.authenticated){$();return}const ct=ut;let we=Pi.get();if(we||(we=Date.now().toString()+"-1",Pi.set(we)),_r(),!h){if(x(!0),M){const dt=await h$({message:ct,model:j,provider:K,keycloakToken:V,isCustomApiKey:pe});me(dt.ambiance);let Sr=dt.template;if(Sr=="blank"&&(Sr="Vanilla Vite",dt.template="Vanilla Vite"),Sr!=="blank"){const Ln=await d$(dt,we).catch(ar=>(ar.message.includes("rate limit")&&he.warning(`Rate limit exceeded. Skipping starter template 406 Continuing with blank template`),null));if(Ln){const{assistantMessage:ar,userMessage:mu}=Ln,vl=[{id:`1-${new Date().getTime()}`,role:"user",content:[{type:"text",text:`[Model: ${j}] 407 408[Provider: ${K.name}] 409 410${ct}`},..._.map(gu=>({type:"image",image:gu}))]},{id:`2-${new Date().getTime()}`,role:"assistant",content:ar},{id:`3-${we}`,role:"user",content:`[Model: ${j}] 411 412[Provider: ${K.name}] 413 414${mu}`,annotations:["hidden"]}];Qe(vl),AE(we,r,Date.now().toString(),vl,V),Xe(),Fe(""),at.remove(os),f([]),b([]),Ei(),c.current?.blur(),x(!1);return}}}const st=[{id:`${we}`,role:"user",content:[{type:"text",text:`[Model: ${j}] 415 416[Provider: ${K.name}] 417 418${ct}`},..._.map(dt=>({type:"image",image:dt}))]}];Qe(st),jo(we,st,V,r),Xe(),x(!1),Fe(""),at.remove(os),f([]),b([]),Ei(),c.current?.blur();return}yt!=null&&Qe(ge.slice(0,-1));const Te=ue.getModifiedFiles();if(On.setKey("aborted",!1),Te!==void 0){const st=_g(Te,`${Date.now()}`);Le({role:"user",content:[{type:"text",text:`[Model: ${j}] 419 420[Provider: ${K.name}] 421 422${st}${ct}`},..._.map(dt=>({type:"image",image:dt}))]}),yr(ct),ue.resetAllFileModifications()}else yr(ct);Fe(""),at.remove(os),f([]),b([]),Ei(),c.current?.blur()},Os=ye=>{_e(ye)},Ji=A.useCallback(yh(ye=>{const Ye=ye.target.value.trim();at.set(os,Ye,{expires:30})},1e3),[]);A.useEffect(()=>{const ye=at.get("apiKeys");ye&&ne(JSON.parse(ye))},[]);const wr=ye=>{B(ye),at.set("selectedModel",ye,{expires:30})},Do=ye=>{U(xg.find(Ye=>
422Ye.name===ye)||Cl),at.set("selectedProvider",ye,{expires:30})};function Po(ye){const Ye=ye[3]?.content??"",ut=/\bnpm run dev\b/.test(Ye),ct=/\bnpm run build\b/.test(Ye);return!!(ut||ct)}Po(ge)&&CE(Fx.building);const Lo=Pi.get();return m.jsx(m.Fragment,{children:m.jsx(PE.Provider,{value:{chatId:Lo},children:m.jsx(p8,{ref:ee,textareaRef:c,input:Ce,showChat:Y,chatStarted:h,isStreaming:Ee||v,onStreamingChange:ye=>{EE.set(ye)},enhancingPrompt:or,promptEnhanced:Br,sendMessage:Ti,apiKeys:le,setApiKeys:ne,model:j,setModel:wr,provider:K,setProvider:Do,providerList:D,handleInputChange:ye=>{Os(ye),Ji(ye)},handleStop:Ai,description:r,importChat:i,exportChat:s,messages:ge.map((ye,Ye)=>ye.role==="user"?ye:{...ye,content:Ns[Ye]||""}),enhancePrompt:()=>{Ci(Ce,ye=>{Fe(ye),xr()},j,K,le)},uploadedFiles:d,setUploadedFiles:f,imageDataList:_,setImageDataList:b,actionAlert:S,clearAlert:()=>ue.clearAlert(),supabaseAlert:E,clearSupabaseAlert:()=>ue.clearSupabaseAlert(),deployAlert:k,clearDeployAlert:()=>ue.clearDeployAlert(),data:$e})})})});export{Oh as A,p8 as B,V$ as C,FP as D,be as E,Ds as F,$h as G,ko as H,lt as I,Gn as J,Mw as K,Mf as L,He as M,pw as N,Tt as O,KP as P,Xc as Q,_t as T,P$ as a,nr as b,Oe as c,L$ as d,I$ as e,kL as f,NI as g,Lt as h,pL as i,oe as j,VL as k,B$ as l,j$ as m,JL as n,O$ as o,M$ as p,N$ as q,hL as r,sL as s,te as t,IF as u,cL as v,R$ as w,Ar as x,Hr as y,SL as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.