@designcombo/state 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.es.js +643 -590
- package/dist/index.umd.js +2 -2
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
(function(
|
1
|
+
(function(x,X){typeof exports=="object"&&typeof module<"u"?module.exports=X(require("@designcombo/events")):typeof define=="function"&&define.amd?define(["@designcombo/events"],X):(x=typeof globalThis<"u"?globalThis:x||self,x.events=X(x.events))})(this,function(x){"use strict";var va=Object.defineProperty;var Ia=(x,X,ut)=>X in x?va(x,X,{enumerable:!0,configurable:!0,writable:!0,value:ut}):x[X]=ut;var jt=(x,X,ut)=>Ia(x,typeof X!="symbol"?X+"":X,ut);var X=function(t,r){return X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},X(t,r)};function ut(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");X(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}function ir(t){var r=typeof Symbol=="function"&&Symbol.iterator,n=r&&t[r],i=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function ar(t,r){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var i=n.call(t),o,c=[],f;try{for(;(r===void 0||r-- >0)&&!(o=i.next()).done;)c.push(o.value)}catch(d){f={error:d}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(f)throw f.error}}return c}function sr(t,r,n){if(n||arguments.length===2)for(var i=0,o=r.length,c;i<o;i++)(c||!(i in r))&&(c||(c=Array.prototype.slice.call(r,0,i)),c[i]=r[i]);return t.concat(c||Array.prototype.slice.call(r))}typeof SuppressedError=="function"&&SuppressedError;function ht(t){return typeof t=="function"}function wn(t){var r=function(i){Error.call(i),i.stack=new Error().stack},n=t(r);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var or=wn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
2
2
|
`+n.map(function(i,o){return o+1+") "+i.toString()}).join(`
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function cr(t,r){if(t){var n=t.indexOf(r);0<=n&&t.splice(n,1)}}var Ie=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,n,i,o,c;if(!this.closed){this.closed=!0;var l=this._parentage;if(l)if(this._parentage=null,Array.isArray(l))try{for(var d=ir(l),O=d.next();!O.done;O=d.next()){var R=O.value;R.remove(this)}}catch(f){r={error:f}}finally{try{O&&!O.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}else l.remove(this);var S=this.initialTeardown;if(ht(S))try{S()}catch(f){c=f instanceof or?f.errors:[f]}var U=this._finalizers;if(U){this._finalizers=null;try{for(var m=ir(U),p=m.next();!p.done;p=m.next()){var h=p.value;try{An(h)}catch(f){c=c??[],f instanceof or?c=sr(sr([],ar(c)),ar(f.errors)):c.push(f)}}}catch(f){i={error:f}}finally{try{p&&!p.done&&(o=m.return)&&o.call(m)}finally{if(i)throw i.error}}}if(c)throw new or(c)}},t.prototype.add=function(r){var n;if(r&&r!==this)if(this.closed)An(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(r)}},t.prototype._hasParent=function(r){var n=this._parentage;return n===r||Array.isArray(n)&&n.includes(r)},t.prototype._addParent=function(r){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(r),n):n?[n,r]:r},t.prototype._removeParent=function(r){var n=this._parentage;n===r?this._parentage=null:Array.isArray(n)&&cr(n,r)},t.prototype.remove=function(r){var n=this._finalizers;n&&cr(n,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),Tn=Ie.EMPTY;function kn(t){return t instanceof Ie||t&&"closed"in t&&ht(t.remove)&&ht(t.add)&&ht(t.unsubscribe)}function An(t){ht(t)?t():t.unsubscribe()}var En={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},On={setTimeout:function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return setTimeout.apply(void 0,sr([t,r],ar(n)))},clearTimeout:function(t){var r=On.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(t)},delegate:void 0};function ai(t){On.setTimeout(function(){throw t})}function xn(){}function Se(t){t()}var Mn=function(t){ut(r,t);function r(n){var i=t.call(this)||this;return i.isStopped=!1,n?(i.destination=n,kn(n)&&n.add(i)):i.destination=ui,i}return r.create=function(n,i,o){return new fr(n,i,o)},r.prototype.next=function(n){this.isStopped||this._next(n)},r.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(n){this.destination.next(n)},r.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(Ie),si=Function.prototype.bind;function ur(t,r){return si.call(t,r)}var oi=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var n=this.partialObserver;if(n.next)try{n.next(r)}catch(i){we(i)}},t.prototype.error=function(r){var n=this.partialObserver;if(n.error)try{n.error(r)}catch(i){we(i)}else we(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(n){we(n)}},t}(),fr=function(t){ut(r,t);function r(n,i,o){var c=t.call(this)||this,l;if(ht(n)||!n)l={next:n??void 0,error:i??void 0,complete:o??void 0};else{var d;c&&En.useDeprecatedNextContext?(d=Object.create(n),d.unsubscribe=function(){return c.unsubscribe()},l={next:n.next&&ur(n.next,d),error:n.error&&ur(n.error,d),complete:n.complete&&ur(n.complete,d)}):l=n}return c.destination=new oi(l),c}return r}(Mn);function we(t){ai(t)}function ci(t){throw t}var ui={closed:!0,next:xn,error:ci,complete:xn},fi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function li(t){return t}function pi(t){return t.length===0?li:t.length===1?t[0]:function(n){return t.reduce(function(i,o){return o(i)},n)}}var Pn=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var n=new t;return n.source=this,n.operator=r,n},t.prototype.subscribe=function(r,n,i){var o=this,c=hi(r)?r:new fr(r,n,i);return Se(function(){var l=o,d=l.operator,O=l.source;c.add(d?d.call(c,O):O?o._subscribe(c):o._trySubscribe(c))}),c},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(n){r.error(n)}},t.prototype.forEach=function(r,n){var i=this;return n=Dn(n),new n(function(o,c){var l=new fr({next:function(d){try{r(d)}catch(O){c(O),l.unsubscribe()}},error:c,complete:o});i.subscribe(l)})},t.prototype._subscribe=function(r){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(r)},t.prototype[fi]=function(){return this},t.prototype.pipe=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return pi(r)(this)},t.prototype.toPromise=function(r){var n=this;return r=Dn(r),new r(function(i,o){var c;n.subscribe(function(l){return c=l},function(l){return o(l)},function(){return i(c)})})},t.create=function(r){return new t(r)},t}();function Dn(t){var r;return(r=t??En.Promise)!==null&&r!==void 0?r:Promise}function di(t){return t&&ht(t.next)&&ht(t.error)&&ht(t.complete)}function hi(t){return t&&t instanceof Mn||di(t)&&kn(t)}var yi=wn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Cn=function(t){ut(r,t);function r(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return r.prototype.lift=function(n){var i=new jn(this,this);return i.operator=n,i},r.prototype._throwIfClosed=function(){if(this.closed)throw new yi},r.prototype.next=function(n){var i=this;Se(function(){var o,c;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var l=ir(i.currentObservers),d=l.next();!d.done;d=l.next()){var O=d.value;O.next(n)}}catch(R){o={error:R}}finally{try{d&&!d.done&&(c=l.return)&&c.call(l)}finally{if(o)throw o.error}}}})},r.prototype.error=function(n){var i=this;Se(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=n;for(var o=i.observers;o.length;)o.shift().error(n)}})},r.prototype.complete=function(){var n=this;Se(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var i=n.observers;i.length;)i.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},r.prototype._innerSubscribe=function(n){var i=this,o=this,c=o.hasError,l=o.isStopped,d=o.observers;return c||l?Tn:(this.currentObservers=null,d.push(n),new Ie(function(){i.currentObservers=null,cr(d,n)}))},r.prototype._checkFinalizedStatuses=function(n){var i=this,o=i.hasError,c=i.thrownError,l=i.isStopped;o?n.error(c):l&&n.complete()},r.prototype.asObservable=function(){var n=new Pn;return n.source=this,n},r.create=function(n,i){return new jn(n,i)},r}(Pn),jn=function(t){ut(r,t);function r(n,i){var o=t.call(this)||this;return o.destination=n,o.source=i,o}return r.prototype.next=function(n){var i,o;(o=(i=this.destination)===null||i===void 0?void 0:i.next)===null||o===void 0||o.call(i,n)},r.prototype.error=function(n){var i,o;(o=(i=this.destination)===null||i===void 0?void 0:i.error)===null||o===void 0||o.call(i,n)},r.prototype.complete=function(){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||i===void 0||i.call(n)},r.prototype._subscribe=function(n){var i,o;return(o=(i=this.source)===null||i===void 0?void 0:i.subscribe(n))!==null&&o!==void 0?o:Tn},r}(Cn),Rn=function(t){ut(r,t);function r(n){var i=t.call(this)||this;return i._value=n,i}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var i=t.prototype._subscribe.call(this,n);return!i.closed&&n.next(this._value),i},r.prototype.getValue=function(){var n=this,i=n.hasError,o=n.thrownError,c=n._value;if(i)throw o;return this._throwIfClosed(),c},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(Cn),et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Te={exports:{}};Te.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",o=1,c=2,l=9007199254740991,d="[object Arguments]",O="[object Array]",R="[object AsyncFunction]",S="[object Boolean]",U="[object Date]",m="[object Error]",p="[object Function]",h="[object GeneratorFunction]",f="[object Map]",b="[object Number]",v="[object Null]",_="[object Object]",g="[object Promise]",y="[object Proxy]",F="[object RegExp]",E="[object Set]",x="[object String]",C="[object Symbol]",w="[object Undefined]",T="[object WeakMap]",M="[object ArrayBuffer]",z="[object DataView]",Rt="[object Float32Array]",Ft="[object Float64Array]",De="[object Int8Array]",Or="[object Int16Array]",xr="[object Int32Array]",Mr="[object Uint8Array]",Pr="[object Uint8ClampedArray]",N="[object Uint16Array]",Dr="[object Uint32Array]",Cr=/[\\^$.*+?()[\]{}|]/g,at=/^\[object .+?Constructor\]$/,Ce=/^(?:0|[1-9]\d*)$/,H={};H[Rt]=H[Ft]=H[De]=H[Or]=H[xr]=H[Mr]=H[Pr]=H[N]=H[Dr]=!0,H[d]=H[O]=H[M]=H[S]=H[z]=H[U]=H[m]=H[p]=H[f]=H[b]=H[_]=H[F]=H[E]=H[x]=H[T]=!1;var je=typeof et=="object"&&et&&et.Object===Object&&et,jr=typeof self=="object"&&self&&self.Object===Object&&self,st=je||jr||Function("return this")(),Re=r&&!r.nodeType&&r,Fe=Re&&!0&&t&&!t.nodeType&&t,re=Fe&&Fe.exports===Re,ne=re&&je.process,ze=function(){try{return ne&&ne.binding&&ne.binding("util")}catch{}}(),ie=ze&&ze.isTypedArray;function Ne(e,a){for(var s=-1,u=e==null?0:e.length,k=0,I=[];++s<u;){var D=e[s];a(D,s,e)&&(I[k++]=D)}return I}function ae(e,a){for(var s=-1,u=a.length,k=e.length;++s<u;)e[k+s]=a[s];return e}function He(e,a){for(var s=-1,u=e==null?0:e.length;++s<u;)if(a(e[s],s,e))return!0;return!1}function Rr(e,a){for(var s=-1,u=Array(e);++s<e;)u[s]=a(s);return u}function Fr(e){return function(a){return e(a)}}function zt(e,a){return e.has(a)}function se(e,a){return e==null?void 0:e[a]}function Ue(e){var a=-1,s=Array(e.size);return e.forEach(function(u,k){s[++a]=[k,u]}),s}function Le(e,a){return function(s){return e(a(s))}}function ft(e){var a=-1,s=Array(e.size);return e.forEach(function(u){s[++a]=u}),s}var Nt=Array.prototype,zr=Function.prototype,Et=Object.prototype,Ht=st["__core-js_shared__"],oe=zr.toString,nt=Et.hasOwnProperty,Ge=function(){var e=/[^.]+$/.exec(Ht&&Ht.keys&&Ht.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),We=Et.toString,Nr=RegExp("^"+oe.call(nt).replace(Cr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=re?st.Buffer:void 0,Ut=st.Symbol,Be=st.Uint8Array,Lt=Et.propertyIsEnumerable,Ot=Nt.splice,ot=Ut?Ut.toStringTag:void 0,Gt=Object.getOwnPropertySymbols,ue=ce?ce.isBuffer:void 0,xt=Le(Object.keys,Object),fe=mt(st,"DataView"),Mt=mt(st,"Map"),le=mt(st,"Promise"),pe=mt(st,"Set"),de=mt(st,"WeakMap"),vt=mt(Object,"create"),$e=q(fe),yt=q(Mt),Hr=q(le),Ur=q(pe),Lr=q(de),Ke=Ut?Ut.prototype:void 0,he=Ke?Ke.valueOf:void 0;function B(e){var a=-1,s=e==null?0:e.length;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Gr(){this.__data__=vt?vt(null):{},this.size=0}function Wr(e){var a=this.has(e)&&delete this.__data__[e];return this.size-=a?1:0,a}function Br(e){var a=this.__data__;if(vt){var s=a[e];return s===i?void 0:s}return nt.call(a,e)?a[e]:void 0}function $r(e){var a=this.__data__;return vt?a[e]!==void 0:nt.call(a,e)}function Kr(e,a){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=vt&&a===void 0?i:a,this}B.prototype.clear=Gr,B.prototype.delete=Wr,B.prototype.get=Br,B.prototype.has=$r,B.prototype.set=Kr;function K(e){var a=-1,s=e==null?0:e.length;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Yr(){this.__data__=[],this.size=0}function Vr(e){var a=this.__data__,s=$t(a,e);if(s<0)return!1;var u=a.length-1;return s==u?a.pop():Ot.call(a,s,1),--this.size,!0}function Xr(e){var a=this.__data__,s=$t(a,e);return s<0?void 0:a[s][1]}function qr(e){return $t(this.__data__,e)>-1}function Jr(e,a){var s=this.__data__,u=$t(s,e);return u<0?(++this.size,s.push([e,a])):s[u][1]=a,this}K.prototype.clear=Yr,K.prototype.delete=Vr,K.prototype.get=Xr,K.prototype.has=qr,K.prototype.set=Jr;function J(e){var a=-1,s=e==null?0:e.length;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Zr(){this.size=0,this.__data__={hash:new B,map:new(Mt||K),string:new B}}function Qr(e){var a=ct(this,e).delete(e);return this.size-=a?1:0,a}function tn(e){return ct(this,e).get(e)}function en(e){return ct(this,e).has(e)}function rn(e,a){var s=ct(this,e),u=s.size;return s.set(e,a),this.size+=s.size==u?0:1,this}J.prototype.clear=Zr,J.prototype.delete=Qr,J.prototype.get=tn,J.prototype.has=en,J.prototype.set=rn;function Wt(e){var a=-1,s=e==null?0:e.length;for(this.__data__=new J;++a<s;)this.add(e[a])}function Ye(e){return this.__data__.set(e,i),this}function Bt(e){return this.__data__.has(e)}Wt.prototype.add=Wt.prototype.push=Ye,Wt.prototype.has=Bt;function lt(e){var a=this.__data__=new K(e);this.size=a.size}function ye(){this.__data__=new K,this.size=0}function nn(e){var a=this.__data__,s=a.delete(e);return this.size=a.size,s}function an(e){return this.__data__.get(e)}function sn(e){return this.__data__.has(e)}function on(e,a){var s=this.__data__;if(s instanceof K){var u=s.__data__;if(!Mt||u.length<n-1)return u.push([e,a]),this.size=++s.size,this;s=this.__data__=new J(u)}return s.set(e,a),this.size=s.size,this}lt.prototype.clear=ye,lt.prototype.delete=nn,lt.prototype.get=an,lt.prototype.has=sn,lt.prototype.set=on;function cn(e,a){var s=Kt(e),u=!s&&Ze(e),k=!s&&!u&&Yt(e),I=!s&&!u&&!k&&er(e),D=s||u||k||I,P=D?Rr(e.length,String):[],L=P.length;for(var j in e)nt.call(e,j)&&!(D&&(j=="length"||k&&(j=="offset"||j=="parent")||I&&(j=="buffer"||j=="byteLength"||j=="byteOffset")||mn(j,L)))&&P.push(j);return P}function $t(e,a){for(var s=e.length;s--;)if(Je(e[s][0],a))return s;return-1}function me(e,a,s){var u=a(e);return Kt(e)?u:ae(u,s(e))}function Pt(e){return e==null?e===void 0?w:v:ot&&ot in Object(e)?bt(e):qe(e)}function Ve(e){return dt(e)&&Pt(e)==d}function Xe(e,a,s,u,k){return e===a?!0:e==null||a==null||!dt(e)&&!dt(a)?e!==e&&a!==a:un(e,a,s,u,Xe,k)}function un(e,a,s,u,k,I){var D=Kt(e),P=Kt(a),L=D?O:pt(e),j=P?O:pt(a);L=L==d?_:L,j=j==d?_:j;var Y=L==_,Z=j==_,W=L==j;if(W&&Yt(e)){if(!Yt(a))return!1;D=!0,Y=!1}if(W&&!Y)return I||(I=new lt),D||er(e)?be(e,a,s,u,k,I):dn(e,a,L,s,u,k,I);if(!(s&o)){var V=Y&&nt.call(e,"__wrapped__"),$=Z&&nt.call(a,"__wrapped__");if(V||$){var It=V?e.value():e,gt=$?a.value():a;return I||(I=new lt),k(It,gt,s,u,I)}}return W?(I||(I=new lt),hn(e,a,s,u,k,I)):!1}function fn(e){if(!tr(e)||gn(e))return!1;var a=Qe(e)?Nr:at;return a.test(q(e))}function ln(e){return dt(e)&&_e(e.length)&&!!H[Pt(e)]}function pn(e){if(!_n(e))return xt(e);var a=[];for(var s in Object(e))nt.call(e,s)&&s!="constructor"&&a.push(s);return a}function be(e,a,s,u,k,I){var D=s&o,P=e.length,L=a.length;if(P!=L&&!(D&&L>P))return!1;var j=I.get(e);if(j&&I.get(a))return j==a;var Y=-1,Z=!0,W=s&c?new Wt:void 0;for(I.set(e,a),I.set(a,e);++Y<P;){var V=e[Y],$=a[Y];if(u)var It=D?u($,V,Y,a,e,I):u(V,$,Y,e,a,I);if(It!==void 0){if(It)continue;Z=!1;break}if(W){if(!He(a,function(gt,Ct){if(!zt(W,Ct)&&(V===gt||k(V,gt,s,u,I)))return W.push(Ct)})){Z=!1;break}}else if(!(V===$||k(V,$,s,u,I))){Z=!1;break}}return I.delete(e),I.delete(a),Z}function dn(e,a,s,u,k,I,D){switch(s){case z:if(e.byteLength!=a.byteLength||e.byteOffset!=a.byteOffset)return!1;e=e.buffer,a=a.buffer;case M:return!(e.byteLength!=a.byteLength||!I(new Be(e),new Be(a)));case S:case U:case b:return Je(+e,+a);case m:return e.name==a.name&&e.message==a.message;case F:case x:return e==a+"";case f:var P=Ue;case E:var L=u&o;if(P||(P=ft),e.size!=a.size&&!L)return!1;var j=D.get(e);if(j)return j==a;u|=c,D.set(e,a);var Y=be(P(e),P(a),u,k,I,D);return D.delete(e),Y;case C:if(he)return he.call(e)==he.call(a)}return!1}function hn(e,a,s,u,k,I){var D=s&o,P=Dt(e),L=P.length,j=Dt(a),Y=j.length;if(L!=Y&&!D)return!1;for(var Z=L;Z--;){var W=P[Z];if(!(D?W in a:nt.call(a,W)))return!1}var V=I.get(e);if(V&&I.get(a))return V==a;var $=!0;I.set(e,a),I.set(a,e);for(var It=D;++Z<L;){W=P[Z];var gt=e[W],Ct=a[W];if(u)var ii=D?u(Ct,gt,W,a,e,I):u(gt,Ct,W,e,a,I);if(!(ii===void 0?gt===Ct||k(gt,Ct,s,u,I):ii)){$=!1;break}It||(It=W=="constructor")}if($&&!It){var rr=e.constructor,nr=a.constructor;rr!=nr&&"constructor"in e&&"constructor"in a&&!(typeof rr=="function"&&rr instanceof rr&&typeof nr=="function"&&nr instanceof nr)&&($=!1)}return I.delete(e),I.delete(a),$}function Dt(e){return me(e,ve,yn)}function ct(e,a){var s=e.__data__;return bn(a)?s[typeof a=="string"?"string":"hash"]:s.map}function mt(e,a){var s=se(e,a);return fn(s)?s:void 0}function bt(e){var a=nt.call(e,ot),s=e[ot];try{e[ot]=void 0;var u=!0}catch{}var k=We.call(e);return u&&(a?e[ot]=s:delete e[ot]),k}var yn=Gt?function(e){return e==null?[]:(e=Object(e),Ne(Gt(e),function(a){return Lt.call(e,a)}))}:In,pt=Pt;(fe&&pt(new fe(new ArrayBuffer(1)))!=z||Mt&&pt(new Mt)!=f||le&&pt(le.resolve())!=g||pe&&pt(new pe)!=E||de&&pt(new de)!=T)&&(pt=function(e){var a=Pt(e),s=a==_?e.constructor:void 0,u=s?q(s):"";if(u)switch(u){case $e:return z;case yt:return f;case Hr:return g;case Ur:return E;case Lr:return T}return a});function mn(e,a){return a=a??l,!!a&&(typeof e=="number"||Ce.test(e))&&e>-1&&e%1==0&&e<a}function bn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function gn(e){return!!Ge&&Ge in e}function _n(e){var a=e&&e.constructor,s=typeof a=="function"&&a.prototype||Et;return e===s}function qe(e){return We.call(e)}function q(e){if(e!=null){try{return oe.call(e)}catch{}try{return e+""}catch{}}return""}function Je(e,a){return e===a||e!==e&&a!==a}var Ze=Ve(function(){return arguments}())?Ve:function(e){return dt(e)&&nt.call(e,"callee")&&!Lt.call(e,"callee")},Kt=Array.isArray;function ge(e){return e!=null&&_e(e.length)&&!Qe(e)}var Yt=ue||Sn;function vn(e,a){return Xe(e,a)}function Qe(e){if(!tr(e))return!1;var a=Pt(e);return a==p||a==h||a==R||a==y}function _e(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=l}function tr(e){var a=typeof e;return e!=null&&(a=="object"||a=="function")}function dt(e){return e!=null&&typeof e=="object"}var er=ie?Fr(ie):ln;function ve(e){return ge(e)?cn(e):pn(e)}function In(){return[]}function Sn(){return!1}t.exports=vn}(Te,Te.exports);var mi=Te.exports;const it=lr(mi);var ke={exports:{}};ke.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",o=9007199254740991,c="[object Arguments]",l="[object Array]",d="[object Boolean]",O="[object Date]",R="[object Error]",S="[object Function]",U="[object GeneratorFunction]",m="[object Map]",p="[object Number]",h="[object Object]",f="[object Promise]",b="[object RegExp]",v="[object Set]",_="[object String]",g="[object Symbol]",y="[object WeakMap]",F="[object ArrayBuffer]",E="[object DataView]",x="[object Float32Array]",C="[object Float64Array]",w="[object Int8Array]",T="[object Int16Array]",M="[object Int32Array]",z="[object Uint8Array]",Rt="[object Uint8ClampedArray]",Ft="[object Uint16Array]",De="[object Uint32Array]",Or=/[\\^$.*+?()[\]{}|]/g,xr=/\w*$/,Mr=/^\[object .+?Constructor\]$/,Pr=/^(?:0|[1-9]\d*)$/,N={};N[c]=N[l]=N[F]=N[E]=N[d]=N[O]=N[x]=N[C]=N[w]=N[T]=N[M]=N[m]=N[p]=N[h]=N[b]=N[v]=N[_]=N[g]=N[z]=N[Rt]=N[Ft]=N[De]=!0,N[R]=N[S]=N[y]=!1;var Dr=typeof et=="object"&&et&&et.Object===Object&&et,Cr=typeof self=="object"&&self&&self.Object===Object&&self,at=Dr||Cr||Function("return this")(),Ce=r&&!r.nodeType&&r,H=Ce&&!0&&t&&!t.nodeType&&t,je=H&&H.exports===Ce;function jr(e,a){return e.set(a[0],a[1]),e}function st(e,a){return e.add(a),e}function Re(e,a){for(var s=-1,u=e?e.length:0;++s<u&&a(e[s],s,e)!==!1;);return e}function Fe(e,a){for(var s=-1,u=a.length,k=e.length;++s<u;)e[k+s]=a[s];return e}function re(e,a,s,u){for(var k=-1,I=e?e.length:0;++k<I;)s=a(s,e[k],k,e);return s}function ne(e,a){for(var s=-1,u=Array(e);++s<e;)u[s]=a(s);return u}function ze(e,a){return e==null?void 0:e[a]}function ie(e){var a=!1;if(e!=null&&typeof e.toString!="function")try{a=!!(e+"")}catch{}return a}function Ne(e){var a=-1,s=Array(e.size);return e.forEach(function(u,k){s[++a]=[k,u]}),s}function ae(e,a){return function(s){return e(a(s))}}function He(e){var a=-1,s=Array(e.size);return e.forEach(function(u){s[++a]=u}),s}var Rr=Array.prototype,Fr=Function.prototype,zt=Object.prototype,se=at["__core-js_shared__"],Ue=function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Le=Fr.toString,ft=zt.hasOwnProperty,Nt=zt.toString,zr=RegExp("^"+Le.call(ft).replace(Or,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Et=je?at.Buffer:void 0,Ht=at.Symbol,oe=at.Uint8Array,nt=ae(Object.getPrototypeOf,Object),Ge=Object.create,We=zt.propertyIsEnumerable,Nr=Rr.splice,ce=Object.getOwnPropertySymbols,Ut=Et?Et.isBuffer:void 0,Be=ae(Object.keys,Object),Lt=ct(at,"DataView"),Ot=ct(at,"Map"),ot=ct(at,"Promise"),Gt=ct(at,"Set"),ue=ct(at,"WeakMap"),xt=ct(Object,"create"),fe=q(Lt),Mt=q(Ot),le=q(ot),pe=q(Gt),de=q(ue),vt=Ht?Ht.prototype:void 0,$e=vt?vt.valueOf:void 0;function yt(e){var a=-1,s=e?e.length:0;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Hr(){this.__data__=xt?xt(null):{}}function Ur(e){return this.has(e)&&delete this.__data__[e]}function Lr(e){var a=this.__data__;if(xt){var s=a[e];return s===i?void 0:s}return ft.call(a,e)?a[e]:void 0}function Ke(e){var a=this.__data__;return xt?a[e]!==void 0:ft.call(a,e)}function he(e,a){var s=this.__data__;return s[e]=xt&&a===void 0?i:a,this}yt.prototype.clear=Hr,yt.prototype.delete=Ur,yt.prototype.get=Lr,yt.prototype.has=Ke,yt.prototype.set=he;function B(e){var a=-1,s=e?e.length:0;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Gr(){this.__data__=[]}function Wr(e){var a=this.__data__,s=Bt(a,e);if(s<0)return!1;var u=a.length-1;return s==u?a.pop():Nr.call(a,s,1),!0}function Br(e){var a=this.__data__,s=Bt(a,e);return s<0?void 0:a[s][1]}function $r(e){return Bt(this.__data__,e)>-1}function Kr(e,a){var s=this.__data__,u=Bt(s,e);return u<0?s.push([e,a]):s[u][1]=a,this}B.prototype.clear=Gr,B.prototype.delete=Wr,B.prototype.get=Br,B.prototype.has=$r,B.prototype.set=Kr;function K(e){var a=-1,s=e?e.length:0;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Yr(){this.__data__={hash:new yt,map:new(Ot||B),string:new yt}}function Vr(e){return Dt(this,e).delete(e)}function Xr(e){return Dt(this,e).get(e)}function qr(e){return Dt(this,e).has(e)}function Jr(e,a){return Dt(this,e).set(e,a),this}K.prototype.clear=Yr,K.prototype.delete=Vr,K.prototype.get=Xr,K.prototype.has=qr,K.prototype.set=Jr;function J(e){this.__data__=new B(e)}function Zr(){this.__data__=new B}function Qr(e){return this.__data__.delete(e)}function tn(e){return this.__data__.get(e)}function en(e){return this.__data__.has(e)}function rn(e,a){var s=this.__data__;if(s instanceof B){var u=s.__data__;if(!Ot||u.length<n-1)return u.push([e,a]),this;s=this.__data__=new K(u)}return s.set(e,a),this}J.prototype.clear=Zr,J.prototype.delete=Qr,J.prototype.get=tn,J.prototype.has=en,J.prototype.set=rn;function Wt(e,a){var s=ge(e)||Kt(e)?ne(e.length,String):[],u=s.length,k=!!u;for(var I in e)ft.call(e,I)&&!(k&&(I=="length"||bn(I,u)))&&s.push(I);return s}function Ye(e,a,s){var u=e[a];(!(ft.call(e,a)&&Ze(u,s))||s===void 0&&!(a in e))&&(e[a]=s)}function Bt(e,a){for(var s=e.length;s--;)if(Ze(e[s][0],a))return s;return-1}function lt(e,a){return e&&be(a,ve(a),e)}function ye(e,a,s,u,k,I,D){var P;if(u&&(P=I?u(e,k,I,D):u(e)),P!==void 0)return P;if(!dt(e))return e;var L=ge(e);if(L){if(P=yn(e),!a)return pn(e,P)}else{var j=bt(e),Y=j==S||j==U;if(Qe(e))return $t(e,a);if(j==h||j==c||Y&&!I){if(ie(e))return I?e:{};if(P=pt(Y?{}:e),!a)return dn(e,lt(P,e))}else{if(!N[j])return I?e:{};P=mn(e,j,ye,a)}}D||(D=new J);var Z=D.get(e);if(Z)return Z;if(D.set(e,P),!L)var W=s?hn(e):ve(e);return Re(W||e,function(V,$){W&&($=V,V=e[$]),Ye(P,$,ye(V,a,s,u,$,e,D))}),P}function nn(e){return dt(e)?Ge(e):{}}function an(e,a,s){var u=a(e);return ge(e)?u:Fe(u,s(e))}function sn(e){return Nt.call(e)}function on(e){if(!dt(e)||_n(e))return!1;var a=_e(e)||ie(e)?zr:Mr;return a.test(q(e))}function cn(e){if(!qe(e))return Be(e);var a=[];for(var s in Object(e))ft.call(e,s)&&s!="constructor"&&a.push(s);return a}function $t(e,a){if(a)return e.slice();var s=new e.constructor(e.length);return e.copy(s),s}function me(e){var a=new e.constructor(e.byteLength);return new oe(a).set(new oe(e)),a}function Pt(e,a){var s=a?me(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function Ve(e,a,s){var u=a?s(Ne(e),!0):Ne(e);return re(u,jr,new e.constructor)}function Xe(e){var a=new e.constructor(e.source,xr.exec(e));return a.lastIndex=e.lastIndex,a}function un(e,a,s){var u=a?s(He(e),!0):He(e);return re(u,st,new e.constructor)}function fn(e){return $e?Object($e.call(e)):{}}function ln(e,a){var s=a?me(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function pn(e,a){var s=-1,u=e.length;for(a||(a=Array(u));++s<u;)a[s]=e[s];return a}function be(e,a,s,u){s||(s={});for(var k=-1,I=a.length;++k<I;){var D=a[k],P=void 0;Ye(s,D,P===void 0?e[D]:P)}return s}function dn(e,a){return be(e,mt(e),a)}function hn(e){return an(e,ve,mt)}function Dt(e,a){var s=e.__data__;return gn(a)?s[typeof a=="string"?"string":"hash"]:s.map}function ct(e,a){var s=ze(e,a);return on(s)?s:void 0}var mt=ce?ae(ce,Object):In,bt=sn;(Lt&&bt(new Lt(new ArrayBuffer(1)))!=E||Ot&&bt(new Ot)!=m||ot&&bt(ot.resolve())!=f||Gt&&bt(new Gt)!=v||ue&&bt(new ue)!=y)&&(bt=function(e){var a=Nt.call(e),s=a==h?e.constructor:void 0,u=s?q(s):void 0;if(u)switch(u){case fe:return E;case Mt:return m;case le:return f;case pe:return v;case de:return y}return a});function yn(e){var a=e.length,s=e.constructor(a);return a&&typeof e[0]=="string"&&ft.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function pt(e){return typeof e.constructor=="function"&&!qe(e)?nn(nt(e)):{}}function mn(e,a,s,u){var k=e.constructor;switch(a){case F:return me(e);case d:case O:return new k(+e);case E:return Pt(e,u);case x:case C:case w:case T:case M:case z:case Rt:case Ft:case De:return ln(e,u);case m:return Ve(e,u,s);case p:case _:return new k(e);case b:return Xe(e);case v:return un(e,u,s);case g:return fn(e)}}function bn(e,a){return a=a??o,!!a&&(typeof e=="number"||Pr.test(e))&&e>-1&&e%1==0&&e<a}function gn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function _n(e){return!!Ue&&Ue in e}function qe(e){var a=e&&e.constructor,s=typeof a=="function"&&a.prototype||zt;return e===s}function q(e){if(e!=null){try{return Le.call(e)}catch{}try{return e+""}catch{}}return""}function Je(e){return ye(e,!0,!0)}function Ze(e,a){return e===a||e!==e&&a!==a}function Kt(e){return vn(e)&&ft.call(e,"callee")&&(!We.call(e,"callee")||Nt.call(e)==c)}var ge=Array.isArray;function Yt(e){return e!=null&&tr(e.length)&&!_e(e)}function vn(e){return er(e)&&Yt(e)}var Qe=Ut||Sn;function _e(e){var a=dt(e)?Nt.call(e):"";return a==S||a==U}function tr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=o}function dt(e){var a=typeof e;return!!e&&(a=="object"||a=="function")}function er(e){return!!e&&typeof e=="object"}function ve(e){return Yt(e)?Wt(e):cn(e)}function In(){return[]}function Sn(){return!1}t.exports=Je}(ke,ke.exports);var bi=ke.exports;const rt=lr(bi),gi=t=>new Promise((r,n)=>{const i=new Image;console.warn("update cdn config for cors?"),i.onload=()=>{const o=i.width,c=i.height;r({width:o,height:c})},i.onerror=o=>{n(o)},i.crossOrigin="anonymous",i.src=t}),_i=t=>new Promise((r,n)=>{const i=new Audio;i.preload="auto",i.addEventListener("loadedmetadata",()=>{const o=i.duration*1e3;r({duration:o})}),i.addEventListener("error",o=>{n(o)}),i.src=t,i.crossOrigin="anonymous",i.load()}),vi=t=>new Promise((r,n)=>{const i=document.createElement("video");i.preload="auto",i.addEventListener("loadedmetadata",()=>{const o=i.duration*1e3,c=i.videoWidth,l=i.videoHeight;r({duration:o,width:c,height:l})}),i.addEventListener("error",o=>{n(o)}),i.src=t,i.load()}),Fn=(t,r)=>{const n=document.createElement("div");Object.keys(r).forEach(o=>{o!=="height"&&(n.style[o]=r[o])}),document.body.appendChild(n),n.textContent=t,n.style.whiteSpace="normal",n.style.position="absolute",n.style.visibility="hidden",n.style.display="inline-block",n.style.width=r.width+"px",n.style.fontSize=r.fontSize+"px";const i=getComputedStyle(n).height;return document.body.removeChild(n),parseFloat(i)},Ae=t=>{const r=t.map(n=>new FontFace(n.fontFamily,`url(${n.url})`).load().catch(i=>i));return r.length===0?Promise.resolve(!0):new Promise((n,i)=>{Promise.all(r).then(o=>{o.forEach(c=>{c&&c.family&&(document.fonts.add(c),n(!0))})}).catch(o=>i(o))})},Ee={color:"#000000",x:0,y:0,blur:0},Vt=(t,r)=>{let n=r!=null&&r.trim?r.trim.to-r.trim.from:(r==null?void 0:r.duration)||5e3;const i={from:0,to:n};if(!t)return i;if(t.from<0)return console.error("'from' must be a non-negative number. Returning default display."),i;if(t.from!==void 0&&t.to===void 0)return{from:t.from,to:t.from+n};if(t.to!==void 0){if(t.to<0)return console.error("'to' must be a non-negative number. Returning default display."),i;if(t.to<t.from)return console.error("'to' must be greater than or equal to 'from'. Returning default display."),i}return t},zn=(t,r)=>t?t.from&&!t.to?{from:t.from,to:r.duration}:t:{from:0,to:r.duration};function Oe(t,r){const n={x:t.size.width/2,y:t.size.height/2},i={x:r.width/2,y:r.height/2},o=Math.min(t.size.width/r.width,t.size.height/r.height),c=n.x-i.x;return{top:`${n.y-i.y}px`,left:`${c}px`,transform:`scale(${o})`}}const Ii=async(t,r)=>{const n=t.details.src,i=await vi(n),o=Oe(r,{...i}),c=zn(t.trim,{duration:i.duration}),l={width:i.width,height:i.height,duration:i.duration,opacity:100,src:n,volume:t.details.volume??100,borderRadius:t.details.borderRadius??0,borderWidth:t.details.borderWidth??0,borderColor:t.details.borderColor||"#000000",boxShadow:t.details.boxShadow||Ee,top:o.top||"0px",left:o.left||"0px",transform:o.transform,blur:t.details.blur||0,brightness:t.details.brightness||100,flipX:t.details.flipX||!1,flipY:t.details.flipY||!1};return{...t,trim:c,type:"video",name:"video",details:l,playbackRate:t.playbackRate||1,display:Vt(t.display,{duration:i.duration,trim:c})}},Si=async t=>{const r=t.id,n=t.details,o=(await _i(n.src)).duration,c=zn(t.trim,{duration:o});return{id:r,name:"",type:"audio",display:Vt(t.display,{duration:o,trim:c}),trim:c,playbackRate:t.playbackRate||1,details:{src:n.src,duration:o,volume:n.volume??100},metadata:{...t.metadata}}},wi=async(t,r)=>{const n=t.details,i=await gi(n.src),o=Oe(r,i);return{id:t.id,type:"image",name:"image",display:Vt(t.display),playbackRate:t.playbackRate||1,details:{src:n.src||"",width:n.width||i.width||100,height:n.height||i.height||100,opacity:n.opacity??100,transform:o.transform,border:n.border||"none",borderRadius:n.borderRadius||0,boxShadow:n.boxShadow||Ee,top:o.top||"0px",left:o.left||"0px",borderWidth:n.borderWidth??0,borderColor:n.borderColor||"#000000",blur:n.blur||0,brightness:n.brightness||100,flipX:n.flipX||!1,flipY:n.flipY||!1},metadata:t.metadata||{}}},Ti=async(t,r)=>{const n=t;await Ae([{fontFamily:n.details.fontFamily,url:n.details.fontUrl}]);const i=n.id,o=n.details,c=Nn(o),l=Fn(n.details.text,c),d=Oe(r,{width:c.width,height:l});return{id:i,name:"caption",type:"caption",display:Vt(n.display),details:{...c,text:o.text||"",height:l,fontUrl:o.fontUrl,top:d.top,left:d.left,borderWidth:o.borderWidth||0,borderColor:o.borderColor||"#000000",boxShadow:o.boxShadow||Ee,words:o.words||[]},metadata:{}}},ki=async(t,r)=>{await Ae([{fontFamily:t.details.fontFamily,url:t.details.fontUrl}]);const n=t.id,i=t.details,o=Nn(i),c=Fn(t.details.text,o),l=Oe(r,{width:o.width,height:c});return{id:n,name:"text",type:"text",display:Vt(t.display),details:{...o,text:i.text||"",height:c,fontUrl:i.fontUrl,top:l.top,left:l.left,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",boxShadow:i.boxShadow||Ee},metadata:{}}},Nn=t=>({fontFamily:t.fontFamily||"Arial",fontSize:t.fontSize||"16px",fontWeight:t.fontWeight||"normal",fontStyle:t.fontStyle||"normal",textDecoration:t.textDecoration||"none",textAlign:t.textAlign||"left",lineHeight:t.lineHeight||"normal",letterSpacing:t.letterSpacing||"normal",wordSpacing:t.wordSpacing||"normal",color:t.color||"#ffffff",backgroundColor:t.backgroundColor||"transparent",border:t.border||"none",textShadow:t.textShadow||"none",text:t.text||"",opacity:t.opacity??100,width:t.width||300,wordWrap:t.wordWrap||"normal",wordBreak:t.wordBreak||"normal",WebkitTextStrokeColor:t.WebkitTextStrokeColor||"#ffffff",WebkitTextStrokeWidth:t.WebkitTextStrokeWidth||"0px",top:t.top||"0px",left:t.left||"0px",textTransform:t.textTransform||"none"}),Ai="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let pr=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)r+=Ai[n[t]&63];return r};function Ei(t,r){return t.filter(i=>({...i,items:i.items.filter(o=>!r.includes(o))})).filter(i=>!i.items.length)}function Hn(t=16){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=r.charAt(Math.floor(Math.random()*r.length));let i=pr(t-1);return i=i.replace(/[^a-zA-Z0-9]/g,"").slice(0,t-1),n+i}const dr=t=>Object.keys(t).reduce((r,n)=>{const{display:i,playbackRate:o}=t[n];return Math.max(r,i.to/(o||1))},0);function Oi(t){const r=A.subject.pipe(A.filter(({key:p})=>p.startsWith(A.DESIGN_PREFIX))),n=A.subject.pipe(A.filter(({key:p})=>p.startsWith(A.ADD_PREFIX))),i=A.subject.pipe(A.filter(({key:p})=>p.startsWith(A.LAYER_PREFIX))),o=A.subject.pipe(A.filter(({key:p})=>p.startsWith(A.HISTORY_PREFIX))),c=A.subject.pipe(A.filter(({key:p})=>p.startsWith(A.ACTIVE_PREFIX))),l=A.subject.pipe(A.filter(({key:p})=>p.startsWith(A.EDIT_PREFIX))),d=r.subscribe(async p=>{var h;if(p.key===A.DESIGN_LOAD){const f=(h=p.value)==null?void 0:h.payload,b=f.trackItemIds,v=f.trackItemDetailsMap;console.warn("IMPROVE FONTS LOADING");const _=b.map(async g=>{const y=v[g];return(y.type==="caption"||y.type==="text")&&await Ae([{fontFamily:y.details.fontFamily,url:y.details.fontUrl}]),!0});await Promise.all(_),t.updateState({...f})}}),O=o.subscribe(p=>{if(p.key===A.HISTORY_UNDO)return t.undo();if(p.key===A.HISTORY_REDO)return t.redo()}),R=i.subscribe(p=>{var f,b,v;const h=[];if((f=p.value)!=null&&f.payload.trackItemIds&&(h.push((b=p.value)==null?void 0:b.payload.trackItemIds),t.updateState({activeIds:h})),p.key===A.LAYER_DELETE){const _=(v=p.value)==null?void 0:v.payload.trackItemIds,g=rt(t.getState()),y=_&&_.length?_:g.activeIds,F=g.trackItemIds,E=g.trackItemDetailsMap,x=F.filter(z=>!y.includes(z)),C=Object.fromEntries(Object.entries(E).filter(([z])=>!y.includes(z))),w=Ei(g.tracks,y),T=Object.fromEntries(Object.entries(g.trackItemsMap).filter(([z])=>!y.includes(z))),M=dr(g.trackItemsMap);t.updateState({trackItemIds:x,trackItemDetailsMap:C,activeIds:[],trackItemsMap:T,tracks:w,duration:M},{updateHistory:!0,kind:"remove"})}}),S=n.subscribe(async p=>{var _,g,y,F,E;const h=rt(t.getState());let f=[],b="text";if(p.key===A.ADD_CAPTION){b="caption";const x=(_=p.value)==null?void 0:_.payload,C=[];for(const M of x){const z=Ti(M,{size:{width:1080,height:1920}});C.push(z)}const w=await Promise.all(C),T=[];for(const M of w){const z=M.id;T.push(z);const{details:Rt,...Ft}=M;h.trackItemDetailsMap[z]={type:b,details:Rt},h.trackItemsMap[z]=Ft,h.trackItemIds.push(z)}f=T}if(p.key===A.ADD_TEXT){b="text";const x=await ki((g=p.value)==null?void 0:g.payload,{size:{width:1080,height:1920}}),{details:C,...w}=x;h.trackItemDetailsMap[w.id]={type:b,details:C},h.trackItemsMap[w.id]=w,h.trackItemIds.push(w.id),f=[w.id]}if(p.key===A.ADD_IMAGE){b="image";const x=await wi((y=p.value)==null?void 0:y.payload,{size:{width:1080,height:1920}}),{details:C,...w}=x;h.trackItemDetailsMap[w.id]={type:b,details:C},h.trackItemsMap[w.id]=w,h.trackItemIds.push(w.id),f=[w.id]}if(p.key===A.ADD_AUDIO){b="audio";const x=await Si((F=p.value)==null?void 0:F.payload),{details:C,...w}=x;h.trackItemDetailsMap[w.id]={type:b,details:C},h.trackItemsMap[w.id]=w,h.trackItemIds.push(w.id),f=[w.id]}if(p.key===A.ADD_VIDEO){b="video";const x=await Ii((E=p.value)==null?void 0:E.payload,{size:{width:1080,height:1920}}),{details:C,...w}=x;h.trackItemDetailsMap[w.id]={type:b,details:C},h.trackItemsMap[w.id]=w,h.trackItemIds.push(w.id),f=[w.id]}h.tracks.unshift({id:pr(),accepts:["text","audio","helper","video","image","caption"],type:b,items:f,magnetic:!1,static:!1});const v=dr(h.trackItemsMap);t.updateState({trackItemIds:h.trackItemIds,trackItemDetailsMap:h.trackItemDetailsMap,trackItemsMap:h.trackItemsMap,tracks:h.tracks,duration:v},{updateHistory:!0,kind:"add"})}),U=c.subscribe(async p=>{var h;if(p.key===A.ACTIVE_SPLIT){const f=rt(t.getState()),b=(h=p.value)==null?void 0:h.options.time;if(f.activeIds.length===1){const v=f.activeIds[0],_=f.trackItemsMap[v];if(b>=_.display.to||b<=_.display.from)return;const g=f.trackItemDetailsMap[v],y=Hn(),F={..._,id:y,display:{from:b,to:_.display.to},trim:{from:b,to:_.display.to}};f.trackItemsMap[v].display.to=b,f.trackItemsMap[y]=F,f.trackItemIds.push(y),f.trackItemDetailsMap[y]=g,f.tracks.forEach(E=>{E.items.includes(v)&&E.items.push(y)}),t.updateState({trackItemDetailsMap:f.trackItemDetailsMap,tracks:f.tracks,trackItemIds:f.trackItemIds,trackItemsMap:f.trackItemsMap},{updateHistory:!0,kind:"update"})}return}if(p.key===A.ACTIVE_CLONE){const f=rt(t.getState());if(f.activeIds.length){const b=f.activeIds,v=[],_={activeIds:b,trackItemDetailsMap:{},trackItemsMap:{},tracks:[]};b.forEach(y=>{_.trackItemDetailsMap[y]=f.trackItemDetailsMap[y],_.trackItemsMap[y]=f.trackItemsMap[y],v.push(f.tracks.find(F=>F.items.includes(y)))});const g=new Set;v.filter(y=>g.has(y.id)?!1:(g.add(y),!0)),_.tracks=Array.from(g.keys()),localStorage.setItem("DesignComboTemp",JSON.stringify(_))}}if(p.key===A.ACTIVE_PASTE){const f=localStorage.getItem("DesignComboTemp");if(!f)return;const b=rt(t.getState()),v=JSON.parse(f),_={},g=v.trackItemsMap,y=v.trackItemDetailsMap,F=v.tracks,E=[],x=v.activeIds.map(async C=>{const w=y[C];(w.type==="caption"||w.type==="text")&&await Ae([{fontFamily:w.details.fontFamily,url:w.details.fontUrl}]);const T=Hn();return _[C]=T,b.trackItemsMap[T]={...g[C],id:T},b.trackItemDetailsMap[T]=w,b.trackItemIds.push(T),!0});await Promise.all(x),F.forEach(C=>{const w=C.items.map(M=>_[M]),T={...C,items:w,id:pr()};E.push(T)}),b.tracks=[...b.tracks,...E],t.updateState({trackItemDetailsMap:b.trackItemDetailsMap,tracks:b.tracks,trackItemIds:b.trackItemIds,trackItemsMap:b.trackItemsMap},{updateHistory:!0,kind:"update"})}}),m=l.subscribe(p=>{var h,f;if(p.key===A.EDIT_OBJECT){const b=rt(t.getState()),v=b.trackItemDetailsMap,_=b.trackItemsMap,g=Object.keys((h=p.value)==null?void 0:h.payload);if(!g.length)return;const y=(f=p.value)==null?void 0:f.payload;g.forEach(E=>{y[E].details?v[E].details={...v[E].details,...y[E].details}:y[E].playbackRate&&(_[E].playbackRate=y[E].playbackRate)});const F=dr(_);t.updateState({trackItemDetailsMap:{...v},trackItemsMap:{..._},duration:F},{updateHistory:!0,kind:"update:details"})}});return{unsubscribe:()=>{S.unsubscribe(),U.unsubscribe(),m.unsubscribe(),O.unsubscribe(),R.unsubscribe(),d.unsubscribe()}}}const xi={Date:!0,RegExp:!0,String:!0,Number:!0};function Un(t,r,n={cyclesFix:!0},i=[]){var d,O;let o=[];const c=Array.isArray(t);for(const R in t){const S=t[R],U=c?+R:R;if(!(R in r)){o.push({type:"REMOVE",path:[U],oldValue:t[R]});continue}const m=r[R],p=typeof S=="object"&&typeof m=="object"&&Array.isArray(S)===Array.isArray(m);if(S&&m&&p&&!xi[(O=(d=Object.getPrototypeOf(S))==null?void 0:d.constructor)==null?void 0:O.name]&&(!n.cyclesFix||!i.includes(S))){const h=Un(S,m,n,n.cyclesFix?i.concat([S]):[]);o.push.apply(o,h.map(f=>(f.path.unshift(U),f)))}else S!==m&&!(Number.isNaN(S)&&Number.isNaN(m))&&!(p&&(isNaN(S)?S+""==m+"":+S==+m))&&o.push({path:[U],type:"CHANGE",value:m,oldValue:S})}const l=Array.isArray(r);for(const R in r)R in t||o.push({type:"CREATE",path:[l?+R:R],value:r[R]});return o}var hr=Symbol.for("immer-nothing"),Xt=Symbol.for("immer-draftable"),Q=Symbol.for("immer-state"),Ln=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function G(t,...r){if(process.env.NODE_ENV!=="production"){const n=Ln[t],i=typeof n=="function"?n.apply(null,r):n;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var St=Object.getPrototypeOf;function wt(t){return!!t&&!!t[Q]}function _t(t){var r;return t?Gn(t)||Array.isArray(t)||!!t[Xt]||!!((r=t.constructor)!=null&&r[Xt])||Zt(t)||Qt(t):!1}var Mi=Object.prototype.constructor.toString();function Gn(t){if(!t||typeof t!="object")return!1;const r=St(t);if(r===null)return!0;const n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Mi}function qt(t,r){Tt(t)===0?Reflect.ownKeys(t).forEach(n=>{r(n,t[n],t)}):t.forEach((n,i)=>r(i,n,t))}function Tt(t){const r=t[Q];return r?r.type_:Array.isArray(t)?1:Zt(t)?2:Qt(t)?3:0}function Jt(t,r){return Tt(t)===2?t.has(r):Object.prototype.hasOwnProperty.call(t,r)}function yr(t,r){return Tt(t)===2?t.get(r):t[r]}function Wn(t,r,n){const i=Tt(t);i===2?t.set(r,n):i===3?t.add(n):t[r]=n}function Pi(t,r){return t===r?t!==0||1/t===1/r:t!==t&&r!==r}function Zt(t){return t instanceof Map}function Qt(t){return t instanceof Set}function kt(t){return t.copy_||t.base_}function mr(t,r){if(Zt(t))return new Map(t);if(Qt(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Gn(t);if(r===!0||r==="class_only"&&!n){const i=Object.getOwnPropertyDescriptors(t);delete i[Q];let o=Reflect.ownKeys(i);for(let c=0;c<o.length;c++){const l=o[c],d=i[l];d.writable===!1&&(d.writable=!0,d.configurable=!0),(d.get||d.set)&&(i[l]={configurable:!0,writable:!0,enumerable:d.enumerable,value:t[l]})}return Object.create(St(t),i)}else{const i=St(t);if(i!==null&&n)return{...t};const o=Object.create(i);return Object.assign(o,t)}}function br(t,r=!1){return xe(t)||wt(t)||!_t(t)||(Tt(t)>1&&(t.set=t.add=t.clear=t.delete=Di),Object.freeze(t),r&&Object.entries(t).forEach(([n,i])=>br(i,!0))),t}function Di(){G(2)}function xe(t){return Object.isFrozen(t)}var gr={};function At(t){const r=gr[t];return r||G(0,t),r}function Ci(t,r){gr[t]||(gr[t]=r)}var te;function Bn(){return te}function ji(t,r){return{drafts_:[],parent_:t,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function $n(t,r){r&&(At("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=r)}function _r(t){vr(t),t.drafts_.forEach(Ri),t.drafts_=null}function vr(t){t===te&&(te=t.parent_)}function Kn(t){return te=ji(te,t)}function Ri(t){const r=t[Q];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function Yn(t,r){r.unfinalizedDrafts_=r.drafts_.length;const n=r.drafts_[0];return t!==void 0&&t!==n?(n[Q].modified_&&(_r(r),G(4)),_t(t)&&(t=Me(r,t),r.parent_||Pe(r,t)),r.patches_&&At("Patches").generateReplacementPatches_(n[Q].base_,t,r.patches_,r.inversePatches_)):t=Me(r,n,[]),_r(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),t!==hr?t:void 0}function Me(t,r,n){if(xe(r))return r;const i=r[Q];if(!i)return qt(r,(o,c)=>Vn(t,i,r,o,c,n)),r;if(i.scope_!==t)return r;if(!i.modified_)return Pe(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const o=i.copy_;let c=o,l=!1;i.type_===3&&(c=new Set(o),o.clear(),l=!0),qt(c,(d,O)=>Vn(t,i,o,d,O,n,l)),Pe(t,o,!1),n&&t.patches_&&At("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function Vn(t,r,n,i,o,c,l){if(process.env.NODE_ENV!=="production"&&o===n&&G(5),wt(o)){const d=c&&r&&r.type_!==3&&!Jt(r.assigned_,i)?c.concat(i):void 0,O=Me(t,o,d);if(Wn(n,i,O),wt(O))t.canAutoFreeze_=!1;else return}else l&&n.add(o);if(_t(o)&&!xe(o)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Me(t,o),(!r||!r.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&Pe(t,o)}}function Pe(t,r,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&br(r,n)}function Fi(t,r){const n=Array.isArray(t),i={type_:n?1:0,scope_:r?r.scope_:Bn(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,c=Ir;n&&(o=[i],c=ee);const{revoke:l,proxy:d}=Proxy.revocable(o,c);return i.draft_=d,i.revoke_=l,d}var Ir={get(t,r){if(r===Q)return t;const n=kt(t);if(!Jt(n,r))return zi(t,n,r);const i=n[r];return t.finalized_||!_t(i)?i:i===Sr(t.base_,r)?(Tr(t),t.copy_[r]=kr(i,t)):i},has(t,r){return r in kt(t)},ownKeys(t){return Reflect.ownKeys(kt(t))},set(t,r,n){const i=Xn(kt(t),r);if(i!=null&&i.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const o=Sr(kt(t),r),c=o==null?void 0:o[Q];if(c&&c.base_===n)return t.copy_[r]=n,t.assigned_[r]=!1,!0;if(Pi(n,o)&&(n!==void 0||Jt(t.base_,r)))return!0;Tr(t),wr(t)}return t.copy_[r]===n&&(n!==void 0||r in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[r])||(t.copy_[r]=n,t.assigned_[r]=!0),!0},deleteProperty(t,r){return Sr(t.base_,r)!==void 0||r in t.base_?(t.assigned_[r]=!1,Tr(t),wr(t)):delete t.assigned_[r],t.copy_&&delete t.copy_[r],!0},getOwnPropertyDescriptor(t,r){const n=kt(t),i=Reflect.getOwnPropertyDescriptor(n,r);return i&&{writable:!0,configurable:t.type_!==1||r!=="length",enumerable:i.enumerable,value:n[r]}},defineProperty(){G(11)},getPrototypeOf(t){return St(t.base_)},setPrototypeOf(){G(12)}},ee={};qt(Ir,(t,r)=>{ee[t]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),ee.deleteProperty=function(t,r){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(r))&&G(13),ee.set.call(this,t,r,void 0)},ee.set=function(t,r,n){return process.env.NODE_ENV!=="production"&&r!=="length"&&isNaN(parseInt(r))&&G(14),Ir.set.call(this,t[0],r,n,t[0])};function Sr(t,r){const n=t[Q];return(n?kt(n):t)[r]}function zi(t,r,n){var o;const i=Xn(r,n);return i?"value"in i?i.value:(o=i.get)==null?void 0:o.call(t.draft_):void 0}function Xn(t,r){if(!(r in t))return;let n=St(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,r);if(i)return i;n=St(n)}}function wr(t){t.modified_||(t.modified_=!0,t.parent_&&wr(t.parent_))}function Tr(t){t.copy_||(t.copy_=mr(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Ni=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,n,i)=>{if(typeof r=="function"&&typeof n!="function"){const c=n;n=r;const l=this;return function(O=c,...R){return l.produce(O,S=>n.call(this,S,...R))}}typeof n!="function"&&G(6),i!==void 0&&typeof i!="function"&&G(7);let o;if(_t(r)){const c=Kn(this),l=kr(r,void 0);let d=!0;try{o=n(l),d=!1}finally{d?_r(c):vr(c)}return $n(c,i),Yn(o,c)}else if(!r||typeof r!="object"){if(o=n(r),o===void 0&&(o=r),o===hr&&(o=void 0),this.autoFreeze_&&br(o,!0),i){const c=[],l=[];At("Patches").generateReplacementPatches_(r,o,c,l),i(c,l)}return o}else G(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(l,...d)=>this.produceWithPatches(l,O=>r(O,...d));let i,o;return[this.produce(r,n,(l,d)=>{i=l,o=d}),i,o]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){_t(t)||G(8),wt(t)&&(t=Hi(t));const r=Kn(this),n=kr(t,void 0);return n[Q].isManual_=!0,vr(r),n}finishDraft(t,r){const n=t&&t[Q];(!n||!n.isManual_)&&G(9);const{scope_:i}=n;return $n(i,r),Yn(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,r){let n;for(n=r.length-1;n>=0;n--){const o=r[n];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}n>-1&&(r=r.slice(n+1));const i=At("Patches").applyPatches_;return wt(t)?i(t,r):this.produce(t,o=>i(o,r))}};function kr(t,r){const n=Zt(t)?At("MapSet").proxyMap_(t,r):Qt(t)?At("MapSet").proxySet_(t,r):Fi(t,r);return(r?r.scope_:Bn()).drafts_.push(n),n}function Hi(t){return wt(t)||G(10,t),qn(t)}function qn(t){if(!_t(t)||xe(t))return t;const r=t[Q];let n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=mr(t,r.scope_.immer_.useStrictShallowCopy_)}else n=mr(t,!0);return qt(n,(i,o)=>{Wn(n,i,qn(o))}),r&&(r.finalized_=!1),n}function Jn(){process.env.NODE_ENV!=="production"&&Ln.push('Sets cannot have "replace" patches.',function(m){return"Unsupported patch operation: "+m},function(m){return"Cannot apply patch, path doesn't resolve: "+m},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const r="replace",n="add",i="remove";function o(m,p,h,f){switch(m.type_){case 0:case 2:return l(m,p,h,f);case 1:return c(m,p,h,f);case 3:return d(m,p,h,f)}}function c(m,p,h,f){let{base_:b,assigned_:v}=m,_=m.copy_;_.length<b.length&&([b,_]=[_,b],[h,f]=[f,h]);for(let g=0;g<b.length;g++)if(v[g]&&_[g]!==b[g]){const y=p.concat([g]);h.push({op:r,path:y,value:U(_[g])}),f.push({op:r,path:y,value:U(b[g])})}for(let g=b.length;g<_.length;g++){const y=p.concat([g]);h.push({op:n,path:y,value:U(_[g])})}for(let g=_.length-1;b.length<=g;--g){const y=p.concat([g]);f.push({op:i,path:y})}}function l(m,p,h,f){const{base_:b,copy_:v}=m;qt(m.assigned_,(_,g)=>{const y=yr(b,_),F=yr(v,_),E=g?Jt(b,_)?r:n:i;if(y===F&&E===r)return;const x=p.concat(_);h.push(E===i?{op:E,path:x}:{op:E,path:x,value:F}),f.push(E===n?{op:i,path:x}:E===i?{op:n,path:x,value:U(y)}:{op:r,path:x,value:U(y)})})}function d(m,p,h,f){let{base_:b,copy_:v}=m,_=0;b.forEach(g=>{if(!v.has(g)){const y=p.concat([_]);h.push({op:i,path:y,value:g}),f.unshift({op:n,path:y,value:g})}_++}),_=0,v.forEach(g=>{if(!b.has(g)){const y=p.concat([_]);h.push({op:n,path:y,value:g}),f.unshift({op:i,path:y,value:g})}_++})}function O(m,p,h,f){h.push({op:r,path:[],value:p===hr?void 0:p}),f.push({op:r,path:[],value:m})}function R(m,p){return p.forEach(h=>{const{path:f,op:b}=h;let v=m;for(let F=0;F<f.length-1;F++){const E=Tt(v);let x=f[F];typeof x!="string"&&typeof x!="number"&&(x=""+x),(E===0||E===1)&&(x==="__proto__"||x==="constructor")&&G(19),typeof v=="function"&&x==="prototype"&&G(19),v=yr(v,x),typeof v!="object"&&G(18,f.join("/"))}const _=Tt(v),g=S(h.value),y=f[f.length-1];switch(b){case r:switch(_){case 2:return v.set(y,g);case 3:G(16);default:return v[y]=g}case n:switch(_){case 1:return y==="-"?v.push(g):v.splice(y,0,g);case 2:return v.set(y,g);case 3:return v.add(g);default:return v[y]=g}case i:switch(_){case 1:return v.splice(y,1);case 2:return v.delete(y);case 3:return v.delete(h.value);default:return delete v[y]}default:G(17,b)}}),m}function S(m){if(!_t(m))return m;if(Array.isArray(m))return m.map(S);if(Zt(m))return new Map(Array.from(m.entries()).map(([h,f])=>[h,S(f)]));if(Qt(m))return new Set(Array.from(m).map(S));const p=Object.create(St(m));for(const h in m)p[h]=S(m[h]);return Jt(m,Xt)&&(p[Xt]=m[Xt]),p}function U(m){return wt(m)?S(m):m}Ci("Patches",{applyPatches_:R,generatePatches_:o,generateReplacementPatches_:O})}var tt=new Ni,Ui=tt.produce;tt.produceWithPatches.bind(tt),tt.setAutoFreeze.bind(tt),tt.setUseStrictShallowCopy.bind(tt);var Li=tt.applyPatches.bind(tt);tt.createDraft.bind(tt),tt.finishDraft.bind(tt);var Gi=1/0,Wi=9007199254740991,Bi="[object Arguments]",$i="[object Function]",Ki="[object GeneratorFunction]",Yi="[object Symbol]",Vi=typeof et=="object"&&et&&et.Object===Object&&et,Xi=typeof self=="object"&&self&&self.Object===Object&&self,qi=Vi||Xi||Function("return this")();function Ji(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}function Zi(t,r){for(var n=-1,i=t?t.length:0,o=Array(i);++n<i;)o[n]=r(t[n],n,t);return o}function Qi(t,r){for(var n=-1,i=r.length,o=t.length;++n<i;)t[o+n]=r[n];return t}var Ar=Object.prototype,ta=Ar.hasOwnProperty,Er=Ar.toString,Zn=qi.Symbol,ea=Ar.propertyIsEnumerable,Qn=Zn?Zn.isConcatSpreadable:void 0,ti=Math.max;function ra(t,r,n,i,o){var c=-1,l=t.length;for(n||(n=sa),o||(o=[]);++c<l;){var d=t[c];n(d)?Qi(o,d):o[o.length]=d}return o}function na(t,r){return t=Object(t),ia(t,r,function(n,i){return i in t})}function ia(t,r,n){for(var i=-1,o=r.length,c={};++i<o;){var l=r[i],d=t[l];n(d,l)&&(c[l]=d)}return c}function aa(t,r){return r=ti(r===void 0?t.length-1:r,0),function(){for(var n=arguments,i=-1,o=ti(n.length-r,0),c=Array(o);++i<o;)c[i]=n[r+i];i=-1;for(var l=Array(r+1);++i<r;)l[i]=n[i];return l[r]=c,Ji(t,this,l)}}function sa(t){return ua(t)||ca(t)||!!(Qn&&t&&t[Qn])}function oa(t){if(typeof t=="string"||ya(t))return t;var r=t+"";return r=="0"&&1/t==-Gi?"-0":r}function ca(t){return la(t)&&ta.call(t,"callee")&&(!ea.call(t,"callee")||Er.call(t)==Bi)}var ua=Array.isArray;function fa(t){return t!=null&&da(t.length)&&!pa(t)}function la(t){return ei(t)&&fa(t)}function pa(t){var r=ha(t)?Er.call(t):"";return r==$i||r==Ki}function da(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Wi}function ha(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function ei(t){return!!t&&typeof t=="object"}function ya(t){return typeof t=="symbol"||ei(t)&&Er.call(t)==Yi}var ma=aa(function(t,r){return t==null?{}:na(t,Zi(ra(r),oa))}),ba=ma;const ri=lr(ba),ga={tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{unit:1,zoom:1,segments:1},duration:0,activeIds:[],trackItemDetailsMap:{}},ni=["tracks","trackItemsMap","trackItemDetailsMap","transitionIds","transitionsMap","trackItemIds"];class _a{constructor(r){jt(this,"stateSubject");jt(this,"stateHistorySubject");jt(this,"prevState");jt(this,"undos",[]);jt(this,"redos",[]);jt(this,"listener");const n=r||ga;this.stateSubject=new Rn(n),this.stateHistorySubject=new Rn({handleRedo:!1,handleUndo:!1}),this.prevState=n,this.initListeners()}initListeners(){Oi(this)}destroyListeners(){this.listener&&this.listener.unsubscribe()}purge(){this.destroyListeners()}updateHistory(r,n){const i=ri(r,ni),o=ri(this.getState(),ni),c=Un(o,i);c.length&&(this.undos.push({undos:c,type:n}),this.redos=[])}getStateHistory(){return this.stateHistorySubject.getValue()}subscribeHistory(r){return this.stateHistorySubject.subscribe(r)}getState(){return this.stateSubject.getValue()}subscribe(r){return this.stateSubject.subscribe(r)}updateState(r,n={updateHistory:!1}){const i=this.getState(),o={...i,...r};it(i,o)||(n.updateHistory&&this.updateHistory(o,n.kind),this.prevState=i,this.stateSubject.next(o))}subscribeToScale(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.scale,this.prevState.scale)||r({scale:n.scale})})}subscribeToUpdateTrackItem(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemsMap,this.prevState.trackItemsMap)||r({trackItemsMap:n.trackItemsMap})})}subscribeToUpdateItemDetails(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemDetailsMap,this.prevState.trackItemDetailsMap)||r({trackItemDetailsMap:n.trackItemDetailsMap})})}subscribeToDuration(r){return this.stateSubject.asObservable().subscribe(n=>{n.duration!==this.prevState.duration&&r({duration:n.duration})})}subscribeToHistory(r){return this.stateHistorySubject.asObservable().subscribe(n=>{if(n.handleRedo){const i=this.undos[this.undos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}if(n.handleUndo){const i=this.redos[this.redos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}})}subscribeToAddOrRemoveItems(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemIds,this.prevState.trackItemIds)||r({trackItemIds:n.trackItemIds})})}subscribeToActiveIds(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.activeIds,this.prevState.activeIds)||r({activeIds:n.activeIds})})}subscribeToTracks(r){return this.stateSubject.asObservable().subscribe(n=>{(!it(n.tracks,this.prevState.tracks)||!it(n.trackItemIds,this.prevState.trackItemIds)||!it(n.trackItemsMap,this.prevState.trackItemsMap)||!it(n.transitionIds,this.prevState.transitionIds)||!it(n.transitionsMap,this.prevState.transitionsMap))&&r({tracks:n.tracks,trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,transitionIds:n.transitionIds,transitionsMap:n.transitionsMap,trackItemDetailsMap:n.trackItemDetailsMap})})}undo(){const r=this.undos.pop(),n=r==null?void 0:r.undos,i=r==null?void 0:r.type;if(!n||!i)return;Jn();const{trackItemDetailsMap:o,trackItemIds:c,tracks:l,transitionIds:d,transitionsMap:O,trackItemsMap:R}=this.getState(),S=rt({trackItemDetailsMap:o,trackItemIds:c,tracks:l,transitionIds:d,transitionsMap:O,trackItemsMap:R}),U=[],m=[],p=[],h=[],f=[],b=[];n.forEach(T=>{let M;const z=T.path.slice(1);T.type==="CREATE"?M={path:z,op:"remove",value:T.value}:T.type==="CHANGE"?M={path:z,op:"replace",value:T.oldValue}:M={path:z,op:"add",value:T.oldValue},T.path.includes("trackItemIds")?p.push(M):T.path.includes("transitionIds")?m.push(M):T.path.includes("trackItemsMap")?f.push(M):T.path.includes("transitionsMap")?h.push(M):T.path.includes("tracks")?U.push(M):T.path.includes("trackItemDetailsMap")&&b.push(M)});const v=this.applyPatch(S.tracks,U),_=this.applyPatch(S.transitionIds,m),g=this.applyPatch(S.trackItemIds,p),y=this.applyPatch(S.transitionsMap,h),F=this.applyPatch(S.trackItemsMap,f),E=this.applyPatch(S.trackItemDetailsMap,b),x=rt({tracks:v,transitionIds:_,trackItemIds:g,transitionsMap:y,trackItemsMap:F,trackItemDetailsMap:E}),C=rt(this.getState()),w={...C,...x};this.prevState=C,this.redos.push({redos:n,type:i}),this.stateSubject.next(w),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!0})}applyPatch(r,n){return n.reverse().reduce((i,o)=>Ui(i,c=>{Li(c,[o])}),r)}redo(){const r=this.redos.pop(),n=r==null?void 0:r.redos,i=r==null?void 0:r.type;if(!n||!i)return;Jn();const{trackItemDetailsMap:o,trackItemIds:c,tracks:l,transitionIds:d,transitionsMap:O,trackItemsMap:R}=this.getState(),S=rt({trackItemDetailsMap:o,trackItemIds:c,tracks:l,transitionIds:d,transitionsMap:O,trackItemsMap:R}),U=[],m=[],p=[],h=[],f=[],b=[];n.forEach(T=>{let M;const z=T.path.slice(1);T.type==="CREATE"?M={path:z,op:"add",value:T.value}:T.type==="CHANGE"?M={path:z,op:"replace",value:T.value}:M={path:z,op:"remove",value:T.oldValue},T.path.includes("trackItemIds")?p.push(M):T.path.includes("transitionIds")?m.push(M):T.path.includes("trackItemsMap")?f.push(M):T.path.includes("transitionsMap")?h.push(M):T.path.includes("trackItemDetailsMap")?b.push(M):U.push(M)});const v=this.applyPatch(S.tracks,U),_=this.applyPatch(S.transitionIds,m),g=this.applyPatch(S.trackItemIds,p),y=this.applyPatch(S.transitionsMap,h),F=this.applyPatch(S.trackItemsMap,f),E=this.applyPatch(S.trackItemDetailsMap,b),x=rt({tracks:v,transitionIds:_,trackItemIds:g,transitionsMap:y,trackItemsMap:F,trackItemDetailsMap:E}),C=rt(this.getState()),w={...C,...x};this.prevState=C,this.undos.push({undos:n,type:i}),this.stateSubject.next(w),this.stateHistorySubject.next({handleRedo:!0,handleUndo:!1})}}return _a});
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function cr(t,r){if(t){var n=t.indexOf(r);0<=n&&t.splice(n,1)}}var Ie=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,n,i,o,c;if(!this.closed){this.closed=!0;var f=this._parentage;if(f)if(this._parentage=null,Array.isArray(f))try{for(var d=ir(f),P=d.next();!P.done;P=d.next()){var F=P.value;F.remove(this)}}catch(l){r={error:l}}finally{try{P&&!P.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}else f.remove(this);var T=this.initialTeardown;if(ht(T))try{T()}catch(l){c=l instanceof or?l.errors:[l]}var U=this._finalizers;if(U){this._finalizers=null;try{for(var y=ir(U),p=y.next();!p.done;p=y.next()){var h=p.value;try{An(h)}catch(l){c=c??[],l instanceof or?c=sr(sr([],ar(c)),ar(l.errors)):c.push(l)}}}catch(l){i={error:l}}finally{try{p&&!p.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}}if(c)throw new or(c)}},t.prototype.add=function(r){var n;if(r&&r!==this)if(this.closed)An(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(r)}},t.prototype._hasParent=function(r){var n=this._parentage;return n===r||Array.isArray(n)&&n.includes(r)},t.prototype._addParent=function(r){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(r),n):n?[n,r]:r},t.prototype._removeParent=function(r){var n=this._parentage;n===r?this._parentage=null:Array.isArray(n)&&cr(n,r)},t.prototype.remove=function(r){var n=this._finalizers;n&&cr(n,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),Tn=Ie.EMPTY;function kn(t){return t instanceof Ie||t&&"closed"in t&&ht(t.remove)&&ht(t.add)&&ht(t.unsubscribe)}function An(t){ht(t)?t():t.unsubscribe()}var En={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},On={setTimeout:function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return setTimeout.apply(void 0,sr([t,r],ar(n)))},clearTimeout:function(t){var r=On.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(t)},delegate:void 0};function li(t){On.setTimeout(function(){throw t})}function xn(){}function Se(t){t()}var Mn=function(t){ut(r,t);function r(n){var i=t.call(this)||this;return i.isStopped=!1,n?(i.destination=n,kn(n)&&n.add(i)):i.destination=hi,i}return r.create=function(n,i,o){return new lr(n,i,o)},r.prototype.next=function(n){this.isStopped||this._next(n)},r.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(n){this.destination.next(n)},r.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(Ie),fi=Function.prototype.bind;function ur(t,r){return fi.call(t,r)}var pi=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var n=this.partialObserver;if(n.next)try{n.next(r)}catch(i){we(i)}},t.prototype.error=function(r){var n=this.partialObserver;if(n.error)try{n.error(r)}catch(i){we(i)}else we(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(n){we(n)}},t}(),lr=function(t){ut(r,t);function r(n,i,o){var c=t.call(this)||this,f;if(ht(n)||!n)f={next:n??void 0,error:i??void 0,complete:o??void 0};else{var d;c&&En.useDeprecatedNextContext?(d=Object.create(n),d.unsubscribe=function(){return c.unsubscribe()},f={next:n.next&&ur(n.next,d),error:n.error&&ur(n.error,d),complete:n.complete&&ur(n.complete,d)}):f=n}return c.destination=new pi(f),c}return r}(Mn);function we(t){li(t)}function di(t){throw t}var hi={closed:!0,next:xn,error:di,complete:xn},yi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function mi(t){return t}function bi(t){return t.length===0?mi:t.length===1?t[0]:function(n){return t.reduce(function(i,o){return o(i)},n)}}var Pn=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var n=new t;return n.source=this,n.operator=r,n},t.prototype.subscribe=function(r,n,i){var o=this,c=_i(r)?r:new lr(r,n,i);return Se(function(){var f=o,d=f.operator,P=f.source;c.add(d?d.call(c,P):P?o._subscribe(c):o._trySubscribe(c))}),c},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(n){r.error(n)}},t.prototype.forEach=function(r,n){var i=this;return n=Dn(n),new n(function(o,c){var f=new lr({next:function(d){try{r(d)}catch(P){c(P),f.unsubscribe()}},error:c,complete:o});i.subscribe(f)})},t.prototype._subscribe=function(r){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(r)},t.prototype[yi]=function(){return this},t.prototype.pipe=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return bi(r)(this)},t.prototype.toPromise=function(r){var n=this;return r=Dn(r),new r(function(i,o){var c;n.subscribe(function(f){return c=f},function(f){return o(f)},function(){return i(c)})})},t.create=function(r){return new t(r)},t}();function Dn(t){var r;return(r=t??En.Promise)!==null&&r!==void 0?r:Promise}function gi(t){return t&&ht(t.next)&&ht(t.error)&&ht(t.complete)}function _i(t){return t&&t instanceof Mn||gi(t)&&kn(t)}var vi=wn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Cn=function(t){ut(r,t);function r(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return r.prototype.lift=function(n){var i=new jn(this,this);return i.operator=n,i},r.prototype._throwIfClosed=function(){if(this.closed)throw new vi},r.prototype.next=function(n){var i=this;Se(function(){var o,c;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var f=ir(i.currentObservers),d=f.next();!d.done;d=f.next()){var P=d.value;P.next(n)}}catch(F){o={error:F}}finally{try{d&&!d.done&&(c=f.return)&&c.call(f)}finally{if(o)throw o.error}}}})},r.prototype.error=function(n){var i=this;Se(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=n;for(var o=i.observers;o.length;)o.shift().error(n)}})},r.prototype.complete=function(){var n=this;Se(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var i=n.observers;i.length;)i.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},r.prototype._innerSubscribe=function(n){var i=this,o=this,c=o.hasError,f=o.isStopped,d=o.observers;return c||f?Tn:(this.currentObservers=null,d.push(n),new Ie(function(){i.currentObservers=null,cr(d,n)}))},r.prototype._checkFinalizedStatuses=function(n){var i=this,o=i.hasError,c=i.thrownError,f=i.isStopped;o?n.error(c):f&&n.complete()},r.prototype.asObservable=function(){var n=new Pn;return n.source=this,n},r.create=function(n,i){return new jn(n,i)},r}(Pn),jn=function(t){ut(r,t);function r(n,i){var o=t.call(this)||this;return o.destination=n,o.source=i,o}return r.prototype.next=function(n){var i,o;(o=(i=this.destination)===null||i===void 0?void 0:i.next)===null||o===void 0||o.call(i,n)},r.prototype.error=function(n){var i,o;(o=(i=this.destination)===null||i===void 0?void 0:i.error)===null||o===void 0||o.call(i,n)},r.prototype.complete=function(){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||i===void 0||i.call(n)},r.prototype._subscribe=function(n){var i,o;return(o=(i=this.source)===null||i===void 0?void 0:i.subscribe(n))!==null&&o!==void 0?o:Tn},r}(Cn),Rn=function(t){ut(r,t);function r(n){var i=t.call(this)||this;return i._value=n,i}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var i=t.prototype._subscribe.call(this,n);return!i.closed&&n.next(this._value),i},r.prototype.getValue=function(){var n=this,i=n.hasError,o=n.thrownError,c=n._value;if(i)throw o;return this._throwIfClosed(),c},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(Cn),et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Te={exports:{}};Te.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",o=1,c=2,f=9007199254740991,d="[object Arguments]",P="[object Array]",F="[object AsyncFunction]",T="[object Boolean]",U="[object Date]",y="[object Error]",p="[object Function]",h="[object GeneratorFunction]",l="[object Map]",b="[object Number]",v="[object Null]",m="[object Object]",g="[object Promise]",_="[object Proxy]",A="[object RegExp]",w="[object Set]",k="[object String]",M="[object Symbol]",S="[object Undefined]",E="[object WeakMap]",D="[object ArrayBuffer]",z="[object DataView]",Rt="[object Float32Array]",Ft="[object Float64Array]",De="[object Int8Array]",Or="[object Int16Array]",xr="[object Int32Array]",Mr="[object Uint8Array]",Pr="[object Uint8ClampedArray]",N="[object Uint16Array]",Dr="[object Uint32Array]",Cr=/[\\^$.*+?()[\]{}|]/g,at=/^\[object .+?Constructor\]$/,Ce=/^(?:0|[1-9]\d*)$/,H={};H[Rt]=H[Ft]=H[De]=H[Or]=H[xr]=H[Mr]=H[Pr]=H[N]=H[Dr]=!0,H[d]=H[P]=H[D]=H[T]=H[z]=H[U]=H[y]=H[p]=H[l]=H[b]=H[m]=H[A]=H[w]=H[k]=H[E]=!1;var je=typeof et=="object"&&et&&et.Object===Object&&et,jr=typeof self=="object"&&self&&self.Object===Object&&self,st=je||jr||Function("return this")(),Re=r&&!r.nodeType&&r,Fe=Re&&!0&&t&&!t.nodeType&&t,re=Fe&&Fe.exports===Re,ne=re&&je.process,ze=function(){try{return ne&&ne.binding&&ne.binding("util")}catch{}}(),ie=ze&&ze.isTypedArray;function Ne(e,a){for(var s=-1,u=e==null?0:e.length,O=0,I=[];++s<u;){var j=e[s];a(j,s,e)&&(I[O++]=j)}return I}function ae(e,a){for(var s=-1,u=a.length,O=e.length;++s<u;)e[O+s]=a[s];return e}function He(e,a){for(var s=-1,u=e==null?0:e.length;++s<u;)if(a(e[s],s,e))return!0;return!1}function Rr(e,a){for(var s=-1,u=Array(e);++s<e;)u[s]=a(s);return u}function Fr(e){return function(a){return e(a)}}function zt(e,a){return e.has(a)}function se(e,a){return e==null?void 0:e[a]}function Ue(e){var a=-1,s=Array(e.size);return e.forEach(function(u,O){s[++a]=[O,u]}),s}function Le(e,a){return function(s){return e(a(s))}}function lt(e){var a=-1,s=Array(e.size);return e.forEach(function(u){s[++a]=u}),s}var Nt=Array.prototype,zr=Function.prototype,Et=Object.prototype,Ht=st["__core-js_shared__"],oe=zr.toString,nt=Et.hasOwnProperty,Ge=function(){var e=/[^.]+$/.exec(Ht&&Ht.keys&&Ht.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),We=Et.toString,Nr=RegExp("^"+oe.call(nt).replace(Cr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=re?st.Buffer:void 0,Ut=st.Symbol,Be=st.Uint8Array,Lt=Et.propertyIsEnumerable,Ot=Nt.splice,ot=Ut?Ut.toStringTag:void 0,Gt=Object.getOwnPropertySymbols,ue=ce?ce.isBuffer:void 0,xt=Le(Object.keys,Object),le=mt(st,"DataView"),Mt=mt(st,"Map"),fe=mt(st,"Promise"),pe=mt(st,"Set"),de=mt(st,"WeakMap"),vt=mt(Object,"create"),$e=q(le),yt=q(Mt),Hr=q(fe),Ur=q(pe),Lr=q(de),Ke=Ut?Ut.prototype:void 0,he=Ke?Ke.valueOf:void 0;function B(e){var a=-1,s=e==null?0:e.length;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Gr(){this.__data__=vt?vt(null):{},this.size=0}function Wr(e){var a=this.has(e)&&delete this.__data__[e];return this.size-=a?1:0,a}function Br(e){var a=this.__data__;if(vt){var s=a[e];return s===i?void 0:s}return nt.call(a,e)?a[e]:void 0}function $r(e){var a=this.__data__;return vt?a[e]!==void 0:nt.call(a,e)}function Kr(e,a){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=vt&&a===void 0?i:a,this}B.prototype.clear=Gr,B.prototype.delete=Wr,B.prototype.get=Br,B.prototype.has=$r,B.prototype.set=Kr;function K(e){var a=-1,s=e==null?0:e.length;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Yr(){this.__data__=[],this.size=0}function Vr(e){var a=this.__data__,s=$t(a,e);if(s<0)return!1;var u=a.length-1;return s==u?a.pop():Ot.call(a,s,1),--this.size,!0}function Xr(e){var a=this.__data__,s=$t(a,e);return s<0?void 0:a[s][1]}function qr(e){return $t(this.__data__,e)>-1}function Jr(e,a){var s=this.__data__,u=$t(s,e);return u<0?(++this.size,s.push([e,a])):s[u][1]=a,this}K.prototype.clear=Yr,K.prototype.delete=Vr,K.prototype.get=Xr,K.prototype.has=qr,K.prototype.set=Jr;function J(e){var a=-1,s=e==null?0:e.length;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Zr(){this.size=0,this.__data__={hash:new B,map:new(Mt||K),string:new B}}function Qr(e){var a=ct(this,e).delete(e);return this.size-=a?1:0,a}function tn(e){return ct(this,e).get(e)}function en(e){return ct(this,e).has(e)}function rn(e,a){var s=ct(this,e),u=s.size;return s.set(e,a),this.size+=s.size==u?0:1,this}J.prototype.clear=Zr,J.prototype.delete=Qr,J.prototype.get=tn,J.prototype.has=en,J.prototype.set=rn;function Wt(e){var a=-1,s=e==null?0:e.length;for(this.__data__=new J;++a<s;)this.add(e[a])}function Ye(e){return this.__data__.set(e,i),this}function Bt(e){return this.__data__.has(e)}Wt.prototype.add=Wt.prototype.push=Ye,Wt.prototype.has=Bt;function ft(e){var a=this.__data__=new K(e);this.size=a.size}function ye(){this.__data__=new K,this.size=0}function nn(e){var a=this.__data__,s=a.delete(e);return this.size=a.size,s}function an(e){return this.__data__.get(e)}function sn(e){return this.__data__.has(e)}function on(e,a){var s=this.__data__;if(s instanceof K){var u=s.__data__;if(!Mt||u.length<n-1)return u.push([e,a]),this.size=++s.size,this;s=this.__data__=new J(u)}return s.set(e,a),this.size=s.size,this}ft.prototype.clear=ye,ft.prototype.delete=nn,ft.prototype.get=an,ft.prototype.has=sn,ft.prototype.set=on;function cn(e,a){var s=Kt(e),u=!s&&Ze(e),O=!s&&!u&&Yt(e),I=!s&&!u&&!O&&er(e),j=s||u||O||I,C=j?Rr(e.length,String):[],L=C.length;for(var R in e)nt.call(e,R)&&!(j&&(R=="length"||O&&(R=="offset"||R=="parent")||I&&(R=="buffer"||R=="byteLength"||R=="byteOffset")||mn(R,L)))&&C.push(R);return C}function $t(e,a){for(var s=e.length;s--;)if(Je(e[s][0],a))return s;return-1}function me(e,a,s){var u=a(e);return Kt(e)?u:ae(u,s(e))}function Pt(e){return e==null?e===void 0?S:v:ot&&ot in Object(e)?bt(e):qe(e)}function Ve(e){return dt(e)&&Pt(e)==d}function Xe(e,a,s,u,O){return e===a?!0:e==null||a==null||!dt(e)&&!dt(a)?e!==e&&a!==a:un(e,a,s,u,Xe,O)}function un(e,a,s,u,O,I){var j=Kt(e),C=Kt(a),L=j?P:pt(e),R=C?P:pt(a);L=L==d?m:L,R=R==d?m:R;var Y=L==m,Z=R==m,W=L==R;if(W&&Yt(e)){if(!Yt(a))return!1;j=!0,Y=!1}if(W&&!Y)return I||(I=new ft),j||er(e)?be(e,a,s,u,O,I):dn(e,a,L,s,u,O,I);if(!(s&o)){var V=Y&&nt.call(e,"__wrapped__"),$=Z&&nt.call(a,"__wrapped__");if(V||$){var It=V?e.value():e,gt=$?a.value():a;return I||(I=new ft),O(It,gt,s,u,I)}}return W?(I||(I=new ft),hn(e,a,s,u,O,I)):!1}function ln(e){if(!tr(e)||gn(e))return!1;var a=Qe(e)?Nr:at;return a.test(q(e))}function fn(e){return dt(e)&&_e(e.length)&&!!H[Pt(e)]}function pn(e){if(!_n(e))return xt(e);var a=[];for(var s in Object(e))nt.call(e,s)&&s!="constructor"&&a.push(s);return a}function be(e,a,s,u,O,I){var j=s&o,C=e.length,L=a.length;if(C!=L&&!(j&&L>C))return!1;var R=I.get(e);if(R&&I.get(a))return R==a;var Y=-1,Z=!0,W=s&c?new Wt:void 0;for(I.set(e,a),I.set(a,e);++Y<C;){var V=e[Y],$=a[Y];if(u)var It=j?u($,V,Y,a,e,I):u(V,$,Y,e,a,I);if(It!==void 0){if(It)continue;Z=!1;break}if(W){if(!He(a,function(gt,Ct){if(!zt(W,Ct)&&(V===gt||O(V,gt,s,u,I)))return W.push(Ct)})){Z=!1;break}}else if(!(V===$||O(V,$,s,u,I))){Z=!1;break}}return I.delete(e),I.delete(a),Z}function dn(e,a,s,u,O,I,j){switch(s){case z:if(e.byteLength!=a.byteLength||e.byteOffset!=a.byteOffset)return!1;e=e.buffer,a=a.buffer;case D:return!(e.byteLength!=a.byteLength||!I(new Be(e),new Be(a)));case T:case U:case b:return Je(+e,+a);case y:return e.name==a.name&&e.message==a.message;case A:case k:return e==a+"";case l:var C=Ue;case w:var L=u&o;if(C||(C=lt),e.size!=a.size&&!L)return!1;var R=j.get(e);if(R)return R==a;u|=c,j.set(e,a);var Y=be(C(e),C(a),u,O,I,j);return j.delete(e),Y;case M:if(he)return he.call(e)==he.call(a)}return!1}function hn(e,a,s,u,O,I){var j=s&o,C=Dt(e),L=C.length,R=Dt(a),Y=R.length;if(L!=Y&&!j)return!1;for(var Z=L;Z--;){var W=C[Z];if(!(j?W in a:nt.call(a,W)))return!1}var V=I.get(e);if(V&&I.get(a))return V==a;var $=!0;I.set(e,a),I.set(a,e);for(var It=j;++Z<L;){W=C[Z];var gt=e[W],Ct=a[W];if(u)var ui=j?u(Ct,gt,W,a,e,I):u(gt,Ct,W,e,a,I);if(!(ui===void 0?gt===Ct||O(gt,Ct,s,u,I):ui)){$=!1;break}It||(It=W=="constructor")}if($&&!It){var rr=e.constructor,nr=a.constructor;rr!=nr&&"constructor"in e&&"constructor"in a&&!(typeof rr=="function"&&rr instanceof rr&&typeof nr=="function"&&nr instanceof nr)&&($=!1)}return I.delete(e),I.delete(a),$}function Dt(e){return me(e,ve,yn)}function ct(e,a){var s=e.__data__;return bn(a)?s[typeof a=="string"?"string":"hash"]:s.map}function mt(e,a){var s=se(e,a);return ln(s)?s:void 0}function bt(e){var a=nt.call(e,ot),s=e[ot];try{e[ot]=void 0;var u=!0}catch{}var O=We.call(e);return u&&(a?e[ot]=s:delete e[ot]),O}var yn=Gt?function(e){return e==null?[]:(e=Object(e),Ne(Gt(e),function(a){return Lt.call(e,a)}))}:In,pt=Pt;(le&&pt(new le(new ArrayBuffer(1)))!=z||Mt&&pt(new Mt)!=l||fe&&pt(fe.resolve())!=g||pe&&pt(new pe)!=w||de&&pt(new de)!=E)&&(pt=function(e){var a=Pt(e),s=a==m?e.constructor:void 0,u=s?q(s):"";if(u)switch(u){case $e:return z;case yt:return l;case Hr:return g;case Ur:return w;case Lr:return E}return a});function mn(e,a){return a=a??f,!!a&&(typeof e=="number"||Ce.test(e))&&e>-1&&e%1==0&&e<a}function bn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function gn(e){return!!Ge&&Ge in e}function _n(e){var a=e&&e.constructor,s=typeof a=="function"&&a.prototype||Et;return e===s}function qe(e){return We.call(e)}function q(e){if(e!=null){try{return oe.call(e)}catch{}try{return e+""}catch{}}return""}function Je(e,a){return e===a||e!==e&&a!==a}var Ze=Ve(function(){return arguments}())?Ve:function(e){return dt(e)&&nt.call(e,"callee")&&!Lt.call(e,"callee")},Kt=Array.isArray;function ge(e){return e!=null&&_e(e.length)&&!Qe(e)}var Yt=ue||Sn;function vn(e,a){return Xe(e,a)}function Qe(e){if(!tr(e))return!1;var a=Pt(e);return a==p||a==h||a==F||a==_}function _e(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=f}function tr(e){var a=typeof e;return e!=null&&(a=="object"||a=="function")}function dt(e){return e!=null&&typeof e=="object"}var er=ie?Fr(ie):fn;function ve(e){return ge(e)?cn(e):pn(e)}function In(){return[]}function Sn(){return!1}t.exports=vn}(Te,Te.exports);var Ii=Te.exports;const it=fr(Ii);var ke={exports:{}};ke.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",o=9007199254740991,c="[object Arguments]",f="[object Array]",d="[object Boolean]",P="[object Date]",F="[object Error]",T="[object Function]",U="[object GeneratorFunction]",y="[object Map]",p="[object Number]",h="[object Object]",l="[object Promise]",b="[object RegExp]",v="[object Set]",m="[object String]",g="[object Symbol]",_="[object WeakMap]",A="[object ArrayBuffer]",w="[object DataView]",k="[object Float32Array]",M="[object Float64Array]",S="[object Int8Array]",E="[object Int16Array]",D="[object Int32Array]",z="[object Uint8Array]",Rt="[object Uint8ClampedArray]",Ft="[object Uint16Array]",De="[object Uint32Array]",Or=/[\\^$.*+?()[\]{}|]/g,xr=/\w*$/,Mr=/^\[object .+?Constructor\]$/,Pr=/^(?:0|[1-9]\d*)$/,N={};N[c]=N[f]=N[A]=N[w]=N[d]=N[P]=N[k]=N[M]=N[S]=N[E]=N[D]=N[y]=N[p]=N[h]=N[b]=N[v]=N[m]=N[g]=N[z]=N[Rt]=N[Ft]=N[De]=!0,N[F]=N[T]=N[_]=!1;var Dr=typeof et=="object"&&et&&et.Object===Object&&et,Cr=typeof self=="object"&&self&&self.Object===Object&&self,at=Dr||Cr||Function("return this")(),Ce=r&&!r.nodeType&&r,H=Ce&&!0&&t&&!t.nodeType&&t,je=H&&H.exports===Ce;function jr(e,a){return e.set(a[0],a[1]),e}function st(e,a){return e.add(a),e}function Re(e,a){for(var s=-1,u=e?e.length:0;++s<u&&a(e[s],s,e)!==!1;);return e}function Fe(e,a){for(var s=-1,u=a.length,O=e.length;++s<u;)e[O+s]=a[s];return e}function re(e,a,s,u){for(var O=-1,I=e?e.length:0;++O<I;)s=a(s,e[O],O,e);return s}function ne(e,a){for(var s=-1,u=Array(e);++s<e;)u[s]=a(s);return u}function ze(e,a){return e==null?void 0:e[a]}function ie(e){var a=!1;if(e!=null&&typeof e.toString!="function")try{a=!!(e+"")}catch{}return a}function Ne(e){var a=-1,s=Array(e.size);return e.forEach(function(u,O){s[++a]=[O,u]}),s}function ae(e,a){return function(s){return e(a(s))}}function He(e){var a=-1,s=Array(e.size);return e.forEach(function(u){s[++a]=u}),s}var Rr=Array.prototype,Fr=Function.prototype,zt=Object.prototype,se=at["__core-js_shared__"],Ue=function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Le=Fr.toString,lt=zt.hasOwnProperty,Nt=zt.toString,zr=RegExp("^"+Le.call(lt).replace(Or,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Et=je?at.Buffer:void 0,Ht=at.Symbol,oe=at.Uint8Array,nt=ae(Object.getPrototypeOf,Object),Ge=Object.create,We=zt.propertyIsEnumerable,Nr=Rr.splice,ce=Object.getOwnPropertySymbols,Ut=Et?Et.isBuffer:void 0,Be=ae(Object.keys,Object),Lt=ct(at,"DataView"),Ot=ct(at,"Map"),ot=ct(at,"Promise"),Gt=ct(at,"Set"),ue=ct(at,"WeakMap"),xt=ct(Object,"create"),le=q(Lt),Mt=q(Ot),fe=q(ot),pe=q(Gt),de=q(ue),vt=Ht?Ht.prototype:void 0,$e=vt?vt.valueOf:void 0;function yt(e){var a=-1,s=e?e.length:0;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Hr(){this.__data__=xt?xt(null):{}}function Ur(e){return this.has(e)&&delete this.__data__[e]}function Lr(e){var a=this.__data__;if(xt){var s=a[e];return s===i?void 0:s}return lt.call(a,e)?a[e]:void 0}function Ke(e){var a=this.__data__;return xt?a[e]!==void 0:lt.call(a,e)}function he(e,a){var s=this.__data__;return s[e]=xt&&a===void 0?i:a,this}yt.prototype.clear=Hr,yt.prototype.delete=Ur,yt.prototype.get=Lr,yt.prototype.has=Ke,yt.prototype.set=he;function B(e){var a=-1,s=e?e.length:0;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Gr(){this.__data__=[]}function Wr(e){var a=this.__data__,s=Bt(a,e);if(s<0)return!1;var u=a.length-1;return s==u?a.pop():Nr.call(a,s,1),!0}function Br(e){var a=this.__data__,s=Bt(a,e);return s<0?void 0:a[s][1]}function $r(e){return Bt(this.__data__,e)>-1}function Kr(e,a){var s=this.__data__,u=Bt(s,e);return u<0?s.push([e,a]):s[u][1]=a,this}B.prototype.clear=Gr,B.prototype.delete=Wr,B.prototype.get=Br,B.prototype.has=$r,B.prototype.set=Kr;function K(e){var a=-1,s=e?e.length:0;for(this.clear();++a<s;){var u=e[a];this.set(u[0],u[1])}}function Yr(){this.__data__={hash:new yt,map:new(Ot||B),string:new yt}}function Vr(e){return Dt(this,e).delete(e)}function Xr(e){return Dt(this,e).get(e)}function qr(e){return Dt(this,e).has(e)}function Jr(e,a){return Dt(this,e).set(e,a),this}K.prototype.clear=Yr,K.prototype.delete=Vr,K.prototype.get=Xr,K.prototype.has=qr,K.prototype.set=Jr;function J(e){this.__data__=new B(e)}function Zr(){this.__data__=new B}function Qr(e){return this.__data__.delete(e)}function tn(e){return this.__data__.get(e)}function en(e){return this.__data__.has(e)}function rn(e,a){var s=this.__data__;if(s instanceof B){var u=s.__data__;if(!Ot||u.length<n-1)return u.push([e,a]),this;s=this.__data__=new K(u)}return s.set(e,a),this}J.prototype.clear=Zr,J.prototype.delete=Qr,J.prototype.get=tn,J.prototype.has=en,J.prototype.set=rn;function Wt(e,a){var s=ge(e)||Kt(e)?ne(e.length,String):[],u=s.length,O=!!u;for(var I in e)lt.call(e,I)&&!(O&&(I=="length"||bn(I,u)))&&s.push(I);return s}function Ye(e,a,s){var u=e[a];(!(lt.call(e,a)&&Ze(u,s))||s===void 0&&!(a in e))&&(e[a]=s)}function Bt(e,a){for(var s=e.length;s--;)if(Ze(e[s][0],a))return s;return-1}function ft(e,a){return e&&be(a,ve(a),e)}function ye(e,a,s,u,O,I,j){var C;if(u&&(C=I?u(e,O,I,j):u(e)),C!==void 0)return C;if(!dt(e))return e;var L=ge(e);if(L){if(C=yn(e),!a)return pn(e,C)}else{var R=bt(e),Y=R==T||R==U;if(Qe(e))return $t(e,a);if(R==h||R==c||Y&&!I){if(ie(e))return I?e:{};if(C=pt(Y?{}:e),!a)return dn(e,ft(C,e))}else{if(!N[R])return I?e:{};C=mn(e,R,ye,a)}}j||(j=new J);var Z=j.get(e);if(Z)return Z;if(j.set(e,C),!L)var W=s?hn(e):ve(e);return Re(W||e,function(V,$){W&&($=V,V=e[$]),Ye(C,$,ye(V,a,s,u,$,e,j))}),C}function nn(e){return dt(e)?Ge(e):{}}function an(e,a,s){var u=a(e);return ge(e)?u:Fe(u,s(e))}function sn(e){return Nt.call(e)}function on(e){if(!dt(e)||_n(e))return!1;var a=_e(e)||ie(e)?zr:Mr;return a.test(q(e))}function cn(e){if(!qe(e))return Be(e);var a=[];for(var s in Object(e))lt.call(e,s)&&s!="constructor"&&a.push(s);return a}function $t(e,a){if(a)return e.slice();var s=new e.constructor(e.length);return e.copy(s),s}function me(e){var a=new e.constructor(e.byteLength);return new oe(a).set(new oe(e)),a}function Pt(e,a){var s=a?me(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function Ve(e,a,s){var u=a?s(Ne(e),!0):Ne(e);return re(u,jr,new e.constructor)}function Xe(e){var a=new e.constructor(e.source,xr.exec(e));return a.lastIndex=e.lastIndex,a}function un(e,a,s){var u=a?s(He(e),!0):He(e);return re(u,st,new e.constructor)}function ln(e){return $e?Object($e.call(e)):{}}function fn(e,a){var s=a?me(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function pn(e,a){var s=-1,u=e.length;for(a||(a=Array(u));++s<u;)a[s]=e[s];return a}function be(e,a,s,u){s||(s={});for(var O=-1,I=a.length;++O<I;){var j=a[O],C=void 0;Ye(s,j,C===void 0?e[j]:C)}return s}function dn(e,a){return be(e,mt(e),a)}function hn(e){return an(e,ve,mt)}function Dt(e,a){var s=e.__data__;return gn(a)?s[typeof a=="string"?"string":"hash"]:s.map}function ct(e,a){var s=ze(e,a);return on(s)?s:void 0}var mt=ce?ae(ce,Object):In,bt=sn;(Lt&&bt(new Lt(new ArrayBuffer(1)))!=w||Ot&&bt(new Ot)!=y||ot&&bt(ot.resolve())!=l||Gt&&bt(new Gt)!=v||ue&&bt(new ue)!=_)&&(bt=function(e){var a=Nt.call(e),s=a==h?e.constructor:void 0,u=s?q(s):void 0;if(u)switch(u){case le:return w;case Mt:return y;case fe:return l;case pe:return v;case de:return _}return a});function yn(e){var a=e.length,s=e.constructor(a);return a&&typeof e[0]=="string"&<.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function pt(e){return typeof e.constructor=="function"&&!qe(e)?nn(nt(e)):{}}function mn(e,a,s,u){var O=e.constructor;switch(a){case A:return me(e);case d:case P:return new O(+e);case w:return Pt(e,u);case k:case M:case S:case E:case D:case z:case Rt:case Ft:case De:return fn(e,u);case y:return Ve(e,u,s);case p:case m:return new O(e);case b:return Xe(e);case v:return un(e,u,s);case g:return ln(e)}}function bn(e,a){return a=a??o,!!a&&(typeof e=="number"||Pr.test(e))&&e>-1&&e%1==0&&e<a}function gn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function _n(e){return!!Ue&&Ue in e}function qe(e){var a=e&&e.constructor,s=typeof a=="function"&&a.prototype||zt;return e===s}function q(e){if(e!=null){try{return Le.call(e)}catch{}try{return e+""}catch{}}return""}function Je(e){return ye(e,!0,!0)}function Ze(e,a){return e===a||e!==e&&a!==a}function Kt(e){return vn(e)&<.call(e,"callee")&&(!We.call(e,"callee")||Nt.call(e)==c)}var ge=Array.isArray;function Yt(e){return e!=null&&tr(e.length)&&!_e(e)}function vn(e){return er(e)&&Yt(e)}var Qe=Ut||Sn;function _e(e){var a=dt(e)?Nt.call(e):"";return a==T||a==U}function tr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=o}function dt(e){var a=typeof e;return!!e&&(a=="object"||a=="function")}function er(e){return!!e&&typeof e=="object"}function ve(e){return Yt(e)?Wt(e):cn(e)}function In(){return[]}function Sn(){return!1}t.exports=Je}(ke,ke.exports);var Si=ke.exports;const rt=fr(Si),wi=t=>new Promise((r,n)=>{const i=new Image;console.warn("update cdn config for cors?"),i.onload=()=>{const o=i.width,c=i.height;r({width:o,height:c})},i.onerror=o=>{n(o)},i.crossOrigin="anonymous",i.src=t}),Ti=t=>new Promise((r,n)=>{const i=new Audio;i.preload="auto",i.addEventListener("loadedmetadata",()=>{const o=i.duration*1e3;r({duration:o})}),i.addEventListener("error",o=>{n(o)}),i.src=t,i.crossOrigin="anonymous",i.load()}),ki=t=>new Promise((r,n)=>{const i=document.createElement("video");i.preload="auto",i.addEventListener("loadedmetadata",()=>{const o=i.duration*1e3,c=i.videoWidth,f=i.videoHeight;r({duration:o,width:c,height:f})}),i.addEventListener("error",o=>{n(o)}),i.src=t,i.load()}),Fn=(t,r)=>{const n=document.createElement("div");Object.keys(r).forEach(o=>{o!=="height"&&(n.style[o]=r[o])}),document.body.appendChild(n),n.textContent=t,n.style.whiteSpace="normal",n.style.position="absolute",n.style.visibility="hidden",n.style.display="inline-block",n.style.width=r.width+"px",n.style.fontSize=r.fontSize+"px";const i=getComputedStyle(n).height;return document.body.removeChild(n),parseFloat(i)},pr=t=>{const r=t.map(n=>new FontFace(n.fontFamily,`url(${n.url})`).load().catch(i=>i));return r.length===0?Promise.resolve(!0):new Promise((n,i)=>{Promise.all(r).then(o=>{o.forEach(c=>{c&&c.family&&(document.fonts.add(c),n(!0))})}).catch(o=>i(o))})},Ae={color:"#000000",x:0,y:0,blur:0},Vt=(t,r)=>{let n=r!=null&&r.trim?r.trim.to-r.trim.from:(r==null?void 0:r.duration)||5e3;const i={from:0,to:n};if(!t)return i;if(t.from<0)return console.error("'from' must be a non-negative number. Returning default display."),i;if(t.from!==void 0&&t.to===void 0)return{from:t.from,to:t.from+n};if(t.to!==void 0){if(t.to<0)return console.error("'to' must be a non-negative number. Returning default display."),i;if(t.to<t.from)return console.error("'to' must be greater than or equal to 'from'. Returning default display."),i}return t},zn=(t,r)=>t?t.from&&!t.to?{from:t.from,to:r.duration}:t:{from:0,to:r.duration};function Ee(t,r){const n={x:t.size.width/2,y:t.size.height/2},i={x:r.width/2,y:r.height/2},o=Math.min(t.size.width/r.width,t.size.height/r.height),c=n.x-i.x;return{top:`${n.y-i.y}px`,left:`${c}px`,transform:`scale(${o})`}}const Nn=async(t,r)=>{const n=t.details.src,i=await ki(n),o=Ee(r,{...i}),c=zn(t.trim,{duration:i.duration}),f={width:i.width,height:i.height,duration:i.duration,opacity:100,src:n,volume:t.details.volume??100,borderRadius:t.details.borderRadius??0,borderWidth:t.details.borderWidth??0,borderColor:t.details.borderColor||"#000000",boxShadow:t.details.boxShadow||Ae,top:o.top||"0px",left:o.left||"0px",transform:o.transform,blur:t.details.blur||0,brightness:t.details.brightness||100,flipX:t.details.flipX||!1,flipY:t.details.flipY||!1};return{...t,trim:c,type:"video",name:"video",details:f,playbackRate:t.playbackRate||1,display:Vt(t.display,{duration:i.duration,trim:c})}},Hn=async t=>{const r=t.id,n=t.details,o=(await Ti(n.src)).duration,c=zn(t.trim,{duration:o});return{id:r,name:"",type:"audio",display:Vt(t.display,{duration:o,trim:c}),trim:c,playbackRate:t.playbackRate||1,details:{src:n.src,duration:o,volume:n.volume??100},metadata:{...t.metadata}}},Un=async(t,r)=>{const n=t.details,i=await wi(n.src),o=Ee(r,i);return{id:t.id,type:"image",name:"image",display:Vt(t.display),playbackRate:t.playbackRate||1,details:{src:n.src||"",width:n.width||i.width||100,height:n.height||i.height||100,opacity:n.opacity??100,transform:o.transform,border:n.border||"none",borderRadius:n.borderRadius||0,boxShadow:n.boxShadow||Ae,top:o.top||"0px",left:o.left||"0px",borderWidth:n.borderWidth??0,borderColor:n.borderColor||"#000000",blur:n.blur||0,brightness:n.brightness||100,flipX:n.flipX||!1,flipY:n.flipY||!1},metadata:t.metadata||{}}},Ln=async(t,r)=>{const n=t;await pr([{fontFamily:n.details.fontFamily,url:n.details.fontUrl}]);const i=n.id,o=n.details,c=Wn(o),f=Fn(n.details.text,c),d=Ee(r,{width:c.width,height:f});return{id:i,name:"caption",type:"caption",display:Vt(n.display),details:{...c,text:o.text||"",height:f,fontUrl:o.fontUrl,top:d.top,left:d.left,borderWidth:o.borderWidth||0,borderColor:o.borderColor||"#000000",boxShadow:o.boxShadow||Ae,words:o.words||[]},metadata:{}}},Gn=async(t,r)=>{await pr([{fontFamily:t.details.fontFamily,url:t.details.fontUrl}]);const n=t.id,i=t.details,o=Wn(i),c=Fn(t.details.text,o),f=Ee(r,{width:o.width,height:c});return{id:n,name:"text",type:"text",display:Vt(t.display),details:{...o,text:i.text||"",height:c,fontUrl:i.fontUrl,top:f.top,left:f.left,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",boxShadow:i.boxShadow||Ae},metadata:{}}},Wn=t=>({fontFamily:t.fontFamily||"Arial",fontSize:t.fontSize||"16px",fontWeight:t.fontWeight||"normal",fontStyle:t.fontStyle||"normal",textDecoration:t.textDecoration||"none",textAlign:t.textAlign||"left",lineHeight:t.lineHeight||"normal",letterSpacing:t.letterSpacing||"normal",wordSpacing:t.wordSpacing||"normal",color:t.color||"#ffffff",backgroundColor:t.backgroundColor||"transparent",border:t.border||"none",textShadow:t.textShadow||"none",text:t.text||"",opacity:t.opacity??100,width:t.width||300,wordWrap:t.wordWrap||"normal",wordBreak:t.wordBreak||"normal",WebkitTextStrokeColor:t.WebkitTextStrokeColor||"#ffffff",WebkitTextStrokeWidth:t.WebkitTextStrokeWidth||"0px",top:t.top||"0px",left:t.left||"0px",textTransform:t.textTransform||"none"}),Ai="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let dr=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)r+=Ai[n[t]&63];return r};function Ei(t,r){return t.filter(i=>({...i,items:i.items.filter(o=>!r.includes(o))})).filter(i=>!i.items.length)}function Bn(t=16){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=r.charAt(Math.floor(Math.random()*r.length));let i=dr(t-1);return i=i.replace(/[^a-zA-Z0-9]/g,"").slice(0,t-1),n+i}const Oe=t=>Object.keys(t).reduce((r,n)=>{const{display:i,playbackRate:o}=t[n];return Math.max(r,i.to/(o||1))},0);function Oi(t){const r=x.subject.pipe(x.filter(({key:p})=>p.startsWith(x.DESIGN_PREFIX))),n=x.subject.pipe(x.filter(({key:p})=>p.startsWith(x.ADD_PREFIX))),i=x.subject.pipe(x.filter(({key:p})=>p.startsWith(x.LAYER_PREFIX))),o=x.subject.pipe(x.filter(({key:p})=>p.startsWith(x.HISTORY_PREFIX))),c=x.subject.pipe(x.filter(({key:p})=>p.startsWith(x.ACTIVE_PREFIX))),f=x.subject.pipe(x.filter(({key:p})=>p.startsWith(x.EDIT_PREFIX))),d=r.subscribe(async p=>{var h;if(p.key===x.DESIGN_LOAD){const l=(h=p.value)==null?void 0:h.payload,b=l.trackItemIds,v={},m=l.trackItemDetailsMap;console.warn("IMPROVE FONTS LOADING");const g=b.map(async A=>{try{const w=m[A];if(w.type==="image"){const k=await Un({id:A,details:w.details},{size:{width:1080,height:1920}}),{details:M,...S}=k;m[A]={type:"image",details:M},v[A]=S}else if(w.type==="video"){const k=await Nn({id:A,details:w.details},{size:{width:1080,height:1920}}),{details:M,...S}=k;m[A]={type:"video",details:M},v[A]=S}else if(w.type==="audio"){const k=await Hn({id:A,details:w.details}),{details:M,...S}=k;m[A]={type:"audio",details:M},v[A]=S}else if(w.type==="caption"){const k=await Ln({id:A,details:w.details},{size:{width:1080,height:1920}}),{details:M,...S}=k;m[A]={type:"caption",details:M},v[A]=S}else if(w.type==="text"){const k=await Gn({id:A,details:w.details},{size:{width:1080,height:1920}}),{details:M,...S}=k;m[A]={type:"caption",details:M},v[A]=S}return!0}catch{return!1}});await Promise.all(g);const _=Oe(v);t.updateState({...l,duration:_})}}),P=o.subscribe(p=>{if(p.key===x.HISTORY_UNDO)return t.undo();if(p.key===x.HISTORY_REDO)return t.redo()}),F=i.subscribe(p=>{var l,b,v;const h=[];if((l=p.value)!=null&&l.payload.trackItemIds&&(h.push((b=p.value)==null?void 0:b.payload.trackItemIds),t.updateState({activeIds:h})),p.key===x.LAYER_DELETE){const m=(v=p.value)==null?void 0:v.payload.trackItemIds,g=rt(t.getState()),_=m&&m.length?m:g.activeIds,A=g.trackItemIds,w=g.trackItemDetailsMap,k=A.filter(z=>!_.includes(z)),M=Object.fromEntries(Object.entries(w).filter(([z])=>!_.includes(z))),S=Ei(g.tracks,_),E=Object.fromEntries(Object.entries(g.trackItemsMap).filter(([z])=>!_.includes(z))),D=Oe(g.trackItemsMap);t.updateState({trackItemIds:k,trackItemDetailsMap:M,activeIds:[],trackItemsMap:E,tracks:S,duration:D},{updateHistory:!0,kind:"remove"})}}),T=n.subscribe(async p=>{var m,g,_,A,w;const h=rt(t.getState());let l=[],b="text";if(p.key===x.ADD_CAPTION){b="caption";const k=(m=p.value)==null?void 0:m.payload,M=[];for(const D of k){const z=Ln(D,{size:{width:1080,height:1920}});M.push(z)}const S=await Promise.all(M),E=[];for(const D of S){const z=D.id;E.push(z);const{details:Rt,...Ft}=D;h.trackItemDetailsMap[z]={type:b,details:Rt},h.trackItemsMap[z]=Ft,h.trackItemIds.push(z)}l=E}if(p.key===x.ADD_TEXT){b="text";const k=await Gn((g=p.value)==null?void 0:g.payload,{size:{width:1080,height:1920}}),{details:M,...S}=k;h.trackItemDetailsMap[S.id]={type:b,details:M},h.trackItemsMap[S.id]=S,h.trackItemIds.push(S.id),l=[S.id]}if(p.key===x.ADD_IMAGE){b="image";const k=await Un((_=p.value)==null?void 0:_.payload,{size:{width:1080,height:1920}}),{details:M,...S}=k;h.trackItemDetailsMap[S.id]={type:b,details:M},h.trackItemsMap[S.id]=S,h.trackItemIds.push(S.id),l=[S.id]}if(p.key===x.ADD_AUDIO){b="audio";const k=await Hn((A=p.value)==null?void 0:A.payload),{details:M,...S}=k;h.trackItemDetailsMap[S.id]={type:b,details:M},h.trackItemsMap[S.id]=S,h.trackItemIds.push(S.id),l=[S.id]}if(p.key===x.ADD_VIDEO){b="video";const k=await Nn((w=p.value)==null?void 0:w.payload,{size:{width:1080,height:1920}}),{details:M,...S}=k;h.trackItemDetailsMap[S.id]={type:b,details:M},h.trackItemsMap[S.id]=S,h.trackItemIds.push(S.id),l=[S.id]}h.tracks.unshift({id:dr(),accepts:["text","audio","helper","video","image","caption"],type:b,items:l,magnetic:!1,static:!1});const v=Oe(h.trackItemsMap);t.updateState({trackItemIds:h.trackItemIds,trackItemDetailsMap:h.trackItemDetailsMap,trackItemsMap:h.trackItemsMap,tracks:h.tracks,duration:v},{updateHistory:!0,kind:"add"})}),U=c.subscribe(async p=>{var h;if(p.key===x.ACTIVE_SPLIT){const l=rt(t.getState()),b=(h=p.value)==null?void 0:h.options.time;if(l.activeIds.length===1){const v=l.activeIds[0],m=l.trackItemsMap[v];if(b>=m.display.to||b<=m.display.from)return;const g=l.trackItemDetailsMap[v],_=Bn(),A={...m,id:_,display:{from:b,to:m.display.to},trim:{from:b,to:m.display.to}};l.trackItemsMap[v].display.to=b,l.trackItemsMap[_]=A,l.trackItemIds.push(_),l.trackItemDetailsMap[_]=g,l.tracks.forEach(w=>{w.items.includes(v)&&w.items.push(_)}),t.updateState({trackItemDetailsMap:l.trackItemDetailsMap,tracks:l.tracks,trackItemIds:l.trackItemIds,trackItemsMap:l.trackItemsMap},{updateHistory:!0,kind:"update"})}return}if(p.key===x.ACTIVE_CLONE){const l=rt(t.getState());if(l.activeIds.length){const b=l.activeIds,v=[],m={activeIds:b,trackItemDetailsMap:{},trackItemsMap:{},tracks:[]};b.forEach(_=>{m.trackItemDetailsMap[_]=l.trackItemDetailsMap[_],m.trackItemsMap[_]=l.trackItemsMap[_],v.push(l.tracks.find(A=>A.items.includes(_)))});const g=new Set;v.filter(_=>g.has(_.id)?!1:(g.add(_),!0)),m.tracks=Array.from(g.keys()),localStorage.setItem("DesignComboTemp",JSON.stringify(m))}}if(p.key===x.ACTIVE_PASTE){const l=localStorage.getItem("DesignComboTemp");if(!l)return;const b=rt(t.getState()),v=JSON.parse(l),m={},g=v.trackItemsMap,_=v.trackItemDetailsMap,A=v.tracks,w=[],k=v.activeIds.map(async M=>{const S=_[M];(S.type==="caption"||S.type==="text")&&await pr([{fontFamily:S.details.fontFamily,url:S.details.fontUrl}]);const E=Bn();return m[M]=E,b.trackItemsMap[E]={...g[M],id:E},b.trackItemDetailsMap[E]=S,b.trackItemIds.push(E),!0});await Promise.all(k),A.forEach(M=>{const S=M.items.map(D=>m[D]),E={...M,items:S,id:dr()};w.push(E)}),b.tracks=[...b.tracks,...w],t.updateState({trackItemDetailsMap:b.trackItemDetailsMap,tracks:b.tracks,trackItemIds:b.trackItemIds,trackItemsMap:b.trackItemsMap},{updateHistory:!0,kind:"update"})}}),y=f.subscribe(p=>{var h,l;if(p.key===x.EDIT_OBJECT){const b=rt(t.getState()),v=b.trackItemDetailsMap,m=b.trackItemsMap,g=Object.keys((h=p.value)==null?void 0:h.payload);if(!g.length)return;const _=(l=p.value)==null?void 0:l.payload;g.forEach(w=>{_[w].details?v[w].details={...v[w].details,..._[w].details}:_[w].playbackRate&&(m[w].playbackRate=_[w].playbackRate)});const A=Oe(m);t.updateState({trackItemDetailsMap:{...v},trackItemsMap:{...m},duration:A},{updateHistory:!0,kind:"update:details"})}});return{unsubscribe:()=>{T.unsubscribe(),U.unsubscribe(),y.unsubscribe(),P.unsubscribe(),F.unsubscribe(),d.unsubscribe()}}}const xi={Date:!0,RegExp:!0,String:!0,Number:!0};function $n(t,r,n={cyclesFix:!0},i=[]){var d,P;let o=[];const c=Array.isArray(t);for(const F in t){const T=t[F],U=c?+F:F;if(!(F in r)){o.push({type:"REMOVE",path:[U],oldValue:t[F]});continue}const y=r[F],p=typeof T=="object"&&typeof y=="object"&&Array.isArray(T)===Array.isArray(y);if(T&&y&&p&&!xi[(P=(d=Object.getPrototypeOf(T))==null?void 0:d.constructor)==null?void 0:P.name]&&(!n.cyclesFix||!i.includes(T))){const h=$n(T,y,n,n.cyclesFix?i.concat([T]):[]);o.push.apply(o,h.map(l=>(l.path.unshift(U),l)))}else T!==y&&!(Number.isNaN(T)&&Number.isNaN(y))&&!(p&&(isNaN(T)?T+""==y+"":+T==+y))&&o.push({path:[U],type:"CHANGE",value:y,oldValue:T})}const f=Array.isArray(r);for(const F in r)F in t||o.push({type:"CREATE",path:[f?+F:F],value:r[F]});return o}var hr=Symbol.for("immer-nothing"),Xt=Symbol.for("immer-draftable"),Q=Symbol.for("immer-state"),Kn=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function G(t,...r){if(process.env.NODE_ENV!=="production"){const n=Kn[t],i=typeof n=="function"?n.apply(null,r):n;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var St=Object.getPrototypeOf;function wt(t){return!!t&&!!t[Q]}function _t(t){var r;return t?Yn(t)||Array.isArray(t)||!!t[Xt]||!!((r=t.constructor)!=null&&r[Xt])||Zt(t)||Qt(t):!1}var Mi=Object.prototype.constructor.toString();function Yn(t){if(!t||typeof t!="object")return!1;const r=St(t);if(r===null)return!0;const n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Mi}function qt(t,r){Tt(t)===0?Reflect.ownKeys(t).forEach(n=>{r(n,t[n],t)}):t.forEach((n,i)=>r(i,n,t))}function Tt(t){const r=t[Q];return r?r.type_:Array.isArray(t)?1:Zt(t)?2:Qt(t)?3:0}function Jt(t,r){return Tt(t)===2?t.has(r):Object.prototype.hasOwnProperty.call(t,r)}function yr(t,r){return Tt(t)===2?t.get(r):t[r]}function Vn(t,r,n){const i=Tt(t);i===2?t.set(r,n):i===3?t.add(n):t[r]=n}function Pi(t,r){return t===r?t!==0||1/t===1/r:t!==t&&r!==r}function Zt(t){return t instanceof Map}function Qt(t){return t instanceof Set}function kt(t){return t.copy_||t.base_}function mr(t,r){if(Zt(t))return new Map(t);if(Qt(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Yn(t);if(r===!0||r==="class_only"&&!n){const i=Object.getOwnPropertyDescriptors(t);delete i[Q];let o=Reflect.ownKeys(i);for(let c=0;c<o.length;c++){const f=o[c],d=i[f];d.writable===!1&&(d.writable=!0,d.configurable=!0),(d.get||d.set)&&(i[f]={configurable:!0,writable:!0,enumerable:d.enumerable,value:t[f]})}return Object.create(St(t),i)}else{const i=St(t);if(i!==null&&n)return{...t};const o=Object.create(i);return Object.assign(o,t)}}function br(t,r=!1){return xe(t)||wt(t)||!_t(t)||(Tt(t)>1&&(t.set=t.add=t.clear=t.delete=Di),Object.freeze(t),r&&Object.entries(t).forEach(([n,i])=>br(i,!0))),t}function Di(){G(2)}function xe(t){return Object.isFrozen(t)}var gr={};function At(t){const r=gr[t];return r||G(0,t),r}function Ci(t,r){gr[t]||(gr[t]=r)}var te;function Xn(){return te}function ji(t,r){return{drafts_:[],parent_:t,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function qn(t,r){r&&(At("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=r)}function _r(t){vr(t),t.drafts_.forEach(Ri),t.drafts_=null}function vr(t){t===te&&(te=t.parent_)}function Jn(t){return te=ji(te,t)}function Ri(t){const r=t[Q];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function Zn(t,r){r.unfinalizedDrafts_=r.drafts_.length;const n=r.drafts_[0];return t!==void 0&&t!==n?(n[Q].modified_&&(_r(r),G(4)),_t(t)&&(t=Me(r,t),r.parent_||Pe(r,t)),r.patches_&&At("Patches").generateReplacementPatches_(n[Q].base_,t,r.patches_,r.inversePatches_)):t=Me(r,n,[]),_r(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),t!==hr?t:void 0}function Me(t,r,n){if(xe(r))return r;const i=r[Q];if(!i)return qt(r,(o,c)=>Qn(t,i,r,o,c,n)),r;if(i.scope_!==t)return r;if(!i.modified_)return Pe(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const o=i.copy_;let c=o,f=!1;i.type_===3&&(c=new Set(o),o.clear(),f=!0),qt(c,(d,P)=>Qn(t,i,o,d,P,n,f)),Pe(t,o,!1),n&&t.patches_&&At("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function Qn(t,r,n,i,o,c,f){if(process.env.NODE_ENV!=="production"&&o===n&&G(5),wt(o)){const d=c&&r&&r.type_!==3&&!Jt(r.assigned_,i)?c.concat(i):void 0,P=Me(t,o,d);if(Vn(n,i,P),wt(P))t.canAutoFreeze_=!1;else return}else f&&n.add(o);if(_t(o)&&!xe(o)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Me(t,o),(!r||!r.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&Pe(t,o)}}function Pe(t,r,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&br(r,n)}function Fi(t,r){const n=Array.isArray(t),i={type_:n?1:0,scope_:r?r.scope_:Xn(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,c=Ir;n&&(o=[i],c=ee);const{revoke:f,proxy:d}=Proxy.revocable(o,c);return i.draft_=d,i.revoke_=f,d}var Ir={get(t,r){if(r===Q)return t;const n=kt(t);if(!Jt(n,r))return zi(t,n,r);const i=n[r];return t.finalized_||!_t(i)?i:i===Sr(t.base_,r)?(Tr(t),t.copy_[r]=kr(i,t)):i},has(t,r){return r in kt(t)},ownKeys(t){return Reflect.ownKeys(kt(t))},set(t,r,n){const i=ti(kt(t),r);if(i!=null&&i.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const o=Sr(kt(t),r),c=o==null?void 0:o[Q];if(c&&c.base_===n)return t.copy_[r]=n,t.assigned_[r]=!1,!0;if(Pi(n,o)&&(n!==void 0||Jt(t.base_,r)))return!0;Tr(t),wr(t)}return t.copy_[r]===n&&(n!==void 0||r in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[r])||(t.copy_[r]=n,t.assigned_[r]=!0),!0},deleteProperty(t,r){return Sr(t.base_,r)!==void 0||r in t.base_?(t.assigned_[r]=!1,Tr(t),wr(t)):delete t.assigned_[r],t.copy_&&delete t.copy_[r],!0},getOwnPropertyDescriptor(t,r){const n=kt(t),i=Reflect.getOwnPropertyDescriptor(n,r);return i&&{writable:!0,configurable:t.type_!==1||r!=="length",enumerable:i.enumerable,value:n[r]}},defineProperty(){G(11)},getPrototypeOf(t){return St(t.base_)},setPrototypeOf(){G(12)}},ee={};qt(Ir,(t,r)=>{ee[t]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),ee.deleteProperty=function(t,r){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(r))&&G(13),ee.set.call(this,t,r,void 0)},ee.set=function(t,r,n){return process.env.NODE_ENV!=="production"&&r!=="length"&&isNaN(parseInt(r))&&G(14),Ir.set.call(this,t[0],r,n,t[0])};function Sr(t,r){const n=t[Q];return(n?kt(n):t)[r]}function zi(t,r,n){var o;const i=ti(r,n);return i?"value"in i?i.value:(o=i.get)==null?void 0:o.call(t.draft_):void 0}function ti(t,r){if(!(r in t))return;let n=St(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,r);if(i)return i;n=St(n)}}function wr(t){t.modified_||(t.modified_=!0,t.parent_&&wr(t.parent_))}function Tr(t){t.copy_||(t.copy_=mr(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Ni=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,n,i)=>{if(typeof r=="function"&&typeof n!="function"){const c=n;n=r;const f=this;return function(P=c,...F){return f.produce(P,T=>n.call(this,T,...F))}}typeof n!="function"&&G(6),i!==void 0&&typeof i!="function"&&G(7);let o;if(_t(r)){const c=Jn(this),f=kr(r,void 0);let d=!0;try{o=n(f),d=!1}finally{d?_r(c):vr(c)}return qn(c,i),Zn(o,c)}else if(!r||typeof r!="object"){if(o=n(r),o===void 0&&(o=r),o===hr&&(o=void 0),this.autoFreeze_&&br(o,!0),i){const c=[],f=[];At("Patches").generateReplacementPatches_(r,o,c,f),i(c,f)}return o}else G(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(f,...d)=>this.produceWithPatches(f,P=>r(P,...d));let i,o;return[this.produce(r,n,(f,d)=>{i=f,o=d}),i,o]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){_t(t)||G(8),wt(t)&&(t=Hi(t));const r=Jn(this),n=kr(t,void 0);return n[Q].isManual_=!0,vr(r),n}finishDraft(t,r){const n=t&&t[Q];(!n||!n.isManual_)&&G(9);const{scope_:i}=n;return qn(i,r),Zn(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,r){let n;for(n=r.length-1;n>=0;n--){const o=r[n];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}n>-1&&(r=r.slice(n+1));const i=At("Patches").applyPatches_;return wt(t)?i(t,r):this.produce(t,o=>i(o,r))}};function kr(t,r){const n=Zt(t)?At("MapSet").proxyMap_(t,r):Qt(t)?At("MapSet").proxySet_(t,r):Fi(t,r);return(r?r.scope_:Xn()).drafts_.push(n),n}function Hi(t){return wt(t)||G(10,t),ei(t)}function ei(t){if(!_t(t)||xe(t))return t;const r=t[Q];let n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=mr(t,r.scope_.immer_.useStrictShallowCopy_)}else n=mr(t,!0);return qt(n,(i,o)=>{Vn(n,i,ei(o))}),r&&(r.finalized_=!1),n}function ri(){process.env.NODE_ENV!=="production"&&Kn.push('Sets cannot have "replace" patches.',function(y){return"Unsupported patch operation: "+y},function(y){return"Cannot apply patch, path doesn't resolve: "+y},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const r="replace",n="add",i="remove";function o(y,p,h,l){switch(y.type_){case 0:case 2:return f(y,p,h,l);case 1:return c(y,p,h,l);case 3:return d(y,p,h,l)}}function c(y,p,h,l){let{base_:b,assigned_:v}=y,m=y.copy_;m.length<b.length&&([b,m]=[m,b],[h,l]=[l,h]);for(let g=0;g<b.length;g++)if(v[g]&&m[g]!==b[g]){const _=p.concat([g]);h.push({op:r,path:_,value:U(m[g])}),l.push({op:r,path:_,value:U(b[g])})}for(let g=b.length;g<m.length;g++){const _=p.concat([g]);h.push({op:n,path:_,value:U(m[g])})}for(let g=m.length-1;b.length<=g;--g){const _=p.concat([g]);l.push({op:i,path:_})}}function f(y,p,h,l){const{base_:b,copy_:v}=y;qt(y.assigned_,(m,g)=>{const _=yr(b,m),A=yr(v,m),w=g?Jt(b,m)?r:n:i;if(_===A&&w===r)return;const k=p.concat(m);h.push(w===i?{op:w,path:k}:{op:w,path:k,value:A}),l.push(w===n?{op:i,path:k}:w===i?{op:n,path:k,value:U(_)}:{op:r,path:k,value:U(_)})})}function d(y,p,h,l){let{base_:b,copy_:v}=y,m=0;b.forEach(g=>{if(!v.has(g)){const _=p.concat([m]);h.push({op:i,path:_,value:g}),l.unshift({op:n,path:_,value:g})}m++}),m=0,v.forEach(g=>{if(!b.has(g)){const _=p.concat([m]);h.push({op:n,path:_,value:g}),l.unshift({op:i,path:_,value:g})}m++})}function P(y,p,h,l){h.push({op:r,path:[],value:p===hr?void 0:p}),l.push({op:r,path:[],value:y})}function F(y,p){return p.forEach(h=>{const{path:l,op:b}=h;let v=y;for(let A=0;A<l.length-1;A++){const w=Tt(v);let k=l[A];typeof k!="string"&&typeof k!="number"&&(k=""+k),(w===0||w===1)&&(k==="__proto__"||k==="constructor")&&G(19),typeof v=="function"&&k==="prototype"&&G(19),v=yr(v,k),typeof v!="object"&&G(18,l.join("/"))}const m=Tt(v),g=T(h.value),_=l[l.length-1];switch(b){case r:switch(m){case 2:return v.set(_,g);case 3:G(16);default:return v[_]=g}case n:switch(m){case 1:return _==="-"?v.push(g):v.splice(_,0,g);case 2:return v.set(_,g);case 3:return v.add(g);default:return v[_]=g}case i:switch(m){case 1:return v.splice(_,1);case 2:return v.delete(_);case 3:return v.delete(h.value);default:return delete v[_]}default:G(17,b)}}),y}function T(y){if(!_t(y))return y;if(Array.isArray(y))return y.map(T);if(Zt(y))return new Map(Array.from(y.entries()).map(([h,l])=>[h,T(l)]));if(Qt(y))return new Set(Array.from(y).map(T));const p=Object.create(St(y));for(const h in y)p[h]=T(y[h]);return Jt(y,Xt)&&(p[Xt]=y[Xt]),p}function U(y){return wt(y)?T(y):y}Ci("Patches",{applyPatches_:F,generatePatches_:o,generateReplacementPatches_:P})}var tt=new Ni,Ui=tt.produce;tt.produceWithPatches.bind(tt),tt.setAutoFreeze.bind(tt),tt.setUseStrictShallowCopy.bind(tt);var Li=tt.applyPatches.bind(tt);tt.createDraft.bind(tt),tt.finishDraft.bind(tt);var Gi=1/0,Wi=9007199254740991,Bi="[object Arguments]",$i="[object Function]",Ki="[object GeneratorFunction]",Yi="[object Symbol]",Vi=typeof et=="object"&&et&&et.Object===Object&&et,Xi=typeof self=="object"&&self&&self.Object===Object&&self,qi=Vi||Xi||Function("return this")();function Ji(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}function Zi(t,r){for(var n=-1,i=t?t.length:0,o=Array(i);++n<i;)o[n]=r(t[n],n,t);return o}function Qi(t,r){for(var n=-1,i=r.length,o=t.length;++n<i;)t[o+n]=r[n];return t}var Ar=Object.prototype,ta=Ar.hasOwnProperty,Er=Ar.toString,ni=qi.Symbol,ea=Ar.propertyIsEnumerable,ii=ni?ni.isConcatSpreadable:void 0,ai=Math.max;function ra(t,r,n,i,o){var c=-1,f=t.length;for(n||(n=sa),o||(o=[]);++c<f;){var d=t[c];n(d)?Qi(o,d):o[o.length]=d}return o}function na(t,r){return t=Object(t),ia(t,r,function(n,i){return i in t})}function ia(t,r,n){for(var i=-1,o=r.length,c={};++i<o;){var f=r[i],d=t[f];n(d,f)&&(c[f]=d)}return c}function aa(t,r){return r=ai(r===void 0?t.length-1:r,0),function(){for(var n=arguments,i=-1,o=ai(n.length-r,0),c=Array(o);++i<o;)c[i]=n[r+i];i=-1;for(var f=Array(r+1);++i<r;)f[i]=n[i];return f[r]=c,Ji(t,this,f)}}function sa(t){return ua(t)||ca(t)||!!(ii&&t&&t[ii])}function oa(t){if(typeof t=="string"||ya(t))return t;var r=t+"";return r=="0"&&1/t==-Gi?"-0":r}function ca(t){return fa(t)&&ta.call(t,"callee")&&(!ea.call(t,"callee")||Er.call(t)==Bi)}var ua=Array.isArray;function la(t){return t!=null&&da(t.length)&&!pa(t)}function fa(t){return si(t)&&la(t)}function pa(t){var r=ha(t)?Er.call(t):"";return r==$i||r==Ki}function da(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Wi}function ha(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function si(t){return!!t&&typeof t=="object"}function ya(t){return typeof t=="symbol"||si(t)&&Er.call(t)==Yi}var ma=aa(function(t,r){return t==null?{}:na(t,Zi(ra(r),oa))}),ba=ma;const oi=fr(ba),ga={tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{unit:1,zoom:1,segments:1},duration:0,activeIds:[],trackItemDetailsMap:{}},ci=["tracks","trackItemsMap","trackItemDetailsMap","transitionIds","transitionsMap","trackItemIds"];class _a{constructor(r){jt(this,"stateSubject");jt(this,"stateHistorySubject");jt(this,"prevState");jt(this,"undos",[]);jt(this,"redos",[]);jt(this,"listener");const n=r||ga;this.stateSubject=new Rn(n),this.stateHistorySubject=new Rn({handleRedo:!1,handleUndo:!1}),this.prevState=n,this.initListeners()}initListeners(){Oi(this)}destroyListeners(){this.listener&&this.listener.unsubscribe()}purge(){this.destroyListeners()}updateHistory(r,n){const i=oi(r,ci),o=oi(this.getState(),ci),c=$n(o,i);c.length&&(this.undos.push({undos:c,type:n}),this.redos=[])}getStateHistory(){return this.stateHistorySubject.getValue()}subscribeHistory(r){return this.stateHistorySubject.subscribe(r)}getState(){return this.stateSubject.getValue()}subscribe(r){return this.stateSubject.subscribe(r)}updateState(r,n={updateHistory:!1}){const i=this.getState(),o={...i,...r};it(i,o)||(n.updateHistory&&this.updateHistory(o,n.kind),this.prevState=i,this.stateSubject.next(o))}subscribeToScale(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.scale,this.prevState.scale)||r({scale:n.scale})})}subscribeToUpdateTrackItem(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemsMap,this.prevState.trackItemsMap)||r({trackItemsMap:n.trackItemsMap})})}subscribeToUpdateItemDetails(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemDetailsMap,this.prevState.trackItemDetailsMap)||r({trackItemDetailsMap:n.trackItemDetailsMap})})}subscribeToDuration(r){return this.stateSubject.asObservable().subscribe(n=>{n.duration!==this.prevState.duration&&r({duration:n.duration})})}subscribeToHistory(r){return this.stateHistorySubject.asObservable().subscribe(n=>{if(n.handleRedo){const i=this.undos[this.undos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}if(n.handleUndo){const i=this.redos[this.redos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}})}subscribeToAddOrRemoveItems(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemIds,this.prevState.trackItemIds)||r({trackItemIds:n.trackItemIds})})}subscribeToActiveIds(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.activeIds,this.prevState.activeIds)||r({activeIds:n.activeIds})})}subscribeToTracks(r){return this.stateSubject.asObservable().subscribe(n=>{(!it(n.tracks,this.prevState.tracks)||!it(n.trackItemIds,this.prevState.trackItemIds)||!it(n.trackItemsMap,this.prevState.trackItemsMap)||!it(n.transitionIds,this.prevState.transitionIds)||!it(n.transitionsMap,this.prevState.transitionsMap))&&r({tracks:n.tracks,trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,transitionIds:n.transitionIds,transitionsMap:n.transitionsMap,trackItemDetailsMap:n.trackItemDetailsMap})})}undo(){const r=this.undos.pop(),n=r==null?void 0:r.undos,i=r==null?void 0:r.type;if(!n||!i)return;ri();const{trackItemDetailsMap:o,trackItemIds:c,tracks:f,transitionIds:d,transitionsMap:P,trackItemsMap:F}=this.getState(),T=rt({trackItemDetailsMap:o,trackItemIds:c,tracks:f,transitionIds:d,transitionsMap:P,trackItemsMap:F}),U=[],y=[],p=[],h=[],l=[],b=[];n.forEach(E=>{let D;const z=E.path.slice(1);E.type==="CREATE"?D={path:z,op:"remove",value:E.value}:E.type==="CHANGE"?D={path:z,op:"replace",value:E.oldValue}:D={path:z,op:"add",value:E.oldValue},E.path.includes("trackItemIds")?p.push(D):E.path.includes("transitionIds")?y.push(D):E.path.includes("trackItemsMap")?l.push(D):E.path.includes("transitionsMap")?h.push(D):E.path.includes("tracks")?U.push(D):E.path.includes("trackItemDetailsMap")&&b.push(D)});const v=this.applyPatch(T.tracks,U),m=this.applyPatch(T.transitionIds,y),g=this.applyPatch(T.trackItemIds,p),_=this.applyPatch(T.transitionsMap,h),A=this.applyPatch(T.trackItemsMap,l),w=this.applyPatch(T.trackItemDetailsMap,b),k=rt({tracks:v,transitionIds:m,trackItemIds:g,transitionsMap:_,trackItemsMap:A,trackItemDetailsMap:w}),M=rt(this.getState()),S={...M,...k};this.prevState=M,this.redos.push({redos:n,type:i}),this.stateSubject.next(S),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!0})}applyPatch(r,n){return n.reverse().reduce((i,o)=>Ui(i,c=>{Li(c,[o])}),r)}redo(){const r=this.redos.pop(),n=r==null?void 0:r.redos,i=r==null?void 0:r.type;if(!n||!i)return;ri();const{trackItemDetailsMap:o,trackItemIds:c,tracks:f,transitionIds:d,transitionsMap:P,trackItemsMap:F}=this.getState(),T=rt({trackItemDetailsMap:o,trackItemIds:c,tracks:f,transitionIds:d,transitionsMap:P,trackItemsMap:F}),U=[],y=[],p=[],h=[],l=[],b=[];n.forEach(E=>{let D;const z=E.path.slice(1);E.type==="CREATE"?D={path:z,op:"add",value:E.value}:E.type==="CHANGE"?D={path:z,op:"replace",value:E.value}:D={path:z,op:"remove",value:E.oldValue},E.path.includes("trackItemIds")?p.push(D):E.path.includes("transitionIds")?y.push(D):E.path.includes("trackItemsMap")?l.push(D):E.path.includes("transitionsMap")?h.push(D):E.path.includes("trackItemDetailsMap")?b.push(D):U.push(D)});const v=this.applyPatch(T.tracks,U),m=this.applyPatch(T.transitionIds,y),g=this.applyPatch(T.trackItemIds,p),_=this.applyPatch(T.transitionsMap,h),A=this.applyPatch(T.trackItemsMap,l),w=this.applyPatch(T.trackItemDetailsMap,b),k=rt({tracks:v,transitionIds:m,trackItemIds:g,transitionsMap:_,trackItemsMap:A,trackItemDetailsMap:w}),M=rt(this.getState()),S={...M,...k};this.prevState=M,this.undos.push({undos:n,type:i}),this.stateSubject.next(S),this.stateHistorySubject.next({handleRedo:!0,handleUndo:!1})}}return _a});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@designcombo/state",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.17",
|
4
4
|
"private": false,
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -24,8 +24,8 @@
|
|
24
24
|
"typescript": "^5.3.3",
|
25
25
|
"vite": "^5.2.0",
|
26
26
|
"vite-plugin-dts": "^3.9.1",
|
27
|
-
"@designcombo/events": "0.1.
|
28
|
-
"@designcombo/types": "0.1.
|
27
|
+
"@designcombo/events": "0.1.17",
|
28
|
+
"@designcombo/types": "0.1.17",
|
29
29
|
"@designcombo/typescript-config": "0.0.0"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
@@ -38,8 +38,8 @@
|
|
38
38
|
"nanoid": "^5.0.7"
|
39
39
|
},
|
40
40
|
"peerDependencies": {
|
41
|
-
"@designcombo/events": "0.1.
|
42
|
-
"@designcombo/types": "0.1.
|
41
|
+
"@designcombo/events": "0.1.17",
|
42
|
+
"@designcombo/types": "0.1.17"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"dev": "vite",
|