@fungi.computer/inkcap 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/methods.ts +23 -0
- package/backend/test/gills.test.ts +1 -0
- package/backend/test/methods.test.ts +65 -1
- package/dist/assets/FileTab-BNVCSYIo.js +554 -0
- package/dist/assets/InkcapFileTree-Br7vauzn.js +1 -0
- package/dist/assets/InkcapRepositoryApp-CFhDFwtJ.js +1 -0
- package/dist/assets/changes-patch-D9K9yYqR.js +2 -0
- package/dist/assets/dropdown-menu-B4O2bVad.js +1518 -0
- package/dist/assets/index-BtCs7yk8.js +2 -0
- package/dist/assets/{index-BJ3kjE6K.css → index-DtxRjUcW.css} +1 -1
- package/dist/assets/{tree-path-DjMqzQFR.js → tree-path-CkzAyob4.js} +14 -3
- package/dist/assets/{useFileTree-DW5nUsaW.js → useFileTree-BoH_lGwC.js} +1 -1
- package/dist/assets/{useForm-Dp23jvgn.js → useForm-BdDT6sfn.js} +1 -1
- package/dist/index.html +5 -4
- package/package.json +10 -9
- package/dist/assets/FileTab-D7jvkvku.js +0 -2078
- package/dist/assets/InkcapFileTree-vtUqzZ9K.js +0 -1
- package/dist/assets/InkcapRepositoryApp-B9T8rKNs.js +0 -1
- package/dist/assets/folder-open-B8i5TGAB.js +0 -1
- package/dist/assets/index-TMj4VodW.js +0 -2
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bn as t,Ji as n,Jn as r,Kn as i,Kr as a,Xr as o,Yi as s,Yn as c,Yr as l,Zn as u,a as d,ar as f,c as p,d as m,dr as h,er as g,ir as _,l as v,lr as y,o as b,r as x,rr as S,s as C,tr as w,u as T,ur as E}from"./tree-path-CkzAyob4.js";import{$ as ee,A as D,At as O,B as k,Bt as A,C as j,Ct as M,D as N,Dt as P,E as F,Et as I,F as te,G as ne,H as re,I as ie,It as L,J as R,K as z,Kt as ae,L as oe,M as se,Mt as ce,N as le,Nt as ue,O as de,Ot as fe,P as pe,Pt as me,Q as he,R as ge,S as _e,St as ve,T as ye,Tt as be,U as xe,V as Se,Vt as Ce,W as we,Wt as Te,X as Ee,Y as De,Z as Oe,_ as ke,_t as Ae,a as je,at as Me,b as Ne,bt as Pe,c as Fe,ct as Ie,d as Le,dt as Re,et as ze,f as Be,ft as Ve,g as He,gt as Ue,h as We,ht as Ge,i as Ke,it as qe,j as Je,jt as Ye,k as Xe,kt as Ze,l as Qe,lt as $e,m as et,mt as tt,n as nt,nt as rt,o as it,ot as at,p as ot,pt as st,q as ct,qt as lt,r as ut,rt as dt,s as ft,st as pt,t as mt,tt as ht,u as gt,ut as _t,v as vt,vt as yt,w as bt,x as xt,xt as St,y as Ct,yt as wt,z as Tt}from"./dropdown-menu-B4O2bVad.js";import{a as Et,p as Dt,r as Ot,t as kt}from"./useForm-BdDT6sfn.js";var At=E(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),B=n();function jt({file:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:a,renderAnnotation:o,lineAnnotations:s,renderGutterUtility:c,getHoveredLine:l}){let u=t?.(e),d=n?.(e),f=r?.(e),p=a?.(e);return(0,B.jsxs)(B.Fragment,{children:[u==null?(0,B.jsxs)(B.Fragment,{children:[d!=null&&(0,B.jsx)(`div`,{slot:`header-prefix`,children:d}),f!=null&&(0,B.jsx)(`div`,{slot:`header-filename-suffix`,children:f}),p!=null&&(0,B.jsx)(`div`,{slot:`header-metadata`,children:p})]}):(0,B.jsx)(`div`,{slot:i,children:u}),o!=null&&s?.map((e,t)=>(0,B.jsx)(`div`,{slot:Ze(e),children:o(e)},t)),c!=null&&(0,B.jsx)(`div`,{slot:`gutter-utility-slot`,style:O,children:c(l)})]})}function Mt(e){return be.hasResolvedThemes(e)}function Nt(e,t){return P(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function Pt(e){return(e.lang??Ae(e.name))===`text`}var Ft=10,It=13,Lt=4,Rt=40;function zt(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
|
|
2
|
+
`),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
|
|
3
|
+
`,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
|
|
4
|
+
`,o)),t.push(o),++a===Lt){if(o-i<=Rt){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===Ft||r===It)&&(r===It&&n+1<e.length&&e.charCodeAt(n+1)===Ft&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function Bt(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r===Ft||r===It)&&(r===It&&n+1<e.length&&e.charCodeAt(n+1)===Ft&&n++,t++)}return t}function Vt(e){let t=zt(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var Ht={compositeOverBg:rt,contrastRatio:dt,deriveMutedFg:qe,hoverWouldEraseText:Me,isDarkSurface:at,isFullyTransparent:pt,pickReadableForeground:Ie,relativeLuminance:$e,surfacesMatch:_t},Ut={forcePlainText:!1};function Wt(e,t,{theme:n=c,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:a,startingLine:o,totalLines:s,lines:l}=Ut){a?(o??=0,s??=1/0):(o=0,s=1/0);let u=o>0||s<1/0,{state:d,transformers:f}=Ve(i),p=a?`text`:e.lang??Ae(e.name),m=typeof n==`string`?t.getTheme(n).type:void 0,h=ht({theme:n,highlighter:t});d.lineInfo=e=>({type:`context`,lineIndex:e-1+o,lineNumber:e+o});let g=typeof n==`string`?{lang:p,theme:n,transformers:f,defaultColor:!1,cssVariablePrefix:Re(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:p,themes:n,transformers:f,defaultColor:!1,cssVariablePrefix:Re(`token`),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},_=ze(t.codeToHast(u?Gt(l??Vt(e.contents),o,s):e.contents,g)),v=u?Array(o):_;return u&&v.push(..._),{code:v,themeStyles:h,baseThemeType:m}}function Gt(e,t,n){if(e.length===0)return``;let r=Math.min(t+n,e.length);return e.slice(t,r).join(``)}function Kt(e,t){return t.cacheKey==null?e.file===t&&e.sourceContents===t.contents:e.cacheKey===t.cacheKey}var qt=-1,Jt=class{options;onRenderUpdate;workerManager;__id=`file-renderer:${++qt}`;highlighter;renderCache;computedLang=`text`;lineAnnotations={};lineCache;pendingStructuralRows;textDocumentCache=new WeakMap;editSessionActive=!1;constructor(e={theme:c},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=le(e.theme??c)?wt():void 0)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}setLineAnnotations(e){this.lineAnnotations={};for(let t of e){let e=this.lineAnnotations[t.lineNumber]??[];this.lineAnnotations[t.lineNumber]=e,e.push(t)}}cleanUp(){this.recycle(),this.workerManager=void 0,this.onRenderUpdate=void 0}beginEditSession(){this.editSessionActive=!0}endEditSession(){this.editSessionActive=!1}editorRenderReady(){return this.renderCache?.options.useTokenTransformer===!0&&this.renderCache.highlighted&&this.renderCache.result!=null}recycle(){this.clearRenderCache(),this.highlighter=void 0,this.workerManager?.cleanUpTasks(this),this.lineCache=void 0,this.endEditSession(),this.textDocumentCache=new WeakMap}syncEditedContentsToFile(){let{renderCache:e,lineCache:t}=this;e?.isDirty!==!0||t==null||!Kt(t,e.file)||(e.file.contents=t.lines.join(``))}hasUnkeyedFileContentsChanged(e){let{lineCache:t}=this;return e.cacheKey==null&&t!=null&&t.file===e&&t.sourceContents!==e.contents}invalidateChangedUnkeyedFile(e){this.hasUnkeyedFileContentsChanged(e)&&(this.workerManager?.cleanUpTasks(this),this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap)}clearRenderCache(){this.syncEditedContentsToFile(),this.pendingStructuralRows=void 0;let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.file.cacheKey!=null&&this.workerManager?.evictFileFromCache(e.file.cacheKey)}hydrate(e){let{options:t}=this.getRenderOptions(e),n=Yt(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength()),r=this.workerManager?.getFileResultCache(e);r!=null&&!Nt(t,r.options)&&(r=void 0),this.renderCache??={file:e,options:t,highlighted:!n&&!Pt(e),result:n?void 0:r?.result,renderRange:void 0},!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightFileAST(this,e):this.highlighter??(this.computedLang=e.lang??Ae(e.name),this.initializeHighlighter())}getLocalHighlightTheme(){return this.workerManager?.getFileRenderOptions().theme??this.options.theme??c}getEffectiveCodeOptions(){let e=this.workerManager?.isWorkingPool()===!0?this.workerManager.getFileRenderOptions():void 0;return{theme:this.getLocalHighlightTheme(),tokenizeMaxLineLength:e?.tokenizeMaxLineLength??this.options.tokenizeMaxLineLength}}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0){let e=this.workerManager.getFileRenderOptions();return this.editSessionActive&&e.useTokenTransformer!==!0?{...e,useTokenTransformer:!0}:e}let{tokenizeMaxLineLength:e=1e3}=this.options;return{theme:this.getLocalHighlightTheme(),useTokenTransformer:this.editSessionActive||this.options.useTokenTransformer===!0,tokenizeMaxLineLength:e}})(),{renderCache:n}=this;return n?.result==null||!I(e,n.file)||!Nt(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}getOrCreateLineCache(e){this.invalidateChangedUnkeyedFile(e);let{lineCache:t}=this;return(t==null||!Kt(t,e))&&(t={cacheKey:e.cacheKey,file:e,sourceContents:e.contents,lines:Vt(e.contents)}),this.lineCache=t,t.lines}getLineCount(e){let t=this.getOrCreateLineCache(e);return this.textDocumentCache.get(e)?.lineCount??t.length}updateRenderCache(e,t,n=!1){if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:r,result:i}=this.renderCache;if(i==null)return;let a=n?new Map:void 0;this.pendingStructuralRows=a;let o=this.lineCache!=null&&Kt(this.lineCache,r)?this.lineCache:void 0;for(let[t,n]of e){if(a===void 0&&o!=null&&t<o.lines.length){let e=n.map(e=>e[2]).join(``);o.lines[t]=se(o.lines[t]??``,e)}let e={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})};a===void 0?i.code[t]=e:a.set(t,e)}i.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){let t=this.pendingStructuralRows;if(this.pendingStructuralRows=void 0,this.renderCache==null)return;let{file:n,result:r}=this.renderCache;if(r==null)return;let i=this.lineCache!=null&&Kt(this.lineCache,n)?this.lineCache.lines:Vt(n.contents),a=Vt(e.getText());if(i.length!==a.length){let n=Math.min(i.length,a.length),o=0;for(;o<n&&i[o]===a[o];)o++;let s=0;for(;s<n-o&&i[i.length-1-s]===a[a.length-1-s];)s++;let c=r.code;r.code=Array(a.length);for(let e=0;e<o;e++)r.code[e]=c[e];for(let e=0;e<s;e++)r.code[a.length-1-e]=c[i.length-1-e];if(t!==void 0)for(let[e,n]of t)e<a.length&&(r.code[e]=n);for(let t=o;t<a.length-s;t++)r.code[t]??={type:`element`,tagName:`div`,properties:{"data-line":t+1,"data-line-type":`context`,"data-line-index":t},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:e.getLineText(t)}]}]};for(let e=0;e<r.code.length;e++){let t=r.code[e];t?.type===`element`&&(t.properties[`data-line`]=e+1,t.properties[`data-line-index`]=e)}this.renderCache.isDirty=!0}this.lineCache={cacheKey:n.cacheKey,file:n,sourceContents:n.contents,lines:a},this.textDocumentCache.set(n,e)}renderFile(e=this.renderCache?.file,t=r){if(e==null)return;this.invalidateChangedUnkeyedFile(e),this.renderCache?.isDirty===!0&&!I(e,this.renderCache.file)&&(this.clearRenderCache(),this.lineCache=void 0,this.textDocumentCache=new WeakMap);let{options:n,forceHighlight:i}=this.getRenderOptions(e);this.renderCache?.isDirty===!0&&!Nt(n,this.renderCache.options)&&this.clearRenderCache();let a=this.getMatchingWorkerResultCache(e,n);a!=null&&!this.hasHighlightedRenderCache(e,n)&&(this.renderCache={file:e,highlighted:!0,renderRange:void 0,...a},i=!1),this.renderCache??={file:e,highlighted:!1,options:n,result:void 0,renderRange:void 0};let o=this.getOrCreateLineCache(e),s=e.contents.length>0,c=!s||Pt(e)||Yt(o.length,this.getTokenizeMaxLength()),l=!I(e,this.renderCache.file),u=!te(this.renderCache.renderRange,t);if(!this.editSessionActive&&this.workerManager?.isWorkingPool()===!0)(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.file=e,this.renderCache.options=n,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||i)&&(this.renderCache.result=this.workerManager.getPlainFileAST(e,t.startingLine,t.totalLines,o)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||i)&&this.workerManager.highlightFileAST(this,e);else{this.computedLang=e.lang??Ae(e.name);let t=this.highlighter!=null&&le(n.theme),r=this.highlighter!=null&&pe(this.computedLang),a=!c&&r;if(this.highlighter!=null&&t&&(i||c||!this.renderCache.highlighted&&a||this.renderCache.result==null)){let{result:t,options:n}=this.renderFileWithHighlighter(e,this.highlighter,c||!r);this.renderCache={file:e,options:n,highlighted:a,result:t,renderRange:void 0}}(!t||!c&&!r)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.applyHighlightResult(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processFileResult(this.renderCache.file,t,this.renderCache.result)}async asyncRender(e,t=r){let{result:n}=await this.asyncHighlight(e);return this.processFileResult(e,t,n)}async asyncHighlight(e){let t=Yt(this.getOrCreateLineCache(e).length,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??Ae(e.name);let n=this.highlighter!=null&&Mt(yt(this.getLocalHighlightTheme())),r=t||this.highlighter!=null&&pe(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderFileWithHighlighter(e,this.highlighter,t)}renderFileWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e);return{result:Wt(e,t,r,{forcePlainText:n}),options:r}}processFileResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let a=this.getLineCount(e),{disableFileHeader:o=!1}=this.options,s=[],c=Ge(),l=Math.min(t.startingLine+t.totalLines,a),u=0,d=xe(t)?Se(this.lineAnnotations):void 0;d!=null&&(c.children.push(st(`context`,`annotation`,1)),s.push(Je({type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:d.map(e=>Ze(e))})),u++);for(let r=t.startingLine;r<l;r++){let t=r+1,i=n[r];if(i==null){let n=`FileRenderer.processFileResult: Line doesnt exist`;throw console.error(n,{name:e.name,lineIndex:r,lineNumber:t}),Error(n)}c.children.push(tt(`context`,t,`${r}`)),s.push(i),u++;let a=this.lineAnnotations[t];a!=null&&(c.children.push(st(`context`,`annotation`,1)),s.push(Je({type:`annotation`,hunkIndex:0,lineIndex:t,annotations:a.map(e=>Ze(e))})),u++)}return c.properties.style=`grid-row: span ${u}`,{gutterAST:c.children??[],contentAST:s,preAST:this.createPreElement(a),headerAST:o?void 0:this.renderHeader(e),totalLines:a,rowCount:u,themeStyles:r,baseThemeType:i,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderHeader(e){let{headerRenderMode:t=`default`,stickyHeader:n=!1}=this.options;return Xe({fileOrDiff:e,mode:t,stickyHeader:n})}renderFullHTML(e){return St(this.renderFullAST(e))}renderFullAST(e,t=[]){return t.push(Ue({tagName:`code`,children:this.renderCodeAST(e),properties:{"data-code":``}})),{...e.preAST,children:t}}renderCodeAST(e){let t=Ge();return t.children=e.gutterAST,t.properties.style=`grid-row: span ${e.rowCount}`,[t,D(e.contentAST,e.rowCount)]}renderPartialHTML(e,t=!1){return St(t?Ue({tagName:`code`,children:e,properties:{"data-code":``}}):e)}async initializeHighlighter(){return this.highlighter=await Pe(N(this.computedLang,{theme:this.getLocalHighlightTheme(),preferredHighlighter:this.workerManager?.getPreferredHighlighter()??this.options.preferredHighlighter})),this.highlighter}onHighlightSuccess(e,t,n,r=!0){this.editSessionActive||this.applyHighlightResult(e,t,n,r)}applyHighlightResult(e,t,n,r=!0){if(this.renderCache==null)return;let i=!I(e,this.renderCache.file)||!this.renderCache.highlighted||!Nt(n,this.renderCache.options);this.renderCache={file:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){if(this.editSessionActive)return;let n=this.workerManager?.getFileResultCache(e);if(!(n==null||!Nt(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&I(e,n.file)&&Nt(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}createPreElement(e){let{disableLineNumbers:t=!1,overflow:n=`scroll`}=this.options;return de({type:`file`,diffIndicators:`none`,disableBackground:!0,disableLineNumbers:t,overflow:n,split:!1,totalLines:e})}};function Yt(e,t){return e>t}function Xt(e,t){return e.lineNumber===t.lineNumber&&e.metadata===t.metadata}function Zt(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,themeType:e?.themeType,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:ke(e),tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,unsafeCSS:e?.unsafeCSS,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}var Qt=[``],$t=-1,en=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file:${++$t}`;type=`file`;fileContainer;spriteSVG;pre;code;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;errorWrapper;placeHolder;lastRenderedHeaderHTML;cachedHeaderHTML;appliedPreAttributes;lastRowCount;mounted=!1;headerElement;headerCustom;headerPrefix;headerFilenameSuffix;headerMetadata;fileRenderer;resizeManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;file;renderRange;enabled=!0;editor;constructor(e={theme:c},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.fileRenderer=new Jt(e,this.handleHighlightRender,this.workerManager),this.resizeManager=new ie,this.interactionManager=new oe(`file`,ge(e)),this.workerManager?.subscribeToThemeChanges(this)}handleHighlightRender=()=>{this.rerender()};rerender(){!this.enabled||this.file==null||this.render({file:this.file,forceRender:!0,renderRange:this.renderRange})}__getCurrentFile(){return this.file}onThemeChange(){this.fileRenderer.clearRenderCache(),this.rerender()}setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(ge(this.options))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??`system`)!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme==`string`||this.fileContainer==null||this.appliedThemeCSS==null)return!1;let t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType!==t&&(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!P(this.appliedThemeCSS.theme,this.options.theme??c)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}setEditorActiveLine(e,t){this.interactionManager.setEditorActiveLine(e,{lineNumberOnly:t?.lineNumberOnly,side:t?.side??`additions`})}getCodeScrollLeft(){return this.code?.scrollLeft??0}setCodeScrollLeft(e){this.code!=null&&(this.code.scrollLeft=e)}__getEffectiveCodeOptions(){return{...this.options,...this.fileRenderer.getEffectiveCodeOptions()}}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{overflow:e=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:e===`wrap`,columnVariables:this.shouldApplyColumnVariables(e)?`apply`:`measure`}),this.managersDirty=!1}shouldApplyColumnVariables(e){return e===`scroll`&&this.lineAnnotations.length>0}cleanUp(e=!1){this.emitPostRender(!0),this.editor?.cleanUp(e),this.editor=void 0,this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.pre=void 0,this.code=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,e?this.fileRenderer.recycle():(this.fileRenderer.cleanUp(),this.workerManager=void 0,this.file=void 0),this.enabled=!1}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){let{fileContainer:t,prerenderedHTML:n,preventEmit:r=!1,file:i,lineAnnotations:a}=e;if(!this.enabled)throw Error(`File.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`File.hydrate: hydrate can only be called before the instance has rendered or hydrated`);this.hydrateElements(t,n),tn(this.pre,i,this.options.collapsed)||nn(this.headerElement,i,this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({file:i,lineAnnotations:a}),r||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),Le(e,t);for(let t of Array.from(e.shadowRoot?.children??[])){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t,this.appliedPreAttributes=void 0;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}if(`diffsHeader`in t.dataset){this.headerElement=t,this.lastRenderedHeaderHTML=void 0;continue}}}this.pre!=null&&(this.syncCodeNodeFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({file:e,lineAnnotations:t}){this.lineAnnotations=t??this.lineAnnotations,this.file=e,this.fileRenderer.setOptions(Zt(this.options)),this.syncInteractionOptions(),this.pre!=null&&(this.fileRenderer.hydrate(e),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}getOrCreateLineCache(e=this.file){return e==null?Qt:this.fileRenderer.getOrCreateLineCache(e)}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.file,r=this.lineAnnotations,i=this.renderRange;e!=null&&t!=null&&n!=null&&this.fileRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.file!==n||e.__syncRenderView(a,t,n,r,i)})}attachEditor(e){this.editor?.cleanUp(),this.editor=e,this.fileRenderer.beginEditSession();let t=this.file==null?void 0:e.__prepareFile?.(this.file);return t!==void 0&&t!==this.file?this.renderPreparedFile({file:t,forceRender:!0,preventEmit:!0,renderRange:this.renderRange}):this.fileRenderer.editorRenderReady()?this.syncRenderViewToEditor():this.rerender(),()=>{this.editor=void 0,this.fileRenderer.endEditSession()}}applyDocumentChange(e,t){this.fileRenderer.applyDocumentChange(e),t!=null&&t!==this.lineAnnotations&&this.file!=null&&(this.setLineAnnotations(t),this.fileRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}updateRenderCache(e,t,n){this.fileRenderer.updateRenderCache(e,t,n?.lineCountChangeInFlight)}render(e){if(!this.enabled)throw Error(`File.render: attempting to call render after cleaned up`);let t=this.editor?.__prepareFile?.(e.file)??e.file;return this.renderPreparedFile(t===e.file?e:{...e,file:t})}renderPreparedFile({file:e,fileContainer:t,forceRender:n=!1,preventEmit:r=!1,containerWrapper:i,deferManagers:a=!1,lineAnnotations:o,renderRange:s}){this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:c=!1,themeType:l=`system`}=this.options,u=c?void 0:s,d=this.renderRange,f=this.hasThemeChanged(),p=o!=null&&(o.length>0||this.lineAnnotations.length>0)&&o!==this.lineAnnotations,m=!I(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e);if(!c&&!n&&te(u,this.renderRange)&&!m&&!p&&!f)return this.applyCachedThemeState(l);this.renderRange=u,m&&(this.cachedHeaderHTML=void 0),this.file=e,this.fileRenderer.setOptions(Zt(this.options)),this.syncInteractionOptions(),o!=null&&this.setLineAnnotations(o),this.fileRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:h=!1,disableFileHeader:g=!1}=this.options;if(g&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),t=this.getOrCreateFileContainerNode(t,i),this.applyCachedThemeState(l),c){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let n=this.fileRenderer.renderFile(e,w);n!=null&&this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n?.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.injectUnsafeCSS()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}try{let r=this.getOrCreatePreNode(t);if(!this.canPartiallyRender(n,p,m||f)||!this.applyPartialRender(d,u)){let n=this.fileRenderer.renderFile(e,u);if(n==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(t,n.themeStyles,l,n.baseThemeType),n.headerAST!=null&&this.applyHeaderToDOM(n.headerAST,t),this.applyFullRender(n,r)}this.applyBuffers(r,u),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,a||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(h)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,t)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;n?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}removeRenderedCode(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.code?.remove(),this.code=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}canPartiallyRender(e,t,n){return!(e||t||n)}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.file){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||Pt(e))return;let n=this.options.tokenizeMaxLength??1e5;this.fileRenderer.getOrCreateLineCache(e).length>n||await t.primeFileHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.code?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.code=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${Ze(r)}`,a=this.annotationCache.get(i);if(a==null||!Xt(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:bt(Ze(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=j();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}injectUnsafeCSS(){let{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===``){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}(this.unsafeCSSStyle?.parentNode!==t||this.appliedUnsafeCSS!==e)&&(this.unsafeCSSStyle??=_e(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=Ne(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??c,s=typeof o==`string`?o:{...o},l=xt(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:l};return}this.themeCSSStyle=et({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:Ct(t,a,l)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:l}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e!=null&&this.themeCSSStyle!=null&&(this.themeCSSStyle.textContent=vt(this.themeCSSStyle.textContent??``,xt(e)))}shouldGuardRebuildScroll(){return this.editor!=null&&ot()}applyFullRender(e,t){this.cleanupErrorWrapper(),this.applyPreNodeAttributes(t,e);let n=this.code=He({code:this.code}),r=this.fileRenderer.renderCodeAST(e);this.editor?.__captureFocusForDOMReplacement();let i=()=>{if(n.childElementCount>=2)for(let e=0;e<2;e++){let t=n.children[e],i=r[e];t.innerHTML=St(i.children),t.style.cssText=i.properties.style}else n.innerHTML=St(r);t.contains(n)||t.replaceChildren(n)};this.shouldGuardRebuildScroll()?We(t,i):i(),this.lastRowCount=e.rowCount}applyPartialRender(e,t){if(e==null||t==null)return!1;let{file:n,code:r}=this,i=r==null?void 0:this.getColumns(r);if(n==null||r==null||i==null)return!1;let a=e.startingLine,o=t.startingLine,s=e.totalLines===1/0?1/0:a+e.totalLines,c=t.totalLines===1/0?1/0:o+t.totalLines,l=Math.max(a,o),u=Math.min(s,c);if(u<=l)return!1;if(!this.trimDOMToOverlap(i.gutter,l,u)||!this.trimDOMToOverlap(i.content,l,u))throw Error(`File.applyPartialRender: failed to trim to overlap`);let{length:d}=i.content.children,f=(e,t)=>{if(!(t<=0))return this.fileRenderer.renderFile(n,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},p=o<l?f(o,l-o):void 0;if(p===void 0&&o<l)return!1;let m=c===1/0?1/0:Math.max(0,c-u),h=c>u?f(u,m):void 0;return h===void 0&&c>u?!1:(this.cleanupErrorWrapper(),p!=null&&(i.gutter.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.gutterAST)),i.content.insertAdjacentHTML(`afterbegin`,this.fileRenderer.renderPartialHTML(p.contentAST)),d+=p.rowCount),h!=null&&(i.gutter.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.gutterAST)),i.content.insertAdjacentHTML(`beforeend`,this.fileRenderer.renderPartialHTML(h.contentAST)),d+=h.rowCount),this.lastRowCount!==d&&(i.gutter.style.setProperty(`grid-row`,`span ${d}`),i.content.style.setProperty(`grid-row`,`span ${d}`),this.lastRowCount=d),!0)}getColumns(e){let t=e.children[0],n=e.children[1];if(!(!(t instanceof HTMLElement)||!(n instanceof HTMLElement)||t.dataset.gutter==null||n.dataset.content==null))return{gutter:t,content:n}}trimDOMToOverlap(e,t,n){let r=this.getDOMBoundaryIndices(e,[t,n]),i=r.get(t)??e.children.length,a=r.get(n)??e.children.length;if(i>a)return!1;for(let t=e.children.length-1;t>=a;--t)e.children[t]?.remove();for(let t=i-1;t>=0;--t)e.children[t]?.remove();return!0}getDOMBoundaryIndices(e,t){let n=[...new Set(t)].sort((e,t)=>e-t),r=new Map;if(n.length===0)return r;let i=0,a=n[i],{children:o}=e;a===0&&(r.set(0,0),i+=1,a=n[i]);for(let e=0;e<o.length;e+=1){let t=o[e];if(!(t instanceof HTMLElement))continue;let s=this.getLineIndexFromDOMNode(t);if(s!=null){for(;a!=null&&s>=a;)r.set(a,e),i+=1,a=n[i];if(i>=n.length)break}}for(let e of n)r.has(e)||r.set(e,o.length);return r}getLineIndexFromDOMNode(e){let t=e.dataset.lineIndex;if(t==null)return;let n=Number(t);return Number.isNaN(n)?void 0:n}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore??(this.bufferBefore=document.createElement(`div`),this.bufferBefore.dataset.virtualizerBuffer=`before`,e.before(this.bufferBefore)),this.bufferBefore.style.setProperty(`height`,`${t.bufferBefore}px`),this.bufferBefore.style.setProperty(`contain`,`strict`)):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter??(this.bufferAfter=document.createElement(`div`),this.bufferAfter.dataset.virtualizerBuffer=`after`,e.after(this.bufferAfter)),this.bufferAfter.style.setProperty(`height`,`${t.bufferAfter}px`),this.bufferAfter.style.setProperty(`contain`,`strict`)):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyHeaderToDOM(e,t){let{file:n}=this;if(n==null)return;this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let r=this.cachedHeaderHTML??St(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged)return;let{renderHeaderPrefix:a,renderHeaderFilenameSuffix:o,renderCustomHeader:s,renderHeaderMetadata:c}=this.options;if(s!=null){let e=s(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,i,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0}else{let e=a?.(n)??void 0,r=o?.(n)??void 0,i=c?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,f,e),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,S,r),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,_,i),this.headerCustom?.remove(),this.headerCustom=void 0}}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,n,r){if(r==null){t?.remove();return}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}getOrCreateFileContainerNode(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return n!=null&&i&&this.editor?.__captureFocusForDOMReplacement(),i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:we(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):we(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=F;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.code=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(this.editor?.__captureFocusForDOMReplacement(),e.shadowRoot?.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodeFromPre(e){this.code=void 0;for(let t of Array.from(e.children))if(t instanceof HTMLElement&&t.hasAttribute(`data-code`)){this.code=t;return}}applyPreNodeAttributes(e,{totalLines:t}){let{overflow:n=`scroll`,disableLineNumbers:r=!1}=this.options,i={type:`file`,split:!1,overflow:n,disableLineNumbers:r,diffIndicators:`none`,disableBackground:!0,totalLines:t};ye(i,this.appliedPreAttributes)||(gt(e,i),this.appliedPreAttributes=i)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function tn(e,t,n=!1){return!n&&e==null&&t!=null}function nn(e,t,n=!1){return e==null&&t!=null&&!n}var rn=5e3,an=-1;function on(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS}var sn=class extends en{virtualizer;metrics;__id=`virtualized-file:${++an}`;top;height=0;cache={heights:new Map,checkpoints:[],fileAnnotationHeight:0};isVisible=!1;isSetup=!1;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,n=u,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=n}setMetrics(e,t=!1){let n=Oe(e);!t&&De(this.metrics,n)||(this.metrics=n,this.resetLayoutCache())}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache()}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}hasLineAnnotations(){return this.lineAnnotations.some(e=>e.lineNumber>0)}getLineHeight(e,t=!1){let n=this.cache.heights.get(e);if(n!=null)return n;let r=t?2:1;return this.metrics.lineHeight*r}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!R(t,e),r=on(t,e);super.setOptions(e),r&&this.resetLayoutCache(!0),n&&(this.forceRenderOverride=!0),n&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFile.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache(e=!1,t=!0){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heights.size>0&&this.cache.heights.clear(),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.renderRange!=null&&t&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;if(this.fileContainer==null||this.file==null)return this.height!==0&&(e=!0),this.height=0,e;let{overflow:t=`scroll`}=this.options;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled()||this.code==null)return e;let n=this.code.children[1];if(!(n instanceof HTMLElement))return e;let r=re(this.lineAnnotations);if(this.renderRange!=null&&r&&xe(this.renderRange)){let t=cn(n)??0;t!==this.cache.fileAnnotationHeight&&(this.cache.fileAnnotationHeight=t,e=!0)}else!r&&this.cache.fileAnnotationHeight!==0&&(this.cache.fileAnnotationHeight=0,e=!0);for(let t of n.children){if(!(t instanceof HTMLElement))continue;let n=t.dataset.lineIndex;if(n==null)continue;let r=Number(n),i=t.getBoundingClientRect().height,a=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(a=!0),i+=t.nextElementSibling.getBoundingClientRect().height);let o=this.getLineHeight(r,a);i!==o&&(e=!0,i===this.metrics.lineHeight*(a?2:1)?this.cache.heights.delete(r):this.cache.heights.set(r,i))}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null||this.file==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render({file:this.file}));prepareCodeViewItem(e,t,n,r){let i=this.syncLineAnnotations(r),a=!I(this.file,e)||this.fileRenderer.hasUnkeyedFileContentsChanged(e),o=n?.resetFileLayoutCache===!0||a||i;n?.metrics!=null&&(this.metrics=n.metrics,o=!0);let{collapsed:s=!1}=this.options;return this.currentCollapsed!==s&&(this.currentCollapsed=s,o=!0),o&&this.resetLayoutCache(),this.file!==e&&(this.layoutDirty=!0),this.file=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e){if(this.file==null||e<1)return;let{disableFileHeader:t=!1,collapsed:n=!1}=this.options,r=this.fileRenderer.getLineCount(this.file)-1,i=he(this.metrics,t);if(n||r<0)return{top:i,height:0};let a=Math.min(Math.max(e-1,0),r),{overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics;if(i+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())return{top:i+a*s,height:s};let c=this.getLayoutCheckpointBeforeLineIndex(a);i=c?.top??i;for(let e=c?.lineIndex??0;e<a;e++)i+=this.getLineHeight(e,!1);return{top:i,height:this.getLineHeight(a,!1)}}getEditorViewport(){return this.virtualizer.type===`simple`?this.virtualizer.getRoot():this.virtualizer.getContainerElement()}getNumericScrollAnchor(e){if(this.file==null||this.renderRange==null)return;let{disableFileHeader:t=!1,collapsed:n=!1,overflow:r=`scroll`}=this.options;if(n||this.renderRange.totalLines<=0)return;let i=this.fileRenderer.getLineCount(this.file)-1;if(i<0)return;let a=he(this.metrics,t),o=Math.min(this.renderRange.startingLine,i),s=Math.min(o+this.renderRange.totalLines-1,i);if(s<o)return;let{fileAnnotationHeight:c}=this.cache;if(r===`scroll`&&!this.hasLineAnnotations()){let{lineHeight:t}=this.metrics,n=a+(o===0?c:this.renderRange.bufferBefore),r=o+Math.max(Math.ceil((e-n)/t),0);return r>s?void 0:{lineNumber:r+1,top:a+c+r*t}}let l=a+(o===0?c:this.renderRange.bufferBefore);for(let t=o;t<=s;t++){if(l>=e)return{lineNumber:t+1,top:l};l+=this.getLineHeight(t)}}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.file==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.file,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache(),this.isSetup=!1,super.cleanUp(e)}computeApproximateSize(e=!1,t=this.file){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1,overflow:o=`scroll`}=this.options,{lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(t),l=he(this.metrics,i),u=ee(this.metrics);if(this.height+=l,a){this.layoutDirty=!1;return}if(this.height+=this.cache.fileAnnotationHeight,o===`scroll`&&!this.hasLineAnnotations())this.height+=c*s;else for(let e=0;e<c;e++)this.addLayoutCheckpoint(e,this.height),this.height+=this.getLineHeight(e,!1);if(c>0&&(this.height+=u),this.fileContainer!=null&&n&&!r){let e=this.fileContainer.getBoundingClientRect();e.height===this.height?console.log(`VirtualizedFile.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFile.computeApproximateSize: computed height doesnt match`,{name:t.name,elementHeight:e.height,computedHeight:this.height})}this.layoutDirty=!1}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.file==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let{renderRange:r}=this;if(this.getAdvancedVirtualizer()?.capturePendingLayoutAnchor(),super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(this.isSimpleMode(),!1),!this.isSimpleMode())this.computeApproximateSize(!0);else if(n&&r!==void 0&&this.file!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.file,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}renderPreparedFile({fileContainer:e,file:t,forceRender:n=!1,lineAnnotations:r,...i}){let a=this.file==null||!I(this.file,t)||this.fileRenderer.hasUnkeyedFileContentsChanged(t),{forceRenderOverride:o,isSetup:s}=this;this.forceRenderOverride=void 0;let c=this.syncLineAnnotations(r);if(c&&this.resetLayoutCache(),e=this.getOrCreateFileContainerNode(e),t==null)return console.error(`VirtualizedFile.render: attempting to virtually render when we dont have file`),!1;if(s)this.top??=this.getVirtualizedTop(),a&&this.isSimpleMode()&&(this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache(!1),this.computeApproximateSize(!1,t));else{this.computeApproximateSize(!1,t);let n=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(n==null)throw Error(`VirtualizedFile.render: simple virtualizer is not available`);n.connect(e,this),this.isVisible=n.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!a||!s))return this.file=t,a&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let l=this.virtualizer.getWindowSpecs(),u=this.top??0,d=this.computeRenderRangeFromWindow(t,u,l),f=super.renderPreparedFile({file:t,fileContainer:e,renderRange:d,lineAnnotations:r,forceRender:(o??n)||c||a,...i});return this.isSimpleMode()&&f&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),f}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}shouldGuardRebuildScroll(){return!1}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}addLayoutCheckpoint(e,t){e%rn===0&&this.cache.checkpoints.push({lineIndex:e,top:t})}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFile: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFile: invalid checkpoint index`);if(n.lineIndex%t===0)return n}}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}getAdvancedVirtualizer(){return this.virtualizer.type===`advanced`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,overflow:a=`scroll`}=this.options,{hunkLineCount:o,lineHeight:s}=this.metrics,c=this.fileRenderer.getLineCount(e),l=this.height,u=he(this.metrics,i),d=c>0?ee(this.metrics):0,{fileAnnotationHeight:f}=this.cache,p=u+f,m=Math.max(0,l-u-f-d),h=re(this.lineAnnotations),g=t+u,_=f>0&&h&&g<r&&g+f>n;if(t<n-l||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};if(c<=o)return{startingLine:0,totalLines:o,bufferBefore:0,bufferAfter:0};let v=Math.ceil(Math.max(r-n,0)/s),y=Math.ceil(v/o)*o+o,b=y/o,x=(n+r)/2;if(a===`scroll`&&!this.hasLineAnnotations()){let e=t+p,i=e+m;if(!_&&!(e<r&&i>n))return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d};let a=Math.floor(_&&x<t+p?0:(x-(t+p))/s),h=Math.floor(a/o)-Math.floor(b/2),g=Math.ceil(c/o),v=Math.max(0,Math.min(h,g))*o,S=h<0?y+h*o:y,C=v===0?0:f+v*s,w=Math.min(S,c-v);return{startingLine:v,totalLines:S,bufferBefore:C,bufferAfter:Math.max(0,(c-v-w)*s)}}let S=b,C=[],w=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-y*s*2),o),T=t+(w?.top??p),E=w?.lineIndex??0,D,O,k,A=w?.lineIndex??0;for(let e=A;e<c;e++){let i=E%o===0,a=Math.floor(E/o);if(i&&(C[a]=T-(t+p),k!=null)){if(k<=0)break;k--}let s=this.getLineHeight(e,!1);T>n-s&&T<r&&(D??=a),T+s>x&&(O??=a),k==null&&T>=r&&i&&(k=S),E++,T+=s}if(D==null){if(_)D=0,O=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:l-u-d}}O??=D;let j=Math.round(O-b/2),M=Math.max(0,Math.ceil(c/o)-b),N=Math.max(0,Math.min(j,M)),P=N*o,F=j<0?y+j*o:y,I=C[N]??0,te=P===0?0:f+I,ne=N+F/o,ie=ne<C.length?m-C[ne]:m-(T-t-p);return{startingLine:P,totalLines:F,bufferBefore:te,bufferAfter:Math.max(0,ie)}}};function cn(e){let t;for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===k&&(t=Math.max(t??0,n.getBoundingClientRect().height));return t}var V=e(s(),1),ln=typeof window>`u`?V.useEffect:V.useLayoutEffect;function un({file:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=Fe(),f=i!==void 0,p=(0,V.useContext)(Ee),m=ue(),h=(0,V.useRef)(null),g=me(n=>{if(n!=null){if(h.current!=null)throw Error(`File: An instance should not already exist when a node is created`);d==null?h.current=new en(dn({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new sn(dn({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({file:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`File: A File instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return ln(()=>{if(h.current==null)return;let n=dn({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),a=n!==void 0&&!R(h.current.options,n);h.current.setOptions(n),h.current.render({file:e,lineAnnotations:r,forceRender:a}),i!==void 0&&h.current.setSelectedLines(i)}),ln(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`File: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`File: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,V.useCallback)(()=>h.current?.getHoveredLine(),[])}}function dn({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?Ye:e?.renderCustomHeader,renderGutterUtility:r?Ye:e?.renderGutterUtility}:e}function fn({file:e,lineAnnotations:t,selectedLines:n,options:r,editorOptions:i,metrics:a,className:o,style:s,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:f,prerenderedHTML:p,renderGutterUtility:m,disableWorkerPool:h=!1,edit:_=!1}){let{ref:v,getHoveredLine:y}=un({file:e,options:r,editorOptions:i,metrics:a,lineAnnotations:t,selectedLines:n,prerenderedHTML:p,hasGutterRenderUtility:m!=null,hasCustomHeader:l!=null,disableWorkerPool:h,edit:_});return(0,B.jsx)(g,{ref:v,className:o,style:s,children:Qe(jt({file:e,renderAnnotation:c,renderCustomHeader:l,renderHeaderPrefix:u,renderHeaderFilenameSuffix:d,renderHeaderMetadata:f,renderGutterUtility:m,lineAnnotations:t,getHoveredLine:y}),p)})}function pn({oldFile:e,newFile:t,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,className:s,style:c,prerenderedHTML:l,renderAnnotation:u,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderGutterUtility:h,disableWorkerPool:_=!1,edit:v=!1}){let y=(0,V.useMemo)(()=>ne(e,t,n?.parseDiffOptions),[e,t,n?.parseDiffOptions]),{ref:b,getHoveredLine:x}=ft({fileDiff:y,options:n,editorOptions:r,metrics:i,lineAnnotations:a,selectedLines:o,prerenderedHTML:l,hasGutterRenderUtility:h!=null,hasCustomHeader:d!=null,disableWorkerPool:_,edit:v});return(0,B.jsx)(g,{ref:b,className:s,style:c,children:Qe(fe({fileDiff:y,renderCustomHeader:d,renderHeaderPrefix:f,renderHeaderFilenameSuffix:p,renderHeaderMetadata:m,renderAnnotation:u,lineAnnotations:a,renderGutterUtility:h,getHoveredLine:x}),l)})}function mn(e){if(e.local){if(e.closed)return{status:`unavailable`,reason:`This draft is closed.`}}else if(e.closed||!e.savable)return{status:`unavailable`,reason:`No focused savable document.`};return e.saving?{status:`unavailable`,reason:`A save is already running.`}:!e.local&&!e.dirty?{status:`unavailable`,reason:`No unsaved changes.`}:{status:`available`}}var hn=100,gn=1,_n=2,vn=3,yn=class{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??hn)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){if(this.#e.length===0){this.push(e);return}this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function bn(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?_n:n?vn:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function xn(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=wn(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
|
|
5
|
+
`)&&!a.text.includes(`
|
|
6
|
+
`),u=o.start===o.end&&o.text.length>0&&!o.text.includes(`
|
|
7
|
+
`)&&s.text.length===0;if(l&&u){if(o.start!==a.end||(n??=gn,n!==gn||e.coalescingMode!==void 0&&e.coalescingMode!==gn||t.coalescingMode!==void 0&&t.coalescingMode!==gn))return!1;continue}let d=i.text.length===0&&i.end>i.start&&a.text.length>0,f=o.text.length===0&&o.end>o.start&&s.text.length>0;if(d&&f){let r;if(c===i.end)r=vn;else if(c+(o.end-o.start)!==i.start)return!1;else r=_n;if(n??=r,n!==r||e.coalescingMode!==void 0&&e.coalescingMode!==r||t.coalescingMode!==void 0&&t.coalescingMode!==r)return!1;continue}return!1}return n!==void 0}function Sn(e,t){let n=[],r=[],i;for(let a=0;a<e.forwardEdits.length;a++){let o=e.forwardEdits[a],s=e.inverseEdits[a],c=t.forwardEdits[a],l=t.inverseEdits[a],u=wn(c.start,e.forwardEdits);if(o.text.length>0){i??=gn,n.push({start:o.start,end:o.end,text:o.text+c.text}),r.push(s.text);continue}if(u===o.end){i??=vn,n.push({start:o.start,end:u+(c.end-c.start),text:``}),r.push(s.text+l.text);continue}i??=_n,n.push({start:Math.min(o.start,u),end:o.end,text:``}),r.push(l.text+s.text)}return{forwardEdits:n,inverseEdits:Cn(n,r),versionBefore:e.versionBefore,versionAfter:t.versionAfter,selectionsBefore:e.selectionsBefore?.slice(),selectionsAfter:t.selectionsAfter?.slice(),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:t.lineAnnotationsAfter?.slice(),coalescingMode:i}}function Cn(e,t){let n=[];for(let r=0,i=0;r<e.length;r++){let a=e[r],o=a.start+i;n.push({start:o,end:o+a.text.length,text:t[r]}),i+=a.text.length-(a.end-a.start)}return n}function wn(e,t){let n=e;for(let e of t){let t=e.end-e.start,r=e.text.length,i=r-t;if(!(n<e.start)){if(n>=e.start+r){n-=i;continue}n=e.start+Math.min(n-e.start,t)}}return n}var Tn=1e5,En=10,Dn=13,On=`\`~!@#$%^&*()-=+[{]}\\|;:'",.<>/?`,kn=class{source;offset;length;lineOffsetStart;lineOffsetEnd;hasVirtualTrailingCRBreak;firstCharCode;lastCharCode;static Original=0;static Added=1;constructor(e,t,n,r,i,a,o,s){this.source=e,this.offset=t,this.length=n,this.lineOffsetStart=r,this.lineOffsetEnd=i,this.hasVirtualTrailingCRBreak=a,this.firstCharCode=o,this.lastCharCode=s}get lineBreakCount(){return this.lineOffsetEnd-this.lineOffsetStart+ +!!this.hasVirtualTrailingCRBreak}},An=class{text;lineOffsets;constructor(e){this.text=e,this.lineOffsets=zt(e)}append(e){let t=this.text.length;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r===En||r===Dn)&&(r===Dn&&e.charCodeAt(n+1)===En&&n++,this.lineOffsets.push(t+n+1))}return this.text+=e,t}},jn=class{piece;subtreeLength;subtreeLineBreakCount;subtreeFirstCharCode;subtreeLastCharCode;left=null;right=null;parent=null;priority=0;constructor(e,t=e.length,n=e.lineBreakCount,r=e.firstCharCode,i=e.lastCharCode){this.piece=e,this.subtreeLength=t,this.subtreeLineBreakCount=n,this.subtreeFirstCharCode=r,this.subtreeLastCharCode=i}updateSubtreeLength(){this.subtreeLength=(this.left?.subtreeLength??0)+this.piece.length+(this.right?.subtreeLength??0),this.subtreeLineBreakCount=(this.left?.subtreeLineBreakCount??0)+this.piece.lineBreakCount+(this.right?.subtreeLineBreakCount??0)-+!!zn(this.left?.subtreeLastCharCode,this.piece.firstCharCode)-!!zn(this.piece.lastCharCode,this.right?.subtreeFirstCharCode),this.subtreeFirstCharCode=this.left?.subtreeFirstCharCode??this.piece.firstCharCode,this.subtreeLastCharCode=this.right?.subtreeLastCharCode??this.piece.lastCharCode}},Mn=class{#e;#t=new An(``);#n=null;#r=0;#i=0;#a=null;#o=null;#s=null;#c=2654435769;constructor(e){this.#e=new An(e);let t=this.#y(kn.Original,0,e.length);this.#n=t.length>0?this.#C(t):null,this.#r=this.#n?.subtreeLength??0,this.#i=(this.#n?.subtreeLineBreakCount??0)+1}get lineCount(){return this.#i}getText(e){if(e===void 0)return this.#g();let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this.getTextSlice(t,n)}getLineText(e,t=!1){if(this.#a!==null&&this.#a[0]===e&&this.#a[1]===t)return this.#a[2];let n=this.#f(e);if(n===void 0)throw Error(`Line index out of range: ${e}`);let r=this.getTextSlice(n[0],n[1],!t);return this.#a=[e,t,r],this.#o=[e,t,r.length],r}getLineLength(e,t=!1){let n=this.#o,r=this.#a;if(n!==null&&n[0]===e&&n[1]===t)return n[2];if(r!==null&&r[0]===e&&r[1]===t){let n=r[2].length;return this.#o=[e,t,n],n}let i=this.#f(e);if(i===void 0)throw Error(`Line index out of range: ${e}`);let[a,o]=i,s=o-a;if(!t)for(;s>0&&Nn(this.charAt(a+s-1).charCodeAt(0));)s--;return this.#o=[e,t,s],s}getTextSlice(e,t,n=!1){if(e>=t)return``;let r=H(e,0,this.#r),i=H(t,r,this.#r);if(r>=i)return``;let a=this.#u(r);if(a===void 0)return``;let o=[],[s,c]=a,l=i-r;for(;s!==null&&l>0;){let e=Math.min(s.piece.length-c,l),t=this.#v(s.piece.source),r=s.piece.offset+c,i=r+e;if(n)for(;i>r&&Nn(t.text.charCodeAt(i-1));)i--;o.push(t.text.slice(r,i)),l-=e,c=0,s=this.#d(s)}return o.join(``)}charAt(e){let t=this.#u(e);if(t===void 0)return``;let[n,r]=t;return this.#v(n.piece.source).text.charAt(n.piece.offset+r)}includes(e){if(e.length===0)return!0;let t=Pn(e),n=0,r=!1;return this.#_(i=>{for(let a=i.start;a<i.end;a++){let o=i.text.charCodeAt(a);for(;n>0&&o!==e.charCodeAt(n);)n=t[n-1];if(o===e.charCodeAt(n)&&n++,n===e.length)return r=!0,!1}return!0}),r}findNextNonOverlappingSubstring(e,t){if(e.length===0||e.length>this.#r)return;let n=Fn(t,this.#r),r=n.reduce((e,[,t])=>Math.max(e,t),0),i=Pn(e),a=0,o=0,s,c;return this.#_(t=>{for(let l=t.start;l<t.end;l++){let u=t.text.charCodeAt(l);for(;a>0&&u!==e.charCodeAt(a);)a=i[a-1];if(u===e.charCodeAt(a)&&a++,a===e.length){let t=o-e.length+1;if(!In(n,t,t+e.length)){if(t>=r)return c=t,!1;s??=t}a=i[a-1]}o++}return!0}),c??s}search(e){if(e.text.length===0||this.#r===0||e.text.includes(`
|
|
8
|
+
`)||e.text.includes(`\r`)||e.regex&&(e.text.includes(`\\n`)||e.text.includes(`\\r`)))return[];let t;try{t=Wn(e.text,e.regex,e.caseSensitive)}catch{return[]}return this.#l(t,e.wholeWord,Tn)}#l(e,t,n){let r=[],i=this.#g(),a=i.length,o=zt(i);for(let s=0;s<o.length;s++){let c=o[s],l=o[s+1]??a;for(;l>c&&Nn(i.charCodeAt(l-1));)l--;let u=i.slice(c,l);e.lastIndex=0;let d;for(;(d=e.exec(u))!==null;){let a=d.index,o=d[0];if(o.length===0){e.lastIndex=qn(u,a);continue}let s=c+a;if((!t||Un(i,s,o.length))&&(r.push([s,s+o.length]),r.length>=n))return r;a===e.lastIndex&&(e.lastIndex=qn(u,a))}}return r}insert(e,t){if(e.length===0)return;let n=H(t,0,this.#r);this.#b(n,n,e),this.#x()}delete(e,t){if(t<=0||this.#r===0)return;let n=H(e,0,this.#r),r=H(n+t,n,this.#r);n!==r&&(this.#b(n,r,``),this.#x())}applyEdits(e){if(e.length!==0){for(let t=e.length-1;t>=0;t--){let n=e[t],r=H(n.start,0,this.#r),i=H(n.end,r,this.#r);this.#b(r,i,n.text)}this.#x()}}positionAt(e){let t=H(e,0,this.#r);if(this.#r===0)return{line:0,character:0};let n=this.#p(t),r=t-(n===0?0:this.#m(n-1));return this.#s=[n,r,t],{line:n,character:r}}positionsAt(e){let t=Array.from({length:e.length});if(e.length===0)return t;if(this.#r===0)return t.fill({line:0,character:0});for(let n=0;n<e.length;n++)t[n]=this.positionAt(e[n]);return t}offsetAt(e){if(e.line<0||this.#r===0)return 0;if(e.line>=this.#i)throw Error(`Line index out of range: ${e.line}`);let t=this.#s;if(t!==null&&t[0]===e.line&&t[1]===e.character)return t[2];let n=this.#f(e.line);if(n===void 0)throw Error(`Line index out of range: ${e.line}`);let r=H(e.character,0,n[1]-n[0]);return n[0]+r}#u(e){if(e<0||e>=this.#r)return;let t=this.#n,n=e;for(;t!==null;){let e=t.left?.subtreeLength??0;if(n<e){t=t.left;continue}if(n-=e,n<t.piece.length)return[t,n];n-=t.piece.length,t=t.right}}#d(e){if(e.right!==null){let t=e.right;for(;t.left!==null;)t=t.left;return t}let t=e;for(;t.parent!==null&&t===t.parent.right;)t=t.parent;return t.parent}#f(e){if(e<0)throw Error(`Line index out of range: ${e}`);if(this.#r===0){if(e===0)return[0,0];throw Error(`Line index out of range: ${e}`)}if(e>=this.#i)throw Error(`Line index out of range: ${e}`);return[e===0?0:this.#m(e-1),e<this.#i-1?this.#m(e):this.#r]}#p(e){let t=this.#n,n=H(e,0,this.#r),r=0;for(;t!==null;){let e=t.left?.subtreeLength??0;if(n<e){t=t.left;continue}if(r+=(t.left?.subtreeLineBreakCount??0)-+!!zn(t.left?.subtreeLastCharCode,t.piece.firstCharCode),n-=e,n<=t.piece.length){let e=this.#v(t.piece.source),i=Math.min(Bn(e.lineOffsets,t.piece.offset+n),t.piece.lineOffsetEnd);return r+=i-t.piece.lineOffsetStart,n===t.piece.length&&t.piece.hasVirtualTrailingCRBreak&&r++,n===t.piece.length&&zn(t.piece.lastCharCode,this.#d(t)?.piece.firstCharCode)&&r--,r}r+=t.piece.lineBreakCount-+!!zn(t.piece.lastCharCode,t.right?.subtreeFirstCharCode),n-=t.piece.length,t=t.right}return this.#i-1}#m(e){let t=this.#n,n=e,r=0,i;for(;t!==null;){let e=(t.left?.subtreeLineBreakCount??0)-+!!zn(t.left?.subtreeLastCharCode,t.piece.firstCharCode);if(n<e){i=t.piece.firstCharCode,t=t.left;continue}let a=t.left?.subtreeLength??0;r+=a,n-=e;let o=t.right?.subtreeFirstCharCode??i,s=t.piece.lineBreakCount-+!!zn(t.piece.lastCharCode,o);if(n<s)return r+this.#h(t.piece,n);r+=t.piece.length,n-=s,t=t.right}return this.#r}#h(e,t){return t<e.lineOffsetEnd-e.lineOffsetStart?this.#v(e.source).lineOffsets[e.lineOffsetStart+t]-e.offset:e.length}#g(){let e=[];return this.#_(t=>{e.push(t.text.slice(t.start,t.end))}),e.join(``)}#_(e){this.#j(this.#n,t=>{let n=this.#v(t.piece.source);return e({text:n.text,lineOffsets:n.lineOffsets,lineOffsetStart:t.piece.lineOffsetStart,lineOffsetEnd:t.piece.lineOffsetEnd,start:t.piece.offset,end:t.piece.offset+t.piece.length})})}#v(e){return e===kn.Original?this.#e:this.#t}#y(e,t,n){let r=this.#v(e),i=t+n,a=Bn(r.lineOffsets,t),o=Bn(r.lineOffsets,i),s=r.text.charCodeAt(i-1);return new kn(e,t,n,a,o,s===Dn&&r.lineOffsets[o-1]!==i,r.text.charCodeAt(t),s)}#b(e,t,n){if(e===t&&n.length===0)return;let[r,i]=this.#E(this.#n,e),a=this.#D(i,t-e),o;if(n.length>0){let e=this.#y(kn.Added,this.#t.append(n),n.length);o=this.#O(this.#k(r,e),a)}else{let[e,t]=this.#A(a);o=e===void 0?r:this.#O(this.#k(r,e),t)}o!==null&&(o.parent=null),this.#n=o,this.#r=o?.subtreeLength??0,this.#i=(o?.subtreeLineBreakCount??0)+1}#x(){this.#a=null,this.#o=null,this.#s=null}#S(){return this.#c=Math.imul(this.#c,1664525)+1013904223>>>0,this.#c}#C(e){let t=new jn(e);return t.priority=this.#S(),t}#w(e,t){e.left=t,t!==null&&(t.parent=e)}#T(e,t){e.right=t,t!==null&&(t.parent=e)}#E(e,t){if(e===null)return[null,null];if(t<=0)return[null,e];if(t>=e.subtreeLength)return[e,null];let n=e.left?.subtreeLength??0;if(t<=n){let[n,r]=this.#E(e.left,t);return this.#w(e,r),e.updateSubtreeLength(),[n,e]}let r=e.piece.length;if(t>=n+r){let[i,a]=this.#E(e.right,t-n-r);return this.#T(e,i),e.updateSubtreeLength(),[e,a]}let i=t-n,a=new jn(this.#y(e.piece.source,e.piece.offset,i)),o=new jn(this.#y(e.piece.source,e.piece.offset+i,r-i));return a.priority=e.priority,o.priority=e.priority,this.#w(a,e.left),this.#T(o,e.right),a.updateSubtreeLength(),o.updateSubtreeLength(),[a,o]}#D(e,t){if(e===null||t>=e.subtreeLength)return null;if(t<=0)return e;let n=e.left?.subtreeLength??0;if(t<=n)return this.#w(e,this.#D(e.left,t)),e.updateSubtreeLength(),e;let r=n+e.piece.length;if(t>=r)return this.#D(e.right,t-r);let i=t-n,a=new jn(this.#y(e.piece.source,e.piece.offset+i,e.piece.length-i));return a.priority=e.priority,this.#T(a,e.right),a.updateSubtreeLength(),a}#O(e,t){return e===null?t:t===null?e:e.priority>=t.priority?(this.#T(e,this.#O(e.right,t)),e.updateSubtreeLength(),e):(this.#w(t,this.#O(e,t.left)),t.updateSubtreeLength(),t)}#k(e,t){if(e===null)return this.#C(t);let n=e;for(;n.right!==null;)n=n.right;if(Ln(n.piece,t)){n.piece=Rn(n.piece,t);for(let t=n;t!==null&&(t.updateSubtreeLength(),t!==e);)t=t.parent;return e}return this.#O(e,this.#C(t))}#A(e){if(e===null)return[void 0,null];if(e.left===null)return[e.piece,e.right];let[t,n]=this.#A(e.left);return this.#w(e,n),e.updateSubtreeLength(),[t,e]}#j(e,t){return e===null?!0:!this.#j(e.left,t)||t(e)===!1?!1:this.#j(e.right,t)}};function Nn(e){return e===10||e===13}function H(e,t,n){return Math.min(Math.max(e,t),n)}function Pn(e){let t=Array.from({length:e.length}).fill(0),n=0;for(let r=1;r<e.length;r++){let i=e.charCodeAt(r);for(;n>0&&i!==e.charCodeAt(n);)n=t[n-1];i===e.charCodeAt(n)&&n++,t[r]=n}return t}function Fn(e,t){let n=[];for(let[r,i]of e){let e=H(r,0,t),a=H(i,e,t);e<a&&n.push([e,a])}n.sort((e,t)=>e[0]-t[0]);let r=[];for(let e of n){let t=r[r.length-1];if(t!==void 0&&e[0]<=t[1]){t[1]=Math.max(t[1],e[1]);continue}r.push(e)}return r}function In(e,t,n){let r=0,i=e.length;for(;r<i;){let n=r+Math.floor((i-r)/2);e[n][1]<=t?r=n+1:i=n}let a=e[r];return a!==void 0&&a[0]<n}function Ln(e,t){return e.source===t.source&&e.offset+e.length===t.offset&&!zn(e.lastCharCode,t.firstCharCode)}function Rn(e,t){return new kn(e.source,e.offset,e.length+t.length,e.lineOffsetStart,t.lineOffsetEnd,t.hasVirtualTrailingCRBreak,e.firstCharCode,t.lastCharCode)}function zn(e,t){return e===Dn&&t===En}function Bn(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2);e[i]<=t?n=i+1:r=i}return n}function Vn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Hn(e){if(e<=32||e===127)return!0;let t=String.fromCharCode(e);return On.includes(t)}function Un(e,t,n){let r=t<=0||Hn(e.charCodeAt(t-1)),i=t+n>=e.length||Hn(e.charCodeAt(t+n));return r&&i}function Wn(e,t,n){let r=t?e:Vn(e);return new RegExp(r,`g${n?``:`i`}${t?`m`:``}`)}function Gn(e,t){return e.replace(/\$([$&]|\d+)/g,(e,n)=>n===`$`?`$`:n===`&`?t[0]??``:t[Number(n)]??``)}function Kn(e,t,n,r,i,a){if(!r.regex)return r.replaceText;let o=e(i),s=n(o.line),c=i-t({line:o.line,character:0}),l;try{l=Wn(r.text,!0,r.caseSensitive)}catch{return r.replaceText}l.lastIndex=c;let u=l.exec(s);return u===null||u.index!==c||u[0].length!==a-i?r.replaceText:Gn(r.replaceText,u)}function qn(e,t){if(t+1<e.length){let n=e.charCodeAt(t),r=e.charCodeAt(t+1);if(n>=55296&&n<=56319&&r>=56320&&r<=57343)return t+2}return t+1}var Jn=class e{#e;#t;#n;#r;#i;#a;constructor(e,t,n=`text`,r=0,i=new yn){this.#e=new URL(e,`file://`).toString(),this.#t=n,this.#n=r,this.#r=new Mn(t),this.#i=i;let a=this.#r.getLineText(0,!0);this.#a=a.endsWith(`\r
|
|
9
|
+
`)?`\r
|
|
10
|
+
`:a.endsWith(`\r`)?`\r`:`
|
|
11
|
+
`}get uri(){return this.#e}get languageId(){return this.#t}get version(){return this.#n}get lineCount(){return this.#r.lineCount}get eol(){return this.#a}get canUndo(){return this.#i.canUndo}get canRedo(){return this.#i.canRedo}positionAt(e){return this.normalizePosition(this.#r.positionAt(e))}positionsAt(e){let t=this.#r.positionsAt(e);for(let e=0;e<t.length;e++)t[e]=this.normalizePosition(t[e]);return t}offsetAt(e){return this.#r.offsetAt(this.normalizePosition(e))}getText(e){return e===void 0?this.#r.getText():this.#r.getText({start:this.normalizePosition(e.start),end:this.normalizePosition(e.end)})}getLineText(e,t){return this.#r.getLineText(e,t)}normalizeEol(e){return e.replace(/\r\n|\r|\n/g,this.eol)}getLineLength(e,t){return this.#r.getLineLength(e,t)}charAt(e){return typeof e==`number`?this.#r.charAt(e):this.#r.charAt(this.offsetAt(e))}getTextSlice(e,t){return this.#r.getTextSlice(e,t)}findNextNonOverlappingSubstring(e,t){return this.#r.findNextNonOverlappingSubstring(e,t)}search(e){return this.#r.search(e)}applyEdits(e,t=!0,n,r,i=!1){if(e.length!==0)return this.#o(this.#d(this.resolveEdits(e)),t,n,r,i)}resolveEdits(e){return e.map(e=>this.#c(e))}applyResolvedEdits(e,t=!0,n,r,i=!1){if(e.length!==0)return this.#o(this.#d(e.map(e=>this.#l(e))),t,n,r,i)}#o(e,t,n,r,i){let a=bn(this,e,this.#n,this.#n+1,t?n:void 0,t?r:void 0);t&&i&&(a.undoBoundary=!0);let o=this.#i.peekUndoForCoalescing(),s=this.#f(e);return this.#n++,s.lineDelta===0&&xn(o,a)?this.#i.replaceLastUndo(Sn(o,a)):this.#i.push(a),s}setLastUndoSelectionsAfter(e){this.#i.setLastUndoSelectionsAfter(e)}setLastUndoLineAnnotations(e,t){this.#i.setLastUndoLineAnnotations(e,t)}undo(){let e=this.#i.popUndoToRedo();if(e===void 0)return;let t=this.#f(e.inverseEdits);if(t===void 0)return;this.#n=e.versionBefore;let n=e.selectionsBefore?.slice();return[t,n,e.lineAnnotationsBefore?.slice(),n===void 0?e.inverseEdits.map(e=>({...e})):void 0]}redo(){let e=this.#i.popRedoToUndo();if(e===void 0)return;let t=this.#f(e.forwardEdits);if(t===void 0)return;this.#n=e.versionAfter;let n=e.selectionsAfter?.slice();return[t,n,e.lineAnnotationsAfter?.slice(),n===void 0?e.forwardEdits.map(e=>({...e})):void 0]}normalizePosition(t){let n=e.#s(t.line,this.lineCount-1);return{line:n,character:e.#s(t.character,this.getLineLength(n))}}static#s(e,t){return Number.isNaN(e)?0:Math.max(0,Math.min(Math.floor(e),t))}#c(e){let t=this.offsetAt(e.range.start),n=this.offsetAt(e.range.end);if(t>n){let e=t;t=n,n=e}return this.#l({start:t,end:n,text:e.newText})}#l(e){let{start:t,end:n}=e,r=t===n;return this.#u(t)&&t--,r?n=t:this.#u(n)&&n++,{start:t,end:n,text:e.text}}#u(e){let t=this.#r.charAt(e-1).charCodeAt(0),n=this.#r.charAt(e).charCodeAt(0);return t>=55296&&t<=56319&&n>=56320&&n<=57343}#d(e){let t=[...e].sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});for(let e=0;e<t.length-1;e++)if(t[e].end>t[e+1].start)throw Error(`Overlapping text edits are not supported`);return t}#f(e){let t=this.#r.lineCount,n=this.positionsAt(e.flatMap(e=>[e.start,e.end])),r=this.#p(e,n),i=n[0],a=n[n.length-1],o=a.line===t-1&&a.character===this.#r.getLineLength(a.line);this.#r.applyEdits(e);let s=this.#r.lineCount;return{changes:e.map((e,t)=>({...e,range:{start:n[t*2],end:n[t*2+1]}})),startLine:r.startLine,startCharacter:i.character,endCharacter:a.character,endLine:Math.min(r.endLine,Math.max(0,s-1)),endedAtDocumentEnd:o,previousLineCount:t,lineCount:s,lineDelta:s-t,changedLineRanges:r.ranges,changedLineChanges:r.changes}}#p(e,t){let n=1/0,r=0,i=0,a=[],o=[],s=this.#r.lineCount-1,c=this.#r.getLineLength(s);for(let l=0;l<e.length;l++){let u=e[l],d=t[l*2],f=t[l*2+1],p=d.line,m=f.line,h=Bt(u.text),g=p+i,_=g+h,v=h-(m-p);n=Math.min(n,p),r=Math.max(r,_);let y=a[a.length-1];y!==void 0&&g<=y[1]+1?a[a.length-1]=[y[0],Math.max(y[1],_)]:a.push([g,_]),o.push([g,_,v,d.character,f.character,m===s&&f.character===c]),i+=v}return n===1/0?{startLine:0,endLine:0,ranges:[[0,0]],changes:[[0,0,0,0,0,!1]]}:{startLine:n,endLine:r,ranges:a,changes:o}}};function Yn({metaKey:e,ctrlKey:t},n=Be()){return n?e&&!t:t&&!e}function Xn(e){if(Be()&&e.ctrlKey&&!e.altKey&&!e.metaKey)switch(e.key){case`a`:return`start`;case`e`:return`end`;case`p`:return`up`;case`n`:return`down`;case`f`:return`right`;case`b`:return`left`}if(!e.altKey&&!e.ctrlKey&&!e.metaKey){if(e.key===`ArrowUp`)return`up`;if(e.key===`ArrowDown`)return`down`;if(e.key===`ArrowLeft`)return`left`;if(e.key===`ArrowRight`)return`right`;if(e.key===`Home`)return`start`;if(e.key===`End`)return`end`}if(Yn(e)){if(e.key===`ArrowLeft`)return`textStart`;if(e.key===`ArrowRight`)return`end`}}var Zn=new WeakMap,Qn=er([{bindings:{Tab:`indent`,"shift+Tab":`outdent`,"cmdOrCtrl+[":`indentLess`,"cmdOrCtrl+]":`indentMore`,"cmdOrCtrl+z":`undo`,"cmdOrCtrl+shift+z":`redo`,"cmdOrCtrl+a":`selectAll`,"cmdOrCtrl+d":`findNextMatch`,"cmdOrCtrl+f":`openSearchPanel`,"cmdOrCtrl+alt+f":`openSearchReplacePanel`,"alt+ArrowUp":`moveLineUp`,"alt+ArrowDown":`moveLineDown`,"shift+alt+ArrowUp":`copyLineUp`,"shift+alt+ArrowDown":`copyLineDown`,Escape:`simplifySelection`,"cmdOrCtrl+Enter":`insertBlankLine`,"cmdOrCtrl+/":`toggleComment`,"shift+alt+a":`toggleBlockComment`,"cmdOrCtrl+Home":`moveCursorToDocStart`,"cmdOrCtrl+End":`moveCursorToDocEnd`,"cmdOrCtrl+shift+Home":`expandSelectionDocStart`,"cmdOrCtrl+shift+End":`expandSelectionDocEnd`}},{platform:`mac`,bindings:{"ctrl+k":`deleteHardLineForward`,"ctrl+alt+p":`moveLineUp`,"ctrl+alt+n":`moveLineDown`,"cmd+ArrowUp":`moveCursorToDocStart`,"cmd+ArrowDown":`moveCursorToDocEnd`,"cmd+shift+ArrowUp":`expandSelectionDocStart`,"cmd+shift+ArrowDown":`expandSelectionDocEnd`}},{platform:`windows`,bindings:{"ctrl+y":`redo`}},{platform:`linux`,bindings:{"ctrl+y":`redo`,"ctrl+alt+p":`moveLineUp`,"ctrl+alt+n":`moveLineDown`}}]),$n={Backquote:"`",Minus:`-`,Equal:`=`,Comma:`,`,Period:`.`,Slash:`/`,Semicolon:`;`,Quote:`'`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Space:`Space`};function er(e){let t=Zn.get(e);if(t===void 0){t={mac:new Map,windows:new Map,linux:new Map};for(let n of e)for(let e of Object.keys(n.bindings)){let r=n.bindings[e];if(r===void 0)continue;let i=e.split(`+`),a=i.pop();for(let e of[`mac`,`windows`,`linux`]){if(n.platform!==void 0&&n.platform!==e)continue;let o=0;for(let t of i)t===`alt`?o|=1:t===`ctrl`?o|=2:t===`cmd`?o|=4:t===`shift`?o|=8:t===`cmdOrCtrl`&&(o|=e===`mac`?4:2);let s=t[e].get(o);s===void 0&&(s=new Map,t[e].set(o,s)),s.set(a,r)}}Zn.set(e,t)}return t}function tr(e,t,n=Be()){let r=e.key===` `?`Space`:e.key.length===1?e.key.toLowerCase():e.key,i=e.code??``,a=i.startsWith(`Key`)&&i.length===4?i.slice(3).toLowerCase():i.startsWith(`Digit`)&&i.length===6?i.slice(5):$n[i],o=n?`mac`:globalThis.navigator?.platform.includes(`Linux`)===!0?`linux`:`windows`,s=+!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);if(t!==void 0){let e=er(t)[o].get(s),n=e?.get(r)??(a===void 0?void 0:e?.get(a));if(n!==void 0)return n}let c=Qn[o].get(s);return c?.get(r)??(a===void 0?void 0:c?.get(a))}function nr(e,t=Be()){if(!e.altKey&&Yn(e,t)&&((e.key.length===1?e.key.toLowerCase():e.key)===`g`||e.code===`KeyG`))return e.shiftKey?`previous`:`next`}var rr=`::selection {
|
|
12
|
+
background-color: #0000;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[data-deleted-text-selection] [data-deletions] ::selection, [data-deleted-text-selection] [data-line-type="change-deletion"] ::selection {
|
|
16
|
+
background-color: var(--diffs-editor-selection-bg);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@keyframes blinking {
|
|
20
|
+
0% {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
50% {
|
|
25
|
+
opacity: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
100% {
|
|
29
|
+
opacity: 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host, [data-code], [data-content], [data-diff-type="split"][data-overflow="wrap"] {
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-code] {
|
|
38
|
+
container-type: inline-size;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-content] {
|
|
42
|
+
cursor: text;
|
|
43
|
+
caret-color: var(--diffs-bg-caret);
|
|
44
|
+
background-color: #0000;
|
|
45
|
+
outline: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[data-line] {
|
|
49
|
+
cursor: text;
|
|
50
|
+
background-color: #0000;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[data-line]:after {
|
|
54
|
+
content: "";
|
|
55
|
+
z-index: -20;
|
|
56
|
+
background-color: var(--diffs-line-bg);
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
position: absolute;
|
|
59
|
+
inset: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[data-line][data-editor-active-line]:after {
|
|
63
|
+
box-shadow: inset 0 0 0 1px var(--diffs-editor-line-highlight-border);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[data-editor-overlay] {
|
|
67
|
+
display: contents;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[data-caret], [data-selection-range], [data-match-range], [data-bracket-match-range], [data-marker-range] {
|
|
71
|
+
height: 1lh;
|
|
72
|
+
line-height: var(--diffs-line-height);
|
|
73
|
+
pointer-events: none;
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: 0;
|
|
76
|
+
left: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-caret] {
|
|
80
|
+
background-color: var(--diffs-bg-caret-override, var(--diffs-editor-cursor-fg, light-dark(color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg)), color-mix(in lab, var(--diffs-fg) 75%, var(--diffs-bg)))));
|
|
81
|
+
visibility: hidden;
|
|
82
|
+
width: 2px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
86
|
+
[data-caret] {
|
|
87
|
+
animation: 1.2s .8s infinite blinking;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[data-selection-range] {
|
|
92
|
+
z-index: -10;
|
|
93
|
+
background-color: var(--diffs-editor-selection-bg);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
[data-selection-corner] {
|
|
97
|
+
background-color: var(--diffs-selection-corner-bg, var(--diffs-bg));
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 100%;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[data-match-range] {
|
|
103
|
+
z-index: -10;
|
|
104
|
+
background-color: var(--diffs-editor-match-bg, var(--diffs-editor-selection-bg));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[data-match-range]:not([data-focus]) {
|
|
108
|
+
background-color: var(--diffs-editor-match-highlight-bg, light-dark(#ff963288, #ff963266));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[data-bracket-match-range] {
|
|
112
|
+
z-index: -9;
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
border-bottom: 1px solid
|
|
115
|
+
var(--diffs-editor-bracket-match-border, color-mix(in lab, var(--diffs-fg) 60%, transparent));
|
|
116
|
+
background-color: var(--diffs-editor-bracket-match-bg, color-mix(in lab, var(--diffs-fg) 5%, transparent));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
[data-rtl] {
|
|
120
|
+
border-top-left-radius: 3px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
[data-rtr] {
|
|
124
|
+
border-top-right-radius: 3px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
[data-rbl] {
|
|
128
|
+
border-bottom-left-radius: 3px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[data-rbr] {
|
|
132
|
+
border-bottom-right-radius: 3px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
[data-marker-range] {
|
|
136
|
+
z-index: 1;
|
|
137
|
+
background-color: var(--diffs-marker-bg);
|
|
138
|
+
mask-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2IiBoZWlnaHQ9IjMiPjxwYXRoIGQ9Im0wIDIuNSBsMiAtMS41IGwxIDAgbDIgMS41IGwxIDAiIHN0cm9rZT0iI2ZmZiIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIi8+PC9zdmc+");
|
|
139
|
+
mask-position: 0 100%;
|
|
140
|
+
mask-size: 6px 3px;
|
|
141
|
+
mask-repeat: repeat-x;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
[data-marker-error] {
|
|
145
|
+
--diffs-marker-contrast: light-dark(#fff, #000);
|
|
146
|
+
--diffs-marker-bg: var(--diffs-editor-error-fg, var(--diffs-deletion-base));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
[data-marker-warning] {
|
|
150
|
+
--diffs-marker-contrast: #000;
|
|
151
|
+
--diffs-marker-bg: var(--diffs-editor-warning-fg, light-dark(var(--diffs-warning-light), var(--diffs-warning-dark)));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
[data-marker-info] {
|
|
155
|
+
--diffs-marker-contrast: #000;
|
|
156
|
+
--diffs-marker-bg: var(--diffs-editor-info-fg, var(--diffs-modified-base));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
[data-marker-hint] {
|
|
160
|
+
--diffs-marker-contrast: light-dark(#fff, #000);
|
|
161
|
+
--diffs-marker-bg: var(--diffs-editor-hint-fg, var(--diffs-fg-number));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@media (width >= 480px) {
|
|
165
|
+
[data-content] {
|
|
166
|
+
caret-color: #0000;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[data-content]:focus ~ [data-editor-overlay] [data-caret] {
|
|
170
|
+
visibility: visible;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
[data-editor-widget] {
|
|
175
|
+
--diffs-widget-fg: var(--diffs-fg);
|
|
176
|
+
--diffs-widget-bg: color-mix(in lab, var(--diffs-fg) 4%, var(--diffs-bg));
|
|
177
|
+
--diffs-widget-border: color-mix(in lab, var(--diffs-fg) 20%, transparent);
|
|
178
|
+
--diffs-widget-shadow: inset 0 0 0 1px var(--diffs-bg), 0 4px 8px #00000013,
|
|
179
|
+
0 6px 18px #00000013;
|
|
180
|
+
z-index: 100;
|
|
181
|
+
width: fit-content;
|
|
182
|
+
max-width: calc(100% - 24px);
|
|
183
|
+
font: 14px/20px var(--diffs-header-font-fallback);
|
|
184
|
+
border: 1px solid var(--diffs-widget-border);
|
|
185
|
+
background-color: var(--diffs-widget-bg);
|
|
186
|
+
box-shadow: var(--diffs-widget-shadow);
|
|
187
|
+
background-clip: padding-box;
|
|
188
|
+
border-radius: 9px;
|
|
189
|
+
position: absolute;
|
|
190
|
+
top: 0;
|
|
191
|
+
left: 0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
[data-marker-popover], [data-selection-action-popover] {
|
|
195
|
+
--popover-gap: var(--diffs-popover-gap, var(--diffs-gap-fallback, 8px));
|
|
196
|
+
--popover-viewport-left: 0px;
|
|
197
|
+
--popover-viewport-right: 100cqw;
|
|
198
|
+
--popover-viewport-top: -99999px;
|
|
199
|
+
--popover-viewport-bottom: 99999px;
|
|
200
|
+
--popover-min-left: calc(var(--popover-viewport-left) + var(--gutter-width, 0px) + var(--popover-gap));
|
|
201
|
+
--popover-available-width: max(0px,
|
|
202
|
+
calc(var(--popover-viewport-right) - var(--popover-min-left) -
|
|
203
|
+
var(--popover-gap)));
|
|
204
|
+
max-width: min(640px, var(--popover-available-width));
|
|
205
|
+
translate: clamp(var(--popover-min-left),
|
|
206
|
+
var(--popover-x, var(--popover-min-left)),
|
|
207
|
+
calc(var(--popover-viewport-right) - var(--popover-gap) - 100%))
|
|
208
|
+
/* Clamp into the scrollport so a popover with no fitting side stays in view. */
|
|
209
|
+
clamp(var(--popover-viewport-top),
|
|
210
|
+
calc(var(--popover-y, 0px) + var(--popover-y-shift, 0px)),
|
|
211
|
+
calc(var(--popover-viewport-bottom) - var(--popover-gap) - 100%));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
[data-marker-popover] {
|
|
215
|
+
--diffs-widget-bg: var(--diffs-marker-bg);
|
|
216
|
+
--diffs-widget-shadow: 0 4px 8px #00000026, 0 6px 18px #00000026;
|
|
217
|
+
min-width: min(180px, var(--popover-available-width));
|
|
218
|
+
overflow-wrap: anywhere;
|
|
219
|
+
color: var(--diffs-marker-contrast);
|
|
220
|
+
white-space: normal;
|
|
221
|
+
pointer-events: auto;
|
|
222
|
+
border: 0;
|
|
223
|
+
padding: 8px 12px;
|
|
224
|
+
|
|
225
|
+
@supports (color: contrast-color(red)) {
|
|
226
|
+
color: contrast-color(var(--diffs-marker-bg, var(--diffs-bg)));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
& [data-marker-message] {
|
|
230
|
+
white-space: normal;
|
|
231
|
+
overflow-wrap: anywhere;
|
|
232
|
+
|
|
233
|
+
& code {
|
|
234
|
+
white-space: normal;
|
|
235
|
+
color: inherit;
|
|
236
|
+
background-color: #0000;
|
|
237
|
+
display: inline;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
[data-selection-action-popover] {
|
|
243
|
+
pointer-events: auto;
|
|
244
|
+
flex-wrap: wrap;
|
|
245
|
+
align-items: center;
|
|
246
|
+
gap: 4px;
|
|
247
|
+
width: max-content;
|
|
248
|
+
padding: 4px;
|
|
249
|
+
display: flex;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
[data-search-panel] {
|
|
253
|
+
z-index: 100;
|
|
254
|
+
flex-direction: column;
|
|
255
|
+
justify-content: right;
|
|
256
|
+
width: 100%;
|
|
257
|
+
height: 0;
|
|
258
|
+
display: flex;
|
|
259
|
+
position: sticky;
|
|
260
|
+
top: 16px;
|
|
261
|
+
right: 16px;
|
|
262
|
+
container: search-panel / inline-size;
|
|
263
|
+
|
|
264
|
+
& [data-editor-widget] {
|
|
265
|
+
z-index: 100;
|
|
266
|
+
flex-shrink: 0;
|
|
267
|
+
align-items: stretch;
|
|
268
|
+
gap: 8px;
|
|
269
|
+
min-width: 260px;
|
|
270
|
+
max-width: 100%;
|
|
271
|
+
margin-inline: auto 16px;
|
|
272
|
+
padding: 4px;
|
|
273
|
+
display: flex;
|
|
274
|
+
position: relative;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
& svg {
|
|
278
|
+
fill: currentColor;
|
|
279
|
+
width: 12px;
|
|
280
|
+
height: 12px;
|
|
281
|
+
display: block;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
[data-search-grid] {
|
|
286
|
+
grid-template-columns: auto auto auto;
|
|
287
|
+
grid-template-areas: "find matches nav"
|
|
288
|
+
"replace actions .";
|
|
289
|
+
align-items: center;
|
|
290
|
+
gap: 4px 6px;
|
|
291
|
+
width: 100%;
|
|
292
|
+
display: grid;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
[data-input-box][data-find] {
|
|
296
|
+
grid-area: find;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
[data-search-nav] {
|
|
300
|
+
grid-area: nav;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
[data-input-box][data-replace] {
|
|
304
|
+
grid-area: replace;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
[data-replace-actions] {
|
|
308
|
+
grid-area: actions;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
[data-search-grid][data-mode="find"] {
|
|
312
|
+
grid-template-areas: "find matches nav";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
[data-search-grid][data-mode="find"] [data-replace-cell] {
|
|
316
|
+
display: none;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@container search-panel (width < 400px) {
|
|
320
|
+
[data-search-panel] [data-editor-widget] {
|
|
321
|
+
padding: 10px;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
[data-search-grid][data-mode="replace"] {
|
|
325
|
+
grid-template-columns: auto 1fr auto;
|
|
326
|
+
grid-template-areas: "find find find"
|
|
327
|
+
"replace replace replace"
|
|
328
|
+
"nav matches actions";
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
[data-search-grid][data-mode="find"] {
|
|
332
|
+
grid-template-columns: auto 1fr auto;
|
|
333
|
+
grid-template-areas: "find find find"
|
|
334
|
+
"nav matches matches";
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
[data-replace-actions] {
|
|
338
|
+
justify-self: end;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
[data-search-grid] [data-input-box] {
|
|
342
|
+
width: auto;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
[data-input-box] {
|
|
347
|
+
align-items: center;
|
|
348
|
+
width: 200px;
|
|
349
|
+
display: flex;
|
|
350
|
+
position: relative;
|
|
351
|
+
|
|
352
|
+
& input {
|
|
353
|
+
width: 100%;
|
|
354
|
+
min-width: 0;
|
|
355
|
+
color: var(--diffs-fg);
|
|
356
|
+
background-color: var(--diffs-bg);
|
|
357
|
+
border: 1px solid color-mix(in lab, var(--diffs-fg) 12%, var(--diffs-bg));
|
|
358
|
+
border-radius: 6px;
|
|
359
|
+
outline: none;
|
|
360
|
+
flex-grow: 1;
|
|
361
|
+
padding-inline: 6px;
|
|
362
|
+
font-size: 13px;
|
|
363
|
+
line-height: 24px;
|
|
364
|
+
|
|
365
|
+
&::selection {
|
|
366
|
+
background-color: color-mix(in lab, var(--diffs-fg) 8%, var(--diffs-bg));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
&:focus-visible {
|
|
370
|
+
outline: 1px solid var(--diffs-modified-base);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
&[data-find] input {
|
|
375
|
+
padding-inline-end: 72px;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
& [data-search-icon] {
|
|
379
|
+
--diffs-search-icon-size: 20px;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
[data-search-toggles] {
|
|
384
|
+
align-items: center;
|
|
385
|
+
gap: 1px;
|
|
386
|
+
display: flex;
|
|
387
|
+
position: absolute;
|
|
388
|
+
top: 50%;
|
|
389
|
+
right: 4px;
|
|
390
|
+
transform: translateY(-50%);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
[data-matches] {
|
|
394
|
+
white-space: nowrap;
|
|
395
|
+
min-width: 50px;
|
|
396
|
+
color: color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg));
|
|
397
|
+
flex-shrink: 0;
|
|
398
|
+
grid-area: matches;
|
|
399
|
+
font-size: 12px;
|
|
400
|
+
font-weight: 500;
|
|
401
|
+
line-height: 20px;
|
|
402
|
+
|
|
403
|
+
&[data-no-matches] {
|
|
404
|
+
color: color-mix(in lab, var(--diffs-fg) 35%, var(--diffs-bg));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
[data-replace-actions], [data-search-nav] {
|
|
409
|
+
align-items: center;
|
|
410
|
+
display: flex;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
[data-search-icon] {
|
|
414
|
+
appearance: none;
|
|
415
|
+
width: var(--diffs-search-icon-size, 24px);
|
|
416
|
+
height: var(--diffs-search-icon-size, 24px);
|
|
417
|
+
color: color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg));
|
|
418
|
+
border-radius: var(--diffs-search-icon-radius, 4px);
|
|
419
|
+
cursor: pointer;
|
|
420
|
+
background: none;
|
|
421
|
+
border: 0;
|
|
422
|
+
flex-shrink: 0;
|
|
423
|
+
justify-content: center;
|
|
424
|
+
align-items: center;
|
|
425
|
+
margin: 0;
|
|
426
|
+
padding: 0;
|
|
427
|
+
transition: background-color .1s ease-in-out, color .1s ease-in-out;
|
|
428
|
+
display: flex;
|
|
429
|
+
|
|
430
|
+
&:disabled {
|
|
431
|
+
opacity: .25;
|
|
432
|
+
cursor: default;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
&:not(:disabled):hover {
|
|
436
|
+
color: var(--diffs-fg);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
&:focus-visible {
|
|
440
|
+
outline: 1px solid var(--diffs-modified-base);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
&[aria-pressed="true"] {
|
|
444
|
+
color: var(--diffs-modified-base);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
[data-search-close] {
|
|
449
|
+
--diffs-search-icon-size: 20px;
|
|
450
|
+
--diffs-search-icon-radius: 50%;
|
|
451
|
+
color: var(--diffs-widget-bg);
|
|
452
|
+
background-color: color-mix(in lab,
|
|
453
|
+
var(--diffs-widget-fg) 50%,
|
|
454
|
+
var(--diffs-bg));
|
|
455
|
+
position: absolute;
|
|
456
|
+
top: 0;
|
|
457
|
+
right: 0;
|
|
458
|
+
transform: translate(50%, -50%);
|
|
459
|
+
|
|
460
|
+
&:not(:disabled):hover {
|
|
461
|
+
opacity: 1;
|
|
462
|
+
color: var(--diffs-widget-bg);
|
|
463
|
+
background-color: var(--diffs-widget-fg);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
`,ir=`//`,ar=[`/*`,`*/`],or={sql:{lineComment:`--`},ruby:{lineComment:`#`,blockComment:[`=begin`,`=end`]},rst:{lineComment:`..`},coffeescript:{lineComment:`#`,blockComment:[`###`,`###`]},cmd:{lineComment:`@REM`},julia:{lineComment:`#`,blockComment:[`#=`,`=#`]},yaml:{lineComment:`#`},yml:{lineComment:`#`},markdown:{lineComment:null,blockComment:[`<!--`,`-->`]},zsh:{lineComment:`#`},makefile:{lineComment:`#`},handlebars:{lineComment:null,blockComment:[`{{!--`,`--}}`]},ini:{lineComment:`;`,blockComment:[`;`,` `]},powershell:{lineComment:`#`,blockComment:[`<#`,`#>`]},vb:{lineComment:`'`},xml:{lineComment:null,blockComment:[`<!--`,`-->`]},lua:{lineComment:`--`,blockComment:[`--[[`,`]]`]},html:{lineComment:null,blockComment:[`<!--`,`-->`]},diff:{lineComment:`#`,blockComment:[`#`,` `]},r:{lineComment:`#`},fsharp:{blockComment:[`(*`,`*)`]},pug:{lineComment:`//-`},perl:{lineComment:`#`},tex:{lineComment:`%`},clojure:{lineComment:`;;`},css:{lineComment:null},python:{lineComment:`#`,blockComment:[`"""`,`"""`]},dotenv:{lineComment:`#`},dockerfile:{lineComment:`#`},razor:{lineComment:null,blockComment:[`<!--`,`-->`]},prompt:{lineComment:null,blockComment:[`<!--`,`-->`]}};function sr(e,t){let n={...or[e],...t?.[e]};return{lineComment:n.lineComment===void 0?ir:n.lineComment,blockComment:n.blockComment??ar}}function cr(e,t,n){let r=[],i=new Set;for(let a of t){let t=a.end.line;a.start.line<t&&a.end.character===0&&t--;let o=r.length,s=1/0;for(let o=a.start.line;o<=t;o++){if(i.has(o))continue;i.add(o);let t=e.getLineText(o),a=t.length-t.trimStart().length,c=a===t.length;c||(s=Math.min(s,a)),r.push({line:o,comment:t.slice(a,a+n.length)===n?a:-1,empty:c,indent:a,single:!1})}if(s!==1/0)for(let e=o;e<r.length;e++)r[e].empty||(r[e].indent=s);r.length===o+1&&(r[o].single=!0)}let a=r.some(e=>e.comment<0&&(!e.empty||e.single)),o=[];if(a){for(let e of r){if(e.empty&&!e.single)continue;let t={line:e.line,character:e.indent};o.push({range:{start:t,end:t},newText:n+` `})}return o}for(let t of r){if(t.comment<0)continue;let r=e.getLineText(t.line),i=t.comment,a=i+n.length+ +(r[i+n.length]===` `);o.push({range:{start:{line:t.line,character:i},end:{line:t.line,character:a}},newText:``})}return o}var lr=50;function ur(e,t,n,r,i){let a=Math.max(0,r-lr),o=e.getTextSlice(a,r),s=e.getTextSlice(i,i+lr),c=o.length-o.trimEnd().length,l=s.length-s.trimStart().length,u=o.length-c;if(o.slice(u-t.length,u)===t&&s.slice(l,l+n.length)===n)return{open:{start:r-c-t.length,end:r-c+ +(c>0),text:``},close:{start:i+l-+(l>0),end:i+l+n.length,text:``},contentStart:r,contentEnd:i};let d=i-r<=100?e.getTextSlice(r,i):void 0,f=d??e.getTextSlice(r,r+lr),p=d??e.getTextSlice(i-lr,i),m=f.length-f.trimStart().length,h=i-(p.length-p.trimEnd().length)-n.length;if(f.slice(m,m+t.length)!==t||e.getTextSlice(h,h+n.length)!==n)return;let g=r+m,_=g+t.length+ +!!/\s/.test(f[t.length+m]??``),v=h-+!!/\s/.test(e.getTextSlice(h-1,h));return{open:{start:g,end:_,text:``},close:{start:v,end:h+n.length,text:``},contentStart:_,contentEnd:v}}function dr(e,t,n,r){let i=0,a=t.length;for(;i<a;){let n=i+a>>>1;t[n].end<e?i=n+1:a=n}let o=n[i];for(let n=i;n<t.length;n++){let i=t[n];if(e<i.start)break;if(i.start===i.end&&e===i.start){if(r<0)break;o+=i.text.length;continue}if(e>i.end){o+=i.text.length-(i.end-i.start);continue}return e===i.end?i.start+o+i.text.length:i.start+o+(r>0?i.text.length:0)}return e+o}function fr(e,t,[n,r],i=!1){let a=t.map(t=>{let{start:n,end:r}=t;if(i){let t=r.line;n.line<t&&r.character===0&&t--;let i=e.getLineText(n.line),a=i.length-i.trimStart().length;n={line:n.line,character:a},r={line:t,character:e.getLineLength(t)}}return{from:e.offsetAt(n),to:e.offsetAt(r),direction:t.direction,comment:void 0}});if(i&&a.length>1){a.sort((e,t)=>{let n=e.from-t.from;return n===0?e.to-t.to:n});let e=0;for(let t=1;t<a.length;t++){let n=a[e],r=a[t];r.from<=n.to?n.to=Math.max(n.to,r.to):a[++e]=r}a.length=e+1}for(let t of a)t.comment=ur(e,n,r,t.from,t.to);let o=a.every(e=>e.comment!==void 0),s=[];for(let e of a){let t=e.comment;if(o&&t!==void 0){s.push(t.open,t.close);continue}if(t===void 0){if(e.from===e.to){s.push({start:e.from,end:e.to,text:n+` `+r});continue}s.push({start:e.from,end:e.from,text:n+` `},{start:e.to,end:e.to,text:` `+r})}}if(s.length===0)return;s.sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n});let c=s.map(t=>({range:{start:e.positionAt(t.start),end:e.positionAt(t.end)},newText:t.text}));if(i)return{edits:c,nextSelectionOffsets:[]};let l=a.map(e=>{let t=e.comment;return o&&t!==void 0?{start:t.contentStart,end:t.contentEnd,startAssociation:1,endAssociation:-1}:t===void 0?e.from===e.to?{start:e.from,end:e.to,startAssociation:-1,endAssociation:-1,collapsedInset:n.length+1}:{start:e.from,end:e.to,startAssociation:1,endAssociation:-1}:{start:e.from,end:e.to,startAssociation:1,endAssociation:1}}),u=Array(s.length+1);u[0]=0;for(let e=0;e<s.length;e++){let t=s[e];u[e+1]=u[e]+t.text.length-(t.end-t.start)}return{edits:c,nextSelectionOffsets:l.map((e,t)=>{let n=dr(e.start,s,u,e.startAssociation)+(e.collapsedInset??0);return[n,e.collapsedInset===void 0?dr(e.end,s,u,e.endAssociation):n,a[t].direction]})}}function U(e,t,n){let{style:r,dataset:i,children:a,...o}=t??{},s=document.createElement(e);return Object.assign(s,o),r!==void 0&&(typeof r==`string`?s.style.cssText=r:Object.assign(s.style,r)),i!==void 0&&(typeof i==`string`?s.dataset[i]=``:Array.isArray(i)?i.forEach(e=>{s.dataset[e]=``}):Object.assign(s.dataset,i)),a!==void 0&&s.replaceChildren(...a),n!==void 0&&n.appendChild(s),s}function W(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function G(e,t=`line`){let n=e.dataset[t];if(n===void 0)return;let r=parseInt(n,10);if(!Number.isNaN(r))return r}function pr(e,t){if(e.nodeType===3){let n=e.textContent?.length??0;return Math.max(0,Math.min(t,n))}return e.nodeType===1?Math.max(0,Math.min(t,e.childNodes.length)):0}function mr(e,t){return Object.assign(e,t)}function hr(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout(()=>e.apply(this,r),t)}}function gr(e,t=1e3){return Math.round(e*t)/t}function _r(e){return e.endsWith(`
|
|
467
|
+
`)||e.endsWith(`\r`)}function vr(e){if(!(typeof Intl>`u`||typeof Intl.Segmenter!=`function`))return new Intl.Segmenter(void 0,e)}var yr,br=!1;function xr(){return br||=(yr=vr({granularity:`grapheme`}),!0),yr}function Sr(e){let t=e.ownerDocument,n=e.parentElement;for(;n!=null&&n!==t.body&&n!==t.documentElement;){let e=n.ownerDocument.defaultView?.getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return n;n=n.parentElement}return t}function Cr(e,t){let n=wr(e);if(n.length===0)return;let r=[],i=!1;for(let a of t){if(a.side===`deletions`||a.lineNumber<=0){r.push(a);continue}let t=a.lineNumber-1,o=e.previousLineCount,s=!1;for(let e of n){let n=Math.max(1,o+e.lineDelta),r=Tr(t,e,n);if(r===void 0){s=!0,t=void 0;break}(r!==t||Dr(t,e))&&(s=!0),t=r,o=n}if(t===void 0){i=!0;continue}let c=t+1;if(s){r.push(c===a.lineNumber?a:{...a,lineNumber:c}),i=!0;continue}r.push(a)}return i?r:void 0}function wr(e){if(e.changedLineChanges!==void 0)return e.changedLineChanges.flatMap(([e,t,n,r=0,i=0,a=!1])=>{if(n===0)return[];let o=Math.max(0,t-e);return[{startLine:e,startCharacter:r,endLine:e+Math.max(0,o-n),deletesEndLine:n<0&&a,insertedLineBreaks:o,lineDelta:n}]});if(e.lineDelta===0)return e.changedLineRanges.flatMap(([e,t])=>{let n=t-e;return n<=0?[]:[{startLine:e,startCharacter:0,endLine:e,deletesEndLine:!1,insertedLineBreaks:n,lineDelta:n}]});let t=Math.max(0,-e.lineDelta),n=e.endedAtDocumentEnd&&e.startLine+t===e.previousLineCount-1;return[{startLine:e.startLine,startCharacter:e.startCharacter,endLine:e.startLine+t,deletesEndLine:n,insertedLineBreaks:Math.max(0,e.lineDelta),lineDelta:e.lineDelta}]}function Tr(e,t,n){if(e<t.startLine)return e;if(e>t.endLine||t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)return e+t.lineDelta;if(t.startLine===t.endLine)return t.startCharacter===0?e+t.insertedLineBreaks:e;if(Er(e,t))return;let r=Math.min(Math.max(0,e-t.startLine),t.insertedLineBreaks);return Or(t.startLine+r,n)}function Er(e,t){return!(t.lineDelta>=0||e<t.startLine||e>t.endLine||e===t.startLine&&t.startCharacter>0||e===t.endLine&&!t.deletesEndLine)}function Dr(e,t){return t.lineDelta===0||e<t.startLine||e>t.endLine?!1:!(t.endLine>t.startLine&&e===t.endLine&&!t.deletesEndLine)}function Or(e,t){return Math.max(0,Math.min(e,Math.max(0,t-1)))}function kr(e,t,n){let r=new Map,i=new Map;for(let t of e){let e=t.lineNumber;r.has(e)||r.set(e,[]),i.has(e)||i.set(e,[]),(t.side===`deletions`?i:r).get(e).push(Ze(t))}let a=t.parentElement?.previousElementSibling,o,s;if(a!=null&&a instanceof HTMLElement&&a.dataset.deletions!==void 0)for(let e of a.children){let t=e,{gutter:n,content:r}=t.dataset;n===void 0?r!==void 0&&(s=t):o=t}Ar(t,n),s!==void 0&&Ar(s,o);let c=jr(r,t,n);if(s===void 0)return;let l=jr(i,s,o);requestAnimationFrame(()=>{Mr(r,i,c,l)})}function Ar(e,t){let n=[];for(let r=1;r<e.childElementCount;r++){let i=e.children[r];i.dataset.lineAnnotation!==void 0&&(n.push(i),t!==void 0&&n.push(t.children[r]))}for(let e of n)e.remove()}function jr(e,t,n){let r=new Map;for(let n of t.children){let t=G(n);if(t!==void 0){let i=e.get(t);if(i!==void 0){let e=U(`div`,{dataset:{lineAnnotation:`0,`+(t-1)},children:[U(`div`,{dataset:`annotationContent`,children:i.map(e=>U(`slot`,{name:e}))})]});n.after(e),r.set(t,e)}}}if(n!==void 0)for(let t of n.children){let n=G(t,`columnNumber`);if(n!==void 0&&e.has(n)){let e=U(`div`,{dataset:{gutterBuffer:`annotation`,bufferSize:`1`},style:{gridRow:`span 1`}});t.after(e)}}return r}function Mr(e,t,n,r){let i=new Map;for(let[t,n]of e.entries()){let e=r.get(t);if(n.length===0&&e!==void 0){let n=Nr(e);n>0&&i.set(t,n)}}for(let[e,r]of t.entries()){let t=n.get(e);if(r.length===0&&t!==void 0){let n=Nr(t);n>0&&i.set(e,n)}}Pr(e,n,i),Pr(t,r,i)}function Nr(e){let t=e.firstElementChild;return t instanceof HTMLElement?t.getBoundingClientRect().height:0}function Pr(e,t,n){for(let[r,i]of t.entries()){let t=e.get(r),a=n.get(r);t?.length===0&&a!==void 0&&i.style.setProperty(`--diffs-annotation-min-height`,`${a}px`)}}var Fr=class{#e;#t;#n;#r;#i;#a;#o=0;#s=0;#c=0;#l=!0;#u;#d=new Map;#f;#p;constructor(e){this.#f=e.hasActivePopover,this.#p=e.updateActivePopover}setViewportElements(e,t){let n=this.#e!==e||this.#t!==t;this.#e=e,n&&(this.#t=t,this.#l=!0,this.#u?.forEach(e=>e()),this.#u=void 0)}cleanUp(){this.#t=void 0,this.#e=void 0,this.#n=void 0,this.#r=void 0,this.#i=void 0,this.#a=void 0,this.#o=0,this.#s=0,this.#c=0,this.#l=!0,this.#u?.forEach(e=>e()),this.#u=void 0,this.#d.clear()}resetPlacement(e=`default`){this.#d.delete(e)}setPlacement(e,t=`default`){this.#d.set(t,e)}choosePlacement(e){let{preferred:t,fallback:n,viewport:r,popoverHeight:i,atDocumentEdge:a,placementKey:o=`default`}=e,s=this.#d.get(o),c;if(r!==void 0&&i>0){let e=(e,t=0)=>e.top>=r.top+t&&e.bottom<=r.bottom-t;c=s===`fallback`&&e(n)&&!e(t,4)||!e(t)&&e(n)?`fallback`:`preferred`}else c=a?`fallback`:`preferred`;return this.#d.set(o,c),c}getPlacementBounds(){let e=this.#g();if(e===void 0)return;let t=this.#_(),n,r;if(t===void 0?(n=0,r=window.innerHeight):(n=t.top,r=t.bottom),n=Math.max(n,e.top),r=Math.min(r,e.bottom),r<=n)return;let i=this.#o,a=this.#s,o=this.#c>0?this.#c:e.width,s=t===void 0?0:t.left,c=t===void 0?window.innerWidth:t.right,l=i,u=i+o,d=Math.max(l,s-e.left+i),f=Math.min(u,c-e.left+i);return{top:n-e.top+a,bottom:r-e.top+a,left:d,right:Math.max(d,f)}}#m(){let e=this.#e;if(e===void 0)return;if(this.#r===e&&(this.#n===void 0||this.#n.isConnected))return this.#n;let t=e.parentElement;for(;t!==null;){let n=getComputedStyle(t).overflowY;if(n===`auto`||n===`scroll`||n===`overlay`)return this.#n=t,this.#r=e,t;t=t.parentElement}this.#n=void 0,this.#r=e}#h(){if(!this.#l)return;this.#v();let e=this.#t;this.#i=e?.getBoundingClientRect(),this.#o=e?.scrollLeft??0,this.#s=e?.scrollTop??0,this.#c=e?.clientWidth??0,this.#a=this.#m()?.getBoundingClientRect(),this.#l=!1}#g(){return this.#h(),this.#i}#_(){return this.#h(),this.#a}#v(){if(this.#u!==void 0)return;let e,t=()=>{this.#l=!0,!(!this.#f()||e!==void 0)&&(e=requestAnimationFrame(()=>{e=void 0,this.#p()}))},n=this.#m(),r=this.#t;this.#u=[W(n===void 0?window:n,`scroll`,t,{passive:!0}),...r===void 0?[]:[W(r,`scroll`,t,{passive:!0})],W(window,`resize`,t,{passive:!0}),()=>{e!==void 0&&(cancelAnimationFrame(e),e=void 0)}]}};function Ir(e,{gutterWidth:t,placeAbove:n,viewport:r,x:i,y:a}){if(e.style.setProperty(`--gutter-width`,t+`px`),e.style.setProperty(`--popover-x`,i+`px`),e.style.setProperty(`--popover-y`,a+`px`),e.style.setProperty(`--popover-y-shift`,n?`-100%`:`0px`),r===void 0){e.style.removeProperty(`--popover-viewport-left`),e.style.removeProperty(`--popover-viewport-right`),e.style.removeProperty(`--popover-viewport-top`),e.style.removeProperty(`--popover-viewport-bottom`);return}e.style.setProperty(`--popover-viewport-left`,r.left+`px`),e.style.setProperty(`--popover-viewport-right`,r.right+`px`),e.style.setProperty(`--popover-viewport-top`,r.top+`px`),e.style.setProperty(`--popover-viewport-bottom`,r.bottom+`px`)}var Lr=new Map([[`'`,`'`],[`"`,`"`],["`","`"],[`{`,`}`],[`[`,`]`],[`<`,`>`],[`(`,`)`]]),Rr=new Set([`'`,`"`,"`"]),zr=new Set([`{`,`[`,`(`,`<`]);function Br(e,t=0){let n=Ui(e.startContainer,e.startOffset),r=Ui(e.endContainer,e.endOffset);if(n!==null&&r!==null)return{start:n,end:r,direction:t}}function Vr(e,t,n,r){if(e===void 0)return[[],t];let{start:i,end:a}=t,o=[],s={...t},c=i.line!==a.line,l=a.line;i.line<a.line&&a.character===0&&l--;for(let t=i.line;t<=l;t++){let l=e.getLineText(t);if(l===void 0||c&&l.trim().length===0)continue;let u=l.startsWith(` `)?` `:` `.repeat(n),d=0,f=u;if(r){if(l.startsWith(` `))d=1;else if(l.startsWith(` `)){let e=l.length-l.trimStart().length;d=Math.min(u.length,e)}if(d===0)continue;f=``}o.push({range:{start:{line:t,character:0},end:{line:t,character:d}},newText:f});let p=f.length-d;t===i.line&&(s={...s,start:{...i,character:Math.max(0,i.character+p)}}),t===a.line&&(s={...s,end:{...a,character:Math.max(0,a.character+p)}})}return[o,s]}function Hr(e,t,n,r={}){let i=e.lineCount;return t.map(t=>{let{line:a,character:o}=n===`up`||n===`left`?t.start:t.end;if(n===`textStart`||n===`start`||n===`end`){let i=q(t);a=i.line,o=i.character;let s=Gr(e,a,o,r);if(n===`textStart`){let t=e.getLineText(a).slice(s.start,s.end),n=s.start+Bi(t);o=o===n?s.start:n}else o=n===`start`?s.start:s.end}else if(n===`up`){let t=Ur(e,a,o,-1,r);t===void 0?a>0&&(a=r.resolveRenderableLine==null?a-1:r.resolveRenderableLine(a-1,`up`)??a):(a=t.line,o=t.character)}else if(n===`down`){let t=Ur(e,a,o,1,r);if(t!==void 0)a=t.line,o=t.character;else{let e=Math.max(i-1,0);a<e&&(a=r.resolveRenderableLine==null?a+1:Math.min(r.resolveRenderableLine(a+1,`down`)??a,e))}}else if(K(t)){let t=e.getLineLength(a);if(o=Math.min(o,t),n===`left`){if(o>0)o=Ii(e,a,o,!1);else if(a>0){let t=r.resolveRenderableLine==null?a-1:r.resolveRenderableLine(a-1,`up`);t!==void 0&&(a=t,o=e.getLineLength(a))}}else if(o<t)o=Ii(e,a,o,!0);else if(a<i-1){let e=r.resolveRenderableLine==null?a+1:r.resolveRenderableLine(a+1,`down`);e!==void 0&&(a=Math.min(e,i-1),o=0)}}let s={line:a,character:o};return{start:s,end:s,direction:0}})}function Ur(e,t,n,r,i){if(i.getSoftLineOffsets===void 0)return;let a=Gr(e,t,n,i),o=a.index+r,s=t,c;if(o>=0&&o<a.count)c=qr(e,s,o,i);else{let a=t+r;if(a<0||a>=e.lineCount)return{line:t,character:n};let o=i.resolveRenderableLine==null?a:i.resolveRenderableLine(a,r<0?`up`:`down`);if(o===void 0)return{line:t,character:n};s=Math.min(o,e.lineCount-1);let l=Kr(e,s,i);c=qr(e,s,r<0?l-1:0,i)}let l=Math.max(0,n-a.start),u=c.start+l,d=c.index===c.count-1?u:Math.min(u,c.end),f=e.getLineText(s);return{line:s,character:d>f.length?d:Wr(f,d)}}function Wr(e,t){if(t<=0||t>=e.length)return t;let n=xr();if(n!==void 0){for(let r of n.segment(e)){if(t<=r.index)return t;let e=r.index+r.segment.length;if(t<e)return e}return t}let r=0;for(let n of e){if(t<=r)return t;let e=r+n.length;if(t<e)return e;r=e}return t}function Gr(e,t,n,r){let i=e.getLineLength(t),a=r.getSoftLineOffsets?.(t);if(a===void 0||a.length<2)return{start:0,end:i,index:0,count:1};for(let i=0;i+1<a.length;i++){let a=qr(e,t,i,r);if(n>=a.start&&n<=a.end)return a}return qr(e,t,n<(a[0]??0)?0:a.length-2,r)}function Kr(e,t,n){let r=n.getSoftLineOffsets?.(t);return r===void 0||r.length<2?1:r.length-1}function qr(e,t,n,r){let i=e.getLineLength(t),a=r.getSoftLineOffsets?.(t);if(a===void 0||a.length<2)return{start:0,end:i,index:0,count:1};let o=a.length-1,s=Math.max(0,Math.min(n,o-1)),c=Math.max(0,Math.min(i,a[s]??0));return{start:c,end:Math.max(c,Math.min(i,a[s+1]??i)),index:s,count:o}}function Jr(e,t,n,r={}){return t.map(t=>{let i=t.direction===-1?t.start:t.end,[a]=Hr(e,[{start:i,end:i,direction:0}],n,r);return fi(t,a)})}function Yr(e,t,n,r,i=2,a=!1){if(t[t.length-1]===void 0)return{nextSelections:[]};let o=[];for(let e of t)o.push(e.start,e.end);let s=o.map(t=>e.offsetAt(t)),c=s[(t.length-1)*2],l=s[(t.length-1)*2+1],u=[],d=!0;for(let e=0;e<t.length;e++){let t={index:e,start:s[e*2],end:s[e*2+1]},n=u[u.length-1];n!==void 0&&(t.start<n.start||t.start===n.start&&t.end<n.end)&&(d=!1),u.push(t)}d||u.sort((e,t)=>{let n=e.start-t.start;if(n!==0)return n;let r=e.end-t.end;return r===0?e.index-t.index:r});let f=Hi(e,n,i),p=[],m=Array.from({length:t.length}),h=0,g,_=()=>{if(g===void 0)return;let t=Hi(e,{start:g.start,end:g.end,text:f.text},i),n=zi(e,t.text,t.start);p.push({start:t.start,end:t.end,text:n});let r=[g.start+h+n.length,g.start+h+n.length];for(let e of g.indices)m[e]=r;h+=n.length-(t.end-t.start),g=void 0};for(let e of u){let t=Math.max(0,e.start+(f.start-c)),n=Math.max(t,e.end+(f.end-l));if(g!==void 0&&t<g.end){g.end=Math.max(g.end,n),g.indices.push(e.index);continue}_(),g={start:t,end:n,indices:[e.index]}}_();let v=e.applyResolvedEdits(p,!0,t,void 0,a),y=Vi(e,m.map(e=>{if(e===void 0)throw Error(`Missing next selection offsets`);return e}));if(e.setLastUndoSelectionsAfter(y),v!==void 0&&r!==void 0){let t=Cr(v,r);t!==void 0&&e.setLastUndoLineAnnotations(r,t)}return{nextSelections:y,change:v}}function Xr(e,t){if(t.length!==e.length+2)return;let n=Lr.get(t[0]);if(n!==void 0&&t[t.length-1]===n&&t.slice(1,-1)===e)return 1}function Zr(e,t,n,r){let i=t.start+n,a=i+r.length;if(t.end-t.start>0){let n=e.getTextSlice(t.start,t.end),a=Xr(n,r)??r.indexOf(n);if(a!==-1&&a+n.length<=r.length){let e=i+a;return[e,e+n.length]}}return[a,a]}function Qr(e,t,n,r,i=!1,a=`selection`){if(t.length!==n.length)throw Error(`Selection text replacements must match the selection count`);let o=[];for(let e of t)o.push(e.start,e.end);let s=o.map(t=>e.offsetAt(t)),c=[],l=!0;for(let e=0;e<t.length;e++){let t={index:e,start:s[e*2],end:s[e*2+1]},n=c[c.length-1];n!==void 0&&(t.start<n.start||t.start===n.start&&t.end<n.end)&&(l=!1),c.push(t)}l||c.sort((e,t)=>{let n=e.start-t.start;if(n!==0)return n;let r=e.end-t.end;return r===0?e.index-t.index:r});let u=n.every(e=>e===``),d,f=Array.from({length:t.length});if(u){d=[];let e=!1;for(let t of c){if(f[t.index]=[t.end,t.end],t.start>=t.end)continue;e=!0;let n=d[d.length-1];n!==void 0&&t.start<n.end?d[d.length-1]={start:n.start,end:Math.max(n.end,t.end),text:``}:d.push({start:t.start,end:t.end,text:``})}if(!e)return{nextSelections:t};for(let e of c){let t=e.end,n=0,r=t;for(let e of d){if(t<=e.start)break;if(t>=e.end){n-=e.end-e.start;continue}r=e.start+n;break}r===t&&(r+=n),f[e.index]=[r,r]}}else{d=[];let t=0,r=-1;for(let i=0;i<c.length;i++){let o=c[i];if(o.start<r)throw Error(`Overlapping multi-selection edits are not supported`);r=o.end;let s=zi(e,n[a===`document`?i:o.index],o.start);d.push({start:o.start,end:o.end,text:s}),f[o.index]=Zr(e,o,t,s),t+=s.length-(o.end-o.start)}}let p=e.applyResolvedEdits(d,!0,t,void 0,i),m=Vi(e,f.map(e=>{if(e===void 0)throw Error(`Missing next selection offsets`);return e}));if(e.setLastUndoSelectionsAfter(m),p!==void 0&&r!==void 0){let t=Cr(p,r);t!==void 0&&e.setLastUndoLineAnnotations(r,t)}return{nextSelections:m,change:p}}function $r(e,t){return e===`never`?!1:e===`brackets`?zr.has(t):e!==`quotes`||Rr.has(t)}function ei(e,t,n,r){if(n.length!==1||t.length===0)return;let i=Lr.get(n);if(i===void 0||!$r(r,n))return;let a=[];for(let r of t){if(K(r))return;a.push(n+e.getText(r)+i)}return a}function ti(e,t,n){let r=[],i=[];for(let n of t){let[t,a]=Li(e,n);if(!K(n)){i.push([t,a]);continue}let{line:o,character:s}=n.start,c=t,l=e.getLineText(o),u=l.length,d=c-s,f=Fi(l),p;if(s>0&&s<u){let e=Pi(l,s,!1,f),t=Pi(l,s,!0,f);p={start:d+e,end:d+t,text:l.slice(s,t)+l.slice(e,s)},i.push([d+t,d+t])}else if(s===u&&f.length>=2){let e=f[f.length-1],t=f[f.length-2];p={start:d+t,end:c,text:l.slice(e,u)+l.slice(t,e)},i.push([c,c])}else if(s===0&&o>0&&u>0){let t=o-1,n=e.getLineText(t),r=n.length,a=e.offsetAt({line:t,character:r}),s=r>0?Pi(n,r,!1,Fi(n)):r,u=Pi(l,0,!0,f),d=a-(r-s),m=l.slice(0,u)+e.getTextSlice(a,c)+n.slice(s,r);p={start:d,end:c+u,text:m};let h=d+m.length;i.push([h,h])}else{i.push([t,a]);continue}r.push(p)}if(r.length===0)return{nextSelections:t};r.sort((e,t)=>e.start-t.start);for(let e=1;e<r.length;e++)if(r[e].start<r[e-1].end)throw Error(`Overlapping multi-selection edits are not supported`);let a=e.applyResolvedEdits(r,!0,t),o=Vi(e,i);if(e.setLastUndoSelectionsAfter(o),a!==void 0&&n!==void 0){let t=Cr(a,n);t!==void 0&&e.setLastUndoLineAnnotations(n,t)}return{nextSelections:o,change:a}}function ni(e,t,n){let r=t.map(t=>{let n=Ri(e,t);return{start:n.start,end:n.end,direction:0}});return Qr(e,r,r.map(()=>``),n)}function ri(e,t,n,r){let i=t.map(t=>{if(!K(t))return{start:t.start,end:t.end,direction:0};let r=q(t),{line:i,character:a}=r,o=n?.(i,a)??0;if(a>o)return{start:{line:i,character:o},end:{line:i,character:a},direction:0};if(i===0)return{start:r,end:r,direction:0};let s=e.getLineLength(i-1);return{start:{line:i-1,character:s},end:{line:i,character:0},direction:0}});return Qr(e,i,i.map(()=>``),r)}function ii(e,t,n){let r=t.map(t=>{let[n,r]=Ni(e,t);return{start:n,end:r,direction:0}});return Qr(e,r,r.map(()=>``),n)}function ai(e,t,n){if(!K(t))return[t.start,t.end];let r=q(t),{line:i,character:a}=r,o=e.getLineLength(i),s=e.lineCount;if(a=Math.min(a,o),n)return a<o?[{line:i,character:a},{line:i,character:Ii(e,i,a,!0)}]:i<s-1?[{line:i,character:o},{line:i+1,character:0}]:[r,r];if(a>0)return[{line:i,character:Ii(e,i,a,!1)},{line:i,character:a}];if(i>0){let t=e.getLineLength(i-1);return[{line:i-1,character:t},{line:i,character:0}]}return[r,r]}function oi(e,t,n,r,i=2){let a=t.map(t=>{let[r,a]=ai(e,t,n);if(!n&&K(t)){let t=Hi(e,{start:e.offsetAt(r),end:e.offsetAt(a),text:``},i);r=e.positionAt(t.start),a=e.positionAt(t.end)}return{start:r,end:a,direction:0}});return Qr(e,a,a.map(()=>``),r)}function K(e){return e.start.line===e.end.line&&e.start.character===e.end.character}function q(e){let{start:t,end:n,direction:r}=e;return r===-1?t:n}function si(e){return e===`context`||e===`context-expanded`||e===`change-addition`}function ci(e,t){let n=K(e),r=K(t);return n&&r?J(e.start,t.start)===0:n?J(t.start,e.start)<=0&&J(e.start,t.end)<=0:r?J(e.start,t.start)<=0&&J(t.start,e.end)<=0:J(e.start,t.end)<0&&J(t.start,e.end)<0}function J(e,t){return e.line===t.line?e.character-t.character:e.line-t.line}function li(e,t,n){let r=t===n?0:t<n?1:-1,i=Math.min(t,n),a=Math.max(t,n);return{start:e.positionAt(i),end:e.positionAt(a),direction:r}}function ui(e,t){let n=0;for(let r of t){if(e<r.start)break;if(e>=r.end)n+=r.text.length-(r.end-r.start);else return r.start+n+r.text.length}return e+n}function di(e,t,n,r){return t.map((t,i)=>{let[a,o]=n[i],s=ui(a,r),c=ui(o,r);return li(e,t.direction===-1?c:s,t.direction===-1?s:c)})}function fi(e,t){let n=e.direction===-1?e.end:e.start,r=J(n,t.start),i=J(n,t.end),a=t.end;a=r<=0?t.end:i>=0?t.start:r===0?t.end:t.start;let o=J(n,a);return{start:o<=0?n:a,end:o<=0?a:n,direction:o===0?0:o<0?1:-1}}function pi(e,t){let n=J(t.start,e.start)<0,r=J(t.end,e.end)>0;return n&&!r?{start:t.start,end:e.end,direction:-1}:r&&!n?{start:e.start,end:t.end,direction:1}:e.direction===-1?{start:t.start,end:e.end,direction:J(t.start,e.end)===0?0:-1}:{start:e.start,end:t.end,direction:J(e.start,t.end)===0?0:1}}function mi(e,t){return hi(e.map(e=>pi(e,t)))}function hi(e){if(e.length<=1)return e;let t=e.map((e,t)=>({index:t,selection:e})).sort((e,t)=>{let n=J(e.selection.start,t.selection.start);if(n!==0)return n;let r=J(e.selection.end,t.selection.end);return r===0?e.index-t.index:r}),n=[],r=t[0];for(let e of t.slice(1)){if(ci(r.selection,e.selection)){let t=e.index>r.index?e:r,n=J(e.selection.start,r.selection.start)<0?e.selection.start:r.selection.start,i=J(e.selection.end,r.selection.end)>0?e.selection.end:r.selection.end,a=t.selection.direction;a===0&&J(n,i)!==0&&(a=J(t.selection.start,n)===0?-1:1),r={index:t.index,selection:{direction:a,end:i,start:n}};continue}n.push(r),r=e}return n.push(r),n.sort((e,t)=>e.index-t.index).map(({selection:e})=>e)}function gi(e){let t=e.map(e=>{let t=e.end.line;return e.end.character===0&&J(e.start,e.end)!==0&&t--,{startLine:e.start.line,endLine:Math.max(e.start.line,t)}}).sort((e,t)=>{let n=e.startLine-t.startLine;return n===0?e.endLine-t.endLine:n}),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&e.startLine<=t.endLine+1?t.endLine=Math.max(t.endLine,e.endLine):n.push({...e})}return n}function _i(e,t,n,r){let i=e=>{let i=e.line+t;if(i>=n){let e=Math.max(0,n-1);return{line:e,character:r(e)}}return i<0?{line:0,character:0}:{line:i,character:e.character}};return{start:i(e.start),end:i(e.end),direction:e.direction}}function vi(e,t){if(t.length===0)return;let n=t.map(t=>K(t)?ji(e,t):t),r=n.map(t=>e.getText(t)),i=r[0];if(i.length===0||r.some(e=>e!==i))return;let a=n.map(t=>[e.offsetAt(t.start),e.offsetAt(t.end)]),o=e.findNextNonOverlappingSubstring(i,a);if(o===void 0)return n.some((e,n)=>{let r=t[n];return J(e.start,r.start)!==0||J(e.end,r.end)!==0||e.direction!==r.direction})?n:void 0;let s=li(e,o,o+i.length);return[...n,s]}function yi(e){let t=e.lineCount-1;return{start:{line:0,character:0},end:{line:t,character:e.getLineLength(t)},direction:1}}function bi(e,t,n){let r=0;if(t){let t=e.lineCount-1;r=n===!0&&t>0&&e.getLineLength(t)===0?t-1:t}let i=t?e.getLineLength(r):0,a={line:r,character:i};return{start:a,end:a,direction:1}}function xi(e,t){if(K(t)){let n=t.start.line;return{start:e.offsetAt({line:n,character:0}),end:n<e.lineCount-1?e.offsetAt({line:n+1,character:0}):e.offsetAt({line:n,character:e.getLineLength(n)})}}let n=e.offsetAt(t.start),r=e.offsetAt(t.end);return n<=r?{start:n,end:r}:{start:r,end:n}}function Si(e,t){return t.map(t=>xi(e,t)).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n})}function Ci(e,t){return Si(e,t).map(({start:t,end:n})=>e.getTextSlice(t,n))}function wi(e,t){let n=Si(e,t),r=e.eol,i=``,a=-1;for(let t of n)if(!(t.end<=t.start)){if(t.start<=a){t.end>a&&(i+=e.getTextSlice(a,t.end),a=t.end);continue}i.length>0&&!_r(i)&&(i+=r),i+=e.getTextSlice(t.start,t.end),a=t.end}return i}function Ti(e,t){if(K(t))return Ei(e,t);let[n,r]=J(t.start,t.end)<=0?[t.start,t.end]:[t.end,t.start];return{start:e.offsetAt(n),end:e.offsetAt(r),text:``}}function Ei(e,t){let n=t.start.line,r=e.offsetAt({line:n,character:0}),i=e.offsetAt({line:n,character:e.getLineLength(n)});return n<e.lineCount-1?{start:r,end:e.offsetAt({line:n+1,character:0}),text:``}:n>0?{start:e.offsetAt({line:n-1,character:e.getLineLength(n-1)}),end:i,text:``}:{start:r,end:i,text:``}}function Di(e){let t=[];for(let{edit:n}of e){if(n.start>=n.end)continue;let e=t.at(-1);e!==void 0&&n.start<=e.end?t[t.length-1]={start:e.start,end:Math.max(e.end,n.end),text:``}:t.push(n)}return t}function Oi(e,t){let n=Array.from({length:e.length}),r=0,i=0;for(let a of e){for(;r<t.length&&a.edit.start>t[r].end;){let e=t[r];i-=e.end-e.start,r++}let e=t[r];e!==void 0&&a.edit.start>=e.start&&a.edit.start<=e.end?n[a.index]=e.start+i:n[a.index]=a.edit.start+i}return n}function ki(e,t){let n=[...t.map((t,n)=>({index:n,edit:Ti(e,t)}))].sort((e,t)=>{let n=e.edit.start-t.edit.start;if(n!==0)return n;let r=e.edit.end-t.edit.end;return r===0?e.index-t.index:r}),r=Di(n);return{text:wi(e,t),edits:r,nextSelectionOffsets:Oi(n,r)}}function Ai(e,t){let n=Math.max(0,t),r=Wi(e),i=null;for(let e of r){i=e;let t=Y(e);if(n<=t+(e.textContent?.length??0)){let r=Gi(e,n<t?0:n-t);if(r!==null)return r}}if(i!==null){let e=Gi(i,i.textContent?.length??0);return e===null?[i,0]:e}let a=0,o=null;for(let t of e.childNodes){if(t.nodeType===1&&t.tagName===`BR`)return[t,0];if(t.nodeType!==3)continue;o=t;let e=Qi(o.textContent,o.textContent?.length??0);if(n<=a+e)return[o,Qi(o.textContent,n-a)];a+=e}return o===null?[e,0]:[o,Qi(o.textContent,o.textContent?.length??0)]}function ji(e,t){let{line:n,character:r}=t.start,i=e.getLineText(n),a=Mi(i,Math.max(0,Math.min(r,i.length)));return a===void 0?t:{start:{line:n,character:a.start},end:{line:n,character:a.end},direction:1}}function Mi(e,t){let n=vr({granularity:`word`});if(n!==void 0){for(let r of n.segment(e)){if(r.isWordLike!==!0)continue;let e=r.index,n=e+r.segment.length;if(t>=e&&t<=n)return{start:e,end:n}}return}let r=/[\p{Alphabetic}\p{Number}_]+/gu,i;for(;(i=r.exec(e))!==null;){let e=i.index,n=e+i[0].length;if(t>=e&&t<=n)return{start:e,end:n}}}function Ni(e,t){if(!K(t))return[t.start,t.end];let n=q(t),{line:r,character:i}=n;if(i===0){if(r===0)return[n,n];let t=e.getLineLength(r-1);return[{line:r-1,character:t},{line:r,character:0}]}let a=e.getLineText(r),o=Fi(a),s=i,c;for(;s>0;){let e=Pi(a,s,!1,o),t=a.slice(e,s),n=/\S/.test(t)?/\p{Alphabetic}|\p{Number}|_/u.test(t)?1:2:0;if(c!==void 0&&n!==c)break;(n!==0||s!==i)&&(c=n),s=e}return[{line:r,character:s},{line:r,character:i}]}function Pi(e,t,n,r){if(n){for(let e of r)if(e>t)return e;return e.length}for(let e=r.length-1;e>=0;e--){let n=r[e];if(n<t)return n}return 0}function Fi(e){let t=[0],n=xr();if(n!==void 0){for(let r of n.segment(e))r.index>0&&t.push(r.index);return t}let r=0;for(let n of e)r>0&&t.push(r),r+=n.length;return t}function Ii(e,t,n,r){let i=e.getLineLength(t);if(r){if(n>=i)return i;let r=e.offsetAt({line:t,character:0}),a=e.getTextSlice(r+n,r+i),o=xr();if(o!==void 0){for(let e of o.segment(a))return n+e.segment.length;return i}for(let e of a)return n+e.length;return i}if(n<=0)return 0;let a=e.offsetAt({line:t,character:0}),o=e.getTextSlice(a,a+n),s=0,c=xr();if(c!==void 0){for(let e of c.segment(o))s=e.index;return s}let l=0;for(let e of o)s=l,l+=e.length;return s}function Li(e,t){let n=t.direction===-1;return[e.offsetAt(n?t.end:t.start),e.offsetAt(q(t))]}function Ri(e,t){if(!K(t))return{start:t.start,end:t.end};let{line:n,character:r}=t.start,i=e.getLineText(n).length;return r<i?{start:{line:n,character:r},end:{line:n,character:i}}:n<e.lineCount-1?{start:{line:n,character:r},end:{line:n+1,character:0}}:{start:{line:n,character:r},end:{line:n,character:r}}}function zi(e,t,n){if(t!==`
|
|
468
|
+
`&&t!==`\r`&&t!==`\r
|
|
469
|
+
`)return t;let r=e.positionAt(n).line,i=e.getLineText(r),a=Bi(i);return a===0?t:t+i.slice(0,a)}function Bi(e){let t=0;for(;t<e.length;t++){let n=e.charCodeAt(t);if(n!==32&&n!==9)break}return t}function Vi(e,t){let n=[];for(let[e,r]of t)n.push(Math.min(e,r),Math.max(e,r));let r=e.positionsAt(n);return t.map(([e,t],n)=>{let i=e===t?0:e<t?1:-1;return{start:r[n*2],end:r[n*2+1],direction:i}})}function Hi(e,t,n){if(t.text!==``||t.start!==t.end-1)return t;let r=e.positionAt(t.end);if(r.character===0)return t;let i=e.getLineText(r.line),a=i.slice(0,r.character);if(/[^ \t]/.test(a)||i[r.character-1]===` `)return t;let o=Math.max(0,r.character-n),s=i.slice(o,r.character);return s.length===n&&/^ +$/.test(s)?{...t,start:t.end-s.length}:t}function Ui(e,t){let n=e.nodeType===1?e:e.parentElement;for(;n!==null&&Zi(n)===void 0;)n=n.parentElement;if(n===null)return null;let r=Zi(n);if(r===void 0)return null;if(e.nodeType===3)return e.parentElement===null?null:Yi(e.parentElement)===null?{line:r,character:Ji(n,e)+Qi(e.textContent,t)}:{line:r,character:Xi(e,t)};if(e.nodeType===1){let i=e;if(i.tagName===`DIV`){let e=0;for(let n=0;n<t;n++)e=Xi(i.childNodes[n]);return{line:r,character:e}}if(i.tagName===`BR`)return{line:r,character:0};if(i.tagName===`SPAN`){if(t<i.childNodes.length){let e=i.childNodes[t];if(e?.nodeType===1){let t=Y(e);if(t!==void 0)return{line:r,character:t};let n=Yi(e),i=n===null?void 0:Y(n);if(i!==void 0)return{line:r,character:i}}}return{line:r,character:t>0?Xi(i.childNodes[t-1]):Ji(n,i)}}return{line:r,character:Ji(n,i)}}return null}function Wi(e){let t=[];for(let n of e.childNodes){if(n.nodeType!==1)continue;let e=n;if(e.tagName===`SPAN`){if(Y(e)!==void 0){t.push(e);continue}for(let n of e.childNodes)n.nodeType===1&&Y(n)!==void 0&&t.push(n)}}return t}function Gi(e,t){let n=Math.max(0,t),r=[{container:e,index:0}];for(;r.length>0;){let e=r[r.length-1];if(e.index>=e.container.childNodes.length){r.pop();continue}let t=e.container.childNodes[e.index];if(e.index++,t.nodeType===3){let e=Qi(t.textContent,t.textContent?.length??0);if(n<=e)return[t,n];n-=e}else t.nodeType===1&&r.push({container:t,index:0})}return null}function Ki(e,t){let n=0,r=[{container:e,index:0}];for(;r.length>0;){let e=r[r.length-1];if(e.index>=e.container.childNodes.length){r.pop();continue}let i=e.container.childNodes[e.index];if(i===t)return n;e.index++,i.nodeType===3?n+=Qi(i.textContent,i.textContent?.length??0):i.nodeType===1&&r.push({container:i,index:0})}return n}function qi(e,t){let n=t;for(;n!==null;){if(n===e)return!0;n=n.parentElement}return!1}function Ji(e,t){if(t.parentElement===e){let n=0,r=Array.prototype.indexOf.call(e.childNodes,t);for(let t=0;t<r;t++)n=Xi(e.childNodes[t]);return n}for(let n of Wi(e))if(qi(n,t))return Y(n)+(t.nodeType===3?Ki(n,t):0);let n=0,r=t.nodeType===1?t:t.parentElement;for(;r!==null&&r.parentElement!==null&&Zi(r.parentElement)===void 0;){let e=r.parentElement,t=Array.prototype.indexOf.call(e.childNodes,r);for(let r=0;r<t;r++)n=Xi(e.childNodes[r]);r=e}return n}function Yi(e){let t=e;for(;t!==null;){if(Zi(t)!==void 0)return null;if(Y(t)!==void 0)return t;t=t.parentElement}return null}function Xi(e,t){if(e===void 0)return 0;if(e.nodeType===3){let n=e.parentElement;if(n===null)return 0;let r=Yi(n);if(r===null)return 0;let i=Y(r);if(i===void 0)return 0;let a=t===void 0?Qi(e.textContent,e.textContent?.length??0):Qi(e.textContent,t);return i+Ki(r,e)+a}if(e.nodeType!==1)return 0;let n=e;if(n.tagName!==`SPAN`&&n.tagName!==`BR`)return 0;let r=Y(n);if(r!==void 0)return r+(n.textContent?.length??0);let i=0;for(let e of n.childNodes)i=Math.max(i,Xi(e));return i}function Zi(e){let{line:t,lineType:n}=e.dataset;if(t!==void 0&&n!==`change-deletion`){let e=parseInt(t,10);if(!Number.isNaN(e))return e-1}}function Y(e){let{char:t}=e.dataset;if(t!==void 0){let e=parseInt(t,10);if(!Number.isNaN(e))return e}}function Qi(e,t){let n=e??``,r=n.search(/[\r\n]/);return Math.min(t,r===-1?n.length:r)}var $i=300,ea=100,ta=`marker-popover`,na=class{#e;#t=[];#n=0;#r;#i;#a;#o;#s;#c;#l;#u=!1;constructor(e){this.#e=e}get markers(){return this.#t}isPopoverVisible(){return this.#l!==void 0}updatePopoverPosition(){let e=this.#l,t=this.#r;if(e===void 0||t===void 0)return;let n=this.#t[e];if(n===void 0){this.removePopover();return}this.#_(t,n.start.line,n.start.character)}setMarkers(e,t){this.#n=t.lineCount,this.#t=e.map(e=>({...e,start:t.normalizePosition(e.start),end:t.normalizePosition(e.end)})),this.removePopover()}listenHover(e){this.#a?.forEach(e=>e()),this.#a=void 0,this.#t.length!==0&&(this.#a=[W(e,`mouseover`,e=>{if(this.#e.isMouseDown())return;let t=e.composedPath()[0];if(t===void 0)return;let n=this.#d(t);n===void 0?(this.#f(),this.#h()):this.#m(n)}),W(e,`mouseleave`,()=>{this.#f(),this.#h()})])}removePopover(){this.#f(),this.#p(),this.#v()}cleanup(){this.#a?.forEach(e=>e()),this.#a=void 0,this.removePopover(),this.#t=[]}#d(e){let t=e.closest(`[data-line]`);if(t==null)return;let n=G(t);if(n===void 0)return;let r;if(e.tagName===`SPAN`){let t=e.dataset.char;if(t===void 0||(r=parseInt(t,10),Number.isNaN(r)))return}else if(e.tagName===`BR`)r=0;else return;let i={line:n-1,character:r};for(let e=this.#t.length-1;e>=0;e--)if(ci({start:i,end:i},this.#t[e]))return e}#f(){this.#o!==void 0&&(clearTimeout(this.#o),this.#o=void 0),this.#c=void 0}#p(){this.#s!==void 0&&(clearTimeout(this.#s),this.#s=void 0)}#m(e){if(e===this.#l||e===this.#c){this.#p();return}if(this.#f(),this.#p(),this.#r!==void 0){this.#y(e);return}this.#c=e,this.#o=setTimeout(()=>{this.#o=void 0,this.#c=void 0,this.#y(e)},$i)}#h(){this.#u||(this.#p(),this.#s=setTimeout(()=>{this.#s=void 0,this.#u||this.removePopover()},ea))}#g(e,t,n,r,i=this.#e.popoverManager.getPlacementBounds()){Ir(e,{gutterWidth:this.#e.getGutterWidth(),placeAbove:r,viewport:i,x:t,y:n})}#_(e,t,n){let{getCharX:r,getLineY:i,getLineHeight:a,popoverManager:o}=this.#e,[s,c]=r(t,n),l=a(),u=i(t)+c*l,d=e.offsetHeight,f={top:u+l,bottom:u+l+d},p={top:u-d,bottom:u},m=t>=this.#n-3,h=o.getPlacementBounds(),g=o.choosePlacement({preferred:f,fallback:p,viewport:h,popoverHeight:d,atDocumentEdge:m,placementKey:ta})===`fallback`;this.#g(e,s,g?u:u+l,g,h)}#v(){this.#i?.forEach(e=>e()),this.#i=void 0,this.#r?.remove(),this.#r=void 0,this.#l=void 0,this.#u=!1,this.#e.popoverManager.resetPlacement(ta)}#y(e){if(e===this.#l)return;let t=this.#e.getOverlayElement();if(e>=this.#t.length||t==null)return;let{start:n,message:r,severity:i}=this.#t[e],{line:a,character:o}=n,s=this.#r;if(this.#e.popoverManager.resetPlacement(ta),s!==void 0){ia(s,i);let t=s.firstElementChild;t?.dataset.markerMessage!==void 0&&(typeof r==`string`?t.textContent=r:r instanceof HTMLElement?t.replaceChildren(r):t.innerHTML=r.html),this.#_(s,a,o),this.#l=e;return}this.#r=U(`div`,{dataset:{editorWidget:``,markerPopover:``,[aa(i)]:``},children:[U(`div`,{dataset:`markerMessage`,...typeof r==`string`?{textContent:r}:r instanceof HTMLElement?{children:[r]}:{innerHTML:r.html}})]},t),this.#_(this.#r,a,o),this.#l=e,this.#i=[W(this.#r,`mouseenter`,()=>{this.#u=!0,this.#p()}),W(this.#r,`mouseleave`,()=>{this.#u=!1,this.#h()})]}},ra=[`error`,`warning`,`info`,`hint`];function ia(e,t){for(let t of ra)delete e.dataset[aa(t)];e.dataset[aa(t)]=``}function aa(e){switch(e){case`error`:return`markerError`;case`warning`:return`markerWarning`;case`info`:return`markerInfo`;case`hint`:return`markerHint`}}var oa=new Map([[`(`,`)`],[`[`,`]`],[`{`,`}`]]),sa=new Map([...oa].map(([e,t])=>[t,e])),ca=1e3,la=5e4;function ua(e,t,n){let r=da(e,t,e.normalizePosition(n));if(r===void 0)return;let i=oa.get(r.char),a=sa.get(r.char);if(i!==void 0)return ba(r,ma(e,t,r,i));if(a!==void 0)return ba(ha(e,t,r,a),r)}function da(e,t,n){let r=fa(n);if(r!==void 0){let n=pa(e,t,r);if(n!==void 0)return n}return pa(e,t,n)}function fa(e){if(e.character>0)return{line:e.line,character:e.character-1}}function pa(e,t,n){let r=e.getLineText(n.line)[n.character];if(!(r===void 0||!oa.has(r)&&!sa.has(r)||ga(t,n)))return{...n,char:r}}function ma(e,t,n,r){let i=0,a=0,o=0;for(let s=n.line;s<e.lineCount;s++){if(a>=ca)return;a++;let c=e.getLineText(s),l=t.getStringCommentRegexpRangesInLine(s),u={index:0},d=s===n.line?n.character:0;for(let e=d;e<c.length;e++){if(o>=la)return;if(o++,va(l,e,u))continue;let t=c[e];if(t===n.char)i++;else if(t===r&&(i--,i===0))return{line:s,character:e,char:t}}}}function ha(e,t,n,r){let i=0,a=0,o=0;for(let s=n.line;s>=0;s--){if(a>=ca)return;a++;let c=e.getLineText(s),l=t.getStringCommentRegexpRangesInLine(s),u={index:l===null?-1:l.length-1},d=s===n.line?n.character:c.length-1;for(let e=d;e>=0;e--){if(o>=la)return;if(o++,ya(l,e,u))continue;let t=c[e];if(t===n.char)i++;else if(t===r&&(i--,i===0))return{line:s,character:e,char:t}}}}function ga(e,t){return _a(e.getStringCommentRegexpRangesInLine(t.line),t.character)}function _a(e,t){if(e===null)return!1;for(let[n,r]of e){if(t<n)return!1;if(t<r)return!0}return!1}function va(e,t,n){if(e===null)return!1;for(;n.index<e.length&&t>=e[n.index][1];)n.index++;let r=e[n.index];return r!==void 0&&t>=r[0]}function ya(e,t,n){if(e===null)return!1;for(;n.index>=0&&t<e[n.index][0];)n.index--;let r=e[n.index];return r!==void 0&&t<r[1]}function ba(e,t){if(e!==void 0&&t!==void 0)return[xa(e),xa(t)]}function xa(e){return{start:{line:e.line,character:e.character},end:{line:e.line,character:e.character+1}}}var Sa=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
470
|
+
<symbol id="diffs-editor-icon-close" viewBox="0 0 16 16">
|
|
471
|
+
<path fill="currentColor" d="M3.21967 3.21967C3.51256 2.92678 3.98744 2.92678 4.28033 3.21967L8 6.93934L11.7197 3.21967C12.0126 2.92678 12.4874 2.92678 12.7803 3.21967C13.0732 3.51256 13.0732 3.98744 12.7803 4.28033L9.06066 8L12.7803 11.7197C13.0732 12.0126 13.0732 12.4874 12.7803 12.7803C12.4874 13.0732 12.0126 13.0732 11.7197 12.7803L8 9.06066L4.28033 12.7803C3.98744 13.0732 3.51256 13.0732 3.21967 12.7803C2.92678 12.4874 2.92678 12.0126 3.21967 11.7197L6.93934 8L3.21967 4.28033C2.92678 3.98744 2.92678 3.51256 3.21967 3.21967Z"></path>
|
|
472
|
+
</symbol>
|
|
473
|
+
<symbol id="diffs-editor-icon-arrow-up" viewBox="0 0 16 16">
|
|
474
|
+
<path fill="currentColor" transform="rotate(-90 8 8)" d="M8.46967 2.21967C8.17678 2.51256 8.17678 2.98744 8.46967 3.28033L12.4393 7.25H1.75C1.33579 7.25 1 7.58579 1 8C1 8.41421 1.33579 8.75 1.75 8.75H12.4393L8.46967 12.7197C8.17678 13.0126 8.17678 13.4874 8.46967 13.7803C8.76256 14.0732 9.23744 14.0732 9.53033 13.7803L14.7803 8.53033C15.0732 8.23744 15.0732 7.76256 14.7803 7.46967L9.53033 2.21967C9.23744 1.92678 8.76256 1.92678 8.46967 2.21967Z"></path>
|
|
475
|
+
</symbol>
|
|
476
|
+
<symbol id="diffs-editor-icon-arrow-down" viewBox="0 0 16 16">
|
|
477
|
+
<path fill="currentColor" transform="rotate(90 8 8)" d="M8.46967 2.21967C8.17678 2.51256 8.17678 2.98744 8.46967 3.28033L12.4393 7.25H1.75C1.33579 7.25 1 7.58579 1 8C1 8.41421 1.33579 8.75 1.75 8.75H12.4393L8.46967 12.7197C8.17678 13.0126 8.17678 13.4874 8.46967 13.7803C8.76256 14.0732 9.23744 14.0732 9.53033 13.7803L14.7803 8.53033C15.0732 8.23744 15.0732 7.76256 14.7803 7.46967L9.53033 2.21967C9.23744 1.92678 8.76256 1.92678 8.46967 2.21967Z"></path>
|
|
478
|
+
</symbol>
|
|
479
|
+
<symbol id="diffs-editor-icon-case" viewBox="0 0 16 16">
|
|
480
|
+
<path fill="currentColor" d="M12.2969 12.9969C10.7109 12.9969 9.61719 12.0125 9.61719 10.5047C9.61719 9.06719 10.6172 8.16094 12.5 8.15312H14.6641V7.31719C14.6641 6.23906 14.0391 5.64531 12.9297 5.64531C11.875 5.64531 11.2734 6.18437 11.1953 7.00469H9.92969C10.0156 5.56719 10.9922 4.52031 12.9766 4.52031C14.7266 4.52031 16 5.47344 16 7.2V12.8641H14.7109V11.8406H14.6719C14.2578 12.5047 13.5078 12.9969 12.2969 12.9969ZM12.6562 11.8797C13.8047 11.8797 14.6641 11.1609 14.6641 10.1375V9.18437H12.6016C11.4766 9.18437 10.9922 9.71562 10.9922 10.4578C10.9922 11.4266 11.7969 11.8797 12.6562 11.8797Z"></path>
|
|
481
|
+
<path fill="currentColor" d="M1.42188 12.8641H0L3.79688 2H5.1875L8.98438 12.8641H7.54688L6.46875 9.66094H2.5L1.42188 12.8641ZM4.50781 3.60938H4.46875L2.86719 8.55937H6.10156L4.50781 3.60938Z"></path>
|
|
482
|
+
</symbol>
|
|
483
|
+
<symbol id="diffs-editor-icon-whole-word" viewBox="0 0 16 16">
|
|
484
|
+
<path fill="currentColor" d="M11.4089 9.99449C11.1417 9.99449 10.8961 9.95595 10.6722 9.87887C10.4519 9.80179 10.2605 9.69167 10.098 9.54852C9.93551 9.40537 9.81453 9.23469 9.73508 9.03648H9.67007V9.91191H8.5V2H9.70258V5.01721H9.76758C9.81092 4.86671 9.88314 4.7309 9.98426 4.60977C10.089 4.48497 10.2136 4.37853 10.358 4.29043C10.5025 4.19867 10.6668 4.13076 10.851 4.08672C11.0352 4.039 11.2302 4.01514 11.436 4.01514C11.8802 4.01514 12.2648 4.11792 12.5898 4.32347C12.9149 4.52535 13.164 4.81532 13.3374 5.19339C13.5107 5.57146 13.5974 6.02478 13.5974 6.55334V7.45079C13.5974 7.97568 13.5089 8.429 13.332 8.81074C13.1586 9.1888 12.9076 9.48061 12.579 9.68617C12.2504 9.89172 11.8604 9.99449 11.4089 9.99449ZM11.0785 8.99243C11.353 8.99243 11.5859 8.92636 11.7773 8.79422C11.9723 8.66208 12.1204 8.46937 12.2215 8.2161C12.3226 7.95916 12.3732 7.65267 12.3732 7.29663V6.73503C12.3732 6.37164 12.3208 6.06332 12.2161 5.81005C12.115 5.55311 11.9669 5.35673 11.7719 5.22092C11.5769 5.08511 11.3385 5.01721 11.0568 5.01721C10.7824 5.01721 10.5422 5.08328 10.3364 5.21542C10.1341 5.34389 9.97704 5.52925 9.86509 5.77151C9.75675 6.01009 9.70258 6.2964 9.70258 6.63042V7.47281C9.70258 7.77013 9.76036 8.03441 9.87592 8.26566C9.99509 8.49323 10.1576 8.67125 10.3635 8.79972C10.5729 8.92819 10.8113 8.99243 11.0785 8.99243Z"></path>
|
|
485
|
+
<path fill="currentColor" d="M4.70482 9.99449C4.15229 9.99449 3.70087 9.83482 3.35057 9.51548C3.00388 9.19247 2.83054 8.75935 2.83054 8.2161C2.83054 7.70223 3.00207 7.28745 3.34515 6.97178C3.69184 6.65244 4.19562 6.49277 4.8565 6.49277H6.30284V5.94769C6.30284 5.61367 6.20533 5.36774 6.01032 5.20991C5.81531 5.04841 5.55349 4.96765 5.22485 4.96765C5.00817 4.96765 4.82941 4.99702 4.68857 5.05575C4.54773 5.11081 4.43758 5.18789 4.35813 5.28699C4.27868 5.38243 4.22271 5.49621 4.19021 5.62835H3.04722C3.06527 5.3861 3.12305 5.16586 3.22056 4.96765C3.32168 4.76577 3.46252 4.59326 3.64309 4.4501C3.82727 4.30328 4.05297 4.19133 4.32021 4.11425C4.59106 4.03716 4.90525 3.99862 5.26277 3.99862C5.67086 3.99862 6.04463 4.06286 6.38409 4.19133C6.72356 4.31613 6.99441 4.52168 7.19665 4.80798C7.39888 5.09429 7.5 5.4797 7.5 5.96421V9.9064H6.35701V9.1521H6.30284C6.21978 9.29892 6.10783 9.43657 5.96698 9.56504C5.82614 9.69351 5.65099 9.79812 5.44153 9.87887C5.23569 9.95595 4.99012 9.99449 4.70482 9.99449ZM5.07318 9.04749C5.3043 9.04749 5.51196 8.99977 5.69613 8.90434C5.88031 8.80523 6.02657 8.67309 6.13491 8.50791C6.24686 8.34274 6.30284 8.1537 6.30284 7.94081V7.31314H5.04609C4.69579 7.31314 4.43939 7.39206 4.27688 7.5499C4.11798 7.70773 4.03853 7.90961 4.03853 8.15554C4.03853 8.4602 4.14326 8.68594 4.35272 8.83276C4.56578 8.97591 4.80594 9.04749 5.07318 9.04749Z"></path>
|
|
486
|
+
<path fill="currentColor" d="M2.5 12.5L13.5 12.5C14.3284 12.5 15 11.8284 15 11V9.5C15 9.22386 15.2239 9 15.5 9C15.7761 9 16 9.22386 16 9.5V11C16 12.3807 14.8807 13.5 13.5 13.5L2.5 13.5C1.11929 13.5 -7.56324e-07 12.3807 0 11L6.55675e-08 9.5C3.58362e-07 9.22386 0.223858 9 0.5 9C0.776142 9 1 9.22386 1 9.5L1 11C0.999999 11.8284 1.67157 12.5 2.5 12.5Z"></path>
|
|
487
|
+
</symbol>
|
|
488
|
+
<symbol id="diffs-editor-icon-regex" viewBox="0 0 16 16">
|
|
489
|
+
<path fill="currentColor" d="M8.60788 6.59074C8.78227 6.46701 9.02141 6.60508 9.00146 6.81797L8.77564 9.22666C8.76189 9.37331 8.87726 9.5 9.02455 9.5H9.97548C10.1228 9.5 10.2381 9.37331 10.2244 9.22667L9.99858 6.81801C9.97862 6.60513 10.2178 6.46706 10.3922 6.59079L12.3652 7.99066C12.4853 8.07589 12.6527 8.03932 12.7264 7.91177L13.2018 7.08823C13.2755 6.96068 13.2234 6.79742 13.0896 6.73601L10.8907 5.72723C10.6963 5.63807 10.6963 5.36193 10.8907 5.27277L13.0896 4.264C13.2234 4.20258 13.2755 4.03932 13.2018 3.91177L12.7263 3.08824C12.6527 2.96068 12.4853 2.92411 12.3652 3.00934L10.3922 4.40921C10.2178 4.53294 9.97862 4.39486 9.99858 4.18198L10.2244 1.77334C10.2381 1.62669 10.1228 1.5 9.97548 1.5H9.02455C8.87726 1.5 8.76189 1.62669 8.77564 1.77334L9.00146 4.18203C9.02141 4.39491 8.78227 4.53298 8.60788 4.40926L6.63479 3.00934C6.51466 2.92411 6.34726 2.96068 6.27362 3.08823L5.79815 3.91177C5.72451 4.03932 5.77654 4.20258 5.91041 4.26399L8.10929 5.27277C8.30363 5.36193 8.30363 5.63807 8.10929 5.72723L5.91041 6.73601C5.77653 6.79742 5.7245 6.96068 5.79814 7.08824L6.27361 7.91177C6.34725 8.03932 6.51466 8.07589 6.63478 7.99066L8.60788 6.59074Z"></path>
|
|
490
|
+
<path fill="currentColor" d="M4 11C3.44772 11 3 11.4477 3 12V13C3 13.5523 3.44772 14 4 14H5C5.55228 14 6 13.5523 6 13V12C6 11.4477 5.55228 11 5 11H4Z"></path>
|
|
491
|
+
</symbol>
|
|
492
|
+
<symbol id="diffs-editor-icon-replace" viewBox="0 0 16 16">
|
|
493
|
+
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M5.28033 5.71967C5.57322 6.01256 5.57322 6.48744 5.28033 6.78033L3.56066 8.5H11.75C12.7165 8.5 13.5 7.7165 13.5 6.75V2.75C13.5 2.33579 13.8358 2 14.25 2C14.6642 2 15 2.33579 15 2.75V6.75C15 8.54493 13.5449 10 11.75 10H3.56066L5.28033 11.7197C5.57322 12.0126 5.57322 12.4874 5.28033 12.7803C4.98744 13.0732 4.51256 13.0732 4.21967 12.7803L1.21967 9.78033C0.926777 9.48744 0.926777 9.01256 1.21967 8.71967L4.21967 5.71967C4.51256 5.42678 4.98744 5.42678 5.28033 5.71967Z"></path>
|
|
494
|
+
</symbol>
|
|
495
|
+
<symbol id="diffs-editor-icon-replace-all" viewBox="0 0 16 16">
|
|
496
|
+
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M10.7197 0.21967C11.0126 -0.0732233 11.4874 -0.0732233 11.7803 0.21967L14.7803 3.21967C15.0732 3.51256 15.0732 3.98744 14.7803 4.28033L11.7803 7.28033C11.4874 7.57322 11.0126 7.57322 10.7197 7.28033C10.4268 6.98744 10.4268 6.51256 10.7197 6.21967L12.4393 4.5H4.25C3.2835 4.5 2.5 5.2835 2.5 6.25V6.875C2.5 7.28921 2.16421 7.625 1.75 7.625C1.33579 7.625 1 7.28921 1 6.875V6.25C1 4.45507 2.45508 3 4.25 3H12.4393L10.7197 1.28033C10.4268 0.987437 10.4268 0.512563 10.7197 0.21967ZM5.28033 8.71967C5.57322 9.01256 5.57322 9.48744 5.28033 9.78033L3.56066 11.5H11.75C12.7165 11.5 13.5 10.7165 13.5 9.75V9.125C13.5 8.71079 13.8358 8.375 14.25 8.375C14.6642 8.375 15 8.71079 15 9.125V9.75C15 11.5449 13.5449 13 11.75 13H3.56066L5.28033 14.7197C5.57322 15.0126 5.57322 15.4874 5.28033 15.7803C4.98744 16.0732 4.51256 16.0732 4.21967 15.7803L1.21967 12.7803C0.926777 12.4874 0.926777 12.0126 1.21967 11.7197L4.21967 8.71967C4.51256 8.42678 4.98744 8.42678 5.28033 8.71967Z"></path>
|
|
497
|
+
</symbol>
|
|
498
|
+
</svg>`,Ca=()=>{let e=document.createElement(`div`);e.innerHTML=Sa;let t=e.firstElementChild;if(t===null||!(t instanceof SVGSVGElement))throw Error(`Failed to create sprite element`);return t},wa=(e,t=16)=>`<svg width="${t}" height="${t}" aria-hidden="true" focusable="false">
|
|
499
|
+
<use href="#diffs-editor-icon-${e}"></use>
|
|
500
|
+
</svg>`,Ta=class{#e;#t;#n;#r;#i;#a;constructor(e){let{textDocument:t,containerElement:n,defaultQuery:r,mode:i=`find`,initialMatch:a,scrollToMatch:o,applyReplace:s,onUpdate:c,onClose:l}=e,u={text:r,replaceText:``,caseSensitive:!1,wholeWord:!1,regex:!1},d={all:[],current:void 0},f=U(`div`,{dataset:{matches:``,noMatches:``},textContent:`No results`}),p=e=>{d.all=u.text===``?[]:t.search(u);let n=d.all.length===0;if(A.disabled=n,j.disabled=n,n){f.textContent=`No results`,f.dataset.noMatches=``,d.current=void 0,c([]);return}if(delete f.dataset.noMatches,e?.syncSelection===!1){m(c(d.all,{syncSelection:!1}));return}m(c(d.all))};this.#n=p;let m=e=>{if(e===void 0)f.textContent=`${d.all.length} results`;else{let[t,n]=e;f.textContent=`${d.all.findIndex(e=>e[0]===t&&e[1]===n)+1} of ${d.all.length}`}d.current=e},h=(e,t)=>{u[e]=t,p()},g=(e=!1,t=!1)=>{let n=d.all,r=n[0];if(n.length>0){if(e){let e=d.current?.[0]??0;r=n.at(-1);for(let t of n)if(t[1]<=e)r=t;else break}else{let e=d.current?.[1]??0;for(let t of n)if(t[0]>=e){r=t;break}}}r!==void 0&&(m(r),o(r,t)),d.current=r};this.#i=e=>g(e,!0);let _=(e,n)=>({start:e,end:n,text:Kn(e=>t.positionAt(e),e=>t.offsetAt(e),e=>t.getLineText(e),u,e,n)}),v=()=>{if(u.text===``||d.all.length===0)return;let e=d.current;if(e===void 0&&(g(!1,!0),e=d.current,e===void 0))return;let[t,n]=e,r=_(t,n);s([r]),o([t+r.text.length,t+r.text.length],!0),d.current=void 0,p()},y=()=>{u.text!==``&&d.all.length!==0&&(s(d.all.map(([e,t])=>_(e,t))),d.current=void 0,p())},b=()=>{this.cleanup(),l()};this.#a=b;let x=e=>U(`button`,{type:`button`,title:e.label,ariaLabel:e.label,dataset:{searchIcon:``,...e.dataset},innerHTML:wa(e.icon,e.size??16),onclick:e.onClick}),S=(e,t,n)=>{let r=x({icon:e,label:t,size:14,onClick:()=>{let e=!u[n];r.ariaPressed=String(e),h(n,e)}});return r.ariaPressed=String(u[n]),r},C=S(`case`,`Match Case`,`caseSensitive`),w=S(`whole-word`,`Whole Word`,`wholeWord`),T=S(`regex`,`Regexp`,`regex`),E=U(`input`,{type:`text`,placeholder:`Replace`,dataset:`replace`,value:``,oninput:e=>{u.replaceText=e.target.value},onkeydown:e=>{if(e.isComposing||e.keyCode===229)return;let t=nr(e);e.key===`Escape`?(e.preventDefault(),b()):e.key===`Enter`?(e.preventDefault(),v()):t!==void 0&&(e.preventDefault(),g(t===`previous`,!0))}});this.#t=U(`input`,{type:`text`,placeholder:`Search`,dataset:`search`,value:r,oninput:e=>{u.text=e.target.value,d.current=void 0,p()},onkeydown:e=>{if(e.isComposing||e.keyCode===229)return;let t=nr(e);e.key===`Escape`?(e.preventDefault(),b()):e.key===`Enter`?(e.preventDefault(),g(e.shiftKey,!0)):t===void 0?Yn(e)&&(e.key===`f`||e.code===`KeyF`)&&(e.preventDefault(),F(e.altKey?`replace`:`find`)):(e.preventDefault(),g(t===`previous`,!0))}});let ee=U(`div`,{dataset:`searchToggles`,children:[C,w,T]}),D=U(`div`,{dataset:{inputBox:``,find:``},children:[this.#t,ee]}),O=U(`div`,{dataset:{inputBox:``,replace:``,replaceCell:``},children:[E]}),k=U(`div`,{dataset:{replaceActions:``,replaceCell:``},children:[x({icon:`replace`,label:`Replace`,onClick:v}),x({icon:`replace-all`,label:`Replace All`,onClick:y})]}),A=x({icon:`arrow-up`,label:`Previous`,onClick:()=>{g(!0)}}),j=x({icon:`arrow-down`,label:`Next`,onClick:()=>{g()}});A.disabled=!0,j.disabled=!0;let M=U(`div`,{dataset:`searchNav`,children:[A,j]}),N=x({icon:`close`,label:`Close`,onClick:b,dataset:{searchClose:``}}),P=U(`div`,{dataset:{searchGrid:``,mode:i},children:[D,O,k,f,M,N]}),F=e=>{P.dataset.mode=e,this.#t.focus(),this.#t.select()};this.#r=F,this.#e=U(`div`,{dataset:`searchPanel`,children:[U(`div`,{dataset:`editorWidget`,children:[P]})]}),d.current=a,n.before(this.#e),requestAnimationFrame(()=>{a===void 0?c([]):p(),this.#t.select()})}focus(){this.#t.focus()}navigate(e){this.#i?.(e)}updateMatches(e){this.#n?.(e)}setMode(e){this.#r?.(e)}close(){this.#a?.()}cleanup(){this.#e.remove()}},Ea=class{#e;#t;#n;constructor(e,t,n){this.#e=U(`div`,{dataset:{editorWidget:``,selectionActionPopover:``},contentEditable:`false`,children:[e]},t),this.#t=this.#e.offsetHeight,this.#n=new ResizeObserver(()=>{let e=this.#e.offsetHeight;e!==this.#t&&(this.#t=e,n())}),this.#n.observe(this.#e)}reposition(e,t,n,r,i,a){this.#e.style.visibility=i?``:`hidden`,Ir(this.#e,{gutterWidth:n,placeAbove:r,viewport:a,x:e,y:t})}get height(){return this.#t}cleanup(){this.#n.disconnect(),this.#e.remove()}};function Da(e){return{selections:e.selections?.map(e=>({start:{...e.start},end:{...e.end},direction:e.direction})),view:e.view===void 0?void 0:{...e.view}}}function Oa(e){return typeof e==`object`?e:e===`indexedDB`?new Na:new ka}var ka=class{#e=new Map;get(e){let t=this.#e.get(e);return t===void 0?void 0:Da(t)}set(e,t){this.#e.set(e,Da(t))}},Aa=`pierre-diffs-editor-state`,ja=1,Ma=`states`,Na=class{#e=Pa();async get(e){let t=await this.#e;if(t===void 0)return;let n=await Fa(t.transaction(Ma,`readonly`).objectStore(Ma).get(e));return n===void 0?void 0:Da(n)}async set(e,t){let n=await this.#e;n!==void 0&&await Fa(n.transaction(Ma,`readwrite`).objectStore(Ma).put(Da(t),e))}};function Pa(){try{let e=globalThis.indexedDB;if(e===void 0)return Promise.resolve(void 0);let t=e.open(Aa,ja);return t.onupgradeneeded=()=>{let e=t.result;e.objectStoreNames.contains(Ma)||e.createObjectStore(Ma)},Fa(t)}catch{return Promise.resolve(void 0)}}function Fa(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}var Ia=4096,La=/\p{Mark}/u,Ra=class{#e;#t;#n;#r=new Map;ch=-1;tabSize=2;lineHeight=20;paddingTop=0;init(e){if(this.#e===e&&this.#t!==void 0&&this.ch!==-1)return;if(this.#e=e,this.#t??=document.createElement(`canvas`).getContext(`2d`)??void 0,this.#t===void 0)throw Error(`Could not get canvas context`);let t=e.parentElement;if(t!==null){let{paddingTop:e}=getComputedStyle(t);e.endsWith(`px`)&&(this.paddingTop=parseFloat(e.slice(0,-2)))}let{fontSize:n,fontFamily:r,tabSize:i,lineHeight:a}=getComputedStyle(e);a.endsWith(`px`)?this.lineHeight=parseFloat(a.slice(0,-2)):n.endsWith(`px`)&&(this.lineHeight=gr(parseFloat(n.slice(0,-2))*parseFloat(a)));let o=n+` `+r;(this.#n!==o||this.ch===-1)&&(this.#n=o,this.#t.font=o,this.ch=this.canvasMeasureTextWidth(`0`),this.clearTextWidthCache());let s=parseInt(i,10);Number.isNaN(s)||(this.tabSize=s)}remeasureCharacterWidth(){if(this.#t===void 0||this.#n===void 0)return!1;this.#t.font=this.#n;let e=this.canvasMeasureTextWidth(`0`),t=e!==this.ch;t&&(this.ch=e);let n=this.#a();return t||n}measureTextWidth(e){if(!e.includes(` `))return this.#i(e);if(this.#t===void 0)throw Error(`Metrics not initialized`);let t=Ha(e,this.tabSize);if(t!==-1)return t*this.ch;let n=0,r=0,i=this.tabSize*this.ch;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)===9){if(t>r&&(n+=this.#i(e.slice(r,t))),i>0){let e=n%i;n+=e===0?i:i-e}r=t+1}return r<e.length&&(n+=this.#i(e.slice(r))),gr(n)}#i(e){return za(e)?this.domMeasureTextWidth(e):this.canvasMeasureTextWidth(e)}canvasMeasureTextWidth(e){if(this.#t===void 0)throw Error(`Metrics not initialized`);return gr(this.#t.measureText(e).width)}domMeasureTextWidth(e){if(this.#e===void 0)throw Error(`Metrics not initialized`);let t=e+`|`+this.#n,n=this.#r.get(t);if(n!==void 0)return n;let r=U(`span`,{style:{position:`absolute`,top:`0`,left:`0`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre`,font:`inherit`},textContent:e},this.#e),i;try{i=gr(r.getBoundingClientRect().width)}finally{r.remove()}if(this.#r.size>=Ia){let e=this.#r.keys().next().value;e!==void 0&&this.#r.delete(e)}return this.#r.set(t,i),i}clearTextWidthCache(){this.#a()}#a(){let e=this.#r.size>0;return this.#r.clear(),e}};function za(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=55296&&n<=57343||n===8205||n===65038||n===65039||n>127&&La.test(e.charAt(t)))return!0}return!1}function Ba(e,t){let n=Math.max(0,Math.min(t,e.length));if(n===0||n===e.length||!za(e))return n;let r=xr();if(r!==void 0){for(let t of r.segment(e)){let e=t.index,r=e+t.segment.length;if(n>e&&n<r)return r;if(n<=e)break}return n}let i=0;for(let t of e){let e=i+t.length;if(n>i&&n<e)return e;if(n<=i)break;i=e}return n}function Va(e){if(!za(e))return;let t=[0],n=xr();if(n!==void 0){for(let r of n.segment(e))t.push(r.index+r.segment.length);return t}let r=0;for(let n of e)r+=n.length,t.push(r);return t}function Ha(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i>127)return-1;n+=i===9?t-n%t:1}return n}var Ua=500,Wa=0,Ga=class{#e;#t;#n;#r=`dark`;#i=``;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=!1;#h=[M];#g=[];#_=0;#v=[];#y=-1;#b=!0;#x=!1;#S=0;#C=++Wa;#w=-1;#T=-1;#E;#D=0;#O=[];#k=!1;#A=hr(async e=>{if(this.#m)return;let{startingLine:t=0,totalLines:n=1/0}=e??{},r=Math.min(n===1/0?1/0:t+n,this.#o.lineCount);if(this.#t===void 0&&!Ja(this.#o.languageId)){if(await this.#e.loadLanguage(this.#o.languageId),this.#m)return;this.#t=this.#e.getLanguage(this.#o.languageId)}this.#F(),this.#V(r)},500);#j=({data:e})=>{if(typeof e!=`object`||!e)return;let{type:t,tokenizerId:n,jobId:r}=e;t===`tokenize`&&n===this.#C&&typeof r==`number`&&r===this.#S&&(this.#w>=0?this.#q(r):this.#J(r))};get themeType(){return this.#r}getStringCommentRegexpRangesInLine(e){if(!this.#d||e<0||e>=this.#o.lineCount||(this.#I(),this.#t===void 0))return null;if(this.#O[e]===void 0){this.#K(e);let t=this.#h[e]??M,n=this.#H(e,t);this.#h[e+1]=n.state}return this.#O[e]??null}constructor({codeOptions:e,highlighter:t,textDocument:n,matchBrackets:r,setStyle:i,onDeferTokenize:a,onThemeChange:o,__debug:s}){let{themeType:l=`system`,theme:u=c,tokenizeMaxLineLength:d=1e3}=e;this.#n=window.matchMedia(`(prefers-color-scheme: dark)`);let f;if(f=l===`system`?this.#N():l,typeof u!=`string`&&l===`system`){let e=new MutationObserver(e=>{for(let{type:t,attributeName:n}of e)if(t===`attributes`&&n!==null&&(n===`class`||n.startsWith(`data-`))){let e=this.#N();this.#M(u[e],e);break}});e.observe(document.documentElement,{attributes:!0}),e.observe(document.body,{attributes:!0}),this.#p=[W(this.#n,`change`,()=>{let e=this.#N();this.#M(u[e],e)}),()=>e.disconnect()]}this.#e=t,this.#o=n,this.#s=d,this.#c=i,this.#l=a,this.#u=o,this.#d=r!==!1,this.#f=s??!1,this.#I(),this.#a=[],this.#P(typeof u==`string`?u:u[f],typeof u==`string`?void 0:f)}#M(e,t){(e!==this.#i||t!==this.#r)&&(this.#P(e,t),this.stopBackgroundTokenize(),this.#h=[M],this.#g=[],this.#_=0,this.#v=[],this.#t!==void 0&&this.#o.lineCount>0&&this.#B(0),this.#u?.())}#N(){try{if(typeof document<`u`&&typeof getComputedStyle==`function`&&document.body!=null){let e=getComputedStyle(document.body).colorScheme.split(/\s+/),t=e.includes(`dark`);if(t!==e.includes(`light`))return t?`dark`:`light`}}catch{}return this.#n.matches?`dark`:`light`}syncTheme(e){let{themeType:t=`system`,theme:n=c}=e;if(typeof n==`string`){let e=this.#e.getTheme(n).type;if(n===this.#i&&e===this.#r)return;this.#M(n,e);return}let r=t===`system`?this.#N():t,i=n[r];(r!==this.#r||i!==this.#i)&&this.#M(i,r)}#P(e,t){let{theme:n,colorMap:r}=this.#e.setTheme(e),{colors:i={}}=this.#e.getTheme(e),a=i[`editor.selectionBackground`],o=i[`editor.lineHighlightBackground`],s=o!=null&&o.trim()!==``&&!Ht.isFullyTransparent(o)?o:void 0,c=i[`editor.lineHighlightBorder`]??(s==null?`color-mix(in lab, var(--diffs-bg) 70%, var(--diffs-fg))`:`transparent`),l=s==null?`100%`:`85%`,u=i[`editorCursor.foreground`],d=i[`editor.findMatchBackground`],f=i[`editor.findMatchHighlightBackground`],p=i[`editorBracketMatch.background`],m=i[`editorBracketMatch.border`],h=i[`editorHint.foreground`],g=i[`editorInfo.foreground`],_=i[`editorWarning.foreground`],v=i[`editorError.foreground`];this.#c(`:host {
|
|
501
|
+
--diffs-editor-selection-bg: ${a??`var(--diffs-line-bg)`};
|
|
502
|
+
--diffs-editor-line-highlight-border: ${c};
|
|
503
|
+
--diffs-editor-active-line-source-mix: ${l};
|
|
504
|
+
--diffs-editor-match-bg: ${d??`initial`};
|
|
505
|
+
--diffs-editor-match-highlight-bg: ${f??`initial`};
|
|
506
|
+
--diffs-editor-bracket-match-bg: ${p??`initial`};
|
|
507
|
+
--diffs-editor-bracket-match-border: ${m??`initial`};
|
|
508
|
+
--diffs-editor-cursor-fg: ${u??`initial`};
|
|
509
|
+
--diffs-editor-hint-fg: ${h??`initial`};
|
|
510
|
+
--diffs-editor-info-fg: ${g??`initial`};
|
|
511
|
+
--diffs-editor-warning-fg: ${_??`initial`};
|
|
512
|
+
--diffs-editor-error-fg: ${v??`initial`};
|
|
513
|
+
}`),this.#i=e,this.#r=t??n.type,this.#a=r}#F(){if(this.#i===``)return;let{colorMap:e}=this.#e.setTheme(this.#i);this.#a=e}cleanUp(){this.#m=!0,this.stopBackgroundTokenize(),this.#R(),this.#p?.forEach(e=>e()),this.#p=void 0}tokenize(e,t,n=!1){if(this.#I(),this.#F(),this.#t===void 0&&!Ja(this.#o.languageId))throw Error(`Grammar for language "${this.#o.languageId}" not loaded`);let{lineCount:r}=this.#o,{startingLine:i=0,totalLines:a=1/0}=t??{},o=a===1/0?r:Math.min(i+a,r),s=e.startLine,c=Math.max(i,s),l=t!==void 0&&a!==1/0&&e.lineDelta>0&&s<o&&e.endLine>=o,u=e.lineDelta===0&&(e.changedLineChanges?.every(([,,e])=>e===0)??!0);this.#d&&!u&&(this.#O.length=Math.min(this.#O.length,e.startLine));let d=n&&e.lineDelta!==0&&s>=i,f=u||t===void 0||s>=c,p=e.changedLineRanges??[[s,e.endLine]];this.#g=[],this.#_=0,this.#v=[];let m=-1;if(s<c)for(let[e,t]of p)e<c&&(m=Math.max(m,Math.min(t,c-1)));let h=m>=s&&(u||e.lineDelta<0);u?this.#K(s):(this.#W(e),(t===void 0||s>=c)&&this.#K(c));let g=0,_=p[g][1],v,y=0,b=u?p[g][0]:c,x=!1,S=new Map,C=h?new Map:void 0;if(C!==void 0&&!u){let e=Math.min(m+1,c,o);if(e>s){this.#K(e);let t=s,n=this.#h[t]??M;for(;t<e;t++){let e=this.#H(t,n);n=e.state,C.set(t,e.resolvedTokens)}this.#h[e]=n}}let w=this.#h[b]??M;for(;b<o;){let e=u?this.#h[b+1]:d?this.#G(b+1):void 0;f&&(this.#h[b]=w);let{resolvedTokens:t,state:n}=this.#H(b,w);if(w=n,b>=c?S.set(b,t):C?.set(b,t),f&&(this.#h[b+1]=w),x=b>=_&&(u||d)&&e!==void 0&&w.equals(e),x){g++;let e=p[g];if(e===void 0)break;if(e[0]>=o){v=e[0],y=g;break}let t=this.#h[e[0]];if(d)for(let n=b+2;n<=e[0]&&(t=this.#G(n),t!==void 0);n++)this.#h[n]=t;t===void 0?(_=e[1],b++):(b=e[0],w=t,_=e[1]),x=!1;continue}b++}if(f&&(b<o?this.#h[b+1]=w:this.#h[b]=w),x&&d&&v===void 0){for(let e=b+2;e<=r;e++){let t=this.#G(e);if(t===void 0)break;this.#h[e]=t}this.#g=[],this.#_=0,this.#v=[]}if(C!==void 0&&C.size>0&&this.#l(C,this.#r),v!==void 0)this.#d&&u&&(this.#O.length=Math.min(this.#O.length,v)),this.#B(v,p,y);else if(!x&&b<r){let e=l&&s>=c?o:s<c&&!u?s:b;this.#d&&u&&(this.#O.length=Math.min(this.#O.length,e)),this.#B(e,p,g)}return S}prebuildStateStack(e){this.#I(),this.#A(e)}stopBackgroundTokenize(){this.#T=-1,!this.#b&&(this.#b=!0,this.#x=!1,this.#y=-1,this.#w=-1,this.#E=void 0,this.#D=0,this.#g=[],this.#_=0,this.#v=[],this.#R())}pauseBackgroundTokenize(){this.#b||this.#x||(this.#f&&console.log(`[diffs/editor] background tokenization paused`,{jobId:this.#S}),this.#x=!0)}resumeBackgroundTokenize(){this.#b||!this.#x||this.#t===void 0||this.#y<0||(this.#f&&console.log(`[diffs/editor] background tokenization resumed`,{jobId:this.#S}),this.#x=!1,this.#z(this.#S))}#I(){this.#t===void 0&&!Ja(this.#o.languageId)&&this.#e.getLoadedLanguages().includes(this.#o.languageId)&&(this.#t=this.#e.getLanguage(this.#o.languageId))}#L(){this.#k||=(globalThis.addEventListener(`message`,this.#j),!0)}#R(){this.#k&&=(globalThis.removeEventListener(`message`,this.#j),!1)}#z(e){globalThis.postMessage({type:`tokenize`,tokenizerId:this.#C,jobId:e})}#B(e,t,n=0){if(Ja(this.#o.languageId))return;let r=++this.#S;this.#f&&console.log(`[diffs/editor] background tokenization scheduled`,{jobId:r,startLine:e,changedLineRanges:t,changedRangeIndex:n}),this.#b=!1,this.#x=!1,this.#y=e,this.#w>=0&&(this.#T=Math.max(this.#T,this.#w)),this.#w=-1,this.#E=t,this.#D=n,this.#L(),this.#z(r)}#V(e){if(this.#t===void 0||this.#h.length>e)return;if(!this.#b){this.#w>=0?this.#w=Math.max(this.#w,e):this.#T=Math.max(this.#T,e);return}let t=++this.#S;this.#b=!1,this.#x=!1,this.#y=this.#h.length-1,this.#w=e,this.#T=-1,this.#E=void 0,this.#D=0,this.#L(),this.#z(t)}#H(e,t){let n=this.#o.getLineText(e);if(n.length>this.#s)return console.warn(`[diffs] Line(${e}) too long to tokenize: ${n.length}`),this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};if(this.#t===void 0||n===``||n.trim()===``)return this.#U(e,null),{resolvedTokens:[[0,``,n]],state:t};let r=Ka(this.#t,this.#a,n,t,Ua,this.#d);return this.#U(e,r.bracketIgnoredRanges),{resolvedTokens:r.resolvedTokens,state:r.ruleStack}}#U(e,t){this.#d&&(this.#O[e]=t)}#W(e){let t=e.changedLineChanges??[[e.startLine,e.endLine,e.lineDelta]],n=e.startLine+1;n<=this.#h.length-n?(this.#g=this.#h,this.#_=0,this.#h=this.#h.slice(0,n)):(this.#_=n,this.#g=this.#h.slice(n),this.#h.length=Math.min(this.#h.length,n)),this.#v=t}#G(e){let t=e;for(let n=this.#v.length-1;n>=0;n--){let[r,i,a]=this.#v[n];if(a!==0){if(t>i)t-=a;else if(t>r)return this.#h[e]}}return this.#g[t-this.#_]??this.#h[e]}#K(e,t){let n=Math.min(Math.max(0,e),this.#o.lineCount);if(this.#h.length>n||this.#t===void 0)return!0;let r=t===void 0?0:performance.now(),i=this.#h.length-1,a=this.#h[i]??M;for(;i<n;){this.#h[i]=a;let e=this.#o.getLineText(i);if(e.length<=this.#s&&e!==``&&e.trim()!==``){let t=Ka(this.#t,this.#a,e,a,Ua,this.#d,!1);this.#U(i,t.bracketIgnoredRanges),a=t.ruleStack}else this.#U(i,null);if(i++,this.#h[i]=a,t!==void 0&&performance.now()-r>t)break}return i>=n}#q(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=this.#K(this.#w,1);if(!(this.#b||this.#x||e!==this.#S)){if(t){this.stopBackgroundTokenize();return}this.#y=this.#h.length-1,this.#z(e)}}#J(e){if(this.#b||this.#x||this.#t===void 0||e!==this.#S)return;this.#F();let t=performance.now(),n=new Map,r=this.#o.lineCount,i=this.#E,a=this.#y,o=this.#h[a]??M,s=!1,c=this.#D,l=i?.[c]?.[1];for(;a<r;){this.#h[a]=o;let e=l===void 0?void 0:this.#G(a+1),r=this.#o.getLineText(a);if(r.length>this.#s)console.warn(`[diffs] Line(${a}) too long to tokenize: ${r.length}`),n.set(a,[[0,``,r]]),this.#U(a,null);else if(r===``||r.trim()===``)n.set(a,[[0,``,r]]),this.#U(a,null);else{let e=Ka(this.#t,this.#a,r,o,Ua,this.#d);n.set(a,e.resolvedTokens),this.#U(a,e.bracketIgnoredRanges),o=e.ruleStack}if(this.#h[a+1]=o,s=l!==void 0&&a>=l&&e!==void 0&&o.equals(e),a++,s){c++;let e=i?.[c];if(e===void 0)break;if(l=e[1],this.#h[e[0]]===void 0)s=!1;else{a=e[0],o=this.#h[a]??o,s=!1;continue}}if(performance.now()-t>1)break}if(this.#l(n,this.#r),!(this.#b||this.#x||e!==this.#S)){if(s||a>=r){let e=this.#T;this.stopBackgroundTokenize(),e>=0&&this.#V(e);return}this.#y=a,this.#D=c,this.#z(e)}}};function Ka(e,t,n,r,i,a=!0,o=!0){let s=e.tokenizeLine2(n,r,i);s.stoppedEarly&&console.warn(`[diffs] Time limit reached when tokenizing line: ${n.substring(0,100)}`);let c=s.tokens,l=c.length/2,u=[],d=[];if(!o&&!a)return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d};for(let e=0;e<l;e++){let r=c[2*e],i=e+1<l?c[2*e+2]:n.length;if(r===i)continue;let s=c[2*e+1];if(o){let e=ve.getForeground(s);u.push([r,t[e],n.slice(r,i)])}a&&ve.getTokenType(s)>0&&d.push([r,i])}return{ruleStack:s.ruleStack,resolvedTokens:u,bracketIgnoredRanges:d}}function qa(e){return e.map(([e,t,n])=>e===0&&t===``?n===``?U(`br`):n:U(`span`,{dataset:{char:e.toString()},style:`color:${t};`,textContent:n}))}function Ja(e){return e===`text`||e===`ansi`}function Ya(e){let t=e.getSelection?.();if(t==null||t.rangeCount===0)return;let n=t.getRangeAt(0);return{collapsed:n.collapsed,startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset}}function Xa(e){if(typeof e.cacheKey!=`string`||e.cacheKey.length===0)throw Error(`Editor persistState requires a non-empty file.cacheKey for "${e.name}". Provide a unique, stable cacheKey for every editable file.`);return e.cacheKey}function Za(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}var Qa=2,$a=1e4,eo=`selection-action`,to=`application/vnd.pierre.diffs-selections+json`,no=class{#e;#t=new Ra;#n;#r;#i=new Map;#a;#o;#s=new Map;#c;#l=0;#u=!1;#d;#f;#p;#m;#h={generation:0,callback:void 0,delivered:!1};#g;#_;#v;#y=new Map;#b=new Map;#x=new Map;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I;#L;#R;#z;#B;#V;#H;#U=!0;#W=!1;#G=!1;#K=!1;#q;#J=!1;#Y=!1;#X=!1;#Z;#Q=!1;#$;#ee=``;#te;#ne;#re;#ie;#ae;#oe;#se=!1;#ce=!1;#le=!1;#ue=!1;#de;#fe=(e,t)=>{if(this.#P?.updateRenderCache(e,t),this.#R!==void 0&&this.#R.totalLines!==1/0){let{startingLine:t,totalLines:n}=this.#R,r=Math.min(t+n,this.#L?.lineCount??0);for(let[n,i]of e)if(n>=t&&n<r){let e=this.#Ht(n);e!==void 0&&e.replaceChildren(...qa(i))}}};constructor(e={}){this.#e=e}setOptions(e){let t=this.#e.persistStateStorage??`inMemory`,n={...this.#e,...e};if(n.persistState===!0&&this.#P?.type===`file`){let e=this.#P.__getCurrentFile?.()??this.#F;e!==void 0&&Xa(e)}this.#e=n,this.#e.persistState!==!0&&(this.#i.clear(),this.#l++,this.#u=!1),(this.#e.persistStateStorage??`inMemory`)!==t&&(this.#l++,this.#a=void 0,this.#o=void 0,this.#s.clear())}edit(e){if(this.#e.persistState===!0&&e.type===`file`){let t=e.__getCurrentFile?.();t!==void 0&&Xa(t)}return this.#ke(),this.#P=e,this.#Pe(),this.#m=e.attachEditor(this),()=>this.cleanUp()}applyEdits(e,t=!0){let n=this.#L;if(n==null)throw Error(`Editor is not attached`);let r=this.#K,i=this.#re,a=i?.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]),o=i===void 0?void 0:n.resolveEdits(e).sort((e,t)=>e.start-t.start),s=n.applyEdits(e,t,i);if(s===void 0)return;let c;i!==void 0&&a!==void 0&&o!==void 0&&(c=di(n,i,a,o),t&&n.setLastUndoSelectionsAfter(c)),this.#zt(s,c,this.#Bt(s),{skipFocus:!r})}get canUndo(){return this.#L?.canUndo??!1}get canRedo(){return this.#L?.canRedo??!1}undo(){this.#Ue(`undo`)}redo(){this.#Ue(`redo`)}getFile(){let e=this.#F,t=this.#L;if(e===void 0||t===void 0)return;let n={...e};return Object.defineProperty(n,"contents",{enumerable:!0,get:()=>t.getText()}),n}getText(){return this.#L?.getText()??``}getState(){let e=this.#P;return{selections:this.#re,view:e==null?void 0:{scrollLeft:e.getCodeScrollLeft(),scrollTop:this.#Me()}}}setState({selections:e,view:t}){if(this.#P===void 0||this.#L===void 0)throw Error(`Editor is not attached`);if(this.#U=!1,this.#yt(e??[]),t!=null){this.#P.setCodeScrollLeft(t.scrollLeft),t.scrollTop!==void 0&&this.#Ne(t.scrollTop);return}this.#at()}setSelections(e){let t=this.#L;if(t===void 0)throw Error(`Text document is not initialized`);let n=e.map(e=>{let n=t.normalizePosition(e.start),r=t.normalizePosition(e.end),i=e.direction===`none`?0:e.direction===`backward`?-1:1;return J(n,r)>0&&([n,r]=[r,n],i!==0&&(i=i===1?-1:1)),{direction:i,start:n,end:r}});this.#U=!1,this.#yt(n);let r=n.at(-1);r!==void 0&&this.#Se(q(r).line),this.#at()}setMarkers(e){let t=this.#L;if(t===void 0)throw Error(`Text document is not initialized`);if(e.length===0){this.#B?.cleanup(),this.#B=void 0,this.#yt(this.#re??[]);return}this.#B??=new na({popoverManager:this.#Ee(),getLineHeight:()=>this.#t.lineHeight,getOverlayElement:()=>this.#A,getGutterWidth:()=>this.#Ut(),getCharX:(e,t)=>this.#Kt(e,t),getLineY:e=>this.#Gt(e),isMouseDown:()=>this.#X||this.#Y}),this.#B.setMarkers(e,t),this.#k!==void 0&&this.#B.listenHover(this.#k),this.#yt(this.#re??[])}focus(e){let t=e?.preventScroll??!1,n=e?.lineNumber;if(n===`first-visible`||typeof n==`number`){let r=this.#L;if(r==null||this.#P==null)return;let i=n===`first-visible`?this.#nt(e?.offset):n;if(i==null)return;let a=r.normalizePosition({line:i-1,character:n===`first-visible`?0:e?.character??0});this.#rt(a,t);return}let r=this.#re?.at(-1);if(r!==void 0){let e=r.direction===-1?r.end:r.start;this.#$e(e,t)}else this.#$e(void 0,t)}blur(){this.#q=void 0,this.#K=!1,this.#W=!1,this.#k?.blur()}cleanUp(e=!1){this.#ke(),e||(this.#h.delivered=!1);let t=this.#P!=null,n=this.#e.persistState===!0;this.#l++,this.#he(),t&&(this.#u=n),z(this.#Be),this.#n?.cleanUp(),this.#n=void 0,e||(this.#L=void 0,this.#F=void 0),this.#f?.forEach(e=>e()),this.#f=void 0,this.#d?.forEach(e=>e()),this.#d=void 0,this.#m?.(e),this.#m=void 0,this.#_=void 0,this.#v=void 0,this.#y.clear(),this.#b.clear(),this.#x.clear(),this.#S=void 0,this.#C?.remove(),this.#C=void 0,this.#w?.remove(),this.#w=void 0,this.#T?.remove(),this.#T=void 0,this.#E?.remove(),this.#E=void 0,this.#D=void 0,this.#r?.cleanUp(),this.#r=void 0,this.#O=void 0,this.#k?.removeAttribute(`contentEditable`),this.#k=void 0,this.#q=void 0,this.#K=!1,this.#A?.remove(),this.#A=void 0,this.#N?.disconnect(),this.#N=void 0,this.#ue=!1,this.#de!==void 0&&(cancelAnimationFrame(this.#de),this.#de=void 0),this.#Oe(),this.#P=void 0}__prepareFile(e){if(this.#e.persistState!==!0)return e;let t=Xa(e),n=this.#F,r=e.lang??Ae(e.name);n!==void 0&&(Xa(n)!==t||n.name!==e.name||this.#L?.languageId!==r)&&(this.#l++,this.#he());let i=this.#pe(e,t);return i===void 0||i.getText()===e.contents?e:{...e,contents:i.getText()}}__postponeBgTokenizeToNextFrame(){let e=this.#n;e!==void 0&&(e.pauseBackgroundTokenize(),requestAnimationFrame(()=>{e.resumeBackgroundTokenize()}))}__captureFocusForDOMReplacement(){let e=this.#k,t=this.#D?.shadowRoot?.activeElement;e!=null&&(this.#K||t===e||t!=null&&e.contains(t))&&(this.#q={})}__syncRenderView=(e,t,n,r,i)=>{let a=this.#P;if(a==null)return;let o=t.shadowRoot;if(o==null){console.error(`[editor] Could not find the shadow root.`);return}let s,c,l;for(let e of o.querySelectorAll(`[data-code]`))if(e.dataset.deletions===void 0){s=e;for(let t of e.children){let e=t,{gutter:n,content:r}=e.dataset;n===void 0?r!==void 0&&(l=e):c=e}break}if(s===void 0||l===void 0){this.#q=void 0;return}this.#Ee().setViewportElements(t,s),this.#D!==t&&(this.#D=t,this.#C!==void 0&&t.appendChild(this.#C),this.#w!==void 0&&o.appendChild(this.#w),this.#T!==void 0&&o.appendChild(this.#T),this.#E!==void 0&&o.prepend(this.#E));let u=this.#L===void 0||this.#F===void 0||this.#F.name!==n.name||this.#F.lang!==n.lang||this.#F.cacheKey!==n.cacheKey,d=this.#e.persistState===!0?Xa(n):void 0,f;if(u){this.#ke();let e=``;e=`contents`in n?n.contents:n.additionLines.join(``);let t=new yn({maxEntries:this.#e.historyMaxEntries}),{name:r,lang:i,cacheKey:o}=n,s=i??Ae(n.name),c=d===void 0?void 0:this.#pe(n,d),l=a.type===`file`||c?.getText()===e?c:void 0,u=l??new Jn(n.name,e,s,0,t);this.#F={name:r,lang:i,cacheKey:o},this.#L=u,d!==void 0&&(this.#i.set(d,u),f={cacheKey:d,textDocument:u}),this.#n?.cleanUp(),this.#n=void 0,this.#Oe(),this.#b.clear(),this.#re=this.#ne,this.#e.__debug===!0&&console.log(l===void 0?`[diffs/editor] text document rebuilt from`:`[diffs/editor] cached text document reused for`,n.name)}f===void 0&&this.#u&&d!==void 0&&this.#L!==void 0&&(f={cacheKey:d,textDocument:this.#L});let p=this.#L;if(this.#n==null&&p!=null&&(this.#n=new Ga({highlighter:e,textDocument:p,codeOptions:this.#P?.__getEffectiveCodeOptions()??{},matchBrackets:this.#e.matchBrackets,onDeferTokenize:this.#fe,onThemeChange:()=>this.#_t(),setStyle:e=>{this.#T.textContent=e},__debug:this.#e.__debug})),this.#k!==l&&(this.#O=c,this.#k=mr(l,{contentEditable:`true`,role:`textbox`,ariaMultiLine:`true`,autocapitalize:`off`,writingSuggestions:`off`,autocorrect:!1,spellcheck:!1,translate:!1}),this.#A!==void 0&&l.after(this.#A),this.#t.init(l),this.#Xe(),this.#ze(l,c),this.#k!==void 0&&this.#e.__debug===!0&&console.log(`[diffs/editor] full re-render triggered !!!`)),this.#q!=null&&(this.#q.target=l),l.ariaLabel!==n.name&&(l.ariaLabel=n.name),r!==void 0&&r.length>0||this.#we)for(let e of this.#k.children){let t=e,{lineAnnotation:n,lineType:r,separator:i}=t.dataset;(n!==void 0||i!==void 0||r===`change-deletion`)&&t.setAttribute(`contenteditable`,`false`)}if(this.#De(),this.#n?.syncTheme(this.#P?.__getEffectiveCodeOptions()??{}),this.#I=r,this.#R=i,this.#z=i?.totalLines,this.#n?.prebuildStateStack(i),this.#B?.removePopover(),(this.#re!==void 0||this.#ie!==void 0||this.#B!==void 0)&&this.#yt(this.#re??[]),this.#ne!==void 0&&this.#M!==void 0?(this.#ne=void 0,this.#at(!1,`center`)):this.#ae===void 0?this.#q===void 0?this.#re!==void 0&&this.#re.length>0&&this.#K&&!this.#le&&this.focus({preventScroll:!0}):this.#et():this.#st(this.#ae,this.#oe,this.#ce),this.#le&&this.#V?.focus(),this.#e.__debug===!0&&i!==void 0){let{startingLine:e,totalLines:t}=i;console.log(`[diffs/editor] render file:`,n.name,`RenderRange:`,e+`-`+(e+t),`of`,this.#L?.lineCount,`lines`)}f!==void 0&&(this.#u=!1,this.#ve(f.cacheKey,f.textDocument)),this.#Ae(a)};#pe(e,t){let n=this.#i.get(t),r=e.lang??Ae(e.name);return n?.languageId===r?n:void 0}#me(){let e=this.#e.persistStateStorage??`inMemory`;return(this.#a===void 0||this.#o!==e)&&(this.#a=Oa(e),this.#o=e),this.#a}#he(){let e=this.#F,t=this.#L;if(this.#e.persistState!==!0||this.#P===void 0||e===void 0||t===void 0)return;let n=Xa(e);this.#i.set(n,t);let r;try{r=this.#me()}catch{return}let i=Da(this.getState()),a=this.#c;if(a?.cacheKey===n&&a.textDocument===t){if(this.#c=void 0,t.version===a.documentVersion&&this.#re===a.selections&&i.view?.scrollLeft===a.view?.scrollLeft&&i.view?.scrollTop===a.view?.scrollTop)return;this.#ge(r,n,i,a.completion);return}this.#ge(r,n,i)}#ge(e,t,n,r){let i=this.#s.get(t);if(r!==void 0||i!==void 0){let a=r??Promise.resolve();i!==void 0&&(a=a.then(()=>i)),this.#_e(t,a.then(()=>e.set(t,n)));return}let a;try{a=e.set(t,n)}catch{return}Za(a)&&this.#_e(t,a)}#_e(e,t){let n=t.catch(()=>{});this.#s.set(e,n),n.finally(()=>{this.#s.get(e)===n&&this.#s.delete(e)})}#ve(e,t){let n=++this.#l,r=t.version,i=this.#re,a=this.getState().view,o,s=s=>{let c=this.getState().view;if(n!==this.#l||this.#L!==t||t.version!==r||this.#re!==i||c?.scrollLeft!==a?.scrollLeft||this.#F===void 0||Xa(this.#F)!==e)return;let l=o?.userScrolled()===!0;if(s===void 0){this.#P?.setCodeScrollLeft(0),l||this.#Ne(0);return}let u=Da(s);l&&u.view!==void 0&&(u.view={scrollLeft:u.view.scrollLeft}),this.setState(u)},c=()=>{let t;try{t=this.#me().get(e)}catch{return}if(Za(t))return t.then(s).catch(()=>{});try{s(t)}catch{}},l=this.#s.get(e),u=l===void 0?c():l.then(c);if(Za(u)){o=this.#ye();let n={cacheKey:e,textDocument:t,documentVersion:r,selections:i,view:a,completion:u.catch(()=>{})};this.#c=n,n.completion.finally(()=>{o?.dispose(),this.#c===n&&(this.#c=void 0)})}}#ye(){let e=this.#je();if(!(e instanceof HTMLElement))return;let t=!1,n=[`wheel`,`touchstart`,`mousedown`],r=()=>{for(let t of n)e.removeEventListener(t,i,{capture:!0})},i=()=>{t=!0,r()};for(let t of n)e.addEventListener(t,i,{capture:!0,passive:!0});return{userScrolled:()=>t,dispose:r}}#be(e){return this.#P?.isLineRenderable?.(e+1)??!0}get#xe(){let e=this.#P;if(e?.getNearestRenderableLine!=null)return(t,n)=>{let r=e.getNearestRenderableLine(t+1,n);return r==null?void 0:r-1}}#Se(e){this.#be(e)||this.#P?.revealLine?.(e+1)}get#Ce(){return this.#P?.options.diffStyle??`split`}get#we(){return this.#P?.type===`file-diff`}get#Te(){return this.#P?.options.overflow===`wrap`}#Ee(){return this.#r??=new Fr({hasActivePopover:()=>this.#H!==void 0||this.#B?.isPopoverVisible()===!0,updateActivePopover:()=>{this.#Tt(),this.#B?.updatePopoverPosition()}})}#De(){this.#y.clear(),this.#x.clear(),this.#S=void 0}#Oe(){this.#gt(null),this.#_=void 0,this.#v=void 0,this.#Fe(),this.#G=!1,this.#j?.forEach(e=>e.remove()),this.#j=void 0,this.#re=void 0,this.#ae=void 0,this.#B?.cleanup(),this.#B=void 0,this.#V?.cleanup(),this.#V=void 0,this.#H?.cleanup(),this.#H=void 0,this.#U=!0}#ke(){let e=this.#h;e.generation++,e.callback!=null&&(z(e.callback),e.callback=void 0)}#Ae(e){let t=this.#h,n=this.#L;if(t.delivered||t.callback!=null||n==null)return;let{generation:r}=t,i=()=>{if(t.callback!==i||(t.callback=void 0,r!==t.generation||this.#P!==e||this.#L!==n))return;let a=this.#k,o=this.#D?.shadowRoot;a==null||o==null||!o.contains(a)||(t.delivered=!0,this.#e.onAttach?.(this,e))};t.callback=i,ct(i)}#je(){let e=this.#P?.getEditorViewport?.();if(e!==void 0)return e;let t=this.#D;if(this.#P!=null&&t!=null)return Sr(t)}#Me(){let e=this.#je();return e instanceof HTMLElement?e.scrollTop:e?.defaultView?.scrollY??0}#Ne(e){let t=this.#je();t instanceof HTMLElement?t.scrollTop=e:t instanceof Document&&t.defaultView?.scrollTo({top:e})}#Pe(){this.#C=U(`style`,{dataset:`editorGlobalCss`,textContent:`
|
|
514
|
+
[data-annotation-slot] {
|
|
515
|
+
user-select: none;
|
|
516
|
+
-webkit-user-select: none;
|
|
517
|
+
}
|
|
518
|
+
`}),this.#w=U(`style`,{dataset:`editorCss`,textContent:rr}),this.#T=U(`style`,{dataset:`editorThemeCss`}),this.#E=Ca(),this.#A=U(`div`,{dataset:`editorOverlay`});let e=e=>{let t=e.composedPath()[0];return t instanceof Node&&this.#k?.contains(t)===!0},t=()=>{this.#q!=null&&(this.#q=void 0,this.#K=!1,this.#W=!1)},n=e=>{if(e.pointerType!==`mouse`)return;let t=this.#Y;this.#Fe(),t&&this.#$e(),this.#e.enabledSelectionAction===!0&&this.#re!==void 0&&this.#re.length>0&&!K(this.#re.at(-1))&&this.#yt(this.#re)};this.#f=[W(document,`focusin`,n=>{e(n)||t()},{passive:!0}),W(document,`pointerdown`,n=>{e(n)||queueMicrotask(t)},{capture:!0,passive:!0}),W(document,`selectionchange`,()=>{let e=this.#D?.shadowRoot;if(this.#W||this.#G||e==null||!this.#K||this.#re!==void 0&&this.#re.length>1&&!this.#X)return;let t=document.getSelection();if(t==null)return;let n=typeof t.getComposedRanges==`function`?t.getComposedRanges({shadowRoots:[e]})?.[0]:Ya(e);if(n===void 0||!this.#Yt(n))return;let r=Br(n,0);if(r!==void 0){if(this.#X&&this.#Q&&this.#re!==void 0&&this.#re.length>0){let e=this.#re.at(-1);this.#yt([pi(e,r)]);return}if(this.#X)this.#$===void 0?this.#$=r:r=fi(this.#$,r);else if(this.#$!==void 0)r.direction=fi(this.#$,r).direction;else if(this.#re!==void 0&&this.#re.length===1){let e=this.#re[0];J(e.start,r.start)===0&&J(e.end,r.end)===0&&(r.direction=e.direction)}this.#Z!==void 0&&(this.#Z.focusLine=q(r).line,this.#vt())||(this.#te===void 0?this.#yt([r]):this.#yt([...this.#te.filter(e=>!ci(e,r)),r]))}},{passive:!0}),W(document,`pointerup`,n,{passive:!0}),W(document,`pointercancel`,n,{passive:!0}),W(document,`keydown`,e=>{e.key===`Shift`&&(this.#$=this.#re?.at(-1))},{passive:!0}),W(document,`keyup`,e=>{e.key===`Shift`&&(this.#$=void 0)},{passive:!0})]}#Fe(){this.#p?.forEach(e=>e()),this.#p=void 0,this.#W=!1,this.#Y=!1,this.#X=!1,this.#Z=void 0,this.#Q=!1,this.#$=void 0,this.#te=void 0}#Ie(e){this.#p?.forEach(e=>e()),this.#p=e}#Le(){return this.#P?.options.enableLineSelection===!0}#Re(){this.#G=this.#re!==void 0}#ze(e,t){let{onFocus:n,onBlur:r}=this.#e,i=t=>{let n=t.composedPath()[0];return n!==void 0&&(n===e||e.contains(n))};this.#d?.forEach(e=>e()),this.#d=[W(e,`focus`,()=>{this.#K=!0,n?.(),!this.#X&&!this.#W&&this.#re!==void 0&&this.#re.length>0&&this.#it(this.#re.at(-1))},{passive:!0}),W(e,`blur`,()=>{this.#q?.target===e&&(this.#q=void 0,this.#W=!1),this.#K=!1,r?.()},{passive:!0}),W(e,`pointerdown`,t=>{if(this.#U=!0,this.#G=!1,t.pointerType!==`mouse`)return;if(this.#Z=void 0,this.#lt(t)){this.#ht(!0),this.#re!==void 0&&this.#yt([]);return}this.#ht(!1),this.#B?.removePopover();let n=[];if(ot()&&this.#I!==void 0&&this.#I.length>0){let t=[...e.querySelectorAll(`[data-line-annotation]`)].map(e=>[W(e,`mouseenter`,()=>{this.#W=!0}),W(e,`mouseleave`,()=>{this.#W=!1})]).flat();n.push(...t)}this.#X=!0;let r=t.button===0&&t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey;if(this.#$=void 0,r?(this.#Z={pointerId:t.pointerId,startClientX:t.clientX,clientX:t.clientX,startScrollLeft:e.parentElement?.scrollLeft??0},this.#te=void 0,this.#re=void 0,this.#yt([]),n.push(W(document,`pointermove`,e=>{let t=this.#Z;t!==void 0&&e.pointerType===`mouse`&&e.pointerId===t.pointerId&&(t.clientX=e.clientX,this.#vt())},{capture:!0,passive:!0}))):t.button===0&&Yn(t)&&(this.#te=this.#re?.map(e=>({...e}))),this.#Ie(n),t.shiftKey){let e=this.#re?.at(-1);if(e!==void 0){let t=e.direction===-1?e.end:e.start;this.#it({start:t,end:t,direction:0})}this.#Q=!0}},{passive:!0}),W(e,`keydown`,e=>{if(!i(e)||(this.#U=!0,this.#G=!1,e.isComposing||e.keyCode===229))return;let t=tr(e,this.#e.keymap);if(t!==void 0){e.preventDefault(),t===`simplifySelection`&&(this.#V?.close(),this.#V=void 0,this.#le=!1,this.#H?.cleanup(),this.#H=void 0),this.#Ue(t);return}let n=Xn(e),r=this.#L;if(this.#re!==void 0&&this.#re.length>0&&n!==void 0&&r!==void 0){let t={getSoftLineOffsets:this.#Te?e=>this.#Jt(e):void 0,resolveRenderableLine:this.#xe};e.shiftKey?this.#yt(Jr(r,this.#re,n,t)):this.#yt(Hr(r,this.#re,n,t)),this.#at(),e.preventDefault();return}if((e.key.length===1?e.key.toLowerCase():e.key)===`v`&&Yn(e)){if(e.repeat&&this.#we){e.preventDefault();return}if(this.#e.clipboard!==void 0){e.preventDefault(),ct(this.#Be);return}}if(this.#V!==void 0){let t=nr(e);if(t!==void 0){e.preventDefault(),this.#V.navigate(t===`previous`);return}}}),W(e,`copy`,e=>{i(e)&&(e.preventDefault(),this.#pt()?e.clipboardData?.setData(`text`,this.#mt()):this.#At(e.clipboardData,this.#Ot(),this.#kt()))}),W(e,`cut`,e=>{if(i(e)){if(e.preventDefault(),this.#pt())e.clipboardData?.setData(`text`,this.#mt());else{let t=this.#kt();this.#At(e.clipboardData,this.#jt(),t)}}}),W(e,`paste`,e=>{if(!i(e))return;e.preventDefault();let t=e.clipboardData,n=this.#L;if(t===null||n===void 0)return;let r=t.getData(`text`),a=this.#re?.length??0;if(a>1){let e=t.getData(to);if(e!==void 0)try{let t=JSON.parse(e);Array.isArray(t)&&t.length===a&&(r=t)}catch{}}this.#Nt(Array.isArray(r)?r.map(e=>n.normalizeEol(e)):n.normalizeEol(r),void 0,!0,`document`)}),W(e,`beforeinput`,e=>{i(e)&&e.inputType!==`insertCompositionText`&&(e.preventDefault(),this.#Qe(e.inputType,e.data))}),W(e,`drop`,e=>{i(e)&&e.preventDefault()}),W(e,`compositionstart`,e=>{i(e)&&(this.#J=!0,this.#W=!0)},{passive:!0}),W(e,`compositionend`,e=>{if(!i(e))return;this.#W=!1;let t=this.#J;this.#J=!1,(e.data!==``||!t)&&this.#Qe(`insertText`,e.data)},{passive:!0})];let a=this.#D?.shadowRoot?.querySelector(`[data-deletions]`);if(a!=null&&this.#d.push(W(a,`pointerdown`,e=>{let t=e.composedPath();if(Tt(t)){this.#Re();return}let n=t[0],r=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(r instanceof HTMLElement){if(this.#Le()){this.#Re();return}if(this.#ft(r,a,e.pointerType===`mouse`))return}this.#ht(!0),this.#re!==void 0&&this.#yt([])},{passive:!0})),t!==void 0){let e=(e,t=!1)=>{let n=e;return n?.dataset.lineNumberContent===void 0?t&&n?.tagName===`SPAN`&&(n=n.closest(`[data-line]`)):n=n.parentElement??void 0,n},n=e=>{if(e===void 0)return;let t=e.dataset.lineType,n=G(e)??G(e,`columnNumber`);if(!(n===void 0||t===void 0||!si(t)))return n-1};this.#d.push(W(t,`pointerdown`,t=>{let r=t.composedPath();if(Tt(r)){this.#Re();return}let i=e(r[0]);if(i!==void 0&&this.#Le()){this.#Re();return}if(i?.dataset.lineType===`change-deletion`){let e=i.closest(`[data-code]`);e!=null&&this.#ft(i,e,t.pointerType===`mouse`);return}if(t.pointerType!==`mouse`)return;let a=this.#L,o=n(i);if(o===void 0||a===void 0)return;this.#U=!0,this.#B?.removePopover();let s=this.#ct(o,o,a);this.#Y=!0,this.#$=s,this.#yt([s]),this.#it(s),this.#$e(),this.#Ie([W(document,`mousemove`,t=>{if(!this.#Y)return;let r=this.#L,i=n(e(t.composedPath()[0],!0));if(i===void 0||r===void 0)return;let a=this.#$?.start.line??i,o=this.#ct(a,i,r);this.#$??=o,this.#yt([o]),this.#$e(o.direction===-1?o.start:o.end)},{passive:!0})])},{passive:!0}))}this.#B?.listenHover(e),this.#N?.disconnect(),this.#N=new ResizeObserver(this.#Ye),this.#N.observe(e),this.#N.observe(e.parentElement),this.#Ve(e)}#Be=async()=>{let e=this.#e.clipboard;if(e!==void 0){let t=await e.readText(),n=this.#re?.length??0;if(n>1){let r=await e.readText(to);try{let e=JSON.parse(r);Array.isArray(e)&&e.length===n&&(t=e)}catch{}}let r=this.#L;r!==void 0&&this.#Nt(Array.isArray(t)?t.map(e=>r.normalizeEol(e)):r.normalizeEol(t),void 0,!0,`document`)}};#Ve(e){this.#we&&this.#Ce===`split`&&this.#Te&&(this.#g={top:e.offsetTop,left:e.offsetLeft-this.#Ut()},this.#e.__debug===!0&&console.log(`[diffs/editor] content offset:`,this.#g))}get#He(){if(this.#we&&this.#Ce===`split`&&this.#Te)return this.#g}#Ue(e){let t=this.#L;if(t!==void 0)switch(e){case`openSearchPanel`:this.#Et(`find`);break;case`openSearchReplacePanel`:this.#Et(`replace`);break;case`findNextMatch`:{let e=this.#re;if(e===void 0)break;if(e.some(K)){let n=e.map(e=>K(e)?ji(t,e):e);this.#yt(n),this.focus()}else{let n=vi(t,e);if(n!==void 0){this.#yt(n);let e=n.at(-1);e!==void 0&&this.#Se(q(e).line),this.#at()}}break}case`moveLineUp`:case`moveLineDown`:this.#Je(e===`moveLineUp`?-1:1);break;case`copyLineUp`:case`copyLineDown`:this.#Ke(e===`copyLineUp`?-1:1);break;case`simplifySelection`:{let e=this.#re,t=e?.at(-1);if(e===void 0||t===void 0)break;if(e.length>1)this.#yt([t]),this.#$e(q(t));else if(!K(t)){let e=q(t);this.#yt([{start:e,end:e,direction:0}]),this.#$e(e)}break}case`insertBlankLine`:this.#qe();break;case`deleteHardLineForward`:this.#Lt();break;case`toggleComment`:case`toggleBlockComment`:{let n=this.#re;if(n===void 0)break;let{lineComment:r,blockComment:i}=sr(t.languageId,this.#e.languageCommentConfig);if(e===`toggleComment`&&r!==null){this.#Ge(cr(t,n,r));break}let a=e===`toggleComment`,o=fr(t,n,i,a);o!==void 0&&this.#Ge(o.edits,a?void 0:e=>o.nextSelectionOffsets.map(([t,n,r])=>({start:e.positionAt(t),end:e.positionAt(n),direction:r})));break}case`indent`:case`outdent`:case`indentLess`:case`indentMore`:if(this.#re!==void 0){let n=[],r=[],i=new Set,a=[];for(let o of this.#re){let s=o.start.line,c=e===`outdent`||e===`indentLess`,l=e===`indentLess`||e===`indentMore`;if(s!==o.end.line||c||l){let e=Vr(t,o,this.#t.tabSize,c);for(let t of e[0]){let e=t.range.start.line;i.has(e)||(i.add(e),n.push(t))}r.push(e[1])}else{let e=t.charAt({line:s,character:0})===` `?` `:` `.repeat(this.#t.tabSize);n.push({range:o,newText:e}),a.push({line:s,startCharacter:o.start.character,addedLength:e.length-(o.end.character-o.start.character),selectionIndex:r.length});let i={line:o.start.line,character:o.start.character+e.length};r.push({start:i,end:i,direction:0})}}for(let e of a){let t=0;for(let n of a)n.line===e.line&&n.startCharacter<e.startCharacter&&(t+=n.addedLength);if(t!==0){let n=r[e.selectionIndex],i={line:e.line,character:n.start.character+t};r[e.selectionIndex]={start:i,end:i,direction:0}}}let o=t.applyEdits(n,!0,this.#re,r);o!==void 0&&this.#zt(o,r)}break;case`selectAll`:{let e=yi(t);this.#yt([e]),this.focus();let n=this.#Vt(),r=n[0]?.[0],i=n.at(-1)?.[1];r!==void 0&&i!==void 0&&(this.#G=!0,this.#it({start:{line:r,character:0},end:{line:i,character:t.getLineLength(i)},direction:1}));break}case`moveCursorToDocStart`:case`moveCursorToDocEnd`:{let n=bi(t,e===`moveCursorToDocEnd`,this.#we);this.#yt([n]),this.#Se(q(n).line),this.#at()}break;case`expandSelectionDocStart`:case`expandSelectionDocEnd`:{let n=e===`expandSelectionDocEnd`,r=this.#re;if(r!==void 0){let e=bi(t,n,this.#we);this.#yt(mi(r,e)),this.#Se(q(e).line),this.#at()}}break;case`undo`:case`redo`:this.#We(e)}}#We(e){let t=this.#L;if(t===void 0||e===`undo`&&!t.canUndo||e===`redo`&&!t.canRedo)return;let n=this.#re,r=n?.map(e=>[t.offsetAt(e.start),t.offsetAt(e.end)]),i=e===`undo`?t.undo():t.redo();if(i===void 0)return;let[a,o,s,c]=i,l=o??(n!==void 0&&r!==void 0&&c!==void 0?di(t,n,r,c):void 0);this.#zt(a,l,s)}#Ge(e,t){let n=this.#L,r=this.#re;if(n===void 0||r===void 0)return;let i=t===void 0,a=i?r.map(e=>[n.offsetAt(e.start),n.offsetAt(e.end)]):void 0,o=i?e.map(e=>{let t=n.offsetAt(e.range.start),r=n.offsetAt(e.range.end);return{start:Math.min(t,r),end:Math.max(t,r),text:e.newText}}).sort((e,t)=>{let n=e.start-t.start;return n===0?e.end-t.end:n}):void 0,s=n.applyEdits(e,!0,r,void 0,!0);if(s===void 0)return;let c=i?di(n,r,a,o):t(n);n.setLastUndoSelectionsAfter(c),this.#zt(s,c,this.#Bt(s))}#Ke(e){let t=this.#L,n=this.#re;if(t===void 0||n===void 0)return;let r=gi(n);if(r.length===0)return;let i=[],a=0,o=[];for(let n of r){i.push(a);let r=n.endLine-n.startLine+1;a+=r;let s=t.getText({start:{line:n.startLine,character:0},end:{line:n.endLine,character:t.getLineLength(n.endLine)}});if(e>0){let e={line:n.startLine,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else if(n.endLine<t.lineCount-1){let e={line:n.endLine+1,character:0};o.push({range:{start:e,end:e},newText:s+t.eol})}else{let e={line:n.endLine,character:t.getLineLength(n.endLine)};o.push({range:{start:e,end:e},newText:t.eol+s})}}let s=n.map(t=>{let n=t.start.line,a=0,o=r.length-1;for(;a<=o;){let e=a+o>>>1,t=r[e];if(n<t.startLine)o=e-1;else if(n>t.endLine)a=e+1;else{a=e;break}}let s=Math.max(0,a<=o?a:o),c=r[s],l=i[s]+(e>0?c.endLine-c.startLine+1:0);return{start:{...t.start,line:t.start.line+l},end:{...t.end,line:t.end.line+l},direction:t.direction}});this.#Ge(o,()=>s)}#qe(){let e=this.#L,t=this.#re;if(e===void 0||t===void 0)return;let n=t.map(e=>q(e).line),r=Array.from(new Set(n)).sort((e,t)=>e-t),i=new Map,a=new Map,o=[];for(let t=0;t<r.length;t++){let n=r[t],s=e.getLineText(n),c=/^\s*/.exec(s)?.[0]??``;i.set(n,t),a.set(n,c);let l={line:n,character:e.getLineLength(n)};o.push({range:{start:l,end:l},newText:e.eol+c})}let s=t.map((e,t)=>{let r=n[t],o={line:r+1+i.get(r),character:a.get(r).length};return{start:o,end:o,direction:0}});this.#Ge(o,()=>s)}#Je(e){let t=this.#L,n=this.#re;if(t===void 0||n===void 0)return;let r=gi(n);if(r.length===0||e<0&&r[0].startLine===0||e>0&&r.at(-1).endLine>=t.lineCount-1)return;let i=t.lineCount,a=e=>e<i-1?{line:e+1,character:0}:{line:e,character:t.getLineLength(e)},o=(e,n)=>{let r=e.map(e=>t.getLineText(e)).join(t.eol);return n?r+t.eol:r},s=[];if(e<0)for(let e of r){let t=e.startLine-1,n=[];for(let t=e.startLine;t<=e.endLine;t++)n.push(t);s.push({range:{start:{line:t,character:0},end:a(e.endLine)},newText:o([...n,t],e.endLine<i-1)})}else for(let e=r.length-1;e>=0;e--){let t=r[e],n=t.endLine+1,c=[];for(let e=t.startLine;e<=t.endLine;e++)c.push(e);s.push({range:{start:{line:t.startLine,character:0},end:a(n)},newText:o([n,...c],n<i-1)})}let c=r.at(-1),l=e>0&&c.endLine===i-2?t.getLineLength(c.endLine):t.getLineLength(i-1),u=n.map(n=>_i(n,e,i,e=>e===i-1?l:t.getLineLength(e))),d=t.applyEdits(s,!0,n,u,!0);d!==void 0&&this.#zt(d,u)}#Ye=()=>{let e=this.#I?.length??0,t=this.#_,n=this.#v;this.#_=void 0,this.#v=void 0;let r=this.#Ut()!==t,i=this.#Wt()!==n;!r&&!i||(this.#x.clear(),this.#S=void 0,this.#t.clearTextWidthCache(),i&&(this.#b.clear(),(this.#Te||e>0)&&this.#y.clear()),(this.#re!==void 0||this.#ie!==void 0||this.#B!==void 0)&&(this.#yt(this.#re??[]),this.#re!==void 0&&this.#K&&this.focus()),this.#B?.removePopover(),this.#Ve(this.#k))};#Xe(){if(this.#ue)return;let e=document.fonts;e!==void 0&&(this.#ue=!0,e.ready.then(()=>{this.#k===void 0||!this.#t.remeasureCharacterWidth()||(this.#_=void 0,this.#v=void 0,this.#De(),this.#b.clear(),(this.#re!==void 0||this.#ie!==void 0||this.#B!==void 0)&&this.#yt(this.#re??[]),this.#B?.removePopover())}))}#Ze(e,t,n=this.#R,r){let i=this.#n,a=this.#P,o=this.#L,s=this.#O,c=this.#k;if(i===void 0||a===void 0||o===void 0||c===void 0)return;i.stopBackgroundTokenize();let l=performance.now(),u=i.tokenize(e,n,!this.#we&&a.getLinePosition!==void 0),d=performance.now();if(u.size>0){let e=c.children,t=new Set;for(let e of u.keys())this.#be(e)&&t.add(e);for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=G(r),n=r.dataset.lineType;if(e===void 0||n===`change-deletion`)continue;let i=e-1;if(t.has(i)){let e=u.get(i);if(r.replaceChildren(...qa(e)),t.delete(i),t.size===0)break}}}if(t.size>0){let n=0;for(let t=e.length-1;t>=0;t--){let r=e[t],i=G(r);if(i!==void 0&&r.dataset.lineType!==`change-deletion`){n=i;break}}for(let e of t){if(e<n)continue;let t=u.get(e),r=String(e+1);U(`div`,{dataset:{line:r,lineType:`context`,lineIndex:e.toString()},children:qa(t)},c),s!==void 0&&U(`div`,{dataset:{lineType:`context`,columnNumber:r,lineIndex:e.toString()},children:[U(`span`,{dataset:{lineNumberContent:``},textContent:r})]},s)}}}if(e.lineDelta<0)for(let t of[c.children,s?.children??[]])for(let n=t.length-1;n>=0;n--){let r=t[n],i=G(r)??G(r,`columnNumber`),a=r.dataset.lineType;if(i!==void 0&&a!==`change-deletion`){if(i-1<e.lineCount)break;r.remove()}}let f=e.lineDelta!==0;if(f){let e=c.children.length;for(let t of c.children){let{bufferSize:n}=t.dataset;n!==void 0&&(e+=parseInt(n)-1)}c.style.gridRow=`span `+e,s!==void 0&&(s.style.gridRow=`span `+e)}a.updateRenderCache(u,i.themeType,{shouldRefreshDiffsView:this.#we&&!f,lineCountChangeInFlight:f}),f&&a.applyDocumentChange(o,t,r),(f||this.#we&&this.#Ce===`unified`)&&this.#De(),t!==void 0&&(this.#I=t,kr(t,c,s)),this.#e.__debug===!0&&console.log(`[diffs/editor] re-render in: ${gr(performance.now()-d)}ms,`,`tokenize in: ${gr(d-l)}ms (${u.size} dirty lines)`)}#Qe(e,t){switch(e){case`insertText`:{let e=t??``,n=this.#L,r=this.#re,i=n!==void 0&&r!==void 0?ei(n,r,e,this.#e.autoSurround):void 0;this.#Nt(i??e);break}case`insertCompositionText`:break;case`insertLineBreak`:case`insertParagraph`:this.#Nt(this.#L?.eol??`
|
|
519
|
+
`);break;case`deleteContentBackward`:this.#Pt();break;case`deleteContentForward`:this.#Pt(!0);break;case`deleteSoftLineBackward`:case`deleteHardLineBackward`:this.#Ft();break;case`deleteWordBackward`:this.#It();break;case`insertTranspose`:this.#Rt();break;default:console.warn(`[diffs] Unknown input type: ${e}`,t)}}#$e(e,t=!0,n){this.#K=!0,e===void 0?n?.()===!1?this.#K=!1:this.#k?.focus({preventScroll:t}):(this.#W=!0,this.#it({start:e,end:e,direction:0}),ct(()=>{if(n?.()===!1||!this.#K){this.#W=!1;return}this.#k?.focus({preventScroll:t}),ct(()=>{this.#W=!1})}))}#et(e){let t=this.#q;if(t==null)return;if(this.#le){this.#q=void 0,this.#K=!1,this.#W=!1;return}let n=this.#k;if(n==null||!this.#tt(n)){this.#q=void 0,this.#K=!1;return}let r=()=>{if(this.#q!==t)return!1;let e=this.#tt(n);return this.#q=void 0,e};if(e!=null){this.#$e(e,!0,r);return}let i=this.#re?.at(-1);if(i==null){this.#$e(void 0,!0,r);return}let a=i.direction===-1?i.end:i.start;this.#$e(a,!0,r)}#tt(e){let t=this.#D,n=t?.shadowRoot;if(t==null||n==null||this.#k!==e||!n.contains(e))return!1;let{activeElement:r}=n;if(r===e||r!=null&&e.contains(r))return!0;if(r!=null)return!1;let{ownerDocument:i}=t,{activeElement:a}=i;return a==null||a===i.body||a===i.documentElement||a===t}#nt(e=0){let t=this.#k,n=this.#D;if(this.#L==null||t==null||n==null)return;let r=this.#je();if(r===void 0)return;let i,a;if(r instanceof HTMLElement){let e=r.getBoundingClientRect();i=e.top,a=e.bottom}else i=0,a=r.defaultView?.innerHeight??0;let o=n.shadowRoot?.querySelector(`[data-diffs-header][data-sticky]`);if(o!=null&&(i=Math.max(i,o.getBoundingClientRect().bottom)),Number.isFinite(e)&&(i+=Math.max(0,e)),!(a<=i))for(let e of t.children){let t=e,n=G(t),r=t.dataset.lineType;if(n==null||r==null||!si(r))continue;let o=t.getBoundingClientRect();if(!(o.bottom<=o.top)&&o.top>=i&&o.top<a)return n}}#rt(e,t){let n={start:e,end:e,direction:0};this.#U=!1,this.#yt([n]),this.#Se(e.line),t?this.#$e(e,!0):this.#at()}#it(e){let t=window.getSelection();if(t===null)return;let{start:n,end:r,direction:i}=e;J(n,r)>0&&([n,r]=[r,n]);let a=this.#Ht(n.line),o=this.#Ht(r.line);if(a===void 0||o===void 0)return;let[s,c]=Ai(a,n.character),[l,u]=Ai(o,r.character);i===-1&&([s,c,l,u]=[l,u,s,c]);try{t.setBaseAndExtent(s,pr(s,c),l,pr(l,u))}catch(e){console.error(`[diffs/editor] failed to update window selection:`,e)}}#at(e=!1,t=`nearest`){let n=this.#re?.at(-1);if(n===void 0)return;let r=this.#M;if(r!==void 0){if(r.scrollIntoView({block:t,inline:`nearest`}),!e){let e=n.direction===-1?n.end:n.start;this.#q===void 0?this.#$e(e):this.#et(e)}}else{let t=q(n);this.#st(t.line,t.character,e)}}#ot(){let e=this.#V===void 0?0:48,t=this.#Ut()+this.#t.ch;return`${e}px ${this.#t.ch}px 0 ${t}px`}#st(e,t=0,n=!1){this.__postponeBgTokenizeToNextFrame();let r=U(`div`,{style:{position:`absolute`,left:`0`,width:`2px`,height:this.#t.lineHeight+`px`,scrollMargin:this.#ot()}});if(this.#Ht(e)!==void 0){let[i,a]=this.#Kt(e,t),o=this.#Gt(e)+a*this.#t.lineHeight;if(r.style.top=o+`px`,r.style.left=i+`px`,this.#A?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),!n){let n={line:e,character:t};this.#q===void 0?this.#$e(n):this.#et(n)}this.#ae=void 0,this.#oe=void 0,this.#se=!1,this.#ce=!1}else{let i=this.#P?.getLinePosition?.(e+1);if(i!==void 0)r.style.top=i.top+`px`,this.#D?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),i.height>0&&this.#be(e)?(this.#ae=e,this.#oe=t,this.#ce=n):(this.#ae=void 0,this.#oe=void 0,this.#ce=!1);else{let i=0;if(this.#ae===e&&this.#k!==void 0)for(let t=this.#k.childElementCount-1;t>=0;t--){let n=this.#k.children[t],r=n.dataset.lineType,a=G(n);if(r!==void 0&&si(r)&&a!==void 0){i=(e-(a-1))*this.#t.lineHeight;break}}let a=((this.#I??[]).filter(t=>t.lineNumber<e).length+e)*this.#t.lineHeight+i;r.style.top=a+`px`,this.#D?.shadowRoot?.appendChild(r),r.scrollIntoView({block:`center`,inline:`nearest`}),this.#ae===e&&(i===0||this.#se)||!this.#be(e)?(this.#ae=void 0,this.#oe=void 0,this.#se=!1,this.#ce=!1):(this.#ae=e,this.#oe=t,this.#se=i!==0,this.#ce=n)}}r.remove()}#ct(e,t,n){let r=e=>({line:e,character:0}),i=e=>({line:e,character:n.getLineText(e).length});return t<e?{start:r(t),end:i(e),direction:-1}:{start:r(e),end:i(t),direction:1}}#lt(e){let t=e.composedPath()[0];return t instanceof HTMLElement&&t.closest(`[data-line]`)?.getAttribute(`data-line-type`)===`change-deletion`}#ut(e,t,n){let r=[...n.querySelectorAll(`[data-content] > [data-line]`)],i=r.indexOf(e),a=r.indexOf(t),[o,s]=a<i?[t,e]:[e,t],c=window.getSelection();if(c!==null){let e=document.createRange();e.setStart(o,0),e.setEnd(s,s.childNodes.length),c.removeAllRanges(),c.addRange(e)}this.#ht(!0),this.#yt([]),this.#gt(G(t)??null,!0,`deletions`);let l=Math.min(i,a),u=Math.max(i,a);this.#ee=l<0?``:r.slice(l,u+1).filter(e=>e.getAttribute(`data-line-type`)===`change-deletion`).map(e=>e.textContent??``).join(`
|
|
520
|
+
`)}#dt(e,t){let n=e.parentElement;if(n==null||t==null)return;let r=[...n.children].indexOf(e),i=t.children[r];return i instanceof HTMLElement?i:void 0}#ft(e,t,n){let r=t.querySelector(`[data-content]`),i=this.#dt(e,r);return i!==void 0&&(this.#ut(i,i,t),n&&this.#Ie([W(document,`mousemove`,e=>{let n=e.composedPath()[0],a=n instanceof HTMLElement?n.closest(`[data-column-number]`):null;if(a instanceof HTMLElement&&t.contains(a)){let e=this.#dt(a,r);e!==void 0&&this.#ut(i,e,t)}},{passive:!0})]),!0)}#pt(){return this.#D?.shadowRoot?.querySelector(`pre`)?.hasAttribute(`data-deleted-text-selection`)??!1}#mt(){return this.#ee===``?window.getSelection()?.toString()??``:this.#ee}#ht(e){let t=this.#D?.shadowRoot?.querySelector(`pre`);t!=null&&(e?(t.setAttribute(`data-deleted-text-selection`,``),this.#gt(null),this.#ee=``):(t.removeAttribute(`data-deleted-text-selection`),this.#ee=``))}#gt(e,t=!1,n=`additions`){try{this.#P?.setEditorActiveLine(e,{lineNumberOnly:t,side:n})}catch{}}#_t(){this.#de===void 0&&(this.#de=requestAnimationFrame(()=>{this.#de=void 0,(this.#re!==void 0||this.#ie!==void 0||this.#B!==void 0)&&this.#yt(this.#re??[])}))}#vt(){let e=this.#Z,t=this.#$,n=this.#L;if(e===void 0||e.focusLine===void 0||t===void 0||n===void 0)return!1;let r=t.direction===-1?t.end:t.start,i=this.#k?.parentElement?.scrollLeft??0,a=(e.clientX-e.startClientX+i-e.startScrollLeft)/this.#t.ch,o=a<0?-Math.round(-a):Math.round(a),s=Math.max(0,r.character+o),c={line:e.focusLine,character:s};if(e.renderedGoal!==void 0&&J(e.renderedGoal,c)===0)return!0;e.renderedGoal=c;let l=[],u=c.line<r.line?-1:1;for(let e=r.line;;e+=u){if(this.#be(e)){let t=n.getLineText(e),i=Math.min(r.character,t.length),a=Math.min(s,t.length),o=Wr(t,i),c=a===i?o:Wr(t,a);l.push({start:{line:e,character:Math.min(o,c)},end:{line:e,character:Math.max(o,c)},direction:o===c?0:o<c?1:-1})}if(e===c.line)break}return this.#yt(l),!0}#yt(e){if(this.__postponeBgTokenizeToNextFrame(),this.#M=void 0,this.#gt(null),e.length===0&&this.#ie===void 0&&this.#B===void 0){this.#re=void 0,this.#j?.forEach(e=>e.remove()),this.#j?.clear(),this.#H?.cleanup(),this.#H=void 0;return}let t=document.createDocumentFragment(),n={fragment:t,elements:new Map};if(e.length>0){let t=hi(e),r=t.at(-1);this.#re=t;let i=t.some(e=>!K(e)),a=q(r).line+1;this.#gt(a,i);for(let e of t)K(e)||this.#bt(n,`selection`,e),this.#wt(n,e,e===r);let o=this.#e.matchBrackets!==!1&&this.#L!==void 0&&this.#n!==void 0&&K(r)?ua(this.#L,this.#n,r.start):void 0;if(o!==void 0)for(let e of o)this.#bt(n,`bracketMatch`,e)}let r=this.#L;if(this.#ie!==void 0&&r!==void 0){let e=this.#ie,t=this.#R,i=t!==void 0&&Number.isFinite(t.totalLines)||this.#we&&this.#P?.options.expandUnchanged!==!0?this.#Vt():void 0,a=this.#re?.at(-1),o=a===void 0?-1:r.offsetAt(a.start),s=a===void 0?-1:r.offsetAt(a.end),c=0,l=i?.length??1;for(let t=0;t<l;t++){let a=1/0,l=i?.[t];if(l!==void 0){let[t,n]=l,i=r.offsetAt({line:t,character:0}),o=n+1;a=o<r.lineCount?r.offsetAt({line:o,character:0}):r.offsetAt({line:o-1,character:r.getLineLength(o-1)});let s=c,u=e.length;for(;s<u;){let t=s+Math.floor((u-s)/2);e[t][1]<=i?s=t+1:u=t}c=s}for(;c<e.length;c++){let[t,i]=e[c];if(t>=a)break;let l={start:r.positionAt(t),end:r.positionAt(i)},u=o===t&&s===i;this.#bt(n,`match`,l,u?`focus`:void 0)}}}if(this.#B!==void 0&&r!==void 0)for(let e of this.#B.markers)this.#bt(n,`marker`,e,aa(e.severity));this.#A?.appendChild(t),this.#j?.forEach(e=>e.remove()),this.#j?.clear(),this.#j=n.elements,this.#Tt()}#bt(e,t,n,r){if(this.#L===void 0)return;let{start:i,end:a}=n,o=i.line,s=a.line+1;if(this.#R!==void 0){let{startingLine:e,totalLines:t}=this.#R;o=Math.max(o,e),s=Math.min(s,e+t)}for(let n=o;n<s;n++){if(!this.#Xt(n))continue;let o=n===a.line,s=n===i.line?i.character:0,c=o?a.character:this.#L.getLineLength(n);if(this.#Te){let i=this.#Wt(),a=this.#L.getLineText(n);if(2*this.#t.ch+this.#t.measureTextWidth(a)>i){this.#xt(e,n,a,s,c,o,t,r);continue}}let l=0,u=0,d=0;l=s===0?this.#Ut()+this.#t.ch+(this.#He?.left??0):this.#Kt(n,s)[0],!o&&t===`selection`&&(d=this.#t.ch),u=s===c?d:this.#Kt(n,c)[0]-l+d,this.#Ct(e,t,n,0,l,u,r)}}#xt(e,t,n,r,i,a,o,s){let c=this.#Jt(t),l=c.length-1,u=this.#Ut()+this.#t.ch+(this.#He?.left??0);for(let d=0;d<l;d++){let f=c[d],p=c[d+1],m=Math.max(r,f),h=Math.min(i,p);if(m>h)continue;let g=this.#St(n,f,m),_=u+g,v=0;!a&&d===l-1&&o===`selection`&&(v=this.#t.ch);let y=m===h?v:this.#St(n,f,h)-g+v;this.#Ct(e,o,t,d,_,y,s)}}#St(e,t,n){if(n<=t)return 0;let r=e.slice(t,n),i=Ha(r,this.#t.tabSize);return i===-1?this.#t.measureTextWidth(r):i*this.#t.ch}#Ct(e,t,n,r,i,a,o){if(a===0)return;let{ch:s,lineHeight:c}=this.#t,l=this.#Gt(n)+r*c,u=`${t}-${n}/${r}-${i}-${a} ${o??``}`,d=this.#j,f=(this.#e.roundedSelection??!0)&&t===`selection`,p=(n,r,i,a)=>{let o=this.#Gt(n)+r*c,l=this.#Ht(n),u=`initial`;l!==void 0&&(l.dataset.lineType===`change-addition`||l.dataset.selectedLine!==void 0)&&(u=getComputedStyle(l).getPropertyValue(`--diffs-line-bg`));let f=`width:${s}px;transform:translateX(${i}px) translateY(${o}px);--diffs-selection-corner-bg:${u}`,p={selectionCorner:``,[a]:``},m=`${t}-block-${n}/${r}-${i}-1ch`,h=m+`-`+a;if(a===`rbl`){let t=m+`-rtl`,n=e.elements.get(t);n!==void 0&&(n.remove(),e.elements.delete(t),h+=`-rtl`,p.rtl=``)}let g=e.elements.get(h);g===void 0&&(d?.has(h)===!0?(g=d.get(h),g.style.cssText=f,d.delete(h)):g=U(`div`,{dataset:`selectionRange`,style:{cssText:f},children:[U(`div`,{dataset:p})]},e.fragment),e.elements.set(h,g))},m=t=>{let o=i+a,c=t.dataset,l=e.previousSelectionRange;if((l===void 0||l.line!==n||l.wrapLine!==r)&&(e.previousSelectionRange={element:t,line:n,wrapLine:r,left:i,width:a}),l===void 0||o<=l.left)[`rtl`,`rtr`,`rbl`,`rbr`].forEach(e=>{c[e]=``});else{let e=l.line,t=l.wrapLine,a=l.left,u=l.element.dataset,d=a+l.width;a>i&&p(e,t,a-s,`rbr`),delete u.rbl,delete c.rtl,delete c.rtr,o>=d&&delete u.rbr,o>d&&(p(e,t,d,`rbl`),c.rtr=``),o<d&&p(n,r,o,`rtl`),i<a&&(c.rtl=``),c.rbl=``,c.rbr=``}},h=e.elements.get(u);if(h!==void 0){f&&m(h);return}d?.has(u)===!0?(h=d.get(u),d.delete(u)):h=U(`div`,{dataset:o?[t+`Range`,o]:t+`Range`},e.fragment),h.style.width=`${a}px`,h.style.transform=`translateX(${i}px) translateY(${l}px)`,f&&m(h),e.elements.set(u,h)}#wt(e,t,n){let{line:r,character:i}=q(t);if(!this.#Xt(r))return;let[a,o]=this.#Kt(r,i),s=`caret-`+r+`/`+o+`:`+i;if(e.elements.has(s))return;let c=U(`div`,{dataset:`caret`,style:{transform:`translateX(${a-1}px) translateY(${this.#Gt(r)+o*this.#t.lineHeight}px)`}},e.fragment);e.elements.set(s,c),n&&(c.style.scrollMargin=this.#ot(),this.#M=c)}#Tt(){let e=this.#re?.at(-1),t=this.#A,n=this.#L,r=this.#e.renderSelectionAction,i=()=>{this.#H?.cleanup(),this.#H=void 0};if(this.#e.enabledSelectionAction!==!0||r===void 0||e===void 0||K(e)||this.#X||t===void 0||n===void 0){i();return}let a=q(e);if(!this.#Xt(a.line)){i();return}if(this.#H===void 0){if(!this.#U)return;let a=()=>this.#re?.at(-1)??e,o=r({textDocument:n,get selection(){return a()},applyEdits:e=>this.applyEdits(e),getSelectionText:()=>this.#L?.getText(a())??``,replaceSelectionText:e=>{this.#Nt(e,[a()])},close:()=>{i(),this.#at()}});this.#H=new Ea(o,t,()=>this.#Tt()),this.#Ee().resetPlacement(eo)}let o=this.#t.lineHeight,s=e.direction===-1,c={placeAbove:s,anchor:a},l=s?{placeAbove:!1,anchor:e.end}:{placeAbove:!0,anchor:e.start},u=this.#H.height,d=e=>{let[t,n]=this.#Kt(e.anchor.line,e.anchor.character),r=this.#Gt(e.anchor.line)+n*o,i=e.placeAbove?r:r+o,a=e.placeAbove?i-u:i;return{top:a,bottom:a+u,left:t,anchorTop:i,rowTop:r}},f=d(c),p=n.lineCount,m=s?a.line<3:a.line>=p-3,h=this.#Xt(l.anchor.line)?d(l):void 0,g=this.#Ee(),_=g.getPlacementBounds(),v=h!==void 0&&g.choosePlacement({preferred:f,fallback:h,viewport:_,popoverHeight:u,atDocumentEdge:m,placementKey:eo})===`fallback`;h===void 0&&g.setPlacement(`preferred`,eo);let{placeAbove:y}=v?l:c,{left:b,anchorTop:x}=v&&h!==void 0?h:f,S=s?f.rowTop:h?.rowTop??-1/0,C=(s?h?.rowTop??1/0:f.rowTop)+(e.end.line>e.start.line&&e.end.character===0?0:o),w=_===void 0||C>_.top&&S<_.bottom;this.#H.reposition(b,x,this.#Ut(),y,w,_)}#Et(e){if(this.#V!==void 0){this.#V.setMode(e);return}this.#Dt(e)}#Dt(e){this.#V?.cleanup();let t=this.#L,n=this.#D?.shadowRoot?.querySelector(`pre`),r=this.#re;if(t===void 0||n==null)return;let i=``,a;if(r!==void 0&&r.length>0){let e=r.at(-1);if(K(e)){e=ji(t,e),this.#yt([...r.slice(0,-1),e]);let n=t.getText(e);n!==``&&!n.includes(`
|
|
521
|
+
`)&&(i=n,a=[t.offsetAt(e.start),t.offsetAt(e.end)])}}let o=([e,n],r)=>{let i=li(t,e,n);this.#yt([i]),this.#Se(q(i).line),this.#at(!0),this.#le=r},s=new Ta({textDocument:t,containerElement:n,defaultQuery:i,mode:e,initialMatch:a,scrollToMatch:o,applyReplace:e=>{if(e.length===0)return;let n=t.applyEdits(e.map(e=>({range:{start:t.positionAt(e.start),end:t.positionAt(e.end)},newText:e.text})),!0,this.#re);n!==void 0&&this.#zt(n,void 0,this.#Bt(n),{skipSearchRefresh:!0})},onUpdate:(e,n)=>{if(e.length===0){this.#ie=void 0,this.#yt(this.#re??[]);return}if(this.#ie=e,n?.syncSelection===!1){this.#yt(this.#re??[]);let n=this.#re?.at(-1);if(n!==void 0){let r=t.offsetAt(n.start),i=t.offsetAt(n.end);for(let t of e)if(t[0]===r&&t[1]===i)return t}return}let r=this.#re?.at(-1),i=0,a;r!==void 0&&(i=t.offsetAt(r.start));for(let t of e)if(t[0]>=i){a=t;break}return a===void 0?this.#yt(this.#re??[]):o(a,!0),a},onClose:()=>{this.#V=void 0,this.#le=!1,this.#ie=void 0,this.#yt(this.#re??[])}});this.#V=s,this.#le=!1}#Ot(){let e=this.#L,t=this.#re;return e===void 0||t===void 0?``:wi(e,t)}#kt(){let e=this.#L,t=this.#re;return e===void 0||t===void 0?[]:Ci(e,t)}#At(e,t,n){e!==null&&(e.setData(`text`,t),n.length>1&&e.setData(to,JSON.stringify(n)))}#jt(){let e=this.#L,t=this.#re;if(e===void 0||t===void 0||t.length===0)return``;if(t.some(e=>K(e))){let n=ki(e,t);return this.#Mt(n.edits,n.nextSelectionOffsets),n.text}let n=wi(e,t);return this.#Nt(``,void 0,!0),n}#Mt(e,t){let n=this.#L,r=this.#re;if(n===void 0||r===void 0||e.length===0)return;let i=n.applyResolvedEdits(e,!0,r,void 0,!0);if(i===void 0)return;let a=t.map(e=>{let t=n.positionAt(e);return{start:t,end:t,direction:0}});n.setLastUndoSelectionsAfter(a),this.#zt(i,a,this.#Bt(i))}#Nt(e,t=this.#re,n=!1,r=`selection`){if(t===void 0)return;let i=this.#L,a=t.at(-1);if(i===void 0||a===void 0)return;let{nextSelections:o,change:s}=Array.isArray(e)&&e.length===t.length?Qr(i,t,e,this.#I,n,r):Yr(i,t,{start:i.offsetAt(a.start),end:i.offsetAt(a.end),text:Array.isArray(e)?e.join(i.eol):e},this.#I,void 0,n);s!==void 0&&this.#zt(s,o,this.#Bt(s))}#Pt(e=!1){let t=this.#re,n=this.#L;if(t===void 0||n===void 0)return;let{nextSelections:r,change:i}=oi(n,t,e,this.#I,this.#t.tabSize);i!==void 0&&this.#zt(i,r,this.#Bt(i))}#Ft(){let e=this.#re,t=this.#L;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=ri(t,e,this.#Te?(e,t)=>{let n=this.#Jt(e);for(let e=0;e+1<n.length;e++){let r=n[e],i=n[e+1];if(t>=r&&t<=i)return r}return 0}:void 0,this.#I);r!==void 0&&this.#zt(r,n,this.#Bt(r))}#It(){let e=this.#re,t=this.#L;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=ii(t,e,this.#I);r!==void 0&&this.#zt(r,n,this.#Bt(r))}#Lt(){let e=this.#re,t=this.#L;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=ni(t,e,this.#I);r!==void 0&&this.#zt(r,n,this.#Bt(r))}#Rt(){let e=this.#re,t=this.#L;if(e===void 0||t===void 0)return;let{nextSelections:n,change:r}=ti(t,e,this.#I);r!==void 0&&this.#zt(r,n,this.#Bt(r))}#zt(e,t,n,r){let i=this.getFile(),a=this.#e.onChange;if(i!==void 0&&a!==void 0){let t=n??this.#I;a(i,t,{changes:e.changes,file:i,lineAnnotations:t})}if(e.lineDelta!==0||this.#Te)for(let t of this.#y.keys())t>=e.startLine&&this.#y.delete(t);if(this.#b.size>0){if(e.lineDelta===0&&(e.changedLineRanges.length===1||e.changedLineChanges?.every(([,,e])=>e===0)===!0))for(let[t,n]of e.changedLineRanges)for(let e=t;e<=n;e++)this.#b.delete(e);else for(let t of this.#b.keys())t>=e.startLine&&this.#b.delete(t)}this.#S=void 0;let o=this.#R,s;if(o!==void 0&&t!==void 0&&t.length>0){let n=t.at(-1),r=o.startingLine+o.totalLines;if(n.end.line>=r){let t=n.end.line-o.startingLine+1,i=this.#z===void 0||this.#z===1/0?1/0:this.#z*Qa;e.startLine<=r&&t<=i&&this.#be(n.end.line)?(n.end.line>r&&(s=!0),o={...o,totalLines:t},this.#R=o):s=!0}}if(this.#Ze(e,n,o,s),r?.skipSearchRefresh!==!0&&this.#V!==void 0&&this.#ie!==void 0&&this.#V.updateMatches({syncSelection:!1}),t!==void 0&&(this.#yt(t),r?.skipFocus!==!0)){let e=t.at(-1);if(e!==void 0&&this.#Se(q(e).line),this.#M!==void 0)requestAnimationFrame(()=>{this.#M?.scrollIntoView({block:`nearest`,inline:`nearest`})});else if(t.length>0){let e=q(t.at(-1));this.#st(e.line,e.character)}this.focus({preventScroll:!0})}}#Bt(e){if(this.#I!==void 0){let t=Cr(e,this.#I);if(t!==void 0)return this.#L?.setLastUndoLineAnnotations(this.#I,t),t}}#Vt(){let e=this.#k;if(e===void 0)return[];let t=[];for(let n of e.children){let e=n,r=e.dataset.lineType,i=G(e);if(i===void 0||r===void 0||!si(r))continue;let a=i-1,o=t.at(-1);o!==void 0&&a<=o[1]+1?o[1]=Math.max(o[1],a):t.push([a,a])}return t}#Ht(e){let t=this.#x.get(e);if(t!==void 0)return t??void 0;let n=this.#R;if(n!==void 0&&(e<n.startingLine||e>=n.startingLine+n.totalLines))return;let r=this.#k;if(r!==void 0){if(n!==void 0){let{startingLine:i}=n,{children:a}=r;for(let n=e-i;n<=a.length;n++){let r=a[n];if(r===void 0)break;let i=G(r),o=r.dataset.lineType;if(i!==void 0&&i===e+1&&o!==void 0&&si(o)){t=r;break}}}return t??=r.querySelector(`[data-line="${e+1}"]`+(this.#Ce===`unified`?`:not([data-line-type="change-deletion"])`:``)),t!==void 0&&this.#x.set(e,t),t??void 0}}#Ut(){if(this.#O===void 0)return 0;if(this.#_===void 0){let e=this.#k?.parentElement?.style.getPropertyValue(`--diffs-column-number-width`);this.#_=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseInt(e.slice(0,-2),10):this.#O.offsetWidth}return this.#_}#Wt(){if(this.#k===void 0)return 0;if(this.#v===void 0){let e=this.#k.parentElement?.style.getPropertyValue(`--diffs-column-content-width`);this.#v=e!==void 0&&e.length>2&&e.endsWith(`px`)?parseFloat(e.slice(0,-2)):this.#k.offsetWidth}return this.#v}#Gt(e){let t=this.#y.get(e);if(t!==void 0)return t;let n=this.#Ht(e);if(n===void 0)return-1;let r=n.offsetTop+this.#t.paddingTop;return r+=this.#He?.top??0,this.#y.set(e,r),r}#Kt(e,t){if(this.#S!==void 0&&this.#S[0]===e&&this.#S[1]===t)return[this.#S[2],this.#S[3]];let n=this.#L?.getLineText(e),r=this.#Ut()+this.#t.ch;if(n===void 0||n.length===0||t<=0)return[r+(this.#He?.left??0),0];let i=Ba(n,Math.min(t,n.length)),a=n.slice(0,i),o=Ha(a,this.#t.tabSize),s=0,c=0;if(s=o===-1?r+this.#t.measureTextWidth(a):r+o*this.#t.ch,this.#Te){let t=this.#Wt();if(2*this.#t.ch+this.#t.measureTextWidth(n)>t){let t=this.#qt(e);if(t==null)return[s+(this.#He?.left??0),0];for(let e=0;e+1<t.length;e++){let a=t[e];if(i<=t[e+1]){c=e;let t=n.slice(a,i),o=Ha(t,this.#t.tabSize);s=o===-1?r+this.#t.measureTextWidth(t):r+o*this.#t.ch;break}}}s+=this.#He?.left??0}return this.#S===void 0?this.#S=[e,t,s,c]:(this.#S[0]=e,this.#S[1]=t,this.#S[2]=s,this.#S[3]=c),[s,c]}#qt(e){let t=this.#b.get(e);if(t!==void 0)return t;this.#b.size>=$a&&this.#b.clear();let n=this.#L?.getLineText(e);if(n===void 0||n.length===0){let t=new Uint32Array([0]);return this.#b.set(e,t),t}let r=this.#k;if(r==null||!r.isConnected)return;let i=U(`div`,{style:{position:`absolute`,top:`0`,left:`0`,width:`100%`,boxSizing:`border-box`,visibility:`hidden`,pointerEvents:`none`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,font:`inherit`,paddingInline:`1ch`,tabSize:this.#t.tabSize.toString()},textContent:n},r),a=i.firstChild,o=document.createRange(),s=[];try{let t=i.getBoundingClientRect();if(t.width===0)return;let r=Va(n),c=t.left+this.#t.ch,l=r===void 0?n.length:r.length-1,u=e=>r===void 0?e:r[e],d=e=>(o.setStart(a,u(e)),o.setEnd(a,u(e+1)),o.getBoundingClientRect());s.push(0);let f=d(0).top,p=1;for(;p<l;){let e=p,t=l;for(;e<t;){let n=e+t>>1;d(n).top>f?t=n:e=n+1}if(e>=l)break;let{left:n,top:r}=d(e),i=ot()&&n-c>this.#t.ch/2;s.push(u(i?e-1:e)),f=r,p=e+1}let m=new Uint32Array(s.length+1);for(let e=0;e<s.length;e++)m[e]=s[e];return m[s.length]=n.length,this.#b.set(e,m),m}finally{i.remove()}}#Jt(e){let t=this.#qt(e);if(t!==void 0)return t;let n=this.#L?.getLineText(e)?.length??0;return Uint32Array.of(0,n)}#Yt({startContainer:e,endContainer:t}){let n=this.#k;return n!==void 0&&n.contains(e)&&n.contains(t)}#Xt(e){let t=this.#L?.lineCount??0;return e<0||e>=t?!1:this.#Ht(e)!==void 0}},ro=e(l(),1);function io(e){return e.replace(/^\uFEFF/,``).replace(/\r\n?/g,`
|
|
522
|
+
`)}function ao(e){return/^\s*$/.test(e)}function oo(e,t){let n=0;for(;n<e.length&&n<t&&e[n]===` `;)n++;return e.slice(n)}function so(e){let t=``;for(let n of e)n.type===`text`||n.type===`inlineCode`?t+=n.value:`children`in n?t+=so(n.children):n.type===`image`&&(t+=n.alt);return t}function co(){let e=new Map;return t=>{let n=t.toLowerCase().normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/&[a-z0-9#]+;/gi,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`section`,r=e.get(n)??0;return e.set(n,r+1),r===0?n:`${n}-${r+1}`}}function lo(e){let t=e.trim().replace(/[\u0000-\u001F\u007F\s]+/g,``);return t?/^(#|\/|\.\/|\.\.\/)/.test(t)||/^(https?:|mailto:|tel:)/i.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?``:t:``}function uo(e){return e.trim().toLowerCase()}function fo(e){return uo(e).replace(/[^a-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``)}function po(e,t={}){let n=Mo(X(e,t));for(let e of t.extensions??[])n=e.transformInline?.(n,{options:t})??n;return n}var mo=32,ho=16;function X(e,t,n={scans:Math.max(e.length*ho,1024),depth:0}){if(n.depth>=mo)return e?[{type:`text`,value:e}]:[];n.depth++;let r=[],i=0,a=``,o=()=>{a&&=(r.push({type:`text`,value:a}),``)};for(;i<e.length;){let s=e[i],c=e[i+1];if(s===`\\`){if(c===`
|
|
523
|
+
`){o(),r.push({type:`break`}),i+=2;continue}if(c&&/[\\`*_[\]{}()#+\-.!|~<>]/.test(c)){a+=c,i+=2;continue}}if(s==="`"){let t=xo(e,i,"`"),s=So(e,i+t,"`",t,n);if(s!==-1){o(),r.push({type:`inlineCode`,value:e.slice(i+t,s).replace(/\s+/g,` `).trim()}),i=s+t;continue}a+=e.slice(i,i+t),i+=t;continue}if(s===`!`&&c===`[`){let a=_o(e,i+1,t,n);if(a){o(),r.push({type:`image`,src:lo(a.href),alt:jo(a.label,n),...a.title?{title:a.title}:{}}),i=a.end;continue}}if(s===`[`){let a=go(e,i,t,n);if(a){o(),r.push(a.node),i=a.end;continue}let s=_o(e,i,t,n);if(s){let e=lo(s.href);o(),e?r.push({type:`link`,href:e,...s.title?{title:s.title}:{},children:X(s.label,t,n)}):r.push(...X(s.label,t,n)),i=s.end;continue}}if(s===`*`&&c===`*`&&e[i+2]===`*`){let a=Co(e,i+3,`***`,n);if(a!==-1){o(),r.push({type:`emphasis`,children:X(e.slice(i+1,a+2),t,n)}),i=a+3;continue}}if(s===`*`&&c===`*`||s===`_`&&c===`_`){let l=s===`_`&&!Do(e,i,2,!0)?-1:Co(e,i+2,s+s,n);if(l!==-1){o(),r.push({type:`strong`,children:X(e.slice(i+2,l),t,n)}),i=l+2;continue}a+=s+c,i+=2;continue}if(s===`~`&&c===`~`&&e[i+2]===`~`){let t=xo(e,i,`~`);a+=e.slice(i,i+t),i+=t;continue}if(s===`~`&&c===`~`){let s=Co(e,i+2,`~~`,n);if(s!==-1){o(),r.push({type:`strike`,children:X(e.slice(i+2,s),t,n)}),i=s+2;continue}a+=`~~`,i+=2;continue}if(s===`~`){let a=wo(e,i+1,n);if(a!==-1){o(),r.push({type:`strike`,children:X(e.slice(i+1,a),t,n)}),i=a+1;continue}}if(s===`*`||s===`_`){let a=s===`_`&&!Do(e,i,1,!0)?-1:Co(e,i+1,s,n);if(a!==-1){o(),r.push({type:`emphasis`,children:X(e.slice(i+1,a),t,n)}),i=a+1;continue}}if(s===`<`&&t.allowHtml){let t=To(e,i+1,`>`,n);if(t!==-1&&vo(e.slice(i,t+1))){o(),r.push({type:`inlineHtml`,value:e.slice(i,t+1)}),i=t+1;continue}}a+=s,i++}return o(),n.depth--,r}function go(e,t,n,r){if(e[t+1]!==`^`)return;let i=To(e,t+2,`]`,r);if(i===-1)return;let a=uo(e.slice(t+2,i)),o=n.footnotes?.[a];if(!o||!n.footnoteOrder)return;let s=n.footnoteOrder.indexOf(a);s===-1&&(n.footnoteOrder.push(a),s=n.footnoteOrder.length-1);let c=(n.footnoteCounts?.[a]??0)+1;return n.footnoteCounts&&(n.footnoteCounts[a]=c),{node:{type:`footnoteReference`,id:o.id??(fo(o.label)||`footnote`),number:s+1,...c>1?{referenceIndex:c}:{}},end:i+1}}function _o(e,t,n,r){let i=bo(e,t,`[`,`]`,r);if(i===-1)return;let a=e.slice(t+1,i);if(e[i+1]===`(`){let t=bo(e,i+1,`(`,`)`,r);if(t===-1)return;let n=yo(e.slice(i+2,t).trim());return n?{label:a,href:n.href,...n.title?{title:n.title}:{},end:t+1}:void 0}if(e[i+1]===`[`){let t=bo(e,i+1,`[`,`]`,r);if(t===-1)return;let o=e.slice(i+2,t),s=n.references?.[uo(o||a)];return s?{label:a,href:s.href,...s.title?{title:s.title}:{},end:t+1}:void 0}let o=n.references?.[uo(a)];if(o)return{label:a,href:o.href,...o.title?{title:o.title}:{},end:i+1}}function vo(e){return/^<!--(?:[\s\S]*--|-?)>$/.test(e)||/^<\?[\s\S]*\?>$/.test(e)||/^<![A-Z][\s\S]*>$/.test(e)||/^<!\[CDATA\[[\s\S]*\]\]>$/.test(e)||/^<\/[A-Za-z][\w:-]*\s*>$/.test(e)?!0:/^<[A-Za-z][\w:-]*(?:\s+[A-Za-z_:][\w:.-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>$/.test(e)}function yo(e){let t=e.match(/^(\S+)(?:\s+["']([^"']*)["'])?$/);return t?{href:t[1].replace(/^<|>$/g,``),...t[2]?{title:t[2]}:{}}:{href:e}}function bo(e,t,n,r,i){let a=0;for(let o=t;o<e.length;o++){if(!Eo(i))return-1;if(e[o-1]!==`\\`&&(e[o]===n&&a++,e[o]===r&&(a--,a===0)))return o}return-1}function xo(e,t,n,r){let i=0;for(;e[t+i]===n&&!(r&&!Eo(r));)i++;return i}function So(e,t,n,r,i){for(let a=t;a<e.length;a++){if(!Eo(i))return-1;if(e[a]===n&&xo(e,a,n,i)>=r)return a}return-1}function Co(e,t,n,r){for(let i=t;i<e.length;i++){if(!Eo(r))return-1;if(e[i-1]!==`\\`&&(n!==`~~`||e[i-1]!==`~`&&e[i+2]!==`~`)&&!(n[0]===`_`&&!Do(e,i,n.length,!1))&&e.startsWith(n,i))return i}return-1}function wo(e,t,n){if(Ao(e[t]??``)||/\d/.test(e[t]??``))return-1;for(let r=t;r<e.length;r++){if(!Eo(n))return-1;if(e[r-1]!==`\\`&&e[r]===`~`&&e[r-1]!==`~`&&e[r+1]!==`~`)return Ao(e[r-1]??``)?-1:r}return-1}function To(e,t,n,r){for(let i=t;i<e.length;i++){if(!Eo(r))return-1;if(e[i]===n)return i}return-1}function Eo(e){return e.scans<=0?!1:(e.scans--,!0)}function Do(e,t,n,r){let i=e[t-1],a=e[t+n],o=!Oo(a)&&(!ko(a)||Oo(i)||ko(i)),s=!Oo(i)&&(!ko(i)||Oo(a)||ko(a));return r?o&&(!s||ko(i)):s&&(!o||ko(a))}function Oo(e){return e===void 0||/\s/.test(e)}function ko(e){return e!==void 0&&/[^\p{L}\p{N}\s]/u.test(e)}function Ao(e){return/\s/.test(e)}function jo(e,t){return X(e,{},t).map(e=>e.type===`text`||e.type===`inlineCode`?e.value:``).join(``)}function Mo(e){let t=[];for(let n of e){let e=t.at(-1);e?.type===`text`&&n.type===`text`?e.value+=n.value:t.push(n)}return t}var No=64;function Po(e,t={}){let n=io(e),r=t.frontmatter!==!1,i=n.split(`
|
|
524
|
+
`),a;if(r&&i[0]===`---`){let e=i.findIndex((e,t)=>t>0&&e===`---`);e>0&&(a=i.slice(1,e).join(`
|
|
525
|
+
`),i=i.slice(e+1))}let o=Lo(i);i=o.lines;let s=[],c=Object.create(null),l=Object.keys(o.references).length>0,u=Object.keys(o.footnotes).length>0,d=l||u?{...t,...l?{references:o.references}:{},...u?{footnotes:o.footnotes,footnoteOrder:s,footnoteCounts:c}:{}}:t,f=new Fo(i,d,co()).parse();u&&s.length>0&&f.push(Ro(o.footnotes,s,d));let p=a===void 0?{type:`root`,children:f}:{type:`root`,frontmatter:a,children:f};for(let e of d.extensions??[])p=e.transformDocument?.(p,{options:d})??p;return p}var Fo=class e{lines;options;slugger;budget;index=0;constructor(e,t,n,r={depth:0}){this.lines=e,this.options=t,this.slugger=n,this.budget=r}parse(){if(this.budget.depth>=No){let e=this.lines.slice(this.index).join(`
|
|
526
|
+
`);return this.index=this.lines.length,e?[{type:`paragraph`,children:po(e,this.options)}]:[]}this.budget.depth++;let e=[];for(;this.index<this.lines.length;){if(ao(this.current())){this.index++;continue}let t=this.parseExtensionBlock();if(t){e.push(t);continue}let n=this.parseFence()??this.parseHeading()??this.parseThematicBreak()??this.parseBlockquote()??this.parseList()??this.parseTable()??this.parseHtmlBlock()??this.parseParagraph();e.push(n)}return this.budget.depth--,e}parseExtensionBlock(){for(let t of this.options.extensions??[]){let n=0,r=t.parseBlock?.({lines:this.lines,index:this.index,options:this.options,parseInline:e=>po(e,this.options),parseBlocks:t=>new e(io(t).split(`
|
|
527
|
+
`),this.options,this.slugger,this.budget).parse(),consume:e=>{n=e}});if(r)return this.index+=Math.max(n,1),r}}parseFence(){let e=this.current().match(/^ {0,3}(`{3,}|~{3,})(.*)$/);if(!e)return;let t=e[1],n=t[0],r=t.length,i=e[2].trim(),a=[];for(this.index++;this.index<this.lines.length;){let e=this.current(),t=e.match(/^ {0,3}(`{3,}|~{3,})\s*$/);if(t&&t[1][0]===n&&t[1].length>=r){this.index++;break}a.push(e),this.index++}return{type:`code`,value:a.join(`
|
|
528
|
+
`),...Io(i)}}parseHeading(){let e=this.current().match(/^ {0,3}(#{1,6})(?:[ \t]+(.*)|[ \t]*)$/);if(!e)return;let t=e[1].length,n=e[2]??``,r=po((/^#+[ \t]*$/.test(n)?``:n.replace(/[ \t]+#+[ \t]*$/,``)).trim(),this.options),i=this.createHeadingId(r);return this.index++,i?{type:`heading`,depth:t,id:i,children:r}:{type:`heading`,depth:t,children:r}}parseThematicBreak(){if(/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(this.current()))return this.index++,{type:`thematicBreak`}}parseBlockquote(){if(!/^ {0,3}>\s?/.test(this.current()))return;let t=[];for(;this.index<this.lines.length;){let e=this.current();if(ao(e)){t.push(``),this.index++;continue}let n=e.match(/^ {0,3}>\s?(.*)$/);if(!n)break;t.push(n[1]),this.index++}return{type:`blockquote`,children:new e(t,this.options,this.slugger,this.budget).parse()}}parseList(){let t=Bo(this.current());if(!t)return;let n=[],r=t.ordered,i=t.indent,a=r?t.number:void 0,o=!1;for(;this.index<this.lines.length;){let r=Bo(this.current());if(!r||!Vo(r,t)||r.indent!==i)break;let a=r.content,s=a.match(/^\[([ xX])\]\s+(.*)$/),c=s?s[1].toLowerCase()===`x`:void 0;s&&(a=s[2]);let l=[a];for(this.index++;this.index<this.lines.length;){let e=this.current(),n=Bo(e);if(n&&n.indent===i)break;if(ao(e)){let e=this.index;for(;e<this.lines.length&&ao(this.lines[e]);)e++;let n=this.lines[e];if(n===void 0)break;let a=Bo(n);if(a?.indent===i){if(!Vo(a,t))break;o=!0,this.index=e;break}if(Ho(n)<r.contentIndent)break;o=!0,l.push(``),this.index=e;continue}if(Ho(e)>=r.contentIndent){l.push(oo(e,r.contentIndent)),this.index++;continue}if(Uo(e,this.next()))break;l.push(e.trimStart()),this.index++}let u={type:`listItem`,children:new e(l,this.options,this.slugger,this.budget).parse()};c!==void 0&&(u.checked=c),n.push(u)}return{type:`list`,ordered:r,...r&&a!==void 0?{start:a}:{},...o&&{loose:!0},items:n}}parseTable(){let e=this.current(),t=this.next();if(!t||!Wo(e,t))return;let n=Go(e),r=Go(t).map(Ko),i=n.length,a=[];for(this.index+=2;this.index<this.lines.length;){let e=this.current();if(ao(e)||Uo(e,this.next()))break;let t=Go(e);a.push(Array.from({length:i},(e,n)=>qo(t[n]??``,this.options))),this.index++}return{type:`table`,align:r,header:n.map(e=>qo(e,this.options)),rows:a}}parseHtmlBlock(){if(!this.options.allowHtml||!/^ {0,3}<([A-Za-z][\w:-]*|!--|\/[A-Za-z])/.test(this.current()))return;let e=[];if(/^ {0,3}<!--/.test(this.current())){for(;this.index<this.lines.length;){let t=this.current();if(e.push(t),this.index++,t.includes(`-->`))break}return{type:`html`,value:e.join(`
|
|
529
|
+
`)}}for(;this.index<this.lines.length&&!ao(this.current());)e.push(this.current()),this.index++;return{type:`html`,value:e.join(`
|
|
530
|
+
`)}}parseParagraph(){let e=[];for(;this.index<this.lines.length;){let t=this.current();if(ao(t)||e.length>0&&Uo(t,this.next()))break;e.push(t.trim()),this.index++}return{type:`paragraph`,children:po(e.join(`
|
|
531
|
+
`),this.options)}}createHeadingId(e){if(this.options.headingIds===!1)return;let t=so(e);return typeof this.options.headingIds==`function`?this.options.headingIds(t,this.index):this.slugger(t)}current(){return this.lines[this.index]??``}next(){return this.lines[this.index+1]}};function Io(e){if(!e)return{};let t=e.match(/^([A-Za-z0-9_+.#-]+)/)?.[1],n=t?e.slice(t.length).trim():e,r=n.match(/(?:^|\s)(?:title|file)=(?:"([^"]+)"|'([^']+)'|([^\s}]+))/),i=n.match(/(?:^|\s)framework=(?:"([^"]+)"|'([^']+)'|([^\s}]+))/),a=n.match(/\{([^}]+)\}|(?:^|\s)lines=([^\s]+)/),o=zo(a?.[1]??a?.[2]??``),s=r?r[1]??r[2]??r[3]:void 0,c=i?i[1]??i[2]??i[3]:void 0;return{...t?{lang:t}:{},...n?{meta:n}:{},...s?{title:s,file:s}:{},...c?{framework:c.toLowerCase()}:{},...o.length?{highlightLines:o}:{}}}function Lo(e){let t=Object.create(null),n=Object.create(null),r=new Map,i=[],a,o=0,s=0;for(;s<e.length;){let c=e[s],l=c.match(/^ {0,3}(`{3,}|~{3,})/);if(l){let e=l[1][0];a?e===a&&l[1].length>=o&&(a=void 0,o=0):(a=e,o=l[1].length),i.push(c),s++;continue}if(!a){let i=c.match(/^ {0,3}\[\^([^\]\n]+)\]:[ \t]*(.*)$/);if(i){let t=i[1],a=[i[2]??``];for(s++;s<e.length;){let t=e[s];if(!/^(?: {4,}|\t)/.test(t))break;a.push(t.replace(/^(?: {4}|\t)/,``)),s++}let o=uo(t);if(!n[o]){let e=fo(t)||`footnote`,i=(r.get(e)??0)+1;r.set(e,i),n[o]={label:t,content:a.join(`
|
|
532
|
+
`),id:i===1?e:`${e}-${i}`}}continue}let a=c.match(/^ {0,3}\[([^\]\n]+)\]:[ \t]*(\S+)(?:[ \t]+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?[ \t]*$/);if(a){let e=a[3]??a[4]??a[5];t[uo(a[1])]={href:a[2].replace(/^<|>$/g,``),...e===void 0?{}:{title:e}},s++;continue}}i.push(c),s++}return{lines:i,references:t,footnotes:n}}function Ro(e,t,n){let r=[];for(let i=0;i<t.length;i++){let a=e[t[i]];a&&r.push({id:a.id??(fo(a.label)||`footnote`),number:i+1,children:new Fo(io(a.content).split(`
|
|
533
|
+
`),n,co()).parse()})}for(let e of r){let r=n.footnoteCounts?.[t[e.number-1]]??1;r>1&&(e.referenceCount=r)}return{type:`footnotes`,items:r}}function zo(e){let t=new Set;for(let n of e.split(`,`)){let e=n.trim().match(/^(\d+)(?:-(\d+))?$/);if(!e)continue;let r=Number(e[1]),i=Number(e[2]??e[1]);for(let e=r;e<=i&&e<r+1e3;e++)t.add(e)}return[...t].sort((e,t)=>e-t)}function Bo(e){let t=e.match(/^(\s{0,8})([-+*]|\d{1,9}[.)])(?:([ \t]+)(.*))?$/);if(!t)return;let n=t[2],r=/\d/.test(n[0]);return{ordered:r,...r?{number:Number.parseInt(n,10)}:{},indent:t[1].length,marker:r?n.at(-1):n,contentIndent:t[1].length+n.length+(t[3]?.length??1),content:t[4]??``}}function Vo(e,t){return e.ordered===t.ordered&&e.marker===t.marker}function Ho(e){return e.match(/^ */)?.[0].length??0}function Uo(e,t){let n=Bo(e);return/^ {0,3}(`{3,}|~{3,})/.test(e)||/^ {0,3}#{1,6}(?:\s+|$)/.test(e)||/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(e)||/^ {0,3}>\s?/.test(e)||n!==void 0&&(!n.ordered||n.number===1)||!!t&&Wo(e,t)}function Wo(e,t){if(!e.includes(`|`))return!1;let n=Go(t);return n.length===Go(e).length&&n.every(e=>/^:?-+:?$/.test(e.trim()))}function Go(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e++){let i=t[e];if(i===`\\`&&t[e+1]===`|`){r+=`|`,e++;continue}if(i===`|`){n.push(r.trim()),r=``;continue}r+=i}return n.push(r.trim()),n}function Ko(e){let t=e.trim();if(t.startsWith(`:`)&&t.endsWith(`:`))return`center`;if(t.endsWith(`:`))return`right`;if(t.startsWith(`:`))return`left`}function qo(e,t){return{type:`tableCell`,children:po(e,t)}}function Jo({children:e,...t}){return(0,V.createElement)(V.Fragment,null,Yo(e,t))}function Yo(e,t={}){return(typeof e==`string`?Po(e,t):e).children.map((e,n)=>Xo(e,t,`b:${n}`))}function Xo(e,t={},n){switch(e.type){case`heading`:return Q(t,`h${e.depth}`,{key:n,...e.id?{id:e.id}:{},...e.framework?{"data-framework":e.framework}:{}},Z(e.children,t),ss(e.id,t));case`paragraph`:return Q(t,`p`,{key:n},Z(e.children,t));case`code`:return Qo(e,t,n);case`list`:return Q(t,e.ordered?`ol`:`ul`,{key:n,...e.ordered&&e.start&&e.start!==1?{start:e.start}:{}},e.items.map((n,r)=>Q(t,`li`,{key:r},$o(n.children,n.checked,e.loose,t,`${r}`))));case`blockquote`:return Q(t,`blockquote`,{key:n},e.children.map((e,r)=>Xo(e,t,`${n}:${r}`)));case`table`:return Q(t,`table`,{key:n},Q(t,`thead`,null,Q(t,`tr`,null,e.header.map((n,r)=>ts(`th`,n,e.align[r],t,r)))),e.rows.length?Q(t,`tbody`,null,e.rows.map((n,r)=>Q(t,`tr`,{key:r},n.map((n,r)=>ts(`td`,n,e.align[r],t,r))))):null);case`footnotes`:return ns(e.items,t,n);case`thematicBreak`:return Q(t,`hr`,{key:n});case`html`:return t.allowHtml?Q(t,`div`,{key:n,dangerouslySetInnerHTML:{__html:e.value}}):Q(t,`p`,{key:n},e.value);case`callout`:return Q(t,`div`,{key:n,className:`markdown-alert markdown-alert-${e.kind.toLowerCase()}`},Q(t,`p`,{className:`markdown-alert-title`},e.title),Q(t,`div`,{className:`markdown-alert-content`},e.children.map((e,r)=>Xo(e,t,`${n}:${r}`))));case`component`:return os(e,t,n)}}function Zo(e,t={},n){switch(e.type){case`text`:return e.value;case`inlineCode`:return Q(t,`code`,{key:n},e.value);case`strong`:return Q(t,`strong`,{key:n},Z(e.children,t));case`emphasis`:return Q(t,`em`,{key:n},Z(e.children,t));case`strike`:return Q(t,`del`,{key:n},Z(e.children,t));case`footnoteReference`:return Q(t,`sup`,{key:n},Q(t,`a`,{id:`user-content-fnref-${as(e)}`,"data-footnote-ref":``,"aria-describedby":`footnote-label`,href:`#user-content-fn-${e.id}`},e.number));case`link`:return Q(t,`a`,{key:n,href:e.href,...e.title?{title:e.title}:{}},Z(e.children,t));case`image`:return Q(t,`img`,{key:n,src:e.src,alt:e.alt,...e.title?{title:e.title}:{}});case`break`:return Q(t,`br`,{key:n});case`inlineHtml`:return t.allowHtml?Q(t,`span`,{key:n,dangerouslySetInnerHTML:{__html:e.value}}):e.value}}function Z(e,t){return e.map((e,n)=>Zo(e,t,`i:${n}`))}function Qo(e,t,n){let r=e.lang??`plaintext`,i=t.highlighter,a={className:`language-${r}`},o=i?void 0:e.value,s=i?{dangerouslySetInnerHTML:{__html:i(e.value,r,{...e.highlightLines&&{highlightLines:e.highlightLines},...t.codeLineNumbers!==void 0&&{lineNumbers:t.codeLineNumbers}})}}:void 0,c=Q(t,`pre`,{className:`tm-code${t.codeLineNumbers?` tm-code--line-numbers`:``}`,"data-lang":r,...e.title?{"data-code-title":e.title}:{},...e.file?{"data-filename":e.file}:{},...e.framework?{"data-framework":e.framework}:{}},Q(t,`code`,{...a,...s},o));return e.title?Q(t,`figure`,{key:n,className:`tm-code-frame`,"data-lang":r},Q(t,`figcaption`,null,e.title),c):Q(t,V.Fragment,{key:n},c)}function $o(e,t,n,r,i){let[a,...o]=e,s=t===void 0?[]:[Q(r,`input`,{key:`${i}:checkbox`,type:`checkbox`,disabled:!0,checked:t,readOnly:!0}),` `];if(a?.type===`paragraph`){let e=[...s,...Z(a.children,r)];return[...n?[Q(r,`p`,{key:`${i}:paragraph`},e)]:e,...o.flatMap((e,t)=>es(e,n,r,`${i}:${t+1}`))]}return[...s,...e.flatMap((e,t)=>es(e,n,r,`${i}:${t}`))]}function es(e,t,n,r){return!t&&e.type===`paragraph`?Z(e.children,n):[Xo(e,n,r)]}function ts(e,t,n,r,i){return Q(r,e,{key:i,...n?{style:{textAlign:n}}:{}},Z(t.children,r))}function ns(e,t,n){return Q(t,`section`,{key:n,"data-footnotes":``,className:`footnotes`},Q(t,`h2`,{id:`footnote-label`,className:`sr-only`},`Footnotes`,ss(`footnote-label`,t)),Q(t,`ol`,null,e.map(e=>Q(t,`li`,{key:e.id,id:`user-content-fn-${e.id}`},rs(e,t)))))}function rs(e,t){let n=e.children.length-1,r=is(e,t);return n<0?[Q(t,`p`,{key:`backref-wrapper`},r.slice(1))]:e.children.map((e,i)=>i===n&&e.type===`paragraph`?Q(t,`p`,{key:i},Z(e.children,t),r):Xo(e,t,`${i}`))}function is(e,t){let n=[];for(let r=1;r<=(e.referenceCount??1);r++){let i=r===1?e.id:`${e.id}-${r}`,a=r===1?`${e.number}`:`${e.number}-${r}`;n.push(` `,Q(t,`a`,{key:r,"data-footnote-backref":``,"aria-label":`Back to reference ${a}`,className:`data-footnote-backref`,href:`#user-content-fnref-${i}`},`↩`))}return n}function as(e){return e.referenceIndex&&e.referenceIndex>1?`${e.id}-${e.referenceIndex}`:e.id}function Q(e,t,n,...r){let i=typeof t==`string`?e.components?.[t]??t:t;return(0,V.createElement)(i,n,...r)}function os(e,t,n){let r=e.tagName??`md-comment-component`,i={...e.properties??{}};return e.tagName||(i[`data-component`]=e.name,i[`data-attributes`]||=JSON.stringify(e.attributes)),Q(t,r,{key:n,...i},e.children.map((e,r)=>Xo(e,t,`${n}:${r}`)))}function ss(e,t){if(!e||!t.headingAnchors)return null;let n=typeof t.headingAnchors==`object`?t.headingAnchors:{};return Q(t,`a`,{href:`#${e}`,"aria-hidden":n.ariaHidden??!0,className:n.className??`anchor-heading anchor-heading-link`,tabIndex:n.tabIndex??-1},n.content??`#`)}function $(e){return e}function cs({fallbackLanguage:e=`plaintext`,languages:t}){let n=new Map,r=new Map;for(let e of t){let t=fs(e.name);n.set(t,e),r.set(t,t);for(let n of e.aliases||[])r.set(fs(n),t)}let i=fs(e);function a(e){return r.get(fs(e||i))||i}function o(e,t,i=0){let s=n.get(a(t));return!s||i>24?[]:ps(e.length,s.tokenize(e,{hasLanguage(e){let t=r.get(fs(e));return!!(t&&n.has(t))},tokenize(e,t){return o(e,t,i+1)}}))}function s(e,t={}){let n=a(t.lang),r=o(e,n);return{code:e,lang:n,tokens:r.length?ms(e,r):[{value:e}]}}function c(e,t={}){let n=s(e,t),r=us(ls(n.tokens,t));return{...n,html:`<pre class="th-code th-code--${Ts(n.lang)}${t.lineNumbers?` th-code--line-numbers`:``}" data-language="${Ts(n.lang)}"><code>${r}</code></pre>`}}function l({code:e,decorations:t,lang:n,lineNumbers:r,title:i}){let a=e.trimEnd(),o=c(a,{decorations:t,lang:n,lineNumbers:r});return{copyText:a,htmlMarkup:o.html,lang:o.lang,title:i,tokens:o.tokens}}return{highlight:c,highlightToHtml(e,t={}){return c(e,t).html},listLanguages(){return[...n.keys()]},normalizeLanguage:a,renderCodeBlockData:l,tokenize:s}}function ls(e,t={}){let n=e.map(e=>e.value).join(``),r=t.decorations||[],i=r.filter(gs),a=r.filter(_s);if(!(t.lineNumbers||a.length))return hs(e,0,n.length,i);let o=[],s=vs(n);for(let t=0;t<s.length;t++){let r=t+1,c=s[t],l=s[t+1]??n.length,u=l>c&&n[l-1]===`
|
|
534
|
+
`,d=u?l-1:l,f=a.filter(e=>ys(e.lines,r));o.push({type:`element`,classNames:[`th-line`,...f.flatMap(e=>Cs(e.className))],data:{...bs(f),line:String(r)},children:hs(e,c,d,i)}),u&&o.push({type:`text`,value:`
|
|
535
|
+
`})}return o}function us(e){let t=``;for(let n of e){if(n.type===`text`){t+=ds(n.value);continue}let e=n.classNames.map(Ts).join(` `),r=Object.entries(n.data||{}).map(([e,t])=>` data-${Ts(ws(e))}="${Ts(t)}"`).join(``);t+=`<span${e?` class="${e}"`:``}${r}>${us(n.children)}</span>`}return t}function ds(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}function fs(e){return e.trim().toLowerCase()}function ps(e,t){let n=[],r=t.map(t=>({...t,start:Math.max(0,Math.min(e,t.start)),end:Math.max(0,Math.min(e,t.end))})).sort((e,t)=>e.start-t.start),i=0;for(let e of r)e.start>=e.end||e.start<i||(n.push(e),i=e.end);return n}function ms(e,t){let n=[],r=0;for(let i of t)i.start>r&&n.push({value:e.slice(r,i.start)}),n.push({className:i.className,value:e.slice(i.start,i.end)}),r=i.end;return r<e.length&&n.push({value:e.slice(r)}),n}function hs(e,t,n,r){let i=[],a=0;for(let o of e){let e=a+o.value.length,s=Math.max(t,a),c=Math.min(n,e);if(s<c){let e=new Set([s,c]);for(let t of r){let[n,r]=t.range;r<=s||n>=c||(e.add(Math.max(s,n)),e.add(Math.min(c,r)))}let t=[...e].sort((e,t)=>e-t);for(let e=0;e<t.length-1;e++){let n=t[e],s=t[e+1],c={type:`text`,value:o.value.slice(n-a,s-a)};o.className&&(c={type:`element`,classNames:[`th-token`,`th-${o.className}`],children:[c]});let l=r.filter(e=>e.range[0]<=n&&e.range[1]>=s);for(let e of l)c={type:`element`,classNames:[`th-decoration`,...Cs(e.className)],data:xs(e.data),children:[c]};i.push(c)}}if(a=e,a>=n)break}return i}function gs(e){return`range`in e}function _s(e){return`lines`in e}function vs(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
536
|
+
`&&n+1<e.length&&t.push(n+1);return t}function ys(e,t){return typeof e==`number`?e===t:t>=e[0]&&t<=e[1]}function bs(e){let t={};for(let n of e)Object.assign(t,xs(n.data));return t}function xs(e){if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>[Ss(e),String(t)]))}function Ss(e){return ws(e).replace(/[^a-z0-9_.:-]/gi,`-`)}function Cs(e){return e?.trim().split(/\s+/).filter(Boolean)||[]}function ws(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Ts(e){return ds(e)}function Es(e){return t=>Ds(t,e)}function Ds(e,t,n=[]){let r=[...n],i=new Uint8Array(e.length);for(let e of n)i.fill(1,e.start,e.end);for(let n of t){if(`collect`in n){for(let t of n.collect(e))ks(r,i,t);continue}let t=As(n.regex),a;for(;a=t.exec(e);){let e=n.group?a[n.group]:a[0];if(!e){a[0].length||t.lastIndex++;continue}let o=n.group?a[0].indexOf(e):0,s=a.index+o;ks(r,i,{start:s,end:s+e.length,className:typeof n.className==`function`?n.className(a):n.className})}}return r}function Os(e,t){return e.map(e=>({...e,start:e.start+t,end:e.end+t}))}function ks(e,t,n){return n.start>=n.end||n.start<0||n.end>t.length||js(t,n.start,n.end)?!1:(e.push(n),t.fill(1,n.start,n.end),!0)}function As(e){return new RegExp(e.source,e.flags.includes(`g`)?e.flags:`${e.flags}g`)}function js(e,t,n){for(let r=t;r<n;r++)if(e[r])return!0;return!1}var Ms=$({name:`css`,tokenize:Es([{className:e=>e[0].startsWith(`/*`)?`comment`:`string`,regex:/\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g},{className:`variable`,regex:/--[A-Za-z0-9_-]+/g},{className:`selector`,regex:/(^|[}\n])\s*([^@{}\n][^{}\n]*)(?=\s*\{)/g,group:2},{className:`property`,regex:/(?:^|[;{]\s*)([A-Za-z-]+)(?=\s*:)/gm,group:1},{className:`function`,regex:/\b[A-Za-z-]+(?=\()/g},{className:`number`,regex:/\b\d+(?:\.\d+)?(?:px|rem|em|%|s|ms|vh|vw|deg)?\b/g}])}),Ns=$({name:`dockerfile`,aliases:[`docker`],tokenize:Es([{className:`comment`,regex:/^\s*#.*$/gm},{className:`keyword`,regex:/^\s*(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|ONBUILD|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)\b/gim},{className:`string`,regex:/\b[A-Za-z0-9._/-]+:[A-Za-z0-9._-]+\b/g},{className:`variable`,regex:/\$\{?[A-Za-z_][A-Za-z0-9_]*\}?/g},{className:`command`,regex:/\b(?:bun|npm|npx|pnpm|yarn|node|apt|apt-get|apk)\b/g}])});function Ps(e,t,n=`html`){let r=[],i=[],a=0;for(;a<e.length;){if(e.startsWith(`<!--`,a)){let t=e.indexOf(`-->`,a+4),n=t<0?e.length:t+3;r.push({start:a,end:n,className:`comment`}),a=n;continue}if(n===`ejs`&&e.startsWith(`<%`,a)){let t=e.indexOf(`%>`,a+2),n=t<0?e.length:t;i.push({start:a+2,end:n,lang:`js`}),a=t<0?e.length:t+2;continue}if(e[a]!==`<`){a++;continue}let t=e[a+1]===`/`,o=a+(t?2:1),s=/^[A-Za-z][\w:.-]*/.exec(e.slice(o));if(!s){a++;continue}let c=zs(e,o+s[0].length);if(c<0){a++;continue}let l=s[0].toLowerCase();if(r.push({start:o,end:o+s[0].length,className:`tag`}),t||Fs(e,o+s[0].length,c,r),!t&&(l===`script`||l===`style`)){let t=`</${l}`,n=e.toLowerCase().indexOf(t,c+1);if(n>=0){let t=Is(l,e.slice(a,c+1));i.push({start:c+1,end:n,lang:t})}}a=c+1}n===`vue`&&Ls(e,`{{`,`}}`,`js`,i),n===`svelte`&&Rs(e,i);for(let n of i)n.start>=n.end||!t.hasLanguage(n.lang)||r.push(...Os(t.tokenize(e.slice(n.start,n.end),n.lang),n.start));return r}function Fs(e,t,n,r){let i=e.slice(t,n),a=/\s([:@A-Za-z_][\w:.-]*)(?=\s*(?:=|\/?>))/g,o;for(;o=a.exec(i);){let e=o[0].indexOf(o[1]),n=t+o.index+e;r.push({start:n,end:n+o[1].length,className:`attr`})}let s=t;for(;s<n;){let t=e[s];if(t!==`"`&&t!==`'`){s++;continue}let i=Bs(e,s,t,n);r.push({start:s,end:i,className:`string`}),s=i}}function Is(e,t){if(e===`style`)return`css`;let n=/\blang\s*=\s*["']?([\w-]+)/i.exec(t)?.[1];return n===`ts`||n===`typescript`?`ts`:`js`}function Ls(e,t,n,r,i){let a=0;for(;(a=e.indexOf(t,a))>=0;){let o=e.indexOf(n,a+t.length);if(o<0)return;i.push({start:a+t.length,end:o,lang:r}),a=o+n.length}}function Rs(e,t){let n=0;for(;n<e.length;){if(e[n]!==`{`||e[n+1]===`#`){n++;continue}let r=e.indexOf(`}`,n+1);if(r<0)return;t.push({start:n+1,end:r,lang:`js`}),n=r+1}}function zs(e,t){let n=t;for(;n<e.length;)if(e[n]===`"`||e[n]===`'`)n=Bs(e,n,e[n],e.length);else if(e[n]===`>`)return n;else n++;return-1}function Bs(e,t,n,r){let i=t+1;for(;i<r;)if(e[i]===`\\`)i+=2;else if(e[i]===n)return i+1;else i++;return r}var Vs=$({name:`html`,aliases:[`htm`,`xml`,`angular-html`],tokenize:(e,t)=>Ps(e,t)}),Hs=[{className:`function`,regex:/@[A-Za-z_$][\w$]*/g},{className:`keyword`,regex:RegExp(`\\b(?:abstract|as|asserts|async|await|break|case|catch|class|const|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|infer|instanceof|interface|is|keyof|let|module|namespace|new|of|override|package|private|protected|public|readonly|return|satisfies|set|static|super|switch|this|throw|try|type|typeof|using|var|while|with|yield)\\b`,`g`)},{className:`literal`,regex:/\b(?:false|null|true|undefined|NaN|Infinity)\b/g},{className:`number`,regex:/\b(?:0x[\da-f](?:_?[\da-f])*n?|0b[01](?:_?[01])*n?|0o[0-7](?:_?[0-7])*n?|\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:e[+-]?\d(?:_?\d)*)?n?)\b/gi},{className:`function`,regex:/\bfunction\s*\*?\s*([A-Za-z_$][\w$]*)/g,group:1},{className:`function`,regex:/(^|[^.A-Za-z0-9_$])([A-Za-z_$][\w$]*)\s*(?=\()/g,group:2},{className:`type`,regex:/\b(?:Array|Record|Promise|Readonly|Set|Map|WeakMap|WeakSet|string|number|boolean|bigint|symbol|object|unknown|never|void|any|[A-Z][A-Za-z0-9_$]*)\b/g},{className:`property`,regex:/(?:\.|\?\.)([A-Za-z_$][\w$]*)/g,group:1}];function Us(e,t=!1,n=!1){let r=Ws(e,t,n),i=t?Js(e,n):[];return Ds(e,Hs,[...r,...i])}function Ws(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i],o=e[i+1];if(a===`/`&&o===`/`){let t=nc(e,i+2);r.push({start:i,end:t,className:`comment`}),i=t;continue}if(a===`/`&&o===`*`){let t=e.indexOf(`*/`,i+2),n=t<0?e.length:t+2;r.push({start:i,end:n,className:`comment`}),i=n;continue}if(a===`'`||a===`"`){let t=tc(e,i,a);r.push({start:i,end:t,className:`string`}),i=t;continue}if(a==="`"){i=Gs(e,i,r,t,n);continue}if(a===`/`&&!(t&&e[i-1]===`<`)&&Qs(e,i)){let t=$s(e,i);if(t>i+1){r.push({start:i,end:t,className:`literal`}),i=t;continue}}i++}return r}function Gs(e,t,n,r,i){let a=t,o=t+1;for(;o<e.length;){if(e[o]===`\\`){o+=2;continue}if(e[o]==="`")return n.push({start:a,end:o+1,className:`string`}),o+1;if(e[o]===`$`&&e[o+1]===`{`){a<o&&n.push({start:a,end:o,className:`string`}),n.push({start:o,end:o+2,className:`operator`});let t=Ks(e,o+2),s=t<0?e.length:t,c=e.slice(o+2,s);if(n.push(...Os(Us(c,r,i),o+2)),t<0)return e.length;n.push({start:t,end:t+1,className:`operator`}),o=t+1,a=o;continue}o++}return a<e.length&&n.push({start:a,end:e.length,className:`string`}),e.length}function Ks(e,t){let n=1,r=t;for(;r<e.length;){let t=e[r],i=e[r+1];if(t===`'`||t===`"`){r=tc(e,r,t);continue}if(t==="`"){r=qs(e,r);continue}if(t===`/`&&i===`/`){r=nc(e,r+2);continue}if(t===`/`&&i===`*`){let t=e.indexOf(`*/`,r+2);r=t<0?e.length:t+2;continue}if(t===`{`&&n++,t===`}`&&--n===0)return r;r++}return-1}function qs(e,t){let n=t+1;for(;n<e.length;)if(e[n]===`\\`)n+=2;else if(e[n]==="`")return n+1;else if(e[n]===`$`&&e[n+1]===`{`){let t=Ks(e,n+2);n=t<0?e.length:t+1}else n++;return e.length}function Js(e,t){let n=[],r=0,i=0,a=0;for(;r<e.length;){if(i&&(e[r]===`"`||e[r]===`'`||e[r]==="`")){r=e[r]==="`"?qs(e,r):tc(e,r,e[r]);continue}if(i&&e[r]===`{`){a++,r++;continue}if(i&&e[r]===`}`){a=Math.max(0,a-1),r++;continue}if(e[r]!==`<`){r++;continue}if(e.startsWith(`</>`,r)){i=Math.max(0,i-1),r+=3;continue}if(e.startsWith(`<>`,r)&&(i>0||Xs(e,r,t))){i++,r+=2;continue}let o=e[r+1]===`/`,s=r+(o?2:1),c=/^[A-Za-z][\w:.-]*/.exec(e.slice(s));if(!c||!o&&!(i>0&&a===0)&&!Xs(e,r,t)){r++;continue}let l=ec(e,s+c[0].length);if(l<0||Zs(e,r,l,o)){r++;continue}n.push({start:s,end:s+c[0].length,className:`tag`}),o||Ys(e,s+c[0].length,l,n);let u=/\/\s*$/.test(e.slice(s,l));o?i=Math.max(0,i-1):u||i++,r=l+1}return n}function Ys(e,t,n,r){let i=e.slice(t,n),a=/\s([:@A-Za-z_$][\w$:.-]*)(?=\s*(?:=|\/?>))/g,o;for(;o=a.exec(i);){let e=o[0].indexOf(o[1]),n=t+o.index+e;r.push({start:n,end:n+o[1].length,className:`attr`})}}function Xs(e,t,n){if(n&&/^\s*$/.test(e.slice(e.lastIndexOf(`
|
|
537
|
+
`,t-1)+1,t)))return!0;let r=e.slice(0,t).trimEnd();return!r||/\b(?:return|case|yield)$/.test(r)?!0:/(?:[=([{,:;!&|?]|>)$/.test(r)}function Zs(e,t,n,r){if(r)return!1;let i=e.slice(t+1,n),a=e.slice(n+1).trimStart();return/\s+extends\s+/.test(i)||a[0]===`(`&&!i.trimEnd().endsWith(`/`)}function Qs(e,t){let n=e.slice(0,t).trimEnd();return!n||/\b(?:case|delete|in|instanceof|of|return|throw|typeof|void|yield)$/.test(n)?!0:/[=([{,:;!&|?~+*%^<>-]$/.test(n)}function $s(e,t){let n=!1,r=t+1;for(;r<e.length&&e[r]!==`
|
|
538
|
+
`;)if(e[r]===`\\`)r+=2;else if(e[r]===`[`)n=!0,r++;else if(e[r]===`]`)n=!1,r++;else if(e[r]===`/`&&!n){for(r++;/[a-z]/i.test(e[r]||``);)r++;return r}else r++;return t+1}function ec(e,t){let n=0,r=t;for(;r<e.length;){let t=e[r];if(t===`'`||t===`"`){r=tc(e,r,t);continue}if(t===`{`)n++;else if(t===`}`)n=Math.max(0,n-1);else if(t===`>`&&n===0)return r;else if(t===`
|
|
539
|
+
`&&n===0)return-1;r++}return-1}function tc(e,t,n){let r=t+1;for(;r<e.length;)if(e[r]===`\\`)r+=2;else if(e[r]===n)return r+1;else if(e[r]===`
|
|
540
|
+
`&&n!=="`")return r;else r++;return e.length}function nc(e,t){let n=e.indexOf(`
|
|
541
|
+
`,t);return n<0?e.length:n}var rc=$({name:`js`,aliases:[`javascript`,`mjs`,`cjs`,`js-vue`],tokenize:e=>Us(e)}),ic=$({name:`json`,aliases:[`jsonc`,`json5`],tokenize:Es([{className:e=>e[0].startsWith(`//`)||e[0].startsWith(`/*`)?`comment`:e[1]?`property`:`string`,regex:/\/\/[^\n]*|\/\*[\s\S]*?\*\/|("(?:\\.|[^"\\])*")(?=\s*:)|"(?:\\.|[^"\\])*"/g},{className:`literal`,regex:/\b(?:false|null|true)\b/g},{className:`number`,regex:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/gi}])}),ac=$({name:`jsx`,tokenize:e=>Us(e,!0)}),oc=$({name:`markdown`,aliases:[`md`],tokenize(e,t){return Ds(e,[{className:`heading`,regex:/^#{1,6}\s.*$/gm},{className:`heading`,regex:/^.+\n(?:=+|-+)\s*$/gm},{className:`code-inline`,regex:/`[^`\n]+`/g},{className:`link`,regex:/!?\[[^\]]+\]\([^)]+\)/g},{className:`meta`,regex:/^\s{0,3}(?:>|[-*+] |\d+\. )/gm}],sc(e,t))}});function sc(e,t){let n=[],r=/^( {0,3})(`{3,}|~{3,})\s*([^\n]*)$/gm,i;for(;i=r.exec(e);){let a=i[2],o=e.indexOf(`
|
|
542
|
+
`,i.index+i[0].length);if(o<0)break;let s=RegExp(`^ {0,3}${a[0]}{${a.length},}\\s*$`,`gm`);s.lastIndex=o+1;let c=s.exec(e),l=c?.index??e.length,u=i[3].trim().split(/\s+/)[0],d=u&&t.hasLanguage(u)?Os(t.tokenize(e.slice(o+1,l),u),o+1):[];n.push({start:i.index,end:o,className:`meta`}),n.push(...cc(o+1,l,d)),c&&n.push({start:c.index,end:c.index+c[0].length,className:`meta`}),r.lastIndex=c?c.index+c[0].length:e.length}return n}function cc(e,t,n){let r=[],i=e;for(let e of[...n].sort((e,t)=>e.start-t.start))e.start>i&&r.push({start:i,end:e.start,className:`code-inline`}),r.push(e),i=e.end;return i<t&&r.push({start:i,end:t,className:`code-inline`}),r}var lc=$({name:`plaintext`,aliases:[`text`,`txt`,`-->`],tokenize:()=>[]}),uc=$({name:`python`,aliases:[`py`],tokenize(e){return Ds(e,[{className:e=>e[0].startsWith(`#`)?`comment`:`string`,regex:/#[^\n]*|(?:br|rb|fr|rf|[rubf])?(?:"""[\s\S]*?"""|'''[\s\S]*?'''|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*')/gi},{className:`keyword`,regex:/\b(?:and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b/g},{className:`literal`,regex:/\b(?:False|None|True|NotImplemented|Ellipsis)\b/g},{className:`function`,regex:/@[A-Za-z_][\w.]*/g},{className:`function`,regex:/\bdef\s+([A-Za-z_]\w*)/g,group:1},{className:`type`,regex:/\b(?:bool|bytes|dict|float|frozenset|int|list|object|set|str|tuple|type)\b/g},{className:`number`,regex:/\b(?:0x[\da-f_]+|0b[01_]+|0o[0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:e[+-]?\d[\d_]*)?j?)\b/gi}])}}),dc=$({name:`shell`,aliases:[`bash`,`sh`,`zsh`,`cmd`,`console`],tokenize(e){return Ds(e,[{collect:fc},{className:`variable`,regex:/\$[A-Za-z_][A-Za-z0-9_]*|\b[A-Z_][A-Z0-9_]*(?==)/g},{className:`keyword`,regex:/\b(?:case|do|done|elif|else|esac|export|fi|for|function|if|in|select|then|time|until|while)\b/g},{className:`command`,regex:/(^|[\n;|&])\s*([A-Za-z0-9_./-]+)(?=\s|$)/g,group:2}])}});function fc(e){let t=[];pc(e,t);let n=0;for(;n<e.length;){if(hc(n,t)){n=t.find(e=>e.start<=n&&e.end>n).end;continue}let r=e[n];if(r===`"`||r===`'`){let i=r,a=n+1;for(;a<e.length;)if(e[a]===`\\`&&i===`"`)a+=2;else if(e[a]===i){a++;break}else a++;t.push({start:n,end:a,className:`string`}),n=a;continue}if(r===`$`&&e[n+1]===`{`){let r=e.indexOf(`}`,n+2),i=r<0?e.length:r+1;t.push({start:n,end:i,className:`variable`}),n=i;continue}if(r===`#`&&(n===0||e[n-1]===`
|
|
543
|
+
`||/[\s;|&()]/.test(e[n-1]))){let r=e.indexOf(`
|
|
544
|
+
`,n),i=r<0?e.length:r;t.push({start:n,end:i,className:`comment`}),n=i;continue}n++}return t}function pc(e,t){let n=/<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/g,r;for(;r=n.exec(e);){if(e[r.index-1]===`<`||mc(e,r.index))continue;let n=e.indexOf(`
|
|
545
|
+
`,r.index+r[0].length);if(n<0)continue;let i=n+1,a=RegExp(`^\\t*${gc(r[2])}\\s*$`,`m`).exec(e.slice(i));if(!a){t.push({start:i,end:e.length,className:`string`});continue}let o=i+a.index;o>i&&t.push({start:i,end:o,className:`string`});let s=i+a.index;t.push({start:s,end:s+a[0].length,className:`meta`})}}function mc(e,t){let n=e.lastIndexOf(`
|
|
546
|
+
`,t-1)+1,r=``;for(let i=n;i<t;i++)e[i]===`\\`&&r!==`'`?i++:r&&e[i]===r?r=``:!r&&(e[i]===`"`||e[i]===`'`)&&(r=e[i]);return!!r}function hc(e,t){return t.some(t=>t.start<=e&&t.end>e)}function gc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var _c=$({name:`sql`,tokenize:Es([{className:e=>e[0].startsWith(`--`)||e[0].startsWith(`/*`)?`comment`:`string`,regex:/--[^\n]*|\/\*[\s\S]*?\*\/|'(?:''|[^'])*'|"(?:""|[^"])*"/g},{className:`keyword`,regex:/\b(?:add|all|alter|and|as|asc|begin|between|by|case|check|column|commit|constraint|create|cross|database|default|delete|desc|distinct|drop|else|end|exists|foreign|from|full|group|having|index|inner|insert|into|join|key|left|like|limit|not|null|on|or|order|outer|primary|references|returning|right|rollback|select|set|table|then|union|unique|update|using|values|view|when|where|with)\b/gi},{className:`literal`,regex:/\b(?:false|null|true)\b/gi},{className:`number`,regex:/\b\d+(?:\.\d+)?\b/g},{className:`function`,regex:/\b[A-Za-z_][A-Za-z0-9_]*(?=\s*\()/g}])}),vc=$({name:`ts`,aliases:[`typescript`,`angular-ts`],tokenize:e=>Us(e)}),yc=$({name:`tsx`,tokenize:e=>Us(e,!0)}),bc=$({name:`yaml`,aliases:[`yml`],tokenize(e){let t=[...xc(e),...Sc(e)];return Ds(e,[{className:`property`,regex:/^[ \t-]*([A-Za-z0-9_.-]+)(?=\s*:)/gm,group:1},{collect:Cc},{className:`literal`,regex:/\b(?:false|null|true|yes|no|on|off|~)\b/gi},{className:`number`,regex:/\b\d+(?:\.\d+)?\b/g}],t)}});function xc(e){let t=[],n=/^(\s*)[\w.-]+:\s*[>|][+-]?\s*(?:#.*)?$/gm,r;for(;r=n.exec(e);){let n=e.indexOf(`
|
|
547
|
+
`,r.index+r[0].length);if(n<0)continue;let i=r[1].length,a=n+1;for(;a<e.length;){let t=e.indexOf(`
|
|
548
|
+
`,a),n=t<0?e.length:t,r=e.slice(a,n);if(r.trim()&&(r.match(/^\s*/)?.[0].length||0)<=i)break;a=t<0?e.length:t+1}a>n+1&&t.push({start:n+1,end:a,className:`string`})}return t}function Sc(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`"`||r===`'`){let i=r,a=n+1;for(;a<e.length&&e[a]!==`
|
|
549
|
+
`;)if(e[a]===`\\`&&i===`"`)a+=2;else if(e[a]===i){a++;break}else a++;t.push({start:n,end:a,className:`string`}),n=a;continue}if(r===`#`&&(n===0||e[n-1]===`
|
|
550
|
+
`||/\s/.test(e[n-1]))){let r=e.indexOf(`
|
|
551
|
+
`,n),i=r<0?e.length:r;t.push({start:n,end:i,className:`comment`}),n=i;continue}n++}return t}function Cc(e){let t=[],n=/:\s*([^\n]*)/g,r;for(;r=n.exec(e);){let n=r[1],i=n.trimEnd();if(!i)continue;let a=r.index+r[0].indexOf(n),o=a+i.length,s=/\s+#/.exec(i);for(s&&(o=a+s.index);o>a&&/\s/.test(e[o-1]);)o--;o>a&&t.push({start:a,end:o,className:`string`})}return t}var wc=/[ \t]*(?:(?:\/\/|#)[ \t]*\[!code[ \t]+(\+\+|--)\]|\/\*[ \t]*\[!code[ \t]+(\+\+|--)\][ \t]*\*\/|<!--[ \t]*\[!code[ \t]+(\+\+|--)\][ \t]*-->)[ \t]*$/;function Tc(e){let t=[];return{code:e.split(`
|
|
552
|
+
`).map((e,n)=>{let r=wc.exec(e);if(!r)return e;let i=r[1]||r[2]||r[3];return t.push({className:i===`++`?`th-line--inserted`:`th-line--deleted`,lines:n+1}),e.slice(0,r.index)}).join(`
|
|
553
|
+
`),decorations:t}}function Ec(e){return(t,n=`plaintext`,r={})=>{let i=Tc(t);return us(ls(e.tokenize(i.code,{lang:n}).tokens,{...r.lineNumbers===void 0?{}:{lineNumbers:r.lineNumbers},...i.decorations.length||r.highlightLines?.length?{decorations:[...i.decorations,...(r.highlightLines||[]).map(e=>({className:`th-line--highlighted`,lines:e}))]}:{}}))}}var Dc=Ec(cs({fallbackLanguage:`plaintext`,languages:[Ms,Ns,Vs,rc,ic,ac,oc,lc,uc,dc,_c,vc,yc,bc]})),Oc=(0,V.forwardRef)(function({className:e,variant:t=`default`,...n},r){return(0,B.jsx)(`article`,{...n,className:a(`prose prose-caps`,t===`dropcap`&&`caps-prose-dropcap`,e),ref:r})});function kc(e){return URL.parse(e)?.protocol??null}function Ac(e){if(e===``||e.startsWith(`//`))return!1;let t=kc(e);return t===null||t===`http:`||t===`https:`||t===`mailto:`}function jc(e){let t=kc(e);return t===`http:`||t===`https:`}function Mc(e){if(e===``||e.startsWith(`//`))return!1;let t=kc(e);return t===null||t===`http:`||t===`https:`}function Nc({children:e,className:t,components:n,frontmatter:r=!0,policy:i=`default`,typography:o=`prose`}){let s=(0,V.useMemo)(()=>Po(e,{allowHtml:!1,frontmatter:r}),[e,r]),c=(0,V.useMemo)(()=>({...n,a(e){let t=e.href??``;if(i===`visitor`){let n=URL.parse(t);return n===null||!jc(n.href)?(0,B.jsx)(`span`,{children:e.children}):(0,B.jsx)(`a`,{href:n.href,target:`_blank`,rel:`noopener noreferrer`,children:e.children})}if(!Ac(t))return(0,B.jsx)(B.Fragment,{children:e.children});let n=jc(t);return(0,B.jsx)(`a`,{...e,href:t,rel:n?`noopener noreferrer`:e.rel,target:n?`_blank`:e.target})},img(e){if(i===`visitor`)return(0,B.jsx)(`span`,{className:`text-dim`,children:`Image removed`});let t=e.src??``;return Mc(t)?n?.img?(0,V.createElement)(n.img,e):(0,B.jsx)(`img`,{alt:e.alt??``,className:`max-w-full`,src:t}):(0,B.jsx)(B.Fragment,{children:e.alt??``})}}),[n,i]),l=(0,B.jsx)(Jo,{allowHtml:!1,components:c,highlighter:Dc,children:s}),u=a(`min-w-0 break-words`,t);return o===`prose`?(0,B.jsx)(Oc,{className:u,children:l}):(0,B.jsx)(`div`,{className:u,children:l})}function Pc(e){return e.replace(/^\uFEFF/u,``).replace(/\r\n?/gu,`
|
|
554
|
+
`)}function Fc({document:e,theme:t,sourceLabel:n,savedConflict:r=!1}){if(!e.conflict)return null;let i=e.saving||e.resolving;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`inkcap-conflict`,role:`region`,"aria-label":`File conflict`,children:[(0,B.jsx)(Te,{tone:`warning`,title:n?`The repository changed since you opened this file`:`This file changed on the Computer since you opened it`,description:r?`Your file is saved in Bonsai. Your saved text and any newer edits stay here.`:`Your edits are still here and have not been saved.`}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-xs`,children:[(0,B.jsx)(h,{size:`sm`,disabled:i,onClick:()=>{e.keepMine()},children:`Keep mine`}),(0,B.jsx)(h,{size:`sm`,variant:`outline`,disabled:i,onClick:()=>{e.reloadTheirs()},children:`Reload theirs`}),(0,B.jsx)(h,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>{e.compare()},children:e.resolving?`Loading…`:`Compare`})]}),(0,B.jsxs)(`p`,{className:`text-xs text-dim`,children:[`Keep mine`,` `,n?`saves your file in Bonsai and retries sync`:`overwrites the Computer file`,`. Reload theirs replaces your edits.`]})]}),(0,B.jsx)(d,{open:e.comparison!==null,onOpenChange:t=>{t||e.closeComparison()},children:(0,B.jsxs)(C,{className:`inkcap-compare-dialog`,children:[(0,B.jsxs)(T,{children:[(0,B.jsx)(m,{children:`Compare file versions`}),(0,B.jsxs)(p,{children:[`Removed lines are from `,n??`the Computer`,`. Added lines are your edits. Nothing is saved by comparing.`]})]}),(0,B.jsx)(`div`,{className:`inkcap-conflict-diff`,role:`region`,"aria-label":`File comparison`,children:e.comparison===null?null:(0,B.jsx)(pn,{oldFile:{name:e.currentPath,contents:Pc(e.comparison)},newFile:{name:e.currentPath,contents:Pc(e.contents)},options:{diffStyle:`unified`,disableFileHeader:!0,themeType:t===`mocha`?`dark`:`light`,theme:{dark:`catppuccin-mocha`,light:`catppuccin-latte`}}})}),(0,B.jsx)(v,{children:(0,B.jsx)(h,{variant:`ghost`,onClick:e.closeComparison,children:`Back to editing`})})]})})]})}function Ic(e,t){return{...e,contents:t}}function Lc(e,t){return{...e,saved:t}}function Rc(e){return e.contents!==e.saved}function zc({path:e,initial:t,local:n,onSaveAs:r,onPathChange:i,onStatus:a,write:s,overwrite:c,readCurrent:l,target:u,syncConflict:d=!1}){let f=(0,V.useRef)({saved:t,contents:t}),p=(0,V.useRef)(e),m=(0,V.useRef)(s),h=(0,V.useRef)(c),g=(0,V.useRef)(l),_=(0,V.useRef)(r),v=(0,V.useRef)(i),y=(0,V.useRef)(a),b=(0,V.useRef)(u);m.current=s,h.current=c,g.current=l,_.current=r,v.current=i,y.current=a,b.current=u;let[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(t),[T,E]=(0,V.useState)(!1),[ee,D]=(0,V.useState)(``),[O,k]=(0,V.useState)(!1),A=(0,V.useRef)(!1),j=(0,V.useRef)(d);j.current=d;function M(e){A.current=e,k(e)}let[N,P]=(0,V.useState)(null),[F,I]=(0,V.useState)(!1),[te,ne]=(0,V.useState)(0),[re,ie]=(0,V.useState)(!1),L=(0,V.useRef)(!1),R=(0,V.useRef)({dirty:!1,saving:!1});function z(e,t){S(e),E(t);let n=b.current;n&&(n.revision+=1,n.dirty=e,n.saving=t),(R.current.dirty!==e||R.current.saving!==t)&&(R.current={dirty:e,saving:t},y.current(e,t))}function ae(e){f.current=Ic(f.current,e),w(e),z(Rc(f.current)||A.current,R.current.saving)}async function oe(){if(L.current||O||j.current)return!1;if(!Rc(f.current))return!0;L.current=!0,z(!0,!0),D(``);let e=f.current.contents;try{return await m.current(e,f.current.saved),f.current=Lc(f.current,e),z(Rc(f.current)||A.current,!0),!0}catch(e){if(e instanceof o&&e.code===`CANCELLED`)return!1;if(e instanceof o&&e.code===`CONFLICT`)return M(!0),P(null),!1;console.error(`Inkcap save failed`,e);let t=n?`Download could not start. Your edits remain in this tab.`:`Save was denied or failed. Your edits remain in this tab; retry with the same or another path.`;throw D(t),Error(t,{cause:e})}finally{L.current=!1,z(Rc(f.current)||A.current,!1)}}async function se(){if(!O&&!j.current||L.current)return!1;L.current=!0,z(!0,!0),D(``);let e=f.current.contents;try{return await h.current(e),f.current=Lc(f.current,e),M(!1),P(null),!0}catch(e){return e instanceof o&&e.code===`CANCELLED`?!1:(console.error(`Inkcap explicit overwrite failed`,e),D(`Could not overwrite the file. Your edits remain in this tab.`),!1)}finally{L.current=!1,z(Rc(f.current)||A.current,!1)}}async function ce(e){if(!O&&!j.current||L.current)return!1;L.current=!0,I(!0),D(``);let t=b.current?.revision,n=f.current.contents;try{let r=await g.current(e);return b.current?.closed?!1:e?f.current.contents!==n||b.current?.revision!==t?(D(`Your edits changed while reloading. They remain in this tab; compare or reload again.`),!1):(f.current={saved:r,contents:r},w(r),M(!1),P(null),ne(e=>e+1),z(!1,!1),!0):(P(r),!0)}catch(e){return console.error(`Inkcap conflict read failed`,e),D(`Could not read the file. Your edits remain in this tab.`),!1}finally{L.current=!1,I(!1)}}async function le(e){let t=e.trim();if(!n&&t===p.current)return oe();if(!t||t.endsWith(`/`)||L.current)return!1;L.current=!0,z(!0,!0),D(``);let r=f.current.contents;try{if(!_.current)throw Error(`Save As is unavailable`);let e=await _.current(t,r);return f.current=Lc(f.current,r),p.current=e,M(!1),P(null),v.current?.(e),z(Rc(f.current)||A.current,!0),!0}catch(e){return e instanceof o&&e.code===`CANCELLED`?!1:(console.error(`Inkcap save failed`,e),D(`Save As was denied or failed. Your edits remain in this tab; retry with the same or another path.`),!1)}finally{L.current=!1,z(Rc(f.current)||A.current,!1)}}return{currentPath:p.current,contents:C,dirty:x,saving:T,error:ee,conflict:O||d,comparison:N,resolving:F,reloadVersion:te,keepMine:se,compare:()=>ce(!1),reloadTheirs:()=>ce(!0),closeComparison:()=>{P(null)},imageError:re,setImageError:ie,edit:ae,save:oe,saveAs:le}}function Bc({path:e,initial:t,active:n,menuSlot:r,narrow:i,tabKey:a,savable:o,local:s,sourceLabel:c,activityNotice:l,onDismissActivityNotice:u,previewUrl:d,previewKind:f,onReopen:p,onSaveAs:m,pathExists:h,onPathChange:g,target:_,write:v,overwrite:y,readCurrent:b,onStatus:x,onSaveBinding:S,saveAsDirectory:C,downloads:w=!1,onSaved:T,syncConflict:E=!1}){let[ee,D]=(0,V.useState)(()=>ae()??`latte`),O=(0,V.useRef)(null),[k,A]=(0,V.useState)(!1),[j,M]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=O.current?.closest(`[data-theme]`);return D(ae(e??void 0)??`latte`),lt(D,e??void 0)},[]);let N=zc({path:e,initial:t,local:s,onSaveAs:m,onPathChange:g,onStatus:x,target:_,write:v,overwrite:y,readCurrent:b,syncConflict:E}),P=(0,V.useRef)(N.save),F=(0,V.useRef)(s),I=(0,V.useRef)(N.currentPath),te=(0,V.useRef)(T),ne=(0,V.useRef)(w),re=(0,V.useRef)(N.saving),ie=(0,V.useRef)(o),L=(0,V.useRef)(!1),R=(0,V.useRef)(!1),z=(0,V.useRef)(!1),oe=(0,V.useRef)(null),se=(0,V.useRef)(n);se.current=n,(0,V.useEffect)(()=>{n&&oe.current?.focus()},[n]);let ce=(0,V.useRef)(N.edit),le=(0,V.useRef)(N.contents);ce.current=N.edit,le.current=N.contents;let ue=()=>{let e=oe.current?.getFile()?.contents;return e!==void 0&&e!==le.current?e:null};P.current=N.save,F.current=s,I.current=N.currentPath,te.current=T,ne.current=w,re.current=N.saving,ie.current=o&&!N.conflict&&!N.resolving,L.current=N.dirty,R.current=_?.closed??!1,z.current=!!(m&&!d);let de=async()=>{if(F.current)return A(!0),!0;let e=ue();e!==null&&ce.current(e);let t=await P.current();return t&&te.current?.(Wc(I.current),ne.current),t},fe=async e=>{let t=await N.saveAs(e);return t&&te.current?.(Wc(e),ne.current),t},pe=(0,V.useMemo)(()=>({availability:()=>mn({local:F.current,closed:R.current,savable:ie.current,saving:_?.saving??re.current,dirty:L.current}),save:()=>de(),saveAsAvailability:()=>R.current||!z.current?{status:`unavailable`,reason:`This file cannot be saved as.`}:ie.current?_?.saving??re.current?{status:`unavailable`,reason:`A save is already running.`}:{status:`available`}:{status:`unavailable`,reason:`No focused savable document.`},saveAs:()=>{A(!0)}}),[]);(0,V.useEffect)(()=>(S(a,pe),()=>{S(a,void 0)}),[S,pe,a,N.dirty,N.saving,N.conflict,N.resolving,o,_?.closed]);let me=(0,V.useMemo)(()=>({name:N.currentPath,contents:N.contents}),[N.currentPath,N.contents]),he=(0,V.useMemo)(()=>({onAttach:e=>{oe.current=e,se.current&&e.focus({lineNumber:1,character:0})},onChange:e=>{ce.current(e.contents)}}),[]),ge=Ce(N.currentPath);return(0,B.jsx)(Vc,{themeRoot:O,menuSlot:n?r:null,tabKey:a,savable:o,narrow:i,local:s,sourceLabel:c,savedConflict:E,activityNotice:l,onDismissActivityNotice:u,previewUrl:d,previewKind:f,onSaveAs:m,pathExists:w?void 0:h,onSave:de,onSubmitSaveAs:fe,saveAsDirectory:w?null:C??null,downloads:w,onReopen:p,document:N,file:me,editorOptions:he,theme:ee,saveAsOpen:k,setSaveAsOpen:A,canPreviewMarkdown:ge,markdownPreview:ge&&j,onToggleMarkdownPreview:()=>{M(e=>!e)}})}function Vc({themeRoot:e,menuSlot:n,tabKey:r,savable:i,narrow:a,local:o,sourceLabel:s,savedConflict:c,activityNotice:l,onDismissActivityNotice:u,previewUrl:d,previewKind:f,onSaveAs:p,pathExists:m,onSave:h,onSubmitSaveAs:g,saveAsDirectory:_,downloads:v,onReopen:b,document:S,file:C,editorOptions:w,theme:T,saveAsOpen:E,setSaveAsOpen:ee,canPreviewMarkdown:D,markdownPreview:O,onToggleMarkdownPreview:k}){return(0,B.jsxs)(L,{ref:e,className:`inkcap-editor mt-0`,value:String(r),forceMount:!0,"aria-label":S.currentPath,children:[n?(0,ro.createPortal)((0,B.jsx)(Hc,{savable:i&&!S.conflict&&!S.resolving,path:S.currentPath,dirty:S.dirty,saving:S.saving,local:o,canSaveAs:!!(p&&!d),canPreviewMarkdown:D,markdownPreview:O,onToggleMarkdownPreview:k,onSave:()=>{h().catch(e=>{console.error(`Inkcap save failed`,e)})},onSaveAs:()=>{ee(!0)},onReopen:b}),n):null,l?(0,B.jsx)(Te,{className:`inkcap-notice`,tone:`warning`,role:`status`,title:`Recent files didn't update`,description:`${Uc(o,S.dirty,S.saving)} worked; the Recent Files list could not record it.`,action:(0,B.jsx)(t,{icon:(0,B.jsx)(y,{}),"aria-label":`Dismiss Recent Files notice`,title:`Dismiss Recent Files notice`,variant:`ghost`,size:`responsive`,onClick:u})}):null,(0,B.jsx)(Fc,{document:S,theme:T,sourceLabel:s,savedConflict:c}),S.error?(0,B.jsx)(Te,{className:`inkcap-notice`,tone:`error`,title:S.conflict?`Couldn't resolve the file conflict`:`Couldn't save`,description:S.error}):null,(0,B.jsx)(Kc,{previewUrl:d,previewKind:f,path:S.currentPath,imageError:S.imageError,setImageError:S.setImageError,file:C,editorOptions:w,theme:T,narrow:a,markdownPreview:O},`${String(S.reloadVersion)}:${S.currentPath}`),(0,B.jsx)(Yc,{sourceLabel:s,error:S.error,path:o&&!S.currentPath.startsWith(`/`)?x(_,S.currentPath,S.contents):S.currentPath,selectName:o,downloads:v,open:E,busy:S.saving,pathExists:m,onSubmit:g,onOpenChange:ee})]})}function Hc({savable:e,path:n,dirty:r,saving:i,local:a,canSaveAs:o,canPreviewMarkdown:s,markdownPreview:c,onToggleMarkdownPreview:l,onSave:u,onSaveAs:d,onReopen:f}){return(0,B.jsxs)(mt,{children:[(0,B.jsx)(it,{render:(0,B.jsx)(t,{variant:`ghost`,size:`responsive`,icon:(0,B.jsx)(At,{}),"aria-label":`More`,title:`More`})}),(0,B.jsxs)(ut,{align:`end`,children:[(0,B.jsx)(Ke,{disabled:!e||!a&&!r||i,onSelect:u,children:Uc(a,r,i)}),o?(0,B.jsx)(Ke,{disabled:!e||i,onSelect:d,children:`Save file as`}):null,f?(0,B.jsx)(Ke,{disabled:!e||r||i,onSelect:f,children:`Reload from disk`}):null,s?(0,B.jsx)(nt,{checked:c,onSelect:l,children:`Preview Markdown`}):null,(0,B.jsx)(je,{}),(0,B.jsx)(Ke,{onSelect:()=>{globalThis.navigator.clipboard.writeText(n).catch(e=>{console.error(`Inkcap could not copy the path`,e)})},children:`Copy path`})]})]})}function Uc(e,t,n){return n?`Saving…`:e||t?`Save`:`Saved`}function Wc(e){return e.trim().split(`/`).at(-1)??e}function Gc(e){let t=e.lastIndexOf(`/`)+1,n=e.lastIndexOf(`.`);return[t,n>t?n:e.length]}function Kc({previewUrl:e,previewKind:t,path:n,imageError:r,setImageError:i,file:a,editorOptions:o,theme:s,narrow:c,markdownPreview:l}){return e?t===`video`?(0,B.jsx)(Jc,{path:n,url:e}):(0,B.jsx)(qc,{path:n,url:e,failed:r,onFailed:i}):l?(0,B.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,B.jsx)(Nc,{className:`max-w-none p-lg`,children:a.contents})}):(0,B.jsx)(`div`,{className:`inkcap-code`,children:(0,B.jsx)(ce,{createEditor:e=>new no(e),children:(0,B.jsx)(fn,{file:a,edit:!0,editorOptions:o,options:{disableFileHeader:!0,overflow:c?`wrap`:`scroll`,themeType:s===`mocha`?`dark`:`light`,theme:{dark:`catppuccin-mocha`,light:`catppuccin-latte`}}})})})}function qc({path:e,url:t,failed:n,onFailed:r}){let i=A(e)===`image/svg+xml`;return(0,B.jsx)(`div`,{className:`inkcap-preview`,children:n?(0,B.jsxs)(`div`,{role:`alert`,children:[(0,B.jsx)(`strong`,{children:`Preview unavailable`}),(0,B.jsx)(`span`,{children:e})]}):(0,B.jsx)(`img`,{src:t,alt:e,draggable:!i&&void 0,onContextMenu:e=>{i&&e.preventDefault()},onError:()=>{i&&URL.revokeObjectURL(t),r(!0)},onLoad:()=>{i&&URL.revokeObjectURL(t),r(!1)}})})}function Jc({path:e,url:t}){return(0,B.jsx)(`div`,{className:`inkcap-preview`,children:(0,B.jsx)(`video`,{src:t,controls:!0,"aria-label":e})})}function Yc({sourceLabel:e,error:t,path:n,selectName:r,downloads:i,open:a,busy:o,pathExists:s,onSubmit:c,onOpenChange:l}){let[u,f]=(0,V.useState)(null),g=(0,V.useRef)(null),_=(0,V.useRef)(null),y=(0,V.useRef)(!1),x=kt({defaultValues:{path:n},onSubmit:async({value:e})=>{if(_.current!==e.path&&s){let t=await s(e.path);if(t===`unchecked`)return;if(t===`exists`){f(e.path);return}}_.current=null,await c(e.path)&&l(!1)}}),S=Ot(x.store,e=>e.isSubmitting),w=o||S,E=(0,V.useRef)(n);return E.current=n,(0,V.useEffect)(()=>{a&&(_.current=null,f(null),x.setFieldValue(`path`,E.current))},[a]),(0,V.useEffect)(()=>{if(u!==null||!y.current)return;y.current=!1;let e=g.current;if(!e)return;e.focus();let[t,n]=Gc(e.value);e.setSelectionRange(t,n)},[u]),(0,B.jsx)(d,{open:a&&!(e&&o),onOpenChange:e=>{o||l(e)},children:(0,B.jsxs)(C,{children:[(0,B.jsxs)(T,{className:`mb-4`,children:[(0,B.jsx)(m,{children:i?`Download file`:`Save file`}),(0,B.jsx)(p,{children:i?`Choose a name for the file. It goes to your Downloads folder.`:e?`Choose a path in ${e}.`:`Choose where to save it on your Computer.`})]}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(x.Field,{name:`path`,validators:{onChange:({value:e})=>e.trim()?e.trim().endsWith(`/`)?`Save As needs a file path.`:void 0:`A file path is required.`},children:n=>(0,B.jsx)(Et,{label:i?`File name`:e?`Path`:`Location`,required:!0,error:n.state.meta.errors[0]??t,children:(0,B.jsx)(Dt,{value:n.state.value,onBlur:n.handleBlur,onChange:e=>{n.handleChange(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),w||x.handleSubmit())},ref:g,autoFocus:!0,onFocus:e=>{if(!r)return;let t=e.currentTarget,[n,i]=Gc(t.value);t.setSelectionRange(n,i)},disabled:w||u!==null,required:!0})})}),u===null?(0,B.jsxs)(v,{children:[(0,B.jsx)(b,{disabled:w,children:`Cancel`}),(0,B.jsx)(h,{type:`button`,disabled:w,onClick:()=>{x.handleSubmit()},children:i?w?`Downloading…`:`Download`:w?`Saving…`:`Save`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Te,{tone:`warning`,role:`alert`,title:`${Wc(u)} already exists. Replace it?`}),(0,B.jsxs)(v,{children:[(0,B.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>{_.current=null,y.current=!0,f(null)},children:`Cancel`}),(0,B.jsx)(h,{type:`button`,onClick:()=>{_.current=u,f(null),x.handleSubmit()},children:`Replace`})]})]})]})]})})}export{Bc as FileTab};
|