!function(e,t){if("function"==typeof define&&define.amd)define(["elfinder"],e);else if(t){var i=t.prototype._options.commandsOptions.edit.editors;t.prototype._options.commandsOptions.edit.editors=i.concat(e(t))}}(function(e){"use strict";var t,i=window.location.search.match(/getfile=([a-z]+)/),n=e.prototype.hasRequire,o=function(){var e;try{e=!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(t){e=!!("undefined"==typeof window.orientation||navigator&&navigator.mimeTypes["application/x-shockwave-flash"])}return e}(),a={bmp:"image/x-ms-bmp",dng:"image/x-adobe-dng",gif:"image/gif",jpeg:"image/jpeg",jpg:"image/jpeg",pdf:"application/pdf",png:"image/png",ppm:"image/x-portable-pixmap",psd:"image/vnd.adobe.photoshop",pxd:"image/x-pixlr-data",svg:"image/svg+xml",tiff:"image/tiff",webp:"image/webp",xcf:"image/x-xcf",sketch:"application/x-sketch"},r=function(e,i){t||(t=i.arrayFlip(a));var n=t[e]||i.mimeTypes[e];return"jpeg"===n&&(n="jpg"),n},s=function(e,t){var i=$.Deferred();try{var n=document.createElement("canvas"),o=n.getContext("2d"),a=new Image,r=function(){var e,o,a=n.toDataURL(t);e=(o=a.match(/^data:([a-z0-9]+\/[a-z0-9.+-]+)/i))?o[1]:"",e.toLowerCase()===t.toLowerCase()?i.resolve(n.toDataURL(t),n):i.reject()};return a.src=e,$(a).on("load",function(){try{n.width=a.width,n.height=a.height,o.drawImage(a,0,0),r()}catch(e){i.reject()}}).on("error",function(){i.reject()}),i}catch(s){return i.reject()}},c=function(e,t,i,n){var o,a=$(this).children("img:first").data("ext",r(t.mime,n)),s=$('
').html(''+n.i18n("ntfloadimg")+'').hide().appendTo(this);i.match(/^data:/)||(o=n.openUrl(t.hash),a.attr("_src",i)),a.attr("id",e+"-img").attr("src",o||i).css({height:"","max-width":"100%","max-height":"100%",cursor:"pointer"}).data("loading",function(e){var t=a.closest(".elfinder-dialog").find("button,.elfinder-titlebar-button");return t.prop("disabled",!e)[e?"removeClass":"addClass"]("ui-state-disabled"),a.css("opacity",e?"":"0.3"),s[e?"hide":"show"](),a})},d=function(e,t){var i,n,o,a=e.attr("style");try{e.attr("style",""),i=e.get(0),n=document.createElement("canvas"),n.width=i.width,n.height=i.height,e.attr("style",a),n.getContext("2d").drawImage(i,0,0),o=n.toDataURL(t)}catch(r){o=e.attr("src")}return o},l=function(){if(o&&window.parent!==window){var e,t,i,n,r,s=window.location.search.match(/[?&]pixlr=([^&]+)/),c=window.location.search.match(/[?&]image=([^&]+)/);s&&(e=window.parent,t=e.$("#"+s[1]+"iframe").hide(),n=e.$("#"+s[1]).data("resizeoff")(),"http"===c[1].substr(0,4)?(i=c[1],r=i.replace(/.+\.([^.]+)$/,"$1"),n.data("ext")!==r&&n.closest(".ui-dialog").trigger("changeType",{extention:r,mime:a[r]}),"https:"===window.location.protocol&&(i=i.replace(/^http:/,"https:")),n.on("load error",function(){n.data("loading")(!0)}).attr("src",i).data("loading")()):n.data("loading")(!0),t.trigger("destroy").remove())}},p=function(e,t){o&&!t.UA.ltIE8||(this.disabled=!0)},m=function(e,t){var i,n=this,o=this.fm,a=o.res("class","preventback"),r=$(t).children("img:first").data("loading")().data("resizeoff",function(){return $(window).off("resize."+r.attr("id")),s.addClass(a),r}).on("click",function(){u()}),s=$(t).closest(".ui-dialog"),c=o.getUI(),d=o.getUI("toast"),l=$('',setup:function(e,t){(t.UA.IE||t.UA.Mobile)&&(this.disabled=!0)},init:function(e,t,i,n){var o,s,c,d="https://www.photopea.com",l=$(this).hide().on("load",function(){l.show()}).on("error",function(){f.remove(),l.show()}),p=this.editor,m=p.confObj,f=$('
').html(''+n.i18n("nowLoading")+'').appendTo(l.parent()),u=n.arrayFlip(m.info.canMakeEmpty),g=function(e){var t=r(e,n),i=a[t];return m.mimesFlip[i]?"jpeg"===t&&(t="jpg"):t="",t&&!u[t]||(t="psd",i=a[t],l.closest(".ui-dialog").trigger("changeType",{extention:t,mime:i,keepEditor:!0})),t},h=t.mime;m.mimesFlip||(m.mimesFlip=n.arrayFlip(m.mimes,!0)),m.liveMsg||(m.liveMsg=function(e,t,i){var o=n.openUrl(i.hash);n.isSameOrigin(o)||(o=n.openUrl(i.hash,!0));var a,r=e.get(0).contentWindow,s=0,c=null,l=$.Deferred().done(function(){t.remove(),s=1,r.postMessage(c,"*")});this.load=function(){return n.request({data:{cmd:"get"},options:{url:o,type:"get",cache:!0,dataType:"binary",responseType:"arraybuffer",processData:!1}}).done(function(e){c=e})},this.receive=function(t){var i=t.originalEvent;i.origin===d&&i.source===r&&("done"===i.data?0===s?l.resolve():1===s?(s=2,e.trigger("contentsloaded")):a&&"pending"===a.state()&&a.reject("errDataEmpty"):a&&"pending"===a.state()&&("object"==typeof i.data?a.resolve("data:"+h+";base64,"+n.arrayBufferToBase64(i.data)):a.reject("errDataEmpty")))},this.getContent=function(){var t,i;if(s>1)return a&&"pending"===a.state()&&a.reject(),a=null,a=$.Deferred(),2===s?(s=3,a.resolve("data:"+h+";base64,"+n.arrayBufferToBase64(c)),c=null,a):(e.data("mime")&&(h=e.data("mime"),t=g(h)),(i=e.data("quality"))&&(t+=":"+i/100),r.postMessage('app.activeDocument.saveToOE("'+t+'")',d),a)}}),l.parent().css("padding",0),s=g(t.mime),o=p.liveMsg=new m.liveMsg(l,f,t),$(window).on("message."+n.namespace,o.receive),o.load().done(function(){var e=JSON.stringify({files:[],environment:{lang:n.lang.replace(/_/g,"-")}});l.attr("src",d+"/#"+encodeURI(e))}).fail(function(e){e&&n.error(e),p.initFail=!0}),"image/jpeg"!==t.mime&&"image/webp"!==t.mime||(l.data("quality",n.storage("jpgQuality")||n.option("jpgQuality")),c=$('').attr("min","1").attr("max","100").attr("title","1 - 100").on("change",function(){var e=c.val();l.data("quality",e)}).val(l.data("quality")),$('
').append($("").html(n.i18n("quality")+" : "),c,$("")).prependTo(l.parent().next()))},load:function(e){var t=$.Deferred(),i=this,n=(this.fm,$(e));return i.initFail?t.reject():n.on("contentsloaded",function(){t.resolve(i.liveMsg)}),t},getContent:function(){return this.editor.liveMsg?this.editor.liveMsg.getContent():void 0},save:function(e,t){var i,n=$(e),o=n.data("quality"),a=n.data("hash");"undefined"!=typeof o&&this.fm.storage("jpgQuality",o),a?(i=this.fm.file(a),n.data("mime",i.mime)):n.removeData("mime")},close:function(e,t){$(e).attr("src",""),t&&$(window).off("message."+this.fm.namespace,t.receive)}},{info:{id:"pixo",name:"Pixo Editor",iconImg:"img/editor-icons.png 0 -208",dataScheme:!0,schemeContent:!0,single:!0,canMakeEmpty:!1,integrate:{title:"Pixo Editor",link:"https://pixoeditor.com/privacy-policy/"}},mimes:["image/jpeg","image/png","image/gif","image/svg+xml","image/x-ms-bmp"],html:'
',setup:function(e,t){!t.UA.ltIE8&&e.extraOptions&&e.extraOptions.pixo&&e.extraOptions.pixo.apikey?this.editorOpts=e.extraOptions.pixo:this.disabled=!0},init:function(e,t,i,n){c.call(this,e,t,i,n)},getContent:function(){return $(this).children("img:first").attr("src")},load:function(e){var t,i,n,o,a,c=this,d=this.fm,l=$(e),p=l.children("img:first"),m=l.closest(".ui-dialog"),f=d.getUI(),u=$.Deferred(),g=$("#elfinder-pixo-container"),h=function(n){var h;g.length?g.appendTo(g.parent()):(g=$('
').css({position:"fixed",top:0,right:0,width:"100%",height:$(window).height(),overflow:"hidden"}).hide().appendTo(f.hasClass("elfinder-fullscreen")?f:"body"),f.on("resize."+d.namespace,function(e,t){e.preventDefault(),e.stopPropagation(),t&&t.fullscreen&&g.appendTo("on"===t.fullscreen?f:"body")}),d.bind("destroy",function(){a&&a.cancelEditing(),g.remove()})),p.on("click",v),h=Object.assign({type:"child",parent:g.get(0),onSave:function(n){var a=n.toBlob().type,l=r(a,d),f=function(e){p.one("load error",function(){p.data("loading")&&p.data("loading")(!0)}).attr("crossorigin","anonymous").attr("src",e)},u=n.toDataURL();p.data("loading")(),delete e._canvas,p.data("ext")!==l?s(u,c.file.mime).done(function(n,a){a&&(e._canvas=o=a,i.trigger("change"),t&&t.show()),f(n)}).fail(function(){m.trigger("changeType",{extention:l,mime:a}),f(u)}):f(u)},onClose:function(){m.removeClass(d.res("class","preventback")),d.toggleMaximize(g,!1),g.hide(),d.toFront(m)}},c.confObj.editorOpts),c.trigger("Prepare",{node:e,editorObj:Pixo,instance:void 0,opts:h}),a=new Pixo.Bridge(h),u.resolve(a),l.on("saveAsFail",v),n&&n()},v=function(){m.addClass(d.res("class","preventback")),d.toggleMaximize(g,!0),d.toFront(g),g.show().data("curhash",c.file.hash),a.edit(p.get(0)),p.data("loading")(!0)};return p.data("loading")(),"image/jpeg"===c.file.mime&&(i=$('').attr("min","1").attr("max","100").attr("title","1 - 100").on("change",function(){var e=i.val();n&&cancelAnimationFrame(n),n=requestAnimationFrame(function(){o&&o.toBlob(function(e){e&&i.next("span").text(" ("+d.formatSize(e.size)+")")},"image/jpeg",Math.max(Math.min(e,100),1)/100)})}).val(d.storage("jpgQuality")||d.option("jpgQuality")),t=$('
').hide().append($("").html(d.i18n("quality")+" : "),i,$("")).prependTo(l.parent().next()),l.data("quty",i)),"undefined"==typeof Pixo?d.loadScript(["https://pixoeditor.com:8443/editor/scripts/bridge.m.js"],function(){h(v)},{loadType:"tag"}):(h(),v()),u},save:function(e){var t,i=this,n=$(e),o=n.children("img:first");e._canvas?(t=n.data("quty")?Math.max(Math.min(n.data("quty").val(),100),1)/100:void 0,o.attr("src",e._canvas.toDataURL(i.file.mime,t))):"data:"!==o.attr("src").substr(0,5)&&o.attr("src",d(o,this.file.mime))},close:function(e,t){t&&t.destroy()}},{info:{id:"creativecloud",name:"Creative Cloud",iconImg:"img/editor-icons.png 0 -192",dataScheme:!0,schemeContent:!0,single:!0,canMakeEmpty:!1,integrate:{title:"Adobe Creative Cloud",link:"https://www.adobe.io/apis/creativecloud.html"}},mimes:["image/jpeg","image/png","image/gif","image/svg+xml","image/x-ms-bmp"],html:'
',setup:function(e,t){!t.UA.ltIE8&&e.extraOptions&&e.extraOptions.creativeCloudApiKey?this.apiKey=e.extraOptions.creativeCloudApiKey:this.disabled=!0},init:function(e,t,i,n){c.call(this,e,t,i,n)},getContent:function(){return $(this).children("img:first").attr("src")},load:function(e){var t,i=this,n=this.fm,o=$(e).children("img:first"),r=$(e).closest(".ui-dialog"),s=n.getUI(),c=$.Deferred(),d=$("#elfinder-aviary-container"),l=function(l){var m,f=function(){var e={zh_TW:"zh_HANT",zh_CN:"zh_HANS"};return e[n.lang]?e[n.lang]:n.lang};d.length?d.appendTo(d.parent()):(d=$('
').css({position:"fixed",top:0,right:0,width:"100%",height:$(window).height(),overflow:"auto"}).hide().appendTo(s.hasClass("elfinder-fullscreen")?s:"body"),s.on("resize."+n.namespace,function(e,t){e.preventDefault(),e.stopPropagation(),t&&t.fullscreen&&d.appendTo("on"===t.fullscreen?s:"body")}),n.bind("destroy",function(){d.remove()})),o.on("click",p).data("loading")(),m={apiKey:i.confObj.apiKey,onSave:function(e,i){var n;t.showWaitIndicator(),n=i.replace(/.+\.([^.]+)$/,"$1"),o.data("ext")!==n&&o.closest(".ui-dialog").trigger("changeType",{extention:n,mime:a[n]}),o.on("load error",function(){o.data("loading")(!0)}).attr("crossorigin","anonymous").attr("src",i).data("loading")(),t.close()},onLoad:l||function(){},onClose:function(){r.removeClass(n.res("class","preventback")),n.toggleMaximize(d,!1),$(d).hide()},appendTo:d.get(0),maxSize:2048,language:f()},i.trigger("Prepare",{node:e,editorObj:Aviary,instance:void 0,opts:m}),t=new Aviary.Feather(m),c.resolve(t),$(e).on("saveAsFail",p)},p=function(){r.addClass(n.res("class","preventback")),n.toggleMaximize(d,!0),n.toFront(d),$(d).show(),t.launch({image:o.attr("id"),url:o.attr("src")}),o.data("loading")(!0)};return"undefined"==typeof Aviary?n.loadScript(["https://dme0ih8comzn4.cloudfront.net/imaging/v3/editor.js"],function(){l(p)},{loadType:"tag"}):(l(),p()),c},save:function(e){var t=$(e).children("img:first");"data:"!==t.attr("src").substr(0,5)&&t.attr("src",d(t,this.file.mime))}},{setup:function(e,t){!t.UA.ltIE8&&t.options.cdns.ace||(this.disabled=!0)},info:{id:"aceeditor",name:"ACE Editor",iconImg:"img/editor-icons.png 0 -96"},load:function(e){var t=this,i=this.fm,n=$.Deferred(),o=i.options.cdns.ace,a=function(){var i,a,r,s=$(e),c=s.parent(),d=c.parent(),l=e.id+"_ace",p=(t.file.name.replace(/^.+\.([^.]+)|(.+)$/,"$1$2").toLowerCase(),{"text/x-php":"php","application/x-php":"php","text/html":"html","application/xhtml+xml":"html","text/javascript":"javascript","application/javascript":"javascript","text/css":"css","text/x-c":"c_cpp","text/x-csrc":"c_cpp","text/x-chdr":"c_cpp","text/x-c++":"c_cpp","text/x-c++src":"c_cpp","text/x-c++hdr":"c_cpp","text/x-shellscript":"sh","application/x-csh":"sh","text/x-python":"python","text/x-java":"java","text/x-java-source":"java","text/x-ruby":"ruby","text/x-perl":"perl","application/x-perl":"perl","text/x-sql":"sql","text/xml":"xml","application/docbook+xml":"xml","application/xml":"xml"});c.height(c.height()),ace.config.set("basePath",o),a=$('
').text(s.val()).insertBefore(s.hide()),s.data("ace",!0),i=ace.edit(l),i.$blockScrolling=1/0,i.setOptions({theme:"ace/theme/monokai",fontSize:"14px",wrap:!0}),ace.config.loadModule("ace/ext/modelist",function(){r=ace.require("ace/ext/modelist").getModeForPath("/"+t.file.name).name,"text"===r&&p[t.file.mime]&&(r=p[t.file.mime]),c.prev().children(".elfinder-dialog-title").append(" ("+t.file.mime+" : "+r.split(/[\/\\]/).pop()+")"),i.setOptions({mode:"ace/mode/"+r}),"resolved"===n.state()&&d.trigger("resize")}),ace.config.loadModule("ace/ext/language_tools",function(){ace.require("ace/ext/language_tools"),i.setOptions({enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!1})}),ace.config.loadModule("ace/ext/settings_menu",function(){ace.require("ace/ext/settings_menu").init(i)}),i.commands.addCommand({name:"saveFile",bindKey:{win:"Ctrl-s",mac:"Command-s"},exec:function(e){t.doSave()}}),i.commands.addCommand({name:"closeEditor",bindKey:{win:"Ctrl-w|Ctrl-q",mac:"Command-w|Command-q"},exec:function(e){t.doCancel()}}),i.resize(),$('
').css("float","left").append($("").button({icons:{primary:"ui-icon-gear",secondary:"ui-icon-triangle-1-e"},text:!1}).on("click",function(){i.showSettingsMenu(),$("#ace_settingsmenu").css("font-size","80%").find('div[contains="setOptions"]').hide().end().parent().appendTo($("#elfinder"))})).prependTo(c.next()),t.trigger("Prepare",{node:e,editorObj:ace,instance:i,opts:{}}),n.resolve(i)};return t.confObj.loader||(t.confObj.loader=$.Deferred(),t.fm.loadScript([o+"/ace.js"],function(){t.confObj.loader.resolve()},void 0,{obj:window,name:"ace"})),t.confObj.loader.done(a),n},close:function(e,t){t&&t.destroy()},save:function(e,t){t&&$(e).data("ace")&&(e.value=t.session.getValue())},focus:function(e,t){t&&$(e).data("ace")&&t.focus()},resize:function(e,t,i,n){t&&t.resize()}},{setup:function(e,t){!t.UA.ltIE10&&t.options.cdns.codemirror||(this.disabled=!0)},info:{id:"codemirror",name:"CodeMirror",iconImg:"img/editor-icons.png 0 -176"},load:function(e){var t=this.fm,i=t.options.cdns.codemirror,o=$.Deferred(),a=this,r=function(t){var r,s,c,d=$(e),l=d.parent();l.height(l.height()),c={lineNumbers:!0,lineWrapping:!0,extraKeys:{"Ctrl-S":function(){a.doSave()},"Ctrl-Q":function(){a.doCancel()},"Ctrl-W":function(){a.doCancel()}}},a.trigger("Prepare",{node:e,editorObj:t,instance:void 0,opts:c}),r=t.fromTextArea(e,c),o.resolve(r);var p,m,f,u;p||(p=t.findModeByMIME(a.file.mime)),!p&&(m=a.file.name.match(/.+\.([^.]+)$/))&&(p=t.findModeByExtension(m[1])),p&&(t.modeURL=n?"codemirror/mode/%N/%N.min":i+"/mode/%N/%N.min.js",f=p.mode,u=p.mime,r.setOption("mode",u),t.autoLoadMode(r,f),l.prev().children(".elfinder-dialog-title").append(" ("+u+" : "+f+")")),s=$(r.getWrapperElement()).css({padding:0,border:"none"}),d.data("cm",!0),s.height("100%"),$('
').css("float","left").append($("