varOS;!function(t){lete,i;!function(e){leti;!function(e){classiextendst.API.VFS.BaseFileHandle{constructor(t){super(""),this.path=`${t[0].path} -> ${t[1].path}`,this.cache=t,this.basename=`${t[0].basename} -> ${t[1].basename}`,this.info={type:"file",mime:void0,size:0,name:this.basename,path:this.path},this.ready=!0}meta(){returnnewPromise(async(t,e)=>{try{awaitPromise.all([this.cache[0].meta(),this.cache[1].meta]),t({result:this.info,error:!1})}catch(t){e(t)}})}_rd(t){returnnewPromise(async(t,e)=>{try{this.cache[0].cache=awaitthis.cache[0].read(),this.cache[1].cache=awaitthis.cache[1].read(),t(this.cache)}catch(t){e(t)}})}_wr(t,e){returnthis.cache=e,newPromise((t,e)=>{t({result:!0,error:!1})})}setPath(t){}}e.DiffEditorFileHandle=i}(i=e.VFS||(e.VFS={}))}(e=t.API||(t.API={})),function(t){t.BaseEditorModel=class{constructor(t,e,i){this.container=i,this.currfile="Untitled".asFileHandle(),this.tabbar=e,this.editorSetup(i),this.app=t,this.onstatuschange=void0,this.on("focus",()=>{this.onstatuschange&&this.onstatuschange(this.getEditorStatus())}),this.on("input",()=>{if(!this.currfile.dirty)returnconsole.log("dirty",this.currfile.path),this.currfile.dirty=!0,this.currfile.text+="*",this.tabbar.update(void0)}),this.on("changeCursor",()=>{this.onstatuschange&&this.onstatuschange(this.getEditorStatus())}),this.tabbar.ontabselect=t=>this.selecteTab($(t.data.item).index()),this.tabbar.ontabclose=t=>{conste=t.data.item;return!!e&&(e.data.dirty?(this.app.openDialog("YesNoDialog",{title:__("Close tab"),text:__("Close without saving ?")}).then(t=>t?this.closeTab(e):this.focus()),!1):this.closeTab(e))}}findTabByFile(t){conste=this.tabbar.items,i=(()=>{consti=[];for(leta=0;a<e.length;a++)e[a].hash()===t.hash()&&i.push(a);returni})();return0===i.length?-1:i[0]}newTab(t){t.text=t.basename?t.basename:t.path,t.cache||(t.cache=""),t.textModel=this.newTextModelFrom(t),this.currfile.selected=!1,t.selected=!0,this.tabbar.push(t)}closeTab(t){this.tabbar.delete(t);conste=this.tabbar.items.length;return0===e?(this.openFile("Untitled".asFileHandle()),!1):(this.tabbar.selected=e-1,!1)}selecteTab(t){conste=this.tabbar.items[t];e&&(this.currfile!==e&&(this.currfile.textModel=this.getTexModel(),this.currfile.selected=!1,this.currfile=e),this.setTextModel(e.textModel),this.focus())}selectFile(t){conste=this.findTabByFile(t.asFileHandle());-1!==e&&(this.tabbar.selected=e)}openFile(t){conste=this.findTabByFile(t);-1===e?"Untitled"!==t.path.toString()?t.read().then(e=>(t.cache=e||"",this.newTab(t))).catch(e=>this.app.error(__("Unable to open: {0}",t.path),e)):this.newTab(t):this.tabbar.selected=e}write(){this.currfile.cache=this.getValue(),this.currfile.write("text/plain").then(t=>{this.currfile.dirty=!1,this.currfile.text=this.currfile.basename,this.tabbar.update(void0)}).catch(t=>this.app.error(__("Unable to save file: {0}",this.currfile.path),t))}save(){returnthis.currfile.cache=this.getValue(),this.currfile.basename?this.write():this.saveAs()}saveAs(){this.app.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(t=>{lete=t.file.path.asFileHandle();"file"===t.file.type&&(e=e.parent()),this.currfile.setPath(`${e.path}/${t.name}`),this.write()})}dirties(){constt=[];for(leteofArray.from(this.tabbar.items))e.dirty&&t.push(e);returnt}setcontextmenuHandle(t){this.container.contextmenuHandle=t}closeAll(){this.tabbar.items=[],this.openFile("Untitled".asFileHandle()),this.resetEditor()}isDirty(){returnthis.dirties().length>0}setTabbarCtxMenu(t,e){this.tabbar.contextmenuHandle=(i,a)=>(a.items=t,a.onmenuselect=t=>{if(e){consta=$(i.target).closest("afx-list-item");e(a[0],t.data.item.data)}},a.show(i))}}}(i=t.application||(t.application={}))}(OS||(OS={})),function(t){lete;!function(e){classiextendst.application.BaseEditorModel{constructor(t,e,i){super(t,e,i)}resetEditor(){}getTexModel(){return{model:this.editor.getModel(),position:this.editor.getPosition()}}setTextModel(t){this.editor.setModel(t.model),t.position&&(this.editor.setPosition(t.position),this.editor.revealLineInCenter(t.position.lineNumber))}