(function(){var logStore,syncStore,waitTimeFn;logStore=idbKeyval.createStore("log-store","log-store"),syncStore=idbKeyval.createStore("sync-store","sync"),waitTimeFn=function(timeout){return null==timeout&&(timeout=1e3),new Promise((function(resolve,reject){return setTimeout((function(){return resolve()}),timeout)}))},window.OmegaDebug={getProjectVersion:function(){return chrome.runtime.getManifest().version},getExtensionVersion:function(){return chrome.runtime.getManifest().version},downloadLog:function(){return idbKeyval.entries(logStore).then((function(entries){var zip,zipFolder;return zip=new JSZip,zipFolder=zip.folder("ZeroOmega"),entries.forEach((function(entry){if("lastError"!==entry[0])return zipFolder.file(entry[1].date+".log",entry[1].val)})),zip.generateAsync({compression:"DEFLATE",compressionOptions:{level:9},type:"blob"})})).then((function(blob){var filename;return filename="ZeroOmegaLog_"+Date.now()+".zip",saveAs(blob,filename)}))},resetOptions:function(){return chrome.runtime.sendMessage({method:"resetAllOptions"},(function(response){return localStorage.clear(),Promise.all([idbKeyval.clear(logStore),idbKeyval.clear(syncStore),waitTimeFn(2e3)]).then((function(){return idbKeyval.clear()})).then((function(){return chrome.runtime.reload()}))}))},reportIssue:function(){return idbKeyval.get("lastError",logStore).then((function(lastError){var body,env,err,extensionVersion,finalUrl,url;finalUrl=url="https://github.com/suziwen/ZeroOmega/issues/new?title=&body=";try{OmegaDebug.getProjectVersion(),env={extensionVersion:extensionVersion=OmegaDebug.getExtensionVersion(),projectVersion:extensionVersion,userAgent:navigator.userAgent},(body=chrome.i18n.getMessage("popup_issueTemplate",[env.projectVersion,env.userAgent]))||(body="\n\n\n\x3c!-- Please write your comment ABOVE this line. --\x3e\nZeroOmega "+env.projectVersion+"\n"+env.userAgent),finalUrl=url+encodeURIComponent(body),(err=lastError||"")&&(body+="\n```\n"+err+"\n```",finalUrl=(url+encodeURIComponent(body)).substr(0,2e3))}catch(_error){}return chrome.tabs.create({url:finalUrl})}))}}}).call(this);