{"version":3,"sources":["webpack:///./app/javascript/src/uppy.js"],"names":["document","querySelectorAll","length","forEach","element","trigger","querySelector","direct_upload_url","closest","getAttribute","field_name","dataset","uppy","addEventListener","event","preventDefault","Uppy","autoProceed","allowMultipleUploads","logger","debugLogger","restrictions","maxFileSize","maxNumberOfFiles","minNumberOfFiles","allowedFileTypes","use","ActiveStorageUpload","directUploadUrl","Dashboard","inline","closeAfterFinish","ImageEditor","target","quality","cropperOptions","viewMode","background","autoCropArea","responsive","croppedCanvasOptions","actions","revert","rotate","granularRotate","flip","zoomIn","zoomOut","cropSquare","cropWidescreen","cropWidescreenVertical","Compressor","limit","on","result","parentNode","removeChild","successful","file","hiddenField","createElement","setAttribute","response","signed_id","appendChild","appendUploadedFile","preview","src","existingTag","remove","newImageTag","textContent","className","brTag","insertAdjacentElement","message","innerHTML","setPreview","reset","setupUppy"],"mappings":"2FAAA,+IAeoBA,SAASC,iBAAiB,gBAAkB,IAC9CC,OAAS,GACzBF,SACGC,iBAAiB,eACjBE,SAAQ,SAACC,GAAO,OAGrB,SAAmBA,GACjB,IAAIC,EAAUD,EAAQE,cAAc,kCAEhCC,GADOH,EAAQI,QAAQ,QACHR,SACrBM,cAAc,kCACdG,aAAa,YACZC,EAAaN,EAAQO,QAAQC,KACjCP,EAAQQ,iBAAiB,SAAS,SAACC,GAAK,OAAKA,EAAMC,gBAAgB,IAEnE,IAAIH,EAAO,IAAII,IAAK,CAClBC,aAAa,EACbC,sBAAsB,EACtBC,OAAQH,IAAKI,YACbC,aAAc,CACZC,YAAa,KACbC,iBAAkB,EAClBC,iBAAkB,EAClBC,iBAAkB,CAAC,cAIvBb,EAAKc,IAAIC,IAAqB,CAC5BC,gBAAiBrB,IAGnBK,EAAKc,IAAIG,IAAW,CAClBxB,QAASA,EACTyB,QAAQ,EACRC,kBAAkB,IAGpBnB,EAAKc,IAAIM,IAAa,CACpBC,OAAQJ,IACRK,QAAS,EACTC,eAAgB,CACdC,SAAU,EACVC,YAAY,EACZC,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-9e7fbf353b0c2ac05558.chunk.js","sourcesContent":["import { Modal } from \"bootstrap\";\nimport \"data-confirm-modal\";\n\nimport Uppy from \"@uppy/core\";\nimport Dashboard from \"@uppy/dashboard\";\nimport ActiveStorageUpload from \"@excid3/uppy-activestorage-upload\";\nimport Url from \"@uppy/url\";\nimport Compressor from \"@uppy/compressor\";\nimport ImageEditor from \"@uppy/image-editor\";\n\nimport \"@uppy/core/dist/style.css\";\nimport \"@uppy/dashboard/dist/style.css\";\nimport \"@uppy/image-editor/dist/style.css\";\nimport \"@uppy/url/dist/style.css\";\n\nlet uppyInstances = document.querySelectorAll(\"[data-uppy]\") || [];\nif (uppyInstances.length > 0) {\n document\n .querySelectorAll(\"[data-uppy]\")\n .forEach((element) => setupUppy(element));\n}\n\nfunction setupUppy(element) {\n let trigger = element.querySelector('[data-behavior=\"uppy-trigger\"]');\n let form = element.closest(\"form\");\n let direct_upload_url = document\n .querySelector(\"meta[name='direct-upload-url']\")\n .getAttribute(\"content\");\n let field_name = element.dataset.uppy;\n trigger.addEventListener(\"click\", (event) => event.preventDefault());\n\n let uppy = new Uppy({\n autoProceed: false,\n allowMultipleUploads: false,\n logger: Uppy.debugLogger,\n restrictions: {\n maxFileSize: 5200000,\n maxNumberOfFiles: 1,\n minNumberOfFiles: 1,\n allowedFileTypes: [\"image/*\"],\n },\n });\n\n uppy.use(ActiveStorageUpload, {\n directUploadUrl: direct_upload_url,\n });\n\n uppy.use(Dashboard, {\n trigger: trigger,\n inline: false,\n closeAfterFinish: false,\n });\n\n uppy.use(ImageEditor, {\n target: Dashboard,\n quality: 1,\n cropperOptions: {\n viewMode: 1,\n background: false,\n autoCropArea: 1,\n responsive: true,\n croppedCanvasOptions: {},\n },\n actions: {\n revert: true,\n rotate: true,\n granularRotate: true,\n flip: true,\n zoomIn: true,\n zoomOut: true,\n cropSquare: true,\n cropWidescreen: true,\n cropWidescreenVertical: true,\n },\n });\n\n uppy.use(Compressor, {\n quality: 0.6,\n limit: 10,\n });\n\n uppy.on(\"complete\", (result) => {\n element\n .querySelectorAll(\"[data-pending-upload]\")\n .forEach((element) => element.parentNode.removeChild(element));\n\n result.successful.forEach((file) => {\n appendUploadedFile(element, file, field_name);\n setPreview(element, file);\n });\n uppy.reset();\n });\n}\n\nfunction appendUploadedFile(element, file, field_name) {\n const hiddenField = document.createElement(\"input\");\n\n hiddenField.setAttribute(\"type\", \"hidden\");\n hiddenField.setAttribute(\"name\", field_name);\n hiddenField.setAttribute(\"data-pending-upload\", true);\n hiddenField.setAttribute(\"value\", file.response.signed_id);\n\n element.appendChild(hiddenField);\n}\n\nfunction setPreview(element, file) {\n let preview = element.querySelector('[data-behavior=\"uppy-preview\"]');\n if (preview) {\n let src = file.preview\n ? file.preview\n : \"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSpj0DBTVsaja01_xWh37bcutvpd7rh7zEd528HD0d_l6A73osY\";\n preview.src = src;\n\n // Remove any existing new image tag\n let existingTag = element.querySelector('.current-img-tag, .new-img-tag');\n if (existingTag) {\n existingTag.remove();\n }\n\n // Add \"New Image\" tag\n let newImageTag = document.createElement(\"span\");\n newImageTag.textContent = \"New Image\";\n newImageTag.className = \"new-img-tag\";\n let brTag = document.createElement(\"br\");\n preview.insertAdjacentElement(\"afterend\", brTag);\n brTag.insertAdjacentElement(\"afterend\", newImageTag);\n\n // Update the message to indicate the image is attached\n let message = element.querySelector('[data-behavior=\"uppy-message\"]');\n if (message) {\n message.className = \"info-box\";\n message.innerHTML = \"
New Image Attached - Save to Update
\";\n }\n }\n}\n"],"sourceRoot":""}