(function(){var i;i=class extends this.OS.application.BaseApplication{constructor(i){super("Preview",i)}main(){return this.currfile=void 0,this.args&&this.args.length>0&&(this.currfile=this.args[0].path.asFileHandle()),this.view=this.find("view"),this.status=this.find("status"),this.zoom=this.find("zoom"),this.btreset=this.find("btreset"),this.zoom.onvaluechange=i=>this.setViewScale(i.data),this.btreset.onbtclick=i=>(this.zoom.value=100,this.setViewScale(100)),this.img=void 0,this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-X",()=>this.actionFile(this.name+"-Close")),this.zoom.max=200,this.zoom.value=100,this.open(this.currfile)}open(i){if(i)return this.currfile!==i&&(this.currfile=i),i.onready().then(()=>(i.info.size=(i.info.size/1024).toFixed(2),this.renderFile())).catch(t=>this.error(__("File not found {0}",i.path),t))}renderFile(){var i;if(i=this.currfile.info.mime)return this.img=void 0,$(this.view).empty(),this.zoom.value=100,this.scheme.apptitle=this.currfile.info.name,i.match(/^[^\/]+\/.*pdf.*/g)?this.renderPDF():i.match(/image\/.*svg.*/g)?this.renderSVG():i.match(/image\/.*/g)?this.renderImage():this.notify(__("Mime type {0} is not supported",file.info.mime))}setStatus(i){return $(this.status).html(i)}setViewScale(i){var t,e,s,h,r,a;if(this.currfile){if(r=i/100,(h=this.currfile.info.mime).match(/image\/.*svg.*/g))return $($(this.view).children()[0]).css("width",Math.round(i)+"%").css("height",Math.round(i)+"%");if(h.match(/image\/.*/g)){if(!this.img)return;return e=(t=$(this.view).children()[0]).getContext("2d"),a=this.img.width*r,s=this.img.height*r,t.height=s,t.width=a,e.clearRect(0,0,t.width,t.height),e.scale(r,r),e.drawImage(this.img,0,0)}}}renderPDF(){var i;return $(this.find("statcontainer")).hide(),this.trigger("resize"),$(this.view).attr("class","pdf"),i=$("