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