import{Ls as e,Qi as t,ai as n,bo as r,js as i,oi as a,pa as o,si as s,za as c}from"./editorContextKeys-DnUTgpav.js";var l=r(`ILanguageFeaturesService`),u=r(`environmentService`),d=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},f=function(e,t){return function(n,r){t(n,r,e)}},p=r(`ILanguageFeatureDebounceService`),m;(function(e){let t=new WeakMap,n=0;function r(e){let r=t.get(e);return r===void 0&&(r=++n,t.set(e,r)),r}e.of=r})(m||={});var h=class{constructor(e){this._default=e}get(e){return this._default}update(e,t){return this._default}default(){return this._default}},g=class{constructor(e,n,r,i,a,o){this._logService=e,this._name=n,this._registry=r,this._default=i,this._min=a,this._max=o,this._cache=new t(50,.7)}_key(e){return e.id+this._registry.all(e).reduce((e,t)=>i(m.of(t),e),0)}get(e){let t=this._key(e),n=this._cache.get(t);return n?s(n.value,this._min,this._max):this.default()}update(t,n){let r=this._key(t),i=this._cache.get(r);i||(i=new a(6),this._cache.set(r,i));let o=s(i.update(n),this._min,this._max);return e(t.uri,`output`)||this._logService.trace(`[DEBOUNCE: ${this._name}] for ${t.uri.toString()} is ${o}ms`),o}_overall(){let e=new n;for(let[,t]of this._cache)e.update(t.value);return e.value}default(){return s(this._overall()|0||this._default,this._min,this._max)}},_=class{constructor(e,t){this._logService=e,this._data=new Map,this._isDev=t.isExtensionDevelopment||!t.isBuilt}for(e,t,n){let r=n?.min??50,i=n?.max??r**2,a=n?.key??void 0,o=`${m.of(e)},${r}${a?`,`+a:``}`,s=this._data.get(o);return s||(this._isDev?(this._logService.debug(`[DEBOUNCE: ${t}] is disabled in developed mode`),s=new h(r*1.5)):s=new g(this._logService,t,e,this._overallAverage()|0||r*1.5,r,i),this._data.set(o,s)),s}_overallAverage(){let e=new n;for(let t of this._data.values())e.update(t.default());return e.value}};_=d([f(0,c),f(1,u)],_),o(p,_,1);var v=class e{static capture(t){if(t.getScrollTop()===0||t.hasPendingScrollAnimation())return new e(t.getScrollTop(),t.getContentHeight(),null,0,null);let n=null,r=0,i=t.getVisibleRanges();if(i.length>0){n=i[0].getStartPosition();let e=t.getTopForPosition(n.lineNumber,n.column);r=t.getScrollTop()-e}return new e(t.getScrollTop(),t.getContentHeight(),n,r,t.getPosition())}constructor(e,t,n,r,i){this._initialScrollTop=e,this._initialContentHeight=t,this._visiblePosition=n,this._visiblePositionScrollDelta=r,this._cursorPosition=i}restore(e){if(!(this._initialContentHeight===e.getContentHeight()&&this._initialScrollTop===e.getScrollTop())&&this._visiblePosition){let t=e.getTopForPosition(this._visiblePosition.lineNumber,this._visiblePosition.column);e.setScrollTop(t+this._visiblePositionScrollDelta)}}restoreRelativeVerticalPositionOfCursor(e){if(this._initialContentHeight===e.getContentHeight()&&this._initialScrollTop===e.getScrollTop())return;let t=e.getPosition();if(!this._cursorPosition||!t)return;let n=e.getTopForLineNumber(t.lineNumber)-e.getTopForLineNumber(this._cursorPosition.lineNumber);e.setScrollTop(e.getScrollTop()+n,1)}};export{l as i,p as n,u as r,v as t};