@designcombo/state 5.5.1 → 5.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1003 -984
- package/dist/index.umd.js +2 -2
- package/package.json +4 -4
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(w,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("@designcombo/events")):typeof define=="function"&&define.amd?define(["exports","@designcombo/events"],H):(w=typeof globalThis<"u"?globalThis:w||self,H(w.events={},w.events))})(this,function(w,H){"use strict";var Uo=Object.defineProperty;var jo=(w,H,Ft)=>H in w?Uo(w,H,{enumerable:!0,configurable:!0,writable:!0,value:Ft}):w[H]=Ft;var Qt=(w,H,Ft)=>jo(w,typeof H!="symbol"?H+"":H,Ft);var Ft=function(t,r){return Ft=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Ft(t,r)};function Be(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");Ft(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function Rr(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function Cr(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),i,
|
|
1
|
+
(function(w,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("@designcombo/events")):typeof define=="function"&&define.amd?define(["exports","@designcombo/events"],H):(w=typeof globalThis<"u"?globalThis:w||self,H(w.events={},w.events))})(this,function(w,H){"use strict";var Uo=Object.defineProperty;var jo=(w,H,Ft)=>H in w?Uo(w,H,{enumerable:!0,configurable:!0,writable:!0,value:Ft}):w[H]=Ft;var Qt=(w,H,Ft)=>jo(w,typeof H!="symbol"?H+"":H,Ft);var Ft=function(t,r){return Ft=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])},Ft(t,r)};function Be(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");Ft(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function Rr(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function Cr(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),i,a=[],u;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(c){u={error:c}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(u)throw u.error}}return a}function Pr(t,r,e){if(e||arguments.length===2)for(var n=0,i=r.length,a;n<i;n++)(a||!(n in r))&&(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return t.concat(a||Array.prototype.slice.call(r))}typeof SuppressedError=="function"&&SuppressedError;function wt(t){return typeof t=="function"}function Yn(t){var r=function(n){Error.call(n),n.stack=new Error().stack},e=t(r);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var xr=Yn(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
2
|
`+e.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function Lr(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var cr=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,n,i,o;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var c=Rr(u),d=c.next();!d.done;d=c.next()){var p=d.value;p.remove(this)}}catch(y){r={error:y}}finally{try{d&&!d.done&&(e=c.return)&&e.call(c)}finally{if(r)throw r.error}}else u.remove(this);var h=this.initialTeardown;if(wt(h))try{h()}catch(y){o=y instanceof xr?y.errors:[y]}var I=this._finalizers;if(I){this._finalizers=null;try{for(var m=Rr(I),k=m.next();!k.done;k=m.next()){var _=k.value;try{Xn(_)}catch(y){o=o??[],y instanceof xr?o=Pr(Pr([],Cr(o)),Cr(y.errors)):o.push(y)}}}catch(y){n={error:y}}finally{try{k&&!k.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}}if(o)throw new xr(o)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)Xn(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&Lr(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&Lr(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),Wn=cr.EMPTY;function Gn(t){return t instanceof cr||t&&"closed"in t&&wt(t.remove)&&wt(t.add)&&wt(t.unsubscribe)}function Xn(t){wt(t)?t():t.unsubscribe()}var Ei={Promise:void 0},Ti={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,Pr([t,r],Cr(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function wi(t){Ti.setTimeout(function(){throw t})}function Kn(){}function ur(t){t()}var Vn=function(t){Be(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,Gn(e)&&e.add(n)):n.destination=Oi,n}return r.create=function(e,n,i){return new zr(e,n,i)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},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(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(cr),Ai=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){lr(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){lr(n)}else lr(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){lr(e)}},t}(),zr=function(t){Be(r,t);function r(e,n,i){var o=t.call(this)||this,u;return wt(e)||!e?u={next:e??void 0,error:n??void 0,complete:i??void 0}:u=e,o.destination=new Ai(u),o}return r}(Vn);function lr(t){wi(t)}function Mi(t){throw t}var Oi={closed:!0,next:Kn,error:Mi,complete:Kn},Di=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ri(t){return t}function Ci(t){return t.length===0?Ri:t.length===1?t[0]:function(e){return t.reduce(function(n,i){return i(n)},e)}}var qn=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var i=this,o=xi(r)?r:new zr(r,e,n);return ur(function(){var u=i,c=u.operator,d=u.source;o.add(c?c.call(o,d):d?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=Jn(e),new e(function(i,o){var u=new zr({next:function(c){try{r(c)}catch(d){o(d),u.unsubscribe()}},error:o,complete:i});n.subscribe(u)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[Di]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return Ci(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=Jn(r),new r(function(n,i){var o;e.subscribe(function(u){return o=u},function(u){return i(u)},function(){return n(o)})})},t.create=function(r){return new t(r)},t}();function Jn(t){var r;return(r=t??Ei.Promise)!==null&&r!==void 0?r:Promise}function Pi(t){return t&&wt(t.next)&&wt(t.error)&&wt(t.complete)}function xi(t){return t&&t instanceof Vn||Pi(t)&&Gn(t)}var Li=Yn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Zn=function(t){Be(r,t);function r(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.prototype.lift=function(e){var n=new Qn(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new Li},r.prototype.next=function(e){var n=this;ur(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=Rr(n.currentObservers),c=u.next();!c.done;c=u.next()){var d=c.value;d.next(e)}}catch(p){i={error:p}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}}})},r.prototype.error=function(e){var n=this;ur(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var i=n.observers;i.length;)i.shift().error(e)}})},r.prototype.complete=function(){var e=this;ur(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=this,i=this,o=i.hasError,u=i.isStopped,c=i.observers;return o||u?Wn:(this.currentObservers=null,c.push(e),new cr(function(){n.currentObservers=null,Lr(c,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,i=n.hasError,o=n.thrownError,u=n.isStopped;i?e.error(o):u&&e.complete()},r.prototype.asObservable=function(){var e=new qn;return e.source=this,e},r.create=function(e,n){return new Qn(e,n)},r}(qn),Qn=function(t){Be(r,t);function r(e,n){var i=t.call(this)||this;return i.destination=e,i.source=n,i}return r.prototype.next=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,e)},r.prototype.error=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&i!==void 0?i:Wn},r}(Zn),ts=function(t){Be(r,t);function r(e){var n=t.call(this)||this;return n._value=e,n}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return!n.closed&&e.next(this._value),n},r.prototype.getValue=function(){var e=this,n=e.hasError,i=e.thrownError,o=e._value;if(n)throw i;return this._throwIfClosed(),o},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(Zn),ht=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var dr={exports:{}};dr.exports,function(t,r){var e=200,n="__lodash_hash_undefined__",i=1,o=2,u=9007199254740991,c="[object Arguments]",d="[object Array]",p="[object AsyncFunction]",h="[object Boolean]",I="[object Date]",m="[object Error]",k="[object Function]",_="[object GeneratorFunction]",y="[object Map]",v="[object Number]",f="[object Null]",b="[object Object]",E="[object Promise]",S="[object Proxy]",M="[object RegExp]",T="[object Set]",A="[object String]",U="[object Symbol]",P="[object Undefined]",K="[object WeakMap]",D="[object ArrayBuffer]",F="[object DataView]",nt="[object Float32Array]",ce="[object Float64Array]",ue="[object Int8Array]",Ae="[object Int16Array]",Me="[object Int32Array]",Oe="[object Uint8Array]",De="[object Uint8ClampedArray]",z="[object Uint16Array]",Re="[object Uint32Array]",Ce=/[\\^$.*+?()[\]{}|]/g,at=/^\[object .+?Constructor\]$/,le=/^(?:0|[1-9]\d*)$/,N={};N[nt]=N[ce]=N[ue]=N[Ae]=N[Me]=N[Oe]=N[De]=N[z]=N[Re]=!0,N[c]=N[d]=N[D]=N[h]=N[F]=N[I]=N[m]=N[k]=N[y]=N[v]=N[b]=N[M]=N[T]=N[A]=N[K]=!1;var de=typeof ht=="object"&&ht&&ht.Object===Object&&ht,Pe=typeof self=="object"&&self&&self.Object===Object&&self,ot=de||Pe||Function("return this")(),fe=r&&!r.nodeType&&r,pe=fe&&!0&&t&&!t.nodeType&&t,Ht=pe&&pe.exports===fe,Ut=Ht&&de.process,he=function(){try{return Ut&&Ut.binding&&Ut.binding("util")}catch{}}(),jt=he&&he.isTypedArray;function me(s,a){for(var l=-1,g=s==null?0:s.length,R=0,O=[];++l<g;){var L=s[l];a(L,l,s)&&(O[R++]=L)}return O}function Bt(s,a){for(var l=-1,g=a.length,R=s.length;++l<g;)s[R+l]=a[l];return s}function Ie(s,a){for(var l=-1,g=s==null?0:s.length;++l<g;)if(a(s[l],l,s))return!0;return!1}function xe(s,a){for(var l=-1,g=Array(s);++l<s;)g[l]=a(l);return g}function Le(s){return function(a){return s(a)}}function Mt(s,a){return s.has(a)}function Yt(s,a){return s==null?void 0:s[a]}function ge(s){var a=-1,l=Array(s.size);return s.forEach(function(g,R){l[++a]=[R,g]}),l}function ye(s,a){return function(l){return s(a(l))}}function pt(s){var a=-1,l=Array(s.size);return s.forEach(function(g){l[++a]=g}),l}var Ot=Array.prototype,ze=Function.prototype,bt=Object.prototype,Dt=ot["__core-js_shared__"],Wt=ze.toString,st=bt.hasOwnProperty,be=function(){var s=/[^.]+$/.exec(Dt&&Dt.keys&&Dt.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),ke=bt.toString,Ne=RegExp("^"+Wt.call(st).replace(Ce,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Gt=Ht?ot.Buffer:void 0,Rt=ot.Symbol,_e=ot.Uint8Array,Ct=bt.propertyIsEnumerable,kt=Ot.splice,ct=Rt?Rt.toStringTag:void 0,Pt=Object.getOwnPropertySymbols,Xt=Gt?Gt.isBuffer:void 0,_t=ye(Object.keys,Object),Kt=Lt(ot,"DataView"),vt=Lt(ot,"Map"),Vt=Lt(ot,"Promise"),qt=Lt(ot,"Set"),tr=Lt(ot,"WeakMap"),Jt=Lt(Object,"create"),yr=it(Kt),xt=it(vt),on=it(Vt),cn=it(qt),un=it(tr),br=Rt?Rt.prototype:void 0,er=br?br.valueOf:void 0;function J(s){var a=-1,l=s==null?0:s.length;for(this.clear();++a<l;){var g=s[a];this.set(g[0],g[1])}}function ln(){this.__data__=Jt?Jt(null):{},this.size=0}function dn(s){var a=this.has(s)&&delete this.__data__[s];return this.size-=a?1:0,a}function fn(s){var a=this.__data__;if(Jt){var l=a[s];return l===n?void 0:l}return st.call(a,s)?a[s]:void 0}function pn(s){var a=this.__data__;return Jt?a[s]!==void 0:st.call(a,s)}function hn(s,a){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=Jt&&a===void 0?n:a,this}J.prototype.clear=ln,J.prototype.delete=dn,J.prototype.get=fn,J.prototype.has=pn,J.prototype.set=hn;function Q(s){var a=-1,l=s==null?0:s.length;for(this.clear();++a<l;){var g=s[a];this.set(g[0],g[1])}}function mn(){this.__data__=[],this.size=0}function In(s){var a=this.__data__,l=He(a,s);if(l<0)return!1;var g=a.length-1;return l==g?a.pop():kt.call(a,l,1),--this.size,!0}function gn(s){var a=this.__data__,l=He(a,s);return l<0?void 0:a[l][1]}function yn(s){return He(this.__data__,s)>-1}function bn(s,a){var l=this.__data__,g=He(l,s);return g<0?(++this.size,l.push([s,a])):l[g][1]=a,this}Q.prototype.clear=mn,Q.prototype.delete=In,Q.prototype.get=gn,Q.prototype.has=yn,Q.prototype.set=bn;function ut(s){var a=-1,l=s==null?0:s.length;for(this.clear();++a<l;){var g=s[a];this.set(g[0],g[1])}}function kn(){this.size=0,this.__data__={hash:new J,map:new(vt||Q),string:new J}}function _n(s){var a=gt(this,s).delete(s);return this.size-=a?1:0,a}function vn(s){return gt(this,s).get(s)}function Sn(s){return gt(this,s).has(s)}function En(s,a){var l=gt(this,s),g=l.size;return l.set(s,a),this.size+=l.size==g?0:1,this}ut.prototype.clear=kn,ut.prototype.delete=_n,ut.prototype.get=vn,ut.prototype.has=Sn,ut.prototype.set=En;function Fe(s){var a=-1,l=s==null?0:s.length;for(this.__data__=new ut;++a<l;)this.add(s[a])}function kr(s){return this.__data__.set(s,n),this}function $e(s){return this.__data__.has(s)}Fe.prototype.add=Fe.prototype.push=kr,Fe.prototype.has=$e;function St(s){var a=this.__data__=new Q(s);this.size=a.size}function rr(){this.__data__=new Q,this.size=0}function Tn(s){var a=this.__data__,l=a.delete(s);return this.size=a.size,l}function wn(s){return this.__data__.get(s)}function An(s){return this.__data__.has(s)}function Mn(s,a){var l=this.__data__;if(l instanceof Q){var g=l.__data__;if(!vt||g.length<e-1)return g.push([s,a]),this.size=++l.size,this;l=this.__data__=new ut(g)}return l.set(s,a),this.size=l.size,this}St.prototype.clear=rr,St.prototype.delete=Tn,St.prototype.get=wn,St.prototype.has=An,St.prototype.set=Mn;function On(s,a){var l=Ue(s),g=!l&&Tr(s),R=!l&&!g&&je(s),O=!l&&!g&&!R&&Mr(s),L=l||g||R||O,x=L?xe(s.length,String):[],B=x.length;for(var $ in s)st.call(s,$)&&!(L&&($=="length"||R&&($=="offset"||$=="parent")||O&&($=="buffer"||$=="byteLength"||$=="byteOffset")||Nn($,B)))&&x.push($);return x}function He(s,a){for(var l=s.length;l--;)if(Er(s[l][0],a))return l;return-1}function nr(s,a,l){var g=a(s);return Ue(s)?g:Bt(g,l(s))}function ve(s){return s==null?s===void 0?P:f:ct&&ct in Object(s)?zt(s):Sr(s)}function _r(s){return Tt(s)&&ve(s)==c}function vr(s,a,l,g,R){return s===a?!0:s==null||a==null||!Tt(s)&&!Tt(a)?s!==s&&a!==a:Dn(s,a,l,g,vr,R)}function Dn(s,a,l,g,R,O){var L=Ue(s),x=Ue(a),B=L?d:Et(s),$=x?d:Et(a);B=B==c?b:B,$=$==c?b:$;var tt=B==b,lt=$==b,G=B==$;if(G&&je(s)){if(!je(a))return!1;L=!0,tt=!1}if(G&&!tt)return O||(O=new St),L||Mr(s)?sr(s,a,l,g,R,O):xn(s,a,B,l,g,R,O);if(!(l&i)){var et=tt&&st.call(s,"__wrapped__"),Z=lt&&st.call(a,"__wrapped__");if(et||Z){var Zt=et?s.value():s,Nt=Z?a.value():a;return O||(O=new St),R(Zt,Nt,l,g,O)}}return G?(O||(O=new St),Ln(s,a,l,g,R,O)):!1}function Rn(s){if(!Ar(s)||$n(s))return!1;var a=wr(s)?Ne:at;return a.test(it(s))}function Cn(s){return Tt(s)&&ar(s.length)&&!!N[ve(s)]}function Pn(s){if(!Hn(s))return _t(s);var a=[];for(var l in Object(s))st.call(s,l)&&l!="constructor"&&a.push(l);return a}function sr(s,a,l,g,R,O){var L=l&i,x=s.length,B=a.length;if(x!=B&&!(L&&B>x))return!1;var $=O.get(s);if($&&O.get(a))return $==a;var tt=-1,lt=!0,G=l&o?new Fe:void 0;for(O.set(s,a),O.set(a,s);++tt<x;){var et=s[tt],Z=a[tt];if(g)var Zt=L?g(Z,et,tt,a,s,O):g(et,Z,tt,s,a,O);if(Zt!==void 0){if(Zt)continue;lt=!1;break}if(G){if(!Ie(a,function(Nt,Ee){if(!Mt(G,Ee)&&(et===Nt||R(et,Nt,l,g,O)))return G.push(Ee)})){lt=!1;break}}else if(!(et===Z||R(et,Z,l,g,O))){lt=!1;break}}return O.delete(s),O.delete(a),lt}function xn(s,a,l,g,R,O,L){switch(l){case F:if(s.byteLength!=a.byteLength||s.byteOffset!=a.byteOffset)return!1;s=s.buffer,a=a.buffer;case D:return!(s.byteLength!=a.byteLength||!O(new _e(s),new _e(a)));case h:case I:case v:return Er(+s,+a);case m:return s.name==a.name&&s.message==a.message;case M:case A:return s==a+"";case y:var x=ge;case T:var B=g&i;if(x||(x=pt),s.size!=a.size&&!B)return!1;var $=L.get(s);if($)return $==a;g|=o,L.set(s,a);var tt=sr(x(s),x(a),g,R,O,L);return L.delete(s),tt;case U:if(er)return er.call(s)==er.call(a)}return!1}function Ln(s,a,l,g,R,O){var L=l&i,x=Se(s),B=x.length,$=Se(a),tt=$.length;if(B!=tt&&!L)return!1;for(var lt=B;lt--;){var G=x[lt];if(!(L?G in a:st.call(a,G)))return!1}var et=O.get(s);if(et&&O.get(a))return et==a;var Z=!0;O.set(s,a),O.set(a,s);for(var Zt=L;++lt<B;){G=x[lt];var Nt=s[G],Ee=a[G];if(g)var Si=L?g(Ee,Nt,G,a,s,O):g(Nt,Ee,G,s,a,O);if(!(Si===void 0?Nt===Ee||R(Nt,Ee,l,g,O):Si)){Z=!1;break}Zt||(Zt=G=="constructor")}if(Z&&!Zt){var Or=s.constructor,Dr=a.constructor;Or!=Dr&&"constructor"in s&&"constructor"in a&&!(typeof Or=="function"&&Or instanceof Or&&typeof Dr=="function"&&Dr instanceof Dr)&&(Z=!1)}return O.delete(s),O.delete(a),Z}function Se(s){return nr(s,or,zn)}function gt(s,a){var l=s.__data__;return Fn(a)?l[typeof a=="string"?"string":"hash"]:l.map}function Lt(s,a){var l=Yt(s,a);return Rn(l)?l:void 0}function zt(s){var a=st.call(s,ct),l=s[ct];try{s[ct]=void 0;var g=!0}catch{}var R=ke.call(s);return g&&(a?s[ct]=l:delete s[ct]),R}var zn=Pt?function(s){return s==null?[]:(s=Object(s),me(Pt(s),function(a){return Ct.call(s,a)}))}:jn,Et=ve;(Kt&&Et(new Kt(new ArrayBuffer(1)))!=F||vt&&Et(new vt)!=y||Vt&&Et(Vt.resolve())!=E||qt&&Et(new qt)!=T||tr&&Et(new tr)!=K)&&(Et=function(s){var a=ve(s),l=a==b?s.constructor:void 0,g=l?it(l):"";if(g)switch(g){case yr:return F;case xt:return y;case on:return E;case cn:return T;case un:return K}return a});function Nn(s,a){return a=a??u,!!a&&(typeof s=="number"||le.test(s))&&s>-1&&s%1==0&&s<a}function Fn(s){var a=typeof s;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?s!=="__proto__":s===null}function $n(s){return!!be&&be in s}function Hn(s){var a=s&&s.constructor,l=typeof a=="function"&&a.prototype||bt;return s===l}function Sr(s){return ke.call(s)}function it(s){if(s!=null){try{return Wt.call(s)}catch{}try{return s+""}catch{}}return""}function Er(s,a){return s===a||s!==s&&a!==a}var Tr=_r(function(){return arguments}())?_r:function(s){return Tt(s)&&st.call(s,"callee")&&!Ct.call(s,"callee")},Ue=Array.isArray;function ir(s){return s!=null&&ar(s.length)&&!wr(s)}var je=Xt||Bn;function Un(s,a){return vr(s,a)}function wr(s){if(!Ar(s))return!1;var a=ve(s);return a==k||a==_||a==p||a==S}function ar(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=u}function Ar(s){var a=typeof s;return s!=null&&(a=="object"||a=="function")}function Tt(s){return s!=null&&typeof s=="object"}var Mr=jt?Le(jt):Cn;function or(s){return ir(s)?On(s):Pn(s)}function jn(){return[]}function Bn(){return!1}t.exports=Un}(dr,dr.exports);var zi=dr.exports;const Y=Nr(zi),Ni="add",es="track",rs="trackItems",Fi=`${es}:changed`,$i=`${rs}:changed`,ns="state",Hi=`${ns}:changed`,ss="bulk",Fr=`${ss}:edit`,fr="design",is=`${fr}:load`,as=`${fr}:resize`,j="add",os=`${j}:text`,cs=`${j}:video`,us=`${j}:audio`,Ui=`${j}:placeholder`,ls=`${j}:image`,ds=`${j}:illustration`,fs=`${j}:shape`,ji=`${j}:mask`,Bi=`${j}:transition`,ps=`${j}:animation`,hs=`${j}:caption`,ms=`${j}:template`,Is=`${j}:items`,gs=`${j}:composition`,ys=`${j}:progressBar`,bs=`${j}:progressFrame`,ks=`${j}:radialAudioBars`,_s=`${j}:linealAudioBars`,vs=`${j}:progressSquare`,Ss=`${j}:waveAudioBars`,Es=`${j}:hillAudioBars`,Ts=`${j}:rect`,At="edit",ws=`${At}:object`,As=`${At}:replaceMedia`,Yi=`${At}:text`,Wi=`${At}:shape`,Gi=`${At}:templateItem`,Xi=`${At}:deleteTemplateItem`,Ms=`${At}:backgroundEditor`,Ki="enterEditMode",te="active",Vi=`${te}:set`,qi=`${te}:delete`,Os=`${te}:paste`,Ji=`${te}:clone`,Ds=`${te}:split`,V="layer",Zi=`${V}:locked`,Qi=`${V}:hidden`,ta=`${V}:move`,Rs=`${V}:select`,ea=`${V}:selection`,ra=`${V}:sendTo`,na=`${V}:rename`,sa=`${V}:editingName`,Cs=`${V}:copy`,ia=`${V}:paste`,Ps=`${V}:clone`,aa=`${V}:split`,oa=`${V}:cut`,xs=`${V}:delete`,Ls=`${V}:replace`,Ye="history",zs=`${Ye}:undo`,Ns=`${Ye}:redo`,ca=`${Ye}:reset`,$r="scale",Fs=`${$r}:changed`;var pr={exports:{}};pr.exports,function(t,r){var e=200,n="__lodash_hash_undefined__",i=9007199254740991,o="[object Arguments]",u="[object Array]",c="[object Boolean]",d="[object Date]",p="[object Error]",h="[object Function]",I="[object GeneratorFunction]",m="[object Map]",k="[object Number]",_="[object Object]",y="[object Promise]",v="[object RegExp]",f="[object Set]",b="[object String]",E="[object Symbol]",S="[object WeakMap]",M="[object ArrayBuffer]",T="[object DataView]",A="[object Float32Array]",U="[object Float64Array]",P="[object Int8Array]",K="[object Int16Array]",D="[object Int32Array]",F="[object Uint8Array]",nt="[object Uint8ClampedArray]",ce="[object Uint16Array]",ue="[object Uint32Array]",Ae=/[\\^$.*+?()[\]{}|]/g,Me=/\w*$/,Oe=/^\[object .+?Constructor\]$/,De=/^(?:0|[1-9]\d*)$/,z={};z[o]=z[u]=z[M]=z[T]=z[c]=z[d]=z[A]=z[U]=z[P]=z[K]=z[D]=z[m]=z[k]=z[_]=z[v]=z[f]=z[b]=z[E]=z[F]=z[nt]=z[ce]=z[ue]=!0,z[p]=z[h]=z[S]=!1;var Re=typeof ht=="object"&&ht&&ht.Object===Object&&ht,Ce=typeof self=="object"&&self&&self.Object===Object&&self,at=Re||Ce||Function("return this")(),le=r&&!r.nodeType&&r,N=le&&!0&&t&&!t.nodeType&&t,de=N&&N.exports===le;function Pe(s,a){return s.set(a[0],a[1]),s}function ot(s,a){return s.add(a),s}function fe(s,a){for(var l=-1,g=s?s.length:0;++l<g&&a(s[l],l,s)!==!1;);return s}function pe(s,a){for(var l=-1,g=a.length,R=s.length;++l<g;)s[R+l]=a[l];return s}function Ht(s,a,l,g){for(var R=-1,O=s?s.length:0;++R<O;)l=a(l,s[R],R,s);return l}function Ut(s,a){for(var l=-1,g=Array(s);++l<s;)g[l]=a(l);return g}function he(s,a){return s==null?void 0:s[a]}function jt(s){var a=!1;if(s!=null&&typeof s.toString!="function")try{a=!!(s+"")}catch{}return a}function me(s){var a=-1,l=Array(s.size);return s.forEach(function(g,R){l[++a]=[R,g]}),l}function Bt(s,a){return function(l){return s(a(l))}}function Ie(s){var a=-1,l=Array(s.size);return s.forEach(function(g){l[++a]=g}),l}var xe=Array.prototype,Le=Function.prototype,Mt=Object.prototype,Yt=at["__core-js_shared__"],ge=function(){var s=/[^.]+$/.exec(Yt&&Yt.keys&&Yt.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),ye=Le.toString,pt=Mt.hasOwnProperty,Ot=Mt.toString,ze=RegExp("^"+ye.call(pt).replace(Ae,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bt=de?at.Buffer:void 0,Dt=at.Symbol,Wt=at.Uint8Array,st=Bt(Object.getPrototypeOf,Object),be=Object.create,ke=Mt.propertyIsEnumerable,Ne=xe.splice,Gt=Object.getOwnPropertySymbols,Rt=bt?bt.isBuffer:void 0,_e=Bt(Object.keys,Object),Ct=gt(at,"DataView"),kt=gt(at,"Map"),ct=gt(at,"Promise"),Pt=gt(at,"Set"),Xt=gt(at,"WeakMap"),_t=gt(Object,"create"),Kt=it(Ct),vt=it(kt),Vt=it(ct),qt=it(Pt),tr=it(Xt),Jt=Dt?Dt.prototype:void 0,yr=Jt?Jt.valueOf:void 0;function xt(s){var a=-1,l=s?s.length:0;for(this.clear();++a<l;){var g=s[a];this.set(g[0],g[1])}}function on(){this.__data__=_t?_t(null):{}}function cn(s){return this.has(s)&&delete this.__data__[s]}function un(s){var a=this.__data__;if(_t){var l=a[s];return l===n?void 0:l}return pt.call(a,s)?a[s]:void 0}function br(s){var a=this.__data__;return _t?a[s]!==void 0:pt.call(a,s)}function er(s,a){var l=this.__data__;return l[s]=_t&&a===void 0?n:a,this}xt.prototype.clear=on,xt.prototype.delete=cn,xt.prototype.get=un,xt.prototype.has=br,xt.prototype.set=er;function J(s){var a=-1,l=s?s.length:0;for(this.clear();++a<l;){var g=s[a];this.set(g[0],g[1])}}function ln(){this.__data__=[]}function dn(s){var a=this.__data__,l=$e(a,s);if(l<0)return!1;var g=a.length-1;return l==g?a.pop():Ne.call(a,l,1),!0}function fn(s){var a=this.__data__,l=$e(a,s);return l<0?void 0:a[l][1]}function pn(s){return $e(this.__data__,s)>-1}function hn(s,a){var l=this.__data__,g=$e(l,s);return g<0?l.push([s,a]):l[g][1]=a,this}J.prototype.clear=ln,J.prototype.delete=dn,J.prototype.get=fn,J.prototype.has=pn,J.prototype.set=hn;function Q(s){var a=-1,l=s?s.length:0;for(this.clear();++a<l;){var g=s[a];this.set(g[0],g[1])}}function mn(){this.__data__={hash:new xt,map:new(kt||J),string:new xt}}function In(s){return Se(this,s).delete(s)}function gn(s){return Se(this,s).get(s)}function yn(s){return Se(this,s).has(s)}function bn(s,a){return Se(this,s).set(s,a),this}Q.prototype.clear=mn,Q.prototype.delete=In,Q.prototype.get=gn,Q.prototype.has=yn,Q.prototype.set=bn;function ut(s){this.__data__=new J(s)}function kn(){this.__data__=new J}function _n(s){return this.__data__.delete(s)}function vn(s){return this.__data__.get(s)}function Sn(s){return this.__data__.has(s)}function En(s,a){var l=this.__data__;if(l instanceof J){var g=l.__data__;if(!kt||g.length<e-1)return g.push([s,a]),this;l=this.__data__=new Q(g)}return l.set(s,a),this}ut.prototype.clear=kn,ut.prototype.delete=_n,ut.prototype.get=vn,ut.prototype.has=Sn,ut.prototype.set=En;function Fe(s,a){var l=ir(s)||Ue(s)?Ut(s.length,String):[],g=l.length,R=!!g;for(var O in s)pt.call(s,O)&&!(R&&(O=="length"||Fn(O,g)))&&l.push(O);return l}function kr(s,a,l){var g=s[a];(!(pt.call(s,a)&&Tr(g,l))||l===void 0&&!(a in s))&&(s[a]=l)}function $e(s,a){for(var l=s.length;l--;)if(Tr(s[l][0],a))return l;return-1}function St(s,a){return s&&sr(a,or(a),s)}function rr(s,a,l,g,R,O,L){var x;if(g&&(x=O?g(s,R,O,L):g(s)),x!==void 0)return x;if(!Tt(s))return s;var B=ir(s);if(B){if(x=zn(s),!a)return Pn(s,x)}else{var $=zt(s),tt=$==h||$==I;if(wr(s))return He(s,a);if($==_||$==o||tt&&!O){if(jt(s))return O?s:{};if(x=Et(tt?{}:s),!a)return xn(s,St(x,s))}else{if(!z[$])return O?s:{};x=Nn(s,$,rr,a)}}L||(L=new ut);var lt=L.get(s);if(lt)return lt;if(L.set(s,x),!B)var G=l?Ln(s):or(s);return fe(G||s,function(et,Z){G&&(Z=et,et=s[Z]),kr(x,Z,rr(et,a,l,g,Z,s,L))}),x}function Tn(s){return Tt(s)?be(s):{}}function wn(s,a,l){var g=a(s);return ir(s)?g:pe(g,l(s))}function An(s){return Ot.call(s)}function Mn(s){if(!Tt(s)||Hn(s))return!1;var a=ar(s)||jt(s)?ze:Oe;return a.test(it(s))}function On(s){if(!Sr(s))return _e(s);var a=[];for(var l in Object(s))pt.call(s,l)&&l!="constructor"&&a.push(l);return a}function He(s,a){if(a)return s.slice();var l=new s.constructor(s.length);return s.copy(l),l}function nr(s){var a=new s.constructor(s.byteLength);return new Wt(a).set(new Wt(s)),a}function ve(s,a){var l=a?nr(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.byteLength)}function _r(s,a,l){var g=a?l(me(s),!0):me(s);return Ht(g,Pe,new s.constructor)}function vr(s){var a=new s.constructor(s.source,Me.exec(s));return a.lastIndex=s.lastIndex,a}function Dn(s,a,l){var g=a?l(Ie(s),!0):Ie(s);return Ht(g,ot,new s.constructor)}function Rn(s){return yr?Object(yr.call(s)):{}}function Cn(s,a){var l=a?nr(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.length)}function Pn(s,a){var l=-1,g=s.length;for(a||(a=Array(g));++l<g;)a[l]=s[l];return a}function sr(s,a,l,g){l||(l={});for(var R=-1,O=a.length;++R<O;){var L=a[R],x=void 0;kr(l,L,x===void 0?s[L]:x)}return l}function xn(s,a){return sr(s,Lt(s),a)}function Ln(s){return wn(s,or,Lt)}function Se(s,a){var l=s.__data__;return $n(a)?l[typeof a=="string"?"string":"hash"]:l.map}function gt(s,a){var l=he(s,a);return Mn(l)?l:void 0}var Lt=Gt?Bt(Gt,Object):jn,zt=An;(Ct&&zt(new Ct(new ArrayBuffer(1)))!=T||kt&&zt(new kt)!=m||ct&&zt(ct.resolve())!=y||Pt&&zt(new Pt)!=f||Xt&&zt(new Xt)!=S)&&(zt=function(s){var a=Ot.call(s),l=a==_?s.constructor:void 0,g=l?it(l):void 0;if(g)switch(g){case Kt:return T;case vt:return m;case Vt:return y;case qt:return f;case tr:return S}return a});function zn(s){var a=s.length,l=s.constructor(a);return a&&typeof s[0]=="string"&&pt.call(s,"index")&&(l.index=s.index,l.input=s.input),l}function Et(s){return typeof s.constructor=="function"&&!Sr(s)?Tn(st(s)):{}}function Nn(s,a,l,g){var R=s.constructor;switch(a){case M:return nr(s);case c:case d:return new R(+s);case T:return ve(s,g);case A:case U:case P:case K:case D:case F:case nt:case ce:case ue:return Cn(s,g);case m:return _r(s,g,l);case k:case b:return new R(s);case v:return vr(s);case f:return Dn(s,g,l);case E:return Rn(s)}}function Fn(s,a){return a=a??i,!!a&&(typeof s=="number"||De.test(s))&&s>-1&&s%1==0&&s<a}function $n(s){var a=typeof s;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?s!=="__proto__":s===null}function Hn(s){return!!ge&&ge in s}function Sr(s){var a=s&&s.constructor,l=typeof a=="function"&&a.prototype||Mt;return s===l}function it(s){if(s!=null){try{return ye.call(s)}catch{}try{return s+""}catch{}}return""}function Er(s){return rr(s,!0,!0)}function Tr(s,a){return s===a||s!==s&&a!==a}function Ue(s){return Un(s)&&pt.call(s,"callee")&&(!ke.call(s,"callee")||Ot.call(s)==o)}var ir=Array.isArray;function je(s){return s!=null&&Ar(s.length)&&!ar(s)}function Un(s){return Mr(s)&&je(s)}var wr=Rt||Bn;function ar(s){var a=Tt(s)?Ot.call(s):"";return a==h||a==I}function Ar(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=i}function Tt(s){var a=typeof s;return!!s&&(a=="object"||a=="function")}function Mr(s){return!!s&&typeof s=="object"}function or(s){return je(s)?Fe(s):On(s)}function jn(){return[]}function Bn(){return!1}t.exports=Er}(pr,pr.exports);var ua=pr.exports;const C=Nr(ua);function la(t,r){return t.filter(n=>{if(r.forEach(i=>{n.items.includes(i)&&(n.items=n.items.filter(o=>o!==i))}),n.items.length!==0||n.static)return n})}const X=t=>Object.keys(t).reduce((r,e)=>{const{display:n}=t[e];return Math.max(r,n.to)},0);function rt(t,r,e){t.forEach(n=>{const i=n.items.map(_=>String(_)),o=Object.values(r).filter(_=>i.includes(String(_.id))),c=o.filter(_=>!e.includes(String(_.id))).sort((_,y)=>_.display.from-y.display.from),d=o.sort((_,y)=>_.display.from-y.display.from),p=c[c.length-1];let h=(p==null?void 0:p.display.to)||0;d.forEach(_=>{if(e.includes(String(_.id))){const y=_.playbackRate||1;let v;(_.type==="video"||_.type==="audio")&&_.trim?v=(_.trim.to-_.trim.from)/y:v=_.display.to-_.display.from,_.display={from:h,to:h+v},h=h+v}});const m=o.sort((_,y)=>_.display.from-y.display.from).map(_=>String(_.id));let k=0;m.forEach(_=>{const y=[];let v=0;if(y.forEach(f=>{f.forEach(b=>{b.type==="transition"&&(v+=b.duration)})}),r[String(_)]){const f=r[String(_)],b=f.playbackRate||1;let E;(f.type==="video"||f.type==="audio")&&f.trim?E=(f.trim.to-f.trim.from)/b:E=f.display.to-f.display.from,r[String(_)].display={from:k-v,to:k+E-v},k+=E}})})}function $s(t,r,e,n,i,o){return r.forEach(u=>{if(!t.includes(u)&&(i[u]=e[u],e[u].type==="composition"||e[u].type==="template")){const c=n.find(d=>d.id===u);c&&(o.push(c),$s(t,c.items,e,n,i,o))}}),{updatedTrackItems:i,updatedStructure:o}}function da(t,r){const e=C(t),n=r&&r.length?r:e.activeIds,i=n.map(T=>e.trackItemsMap[T]).filter(T=>!!T).map(T=>T.id),o=e.transitionIds.filter(T=>{const A=e.transitionsMap[T];return i.includes(A.fromId)||i.includes(A.toId)});i.push(...o);const u=e.trackItemIds,c=e.transitionIds,d=C(e.tracks),p=C(e.structure);i.forEach(T=>{var U;const A=e.trackItemsMap[T]||e.transitionsMap[T];if(A.type==="template"||A.type==="composition"){const P=(U=e.structure.find(D=>D.id===A.id))==null?void 0:U.items;i.push(...P);const K=p.findIndex(D=>D.id===A.id);p.splice(K,1)}}),i.forEach(T=>{p.forEach(A=>{A.items.includes(T)&&(A.items=A.items.filter(U=>U!==T))})});const h=u.filter(T=>!i.includes(T));c.forEach(T=>{n.includes(T)&&n.length===1&&C(e.transitionsMap[T])});const I=c.filter(T=>!i.includes(T)&&!n.includes(T)),m=Object.fromEntries(Object.entries(e.transitionsMap).filter(([T])=>!i.includes(T)));Object.keys(m).forEach(T=>{n.includes(T)&&(m[T].kind="none")});const k=e.trackItemIds.filter(T=>!n.includes(T)),_=la(e.tracks,n),y=Object.fromEntries(Object.entries(e.trackItemsMap).filter(([T])=>!i.includes(T))),v=d.filter(T=>T.magnetic);rt(v,y,[]);const f={},b=[],{updatedTrackItems:E,updatedStructure:S}=$s(i,k,e.trackItemsMap,e.structure,f,b),M=X(E);return{trackItemIds:h,activeIds:[],trackItemsMap:E,tracks:_,duration:M,structure:S,transitionIds:I,transitionsMap:m}}const fa="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Hr=(t=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)r+=fa[e[t]&63];return r};function ee(t=16){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e=r.charAt(Math.floor(Math.random()*r.length));let n=Hr(t-1);return n=n.replace(/[^a-zA-Z0-9]/g,"").slice(0,t-1),e+n}const Te=t=>{const r=t.map(e=>new FontFace(e.fontFamily,`url(${e.url})`).load().catch(n=>n));return r.length===0?Promise.resolve(!0):new Promise((e,n)=>{Promise.all(r).then(i=>{i.forEach(o=>{o&&o.family&&(document.fonts.add(o),e(!0))})}).catch(i=>n(i))})};function pa(t,r){return t.forEach(e=>{r=r.split(e).join(ee())}),r}function Hs(t,r,e){const n=t.find(o=>o.id===r);if(!n)return[];const i=n.items;return i.forEach(o=>{const u=e[o];(u.type==="text"||u.type==="caption")&&Te([{fontFamily:u.details.fontFamily,url:u.details.fontUrl}]),(u.type==="composition"||u.type==="template")&&i.push(...Hs(t,o,e))}),i}async function ha(t){let r=localStorage.getItem("DesignComboTemp");if(!r)return{};const e=C(t);let n=C(JSON.parse(r));const i=n.activeIds,o=n.trackItemsMap,u=n.structure;Object.keys(o).forEach(y=>{const v=o[y];if((v.type==="text"||v.type==="caption")&&Te([{fontFamily:v.details.fontFamily,url:v.details.fontUrl}]),v.type==="composition"||v.type==="template"){const f=Hs(u,y,o);i.push(...f)}});const c=pa(i,r),d=C(JSON.parse(c)),p=e.tracks;d.activeIds.forEach(y=>{const v=d.trackItemsMap[y];e.trackItemsMap[y]=v,e.trackItemIds.push(y);const f={id:ee(),type:v.type,items:[y],magnetic:!1,static:!1};p.unshift(f)});const h=[...d.structure,...e.structure],I=e.trackItemIds,m={...d.trackItemsMap,...e.trackItemsMap},k={structure:h,trackItemIds:I,trackItemsMap:m,tracks:p},_=X(k.trackItemsMap);return{trackItemIds:k.trackItemIds,trackItemsMap:k.trackItemsMap,structure:k.structure,tracks:k.tracks,duration:_}}let hr={cors:{audio:!0,video:!0,image:!0},acceptsMap:{text:["text","caption","composition"],image:["image","video"],video:["video","image"],audio:["audio"],composition:["composition"],caption:["caption","text","composition"],template:["template","image","video"],customTrack:["video","image","template"],customTrack2:["video","image","template"],illustration:["illustration","custom"],custom:["custom","video","illustration"],main:["video","image","template"],shape:["shape","custom","illustration"],linealAudioBars:["audio","linealAudioBars"],radialAudioBars:["audio","radialAudioBars"],progressFrame:["audio","progressFrame"],progressBar:["audio","progressBar"],rect:["rect"],progressSquare:["progressSquare"]}};const ma=t=>{const r=Object.fromEntries(Object.entries(t).filter(([e,n])=>n!==void 0));hr={...hr,...r}},Ur=()=>hr.cors,jr=()=>hr.acceptsMap,we=t=>new Promise((r,e)=>{const n=new Image;n.onload=()=>{const o=n.width,u=n.height;r({width:o,height:u})},n.onerror=o=>{e(o)},Ur().image&&(n.crossOrigin="anonymous"),n.src=t}),Us=t=>new Promise((r,e)=>{const n=new Audio;n.preload="auto",n.addEventListener("loadedmetadata",()=>{const o=n.duration*1e3;r({duration:o})}),n.addEventListener("error",o=>{e(o)}),n.src=t,Ur().audio&&(n.crossOrigin="anonymous"),n.load()}),Br=t=>new Promise((r,e)=>{const n=document.createElement("video");n.preload="auto",n.addEventListener("loadedmetadata",()=>{const o=n.duration*1e3,u=n.videoWidth,c=n.videoHeight;r({duration:o,width:u,height:c})}),n.addEventListener("error",o=>{e(o)}),n.src=t,Ur().video&&(n.crossOrigin="anonymous"),n.load()}),Ia=async t=>{var i,o;const r=t.duration,e=(i=t.details)==null?void 0:i.width,n=(o=t.details)==null?void 0:o.height;return r&&e&&n?{duration:r,width:e,height:n}:Br(t.details.src)},js=(t,r)=>{const e=document.createElement("div");Object.keys(r).forEach(i=>{i!=="height"&&(e.style[i]=r[i])}),document.body.appendChild(e),e.textContent=t,e.style.whiteSpace="normal",e.style.position="absolute",e.style.visibility="hidden",e.style.display="inline-block",e.style.width=r.width+"px",e.style.fontSize=r.fontSize+"px";const n=getComputedStyle(e).height;return document.body.removeChild(e),parseFloat(n)},Bs=(t,r)=>{var c,d;const e=((c=t.details.crop)==null?void 0:c.width)||t.details.width||0,n=((d=t.details.crop)==null?void 0:d.height)||t.details.height||0;let i=r.width,o=r.height;const u=r.width/r.height;return e/n>u?(i=e,o=e/u):(o=n,i=n*u),{newWidth:i,newHeight:o,crop:{x:0,y:0,height:n,width:e}}},Ys=(t,r)=>{const e=C(t.trim),n=C(t.display);return r.duration<t.display.to&&(n.to=r.duration+t.display.from,e&&(e.to=r.duration)),{duration:r.duration,trim:e,display:n}};async function ga(t,r){const e={...t},n=Object.keys(r)[0],i=Object.values(r)[0],o=e.trackItemsMap[n],u={...e.trackItemsMap[n]},c=o.details;if(!i.details.src)return{};if(o.type==="image"){const d=await we(i.details.src),{crop:p,newHeight:h,newWidth:I}=Bs(o,d);i.details.crop=p,i.details.height=h,i.details.width=I}else if(o.type==="video"){const d=await Br(i.details.src),p=e.trackItemsMap[n],{display:h,duration:I,trim:m}=Ys(p,d),{crop:k,newHeight:_,newWidth:y}=Bs(o,d);i.details.crop=k,i.details.height=_,i.details.width=y,u.display=h,u.duration=I,u.trim=m}else if(o.type==="audio"){const d=await Us(i.details.src),p=e.trackItemsMap[n],{display:h,duration:I,trim:m}=Ys(p,d);u.display=h,u.duration=I,u.trim=m}return o.metadata&&i.metadata?u.metadata={...o.metadata,...i.metadata}:i.metadata&&(u.metadata=i.metadata),o.details={...c,...i.details},e.trackItemsMap[n]={...u},{trackItemsMap:{...e.trackItemsMap,[n]:{...u,details:{...c,...i.details}}}}}function ya(t,r){const e=C(t),n={},i=r&&r.length?r:e.activeIds;if(i.length===0)return{};i.forEach(u=>{const c=e.trackItemsMap[u],d=ee();e.trackItemsMap[d]={...C(c),id:d},e.trackItemIds.push(d);const p=e.tracks.find(h=>h.items.includes(u));n[p.id]?n[p.id].items.push(d):n[p.id]={...p,id:ee(),items:[d],static:!1,magnetic:!1}});const o=Object.values(n);return e.tracks=[...o,...e.tracks],{trackItemsMap:e.trackItemsMap,tracks:e.tracks,trackItemIds:e.trackItemIds}}function ba(t){const r=/#([0-9a-fA-F]{3,6})\b/g,e=/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/g,n=/rgba\(\s*(\d+),\s*(\d+),\s*(\d+),\s*([0-9.]+)\s*\)/g;function i(u){return u.length===3?`#${u[0]}${u[0]}${u[1]}${u[1]}${u[2]}${u[2]}`.toUpperCase():`#${u.toUpperCase()}`}function o(u,c,d){return`#${(1<<24|u<<16|c<<8|d).toString(16).slice(1).toUpperCase()}`}return t=t.replace(r,(u,c)=>i(c)),t=t.replace(e,(u,c,d,p)=>o(+c,+d,+p)),t=t.replace(n,(u,c,d,p)=>o(+c,+d,+p)),t}function q(t){return/^#[0-9a-fA-F]{3}$/.test(t)?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}function Ws(t,r){let e=t;for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)){const i=new RegExp(n,"g");e=e.replace(i,r[n])}return e}function Gs(t){const r=t.getAttribute("fill");if(r&&r.trim()!==""&&r.trim()!=="none")return r.trim();const e=t.getAttribute("style");if(e){const i=/fill\s*:\s*([^;]+);?/.exec(e);if(i){const o=i[1].trim();if(o!==""&&o!=="none")return o}}const n=t.parentElement;return n?Gs(n):null}function We(t){return/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(t)}const ka=t=>{const r=`.${t.split(".").filter(o=>o.includes("fill:")).join(".")}`,e={},n=/\.([\w-]+)\s*\{\s*([^}]+)\s*\}/g;let i;for(;(i=n.exec(r))!==null;){const o=i[1],u=i[2],c={},d=/fill\s*:\s*([^;]+);?/.exec(u),p=/stroke\s*:\s*([^;]+);?/.exec(u);d&&(c.fill=q(d[1].trim())),p&&(c.stroke=q(p[1].trim())),e[o]=c}return e};function Yr(t){let r=t.parentElement;for(;r;){if(r.tagName.toLowerCase()==="mask")return!0;r=r.parentElement}return!1}function _a(t,r,e=300,n=300){const i=[],u=new DOMParser().parseFromString(t,"image/svg+xml"),c=u.documentElement;c.setAttribute("width",`${e}`),c.setAttribute("height",`${n}`);const d=c.querySelectorAll("style"),p={};d.forEach(y=>{const v=y.textContent||"",f=ka(v);Object.assign(p,f);const b=v.replace(/\.(st[\w-]+)/g,`.${r}-$1`).replace(/url\(#(.*?)\)/g,`url(#${r}-$1)`);y.textContent=b;const E=Array.from(u.querySelectorAll("*")),S=new Set;E.forEach(M=>{if(Yr(M))return;["fill","stroke","stop-color"].forEach(U=>{const P=M.getAttribute(U);P&&!["none","transparent"].includes(P)&&S.add(q(P))});const T=M.getAttribute("style");if(T){const U=/fill\s*:\s*([^;]+);?/.exec(T),P=/stroke\s*:\s*([^;]+);?/.exec(T),K=/stop-color\s*:\s*([^;]+);?/.exec(T);if(U){const D=U[1].trim();D&&!["none","transparent"].includes(D)&&We(q(D))&&S.add(q(D))}if(P){const D=P[1].trim();D&&!["none","transparent"].includes(D)&&We(q(D))&&S.add(q(D))}if(K){const D=K[1].trim();D&&!["none","transparent"].includes(D)&&We(q(D))&&S.add(q(D))}}const A=M.getAttribute("class");A&&A.split(" ").forEach(U=>{const P=p[U];P!=null&&P.fill&&!["none","transparent"].includes(P.fill)&&S.add(q(P.fill)),P!=null&&P.stroke&&!["none","transparent"].includes(P.stroke)&&S.add(q(P.stroke))})}),Array.from(S).forEach(M=>{We(M)&&i.push(M)})});const h=Array.from(u.querySelectorAll("*")),I=new Set;return h.forEach(y=>{if(Yr(y))return;const v=y.getAttribute("class");if(v){const b=v.split(" ").map(E=>`${r}-${E}`).join(" ");y.setAttribute("class",b),b.split(" ").forEach(E=>{const S=p[E];S!=null&&S.fill&&!["none","transparent"].includes(S.fill)&&I.add(q(S.fill)),S!=null&&S.stroke&&!["none","transparent"].includes(S.stroke)&&I.add(q(S.stroke))})}["fill","stroke","stop-color"].forEach(b=>{const E=y.getAttribute(b);E&&!["none","transparent"].includes(E)&&I.add(q(E))});const f=y.getAttribute("style");if(f){const b=/fill\s*:\s*([^;]+);?/.exec(f),E=/stroke\s*:\s*([^;]+);?/.exec(f),S=/stop-color\s*:\s*([^;]+);?/.exec(f);if(b){const M=b[1].trim();M&&!["none","transparent"].includes(M)&&I.add(q(M))}if(E){const M=E[1].trim();M&&!["none","transparent"].includes(M)&&I.add(q(M))}if(S){const M=S[1].trim();M&&!["none","transparent"].includes(M)&&I.add(q(M))}}}),I.forEach(y=>!i.includes(y)&&We(y)&&i.push(y)),Array.from(u.querySelectorAll("*")).forEach(y=>{if(y.hasAttribute("id")){const v=y.getAttribute("id");y.setAttribute("id",`${r}-${v}`)}if(["fill","stroke","stop-color","filter","clip-path","mask"].forEach(v=>{const f=y.getAttribute(v);f&&f.includes("url(#")&&y.setAttribute(v,f.replace(/url\(#(.*?)\)/g,`url(#${r}-$1)`))}),y.hasAttribute("style")){const v=y.getAttribute("style");v.includes("url(#")&&y.setAttribute("style",v.replace(/url\(#(.*?)\)/g,`url(#${r}-$1)`))}}),Array.from(u.querySelectorAll("path")).forEach(y=>{if(Yr(y))return;!Gs(y)&&!y.getAttribute("class")&&(y.setAttribute("fill","#000000"),i.includes("#000000")||i.push("#000000"))}),{serializer:new XMLSerializer().serializeToString(u),colors:i}}const Ge={color:"#000000",x:0,y:0,blur:0},mt=(t,r)=>{let e=r!=null&&r.trim?r.trim.to-r.trim.from:(r==null?void 0:r.duration)||5e3;const n={from:0,to:e};if(!t)return n;if(t.from<0)return console.error("'from' must be a non-negative number. Returning default display."),n;if(t.from!==void 0&&t.to===void 0)return{from:t.from,to:t.from+e};if(t.to!==void 0){if(t.to<0)return console.error("'to' must be a non-negative number. Returning default display."),n;if(t.to<t.from)return console.error("'to' must be greater than or equal to 'from'. Returning default display."),n}return t},Xs=(t,r)=>t?t.from&&!t.to?{from:t.from,to:r.duration}:t:{from:0,to:r.duration};function Ks(t,r){const e={x:t.size.width/2,y:t.size.height/2},n={x:r.width/2,y:r.height/2},i=e.x-n.x;return{top:`${e.y-n.y}px`,left:`${i}px`,transform:"none"}}function It(t,r){const e=t.scaleMode,n={x:t.size.width/2,y:t.size.height/2},i={x:r.width/2,y:r.height/2};let o;if(e==="fill")o=Math.max(t.size.width/r.width,t.size.height/r.height);else if(e==="fit"){const d=t.scaleAspectRatio||1;o=Math.min(t.size.width/r.width,t.size.height/r.height)*d}else o=Math.min(t.size.width/r.width,t.size.height/r.height);const u=n.x-i.x;return{top:`${n.y-i.y}px`,left:`${u}px`,transform:`scale(${o})`}}const Vs=async(t,r)=>{const e=t.details.src,n=await Ia(t),i=It(r,{...n}),o=Xs(t.trim,{duration:n.duration}),u={width:n.width,height:n.height,opacity:100,src:e,volume:t.details.volume??100,borderRadius:t.details.borderRadius??0,borderWidth:t.details.borderWidth??0,borderColor:t.details.borderColor||"#000000",boxShadow:t.details.boxShadow||Ge,top:t.details.top||i.top||"0px",left:t.details.left||i.left||"0px",transform:t.details.transform||i.transform,blur:t.details.blur||0,brightness:t.details.brightness||100,flipX:t.details.flipX||!1,flipY:t.details.flipY||!1,rotate:t.details.rotate||"0deg",visibility:t.details.visibility||"visible"};return{...t,trim:o,type:"video",name:"video",details:u,playbackRate:t.playbackRate||1,display:mt(t.display,{duration:n.duration,trim:o}),duration:n.duration}},qs=async t=>{const r=t.id,e=t.details,i=(await Us(e.src)).duration,o=Xs(t.trim,{duration:i});return{id:r,name:t.name||"audio",type:"audio",display:mt(t.display,{duration:i,trim:o}),trim:o,playbackRate:t.playbackRate||1,details:{src:e.src,volume:e.volume??100},metadata:{...t.metadata},duration:i}},va=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,o=It(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||o.top,left:(i==null?void 0:i.left)||o.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1,inverted:i.inverted||!1,backgroundColors:(i==null?void 0:i.backgroundColors)||["rgba(128, 128, 128,0.5)","rgba(128, 128, 128,1)"]},metadata:{}}},Sa=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,o=It(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||o.top,left:(i==null?void 0:i.left)||o.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1,inverted:i.inverted||!1,backgroundColors:(i==null?void 0:i.backgroundColors)||["rgba(128, 128, 128,0.5)","rgba(128, 128, 128,1)"],barThickness:i.barThickness||10},metadata:{}}},Ea=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,o=It(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||o.top,left:(i==null?void 0:i.left)||o.left,radialBarColor:i.radialBarColor||"rgba(128, 128, 128,1)",border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1},metadata:{}}},Ta=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,o=It(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||o.top,left:(i==null?void 0:i.left)||o.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,strokeColors:(i==null?void 0:i.strokeColors)||["#ff9800","#ff5722"],strokeWidth:(i==null?void 0:i.strokeWidth)||100,strokeBackground:(i==null?void 0:i.strokeBackground)||"#fff",flipX:(i==null?void 0:i.flipX)||!1,flipY:(i==null?void 0:i.flipY)||!1,rotate:(i==null?void 0:i.rotate)||"0deg",transform:(i==null?void 0:i.transform)||"none"},metadata:{}}},Wr=async(t,r)=>{var u,c;const e=t.id,n={width:((u=t.details)==null?void 0:u.width)||r.size.width,height:((c=t.details)==null?void 0:c.height)||r.size.height},i=t.details,o=It(r,n);return{id:e,name:t.type,type:t.type,display:{from:0,to:t.duration||1e4},details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||o.top,left:(i==null?void 0:i.left)||o.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1,inverted:i.inverted||!1,linealBarColor:i.linealBarColor||"rgba(128, 128, 128,1)",lineThickness:i.lineThickness||1,gapSize:i.gapSize||1,roundness:i.roundness||1,placement:i.placement||null,strokeColor:i.strokeColor||"#92E1B0",fillColor:i.fillColor||null,strokeWidth:i.strokeWidth||null,copies:i.copies||null,offsetPixelSpeed:i.offsetPixelSpeed||0,lineColor:i.lineColor||"#92E1B0",lineGap:i.lineGap||0,topRoundness:i.topRoundness||0,bottomRoundness:i.bottomRoundness||0,lines:i.lines||0,sections:i.sections||0},metadata:{}}},Js=async(t,r)=>{var I;const e=t.trackItemIds,n=t.size||{width:t.details.width,height:t.details.height},i=Math.min(r.size.width/n.width,r.size.height/n.height),o=((I=t.details)==null?void 0:I.rotate)||0,u=It(r,n),c=t.display;let d=1/0,p=0;e.forEach(m=>{const k=t.trackItemsMap[m];k.display.from<d&&(d=k.display.from),k.display.to>p&&(p=k.display.to)});const h=t.trim||t.display||{from:d,to:p};return{id:t.id,type:"template",details:{...n,transform:t.details.transform||u.transform,top:t.details.top||u.top,left:t.details.left||u.left,scale:i,rotate:o,background:t.details.background||"transparent"},trim:h,display:c||{from:d,to:p},activeEdit:!1}},wa=async(t,r)=>{var h;const e=t.trackItemIds,n=t.size||{width:t.details.width,height:t.details.height},i=Math.min(r.size.width/n.width,r.size.height/n.height),o=((h=t.details)==null?void 0:h.rotate)||0,u=It(r,n),c=t.display;let d=1/0,p=0;return e.forEach(I=>{const m=t.trackItemsMap[I];m.display.from<d&&(d=m.display.from),m.display.to>p&&(p=m.display.to)}),{id:t.id,type:"composition",details:{...n,transform:t.details.transform||u.transform,top:t.details.top||u.top,left:t.details.left||u.left,scale:i,rotate:o},display:c||{from:d,to:p}}},Zs=async(t,r)=>{const e=t.details,n=we(e.src),i=fetch(e.src),[o,u]=await Promise.all([n,i]),c=await u.text(),d=It(r,o),{serializer:p,colors:h}=_a(ba(c),t.id,Number(e.width||o.width),Number(e.height||o.height)),I=t.details.colorMap||Object.fromEntries(h.map(m=>[m,m]));return{id:t.id,name:"illustration",type:t.type,display:mt(t.display),playbackRate:t.playbackRate||1,details:{src:e.src||"",width:e.width||o.width||100,height:e.height||o.height||100,opacity:e.opacity??100,transform:e.transform||d.transform,border:e.border||"none",borderRadius:e.borderRadius||0,top:e.top||d.top||"0px",left:e.left||d.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible",svgString:p,initialSvgString:C(p),colorMap:I},metadata:t.metadata||{}}},Aa=async(t,r)=>{const e=t.details,n=we(e.src),[i]=await Promise.all([n]),o=It(r,i);return{id:t.id,name:"shape",type:t.type,display:mt(t.display),playbackRate:t.playbackRate||1,details:{src:e.src||"",width:e.width||i.width||100,height:e.height||i.height||100,opacity:e.opacity??100,transform:e.transform||o.transform,border:e.border||"none",borderRadius:e.borderRadius||0,top:e.top||o.top||"0px",left:e.left||o.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible",backgroundColor:e.backgroundColor||"#808080"},metadata:t.metadata||{}}},Ma=async(t,r)=>{const e=t.details,n=It(r,{width:e.width,height:e.height});return{id:t.id,name:"rect",type:t.type,display:mt(t.display),playbackRate:t.playbackRate||1,details:{width:e.width||100,height:e.height||100,opacity:e.opacity??100,transform:e.transform||n.transform,border:e.border||"none",borderRadius:e.borderRadius||0,top:e.top||n.top||"0px",left:e.left||n.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible",backgroundColor:e.backgroundColor||"#808080",boxShadow:e.boxShadow||Ge,blur:e.blur||0,brightness:e.brightness||100},metadata:t.metadata||{}}},Qs=async(t,r)=>{const e=t.details,n=await we(e.src),i=It(r,n);return{id:t.id,type:"image",name:"image",display:mt(t.display),playbackRate:t.playbackRate||1,details:{src:e.src||"",width:e.width||n.width||100,height:e.height||n.height||100,opacity:e.opacity??100,transform:e.transform||i.transform,border:e.border||"none",borderRadius:e.borderRadius||0,boxShadow:e.boxShadow||Ge,top:e.top||i.top||"0px",left:e.left||i.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",blur:e.blur||0,brightness:e.brightness||100,flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible"},metadata:t.metadata||{}}},ti=async(t,r)=>{const e=t;e.details.fontUrl&&await Te([{fontFamily:e.details.fontFamily,url:e.details.fontUrl}]);const n=e.id,i=e.details,o=ri(i),u=i.height||js(e.details.text,o),c=i.top!=null&&i.left!=null?{top:`${i.top}px`,left:`${i.left}px`}:Ks(r,{width:o.width,height:u});return{id:n,name:"caption",type:"caption",display:mt(e.display),details:{...e.details,...o,text:i.text||"",height:u,fontUrl:i.fontUrl,top:o.top||c.top,left:o.left||c.left,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",boxShadow:i.boxShadow||Ge,words:i.words||[],appearedColor:i.appearedColor||i.color,activeColor:i.activeColor||i.color,activeFillColor:i.activeFillColor||"transparent",isKeywordColor:i.isKeywordColor||"transparent",preservedColorKeyWord:i.preservedColorKeyWord||!1,linesPerCaption:i.linesPerCaption||2,wordsPerLine:i.wordsPerLine||"punctuationOrPause"},metadata:t.metadata||{}}},ei=async(t,r)=>{t.details.fontUrl&&await Te([{fontFamily:t.details.fontFamily,url:t.details.fontUrl}]);const e=t.id,n=t.details,i=ri(n),o=n.height||js(t.details.text,i),u=n.top!=null&&n.left!=null?{top:`${n.top}px`,left:`${n.left}px`}:Ks(r,{width:i.width,height:o});return{id:e,name:"text",type:"text",display:mt(t.display),details:{...t.details,...i,text:n.text||"",height:o,fontUrl:n.fontUrl,top:i.top||u.top,left:i.left||u.left,borderWidth:n.borderWidth||0,borderColor:n.borderColor||"#000000",boxShadow:n.boxShadow||Ge},metadata:{}}},ri=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,left:t.left,textTransform:t.textTransform||"none",transform:t.transform||"none",skewX:t.skewX||0,skewY:t.skewY||0}),Oa=async(t,r)=>{switch(t.type){case"video":return Vs(t,r||{});case"audio":return qs(t);case"image":return Qs(t,r||{});case"text":return ei(t,r||{});case"caption":return ti(t,r||{});case"template":return Js(t,{size:r==null?void 0:r.size});default:throw new Error("Unsupported track item")}};function ni(t,r){return r.some(e=>t.some(n=>n.id===e.id))}const si=(t=[],r=[])=>t.length===0?r.map(n=>({id:ee(),items:[n.id],type:n.type,accepts:["text","image","video","audio","caption","template"]})):t.map(e=>({...e,items:e.items||[],accepts:["audio","video","image","text","caption","template"],type:e.type||"text",magnetic:e.magnetic||!1,static:e.static||!1,id:e.id||ee()}));async function Da(t,r){var u,c,d;const e=r.trackItemsMap,n=new Set,i=new Map;for(const p in e){const h=e[p];if(h.type==="text"||h.type==="caption"){if(h.details.fontUrl){const I={fontFamily:h.details.fontFamily,url:h.details.fontUrl};n.add(JSON.stringify(I))}(u=h.animations)!=null&&u.in&&h.animations.in.composition.forEach(I=>{var m;(m=I.details)!=null&&m.fonts&&I.details.fonts.forEach(k=>{n.add(JSON.stringify(k))})}),(c=h.animations)!=null&&c.loop&&h.animations.loop.composition.forEach(I=>{var m;(m=I.details)!=null&&m.fonts&&I.details.fonts.forEach(k=>{n.add(JSON.stringify(k))})}),(d=h.animations)!=null&&d.out&&h.animations.out.composition.forEach(I=>{var m;(m=I.details)!=null&&m.fonts&&I.details.fonts.forEach(k=>{n.add(JSON.stringify(k))})})}else h.type==="illustration"&&i.set(p,{trackItem:h,details:h.details})}n.size>0&&await Te(Array.from(n).map(p=>JSON.parse(p)));for(const[p,h]of i){const I=await Zs({...h.trackItem,details:h.details},{size:{width:h.details.width,height:h.details.height}}),m=Ws(I.details.svgString,h.details.colorMap);I.details.svgString=m,e[p]=I}const o=X(e);return{...r,duration:o}}function Ra(t){const r=C(t);if(!r.activeIds.length)return;const e=r.activeIds,n=[],i={activeIds:e,trackItemsMap:{},tracks:[],structure:[]};e.forEach(d=>{i.trackItemsMap[d]=r.trackItemsMap[d],n.push(r.tracks.find(p=>p.items.includes(d)))});const o=new Set;n.filter(d=>o.has(d.id)?!1:(o.add(d.id),!0)),i.tracks=Array.from(o),i.activeIds.forEach(d=>{if(i.trackItemsMap[d].type==="composition"||i.trackItemsMap[d].type==="template"){const p=r.structure.find(h=>h.id===d);p&&(i.structure.push(p),p.items.forEach(h=>{i.trackItemsMap[h]=r.trackItemsMap[h]}))}});let c=JSON.stringify(i);localStorage.setItem("DesignComboTemp",c)}function Ca(t,r){const e=C(t);if(e.activeIds.length!==1)return{};const n=e.activeIds[0],i=C(e.trackItemsMap[n]);if(r>=i.display.to||r<=i.display.from)return{};const o=ee(),u={...i,display:{from:i.display.from,to:r}},c={...i,id:o,display:{from:r,to:i.display.to}},d=Object.values(e.transitionsMap).find(h=>h.fromId===i.id&&h.kind!=="none"),p=Object.values(e.transitionsMap).find(h=>h.toId===i.id&&h.kind!=="none");if(i.type==="video"||i.type==="audio"){const h=r-u.display.from;u.trim={from:i.trim.from,to:i.trim.from+h},c.trim={from:i.trim.from+h,to:i.trim.to}}if(p){const h=u.display.to-u.display.from;if(p.duration/2>h){e.transitionIds=e.transitionIds.filter(m=>m!==p.id);const I={};e.transitionIds.forEach(m=>I[m]=e.transitionsMap[m]),e.transitionsMap=I}}if(d){const h=c.display.to-c.display.from,I={};d.duration/2>h?(e.transitionIds=e.transitionIds.filter(m=>m!==d.id),e.transitionIds.forEach(m=>I[m]=e.transitionsMap[m]),e.transitionsMap=I):(e.transitionIds=e.transitionIds.map(m=>e.transitionsMap[m].fromId===u.id?m.replace(u.id,o):m),Object.keys(e.transitionsMap).forEach(m=>{if(e.transitionsMap[m].fromId===u.id){const _=m.replace(u.id,o);I[_]={...e.transitionsMap[m],id:_,fromId:o}}else I[m]=e.transitionsMap[m]}),e.transitionsMap=I)}return e.trackItemsMap[n]=u,e.trackItemsMap[o]=c,e.trackItemIds.push(o),e.tracks.forEach(h=>{h.items.includes(n)&&h.items.push(o)}),{tracks:e.tracks,trackItemIds:e.trackItemIds,trackItemsMap:e.trackItemsMap,transitionsMap:e.transitionsMap,transitionIds:e.transitionIds}}async function Pa(t,r){const e=C(t),n=e.trackItemsMap,i=Object.keys(r);if(!i.length)return{};for(const c of i){const d=r[c];if(d.details&&(n[c].details={...n[c].details,...d.details},d.details.colorMap)){const p=n[c].details.initialSvgString,h=Ws(p,d.details.colorMap);n[c].details.svgString=h}if(d.metadata&&(n[c].metadata?n[c].metadata={...n[c].metadata,...d.metadata}:n[c].metadata=d.metadata),d.display||d.playbackRate){const p=d.playbackRate,h=n[c].playbackRate||1,I=n[c].display,_=(I.to-I.from)*h/p,y={from:I.from,to:I.from+_};n[c].display=y,n[c].playbackRate=p}d.animations&&(n[c].animations={...n[c].animations,...d.animations})}for(const c of i){const d=r[c];if(n[c].type==="shape"&&d.details.src){const p=await we(d.details.src);n[c].details.width=p.width,n[c].details.height=p.height}}if(i.some(c=>{const d=r[c];return d.display!==void 0||d.playbackRate!==void 0})){const c=e.tracks.filter(h=>h.magnetic);i.filter(h=>c.some(I=>I.items.includes(h))).length>0&&rt(c,n,[]);const p=[];for(const h of i){const I=r[h];if(I.playbackRate===void 0&&I.display===void 0)continue;const m=n[h];if(!m)continue;const k=e.tracks.find(b=>b.items.includes(h));if(!k||k.magnetic)continue;const _=m.display;if(Object.values(e.transitionsMap).filter(b=>b.fromId===h||b.toId===h).forEach(b=>{const E=n[b.fromId],S=n[b.toId];if(!E||!S){p.push(b.id);return}const M=E.display,T=S.display,A=M.to,U=T.from;Math.abs(A-U)<=1||p.push(b.id)}),k.items.map(b=>n[b]).filter(b=>b&&b.id!==h).some(b=>{const E=b.display.from,S=b.display.to,M=_.from;return!(_.to<=E||M>=S)})){const b=e.tracks.findIndex(M=>M.id===k.id);k.items=k.items.filter(M=>M!==h);const E={id:Hr(),accepts:Object.keys(jr()),type:m.type,items:[h],magnetic:!1,static:!1},S=Math.max(0,b-1);e.tracks.splice(S,0,E)}}p.length>0&&(e.transitionIds=e.transitionIds.filter(h=>!p.includes(h)),p.forEach(h=>{delete e.transitionsMap[h]}))}const u=X(n);return{trackItemsMap:{...n},tracks:e.tracks,transitionIds:e.transitionIds,transitionsMap:e.transitionsMap,duration:u}}async function xa(t,r){const e=C(t),n=Object.keys(r)[0],i=Object.values(r)[0],o=e.trackItemsMap[n],u=o.details;if(!i.details.src)return{};if(o.type==="image"){const c=await we(i.details.src),d=o.details.width||0,p=o.details.height||0;let h=c.width,I=c.height;const m=c.width/c.height;d/p>m?(h=d,I=d/m):(I=p,h=p*m),u.crop={x:0,y:0,height:u.height,width:u.width},i.details.width=h,i.details.height=I}else if(o.type==="video"){const c=await Br(i.details.src),d=o.details.width||0,p=o.details.height||0;let h=c.width,I=c.height;const m=c.width/c.height;d/p>m?(h=d,I=d/m):(I=p,h=p*m),u.crop={x:0,y:0,height:u.height,width:u.width},i.details.width=h,i.details.height=I}return i.details&&(o.details={...u,...i.details},i.details=o.details),e.trackItemsMap[n]={...e.trackItemsMap[n],type:i.type},{trackItemsMap:{...e.trackItemsMap}}}function La(t,r){const e=C(t);return e.background.value=r.value,e.background.type=r.type||"color",{...e}}function za(t,{idTrack:r,idItems:e},n){const i=n.tracks.find(c=>c.id===r);if(!i||!i.magnetic)return;let u=i.items.reduce((c,d)=>{const p=n.trackItemsMap[d];return p.display.to>c.display.to?p:c},{display:{to:0}}).display.to;e.forEach(c=>{const d=t.find(I=>String(I.id)===String(c));if(!d)return;const p=d.playbackRate||1;let h;(d.type==="video"||d.type==="audio")&&d.trim?h=(d.trim.to-d.trim.from)/p:h=d.display.to-d.display.from,d.display.from=u,d.display.to=u+h,u=u+h})}async function Na(t,r,e={}){var m;const n=C(t),i=r.trackItems.map(k=>Oa(k,{size:n.size})),o=await Promise.all(i);(m=r.tracks)==null||m.forEach(k=>{za(o,{idTrack:k.id,idItems:k.items},n)});const u=si(r.tracks,r.trackItems),c=[],d=o.map(k=>k.id);r.trackItems.forEach(k=>{if(k.type!=="template")return;n.trackItemsMap={...n.trackItemsMap,...k.trackItemsMap},n.transitionsMap={...n.transitionsMap,...k.transitionsMap};const _={id:k.id,items:k.trackItemIds,transitions:k.transitionsIds||[],tracks:k.tracks};c.push(_)});const p=[],h={};return o.forEach(k=>{p.push(k.id),h[k.id]=k}),u.map(k=>ni(n.tracks,[k])?k:null).forEach((k,_)=>{if(k)n.tracks.forEach(y=>{y.id===k.id&&(y.items=y.items.concat(k.items),y.magnetic&&rt([y],n.trackItemsMap,d))});else{const y=e.trackIndex||0,v=u[_],f=Math.min(Math.max(y,0),n.tracks.length);n.tracks.splice(f,0,v)}}),n.trackItemsMap={...n.trackItemsMap,...h},n.trackItemIds=[...n.trackItemIds,...p],n.structure=[...n.structure,...c],n.duration=X(n.trackItemsMap),{trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,tracks:n.tracks,duration:n.duration,structure:n.structure,transitionIds:n.transitionIds,transitionsMap:n.transitionsMap}}function yt(t,r,e={isNewTrack:!0}){const n=r.map(u=>u.id),i=[],o={};if(r.forEach(u=>{i.push(u.id),o[u.id]=u}),(e.targetTrackIndex!==void 0||e.targetTrackId)&&!e.isNewTrack){const u=e.targetTrackIndex||0,c=e.targetTrackId;let d=t.tracks[u];if(c&&(d=t.tracks.find(p=>p.id===c)),!d)throw new Error("Target track not found");d.items.push(...i)}else{const u={id:Hr(),accepts:Object.keys(jr()),type:r[0].type,items:n,magnetic:!1,static:!1};t.tracks.splice(e.targetTrackIndex||0,0,u)}return t.trackItemsMap={...t.trackItemsMap,...o},t.trackItemIds=[...t.trackItemIds,...i],t}async function Fa(t,r,e={}){const n=C(t),i=[Qs(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],o=await Promise.all(i),u=o.map(p=>p.id),c=yt(n,o,e),d=c.tracks.filter(p=>p.magnetic);return rt(d,c.trackItemsMap,u),c.duration=X(c.trackItemsMap),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function $a(t,r,e={}){const n=C(t),i=[qs(r)],o=await Promise.all(i),u=o.map(p=>p.id),c=yt(n,o,e);c.duration=X(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return rt(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ha(t,r,e={}){const n=C(t),i=[Vs(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],o=await Promise.all(i),u=o.map(p=>p.id),c=yt(n,o,e);c.duration=X(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return rt(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ua(t,r,e={}){const n=C(t),i=[ei(r,{size:e.size})],o=await Promise.all(i),u=o.map(p=>p.id),c=yt(n,o,e);c.duration=X(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return rt(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function ja(t,r,e={}){const n=C(t),i=[Aa(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],o=await Promise.all(i),u=o.map(p=>p.id),c=yt(n,o,e);c.duration=X(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return rt(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ba(t,r,e={}){const n=C(t),i=[Zs(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],o=await Promise.all(i),u=o.map(p=>p.id),c=yt(n,o,e);c.duration=X(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return rt(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ya(t,r,e={}){const n=C(t),i="composition",o=r.trackItemsMap,u=r.trackItemIds,c=r.tracks||[],d=r.trackItemDetailsMap,{details:p,...h}=await wa(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}),I={id:h.id,items:u,transitions:[],tracks:c},k=[{...h,type:i,details:p}],_=yt(n,k,e);_.trackItemsMap={..._.trackItemsMap,...o,[h.id]:{...h,type:i,details:p}},_.structure=[..._.structure,I],_.duration=X(_.trackItemsMap);const y=_.tracks.filter(v=>v.magnetic);return rt(y,_.trackItemsMap,[h.id]),d&&Object.keys(d).forEach(v=>{_.trackItemsMap[v]={..._.trackItemsMap[v],details:{...d[v].details}}}),{trackItemIds:_.trackItemIds,trackItemsMap:_.trackItemsMap,tracks:_.tracks,duration:_.duration,structure:_.structure}}async function re(t,r,e={},n){const i=C(t),o=I=>I.display?I.display:{from:0,to:i.duration},u=[];n==="progress-bar"&&u.push(va(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})),n==="progress-frame"&&u.push(Sa(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})),n==="radial-audio-bars"&&(r.display=o(r),u.push(Ea(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="lineal-audio-bars"&&(r.display=o(r),u.push(Wr(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="wave-audio-bars"&&(r.display=o(r),u.push(Wr(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="hill-audio-bars"&&(r.display=o(r),u.push(Wr(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="progress-square"&&u.push(Ta(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}));const c=await Promise.all(u),d=c.map(I=>I.id),p=yt(i,c,e);p.duration=X(p.trackItemsMap);const h=p.tracks.filter(I=>I.magnetic);return rt(h,p.trackItemsMap,d),{trackItemIds:p.trackItemIds,trackItemsMap:p.trackItemsMap,tracks:p.tracks,duration:p.duration}}async function Wa(t,r,e={}){const n=C(t),i="template",o=r.trackItemsMap,u=r.trackItemIds,c=r.transitionsMap,d=r.transitionIds||[],p=r.tracks||[],h=r.structure||[],{details:I,...m}=await Js(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}),k={id:m.id,items:u,transitions:d,tracks:p},y=[{...m,type:i,details:I}],v=yt(n,y,e);v.transitionIds=[...v.transitionIds,...d],v.transitionsMap={...v.transitionsMap,...c},v.trackItemsMap={...v.trackItemsMap,...o,[m.id]:{...m,type:i,details:I}},v.structure=[...v.structure,k,...h],v.duration=X(v.trackItemsMap);const f=v.tracks.filter(b=>b.magnetic);return rt(f,v.trackItemsMap,[m.id]),{trackItemIds:v.trackItemIds,trackItemsMap:v.trackItemsMap,tracks:v.tracks,duration:v.duration,structure:v.structure,transitionsMap:v.transitionsMap}}async function Ga(t,r,e={}){const n=C(t),i=r.trackItems.map(I=>ti(I,{size:e.size})),o=await Promise.all(i),u=si(r.tracks,r.trackItems),c=[],d={};if(o.forEach(I=>{const{details:m,...k}=I;c.push(I.id),d[I.id]=k}),ni(n.tracks,u))n.tracks.forEach(I=>{u.forEach(m=>{I.id===m.id&&(I.magnetic&&rt([I],n.trackItemsMap,c),I.items.push(...c))})});else{const I=e.trackIndex||0,m=Math.min(Math.max(I,0),n.tracks.length);n.tracks.splice(m,0,...u)}n.trackItemsMap={...n.trackItemsMap,...d},n.trackItemIds=[...n.trackItemIds,...c],n.duration=X(n.trackItemsMap);const h=n.tracks.filter(I=>I.magnetic);return rt(h,n.trackItemsMap,c),{trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,tracks:n.tracks,duration:n.duration}}async function Xa(t,r){const e=C(t),n=e.trackItemsMap[r.id],i=[];if(!n)return{};let o=n.animations||{};return r.animations.loop?r.animations.loop.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}):r.animations.in?r.animations.in.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}):r.animations.out?r.animations.out.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}):r.animations.timed&&r.animations.timed.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}),i.length>0&&await Te(i),o.in&&r.animations.in?o.in=r.animations.in:o.out&&r.animations.out?o.out=r.animations.out:o.loop&&r.animations.loop?o.loop=r.animations.loop:!o.out&&r.animations.out?o.out=r.animations.out:!o.in&&r.animations.in?o.in=r.animations.in:!o.loop&&r.animations.loop?o.loop=r.animations.loop:o=r.animations,(r.animations.in||r.animations.out||r.animations.loop)&&delete o.timed,r.animations.timed&&(o.timed=r.animations.timed,delete o.in,delete o.out,delete o.loop),n.animations=o,{trackItemsMap:e.trackItemsMap}}async function Ka(t,r,e={}){const n=C(t),i=[Ma(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],o=await Promise.all(i),u=o.map(p=>p.id),c=yt(n,o,e);c.duration=X(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return rt(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}function Va(t){const r=H.subject.pipe(H.filter(({key:f})=>f.startsWith(Fr))),e=H.subject.pipe(H.filter(({key:f})=>f.startsWith(fr))),n=H.subject.pipe(H.filter(({key:f})=>f.startsWith(j))),i=H.subject.pipe(H.filter(({key:f})=>f.startsWith(V))),o=H.subject.pipe(H.filter(({key:f})=>f.startsWith(Ye))),u=H.subject.pipe(H.filter(({key:f})=>f.startsWith(te))),c=H.subject.pipe(H.filter(({key:f})=>f.startsWith(At))),d=H.subject.pipe(H.filter(({key:f})=>f.startsWith($r))),p=r.subscribe(async f=>{var b;if(f.key===Fr){const{actions:E}=(b=f.value)==null?void 0:b.payload;E.forEach(S=>{H.dispatch(S.type,S.payload&&{payload:S.payload})})}}),h=e.subscribe(async f=>{var b,E;if(f.key===is){const S=(b=f.value)==null?void 0:b.payload,M=await Da(t.getState(),S);t.updateState(M,{kind:"design:load",updateHistory:!1})}if(f.key===as){const S=(E=f.value)==null?void 0:E.payload;t.updateState({size:S},{kind:"design:resize",updateHistory:!1})}}),I=o.subscribe(f=>{if(f.key===zs)return t.undo();if(f.key===Ns)return t.redo()}),m=d.subscribe(f=>{var b;if(f.key===Fs){const E=(b=f.value)==null?void 0:b.payload.scale;t.updateState({scale:E},{kind:"update",updateHistory:!1})}}),k=i.subscribe(async f=>{var b,E,S,M;if(f.key===Rs){const T=((b=f.value)==null?void 0:b.payload.trackItemIds)||[];t.updateState({activeIds:T},{kind:"update",updateHistory:!1})}if(f.key===Cs&&Ra(t.getState()),f.key===xs){const T=(E=f.value)==null?void 0:E.payload.trackItemIds,A=da(t.getState(),T);t.updateState(A,{updateHistory:!0,kind:"remove"})}if(f.key===Ps){const T=ya(t.getState(),(S=f.value)==null?void 0:S.payload.trackItemIds);t.updateState(T,{updateHistory:!0,kind:"update"})}if(f.key===Ls){const T=(M=f.value)==null?void 0:M.payload,A=await ga(t.getState(),T);t.updateState(A,{updateHistory:!0,kind:"update:details"})}}),_=n.subscribe(async f=>{var U,P,K,D,F,nt,ce,ue,Ae,Me,Oe,De,z,Re,Ce,at,le,N,de,Pe,ot,fe,pe,Ht,Ut,he,jt,me,Bt,Ie,xe,Le,Mt,Yt,ge,ye,pt,Ot,ze,bt,Dt,Wt,st,be,ke,Ne,Gt,Rt,_e,Ct,kt,ct,Pt,Xt,_t,Kt,vt,Vt,qt;const b=C(t.getState()),E=((P=(U=f.value)==null?void 0:U.options)==null?void 0:P.isSelected)||!1,S=(D=(K=f.value)==null?void 0:K.options)==null?void 0:D.scaleMode,M=(nt=(F=f.value)==null?void 0:F.options)==null?void 0:nt.scaleAspectRatio,T=(ue=(ce=f.value)==null?void 0:ce.options)==null?void 0:ue.trackIndex;let A={};f.key===ps?A=await Xa(b,(Ae=f.value)==null?void 0:Ae.payload):f.key===Is?A=await Na(b,(Me=f.value)==null?void 0:Me.payload,{trackIndex:T}):f.key===hs?A=await Ga(b,(Oe=f.value)==null?void 0:Oe.payload,{trackIndex:T}):f.key===os?A=await Ua(b,(De=f.value)==null?void 0:De.payload,{targetTrackIndex:T,targetTrackId:(z=f.value)==null?void 0:z.options.targetTrackId,size:b.size,isNewTrack:(Ce=(Re=f.value)==null?void 0:Re.options)==null?void 0:Ce.isNewTrack}):f.key===ms?A=await Wa(b,(at=f.value)==null?void 0:at.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:T,targetTrackId:(N=(le=f.value)==null?void 0:le.options)==null?void 0:N.targetTrackId}):f.key===ds?A=await Ba(b,(de=f.value)==null?void 0:de.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:T,targetTrackId:(Pe=f.value)==null?void 0:Pe.options.targetTrackId}):f.key===fs?A=await ja(b,(ot=f.value)==null?void 0:ot.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:T,targetTrackId:(fe=f.value)==null?void 0:fe.options.targetTrackId}):f.key===Ts?A=await Ka(b,(pe=f.value)==null?void 0:pe.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:T,targetTrackId:(Ht=f.value)==null?void 0:Ht.options.targetTrackId}):f.key===ls?A=await Fa(b,(Ut=f.value)==null?void 0:Ut.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:T,targetTrackId:(he=f.value)==null?void 0:he.options.targetTrackId,isNewTrack:(me=(jt=f.value)==null?void 0:jt.options)==null?void 0:me.isNewTrack}):f.key===us?A=await $a(b,(Bt=f.value)==null?void 0:Bt.payload,{targetTrackIndex:T,targetTrackId:(Ie=f.value)==null?void 0:Ie.options.targetTrackId,isNewTrack:(Le=(xe=f.value)==null?void 0:xe.options)==null?void 0:Le.isNewTrack}):f.key===cs?A=await Ha(b,(Mt=f.value)==null?void 0:Mt.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:T,targetTrackId:(Yt=f.value)==null?void 0:Yt.options.targetTrackId,isNewTrack:(ye=(ge=f.value)==null?void 0:ge.options)==null?void 0:ye.isNewTrack}):f.key===gs?A=await Ya(b,(pt=f.value)==null?void 0:pt.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:T,targetTrackId:(Ot=f.value)==null?void 0:Ot.options.targetTrackId}):f.key===ys?A=await re(b,(ze=f.value)==null?void 0:ze.payload,{targetTrackIndex:T,targetTrackId:(Dt=(bt=f.value)==null?void 0:bt.options)==null?void 0:Dt.targetTrackId},"progress-bar"):f.key===vs?A=await re(b,(Wt=f.value)==null?void 0:Wt.payload,{targetTrackIndex:T,targetTrackId:(be=(st=f.value)==null?void 0:st.options)==null?void 0:be.targetTrackId},"progress-square"):f.key===bs?A=await re(b,(ke=f.value)==null?void 0:ke.payload,{targetTrackIndex:T,targetTrackId:(Gt=(Ne=f.value)==null?void 0:Ne.options)==null?void 0:Gt.targetTrackId},"progress-frame"):f.key===ks?A=await re(b,(Rt=f.value)==null?void 0:Rt.payload,{targetTrackIndex:T,targetTrackId:(Ct=(_e=f.value)==null?void 0:_e.options)==null?void 0:Ct.targetTrackId},"radial-audio-bars"):f.key===_s?A=await re(b,(kt=f.value)==null?void 0:kt.payload,{targetTrackIndex:T,targetTrackId:(Pt=(ct=f.value)==null?void 0:ct.options)==null?void 0:Pt.targetTrackId},"lineal-audio-bars"):f.key===Ss?A=await re(b,(Xt=f.value)==null?void 0:Xt.payload,{targetTrackIndex:T,targetTrackId:(Kt=(_t=f.value)==null?void 0:_t.options)==null?void 0:Kt.targetTrackId},"wave-audio-bars"):f.key===Es&&(A=await re(b,(vt=f.value)==null?void 0:vt.payload,{targetTrackIndex:T,targetTrackId:(qt=(Vt=f.value)==null?void 0:Vt.options)==null?void 0:qt.targetTrackId},"hill-audio-bars")),E&&A.trackItemIds&&(A.activeIds=A.trackItemIds),t.updateState(A,{updateHistory:!0,kind:"add"})}),y=u.subscribe(async f=>{var b;if(f.key===Ds){const E=(b=f.value)==null?void 0:b.options.time,S=Ca(t.getState(),E);Object.keys(S).length>0&&t.updateState(S,{updateHistory:!0,kind:"update"})}if(f.key===Os){const E=await ha(t.getState());t.updateState(E,{updateHistory:!0,kind:"update"})}}),v=c.subscribe(async f=>{var b,E,S;if(f.key===ws){const M=await Pa(t.getState(),(b=f.value)==null?void 0:b.payload);t.updateState(M,{updateHistory:!0,kind:"update:details"})}if(f.key===As){const M=await xa(t.getState(),(E=f.value)==null?void 0:E.payload);t.updateState(M,{updateHistory:!0,kind:"update:details"})}if(f.key===Ms){const M=La(t.getState(),(S=f.value)==null?void 0:S.payload);t.updateState(M,{updateHistory:!0,kind:"update:details"})}});return{unsubscribe:()=>{_.unsubscribe(),y.unsubscribe(),v.unsubscribe(),I.unsubscribe(),k.unsubscribe(),h.unsubscribe(),m.unsubscribe(),p.unsubscribe()}}}const qa={Date:!0,RegExp:!0,String:!0,Number:!0};function ii(t,r,e={cyclesFix:!0},n=[]){var c,d;let i=[];const o=Array.isArray(t);for(const p in t){const h=t[p],I=o?+p:p;if(!(p in r)){i.push({type:"REMOVE",path:[I],oldValue:t[p]});continue}const m=r[p],k=typeof h=="object"&&typeof m=="object"&&Array.isArray(h)===Array.isArray(m);h&&m&&k&&!qa[(d=(c=Object.getPrototypeOf(h))==null?void 0:c.constructor)==null?void 0:d.name]&&(!e.cyclesFix||!n.includes(h))?i.push.apply(i,ii(h,m,e,e.cyclesFix?n.concat([h]):[]).map(_=>(_.path.unshift(I),_))):h!==m&&!(Number.isNaN(h)&&Number.isNaN(m))&&!(k&&(isNaN(h)?h+""==m+"":+h==+m))&&i.push({path:[I],type:"CHANGE",value:m,oldValue:h})}const u=Array.isArray(r);for(const p in r)p in t||i.push({type:"CREATE",path:[u?+p:p],value:r[p]});return i}var Gr=Symbol.for("immer-nothing"),Xe=Symbol.for("immer-draftable"),dt=Symbol.for("immer-state"),ai=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 W(t,...r){if(process.env.NODE_ENV!=="production"){const e=ai[t],n=typeof e=="function"?e.apply(null,r):e;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ne=Object.getPrototypeOf;function se(t){return!!t&&!!t[dt]}function $t(t){var r;return t?oi(t)||Array.isArray(t)||!!t[Xe]||!!((r=t.constructor)!=null&&r[Xe])||qe(t)||Je(t):!1}var Ja=Object.prototype.constructor.toString();function oi(t){if(!t||typeof t!="object")return!1;const r=ne(t);if(r===null)return!0;const e=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return e===Object?!0:typeof e=="function"&&Function.toString.call(e)===Ja}function Ke(t,r){ie(t)===0?Reflect.ownKeys(t).forEach(e=>{r(e,t[e],t)}):t.forEach((e,n)=>r(n,e,t))}function ie(t){const r=t[dt];return r?r.type_:Array.isArray(t)?1:qe(t)?2:Je(t)?3:0}function Ve(t,r){return ie(t)===2?t.has(r):Object.prototype.hasOwnProperty.call(t,r)}function Xr(t,r){return ie(t)===2?t.get(r):t[r]}function ci(t,r,e){const n=ie(t);n===2?t.set(r,e):n===3?t.add(e):t[r]=e}function Za(t,r){return t===r?t!==0||1/t===1/r:t!==t&&r!==r}function qe(t){return t instanceof Map}function Je(t){return t instanceof Set}function ae(t){return t.copy_||t.base_}function Kr(t,r){if(qe(t))return new Map(t);if(Je(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const e=oi(t);if(r===!0||r==="class_only"&&!e){const n=Object.getOwnPropertyDescriptors(t);delete n[dt];let i=Reflect.ownKeys(n);for(let o=0;o<i.length;o++){const u=i[o],c=n[u];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(n[u]={configurable:!0,writable:!0,enumerable:c.enumerable,value:t[u]})}return Object.create(ne(t),n)}else{const n=ne(t);if(n!==null&&e)return{...t};const i=Object.create(n);return Object.assign(i,t)}}function Vr(t,r=!1){return mr(t)||se(t)||!$t(t)||(ie(t)>1&&(t.set=t.add=t.clear=t.delete=Qa),Object.freeze(t),r&&Object.entries(t).forEach(([e,n])=>Vr(n,!0))),t}function Qa(){W(2)}function mr(t){return Object.isFrozen(t)}var qr={};function oe(t){const r=qr[t];return r||W(0,t),r}function to(t,r){qr[t]||(qr[t]=r)}var Ze;function ui(){return Ze}function eo(t,r){return{drafts_:[],parent_:t,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function li(t,r){r&&(oe("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=r)}function Jr(t){Zr(t),t.drafts_.forEach(ro),t.drafts_=null}function Zr(t){t===Ze&&(Ze=t.parent_)}function di(t){return Ze=eo(Ze,t)}function ro(t){const r=t[dt];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function fi(t,r){r.unfinalizedDrafts_=r.drafts_.length;const e=r.drafts_[0];return t!==void 0&&t!==e?(e[dt].modified_&&(Jr(r),W(4)),$t(t)&&(t=Ir(r,t),r.parent_||gr(r,t)),r.patches_&&oe("Patches").generateReplacementPatches_(e[dt].base_,t,r.patches_,r.inversePatches_)):t=Ir(r,e,[]),Jr(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),t!==Gr?t:void 0}function Ir(t,r,e){if(mr(r))return r;const n=r[dt];if(!n)return Ke(r,(i,o)=>pi(t,n,r,i,o,e)),r;if(n.scope_!==t)return r;if(!n.modified_)return gr(t,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let o=i,u=!1;n.type_===3&&(o=new Set(i),i.clear(),u=!0),Ke(o,(c,d)=>pi(t,n,i,c,d,e,u)),gr(t,i,!1),e&&t.patches_&&oe("Patches").generatePatches_(n,e,t.patches_,t.inversePatches_)}return n.copy_}function pi(t,r,e,n,i,o,u){if(process.env.NODE_ENV!=="production"&&i===e&&W(5),se(i)){const c=o&&r&&r.type_!==3&&!Ve(r.assigned_,n)?o.concat(n):void 0,d=Ir(t,i,c);if(ci(e,n,d),se(d))t.canAutoFreeze_=!1;else return}else u&&e.add(i);if($t(i)&&!mr(i)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Ir(t,i),(!r||!r.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(e,n)&&gr(t,i)}}function gr(t,r,e=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Vr(r,e)}function no(t,r){const e=Array.isArray(t),n={type_:e?1:0,scope_:r?r.scope_:ui(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,o=Qr;e&&(i=[n],o=Qe);const{revoke:u,proxy:c}=Proxy.revocable(i,o);return n.draft_=c,n.revoke_=u,c}var Qr={get(t,r){if(r===dt)return t;const e=ae(t);if(!Ve(e,r))return so(t,e,r);const n=e[r];return t.finalized_||!$t(n)?n:n===tn(t.base_,r)?(rn(t),t.copy_[r]=nn(n,t)):n},has(t,r){return r in ae(t)},ownKeys(t){return Reflect.ownKeys(ae(t))},set(t,r,e){const n=hi(ae(t),r);if(n!=null&&n.set)return n.set.call(t.draft_,e),!0;if(!t.modified_){const i=tn(ae(t),r),o=i==null?void 0:i[dt];if(o&&o.base_===e)return t.copy_[r]=e,t.assigned_[r]=!1,!0;if(Za(e,i)&&(e!==void 0||Ve(t.base_,r)))return!0;rn(t),en(t)}return t.copy_[r]===e&&(e!==void 0||r in t.copy_)||Number.isNaN(e)&&Number.isNaN(t.copy_[r])||(t.copy_[r]=e,t.assigned_[r]=!0),!0},deleteProperty(t,r){return tn(t.base_,r)!==void 0||r in t.base_?(t.assigned_[r]=!1,rn(t),en(t)):delete t.assigned_[r],t.copy_&&delete t.copy_[r],!0},getOwnPropertyDescriptor(t,r){const e=ae(t),n=Reflect.getOwnPropertyDescriptor(e,r);return n&&{writable:!0,configurable:t.type_!==1||r!=="length",enumerable:n.enumerable,value:e[r]}},defineProperty(){W(11)},getPrototypeOf(t){return ne(t.base_)},setPrototypeOf(){W(12)}},Qe={};Ke(Qr,(t,r)=>{Qe[t]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),Qe.deleteProperty=function(t,r){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(r))&&W(13),Qe.set.call(this,t,r,void 0)},Qe.set=function(t,r,e){return process.env.NODE_ENV!=="production"&&r!=="length"&&isNaN(parseInt(r))&&W(14),Qr.set.call(this,t[0],r,e,t[0])};function tn(t,r){const e=t[dt];return(e?ae(e):t)[r]}function so(t,r,e){var i;const n=hi(r,e);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(t.draft_):void 0}function hi(t,r){if(!(r in t))return;let e=ne(t);for(;e;){const n=Object.getOwnPropertyDescriptor(e,r);if(n)return n;e=ne(e)}}function en(t){t.modified_||(t.modified_=!0,t.parent_&&en(t.parent_))}function rn(t){t.copy_||(t.copy_=Kr(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var io=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,e,n)=>{if(typeof r=="function"&&typeof e!="function"){const o=e;e=r;const u=this;return function(d=o,...p){return u.produce(d,h=>e.call(this,h,...p))}}typeof e!="function"&&W(6),n!==void 0&&typeof n!="function"&&W(7);let i;if($t(r)){const o=di(this),u=nn(r,void 0);let c=!0;try{i=e(u),c=!1}finally{c?Jr(o):Zr(o)}return li(o,n),fi(i,o)}else if(!r||typeof r!="object"){if(i=e(r),i===void 0&&(i=r),i===Gr&&(i=void 0),this.autoFreeze_&&Vr(i,!0),n){const o=[],u=[];oe("Patches").generateReplacementPatches_(r,i,o,u),n(o,u)}return i}else W(1,r)},this.produceWithPatches=(r,e)=>{if(typeof r=="function")return(u,...c)=>this.produceWithPatches(u,d=>r(d,...c));let n,i;return[this.produce(r,e,(u,c)=>{n=u,i=c}),n,i]},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)||W(8),se(t)&&(t=ao(t));const r=di(this),e=nn(t,void 0);return e[dt].isManual_=!0,Zr(r),e}finishDraft(t,r){const e=t&&t[dt];(!e||!e.isManual_)&&W(9);const{scope_:n}=e;return li(n,r),fi(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,r){let e;for(e=r.length-1;e>=0;e--){const i=r[e];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}e>-1&&(r=r.slice(e+1));const n=oe("Patches").applyPatches_;return se(t)?n(t,r):this.produce(t,i=>n(i,r))}};function nn(t,r){const e=qe(t)?oe("MapSet").proxyMap_(t,r):Je(t)?oe("MapSet").proxySet_(t,r):no(t,r);return(r?r.scope_:ui()).drafts_.push(e),e}function ao(t){return se(t)||W(10,t),mi(t)}function mi(t){if(!$t(t)||mr(t))return t;const r=t[dt];let e;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,e=Kr(t,r.scope_.immer_.useStrictShallowCopy_)}else e=Kr(t,!0);return Ke(e,(n,i)=>{ci(e,n,mi(i))}),r&&(r.finalized_=!1),e}function Ii(){process.env.NODE_ENV!=="production"&&ai.push('Sets cannot have "replace" patches.',function(m){return"Unsupported patch operation: "+m},function(m){return"Cannot apply patch, path doesn't resolve: "+m},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const r="replace",e="add",n="remove";function i(m,k,_,y){switch(m.type_){case 0:case 2:return u(m,k,_,y);case 1:return o(m,k,_,y);case 3:return c(m,k,_,y)}}function o(m,k,_,y){let{base_:v,assigned_:f}=m,b=m.copy_;b.length<v.length&&([v,b]=[b,v],[_,y]=[y,_]);for(let E=0;E<v.length;E++)if(f[E]&&b[E]!==v[E]){const S=k.concat([E]);_.push({op:r,path:S,value:I(b[E])}),y.push({op:r,path:S,value:I(v[E])})}for(let E=v.length;E<b.length;E++){const S=k.concat([E]);_.push({op:e,path:S,value:I(b[E])})}for(let E=b.length-1;v.length<=E;--E){const S=k.concat([E]);y.push({op:n,path:S})}}function u(m,k,_,y){const{base_:v,copy_:f}=m;Ke(m.assigned_,(b,E)=>{const S=Xr(v,b),M=Xr(f,b),T=E?Ve(v,b)?r:e:n;if(S===M&&T===r)return;const A=k.concat(b);_.push(T===n?{op:T,path:A}:{op:T,path:A,value:M}),y.push(T===e?{op:n,path:A}:T===n?{op:e,path:A,value:I(S)}:{op:r,path:A,value:I(S)})})}function c(m,k,_,y){let{base_:v,copy_:f}=m,b=0;v.forEach(E=>{if(!f.has(E)){const S=k.concat([b]);_.push({op:n,path:S,value:E}),y.unshift({op:e,path:S,value:E})}b++}),b=0,f.forEach(E=>{if(!v.has(E)){const S=k.concat([b]);_.push({op:e,path:S,value:E}),y.unshift({op:n,path:S,value:E})}b++})}function d(m,k,_,y){_.push({op:r,path:[],value:k===Gr?void 0:k}),y.push({op:r,path:[],value:m})}function p(m,k){return k.forEach(_=>{const{path:y,op:v}=_;let f=m;for(let M=0;M<y.length-1;M++){const T=ie(f);let A=y[M];typeof A!="string"&&typeof A!="number"&&(A=""+A),(T===0||T===1)&&(A==="__proto__"||A==="constructor")&&W(19),typeof f=="function"&&A==="prototype"&&W(19),f=Xr(f,A),typeof f!="object"&&W(18,y.join("/"))}const b=ie(f),E=h(_.value),S=y[y.length-1];switch(v){case r:switch(b){case 2:return f.set(S,E);case 3:W(16);default:return f[S]=E}case e:switch(b){case 1:return S==="-"?f.push(E):f.splice(S,0,E);case 2:return f.set(S,E);case 3:return f.add(E);default:return f[S]=E}case n:switch(b){case 1:return f.splice(S,1);case 2:return f.delete(S);case 3:return f.delete(_.value);default:return delete f[S]}default:W(17,v)}}),m}function h(m){if(!$t(m))return m;if(Array.isArray(m))return m.map(h);if(qe(m))return new Map(Array.from(m.entries()).map(([_,y])=>[_,h(y)]));if(Je(m))return new Set(Array.from(m).map(h));const k=Object.create(ne(m));for(const _ in m)k[_]=h(m[_]);return Ve(m,Xe)&&(k[Xe]=m[Xe]),k}function I(m){return se(m)?h(m):m}to("Patches",{applyPatches_:p,generatePatches_:i,generateReplacementPatches_:d})}var ft=new io,oo=ft.produce;ft.produceWithPatches.bind(ft),ft.setAutoFreeze.bind(ft),ft.setUseStrictShallowCopy.bind(ft);var co=ft.applyPatches.bind(ft);ft.createDraft.bind(ft),ft.finishDraft.bind(ft);var uo=9007199254740991,lo="[object Arguments]",fo="[object Function]",po="[object GeneratorFunction]",ho="[object Symbol]",mo=typeof ht=="object"&&ht&&ht.Object===Object&&ht,Io=typeof self=="object"&&self&&self.Object===Object&&self,go=mo||Io||Function("return this")();function yo(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}function bo(t,r){for(var e=-1,n=t?t.length:0,i=Array(n);++e<n;)i[e]=r(t[e],e,t);return i}function ko(t,r){for(var e=-1,n=r.length,i=t.length;++e<n;)t[i+e]=r[e];return t}var sn=Object.prototype,_o=sn.hasOwnProperty,an=sn.toString,gi=go.Symbol,vo=sn.propertyIsEnumerable,yi=gi?gi.isConcatSpreadable:void 0,bi=Math.max;function So(t,r,e,n,i){var o=-1,u=t.length;for(e||(e=Ao),i||(i=[]);++o<u;){var c=t[o];e(c)?ko(i,c):i[i.length]=c}return i}function Eo(t,r){return t=Object(t),To(t,r,function(e,n){return n in t})}function To(t,r,e){for(var n=-1,i=r.length,o={};++n<i;){var u=r[n],c=t[u];e(c,u)&&(o[u]=c)}return o}function wo(t,r){return r=bi(r===void 0?t.length-1:r,0),function(){for(var e=arguments,n=-1,i=bi(e.length-r,0),o=Array(i);++n<i;)o[n]=e[r+n];n=-1;for(var u=Array(r+1);++n<r;)u[n]=e[n];return u[r]=o,yo(t,this,u)}}function Ao(t){return Do(t)||Oo(t)||!!(yi&&t&&t[yi])}function Mo(t){if(typeof t=="string"||zo(t))return t;var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Oo(t){return Co(t)&&_o.call(t,"callee")&&(!vo.call(t,"callee")||an.call(t)==lo)}var Do=Array.isArray;function Ro(t){return t!=null&&xo(t.length)&&!Po(t)}function Co(t){return ki(t)&&Ro(t)}function Po(t){var r=Lo(t)?an.call(t):"";return r==fo||r==po}function xo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=uo}function Lo(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function ki(t){return!!t&&typeof t=="object"}function zo(t){return typeof t=="symbol"||ki(t)&&an.call(t)==ho}var No=wo(function(t,r){return t==null?{}:Eo(t,bo(So(r),Mo))}),Fo=No;const _i=Nr(Fo),$o={size:{width:1080,height:1920},fps:30,tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{index:7,unit:300,zoom:1/300,segments:5},duration:0,activeIds:[],structure:[],background:{type:"color",value:"transparent"}},vi=["tracks","trackItemsMap","transitionIds","transitionsMap","trackItemIds","structure"];class Ho{constructor(r,e){Qt(this,"stateSubject");Qt(this,"stateHistorySubject");Qt(this,"prevState");Qt(this,"background");Qt(this,"undos",[]);Qt(this,"redos",[]);Qt(this,"listener");const n=Object.assign({},$o,r,e!=null&&e.scale?{scale:e.scale}:{});this.stateSubject=new ts(n),this.stateHistorySubject=new ts({handleRedo:!1,handleUndo:!1}),this.background=n.background,this.prevState=n,(e!=null&&e.cors||e!=null&&e.acceptsMap)&&ma({cors:e.cors,acceptsMap:e.acceptsMap}),this.initListeners()}initListeners(){Va(this)}destroyListeners(){this.listener&&this.listener.unsubscribe()}purge(){this.destroyListeners()}updateHistory(r,e){const n=_i(r,vi),i=_i(this.getState(),vi),o=ii(i,n);o.length&&(this.undos.push({undos:o,type:e}),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,e={updateHistory:!1}){const n=this.getState(),i={...C(n),...C(r)};Y(n,i)||(e.updateHistory&&this.updateHistory(i,e.kind),this.prevState=n,this.stateSubject.next(i))}subscribeToUpdateStateDetails(r){return this.stateSubject.asObservable().subscribe(e=>{(!Y(e.size,this.prevState.size)||!Y(e.background,this.prevState.background))&&r({size:e.size,background:e.background})})}subscribeToScale(r){return this.stateSubject.asObservable().subscribe(e=>{Y(e.scale,this.prevState.scale)||r({scale:e.scale})})}subscribeToFps(r){return this.stateSubject.asObservable().subscribe(e=>{e.fps!==this.prevState.fps&&r({fps:e.fps})})}subscribeToUpdateTrackItem(r){return this.stateSubject.asObservable().subscribe(e=>{Y(e.trackItemsMap,this.prevState.trackItemsMap)||r({trackItemsMap:e.trackItemsMap})})}subscribeToUpdateAnimations(r){return this.stateSubject.asObservable().subscribe(e=>{const n=Object.keys(e.trackItemsMap).filter(i=>{const o=this.prevState.trackItemsMap[i],u=e.trackItemsMap[i];return o&&u&&!Y(o.animations,u.animations)});r({trackItemsMap:e.trackItemsMap,changedAnimationIds:n})})}subscribeToUpdateTrackItemTiming(r){return this.stateSubject.asObservable().subscribe(e=>{if(!Y(e.trackItemsMap,this.prevState.trackItemsMap)){const n=Object.keys(e.trackItemsMap).filter(o=>{const u=this.prevState.trackItemsMap[o],c=e.trackItemsMap[o];return u&&c&&!Y(u.trim,c.trim)}),i=Object.keys(e.trackItemsMap).filter(o=>{const u=this.prevState.trackItemsMap[o],c=e.trackItemsMap[o];return u&&c&&!Y(u.display,c.display)});r({trackItemsMap:e.trackItemsMap,changedTrimIds:n.length>0?n:void 0,changedDisplayIds:i.length>0?i:void 0})}})}subscribeToUpdateItemDetails(r){return this.stateSubject.asObservable().subscribe(e=>{Object.keys(e.trackItemsMap).some(i=>{const o=this.prevState.trackItemsMap[i],u=e.trackItemsMap[i];return o&&u&&!Y(o.details,u.details)})&&r({trackItemsMap:e.trackItemsMap})})}subscribeToDuration(r){return this.stateSubject.asObservable().subscribe(e=>{e.duration!==this.prevState.duration&&r({duration:e.duration})})}subscribeToHistory(r){return this.stateHistorySubject.asObservable().subscribe(e=>{if(e.handleRedo){const n=this.undos[this.undos.length-1].type;r({...this.getState(),type:n}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}if(e.handleUndo){const n=this.redos[this.redos.length-1].type;r({...this.getState(),type:n}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}})}subscribeToAddOrRemoveItems(r){return this.stateSubject.asObservable().subscribe(e=>{const n=[...e.trackItemIds].sort(),i=[...this.prevState.trackItemIds].sort(),o=[...e.transitionIds].sort(),u=[...this.prevState.transitionIds].sort();(!Y(n,i)||!Y(o,u))&&r({trackItemIds:e.trackItemIds})})}subscribeToActiveIds(r){return this.stateSubject.asObservable().subscribe(e=>{Y(e.activeIds,this.prevState.activeIds)||r({activeIds:e.activeIds})})}subscribeToTracks(r){return this.stateSubject.asObservable().subscribe(e=>{const n=e.tracks,o=this.prevState.tracks.map(c=>c.id),u=n.filter(c=>!o.includes(c.id));u.length&&r({tracks:e.tracks,changedTracks:u.map(c=>c.id)})})}subscribeToState(r){return this.stateSubject.asObservable().subscribe(e=>{(!Y(e.tracks,this.prevState.tracks)||!Y(e.trackItemIds,this.prevState.trackItemIds)||!Y(e.trackItemsMap,this.prevState.trackItemsMap)||!Y(e.transitionIds,this.prevState.transitionIds)||!Y(e.transitionsMap,this.prevState.transitionsMap)||!Y(e.structure,this.prevState.structure))&&r({tracks:e.tracks,trackItemIds:e.trackItemIds,trackItemsMap:e.trackItemsMap,transitionIds:e.transitionIds,transitionsMap:e.transitionsMap,structure:e.structure})})}undo(){const r=this.undos.pop(),e=r==null?void 0:r.undos,n=r==null?void 0:r.type;if(!e||!n)return;Ii();const{trackItemIds:i,tracks:o,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}=this.getState(),h=C({trackItemIds:i,tracks:o,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}),I=[],m=[],k=[],_=[],y=[],v=[];e.forEach(D=>{let F;const nt=D.path.slice(1);D.type==="CREATE"?F={path:nt,op:"remove",value:D.value}:D.type==="CHANGE"?F={path:nt,op:"replace",value:D.oldValue}:F={path:nt,op:"add",value:D.oldValue},D.path.includes("trackItemIds")?k.push(F):D.path.includes("transitionIds")?m.push(F):D.path.includes("trackItemsMap")?y.push(F):D.path.includes("transitionsMap")?_.push(F):D.path.includes("tracks")?I.push(F):D.path.includes("structure")&&v.push(F)});const f=this.applyPatch(h.tracks,I),b=this.applyPatch(h.transitionIds,m),E=this.applyPatch(h.trackItemIds,k),S=this.applyPatch(h.transitionsMap,_),M=this.applyPatch(h.trackItemsMap,y),T=this.applyPatch(h.structure,v),A=C({tracks:f,transitionIds:b,trackItemIds:E,transitionsMap:S,trackItemsMap:M,structure:T}),U=C(this.getState()),P={...U,...A};this.prevState=U,this.redos.push({redos:e,type:n});const K=X(P.trackItemsMap);this.stateSubject.next({...P,duration:K}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!0}),this.updateState(P,{updateHistory:!1})}applyPatch(r,e){return e.reverse().reduce((n,i)=>oo(n,o=>{co(o,[i])}),r)}redo(){const r=this.redos.pop(),e=r==null?void 0:r.redos,n=r==null?void 0:r.type;if(!e||!n)return;Ii();const{trackItemIds:i,tracks:o,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}=this.getState(),h=C({trackItemIds:i,tracks:o,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}),I=[],m=[],k=[],_=[],y=[],v=[];e.forEach(D=>{let F;const nt=D.path.slice(1);D.type==="CREATE"?F={path:nt,op:"add",value:D.value}:D.type==="CHANGE"?F={path:nt,op:"replace",value:D.value}:F={path:nt,op:"remove",value:D.oldValue},D.path.includes("trackItemIds")?k.push(F):D.path.includes("transitionIds")?m.push(F):D.path.includes("trackItemsMap")?y.push(F):D.path.includes("transitionsMap")?_.push(F):D.path.includes("structure")?v.push(F):I.push(F)});const f=this.applyPatch(h.tracks,I),b=this.applyPatch(h.transitionIds,m),E=this.applyPatch(h.trackItemIds,k),S=this.applyPatch(h.transitionsMap,_),M=this.applyPatch(h.trackItemsMap,y),T=this.applyPatch(h.structure,v),A=C({tracks:f,transitionIds:b,trackItemIds:E,transitionsMap:S,trackItemsMap:M,structure:T}),U=C(this.getState()),P={...U,...A};this.prevState=U,this.undos.push({undos:e,type:n});const K=X(P.trackItemsMap);this.stateSubject.next({...P,duration:K}),this.stateHistorySubject.next({handleRedo:!0,handleUndo:!1}),this.updateState(P,{updateHistory:!1})}toJSON(){const{fps:r,tracks:e,size:n,trackItemIds:i,transitionsMap:o,trackItemsMap:u,transitionIds:c}=this.getState();return{fps:r,tracks:e,size:n,trackItemIds:i,transitionsMap:o,trackItemsMap:u,transitionIds:c}}}w.ACTIVE_CLONE=Ji,w.ACTIVE_DELETE=qi,w.ACTIVE_PASTE=Os,w.ACTIVE_PREFIX=te,w.ACTIVE_SET=Vi,w.ACTIVE_SPLIT=Ds,w.ADD_ANIMATION=ps,w.ADD_AUDIO=us,w.ADD_CAPTIONS=hs,w.ADD_COMPOSITION=gs,w.ADD_HILL_AUDIO_BARS=Es,w.ADD_ILLUSTRATION=ds,w.ADD_IMAGE=ls,w.ADD_ITEMS=Is,w.ADD_LINEAL_AUDIO_BARS=_s,w.ADD_MASK=ji,w.ADD_PLACEHOLDER=Ui,w.ADD_PREFIX=j,w.ADD_PROGRESS_BAR=ys,w.ADD_PROGRESS_FRAME=bs,w.ADD_PROGRESS_SQUARE=vs,w.ADD_RADIAL_AUDIO_BARS=ks,w.ADD_RECT=Ts,w.ADD_SHAPE=fs,w.ADD_SUFFIX=Ni,w.ADD_TEMPLATE=ms,w.ADD_TEXT=os,w.ADD_TRANSITION=Bi,w.ADD_VIDEO=cs,w.ADD_WAVE_AUDIO_BARS=Ss,w.BULK_PREFIX=ss,w.DELETE_TEMPLATE_ITEM=Xi,w.DESIGN_LOAD=is,w.DESIGN_PREFIX=fr,w.DESIGN_RESIZE=as,w.EDIT_BACKGROUND_EDITOR=Ms,w.EDIT_BULK=Fr,w.EDIT_OBJECT=ws,w.EDIT_PREFIX=At,w.EDIT_SHAPE=Wi,w.EDIT_TEMPLATE_ITEM=Gi,w.EDIT_TEXT=Yi,w.ENTER_EDIT_MODE=Ki,w.HISTORY_PREFIX=Ye,w.HISTORY_REDO=Ns,w.HISTORY_RESET=ca,w.HISTORY_UNDO=zs,w.LAYER_CLONE=Ps,w.LAYER_COPY=Cs,w.LAYER_CUT=oa,w.LAYER_DELETE=xs,w.LAYER_EDITING_NAME=sa,w.LAYER_HIDDEN=Qi,w.LAYER_LOCKED=Zi,w.LAYER_MOVE=ta,w.LAYER_PASTE=ia,w.LAYER_PREFIX=V,w.LAYER_RENAME=na,w.LAYER_REPLACE=Ls,w.LAYER_SELECT=Rs,w.LAYER_SELECTION=ea,w.LAYER_SEND_TO=ra,w.LAYER_SPLIT=aa,w.REPLACE_MEDIA=As,w.STATE_CHANGED=Hi,w.STATE_PREFIX=ns,w.TIMELINE_SCALE_CHANGED=Fs,w.TIMELINE_SCALE_PREFIX=$r,w.TRACKS_CHANGED=Fi,w.TRACK_ITEMS_CHANGED=$i,w.TRACK_ITEMS_PREFIX=rs,w.TRACK_PREFIX=es,w.default=Ho,w.getAcceptsMap=jr,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function Lr(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var cr=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,n,i,a;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var c=Rr(u),d=c.next();!d.done;d=c.next()){var p=d.value;p.remove(this)}}catch(b){r={error:b}}finally{try{d&&!d.done&&(e=c.return)&&e.call(c)}finally{if(r)throw r.error}}else u.remove(this);var h=this.initialTeardown;if(wt(h))try{h()}catch(b){a=b instanceof xr?b.errors:[b]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var m=Rr(y),g=m.next();!g.done;g=m.next()){var k=g.value;try{Xn(k)}catch(b){a=a??[],b instanceof xr?a=Pr(Pr([],Cr(a)),Cr(b.errors)):a.push(b)}}}catch(b){n={error:b}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(n)throw n.error}}}if(a)throw new xr(a)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)Xn(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&Lr(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&Lr(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),Wn=cr.EMPTY;function Gn(t){return t instanceof cr||t&&"closed"in t&&wt(t.remove)&&wt(t.add)&&wt(t.unsubscribe)}function Xn(t){wt(t)?t():t.unsubscribe()}var Ti={Promise:void 0},Ei={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,Pr([t,r],Cr(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function wi(t){Ei.setTimeout(function(){throw t})}function Kn(){}function ur(t){t()}var Vn=function(t){Be(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,Gn(e)&&e.add(n)):n.destination=Oi,n}return r.create=function(e,n,i){return new zr(e,n,i)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},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(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(cr),Ai=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){lr(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){lr(n)}else lr(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){lr(e)}},t}(),zr=function(t){Be(r,t);function r(e,n,i){var a=t.call(this)||this,u;return wt(e)||!e?u={next:e??void 0,error:n??void 0,complete:i??void 0}:u=e,a.destination=new Ai(u),a}return r}(Vn);function lr(t){wi(t)}function Mi(t){throw t}var Oi={closed:!0,next:Kn,error:Mi,complete:Kn},Di=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Ri(t){return t}function Ci(t){return t.length===0?Ri:t.length===1?t[0]:function(e){return t.reduce(function(n,i){return i(n)},e)}}var qn=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var i=this,a=xi(r)?r:new zr(r,e,n);return ur(function(){var u=i,c=u.operator,d=u.source;a.add(c?c.call(a,d):d?i._subscribe(a):i._trySubscribe(a))}),a},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=Jn(e),new e(function(i,a){var u=new zr({next:function(c){try{r(c)}catch(d){a(d),u.unsubscribe()}},error:a,complete:i});n.subscribe(u)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[Di]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return Ci(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=Jn(r),new r(function(n,i){var a;e.subscribe(function(u){return a=u},function(u){return i(u)},function(){return n(a)})})},t.create=function(r){return new t(r)},t}();function Jn(t){var r;return(r=t??Ti.Promise)!==null&&r!==void 0?r:Promise}function Pi(t){return t&&wt(t.next)&&wt(t.error)&&wt(t.complete)}function xi(t){return t&&t instanceof Vn||Pi(t)&&Gn(t)}var Li=Yn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Zn=function(t){Be(r,t);function r(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.prototype.lift=function(e){var n=new Qn(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new Li},r.prototype.next=function(e){var n=this;ur(function(){var i,a;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=Rr(n.currentObservers),c=u.next();!c.done;c=u.next()){var d=c.value;d.next(e)}}catch(p){i={error:p}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}}})},r.prototype.error=function(e){var n=this;ur(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var i=n.observers;i.length;)i.shift().error(e)}})},r.prototype.complete=function(){var e=this;ur(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=this,i=this,a=i.hasError,u=i.isStopped,c=i.observers;return a||u?Wn:(this.currentObservers=null,c.push(e),new cr(function(){n.currentObservers=null,Lr(c,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,i=n.hasError,a=n.thrownError,u=n.isStopped;i?e.error(a):u&&e.complete()},r.prototype.asObservable=function(){var e=new qn;return e.source=this,e},r.create=function(e,n){return new Qn(e,n)},r}(qn),Qn=function(t){Be(r,t);function r(e,n){var i=t.call(this)||this;return i.destination=e,i.source=n,i}return r.prototype.next=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,e)},r.prototype.error=function(e){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&i!==void 0?i:Wn},r}(Zn),ts=function(t){Be(r,t);function r(e){var n=t.call(this)||this;return n._value=e,n}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return!n.closed&&e.next(this._value),n},r.prototype.getValue=function(){var e=this,n=e.hasError,i=e.thrownError,a=e._value;if(n)throw i;return this._throwIfClosed(),a},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(Zn),ht=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var dr={exports:{}};dr.exports,function(t,r){var e=200,n="__lodash_hash_undefined__",i=1,a=2,u=9007199254740991,c="[object Arguments]",d="[object Array]",p="[object AsyncFunction]",h="[object Boolean]",y="[object Date]",m="[object Error]",g="[object Function]",k="[object GeneratorFunction]",b="[object Map]",v="[object Number]",f="[object Null]",_="[object Object]",T="[object Promise]",S="[object Proxy]",M="[object RegExp]",E="[object Set]",A="[object String]",U="[object Symbol]",P="[object Undefined]",K="[object WeakMap]",D="[object ArrayBuffer]",F="[object DataView]",nt="[object Float32Array]",ce="[object Float64Array]",ue="[object Int8Array]",Ae="[object Int16Array]",Me="[object Int32Array]",Oe="[object Uint8Array]",De="[object Uint8ClampedArray]",z="[object Uint16Array]",Re="[object Uint32Array]",Ce=/[\\^$.*+?()[\]{}|]/g,at=/^\[object .+?Constructor\]$/,le=/^(?:0|[1-9]\d*)$/,N={};N[nt]=N[ce]=N[ue]=N[Ae]=N[Me]=N[Oe]=N[De]=N[z]=N[Re]=!0,N[c]=N[d]=N[D]=N[h]=N[F]=N[y]=N[m]=N[g]=N[b]=N[v]=N[_]=N[M]=N[E]=N[A]=N[K]=!1;var de=typeof ht=="object"&&ht&&ht.Object===Object&&ht,Pe=typeof self=="object"&&self&&self.Object===Object&&self,ot=de||Pe||Function("return this")(),fe=r&&!r.nodeType&&r,pe=fe&&!0&&t&&!t.nodeType&&t,Ht=pe&&pe.exports===fe,Ut=Ht&&de.process,he=function(){try{return Ut&&Ut.binding&&Ut.binding("util")}catch{}}(),jt=he&&he.isTypedArray;function me(s,o){for(var l=-1,I=s==null?0:s.length,R=0,O=[];++l<I;){var L=s[l];o(L,l,s)&&(O[R++]=L)}return O}function Bt(s,o){for(var l=-1,I=o.length,R=s.length;++l<I;)s[R+l]=o[l];return s}function ye(s,o){for(var l=-1,I=s==null?0:s.length;++l<I;)if(o(s[l],l,s))return!0;return!1}function xe(s,o){for(var l=-1,I=Array(s);++l<s;)I[l]=o(l);return I}function Le(s){return function(o){return s(o)}}function Mt(s,o){return s.has(o)}function Yt(s,o){return s==null?void 0:s[o]}function Ie(s){var o=-1,l=Array(s.size);return s.forEach(function(I,R){l[++o]=[R,I]}),l}function ge(s,o){return function(l){return s(o(l))}}function pt(s){var o=-1,l=Array(s.size);return s.forEach(function(I){l[++o]=I}),l}var Ot=Array.prototype,ze=Function.prototype,bt=Object.prototype,Dt=ot["__core-js_shared__"],Wt=ze.toString,st=bt.hasOwnProperty,be=function(){var s=/[^.]+$/.exec(Dt&&Dt.keys&&Dt.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),ke=bt.toString,Ne=RegExp("^"+Wt.call(st).replace(Ce,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Gt=Ht?ot.Buffer:void 0,Rt=ot.Symbol,_e=ot.Uint8Array,Ct=bt.propertyIsEnumerable,kt=Ot.splice,ct=Rt?Rt.toStringTag:void 0,Pt=Object.getOwnPropertySymbols,Xt=Gt?Gt.isBuffer:void 0,_t=ge(Object.keys,Object),Kt=Lt(ot,"DataView"),vt=Lt(ot,"Map"),Vt=Lt(ot,"Promise"),qt=Lt(ot,"Set"),tr=Lt(ot,"WeakMap"),Jt=Lt(Object,"create"),gr=it(Kt),xt=it(vt),on=it(Vt),cn=it(qt),un=it(tr),br=Rt?Rt.prototype:void 0,er=br?br.valueOf:void 0;function J(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o<l;){var I=s[o];this.set(I[0],I[1])}}function ln(){this.__data__=Jt?Jt(null):{},this.size=0}function dn(s){var o=this.has(s)&&delete this.__data__[s];return this.size-=o?1:0,o}function fn(s){var o=this.__data__;if(Jt){var l=o[s];return l===n?void 0:l}return st.call(o,s)?o[s]:void 0}function pn(s){var o=this.__data__;return Jt?o[s]!==void 0:st.call(o,s)}function hn(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=Jt&&o===void 0?n:o,this}J.prototype.clear=ln,J.prototype.delete=dn,J.prototype.get=fn,J.prototype.has=pn,J.prototype.set=hn;function tt(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o<l;){var I=s[o];this.set(I[0],I[1])}}function mn(){this.__data__=[],this.size=0}function yn(s){var o=this.__data__,l=He(o,s);if(l<0)return!1;var I=o.length-1;return l==I?o.pop():kt.call(o,l,1),--this.size,!0}function In(s){var o=this.__data__,l=He(o,s);return l<0?void 0:o[l][1]}function gn(s){return He(this.__data__,s)>-1}function bn(s,o){var l=this.__data__,I=He(l,s);return I<0?(++this.size,l.push([s,o])):l[I][1]=o,this}tt.prototype.clear=mn,tt.prototype.delete=yn,tt.prototype.get=In,tt.prototype.has=gn,tt.prototype.set=bn;function ut(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o<l;){var I=s[o];this.set(I[0],I[1])}}function kn(){this.size=0,this.__data__={hash:new J,map:new(vt||tt),string:new J}}function _n(s){var o=It(this,s).delete(s);return this.size-=o?1:0,o}function vn(s){return It(this,s).get(s)}function Sn(s){return It(this,s).has(s)}function Tn(s,o){var l=It(this,s),I=l.size;return l.set(s,o),this.size+=l.size==I?0:1,this}ut.prototype.clear=kn,ut.prototype.delete=_n,ut.prototype.get=vn,ut.prototype.has=Sn,ut.prototype.set=Tn;function Fe(s){var o=-1,l=s==null?0:s.length;for(this.__data__=new ut;++o<l;)this.add(s[o])}function kr(s){return this.__data__.set(s,n),this}function $e(s){return this.__data__.has(s)}Fe.prototype.add=Fe.prototype.push=kr,Fe.prototype.has=$e;function St(s){var o=this.__data__=new tt(s);this.size=o.size}function rr(){this.__data__=new tt,this.size=0}function En(s){var o=this.__data__,l=o.delete(s);return this.size=o.size,l}function wn(s){return this.__data__.get(s)}function An(s){return this.__data__.has(s)}function Mn(s,o){var l=this.__data__;if(l instanceof tt){var I=l.__data__;if(!vt||I.length<e-1)return I.push([s,o]),this.size=++l.size,this;l=this.__data__=new ut(I)}return l.set(s,o),this.size=l.size,this}St.prototype.clear=rr,St.prototype.delete=En,St.prototype.get=wn,St.prototype.has=An,St.prototype.set=Mn;function On(s,o){var l=Ue(s),I=!l&&Er(s),R=!l&&!I&&je(s),O=!l&&!I&&!R&&Mr(s),L=l||I||R||O,x=L?xe(s.length,String):[],B=x.length;for(var $ in s)st.call(s,$)&&!(L&&($=="length"||R&&($=="offset"||$=="parent")||O&&($=="buffer"||$=="byteLength"||$=="byteOffset")||Nn($,B)))&&x.push($);return x}function He(s,o){for(var l=s.length;l--;)if(Tr(s[l][0],o))return l;return-1}function nr(s,o,l){var I=o(s);return Ue(s)?I:Bt(I,l(s))}function ve(s){return s==null?s===void 0?P:f:ct&&ct in Object(s)?zt(s):Sr(s)}function _r(s){return Et(s)&&ve(s)==c}function vr(s,o,l,I,R){return s===o?!0:s==null||o==null||!Et(s)&&!Et(o)?s!==s&&o!==o:Dn(s,o,l,I,vr,R)}function Dn(s,o,l,I,R,O){var L=Ue(s),x=Ue(o),B=L?d:Tt(s),$=x?d:Tt(o);B=B==c?_:B,$=$==c?_:$;var et=B==_,lt=$==_,X=B==$;if(X&&je(s)){if(!je(o))return!1;L=!0,et=!1}if(X&&!et)return O||(O=new St),L||Mr(s)?sr(s,o,l,I,R,O):xn(s,o,B,l,I,R,O);if(!(l&i)){var rt=et&&st.call(s,"__wrapped__"),Z=lt&&st.call(o,"__wrapped__");if(rt||Z){var Zt=rt?s.value():s,Nt=Z?o.value():o;return O||(O=new St),R(Zt,Nt,l,I,O)}}return X?(O||(O=new St),Ln(s,o,l,I,R,O)):!1}function Rn(s){if(!Ar(s)||$n(s))return!1;var o=wr(s)?Ne:at;return o.test(it(s))}function Cn(s){return Et(s)&&ar(s.length)&&!!N[ve(s)]}function Pn(s){if(!Hn(s))return _t(s);var o=[];for(var l in Object(s))st.call(s,l)&&l!="constructor"&&o.push(l);return o}function sr(s,o,l,I,R,O){var L=l&i,x=s.length,B=o.length;if(x!=B&&!(L&&B>x))return!1;var $=O.get(s);if($&&O.get(o))return $==o;var et=-1,lt=!0,X=l&a?new Fe:void 0;for(O.set(s,o),O.set(o,s);++et<x;){var rt=s[et],Z=o[et];if(I)var Zt=L?I(Z,rt,et,o,s,O):I(rt,Z,et,s,o,O);if(Zt!==void 0){if(Zt)continue;lt=!1;break}if(X){if(!ye(o,function(Nt,Te){if(!Mt(X,Te)&&(rt===Nt||R(rt,Nt,l,I,O)))return X.push(Te)})){lt=!1;break}}else if(!(rt===Z||R(rt,Z,l,I,O))){lt=!1;break}}return O.delete(s),O.delete(o),lt}function xn(s,o,l,I,R,O,L){switch(l){case F:if(s.byteLength!=o.byteLength||s.byteOffset!=o.byteOffset)return!1;s=s.buffer,o=o.buffer;case D:return!(s.byteLength!=o.byteLength||!O(new _e(s),new _e(o)));case h:case y:case v:return Tr(+s,+o);case m:return s.name==o.name&&s.message==o.message;case M:case A:return s==o+"";case b:var x=Ie;case E:var B=I&i;if(x||(x=pt),s.size!=o.size&&!B)return!1;var $=L.get(s);if($)return $==o;I|=a,L.set(s,o);var et=sr(x(s),x(o),I,R,O,L);return L.delete(s),et;case U:if(er)return er.call(s)==er.call(o)}return!1}function Ln(s,o,l,I,R,O){var L=l&i,x=Se(s),B=x.length,$=Se(o),et=$.length;if(B!=et&&!L)return!1;for(var lt=B;lt--;){var X=x[lt];if(!(L?X in o:st.call(o,X)))return!1}var rt=O.get(s);if(rt&&O.get(o))return rt==o;var Z=!0;O.set(s,o),O.set(o,s);for(var Zt=L;++lt<B;){X=x[lt];var Nt=s[X],Te=o[X];if(I)var Si=L?I(Te,Nt,X,o,s,O):I(Nt,Te,X,s,o,O);if(!(Si===void 0?Nt===Te||R(Nt,Te,l,I,O):Si)){Z=!1;break}Zt||(Zt=X=="constructor")}if(Z&&!Zt){var Or=s.constructor,Dr=o.constructor;Or!=Dr&&"constructor"in s&&"constructor"in o&&!(typeof Or=="function"&&Or instanceof Or&&typeof Dr=="function"&&Dr instanceof Dr)&&(Z=!1)}return O.delete(s),O.delete(o),Z}function Se(s){return nr(s,or,zn)}function It(s,o){var l=s.__data__;return Fn(o)?l[typeof o=="string"?"string":"hash"]:l.map}function Lt(s,o){var l=Yt(s,o);return Rn(l)?l:void 0}function zt(s){var o=st.call(s,ct),l=s[ct];try{s[ct]=void 0;var I=!0}catch{}var R=ke.call(s);return I&&(o?s[ct]=l:delete s[ct]),R}var zn=Pt?function(s){return s==null?[]:(s=Object(s),me(Pt(s),function(o){return Ct.call(s,o)}))}:jn,Tt=ve;(Kt&&Tt(new Kt(new ArrayBuffer(1)))!=F||vt&&Tt(new vt)!=b||Vt&&Tt(Vt.resolve())!=T||qt&&Tt(new qt)!=E||tr&&Tt(new tr)!=K)&&(Tt=function(s){var o=ve(s),l=o==_?s.constructor:void 0,I=l?it(l):"";if(I)switch(I){case gr:return F;case xt:return b;case on:return T;case cn:return E;case un:return K}return o});function Nn(s,o){return o=o??u,!!o&&(typeof s=="number"||le.test(s))&&s>-1&&s%1==0&&s<o}function Fn(s){var o=typeof s;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?s!=="__proto__":s===null}function $n(s){return!!be&&be in s}function Hn(s){var o=s&&s.constructor,l=typeof o=="function"&&o.prototype||bt;return s===l}function Sr(s){return ke.call(s)}function it(s){if(s!=null){try{return Wt.call(s)}catch{}try{return s+""}catch{}}return""}function Tr(s,o){return s===o||s!==s&&o!==o}var Er=_r(function(){return arguments}())?_r:function(s){return Et(s)&&st.call(s,"callee")&&!Ct.call(s,"callee")},Ue=Array.isArray;function ir(s){return s!=null&&ar(s.length)&&!wr(s)}var je=Xt||Bn;function Un(s,o){return vr(s,o)}function wr(s){if(!Ar(s))return!1;var o=ve(s);return o==g||o==k||o==p||o==S}function ar(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=u}function Ar(s){var o=typeof s;return s!=null&&(o=="object"||o=="function")}function Et(s){return s!=null&&typeof s=="object"}var Mr=jt?Le(jt):Cn;function or(s){return ir(s)?On(s):Pn(s)}function jn(){return[]}function Bn(){return!1}t.exports=Un}(dr,dr.exports);var zi=dr.exports;const Y=Nr(zi),Ni="add",es="track",rs="trackItems",Fi=`${es}:changed`,$i=`${rs}:changed`,ns="state",Hi=`${ns}:changed`,ss="bulk",Fr=`${ss}:edit`,fr="design",is=`${fr}:load`,as=`${fr}:resize`,j="add",os=`${j}:text`,cs=`${j}:video`,us=`${j}:audio`,Ui=`${j}:placeholder`,ls=`${j}:image`,ds=`${j}:illustration`,fs=`${j}:shape`,ji=`${j}:mask`,Bi=`${j}:transition`,ps=`${j}:animation`,hs=`${j}:caption`,ms=`${j}:template`,ys=`${j}:items`,Is=`${j}:composition`,gs=`${j}:progressBar`,bs=`${j}:progressFrame`,ks=`${j}:radialAudioBars`,_s=`${j}:linealAudioBars`,vs=`${j}:progressSquare`,Ss=`${j}:waveAudioBars`,Ts=`${j}:hillAudioBars`,Es=`${j}:rect`,At="edit",ws=`${At}:object`,As=`${At}:replaceMedia`,Yi=`${At}:text`,Wi=`${At}:shape`,Gi=`${At}:templateItem`,Xi=`${At}:deleteTemplateItem`,Ms=`${At}:backgroundEditor`,Ki="enterEditMode",te="active",Vi=`${te}:set`,qi=`${te}:delete`,Os=`${te}:paste`,Ji=`${te}:clone`,Ds=`${te}:split`,V="layer",Zi=`${V}:locked`,Qi=`${V}:hidden`,ta=`${V}:move`,Rs=`${V}:select`,ea=`${V}:selection`,ra=`${V}:sendTo`,na=`${V}:rename`,sa=`${V}:editingName`,Cs=`${V}:copy`,ia=`${V}:paste`,Ps=`${V}:clone`,aa=`${V}:split`,oa=`${V}:cut`,xs=`${V}:delete`,Ls=`${V}:replace`,Ye="history",zs=`${Ye}:undo`,Ns=`${Ye}:redo`,ca=`${Ye}:reset`,$r="scale",Fs=`${$r}:changed`;var pr={exports:{}};pr.exports,function(t,r){var e=200,n="__lodash_hash_undefined__",i=9007199254740991,a="[object Arguments]",u="[object Array]",c="[object Boolean]",d="[object Date]",p="[object Error]",h="[object Function]",y="[object GeneratorFunction]",m="[object Map]",g="[object Number]",k="[object Object]",b="[object Promise]",v="[object RegExp]",f="[object Set]",_="[object String]",T="[object Symbol]",S="[object WeakMap]",M="[object ArrayBuffer]",E="[object DataView]",A="[object Float32Array]",U="[object Float64Array]",P="[object Int8Array]",K="[object Int16Array]",D="[object Int32Array]",F="[object Uint8Array]",nt="[object Uint8ClampedArray]",ce="[object Uint16Array]",ue="[object Uint32Array]",Ae=/[\\^$.*+?()[\]{}|]/g,Me=/\w*$/,Oe=/^\[object .+?Constructor\]$/,De=/^(?:0|[1-9]\d*)$/,z={};z[a]=z[u]=z[M]=z[E]=z[c]=z[d]=z[A]=z[U]=z[P]=z[K]=z[D]=z[m]=z[g]=z[k]=z[v]=z[f]=z[_]=z[T]=z[F]=z[nt]=z[ce]=z[ue]=!0,z[p]=z[h]=z[S]=!1;var Re=typeof ht=="object"&&ht&&ht.Object===Object&&ht,Ce=typeof self=="object"&&self&&self.Object===Object&&self,at=Re||Ce||Function("return this")(),le=r&&!r.nodeType&&r,N=le&&!0&&t&&!t.nodeType&&t,de=N&&N.exports===le;function Pe(s,o){return s.set(o[0],o[1]),s}function ot(s,o){return s.add(o),s}function fe(s,o){for(var l=-1,I=s?s.length:0;++l<I&&o(s[l],l,s)!==!1;);return s}function pe(s,o){for(var l=-1,I=o.length,R=s.length;++l<I;)s[R+l]=o[l];return s}function Ht(s,o,l,I){for(var R=-1,O=s?s.length:0;++R<O;)l=o(l,s[R],R,s);return l}function Ut(s,o){for(var l=-1,I=Array(s);++l<s;)I[l]=o(l);return I}function he(s,o){return s==null?void 0:s[o]}function jt(s){var o=!1;if(s!=null&&typeof s.toString!="function")try{o=!!(s+"")}catch{}return o}function me(s){var o=-1,l=Array(s.size);return s.forEach(function(I,R){l[++o]=[R,I]}),l}function Bt(s,o){return function(l){return s(o(l))}}function ye(s){var o=-1,l=Array(s.size);return s.forEach(function(I){l[++o]=I}),l}var xe=Array.prototype,Le=Function.prototype,Mt=Object.prototype,Yt=at["__core-js_shared__"],Ie=function(){var s=/[^.]+$/.exec(Yt&&Yt.keys&&Yt.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),ge=Le.toString,pt=Mt.hasOwnProperty,Ot=Mt.toString,ze=RegExp("^"+ge.call(pt).replace(Ae,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bt=de?at.Buffer:void 0,Dt=at.Symbol,Wt=at.Uint8Array,st=Bt(Object.getPrototypeOf,Object),be=Object.create,ke=Mt.propertyIsEnumerable,Ne=xe.splice,Gt=Object.getOwnPropertySymbols,Rt=bt?bt.isBuffer:void 0,_e=Bt(Object.keys,Object),Ct=It(at,"DataView"),kt=It(at,"Map"),ct=It(at,"Promise"),Pt=It(at,"Set"),Xt=It(at,"WeakMap"),_t=It(Object,"create"),Kt=it(Ct),vt=it(kt),Vt=it(ct),qt=it(Pt),tr=it(Xt),Jt=Dt?Dt.prototype:void 0,gr=Jt?Jt.valueOf:void 0;function xt(s){var o=-1,l=s?s.length:0;for(this.clear();++o<l;){var I=s[o];this.set(I[0],I[1])}}function on(){this.__data__=_t?_t(null):{}}function cn(s){return this.has(s)&&delete this.__data__[s]}function un(s){var o=this.__data__;if(_t){var l=o[s];return l===n?void 0:l}return pt.call(o,s)?o[s]:void 0}function br(s){var o=this.__data__;return _t?o[s]!==void 0:pt.call(o,s)}function er(s,o){var l=this.__data__;return l[s]=_t&&o===void 0?n:o,this}xt.prototype.clear=on,xt.prototype.delete=cn,xt.prototype.get=un,xt.prototype.has=br,xt.prototype.set=er;function J(s){var o=-1,l=s?s.length:0;for(this.clear();++o<l;){var I=s[o];this.set(I[0],I[1])}}function ln(){this.__data__=[]}function dn(s){var o=this.__data__,l=$e(o,s);if(l<0)return!1;var I=o.length-1;return l==I?o.pop():Ne.call(o,l,1),!0}function fn(s){var o=this.__data__,l=$e(o,s);return l<0?void 0:o[l][1]}function pn(s){return $e(this.__data__,s)>-1}function hn(s,o){var l=this.__data__,I=$e(l,s);return I<0?l.push([s,o]):l[I][1]=o,this}J.prototype.clear=ln,J.prototype.delete=dn,J.prototype.get=fn,J.prototype.has=pn,J.prototype.set=hn;function tt(s){var o=-1,l=s?s.length:0;for(this.clear();++o<l;){var I=s[o];this.set(I[0],I[1])}}function mn(){this.__data__={hash:new xt,map:new(kt||J),string:new xt}}function yn(s){return Se(this,s).delete(s)}function In(s){return Se(this,s).get(s)}function gn(s){return Se(this,s).has(s)}function bn(s,o){return Se(this,s).set(s,o),this}tt.prototype.clear=mn,tt.prototype.delete=yn,tt.prototype.get=In,tt.prototype.has=gn,tt.prototype.set=bn;function ut(s){this.__data__=new J(s)}function kn(){this.__data__=new J}function _n(s){return this.__data__.delete(s)}function vn(s){return this.__data__.get(s)}function Sn(s){return this.__data__.has(s)}function Tn(s,o){var l=this.__data__;if(l instanceof J){var I=l.__data__;if(!kt||I.length<e-1)return I.push([s,o]),this;l=this.__data__=new tt(I)}return l.set(s,o),this}ut.prototype.clear=kn,ut.prototype.delete=_n,ut.prototype.get=vn,ut.prototype.has=Sn,ut.prototype.set=Tn;function Fe(s,o){var l=ir(s)||Ue(s)?Ut(s.length,String):[],I=l.length,R=!!I;for(var O in s)pt.call(s,O)&&!(R&&(O=="length"||Fn(O,I)))&&l.push(O);return l}function kr(s,o,l){var I=s[o];(!(pt.call(s,o)&&Er(I,l))||l===void 0&&!(o in s))&&(s[o]=l)}function $e(s,o){for(var l=s.length;l--;)if(Er(s[l][0],o))return l;return-1}function St(s,o){return s&&sr(o,or(o),s)}function rr(s,o,l,I,R,O,L){var x;if(I&&(x=O?I(s,R,O,L):I(s)),x!==void 0)return x;if(!Et(s))return s;var B=ir(s);if(B){if(x=zn(s),!o)return Pn(s,x)}else{var $=zt(s),et=$==h||$==y;if(wr(s))return He(s,o);if($==k||$==a||et&&!O){if(jt(s))return O?s:{};if(x=Tt(et?{}:s),!o)return xn(s,St(x,s))}else{if(!z[$])return O?s:{};x=Nn(s,$,rr,o)}}L||(L=new ut);var lt=L.get(s);if(lt)return lt;if(L.set(s,x),!B)var X=l?Ln(s):or(s);return fe(X||s,function(rt,Z){X&&(Z=rt,rt=s[Z]),kr(x,Z,rr(rt,o,l,I,Z,s,L))}),x}function En(s){return Et(s)?be(s):{}}function wn(s,o,l){var I=o(s);return ir(s)?I:pe(I,l(s))}function An(s){return Ot.call(s)}function Mn(s){if(!Et(s)||Hn(s))return!1;var o=ar(s)||jt(s)?ze:Oe;return o.test(it(s))}function On(s){if(!Sr(s))return _e(s);var o=[];for(var l in Object(s))pt.call(s,l)&&l!="constructor"&&o.push(l);return o}function He(s,o){if(o)return s.slice();var l=new s.constructor(s.length);return s.copy(l),l}function nr(s){var o=new s.constructor(s.byteLength);return new Wt(o).set(new Wt(s)),o}function ve(s,o){var l=o?nr(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.byteLength)}function _r(s,o,l){var I=o?l(me(s),!0):me(s);return Ht(I,Pe,new s.constructor)}function vr(s){var o=new s.constructor(s.source,Me.exec(s));return o.lastIndex=s.lastIndex,o}function Dn(s,o,l){var I=o?l(ye(s),!0):ye(s);return Ht(I,ot,new s.constructor)}function Rn(s){return gr?Object(gr.call(s)):{}}function Cn(s,o){var l=o?nr(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.length)}function Pn(s,o){var l=-1,I=s.length;for(o||(o=Array(I));++l<I;)o[l]=s[l];return o}function sr(s,o,l,I){l||(l={});for(var R=-1,O=o.length;++R<O;){var L=o[R],x=void 0;kr(l,L,x===void 0?s[L]:x)}return l}function xn(s,o){return sr(s,Lt(s),o)}function Ln(s){return wn(s,or,Lt)}function Se(s,o){var l=s.__data__;return $n(o)?l[typeof o=="string"?"string":"hash"]:l.map}function It(s,o){var l=he(s,o);return Mn(l)?l:void 0}var Lt=Gt?Bt(Gt,Object):jn,zt=An;(Ct&&zt(new Ct(new ArrayBuffer(1)))!=E||kt&&zt(new kt)!=m||ct&&zt(ct.resolve())!=b||Pt&&zt(new Pt)!=f||Xt&&zt(new Xt)!=S)&&(zt=function(s){var o=Ot.call(s),l=o==k?s.constructor:void 0,I=l?it(l):void 0;if(I)switch(I){case Kt:return E;case vt:return m;case Vt:return b;case qt:return f;case tr:return S}return o});function zn(s){var o=s.length,l=s.constructor(o);return o&&typeof s[0]=="string"&&pt.call(s,"index")&&(l.index=s.index,l.input=s.input),l}function Tt(s){return typeof s.constructor=="function"&&!Sr(s)?En(st(s)):{}}function Nn(s,o,l,I){var R=s.constructor;switch(o){case M:return nr(s);case c:case d:return new R(+s);case E:return ve(s,I);case A:case U:case P:case K:case D:case F:case nt:case ce:case ue:return Cn(s,I);case m:return _r(s,I,l);case g:case _:return new R(s);case v:return vr(s);case f:return Dn(s,I,l);case T:return Rn(s)}}function Fn(s,o){return o=o??i,!!o&&(typeof s=="number"||De.test(s))&&s>-1&&s%1==0&&s<o}function $n(s){var o=typeof s;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?s!=="__proto__":s===null}function Hn(s){return!!Ie&&Ie in s}function Sr(s){var o=s&&s.constructor,l=typeof o=="function"&&o.prototype||Mt;return s===l}function it(s){if(s!=null){try{return ge.call(s)}catch{}try{return s+""}catch{}}return""}function Tr(s){return rr(s,!0,!0)}function Er(s,o){return s===o||s!==s&&o!==o}function Ue(s){return Un(s)&&pt.call(s,"callee")&&(!ke.call(s,"callee")||Ot.call(s)==a)}var ir=Array.isArray;function je(s){return s!=null&&Ar(s.length)&&!ar(s)}function Un(s){return Mr(s)&&je(s)}var wr=Rt||Bn;function ar(s){var o=Et(s)?Ot.call(s):"";return o==h||o==y}function Ar(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=i}function Et(s){var o=typeof s;return!!s&&(o=="object"||o=="function")}function Mr(s){return!!s&&typeof s=="object"}function or(s){return je(s)?Fe(s):On(s)}function jn(){return[]}function Bn(){return!1}t.exports=Tr}(pr,pr.exports);var ua=pr.exports;const C=Nr(ua);function la(t,r){return t.filter(n=>{if(r.forEach(i=>{n.items.includes(i)&&(n.items=n.items.filter(a=>a!==i))}),n.items.length!==0||n.static)return n})}const W=t=>Object.keys(t).reduce((r,e)=>{const{display:n}=t[e];return Math.max(r,n.to)},0);function Q(t,r,e){t.forEach(n=>{const i=n.items.map(k=>String(k)),a=Object.values(r).filter(k=>i.includes(String(k.id))),c=a.filter(k=>!e.includes(String(k.id))).sort((k,b)=>k.display.from-b.display.from),d=a.sort((k,b)=>k.display.from-b.display.from),p=c[c.length-1];let h=(p==null?void 0:p.display.to)||0;d.forEach(k=>{if(e.includes(String(k.id))){const b=k.playbackRate||1;let v;(k.type==="video"||k.type==="audio")&&k.trim?v=(k.trim.to-k.trim.from)/b:v=k.display.to-k.display.from,k.display={from:h,to:h+v},h=h+v}});const m=a.sort((k,b)=>k.display.from-b.display.from).map(k=>String(k.id));let g=0;m.forEach(k=>{const b=[];let v=0;if(b.forEach(f=>{f.forEach(_=>{_.type==="transition"&&(v+=_.duration)})}),r[String(k)]){const f=r[String(k)],_=f.playbackRate||1;let T;(f.type==="video"||f.type==="audio")&&f.trim?T=(f.trim.to-f.trim.from)/_:T=f.display.to-f.display.from,r[String(k)].display={from:g-v,to:g+T-v},g+=T}})})}function $s(t,r,e,n,i,a){return r.forEach(u=>{if(!t.includes(u)&&(i[u]=e[u],e[u].type==="composition"||e[u].type==="template")){const c=n.find(d=>d.id===u);c&&(a.push(c),$s(t,c.items,e,n,i,a))}}),{updatedTrackItems:i,updatedStructure:a}}function da(t,r){const e=C(t),n=r&&r.length?r:e.activeIds,i=n.map(E=>e.trackItemsMap[E]).filter(E=>!!E).map(E=>E.id),a=e.transitionIds.filter(E=>{const A=e.transitionsMap[E];return i.includes(A.fromId)||i.includes(A.toId)});i.push(...a);const u=e.trackItemIds,c=e.transitionIds,d=C(e.tracks),p=C(e.structure);i.forEach(E=>{var U;const A=e.trackItemsMap[E]||e.transitionsMap[E];if(A.type==="template"||A.type==="composition"){const P=(U=e.structure.find(D=>D.id===A.id))==null?void 0:U.items;i.push(...P);const K=p.findIndex(D=>D.id===A.id);p.splice(K,1)}}),i.forEach(E=>{p.forEach(A=>{A.items.includes(E)&&(A.items=A.items.filter(U=>U!==E))})});const h=u.filter(E=>!i.includes(E));c.forEach(E=>{n.includes(E)&&n.length===1&&C(e.transitionsMap[E])});const y=c.filter(E=>!i.includes(E)&&!n.includes(E)),m=Object.fromEntries(Object.entries(e.transitionsMap).filter(([E])=>!i.includes(E)));Object.keys(m).forEach(E=>{n.includes(E)&&(m[E].kind="none")});const g=e.trackItemIds.filter(E=>!n.includes(E)),k=la(e.tracks,n),b=Object.fromEntries(Object.entries(e.trackItemsMap).filter(([E])=>!i.includes(E))),v=d.filter(E=>E.magnetic);Q(v,b,[]);const f={},_=[],{updatedTrackItems:T,updatedStructure:S}=$s(i,g,e.trackItemsMap,e.structure,f,_),M=W(T);return{trackItemIds:h,activeIds:[],trackItemsMap:T,tracks:k,duration:M,structure:S,transitionIds:y,transitionsMap:m}}const fa="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Hr=(t=21)=>{let r="",e=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)r+=fa[e[t]&63];return r};function ee(t=16){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e=r.charAt(Math.floor(Math.random()*r.length));let n=Hr(t-1);return n=n.replace(/[^a-zA-Z0-9]/g,"").slice(0,t-1),e+n}const Ee=t=>{const r=t.map(e=>new FontFace(e.fontFamily,`url(${e.url})`).load().catch(n=>n));return r.length===0?Promise.resolve(!0):new Promise((e,n)=>{Promise.all(r).then(i=>{i.forEach(a=>{a&&a.family&&(document.fonts.add(a),e(!0))})}).catch(i=>n(i))})};function pa(t,r){return t.forEach(e=>{r=r.split(e).join(ee())}),r}function Hs(t,r,e){const n=t.find(a=>a.id===r);if(!n)return[];const i=n.items;return i.forEach(a=>{const u=e[a];(u.type==="text"||u.type==="caption")&&Ee([{fontFamily:u.details.fontFamily,url:u.details.fontUrl}]),(u.type==="composition"||u.type==="template")&&i.push(...Hs(t,a,e))}),i}async function ha(t){let r=localStorage.getItem("DesignComboTemp");if(!r)return{};const e=C(t);let n=C(JSON.parse(r));const i=n.activeIds,a=n.trackItemsMap,u=n.structure;Object.keys(a).forEach(b=>{const v=a[b];if((v.type==="text"||v.type==="caption")&&Ee([{fontFamily:v.details.fontFamily,url:v.details.fontUrl}]),v.type==="composition"||v.type==="template"){const f=Hs(u,b,a);i.push(...f)}});const c=pa(i,r),d=C(JSON.parse(c)),p=e.tracks;d.activeIds.forEach(b=>{const v=d.trackItemsMap[b];e.trackItemsMap[b]=v,e.trackItemIds.push(b);const f={id:ee(),type:v.type,items:[b],magnetic:!1,static:!1};p.unshift(f)});const h=[...d.structure,...e.structure],y=e.trackItemIds,m={...d.trackItemsMap,...e.trackItemsMap},g={structure:h,trackItemIds:y,trackItemsMap:m,tracks:p},k=W(g.trackItemsMap);return{trackItemIds:g.trackItemIds,trackItemsMap:g.trackItemsMap,structure:g.structure,tracks:g.tracks,duration:k}}let hr={cors:{audio:!0,video:!0,image:!0},acceptsMap:{text:["text","caption","composition"],image:["image","video"],video:["video","image"],audio:["audio"],composition:["composition"],caption:["caption","text","composition"],template:["template","image","video"],customTrack:["video","image","template"],customTrack2:["video","image","template"],illustration:["illustration","custom"],custom:["custom","video","illustration"],main:["video","image","template"],shape:["shape","custom","illustration"],linealAudioBars:["audio","linealAudioBars"],radialAudioBars:["audio","radialAudioBars"],progressFrame:["audio","progressFrame"],progressBar:["audio","progressBar"],rect:["rect"],progressSquare:["progressSquare"]}};const ma=t=>{const r=Object.fromEntries(Object.entries(t).filter(([e,n])=>n!==void 0));hr={...hr,...r}},Ur=()=>hr.cors,jr=()=>hr.acceptsMap,we=t=>new Promise((r,e)=>{const n=new Image;n.onload=()=>{const a=n.width,u=n.height;r({width:a,height:u})},n.onerror=a=>{e(a)},Ur().image&&(n.crossOrigin="anonymous"),n.src=t}),Us=t=>new Promise((r,e)=>{const n=new Audio;n.preload="auto",n.addEventListener("loadedmetadata",()=>{const a=n.duration*1e3;r({duration:a})}),n.addEventListener("error",a=>{e(a)}),n.src=t,Ur().audio&&(n.crossOrigin="anonymous"),n.load()}),Br=t=>new Promise((r,e)=>{const n=document.createElement("video");n.preload="auto",n.addEventListener("loadedmetadata",()=>{const a=n.duration*1e3,u=n.videoWidth,c=n.videoHeight;r({duration:a,width:u,height:c})}),n.addEventListener("error",a=>{e(a)}),n.src=t,Ur().video&&(n.crossOrigin="anonymous"),n.load()}),ya=async t=>{var i,a;const r=t.duration,e=(i=t.details)==null?void 0:i.width,n=(a=t.details)==null?void 0:a.height;return r&&e&&n?{duration:r,width:e,height:n}:Br(t.details.src)},js=(t,r)=>{const e=document.createElement("div");Object.keys(r).forEach(i=>{i!=="height"&&(e.style[i]=r[i])}),document.body.appendChild(e),e.textContent=t,e.style.whiteSpace="normal",e.style.position="absolute",e.style.visibility="hidden",e.style.display="inline-block",e.style.width=r.width+"px",e.style.fontSize=r.fontSize+"px";const n=getComputedStyle(e).height;return document.body.removeChild(e),parseFloat(n)},Bs=(t,r)=>{var c,d;const e=((c=t.details.crop)==null?void 0:c.width)||t.details.width||0,n=((d=t.details.crop)==null?void 0:d.height)||t.details.height||0;let i=r.width,a=r.height;const u=r.width/r.height;return e/n>u?(i=e,a=e/u):(a=n,i=n*u),{newWidth:i,newHeight:a,crop:{x:0,y:0,height:n,width:e}}},Ys=(t,r)=>{const e=C(t.trim),n=C(t.display);return r.duration<t.display.to&&(n.to=r.duration+t.display.from,e&&(e.to=r.duration)),{duration:r.duration,trim:e,display:n}};async function Ia(t,r){const e={...t},n=Object.keys(r)[0],i=Object.values(r)[0],a=e.trackItemsMap[n],u={...e.trackItemsMap[n]},c=a.details;if(!i.details.src)return{};if(a.type==="image"){const d=await we(i.details.src),{crop:p,newHeight:h,newWidth:y}=Bs(a,d);i.details.crop=p,i.details.height=h,i.details.width=y}else if(a.type==="video"){const d=await Br(i.details.src),p=e.trackItemsMap[n],{display:h,duration:y,trim:m}=Ys(p,d),{crop:g,newHeight:k,newWidth:b}=Bs(a,d);i.details.crop=g,i.details.height=k,i.details.width=b,u.display=h,u.duration=y,u.trim=m}else if(a.type==="audio"){const d=await Us(i.details.src),p=e.trackItemsMap[n],{display:h,duration:y,trim:m}=Ys(p,d);u.display=h,u.duration=y,u.trim=m}return a.metadata&&i.metadata?u.metadata={...a.metadata,...i.metadata}:i.metadata&&(u.metadata=i.metadata),a.details={...c,...i.details},e.trackItemsMap[n]={...u},{trackItemsMap:{...e.trackItemsMap,[n]:{...u,details:{...c,...i.details}}}}}function ga(t,r){const e=C(t),n={},i=r&&r.length?r:e.activeIds;if(i.length===0)return{};i.forEach(u=>{const c=e.trackItemsMap[u],d=ee();e.trackItemsMap[d]={...C(c),id:d},e.trackItemIds.push(d);const p=e.tracks.find(h=>h.items.includes(u));n[p.id]?n[p.id].items.push(d):n[p.id]={...p,id:ee(),items:[d],static:!1,magnetic:!1}});const a=Object.values(n);return e.tracks=[...a,...e.tracks],{trackItemsMap:e.trackItemsMap,tracks:e.tracks,trackItemIds:e.trackItemIds}}function ba(t){const r=/#([0-9a-fA-F]{3,6})\b/g,e=/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/g,n=/rgba\(\s*(\d+),\s*(\d+),\s*(\d+),\s*([0-9.]+)\s*\)/g;function i(u){return u.length===3?`#${u[0]}${u[0]}${u[1]}${u[1]}${u[2]}${u[2]}`.toUpperCase():`#${u.toUpperCase()}`}function a(u,c,d){return`#${(1<<24|u<<16|c<<8|d).toString(16).slice(1).toUpperCase()}`}return t=t.replace(r,(u,c)=>i(c)),t=t.replace(e,(u,c,d,p)=>a(+c,+d,+p)),t=t.replace(n,(u,c,d,p)=>a(+c,+d,+p)),t}function q(t){return/^#[0-9a-fA-F]{3}$/.test(t)?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t}function Ws(t,r){let e=t;for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)){const i=new RegExp(n,"g");e=e.replace(i,r[n])}return e}function Gs(t){const r=t.getAttribute("fill");if(r&&r.trim()!==""&&r.trim()!=="none")return r.trim();const e=t.getAttribute("style");if(e){const i=/fill\s*:\s*([^;]+);?/.exec(e);if(i){const a=i[1].trim();if(a!==""&&a!=="none")return a}}const n=t.parentElement;return n?Gs(n):null}function We(t){return/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(t)}const ka=t=>{const r=`.${t.split(".").filter(a=>a.includes("fill:")).join(".")}`,e={},n=/\.([\w-]+)\s*\{\s*([^}]+)\s*\}/g;let i;for(;(i=n.exec(r))!==null;){const a=i[1],u=i[2],c={},d=/fill\s*:\s*([^;]+);?/.exec(u),p=/stroke\s*:\s*([^;]+);?/.exec(u);d&&(c.fill=q(d[1].trim())),p&&(c.stroke=q(p[1].trim())),e[a]=c}return e};function Yr(t){let r=t.parentElement;for(;r;){if(r.tagName.toLowerCase()==="mask")return!0;r=r.parentElement}return!1}function _a(t,r,e=300,n=300){const i=[],u=new DOMParser().parseFromString(t,"image/svg+xml"),c=u.documentElement;c.setAttribute("width",`${e}`),c.setAttribute("height",`${n}`);const d=c.querySelectorAll("style"),p={};d.forEach(b=>{const v=b.textContent||"",f=ka(v);Object.assign(p,f);const _=v.replace(/\.(st[\w-]+)/g,`.${r}-$1`).replace(/url\(#(.*?)\)/g,`url(#${r}-$1)`);b.textContent=_;const T=Array.from(u.querySelectorAll("*")),S=new Set;T.forEach(M=>{if(Yr(M))return;["fill","stroke","stop-color"].forEach(U=>{const P=M.getAttribute(U);P&&!["none","transparent"].includes(P)&&S.add(q(P))});const E=M.getAttribute("style");if(E){const U=/fill\s*:\s*([^;]+);?/.exec(E),P=/stroke\s*:\s*([^;]+);?/.exec(E),K=/stop-color\s*:\s*([^;]+);?/.exec(E);if(U){const D=U[1].trim();D&&!["none","transparent"].includes(D)&&We(q(D))&&S.add(q(D))}if(P){const D=P[1].trim();D&&!["none","transparent"].includes(D)&&We(q(D))&&S.add(q(D))}if(K){const D=K[1].trim();D&&!["none","transparent"].includes(D)&&We(q(D))&&S.add(q(D))}}const A=M.getAttribute("class");A&&A.split(" ").forEach(U=>{const P=p[U];P!=null&&P.fill&&!["none","transparent"].includes(P.fill)&&S.add(q(P.fill)),P!=null&&P.stroke&&!["none","transparent"].includes(P.stroke)&&S.add(q(P.stroke))})}),Array.from(S).forEach(M=>{We(M)&&i.push(M)})});const h=Array.from(u.querySelectorAll("*")),y=new Set;return h.forEach(b=>{if(Yr(b))return;const v=b.getAttribute("class");if(v){const _=v.split(" ").map(T=>`${r}-${T}`).join(" ");b.setAttribute("class",_),_.split(" ").forEach(T=>{const S=p[T];S!=null&&S.fill&&!["none","transparent"].includes(S.fill)&&y.add(q(S.fill)),S!=null&&S.stroke&&!["none","transparent"].includes(S.stroke)&&y.add(q(S.stroke))})}["fill","stroke","stop-color"].forEach(_=>{const T=b.getAttribute(_);T&&!["none","transparent"].includes(T)&&y.add(q(T))});const f=b.getAttribute("style");if(f){const _=/fill\s*:\s*([^;]+);?/.exec(f),T=/stroke\s*:\s*([^;]+);?/.exec(f),S=/stop-color\s*:\s*([^;]+);?/.exec(f);if(_){const M=_[1].trim();M&&!["none","transparent"].includes(M)&&y.add(q(M))}if(T){const M=T[1].trim();M&&!["none","transparent"].includes(M)&&y.add(q(M))}if(S){const M=S[1].trim();M&&!["none","transparent"].includes(M)&&y.add(q(M))}}}),y.forEach(b=>!i.includes(b)&&We(b)&&i.push(b)),Array.from(u.querySelectorAll("*")).forEach(b=>{if(b.hasAttribute("id")){const v=b.getAttribute("id");b.setAttribute("id",`${r}-${v}`)}if(["fill","stroke","stop-color","filter","clip-path","mask"].forEach(v=>{const f=b.getAttribute(v);f&&f.includes("url(#")&&b.setAttribute(v,f.replace(/url\(#(.*?)\)/g,`url(#${r}-$1)`))}),b.hasAttribute("style")){const v=b.getAttribute("style");v.includes("url(#")&&b.setAttribute("style",v.replace(/url\(#(.*?)\)/g,`url(#${r}-$1)`))}}),Array.from(u.querySelectorAll("path")).forEach(b=>{if(Yr(b))return;!Gs(b)&&!b.getAttribute("class")&&(b.setAttribute("fill","#000000"),i.includes("#000000")||i.push("#000000"))}),{serializer:new XMLSerializer().serializeToString(u),colors:i}}const Ge={color:"#000000",x:0,y:0,blur:0},mt=(t,r)=>{let e=r!=null&&r.trim?r.trim.to-r.trim.from:(r==null?void 0:r.duration)||5e3;const n={from:0,to:e};if(!t)return n;if(t.from<0)return console.error("'from' must be a non-negative number. Returning default display."),n;if(t.from!==void 0&&t.to===void 0)return{from:t.from,to:t.from+e};if(t.to!==void 0){if(t.to<0)return console.error("'to' must be a non-negative number. Returning default display."),n;if(t.to<t.from)return console.error("'to' must be greater than or equal to 'from'. Returning default display."),n}return t},Xs=(t,r)=>t?t.from&&!t.to?{from:t.from,to:r.duration}:t:{from:0,to:r.duration};function Ks(t,r){const e={x:t.size.width/2,y:t.size.height/2},n={x:r.width/2,y:r.height/2},i=e.x-n.x;return{top:`${e.y-n.y}px`,left:`${i}px`,transform:"none"}}function yt(t,r){const e=t.scaleMode,n={x:t.size.width/2,y:t.size.height/2},i={x:r.width/2,y:r.height/2};let a;if(e==="fill")a=Math.max(t.size.width/r.width,t.size.height/r.height);else if(e==="fit"){const d=t.scaleAspectRatio||1;a=Math.min(t.size.width/r.width,t.size.height/r.height)*d}else a=Math.min(t.size.width/r.width,t.size.height/r.height);const u=n.x-i.x;return{top:`${n.y-i.y}px`,left:`${u}px`,transform:`scale(${a})`}}const Vs=async(t,r)=>{const e=t.details.src,n=await ya(t),i=yt(r,{...n}),a=Xs(t.trim,{duration:n.duration}),u={width:n.width,height:n.height,opacity:100,src:e,volume:t.details.volume??100,borderRadius:t.details.borderRadius??0,borderWidth:t.details.borderWidth??0,borderColor:t.details.borderColor||"#000000",boxShadow:t.details.boxShadow||Ge,top:t.details.top||i.top||"0px",left:t.details.left||i.left||"0px",transform:t.details.transform||i.transform,blur:t.details.blur||0,brightness:t.details.brightness||100,flipX:t.details.flipX||!1,flipY:t.details.flipY||!1,rotate:t.details.rotate||"0deg",visibility:t.details.visibility||"visible"};return{...t,trim:a,type:"video",name:"video",details:u,playbackRate:t.playbackRate||1,display:mt(t.display,{duration:n.duration,trim:a}),duration:n.duration}},qs=async t=>{const r=t.id,e=t.details,i=(await Us(e.src)).duration,a=Xs(t.trim,{duration:i});return{id:r,name:t.name||"audio",type:"audio",display:mt(t.display,{duration:i,trim:a}),trim:a,playbackRate:t.playbackRate||1,details:{src:e.src,volume:e.volume??100},metadata:{...t.metadata},duration:i}},va=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,a=yt(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||a.top,left:(i==null?void 0:i.left)||a.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1,inverted:i.inverted||!1,backgroundColors:(i==null?void 0:i.backgroundColors)||["rgba(128, 128, 128,0.5)","rgba(128, 128, 128,1)"]},metadata:{}}},Sa=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,a=yt(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||a.top,left:(i==null?void 0:i.left)||a.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1,inverted:i.inverted||!1,backgroundColors:(i==null?void 0:i.backgroundColors)||["rgba(128, 128, 128,0.5)","rgba(128, 128, 128,1)"],barThickness:i.barThickness||10},metadata:{}}},Ta=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,a=yt(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||a.top,left:(i==null?void 0:i.left)||a.left,radialBarColor:i.radialBarColor||"rgba(128, 128, 128,1)",border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1},metadata:{}}},Ea=async(t,r)=>{var c,d;const e=t.id,n={width:((c=t.details)==null?void 0:c.width)||r.size.width,height:((d=t.details)==null?void 0:d.height)||r.size.height},i=t.details,a=yt(r,n),u=mt(t.display);return{id:e,name:t.type,type:t.type,display:u,details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||a.top,left:(i==null?void 0:i.left)||a.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,strokeColors:(i==null?void 0:i.strokeColors)||["#ff9800","#ff5722"],strokeWidth:(i==null?void 0:i.strokeWidth)||100,strokeBackground:(i==null?void 0:i.strokeBackground)||"#fff",flipX:(i==null?void 0:i.flipX)||!1,flipY:(i==null?void 0:i.flipY)||!1,rotate:(i==null?void 0:i.rotate)||"0deg",transform:(i==null?void 0:i.transform)||"none"},metadata:{}}},Wr=async(t,r)=>{var u,c;const e=t.id,n={width:((u=t.details)==null?void 0:u.width)||r.size.width,height:((c=t.details)==null?void 0:c.height)||r.size.height},i=t.details,a=yt(r,n);return{id:e,name:t.type,type:t.type,display:{from:0,to:t.duration||1e4},details:{width:(i==null?void 0:i.width)||n.width,height:(i==null?void 0:i.height)||n.height,top:(i==null?void 0:i.top)||a.top,left:(i==null?void 0:i.left)||a.left,border:i.border||"none",borderRadius:i.borderRadius||0,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",opacity:i.opacity||100,flipX:i.flipX||!1,flipY:i.flipY||!1,inverted:i.inverted||!1,linealBarColor:i.linealBarColor||"rgba(128, 128, 128,1)",lineThickness:i.lineThickness||1,gapSize:i.gapSize||1,roundness:i.roundness||1,placement:i.placement||null,strokeColor:i.strokeColor||"#92E1B0",fillColor:i.fillColor||null,strokeWidth:i.strokeWidth||null,copies:i.copies||null,offsetPixelSpeed:i.offsetPixelSpeed||0,lineColor:i.lineColor||"#92E1B0",lineGap:i.lineGap||0,topRoundness:i.topRoundness||0,bottomRoundness:i.bottomRoundness||0,lines:i.lines||0,sections:i.sections||0},metadata:{}}},Js=async(t,r)=>{var y;const e=t.trackItemIds,n=t.size||{width:t.details.width,height:t.details.height},i=Math.min(r.size.width/n.width,r.size.height/n.height),a=((y=t.details)==null?void 0:y.rotate)||0,u=yt(r,n),c=t.display;let d=1/0,p=0;e.forEach(m=>{const g=t.trackItemsMap[m];g.display.from<d&&(d=g.display.from),g.display.to>p&&(p=g.display.to)});const h=t.trim||t.display||{from:d,to:p};return{id:t.id,type:"template",details:{...n,transform:t.details.transform||u.transform,top:t.details.top||u.top,left:t.details.left||u.left,scale:i,rotate:a,background:t.details.background||"transparent"},trim:h,display:c||{from:d,to:p},activeEdit:!1}},wa=async(t,r)=>{var h;const e=t.trackItemIds,n=t.size||{width:t.details.width,height:t.details.height},i=Math.min(r.size.width/n.width,r.size.height/n.height),a=((h=t.details)==null?void 0:h.rotate)||0,u=yt(r,n),c=t.display;let d=1/0,p=0;return e.forEach(y=>{const m=t.trackItemsMap[y];m.display.from<d&&(d=m.display.from),m.display.to>p&&(p=m.display.to)}),{id:t.id,type:"composition",details:{...n,transform:t.details.transform||u.transform,top:t.details.top||u.top,left:t.details.left||u.left,scale:i,rotate:a},display:c||{from:d,to:p}}},Zs=async(t,r)=>{const e=t.details,n=we(e.src),i=fetch(e.src),[a,u]=await Promise.all([n,i]),c=await u.text(),d=yt(r,a),{serializer:p,colors:h}=_a(ba(c),t.id,Number(e.width||a.width),Number(e.height||a.height)),y=t.details.colorMap||Object.fromEntries(h.map(m=>[m,m]));return{id:t.id,name:"illustration",type:t.type,display:mt(t.display),playbackRate:t.playbackRate||1,details:{src:e.src||"",width:e.width||a.width||100,height:e.height||a.height||100,opacity:e.opacity??100,transform:e.transform||d.transform,border:e.border||"none",borderRadius:e.borderRadius||0,top:e.top||d.top||"0px",left:e.left||d.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible",svgString:p,initialSvgString:C(p),colorMap:y},metadata:t.metadata||{}}},Aa=async(t,r)=>{const e=t.details,n=we(e.src),[i]=await Promise.all([n]),a=yt(r,i);return{id:t.id,name:"shape",type:t.type,display:mt(t.display),playbackRate:t.playbackRate||1,details:{src:e.src||"",width:e.width||i.width||100,height:e.height||i.height||100,opacity:e.opacity??100,transform:e.transform||a.transform,border:e.border||"none",borderRadius:e.borderRadius||0,top:e.top||a.top||"0px",left:e.left||a.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible",backgroundColor:e.backgroundColor||"#808080"},metadata:t.metadata||{}}},Ma=async(t,r)=>{const e=t.details,n=yt(r,{width:e.width,height:e.height});return{id:t.id,name:"rect",type:t.type,display:mt(t.display),playbackRate:t.playbackRate||1,details:{width:e.width||100,height:e.height||100,opacity:e.opacity??100,transform:e.transform||n.transform,border:e.border||"none",borderRadius:e.borderRadius||0,top:e.top||n.top||"0px",left:e.left||n.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible",backgroundColor:e.backgroundColor||"#808080",boxShadow:e.boxShadow||Ge,blur:e.blur||0,brightness:e.brightness||100},metadata:t.metadata||{}}},Qs=async(t,r)=>{const e=t.details,n=await we(e.src),i=yt(r,n);return{id:t.id,type:"image",name:"image",display:mt(t.display),playbackRate:t.playbackRate||1,details:{src:e.src||"",width:e.width||n.width||100,height:e.height||n.height||100,opacity:e.opacity??100,transform:e.transform||i.transform,border:e.border||"none",borderRadius:e.borderRadius||0,boxShadow:e.boxShadow||Ge,top:e.top||i.top||"0px",left:e.left||i.left||"0px",borderWidth:e.borderWidth??0,borderColor:e.borderColor||"#000000",blur:e.blur||0,brightness:e.brightness||100,flipX:e.flipX||!1,flipY:e.flipY||!1,rotate:e.rotate||"0deg",visibility:e.visibility||"visible"},metadata:t.metadata||{}}},ti=async(t,r)=>{const e=t;e.details.fontUrl&&await Ee([{fontFamily:e.details.fontFamily,url:e.details.fontUrl}]);const n=e.id,i=e.details,a=ri(i),u=i.height||js(e.details.text,a),c=i.top!=null&&i.left!=null?{top:`${i.top}px`,left:`${i.left}px`}:Ks(r,{width:a.width,height:u});return{id:n,name:"caption",type:"caption",display:mt(e.display),details:{...e.details,...a,text:i.text||"",height:u,fontUrl:i.fontUrl,top:a.top||c.top,left:a.left||c.left,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",boxShadow:i.boxShadow||Ge,words:i.words||[],appearedColor:i.appearedColor||i.color,activeColor:i.activeColor||i.color,activeFillColor:i.activeFillColor||"transparent",isKeywordColor:i.isKeywordColor||"transparent",preservedColorKeyWord:i.preservedColorKeyWord||!1,linesPerCaption:i.linesPerCaption||2,wordsPerLine:i.wordsPerLine||"punctuationOrPause"},metadata:t.metadata||{}}},ei=async(t,r)=>{t.details.fontUrl&&await Ee([{fontFamily:t.details.fontFamily,url:t.details.fontUrl}]);const e=t.id,n=t.details,i=ri(n),a=n.height||js(t.details.text,i),u=n.top!=null&&n.left!=null?{top:`${n.top}px`,left:`${n.left}px`}:Ks(r,{width:i.width,height:a});return{id:e,name:"text",type:"text",display:mt(t.display),details:{...t.details,...i,text:n.text||"",height:a,fontUrl:n.fontUrl,top:i.top||u.top,left:i.left||u.left,borderWidth:n.borderWidth||0,borderColor:n.borderColor||"#000000",boxShadow:n.boxShadow||Ge},metadata:{}}},ri=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,left:t.left,textTransform:t.textTransform||"none",transform:t.transform||"none",skewX:t.skewX||0,skewY:t.skewY||0}),Oa=async(t,r)=>{switch(t.type){case"video":return Vs(t,r||{});case"audio":return qs(t);case"image":return Qs(t,r||{});case"text":return ei(t,r||{});case"caption":return ti(t,r||{});case"template":return Js(t,{size:r==null?void 0:r.size});default:throw new Error("Unsupported track item")}};function ni(t,r){return r.some(e=>t.some(n=>n.id===e.id))}const si=(t=[],r=[])=>t.length===0?r.map(n=>({id:ee(),items:[n.id],type:n.type,accepts:["text","image","video","audio","caption","template"]})):t.map(e=>({...e,items:e.items||[],accepts:["audio","video","image","text","caption","template"],type:e.type||"text",magnetic:e.magnetic||!1,static:e.static||!1,id:e.id||ee()}));async function Da(t,r){var u,c,d;const e=r.trackItemsMap,n=new Set,i=new Map;for(const p in e){const h=e[p];if(h.type==="text"||h.type==="caption"){if(h.details.fontUrl){const y={fontFamily:h.details.fontFamily,url:h.details.fontUrl};n.add(JSON.stringify(y))}(u=h.animations)!=null&&u.in&&h.animations.in.composition.forEach(y=>{var m;(m=y.details)!=null&&m.fonts&&y.details.fonts.forEach(g=>{n.add(JSON.stringify(g))})}),(c=h.animations)!=null&&c.loop&&h.animations.loop.composition.forEach(y=>{var m;(m=y.details)!=null&&m.fonts&&y.details.fonts.forEach(g=>{n.add(JSON.stringify(g))})}),(d=h.animations)!=null&&d.out&&h.animations.out.composition.forEach(y=>{var m;(m=y.details)!=null&&m.fonts&&y.details.fonts.forEach(g=>{n.add(JSON.stringify(g))})})}else h.type==="illustration"&&i.set(p,{trackItem:h,details:h.details})}n.size>0&&await Ee(Array.from(n).map(p=>JSON.parse(p)));for(const[p,h]of i){const y=await Zs({...h.trackItem,details:h.details},{size:{width:h.details.width,height:h.details.height}}),m=Ws(y.details.svgString,h.details.colorMap);y.details.svgString=m,e[p]=y}const a=W(e);return{...r,duration:a}}function Ra(t){const r=C(t);if(!r.activeIds.length)return;const e=r.activeIds,n=[],i={activeIds:e,trackItemsMap:{},tracks:[],structure:[]};e.forEach(d=>{i.trackItemsMap[d]=r.trackItemsMap[d],n.push(r.tracks.find(p=>p.items.includes(d)))});const a=new Set;n.filter(d=>a.has(d.id)?!1:(a.add(d.id),!0)),i.tracks=Array.from(a),i.activeIds.forEach(d=>{if(i.trackItemsMap[d].type==="composition"||i.trackItemsMap[d].type==="template"){const p=r.structure.find(h=>h.id===d);p&&(i.structure.push(p),p.items.forEach(h=>{i.trackItemsMap[h]=r.trackItemsMap[h]}))}});let c=JSON.stringify(i);localStorage.setItem("DesignComboTemp",c)}function Ca(t,r){const e=C(t);if(e.activeIds.length!==1)return{};const n=e.activeIds[0],i=C(e.trackItemsMap[n]);if(r>=i.display.to||r<=i.display.from)return{};const a=ee(),u={...i,display:{from:i.display.from,to:r}},c={...i,id:a,display:{from:r,to:i.display.to}},d=Object.values(e.transitionsMap).find(h=>h.fromId===i.id&&h.kind!=="none"),p=Object.values(e.transitionsMap).find(h=>h.toId===i.id&&h.kind!=="none");if(i.type==="video"||i.type==="audio"){const h=r-u.display.from;u.trim={from:i.trim.from,to:i.trim.from+h},c.trim={from:i.trim.from+h,to:i.trim.to}}if(p){const h=u.display.to-u.display.from;if(p.duration/2>h){e.transitionIds=e.transitionIds.filter(m=>m!==p.id);const y={};e.transitionIds.forEach(m=>y[m]=e.transitionsMap[m]),e.transitionsMap=y}}if(d){const h=c.display.to-c.display.from,y={};d.duration/2>h?(e.transitionIds=e.transitionIds.filter(m=>m!==d.id),e.transitionIds.forEach(m=>y[m]=e.transitionsMap[m]),e.transitionsMap=y):(e.transitionIds=e.transitionIds.map(m=>e.transitionsMap[m].fromId===u.id?m.replace(u.id,a):m),Object.keys(e.transitionsMap).forEach(m=>{if(e.transitionsMap[m].fromId===u.id){const k=m.replace(u.id,a);y[k]={...e.transitionsMap[m],id:k,fromId:a}}else y[m]=e.transitionsMap[m]}),e.transitionsMap=y)}return e.trackItemsMap[n]=u,e.trackItemsMap[a]=c,e.trackItemIds.push(a),e.tracks.forEach(h=>{h.items.includes(n)&&h.items.push(a)}),{tracks:e.tracks,trackItemIds:e.trackItemIds,trackItemsMap:e.trackItemsMap,transitionsMap:e.transitionsMap,transitionIds:e.transitionIds}}async function Pa(t,r){const e=C(t),n=e.trackItemsMap,i=Object.keys(r);if(!i.length)return{};for(const c of i){const d=r[c];if(d.details&&(n[c].details={...n[c].details,...d.details},d.details.colorMap)){const p=n[c].details.initialSvgString,h=Ws(p,d.details.colorMap);n[c].details.svgString=h}if(d.metadata&&(n[c].metadata?n[c].metadata={...n[c].metadata,...d.metadata}:n[c].metadata=d.metadata),d.display||d.playbackRate){const p=d.playbackRate,h=n[c].playbackRate||1,y=n[c].display,k=(y.to-y.from)*h/p,b={from:y.from,to:y.from+k};n[c].display=b,n[c].playbackRate=p}d.animations&&(n[c].animations={...n[c].animations,...d.animations})}for(const c of i){const d=r[c];if(n[c].type==="shape"&&d.details.src){const p=await we(d.details.src);n[c].details.width=p.width,n[c].details.height=p.height}}if(i.some(c=>{const d=r[c];return d.display!==void 0||d.playbackRate!==void 0})){const c=e.tracks.filter(h=>h.magnetic);i.filter(h=>c.some(y=>y.items.includes(h))).length>0&&Q(c,n,[]);const p=[];for(const h of i){const y=r[h];if(y.playbackRate===void 0&&y.display===void 0)continue;const m=n[h];if(!m)continue;const g=e.tracks.find(_=>_.items.includes(h));if(!g||g.magnetic)continue;const k=m.display;if(Object.values(e.transitionsMap).filter(_=>_.fromId===h||_.toId===h).forEach(_=>{const T=n[_.fromId],S=n[_.toId];if(!T||!S){p.push(_.id);return}const M=T.display,E=S.display,A=M.to,U=E.from;Math.abs(A-U)<=1||p.push(_.id)}),g.items.map(_=>n[_]).filter(_=>_&&_.id!==h).some(_=>{const T=_.display.from,S=_.display.to,M=k.from;return!(k.to<=T||M>=S)})){const _=e.tracks.findIndex(M=>M.id===g.id);g.items=g.items.filter(M=>M!==h);const T={id:Hr(),accepts:Object.keys(jr()),type:m.type,items:[h],magnetic:!1,static:!1},S=Math.max(0,_-1);e.tracks.splice(S,0,T)}}p.length>0&&(e.transitionIds=e.transitionIds.filter(h=>!p.includes(h)),p.forEach(h=>{delete e.transitionsMap[h]}))}const u=W(n);return{trackItemsMap:{...n},tracks:e.tracks,transitionIds:e.transitionIds,transitionsMap:e.transitionsMap,duration:u}}async function xa(t,r){const e=C(t),n=Object.keys(r)[0],i=Object.values(r)[0],a=e.trackItemsMap[n],u=a.details;if(!i.details.src)return{};if(a.type==="image"){const p=await we(i.details.src),h=a.details.width||0,y=a.details.height||0;let m=p.width,g=p.height;const k=p.width/p.height;h/y>k?(m=h,g=h/k):(g=y,m=y*k),u.crop={x:0,y:0,height:u.height,width:u.width},i.details.width=m,i.details.height=g}else if(a.type==="video"){const p=await Br(i.details.src),h=a.details.width||0,y=a.details.height||0;let m=p.width,g=p.height;const k=p.width/p.height;h/y>k?(m=h,g=h/k):(g=y,m=y*k),u.crop={x:0,y:0,height:u.height,width:u.width},i.details.width=m,i.details.height=g,a.duration=p.duration,a.trim={from:0,to:p.duration};const b=a.playbackRate||1,v=p.duration/b,f=a.display.from+v;a.display={from:a.display.from,to:(a.duration||0)>=p.duration?a.display.to:f}}i.details&&(a.details={...u,...i.details},i.details=a.details),e.trackItemsMap[n]={...e.trackItemsMap[n],type:i.type},a.type==="video"&&(e.trackItemsMap[n].display=a.display,e.trackItemsMap[n].duration=a.duration,e.trackItemsMap[n].trim=a.trim);const c=e.tracks.find(p=>p.items.includes(n));if(c&&c.magnetic&&a.type==="video"){const p=e.tracks.filter(h=>h.magnetic);Q(p,e.trackItemsMap,[])}const d=W(e.trackItemsMap);return{trackItemsMap:{...e.trackItemsMap},tracks:e.tracks,duration:d}}function La(t,r){const e=C(t);return e.background.value=r.value,e.background.type=r.type||"color",{...e}}function za(t,{idTrack:r,idItems:e},n){const i=n.tracks.find(c=>c.id===r);if(!i||!i.magnetic)return;let u=i.items.reduce((c,d)=>{const p=n.trackItemsMap[d];return p.display.to>c.display.to?p:c},{display:{to:0}}).display.to;e.forEach(c=>{const d=t.find(y=>String(y.id)===String(c));if(!d)return;const p=d.playbackRate||1;let h;(d.type==="video"||d.type==="audio")&&d.trim?h=(d.trim.to-d.trim.from)/p:h=d.display.to-d.display.from,d.display.from=u,d.display.to=u+h,u=u+h})}async function Na(t,r,e={}){var m;const n=C(t),i=r.trackItems.map(g=>Oa(g,{size:n.size})),a=await Promise.all(i);(m=r.tracks)==null||m.forEach(g=>{za(a,{idTrack:g.id,idItems:g.items},n)});const u=si(r.tracks,r.trackItems),c=[],d=a.map(g=>g.id);r.trackItems.forEach(g=>{if(g.type!=="template")return;n.trackItemsMap={...n.trackItemsMap,...g.trackItemsMap},n.transitionsMap={...n.transitionsMap,...g.transitionsMap};const k={id:g.id,items:g.trackItemIds,transitions:g.transitionsIds||[],tracks:g.tracks};c.push(k)});const p=[],h={};return a.forEach(g=>{p.push(g.id),h[g.id]=g}),u.map(g=>ni(n.tracks,[g])?g:null).forEach((g,k)=>{if(g)n.tracks.forEach(b=>{b.id===g.id&&(b.items=b.items.concat(g.items),b.magnetic&&Q([b],n.trackItemsMap,d))});else{const b=e.trackIndex||0,v=u[k],f=Math.min(Math.max(b,0),n.tracks.length);n.tracks.splice(f,0,v)}}),n.trackItemsMap={...n.trackItemsMap,...h},n.trackItemIds=[...n.trackItemIds,...p],n.structure=[...n.structure,...c],n.duration=W(n.trackItemsMap),{trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,tracks:n.tracks,duration:n.duration,structure:n.structure,transitionIds:n.transitionIds,transitionsMap:n.transitionsMap}}function gt(t,r,e={isNewTrack:!0}){const n=r.map(u=>u.id),i=[],a={};if(r.forEach(u=>{i.push(u.id),a[u.id]=u}),(e.targetTrackIndex!==void 0||e.targetTrackId)&&!e.isNewTrack){const u=e.targetTrackIndex||0,c=e.targetTrackId;let d=t.tracks[u];if(c&&(d=t.tracks.find(p=>p.id===c)),!d)throw new Error("Target track not found");d.items.push(...i)}else{const u={id:Hr(),accepts:Object.keys(jr()),type:r[0].type,items:n,magnetic:!1,static:!1};t.tracks.splice(e.targetTrackIndex||0,0,u)}return t.trackItemsMap={...t.trackItemsMap,...a},t.trackItemIds=[...t.trackItemIds,...i],t}async function Fa(t,r,e={}){const n=C(t),i=[Qs(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],a=await Promise.all(i),u=a.map(p=>p.id),c=gt(n,a,e),d=c.tracks.filter(p=>p.magnetic);return Q(d,c.trackItemsMap,u),c.duration=W(c.trackItemsMap),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function $a(t,r,e={}){const n=C(t),i=[qs(r)],a=await Promise.all(i),u=a.map(p=>p.id),c=gt(n,a,e);c.duration=W(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return Q(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ha(t,r,e={}){const n=C(t),i=[Vs(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],a=await Promise.all(i),u=a.map(p=>p.id),c=gt(n,a,e);c.duration=W(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return Q(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ua(t,r,e={}){const n=C(t),i=[ei(r,{size:e.size})],a=await Promise.all(i),u=a.map(p=>p.id),c=gt(n,a,e);c.duration=W(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return Q(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function ja(t,r,e={}){const n=C(t),i=[Aa(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],a=await Promise.all(i),u=a.map(p=>p.id),c=gt(n,a,e);c.duration=W(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return Q(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ba(t,r,e={}){const n=C(t),i=[Zs(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],a=await Promise.all(i),u=a.map(p=>p.id),c=gt(n,a,e);c.duration=W(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return Q(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}async function Ya(t,r,e={}){const n=C(t),i="composition",a=r.trackItemsMap,u=r.trackItemIds,c=r.tracks||[],d=r.trackItemDetailsMap,{details:p,...h}=await wa(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}),y={id:h.id,items:u,transitions:[],tracks:c},g=[{...h,type:i,details:p}],k=gt(n,g,e);k.trackItemsMap={...k.trackItemsMap,...a,[h.id]:{...h,type:i,details:p}},k.structure=[...k.structure,y],k.duration=W(k.trackItemsMap);const b=k.tracks.filter(v=>v.magnetic);return Q(b,k.trackItemsMap,[h.id]),d&&Object.keys(d).forEach(v=>{k.trackItemsMap[v]={...k.trackItemsMap[v],details:{...d[v].details}}}),{trackItemIds:k.trackItemIds,trackItemsMap:k.trackItemsMap,tracks:k.tracks,duration:k.duration,structure:k.structure}}async function re(t,r,e={},n){const i=C(t),a=y=>y.display?y.display:{from:0,to:i.duration},u=[];n==="progress-bar"&&u.push(va(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})),n==="progress-frame"&&u.push(Sa(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})),n==="radial-audio-bars"&&(r.display=a(r),u.push(Ta(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="lineal-audio-bars"&&(r.display=a(r),u.push(Wr(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="wave-audio-bars"&&(r.display=a(r),u.push(Wr(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="hill-audio-bars"&&(r.display=a(r),u.push(Wr(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}))),n==="progress-square"&&u.push(Ea(r,{size:i.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}));const c=await Promise.all(u),d=c.map(y=>y.id),p=gt(i,c,e);p.duration=W(p.trackItemsMap);const h=p.tracks.filter(y=>y.magnetic);return Q(h,p.trackItemsMap,d),{trackItemIds:p.trackItemIds,trackItemsMap:p.trackItemsMap,tracks:p.tracks,duration:p.duration}}async function Wa(t,r,e={}){const n=C(t),i="template",a=r.trackItemsMap,u=r.trackItemIds,c=r.transitionsMap,d=r.transitionIds||[],p=r.tracks||[],h=r.structure||[],{details:y,...m}=await Js(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio}),g={id:m.id,items:u,transitions:d,tracks:p},b=[{...m,type:i,details:y}],v=gt(n,b,e);v.transitionIds=[...v.transitionIds,...d],v.transitionsMap={...v.transitionsMap,...c},v.trackItemsMap={...v.trackItemsMap,...a,[m.id]:{...m,type:i,details:y}},v.structure=[...v.structure,g,...h],v.duration=W(v.trackItemsMap);const f=v.tracks.filter(_=>_.magnetic);return Q(f,v.trackItemsMap,[m.id]),{trackItemIds:v.trackItemIds,trackItemsMap:v.trackItemsMap,tracks:v.tracks,duration:v.duration,structure:v.structure,transitionsMap:v.transitionsMap}}async function Ga(t,r,e={}){const n=C(t),i=r.trackItems.map(y=>ti(y,{size:e.size})),a=await Promise.all(i),u=si(r.tracks,r.trackItems),c=[],d={};if(a.forEach(y=>{const{details:m,...g}=y;c.push(y.id),d[y.id]=g}),ni(n.tracks,u))n.tracks.forEach(y=>{u.forEach(m=>{y.id===m.id&&(y.magnetic&&Q([y],n.trackItemsMap,c),y.items.push(...c))})});else{const y=e.trackIndex||0,m=Math.min(Math.max(y,0),n.tracks.length);n.tracks.splice(m,0,...u)}n.trackItemsMap={...n.trackItemsMap,...d},n.trackItemIds=[...n.trackItemIds,...c],n.duration=W(n.trackItemsMap);const h=n.tracks.filter(y=>y.magnetic);return Q(h,n.trackItemsMap,c),{trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,tracks:n.tracks,duration:n.duration}}async function Xa(t,r){const e=C(t),n=e.trackItemsMap[r.id],i=[];if(!n)return{};let a=n.animations||{};return r.animations.loop?r.animations.loop.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}):r.animations.in?r.animations.in.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}):r.animations.out?r.animations.out.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}):r.animations.timed&&r.animations.timed.composition.forEach(u=>{var c;(c=u.details)!=null&&c.fonts&&i.push(...u.details.fonts)}),i.length>0&&await Ee(i),a.in&&r.animations.in?a.in=r.animations.in:a.out&&r.animations.out?a.out=r.animations.out:a.loop&&r.animations.loop?a.loop=r.animations.loop:!a.out&&r.animations.out?a.out=r.animations.out:!a.in&&r.animations.in?a.in=r.animations.in:!a.loop&&r.animations.loop?a.loop=r.animations.loop:a=r.animations,(r.animations.in||r.animations.out||r.animations.loop)&&delete a.timed,r.animations.timed&&(a.timed=r.animations.timed,delete a.in,delete a.out,delete a.loop),n.animations=a,{trackItemsMap:e.trackItemsMap}}async function Ka(t,r,e={}){const n=C(t),i=[Ma(r,{size:n.size,scaleMode:e.scaleMode,scaleAspectRatio:e.scaleAspectRatio})],a=await Promise.all(i),u=a.map(p=>p.id),c=gt(n,a,e);c.duration=W(c.trackItemsMap);const d=c.tracks.filter(p=>p.magnetic);return Q(d,c.trackItemsMap,u),{trackItemIds:c.trackItemIds,trackItemsMap:c.trackItemsMap,tracks:c.tracks,duration:c.duration}}function Va(t){const r=H.subject.pipe(H.filter(({key:f})=>f.startsWith(Fr))),e=H.subject.pipe(H.filter(({key:f})=>f.startsWith(fr))),n=H.subject.pipe(H.filter(({key:f})=>f.startsWith(j))),i=H.subject.pipe(H.filter(({key:f})=>f.startsWith(V))),a=H.subject.pipe(H.filter(({key:f})=>f.startsWith(Ye))),u=H.subject.pipe(H.filter(({key:f})=>f.startsWith(te))),c=H.subject.pipe(H.filter(({key:f})=>f.startsWith(At))),d=H.subject.pipe(H.filter(({key:f})=>f.startsWith($r))),p=r.subscribe(async f=>{var _;if(f.key===Fr){const{actions:T}=(_=f.value)==null?void 0:_.payload;T.forEach(S=>{H.dispatch(S.type,S.payload&&{payload:S.payload})})}}),h=e.subscribe(async f=>{var _,T;if(f.key===is){const S=(_=f.value)==null?void 0:_.payload,M=await Da(t.getState(),S);t.updateState(M,{kind:"design:load",updateHistory:!1})}if(f.key===as){const S=(T=f.value)==null?void 0:T.payload;t.updateState({size:S},{kind:"design:resize",updateHistory:!1})}}),y=a.subscribe(f=>{if(f.key===zs)return t.undo();if(f.key===Ns)return t.redo()}),m=d.subscribe(f=>{var _;if(f.key===Fs){const T=(_=f.value)==null?void 0:_.payload.scale;t.updateState({scale:T},{kind:"update",updateHistory:!1})}}),g=i.subscribe(async f=>{var _,T,S,M;if(f.key===Rs){const E=((_=f.value)==null?void 0:_.payload.trackItemIds)||[];t.updateState({activeIds:E},{kind:"update",updateHistory:!1})}if(f.key===Cs&&Ra(t.getState()),f.key===xs){const E=(T=f.value)==null?void 0:T.payload.trackItemIds,A=da(t.getState(),E);t.updateState(A,{updateHistory:!0,kind:"remove"})}if(f.key===Ps){const E=ga(t.getState(),(S=f.value)==null?void 0:S.payload.trackItemIds);t.updateState(E,{updateHistory:!0,kind:"update"})}if(f.key===Ls){const E=(M=f.value)==null?void 0:M.payload,A=await Ia(t.getState(),E);t.updateState(A,{updateHistory:!0,kind:"update:details"})}}),k=n.subscribe(async f=>{var U,P,K,D,F,nt,ce,ue,Ae,Me,Oe,De,z,Re,Ce,at,le,N,de,Pe,ot,fe,pe,Ht,Ut,he,jt,me,Bt,ye,xe,Le,Mt,Yt,Ie,ge,pt,Ot,ze,bt,Dt,Wt,st,be,ke,Ne,Gt,Rt,_e,Ct,kt,ct,Pt,Xt,_t,Kt,vt,Vt,qt;const _=C(t.getState()),T=((P=(U=f.value)==null?void 0:U.options)==null?void 0:P.isSelected)||!1,S=(D=(K=f.value)==null?void 0:K.options)==null?void 0:D.scaleMode,M=(nt=(F=f.value)==null?void 0:F.options)==null?void 0:nt.scaleAspectRatio,E=(ue=(ce=f.value)==null?void 0:ce.options)==null?void 0:ue.trackIndex;let A={};f.key===ps?A=await Xa(_,(Ae=f.value)==null?void 0:Ae.payload):f.key===ys?A=await Na(_,(Me=f.value)==null?void 0:Me.payload,{trackIndex:E}):f.key===hs?A=await Ga(_,(Oe=f.value)==null?void 0:Oe.payload,{trackIndex:E}):f.key===os?A=await Ua(_,(De=f.value)==null?void 0:De.payload,{targetTrackIndex:E,targetTrackId:(z=f.value)==null?void 0:z.options.targetTrackId,size:_.size,isNewTrack:(Ce=(Re=f.value)==null?void 0:Re.options)==null?void 0:Ce.isNewTrack}):f.key===ms?A=await Wa(_,(at=f.value)==null?void 0:at.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:E,targetTrackId:(N=(le=f.value)==null?void 0:le.options)==null?void 0:N.targetTrackId}):f.key===ds?A=await Ba(_,(de=f.value)==null?void 0:de.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:E,targetTrackId:(Pe=f.value)==null?void 0:Pe.options.targetTrackId}):f.key===fs?A=await ja(_,(ot=f.value)==null?void 0:ot.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:E,targetTrackId:(fe=f.value)==null?void 0:fe.options.targetTrackId}):f.key===Es?A=await Ka(_,(pe=f.value)==null?void 0:pe.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:E,targetTrackId:(Ht=f.value)==null?void 0:Ht.options.targetTrackId}):f.key===ls?A=await Fa(_,(Ut=f.value)==null?void 0:Ut.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:E,targetTrackId:(he=f.value)==null?void 0:he.options.targetTrackId,isNewTrack:(me=(jt=f.value)==null?void 0:jt.options)==null?void 0:me.isNewTrack}):f.key===us?A=await $a(_,(Bt=f.value)==null?void 0:Bt.payload,{targetTrackIndex:E,targetTrackId:(ye=f.value)==null?void 0:ye.options.targetTrackId,isNewTrack:(Le=(xe=f.value)==null?void 0:xe.options)==null?void 0:Le.isNewTrack}):f.key===cs?A=await Ha(_,(Mt=f.value)==null?void 0:Mt.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:E,targetTrackId:(Yt=f.value)==null?void 0:Yt.options.targetTrackId,isNewTrack:(ge=(Ie=f.value)==null?void 0:Ie.options)==null?void 0:ge.isNewTrack}):f.key===Is?A=await Ya(_,(pt=f.value)==null?void 0:pt.payload,{scaleMode:S,scaleAspectRatio:M,targetTrackIndex:E,targetTrackId:(Ot=f.value)==null?void 0:Ot.options.targetTrackId}):f.key===gs?A=await re(_,(ze=f.value)==null?void 0:ze.payload,{targetTrackIndex:E,targetTrackId:(Dt=(bt=f.value)==null?void 0:bt.options)==null?void 0:Dt.targetTrackId},"progress-bar"):f.key===vs?A=await re(_,(Wt=f.value)==null?void 0:Wt.payload,{targetTrackIndex:E,targetTrackId:(be=(st=f.value)==null?void 0:st.options)==null?void 0:be.targetTrackId},"progress-square"):f.key===bs?A=await re(_,(ke=f.value)==null?void 0:ke.payload,{targetTrackIndex:E,targetTrackId:(Gt=(Ne=f.value)==null?void 0:Ne.options)==null?void 0:Gt.targetTrackId},"progress-frame"):f.key===ks?A=await re(_,(Rt=f.value)==null?void 0:Rt.payload,{targetTrackIndex:E,targetTrackId:(Ct=(_e=f.value)==null?void 0:_e.options)==null?void 0:Ct.targetTrackId},"radial-audio-bars"):f.key===_s?A=await re(_,(kt=f.value)==null?void 0:kt.payload,{targetTrackIndex:E,targetTrackId:(Pt=(ct=f.value)==null?void 0:ct.options)==null?void 0:Pt.targetTrackId},"lineal-audio-bars"):f.key===Ss?A=await re(_,(Xt=f.value)==null?void 0:Xt.payload,{targetTrackIndex:E,targetTrackId:(Kt=(_t=f.value)==null?void 0:_t.options)==null?void 0:Kt.targetTrackId},"wave-audio-bars"):f.key===Ts&&(A=await re(_,(vt=f.value)==null?void 0:vt.payload,{targetTrackIndex:E,targetTrackId:(qt=(Vt=f.value)==null?void 0:Vt.options)==null?void 0:qt.targetTrackId},"hill-audio-bars")),T&&A.trackItemIds&&(A.activeIds=A.trackItemIds),t.updateState(A,{updateHistory:!0,kind:"add"})}),b=u.subscribe(async f=>{var _;if(f.key===Ds){const T=(_=f.value)==null?void 0:_.options.time,S=Ca(t.getState(),T);Object.keys(S).length>0&&t.updateState(S,{updateHistory:!0,kind:"update"})}if(f.key===Os){const T=await ha(t.getState());t.updateState(T,{updateHistory:!0,kind:"update"})}}),v=c.subscribe(async f=>{var _,T,S;if(f.key===ws){const M=await Pa(t.getState(),(_=f.value)==null?void 0:_.payload);t.updateState(M,{updateHistory:!0,kind:"update:details"})}if(f.key===As){const M=await xa(t.getState(),(T=f.value)==null?void 0:T.payload);t.updateState(M,{updateHistory:!0,kind:"update:details"})}if(f.key===Ms){const M=La(t.getState(),(S=f.value)==null?void 0:S.payload);t.updateState(M,{updateHistory:!0,kind:"update:details"})}});return{unsubscribe:()=>{k.unsubscribe(),b.unsubscribe(),v.unsubscribe(),y.unsubscribe(),g.unsubscribe(),h.unsubscribe(),m.unsubscribe(),p.unsubscribe()}}}const qa={Date:!0,RegExp:!0,String:!0,Number:!0};function ii(t,r,e={cyclesFix:!0},n=[]){var c,d;let i=[];const a=Array.isArray(t);for(const p in t){const h=t[p],y=a?+p:p;if(!(p in r)){i.push({type:"REMOVE",path:[y],oldValue:t[p]});continue}const m=r[p],g=typeof h=="object"&&typeof m=="object"&&Array.isArray(h)===Array.isArray(m);h&&m&&g&&!qa[(d=(c=Object.getPrototypeOf(h))==null?void 0:c.constructor)==null?void 0:d.name]&&(!e.cyclesFix||!n.includes(h))?i.push.apply(i,ii(h,m,e,e.cyclesFix?n.concat([h]):[]).map(k=>(k.path.unshift(y),k))):h!==m&&!(Number.isNaN(h)&&Number.isNaN(m))&&!(g&&(isNaN(h)?h+""==m+"":+h==+m))&&i.push({path:[y],type:"CHANGE",value:m,oldValue:h})}const u=Array.isArray(r);for(const p in r)p in t||i.push({type:"CREATE",path:[u?+p:p],value:r[p]});return i}var Gr=Symbol.for("immer-nothing"),Xe=Symbol.for("immer-draftable"),dt=Symbol.for("immer-state"),ai=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 e=ai[t],n=typeof e=="function"?e.apply(null,r):e;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ne=Object.getPrototypeOf;function se(t){return!!t&&!!t[dt]}function $t(t){var r;return t?oi(t)||Array.isArray(t)||!!t[Xe]||!!((r=t.constructor)!=null&&r[Xe])||qe(t)||Je(t):!1}var Ja=Object.prototype.constructor.toString();function oi(t){if(!t||typeof t!="object")return!1;const r=ne(t);if(r===null)return!0;const e=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return e===Object?!0:typeof e=="function"&&Function.toString.call(e)===Ja}function Ke(t,r){ie(t)===0?Reflect.ownKeys(t).forEach(e=>{r(e,t[e],t)}):t.forEach((e,n)=>r(n,e,t))}function ie(t){const r=t[dt];return r?r.type_:Array.isArray(t)?1:qe(t)?2:Je(t)?3:0}function Ve(t,r){return ie(t)===2?t.has(r):Object.prototype.hasOwnProperty.call(t,r)}function Xr(t,r){return ie(t)===2?t.get(r):t[r]}function ci(t,r,e){const n=ie(t);n===2?t.set(r,e):n===3?t.add(e):t[r]=e}function Za(t,r){return t===r?t!==0||1/t===1/r:t!==t&&r!==r}function qe(t){return t instanceof Map}function Je(t){return t instanceof Set}function ae(t){return t.copy_||t.base_}function Kr(t,r){if(qe(t))return new Map(t);if(Je(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const e=oi(t);if(r===!0||r==="class_only"&&!e){const n=Object.getOwnPropertyDescriptors(t);delete n[dt];let i=Reflect.ownKeys(n);for(let a=0;a<i.length;a++){const u=i[a],c=n[u];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(n[u]={configurable:!0,writable:!0,enumerable:c.enumerable,value:t[u]})}return Object.create(ne(t),n)}else{const n=ne(t);if(n!==null&&e)return{...t};const i=Object.create(n);return Object.assign(i,t)}}function Vr(t,r=!1){return mr(t)||se(t)||!$t(t)||(ie(t)>1&&(t.set=t.add=t.clear=t.delete=Qa),Object.freeze(t),r&&Object.entries(t).forEach(([e,n])=>Vr(n,!0))),t}function Qa(){G(2)}function mr(t){return Object.isFrozen(t)}var qr={};function oe(t){const r=qr[t];return r||G(0,t),r}function to(t,r){qr[t]||(qr[t]=r)}var Ze;function ui(){return Ze}function eo(t,r){return{drafts_:[],parent_:t,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function li(t,r){r&&(oe("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=r)}function Jr(t){Zr(t),t.drafts_.forEach(ro),t.drafts_=null}function Zr(t){t===Ze&&(Ze=t.parent_)}function di(t){return Ze=eo(Ze,t)}function ro(t){const r=t[dt];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function fi(t,r){r.unfinalizedDrafts_=r.drafts_.length;const e=r.drafts_[0];return t!==void 0&&t!==e?(e[dt].modified_&&(Jr(r),G(4)),$t(t)&&(t=yr(r,t),r.parent_||Ir(r,t)),r.patches_&&oe("Patches").generateReplacementPatches_(e[dt].base_,t,r.patches_,r.inversePatches_)):t=yr(r,e,[]),Jr(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),t!==Gr?t:void 0}function yr(t,r,e){if(mr(r))return r;const n=r[dt];if(!n)return Ke(r,(i,a)=>pi(t,n,r,i,a,e)),r;if(n.scope_!==t)return r;if(!n.modified_)return Ir(t,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const i=n.copy_;let a=i,u=!1;n.type_===3&&(a=new Set(i),i.clear(),u=!0),Ke(a,(c,d)=>pi(t,n,i,c,d,e,u)),Ir(t,i,!1),e&&t.patches_&&oe("Patches").generatePatches_(n,e,t.patches_,t.inversePatches_)}return n.copy_}function pi(t,r,e,n,i,a,u){if(process.env.NODE_ENV!=="production"&&i===e&&G(5),se(i)){const c=a&&r&&r.type_!==3&&!Ve(r.assigned_,n)?a.concat(n):void 0,d=yr(t,i,c);if(ci(e,n,d),se(d))t.canAutoFreeze_=!1;else return}else u&&e.add(i);if($t(i)&&!mr(i)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;yr(t,i),(!r||!r.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(e,n)&&Ir(t,i)}}function Ir(t,r,e=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Vr(r,e)}function no(t,r){const e=Array.isArray(t),n={type_:e?1:0,scope_:r?r.scope_:ui(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,a=Qr;e&&(i=[n],a=Qe);const{revoke:u,proxy:c}=Proxy.revocable(i,a);return n.draft_=c,n.revoke_=u,c}var Qr={get(t,r){if(r===dt)return t;const e=ae(t);if(!Ve(e,r))return so(t,e,r);const n=e[r];return t.finalized_||!$t(n)?n:n===tn(t.base_,r)?(rn(t),t.copy_[r]=nn(n,t)):n},has(t,r){return r in ae(t)},ownKeys(t){return Reflect.ownKeys(ae(t))},set(t,r,e){const n=hi(ae(t),r);if(n!=null&&n.set)return n.set.call(t.draft_,e),!0;if(!t.modified_){const i=tn(ae(t),r),a=i==null?void 0:i[dt];if(a&&a.base_===e)return t.copy_[r]=e,t.assigned_[r]=!1,!0;if(Za(e,i)&&(e!==void 0||Ve(t.base_,r)))return!0;rn(t),en(t)}return t.copy_[r]===e&&(e!==void 0||r in t.copy_)||Number.isNaN(e)&&Number.isNaN(t.copy_[r])||(t.copy_[r]=e,t.assigned_[r]=!0),!0},deleteProperty(t,r){return tn(t.base_,r)!==void 0||r in t.base_?(t.assigned_[r]=!1,rn(t),en(t)):delete t.assigned_[r],t.copy_&&delete t.copy_[r],!0},getOwnPropertyDescriptor(t,r){const e=ae(t),n=Reflect.getOwnPropertyDescriptor(e,r);return n&&{writable:!0,configurable:t.type_!==1||r!=="length",enumerable:n.enumerable,value:e[r]}},defineProperty(){G(11)},getPrototypeOf(t){return ne(t.base_)},setPrototypeOf(){G(12)}},Qe={};Ke(Qr,(t,r)=>{Qe[t]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),Qe.deleteProperty=function(t,r){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(r))&&G(13),Qe.set.call(this,t,r,void 0)},Qe.set=function(t,r,e){return process.env.NODE_ENV!=="production"&&r!=="length"&&isNaN(parseInt(r))&&G(14),Qr.set.call(this,t[0],r,e,t[0])};function tn(t,r){const e=t[dt];return(e?ae(e):t)[r]}function so(t,r,e){var i;const n=hi(r,e);return n?"value"in n?n.value:(i=n.get)==null?void 0:i.call(t.draft_):void 0}function hi(t,r){if(!(r in t))return;let e=ne(t);for(;e;){const n=Object.getOwnPropertyDescriptor(e,r);if(n)return n;e=ne(e)}}function en(t){t.modified_||(t.modified_=!0,t.parent_&&en(t.parent_))}function rn(t){t.copy_||(t.copy_=Kr(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var io=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,e,n)=>{if(typeof r=="function"&&typeof e!="function"){const a=e;e=r;const u=this;return function(d=a,...p){return u.produce(d,h=>e.call(this,h,...p))}}typeof e!="function"&&G(6),n!==void 0&&typeof n!="function"&&G(7);let i;if($t(r)){const a=di(this),u=nn(r,void 0);let c=!0;try{i=e(u),c=!1}finally{c?Jr(a):Zr(a)}return li(a,n),fi(i,a)}else if(!r||typeof r!="object"){if(i=e(r),i===void 0&&(i=r),i===Gr&&(i=void 0),this.autoFreeze_&&Vr(i,!0),n){const a=[],u=[];oe("Patches").generateReplacementPatches_(r,i,a,u),n(a,u)}return i}else G(1,r)},this.produceWithPatches=(r,e)=>{if(typeof r=="function")return(u,...c)=>this.produceWithPatches(u,d=>r(d,...c));let n,i;return[this.produce(r,e,(u,c)=>{n=u,i=c}),n,i]},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),se(t)&&(t=ao(t));const r=di(this),e=nn(t,void 0);return e[dt].isManual_=!0,Zr(r),e}finishDraft(t,r){const e=t&&t[dt];(!e||!e.isManual_)&&G(9);const{scope_:n}=e;return li(n,r),fi(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,r){let e;for(e=r.length-1;e>=0;e--){const i=r[e];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}e>-1&&(r=r.slice(e+1));const n=oe("Patches").applyPatches_;return se(t)?n(t,r):this.produce(t,i=>n(i,r))}};function nn(t,r){const e=qe(t)?oe("MapSet").proxyMap_(t,r):Je(t)?oe("MapSet").proxySet_(t,r):no(t,r);return(r?r.scope_:ui()).drafts_.push(e),e}function ao(t){return se(t)||G(10,t),mi(t)}function mi(t){if(!$t(t)||mr(t))return t;const r=t[dt];let e;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,e=Kr(t,r.scope_.immer_.useStrictShallowCopy_)}else e=Kr(t,!0);return Ke(e,(n,i)=>{ci(e,n,mi(i))}),r&&(r.finalized_=!1),e}function yi(){process.env.NODE_ENV!=="production"&&ai.push('Sets cannot have "replace" patches.',function(m){return"Unsupported patch operation: "+m},function(m){return"Cannot apply patch, path doesn't resolve: "+m},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const r="replace",e="add",n="remove";function i(m,g,k,b){switch(m.type_){case 0:case 2:return u(m,g,k,b);case 1:return a(m,g,k,b);case 3:return c(m,g,k,b)}}function a(m,g,k,b){let{base_:v,assigned_:f}=m,_=m.copy_;_.length<v.length&&([v,_]=[_,v],[k,b]=[b,k]);for(let T=0;T<v.length;T++)if(f[T]&&_[T]!==v[T]){const S=g.concat([T]);k.push({op:r,path:S,value:y(_[T])}),b.push({op:r,path:S,value:y(v[T])})}for(let T=v.length;T<_.length;T++){const S=g.concat([T]);k.push({op:e,path:S,value:y(_[T])})}for(let T=_.length-1;v.length<=T;--T){const S=g.concat([T]);b.push({op:n,path:S})}}function u(m,g,k,b){const{base_:v,copy_:f}=m;Ke(m.assigned_,(_,T)=>{const S=Xr(v,_),M=Xr(f,_),E=T?Ve(v,_)?r:e:n;if(S===M&&E===r)return;const A=g.concat(_);k.push(E===n?{op:E,path:A}:{op:E,path:A,value:M}),b.push(E===e?{op:n,path:A}:E===n?{op:e,path:A,value:y(S)}:{op:r,path:A,value:y(S)})})}function c(m,g,k,b){let{base_:v,copy_:f}=m,_=0;v.forEach(T=>{if(!f.has(T)){const S=g.concat([_]);k.push({op:n,path:S,value:T}),b.unshift({op:e,path:S,value:T})}_++}),_=0,f.forEach(T=>{if(!v.has(T)){const S=g.concat([_]);k.push({op:e,path:S,value:T}),b.unshift({op:n,path:S,value:T})}_++})}function d(m,g,k,b){k.push({op:r,path:[],value:g===Gr?void 0:g}),b.push({op:r,path:[],value:m})}function p(m,g){return g.forEach(k=>{const{path:b,op:v}=k;let f=m;for(let M=0;M<b.length-1;M++){const E=ie(f);let A=b[M];typeof A!="string"&&typeof A!="number"&&(A=""+A),(E===0||E===1)&&(A==="__proto__"||A==="constructor")&&G(19),typeof f=="function"&&A==="prototype"&&G(19),f=Xr(f,A),typeof f!="object"&&G(18,b.join("/"))}const _=ie(f),T=h(k.value),S=b[b.length-1];switch(v){case r:switch(_){case 2:return f.set(S,T);case 3:G(16);default:return f[S]=T}case e:switch(_){case 1:return S==="-"?f.push(T):f.splice(S,0,T);case 2:return f.set(S,T);case 3:return f.add(T);default:return f[S]=T}case n:switch(_){case 1:return f.splice(S,1);case 2:return f.delete(S);case 3:return f.delete(k.value);default:return delete f[S]}default:G(17,v)}}),m}function h(m){if(!$t(m))return m;if(Array.isArray(m))return m.map(h);if(qe(m))return new Map(Array.from(m.entries()).map(([k,b])=>[k,h(b)]));if(Je(m))return new Set(Array.from(m).map(h));const g=Object.create(ne(m));for(const k in m)g[k]=h(m[k]);return Ve(m,Xe)&&(g[Xe]=m[Xe]),g}function y(m){return se(m)?h(m):m}to("Patches",{applyPatches_:p,generatePatches_:i,generateReplacementPatches_:d})}var ft=new io,oo=ft.produce;ft.produceWithPatches.bind(ft),ft.setAutoFreeze.bind(ft),ft.setUseStrictShallowCopy.bind(ft);var co=ft.applyPatches.bind(ft);ft.createDraft.bind(ft),ft.finishDraft.bind(ft);var uo=9007199254740991,lo="[object Arguments]",fo="[object Function]",po="[object GeneratorFunction]",ho="[object Symbol]",mo=typeof ht=="object"&&ht&&ht.Object===Object&&ht,yo=typeof self=="object"&&self&&self.Object===Object&&self,Io=mo||yo||Function("return this")();function go(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}function bo(t,r){for(var e=-1,n=t?t.length:0,i=Array(n);++e<n;)i[e]=r(t[e],e,t);return i}function ko(t,r){for(var e=-1,n=r.length,i=t.length;++e<n;)t[i+e]=r[e];return t}var sn=Object.prototype,_o=sn.hasOwnProperty,an=sn.toString,Ii=Io.Symbol,vo=sn.propertyIsEnumerable,gi=Ii?Ii.isConcatSpreadable:void 0,bi=Math.max;function So(t,r,e,n,i){var a=-1,u=t.length;for(e||(e=Ao),i||(i=[]);++a<u;){var c=t[a];e(c)?ko(i,c):i[i.length]=c}return i}function To(t,r){return t=Object(t),Eo(t,r,function(e,n){return n in t})}function Eo(t,r,e){for(var n=-1,i=r.length,a={};++n<i;){var u=r[n],c=t[u];e(c,u)&&(a[u]=c)}return a}function wo(t,r){return r=bi(r===void 0?t.length-1:r,0),function(){for(var e=arguments,n=-1,i=bi(e.length-r,0),a=Array(i);++n<i;)a[n]=e[r+n];n=-1;for(var u=Array(r+1);++n<r;)u[n]=e[n];return u[r]=a,go(t,this,u)}}function Ao(t){return Do(t)||Oo(t)||!!(gi&&t&&t[gi])}function Mo(t){if(typeof t=="string"||zo(t))return t;var r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Oo(t){return Co(t)&&_o.call(t,"callee")&&(!vo.call(t,"callee")||an.call(t)==lo)}var Do=Array.isArray;function Ro(t){return t!=null&&xo(t.length)&&!Po(t)}function Co(t){return ki(t)&&Ro(t)}function Po(t){var r=Lo(t)?an.call(t):"";return r==fo||r==po}function xo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=uo}function Lo(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function ki(t){return!!t&&typeof t=="object"}function zo(t){return typeof t=="symbol"||ki(t)&&an.call(t)==ho}var No=wo(function(t,r){return t==null?{}:To(t,bo(So(r),Mo))}),Fo=No;const _i=Nr(Fo),$o={size:{width:1080,height:1920},fps:30,tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{index:7,unit:300,zoom:1/300,segments:5},duration:0,activeIds:[],structure:[],background:{type:"color",value:"transparent"}},vi=["tracks","trackItemsMap","transitionIds","transitionsMap","trackItemIds","structure"];class Ho{constructor(r,e){Qt(this,"stateSubject");Qt(this,"stateHistorySubject");Qt(this,"prevState");Qt(this,"background");Qt(this,"undos",[]);Qt(this,"redos",[]);Qt(this,"listener");const n=Object.assign({},$o,r,e!=null&&e.scale?{scale:e.scale}:{});this.stateSubject=new ts(n),this.stateHistorySubject=new ts({handleRedo:!1,handleUndo:!1}),this.background=n.background,this.prevState=n,(e!=null&&e.cors||e!=null&&e.acceptsMap)&&ma({cors:e.cors,acceptsMap:e.acceptsMap}),this.initListeners()}initListeners(){Va(this)}destroyListeners(){this.listener&&this.listener.unsubscribe()}purge(){this.destroyListeners()}updateHistory(r,e){const n=_i(r,vi),i=_i(this.getState(),vi),a=ii(i,n);a.length&&(this.undos.push({undos:a,type:e}),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,e={updateHistory:!1}){const n=this.getState(),i={...C(n),...C(r)};Y(n,i)||(e.updateHistory&&this.updateHistory(i,e.kind),this.prevState=n,this.stateSubject.next(i))}subscribeToUpdateStateDetails(r){return this.stateSubject.asObservable().subscribe(e=>{(!Y(e.size,this.prevState.size)||!Y(e.background,this.prevState.background))&&r({size:e.size,background:e.background})})}subscribeToScale(r){return this.stateSubject.asObservable().subscribe(e=>{Y(e.scale,this.prevState.scale)||r({scale:e.scale})})}subscribeToFps(r){return this.stateSubject.asObservable().subscribe(e=>{e.fps!==this.prevState.fps&&r({fps:e.fps})})}subscribeToUpdateTrackItem(r){return this.stateSubject.asObservable().subscribe(e=>{Y(e.trackItemsMap,this.prevState.trackItemsMap)||r({trackItemsMap:e.trackItemsMap})})}subscribeToUpdateAnimations(r){return this.stateSubject.asObservable().subscribe(e=>{const n=Object.keys(e.trackItemsMap).filter(i=>{const a=this.prevState.trackItemsMap[i],u=e.trackItemsMap[i];return a&&u&&!Y(a.animations,u.animations)});r({trackItemsMap:e.trackItemsMap,changedAnimationIds:n})})}subscribeToUpdateTrackItemTiming(r){return this.stateSubject.asObservable().subscribe(e=>{if(!Y(e.trackItemsMap,this.prevState.trackItemsMap)){const n=Object.keys(e.trackItemsMap).filter(a=>{const u=this.prevState.trackItemsMap[a],c=e.trackItemsMap[a];return u&&c&&!Y(u.trim,c.trim)}),i=Object.keys(e.trackItemsMap).filter(a=>{const u=this.prevState.trackItemsMap[a],c=e.trackItemsMap[a];return u&&c&&!Y(u.display,c.display)});r({trackItemsMap:e.trackItemsMap,changedTrimIds:n.length>0?n:void 0,changedDisplayIds:i.length>0?i:void 0})}})}subscribeToUpdateItemDetails(r){return this.stateSubject.asObservable().subscribe(e=>{Object.keys(e.trackItemsMap).some(i=>{const a=this.prevState.trackItemsMap[i],u=e.trackItemsMap[i];return a&&u&&!Y(a.details,u.details)})&&r({trackItemsMap:e.trackItemsMap})})}subscribeToDuration(r){return this.stateSubject.asObservable().subscribe(e=>{e.duration!==this.prevState.duration&&r({duration:e.duration})})}subscribeToHistory(r){return this.stateHistorySubject.asObservable().subscribe(e=>{if(e.handleRedo){const n=this.undos[this.undos.length-1].type;r({...this.getState(),type:n}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}if(e.handleUndo){const n=this.redos[this.redos.length-1].type;r({...this.getState(),type:n}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}})}subscribeToAddOrRemoveItems(r){return this.stateSubject.asObservable().subscribe(e=>{const n=[...e.trackItemIds].sort(),i=[...this.prevState.trackItemIds].sort(),a=[...e.transitionIds].sort(),u=[...this.prevState.transitionIds].sort();(!Y(n,i)||!Y(a,u))&&r({trackItemIds:e.trackItemIds})})}subscribeToActiveIds(r){return this.stateSubject.asObservable().subscribe(e=>{Y(e.activeIds,this.prevState.activeIds)||r({activeIds:e.activeIds})})}subscribeToTracks(r){return this.stateSubject.asObservable().subscribe(e=>{const n=e.tracks,a=this.prevState.tracks.map(c=>c.id),u=n.filter(c=>!a.includes(c.id));u.length&&r({tracks:e.tracks,changedTracks:u.map(c=>c.id)})})}subscribeToState(r){return this.stateSubject.asObservable().subscribe(e=>{(!Y(e.tracks,this.prevState.tracks)||!Y(e.trackItemIds,this.prevState.trackItemIds)||!Y(e.trackItemsMap,this.prevState.trackItemsMap)||!Y(e.transitionIds,this.prevState.transitionIds)||!Y(e.transitionsMap,this.prevState.transitionsMap)||!Y(e.structure,this.prevState.structure))&&r({tracks:e.tracks,trackItemIds:e.trackItemIds,trackItemsMap:e.trackItemsMap,transitionIds:e.transitionIds,transitionsMap:e.transitionsMap,structure:e.structure})})}undo(){const r=this.undos.pop(),e=r==null?void 0:r.undos,n=r==null?void 0:r.type;if(!e||!n)return;yi();const{trackItemIds:i,tracks:a,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}=this.getState(),h=C({trackItemIds:i,tracks:a,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}),y=[],m=[],g=[],k=[],b=[],v=[];e.forEach(D=>{let F;const nt=D.path.slice(1);D.type==="CREATE"?F={path:nt,op:"remove",value:D.value}:D.type==="CHANGE"?F={path:nt,op:"replace",value:D.oldValue}:F={path:nt,op:"add",value:D.oldValue},D.path.includes("trackItemIds")?g.push(F):D.path.includes("transitionIds")?m.push(F):D.path.includes("trackItemsMap")?b.push(F):D.path.includes("transitionsMap")?k.push(F):D.path.includes("tracks")?y.push(F):D.path.includes("structure")&&v.push(F)});const f=this.applyPatch(h.tracks,y),_=this.applyPatch(h.transitionIds,m),T=this.applyPatch(h.trackItemIds,g),S=this.applyPatch(h.transitionsMap,k),M=this.applyPatch(h.trackItemsMap,b),E=this.applyPatch(h.structure,v),A=C({tracks:f,transitionIds:_,trackItemIds:T,transitionsMap:S,trackItemsMap:M,structure:E}),U=C(this.getState()),P={...U,...A};this.prevState=U,this.redos.push({redos:e,type:n});const K=W(P.trackItemsMap);this.stateSubject.next({...P,duration:K}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!0}),this.updateState(P,{updateHistory:!1})}applyPatch(r,e){return e.reverse().reduce((n,i)=>oo(n,a=>{co(a,[i])}),r)}redo(){const r=this.redos.pop(),e=r==null?void 0:r.redos,n=r==null?void 0:r.type;if(!e||!n)return;yi();const{trackItemIds:i,tracks:a,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}=this.getState(),h=C({trackItemIds:i,tracks:a,transitionIds:u,transitionsMap:c,trackItemsMap:d,structure:p}),y=[],m=[],g=[],k=[],b=[],v=[];e.forEach(D=>{let F;const nt=D.path.slice(1);D.type==="CREATE"?F={path:nt,op:"add",value:D.value}:D.type==="CHANGE"?F={path:nt,op:"replace",value:D.value}:F={path:nt,op:"remove",value:D.oldValue},D.path.includes("trackItemIds")?g.push(F):D.path.includes("transitionIds")?m.push(F):D.path.includes("trackItemsMap")?b.push(F):D.path.includes("transitionsMap")?k.push(F):D.path.includes("structure")?v.push(F):y.push(F)});const f=this.applyPatch(h.tracks,y),_=this.applyPatch(h.transitionIds,m),T=this.applyPatch(h.trackItemIds,g),S=this.applyPatch(h.transitionsMap,k),M=this.applyPatch(h.trackItemsMap,b),E=this.applyPatch(h.structure,v),A=C({tracks:f,transitionIds:_,trackItemIds:T,transitionsMap:S,trackItemsMap:M,structure:E}),U=C(this.getState()),P={...U,...A};this.prevState=U,this.undos.push({undos:e,type:n});const K=W(P.trackItemsMap);this.stateSubject.next({...P,duration:K}),this.stateHistorySubject.next({handleRedo:!0,handleUndo:!1}),this.updateState(P,{updateHistory:!1})}toJSON(){const{fps:r,tracks:e,size:n,trackItemIds:i,transitionsMap:a,trackItemsMap:u,transitionIds:c}=this.getState();return{fps:r,tracks:e,size:n,trackItemIds:i,transitionsMap:a,trackItemsMap:u,transitionIds:c}}}w.ACTIVE_CLONE=Ji,w.ACTIVE_DELETE=qi,w.ACTIVE_PASTE=Os,w.ACTIVE_PREFIX=te,w.ACTIVE_SET=Vi,w.ACTIVE_SPLIT=Ds,w.ADD_ANIMATION=ps,w.ADD_AUDIO=us,w.ADD_CAPTIONS=hs,w.ADD_COMPOSITION=Is,w.ADD_HILL_AUDIO_BARS=Ts,w.ADD_ILLUSTRATION=ds,w.ADD_IMAGE=ls,w.ADD_ITEMS=ys,w.ADD_LINEAL_AUDIO_BARS=_s,w.ADD_MASK=ji,w.ADD_PLACEHOLDER=Ui,w.ADD_PREFIX=j,w.ADD_PROGRESS_BAR=gs,w.ADD_PROGRESS_FRAME=bs,w.ADD_PROGRESS_SQUARE=vs,w.ADD_RADIAL_AUDIO_BARS=ks,w.ADD_RECT=Es,w.ADD_SHAPE=fs,w.ADD_SUFFIX=Ni,w.ADD_TEMPLATE=ms,w.ADD_TEXT=os,w.ADD_TRANSITION=Bi,w.ADD_VIDEO=cs,w.ADD_WAVE_AUDIO_BARS=Ss,w.BULK_PREFIX=ss,w.DELETE_TEMPLATE_ITEM=Xi,w.DESIGN_LOAD=is,w.DESIGN_PREFIX=fr,w.DESIGN_RESIZE=as,w.EDIT_BACKGROUND_EDITOR=Ms,w.EDIT_BULK=Fr,w.EDIT_OBJECT=ws,w.EDIT_PREFIX=At,w.EDIT_SHAPE=Wi,w.EDIT_TEMPLATE_ITEM=Gi,w.EDIT_TEXT=Yi,w.ENTER_EDIT_MODE=Ki,w.HISTORY_PREFIX=Ye,w.HISTORY_REDO=Ns,w.HISTORY_RESET=ca,w.HISTORY_UNDO=zs,w.LAYER_CLONE=Ps,w.LAYER_COPY=Cs,w.LAYER_CUT=oa,w.LAYER_DELETE=xs,w.LAYER_EDITING_NAME=sa,w.LAYER_HIDDEN=Qi,w.LAYER_LOCKED=Zi,w.LAYER_MOVE=ta,w.LAYER_PASTE=ia,w.LAYER_PREFIX=V,w.LAYER_RENAME=na,w.LAYER_REPLACE=Ls,w.LAYER_SELECT=Rs,w.LAYER_SELECTION=ea,w.LAYER_SEND_TO=ra,w.LAYER_SPLIT=aa,w.REPLACE_MEDIA=As,w.STATE_CHANGED=Hi,w.STATE_PREFIX=ns,w.TIMELINE_SCALE_CHANGED=Fs,w.TIMELINE_SCALE_PREFIX=$r,w.TRACKS_CHANGED=Fi,w.TRACK_ITEMS_CHANGED=$i,w.TRACK_ITEMS_PREFIX=rs,w.TRACK_PREFIX=es,w.default=Ho,w.getAcceptsMap=jr,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designcombo/state",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"typescript": "^5.3.3",
|
|
26
26
|
"vite": "^5.2.0",
|
|
27
27
|
"vite-plugin-dts": "^3.9.1",
|
|
28
|
-
"@designcombo/
|
|
29
|
-
"@designcombo/
|
|
28
|
+
"@designcombo/typescript-config": "0.0.0",
|
|
29
|
+
"@designcombo/types": "5.5.3"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"immer": "^10.1.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@designcombo/events": "^1.0.2",
|
|
42
|
-
"@designcombo/types": "5.5.
|
|
42
|
+
"@designcombo/types": "5.5.3"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"dev": "vite",
|