!function (e) { e.fn.filedrop = function (l) { var i, n, a = (i = 1, n = Number.MAX_SAFE_INTEGER, i = Math.ceil(i), n = Math.floor(n), Math.floor(Math.random() * (n - i + 1)) + i), t = l.Accept.split(/\s*,\s*/).map(function (e) { return e.substring(1).toUpperCase() }), o = [], r = function (e) { (e = e || event).preventDefault(), e.stopPropagation() }, d = function (i) { var n = function () { var e, l = 1; do { e = !1; for (let i = 0; i < o.length; i++)if (o[i].id === l) { l += 1, e = !0; break } } while (e); return l }(), t = i.name, d = null, p = null; l.UseSorting && (d = e('                    <a class="fileMoveUpLink">                        <i class="fa fa-arrow-up"></i>                    </a>                '), p = e('                    <a class="fileMoveDownLink">                        <i class="fa fa-arrow-down"></i>                    </a>                '), d.find("i").on("click", function () { !function (l) { var i; for (i = 0; i < o.length && o[i].id !== l; i++); if (i < o.length && 0 !== i) { var n = o[i - 1].id, t = o[i - 1]; o[i - 1] = o[i], o[i] = t; var r = e("#filedrop-" + a + " > #fileupload-" + l).detach(); e("#filedrop-" + a + " > #fileupload-" + n).before(r) } }(n) }), p.find("i").on("click", function () { !function (l) { var i; for (i = 0; i < o.length && o[i].id !== l; i++); if (i < o.length && i !== o.length - 1) { var n = o[i + 1].id, t = o[i + 1]; o[i + 1] = o[i], o[i] = t; var r = e("#filedrop-" + a + " > #fileupload-" + l).detach(); e("#filedrop-" + a + " > #fileupload-" + n).after(r) } }(n) })); var s = e('                <a class="fileRemoveLink">                    <i class="fa fa-times"></i>                </a>            '); s.find("i").on("click", function () { !function (l) { var i; for (i = 0; i < o.length && o[i].id !== l; i++); i < o.length && (o.splice(i, 1), e("#filedrop-" + a).find("#fileupload-" + l).remove(), 0 === o.length && e("#filedrop-" + a).find(".chooseFilesLabel").removeClass("hidden")) }(n) }); var f = e('                <span class="filename">                    <label class="custom-file-upload" style="display:inline">' + t + "</label>                </span>            "); null !== d && null !== p && (f.append(d), f.append(p)), f.append(s); var u = e('<div id="fileupload-' + n + '" class="fileupload"></div>'); u.on("dragover", r), u.on("drop", r), u.append(f), e("#filedrop-" + a).append(u), o.push({ id: n, file: i, name: t }) }, p = function (e = 1, i) { if (void 0 === i && (i = l.MaximumUploadFiles), o.length) { if (o.length < e || o.length > i) return l.showAlert(l.FileAmountMessage), null; for (var n, a, t, r = new FormData, d = 0; d < o.length; d++) { if (null === (a = (n = (t = o[d]).name.lastIndexOf(".")) >= 0 ? t.name.substring(n + 1).toUpperCase() : null) || -1 === l.UploadOptions.indexOf(a)) return l.showAlert(l.FileWrongTypeMessage + a), null; r.append(t.id, t.file, t.name) } return r } return l.showAlert(l.FileSelectMessage), null }, s = function (i) { var n, r, p = !1; if (i.target.files && i.target.files.length) if (i.target.files.length + o.length <= l.MaximumUploadFiles) { var s; l.hideAlert(); for (var f = 0; f < i.target.files.length; f++)n = i.target.files[f], r = void 0, null !== (s = -1 !== (r = n.name.lastIndexOf(".")) ? n.name.substring(r + 1).toUpperCase() : null) && -1 !== t.indexOf(s) ? (e("#filedrop-" + a).find(".chooseFilesLabel").addClass("hidden"), d(i.target.files[f])) : (p = !0, null !== s && (s = s.toUpperCase()), l.showAlert(l.FileWrongTypeMessage + s)) } else p = !0, l.showAlert(l.FileAmountMessage), window.setTimeout(function () { l.hideAlert() }, 5e3); return e("input#UploadFileInput-" + a).val(""), !p }, f = '            <div class="filedrop filedrop-mvc fileplacement" id="filedrop-' + a + '">                <label for="UploadFileInput-' + a + '" style="margin-top: 50px;text-decoration: underline">' + l.DropFilesPrompt + '</label>                <input type="file" class="uploadfileinput" id="UploadFileInput-' + a + '" name="UploadFileInput-' + a + '"                    title=""                    accept="' + l.Accept + '"' + (l.Multiple ? 'multiple="' + l.Multiple + '"' : "") + "/>            </div>", u = e(f); return this.prepend(u), l.UploadAndRedirect ? e("input#UploadFileInput-" + a).on("change", function (i) { if (l.showLoader(), s(i)) { var n = p(); null !== n && e.ajax({ method: "POST", url: l.APIBasePath + "Common/UploadFile", data: n, processData: !1, contentType: !1, cache: !1, timeout: 6e5, success: l.Method, xhr: function () { var i = e.ajaxSettings.xhr(); return i.upload && i.upload.addEventListener("progress", l.progress, !1), i }, error: function (e) { l.showAlert(e.Status) } }) } }) : e("input#UploadFileInput-" + a).on("change", s), { get droppedFiles() { return o }, get prepareFormData() { return p }, reset: function () { o = [], e("#filedrop-" + a).find("div[id^=fileupload-]").remove(), e("#filedrop-" + a).find(".chooseFilesLabel").removeClass("hidden") } } } }(jQuery);