Select a pattern to edit
+or create a new one with the + button
+=0&&f>=0&&t(a[x],c[f],u);)x--,f--;let y=x+1-h,w=h===f+1?void 0:c.slice(h,f+1);return w!==void 0?{start:h,deleteCount:y,cells:w}:{start:h,deleteCount:y}}else return h
i.document.uri.toString()))}}n.create=e})(Eu||(Eu={}));var qs=class{constructor(e,t){this.client=e,this.options=t,this.notebookSyncInfo=new Map,this.notebookDidOpen=new Set,this.disposables=[],this.selector=e.protocol2CodeConverter.asDocumentSelector(Tu.asDocumentSelector(t)),Wt.workspace.onDidOpenNotebookDocument(i=>{this.notebookDidOpen.add(i.uri.toString()),this.didOpen(i)},void 0,this.disposables);for(let i of Wt.workspace.notebookDocuments)this.notebookDidOpen.add(i.uri.toString()),this.didOpen(i);Wt.workspace.onDidChangeNotebookDocument(i=>this.didChangeNotebookDocument(i),void 0,this.disposables),this.options.save===!0&&Wt.workspace.onDidSaveNotebookDocument(i=>this.didSave(i),void 0,this.disposables),Wt.workspace.onDidCloseNotebookDocument(i=>{this.didClose(i),this.notebookDidOpen.delete(i.uri.toString())},void 0,this.disposables)}getState(){for(let e of Wt.workspace.notebookDocuments)if(this.getMatchingCells(e)!==void 0)return{kind:"document",id:"$internal",registrations:!0,matches:!0};return{kind:"document",id:"$internal",registrations:!0,matches:!1}}get mode(){return"notebook"}handles(e){return Wt.languages.match(this.selector,e)>0}didOpenNotebookCellTextDocument(e,t){if(Wt.languages.match(this.selector,t.document)===0||!this.notebookDidOpen.has(e.uri.toString()))return;let i=this.notebookSyncInfo.get(e.uri.toString()),r=this.cellMatches(e,t);if(i!==void 0){let s=i.uris.has(t.document.uri.toString());if(r&&s||!r&&!s)return;if(r){let o=this.getMatchingCells(e);if(o!==void 0){let a=this.asNotebookDocumentChangeEvent(e,void 0,i,o);a!==void 0&&this.doSendChange(a,o).catch(()=>{})}}}else r&&this.doSendOpen(e,[t]).catch(()=>{})}didChangeNotebookCellTextDocument(e,t){Wt.languages.match(this.selector,t.document)!==0&&this.doSendChange({notebook:e,cells:{textContent:[t]}},void 0).catch(()=>{})}didCloseNotebookCellTextDocument(e,t){let i=this.notebookSyncInfo.get(e.uri.toString());if(i===void 0)return;let r=t.document.uri,s=i.cells.findIndex(o=>o.document.uri.toString()===r.toString());if(s!==-1)if(s===0&&i.cells.length===1)this.doSendClose(e,i.cells).catch(()=>{});else{let o=i.cells.slice(),a=o.splice(s,1);this.doSendChange({notebook:e,cells:{structure:{array:{start:s,deleteCount:1},didClose:a}}},o).catch(()=>{})}}dispose(){for(let e of this.disposables)e.dispose()}didOpen(e,t=this.getMatchingCells(e),i=this.notebookSyncInfo.get(e.uri.toString())){if(i!==void 0)if(t!==void 0){let r=this.asNotebookDocumentChangeEvent(e,void 0,i,t);r!==void 0&&this.doSendChange(r,t).catch(()=>{})}else this.doSendClose(e,[]).catch(()=>{});else{if(t===void 0)return;this.doSendOpen(e,t).catch(()=>{})}}didChangeNotebookDocument(e){let t=e.notebook,i=this.notebookSyncInfo.get(t.uri.toString());if(i===void 0){if(e.contentChanges.length===0)return;let r=this.getMatchingCells(t);if(r===void 0)return;this.didOpen(t,r,i)}else{let r=this.getMatchingCells(t);if(r===void 0){this.didClose(t,i);return}let s=this.asNotebookDocumentChangeEvent(e.notebook,e,i,r);s!==void 0&&this.doSendChange(s,r).catch(()=>{})}}didSave(e){this.notebookSyncInfo.get(e.uri.toString())!==void 0&&this.doSendSave(e).catch(()=>{})}didClose(e,t=this.notebookSyncInfo.get(e.uri.toString())){if(t===void 0)return;let i=e.getCells().filter(r=>t.uris.has(r.document.uri.toString()));this.doSendClose(e,i).catch(()=>{})}async sendDidOpenNotebookDocument(e){let t=this.getMatchingCells(e);if(t!==void 0)return this.doSendOpen(e,t)}async doSendOpen(e,t){let i=async(s,o)=>{let a=Os.c2p.asNotebookDocument(s,o,this.client.code2ProtocolConverter),c=o.map(u=>this.client.code2ProtocolConverter.asTextDocumentItem(u.document));try{await this.client.sendNotification(Ei.DidOpenNotebookDocumentNotification.type,{notebookDocument:a,cellTextDocuments:c})}catch(u){throw this.client.error("Sending DidOpenNotebookDocumentNotification failed",u),u}},r=this.client.middleware?.notebooks;return this.notebookSyncInfo.set(e.uri.toString(),Eu.create(t)),r?.didOpen!==void 0?r.didOpen(e,t,i):i(e,t)}async sendDidChangeNotebookDocument(e){return this.doSendChange(e,void 0)}async doSendChange(e,t=this.getMatchingCells(e.notebook)){let i=async s=>{try{await this.client.sendNotification(Ei.DidChangeNotebookDocumentNotification.type,{notebookDocument:Os.c2p.asVersionedNotebookDocumentIdentifier(s.notebook,this.client.code2ProtocolConverter),change:Os.c2p.asNotebookDocumentChangeEvent(s,this.client.code2ProtocolConverter)})}catch(o){throw this.client.error("Sending DidChangeNotebookDocumentNotification failed",o),o}},r=this.client.middleware?.notebooks;return e.cells?.structure!==void 0&&this.notebookSyncInfo.set(e.notebook.uri.toString(),Eu.create(t??[])),r?.didChange!==void 0?r?.didChange(e,i):i(e)}async sendDidSaveNotebookDocument(e){return this.doSendSave(e)}async doSendSave(e){let t=async r=>{try{await this.client.sendNotification(Ei.DidSaveNotebookDocumentNotification.type,{notebookDocument:{uri:this.client.code2ProtocolConverter.asUri(r.uri)}})}catch(s){throw this.client.error("Sending DidSaveNotebookDocumentNotification failed",s),s}},i=this.client.middleware?.notebooks;return i?.didSave!==void 0?i.didSave(e,t):t(e)}async sendDidCloseNotebookDocument(e){return this.doSendClose(e,this.getMatchingCells(e)??[])}async doSendClose(e,t){let i=async(s,o)=>{try{await this.client.sendNotification(Ei.DidCloseNotebookDocumentNotification.type,{notebookDocument:{uri:this.client.code2ProtocolConverter.asUri(s.uri)},cellTextDocuments:o.map(a=>this.client.code2ProtocolConverter.asTextDocumentIdentifier(a.document))})}catch(a){throw this.client.error("Sending DidCloseNotebookDocumentNotification failed",a),a}},r=this.client.middleware?.notebooks;return this.notebookSyncInfo.delete(e.uri.toString()),r?.didClose!==void 0?r.didClose(e,t,i):i(e,t)}asNotebookDocumentChangeEvent(e,t,i,r){if(t!==void 0&&t.notebook!==e)throw new Error("Notebook must be identical");let s={notebook:e};t?.metadata!==void 0&&(s.metadata=Os.c2p.asMetadata(t.metadata));let o;if(t?.cellChanges!==void 0&&t.cellChanges.length>0){let a=[];o=new Set(r.map(c=>c.document.uri.toString()));for(let c of t.cellChanges)o.has(c.cell.document.uri.toString())&&(c.executionSummary!==void 0||c.metadata!==void 0)&&a.push(c.cell);a.length>0&&(s.cells=s.cells??{},s.cells.data=a)}if((t?.contentChanges!==void 0&&t.contentChanges.length>0||t===void 0)&&i!==void 0&&r!==void 0){let a=i.cells,c=r,u=$h.computeDiff(a,c,!1),l,p;if(u!==void 0){l=u.cells===void 0?new Map:new Map(u.cells.map(f=>[f.document.uri.toString(),f])),p=u.deleteCount===0?new Map:new Map(a.slice(u.start,u.start+u.deleteCount).map(f=>[f.document.uri.toString(),f]));for(let f of Array.from(p.keys()))l.has(f)&&(p.delete(f),l.delete(f));s.cells=s.cells??{};let h=[],x=[];if(l.size>0||p.size>0){for(let f of l.values())h.push(f);for(let f of p.values())x.push(f)}s.cells.structure={array:u,didOpen:h,didClose:x}}}return Object.keys(s).length>1?s:void 0}getMatchingCells(e,t=e.getCells()){if(this.options.notebookSelector!==void 0){for(let i of this.options.notebookSelector)if(i.notebook===void 0||Hh.matchNotebook(i.notebook,e)){let r=this.filterCells(e,t,i.cells);return r.length===0?void 0:r}}}cellMatches(e,t){let i=this.getMatchingCells(e,[t]);return i!==void 0&&i[0]===t}filterCells(e,t,i){let r=i!==void 0?t.filter(s=>{let o=s.document.languageId;return i.some(a=>a.language==="*"||o===a.language)}):t;return typeof this.client.clientOptions.notebookDocumentOptions?.filterCells=="function"?this.client.clientOptions.notebookDocumentOptions.filterCells(e,r):r}},Pu=class n{constructor(e){this.client=e,this.registrations=new Map,this.registrationType=Ei.NotebookDocumentSyncRegistrationType.type,Wt.workspace.onDidOpenTextDocument(t=>{if(t.uri.scheme!==n.CellScheme)return;let[i,r]=this.findNotebookDocumentAndCell(t);if(!(i===void 0||r===void 0))for(let s of this.registrations.values())s instanceof qs&&s.didOpenNotebookCellTextDocument(i,r)}),Wt.workspace.onDidChangeTextDocument(t=>{if(t.contentChanges.length===0)return;let i=t.document;if(i.uri.scheme!==n.CellScheme)return;let[r]=this.findNotebookDocumentAndCell(i);if(r!==void 0)for(let s of this.registrations.values())s instanceof qs&&s.didChangeNotebookCellTextDocument(r,t)}),Wt.workspace.onDidCloseTextDocument(t=>{if(t.uri.scheme!==n.CellScheme)return;let[i,r]=this.findNotebookDocumentAndCell(t);if(!(i===void 0||r===void 0))for(let s of this.registrations.values())s instanceof qs&&s.didCloseNotebookCellTextDocument(i,r)})}getState(){if(this.registrations.size===0)return{kind:"document",id:this.registrationType.method,registrations:!1,matches:!1};for(let e of this.registrations.values()){let t=e.getState();if(t.kind==="document"&&t.registrations===!0&&t.matches===!0)return{kind:"document",id:this.registrationType.method,registrations:!0,matches:!0}}return{kind:"document",id:this.registrationType.method,registrations:!0,matches:!1}}fillClientCapabilities(e){let t=nR(nR(e,"notebookDocument"),"synchronization");t.dynamicRegistration=!0,t.executionSummarySupport=!0}preInitialize(e){let t=e.notebookDocumentSync;t!==void 0&&(this.dedicatedChannel=this.client.protocol2CodeConverter.asDocumentSelector(Tu.asDocumentSelector(t)))}initialize(e){let t=e.notebookDocumentSync;if(t===void 0)return;let i=t.id??LA.generateUuid();this.register({id:i,registerOptions:t})}register(e){let t=new qs(this.client,e.registerOptions);this.registrations.set(e.id,t)}unregister(e){let t=this.registrations.get(e);t&&t.dispose()}clear(){for(let e of this.registrations.values())e.dispose();this.registrations.clear()}handles(e){if(e.uri.scheme!==n.CellScheme)return!1;if(this.dedicatedChannel!==void 0&&Wt.languages.match(this.dedicatedChannel,e)>0)return!0;for(let t of this.registrations.values())if(t.handles(e))return!0;return!1}getProvider(e){for(let t of this.registrations.values())if(t.handles(e.document))return t}findNotebookDocumentAndCell(e){let t=e.uri.toString();for(let i of Wt.workspace.notebookDocuments)for(let r of i.getCells())if(r.document.uri.toString()===t)return[i,r];return[void 0,void 0]}};ku.NotebookDocumentSyncFeature=Pu;Pu.CellScheme="vscode-notebook-cell"});var sR=T(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.SyncConfigurationFeature=pr.toJSONObject=pr.ConfigurationFeature=void 0;var Fs=require("vscode"),Mo=ue(),MA=qn(),UA=tt(),rR=Ce(),Bh=class{constructor(e){this._client=e}getState(){return{kind:"static"}}fillClientCapabilities(e){e.workspace=e.workspace||{},e.workspace.configuration=!0}initialize(){let e=this._client;e.onRequest(Mo.ConfigurationRequest.type,(t,i)=>{let r=o=>{let a=[];for(let c of o.items){let u=c.scopeUri!==void 0&&c.scopeUri!==null?this._client.protocol2CodeConverter.asUri(c.scopeUri):void 0;a.push(this.getConfiguration(u,c.section!==null?c.section:void 0))}return a},s=e.middleware.workspace;return s&&s.configuration?s.configuration(t,i,r):r(t,i)})}getConfiguration(e,t){let i=null;if(t){let r=t.lastIndexOf(".");if(r===-1)i=Or(Fs.workspace.getConfiguration(void 0,e).get(t));else{let s=Fs.workspace.getConfiguration(t.substr(0,r),e);s&&(i=Or(s.get(t.substr(r+1))))}}else{let r=Fs.workspace.getConfiguration(void 0,e);i={};for(let s of Object.keys(r))r.has(s)&&(i[s]=Or(r.get(s)))}return i===void 0&&(i=null),i}clear(){}};pr.ConfigurationFeature=Bh;function Or(n){if(n){if(Array.isArray(n))return n.map(Or);if(typeof n=="object"){let e=Object.create(null);for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=Or(n[t]));return e}}return n}pr.toJSONObject=Or;var Wh=class{constructor(e){this._client=e,this.isCleared=!1,this._listeners=new Map}getState(){return{kind:"workspace",id:this.registrationType.method,registrations:this._listeners.size>0}}get registrationType(){return Mo.DidChangeConfigurationNotification.type}fillClientCapabilities(e){(0,rR.ensure)((0,rR.ensure)(e,"workspace"),"didChangeConfiguration").dynamicRegistration=!0}initialize(){this.isCleared=!1;let e=this._client.clientOptions.synchronize?.configurationSection;e!==void 0&&this.register({id:UA.generateUuid(),registerOptions:{section:e}})}register(e){let t=Fs.workspace.onDidChangeConfiguration(i=>{this.onDidChangeConfiguration(e.registerOptions.section,i)});this._listeners.set(e.id,t),e.registerOptions.section!==void 0&&this.onDidChangeConfiguration(e.registerOptions.section,void 0)}unregister(e){let t=this._listeners.get(e);t&&(this._listeners.delete(e),t.dispose())}clear(){for(let e of this._listeners.values())e.dispose();this._listeners.clear(),this.isCleared=!0}onDidChangeConfiguration(e,t){if(this.isCleared)return;let i;if(MA.string(e)?i=[e]:i=e,i!==void 0&&t!==void 0&&!i.some(a=>t.affectsConfiguration(a)))return;let r=async o=>o===void 0?this._client.sendNotification(Mo.DidChangeConfigurationNotification.type,{settings:null}):this._client.sendNotification(Mo.DidChangeConfigurationNotification.type,{settings:this.extractSettingsInformation(o)}),s=this._client.middleware.workspace?.didChangeConfiguration;(s?s(i,r):r(i)).catch(o=>{this._client.error(`Sending notification ${Mo.DidChangeConfigurationNotification.type.method} failed`,o)})}extractSettingsInformation(e){function t(s,o){let a=s;for(let c=0;c