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(h.getItem(u+"time"),10)||0;return!((newDate).getTime()-e>f.autosave_retention)||(r(!1),!1)}functionr(t){h.removeItem(u+"draft"),h.removeItem(u+"time"),t!==!1&&e.fire("RemoveDraft")}functioni(){!c()&&e.isDirty()&&(h.setItem(u+"draft",e.getContent({format:"raw",no_events:!0})),h.setItem(u+"time",(newDate).getTime()),e.fire("StoreDraft"))}functiono(){n()&&(e.setContent(h.getItem(u+"draft"),{format:"raw"}),e.fire("RestoreDraft"))}functiona(){d||(setInterval(function(){e.removed||i()},f.autosave_interval),d=!0)}functions(){vart=this;t.disabled(!n()),e.on("StoreDraft RestoreDraft RemoveDraft",function(){t.disabled(!n())}),a()}functionl(){e.undoManager.beforeChange(),o(),r(),e.undoManager.add()}functionc(t){varn=e.settings.forced_root_block;returnt=tinymce.trim("undefined"==typeoft?e.getBody().innerHTML:t),""===t||newRegExp("^<"+n+"[^>]*>((\xa0| |[ \t]|<br[^>]*>)+?|)</"+n+">|<br>$","i").test(t)}varu,d,f=e.settings,h=tinymce.util.LocalStorage;u=f.autosave_prefix||"tinymce-autosave-{path}{query}-{id}-",u=u.replace(/\{path\}/g,document.location.pathname),u=u.replace(/\{query\}/g,document.location.search),u=u.replace(/\{id\}/g,e.id),f.autosave_interval=t(f.autosave_interval,"30s"),f.autosave_retention=t(f.autosave_retention,"20m"),e.addButton("restoredraft",{title:"Restore last draft",onclick:l,onPostRender:s}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:l,onPostRender:s,context:"file"}),e.settings.autosave_restore_when_empty!==!1&&(e.on("init",function(){n()&&c()&&o()}),e.on("saveContent",function(){r()})),window.onbeforeunload=tinymce._beforeUnloadHandler,this.hasDraft=n,this.storeDraft=i,this.restoreDraft=o,this.removeDraft=r,this.isEmpty=c});