@mux/mux-uploader-react
Advanced tools
Comparing version 0.1.0-canary.10-8cfa013 to 0.1.0-canary.10-8e82f44
@@ -6,2 +6,22 @@ # Change Log | ||
# [0.1.0-beta.6](https://github.com/muxinc/elements/compare/@mux/mux-uploader-react@0.1.0-beta.5...@mux/mux-uploader-react@0.1.0-beta.6) (2022-08-03) | ||
### Features | ||
- **mux-uploader-react:** Handle endpoint and ref attrs. ([6306286](https://github.com/muxinc/elements/commit/6306286ec5f07ac3328976bdd44ff6fdd2e10dc9)) | ||
# [0.1.0-beta.5](https://github.com/muxinc/elements/compare/@mux/mux-uploader-react@0.1.0-beta.4...@mux/mux-uploader-react@0.1.0-beta.5) (2022-08-02) | ||
### Bug Fixes | ||
- **mux-uploader-react:** Clean up typescript defs. ([8cfa013](https://github.com/muxinc/elements/commit/8cfa013c591c94654c7ffc314cef159bc3c0fff0)) | ||
- **mux-uploader-react:** Update event and event handler typedefs for greater accuracy of types. ([5c601b8](https://github.com/muxinc/elements/commit/5c601b8b649a9ff20e046c4ac4aad657ffce4edf)) | ||
### Features | ||
- **mux-uploader:** Add CSS variables for button border and padding. ([359cd89](https://github.com/muxinc/elements/commit/359cd89472781fc41e33e95574c0d9c845b1d081)) | ||
- **mux-uploader:** Add custom event for when upload starts. ([9fd1efc](https://github.com/muxinc/elements/commit/9fd1efc943bcb60efdb51b455d5b9642af86b920)) | ||
- **mux-uploader:** Support css vars for mux-uploader react component. ([8745784](https://github.com/muxinc/elements/commit/87457844f483d695d8f3bfd1da2fddaaa64a96fe)) | ||
- **mux-uploader:** Support Upchunk's attempt and chunkSuccess events. ([739a88e](https://github.com/muxinc/elements/commit/739a88e5eda697b8344ef14e3a20b1bef19e1a41)) | ||
# [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) | ||
@@ -8,0 +28,0 @@ |
@@ -1,4 +0,4 @@ | ||
var et=Object.create;var ie=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var Le=e=>ie(e,"__esModule",{value:!0});var st=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),it=(e,t)=>{Le(e);for(var r in t)ie(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"&&ie(e,o,{get:()=>t[o],enumerable:!(r=tt(t,o))||r.enumerable});return e},z=e=>at(Le(ie(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,fe)=>{(function(e,t){typeof ee=="object"&&typeof fe=="object"?fe.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(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)};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 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}();t.UpChunk=v,t.createUpload=function(d){return new v(d)}},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 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 O{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?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,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 x(s){s.inPassiveListenerFlag?y.warn():s.cancelable?s.canceledFlag=!0:w.warn()}Object.defineProperty(O,"NONE",{enumerable:!0}),Object.defineProperty(O,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(O,"AT_TARGET",{enumerable:!0}),Object.defineProperty(O,"BUBBLING_PHASE",{enumerable:!0});let B=Object.getOwnPropertyNames(O.prototype);for(let s=0;s<B.length;++s)B[s]!=="constructor"&&Object.defineProperty(O.prototype,B[s],{enumerable:!0});let N;d!==void 0&&d.Event!==void 0&&Object.setPrototypeOf(O.prototype,d.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],f=me[c];Object.defineProperty(s,c,{get:()=>f,configurable:!0,enumerable:!0})}}class Z extends O{static wrap(i){return new(function u(c){let f=Object.getPrototypeOf(c);if(f==null)return Z;let m=oe.get(f);return m==null&&(m=function(C,A){class M extends C{}let R=Object.keys(A);for(let L=0;L<R.length;++L)Object.defineProperty(M.prototype,R[L],ye(A,R[L]));return M}(u(f),f),oe.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(),ve.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,ye(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 ve=new WeakMap;function F(s){let i=ve.get(s);return p(i!=null,"'this' is expected an Event object, but got",s),i}let oe=new WeakMap;function ye(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 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(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 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,f,m){let C;m&&(C=de.bind(null,s,i,u),m.addEventListener("abort",C));let A=function(M,R,L,U,se,D){return{callback:M,flags:(R?1:0)|(L?2:0)|(U?4:0),signal:se,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 de(s,i,u){let c=ke(s,i,u);return c!==-1&&Pe(s,c)}function Pe(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 xe(s,i){var u;return(u=s[i])!==null&&u!==void 0?u:s[i]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}oe.set(Object.prototype,Z),d!==void 0&&d.Event!==void 0&&oe.set(d.Event.prototype,Z);class ${constructor(){Ce.set(this,Object.create(null))}addEventListener(i,u,c){let f=Y(this),{callback:m,capture:C,once:A,passive:M,signal:R,type:L}=function(D,H,I){var J;return Se(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=xe(f,L),se=ke(U,m,C);se===-1?Re(U,m,C,M,A,R):function(D,H,I,J){S.warn(Ee(D)?"capture":"bubble",D.callback),Te(D)!==H&&h.warn("passive"),we(D)!==I&&h.warn("once"),D.signal!==J&&h.warn("signal")}(U.listeners[se],M,A,R)}removeEventListener(i,u,c){let f=Y(this),{callback:m,capture:C,type:A}=function(R,L,U){return Se(L),typeof U=="object"&&U!==null?{type:String(R),callback:L!=null?L:void 0,capture:Boolean(U.capture)}:{type:String(R),callback:L!=null?L:void 0,capture:Boolean(U)}}(i,u,c),M=f[A];m!=null&&M&&de(M,m,C)}dispatchEvent(i){let u=Y(this)[String(i.type)];if(u==null)return!0;let c=i instanceof O?i:Z.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 Fe extends Error{constructor(A){super(A),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(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(!Je(R)&&(we(R)&&Pe(u,M,!C)&&(M-=1),f.inPassiveListenerFlag=Te(R),Qe(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 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 Se(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 he=Object.getOwnPropertyNames($.prototype);for(let s=0;s<he.length;++s)he[s]!=="constructor"&&Object.defineProperty($.prototype,he[s],{enumerable:!0});function Ae(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 Me(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=xe(Y(c,"target"),String(f));C.attrCallback=m,C.attrListener==null&&(C.attrListener=Re(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&&(de(m,m.attrListener.callback,!1),m.attrCallback=m.attrListener=void 0)}(s,i)}function Oe(s,i,u){Object.defineProperty(s,"on"+i,{get(){return Ae(this,i)},set(c){Me(this,i,c)},configurable:!0,enumerable:!0})}d!==void 0&&d.EventTarget!==void 0&&Object.setPrototypeOf($.prototype,d.EventTarget.prototype),t.Event=O,t.EventTarget=$,t.default=$,t.defineCustomEventTarget=function(...s){class i extends ${}for(let u=0;u<s.length;++u)Oe(i.prototype,s[u]);return i},t.defineEventAttribute=Oe,t.getEventAttributeValue=Ae,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=Me,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,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(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 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),K)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:O,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,O=h.method=n.method||"GET",q=n.body||n.data,_=h.headers=n.headers||{},W=!!n.sync,K=!1,G={body:void 0,headers:{},statusCode:0,method:O,url:V,rawRequest:h};if("json"in n&&n.json!==!1&&(K=!0,_.accept||_.Accept||(_.Accept="application/json"),O!=="GET"&&O!=="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(O,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}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(),d(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],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(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 et=Object.create;var ie=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var Oe=e=>ie(e,"__esModule",{value:!0});var st=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),it=(e,t)=>{Oe(e);for(var r in t)ie(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"&&ie(e,o,{get:()=>t[o],enumerable:!(r=tt(t,o))||r.enumerable});return e},z=e=>at(Oe(ie(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 Ue=(e,t,r)=>(_e(e,t,"read from private field"),r?r.call(e):t.get(e)),Be=(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((te,fe)=>{(function(e,t){typeof te=="object"&&typeof fe=="object"?fe.exports=t():typeof define=="function"&&define.amd?define([],t):typeof te=="object"?te.UpChunk=t():e.UpChunk=t()})(te,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(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)};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 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(x){var w,y=100/l.totalChunks,M=y*l.file.size,h=y*l.chunkCount,j=x.loaded/((w=x.total)!==null&&w!==void 0?w:M)*y;l.dispatch("progress",Math.min(h+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)})})},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}();t.UpChunk=v,t.createUpload=function(d){return new v(d)}},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 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."),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."),M=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 G}static get BUBBLING_PHASE(){return Z}constructor(i,u){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let c=u!=null?u:{};W.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 G}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?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 f=g(this);f.dispatchFlag?b.warn():W.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,G=2,Z=3,W=new WeakMap;function g(s,i="this"){let u=W.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 U=Object.getOwnPropertyNames(L.prototype);for(let s=0;s<U.length;++s)U[s]!=="constructor"&&Object.defineProperty(L.prototype,U[s],{enumerable:!0});let N;d!==void 0&&d.Event!==void 0&&Object.setPrototypeOf(L.prototype,d.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],f=me[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=oe.get(f);return m==null&&(m=function(C,S){class A extends C{}let R=Object.keys(S);for(let O=0;O<R.length;++O)Object.defineProperty(A.prototype,R[O],ye(S,R[O]));return A}(u(f),f),oe.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(),ve.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,ye(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 ve=new WeakMap;function F(s){let i=ve.get(s);return p(i!=null,"'this' is expected an Event object, but got",s),i}let oe=new WeakMap;function ye(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 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(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 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,f,m){let C;m&&(C=de.bind(null,s,i,u),m.addEventListener("abort",C));let S=function(A,R,O,B,se,D){return{callback:A,flags:(R?1:0)|(O?2:0)|(B?4:0),signal:se,signalListener:D}}(i,u,c,f,m,C);return s.cow?(s.cow=!1,s.listeners=[...s.listeners,S]):s.listeners.push(S),S}function de(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(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 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:[]}}oe.set(Object.prototype,J),d!==void 0&&d.Event!==void 0&&oe.set(d.Event.prototype,J);class K{constructor(){Ce.set(this,Object.create(null))}addEventListener(i,u,c){let f=$(this),{callback:m,capture:C,once:S,passive:A,signal:R,type:O}=function(D,H,I){var Q;return Me(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 B=Pe(f,O),se=ke(B,m,C);se===-1?Re(B,m,C,A,S,R):function(D,H,I,Q){M.warn(Ee(D)?"capture":"bubble",D.callback),Te(D)!==H&&h.warn("passive"),we(D)!==I&&h.warn("once"),D.signal!==Q&&h.warn("signal")}(B.listeners[se],A,S,R)}removeEventListener(i,u,c){let f=$(this),{callback:m,capture:C,type:S}=function(R,O,B){return Me(O),typeof B=="object"&&B!==null?{type:String(R),callback:O!=null?O:void 0,capture:Boolean(B.capture)}:{type:String(R),callback:O!=null?O:void 0,capture:Boolean(B)}}(i,u,c),A=f[S];m!=null&&A&&de(A,m,C)}dispatchEvent(i){let u=$(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 Fe extends Error{constructor(S){super(S),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(f.dispatchFlag=!0,f.target=f.currentTarget=this,!f.stopPropagationFlag){let{cow:C,listeners:S}=u;u.cow=!0;for(let A=0;A<S.length;++A){let R=S[A];if(!Je(R)&&(we(R)&&xe(u,A,!C)&&(A-=1),f.inPassiveListenerFlag=Te(R),Qe(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 Ce=new WeakMap;function $(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 Me(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 he=Object.getOwnPropertyNames(K.prototype);for(let s=0;s<he.length;++s)he[s]!=="constructor"&&Object.defineProperty(K.prototype,he[s],{enumerable:!0});function Se(s,i){var u,c;return(c=(u=$(s,"target")[i])===null||u===void 0?void 0:u.attrCallback)!==null&&c!==void 0?c:null}function Ae(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=Pe($(c,"target"),String(f));C.attrCallback=m,C.attrListener==null&&(C.attrListener=Re(C,function(S){return function(A){let R=S.attrCallback;typeof R=="function"&&R.call(this,A)}}(C),!1,!1,!1,void 0))}(s,i,u):function(c,f){let m=$(c,"target")[String(f)];m&&m.attrListener&&(de(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 Se(this,i)},set(c){Ae(this,i,c)},configurable:!0,enumerable:!0})}d!==void 0&&d.EventTarget!==void 0&&Object.setPrototypeOf(K.prototype,d.EventTarget.prototype),t.Event=L,t.EventTarget=K,t.default=K,t.defineCustomEventTarget=function(...s){class i extends K{}for(let u=0;u<s.length;++u)Le(i.prototype,s[u]);return i},t.defineEventAttribute=Le,t.getEventAttributeValue=Se,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=Ae,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,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 M=d.length;M;){for(v=d,d=[];++l<M;)v&&v[l].run();l=-1,M=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 x(y,M){this.fun=y,this.array=M}function w(){}a.nextTick=function(y){var M=new Array(arguments.length-1);if(arguments.length>1)for(var h=1;h<arguments.length;h++)M[h-1]=arguments[h];d.push(new x(y,M)),d.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 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,P,U){l||(l=!0,n.callback(g,P,U))};function E(){var g=void 0;if(g=h.response?h.response:h.responseText||function(P){try{if(P.responseType==="document")return P.responseXML;var U=P.responseXML&&P.responseXML.documentElement.nodeName==="parsererror";if(P.responseType===""&&!U)return P.responseXML}catch{}return null}(h),Z)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,W)}function w(){if(!M){var g;clearTimeout(j),g=n.useXDR&&h.status===void 0?200:h.status===1223?204:h.status;var P=W,U=null;return g!==0?(P={body:E(),statusCode:g,method:L,headers:{},url:V,rawRequest:h},h.getAllResponseHeaders&&(P.headers=p(h.getAllResponseHeaders()))):U=new Error("Internal XMLHttpRequest Error"),b(U,P,P.body)}}var y,M,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||{},G=!!n.sync,Z=!1,W={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=x,h.onprogress=function(){},h.onabort=function(){M=!0},h.ontimeout=x,h.open(L,V,!G,n.username,n.password),G||(h.withCredentials=!!n.withCredentials),!G&&n.timeout>0&&(j=setTimeout(function(){if(!M){M=!0,h.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",x(g)}},n.timeout)),h.setRequestHeader)for(y in _)_.hasOwnProperty(y)&&h.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&&(h.responseType=n.responseType),"beforeSend"in n&&typeof n.beforeSend=="function"&&n.beforeSend(h),h.send(q||null),h}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(),d(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],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(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:()=>$e,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 ee;if(!globalThis.CustomEvent){class e{constructor(r,o={}){Be(this,ee,void 0);De(this,ee,o==null?void 0:o.detail)}get detail(){Ue(this,ee)}initCustomEvent(r,o,a,p){}}ee=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=` | ||
<style> | ||
@@ -61,5 +61,5 @@ :host { | ||
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); | ||
@@ -229,3 +229,3 @@ -webkit-transition: all 0.2s ease; | ||
</div> | ||
`;var ue={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,d,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 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(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",ue.BAR),e===ue.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 ue.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case ue.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("attempt",({detail:a})=>{this.dispatchEvent(new CustomEvent("attempt",a))}),o.on("chunkSuccess",({detail: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",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,le=(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 ce=z(require("react")),pe=(...e)=>{let t=(0,ce.useRef)(null);return(0,ce.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",le({...t,ref:r}),e)),vt=ne.default.forwardRef((e,t)=>{let r=(0,$e.useRef)(null),o=pe(r,t);return ne.default.createElement(bt,{ref:o,...e})}),Ye=vt;var Ze=z(require("react"));var Ke=z(require("react")),yt=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(!yt.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]),ge=kt;var Rt=X.default.forwardRef(({children:e,...t},r)=>X.default.createElement("mux-uploader",le({...t,ref:r}),e)),re=(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]),Pt=(e,t)=>{let{onAttempt:r,onChunkSuccess:o,onError:a,onProgress:p,onSuccess:T,formatProgress:k,endpoint:v,...d}=t;return ge("endpoint",v,e),ge("formatProgress",k,e),re("attempt",e,r),re("chunkSuccess",e,o),re("error",e,a),re("progress",e,p),re("success",e,T),[d]},xt=X.default.forwardRef((e,t)=>{let r=(0,Ze.useRef)(null),o=pe(r,t),[a]=Pt(r,e);return X.default.createElement(Rt,{ref:o,...a})});var Ct=xt; | ||
`;var ue={BAR:"bar",RADIAL:"radial"},lt=e=>`${Math.floor(e)}%`,ct=e=>{var t;return Number((t=e.svgCircle)==null?void 0:t.getAttribute("r"))},ne=e=>ct(e)*2*Math.PI,pt="Media upload progress bar",qe=["Enter"," "],Ge=class extends HTMLElement{constructor(){super();var e,t,r,o,a,p,T,k,v,d,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=(d=this.shadowRoot)==null?void 0:d.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",ue.BAR),e===ue.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${ne(this)} ${ne(this)}`,this.svgCircle.style.strokeDashoffset=`${ne(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 ue.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case ue.RADIAL:if(this.svgCircle){let r=ne(this)-e/100*ne(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),this.dispatchEvent(new CustomEvent("error",{detail:{message:a}}));return}this.setAttribute("upload-in-progress",""),(t=this.progressBar)==null||t.focus();let o=(0,Xe.createUpload)({endpoint:r,file:e.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",Ge),globalThis.MuxUploaderElement=Ge);var re=z(require("react"));var We={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,We))return We[e];if(typeof t!=null)return/[A-Z]/.test(e)?ft(e):e}};var mt=(e,t)=>typeof e=="boolean"?"":e,le=(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 Ke=z(require("react"));var ce=z(require("react")),pe=(...e)=>{let t=(0,ce.useRef)(null);return(0,ce.useEffect)(()=>{e.forEach(r=>{!r||(typeof r=="function"?r(t.current):r.current=t.current)})},[e]),t};var bt=re.default.forwardRef(({children:e,...t},r)=>re.default.createElement("mux-uploader-drop",le({...t,ref:r}),e)),vt=re.default.forwardRef((e,t)=>{let r=(0,Ke.useRef)(null),o=pe(r,t);return re.default.createElement(bt,{ref:o,...e})}),$e=vt;var Ze=z(require("react"));var Ye=z(require("react")),yt=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(!yt.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,Ye.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]),ge=kt;var Rt=X.default.forwardRef(({children:e,...t},r)=>X.default.createElement("mux-uploader",le({...t,ref:r}),e)),Y=(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{onUploadStart:r,onChunkAttempt:o,onChunkSuccess:a,onError:p,onProgress:T,onSuccess:k,formatProgress:v,endpoint:d,...n}=t;return ge("endpoint",d,e),ge("formatProgress",v,e),Y("uploadstart",e,r),Y("chunkattempt",e,o),Y("chunksuccess",e,a),Y("error",e,p),Y("progress",e,T),Y("success",e,k),[n]},Pt=X.default.forwardRef((e,t)=>{let r=(0,Ze.useRef)(null),o=pe(r,t),[a]=xt(r,e);return X.default.createElement(Rt,{ref:o,...a})});var Ct=Pt; | ||
//# sourceMappingURL=index.js.map |
@@ -6,6 +6,10 @@ import React from 'react'; | ||
import MuxUploaderElement from '@mux/mux-uploader'; | ||
import { MuxUploaderElementEventMap } from '@mux/mux-uploader'; | ||
export declare type MuxUploaderRefAttributes = MuxUploaderElement; | ||
interface GenericEventListener<T extends Event = CustomEvent> { | ||
(evt: T): void; | ||
} | ||
export declare type MuxUploaderProps = { | ||
id?: string; | ||
endpoint?: string; | ||
endpoint?: MuxUploaderElement['endpoint']; | ||
type?: string; | ||
@@ -19,2 +23,4 @@ status?: boolean; | ||
['--button-border-radius']?: CSSProperties['borderRadius']; | ||
['--button-border']?: CSSProperties['border']; | ||
['--button-padding']?: CSSProperties['padding']; | ||
['--button-hover-text']?: CSSProperties['color']; | ||
@@ -29,10 +35,50 @@ ['--button-hover-background']?: CSSProperties['background']; | ||
formatProgress?: (percent: number) => string; | ||
onAttempt?: EventListener; | ||
onChunkSuccess?: EventListener; | ||
onError?: EventListener; | ||
onProgress?: EventListener; | ||
onSuccess?: EventListener; | ||
}; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<MuxUploaderProps & React.RefAttributes<MuxUploaderElement>>; | ||
onUploadStart?: GenericEventListener<MuxUploaderElementEventMap['uploadstart']>; | ||
onChunkAttempt?: GenericEventListener<MuxUploaderElementEventMap['chunkattempt']>; | ||
onChunkSuccess?: GenericEventListener<MuxUploaderElementEventMap['chunksuccess']>; | ||
onError?: GenericEventListener<MuxUploaderElementEventMap['error']>; | ||
onProgress?: GenericEventListener<MuxUploaderElementEventMap['progress']>; | ||
onSuccess?: GenericEventListener<MuxUploaderElementEventMap['success']>; | ||
} & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, Exclude<keyof React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, 'ref'>>; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<{ | ||
id?: string | undefined; | ||
endpoint?: MuxUploaderElement['endpoint']; | ||
type?: string | undefined; | ||
status?: boolean | undefined; | ||
style?: (React.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']; | ||
}) | undefined; | ||
children?: React.ReactNode; | ||
formatProgress?: ((percent: number) => string) | undefined; | ||
onUploadStart?: GenericEventListener<CustomEvent<import("@mux/upchunk").UpChunk>> | undefined; | ||
onChunkAttempt?: GenericEventListener<CustomEvent<{ | ||
chunkNumber: number; | ||
chunkSize: number; | ||
}>> | undefined; | ||
onChunkSuccess?: GenericEventListener<CustomEvent<{ | ||
chunk: number; | ||
attempts: number; | ||
response: any; | ||
}>> | undefined; | ||
onError?: GenericEventListener<CustomEvent<{ | ||
message: string; | ||
chunkNumber?: number | undefined; | ||
attempts?: number | undefined; | ||
}>> | undefined; | ||
onProgress?: GenericEventListener<CustomEvent<number>> | undefined; | ||
onSuccess?: GenericEventListener<CustomEvent<null | undefined>> | undefined; | ||
} & Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, Exclude<keyof React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">> & React.RefAttributes<MuxUploaderElement>>; | ||
export { MuxUploaderDrop }; | ||
export default MuxUploader; |
@@ -6,6 +6,10 @@ import React from 'react'; | ||
import type MuxUploaderElement from '@mux/mux-uploader'; | ||
import type { MuxUploaderElementEventMap } from '@mux/mux-uploader'; | ||
export declare type MuxUploaderRefAttributes = MuxUploaderElement; | ||
interface GenericEventListener<T extends Event = CustomEvent> { | ||
(evt: T): void; | ||
} | ||
export declare type MuxUploaderProps = { | ||
id?: string; | ||
endpoint?: string; | ||
endpoint?: MuxUploaderElement['endpoint']; | ||
type?: string; | ||
@@ -19,2 +23,4 @@ status?: boolean; | ||
['--button-border-radius']?: CSSProperties['borderRadius']; | ||
['--button-border']?: CSSProperties['border']; | ||
['--button-padding']?: CSSProperties['padding']; | ||
['--button-hover-text']?: CSSProperties['color']; | ||
@@ -29,10 +35,50 @@ ['--button-hover-background']?: CSSProperties['background']; | ||
formatProgress?: (percent: number) => string; | ||
onAttempt?: EventListener; | ||
onChunkSuccess?: EventListener; | ||
onError?: EventListener; | ||
onProgress?: EventListener; | ||
onSuccess?: EventListener; | ||
}; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<MuxUploaderProps & React.RefAttributes<MuxUploaderElement>>; | ||
onUploadStart?: GenericEventListener<MuxUploaderElementEventMap['uploadstart']>; | ||
onChunkAttempt?: GenericEventListener<MuxUploaderElementEventMap['chunkattempt']>; | ||
onChunkSuccess?: GenericEventListener<MuxUploaderElementEventMap['chunksuccess']>; | ||
onError?: GenericEventListener<MuxUploaderElementEventMap['error']>; | ||
onProgress?: GenericEventListener<MuxUploaderElementEventMap['progress']>; | ||
onSuccess?: GenericEventListener<MuxUploaderElementEventMap['success']>; | ||
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, 'ref'>; | ||
declare const MuxUploader: React.ForwardRefExoticComponent<{ | ||
id?: string | undefined; | ||
endpoint?: MuxUploaderElement['endpoint']; | ||
type?: string | undefined; | ||
status?: boolean | undefined; | ||
style?: (React.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']; | ||
}) | undefined; | ||
children?: React.ReactNode; | ||
formatProgress?: ((percent: number) => string) | undefined; | ||
onUploadStart?: GenericEventListener<CustomEvent<import("@mux/upchunk").UpChunk>> | undefined; | ||
onChunkAttempt?: GenericEventListener<CustomEvent<{ | ||
chunkNumber: number; | ||
chunkSize: number; | ||
}>> | undefined; | ||
onChunkSuccess?: GenericEventListener<CustomEvent<{ | ||
chunk: number; | ||
attempts: number; | ||
response: any; | ||
}>> | undefined; | ||
onError?: GenericEventListener<CustomEvent<{ | ||
message: string; | ||
chunkNumber?: number | undefined; | ||
attempts?: number | undefined; | ||
}>> | undefined; | ||
onProgress?: GenericEventListener<CustomEvent<number>> | undefined; | ||
onSuccess?: GenericEventListener<CustomEvent<null | undefined>> | undefined; | ||
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<MuxUploaderElement>>; | ||
export { MuxUploaderDrop }; | ||
export default MuxUploader; |
{ | ||
"name": "@mux/mux-uploader-react", | ||
"version": "0.1.0-canary.10-8cfa013", | ||
"version": "0.1.0-canary.10-8e82f44", | ||
"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-8cfa013", | ||
"@mux/mux-uploader": "0.1.0-canary.10-8e82f44", | ||
"prop-types": "^15.7.2" | ||
@@ -52,0 +52,0 @@ }, |
@@ -90,7 +90,8 @@ <p align="center"> | ||
`<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 | | ||
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `onAttempt` | Invoked immediately before a chunk upload is attempted. | | ||
| `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 } }` | | ||
@@ -97,0 +98,0 @@ | `onError` | Invoked when an error occurs in the chunked upload process. | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
211326
833
100
22
+ Added@mux/mux-uploader@0.1.0-canary.10-8e82f44(transitive)
- Removed@mux/mux-uploader@0.1.0-canary.10-8cfa013(transitive)