"use strict";function initUploadFields(t,r){var f=t.find("[name=csrfmiddlewaretoken]").val(),e=function(e){var l,a=(l=e,r&&r.prefix?"".concat(r.prefix,"-").concat(l):l),i=t.find("[name=".concat(a,"]"));return i.length?i.val():(console.error("Cannot find input with name '".concat(a,"'")),null)},p=e("upload_url"),c=e("delete_url"),m=e("form_id");m&&p&&t.find(".file-uploader").each(function(e,l){var a=$(l),i=$(a.find("input[type=file]")),t=a.find(".file-uploader-container"),n=i.attr("name"),d=Boolean(i.attr("multiple")),o={element:t,fieldName:n,csrfToken:f,uploadUrl:p,deleteUrl:c,formId:m,multiple:d};r&&$.extend(o,r),d||$(t).on("complete",function(){$(a.find(".existing-files")).remove()}),initFileUploader(o)})}function initFileUploader(e){var l=$(e.element),a={request:{endpoint:e.uploadUrl,params:{csrfmiddlewaretoken:e.csrfToken,field_name:e.fieldName,form_id:e.formId}},multiple:e.multiple,deleteFile:{enabled:!0,endpoint:e.deleteUrl,method:"POST",customHeaders:{"X-CSRFToken":e.csrfToken}},failedUploadTextDisplay:{maxChars:100,responseProperty:"error",enableTooltip:!0}};e.text&&(a.text=e.text),e.deleteFile&&$.extend(a.deleteFile,e.deleteFile),e.failedUploadTextDisplay&&$.extend(a.failedUploadTextDisplay,e.failedUploadTextDisplay),e.callbacks&&(a.callbacks=e.callbacks),e.template&&(a.template=e.template),e.validation&&(a.validation=e.validation),l.fineUploader(a);var i=l.data("files");i&&i.forEach(function(e){e.existing||l.fineUploader("addCannedFile",{uuid:e.id,name:e.name})})}