(()=>{const e=()=>{$.widget("oc.ocdialogconflictpredlg",{options:{width:"auto",height:"auto",closeButton:!0,closeOnEscape:!0,closeCallback:null,modal:!1},_create(){const t=this;this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,height:this.element[0].style.height},this.originalTitle=this.element.attr("title"),this.options.title=this.options.title||this.originalTitle,this.$dialog=$('<div class="oc-dialog oc-conflict-pre-dlg" />').attr({tabIndex:-1,role:"dialog"}).insertBefore(this.element),this.$dialog.append(this.element.detach()),this.element.removeAttr("title").addClass("oc-dialog-content").appendTo(this.$dialog),this.$dialog.css({display:"inline-block",position:"fixed"}),this.enterCallback=null,$(document).on("keydown keyup",(function(e){if(e.target===t.$dialog.get(0)||0!==t.$dialog.find($(e.target)).length){if(27===e.keyCode&&"keydown"===e.type&&t.options.closeOnEscape)return e.stopImmediatePropagation(),t.close(),!1;if(13===e.keyCode){if(e.stopImmediatePropagation(),null!==t.enterCallback)return t.enterCallback(),e.preventDefault(),!1;if("keyup"===e.type)return e.preventDefault(),!1;if(t.$buttonrow&&0===t.$buttonrow.find($(e.target)).length){const e=t.$buttonrow.find("button.primary");e&&!e.prop("disabled")&&e.trigger("click")}else t.$buttonrow&&$(e.target).trigger("click");return!1}}})),this._setOptions(this.options),this._createOverlay()},_init(){this.$dialog.focus(),this._trigger("open")},_setOption(t,e){const o=this;switch(t){case"title":if(this.$title)this.$title.text(e);else{const t=$('<div class="flex-container"><div class="oc-conflict-pre-dlg-title-div"><h2 class="oc-conflct-pre-dlg-title">'+e+'</h2></div><div class="oc-conflict-pre-dlg-close-div"><a class="close-conflict-pre-dlg">&nbsp;</a></div></div>');this.$title=t.prependTo(this.$dialog)}this._setSizes();break;case"buttons":if(this.$buttonrow)this.$buttonrow.empty();else{const t=$('<div class="" />');this.$buttonrow=t.appendTo(this.$dialog)}1===e.length?this.$buttonrow.addClass("onebutton"):2===e.length?this.$buttonrow.addClass("twobuttons"):3===e.length?this.$buttonrow.addClass("threebuttons"):4===e.length&&this.$buttonrow.addClass("fourbuttons"),$.each(e,(function(t,e){const i=$("<button>").text(e.text);e.classes&&i.addClass(e.classes),e.defaultButton&&(i.addClass("primary"),o.$defaultButton=i),o.$buttonrow.append(i),i.click((function(){e.click.apply(o.element[0],arguments)}))})),this.$buttonrow.find("button").on("focus",(function(t){o.$buttonrow.find("button").removeClass("primary"),$(this).addClass("primary")})),this._setSizes();break;case"style":void 0!==e.buttons&&this.$buttonrow.addClass(e.buttons);break;case"closeButton":if(e){const t=$('<a class="oc-dialog-close"></a>');this.$dialog.prepend(t),t.on("click",(function(){o.options.closeCallback&&o.options.closeCallback(),o.close()}))}else this.$dialog.find(".oc-dialog-close").remove();break;case"width":this.$dialog.css("width",e);break;case"height":this.$dialog.css("height",e);break;case"close":this.closeCB=e}$.Widget.prototype._setOption.apply(this,arguments)},_setOptions(t){$.Widget.prototype._setOptions.apply(this,arguments)},_setSizes(){let t=0;this.$title&&(t+=this.$title.outerHeight(!0)),this.$buttonrow&&(t+=this.$buttonrow.outerHeight(!0)),this.element.css({height:"calc(100% - "+t+"px)"})},_createOverlay(){if(!this.options.modal)return;const t=this;let e=$("#content");0===e.length&&(e=$(".content")),this.overlay=$("<div>").addClass("oc-dialog-dim").appendTo(e),this.overlay.on("click keydown keyup",(function(e){e.target!==t.$dialog.get(0)&&0===t.$dialog.find($(e.target)).length&&(e.preventDefault(),e.stopPropagation())}))},_destroyOverlay(){this.options.modal&&this.overlay&&(this.overlay.off("click keydown keyup"),this.overlay.remove(),this.overlay=null)},widget(){return this.$dialog},setEnterCallback(t){this.enterCallback=t},unsetEnterCallback(){this.enterCallback=null},close(){this._destroyOverlay();const t=this;setTimeout((function(){t._trigger("close",t)}),200),t.$dialog.remove(),this.destroy()},destroy(){this.$title&&this.$title.remove(),this.$buttonrow&&this.$buttonrow.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),this.element.removeClass("oc-dialog-content").css(this.originalCss).detach().insertBefore(this.$dialog),this.$dialog.remove()}})},o=()=>{OC.conflictsData=null,OC.Uploader.prototype.checkExistingFiles=function(t,e){const o=this.fileList,i=[];t.uploads=_.filter(t.uploads,(function(t){const e=t.getFile();if(e.relativePath)return!0;if(!o)return!0;if(t.getTargetFolder()!==o.getCurrentDirectory())return!0;const l=o.findFile(e.name);return!l||(i.push([_.extend(l,{directory:l.directory||l.path||o.getCurrentDirectory()}),t]),!1)})),OC.conflictsData=i,i.length&&OC.dialogs.fileexists(null,null,null,this).done((function(){_.each(i,(function(t){OC.dialogs.fileexists(t[1],t[0],t[1].getFile(),this)}))})),e.onNoConflicts(t)},OC.Uploader.prototype.onContinueConflictPreDlg=function(t,e){const o=this;jQuery.each(OC.conflictsData,(function(i,l){const s=l[1];t&&e?o.onAutorename(s):e?o.onReplace(s):o.onSkip(s)})),OC.conflictsData=null},OC._fileexistsshownConflictPreDlg=!1,OC.dialogs.fileexists=function(e,o,i,l){const s=new $.Deferred,n="oc-dialog-fileexists-content",c="#"+n,a=OC.conflictsData.length;if(!OC._fileexistsshownConflictPreDlg){const o=OC.conflictsData[0][0].name,i=t("core","Do you want to replace it with files you're moving?"),r=1===a?t("core","The file {filename} already exist in the location.",{filename:o}):t("core","The files already exist in the location.");OC._fileexistsshownConflictPreDlg=!0;const d=$('<div id="{dialog_name}" title="{title}" class="fileexists"><span class="why">{what}</span><br/><span class="what">{why}</span><br/></div>'),h=1===a?t("core","File conflict"):t("core","{conflictCount} File conflicts",{conflictCount:a}),g=d.octemplate({dialog_name:n,title:h,type:"fileexists",allnewfiles:t("core","New Files"),allexistingfiles:t("core","Already existing files"),why:i,what:r});$("body").append(g);const p=[{text:t("core","Cancel"),classes:"cancel oc-conflict-pre-dlg-button",click(){void 0!==l.onCancel&&l.onCancel(e),$(c).ocdialogconflictpredlg("close"),OC.conflictsData=null}},{text:1===a?t("core","Keep both files"):t("core","Keep both files for all"),classes:"cancel oc-conflict-pre-dlg-button",click(){void 0!==l.onContinueConflictPreDlg&&l.onContinueConflictPreDlg(!0,!0),$(c).ocdialogconflictpredlg("close")}},{text:1===a?t("core","Replace file"):t("core","Replace all files"),classes:"cancel oc-conflict-pre-dlg-button oc-conflict-pre-dlg-replace-button",click(){void 0!==l.onContinue&&l.onContinueConflictPreDlg(!1,!0),$(c).ocdialogconflictpredlg("close")}}];$(c).ocdialogconflictpredlg({closeOnEscape:!0,modal:!0,buttons:p,closeButton:null,close(){OC._fileexistsshownConflictPreDlg=!1;try{$(this).ocdialogconflictpredlg("destroy").remove()}catch(t){}}}),$(c).css("height","auto"),$(".close-conflict-pre-dlg").on("click",(function(){$(c).ocdialogconflictpredlg("close"),OC.conflictsData=null})),s.resolve()}return s.promise()}};location.pathname.includes("/apps/files")&&(e(),o())})();
//# sourceMappingURL=nmctheme-conflictdialog.js.map?v=ff52a7388cb2b121f2fa