tinymce._beforeUnloadHandler=function(){vare;returntinymce.each(tinymce.editors,function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&t.getParam("autosave_ask_before_unload",!0)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e},tinymce.PluginManager.add("autosave",function(e){functiont(e,t){varn={s:1e3,m:6e4};returne=/^(\d+)([ms]?)$/.exec(""+(e||t)),(e[2]?n[e[2]]:1)*parseInt(e,10)}functionn(){vare=parseInt(v.getItem(c+"time"),10)||0;return(newDate).getTime()-e>m.autosave_retention?(a(!1),!1):!0}functiona(t){v.removeItem(c+"draft"),v.removeItem(c+"time"),t!==!1&&e.fire("RemoveDraft")}functionr(){!f()&&e.isDirty()&&(v.setItem(c+"draft",e.getContent({format:"raw",no_events:!0})),v.setItem(c+"time",(newDate).getTime()),e.fire("StoreDraft"))}functiono(){n()&&(e.setContent(v.getItem(c+"draft"),{format:"raw"}),e.fire("RestoreDraft"))}functioni(){d||(setInterval(function(){e.removed||r()},m.autosave_interval),d=!0)}functions(){vart=this;t.disabled(!n()),e.on("StoreDraft RestoreDraft RemoveDraft",function(){t.disabled(!n())}),i()}functionu(){e.undoManager.beforeChange(),o(),a(),e.undoManager.add()}functionf(t){varn=e.settings.forced_root_block;returnt=tinymce.trim("undefined"==typeoft?e.getBody().innerHTML:t),""===t||newRegExp("^<"+n+"[^>]*>((| |[ ]|<br[^>]*>)+?|)</"+n+">|<br>$","i").test(t)}varc,d,m=e.settings,v=tinymce.util.LocalStorage;c=m.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",c=c.replace(/\{path\}/g,document.location.pathname),c=c.replace(/\{query\}/g,document.location.search),c=c.replace(/\{id\}/g,e.id),m.autosave_interval=t(m.autosave_interval,"30s"),m.autosave_retention=t(m.autosave_retention,"20m"),e.addButton("restoredraft",{title:"Restore last draft",onclick:u,onPostRender:s}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:u,onPostRender:s,context:"file"}),e.settings.autosave_restore_when_empty!==!1&&(e.on("init",function(){n()&&f()&&o()}),e.on("saveContent",function(){a()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=n,this.storeDraft=r,this.restoreDraft=o,this.removeDraft=a,this.isEmpty=f});