varOS;!function(t){lete;!function(e){classiextendse.BaseApplication{constructor(t){super("SQLiteDBBrowser",t)}menu(){return[{text:"__(File)",nodes:[{text:"__(New database)",dataid:"new",shortcut:"A-N"},{text:"__(Open database)",dataid:"open",shortcut:"A-O"}],onchildselect:t=>{switch(t.data.item.data.dataid){case"new":returnthis.newFile();case"open":returnthis.openFile()}}}]}list_tables(){this.filehandle.read().then(t=>{conste=[];for(letiint)e.push({text:i,name:i,handle:t[i]});this.tbl_list.data=e,e.length>0&&(this.tbl_list.selected=e.length-1)})}asyncopenFile(){try{lett;t=this.args&&this.args.length>0?this.args[0].path.asFileHandle():(awaitthis.openDialog("FileDialog",{title:__("Open file"),mimes:this.meta().mimes})).file.path.asFileHandle(),this.filehandle=("sqlite://"+t.genealogy.join("/")).asFileHandle(),awaitthis.filehandle.onready(),this.list_tables()}catch(t){this.error(__("Unable to open database file: {0}",t.toString()),t)}}asyncnewFile(){try{conste=awaitthis.openDialog("FileDialog",{title:__("Save as"),file:"Untitled.db"});vart=e.file.path.asFileHandle();"file"===e.file.type&&(t=t.parent());consti=`${t.path}/${e.name}`.asFileHandle();this.filehandle=("sqlite://"+i.genealogy.join("/")).asFileHandle(),awaitthis.filehandle.onready(),this.list_tables()}catch(t){this.error(__("Unable to init database file: {0}",t.toString()),t)}}main(){this.filehandle=void0,this.tbl_list=this.find("tbl-list"),this.grid_table=this.find("tb-browser"),this.grid_scheme=this.find("sch-browser"),this.grid_table.resizable=!0,this.grid_scheme.resizable=!0,this.grid_scheme.header=[{text:__("Field name")},{text:__("Field type")}],this.btn_loadmore=this.find("bt-load-next"),this.container=this.find("container"),this.bindKey("ALT-N",()=>this.newFile()),this.bindKey("ALT-O",()=>this.openFile()),this.container.ontabselect=t=>{if(0==this.container.selectedIndex){if(!this.tbl_list.selectedItem)return;constt=this.tbl_list.selectedItem.data.handle.info.schema;if(!t)return;conste=[];for(letiint.types)e.push([{text:i},{text:t.types[i]}]);this.grid_scheme.rows=e}},this.find("bt-rm-table").onbtclick=asynct=>{try{if(!this.filehandle)returnthis.notify(__("Please open a database file"));if(null==this.tbl_list.selectedItem)return;constt=this.tbl_list.selectedItem.data.name;awaitthis.openDialog("YesNoDialog",{title:__("Confirm delete?"),text:__("Do you realy want to delete table: {0}",t)})&&(awaitthis.filehandle.remove(t),this.list_tables())}catch(t){this.error(__("Unable to execute action table delete: {0}",t.toString()),t)}},this.find("bt-add-table").onbtclick=asynct=>{try{if(!this.filehandle)returnthis.notify(__("Please open a database file"));constt=awaitthis.openDialog(newa,{title:__("Create new table")});this.filehandle.cache=t.schema,awaitthis.filehandle.write(t.name),this.list_tables()}catch(t){this.error(__("Unable to create table: {0}",t.toString()),t)}},this.find("btn-edit-record").onbtclick=asynct=>{this.edit_record()},this.find("btn-add-record").onbtclick=asynct=>{this.add_record()},this.find("btn-delete-record").onbtclick=asynct=>{this.remove_record()},this.btn_loadmore.onbtclick=asynct=>{try{awaitthis.load_table()}catch(t){this.error(__("Error reading table: {0}",t.toString()),t)}},this.find("bt-refresh").onbtclick=asynct=>{try{this.last_max_id=0;constt=this.tbl_list.selectedItem.data.handle,e=awaitt.read({fields:["COUNT(*)"]});this.n_records=e[0]["COUNT(*)"],this.grid_table.rows=[],awaitthis.load_table()}catch(t){this.error(__("Error reload table: {0}",t.toString()),t)}},this.tbl_list.onlistselect=asynct=>{try{if(!this.tbl_list.selectedItem)return;constt=this.tbl_list.selectedItem.data.handle;awaitt.onready(),this.last_max_id=0;conste=t.info.schema.fields.map(t=>({text:t}));this.grid_table.header=e,this.grid_table.rows=[];consti=awaitt.read({fields:["COUNT(*)"]});this.n_records=i[0]["COUNT(*)"],this.btn_loadmore.text="0/"+this.n_records,awaitthis.load_table(),this.container.selectedIndex=1}catch(t){this.error(__("Error reading table: {0}",t.toString()),t)}},this.grid_table.oncelldbclick=asy