|
|
(function(){"use strict";class Kr{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Re.isErrorNoTelemetry(t)?new Re(t.message+`
`+t.stack):new Error(t.message+`
`+t.stack):t},0)}}emit(t){this.listeners.forEach(n=>{n(t)})}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}}const es=new Kr;function Ze(e){ts(e)||es.onUnexpectedError(e)}function Zt(e){if(e instanceof Error){const{name:t,message:n}=e,r=e.stacktrace||e.stack;return{$isError:!0,name:t,message:n,stack:r,noTelemetry:Re.isErrorNoTelemetry(e)}}return e}const _t="Canceled";function ts(e){return e instanceof ns?!0:e instanceof Error&&e.name===_t&&e.message===_t}class ns extends Error{constructor(){super(_t),this.name=this.message}}class Re extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Re)return t;const n=new Re;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}}class le extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,le.prototype)}}function rs(e,t){const n=this;let r=!1,s;return function(){return r||(r=!0,s=e.apply(n,arguments)),s}}var Ke;(function(e){function t(_){return _&&typeof _=="object"&&typeof _[Symbol.iterator]=="function"}e.is=t;const n=Object.freeze([]);function r(){return n}e.empty=r;function*s(_){yield _}e.single=s;function i(_){return t(_)?_:s(_)}e.wrap=i;function o(_){return _||n}e.from=o;function*l(_){for(let N=_.length-1;N>=0;N--)yield _[N]}e.reverse=l;function u(_){return!_||_[Symbol.iterator]().next().done===!0}e.isEmpty=u;function c(_){return _[Symbol.iterator]().next().value}e.first=c;function f(_,N){for(const p of _)if(N(p))return!0;return!1}e.some=f;function h(_,N){for(const p of _)if(N(p))return p}e.find=h;function*d(_,N){for(const p of _)N(p)&&(yield p)}e.filter=d;function*m(_,N){let p=0;for(const R of _)yield N(R,p++)}e.map=m;function*g(..._){for(const N of _)yield*N}e.concat=g;function x(_,N,p){let R=p;for(const y of _)R=N(R,y);return R}e.reduce=x;function*v(_,N,p=_.length){for(N<0&&(N+=_.length),p<0?p+=_.length:p>_.length&&(p=_.length);N<p;N++)yield _[N]}e.slice=v;function L(_,N=Number.POSITIVE_INFINITY){const p=[];if(N===0)return[p,_];const R=_[Symbol.iterator]();for(let y=0;y<N;y++){const E=R.next();if(E.done)return[p,e.empty()];p.push(E.value)}return[p,{[Symbol.iterator](){return R}}]}e.consume=L;async function S(_){const N=[];for await(const p of _)N.push(p);return Promise.resolve(N)}e.asyncToArray=S})(Ke||(Ke={}));function Fa(e){return e}function Pa(e,t){}function Kt(e){if(Ke.is(e)){const t=[];for(const n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function ss(...e){return et(()=>Kt(e))}function et(e){return{dispose:rs(()=>{e()})}}class ye{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Kt(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?ye.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}}ye.DISABLE_DISPOSED_WARNING=!1;class We{constructor(){this._store=new ye,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}}We.None=Object.freeze({dispose(){}});class U{constructor(t){this.element=t,this.next=U.Undefined,this.prev=U.Undefined}}U.Undefined=new U(void 0);class is{constructor(){this._first=U.Undefined,this._last=U.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===U.Undefined}clear(){let t=this._first;for(;t!==U.Undefined;){const n=t.next;t.prev=U.Undefined,t.next=U.U
`).slice(2).join(``))}}class us extends Error{constructor(t,n){super(t),this.name="ListenerLeakError",this.stack=n}}class cs extends Error{constructor(t,n){super(t),this.name="ListenerRefusalError",this.stack=n}}class vt{constructor(t){this.value=t}}const hs=2;class se{constructor(t){var n,r,s,i,o,l;this._size=0,this._options=t,this._leakageMon=!((n=this._options)===null||n===void 0)&&n.leakWarningThreshold?new ls((r=t==null?void 0:t.onListenerError)!==null&&r!==void 0?r:Ze,(i=(s=this._options)===null||s===void 0?void 0:s.leakWarningThreshold)!==null&&i!==void 0?i:os):void 0,this._perfMon=!((o=this._options)===null||o===void 0)&&o._profName?new Ee(this._options._profName):void 0,this._deliveryQueue=(l=this._options)===null||l===void 0?void 0:l.deliveryQueue}dispose(){var t,n,r,s;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)===null||t===void 0?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(r=(n=this._options)===null||n===void 0?void 0:n.onDidRemoveLastListener)===null||r===void 0||r.call(n),(s=this._leakageMon)===null||s===void 0||s.dispose())}get event(){var t;return(t=this._event)!==null&&t!==void 0||(this._event=(n,r,s)=>{var i,o,l,u,c,f,h;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){const x=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(x);const v=(i=this._leakageMon.getMostFrequentStack())!==null&&i!==void 0?i:["UNKNOWN stack",-1],L=new cs(`${x}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((o=this._options)===null||o===void 0?void 0:o.onListenerError)||Ze)(L),We.None}if(this._disposed)return We.None;r&&(n=n.bind(r));const d=new vt(n);let m;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(d.stack=pt.create(),m=this._leakageMon.check(d.stack,this._size+1)),this._listeners?this._listeners instanceof vt?((h=this._deliveryQueue)!==null&&h!==void 0||(this._deliveryQueue=new fs),this._listeners=[this._listeners,d]):this._listeners.push(d):((u=(l=this._options)===null||l===void 0?void 0:l.onWillAddFirstListener)===null||u===void 0||u.call(l,this),this._listeners=d,(f=(c=this._options)===null||c===void 0?void 0:c.onDidAddFirstListener)===null||f===void 0||f.call(c,this)),this._size++;const g=et(()=>{m==null||m(),this._removeListener(d)});return s instanceof ye?s.add(g):Array.isArray(s)&&s.push(g),g}),this._event}_removeListener(t){var n,r,s,i;if((r=(n=this._options)===null||n===void 0?void 0:n.onWillRemoveListener)===null||r===void 0||r.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(i=(s=this._options)===null||s===void 0?void 0:s.onDidRemoveLastListener)===null||i===void 0||i.call(s,this),this._size=0;return}const o=this._listeners,l=o.indexOf(t);if(l===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,o[l]=void 0;const u=this._deliveryQueue.current===this;if(this._size*hs<=o.length){let c=0;for(let f=0;f<o.length;f++)o[f]?o[c++]=o[f]:u&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);o.length=c}}_deliver(t,n){var r;if(!t)return;const s=((r=this._options)===null||r===void 0?void 0:r.onListenerError)||Ze;if(!s){t.value(n);return}try{t.value(n)}catch(i){s(i)}}_deliverQueue(t){const n=t.current._listeners;for(;t.i<t.end;)this._deliver(n[t.i++],t.value);t.reset()}fire(t){var n,r,s,i;if(!((n=this._deliveryQueue)===null||n===void 0)&&n.current&&(this._deliverQueue(this._deliveryQueue),(r=this._perfMon)===null||r===void 0||r.stop()),(s=this._perfMon)===null||s===void 0||s.start(this._size),this._listeners)if(this._listeners instanceof vt)this._deliver(this._listeners,t);else{const o=this._deliveryQueue;o.enqueue(this,t,this._listeners.length),this._deliverQueue(o)}(i=this._perfMon)===null||i===void 0||i.stop()}hasListeners(){return this._size>0}}class fs{constructor(){this.i=-1,this.en
`||e===" "}class dt{constructor(t,n,r){this.changes=t,this.moves=n,this.hitTimeout=r}}class Gi{constructor(t,n){this.lineRangeMapping=t,this.changes=n}}class V{static addRange(t,n){let r=0;for(;r<n.length&&n[r].endExclusive<t.start;)r++;let s=r;for(;s<n.length&&n[s].start<=t.endExclusive;)s++;if(r===s)n.splice(r,0,t);else{const i=Math.min(t.start,n[r].start),o=Math.max(t.endExclusive,n[s-1].endExclusive);n.splice(r,s-r,new V(i,o))}}static tryCreate(t,n){if(!(t>n))return new V(t,n)}static ofLength(t){return new V(0,t)}static ofStartAndLength(t,n){return new V(t,t+n)}constructor(t,n){if(this.start=t,this.endExclusive=n,t>n)throw new le(`Invalid range: ${this.toString()}`)}get isEmpty(){return this.start===this.endExclusive}delta(t){return new V(this.start+t,this.endExclusive+t)}deltaStart(t){return new V(this.start+t,this.endExclusive)}deltaEnd(t){return new V(this.start,this.endExclusive+t)}get length(){return this.endExclusive-this.start}toString(){return`[${this.start}, ${this.endExclusive})`}contains(t){return this.start<=t&&t<this.endExclusive}join(t){return new V(Math.min(this.start,t.start),Math.max(this.endExclusive,t.endExclusive))}intersect(t){const n=Math.max(this.start,t.start),r=Math.min(this.endExclusive,t.endExclusive);if(n<=r)return new V(n,r)}intersects(t){const n=Math.max(this.start,t.start),r=Math.min(this.endExclusive,t.endExclusive);return n<r}isBefore(t){return this.endExclusive<=t.start}isAfter(t){return this.start>=t.endExclusive}slice(t){return t.slice(this.start,this.endExclusive)}substring(t){return t.substring(this.start,this.endExclusive)}clip(t){if(this.isEmpty)throw new le(`Invalid clipping range: ${this.toString()}`);return Math.max(this.start,Math.min(this.endExclusive-1,t))}clipCyclic(t){if(this.isEmpty)throw new le(`Invalid clipping range: ${this.toString()}`);return t<this.start?this.endExclusive-(this.start-t)%this.length:t>=this.endExclusive?this.start+(t-this.start)%this.length:t}forEach(t){for(let n=this.start;n<this.endExclusive;n++)t(n)}}function Ie(e,t){const n=Ge(e,t);return n===-1?void 0:e[n]}function Ge(e,t,n=0,r=e.length){let s=n,i=r;for(;s<i;){const o=Math.floor((s+i)/2);t(e[o])?s=o+1:i=o}return s-1}function ji(e,t){const n=$t(e,t);return n===e.length?void 0:e[n]}function $t(e,t,n=0,r=e.length){let s=n,i=r;for(;s<i;){const o=Math.floor((s+i)/2);t(e[o])?i=o:s=o+1}return s}class je{constructor(t){this._array=t,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(je.assertInvariants){if(this._prevFindLastPredicate){for(const r of this._array)if(this._prevFindLastPredicate(r)&&!t(r))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=t}const n=Ge(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=n+1,n===-1?void 0:this._array[n]}}je.assertInvariants=!1;class D{static fromRangeInclusive(t){return new D(t.startLineNumber,t.endLineNumber+1)}static joinMany(t){if(t.length===0)return[];let n=new ce(t[0].slice());for(let r=1;r<t.length;r++)n=n.getUnion(new ce(t[r].slice()));return n.ranges}static join(t){if(t.length===0)throw new le("lineRanges cannot be empty");let n=t[0].startLineNumber,r=t[0].endLineNumberExclusive;for(let s=1;s<t.length;s++)n=Math.min(n,t[s].startLineNumber),r=Math.max(r,t[s].endLineNumberExclusive);return new D(n,r)}static ofLength(t,n){return new D(t,t+n)}static deserialize(t){return new D(t[0],t[1])}constructor(t,n){if(t>n)throw new le(`startLineNumber ${t} cannot be after endLineNumberExclusive ${n}`);this.startLineNumber=t,this.endLineNumberExclusive=n}contains(t){return this.startLineNumber<=t&&t<this.endLineNumberExclusive}get isEmpty(){return this.startLineNumber===this.endLineNumberExclusive}delta(t){return new D(this.startLineNumber+t,this.endLineNumberExclusive+t)}deltaLength(t){return new D(this.startLineNumber,this.endLineNumberExclusive+t)}get length(){return this.endLineNumberExclusive-this.startLineNumber}join(t){return new D(Math.min(this.startLineNumber,t.startLineNumber),Math.max(this.endLineNumberExclusive,t.endLineNu
`);this.histogram[l]=(this.histogram[l]||0)+1}this.totalCount=s}computeSimilarity(t){var n,r;let s=0;const i=Math.max(this.histogram.length,t.histogram.length);for(let o=0;o<i;o++)s+=Math.abs(((n=this.histogram[o])!==null&&n!==void 0?n:0)-((r=t.histogram[o])!==null&&r!==void 0?r:0));return 1-s/(this.totalCount+t.totalCount)}}qe.chrKeys=new Map;class ta{compute(t,n,r=Qe.instance,s){if(t.length===0||n.length===0)return fe.trivial(t,n);const i=new jt(t.length,n.length),o=new jt(t.length,n.length),l=new jt(t.length,n.length);for(let g=0;g<t.length;g++)for(let x=0;x<n.length;x++){if(!r.isValid())return fe.trivialTimedOut(t,n);const v=g===0?0:i.get(g-1,x),L=x===0?0:i.get(g,x-1);let S;t.getElement(g)===n.getElement(x)?(g===0||x===0?S=0:S=i.get(g-1,x-1),g>0&&x>0&&o.get(g-1,x-1)===3&&(S+=l.get(g-1,x-1)),S+=s?s(g,x):1):S=-1;const _=Math.max(v,L,S);if(_===S){const N=g>0&&x>0?l.get(g-1,x-1):0;l.set(g,x,N+1),o.set(g,x,3)}else _===v?(l.set(g,x,0),o.set(g,x,1)):_===L&&(l.set(g,x,0),o.set(g,x,2));i.set(g,x,_)}const u=[];let c=t.length,f=n.length;function h(g,x){(g+1!==c||x+1!==f)&&u.push(new z(new V(g+1,c),new V(x+1,f))),c=g,f=x}let d=t.length-1,m=n.length-1;for(;d>=0&&m>=0;)o.get(d,m)===3?(h(d,m),d--,m--):o.get(d,m)===1?d--:m--;return h(-1,-1),u.reverse(),new fe(u,!1)}}class Vr{compute(t,n,r=Qe.instance){if(t.length===0||n.length===0)return fe.trivial(t,n);const s=t,i=n;function o(x,v){for(;x<s.length&&v<i.length&&s.getElement(x)===i.getElement(v);)x++,v++;return x}let l=0;const u=new na;u.set(0,o(0,0));const c=new ra;c.set(0,u.get(0)===0?null:new Ir(null,0,0,u.get(0)));let f=0;e:for(;;){if(l++,!r.isValid())return fe.trivialTimedOut(s,i);const x=-Math.min(l,i.length+l%2),v=Math.min(l,s.length+l%2);for(f=x;f<=v;f+=2){const L=f===v?-1:u.get(f+1),S=f===x?-1:u.get(f-1)+1,_=Math.min(Math.max(L,S),s.length),N=_-f;if(_>s.length||N>i.length)continue;const p=o(_,N);u.set(f,p);const R=_===L?c.get(f+1):c.get(f-1);if(c.set(f,p!==_?new Ir(R,_,N,p-_):R),u.get(f)===s.length&&u.get(f)-f===i.length)break e}}let h=c.get(f);const d=[];let m=s.length,g=i.length;for(;;){const x=h?h.x+h.length:0,v=h?h.y+h.length:0;if((x!==m||v!==g)&&d.push(new z(new V(x,m),new V(v,g))),!h)break;m=h.x,g=h.y,h=h.prev}return d.reverse(),new fe(d,!1)}}class Ir{constructor(t,n,r,s){this.prev=t,this.x=n,this.y=r,this.length=s}}class na{constructor(){this.positiveArr=new Int32Array(10),this.negativeArr=new Int32Array(10)}get(t){return t<0?(t=-t-1,this.negativeArr[t]):this.positiveArr[t]}set(t,n){if(t<0){if(t=-t-1,t>=this.negativeArr.length){const r=this.negativeArr;this.negativeArr=new Int32Array(r.length*2),this.negativeArr.set(r)}this.negativeArr[t]=n}else{if(t>=this.positiveArr.length){const r=this.positiveArr;this.positiveArr=new Int32Array(r.length*2),this.positiveArr.set(r)}this.positiveArr[t]=n}}}class ra{constructor(){this.positiveArr=[],this.negativeArr=[]}get(t){return t<0?(t=-t-1,this.negativeArr[t]):this.positiveArr[t]}set(t,n){t<0?(t=-t-1,this.negativeArr[t]=n):this.positiveArr[t]=n}}class mt{constructor(t,n,r){this.lines=t,this.considerWhitespaceChanges=r,this.elements=[],this.firstCharOffsetByLine=[],this.additionalOffsetByLine=[];let s=!1;n.start>0&&n.endExclusive>=t.length&&(n=new V(n.start-1,n.endExclusive),s=!0),this.lineRange=n,this.firstCharOffsetByLine[0]=0;for(let i=this.lineRange.start;i<this.lineRange.endExclusive;i++){let o=t[i],l=0;if(s)l=o.length,o="",s=!1;else if(!r){const u=o.trimStart();l=o.length-u.length,o=u.trimEnd()}this.additionalOffsetByLine.push(l);for(let u=0;u<o.length;u++)this.elements.push(o.charCodeAt(u));i<t.length-1&&(this.elements.push(10),this.firstCharOffsetByLine[i-this.lineRange.start+1]=this.elements.length)}this.additionalOffsetByLine.push(0)}toString(){return`Slice: "${this.text}"`}get text(){return this.getText(new V(0,this.length))}getText(t){return this.elements.slice(t.start,t.endExclusive).map(n=>String.fromCharCode(n)).join("")}getElement(t){return this.elements[t]}get length(){return this.elements.length}getBoundaryScore(t){const n=qr(t>0?this.elements[t-1]:-1),r=qr(t<this.elements.length?this.elements[t]:-1);if(n===7&&r
`).length>=15&&aa(h,m=>m.length>=2)>=2}),o=ca(e,o),o}function aa(e,t){let n=0;for(const r of e)t(r)&&n++;return n}function oa(e,t,n,r){const s=[],i=e.filter(u=>u.modified.isEmpty&&u.original.length>=3).map(u=>new qe(u.original,t,u)),o=new Set(e.filter(u=>u.original.isEmpty&&u.modified.length>=3).map(u=>new qe(u.modified,n,u))),l=new Set;for(const u of i){let c=-1,f;for(const h of o){const d=u.computeSimilarity(h);d>c&&(c=d,f=h)}if(c>.9&&f&&(o.delete(f),s.push(new oe(u.range,f.range)),l.add(u.source),l.add(f.source)),!r.isValid())return{moves:s,excludedChanges:l}}return{moves:s,excludedChanges:l}}function la(e,t,n,r,s,i){const o=[],l=new Bi;for(const d of e)for(let m=d.original.startLineNumber;m<d.original.endLineNumberExclusive-2;m++){const g=`${t[m-1]}:${t[m+1-1]}:${t[m+2-1]}`;l.add(g,{range:new D(m,m+3)})}const u=[];e.sort(at(d=>d.modified.startLineNumber,ot));for(const d of e){let m=[];for(let g=d.modified.startLineNumber;g<d.modified.endLineNumberExclusive-2;g++){const x=`${n[g-1]}:${n[g+1-1]}:${n[g+2-1]}`,v=new D(g,g+3),L=[];l.forEach(x,({range:S})=>{for(const N of m)if(N.originalLineRange.endLineNumberExclusive+1===S.endLineNumberExclusive&&N.modifiedLineRange.endLineNumberExclusive+1===v.endLineNumberExclusive){N.originalLineRange=new D(N.originalLineRange.startLineNumber,S.endLineNumberExclusive),N.modifiedLineRange=new D(N.modifiedLineRange.startLineNumber,v.endLineNumberExclusive),L.push(N);return}const _={modifiedLineRange:v,originalLineRange:S};u.push(_),L.push(_)}),m=L}if(!i.isValid())return[]}u.sort(fi(at(d=>d.modifiedLineRange.length,ot)));const c=new ce,f=new ce;for(const d of u){const m=d.modifiedLineRange.startLineNumber-d.originalLineRange.startLineNumber,g=c.subtractFrom(d.modifiedLineRange),x=f.subtractFrom(d.originalLineRange).getWithDelta(m),v=g.getIntersection(x);for(const L of v.ranges){if(L.length<3)continue;const S=L,_=L.delta(-m);o.push(new oe(_,S)),c.addRange(S),f.addRange(_)}}o.sort(at(d=>d.original.startLineNumber,ot));const h=new je(e);for(let d=0;d<o.length;d++){const m=o[d],g=h.findLastMonotonous(R=>R.original.startLineNumber<=m.original.startLineNumber),x=Ie(e,R=>R.modified.startLineNumber<=m.modified.startLineNumber),v=Math.max(m.original.startLineNumber-g.original.startLineNumber,m.modified.startLineNumber-x.modified.startLineNumber),L=h.findLastMonotonous(R=>R.original.startLineNumber<m.original.endLineNumberExclusive),S=Ie(e,R=>R.modified.startLineNumber<m.modified.endLineNumberExclusive),_=Math.max(L.original.endLineNumberExclusive-m.original.endLineNumberExclusive,S.modified.endLineNumberExclusive-m.modified.endLineNumberExclusive);let N;for(N=0;N<v;N++){const R=m.original.startLineNumber-N-1,y=m.modified.startLineNumber-N-1;if(R>r.length||y>s.length||c.contains(y)||f.contains(R)||!Ur(r[R-1],s[y-1],i))break}N>0&&(f.addRange(new D(m.original.startLineNumber-N,m.original.startLineNumber)),c.addRange(new D(m.modified.startLineNumber-N,m.modified.startLineNumber)));let p;for(p=0;p<_;p++){const R=m.original.endLineNumberExclusive+p,y=m.modified.endLineNumberExclusive+p;if(R>r.length||y>s.length||c.contains(y)||f.contains(R)||!Ur(r[R-1],s[y-1],i))break}p>0&&(f.addRange(new D(m.original.endLineNumberExclusive,m.original.endLineNumberExclusive+p)),c.addRange(new D(m.modified.endLineNumberExclusive,m.modified.endLineNumberExclusive+p))),(N>0||p>0)&&(o[d]=new oe(new D(m.original.startLineNumber-N,m.original.endLineNumberExclusive+p),new D(m.modified.startLineNumber-N,m.modified.endLineNumberExclusive+p)))}return o}function Ur(e,t,n){if(e.trim()===t.trim())return!0;if(e.length>300&&t.length>300)return!1;const s=new Vr().compute(new mt([e],new V(0,1),!1),new mt([t],new V(0,1),!1),n);let i=0;const o=z.invert(s.diffs,e.length);for(const f of o)f.seq1Range.forEach(h=>{Xt(e.charCodeAt(h))||i++});function l(f){let h=0;for(let d=0;d<e.length;d++)Xt(f.charCodeAt(d))||h++;return h}const u=l(e.length>t.length?e:t);return i/u>.6&&u>10}function ua(e){if(e.length===0)return e;e.sort(at(n=>n.original.startLineNumber,ot));const t=[e[0]];for(let n=1;n<e.length;n++){const r=t[t.length-1],s=e[n],i=s.original
`)}isStronglyEqual(t,n){return this.lines[t]===this.lines[n]}}function Or(e){let t=0;for(;t<e.length&&(e.charCodeAt(t)===32||e.charCodeAt(t)===9);)t++;return t}class _a{constructor(){this.dynamicProgrammingDiffing=new ta,this.myersDiffingAlgorithm=new Vr}computeDiff(t,n,r){if(t.length<=1&&oi(t,n,(p,R)=>p===R))return new dt([],[],!1);if(t.length===1&&t[0].length===0||n.length===1&&n[0].length===0)return new dt([new he(new D(1,t.length+1),new D(1,n.length+1),[new ve(new F(1,1,t.length,t[t.length-1].length+1),new F(1,1,n.length,n[n.length-1].length+1))])],[],!1);const s=r.maxComputationTimeMs===0?Qe.instance:new ea(r.maxComputationTimeMs),i=!r.ignoreTrimWhitespace,o=new Map;function l(p){let R=o.get(p);return R===void 0&&(R=o.size,o.set(p,R)),R}const u=t.map(p=>l(p.trim())),c=n.map(p=>l(p.trim())),f=new $r(u,t),h=new $r(c,n),d=f.length+h.length<1700?this.dynamicProgrammingDiffing.compute(f,h,s,(p,R)=>t[p]===n[R]?n[R].length===0?.1:1+Math.log(1+n[R].length):.99):this.myersDiffingAlgorithm.compute(f,h,s);let m=d.diffs,g=d.hitTimeout;m=Hr(f,h,m),m=ga(f,h,m);const x=[],v=p=>{if(i)for(let R=0;R<p;R++){const y=L+R,E=S+R;if(t[y]!==n[E]){const q=this.refineDiff(t,n,new z(new V(y,y+1),new V(E,E+1)),s,i);for(const G of q.mappings)x.push(G);q.hitTimeout&&(g=!0)}}};let L=0,S=0;for(const p of m){ft(()=>p.seq1Range.start-L===p.seq2Range.start-S);const R=p.seq1Range.start-L;v(R),L=p.seq1Range.endExclusive,S=p.seq2Range.endExclusive;const y=this.refineDiff(t,n,p,s,i);y.hitTimeout&&(g=!0);for(const E of y.mappings)x.push(E)}v(t.length-L);const _=Gr(x,t,n);let N=[];return r.computeMoves&&(N=this.computeMoves(_,t,n,u,c,s,i)),ft(()=>{function p(y,E){if(y.lineNumber<1||y.lineNumber>E.length)return!1;const q=E[y.lineNumber-1];return!(y.column<1||y.column>q.length+1)}function R(y,E){return!(y.startLineNumber<1||y.startLineNumber>E.length+1||y.endLineNumberExclusive<1||y.endLineNumberExclusive>E.length+1)}for(const y of _){if(!y.innerChanges)return!1;for(const E of y.innerChanges)if(!(p(E.modifiedRange.getStartPosition(),n)&&p(E.modifiedRange.getEndPosition(),n)&&p(E.originalRange.getStartPosition(),t)&&p(E.originalRange.getEndPosition(),t)))return!1;if(!R(y.modified,n)||!R(y.original,t))return!1}return!0}),new dt(_,N,g)}computeMoves(t,n,r,s,i,o,l){return ia(t,n,r,s,i,o).map(f=>{const h=this.refineDiff(n,r,new z(f.original.toOffsetRange(),f.modified.toOffsetRange()),o,l),d=Gr(h.mappings,n,r,!0);return new Gi(f,d)})}refineDiff(t,n,r,s,i){const o=new mt(t,r.seq1Range,i),l=new mt(n,r.seq2Range,i),u=o.length+l.length<500?this.dynamicProgrammingDiffing.compute(o,l,s):this.myersDiffingAlgorithm.compute(o,l,s);let c=u.diffs;return c=Hr(o,l,c),c=da(o,l,c),c=fa(o,l,c),c=ba(o,l,c),{mappings:c.map(h=>new ve(o.translateRange(h.seq1Range),l.translateRange(h.seq2Range))),hitTimeout:u.hitTimeout}}}function Gr(e,t,n,r=!1){const s=[];for(const i of li(e.map(o=>xa(o,t,n)),(o,l)=>o.original.overlapOrTouch(l.original)||o.modified.overlapOrTouch(l.modified))){const o=i[0],l=i[i.length-1];s.push(new he(o.original.join(l.original),o.modified.join(l.modified),i.map(u=>u.innerChanges[0])))}return ft(()=>!r&&s.length>0&&(s[0].modified.startLineNumber!==s[0].original.startLineNumber||n.length-s[s.length-1].modified.endLineNumberExclusive!==t.length-s[s.length-1].original.endLineNumberExclusive)?!1:Mr(s,(i,o)=>o.original.startLineNumber-i.original.endLineNumberExclusive===o.modified.startLineNumber-i.modified.endLineNumberExclusive&&i.original.endLineNumberExclusive<o.original.startLineNumber&&i.modified.endLineNumberExclusive<o.modified.startLineNumber)),s}function xa(e,t,n){let r=0,s=0;e.modifiedRange.endColumn===1&&e.originalRange.endColumn===1&&e.originalRange.startLineNumber+r<=e.originalRange.endLineNumber&&e.modifiedRange.startLineNumber+r<=e.modifiedRange.endLineNumber&&(s=-1),e.modifiedRange.startColumn-1>=n[e.modifiedRange.startLineNumber-1].length&&e.originalRange.startColumn-1>=t[e.originalRange.startLineNumber-1].length&&e.originalRange.startLineNumber<=e.originalRange.endLineNumber+s&&e.modifiedRange.startLineNumber<=e.modifiedRange.endLineNumber+s&&(r=1);cons
|