5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 01:16:23 +00:00
panel/public/assets/activestorage-a32231d4c74e0bd4b322c1466c29120152be4ea1f4b896d9bfa546b49c39c52f.js
2024-01-08 13:59:44 -03:00

1 line
No EOL
16 KiB (Stored with Git LFS)
JavaScript

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.ActiveStorage={})}(this,function(t){"use strict";function e(t,e){return t(e={exports:{}},e.exports),e.exports}function r(t){var e=i(document.head,'meta[name="'+t+'"]');if(e)return e.getAttribute("content")}function n(t,e){return"string"==typeof t&&(e=t,t=document),a(t.querySelectorAll(e))}function i(t,e){return"string"==typeof t&&(e=t,t=document),t.querySelector(e)}function s(t,e){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},n=t.disabled,i=r.bubbles,s=r.cancelable,a=r.detail,u=document.createEvent("Event");u.initEvent(e,i||!0,s||!0),u.detail=a||{};try{t.disabled=!1,t.dispatchEvent(u)}finally{t.disabled=n}return u}function a(t){return Array.isArray(t)?t:Array.from?Array.from(t):[].slice.call(t)}function u(t,e){if(t&&"function"==typeof t[e]){for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return t[e].apply(t,n)}}function o(){q||(q=!0,document.addEventListener("click",h,!0),document.addEventListener("submit",f),document.addEventListener("ajax:before",c))}function h(t){var e=t.target;"INPUT"!=e.tagName&&"BUTTON"!=e.tagName||"submit"!=e.type||!e.form||R.set(e.form,e)}function f(t){l(t)}function c(t){"FORM"==t.target.tagName&&l(t)}function l(t){var e=t.target;if(e.hasAttribute(U))t.preventDefault();else{var r=new C(e),n=r.inputs;n.length&&(t.preventDefault(),e.setAttribute(U,""),n.forEach(p),r.start(function(t){e.removeAttribute(U),t?n.forEach(y):d(e)}))}}function d(t){var e=R.get(t)||i(t,"input[type=submit], button[type=submit]");if(e){var r=e.disabled;e.disabled=!1,e.focus(),e.click(),e.disabled=r}else(e=document.createElement("input")).type="submit",e.style.display="none",t.appendChild(e),e.click(),t.removeChild(e);R["delete"](t)}function p(t){t.disabled=!0}function y(t){t.disabled=!1}function v(){window.ActiveStorage&&o()}var b=e(function(t){var e;e=function(t){function e(t,e){var r=t[0],n=t[1],i=t[2],s=t[3];n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&i|~n&s)+e[0]-680876936|0)<<7|r>>>25)+n|0)&n|~r&i)+e[1]-389564586|0)<<12|s>>>20)+r|0)&r|~s&n)+e[2]+606105819|0)<<17|i>>>15)+s|0)&s|~i&r)+e[3]-1044525330|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&i|~n&s)+e[4]-176418897|0)<<7|r>>>25)+n|0)&n|~r&i)+e[5]+1200080426|0)<<12|s>>>20)+r|0)&r|~s&n)+e[6]-1473231341|0)<<17|i>>>15)+s|0)&s|~i&r)+e[7]-45705983|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&i|~n&s)+e[8]+1770035416|0)<<7|r>>>25)+n|0)&n|~r&i)+e[9]-1958414417|0)<<12|s>>>20)+r|0)&r|~s&n)+e[10]-42063|0)<<17|i>>>15)+s|0)&s|~i&r)+e[11]-1990404162|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&i|~n&s)+e[12]+1804603682|0)<<7|r>>>25)+n|0)&n|~r&i)+e[13]-40341101|0)<<12|s>>>20)+r|0)&r|~s&n)+e[14]-1502002290|0)<<17|i>>>15)+s|0)&s|~i&r)+e[15]+1236535329|0)<<22|n>>>10)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&s|i&~s)+e[1]-165796510|0)<<5|r>>>27)+n|0)&i|n&~i)+e[6]-1069501632|0)<<9|s>>>23)+r|0)&n|r&~n)+e[11]+643717713|0)<<14|i>>>18)+s|0)&r|s&~r)+e[0]-373897302|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&s|i&~s)+e[5]-701558691|0)<<5|r>>>27)+n|0)&i|n&~i)+e[10]+38016083|0)<<9|s>>>23)+r|0)&n|r&~n)+e[15]-660478335|0)<<14|i>>>18)+s|0)&r|s&~r)+e[4]-405537848|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&s|i&~s)+e[9]+568446438|0)<<5|r>>>27)+n|0)&i|n&~i)+e[14]-1019803690|0)<<9|s>>>23)+r|0)&n|r&~n)+e[3]-187363961|0)<<14|i>>>18)+s|0)&r|s&~r)+e[8]+1163531501|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n&s|i&~s)+e[13]-1444681467|0)<<5|r>>>27)+n|0)&i|n&~i)+e[2]-51403784|0)<<9|s>>>23)+r|0)&n|r&~n)+e[7]+1735328473|0)<<14|i>>>18)+s|0)&r|s&~r)+e[12]-1926607734|0)<<20|n>>>12)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n^i^s)+e[5]-378558|0)<<4|r>>>28)+n|0)^n^i)+e[8]-2022574463|0)<<11|s>>>21)+r|0)^r^n)+e[11]+1839030562|0)<<16|i>>>16)+s|0)^s^r)+e[14]-35309556|0)<<23|n>>>9)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n^i^s)+e[1]-1530992060|0)<<4|r>>>28)+n|0)^n^i)+e[4]+1272893353|0)<<11|s>>>21)+r|0)^r^n)+e[7]-155497632|0)<<16|i>>>16)+s|0)^s^r)+e[10]-1094730640|0)<<23|n>>>9)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n^i^s)+e[13]+681279174|0)<<4|r>>>28)+n|0)^n^i)+e[0]-358537222|0)<<11|s>>>21)+r|0)^r^n)+e[3]-722521979|0)<<16|i>>>16)+s|0)^s^r)+e[6]+76029189|0)<<23|n>>>9)+i|0,n=((n+=((i=((i+=((s=((s+=((r=((r+=(n^i^s)+e[9]-640364487|0)<<4|r>>>28)+n|0)^n^i)+e[12]-421815835|0)<<11|s>>>21)+r|0)^r^n)+e[15]+530742520|0)<<16|i>>>16)+s|0)^s^r)+e[2]-995338651|0)<<23|n>>>9)+i|0,n=((n+=((s=((s+=(n^((r=((r+=(i^(n|~s))+e[0]-198630844|0)<<6|r>>>26)+n|0)|~i))+e[7]+1126891415|0)<<10|s>>>22)+r|0)^((i=((i+=(r^(s|~n))+e[14]-1416354905|0)<<15|i>>>17)+s|0)|~r))+e[5]-57434055|0)<<21|n>>>11)+i|0,n=((n+=((s=((s+=(n^((r=((r+=(i^(n|~s))+e[12]+1700485571|0)<<6|r>>>26)+n|0)|~i))+e[3]-1894986606|0)<<10|s>>>22)+r|0)^((i=((i+=(r^(s|~n))+e[10]-1051523|0)<<15|i>>>17)+s|0)|~r))+e[1]-2054922799|0)<<21|n>>>11)+i|0,n=((n+=((s=((s+=(n^((r=((r+=(i^(n|~s))+e[8]+1873313359|0)<<6|r>>>26)+n|0)|~i))+e[15]-30611744|0)<<10|s>>>22)+r|0)^((i=((i+=(r^(s|~n))+e[6]-1560198380|0)<<15|i>>>17)+s|0)|~r))+e[13]+1309151649|0)<<21|n>>>11)+i|0,n=((n+=((s=((s+=(n^((r=((r+=(i^(n|~s))+e[4]-145523070|0)<<6|r>>>26)+n|0)|~i))+e[11]-1120210379|0)<<10|s>>>22)+r|0)^((i=((i+=(r^(s|~n))+e[2]+718787259|0)<<15|i>>>17)+s|0)|~r))+e[9]-343485551|0)<<21|n>>>11)+i|0,t[0]=r+t[0]|0,t[1]=n+t[1]|0,t[2]=i+t[2]|0,t[3]=s+t[3]|0}function r(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}function n(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return r}function i(t){var n,i,s,a,u,o,h=t.length,f=[1732584193,-271733879,-1732584194,271733878];for(n=64;n<=h;n+=64)e(f,r(t.substring(n-64,n)));for(i=(t=t.substring(n-64)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<i;n+=1)s[n>>2]|=t.charCodeAt(n)<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(e(f,s),n=0;n<16;n+=1)s[n]=0;return a=(a=8*h).toString(16).match(/(.*?)(.{0,8})$/),u=parseInt(a[2],16),o=parseInt(a[1],16)||0,s[14]=u,s[15]=o,e(f,s),f}function s(t){var r,i,s,a,u,o,h=t.length,f=[1732584193,-271733879,-1732584194,271733878];for(r=64;r<=h;r+=64)e(f,n(t.subarray(r-64,r)));for(i=(t=r-64<h?t.subarray(r-64):new Uint8Array(0)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<i;r+=1)s[r>>2]|=t[r]<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(e(f,s),r=0;r<16;r+=1)s[r]=0;return a=(a=8*h).toString(16).match(/(.*?)(.{0,8})$/),u=parseInt(a[2],16),o=parseInt(a[1],16)||0,s[14]=u,s[15]=o,e(f,s),f}function a(t){var e,r="";for(e=0;e<4;e+=1)r+=p[t>>8*e+4&15]+p[t>>8*e&15];return r}function u(t){var e;for(e=0;e<t.length;e+=1)t[e]=a(t[e]);return t.join("")}function o(t){return/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t))),t}function h(t,e){var r,n=t.length,i=new ArrayBuffer(n),s=new Uint8Array(i);for(r=0;r<n;r+=1)s[r]=t.charCodeAt(r);return e?s:i}function f(t){return String.fromCharCode.apply(null,new Uint8Array(t))}function c(t,e,r){var n=new Uint8Array(t.byteLength+e.byteLength);return n.set(new Uint8Array(t)),n.set(new Uint8Array(e),t.byteLength),r?n:n.buffer}function l(t){var e,r=[],n=t.length;for(e=0;e<n-1;e+=2)r.push(parseInt(t.substr(e,2),16));return String.fromCharCode.apply(String,r)}function d(){this.reset()}var p=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return u(i("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function e(t,e){return(t=0|t||0)<0?Math.max(t+e,0):Math.min(t,e)}ArrayBuffer.prototype.slice=function(r,n){var i,s,a,u,o=this.byteLength,h=e(r,o),f=o;return n!==t&&(f=e(n,o)),h>f?new ArrayBuffer(0):(i=f-h,s=new ArrayBuffer(i),a=new Uint8Array(s),u=new Uint8Array(this,h,i),a.set(u),s)}}(),d.prototype.append=function(t){return this.appendBinary(o(t)),this},d.prototype.appendBinary=function(t){this._buff+=t,this._length+=t.length;var n,i=this._buff.length;for(n=64;n<=i;n+=64)e(this._hash,r(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},d.prototype.end=function(t){var e,r,n=this._buff,i=n.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<i;e+=1)s[e>>2]|=n.charCodeAt(e)<<(e%4<<3);return this._finish(s,i),r=u(this._hash),t&&(r=l(r)),this.reset(),r},d.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},d.prototype.setState=function(t){return this._buff=t.buff,this._length=t.length,this._hash=t.hash,this},d.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},d.prototype._finish=function(t,r){var n,i,s,a=r;if(t[a>>2]|=128<<(a%4<<3),a>55)for(e(this._hash,t),a=0;a<16;a+=1)t[a]=0;n=(n=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(n[2],16),s=parseInt(n[1],16)||0,t[14]=i,t[15]=s,e(this._hash,t)},d.hash=function(t,e){return d.hashBinary(o(t),e)},d.hashBinary=function(t,e){var r=u(i(t));return e?l(r):r},d.ArrayBuffer=function(){this.reset()},d.ArrayBuffer.prototype.append=function(t){var r,i=c(this._buff.buffer,t,!0),s=i.length;for(this._length+=t.byteLength,r=64;r<=s;r+=64)e(this._hash,n(i.subarray(r-64,r)));return this._buff=r-64<s?new Uint8Array(i.buffer.slice(r-64)):new Uint8Array(0),this},d.ArrayBuffer.prototype.end=function(t){var e,r,n=this._buff,i=n.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e<i;e+=1)s[e>>2]|=n[e]<<(e%4<<3);return this._finish(s,i),r=u(this._hash),t&&(r=l(r)),this.reset(),r},d.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},d.ArrayBuffer.prototype.getState=function(){var t=d.prototype.getState.call(this);return t.buff=f(t.buff),t},d.ArrayBuffer.prototype.setState=function(t){return t.buff=h(t.buff,!0),d.prototype.setState.call(this,t)},d.ArrayBuffer.prototype.destroy=d.prototype.destroy,d.ArrayBuffer.prototype._finish=d.prototype._finish,d.ArrayBuffer.hash=function(t,e){var r=u(s(new Uint8Array(t)));return e?l(r):r},d},t.exports=e()}),g=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},k=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),m=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,A=function(){function t(e){g(this,t),this.file=e,this.chunkSize=2097152,this.chunkCount=Math.ceil(this.file.size/this.chunkSize),this.chunkIndex=0}return k(t,null,[{key:"create",value:function(e,r){new t(e).create(r)}}]),k(t,[{key:"create",value:function(t){var e=this;this.callback=t,this.md5Buffer=new b.ArrayBuffer,this.fileReader=new FileReader,this.fileReader.addEventListener("load",function(t){return e.fileReaderDidLoad(t)}),this.fileReader.addEventListener("error",function(t){return e.fileReaderDidError(t)}),this.readNextChunk()}},{key:"fileReaderDidLoad",value:function(t){if(this.md5Buffer.append(t.target.result),!this.readNextChunk()){var e=this.md5Buffer.end(!0),r=btoa(e);this.callback(null,r)}}},{key:"fileReaderDidError",value:function(){this.callback("Error reading "+this.file.name)}},{key:"readNextChunk",value:function(){if(this.chunkIndex<this.chunkCount||0==this.chunkIndex&&0==this.chunkCount){var t=this.chunkIndex*this.chunkSize,e=Math.min(t+this.chunkSize,this.file.size),r=m.call(this.file,t,e);return this.fileReader.readAsArrayBuffer(r),this.chunkIndex++,!0}return!1}}]),t}(),_=function(){function t(e,n,i){var s=this;g(this,t),this.file=e,this.attributes={filename:e.name,content_type:e.type||"application/octet-stream",byte_size:e.size,checksum:n},this.xhr=new XMLHttpRequest,this.xhr.open("POST",i,!0),this.xhr.responseType="json",this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("Accept","application/json"),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");var a=r("csrf-token");a!=undefined&&this.xhr.setRequestHeader("X-CSRF-Token",a),this.xhr.addEventListener("load",function(t){return s.requestDidLoad(t)}),this.xhr.addEventListener("error",function(t){return s.requestDidError(t)})}return k(t,[{key:"create",value:function(t){this.callback=t,this.xhr.send(JSON.stringify({blob:this.attributes}))}},{key:"requestDidLoad",value:function(t){if(this.status>=200&&this.status<300){var e=this.response,r=e.direct_upload;delete e.direct_upload,this.attributes=e,this.directUploadData=r,this.callback(null,this.toJSON())}else this.requestDidError(t)}},{key:"requestDidError",value:function(){this.callback('Error creating Blob for "'+this.file.name+'". Status: '+this.status)}},{key:"toJSON",value:function(){var t={};for(var e in this.attributes)t[e]=this.attributes[e];return t}},{key:"status",get:function(){return this.xhr.status}},{key:"response",get:function(){var t=this.xhr,e=t.responseType,r=t.response;return"json"==e?r:JSON.parse(r)}}]),t}(),x=function(){function t(e){var r=this;g(this,t),this.blob=e,this.file=e.file;var n=e.directUploadData,i=n.url,s=n.headers;for(var a in this.xhr=new XMLHttpRequest,this.xhr.open("PUT",i,!0),this.xhr.responseType="text",s)this.xhr.setRequestHeader(a,s[a]);this.xhr.addEventListener("load",function(t){return r.requestDidLoad(t)}),this.xhr.addEventListener("error",function(t){return r.requestDidError(t)})}return k(t,[{key:"create",value:function(t){this.callback=t,this.xhr.send(this.file.slice())}},{key:"requestDidLoad",value:function(t){var e=this.xhr,r=e.status,n=e.response;r>=200&&r<300?this.callback(null,n):this.requestDidError(t)}},{key:"requestDidError",value:function(){this.callback('Error storing "'+this.file.name+'". Status: '+this.xhr.status)}}]),t}(),E=0,S=function(){function t(e,r,n){g(this,t),this.id=++E,this.file=e,this.url=r,this.delegate=n}return k(t,[{key:"create",value:function(t){var e=this;A.create(this.file,function(r,n){if(r)t(r);else{var i=new _(e.file,n,e.url);u(e.delegate,"directUploadWillCreateBlobWithXHR",i.xhr),i.create(function(r){if(r)t(r);else{var n=new x(i);u(e.delegate,"directUploadWillStoreFileWithXHR",n.xhr),n.create(function(e){e?t(e):t(null,i.toJSON())})}})}})}}]),t}(),w=function(){function t(e,r){g(this,t),this.input=e,this.file=r,this.directUpload=new S(this.file,this.url,this),this.dispatch("initialize")}return k(t,[{key:"start",value:function(t){var e=this,r=document.createElement("input");r.type="hidden",r.name=this.input.name,this.input.insertAdjacentElement("beforebegin",r),this.dispatch("start"),this.directUpload.create(function(n,i){n?(r.parentNode.removeChild(r),e.dispatchError(n)):r.value=i.signed_id,e.dispatch("end"),t(n)})}},{key:"uploadRequestDidProgress",value:function(t){var e=t.loaded/t.total*100;e&&this.dispatch("progress",{progress:e})}},{key:"dispatch",value:function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return e.file=this.file,e.id=this.directUpload.id,s(this.input,"direct-upload:"+t,{detail:e})}},{key:"dispatchError",value:function(t){this.dispatch("error",{error:t}).defaultPrevented||alert(t)}},{key:"directUploadWillCreateBlobWithXHR",value:function(t){this.dispatch("before-blob-request",{xhr:t})}},{key:"directUploadWillStoreFileWithXHR",value:function(t){var e=this;this.dispatch("before-storage-request",{xhr:t}),t.upload.addEventListener("progress",function(t){return e.uploadRequestDidProgress(t)})}},{key:"url",get:function(){return this.input.getAttribute("data-direct-upload-url")}}]),t}(),B="input[type=file][data-direct-upload-url]:not([disabled])",C=function(){function t(e){g(this,t),this.form=e,this.inputs=n(e,B).filter(function(t){return t.files.length})}return k(t,[{key:"start",value:function(t){var e=this,r=this.createDirectUploadControllers(),n=function i(){var n=r.shift();n?n.start(function(r){r?(t(r),e.dispatch("end")):i()}):(t(),e.dispatch("end"))};this.dispatch("start"),n()}},{key:"createDirectUploadControllers",value:function(){var t=[];return this.inputs.forEach(function(e){a(e.files).forEach(function(r){var n=new w(e,r);t.push(n)})}),t}},{key:"dispatch",value:function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return s(this.form,"direct-uploads:"+t,{detail:e})}}]),t}(),U="data-direct-uploads-processing",R=new WeakMap,q=!1;setTimeout(v,1),t.start=o,t.DirectUpload=S,Object.defineProperty(t,"__esModule",{value:!0})});