!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,i,n){var o=$(this).children("img:first").data("ext",r(t.mime,n)),a=$('
').html(''+n.i18n("ntfloadimg")+'').hide().appendTo(this);o.attr("id",e+"-img").attr("src",i).css({height:"","max-width":"100%","max-height":"100%",cursor:"pointer"}).data("loading",function(e){var t=o.closest(".elfinder-dialog").find("button,.elfinder-titlebar-button");return t.prop("disabled",!e)[e?"removeClass":"addClass"]("ui-state-disabled"),o.css("opacity",e?"":"0.3"),a[e?"hide":"show"](),o})},c=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},d=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())}},l=function(e,t){o&&!t.UA.ltIE8||(this.disabled=!0)},p=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(){f()}),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(){u.remove(),l.show()}),p=this.editor,m=p.confObj,u=$('
').html(''+n.i18n("nowLoading")+'').appendTo(l.parent()),f=function(e){var t=r(e,n),i=a[t];return m.mimesFlip[i]?"jpeg"===t&&(t="jpg"):t="",t&&"xcf"!==t&&"dng"!==t&&"sketch"!==t||(t="psd",i=a[t],l.closest(".ui-dialog").trigger("changeType",{extention:t,mime:i,keepEditor:!0})),t},g=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:"+g+";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:"+g+";base64,"+n.arrayBufferToBase64(c)),c=null,a):(e.data("mime")&&(g=e.data("mime"),t=f(g)),(i=e.data("quality"))&&(t+=":"+i/100),r.postMessage('app.activeDocument.saveToOE("'+t+'")',d),a)}}),l.parent().css("padding",0),s=f(t.mime),o=p.liveMsg=new m.liveMsg(l,u,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:"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){s.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,u=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:u()},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",c(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().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,u,f;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",u=p.mode,f=p.mime,r.setOption("mode",f),t.autoLoadMode(r,u),l.prev().children(".elfinder-dialog-title").append(" ("+f+" : "+u+")")),s=$(r.getWrapperElement()).css({padding:0,border:"none"}),d.data("cm",!0),s.height("100%"),$('
').css("float","left").append($("