{“ast”:null,“code”:“function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }nnfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }nnfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }nnimport { DirectUpload } from "/activestorage";nexport var AttachmentUpload =n/*#__PURE__*/nfunction () {n function AttachmentUpload(attachment, element) {n _classCallCheck(this, AttachmentUpload);nn this.attachment = attachment;n this.element = element;n this.directUpload = new DirectUpload(attachment.file, this.directUploadUrl, this);n }nn _createClass(AttachmentUpload, [{n key: "start",n value: function start() {n this.directUpload.create(this.directUploadDidComplete.bind(this));n }n }, {n key: "directUploadWillStoreFileWithXHR",n value: function directUploadWillStoreFileWithXHR(xhr) {n var _this = this;nn xhr.upload.addEventListener("progress", function (event) {n var progress = event.loaded / event.total * 100;nn _this.attachment.setUploadProgress(progress);n });n }n }, {n key: "directUploadDidComplete",n value: function directUploadDidComplete(error, attributes) {n if (error) {n throw new Error("Direct upload failed: ".concat(error));n }nn this.attachment.setAttributes({n sgid: attributes.attachable_sgid,n url: this.createBlobUrl(attributes.signed_id, attributes.filename)n });n }n }, {n key: "createBlobUrl",n value: function createBlobUrl(signedId, filename) {n return this.blobUrlTemplate.replace(":signed_id", signedId).replace(":filename", encodeURIComponent(filename));n }n }, {n key: "directUploadUrl",n get: function get() {n return this.element.dataset.directUploadUrl;n }n }, {n key: "blobUrlTemplate",n get: function get() {n return this.element.dataset.blobUrlTemplate;n }n }]);nn return AttachmentUpload;n}();”,“map”:null,“metadata”:{},“sourceType”:“module”}