@mux/mux-uploader-react
Advanced tools
Comparing version 0.1.0-canary.10-087f23e to 0.1.0-canary.10-17e7b68
@@ -6,2 +6,8 @@ # Change Log | ||
# [0.1.0-beta.4](https://github.com/muxinc/elements/compare/@mux/mux-uploader-react@0.1.0-beta.2...@mux/mux-uploader-react@0.1.0-beta.4) (2022-07-21) | ||
### Bug Fixes | ||
- **mux-uploader, mux-uploader-react:** Add support for endpoint to react version. Clean up type defs, including css vars (drop component only). Remove unnecessary capture for DandD events. ([c12ded5](https://github.com/muxinc/elements/commit/c12ded5188a3d97d48dc335a98d8537b6fa57443)) | ||
# 0.1.0-beta.2 (2022-07-11) | ||
@@ -8,0 +14,0 @@ |
@@ -1,4 +0,4 @@ | ||
var et=Object.create;var se=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var Se=e=>se(e,"__esModule",{value:!0});var st=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),it=(e,t)=>{Se(e);for(var r in t)se(e,r,{get:t[r],enumerable:!0})},at=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nt(t))!ot.call(e,o)&&o!=="default"&&se(e,o,{get:()=>t[o],enumerable:!(r=tt(t,o))||r.enumerable});return e},z=e=>at(Se(se(e!=null?et(rt(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var _e=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var Be=(e,t,r)=>(_e(e,t,"read from private field"),r?r.call(e):t.get(e)),Ue=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},De=(e,t,r,o)=>(_e(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var Ne=st((ee,he)=>{(function(e,t){typeof ee=="object"&&typeof he=="object"?he.exports=t():typeof define=="function"&&define.amd?define([],t):typeof ee=="object"?ee.UpChunk=t():e.UpChunk=t()})(ee,function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(o,a,p){r.o(o,a)||Object.defineProperty(o,a,{enumerable:!0,get:p})},r.r=function(o){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},r.t=function(o,a){if(1&a&&(o=r(o)),8&a||4&a&&typeof o=="object"&&o&&o.__esModule)return o;var p=Object.create(null);if(r.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:o}),2&a&&typeof o!="string")for(var T in o)r.d(p,T,function(k){return o[k]}.bind(null,T));return p},r.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return r.d(a,"a",a),a},r.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)},r.p="",r(r.s=1)}([function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch{typeof window=="object"&&(r=window)}e.exports=r},function(e,t,r){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(f){for(var n,l=1,b=arguments.length;l<b;l++)for(var E in n=arguments[l])Object.prototype.hasOwnProperty.call(n,E)&&(f[E]=n[E]);return f}).apply(this,arguments)};t.__esModule=!0,t.createUpload=t.UpChunk=void 0;var a=r(2),p=r(4),T=[200,201,202,204,308],k=[408,502,503,504],v=function(){function f(n){var l=this;this.endpoint=n.endpoint,this.file=n.file,this.headers=n.headers||{},this.method=n.method||"PUT",this.chunkSize=n.chunkSize||30720,this.attempts=n.attempts||5,this.delayBeforeAttempt=n.delayBeforeAttempt||1,this.maxFileBytes=1024*(n.maxFileSize||0),this.chunkCount=0,this.chunkByteSize=1024*this.chunkSize,this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.attemptCount=0,this.offline=!1,this.paused=!1,this.success=!1,this.reader=new FileReader,this.eventTarget=new a.EventTarget,this.validateOptions(),this.getEndpoint().then(function(){return l.sendChunks()}),typeof window!="undefined"&&(window.addEventListener("online",function(){l.offline&&(l.offline=!1,l.dispatch("online"),l.sendChunks())}),window.addEventListener("offline",function(){l.offline=!0,l.dispatch("offline")}))}return f.prototype.on=function(n,l){this.eventTarget.addEventListener(n,l)},f.prototype.abort=function(){var n;this.pause(),(n=this.currentXhr)===null||n===void 0||n.abort()},f.prototype.pause=function(){this.paused=!0},f.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},f.prototype.dispatch=function(n,l){var b=new CustomEvent(n,{detail:l});this.eventTarget.dispatchEvent(b)},f.prototype.validateOptions=function(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="object")throw new TypeError("headers must be null or an object");if(this.chunkSize&&(typeof this.chunkSize!="number"||this.chunkSize<=0||this.chunkSize%256!=0))throw new TypeError("chunkSize must be a positive number in multiples of 256");if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error("file size exceeds maximum (".concat(this.file.size," > ").concat(this.maxFileBytes,")"));if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},f.prototype.getEndpoint=function(){var n=this;return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(function(l){return n.endpointValue=l,n.endpointValue})},f.prototype.getChunk=function(){var n=this;return new Promise(function(l){var b=n.totalChunks===1?n.file.size:n.chunkByteSize,E=b*n.chunkCount;n.reader.onload=function(){n.reader.result!==null&&(n.chunk=new Blob([n.reader.result],{type:"application/octet-stream"})),l()},n.reader.readAsArrayBuffer(n.file.slice(E,E+b))})},f.prototype.xhrPromise=function(n){var l=this,b=function(E){E.upload.onprogress=function(x){var w,y=100/l.totalChunks,A=y*l.file.size,d=y*l.chunkCount,j=x.loaded/((w=x.total)!==null&&w!==void 0?w:A)*y;l.dispatch("progress",Math.min(d+j,100))}};return new Promise(function(E,x){l.currentXhr=(0,p.default)(o(o({},n),{beforeSend:b}),function(w,y){return l.currentXhr=void 0,w?x(w):E(y)})})},f.prototype.sendChunk=function(){var n=this.chunkCount*this.chunkByteSize,l=n+this.chunk.size-1,b=o(o({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(n,"-").concat(l,"/").concat(this.file.size)});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:b,url:this.endpointValue,method:this.method,body:this.chunk})},f.prototype.manageRetries=function(){var n=this;if(this.attemptCount<this.attempts)return setTimeout(function(){return n.sendChunks()},1e3*this.delayBeforeAttempt),void this.dispatch("attemptFailure",{message:"An error occured uploading chunk ".concat(this.chunkCount,". ").concat(this.attempts-this.attemptCount," retries left."),chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount});this.dispatch("error",{message:"An error occured uploading chunk ".concat(this.chunkCount,". No more retries, stopping upload"),chunk:this.chunkCount,attempts:this.attemptCount})},f.prototype.sendChunks=function(){var n=this;this.paused||this.offline||this.success||this.getChunk().then(function(){return n.attemptCount=n.attemptCount+1,n.sendChunk()}).then(function(l){if(T.includes(l.statusCode)){n.dispatch("chunkSuccess",{chunk:n.chunkCount,attempts:n.attemptCount,response:l}),n.attemptCount=0,n.chunkCount=n.chunkCount+1,n.chunkCount<n.totalChunks?n.sendChunks():(n.success=!0,n.dispatch("success"));var b=100*(n.chunkCount/n.totalChunks*n.file.size)/n.file.size;n.dispatch("progress",b)}else if(k.includes(l.statusCode)){if(n.paused||n.offline)return;n.manageRetries()}else{if(n.paused||n.offline)return;n.dispatch("error",{message:"Server responded with ".concat(l.statusCode,". Stopping upload."),chunkNumber:n.chunkCount,attempts:n.attemptCount})}}).catch(function(l){n.paused||n.offline||n.manageRetries()})},f}();t.UpChunk=v,t.createUpload=function(f){return new v(f)}},function(e,t,r){"use strict";(function(o,a){function p(s,i,...u){if(!s)throw new TypeError(T(i,u))}function T(s,i){let u=0;return s.replace(/%[os]/gu,()=>k(i[u++]))}function k(s){return typeof s!="object"||s===null?String(s):Object.prototype.toString.call(s)}let v;Object.defineProperty(t,"__esModule",{value:!0});let f=typeof window!="undefined"?window:typeof self!="undefined"?self:a!==void 0?a:typeof globalThis!="undefined"?globalThis:void 0,n;class l{constructor(i,u){this.code=i,this.message=u}warn(...i){var u;try{if(n)return void n({...this,args:i});let c=((u=new Error().stack)!==null&&u!==void 0?u:"").replace(/^(?:.+?\n){2}/gu,` | ||
`);console.warn(this.message,...i,c)}catch{}}}let b=new l("W01","Unable to initialize event under dispatching."),E=new l("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),x=new l("W03","Assigning any truthy value to 'returnValue' property has no effect."),w=new l("W04","Unable to preventDefault on non-cancelable events."),y=new l("W05","Unable to preventDefault inside passive event listener invocation."),A=new l("W06","An event listener wasn't added because it has been added already: %o, %o"),d=new l("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),j=new l("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),V=new l("W09","Event attribute handler must be a function: %o");class L{static get NONE(){return q}static get CAPTURING_PHASE(){return _}static get AT_TARGET(){return W}static get BUBBLING_PHASE(){return K}constructor(i,u){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let c=u!=null?u:{};G.set(this,{type:String(i),bubbles:Boolean(c.bubbles),cancelable:Boolean(c.cancelable),composed:Boolean(c.composed),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return g(this).type}get target(){return g(this).target}get srcElement(){return g(this).target}get currentTarget(){return g(this).currentTarget}composedPath(){let i=g(this).currentTarget;return i?[i]:[]}get NONE(){return q}get CAPTURING_PHASE(){return _}get AT_TARGET(){return W}get BUBBLING_PHASE(){return K}get eventPhase(){return g(this).dispatchFlag?2:0}stopPropagation(){g(this).stopPropagationFlag=!0}get cancelBubble(){return g(this).stopPropagationFlag}set cancelBubble(i){i?g(this).stopPropagationFlag=!0:E.warn()}stopImmediatePropagation(){let i=g(this);i.stopPropagationFlag=i.stopImmediatePropagationFlag=!0}get bubbles(){return g(this).bubbles}get cancelable(){return g(this).cancelable}get returnValue(){return!g(this).canceledFlag}set returnValue(i){i?x.warn():P(g(this))}preventDefault(){P(g(this))}get defaultPrevented(){return g(this).canceledFlag}get composed(){return g(this).composed}get isTrusted(){return!1}get timeStamp(){return g(this).timeStamp}initEvent(i,u=!1,c=!1){let h=g(this);h.dispatchFlag?b.warn():G.set(this,{...h,type:String(i),bubbles:Boolean(u),cancelable:Boolean(c),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}let q=0,_=1,W=2,K=3,G=new WeakMap;function g(s,i="this"){let u=G.get(s);return p(u!=null,"'%s' must be an object that Event constructor created, but got another one: %o",i,s),u}function P(s){s.inPassiveListenerFlag?y.warn():s.cancelable?s.canceledFlag=!0:w.warn()}Object.defineProperty(L,"NONE",{enumerable:!0}),Object.defineProperty(L,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(L,"AT_TARGET",{enumerable:!0}),Object.defineProperty(L,"BUBBLING_PHASE",{enumerable:!0});let B=Object.getOwnPropertyNames(L.prototype);for(let s=0;s<B.length;++s)B[s]!=="constructor"&&Object.defineProperty(L.prototype,B[s],{enumerable:!0});let N;f!==void 0&&f.Event!==void 0&&Object.setPrototypeOf(L.prototype,f.Event.prototype);let me={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function be(s){let i=Object.keys(me);for(let u=0;u<i.length;++u){let c=i[u],h=me[c];Object.defineProperty(s,c,{get:()=>h,configurable:!0,enumerable:!0})}}class Z extends L{static wrap(i){return new(function u(c){let h=Object.getPrototypeOf(c);if(h==null)return Z;let m=re.get(h);return m==null&&(m=function(C,M){class O extends C{}let R=Object.keys(M);for(let S=0;S<R.length;++S)Object.defineProperty(O.prototype,R[S],ve(M,R[S]));return O}(u(h),h),re.set(h,m)),m}(i))(i)}constructor(i){super(i.type,{bubbles:i.bubbles,cancelable:i.cancelable,composed:i.composed}),i.cancelBubble&&super.stopPropagation(),i.defaultPrevented&&super.preventDefault(),ye.set(this,{original:i});let u=Object.keys(i);for(let c=0;c<u.length;++c){let h=u[c];h in this||Object.defineProperty(this,h,ve(i,h))}}stopPropagation(){super.stopPropagation();let{original:i}=F(this);"stopPropagation"in i&&i.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(i){super.cancelBubble=i;let{original:u}=F(this);"cancelBubble"in u&&(u.cancelBubble=i)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:i}=F(this);"stopImmediatePropagation"in i&&i.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(i){super.returnValue=i;let{original:u}=F(this);"returnValue"in u&&(u.returnValue=i)}preventDefault(){super.preventDefault();let{original:i}=F(this);"preventDefault"in i&&i.preventDefault()}get timeStamp(){let{original:i}=F(this);return"timeStamp"in i?i.timeStamp:super.timeStamp}}let ye=new WeakMap;function F(s){let i=ye.get(s);return p(i!=null,"'this' is expected an Event object, but got",s),i}let re=new WeakMap;function ve(s,i){let u=Object.getOwnPropertyDescriptor(s,i);return{get(){let c=F(this).original,h=c[i];return typeof h=="function"?h.bind(c):h},set(c){F(this).original[i]=c},configurable:u.configurable,enumerable:u.enumerable}}function Ee(s){return(1&s.flags)==1}function Te(s){return(2&s.flags)==2}function we(s){return(4&s.flags)==4}function Je(s){return(8&s.flags)==8}function Qe({callback:s},i,u){try{typeof s=="function"?s.call(i,u):typeof s.handleEvent=="function"&&s.handleEvent(u)}catch(c){(function(h){try{let m=h instanceof Error?h:new Error(k(h));if(v)return void v(m);if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:m,message:m.message}));else if(o!==void 0&&typeof o.emit=="function")return void o.emit("uncaughtException",m);console.error(m)}catch{}})(c)}}function ke({listeners:s},i,u){for(let c=0;c<s.length;++c)if(s[c].callback===i&&Ee(s[c])===u)return c;return-1}function Re(s,i,u,c,h,m){let C;m&&(C=pe.bind(null,s,i,u),m.addEventListener("abort",C));let M=function(O,R,S,U,oe,D){return{callback:O,flags:(R?1:0)|(S?2:0)|(U?4:0),signal:oe,signalListener:D}}(i,u,c,h,m,C);return s.cow?(s.cow=!1,s.listeners=[...s.listeners,M]):s.listeners.push(M),M}function pe(s,i,u){let c=ke(s,i,u);return c!==-1&&xe(s,c)}function xe(s,i,u=!1){let c=s.listeners[i];return function(h){h.flags|=8}(c),c.signal&&c.signal.removeEventListener("abort",c.signalListener),s.cow&&!u?(s.cow=!1,s.listeners=s.listeners.filter((h,m)=>m!==i),!1):(s.listeners.splice(i,1),!0)}function Pe(s,i){var u;return(u=s[i])!==null&&u!==void 0?u:s[i]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}re.set(Object.prototype,Z),f!==void 0&&f.Event!==void 0&&re.set(f.Event.prototype,Z);class ${constructor(){Ce.set(this,Object.create(null))}addEventListener(i,u,c){let h=Y(this),{callback:m,capture:C,once:M,passive:O,signal:R,type:S}=function(D,H,I){var J;return Ae(H),typeof I=="object"&&I!==null?{type:String(D),callback:H!=null?H:void 0,capture:Boolean(I.capture),passive:Boolean(I.passive),once:Boolean(I.once),signal:(J=I.signal)!==null&&J!==void 0?J:void 0}:{type:String(D),callback:H!=null?H:void 0,capture:Boolean(I),passive:!1,once:!1,signal:void 0}}(i,u,c);if(m==null||(R==null?void 0:R.aborted))return;let U=Pe(h,S),oe=ke(U,m,C);oe===-1?Re(U,m,C,O,M,R):function(D,H,I,J){A.warn(Ee(D)?"capture":"bubble",D.callback),Te(D)!==H&&d.warn("passive"),we(D)!==I&&d.warn("once"),D.signal!==J&&d.warn("signal")}(U.listeners[oe],O,M,R)}removeEventListener(i,u,c){let h=Y(this),{callback:m,capture:C,type:M}=function(R,S,U){return Ae(S),typeof U=="object"&&U!==null?{type:String(R),callback:S!=null?S:void 0,capture:Boolean(U.capture)}:{type:String(R),callback:S!=null?S:void 0,capture:Boolean(U)}}(i,u,c),O=h[M];m!=null&&O&&pe(O,m,C)}dispatchEvent(i){let u=Y(this)[String(i.type)];if(u==null)return!0;let c=i instanceof L?i:Z.wrap(i),h=g(c,"event");if(h.dispatchFlag)throw m="This event has been in dispatching.",f.DOMException?new f.DOMException(m,"InvalidStateError"):(N==null&&(N=class Fe extends Error{constructor(M){super(M),Error.captureStackTrace&&Error.captureStackTrace(this,Fe)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(N.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),be(N),be(N.prototype)),new N(m));var m;if(h.dispatchFlag=!0,h.target=h.currentTarget=this,!h.stopPropagationFlag){let{cow:C,listeners:M}=u;u.cow=!0;for(let O=0;O<M.length;++O){let R=M[O];if(!Je(R)&&(we(R)&&xe(u,O,!C)&&(O-=1),h.inPassiveListenerFlag=Te(R),Qe(R,this,c),h.inPassiveListenerFlag=!1,h.stopImmediatePropagationFlag))break}C||(u.cow=!1)}return h.target=null,h.currentTarget=null,h.stopImmediatePropagationFlag=!1,h.stopPropagationFlag=!1,h.dispatchFlag=!1,!h.canceledFlag}}let Ce=new WeakMap;function Y(s,i="this"){let u=Ce.get(s);return p(u!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",i,s),u}function Ae(s){if(typeof s!="function"&&(typeof s!="object"||s===null||typeof s.handleEvent!="function")){if(s!=null&&typeof s!="object")throw new TypeError(T(j.message,[s]));j.warn(s)}}let de=Object.getOwnPropertyNames($.prototype);for(let s=0;s<de.length;++s)de[s]!=="constructor"&&Object.defineProperty($.prototype,de[s],{enumerable:!0});function Me(s,i){var u,c;return(c=(u=Y(s,"target")[i])===null||u===void 0?void 0:u.attrCallback)!==null&&c!==void 0?c:null}function Oe(s,i,u){u!=null&&typeof u!="function"&&V.warn(u),typeof u=="function"||typeof u=="object"&&u!==null?function(c,h,m){let C=Pe(Y(c,"target"),String(h));C.attrCallback=m,C.attrListener==null&&(C.attrListener=Re(C,function(M){return function(O){let R=M.attrCallback;typeof R=="function"&&R.call(this,O)}}(C),!1,!1,!1,void 0))}(s,i,u):function(c,h){let m=Y(c,"target")[String(h)];m&&m.attrListener&&(pe(m,m.attrListener.callback,!1),m.attrCallback=m.attrListener=void 0)}(s,i)}function Le(s,i,u){Object.defineProperty(s,"on"+i,{get(){return Me(this,i)},set(c){Oe(this,i,c)},configurable:!0,enumerable:!0})}f!==void 0&&f.EventTarget!==void 0&&Object.setPrototypeOf($.prototype,f.EventTarget.prototype),t.Event=L,t.EventTarget=$,t.default=$,t.defineCustomEventTarget=function(...s){class i extends ${}for(let u=0;u<s.length;++u)Le(i.prototype,s[u]);return i},t.defineEventAttribute=Le,t.getEventAttributeValue=Me,t.setErrorHandler=function(s){p(typeof s=="function"||s===void 0,"The error handler must be a function or undefined, but got %o.",s),v=s},t.setEventAttributeValue=Oe,t.setWarningHandler=function(s){p(typeof s=="function"||s===void 0,"The warning handler must be a function or undefined, but got %o.",s),n=s}}).call(this,r(3),r(0))},function(e,t){var r,o,a=e.exports={};function p(){throw new Error("setTimeout has not been defined")}function T(){throw new Error("clearTimeout has not been defined")}function k(y){if(r===setTimeout)return setTimeout(y,0);if((r===p||!r)&&setTimeout)return r=setTimeout,setTimeout(y,0);try{return r(y,0)}catch{try{return r.call(null,y,0)}catch{return r.call(this,y,0)}}}(function(){try{r=typeof setTimeout=="function"?setTimeout:p}catch{r=p}try{o=typeof clearTimeout=="function"?clearTimeout:T}catch{o=T}})();var v,f=[],n=!1,l=-1;function b(){n&&v&&(n=!1,v.length?f=v.concat(f):l=-1,f.length&&E())}function E(){if(!n){var y=k(b);n=!0;for(var A=f.length;A;){for(v=f,f=[];++l<A;)v&&v[l].run();l=-1,A=f.length}v=null,n=!1,function(d){if(o===clearTimeout)return clearTimeout(d);if((o===T||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(d);try{o(d)}catch{try{return o.call(null,d)}catch{return o.call(this,d)}}}(y)}}function x(y,A){this.fun=y,this.array=A}function w(){}a.nextTick=function(y){var A=new Array(arguments.length-1);if(arguments.length>1)for(var d=1;d<arguments.length;d++)A[d-1]=arguments[d];f.push(new x(y,A)),f.length!==1||n||k(E)},x.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=w,a.addListener=w,a.once=w,a.off=w,a.removeListener=w,a.removeAllListeners=w,a.emit=w,a.prependListener=w,a.prependOnceListener=w,a.listeners=function(y){return[]},a.binding=function(y){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(y){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,t,r){"use strict";var o=r(5),a=r(6),p=r(7),T=r(8);function k(n,l,b){var E=n;return a(l)?(b=l,typeof n=="string"&&(E={uri:n})):E=T(l,{uri:n}),E.callback=b,E}function v(n,l,b){return f(l=k(n,l,b))}function f(n){if(n.callback===void 0)throw new Error("callback argument missing");var l=!1,b=function(g,P,B){l||(l=!0,n.callback(g,P,B))};function E(){var g=void 0;if(g=d.response?d.response:d.responseText||function(P){try{if(P.responseType==="document")return P.responseXML;var B=P.responseXML&&P.responseXML.documentElement.nodeName==="parsererror";if(P.responseType===""&&!B)return P.responseXML}catch{}return null}(d),K)try{g=JSON.parse(g)}catch{}return g}function x(g){return clearTimeout(j),g instanceof Error||(g=new Error(""+(g||"Unknown XMLHttpRequest Error"))),g.statusCode=0,b(g,G)}function w(){if(!A){var g;clearTimeout(j),g=n.useXDR&&d.status===void 0?200:d.status===1223?204:d.status;var P=G,B=null;return g!==0?(P={body:E(),statusCode:g,method:L,headers:{},url:V,rawRequest:d},d.getAllResponseHeaders&&(P.headers=p(d.getAllResponseHeaders()))):B=new Error("Internal XMLHttpRequest Error"),b(B,P,P.body)}}var y,A,d=n.xhr||null;d||(d=n.cors||n.useXDR?new v.XDomainRequest:new v.XMLHttpRequest);var j,V=d.url=n.uri||n.url,L=d.method=n.method||"GET",q=n.body||n.data,_=d.headers=n.headers||{},W=!!n.sync,K=!1,G={body:void 0,headers:{},statusCode:0,method:L,url:V,rawRequest:d};if("json"in n&&n.json!==!1&&(K=!0,_.accept||_.Accept||(_.Accept="application/json"),L!=="GET"&&L!=="HEAD"&&(_["content-type"]||_["Content-Type"]||(_["Content-Type"]="application/json"),q=JSON.stringify(n.json===!0?q:n.json))),d.onreadystatechange=function(){d.readyState===4&&setTimeout(w,0)},d.onload=w,d.onerror=x,d.onprogress=function(){},d.onabort=function(){A=!0},d.ontimeout=x,d.open(L,V,!W,n.username,n.password),W||(d.withCredentials=!!n.withCredentials),!W&&n.timeout>0&&(j=setTimeout(function(){if(!A){A=!0,d.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",x(g)}},n.timeout)),d.setRequestHeader)for(y in _)_.hasOwnProperty(y)&&d.setRequestHeader(y,_[y]);else if(n.headers&&!function(g){for(var P in g)if(g.hasOwnProperty(P))return!1;return!0}(n.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in n&&(d.responseType=n.responseType),"beforeSend"in n&&typeof n.beforeSend=="function"&&n.beforeSend(d),d.send(q||null),d}e.exports=v,e.exports.default=v,v.XMLHttpRequest=o.XMLHttpRequest||function(){},v.XDomainRequest="withCredentials"in new v.XMLHttpRequest?v.XMLHttpRequest:o.XDomainRequest,function(n,l){for(var b=0;b<n.length;b++)l(n[b])}(["get","put","post","patch","head","delete"],function(n){v[n==="delete"?"del":n]=function(l,b,E){return(b=k(l,b,E)).method=n.toUpperCase(),f(b)}})},function(e,t,r){(function(o){var a;a=typeof window!="undefined"?window:o!==void 0?o:typeof self!="undefined"?self:{},e.exports=a}).call(this,r(0))},function(e,t){e.exports=function(o){if(!o)return!1;var a=r.call(o);return a==="[object Function]"||typeof o=="function"&&a!=="[object RegExp]"||typeof window!="undefined"&&(o===window.setTimeout||o===window.alert||o===window.confirm||o===window.prompt)};var r=Object.prototype.toString},function(e,t){var r=function(o){return o.replace(/^\s+|\s+$/g,"")};e.exports=function(o){if(!o)return{};for(var a,p={},T=r(o).split(` | ||
`),k=0;k<T.length;k++){var v=T[k],f=v.indexOf(":"),n=r(v.slice(0,f)).toLowerCase(),l=r(v.slice(f+1));p[n]===void 0?p[n]=l:(a=p[n],Object.prototype.toString.call(a)==="[object Array]"?p[n].push(l):p[n]=[p[n],l])}return p}},function(e,t){e.exports=function(){for(var o={},a=0;a<arguments.length;a++){var p=arguments[a];for(var T in p)r.call(p,T)&&(o[T]=p[T])}return o};var r=Object.prototype.hasOwnProperty}])})});it(exports,{MuxUploaderDrop:()=>Ye,default:()=>Ct});var X=z(require("react"));if(typeof DocumentFragment=="undefined"){class e{}globalThis.DocumentFragment=e}globalThis.customElements||(globalThis.customElements={get(e){},define(e,t,r){},upgrade(e){},whenDefined(e){return Promise.resolve(globalThis.HTMLElement)}});var Q;if(!globalThis.CustomEvent){class e{constructor(r,o={}){Ue(this,Q,void 0);De(this,Q,o==null?void 0:o.detail)}get detail(){Be(this,Q)}initCustomEvent(r,o,a,p){}}Q=new WeakMap,globalThis.CustomEvent=e}if(!globalThis.EventTarget){class e{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}}globalThis.EventTarget=e}if(!globalThis.HTMLElement){class e extends EventTarget{}globalThis.HTMLElement=e}if(!globalThis.HTMLVideoElement){class e extends EventTarget{}globalThis.HTMLVideoElement=e}var je,Ie;if(!((je=globalThis.document)==null?void 0:je.createElement)){let e=(Ie=globalThis.document)!=null?Ie:{};e.createElement=function(r,o){return new HTMLElement},globalThis.document=e}var Xe=z(Ne()),He=document.createElement("template");He.innerHTML=` | ||
var te=Object.create;var it=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var Ot=t=>it(t,"__esModule",{value:!0});var se=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ie=(t,e)=>{Ot(t);for(var r in e)it(t,r,{get:e[r],enumerable:!0})},ae=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ne(e))!oe.call(t,o)&&o!=="default"&&it(t,o,{get:()=>e[o],enumerable:!(r=ee(e,o))||r.enumerable});return t},z=t=>ae(Ot(it(t!=null?te(re(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var _t=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var Bt=(t,e,r)=>(_t(t,e,"read from private field"),r?r.call(t):e.get(t)),Ut=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Dt=(t,e,r,o)=>(_t(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r);var Nt=se((et,ft)=>{(function(t,e){typeof et=="object"&&typeof ft=="object"?ft.exports=e():typeof define=="function"&&define.amd?define([],e):typeof et=="object"?et.UpChunk=e():t.UpChunk=e()})(et,function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=t,r.c=e,r.d=function(o,a,p){r.o(o,a)||Object.defineProperty(o,a,{enumerable:!0,get:p})},r.r=function(o){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},r.t=function(o,a){if(1&a&&(o=r(o)),8&a||4&a&&typeof o=="object"&&o&&o.__esModule)return o;var p=Object.create(null);if(r.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:o}),2&a&&typeof o!="string")for(var T in o)r.d(p,T,function(k){return o[k]}.bind(null,T));return p},r.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return r.d(a,"a",a),a},r.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)},r.p="",r(r.s=1)}([function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch{typeof window=="object"&&(r=window)}t.exports=r},function(t,e,r){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(d){for(var n,l=1,b=arguments.length;l<b;l++)for(var E in n=arguments[l])Object.prototype.hasOwnProperty.call(n,E)&&(d[E]=n[E]);return d}).apply(this,arguments)};e.__esModule=!0,e.createUpload=e.UpChunk=void 0;var a=r(2),p=r(4),T=[200,201,202,204,308],k=[408,502,503,504],v=function(){function d(n){var l=this;this.endpoint=n.endpoint,this.file=n.file,this.headers=n.headers||{},this.method=n.method||"PUT",this.chunkSize=n.chunkSize||30720,this.attempts=n.attempts||5,this.delayBeforeAttempt=n.delayBeforeAttempt||1,this.maxFileBytes=1024*(n.maxFileSize||0),this.chunkCount=0,this.chunkByteSize=1024*this.chunkSize,this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.attemptCount=0,this.offline=!1,this.paused=!1,this.success=!1,this.reader=new FileReader,this.eventTarget=new a.EventTarget,this.validateOptions(),this.getEndpoint().then(function(){return l.sendChunks()}),typeof window!="undefined"&&(window.addEventListener("online",function(){l.offline&&(l.offline=!1,l.dispatch("online"),l.sendChunks())}),window.addEventListener("offline",function(){l.offline=!0,l.dispatch("offline")}))}return d.prototype.on=function(n,l){this.eventTarget.addEventListener(n,l)},d.prototype.abort=function(){var n;this.pause(),(n=this.currentXhr)===null||n===void 0||n.abort()},d.prototype.pause=function(){this.paused=!0},d.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},d.prototype.dispatch=function(n,l){var b=new CustomEvent(n,{detail:l});this.eventTarget.dispatchEvent(b)},d.prototype.validateOptions=function(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="object")throw new TypeError("headers must be null or an object");if(this.chunkSize&&(typeof this.chunkSize!="number"||this.chunkSize<=0||this.chunkSize%256!=0))throw new TypeError("chunkSize must be a positive number in multiples of 256");if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error("file size exceeds maximum (".concat(this.file.size," > ").concat(this.maxFileBytes,")"));if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},d.prototype.getEndpoint=function(){var n=this;return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(function(l){return n.endpointValue=l,n.endpointValue})},d.prototype.getChunk=function(){var n=this;return new Promise(function(l){var b=n.totalChunks===1?n.file.size:n.chunkByteSize,E=b*n.chunkCount;n.reader.onload=function(){n.reader.result!==null&&(n.chunk=new Blob([n.reader.result],{type:"application/octet-stream"})),l()},n.reader.readAsArrayBuffer(n.file.slice(E,E+b))})},d.prototype.xhrPromise=function(n){var l=this,b=function(E){E.upload.onprogress=function(P){var w,y=100/l.totalChunks,S=y*l.file.size,h=y*l.chunkCount,j=P.loaded/((w=P.total)!==null&&w!==void 0?w:S)*y;l.dispatch("progress",Math.min(h+j,100))}};return new Promise(function(E,P){l.currentXhr=(0,p.default)(o(o({},n),{beforeSend:b}),function(w,y){return l.currentXhr=void 0,w?P(w):E(y)})})},d.prototype.sendChunk=function(){var n=this.chunkCount*this.chunkByteSize,l=n+this.chunk.size-1,b=o(o({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(n,"-").concat(l,"/").concat(this.file.size)});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:b,url:this.endpointValue,method:this.method,body:this.chunk})},d.prototype.manageRetries=function(){var n=this;if(this.attemptCount<this.attempts)return setTimeout(function(){return n.sendChunks()},1e3*this.delayBeforeAttempt),void this.dispatch("attemptFailure",{message:"An error occured uploading chunk ".concat(this.chunkCount,". ").concat(this.attempts-this.attemptCount," retries left."),chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount});this.dispatch("error",{message:"An error occured uploading chunk ".concat(this.chunkCount,". No more retries, stopping upload"),chunk:this.chunkCount,attempts:this.attemptCount})},d.prototype.sendChunks=function(){var n=this;this.paused||this.offline||this.success||this.getChunk().then(function(){return n.attemptCount=n.attemptCount+1,n.sendChunk()}).then(function(l){if(T.includes(l.statusCode)){n.dispatch("chunkSuccess",{chunk:n.chunkCount,attempts:n.attemptCount,response:l}),n.attemptCount=0,n.chunkCount=n.chunkCount+1,n.chunkCount<n.totalChunks?n.sendChunks():(n.success=!0,n.dispatch("success"));var b=100*(n.chunkCount/n.totalChunks*n.file.size)/n.file.size;n.dispatch("progress",b)}else if(k.includes(l.statusCode)){if(n.paused||n.offline)return;n.manageRetries()}else{if(n.paused||n.offline)return;n.dispatch("error",{message:"Server responded with ".concat(l.statusCode,". Stopping upload."),chunkNumber:n.chunkCount,attempts:n.attemptCount})}}).catch(function(l){n.paused||n.offline||n.manageRetries()})},d}();e.UpChunk=v,e.createUpload=function(d){return new v(d)}},function(t,e,r){"use strict";(function(o,a){function p(s,i,...u){if(!s)throw new TypeError(T(i,u))}function T(s,i){let u=0;return s.replace(/%[os]/gu,()=>k(i[u++]))}function k(s){return typeof s!="object"||s===null?String(s):Object.prototype.toString.call(s)}let v;Object.defineProperty(e,"__esModule",{value:!0});let d=typeof window!="undefined"?window:typeof self!="undefined"?self:a!==void 0?a:typeof globalThis!="undefined"?globalThis:void 0,n;class l{constructor(i,u){this.code=i,this.message=u}warn(...i){var u;try{if(n)return void n({...this,args:i});let c=((u=new Error().stack)!==null&&u!==void 0?u:"").replace(/^(?:.+?\n){2}/gu,` | ||
`);console.warn(this.message,...i,c)}catch{}}}let b=new l("W01","Unable to initialize event under dispatching."),E=new l("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),P=new l("W03","Assigning any truthy value to 'returnValue' property has no effect."),w=new l("W04","Unable to preventDefault on non-cancelable events."),y=new l("W05","Unable to preventDefault inside passive event listener invocation."),S=new l("W06","An event listener wasn't added because it has been added already: %o, %o"),h=new l("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),j=new l("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),V=new l("W09","Event attribute handler must be a function: %o");class L{static get NONE(){return q}static get CAPTURING_PHASE(){return _}static get AT_TARGET(){return W}static get BUBBLING_PHASE(){return Z}constructor(i,u){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let c=u!=null?u:{};G.set(this,{type:String(i),bubbles:Boolean(c.bubbles),cancelable:Boolean(c.cancelable),composed:Boolean(c.composed),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return g(this).type}get target(){return g(this).target}get srcElement(){return g(this).target}get currentTarget(){return g(this).currentTarget}composedPath(){let i=g(this).currentTarget;return i?[i]:[]}get NONE(){return q}get CAPTURING_PHASE(){return _}get AT_TARGET(){return W}get BUBBLING_PHASE(){return Z}get eventPhase(){return g(this).dispatchFlag?2:0}stopPropagation(){g(this).stopPropagationFlag=!0}get cancelBubble(){return g(this).stopPropagationFlag}set cancelBubble(i){i?g(this).stopPropagationFlag=!0:E.warn()}stopImmediatePropagation(){let i=g(this);i.stopPropagationFlag=i.stopImmediatePropagationFlag=!0}get bubbles(){return g(this).bubbles}get cancelable(){return g(this).cancelable}get returnValue(){return!g(this).canceledFlag}set returnValue(i){i?P.warn():x(g(this))}preventDefault(){x(g(this))}get defaultPrevented(){return g(this).canceledFlag}get composed(){return g(this).composed}get isTrusted(){return!1}get timeStamp(){return g(this).timeStamp}initEvent(i,u=!1,c=!1){let f=g(this);f.dispatchFlag?b.warn():G.set(this,{...f,type:String(i),bubbles:Boolean(u),cancelable:Boolean(c),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}let q=0,_=1,W=2,Z=3,G=new WeakMap;function g(s,i="this"){let u=G.get(s);return p(u!=null,"'%s' must be an object that Event constructor created, but got another one: %o",i,s),u}function x(s){s.inPassiveListenerFlag?y.warn():s.cancelable?s.canceledFlag=!0:w.warn()}Object.defineProperty(L,"NONE",{enumerable:!0}),Object.defineProperty(L,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(L,"AT_TARGET",{enumerable:!0}),Object.defineProperty(L,"BUBBLING_PHASE",{enumerable:!0});let B=Object.getOwnPropertyNames(L.prototype);for(let s=0;s<B.length;++s)B[s]!=="constructor"&&Object.defineProperty(L.prototype,B[s],{enumerable:!0});let N;d!==void 0&&d.Event!==void 0&&Object.setPrototypeOf(L.prototype,d.Event.prototype);let mt={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function bt(s){let i=Object.keys(mt);for(let u=0;u<i.length;++u){let c=i[u],f=mt[c];Object.defineProperty(s,c,{get:()=>f,configurable:!0,enumerable:!0})}}class J extends L{static wrap(i){return new(function u(c){let f=Object.getPrototypeOf(c);if(f==null)return J;let m=ot.get(f);return m==null&&(m=function(C,A){class M extends C{}let R=Object.keys(A);for(let O=0;O<R.length;++O)Object.defineProperty(M.prototype,R[O],yt(A,R[O]));return M}(u(f),f),ot.set(f,m)),m}(i))(i)}constructor(i){super(i.type,{bubbles:i.bubbles,cancelable:i.cancelable,composed:i.composed}),i.cancelBubble&&super.stopPropagation(),i.defaultPrevented&&super.preventDefault(),vt.set(this,{original:i});let u=Object.keys(i);for(let c=0;c<u.length;++c){let f=u[c];f in this||Object.defineProperty(this,f,yt(i,f))}}stopPropagation(){super.stopPropagation();let{original:i}=F(this);"stopPropagation"in i&&i.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(i){super.cancelBubble=i;let{original:u}=F(this);"cancelBubble"in u&&(u.cancelBubble=i)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:i}=F(this);"stopImmediatePropagation"in i&&i.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(i){super.returnValue=i;let{original:u}=F(this);"returnValue"in u&&(u.returnValue=i)}preventDefault(){super.preventDefault();let{original:i}=F(this);"preventDefault"in i&&i.preventDefault()}get timeStamp(){let{original:i}=F(this);return"timeStamp"in i?i.timeStamp:super.timeStamp}}let vt=new WeakMap;function F(s){let i=vt.get(s);return p(i!=null,"'this' is expected an Event object, but got",s),i}let ot=new WeakMap;function yt(s,i){let u=Object.getOwnPropertyDescriptor(s,i);return{get(){let c=F(this).original,f=c[i];return typeof f=="function"?f.bind(c):f},set(c){F(this).original[i]=c},configurable:u.configurable,enumerable:u.enumerable}}function Et(s){return(1&s.flags)==1}function Tt(s){return(2&s.flags)==2}function wt(s){return(4&s.flags)==4}function Jt(s){return(8&s.flags)==8}function Qt({callback:s},i,u){try{typeof s=="function"?s.call(i,u):typeof s.handleEvent=="function"&&s.handleEvent(u)}catch(c){(function(f){try{let m=f instanceof Error?f:new Error(k(f));if(v)return void v(m);if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:m,message:m.message}));else if(o!==void 0&&typeof o.emit=="function")return void o.emit("uncaughtException",m);console.error(m)}catch{}})(c)}}function kt({listeners:s},i,u){for(let c=0;c<s.length;++c)if(s[c].callback===i&&Et(s[c])===u)return c;return-1}function Rt(s,i,u,c,f,m){let C;m&&(C=dt.bind(null,s,i,u),m.addEventListener("abort",C));let A=function(M,R,O,U,st,D){return{callback:M,flags:(R?1:0)|(O?2:0)|(U?4:0),signal:st,signalListener:D}}(i,u,c,f,m,C);return s.cow?(s.cow=!1,s.listeners=[...s.listeners,A]):s.listeners.push(A),A}function dt(s,i,u){let c=kt(s,i,u);return c!==-1&&Pt(s,c)}function Pt(s,i,u=!1){let c=s.listeners[i];return function(f){f.flags|=8}(c),c.signal&&c.signal.removeEventListener("abort",c.signalListener),s.cow&&!u?(s.cow=!1,s.listeners=s.listeners.filter((f,m)=>m!==i),!1):(s.listeners.splice(i,1),!0)}function xt(s,i){var u;return(u=s[i])!==null&&u!==void 0?u:s[i]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}ot.set(Object.prototype,J),d!==void 0&&d.Event!==void 0&&ot.set(d.Event.prototype,J);class ${constructor(){Ct.set(this,Object.create(null))}addEventListener(i,u,c){let f=Y(this),{callback:m,capture:C,once:A,passive:M,signal:R,type:O}=function(D,H,I){var Q;return St(H),typeof I=="object"&&I!==null?{type:String(D),callback:H!=null?H:void 0,capture:Boolean(I.capture),passive:Boolean(I.passive),once:Boolean(I.once),signal:(Q=I.signal)!==null&&Q!==void 0?Q:void 0}:{type:String(D),callback:H!=null?H:void 0,capture:Boolean(I),passive:!1,once:!1,signal:void 0}}(i,u,c);if(m==null||(R==null?void 0:R.aborted))return;let U=xt(f,O),st=kt(U,m,C);st===-1?Rt(U,m,C,M,A,R):function(D,H,I,Q){S.warn(Et(D)?"capture":"bubble",D.callback),Tt(D)!==H&&h.warn("passive"),wt(D)!==I&&h.warn("once"),D.signal!==Q&&h.warn("signal")}(U.listeners[st],M,A,R)}removeEventListener(i,u,c){let f=Y(this),{callback:m,capture:C,type:A}=function(R,O,U){return St(O),typeof U=="object"&&U!==null?{type:String(R),callback:O!=null?O:void 0,capture:Boolean(U.capture)}:{type:String(R),callback:O!=null?O:void 0,capture:Boolean(U)}}(i,u,c),M=f[A];m!=null&&M&&dt(M,m,C)}dispatchEvent(i){let u=Y(this)[String(i.type)];if(u==null)return!0;let c=i instanceof L?i:J.wrap(i),f=g(c,"event");if(f.dispatchFlag)throw m="This event has been in dispatching.",d.DOMException?new d.DOMException(m,"InvalidStateError"):(N==null&&(N=class Ft extends Error{constructor(A){super(A),Error.captureStackTrace&&Error.captureStackTrace(this,Ft)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(N.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),bt(N),bt(N.prototype)),new N(m));var m;if(f.dispatchFlag=!0,f.target=f.currentTarget=this,!f.stopPropagationFlag){let{cow:C,listeners:A}=u;u.cow=!0;for(let M=0;M<A.length;++M){let R=A[M];if(!Jt(R)&&(wt(R)&&Pt(u,M,!C)&&(M-=1),f.inPassiveListenerFlag=Tt(R),Qt(R,this,c),f.inPassiveListenerFlag=!1,f.stopImmediatePropagationFlag))break}C||(u.cow=!1)}return f.target=null,f.currentTarget=null,f.stopImmediatePropagationFlag=!1,f.stopPropagationFlag=!1,f.dispatchFlag=!1,!f.canceledFlag}}let Ct=new WeakMap;function Y(s,i="this"){let u=Ct.get(s);return p(u!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",i,s),u}function St(s){if(typeof s!="function"&&(typeof s!="object"||s===null||typeof s.handleEvent!="function")){if(s!=null&&typeof s!="object")throw new TypeError(T(j.message,[s]));j.warn(s)}}let ht=Object.getOwnPropertyNames($.prototype);for(let s=0;s<ht.length;++s)ht[s]!=="constructor"&&Object.defineProperty($.prototype,ht[s],{enumerable:!0});function At(s,i){var u,c;return(c=(u=Y(s,"target")[i])===null||u===void 0?void 0:u.attrCallback)!==null&&c!==void 0?c:null}function Mt(s,i,u){u!=null&&typeof u!="function"&&V.warn(u),typeof u=="function"||typeof u=="object"&&u!==null?function(c,f,m){let C=xt(Y(c,"target"),String(f));C.attrCallback=m,C.attrListener==null&&(C.attrListener=Rt(C,function(A){return function(M){let R=A.attrCallback;typeof R=="function"&&R.call(this,M)}}(C),!1,!1,!1,void 0))}(s,i,u):function(c,f){let m=Y(c,"target")[String(f)];m&&m.attrListener&&(dt(m,m.attrListener.callback,!1),m.attrCallback=m.attrListener=void 0)}(s,i)}function Lt(s,i,u){Object.defineProperty(s,"on"+i,{get(){return At(this,i)},set(c){Mt(this,i,c)},configurable:!0,enumerable:!0})}d!==void 0&&d.EventTarget!==void 0&&Object.setPrototypeOf($.prototype,d.EventTarget.prototype),e.Event=L,e.EventTarget=$,e.default=$,e.defineCustomEventTarget=function(...s){class i extends ${}for(let u=0;u<s.length;++u)Lt(i.prototype,s[u]);return i},e.defineEventAttribute=Lt,e.getEventAttributeValue=At,e.setErrorHandler=function(s){p(typeof s=="function"||s===void 0,"The error handler must be a function or undefined, but got %o.",s),v=s},e.setEventAttributeValue=Mt,e.setWarningHandler=function(s){p(typeof s=="function"||s===void 0,"The warning handler must be a function or undefined, but got %o.",s),n=s}}).call(this,r(3),r(0))},function(t,e){var r,o,a=t.exports={};function p(){throw new Error("setTimeout has not been defined")}function T(){throw new Error("clearTimeout has not been defined")}function k(y){if(r===setTimeout)return setTimeout(y,0);if((r===p||!r)&&setTimeout)return r=setTimeout,setTimeout(y,0);try{return r(y,0)}catch{try{return r.call(null,y,0)}catch{return r.call(this,y,0)}}}(function(){try{r=typeof setTimeout=="function"?setTimeout:p}catch{r=p}try{o=typeof clearTimeout=="function"?clearTimeout:T}catch{o=T}})();var v,d=[],n=!1,l=-1;function b(){n&&v&&(n=!1,v.length?d=v.concat(d):l=-1,d.length&&E())}function E(){if(!n){var y=k(b);n=!0;for(var S=d.length;S;){for(v=d,d=[];++l<S;)v&&v[l].run();l=-1,S=d.length}v=null,n=!1,function(h){if(o===clearTimeout)return clearTimeout(h);if((o===T||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(h);try{o(h)}catch{try{return o.call(null,h)}catch{return o.call(this,h)}}}(y)}}function P(y,S){this.fun=y,this.array=S}function w(){}a.nextTick=function(y){var S=new Array(arguments.length-1);if(arguments.length>1)for(var h=1;h<arguments.length;h++)S[h-1]=arguments[h];d.push(new P(y,S)),d.length!==1||n||k(E)},P.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=w,a.addListener=w,a.once=w,a.off=w,a.removeListener=w,a.removeAllListeners=w,a.emit=w,a.prependListener=w,a.prependOnceListener=w,a.listeners=function(y){return[]},a.binding=function(y){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(y){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(t,e,r){"use strict";var o=r(5),a=r(6),p=r(7),T=r(8);function k(n,l,b){var E=n;return a(l)?(b=l,typeof n=="string"&&(E={uri:n})):E=T(l,{uri:n}),E.callback=b,E}function v(n,l,b){return d(l=k(n,l,b))}function d(n){if(n.callback===void 0)throw new Error("callback argument missing");var l=!1,b=function(g,x,B){l||(l=!0,n.callback(g,x,B))};function E(){var g=void 0;if(g=h.response?h.response:h.responseText||function(x){try{if(x.responseType==="document")return x.responseXML;var B=x.responseXML&&x.responseXML.documentElement.nodeName==="parsererror";if(x.responseType===""&&!B)return x.responseXML}catch{}return null}(h),Z)try{g=JSON.parse(g)}catch{}return g}function P(g){return clearTimeout(j),g instanceof Error||(g=new Error(""+(g||"Unknown XMLHttpRequest Error"))),g.statusCode=0,b(g,G)}function w(){if(!S){var g;clearTimeout(j),g=n.useXDR&&h.status===void 0?200:h.status===1223?204:h.status;var x=G,B=null;return g!==0?(x={body:E(),statusCode:g,method:L,headers:{},url:V,rawRequest:h},h.getAllResponseHeaders&&(x.headers=p(h.getAllResponseHeaders()))):B=new Error("Internal XMLHttpRequest Error"),b(B,x,x.body)}}var y,S,h=n.xhr||null;h||(h=n.cors||n.useXDR?new v.XDomainRequest:new v.XMLHttpRequest);var j,V=h.url=n.uri||n.url,L=h.method=n.method||"GET",q=n.body||n.data,_=h.headers=n.headers||{},W=!!n.sync,Z=!1,G={body:void 0,headers:{},statusCode:0,method:L,url:V,rawRequest:h};if("json"in n&&n.json!==!1&&(Z=!0,_.accept||_.Accept||(_.Accept="application/json"),L!=="GET"&&L!=="HEAD"&&(_["content-type"]||_["Content-Type"]||(_["Content-Type"]="application/json"),q=JSON.stringify(n.json===!0?q:n.json))),h.onreadystatechange=function(){h.readyState===4&&setTimeout(w,0)},h.onload=w,h.onerror=P,h.onprogress=function(){},h.onabort=function(){S=!0},h.ontimeout=P,h.open(L,V,!W,n.username,n.password),W||(h.withCredentials=!!n.withCredentials),!W&&n.timeout>0&&(j=setTimeout(function(){if(!S){S=!0,h.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",P(g)}},n.timeout)),h.setRequestHeader)for(y in _)_.hasOwnProperty(y)&&h.setRequestHeader(y,_[y]);else if(n.headers&&!function(g){for(var x in g)if(g.hasOwnProperty(x))return!1;return!0}(n.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in n&&(h.responseType=n.responseType),"beforeSend"in n&&typeof n.beforeSend=="function"&&n.beforeSend(h),h.send(q||null),h}t.exports=v,t.exports.default=v,v.XMLHttpRequest=o.XMLHttpRequest||function(){},v.XDomainRequest="withCredentials"in new v.XMLHttpRequest?v.XMLHttpRequest:o.XDomainRequest,function(n,l){for(var b=0;b<n.length;b++)l(n[b])}(["get","put","post","patch","head","delete"],function(n){v[n==="delete"?"del":n]=function(l,b,E){return(b=k(l,b,E)).method=n.toUpperCase(),d(b)}})},function(t,e,r){(function(o){var a;a=typeof window!="undefined"?window:o!==void 0?o:typeof self!="undefined"?self:{},t.exports=a}).call(this,r(0))},function(t,e){t.exports=function(o){if(!o)return!1;var a=r.call(o);return a==="[object Function]"||typeof o=="function"&&a!=="[object RegExp]"||typeof window!="undefined"&&(o===window.setTimeout||o===window.alert||o===window.confirm||o===window.prompt)};var r=Object.prototype.toString},function(t,e){var r=function(o){return o.replace(/^\s+|\s+$/g,"")};t.exports=function(o){if(!o)return{};for(var a,p={},T=r(o).split(` | ||
`),k=0;k<T.length;k++){var v=T[k],d=v.indexOf(":"),n=r(v.slice(0,d)).toLowerCase(),l=r(v.slice(d+1));p[n]===void 0?p[n]=l:(a=p[n],Object.prototype.toString.call(a)==="[object Array]"?p[n].push(l):p[n]=[p[n],l])}return p}},function(t,e){t.exports=function(){for(var o={},a=0;a<arguments.length;a++){var p=arguments[a];for(var T in p)r.call(p,T)&&(o[T]=p[T])}return o};var r=Object.prototype.hasOwnProperty}])})});ie(exports,{MuxUploaderDrop:()=>Yt,default:()=>Ce});var X=z(require("react"));if(typeof DocumentFragment=="undefined"){class t{}globalThis.DocumentFragment=t}globalThis.customElements||(globalThis.customElements={get(t){},define(t,e,r){},upgrade(t){},whenDefined(t){return Promise.resolve(globalThis.HTMLElement)}});var tt;if(!globalThis.CustomEvent){class t{constructor(r,o={}){Ut(this,tt,void 0);Dt(this,tt,o==null?void 0:o.detail)}get detail(){Bt(this,tt)}initCustomEvent(r,o,a,p){}}tt=new WeakMap,globalThis.CustomEvent=t}if(!globalThis.EventTarget){class t{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}}globalThis.EventTarget=t}if(!globalThis.HTMLElement){class t extends EventTarget{}globalThis.HTMLElement=t}if(!globalThis.HTMLVideoElement){class t extends EventTarget{}globalThis.HTMLVideoElement=t}var jt,It;if(!((jt=globalThis.document)==null?void 0:jt.createElement)){let t=(It=globalThis.document)!=null?It:{};t.createElement=function(r,o){return new HTMLElement},globalThis.document=t}var Xt=z(Nt()),Ht=document.createElement("template");Ht.innerHTML=` | ||
<style> | ||
@@ -33,3 +33,3 @@ :host { | ||
</div> | ||
`;var ie={MUX_UPLOADER:"mux-uploader",OVERLAY_TEXT:"overlay-text"},ze=class extends HTMLElement{constructor(){super();let e=this.attachShadow({mode:"open"});e.appendChild(He.content.cloneNode(!0)),this.overlayText=e.getElementById("overlay-label")}connectedCallback(){this.setupDragEvents()}attributeChangedCallback(e,t,r){e===ie.OVERLAY_TEXT&&t!==r?this.overlayText.innerHTML=r!=null?r:"":e==="active"&&this.getAttribute("overlay")&&r!=null&&(this._currentDragTarget=this)}static get observedAttributes(){return[ie.OVERLAY_TEXT,ie.MUX_UPLOADER,"active"]}get muxUploader(){let e=this.getAttribute(ie.MUX_UPLOADER);return e?document.getElementById(e):null}setupDragEvents(){this.addEventListener("dragenter",e=>{this._currentDragTarget=e.target,e.preventDefault(),e.stopPropagation(),this.setAttribute("active","")}),this.addEventListener("dragleave",e=>{this._currentDragTarget===e.target&&(this._currentDragTarget=void 0,this.removeAttribute("active"))}),this.addEventListener("dragover",e=>{e.preventDefault(),e.stopPropagation()}),this.addEventListener("drop",e=>{var t;e.preventDefault(),e.stopPropagation();let{dataTransfer:r}=e,{files:o}=r,a=o[0];((t=this.muxUploader)!=null?t:this).dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:a})),this.removeAttribute("active")})}};globalThis.customElements.get("mux-uploader-drop")||(globalThis.customElements.define("mux-uploader-drop",ze),globalThis.MuxUploaderDropElement=ze);var ut=` | ||
`;var at={MUX_UPLOADER:"mux-uploader",OVERLAY_TEXT:"overlay-text"},zt=class extends HTMLElement{constructor(){super();let t=this.attachShadow({mode:"open"});t.appendChild(Ht.content.cloneNode(!0)),this.overlayText=t.getElementById("overlay-label")}connectedCallback(){this.setupDragEvents()}attributeChangedCallback(t,e,r){t===at.OVERLAY_TEXT&&e!==r?this.overlayText.innerHTML=r!=null?r:"":t==="active"&&this.getAttribute("overlay")&&r!=null&&(this._currentDragTarget=this)}static get observedAttributes(){return[at.OVERLAY_TEXT,at.MUX_UPLOADER,"active"]}get muxUploader(){let t=this.getAttribute(at.MUX_UPLOADER);return t?document.getElementById(t):null}setupDragEvents(){this.addEventListener("dragenter",t=>{this._currentDragTarget=t.target,t.preventDefault(),t.stopPropagation(),this.setAttribute("active","")}),this.addEventListener("dragleave",t=>{this._currentDragTarget===t.target&&(this._currentDragTarget=void 0,this.removeAttribute("active"))}),this.addEventListener("dragover",t=>{t.preventDefault(),t.stopPropagation()}),this.addEventListener("drop",t=>{var e;t.preventDefault(),t.stopPropagation();let{dataTransfer:r}=t,{files:o}=r,a=o[0];((e=this.muxUploader)!=null?e:this).dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:a})),this.removeAttribute("active")})}};globalThis.customElements.get("mux-uploader-drop")||(globalThis.customElements.define("mux-uploader-drop",zt),globalThis.MuxUploaderDropElement=zt);var ue=` | ||
:host { | ||
@@ -62,5 +62,5 @@ font-family: var(--uploader-font-family, Arial); | ||
background: var(--button-background-color, #fff); | ||
border: 1px solid #000000; | ||
border: var(--button-border, 1px solid #000000); | ||
color: #000000; | ||
padding: 16px 24px; | ||
padding: var(--button-padding, 16px 24px); | ||
border-radius: var(--button-border-radius, 4px); | ||
@@ -198,5 +198,5 @@ -webkit-transition: all 0.2s ease; | ||
} | ||
`,Ve=document.createElement("template");Ve.innerHTML=` | ||
`,Vt=document.createElement("template");Vt.innerHTML=` | ||
<style> | ||
${ut} | ||
${ue} | ||
</style> | ||
@@ -231,3 +231,3 @@ | ||
</div> | ||
`;var ae={BAR:"bar",RADIAL:"radial"},lt=e=>`${Math.floor(e)}%`,ct=e=>{var t;return Number((t=e.svgCircle)==null?void 0:t.getAttribute("r"))},te=e=>ct(e)*2*Math.PI,pt="Media upload progress bar",qe=["Enter"," "],We=class extends HTMLElement{constructor(){super();var e,t,r,o,a,p,T,k,v,f,n;this.handleFilePickerButtonClick=this.handleFilePickerButtonClick.bind(this);let l=this.attachShadow({mode:"open"}),b=Ve.content.cloneNode(!0);l.appendChild(b),this.filePickerButton=(e=this.shadowRoot)==null?void 0:e.querySelector("slot[name=upload-button] > *"),this.svgCircle=(t=this.shadowRoot)==null?void 0:t.querySelector("circle"),this.progressBar=(r=this.shadowRoot)==null?void 0:r.getElementById("progress-bar"),this.uploadPercentage=(o=this.shadowRoot)==null?void 0:o.getElementById("upload-status"),this.statusMessage=(a=this.shadowRoot)==null?void 0:a.getElementById("status-message"),this.retryButton=(p=this.shadowRoot)==null?void 0:p.getElementById("retry-button"),this.srOnlyText=(T=this.shadowRoot)==null?void 0:T.getElementById("sr-only"),(k=this.progressBar)==null||k.setAttribute("aria-description",pt),(v=this.hiddenFileInput)==null||v.addEventListener("change",E=>{var x,w;let y=(w=(x=this.hiddenFileInput)==null?void 0:x.files)==null?void 0:w[0];y&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:y}))}),(n=(f=this.shadowRoot)==null?void 0:f.querySelector("slot[name=upload-button]"))==null||n.addEventListener("slotchange",()=>{var E,x;this.filePickerButton=(x=(E=this.shadowRoot)==null?void 0:E.querySelector("slot[name=upload-button]"))==null?void 0:x.assignedNodes()[0]})}connectedCallback(){this.setDefaultType(),this.setupRetry(),this.addEventListener("file-ready",this.handleUpload)}disconnectedCallback(){this.removeEventListener("file-ready",this.handleUpload,!1)}get filePickerButton(){return this._filePickerButton}set filePickerButton(e){e!==this._filePickerButton&&(this._filePickerButton&&this._filePickerButton.removeEventListener("click",this.handleFilePickerButtonClick),this._filePickerButton=e,this._filePickerButton&&this._filePickerButton.addEventListener("click",this.handleFilePickerButtonClick))}get hiddenFileInput(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("#hidden-file-input")}handleFilePickerButtonClick(e){this.hiddenFileInput.click()}get endpoint(){var e;return(e=this.getAttribute("endpoint"))!=null?e:this._endpoint}set endpoint(e){e!==this.endpoint&&(typeof e=="string"?this.setAttribute("endpoint",e):e==null&&this.removeAttribute("endpoint"),this._endpoint=e)}get formatProgress(){var e;return(e=this._formatProgress)!=null?e:lt}set formatProgress(e){this._formatProgress=e}setDefaultType(){let e=this.getAttribute("type");e||this.setAttribute("type",ae.BAR),e===ae.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${te(this)} ${te(this)}`,this.svgCircle.style.strokeDashoffset=`${te(this)}`)}setupRetry(){var e;(e=this.retryButton)==null||e.addEventListener("click",()=>{this.resetState()});let t=r=>{let{key:o}=r;if(!qe.includes(o)){this.removeEventListener("keyup",t);return}this.resetState()};this.addEventListener("keydown",r=>{let{metaKey:o,altKey:a,key:p}=r;if(o||a||!qe.includes(p)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)})}resetState(){this.removeAttribute("upload-error"),this.removeAttribute("upload-in-progress"),this.hiddenFileInput.value="",this.statusMessage&&(this.statusMessage.innerHTML=""),this.uploadPercentage&&(this.uploadPercentage.innerHTML="")}setProgress(e){var t;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=this.formatProgress(e)),(t=this.progressBar)==null||t.setAttribute("aria-valuenow",`${Math.floor(e)}`),this.getAttribute("type")){case ae.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case ae.RADIAL:if(this.svgCircle){let r=te(this)-e/100*te(this);this.svgCircle.style.strokeDashoffset=r.toString()}}}handleUpload(e){var t;let r=this.endpoint;if(r)this.removeAttribute("upload-error"),this.statusMessage&&(this.statusMessage.innerHTML="");else{let a="No url or endpoint specified -- cannot handleUpload";this.statusMessage&&(this.statusMessage.innerHTML=a),this.setAttribute("upload-error",""),console.error(a);return}this.setAttribute("upload-in-progress",""),(t=this.progressBar)==null||t.focus();let o=(0,Xe.createUpload)({endpoint:r,file:e.detail});o.on("error",a=>{let p="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=p),console.error(a.detail.message),this.dispatchEvent(new CustomEvent("error",a))}),o.on("progress",a=>{this.setProgress(a.detail),this.dispatchEvent(new CustomEvent("progress",a))}),o.on("success",a=>{let p="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=p),this.srOnlyText&&(this.srOnlyText.innerHTML=p),console.info(p),this.dispatchEvent(new CustomEvent("success",a))})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",We),globalThis.MuxUploaderElement=We);var ne=z(require("react"));var Ge={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay"},dt=e=>e==null,ht=(e,t)=>dt(t)?!1:e in t,ft=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),gt=(e,t)=>{if(!(typeof t=="boolean"&&!t)){if(ht(e,Ge))return Ge[e];if(typeof t!=null)return/[A-Z]/.test(e)?ft(e):e}};var mt=(e,t)=>typeof e=="boolean"?"":e,ue=(e={})=>Object.entries(e).reduce((t,[r,o])=>{let a=gt(r,o);if(!a)return t;let p=mt(o,r);return t[a]=p,t},{});var $e=z(require("react"));var le=z(require("react")),ce=(...e)=>{let t=(0,le.useRef)(null);return(0,le.useEffect)(()=>{e.forEach(r=>{!r||(typeof r=="function"?r(t.current):r.current=t.current)})},[e]),t};var bt=ne.default.forwardRef(({children:e,...t},r)=>ne.default.createElement("mux-uploader-drop",ue({...t,ref:r}),e)),yt=ne.default.forwardRef((e,t)=>{let r=(0,$e.useRef)(null),o=ce(r,t);return ne.default.createElement(bt,{ref:o,...e})}),Ye=yt;var Ze=z(require("react"));var Ke=z(require("react")),vt=Object.prototype.hasOwnProperty,Et=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.some((a,p)=>t[p]===a);let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(!vt.call(t,r[a])||!Object.is(e[r[a]],t[r[a]]))return!1;return!0},Tt=(e,t,r)=>!Et(t,e[r]),wt=(e,t,r)=>{e[r]=t},kt=(e,t,r,o=wt,a=Tt)=>(0,Ke.useEffect)(()=>{let p=r==null?void 0:r.current;!p||!a(p,t,e)||o(p,t,e)},[r==null?void 0:r.current,t]),fe=kt;var Rt=X.default.forwardRef(({children:e,...t},r)=>X.default.createElement("mux-uploader",ue({...t,ref:r}),e)),ge=(e,t,r)=>(0,X.useEffect)(()=>{let o=t==null?void 0:t.current;if(!(!o||!r))return o.addEventListener(e,r),()=>{o.removeEventListener(e,r)}},[t==null?void 0:t.current,r]),xt=(e,t)=>{let{onError:r,onProgress:o,onSuccess:a,formatProgress:p,endpoint:T,...k}=t;return fe("endpoint",T,e),fe("formatProgress",p,e),ge("error",e,r),ge("progress",e,o),ge("success",e,a),[k]},Pt=X.default.forwardRef((e,t)=>{let r=(0,Ze.useRef)(null),o=ce(r,t),[a]=xt(r,e);return X.default.createElement(Rt,{ref:o,...a})});var Ct=Pt; | ||
`;var ut={BAR:"bar",RADIAL:"radial"},le=t=>`${Math.floor(t)}%`,ce=t=>{var e;return Number((e=t.svgCircle)==null?void 0:e.getAttribute("r"))},nt=t=>ce(t)*2*Math.PI,pe="Media upload progress bar",qt=["Enter"," "],Wt=class extends HTMLElement{constructor(){super();var t,e,r,o,a,p,T,k,v,d,n;this.handleFilePickerButtonClick=this.handleFilePickerButtonClick.bind(this);let l=this.attachShadow({mode:"open"}),b=Vt.content.cloneNode(!0);l.appendChild(b),this.filePickerButton=(t=this.shadowRoot)==null?void 0:t.querySelector("slot[name=upload-button] > *"),this.svgCircle=(e=this.shadowRoot)==null?void 0:e.querySelector("circle"),this.progressBar=(r=this.shadowRoot)==null?void 0:r.getElementById("progress-bar"),this.uploadPercentage=(o=this.shadowRoot)==null?void 0:o.getElementById("upload-status"),this.statusMessage=(a=this.shadowRoot)==null?void 0:a.getElementById("status-message"),this.retryButton=(p=this.shadowRoot)==null?void 0:p.getElementById("retry-button"),this.srOnlyText=(T=this.shadowRoot)==null?void 0:T.getElementById("sr-only"),(k=this.progressBar)==null||k.setAttribute("aria-description",pe),(v=this.hiddenFileInput)==null||v.addEventListener("change",E=>{var P,w;let y=(w=(P=this.hiddenFileInput)==null?void 0:P.files)==null?void 0:w[0];y&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:y}))}),(n=(d=this.shadowRoot)==null?void 0:d.querySelector("slot[name=upload-button]"))==null||n.addEventListener("slotchange",()=>{var E,P;this.filePickerButton=(P=(E=this.shadowRoot)==null?void 0:E.querySelector("slot[name=upload-button]"))==null?void 0:P.assignedNodes()[0]})}connectedCallback(){this.setDefaultType(),this.setupRetry(),this.addEventListener("file-ready",this.handleUpload)}disconnectedCallback(){this.removeEventListener("file-ready",this.handleUpload,!1)}get filePickerButton(){return this._filePickerButton}set filePickerButton(t){t!==this._filePickerButton&&(this._filePickerButton&&this._filePickerButton.removeEventListener("click",this.handleFilePickerButtonClick),this._filePickerButton=t,this._filePickerButton&&this._filePickerButton.addEventListener("click",this.handleFilePickerButtonClick))}get hiddenFileInput(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("#hidden-file-input")}handleFilePickerButtonClick(t){this.hiddenFileInput.click()}get endpoint(){var t;return(t=this.getAttribute("endpoint"))!=null?t:this._endpoint}set endpoint(t){t!==this.endpoint&&(typeof t=="string"?this.setAttribute("endpoint",t):t==null&&this.removeAttribute("endpoint"),this._endpoint=t)}get formatProgress(){var t;return(t=this._formatProgress)!=null?t:le}set formatProgress(t){this._formatProgress=t}setDefaultType(){let t=this.getAttribute("type");t||this.setAttribute("type",ut.BAR),t===ut.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${nt(this)} ${nt(this)}`,this.svgCircle.style.strokeDashoffset=`${nt(this)}`)}setupRetry(){var t;(t=this.retryButton)==null||t.addEventListener("click",()=>{this.resetState()});let e=r=>{let{key:o}=r;if(!qt.includes(o)){this.removeEventListener("keyup",e);return}this.resetState()};this.addEventListener("keydown",r=>{let{metaKey:o,altKey:a,key:p}=r;if(o||a||!qt.includes(p)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)})}resetState(){this.removeAttribute("upload-error"),this.removeAttribute("upload-in-progress"),this.hiddenFileInput.value="",this.statusMessage&&(this.statusMessage.innerHTML=""),this.uploadPercentage&&(this.uploadPercentage.innerHTML="")}setProgress(t){var e;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=this.formatProgress(t)),(e=this.progressBar)==null||e.setAttribute("aria-valuenow",`${Math.floor(t)}`),this.getAttribute("type")){case ut.BAR:this.progressBar&&(this.progressBar.style.width=`${t}%`);case ut.RADIAL:if(this.svgCircle){let r=nt(this)-t/100*nt(this);this.svgCircle.style.strokeDashoffset=r.toString()}}}handleUpload(t){var e;let r=this.endpoint;if(r)this.removeAttribute("upload-error"),this.statusMessage&&(this.statusMessage.innerHTML="");else{let a="No url or endpoint specified -- cannot handleUpload";this.statusMessage&&(this.statusMessage.innerHTML=a),this.setAttribute("upload-error",""),console.error(a);return}this.setAttribute("upload-in-progress",""),(e=this.progressBar)==null||e.focus();let o=(0,Xt.createUpload)({endpoint:r,file:t.detail});this.dispatchEvent(new CustomEvent("uploadstart",{detail:o})),o.on("attempt",a=>{this.dispatchEvent(new CustomEvent("chunkattempt",a))}),o.on("chunkSuccess",a=>{this.dispatchEvent(new CustomEvent("chunksuccess",a))}),o.on("error",a=>{let p="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=p),console.error(a.detail.message),this.dispatchEvent(new CustomEvent("error",a))}),o.on("progress",a=>{this.setProgress(a.detail),this.dispatchEvent(new CustomEvent("progress",a))}),o.on("success",a=>{let p="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=p),this.srOnlyText&&(this.srOnlyText.innerHTML=p),console.info(p),this.dispatchEvent(new CustomEvent("success",a))})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",Wt),globalThis.MuxUploaderElement=Wt);var rt=z(require("react"));var Gt={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay"},de=t=>t==null,he=(t,e)=>de(e)?!1:t in e,fe=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),ge=(t,e)=>{if(!(typeof e=="boolean"&&!e)){if(he(t,Gt))return Gt[t];if(typeof e!=null)return/[A-Z]/.test(t)?fe(t):t}};var me=(t,e)=>typeof t=="boolean"?"":t,lt=(t={})=>Object.entries(t).reduce((e,[r,o])=>{let a=ge(r,o);if(!a)return e;let p=me(o,r);return e[a]=p,e},{});var $t=z(require("react"));var ct=z(require("react")),pt=(...t)=>{let e=(0,ct.useRef)(null);return(0,ct.useEffect)(()=>{t.forEach(r=>{!r||(typeof r=="function"?r(e.current):r.current=e.current)})},[t]),e};var be=rt.default.forwardRef(({children:t,...e},r)=>rt.default.createElement("mux-uploader-drop",lt({...e,ref:r}),t)),ve=rt.default.forwardRef((t,e)=>{let r=(0,$t.useRef)(null),o=pt(r,e);return rt.default.createElement(be,{ref:o,...t})}),Yt=ve;var Zt=z(require("react"));var Kt=z(require("react")),ye=Object.prototype.hasOwnProperty,Ee=(t,e)=>{if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(Array.isArray(t))return!Array.isArray(e)||t.length!==e.length?!1:t.some((a,p)=>e[p]===a);let r=Object.keys(t),o=Object.keys(e);if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(!ye.call(e,r[a])||!Object.is(t[r[a]],e[r[a]]))return!1;return!0},Te=(t,e,r)=>!Ee(e,t[r]),we=(t,e,r)=>{t[r]=e},ke=(t,e,r,o=we,a=Te)=>(0,Kt.useEffect)(()=>{let p=r==null?void 0:r.current;!p||!a(p,e,t)||o(p,e,t)},[r==null?void 0:r.current,e]),gt=ke;var Re=X.default.forwardRef(({children:t,...e},r)=>X.default.createElement("mux-uploader",lt({...e,ref:r}),t)),K=(t,e,r)=>(0,X.useEffect)(()=>{let o=e==null?void 0:e.current;if(!(!o||!r))return o.addEventListener(t,r),()=>{o.removeEventListener(t,r)}},[e==null?void 0:e.current,r]),Pe=(t,e)=>{let{onUploadStart:r,onChunkAttempt:o,onChunkSuccess:a,onError:p,onProgress:T,onSuccess:k,formatProgress:v,endpoint:d,...n}=e;return gt("endpoint",d,t),gt("formatProgress",v,t),K("uploadstart",t,r),K("chunkattempt",t,o),K("chunksuccess",t,a),K("error",t,p),K("progress",t,T),K("success",t,k),[n]},xe=X.default.forwardRef((t,e)=>{let r=(0,Zt.useRef)(null),o=pt(r,e),[a]=Pe(r,t);return X.default.createElement(Re,{ref:o,...a})});var Ce=xe; | ||
//# sourceMappingURL=index.js.map |
@@ -8,22 +8,32 @@ import React from 'react'; | ||
export declare type MuxUploaderProps = { | ||
id?: string; | ||
endpoint?: string; | ||
type?: string; | ||
status?: boolean; | ||
style?: CSSProperties; | ||
style?: CSSProperties & { | ||
['--uploader-font-family']?: CSSProperties['fontFamily']; | ||
['--uploader-font-size']?: CSSProperties['fontSize']; | ||
['--uploader-background-color']?: CSSProperties['backgroundColor']; | ||
['--button-background-color']?: CSSProperties['backgroundColor']; | ||
['--button-border-radius']?: CSSProperties['borderRadius']; | ||
['--button-border']?: CSSProperties['border']; | ||
['--button-padding']?: CSSProperties['padding']; | ||
['--button-hover-text']?: CSSProperties['color']; | ||
['--button-hover-background']?: CSSProperties['background']; | ||
['--button-active-text']?: CSSProperties['color']; | ||
['--button-active-background']?: CSSProperties['background']; | ||
['--progress-bar-fill-color']?: CSSProperties['background']; | ||
['--progress-radial-fill-color']?: CSSProperties['stroke']; | ||
}; | ||
children?: React.ReactNode; | ||
formatProgress?: (percent: number) => string; | ||
onUploadStart?: EventListener; | ||
onChunkAttempt?: EventListener; | ||
onChunkSuccess?: EventListener; | ||
onError?: EventListener; | ||
onProgress?: EventListener; | ||
onSuccess?: EventListener; | ||
} & Partial<MuxUploaderRefAttributes>; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<{ | ||
type?: string | undefined; | ||
status?: boolean | undefined; | ||
style?: React.CSSProperties | undefined; | ||
children?: React.ReactNode; | ||
formatProgress?: ((percent: number) => string) | undefined; | ||
onError?: EventListener | undefined; | ||
onProgress?: EventListener | undefined; | ||
onSuccess?: EventListener | undefined; | ||
} & Partial<MuxUploaderElement> & React.RefAttributes<MuxUploaderElement>>; | ||
}; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<MuxUploaderProps & React.RefAttributes<MuxUploaderElement>>; | ||
export { MuxUploaderDrop }; | ||
export default MuxUploader; |
@@ -8,22 +8,32 @@ import React from 'react'; | ||
export declare type MuxUploaderProps = { | ||
id?: string; | ||
endpoint?: string; | ||
type?: string; | ||
status?: boolean; | ||
style?: CSSProperties; | ||
style?: CSSProperties & { | ||
['--uploader-font-family']?: CSSProperties['fontFamily']; | ||
['--uploader-font-size']?: CSSProperties['fontSize']; | ||
['--uploader-background-color']?: CSSProperties['backgroundColor']; | ||
['--button-background-color']?: CSSProperties['backgroundColor']; | ||
['--button-border-radius']?: CSSProperties['borderRadius']; | ||
['--button-border']?: CSSProperties['border']; | ||
['--button-padding']?: CSSProperties['padding']; | ||
['--button-hover-text']?: CSSProperties['color']; | ||
['--button-hover-background']?: CSSProperties['background']; | ||
['--button-active-text']?: CSSProperties['color']; | ||
['--button-active-background']?: CSSProperties['background']; | ||
['--progress-bar-fill-color']?: CSSProperties['background']; | ||
['--progress-radial-fill-color']?: CSSProperties['stroke']; | ||
}; | ||
children?: React.ReactNode; | ||
formatProgress?: (percent: number) => string; | ||
onUploadStart?: EventListener; | ||
onChunkAttempt?: EventListener; | ||
onChunkSuccess?: EventListener; | ||
onError?: EventListener; | ||
onProgress?: EventListener; | ||
onSuccess?: EventListener; | ||
} & Partial<MuxUploaderRefAttributes>; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<{ | ||
type?: string | undefined; | ||
status?: boolean | undefined; | ||
style?: React.CSSProperties | undefined; | ||
children?: React.ReactNode; | ||
formatProgress?: ((percent: number) => string) | undefined; | ||
onError?: EventListener | undefined; | ||
onProgress?: EventListener | undefined; | ||
onSuccess?: EventListener | undefined; | ||
} & Partial<MuxUploaderElement> & React.RefAttributes<MuxUploaderElement>>; | ||
}; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<MuxUploaderProps & React.RefAttributes<MuxUploaderElement>>; | ||
export { MuxUploaderDrop }; | ||
export default MuxUploader; |
{ | ||
"name": "@mux/mux-uploader-react", | ||
"version": "0.1.0-canary.10-087f23e", | ||
"version": "0.1.0-canary.10-17e7b68", | ||
"type": "commonjs", | ||
@@ -49,3 +49,3 @@ "description": "An uploader element for React that handles Mux Direct Uploads and a visual progress bar for you", | ||
"dependencies": { | ||
"@mux/mux-uploader": "0.1.0-canary.10-087f23e", | ||
"@mux/mux-uploader": "0.1.0-canary.10-17e7b68", | ||
"prop-types": "^15.7.2" | ||
@@ -52,0 +52,0 @@ }, |
@@ -70,9 +70,9 @@ <p align="center"> | ||
| Property | Type | Description | Default | | ||
| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | ||
| `url` | `string` | The authenticated URL that your file will be uploaded to. Check out the [direct uploads docs](https://docs.mux.com/guides/video/upload-files-directly#1-create-an-authenticated-mux-url) for how to create one. Required. | `undefined` | | ||
| `id` | `string` | An ID that allows `<MuxUploaderDrop>` to locate `<MuxUploader>`. Required if you use `<MuxUploaderDrop>`. | N/A | | ||
| `type` | `"bar"` | Specifies the visual type of progress bar. A radial type is in-progress. | "bar" | | ||
| `status` | `boolean` | Toggles text status visibility of progress bar. The text that is displayed is a percentage by default. If you prefer just the progress bar with no text upload status, don't include this attribute. | false | | ||
| `formatProgress` | `function` | A function that accepts numeric percent and is expected to return a string. Allows for customizing how the progress should be rendered. | A function the yields a percent progress string | | ||
| Property | Type | Description | Default | | ||
| ---------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | ||
| `endpoint` | `string \| Promise` | Either a) the authenticated URL that your file will be uploaded to or b) an async function that yields a promise that resolves to that url. Check out the [direct uploads docs](https://docs.mux.com/guides/video/upload-files-directly#1-create-an-authenticated-mux-url) for how to create one. Required. | `undefined` | | ||
| `id` | `string` | An ID that allows `<MuxUploaderDrop>` to locate `<MuxUploader>`. Required if you use `<MuxUploaderDrop>`. | N/A | | ||
| `type` | `"bar"` | Specifies the visual type of progress bar. A radial type is in-progress. | "bar" | | ||
| `status` | `boolean` | Toggles text status visibility of progress bar. The text that is displayed is a percentage by default. If you prefer just the progress bar with no text upload status, don't include this attribute. | false | | ||
| `formatProgress` | `function` | A function that accepts numeric percent and is expected to return a string. Allows for customizing how the progress should be rendered - whether you want to display only the number, a sentence with the number etc. i.e. `formatProgress={(percent: number) => `${percent} percent uploaded`}` | A function that yields only the percent as a string i.e. `"60%"` | | ||
@@ -84,3 +84,3 @@ #### `<MuxUploaderDrop>` | ||
| `overlay` | `boolean` | Toggles fullscreen overlay on dragover. | false | | ||
| `overlayText` | `boolean` | Optional text to display on dragover when `overlay` is on. | `''` | | ||
| `overlayText` | `string` | Optional text to display on dragover when `overlay` is on. | `''` | | ||
| `muxUploader` | `string ` | Must match the `id` on `<MuxUploader>`. Required. | N/A | | ||
@@ -92,8 +92,11 @@ | ||
`<MuxUploader>` has a handful of events to monitor uploading state. | ||
`<MuxUploader>` has a handful of a number of callbacks associated with events to handle uploading state. | ||
| Prop | Description | | ||
| ------------ | -------------------------------------------------------------------------- | | ||
| `onError` | Invoked when an error occurs in the chunked upload process. | | ||
| `onProgress` | Invoked whenever a chunk of the file has successfully completed uploading. | | ||
| `onSuccess` | Invoked when the entire file has successfully completed uploading. | | ||
| Prop | Description | | ||
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `onUploadStart` | Fired when the upload begins. | | ||
| `onChunkAttempt` | Invoked immediately before a chunk upload is attempted. | | ||
| `onChunkSuccess` | Invoked when an indvidual chunk is successfully uploaded. Sample response: `{ detail: { chunk: Integer, attempts: Integer, response: XhrResponse } }` | | ||
| `onError` | Invoked when an error occurs in the chunked upload process. | | ||
| `onProgress` | Invoked continuously with incremental upload progress. This returns the current percentage of the file that's been uploaded. Sample response: `{ detail: [0..100] }` | | ||
| `onSuccess` | Invoked when the entire file has successfully completed uploading. | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
210006
743
100
+ Added@mux/mux-uploader@0.1.0-canary.10-17e7b68(transitive)
- Removed@mux/mux-uploader@0.1.0-canary.10-087f23e(transitive)