@cliquify.me/timeline 4.0.25 → 5.0.1

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 CHANGED
@@ -9488,7 +9488,7 @@ function Th(i) {
9488
9488
  i0(this, i);
9489
9489
  }
9490
9490
  function o0(i) {
9491
- console.log("addScrollEvents"), i.on("mouse:up", _h), i.on("object:moving", Th.bind(i));
9491
+ i.on("mouse:up", _h), i.on("object:moving", Th.bind(i));
9492
9492
  }
9493
9493
  function a0(i) {
9494
9494
  i.off("mouse:up", _h), i.off("object:moving", Th.bind(i));
package/dist/index.umd.js CHANGED
@@ -495,4 +495,4 @@ void main() {
495
495
  color.b += max != color.b ? (max - color.b) * amt : 0.00;
496
496
  gl_FragColor = color;
497
497
  }
498
- `}applyTo2d(t){let{imageData:{data:e}}=t;const s=-this.vibrance;for(let r=0;r<e.length;r+=4){const n=e[r],o=e[r+1],a=e[r+2],c=Math.max(n,o,a),h=(n+o+a)/3,l=2*Math.abs(c-h)/255*s;e[r]+=c!==n?(c-n)*l:0,e[r+1]+=c!==o?(c-o)*l:0,e[r+2]+=c!==a?(c-a)*l:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(ni,"type","Vibrance"),v(ni,"defaults",{vibrance:0}),v(ni,"uniformLocations",["uVibrance"]),C.setClass(ni);function Ft(i,t,e,s,r){const a=r.canvas;if(!a)return;const c=a.viewportTransform;i.save(),this.controlOrientation==="left"?i.translate(r.left+c[4],r.top+c[5]+r.height/2):i.translate(r.left+r.width+c[4],r.top+c[5]+r.height/2),i.rotate(Ga.degreesToRadians(90+r.angle)),i.lineWidth=6,i.lineCap="round",i.strokeStyle="white",i.beginPath(),i.moveTo(-6,0),i.lineTo(6,0),i.stroke(),i.lineWidth=4,i.strokeStyle="black",i.beginPath(),i.moveTo(-6,0),i.lineTo(6,0),i.stroke(),i.restore()}const Fd={selectable:!1,evented:!1,strokeWidth:0,stroke:"transparent"},bs=class bs extends Z{constructor(e){super(e);w(this,"id");w(this,"accepts",["audio","video","image","text","caption","template"]);w(this,"metadata");w(this,"items",[]);w(this,"magnetic");w(this,"static");Object.assign(this,bs.ownDefaults),this.id=e.id,this.accepts=e.accepts||[],this.items=e.items||[],this.magnetic=e.magnetic,this.static=e.static,this.metadata=e.metadata,this.fill="rgba(34, 34, 37, 0.8)"}static getDefaults(){return{...super.getDefaults(),...bs.ownDefaults}}updateCoords(e){this.width=e}};w(bs,"ownDefaults",Fd),w(bs,"type","Track");let Lt=bs;C.setClass(Lt,"Track");const Ys=1,He="rgba(255, 255, 255,1.0)",Ld=["Track","Transition","Helper","PreviewTrackItem"],Rd={top:{top:35,guide:2,bottom:3},center:{top:3,guide:2,bottom:3},bottom:{top:3,guide:2,bottom:35}},Bd=(i,t)=>{const e=Rd[i];return i==="top"?{top:t-(e.guide+e.bottom),guide:e.guide,bottom:e.bottom}:i==="center"?{top:e.top,guide:e.guide,bottom:e.bottom}:{top:e==null?void 0:e.top,guide:e==null?void 0:e.guide,bottom:t-((e==null?void 0:e.guide)+(e==null?void 0:e.top))}},_s=class _s extends Gt{constructor(e){const s=Bd(e.kind,e.height),r=new Z({top:0,left:0,strokeWidth:0,fill:"transparent",selectable:!0,height:s.top,width:e.width}),n=new Z({top:s.top,left:0,strokeWidth:0,fill:"transparent",selectable:!0,height:s.guide,width:e.width}),o=new Z({top:s.top+s.guide,left:0,strokeWidth:0,fill:"transparent",selectable:!0,height:s.bottom,width:e.width});super([r,n,o],e);w(this,"guide");w(this,"topGuide");w(this,"bottomGuide");w(this,"metadata");w(this,"accepts",[]);w(this,"kind");w(this,"activeGuideFill");Object.assign(this,_s.ownDefaults),this.guide=n,this.topGuide=r,this.bottomGuide=o,this.id=e.id,this.metadata=e.metadata,this.tScale=e.tScale,this.kind=e.kind,this.activeGuideFill=e.activeGuideFill||He}static getDefaults(){return{...super.getDefaults(),..._s.ownDefaults}}updateCoords(e){this.scaleToWidth(e),this.set("scaleY",1)}setSelected(e){e?this.guide.set("fill",this.activeGuideFill):this.guide.set("fill","transparent")}};w(_s,"type","Helper"),w(_s,"ownDefaults",{selectable:!1,evented:!1});let ce=_s;C.setClass(ce,"Helper");const Ts=class Ts extends Z{constructor(e){super(e);w(this,"guideItemId");w(this,"distXToActCenter");w(this,"trackItemType");w(this,"defaultPos");w(this,"draggedObject");Object.assign(this,Ts.ownDefaults),this.id=e.id}static getDefaults(){return{...super.getDefaults(),...Ts.ownDefaults}}_render(e){super._render(e),this.updateSelected(e)}updateSelected(e){e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.setLineDash(this.strokeDashArray),e.strokeStyle=He,e.stroke(),e.restore()}};w(Ts,"type","Placeholder"),w(Ts,"ownDefaults",{rx:6,ry:6,objectCaching:!1,borderColor:"transparent",strokeWidth:0,fill:"rgba(255, 211, 42,0.1)",stroke:"rgba(255, 211, 42,1.0)",selectable:!1,borderOpacityWhenMoving:1,hoverCursor:"default",strokeDashArray:[5,1],evented:!1});let ls=Ts;C.setClass(ls,"Placeholder");const Wd={left:-.5,top:-.5,center:0,bottom:.5,right:.5},I=i=>typeof i=="string"?Wd[i]:i-.5,we="center",us="left",Xd="top",zd="bottom",ds="right",Hd="none";function gs(i){return I(i.originX)===I(we)&&I(i.originY)===I(we)}function Vs(i){return(t,e,s,r)=>{const{target:n,originX:o,originY:a}=e,c=n.getRelativeCenterPoint(),h=n.translateToOriginPoint(c,o,a),l=i(t,e,s,r);return n.setPositionByOrigin(h,e.originX,e.originY),l}}const bc=3,Yd=4,_c=188,Vd=1e3/60;function nt(i,t=1,e=1){const s=_c*t;return i*(60/1e3)*s/e}function B(i,t=1,e=1){const s=_c*t;return i/s*Vd*e}function Gd(i,t=1){return nt(i,t)}const Gs=i=>Object.keys(i).reduce((t,e)=>{const{display:s}=i[e];return Math.max(t,s.to)},0),{wrapWithFireEvent:Nd,getLocalPoint:Ud}=Xe,Cn=Nd("resizing",Vs((i,t,e,s)=>{const r=Ud(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){let{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o);if(t.corner==="mr"){const u=n.trim.to,d=h-c,g=B(d,n.tScale,n.playbackRate),f=u+g;if(f>n.duration)return!1;n.set("width",Math.max(h,0)),n.trim.to=f}else{if(n.left<0)return!1;const u=c-h;if(n.left+u<0){const b=nt(n.duration,n.tScale,n.playbackRate),T=n.width+n.left;if(T<=b){n.set("width",T);const x=B(b-T,n.tScale,n.playbackRate);return n.trim.from=x,!0}return!1}const g=h-c,f=n.trim.from,p=B(g,n.tScale,n.playbackRate),m=f-p;if(m<0)return!1;n.set("width",Math.max(h,0)),n.trim.from=m,n.onResize&&n.onResize()}return c!==n.width}return!1})),{wrapWithFireEvent:$d,getLocalPoint:qd,wrapWithFixedAnchor:Kd}=Xe,oi=$d("resizing",Kd((i,t,e,s)=>{const r=qd(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o),l=t.corner==="ml";if(n.left<0)return!1;if(l){const g=c-h;if(n.left+g<0)return n.set("width",n.width+n.left),!0}const u=B(1,n.tScale);return B(h,n.tScale,n.playbackRate)<u?!1:(n.set("width",Math.max(h,0)),c!==n.width)}return!1})),{wrapWithFireEvent:Jd,getLocalPoint:Zd}=Xe,On=Jd("resizing",Vs((i,t,e,s)=>{const r=Zd(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o),l=B(h,n.tScale,n.playbackRate);return l>=1500||l<500?!1:(n.set("width",Math.max(h,0)),n.set("duration",l),c!==n.width)}return!1})),{wrapWithFireEvent:Qd,getLocalPoint:tg}=Xe,Tc=Qd("resizing",Vs((i,t,e,s)=>{const r=tg(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){let{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o);if(t.corner==="mr"){const u=n.trim.to,d=h-c,g=B(d,n.tScale,n.playbackRate),f=u+g;if(f>n.duration)return!1;n.set("width",Math.max(h,0)),n.trim.to=f}else{if(n.left<0)return!1;const u=c-h;if(n.left+u<0)return!1;const g=h-c,f=n.trim.from,p=B(g,n.tScale,n.playbackRate),m=f-p;if(m<0)return!1;n.set("width",Math.max(h,0)),n.trim.from=m}return c!==n.width}return!1})),{scaleSkewCursorStyleHandler:Ut}=Xe,xc=()=>({mr:new Y({x:.5,y:0,actionHandler:oi,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"right"}),ml:new Y({x:-.5,y:0,actionHandler:oi,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"left"})}),eg=()=>({mr:new Y({x:.5,y:0,render:Ft,actionHandler:Tc,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"right"}),ml:new Y({x:-.5,y:0,render:Ft,actionHandler:Tc,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"left"})}),sg=()=>({mr:new Y({x:.5,y:0,render:Ft,actionHandler:Cn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"right"}),ml:new Y({x:-.5,y:0,render:Ft,actionHandler:Cn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"left"})}),Sc=()=>({mr:new Y({x:.5,y:0,render:Ft,actionHandler:Mn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"right"}),ml:new Y({x:-.5,y:0,render:Ft,actionHandler:Mn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"left"})}),kn=()=>({mr:new Y({x:.5,y:0,actionHandler:On,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"right"}),ml:new Y({x:-.5,y:0,actionHandler:On,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"left"})}),rg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ns=(i=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(i|=0));for(;i--;)t+=rg[e[i]&63];return t};function fs(i=16){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e=t.charAt(Math.floor(Math.random()*t.length));let s=Ns(i-1);return s=s.replace(/[^a-zA-Z0-9]/g,"").slice(0,i-1),e+s}const{wrapWithFireEvent:ig,getLocalPoint:ng}=Xe,Mn=ig("resizing",Vs((i,t,e,s)=>{const r=ng(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){let{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o);const l=B(1,n.tScale);if(t.corner==="mr"){const d=n.trim.to,g=h-c,f=B(g,n.tScale,n.playbackRate),p=d+f;if(p>n.duration)return!1;let m=B(h,n.tScale,n.playbackRate);if(m<l||(m=B(h,n.tScale,n.playbackRate),m<l))return!1;n.set("width",Math.max(h,0)),n.trim.to=p}else{if(n.left<0)return!1;const d=c-h;if(n.left+d<0){const x=nt(n.duration,n.tScale,n.playbackRate),S=n.width+n.left;if(S<=x){n.set("width",S);const O=B(x-S,n.tScale,n.playbackRate);return n.trim.from=O,!0}return!1}if(B(h,n.tScale,n.playbackRate)<l)return!1;const p=h-c,m=n.trim.from,b=B(p,n.tScale,n.playbackRate),T=m-b;if(T<0)return!1;n.set("width",Math.max(h,0)),n.trim.from=T,n.onResize&&n.onResize()}return c!==n.width}return!1})),xs=class xs extends Z{constructor(e){super(e);w(this,"duration");w(this,"fromId");w(this,"toId");w(this,"kind","none");w(this,"isSelected",!1);w(this,"availableDrop",!0);Object.assign(this,xs.ownDefaults),this.id=e.id,this.centeredScaling=!0,this.strokeWidth=0,this.tScale=e.tScale,this.duration=e.duration,this.fromId=e.fromId,this.toId=e.toId,this.kind=e.kind,this.strokeDashArray=e.strokeDashArray||[]}static createControls(){return{controls:kn()}}static getDefaults(){return{...super.getDefaults(),...xs.ownDefaults}}updateCoords(){}_render(e){super._render(e),this.updateSelected(e)}setSelected(e){this.isSelected=e,this.set({dirty:!0})}updateSelected(e){const s=this.availableDrop?this.isSelected?He:"rgba(255, 255, 255,0.15)":"red";e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.setLineDash(this.strokeDashArray),e.strokeStyle=s,e.stroke(),e.restore()}};w(xs,"type","Transition"),w(xs,"ownDefaults",{objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:1.5,fill:"rgba(0,0,0, 0.5)",borderOpacityWhenMoving:1,hoverCursor:"default",lockMovementX:!0,lockMovementY:!0,duration:1500,rx:8,ry:8});let Rt=xs;C.setClass(Rt,"Transition");const sr=class sr extends Z{constructor(e){super(e);w(this,"id");w(this,"resourceId","");w(this,"tScale");w(this,"isSelected",!1);w(this,"trim");w(this,"duration");Object.assign(this,sr.ownDefaults),this.id=e.id,this.tScale=e.tScale,this.objectCaching=!1,this.rx=8,this.ry=8}static createControls(){return{controls:Sc()}}_render(e){super._render(e),this.updateSelected(e)}setSelected(e){this.isSelected=e,this.set({dirty:!0})}updateSelected(e){this.isSelected&&(e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.strokeStyle=He,e.stroke(),e.restore())}onResizeSnap(){}setSrc(e){this.src=e}};w(sr,"type","Trimmable"),w(sr,"ownDefaults",{rx:6,ry:6,objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:0,fill:"#27272a",borderOpacityWhenMoving:1,hoverCursor:"default"});let $t=sr;C.setClass($t,"Trimmable");const Ss=class Ss extends Z{constructor(e){super(e);w(this,"isSelected",!1);Object.assign(this,Ss.ownDefaults),this.tScale=e.tScale,this.display=e.display}static createControls(){return{controls:xc()}}static getDefaults(){return{...super.getDefaults(),...Ss.ownDefaults}}setSelected(e){this.isSelected=e,this.set({dirty:!0})}_render(e){super._render(e),this.updateSelected(e)}updateSelected(e){this.isSelected&&(e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,6),e.lineWidth=Ys,e.strokeStyle=He,e.stroke(),e.restore())}};w(Ss,"type","Resizable"),w(Ss,"ownDefaults",{rx:6,ry:6,objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:0,fill:"#27272a",borderOpacityWhenMoving:1,hoverCursor:"default"});let ai=Ss;C.setClass(ai,"Resizable");function og(i){const t=Math.floor(i/1e3),e=Math.floor(t/60),s=t%60,r=String(e).padStart(2,"0"),n=String(s).padStart(2,"0");return`${r}:${n}`}const ws=class ws extends Z{constructor(e){super(e);w(this,"duration");w(this,"fromId");w(this,"toId");w(this,"isSelected",!1);w(this,"name");w(this,"durationString");w(this,"itemType");Object.assign(this,ws.ownDefaults),this.id=e.id,this.fill="#27272a",this.name=e.type.toUpperCase(),this.durationString=og(e.duration),this.itemType=e.type}static getDefaults(){return{...super.getDefaults(),...ws.ownDefaults}}_render(e){e.save(),super._render(e),e.beginPath(),e.rect(-this.width/2,-this.height/2,this.width,this.height),e.clip(),this.drawTextIdentity(e),e.restore()}drawTextIdentity(e){e.font="600 12px 'Geist variable'",e.textAlign="left";const s=e.measureText(this.name).width,r=e.measureText(this.durationString).width,n=8,o=4,a=4-this.height/2,c=20,h=4,l=4-this.width/2,u=s+n*2;this.drawRoundedRect(e,l,a,u,c,h),e.fillStyle="#f4f4f5",e.fillText(this.name,l+n,a+14);const d=l+u+o,g=r+n*2;this.drawRoundedRect(e,d,a,g,c,h),e.fillStyle="#f4f4f5",e.fillText(this.durationString,d+n,a+14)}drawRoundedRect(e,s,r,n,o,a){e.fillStyle="rgba(0, 0, 0, 0.5)",e.roundRect?(e.beginPath(),e.roundRect(s,r,n,o,a),e.fill()):e.fillRect(s,r,n,o)}};w(ws,"type","PreviewTrackItem"),w(ws,"ownDefaults",{objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:0,borderOpacityWhenMoving:1,hoverCursor:"default",rx:4,ry:4});let he=ws;C.setClass(he,"PreviewTrackItem");class ag{constructor(){w(this,"___eventListeners",{});w(this,"___activeObjects",[])}resize(t,{force:e}={force:!1}){var s;this.lowerCanvasEl&&(this.setDimensions(t),e&&this.renderTracks(),(s=this.onResizeCanvas)==null||s.call(this,{width:this.width,height:this.height}))}pauseEventListeners(){this.___eventListeners=this.__eventListeners,this.__eventListeners={};const t=this.getActiveObjects();this.discardActiveObject(),this.___activeObjects=t}resumeEventListeners(){this.__eventListeners=this.___eventListeners,this.___eventListeners={};const t=this.___activeObjects;if(!t.length)return this.requestRenderAll(),!1;if(t.length===1)this.setActiveObject(t[0]);else{const e=new Ct(t);this.setActiveObject(e)}this.requestRenderAll()}updateCachingActiveObjects(t){const e=this.___activeObjects;this.___activeObjects=e.map(s=>{const r=t.find(n=>n.id===s.id);return r||s})}}function Us(i,t){return i.map(e=>({...e,items:e.items.filter(s=>!t.includes(s))}))}const cg=(i,t)=>{var h,l,u,d,g;const e=i.display,s=nt(e.from,t.tScale),r=nt(e.to-e.from,t.tScale,i.playbackRate),n=t.sizesMap[i.type]||42,o=i.type.charAt(0).toUpperCase()+i.type.slice(1),a=C.getClass(o),c={width:r,height:n,id:i.id,tScale:t.tScale,top:10,left:s,display:e,duration:i.duration||e.to-e.from,metadata:i.metadata,playbackRate:i.playbackRate||1,src:(h=i.details)==null?void 0:h.src,trim:i.trim||{from:0,to:i.duration},text:(l=i.details)==null?void 0:l.text,srcs:((u=i.details)==null?void 0:u.srcs)||[],backgroundColorDiv:(d=i.details)==null?void 0:d.backgroundColor,svgString:(g=i.details)==null?void 0:g.svgString};return new a(c)};var wc=typeof global=="object"&&global&&global.Object===Object&&global,hg=typeof self=="object"&&self&&self.Object===Object&&self,Bt=wc||hg||Function("return this")(),kt=Bt.Symbol,Cc=Object.prototype,lg=Cc.hasOwnProperty,ug=Cc.toString,$s=kt?kt.toStringTag:void 0;function dg(i){var t=lg.call(i,$s),e=i[$s];try{i[$s]=void 0;var s=!0}catch{}var r=ug.call(i);return s&&(t?i[$s]=e:delete i[$s]),r}var gg=Object.prototype,fg=gg.toString;function pg(i){return fg.call(i)}var mg="[object Null]",vg="[object Undefined]",Oc=kt?kt.toStringTag:void 0;function ps(i){return i==null?i===void 0?vg:mg:Oc&&Oc in Object(i)?dg(i):pg(i)}function Ce(i){return i!=null&&typeof i=="object"}var yg="[object Symbol]";function ci(i){return typeof i=="symbol"||Ce(i)&&ps(i)==yg}function bg(i,t){for(var e=-1,s=i==null?0:i.length,r=Array(s);++e<s;)r[e]=t(i[e],e,i);return r}var qt=Array.isArray,kc=kt?kt.prototype:void 0,Mc=kc?kc.toString:void 0;function Dc(i){if(typeof i=="string")return i;if(qt(i))return bg(i,Dc)+"";if(ci(i))return Mc?Mc.call(i):"";var t=i+"";return t=="0"&&1/i==-1/0?"-0":t}var _g=/\s/;function Tg(i){for(var t=i.length;t--&&_g.test(i.charAt(t)););return t}var xg=/^\s+/;function Sg(i){return i&&i.slice(0,Tg(i)+1).replace(xg,"")}function Kt(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var jc=NaN,wg=/^[-+]0x[0-9a-f]+$/i,Cg=/^0b[01]+$/i,Og=/^0o[0-7]+$/i,kg=parseInt;function Ec(i){if(typeof i=="number")return i;if(ci(i))return jc;if(Kt(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Kt(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Sg(i);var e=Cg.test(i);return e||Og.test(i)?kg(i.slice(2),e?2:8):wg.test(i)?jc:+i}function Mg(i){return i}var Dg="[object AsyncFunction]",jg="[object Function]",Eg="[object GeneratorFunction]",Ig="[object Proxy]";function Ic(i){if(!Kt(i))return!1;var t=ps(i);return t==jg||t==Eg||t==Dg||t==Ig}var Dn=Bt["__core-js_shared__"],Pc=function(){var i=/[^.]+$/.exec(Dn&&Dn.keys&&Dn.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Pg(i){return!!Pc&&Pc in i}var Ag=Function.prototype,Fg=Ag.toString;function Ye(i){if(i!=null){try{return Fg.call(i)}catch{}try{return i+""}catch{}}return""}var Lg=/[\\^$.*+?()[\]{}|]/g,Rg=/^\[object .+?Constructor\]$/,Bg=Function.prototype,Wg=Object.prototype,Xg=Bg.toString,zg=Wg.hasOwnProperty,Hg=RegExp("^"+Xg.call(zg).replace(Lg,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Yg(i){if(!Kt(i)||Pg(i))return!1;var t=Ic(i)?Hg:Rg;return t.test(Ye(i))}function Vg(i,t){return i==null?void 0:i[t]}function Ve(i,t){var e=Vg(i,t);return Yg(e)?e:void 0}var jn=Ve(Bt,"WeakMap"),Ac=Object.create,Gg=function(){function i(){}return function(t){if(!Kt(t))return{};if(Ac)return Ac(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}();function Ng(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Ug=800,$g=16,qg=Date.now;function Kg(i){var t=0,e=0;return function(){var s=qg(),r=$g-(s-e);if(e=s,r>0){if(++t>=Ug)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}function Jg(i){return function(){return i}}var hi=function(){try{var i=Ve(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Zg=hi?function(i,t){return hi(i,"toString",{configurable:!0,enumerable:!1,value:Jg(t),writable:!0})}:Mg,Qg=Kg(Zg);function tf(i,t){for(var e=-1,s=i==null?0:i.length;++e<s&&t(i[e],e,i)!==!1;);return i}var ef=9007199254740991,sf=/^(?:0|[1-9]\d*)$/;function En(i,t){var e=typeof i;return t=t??ef,!!t&&(e=="number"||e!="symbol"&&sf.test(i))&&i>-1&&i%1==0&&i<t}function rf(i,t,e){t=="__proto__"&&hi?hi(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}function In(i,t){return i===t||i!==i&&t!==t}var nf=Object.prototype,of=nf.hasOwnProperty;function Fc(i,t,e){var s=i[t];(!(of.call(i,t)&&In(s,e))||e===void 0&&!(t in i))&&rf(i,t,e)}var Lc=Math.max;function af(i,t,e){return t=Lc(t===void 0?i.length-1:t,0),function(){for(var s=arguments,r=-1,n=Lc(s.length-t,0),o=Array(n);++r<n;)o[r]=s[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=s[r];return a[t]=e(o),Ng(i,this,a)}}var cf=9007199254740991;function Pn(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=cf}function hf(i){return i!=null&&Pn(i.length)&&!Ic(i)}var lf=Object.prototype;function Rc(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||lf;return i===e}function uf(i,t){for(var e=-1,s=Array(i);++e<i;)s[e]=t(e);return s}var df="[object Arguments]";function Bc(i){return Ce(i)&&ps(i)==df}var Wc=Object.prototype,gf=Wc.hasOwnProperty,ff=Wc.propertyIsEnumerable,An=Bc(function(){return arguments}())?Bc:function(i){return Ce(i)&&gf.call(i,"callee")&&!ff.call(i,"callee")};function pf(){return!1}var Xc=typeof M=="object"&&M&&!M.nodeType&&M,zc=Xc&&typeof module=="object"&&module&&!module.nodeType&&module,mf=zc&&zc.exports===Xc,Hc=mf?Bt.Buffer:void 0,vf=Hc?Hc.isBuffer:void 0,li=vf||pf,yf="[object Arguments]",bf="[object Array]",_f="[object Boolean]",Tf="[object Date]",xf="[object Error]",Sf="[object Function]",wf="[object Map]",Cf="[object Number]",Of="[object Object]",kf="[object RegExp]",Mf="[object Set]",Df="[object String]",jf="[object WeakMap]",Ef="[object ArrayBuffer]",If="[object DataView]",Pf="[object Float32Array]",Af="[object Float64Array]",Ff="[object Int8Array]",Lf="[object Int16Array]",Rf="[object Int32Array]",Bf="[object Uint8Array]",Wf="[object Uint8ClampedArray]",Xf="[object Uint16Array]",zf="[object Uint32Array]",X={};X[Pf]=X[Af]=X[Ff]=X[Lf]=X[Rf]=X[Bf]=X[Wf]=X[Xf]=X[zf]=!0,X[yf]=X[bf]=X[Ef]=X[_f]=X[If]=X[Tf]=X[xf]=X[Sf]=X[wf]=X[Cf]=X[Of]=X[kf]=X[Mf]=X[Df]=X[jf]=!1;function Hf(i){return Ce(i)&&Pn(i.length)&&!!X[ps(i)]}function Fn(i){return function(t){return i(t)}}var Yc=typeof M=="object"&&M&&!M.nodeType&&M,qs=Yc&&typeof module=="object"&&module&&!module.nodeType&&module,Yf=qs&&qs.exports===Yc,Ln=Yf&&wc.process,ms=function(){try{var i=qs&&qs.require&&qs.require("util").types;return i||Ln&&Ln.binding&&Ln.binding("util")}catch{}}(),Vc=ms&&ms.isTypedArray,Gc=Vc?Fn(Vc):Hf,Vf=Object.prototype,Gf=Vf.hasOwnProperty;function Nf(i,t){var e=qt(i),s=!e&&An(i),r=!e&&!s&&li(i),n=!e&&!s&&!r&&Gc(i),o=e||s||r||n,a=o?uf(i.length,String):[],c=a.length;for(var h in i)Gf.call(i,h)&&!(o&&(h=="length"||r&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||En(h,c)))&&a.push(h);return a}function Nc(i,t){return function(e){return i(t(e))}}var Uf=Nc(Object.keys,Object),$f=Object.prototype,qf=$f.hasOwnProperty;function Kf(i){if(!Rc(i))return Uf(i);var t=[];for(var e in Object(i))qf.call(i,e)&&e!="constructor"&&t.push(e);return t}function Jf(i){return hf(i)?Nf(i):Kf(i)}var Zf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qf=/^\w*$/;function tp(i,t){if(qt(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ci(i)?!0:Qf.test(i)||!Zf.test(i)||t!=null&&i in Object(t)}var Ks=Ve(Object,"create");function ep(){this.__data__=Ks?Ks(null):{},this.size=0}function sp(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var rp="__lodash_hash_undefined__",ip=Object.prototype,np=ip.hasOwnProperty;function op(i){var t=this.__data__;if(Ks){var e=t[i];return e===rp?void 0:e}return np.call(t,i)?t[i]:void 0}var ap=Object.prototype,cp=ap.hasOwnProperty;function hp(i){var t=this.__data__;return Ks?t[i]!==void 0:cp.call(t,i)}var lp="__lodash_hash_undefined__";function up(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Ks&&t===void 0?lp:t,this}function Ge(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}Ge.prototype.clear=ep,Ge.prototype.delete=sp,Ge.prototype.get=op,Ge.prototype.has=hp,Ge.prototype.set=up;function dp(){this.__data__=[],this.size=0}function ui(i,t){for(var e=i.length;e--;)if(In(i[e][0],t))return e;return-1}var gp=Array.prototype,fp=gp.splice;function pp(i){var t=this.__data__,e=ui(t,i);if(e<0)return!1;var s=t.length-1;return e==s?t.pop():fp.call(t,e,1),--this.size,!0}function mp(i){var t=this.__data__,e=ui(t,i);return e<0?void 0:t[e][1]}function vp(i){return ui(this.__data__,i)>-1}function yp(i,t){var e=this.__data__,s=ui(e,i);return s<0?(++this.size,e.push([i,t])):e[s][1]=t,this}function le(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}le.prototype.clear=dp,le.prototype.delete=pp,le.prototype.get=mp,le.prototype.has=vp,le.prototype.set=yp;var Js=Ve(Bt,"Map");function bp(){this.size=0,this.__data__={hash:new Ge,map:new(Js||le),string:new Ge}}function _p(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}function di(i,t){var e=i.__data__;return _p(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Tp(i){var t=di(this,i).delete(i);return this.size-=t?1:0,t}function xp(i){return di(this,i).get(i)}function Sp(i){return di(this,i).has(i)}function wp(i,t){var e=di(this,i),s=e.size;return e.set(i,t),this.size+=e.size==s?0:1,this}function ue(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}ue.prototype.clear=bp,ue.prototype.delete=Tp,ue.prototype.get=xp,ue.prototype.has=Sp,ue.prototype.set=wp;var Cp="Expected a function";function Rn(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(Cp);var e=function(){var s=arguments,r=t?t.apply(this,s):s[0],n=e.cache;if(n.has(r))return n.get(r);var o=i.apply(this,s);return e.cache=n.set(r,o)||n,o};return e.cache=new(Rn.Cache||ue),e}Rn.Cache=ue;var Op=500;function kp(i){var t=Rn(i,function(s){return e.size===Op&&e.clear(),s}),e=t.cache;return t}var Mp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Dp=/\\(\\)?/g,jp=kp(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(Mp,function(e,s,r,n){t.push(r?n.replace(Dp,"$1"):s||e)}),t});function Ep(i){return i==null?"":Dc(i)}function gi(i,t){return qt(i)?i:tp(i,t)?[i]:jp(Ep(i))}function Bn(i){if(typeof i=="string"||ci(i))return i;var t=i+"";return t=="0"&&1/i==-1/0?"-0":t}function Ip(i,t){t=gi(t,i);for(var e=0,s=t.length;i!=null&&e<s;)i=i[Bn(t[e++])];return e&&e==s?i:void 0}function Uc(i,t){for(var e=-1,s=t.length,r=i.length;++e<s;)i[r+e]=t[e];return i}var $c=kt?kt.isConcatSpreadable:void 0;function Pp(i){return qt(i)||An(i)||!!($c&&i&&i[$c])}function Ap(i,t,e,s,r){var n=-1,o=i.length;for(e||(e=Pp),r||(r=[]);++n<o;){var a=i[n];e(a)?Uc(r,a):r[r.length]=a}return r}function Wn(i){var t=i==null?0:i.length;return t?Ap(i):[]}function Fp(i){return Qg(af(i,void 0,Wn),i+"")}var Lp=Nc(Object.getPrototypeOf,Object);function Rp(){this.__data__=new le,this.size=0}function Bp(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}function Wp(i){return this.__data__.get(i)}function Xp(i){return this.__data__.has(i)}var zp=200;function Hp(i,t){var e=this.__data__;if(e instanceof le){var s=e.__data__;if(!Js||s.length<zp-1)return s.push([i,t]),this.size=++e.size,this;e=this.__data__=new ue(s)}return e.set(i,t),this.size=e.size,this}function de(i){var t=this.__data__=new le(i);this.size=t.size}de.prototype.clear=Rp,de.prototype.delete=Bp,de.prototype.get=Wp,de.prototype.has=Xp,de.prototype.set=Hp;var qc=typeof M=="object"&&M&&!M.nodeType&&M,Kc=qc&&typeof module=="object"&&module&&!module.nodeType&&module,Yp=Kc&&Kc.exports===qc,Jc=Yp?Bt.Buffer:void 0;Jc&&Jc.allocUnsafe;function Vp(i,t){return i.slice()}function Gp(i,t){for(var e=-1,s=i==null?0:i.length,r=0,n=[];++e<s;){var o=i[e];t(o,e,i)&&(n[r++]=o)}return n}function Np(){return[]}var Up=Object.prototype,$p=Up.propertyIsEnumerable,Zc=Object.getOwnPropertySymbols,qp=Zc?function(i){return i==null?[]:(i=Object(i),Gp(Zc(i),function(t){return $p.call(i,t)}))}:Np;function Kp(i,t,e){var s=t(i);return qt(i)?s:Uc(s,e(i))}function Xn(i){return Kp(i,Jf,qp)}var zn=Ve(Bt,"DataView"),Hn=Ve(Bt,"Promise"),Yn=Ve(Bt,"Set"),Qc="[object Map]",Jp="[object Object]",th="[object Promise]",eh="[object Set]",sh="[object WeakMap]",rh="[object DataView]",Zp=Ye(zn),Qp=Ye(Js),tm=Ye(Hn),em=Ye(Yn),sm=Ye(jn),Wt=ps;(zn&&Wt(new zn(new ArrayBuffer(1)))!=rh||Js&&Wt(new Js)!=Qc||Hn&&Wt(Hn.resolve())!=th||Yn&&Wt(new Yn)!=eh||jn&&Wt(new jn)!=sh)&&(Wt=function(i){var t=ps(i),e=t==Jp?i.constructor:void 0,s=e?Ye(e):"";if(s)switch(s){case Zp:return rh;case Qp:return Qc;case tm:return th;case em:return eh;case sm:return sh}return t});var rm=Object.prototype,im=rm.hasOwnProperty;function nm(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&im.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var fi=Bt.Uint8Array;function Vn(i){var t=new i.constructor(i.byteLength);return new fi(t).set(new fi(i)),t}function om(i,t){var e=Vn(i.buffer);return new i.constructor(e,i.byteOffset,i.byteLength)}var am=/\w*$/;function cm(i){var t=new i.constructor(i.source,am.exec(i));return t.lastIndex=i.lastIndex,t}var ih=kt?kt.prototype:void 0,nh=ih?ih.valueOf:void 0;function hm(i){return nh?Object(nh.call(i)):{}}function lm(i,t){var e=Vn(i.buffer);return new i.constructor(e,i.byteOffset,i.length)}var um="[object Boolean]",dm="[object Date]",gm="[object Map]",fm="[object Number]",pm="[object RegExp]",mm="[object Set]",vm="[object String]",ym="[object Symbol]",bm="[object ArrayBuffer]",_m="[object DataView]",Tm="[object Float32Array]",xm="[object Float64Array]",Sm="[object Int8Array]",wm="[object Int16Array]",Cm="[object Int32Array]",Om="[object Uint8Array]",km="[object Uint8ClampedArray]",Mm="[object Uint16Array]",Dm="[object Uint32Array]";function jm(i,t,e){var s=i.constructor;switch(t){case bm:return Vn(i);case um:case dm:return new s(+i);case _m:return om(i);case Tm:case xm:case Sm:case wm:case Cm:case Om:case km:case Mm:case Dm:return lm(i);case gm:return new s;case fm:case vm:return new s(i);case pm:return cm(i);case mm:return new s;case ym:return hm(i)}}function Em(i){return typeof i.constructor=="function"&&!Rc(i)?Gg(Lp(i)):{}}var Im="[object Map]";function Pm(i){return Ce(i)&&Wt(i)==Im}var oh=ms&&ms.isMap,Am=oh?Fn(oh):Pm,Fm="[object Set]";function Lm(i){return Ce(i)&&Wt(i)==Fm}var ah=ms&&ms.isSet,Rm=ah?Fn(ah):Lm,ch="[object Arguments]",Bm="[object Array]",Wm="[object Boolean]",Xm="[object Date]",zm="[object Error]",hh="[object Function]",Hm="[object GeneratorFunction]",Ym="[object Map]",Vm="[object Number]",lh="[object Object]",Gm="[object RegExp]",Nm="[object Set]",Um="[object String]",$m="[object Symbol]",qm="[object WeakMap]",Km="[object ArrayBuffer]",Jm="[object DataView]",Zm="[object Float32Array]",Qm="[object Float64Array]",tv="[object Int8Array]",ev="[object Int16Array]",sv="[object Int32Array]",rv="[object Uint8Array]",iv="[object Uint8ClampedArray]",nv="[object Uint16Array]",ov="[object Uint32Array]",W={};W[ch]=W[Bm]=W[Km]=W[Jm]=W[Wm]=W[Xm]=W[Zm]=W[Qm]=W[tv]=W[ev]=W[sv]=W[Ym]=W[Vm]=W[lh]=W[Gm]=W[Nm]=W[Um]=W[$m]=W[rv]=W[iv]=W[nv]=W[ov]=!0,W[zm]=W[hh]=W[qm]=!1;function pi(i,t,e,s,r,n){var o;if(o!==void 0)return o;if(!Kt(i))return i;var a=qt(i);if(a)o=nm(i);else{var c=Wt(i),h=c==hh||c==Hm;if(li(i))return Vp(i);if(c==lh||c==ch||h&&!r)o=h?{}:Em(i);else{if(!W[c])return r?i:{};o=jm(i,c)}}n||(n=new de);var l=n.get(i);if(l)return l;n.set(i,o),Rm(i)?i.forEach(function(g){o.add(pi(g,t,e,g,i,n))}):Am(i)&&i.forEach(function(g,f){o.set(f,pi(g,t,e,f,i,n))});var u=Xn,d=a?void 0:u(i);return tf(d||i,function(g,f){d&&(f=g,g=i[f]),Fc(o,f,pi(g,t,e,f,i,n))}),o}var av=1,cv=4;function Ne(i){return pi(i,av|cv)}var hv="__lodash_hash_undefined__";function lv(i){return this.__data__.set(i,hv),this}function uv(i){return this.__data__.has(i)}function mi(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new ue;++t<e;)this.add(i[t])}mi.prototype.add=mi.prototype.push=lv,mi.prototype.has=uv;function dv(i,t){for(var e=-1,s=i==null?0:i.length;++e<s;)if(t(i[e],e,i))return!0;return!1}function gv(i,t){return i.has(t)}var fv=1,pv=2;function uh(i,t,e,s,r,n){var o=e&fv,a=i.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var h=n.get(i),l=n.get(t);if(h&&l)return h==t&&l==i;var u=-1,d=!0,g=e&pv?new mi:void 0;for(n.set(i,t),n.set(t,i);++u<a;){var f=i[u],p=t[u];if(s)var m=o?s(p,f,u,t,i,n):s(f,p,u,i,t,n);if(m!==void 0){if(m)continue;d=!1;break}if(g){if(!dv(t,function(b,T){if(!gv(g,T)&&(f===b||r(f,b,e,s,n)))return g.push(T)})){d=!1;break}}else if(!(f===p||r(f,p,e,s,n))){d=!1;break}}return n.delete(i),n.delete(t),d}function mv(i){var t=-1,e=Array(i.size);return i.forEach(function(s,r){e[++t]=[r,s]}),e}function vv(i){var t=-1,e=Array(i.size);return i.forEach(function(s){e[++t]=s}),e}var yv=1,bv=2,_v="[object Boolean]",Tv="[object Date]",xv="[object Error]",Sv="[object Map]",wv="[object Number]",Cv="[object RegExp]",Ov="[object Set]",kv="[object String]",Mv="[object Symbol]",Dv="[object ArrayBuffer]",jv="[object DataView]",dh=kt?kt.prototype:void 0,Gn=dh?dh.valueOf:void 0;function Ev(i,t,e,s,r,n,o){switch(e){case jv:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case Dv:return!(i.byteLength!=t.byteLength||!n(new fi(i),new fi(t)));case _v:case Tv:case wv:return In(+i,+t);case xv:return i.name==t.name&&i.message==t.message;case Cv:case kv:return i==t+"";case Sv:var a=mv;case Ov:var c=s&yv;if(a||(a=vv),i.size!=t.size&&!c)return!1;var h=o.get(i);if(h)return h==t;s|=bv,o.set(i,t);var l=uh(a(i),a(t),s,r,n,o);return o.delete(i),l;case Mv:if(Gn)return Gn.call(i)==Gn.call(t)}return!1}var Iv=1,Pv=Object.prototype,Av=Pv.hasOwnProperty;function Fv(i,t,e,s,r,n){var o=e&Iv,a=Xn(i),c=a.length,h=Xn(t),l=h.length;if(c!=l&&!o)return!1;for(var u=c;u--;){var d=a[u];if(!(o?d in t:Av.call(t,d)))return!1}var g=n.get(i),f=n.get(t);if(g&&f)return g==t&&f==i;var p=!0;n.set(i,t),n.set(t,i);for(var m=o;++u<c;){d=a[u];var b=i[d],T=t[d];if(s)var x=o?s(T,b,d,t,i,n):s(b,T,d,i,t,n);if(!(x===void 0?b===T||r(b,T,e,s,n):x)){p=!1;break}m||(m=d=="constructor")}if(p&&!m){var S=i.constructor,O=t.constructor;S!=O&&"constructor"in i&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof O=="function"&&O instanceof O)&&(p=!1)}return n.delete(i),n.delete(t),p}var Lv=1,gh="[object Arguments]",fh="[object Array]",vi="[object Object]",Rv=Object.prototype,ph=Rv.hasOwnProperty;function Bv(i,t,e,s,r,n){var o=qt(i),a=qt(t),c=o?fh:Wt(i),h=a?fh:Wt(t);c=c==gh?vi:c,h=h==gh?vi:h;var l=c==vi,u=h==vi,d=c==h;if(d&&li(i)){if(!li(t))return!1;o=!0,l=!1}if(d&&!l)return n||(n=new de),o||Gc(i)?uh(i,t,e,s,r,n):Ev(i,t,c,e,s,r,n);if(!(e&Lv)){var g=l&&ph.call(i,"__wrapped__"),f=u&&ph.call(t,"__wrapped__");if(g||f){var p=g?i.value():i,m=f?t.value():t;return n||(n=new de),r(p,m,e,s,n)}}return d?(n||(n=new de),Fv(i,t,e,s,r,n)):!1}function mh(i,t,e,s,r){return i===t?!0:i==null||t==null||!Ce(i)&&!Ce(t)?i!==i&&t!==t:Bv(i,t,e,s,mh,r)}function Wv(i,t){return i!=null&&t in Object(i)}function Xv(i,t,e){t=gi(t,i);for(var s=-1,r=t.length,n=!1;++s<r;){var o=Bn(t[s]);if(!(n=i!=null&&e(i,o)))break;i=i[o]}return n||++s!=r?n:(r=i==null?0:i.length,!!r&&Pn(r)&&En(o,r)&&(qt(i)||An(i)))}function zv(i,t){return i!=null&&Xv(i,t,Wv)}var Nn=function(){return Bt.Date.now()},Hv="Expected a function",Yv=Math.max,Vv=Math.min;function Gv(i,t,e){var s,r,n,o,a,c,h=0,l=!1,u=!1,d=!0;if(typeof i!="function")throw new TypeError(Hv);t=Ec(t)||0,Kt(e)&&(l=!!e.leading,u="maxWait"in e,n=u?Yv(Ec(e.maxWait)||0,t):n,d="trailing"in e?!!e.trailing:d);function g(k){var j=s,D=r;return s=r=void 0,h=k,o=i.apply(D,j),o}function f(k){return h=k,a=setTimeout(b,t),l?g(k):o}function p(k){var j=k-c,D=k-h,F=t-j;return u?Vv(F,n-D):F}function m(k){var j=k-c,D=k-h;return c===void 0||j>=t||j<0||u&&D>=n}function b(){var k=Nn();if(m(k))return T(k);a=setTimeout(b,p(k))}function T(k){return a=void 0,d&&s?g(k):(s=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),h=0,s=c=r=a=void 0}function S(){return a===void 0?o:T(Nn())}function O(){var k=Nn(),j=m(k);if(s=arguments,r=this,c=k,j){if(a===void 0)return f(c);if(u)return clearTimeout(a),a=setTimeout(b,t),g(c)}return a===void 0&&(a=setTimeout(b,t)),o}return O.cancel=x,O.flush=S,O}function Nv(i,t){return mh(i,t)}function Uv(i,t,e,s){if(!Kt(i))return i;t=gi(t,i);for(var r=-1,n=t.length,o=n-1,a=i;a!=null&&++r<n;){var c=Bn(t[r]),h=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return i;if(r!=o){var l=a[c];h=void 0,h===void 0&&(h=Kt(l)?l:En(t[r+1])?[]:{})}Fc(a,c,h),a=a[c]}return i}function $v(i,t,e){for(var s=-1,r=t.length,n={};++s<r;){var o=t[s],a=Ip(i,o);e(a,o)&&Uv(n,gi(o,i),a)}return n}function qv(i,t){return $v(i,t,function(e,s){return zv(i,s)})}var Kv=Fp(function(i,t){return i==null?{}:qv(i,t)}),Jv="Expected a function";function Zv(i,t,e){var s=!0,r=!0;if(typeof i!="function")throw new TypeError(Jv);return Kt(e)&&(s="leading"in e?!!e.leading:s,r="trailing"in e?!!e.trailing:r),Gv(i,t,{leading:s,maxWait:t,trailing:r})}class Qv{addTrackItem(t){const e=cg(t,{tScale:this.tScale,sizesMap:this.sizesMap});this.add(e)}alignItemsToTrack(){this.pauseEventListeners();const t=new Map(this.getObjects("Track").map(r=>[r.id,r])),e=this.getTrackItems(),s=this.getObjects("Transition");this.trackItemIds.forEach(r=>{const n=this.tracks.find(c=>c.items.includes(r));if(!n)return;const o=t.get(n.id),a=this.getTrackItems().find(c=>c.id===r);a&&o&&(a.isMain=o.magnetic,this.trackItemsMap[r].isMain=o.magnetic,a.set({top:o.top}),a.setCoords())}),t.forEach(r=>{r.items=e.filter(n=>n.top===r.top).map(n=>n.id)}),s.forEach(r=>{const n=r.fromId,o=e.find(a=>a.id===n);o&&(r.set({top:o.top}),r.setCoords())}),this.resumeEventListeners()}updateTrackItemsToHistory(){this.pauseEventListeners(),this.trackItemIds.forEach(t=>{const e=this.tracks.find(c=>c.items.includes(t)),s=this.getObjects().find(c=>c.id===(e==null?void 0:e.id)).top,r=this.trackItemsMap[t],n=this.getObjects().find(c=>c.id===t),o=nt(r.display.from,this.tScale),a=nt(r.display.to-r.display.from,this.tScale,r.playbackRate);if(n.set({left:o,width:a,top:s}),n instanceof $t){const c=n.display.to-n.display.from;n.setDuration?n.setDuration(c):n.set({duration:c}),r.trim=n.trim,r.display=n.display}n.setCoords()}),this.requestRenderAll(),this.resumeEventListeners()}deleteTrackItemToHistory(t){this.getObjects().filter(e=>t.includes(e.id)).map(e=>this.remove(e)),this.alignItemsToTrack(),this.requestRenderAll()}uodateTrackItemIdsOrdering(){const t=this.getTrackItems();t.sort((e,s)=>e.top-s.top),this.trackItemIds=t.map(e=>e.id).reverse()}selectTrackItemByIds(t){const e=this.getActiveObjects().map(n=>n.id);if(Nv(e,t))return;const r=this.getObjects(...ys.objectTypes,"Transition").filter(n=>t.includes(n.id));if(!r.length)this.discardActiveObject();else if(r.length===1)this.setActiveObject(r[0]);else{const n=new Ct(r);this.setActiveObject(n)}this.requestRenderAll()}synchronizeTrackItemsState(){this.pauseEventListeners();const t=this.getTrackItems(),e={};t.forEach(s=>{const{id:r,left:n,width:o}=s,a=this.trackItemsMap[r],c=B(n,this.tScale),h=B(o,this.tScale),l={from:c,to:c+h},u={display:l};s instanceof $t&&(u.trim=s.trim),s.display=l,e[r]={...a,...u}}),this.trackItemsMap={...this.trackItemsMap,...e},this.resumeEventListeners()}deleteTrackItemById(t){const e=t,s=this.getObjects().filter(a=>t.includes(a.id)),r=Us(this.tracks,e),n={};Object.keys(this.trackItemsMap).forEach(a=>{e.includes(a)||(n[a]=this.trackItemsMap[a])});const o=this.trackItemIds.filter(a=>!e.includes(a));this.tracks=r,this.trackItemsMap=n,this.trackItemIds=o,this.discardActiveObject(),this.remove(...s),this.renderTracks(),this.alignItemsToTrack()}deleteActiveTrackItem(){const t=this.getActiveObjects();if(!t.length)return!1;const e=t.map(o=>o.id),s=Us(this.tracks,e),r={};Object.keys(this.trackItemsMap).forEach(o=>{e.includes(o)||(r[o]=this.trackItemsMap[o])});const n=this.trackItemIds.filter(o=>!e.includes(o));this.tracks=s,this.trackItemsMap=r,this.trackItemIds=n,this.discardActiveObject(),this.remove(...t),this.setActiveIds([]),this.renderTracks(),this.alignItemsToTrack(),this.updateState({updateHistory:!0,kind:"remove"})}updateTrackItemCoords(t){const e=t?this.getActiveObjects().map(s=>s.id):[];!t&&this.pauseEventListeners(),this.trackItemIds.forEach(s=>{if(e.includes(s))return;const r=this.getObjects().find(c=>c.id===s),n=this.trackItemsMap[s],o=nt(n.display.from,this.tScale),a=nt(n.display.to-n.display.from,this.tScale);r.set({left:o,width:a}),r.setCoords()}),!t&&this.resumeEventListeners()}getTrackItems(){return this.getObjects(...ys.objectTypes)}setTrackItemCoords(){this.getTrackItems().forEach(t=>{t.setCoords()})}setActiveTrackItemCoords(){this.getActiveObjects().forEach(e=>e.setCoords())}}const vh=i=>{switch(i){case"top":return 1e3;case"bottom":return 1e3;case"center":return 8;default:return 1e3}};class t0{findOrCreateTrack(t,{trackId:e,trackIndex:s}){if(e){const o=this.tracks.find(a=>a.id===e);if(o)return o.items.push(t.id),e}const r=this.getItemAccepts(t.type),n={id:Ns(),items:[t.id],type:t.type,accepts:r,magnetic:!1,static:!1};return s!==void 0?this.tracks.splice(s,0,n):this.tracks.push(n),this.renderTracks(),n.id}removeTracks(){this.getObjects("Track","Helper").forEach(e=>this.remove(e))}renderTracks(){this.filterEmptyTracks(),this.removeTracks();const t=this.width,e=this.tracks.flatMap(a=>[a,{id:`helper-${a.id}`,type:"helper",items:[],accepts:[]}]).slice(0,-1);let s=-970;const r=C.getClass("Helper")||ce,n=new r({top:s,selectable:!1,evented:!1,tScale:this.tScale,id:"helper-line-top",width:t,kind:"top",height:1e3,metadata:{}});s+=vh("top"),this.insertAt(0,n),e.forEach((a,c)=>{if(a.type==="helper"){const h=vh("center"),l=new r({id:a.id,top:s,tScale:this.tScale,width:t,height:h,metadata:{order:(c+1)/2},kind:"center"});s+=h,this.insertAt(0,l)}else{const h=this.getItemSize(a.type),l=C.getClass("Track")||Lt,u=this.getItemAccepts(a.type),d=new l({id:a.id,top:s,left:0,height:h,width:t,tScale:this.tScale,accepts:u,items:a.items,magnetic:a.magnetic,static:a.static});s+=h,this.insertAt(0,d)}});const o=new r({id:"helper-line-bottom",top:s,selectable:!1,evented:!1,tScale:this.tScale,width:t,kind:"bottom",height:1e3,metadata:{}});this.insertAt(0,o)}filterEmptyTracks(){const t=new Set;this.tracks=this.tracks.filter(e=>(e.items.length||e.static)&&!t.has(e.id)?(t.add(e.id),!0):!1)}refreshTrackLayout(){const t=this.bounding.width+this.spacing.right;this.getObjects("Track","Helper").forEach(e=>{e.updateCoords(t),e.setCoords()})}adjustMagneticTrack(){this.pauseEventListeners();const t=this.tracks.filter(e=>e.magnetic);t.length>0&&t.forEach(e=>{const s=e.accepts||[],r=this.getObjects(...s).filter(o=>e.items.includes(o.id)).sort((o,a)=>o.left-a.left);let n=0;r.forEach(o=>{o.left=n,n+=o.width})}),this.resumeEventListeners()}}function yh(i){const t=this,e=i.target,s=i.transform;if(s.action==="resizing"){const r=t.getObjects().filter(l=>l!==e&&!["Track","Helper","Transition","Placeholder"].includes(l.type)),n=10,o=e.left,a=e.width*e.scaleX,c=o+a;let h=!1;r.forEach(l=>{if(h)return;const u=l.getBoundingRect(),d=u.left,g=u.left+u.width;if(s.corner==="mr"){const f=Math.abs(c-g),p=Math.abs(c-d),m=B(1,e.tScale);if(f<n)if(e instanceof $t){const b=g-e.left,T=b-a,x=B(T,e.tScale,e.playbackRate),S=e.trim.to+x;if(b<m||b<m)return;S<=e.duration&&(e.set({width:b,scaleX:1}),e.trim.to=S,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({width:g-e.left,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0;else if(p<n)if(e instanceof $t){const b=d-e.left,T=b-a,x=B(T,e.tScale,e.playbackRate),S=e.trim.to+x;if(b<m)return;S<=e.duration&&(e.set({width:b,scaleX:1}),e.trim.to=S,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({width:d-e.left,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0}else if(s.corner==="ml"){const f=Math.abs(o-d),p=Math.abs(o-g);if(f<n)if(e instanceof $t){const m=c-d,b=m-a,T=B(b,e.tScale,e.playbackRate),x=e.trim.from-T;x>=0&&(e.set({left:d,width:m,scaleX:1}),e.trim.from=x,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({left:d,width:c-d,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0;else if(p<n)if(e instanceof $t){const m=c-g,b=m-a,T=B(b,e.tScale,e.playbackRate),x=e.trim.from-T;x>=0&&(e.set({left:g,width:m,scaleX:1}),e.trim.from=x,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({left:g,width:c-g,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0}}),h&&(e.setCoords(),t.requestRenderAll())}}function e0(i){i.on("object:resizing",yh.bind(i))}function s0(i){i.off("object:resizing",yh.bind(i))}const Zs=100,Un=0,yi=5,bh=3,r0=25,vs={scrollInterval:null};function _h(i){const t=r0-bh,e=(Zs-i)/Zs;return bh+t*e}function i0(i,t){vs.scrollInterval&&clearInterval(vs.scrollInterval);const e=t.target,s=e.getBoundingRect();vs.scrollInterval=setInterval(()=>{const r=i.viewportTransform,n=i.getViewportPoint(t.e);if(n.x>i.width-Zs&&e.left+s.width<i.bounding.width){const o=_h(i.width-n.x);e.set("left",e.left+o),i.setViewportPos(r[4]-o,r[5])}if(n.x<Zs&&e.left>0&&r[4]<Zs&&r[4]<i.spacing.left){const o=_h(n.x);e.set("left",e.left-o),i.setViewportPos(r[4]+o,r[5])}n.y>i.height-Un&&e.top+s.height<i.bounding.height+80&&(e.set("top",e.top+yi),i.setViewportPos(r[4],r[5]-yi)),n.y<Un&&e.top>-80&&-r[5]>Un&&(e.set("top",e.top-yi),i.setViewportPos(r[4],r[5]+yi)),e.setCoords(),i.requestRenderAll()},16)}function n0(){vs.scrollInterval&&(clearInterval(vs.scrollInterval),vs.scrollInterval=null)}function Th(){n0()}function xh(i){i0(this,i)}function o0(i){console.log("addScrollEvents"),i.on("mouse:up",Th),i.on("object:moving",xh.bind(i))}function a0(i){i.off("mouse:up",Th),i.off("object:moving",xh.bind(i))}function Sh(i){const t=i.target,e=i.target.canvas;if(i.action==="resizing"&&t instanceof Rt&&e){const s=t.id,r=e.getObjects("Transition").find(n=>n.id===s);if(r&&r instanceof Rt){const n=Ne(this.transitionsMap),o={...n,[s]:{...n[s],width:r.width,duration:r.duration}};this.transitionsMap=o,this.updateState()}}}function c0(i){i.on("object:modified",Sh)}function h0(i){i.off("object:modified",Sh)}const wh={canvas:null,enableGuideRedraw:!0,isPointerOverHelperTrack:!1,draggingOverTrack:null,placeholderMovingObjects:[],primaryMovingObjects:[],secondaryMovingObjects:[],objectInitialPositions:{},originTrack:{},trackToItemsMap:{},activeTrackToItemsMap:{},trackTopToIdMap:{},trackTops:[],activeObjects:[],primaryTracks:{},secondaryTracks:{},isDragOver:!1,initialTrackPoints:[],updateItemsInTrack:null,orderNormalTrack:!1},Q=()=>wh,ct=i=>{Object.assign(wh,i)},Ch=10,bi=(i,t)=>{t.forEach(e=>e.isAlignmentAuxiliary&&i.remove(e))},Oh=(i,t)=>{const e=[],s=[];return t.getObjects().filter(r=>r.visible).forEach(r=>{if(i.find(o=>o.id===r.id)||r.isAlignmentAuxiliary)return;const n=r.getBoundingRect();e.push(Eh(n.left,n.width,n.top,n.height)),s.push(Eh(n.top,n.height,n.left,n.width))}),{vertical:e.flat(),horizontal:[]}},kh=(i,t)=>{const e=[],s=[];i.vertical.forEach(a=>{t.vertical.forEach(c=>{const h=Math.abs(a.val-c.guide);h<Ch&&e.push({lineGuide:a.val,diff:h,orientation:"V",snap:c.snap,offset:c.offset,targetDim:{start:a.start,end:a.end}})})}),i.horizontal.forEach(a=>{t.horizontal.forEach(c=>{const h=Math.abs(a.val-c.guide);h<Ch&&s.push({lineGuide:a.val,diff:h,orientation:"H",snap:c.snap,offset:c.offset,targetDim:{start:a.start,end:a.end}})})});const r=[],n=e.sort((a,c)=>a.diff-c.diff)[0],o=s.sort((a,c)=>a.diff-c.diff)[0];return n&&r.push({lineGuide:n.lineGuide,offset:n.offset,orientation:"V",snap:n.snap,targetDim:n.targetDim}),o&&r.push({lineGuide:o.lineGuide,offset:o.offset,orientation:"H",snap:o.snap,targetDim:o.targetDim}),r},Mh=(i,t,e)=>{i.forEach(s=>{const r=l0(e.getZoom());s.orientation==="H"?e.add(Dh([0,s.lineGuide-r.strokeWidth/2,2e3,s.lineGuide-r.strokeWidth/2],{...r,stroke:e.guideLineColor})):s.orientation==="V"&&e.add(Dh([s.lineGuide-r.strokeWidth/2,0,s.lineGuide-r.strokeWidth/2,2e3],{...r,stroke:e.guideLineColor}))})},l0=i=>({strokeWidth:2/i}),Dh=(i,t)=>new Se(i,{...t,strokeLineCap:"square",excludeFromExport:!0,isAlignmentAuxiliary:!0,selectable:!1,objectCaching:!1}),jh=i=>{const t=i.getBoundingRect();return{vertical:[{guide:Math.round(t.left),offset:Math.round(i.left-t.left),snap:"start"},{guide:Math.round(t.left+t.width),offset:Math.round(i.left-t.left-t.width),snap:"end"}],horizontal:[{guide:Math.round(t.top),offset:Math.round(i.top-t.top),snap:"start"},{guide:Math.round(t.top+t.height),offset:Math.round(i.top-t.top-t.height),snap:"end"}]}},Eh=(i,t,e,s)=>[i,i+t].map(n=>({val:n,start:e,end:e+s})),Ih=(i,t)=>{i.remove(...t),t=[]},Ph=i=>{i.forEach(t=>t.setSelected(!1))},Ah=i=>i instanceof ce,u0=i=>Object.assign({},{left:16,right:80},i),d0=["touchstart","touchmove","touchend"],g0=i=>d0.includes(i.type)||i.pointerType==="touch";function Fh(i){const t=this;if(!t)return;const s=Q().enableGuideRedraw,r=t.getScenePoint(i.e),n=t.getObjects("Helper","Track"),o=n.find(f=>{const p=f.getBoundingRect();return r.x>=p.left&&r.x<=p.left+p.width&&r.y>=p.top&&r.y<=p.top+p.height});ct({draggingOverTrack:o}),n.forEach(f=>{Ah(f)&&(f===o?f.setSelected(!0):f.setSelected(!1))}),Ah(o)?ct({isPointerOverHelperTrack:!0}):ct({isPointerOverHelperTrack:!1});const a=t.getObjects(),c=i.target,h=c.getBoundingRect();c.setCoords();const l=[c,...t.getActiveObjects(),...t.getObjects("Track","Helper","Transition","Placeholder")],u=Oh(l,t),d=jh(c),g=kh(u,d);s&&(bi(t,a),g.length&&Mh(g,h,t),ct({enableGuideRedraw:!1}),setTimeout(()=>ct({enableGuideRedraw:!0}),50)),g.forEach(f=>{f.orientation==="V"?c.left=f.lineGuide+f.offset:c.top=f.lineGuide+f.offset})}function Lh(i){const t=i.target.canvas;t&&(bi(t,t.getObjects()),Ph(t.getObjects("Helper")),ct({draggingOverTrack:null,isPointerOverHelperTrack:!1}))}function Rh(i){var a;const t=this,e=t.getObjects(),s=i.target,r=i.transform,n=(a=t._currentTransform)==null?void 0:a.corner,o=s.getBoundingRect();if(r.action==="resizing"){const c=[s,...t.getActiveObjects(),...t.getObjects("Track","Helper","Transition","Placeholder")],h=Oh(c,t),l=h.vertical.filter(g=>{const f=g.val;if(n==="ml")return f<=o.left;if(n==="mr")return f>=o.left+o.width});h.vertical=l;const u=jh(s),d=kh(h,u);bi(t,e),d.length&&Mh(d,o,t)}}function f0(i){i.on("object:moving",Fh.bind(i)),i.on("object:modified",Lh.bind(i)),i.on("object:resizing",Rh.bind(i))}function p0(i){i.off("object:moving",Fh.bind(i)),i.off("object:modified",Lh.bind(i)),i.off("object:resizing",Rh.bind(i))}function $n(i,t,e){const s=i.indexOf(t),r=i.indexOf(e);return s===-1||r===-1?null:r-s}function Bh(i,t){const e=t.sort((r,n)=>r.tempIndex-n.tempIndex),s=[];for(const r of e)r.tempIndex<0&&s.push(r);s.push(i);for(const r of e)r.tempIndex>=0&&s.push(r);return s}function Wh(i){const t=Q(),e=t.canvas;ct({activeTrackToItemsMap:{},primaryTracks:{},secondaryTracks:{},trackTops:[],trackToItemsMap:{},activeObjects:[],trackTopToIdMap:{},isDragOver:!1,initialTrackPoints:[],updateItemsInTrack:null}),e.trackIdAfterTransform="",e.positionAfterTransform={};const s=e.getActiveObject(),r=s instanceof Ct?s.getObjects():[s];ct({activeObjects:r});const n=e.getScenePoint(i.e),o=e.getObjects("Track"),a=e.getActiveObjects().map(u=>u.id);let h=o.filter(u=>{const d=u.items;return a.some(g=>d.includes(g))}).find(u=>{const d=u.getBoundingRect();return n.x>=d.left&&n.x<=d.left+d.width&&n.y>=d.top&&n.y<=d.top+d.height});ct({originTrack:h});const l=e.getObjects(...this.itemTypes);o.forEach(u=>{const d=l.filter(g=>u.items.includes(g.id));t.trackToItemsMap[u.id]=d,t.trackTopToIdMap[u.top]=u.id,t.trackTops.push(u.top)}),t.trackTops.sort((u,d)=>u-d),r.forEach(u=>{const d=o.find(f=>f.items.includes(u.id));if(!d)return;const g=d.id;t.activeTrackToItemsMap[g]?t.activeTrackToItemsMap[g].push(u):t.activeTrackToItemsMap[g]=[u]}),t.primaryMovingObjects=r.filter(u=>{const d=u.getBoundingRect();return n.y>=d.top&&n.y<=d.top+d.height&&!(u instanceof Rt)}),t.primaryMovingObjects.length!==0&&(t.primaryMovingObjects.forEach(u=>{const d=u.getBoundingRect().top,g=t.trackTopToIdMap[d];if(t.primaryTracks[g])t.primaryTracks[g].objects.push(u);else{const f=$n(t.trackTops,h==null?void 0:h.top,d);t.primaryTracks[g]={objects:[u],index:f}}}),t.primaryMovingObjects=t.primaryMovingObjects.sort((u,d)=>u.left-d.left),t.secondaryMovingObjects=r.filter(u=>!t.primaryMovingObjects.includes(u)),t.secondaryMovingObjects.forEach(u=>{const d=u.getBoundingRect().top,g=t.trackTopToIdMap[u.getBoundingRect().top];if(t.secondaryTracks[g])t.secondaryTracks[g].objects.push(u);else{const f=$n(t.trackTops,h.top,d);t.secondaryTracks[g]={objects:[u],index:f}}}),h&&(e.trackOriginBeforeTransform=h.id),s&&(e.positionBeforeTransform={top:s.top,left:s.left}),i.transform.action==="drag"&&(t.placeholderMovingObjects=t.primaryMovingObjects.map(u=>{const d=u.getBoundingRect();t.objectInitialPositions[u.id]={top:d.top,left:d.left};const g=new ls({id:`${u.id}-placeholder`,left:d.left,top:d.top,width:d.width,height:d.height});return g.draggedObject=u,g}),e.add(...t.placeholderMovingObjects)))}function m0(i){i.on("before:transform",Wh.bind(i))}function v0(i){i.off("before:transform",Wh.bind(i))}const Cs=class Cs extends Z{constructor(e){super(e);w(this,"duration");w(this,"fromId");w(this,"toId");w(this,"itemType","none");w(this,"isSelected",!1);Object.assign(this,Cs.ownDefaults),this.id=e.id}static createControls(){return{controls:kn()}}static getDefaults(){return{...super.getDefaults(),...Cs.ownDefaults}}updateCoords(){const e=this.canvas;if(!e)return;const s=e.getObjects().find(o=>o.id===this.fromId);if(!s)return;const r=nt(this.duration,this.tScale),n=s.left+s.width-r/2;this.set({width:r,left:n})}_render(e){super._render(e),this.drawTextIdentity(e),this.updateSelected(e)}drawTextIdentity(e){const s=new Path2D("M3 5.30359C3 3.93159 4.659 3.24359 5.629 4.21359L11.997 10.5826L10.583 11.9966L5 6.41359V17.5856L10.586 11.9996L10.583 11.9966L11.997 10.5826L12 10.5856L18.371 4.21459C19.341 3.24459 21 3.93159 21 5.30359V18.6956C21 20.0676 19.341 20.7556 18.371 19.7856L12 13.5L13.414 11.9996L19 17.5866V6.41359L13.414 11.9996L13.421 12.0056L12.006 13.4206L12 13.4136L5.629 19.7846C4.659 20.7546 3 20.0676 3 18.6956V5.30359Z");e.save(),e.translate(-12,-12),e.fillStyle="#ffffff",e.fill(s),e.restore()}setSelected(e){this.isSelected=e,this.set({dirty:!0})}updateSelected(e){this.isSelected&&(e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.strokeStyle=He,e.stroke(),e.restore())}};w(Cs,"type","TransitionGuide"),w(Cs,"ownDefaults",{objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:1.5,fill:"rgba(0,0,0, 0.85)",borderOpacityWhenMoving:1,hoverCursor:"default",lockMovementX:!0,lockMovementY:!0,duration:1500,rx:8,ry:8});let Qs=Cs;const y0=i=>{const{trackItemIds:t,transitionsMap:e,trackItemsMap:s}=i,r=new Map;Object.values(e).forEach(h=>{var g,f;const{fromId:l,toId:u,kind:d}=h;d!=="none"&&(r.has(l)||r.set(l,[]),r.has(u)||r.set(u,[]),(g=r.get(l))==null||g.push(h),(f=r.get(u))==null||f.push(h))});const n=[],o=new Set,a=h=>{const l=[];let u=h;for(;u&&!o.has(u);){o.add(u);const d=s[u];l.push(d);const g=Object.values(e).find(f=>f.fromId===u&&f.kind!=="none");if(!g)break;l.push(g),u=g.toId}return l},c=Object.values(e).filter(h=>h.kind!=="none");for(const h of t)if(!o.has(h)&&(!r.has(h)||!c.some(l=>l.toId===h))){const l=a(h);l.length>0&&n.push(l)}return n.forEach(h=>{h.sort((l,u)=>"display"in l&&"display"in u?l.display.from-u.display.from:0)}),n},b0=["text","image","video","audio","caption","template"];function Xh(){const i=Q();Ih(this,i.placeholderMovingObjects)}function _0(i){const t=i.target.left;i.target.left=Math.max(t,0)}function zh(i,t){return i.find(s=>{const r=s.getBoundingRect();return t.left<r.left+r.width&&t.left+t.width-1>r.left&&t.top<r.top+r.height&&t.top+t.height>r.top})}function T0(i,t){const s=i.canvas.getActiveObject(),r=s.left+s.width/2,n=t.left+t.width/2;return r<n?t.left-s.width:(r>n,t.left+t.width)}const x0=(i,t,e)=>!(e<0||zh(i,{...t.getBoundingRect(),left:e})),Hh=i=>{const e=Q().draggingOverTrack,s=e==null?void 0:e.accepts.map(n=>n.toLowerCase()),r=i.type.toLowerCase();return i instanceof he,e&&(s==null?void 0:s.includes(r))};function S0(i){Q().isPointerOverHelperTrack?i.opacity=0:i.opacity=1}function w0(){const i=Q(),t=i.primaryMovingObjects[0];return{top:i.objectInitialPositions[t.id].top,left:i.objectInitialPositions[t.id].left}}function C0(i){const t=i.getBoundingRect(),e=Q(),s=e.draggingOverTrack;if(e.primaryMovingObjects.map(n=>n.id).includes(i.id)){const o=e.primaryMovingObjects[0].getBoundingRect();return{top:s.top,left:o.left}}return{top:s.top,left:t.left}}function O0(i,t,e,s){const n=i.canvas.getActiveObjects().map(l=>l.id),o=T0(i,t),a=e.filter(l=>!n.includes(l.id)),c=x0(a,i,o),h=Q();if(h.orderNormalTrack=!0,!c||s.x-20<0){const l=h.draggingOverTrack;return{left:h.initialTrackPoints.reduce((d,g)=>Math.abs(g-s.x)<Math.abs(d-s.x)?g:d),top:l.top}}return{left:o,top:t.top}}const k0=(i,t)=>{i.forEach((e,s)=>{e.set({left:t[s]})})},Yh=Zv(i=>{const t=i.target.canvas;_0(i);const e=Q(),s=e.draggingOverTrack;if(s){const a=e.primaryMovingObjects[0];b0.includes(a.type)&&e.placeholderMovingObjects.forEach(c=>{c.visible=!0})}else{e.placeholderMovingObjects.forEach(a=>{a.visible=!1});return}const r=e.placeholderMovingObjects.map(a=>a.draggedObject),n=(e.trackToItemsMap[s.id]||[]).filter(a=>!r.includes(a)),o=Hh(e.primaryMovingObjects[0]);if(s.magnetic&&o){e.updateItemsInTrack?e.updateItemsInTrack!==s.id&&(e.updateItemsInTrack=s.id,e.initialTrackPoints=[]):(e.updateItemsInTrack=s.id,e.initialTrackPoints=[]),e.initialTrackPoints.length===0&&(e.updateItemsInTrack=s.id,e.initialTrackPoints=Vh(e,s));let a=0;for(const[c,h]of e.initialTrackPoints.entries()){const l=h,u=e.initialTrackPoints[c+1],d=e.initialTrackPoints[c-1],g=u-l,f=l-d;if(!u)a=l;else if(l<=i.pointer.x&&l+g/2>=i.pointer.x){a=l;break}else if(l-f/2<=i.pointer.x&&i.pointer.x<=l){a=l;break}}e.placeholderMovingObjects.forEach(c=>{c.opacity=1,c.left=a,c.top=s.top,a+=c.width}),e.placeholderMovingObjects.forEach(c=>{const h=c.draggedObject;t.positionAfterTransform[h.id]={top:c.top,left:c.left}}),t.trackIdAfterTransform=e.trackTopToIdMap[s.top]}else{if(e.orderNormalTrack=!1,e.updateItemsInTrack&&e.updateItemsInTrack!==s.id){const d=t.getObjects().find(g=>g.id===e.updateItemsInTrack);d!=null&&d.magnetic?M0(t,e):t.updateTrackItemCoords(!0),e.updateItemsInTrack=null,e.initialTrackPoints=[]}e.initialTrackPoints.length===0&&s instanceof Lt&&(e.updateItemsInTrack=s.id,e.initialTrackPoints=Vh(e,s));const a=n.find(d=>zh(r,d.getBoundingRect())),c=[],l=e.primaryMovingObjects.sort((d,g)=>d.left-g.left),u=l[0];l.forEach((d,g)=>{if(!l[g-1])return;const f=d.left-u.left;c.push(f)}),e.placeholderMovingObjects.forEach((d,g)=>{const f=d.draggedObject;if(f instanceof Qs){d.visible=!1;return}f.setCoords(),S0(d);let p=I0(f,n,i.pointer,a);if(e.draggingOverTrack instanceof ce?d.opacity=0:d.opacity=1,f instanceof he&&p.isInvalidDrop&&e.draggingOverTrack instanceof Lt){const m=i.pointer,b=[...t.viewportTransform],T=m.y-b[5];E0(t,T)}else e.primaryMovingObjects.length>1?(t.trackIdAfterTransform=e.trackTopToIdMap[p.top],t.positionAfterTransform[f.id]={top:p.top,left:p.left+(c[g-1]||0)},d.left=p.left+(c[g-1]||0),d.top=p.top):(t.trackIdAfterTransform=e.trackTopToIdMap[p.top],t.positionAfterTransform[f.id]={top:p.top,left:p.left},d.left=p.left,d.top=p.top)})}}),Vh=(i,t)=>{const e=i.canvas,s=[];t.items.forEach(h=>{const l=e.getObjects().find(u=>u.id===h);l&&s.push(l)});const r=i.activeObjects.map(h=>h.id),o=s.filter(h=>!r.includes(h.id)).sort((h,l)=>h.left-l.left);let a=0;const c=[];return t.magnetic?D0(o,a,c):j0(t,c,e),c};function M0(i,t){const e=[];i.getObjects().find(a=>a.id===t.updateItemsInTrack).items.forEach(a=>{const c=i.getObjects().find(h=>h.id===a);c&&e.push(c)});const r=t.activeObjects.map(a=>a.id),o=e.filter(a=>!r.includes(a.id)).sort((a,c)=>a.left-c.left);t.initialTrackPoints.length>o.length&&k0(o,t.initialTrackPoints)}function D0(i,t,e){var h;const s=Q(),r=(h=i[0])==null?void 0:h.canvas,n=s.draggingOverTrack,o=s.primaryMovingObjects.map(l=>l.id);if(!r)return;const a=r.transitionIds.filter(l=>r.transitionsMap[l].kind!=="none");i.forEach(l=>{l.set({left:t}),t+=l.width,a.find(d=>r.transitionsMap[d].toId===l.id)||e.push(l.left)});const c=i[i.length-1];if(e.push(((c==null?void 0:c.left)||0)+((c==null?void 0:c.width)||0)),n!=null&&n.items.includes(o[0])){const l=s.primaryMovingObjects[0],u=[...e];if(l){const d=u.findIndex(g=>g>(l==null?void 0:l.left));d!==-1&&e.splice(d,0,nt(l.display.from,r.tScale))}}}function j0(i,t,e){const s=i.items,r={},n={},o=e.getActiveObjects().map(h=>h.id);Object.values(e.trackItemsMap).forEach(h=>{s.includes(h.id)&&(r[h.id]=h)});const a=e.getObjects("Transition").filter(h=>h.top===i.top).map(h=>h.id);Object.values(e.transitionsMap).forEach(h=>{a.includes(h.id)&&(n[h.id]=h)});const c=y0({trackItemIds:Ne(s),transitionsMap:Ne(n),trackItemsMap:Ne(r)});t.push(0),c.forEach(h=>{if(h.length===1){const l=e.getObjects().find(u=>u.id===h[0].id);o.includes(l.id)||t.push(l.left+l.width)}else{const l=h[h.length-1],u=e.getObjects().find(d=>d.id===l.id);t.push(u.width+u.left)}})}function E0(i,t){i.getObjects("Helper").reduce((r,n)=>Math.abs(n.top-t)<Math.abs(r.top-t)?n:r).setSelected(!0)}const I0=(i,t,e,s)=>{const r=Hh(i);return!r&&i instanceof he?{top:0,left:0,isInvalidDrop:!0}:r?s?i instanceof he?{top:0,left:0,isInvalidDrop:!0}:O0(i,s,t,e):C0(i):w0()};function P0(i){i.on("mouse:up",Xh.bind(i)),i.on("object:moving",Yh)}function A0(i){i.off("mouse:up",Xh.bind(i)),i.off("object:moving",Yh)}const F0=i=>{Q().canvas.fire("track:create",i)},L0=i=>{Q().canvas.fire("track-items:moved",i)},Gh=i=>{var a,c,h;const t=(a=i.target)==null?void 0:a.canvas;if(!t)return;const e=Q(),s=t.getActiveObject();if(!s||!t.positionBeforeTransform)return;const r=t.getScenePoint(i.e),o=t.getObjects("Track","Helper").find(l=>{const u=l.getBoundingRect();return r.x>=u.left&&r.x<=u.left+u.width&&r.y>=u.top&&r.y<=u.top+u.height});if(i.action==="resizing"){const l=(e.trackToItemsMap[(c=e.originTrack)==null?void 0:c.id]||[]).filter(d=>d!==s);s.setCoords();const u=Nh(l,s.getBoundingRect());return t.fire("track-items:resized",{trackId:(h=e.originTrack)==null?void 0:h.id,trackItemIds:[s.id],isOverlapped:!!u}),!1}if(!o)return s==null||s.set(t.positionBeforeTransform),s==null||s.setCoords(),!1;if(o instanceof ce){let l;switch(o.kind){case"top":l=0;break;case"center":l=o.metadata.order||0;break;case"bottom":l=-1;break;default:return}const u={isSecondaryOverlapped:!1,secondaryTracks:e.secondaryTracks,primaryTracks:e.primaryTracks,primaryPositions:{trackIndex:l,trackId:t.trackIdAfterTransform,positions:t.positionAfterTransform}};F0(u)}else if(o instanceof Lt){const u={isSecondaryOverlapped:B0(),secondaryTracks:e.secondaryTracks,primaryTracks:e.primaryTracks,primaryPositions:{trackId:t.trackIdAfterTransform,positions:t.positionAfterTransform}};L0(u)}};function R0(){const i=Q(),t=i.canvas,[e]=i.primaryMovingObjects,s=e.id,r=t.positionAfterTransform[s],n=e.getBoundingRect().top,o=r.top-n,a={};return i.secondaryMovingObjects.forEach(c=>{const h=c.getBoundingRect().top+o,l=i.trackTopToIdMap[h],u=$n(i.trackTops,i.originTrack.top,h);a[l]?a[l].objects.push(c):a[l]={objects:[c],index:u}}),a}function B0(){const i=R0(),t=Q();return Object.keys(i).some(e=>{const s=t.trackToItemsMap[e],r=i[e].objects;return!s||!s.length?!0:s.filter(n=>!r.includes(n)).some(n=>Nh(r,n.getBoundingRect()))})}function Nh(i,t){return i.find(s=>{const r=s.getBoundingRect();return t.left<r.left+r.width&&t.left+t.width>r.left&&t.top<r.top+r.height&&t.top+t.height>r.top})}const W0=i=>{i.on("object:modified",Gh)},X0=i=>{i.off("object:modified",Gh)},qn="drag",Uh=`${qn}:start`,Kn=`${qn}:end`,Jn="timeline",$h=`${Jn}:boundingChanged`,qh=`${Jn}:seek`,z0=i=>{const{trackItemIds:t,transitionsMap:e,trackItemsMap:s}=i,r=new Map;Object.values(e).forEach(c=>{var u,d;if(c.kind==="none")return;const{fromId:h,toId:l}=c;r.has(h)||r.set(h,[]),r.has(l)||r.set(l,[]),(u=r.get(h))==null||u.push(c),(d=r.get(l))==null||d.push(c)});const n=[],o=new Set,a=c=>{const h=[];let l=c;for(;l&&!o.has(l);){o.add(l);const u=s[l];h.push(u);const d=Object.values(e).find(g=>g.fromId===l&&g.kind!=="none");if(!d)break;h.push(d),l=d.toId}return h};for(const c of t)if(!o.has(c)&&(!r.has(c)||!Object.values(e).some(h=>h.toId===c&&h.kind!=="none"))){const h=a(c);h.length>0&&n.push(h)}return n.forEach(c=>{c.sort((h,l)=>"display"in h&&"display"in l?h.display.from-l.display.from:0)}),n},H0="add:audio",Y0="add:video",V0="add:image",G0="add:text",N0=["transition","image","video","audio","caption","text"];let st,tr,Ue=[],er="";function U0(i,t){let e=1/0,s=null;const r=new _(i.x,i.y);return t.forEach(n=>{const o=Math.sqrt(Math.pow(n.left-r.x,2)+Math.pow(n.top-r.y,2));o<e&&(e=o,s=n)}),s}const $0=({width:i,height:t,id:e,left:s,top:r,type:n,duration:o})=>{if(n==="transition")return new Qs({top:0,left:0,height:48,width:48,id:"TransitionGuide"});const a=C.getClass("PreviewTrackItem")||he;return new a({top:r,left:s,height:t,width:i,id:e,type:n,duration:o})};function Kh(i){var f;const t=(f=i.e.dataTransfer)==null?void 0:f.types[0];if(!t)return;const e=JSON.parse(t),s=e.type;if(!N0.includes(s))return;const r=e.duration||5e3,n=this;n.discardActiveObject(),n.setActiveIds([]);const o=nt(r,this.tScale),a=n.getItemSize(s),c=n.getTrackItems();if(st=$0({width:o,height:a,id:"TransitionGuide",left:0,top:0,type:s,duration:r}),st.visible=!1,er=s,s==="transition"){Ue=n.getObjects("Transition");const p=Ue.filter(m=>m.kind!=="none");Ue.forEach(m=>{const b=c.find(k=>k.id===m.toId),T=c.find(k=>k.id===m.fromId),x=m.width;((b==null?void 0:b.width)||0)>=x/2&&((T==null?void 0:T.width)||0)>=x/2||(m.availableDrop=!1);const S=p.find(k=>k.fromId===m.toId);S&&S.width+x/2>=((b==null?void 0:b.width)||0)&&(m.availableDrop=!1);const O=p.find(k=>k.toId===m.fromId);O&&O.width+x/2>=((T==null?void 0:T.width)||0)&&(m.availableDrop=!1),m.visible=!0})}const h=Q();n.trackIdAfterTransform="",n.positionAfterTransform={};const l=st,u=[st];ct({activeTrackToItemsMap:{},primaryTracks:{},secondaryTracks:{},trackTops:[],trackToItemsMap:{},activeObjects:[],trackTopToIdMap:{},isDragOver:!1}),ct({activeObjects:u});const d=n.getObjects("Track"),g=n.getTrackItems();d.forEach(p=>{const m=g.filter(b=>p.items.includes(b.id));h.trackToItemsMap[p.id]=m,h.trackTopToIdMap[p.top]=p.id,h.trackTops.push(p.top)}),h.trackTops.sort((p,m)=>p-m),h.primaryMovingObjects=u,h.primaryMovingObjects=h.primaryMovingObjects.sort((p,m)=>p.left-m.left),l&&(n.positionBeforeTransform={top:l.top,left:l.left}),h.placeholderMovingObjects=h.primaryMovingObjects.map(p=>{const m=p.getBoundingRect();h.objectInitialPositions[p.id]={top:m.top,left:m.left};const b=new ls({id:`${p.id}-placeholder`,left:m.left,top:m.top,width:m.width,height:m.height});return b.visible=!1,b.draggedObject=p,b}),n.add(...h.placeholderMovingObjects),n.add(st),K.dispatch(Uh)}const Jh=i=>{const t=Q();Ih(i,t.placeholderMovingObjects),i&&(bi(i,i.getObjects()),Ph(i.getObjects("Helper")))};function Zh(){if(er="",Jh(this),ct({draggingOverTrack:null,isPointerOverHelperTrack:!1}),!st)return;K.dispatch(Kn);const i=this;Ue.forEach(t=>{t.strokeDashArray=[],t.setSelected(!1),t.kind==="none"&&(t.visible=!1)}),i.getObjects("Helper","Track").forEach(t=>{t.setSelected&&t.setSelected(!1)}),i.remove(st)}function Qh(i){const t=Q(),e=t.placeholderMovingObjects[0];if(e.visible||(st.visible=!0,e.visible=!0),t.activeObjects[0]instanceof Qs&&(e.visible=!1),!st)return!1;i.e.preventDefault();const s=this,r=s.getViewportPoint(i.e),n=[...this.viewportTransform];st.set({left:r.x-16-n[4],top:r.y-n[5]-st.height/2});const o=U0(r,Ue.filter(h=>h.availableDrop));o&&(tr=o,o.strokeDashArray=[5,1],o.setSelected(!0)),Ue.forEach(h=>{h!==o&&h.setSelected(!1)}),ct({isDragOver:!0}),st.setCoords();const a={target:st,action:"drag",originX:"center",originY:"center",offsetX:r.x-st.left,offsetY:r.y-st.top,scaleX:st.scaleX,scaleY:st.scaleY};if(t.activeObjects[0].type!=="transitionguide"&&s.fire("object:moving",{target:st,e:i.e,pointer:r,transform:a}),this.itemTypes.includes(er))if(t.draggingOverTrack instanceof Lt){ct({isPointerOverHelperTrack:!1});const h=t.activeObjects[0].left,l=t.activeObjects[0].left+t.activeObjects[0].width;let u=!1;const d=t.draggingOverTrack.items;s.getObjects().filter(g=>d.includes(g.id)).forEach(g=>{(g.left<=h&&g.left+g.width>=h||g.left<=l&&g.left+g.width>=l||h<=g.left&&l>=g.left+g.width)&&(u=!0)}),t.draggingOverTrack.accepts.includes(er)&&!u?(t.placeholderMovingObjects[0].left=t.activeObjects[0].left,t.placeholderMovingObjects[0].top=t.draggingOverTrack.top,s.getObjects("Helper").forEach(g=>{g.setSelected&&g.setSelected(!1)})):t.placeholderMovingObjects.forEach(g=>{g.opacity=0})}else t.draggingOverTrack instanceof ce&&(ct({isPointerOverHelperTrack:!0}),t.draggingOverTrack.setSelected(!0));s.requestRenderAll()}function tl(i){var o;er="";const t=this;Jh(t);const e=Q(),s=e.draggingOverTrack;ct({draggingOverTrack:null,isPointerOverHelperTrack:!1});const r=(o=i.e.dataTransfer)==null?void 0:o.types[0],n=JSON.parse(i.e.dataTransfer.getData(r));if(n.type!=="transition"){const a=e.activeObjects[0],c=B(a.left,t.tScale);if(s instanceof Lt)if(e.placeholderMovingObjects[0].opacity!==0){const l=Zn(s,this.getObjects("Track"));if(s.magnetic){const u=e.initialTrackPoints[e.initialTrackPoints.length-1],d=B(u,t.tScale);_i(n,l,d)}else _i(n,l,c)}else{const l=i.viewportPoint,u=[...t.viewportTransform],d=l.y-u[5],f=t.getObjects("Helper").reduce((m,b)=>Math.abs(b.top-d)<Math.abs(m.top-d)?b:m),p=Zn(f,this.getObjects("Track"));_i(n,p,c,!0)}else{const h=Zn(s,this.getObjects("Track"));_i(n,h,c,!0)}this.remove(a),this.requestRenderAll();return}if(st){if(tr){const a=tr.id,c=Kv(n,["kind","direction"]);Object.keys(c).forEach(T=>{T==="kind"?tr.kind=c[T]:tr[T]=c[T]});const h=Ne(this.trackItemIds),l=Ne(this.transitionsMap),u=Ne(this.trackItemsMap);l[a]={...l[a],...c};const d=z0({trackItemIds:h,transitionsMap:l,trackItemsMap:u}),f=l[a].fromId,p=d.find(T=>T.find(x=>x.id===f))||[],m=q0(p),b=K0(this.trackItemsMap,m);this.trackItemsMap=b,this.transitionsMap[a]={...this.transitionsMap[a],...c},this.adjustMagneticTrack(),this.calcBounding(),this.updateTransitions(),this.refreshTrackLayout(),this.updateState({kind:"add:transition",updateHistory:!0})}Ue.forEach(a=>{a.strokeDashArray=[],a.setSelected(!1),a.kind==="none"&&(a.visible=!1)}),t.remove(st),t.requestRenderAll(),K.dispatch(Kn)}}const q0=i=>{const[t]=i,e=i.filter(r=>r.type!=="transition");let s=t.display.from;return e.map(r=>{const n=r.display.to-r.display.from,o={from:s,to:s+n};return s=o.to,{...r,display:o}})},K0=(i,t)=>{let e=i;return t.forEach(s=>{e[s.id]=s}),e},Zn=(i,t)=>{const e=t.sort((o,a)=>o.top-a.top);if(e.length===0)return 0;const s=e[e.length-1];if(s.top+s.height<=i.top)return e.length;const r=i.top;return e.reduce((o,a,c)=>{const h=Math.abs(a.top-r),l=Math.abs(e[o].top-r);return h<l?c:o},0)},_i=(i,t,e,s)=>{i.type==="image"?K.dispatch(V0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}}):i.type==="video"?K.dispatch(Y0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}}):i.type==="audio"?K.dispatch(H0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}}):i.type==="text"&&K.dispatch(G0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}})};function J0(i){i.on("dragover",Qh),i.on("dragenter",Kh),i.on("dragleave",Zh),i.on("drop",tl)}function Z0(i){i.off("dragover",Qh),i.off("dragenter",Kh),i.off("dragleave",Zh),i.off("drop",tl)}function el(i){const t=this.height<this.bounding.height;if(!(this.width<this.bounding.width)&&!t)return;const s=this.viewportTransform;let r=s[4],n=s[5];const o=2;i.e.shiftKey?r=r-i.e.deltaY*o:(t&&(n=n-i.e.deltaY*o),r=r-i.e.deltaX*o),this.setViewportPos(r,n)}function sl(){const i=this,t=i.getActiveObject(),e=i.getActiveObjects(),s=e.map(n=>n.id),r=e.filter(n=>{if(e.length===1)return!0;if(n.id&&!(n instanceof Rt))return!0;if(n instanceof Rt&&s.includes(n.fromId)&&s.includes(n.toId))return!0}).map(n=>n.id);t instanceof Ct?(t.borderColor="rgba(0, 216, 214,0.75)",t.hasControls=!1,t.hoverCursor="default",t.borderScaleFactor=1,t.padding=0,t.getObjects().forEach(n=>{n.setSelected(!0)})):t==null||t.setSelected(!0),this.setActiveIds(r)}function rl(i){const t=this,e=t.getActiveObject();e instanceof Ct&&(e.borderColor="transparent",e.hasControls=!1,e.hoverCursor="default"),i.selected.forEach(n=>{n.setSelected(!0)}),i.deselected.forEach(n=>{n.setSelected(!1)});const r=t.getActiveObjects().map(n=>n.id);this.setActiveIds(r)}function il(i){i.deselected.forEach(t=>{t.setSelected(!1)})}const Q0=i=>{i.on("selection:created",sl),i.on("selection:updated",rl),i.on("selection:cleared",il),i.on("mouse:wheel",el)},ty=i=>{i.off("mouse:wheel",el),i.off("selection:created",sl),i.off("selection:updated",rl),i.off("selection:cleared",il)},nl=()=>{var n;const i=Q(),t=i.canvas,e=i.draggingOverTrack;t.updateTrackItemCoords(!0);const s=e==null?void 0:e.magnetic,r=new Set(i.activeObjects.map(o=>o.id));if(s){const o=e.id,c=i.trackToItemsMap[o].sort((f,p)=>f.left-p.left),h=i.placeholderMovingObjects,l=((n=h[0])==null?void 0:n.top)||0,u=h.reduce((f,p)=>f+p.width,0),d=Math.min(...h.map(f=>f.left));let g=0;c.forEach(f=>{r.has(f.id)||f.top===l&&(Math.abs(d-g)<1&&(g+=u),f.left=g,g+=f.width)})}else if(e instanceof Lt&&i.orderNormalTrack){const o=e.items,a=t.getTrackItems().filter(p=>!r.has(p.id)&&o.includes(p.id)),c=a.sort((p,m)=>p.left-m.left),h=i.placeholderMovingObjects[0],l=i.placeholderMovingObjects[i.placeholderMovingObjects.length-1],u=h.left,d=l.left-h.left+l.width,g=c.find((p,m)=>{if(p.left>=u-1)return c[m]}),f=a.filter(p=>p.left>=u-1);if(h.left+d>(g==null?void 0:g.left)){const p=d-(g.left-h.left);f.forEach(m=>{const b=nt(m.display.from,t.tScale);m.left=b+p})}}t.alignTransitionsToTrack(!1)};function ey(i){i.on("object:moving",nl)}function sy(i){i.off("object:moving",nl)}let Xt,Qn=!1;function ry(i,t){const e=i.canvas;if(e.objectTypes.includes(i.type)){Xt||(Xt=i);const r=i.top,n=i.height,o=i.left,a=i.width,c=t.x,h=t.y,l=Math.abs(h-(r+n/2))<=Yd;Math.abs(c-o)<=bc&&l||Math.abs(c-o-a)<=bc&&l?(e.hoverCornerItem=!0,i.hoverCursor="ew-resize"):(e.hoverCornerItem=!1,i.hoverCursor="move"),e.requestRenderAll()}}function ol(i){const t=this,e=t.findTarget(i.e),s=t.getScenePoint(i.e);e&&(e.isSelected&&Xt&&(e.hoverCursor="default"),ry(e,s))}function al(){Xt&&(Xt.lockMovementX=!1,Xt.lockMovementY=!1,Xt=void 0)}function cl(i){Xt&&(Qn||Xt._renderControls(i.ctx))}function hl(){Xt&&(Xt=void 0,this.requestRenderAll())}function ll(){Qn=!0}function ul(){Qn=!1}function iy(i){i.on("mouse:out",hl.bind(i)),i.on("mouse:up",al.bind(i)),i.on("mouse:move",ol.bind(i)),i.on("after:render",cl.bind(i)),i.on("object:resizing",ll.bind(i)),i.on("object:modified",ul.bind(i))}function ny(i){i.off("mouse:out",hl.bind(i)),i.off("mouse:up",al.bind(i)),i.off("mouse:move",ol.bind(i)),i.off("after:render",cl.bind(i)),i.off("object:resizing",ll.bind(i)),i.off("object:modified",ul.bind(i))}const oy=i=>{ct({canvas:i}),o0(i),e0(i),c0(i),f0(i),m0(i),P0(i),W0(i),J0(i),Q0(i),ey(i),iy(i)},ay=i=>{ct({canvas:null}),a0(i),s0(i),h0(i),p0(i),v0(i),A0(i),X0(i),Z0(i),ty(i),sy(i),ny(i)};class cy{removeTransitions(){const t=this.getObjects("Transition");this.remove(...t)}renderTransitions(){this.removeTransitions(),this.transitionIds.forEach(t=>{const e=this.transitionsMap[t],s=e.fromId,r=e.toId,n=this.getObjects(),o=n.find(d=>d.id===s),a=n.find(d=>d.id===r);if(!o||!a)return;const c=nt(e.duration,this.tScale),h=o.left+o.width-c/2,l=o.height,u=new Rt({id:e.id,left:h,top:o.top,height:l,width:c,tScale:this.tScale,duration:e.duration,fromId:o.id,toId:a.id,kind:e.kind});e.kind==="none"&&(u.visible=!1),u&&this.add(u)})}updateTrackTransitionsItemCoords(){this.pauseEventListeners(),this.getObjects("Transition").forEach(e=>{e.tScale=this.tScale,e.updateCoords(),e.setCoords()}),this.resumeEventListeners()}alignTransitionsToTrack(t=!0){const e=t?[]:this.getActiveObjects().map(s=>s.id);this.transitionIds.forEach(s=>{const r=this.getObjects("Transition").find(n=>n.id===s);if(r instanceof Rt){const n=this.getObjects().find(c=>c.id===r.fromId&&!e.includes(c.id));if(!n)return;const o=nt(r.duration,this.tScale),a=n.left+n.width-o/2;r.set({left:a,top:n.top}),r.setCoords()}})}updateTransitions(t=!0){t&&this.pauseEventListeners();const e=this.getObjects("Track"),s=this.getObjects(...this.withTransitions);this.removeTransitions();const r={},n=[];e.forEach(a=>{const c=s.filter(h=>a.items.includes(h.id)).sort((h,l)=>h.left-l.left);for(let h=0;h<c.length-1;h++){const l=c[h],u=c[h+1];if(Math.abs(l.left+l.width-u.left)<=1){const d=`${l.id}-${u.id}`;if(this.transitionIds.includes(d)){const f=this.transitionsMap[d];r[d]=f}else{const f={id:d,duration:1500,fromId:l.id,toId:u.id,kind:"none",trackId:a.id,type:"transition"};r[d]=f}n.push(d)}}}),this.transitionIds=n,this.transitionsMap=r,this.renderTransitions();const o=this.getObjects("Transition");this.updateCachingActiveObjects(o),t&&this.resumeEventListeners()}}function dl(i){const{secondaryTracks:t,primaryTracks:e,primaryPositions:s}=i,{positions:r,trackIndex:n}=s,o=n===-1?this.tracks.length:n,[a]=Object.keys(e),c=this.tracks.find(p=>p.id===a),h=e[a],l={id:fs(),items:h.objects.map(p=>p.id),type:c.type,accepts:c.accepts},u=Wn(Object.keys(t).map(p=>t[p].objects.map(m=>m.id)));let d=Us(this.tracks,[...Object.keys(r),...u]);const g=[];Object.keys(t).forEach(p=>{const{objects:m,index:b}=t[p],T=this.tracks.find(O=>O.id===p),x=m.map(O=>O.id).filter(O=>!this.transitionIds.includes(O)),S={id:Ns(),items:x,type:T.type,accepts:T.accepts,tempIndex:b};g.push(S)});const f=Bh(l,g);f.length&&d.splice(o,0,...f),this.tracks=d,this.renderTracks(),this.refreshTrackLayout(),this.alignItemsToTrack(),this.uodateTrackItemIdsOrdering(),this.adjustMagneticTrack(),this.updateTransitions(!0),this.updateState({updateHistory:!0,kind:"update"})}function gl(i){const{isSecondaryOverlapped:t,secondaryTracks:e,primaryTracks:s,primaryPositions:r}=i,{trackId:n,positions:o}=r,a=this.tracks.find(b=>b.id===n),l=Q().primaryMovingObjects.sort((b,T)=>b.left-T.left);l.forEach((b,T)=>{l[T-1]&&b.left-l[T-1].left});const u=this.tracks.findIndex(b=>b.id===n),d=Wn(Object.keys(e).map(b=>e[b].objects.map(T=>T.id)));let g=Us(this.tracks,[...Object.keys(o),...d]);Object.keys(s).forEach(b=>{this.pauseEventListeners();const{objects:T}=s[b];T.forEach(O=>{if(O.isMain&&(a!=null&&a.magnetic))return;const k=o[O.id];O.left=k==null?void 0:k.left}),this.resumeEventListeners();const x=r.trackId,S=g.find(O=>O.id===x);S==null||S.items.push(...Object.keys(o)),this.tracks=g});const f=this.tracks[u],p=[];Object.keys(e).forEach(b=>{const{objects:T,index:x}=e[b],S=T.filter(j=>j.type!=="transition").map(j=>j.id),[O]=S,k=this.trackItemsMap[O];if(t&&k){const j=this.getItemAccepts(k.type),D={id:Ns(),items:S,type:k.type,accepts:j,tempIndex:x};p.push(D)}else{const j=g[u+x];j==null||j.items.push(...S),this.tracks=g}});const m=Bh(f,p);m.length&&g.splice(u,1,...m),this.tracks=g,this.renderTracks(),this.alignItemsToTrack(),this.uodateTrackItemIdsOrdering(),this.adjustMagneticTrack(),this.updateTransitions(!0),this.updateState({updateHistory:!0,kind:"update"})}function fl({trackItemIds:i,isOverlapped:t}){var o,a;const[e]=i;if(!e)return;const s=this.getObjects("Transition");if(!s.find(c=>c.id===e)){const c=this.tracks.find(h=>h.items.includes(e));if(t){const h=Us(this.tracks,i),l={id:Ns(),items:[e],type:c.type,accepts:c.accepts},u=this.tracks.findIndex(d=>d.id===c.id);h.splice(u,0,l),this.tracks=h}}const n=s.filter(c=>c.fromId===e||c.toId===e);if(n){const c=this.getTrackItems().find(g=>g.id===e),h=c==null?void 0:c.width;n.forEach(g=>{if(g.width/2>h){this.transitionIds=this.transitionIds.filter(p=>p!==g.id);const f={};Object.keys(this.transitionsMap).forEach(p=>{p!==g.id&&(f[p]=this.transitionsMap[p])}),this.transitionsMap=f}});const l=((o=n[0])==null?void 0:o.width)||0,u=((a=n[1])==null?void 0:a.width)||0,d=n[1];if(h<=l/2+u/2){this.transitionIds=this.transitionIds.filter(f=>f!==(d==null?void 0:d.id));const g={};Object.keys(this.transitionsMap).forEach(f=>{f!==(d==null?void 0:d.id)&&(g[f]=this.transitionsMap[f])}),this.transitionsMap=g}}this.renderTracks(),this.alignItemsToTrack(),this.adjustMagneticTrack(),this.updateTransitions(!0),this.uodateTrackItemIdsOrdering(),this.updateState({updateHistory:!0,kind:"update"})}let to={x:0,y:0};function hy(i){to=i.scenePoint}function pl(i){const t=i.scenePoint;if((to.x===t.x||to.y===t.y)&&!i.target){const s=this.getElement().getBoundingClientRect(),r=this.viewportTransform,n=i.e.clientX-s.left-r[4],o=B(n,this.scale.zoom);K.dispatch(qh,{payload:{time:o}})}}const ly=i=>{i.on("track:create",dl.bind(i)),i.on("track-items:resized",fl.bind(i)),i.on("track-items:moved",gl.bind(i)),i.on("mouse:up",pl.bind(i)),i.on("mouse:down",hy.bind(i))};function uy(i){i.off("track:create",dl.bind(i)),i.off("track-items:resized",fl.bind(i)),i.off("track-items:moved",gl.bind(i)),i.off("mouse:up",pl.bind(i))}function dy(i,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(s=>{s!=="constructor"&&Object.defineProperty(i.prototype,s,Object.getOwnPropertyDescriptor(e.prototype,s)||Object.create(null))})}),i}let ml,vl,yl,bl,_l,Tl,xl,Sl;const gy=i=>{ml=i.state.subscribeToActiveIds(({activeIds:t})=>{const e=i.activeIds;if(t.length===1&&e.length===1){const s=t[0],r=e[0],o=i.state.getState().structure;let a="";if(o.forEach(c=>{c.id===r&&c.items.includes(s)&&(a=c.id)}),a!=="")return;i.selectTrackItemByIds([s])}else i.selectTrackItemByIds(t)}),Sl=i.state.subscribeToTracks(({tracks:t,changedTracks:e})=>{e.length&&(i.tracks=t,i.renderTracks(),i.refreshTrackLayout())}),xl=i.state.subscribeToUpdateAnimations(({trackItemsMap:t,changedAnimationIds:e})=>{if(e!=null&&e.length){const s=i.getTrackItems();i.trackItemsMap=t,s.forEach(r=>{if(e.includes(r.id)){const n=t[r.id].animations;n&&r.set({animations:n})}})}}),Tl=i.state.subscribeToUpdateTrackItemTiming(({trackItemsMap:t,changedTrimIds:e,changedDisplayIds:s})=>{if(e&&i.getTrackItems().forEach(n=>{if(e.includes(n.id)){const o=t[n.id].trim;o&&n.set({trim:{from:o.from,to:o.to}})}}),s){const r=i.getTrackItems();i.pauseEventListeners(),r.forEach(n=>{if(s.includes(n.id)){const o=t[n.id].display;i.trackItemsMap[n.id].display=o,t[n.id].playbackRate!==i.trackItemsMap[n.id].playbackRate&&(i.trackItemsMap[n.id].playbackRate=t[n.id].playbackRate,n.playbackRate=t[n.id].playbackRate,n.onScale&&n.onScale()),o&&n.set({display:o})}}),i.resumeEventListeners()}i.updateTrackItemCoords(),i.adjustMagneticTrack(),i.updateTransitions(),i.requestRenderAll()}),_l=i.state.subscribeToScale(t=>{i.setScale(t.scale)}),bl=i.state.subscribeToUpdateItemDetails(t=>{const e=i.getTrackItems();if(e.length===0)return;const s=i.state.getState(),r=t.trackItemsMap,n=s.trackItemsMap;i.trackItemsMap=r,e.forEach(o=>{const a=r[o.id];if(a)if(o.hasSrc){const c=n[o.id];if(o.src!==a.details.src&&o.setSrc&&o.setSrc(a.details.src),a.type==="video"||a.type==="audio"){const l=c.display.to-c.display.from,u=nt(l,i.scale.zoom,c.playbackRate);o.set({duration:c.duration,display:c.display,trim:c.trim,width:u}),o.setCoords()}}else(a.type==="text"||a.type==="caption")&&(a.type==="text"||a.type==="caption")&&o.set({text:a.details.text})}),i.requestRenderAll()}),yl=i.state.subscribeToHistory(t=>{i.tracks=t.tracks,i.trackItemsMap=t.trackItemsMap,i.trackItemIds=t.trackItemIds,i.transitionIds=t.transitionIds,i.transitionsMap=t.transitionsMap,i.renderTracks(),i.refreshTrackLayout(),i.updateTrackItemCoords(),i.alignItemsToTrack(),i.alignTransitionsToTrack(),i.adjustMagneticTrack(),i.updateTransitions(),i.calcBounding(),i.duration=Gs(i.trackItemsMap)}),vl=i.state.subscribeToAddOrRemoveItems(()=>{const t=i.getTrackItems().map(n=>n.id),e=i.state.getState(),s=e.trackItemIds,r=[];t.forEach(n=>{s.includes(n)||r.push(n)}),i.deleteTrackItemById(r),i.tracks=e.tracks,i.trackItemsMap=e.trackItemsMap,i.transitionIds=e.transitionIds,i.transitionsMap=e.transitionsMap,s.forEach(n=>{if(!t.includes(n)){const a={...e.trackItemsMap[n]};i.addTrackItem(a)}}),i.trackItemIds=e.trackItemIds,i.activeIds=e.activeIds,i.renderTracks(),i.alignItemsToTrack(),i.updateTrackItemCoords(),i.calcBounding(),i.updateTransitions(),i.refreshTrackLayout(),i.selectTrackItemByIds(e.activeIds)})},fy=i=>{ml.unsubscribe(),vl.unsubscribe(),yl.unsubscribe(),bl.unsubscribe(),_l.unsubscribe(),Tl.unsubscribe(),xl.unsubscribe(),Sl.unsubscribe()},wl=(i,t)=>{let e=!1;const s=[];return t.forEach(r=>{r.containsPoint(i)&&(s.push(r),e=!0)}),{isOverObject:e,overObjects:s}};function py(i){return JSON.parse(JSON.stringify(i))}const rr=class rr extends pn{constructor(e,s){var r;super(e,s);w(this,"itemTypes",[]);w(this,"acceptsMap");w(this,"sizesMap",{});w(this,"objectTypes",[]);w(this,"tracks",[]);w(this,"hoverCornerItem",!1);w(this,"trackItemsMap",{});w(this,"trackItemIds",[]);w(this,"transitionIds",[]);w(this,"transitionsMap",{});w(this,"scale");w(this,"duration");w(this,"bounding");w(this,"onScroll");w(this,"onResizeCanvas");w(this,"tScale");w(this,"state");w(this,"activeIds",[]);w(this,"spacing");w(this,"guideLineColor");w(this,"withTransitions",[]);this.bounding=s.bounding||{width:s.width||0,height:s.height||0},this.tScale=((r=s.scale)==null?void 0:r.zoom)||1,this.state=s.state,this.onScroll=s.onScroll,this.onResizeCanvas=s.onResizeCanvas,this.acceptsMap=s.acceptsMap||{},this.sizesMap=s.sizesMap||{},this.itemTypes=s.itemTypes||[],this.objectTypes=rr.objectTypes,this.spacing=u0(s.spacing),this.itemTypes=s.itemTypes||[],this.positionAfterTransform={},this.initializeCanvasDefaults(),this.scale=s.scale,this.duration=s.duration,this.guideLineColor=s.guideLineColor||He,this.initEventListeners(),this.withTransitions=s.withTransitions||[]}static registerItems(e){Object.keys(e).forEach(s=>{C.setClass(e[s],s)}),rr.objectTypes=Object.keys(e).filter(s=>!Ld.includes(s))}getItemAccepts(e){return this.acceptsMap[e]||this.itemTypes}getItemSize(e){return this.sizesMap[e]||42}initializeCanvasDefaults(){const e=this.viewportTransform;e[4]=this.spacing.left,Object.assign(at.ownDefaults,{borderColor:"transparent",cornerColor:"white",cornerStrokeColor:"transparent",strokeWidth:0,borderOpacityWhenMoving:1,borderScaleFactor:1,cornerSize:8,cornerStyle:"rect",centeredScaling:!1,centeredRotation:!0,transparentCorners:!1})}__onMouseDown(e){const s=this.getScenePoint(e),r=this._activeObject,n=this.getActiveObjects();if(n.length===0){super.__onMouseDown(e);return}const{isOverObject:o}=wl(s,n);if(r&&(r==null?void 0:r.findControl(this.getViewportPoint(e),g0(e)))){super.__onMouseDown(e);return}const a=this.getTrackItems(),c=this.getObjects("Transition"),{isOverObject:h,overObjects:l}=wl(s,[...c,...a]);h?o?super.__onMouseDown(e):(this.setActiveIds([l[0].id]),super.__onMouseDown(e)):(this.discardActiveObject(),this.requestRenderAll(),this.setActiveIds([]),this._groupSelector={x:s.x,y:s.y,deltaY:0,deltaX:0},super.__onMouseDown(e))}_setupCurrentTransform(e,s,r){var n;if(this.hoverCornerItem){const o=this.getScenePoint(e),{key:a="",control:c}=s.getActiveControl()||{},h=c&&((n=c.getActionHandler(e,s,c))==null?void 0:n.bind(c)),l=this._getOriginFromCorner(s,a),u={target:s,action:"resizing",actionHandler:h,actionPerformed:!1,corner:a,scaleX:s.scaleX,scaleY:s.scaleY,skewX:s.skewX,skewY:s.skewY,offsetX:o.x-s.left,offsetY:o.y-s.top,originX:l.x,originY:l.y,ex:o.x,ey:o.y,lastX:o.x,lastY:o.y,theta:s.angle*Math.PI/180,width:s.width,height:s.height,shiftKey:e.shiftKey,altKey:!1,original:{scaleX:s.scaleX,scaleY:s.scaleY,skewX:s.skewX,skewY:s.skewY,angle:s.angle,left:s.left,flipX:s.flipX,flipY:s.flipY,top:s.top,originX:l.x,originY:l.y}};this._currentTransform=u,this.fire("before:transform",{e,transform:u})}else super._setupCurrentTransform(e,s,r)}initEventListeners(){ly(this),oy(this),gy(this)}setActiveIds(e){this.activeIds=e,this.state.updateState({activeIds:py(this.activeIds)},{kind:"layer:selection",updateHistory:!1})}updateState(e={updateHistory:!1}){this.filterEmptyTracks(),this.synchronizeTrackItemsState(),this.requestRenderAll(),this.duration=Gs(this.trackItemsMap),this.calcBounding(),this.refreshTrackLayout(),this.setTrackItemCoords();const s=this.getUpdatedState();this.state.updateState(s,e)}getUpdatedState(){const e=Gs(this.trackItemsMap);return{tracks:this.tracks,trackItemIds:this.trackItemIds,trackItemsMap:this.trackItemsMap,transitionIds:this.transitionIds,transitionsMap:this.transitionsMap,scale:this.scale,duration:e}}getDurationBasedOnTrackItemsPosition(){const e=this.getTrackItems().map(n=>n.getBoundingRect()),s=e.reduce((n,o)=>n.left+n.width<o.left+o.width?o:n,e[0]),r=s.left+s.width;return B(r,this.tScale)}notify(e={updateHistory:!1}){const s=this.getUpdatedState();this.state.updateState(s,e)}getState(){const e=Gs(this.trackItemsMap);return{tracks:this.tracks,trackItemIds:this.trackItemIds,trackItemsMap:this.trackItemsMap,transitionIds:this.transitionIds,transitionsMap:this.transitionsMap,scale:this.scale,duration:e}}purge(){ay(this),uy(this),fy(),this.dispose()}scrollTo({scrollLeft:e,scrollTop:s}){var o;const r=[...this.viewportTransform];let n=!1;typeof e=="number"&&(r[4]=-e+this.spacing.left,n=!0),typeof s=="number"&&(r[5]=-s,n=!0),n&&(this.viewportTransform=r,(o=this.getActiveObject())==null||o.setCoords(),this.requestRenderAll())}setBounding(e){this.bounding=e}calcBounding(){const e=this.getObjects("Track").filter(c=>c.static),s=[...this.getTrackItems(),...e].reduce((c,h)=>{const{top:l,height:u}=h.getBoundingRect();return{top:Math.min(c.top,l),height:Math.max(c.height,l+u)}},{top:1/0,height:0}),r=[...this.getTrackItems()].reduce((c,h)=>{const{left:l,width:u}=h.getBoundingRect();return{left:Math.min(c.left,l),width:Math.max(c.width,l+u)}},{left:1/0,width:this.width}),n=this.bounding.width,o=r.width,a=o-n;if(a<0){const c=this.getTrackItems(),h=this.getElement().clientWidth,l=c.reduce((u,d)=>d.left+d.width>u.left+u.width?d:u,c[0]);Math.abs(a)>h?this.setViewportPos(-(o-h)+this.spacing.right,this.viewportTransform[5]):l.left+l.width<=h?this.setViewportPos(16,this.viewportTransform[5]):this.setViewportPos(this.viewportTransform[4]-a,this.viewportTransform[5])}this.bounding={...s,...r},K.dispatch($h,{payload:{bounding:{...s,...r}}})}setViewportPos(e,s){var o;const r=this.getViewportPos(e,s),n=this.viewportTransform;n[4]=r.x,n[5]=r.y,this.requestRenderAll(),this.setActiveTrackItemCoords(),(o=this.onScroll)==null||o.call(this,{scrollTop:r.y,scrollLeft:r.x-this.spacing.left})}getViewportPos(e,s){const r=this,n=this.bounding.width-100>=r.width?this.spacing.right:0,o=r.width-this.bounding.width-n,a=this.spacing.left,c=Math.max(o,Math.min(e,a));if(this.bounding.height<this.height)return{x:c,y:0};const h=r.height-this.bounding.height-40,u=Math.max(h,Math.min(s,0));return{x:c,y:u}}setScale(e){this.pauseEventListeners(),this.tScale=e.zoom,this.scale=e,this.getTrackItems().forEach(r=>{const n=nt(r.display.from,this.tScale),o=nt(r.display.to-r.display.from,this.tScale,r.playbackRate);r.set({left:n,width:o,tScale:e.zoom}),r.onScale&&r.onScale(),r.setCoords()}),this.requestRenderAll(),this.calcBounding(),this.refreshTrackLayout(),this.updateTransitions(!1),this.resumeEventListeners()}};w(rr,"objectTypes",[]);let ys=rr;dy(ys,[ag,t0,Qv,cy]);const my={audio:Cn,media:Mn,common:oi,transition:On};M.BOTTOM=zd,M.CENTER=we,M.Control=Y,M.DRAG_END=Kn,M.DRAG_PREFIX=qn,M.DRAG_START=Uh,M.FabricObject=at,M.Helper=ce,M.LEFT=us,M.NONE=Hd,M.Pattern=Fr,M.Placeholder=ls,M.PreviewTrackItem=he,M.RIGHT=ds,M.Rect=Z,M.Resizable=ai,M.TIMELINE_BOUNDING_CHANGED=$h,M.TIMELINE_PREFIX=Jn,M.TIMELINE_SEEK=qh,M.TOP=Xd,M.Track=Lt,M.Transition=Rt,M.Trimmable=$t,M.calculateTimelineWidth=Gd,M.changeWidth=oi,M.classRegistry=C,M.controlsUtils=Xe,M.createAudioControls=sg,M.createMediaControls=Sc,M.createResizeControls=xc,M.createTemplateControls=eg,M.createTransitionControls=kn,M.default=ys,M.drawVerticalLine=Ft,M.generateId=fs,M.getDuration=Gs,M.isTransformCentered=gs,M.resize=my,M.resolveOrigin=I,M.timeMsToUnits=nt,M.unitsToTimeMs=B,M.util=Ga,M.wrapWithFixedAnchor=Vs,Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
498
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const s=-this.vibrance;for(let r=0;r<e.length;r+=4){const n=e[r],o=e[r+1],a=e[r+2],c=Math.max(n,o,a),h=(n+o+a)/3,l=2*Math.abs(c-h)/255*s;e[r]+=c!==n?(c-n)*l:0,e[r+1]+=c!==o?(c-o)*l:0,e[r+2]+=c!==a?(c-a)*l:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(ni,"type","Vibrance"),v(ni,"defaults",{vibrance:0}),v(ni,"uniformLocations",["uVibrance"]),C.setClass(ni);function Ft(i,t,e,s,r){const a=r.canvas;if(!a)return;const c=a.viewportTransform;i.save(),this.controlOrientation==="left"?i.translate(r.left+c[4],r.top+c[5]+r.height/2):i.translate(r.left+r.width+c[4],r.top+c[5]+r.height/2),i.rotate(Ga.degreesToRadians(90+r.angle)),i.lineWidth=6,i.lineCap="round",i.strokeStyle="white",i.beginPath(),i.moveTo(-6,0),i.lineTo(6,0),i.stroke(),i.lineWidth=4,i.strokeStyle="black",i.beginPath(),i.moveTo(-6,0),i.lineTo(6,0),i.stroke(),i.restore()}const Fd={selectable:!1,evented:!1,strokeWidth:0,stroke:"transparent"},bs=class bs extends Z{constructor(e){super(e);w(this,"id");w(this,"accepts",["audio","video","image","text","caption","template"]);w(this,"metadata");w(this,"items",[]);w(this,"magnetic");w(this,"static");Object.assign(this,bs.ownDefaults),this.id=e.id,this.accepts=e.accepts||[],this.items=e.items||[],this.magnetic=e.magnetic,this.static=e.static,this.metadata=e.metadata,this.fill="rgba(34, 34, 37, 0.8)"}static getDefaults(){return{...super.getDefaults(),...bs.ownDefaults}}updateCoords(e){this.width=e}};w(bs,"ownDefaults",Fd),w(bs,"type","Track");let Lt=bs;C.setClass(Lt,"Track");const Ys=1,He="rgba(255, 255, 255,1.0)",Ld=["Track","Transition","Helper","PreviewTrackItem"],Rd={top:{top:35,guide:2,bottom:3},center:{top:3,guide:2,bottom:3},bottom:{top:3,guide:2,bottom:35}},Bd=(i,t)=>{const e=Rd[i];return i==="top"?{top:t-(e.guide+e.bottom),guide:e.guide,bottom:e.bottom}:i==="center"?{top:e.top,guide:e.guide,bottom:e.bottom}:{top:e==null?void 0:e.top,guide:e==null?void 0:e.guide,bottom:t-((e==null?void 0:e.guide)+(e==null?void 0:e.top))}},_s=class _s extends Gt{constructor(e){const s=Bd(e.kind,e.height),r=new Z({top:0,left:0,strokeWidth:0,fill:"transparent",selectable:!0,height:s.top,width:e.width}),n=new Z({top:s.top,left:0,strokeWidth:0,fill:"transparent",selectable:!0,height:s.guide,width:e.width}),o=new Z({top:s.top+s.guide,left:0,strokeWidth:0,fill:"transparent",selectable:!0,height:s.bottom,width:e.width});super([r,n,o],e);w(this,"guide");w(this,"topGuide");w(this,"bottomGuide");w(this,"metadata");w(this,"accepts",[]);w(this,"kind");w(this,"activeGuideFill");Object.assign(this,_s.ownDefaults),this.guide=n,this.topGuide=r,this.bottomGuide=o,this.id=e.id,this.metadata=e.metadata,this.tScale=e.tScale,this.kind=e.kind,this.activeGuideFill=e.activeGuideFill||He}static getDefaults(){return{...super.getDefaults(),..._s.ownDefaults}}updateCoords(e){this.scaleToWidth(e),this.set("scaleY",1)}setSelected(e){e?this.guide.set("fill",this.activeGuideFill):this.guide.set("fill","transparent")}};w(_s,"type","Helper"),w(_s,"ownDefaults",{selectable:!1,evented:!1});let ce=_s;C.setClass(ce,"Helper");const Ts=class Ts extends Z{constructor(e){super(e);w(this,"guideItemId");w(this,"distXToActCenter");w(this,"trackItemType");w(this,"defaultPos");w(this,"draggedObject");Object.assign(this,Ts.ownDefaults),this.id=e.id}static getDefaults(){return{...super.getDefaults(),...Ts.ownDefaults}}_render(e){super._render(e),this.updateSelected(e)}updateSelected(e){e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.setLineDash(this.strokeDashArray),e.strokeStyle=He,e.stroke(),e.restore()}};w(Ts,"type","Placeholder"),w(Ts,"ownDefaults",{rx:6,ry:6,objectCaching:!1,borderColor:"transparent",strokeWidth:0,fill:"rgba(255, 211, 42,0.1)",stroke:"rgba(255, 211, 42,1.0)",selectable:!1,borderOpacityWhenMoving:1,hoverCursor:"default",strokeDashArray:[5,1],evented:!1});let ls=Ts;C.setClass(ls,"Placeholder");const Wd={left:-.5,top:-.5,center:0,bottom:.5,right:.5},I=i=>typeof i=="string"?Wd[i]:i-.5,we="center",us="left",Xd="top",zd="bottom",ds="right",Hd="none";function gs(i){return I(i.originX)===I(we)&&I(i.originY)===I(we)}function Vs(i){return(t,e,s,r)=>{const{target:n,originX:o,originY:a}=e,c=n.getRelativeCenterPoint(),h=n.translateToOriginPoint(c,o,a),l=i(t,e,s,r);return n.setPositionByOrigin(h,e.originX,e.originY),l}}const bc=3,Yd=4,_c=188,Vd=1e3/60;function nt(i,t=1,e=1){const s=_c*t;return i*(60/1e3)*s/e}function B(i,t=1,e=1){const s=_c*t;return i/s*Vd*e}function Gd(i,t=1){return nt(i,t)}const Gs=i=>Object.keys(i).reduce((t,e)=>{const{display:s}=i[e];return Math.max(t,s.to)},0),{wrapWithFireEvent:Nd,getLocalPoint:Ud}=Xe,Cn=Nd("resizing",Vs((i,t,e,s)=>{const r=Ud(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){let{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o);if(t.corner==="mr"){const u=n.trim.to,d=h-c,g=B(d,n.tScale,n.playbackRate),f=u+g;if(f>n.duration)return!1;n.set("width",Math.max(h,0)),n.trim.to=f}else{if(n.left<0)return!1;const u=c-h;if(n.left+u<0){const b=nt(n.duration,n.tScale,n.playbackRate),T=n.width+n.left;if(T<=b){n.set("width",T);const x=B(b-T,n.tScale,n.playbackRate);return n.trim.from=x,!0}return!1}const g=h-c,f=n.trim.from,p=B(g,n.tScale,n.playbackRate),m=f-p;if(m<0)return!1;n.set("width",Math.max(h,0)),n.trim.from=m,n.onResize&&n.onResize()}return c!==n.width}return!1})),{wrapWithFireEvent:$d,getLocalPoint:qd,wrapWithFixedAnchor:Kd}=Xe,oi=$d("resizing",Kd((i,t,e,s)=>{const r=qd(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o),l=t.corner==="ml";if(n.left<0)return!1;if(l){const g=c-h;if(n.left+g<0)return n.set("width",n.width+n.left),!0}const u=B(1,n.tScale);return B(h,n.tScale,n.playbackRate)<u?!1:(n.set("width",Math.max(h,0)),c!==n.width)}return!1})),{wrapWithFireEvent:Jd,getLocalPoint:Zd}=Xe,On=Jd("resizing",Vs((i,t,e,s)=>{const r=Zd(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o),l=B(h,n.tScale,n.playbackRate);return l>=1500||l<500?!1:(n.set("width",Math.max(h,0)),n.set("duration",l),c!==n.width)}return!1})),{wrapWithFireEvent:Qd,getLocalPoint:tg}=Xe,Tc=Qd("resizing",Vs((i,t,e,s)=>{const r=tg(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){let{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o);if(t.corner==="mr"){const u=n.trim.to,d=h-c,g=B(d,n.tScale,n.playbackRate),f=u+g;if(f>n.duration)return!1;n.set("width",Math.max(h,0)),n.trim.to=f}else{if(n.left<0)return!1;const u=c-h;if(n.left+u<0)return!1;const g=h-c,f=n.trim.from,p=B(g,n.tScale,n.playbackRate),m=f-p;if(m<0)return!1;n.set("width",Math.max(h,0)),n.trim.from=m}return c!==n.width}return!1})),{scaleSkewCursorStyleHandler:Ut}=Xe,xc=()=>({mr:new Y({x:.5,y:0,actionHandler:oi,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"right"}),ml:new Y({x:-.5,y:0,actionHandler:oi,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"left"})}),eg=()=>({mr:new Y({x:.5,y:0,render:Ft,actionHandler:Tc,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"right"}),ml:new Y({x:-.5,y:0,render:Ft,actionHandler:Tc,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"left"})}),sg=()=>({mr:new Y({x:.5,y:0,render:Ft,actionHandler:Cn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"right"}),ml:new Y({x:-.5,y:0,render:Ft,actionHandler:Cn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"left"})}),Sc=()=>({mr:new Y({x:.5,y:0,render:Ft,actionHandler:Mn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"right"}),ml:new Y({x:-.5,y:0,render:Ft,actionHandler:Mn,cursorStyleHandler:Ut,actionName:"resizing",controlOrientation:"left"})}),kn=()=>({mr:new Y({x:.5,y:0,actionHandler:On,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"right"}),ml:new Y({x:-.5,y:0,actionHandler:On,cursorStyleHandler:Ut,actionName:"resizing",render:Ft,controlOrientation:"left"})}),rg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ns=(i=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(i|=0));for(;i--;)t+=rg[e[i]&63];return t};function fs(i=16){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e=t.charAt(Math.floor(Math.random()*t.length));let s=Ns(i-1);return s=s.replace(/[^a-zA-Z0-9]/g,"").slice(0,i-1),e+s}const{wrapWithFireEvent:ig,getLocalPoint:ng}=Xe,Mn=ig("resizing",Vs((i,t,e,s)=>{const r=ng(t,t.originX,t.originY,e,s);if(I(t.originX)===I(we)||I(t.originX)===I(ds)&&r.x<0||I(t.originX)===I(us)&&r.x>0){let{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=gs(t)?2:1,c=n.width,h=Math.ceil(Math.abs(r.x*a/n.scaleX)-o);const l=B(1,n.tScale);if(t.corner==="mr"){const d=n.trim.to,g=h-c,f=B(g,n.tScale,n.playbackRate),p=d+f;if(p>n.duration)return!1;let m=B(h,n.tScale,n.playbackRate);if(m<l||(m=B(h,n.tScale,n.playbackRate),m<l))return!1;n.set("width",Math.max(h,0)),n.trim.to=p}else{if(n.left<0)return!1;const d=c-h;if(n.left+d<0){const x=nt(n.duration,n.tScale,n.playbackRate),S=n.width+n.left;if(S<=x){n.set("width",S);const O=B(x-S,n.tScale,n.playbackRate);return n.trim.from=O,!0}return!1}if(B(h,n.tScale,n.playbackRate)<l)return!1;const p=h-c,m=n.trim.from,b=B(p,n.tScale,n.playbackRate),T=m-b;if(T<0)return!1;n.set("width",Math.max(h,0)),n.trim.from=T,n.onResize&&n.onResize()}return c!==n.width}return!1})),xs=class xs extends Z{constructor(e){super(e);w(this,"duration");w(this,"fromId");w(this,"toId");w(this,"kind","none");w(this,"isSelected",!1);w(this,"availableDrop",!0);Object.assign(this,xs.ownDefaults),this.id=e.id,this.centeredScaling=!0,this.strokeWidth=0,this.tScale=e.tScale,this.duration=e.duration,this.fromId=e.fromId,this.toId=e.toId,this.kind=e.kind,this.strokeDashArray=e.strokeDashArray||[]}static createControls(){return{controls:kn()}}static getDefaults(){return{...super.getDefaults(),...xs.ownDefaults}}updateCoords(){}_render(e){super._render(e),this.updateSelected(e)}setSelected(e){this.isSelected=e,this.set({dirty:!0})}updateSelected(e){const s=this.availableDrop?this.isSelected?He:"rgba(255, 255, 255,0.15)":"red";e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.setLineDash(this.strokeDashArray),e.strokeStyle=s,e.stroke(),e.restore()}};w(xs,"type","Transition"),w(xs,"ownDefaults",{objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:1.5,fill:"rgba(0,0,0, 0.5)",borderOpacityWhenMoving:1,hoverCursor:"default",lockMovementX:!0,lockMovementY:!0,duration:1500,rx:8,ry:8});let Rt=xs;C.setClass(Rt,"Transition");const sr=class sr extends Z{constructor(e){super(e);w(this,"id");w(this,"resourceId","");w(this,"tScale");w(this,"isSelected",!1);w(this,"trim");w(this,"duration");Object.assign(this,sr.ownDefaults),this.id=e.id,this.tScale=e.tScale,this.objectCaching=!1,this.rx=8,this.ry=8}static createControls(){return{controls:Sc()}}_render(e){super._render(e),this.updateSelected(e)}setSelected(e){this.isSelected=e,this.set({dirty:!0})}updateSelected(e){this.isSelected&&(e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.strokeStyle=He,e.stroke(),e.restore())}onResizeSnap(){}setSrc(e){this.src=e}};w(sr,"type","Trimmable"),w(sr,"ownDefaults",{rx:6,ry:6,objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:0,fill:"#27272a",borderOpacityWhenMoving:1,hoverCursor:"default"});let $t=sr;C.setClass($t,"Trimmable");const Ss=class Ss extends Z{constructor(e){super(e);w(this,"isSelected",!1);Object.assign(this,Ss.ownDefaults),this.tScale=e.tScale,this.display=e.display}static createControls(){return{controls:xc()}}static getDefaults(){return{...super.getDefaults(),...Ss.ownDefaults}}setSelected(e){this.isSelected=e,this.set({dirty:!0})}_render(e){super._render(e),this.updateSelected(e)}updateSelected(e){this.isSelected&&(e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,6),e.lineWidth=Ys,e.strokeStyle=He,e.stroke(),e.restore())}};w(Ss,"type","Resizable"),w(Ss,"ownDefaults",{rx:6,ry:6,objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:0,fill:"#27272a",borderOpacityWhenMoving:1,hoverCursor:"default"});let ai=Ss;C.setClass(ai,"Resizable");function og(i){const t=Math.floor(i/1e3),e=Math.floor(t/60),s=t%60,r=String(e).padStart(2,"0"),n=String(s).padStart(2,"0");return`${r}:${n}`}const ws=class ws extends Z{constructor(e){super(e);w(this,"duration");w(this,"fromId");w(this,"toId");w(this,"isSelected",!1);w(this,"name");w(this,"durationString");w(this,"itemType");Object.assign(this,ws.ownDefaults),this.id=e.id,this.fill="#27272a",this.name=e.type.toUpperCase(),this.durationString=og(e.duration),this.itemType=e.type}static getDefaults(){return{...super.getDefaults(),...ws.ownDefaults}}_render(e){e.save(),super._render(e),e.beginPath(),e.rect(-this.width/2,-this.height/2,this.width,this.height),e.clip(),this.drawTextIdentity(e),e.restore()}drawTextIdentity(e){e.font="600 12px 'Geist variable'",e.textAlign="left";const s=e.measureText(this.name).width,r=e.measureText(this.durationString).width,n=8,o=4,a=4-this.height/2,c=20,h=4,l=4-this.width/2,u=s+n*2;this.drawRoundedRect(e,l,a,u,c,h),e.fillStyle="#f4f4f5",e.fillText(this.name,l+n,a+14);const d=l+u+o,g=r+n*2;this.drawRoundedRect(e,d,a,g,c,h),e.fillStyle="#f4f4f5",e.fillText(this.durationString,d+n,a+14)}drawRoundedRect(e,s,r,n,o,a){e.fillStyle="rgba(0, 0, 0, 0.5)",e.roundRect?(e.beginPath(),e.roundRect(s,r,n,o,a),e.fill()):e.fillRect(s,r,n,o)}};w(ws,"type","PreviewTrackItem"),w(ws,"ownDefaults",{objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:0,borderOpacityWhenMoving:1,hoverCursor:"default",rx:4,ry:4});let he=ws;C.setClass(he,"PreviewTrackItem");class ag{constructor(){w(this,"___eventListeners",{});w(this,"___activeObjects",[])}resize(t,{force:e}={force:!1}){var s;this.lowerCanvasEl&&(this.setDimensions(t),e&&this.renderTracks(),(s=this.onResizeCanvas)==null||s.call(this,{width:this.width,height:this.height}))}pauseEventListeners(){this.___eventListeners=this.__eventListeners,this.__eventListeners={};const t=this.getActiveObjects();this.discardActiveObject(),this.___activeObjects=t}resumeEventListeners(){this.__eventListeners=this.___eventListeners,this.___eventListeners={};const t=this.___activeObjects;if(!t.length)return this.requestRenderAll(),!1;if(t.length===1)this.setActiveObject(t[0]);else{const e=new Ct(t);this.setActiveObject(e)}this.requestRenderAll()}updateCachingActiveObjects(t){const e=this.___activeObjects;this.___activeObjects=e.map(s=>{const r=t.find(n=>n.id===s.id);return r||s})}}function Us(i,t){return i.map(e=>({...e,items:e.items.filter(s=>!t.includes(s))}))}const cg=(i,t)=>{var h,l,u,d,g;const e=i.display,s=nt(e.from,t.tScale),r=nt(e.to-e.from,t.tScale,i.playbackRate),n=t.sizesMap[i.type]||42,o=i.type.charAt(0).toUpperCase()+i.type.slice(1),a=C.getClass(o),c={width:r,height:n,id:i.id,tScale:t.tScale,top:10,left:s,display:e,duration:i.duration||e.to-e.from,metadata:i.metadata,playbackRate:i.playbackRate||1,src:(h=i.details)==null?void 0:h.src,trim:i.trim||{from:0,to:i.duration},text:(l=i.details)==null?void 0:l.text,srcs:((u=i.details)==null?void 0:u.srcs)||[],backgroundColorDiv:(d=i.details)==null?void 0:d.backgroundColor,svgString:(g=i.details)==null?void 0:g.svgString};return new a(c)};var wc=typeof global=="object"&&global&&global.Object===Object&&global,hg=typeof self=="object"&&self&&self.Object===Object&&self,Bt=wc||hg||Function("return this")(),kt=Bt.Symbol,Cc=Object.prototype,lg=Cc.hasOwnProperty,ug=Cc.toString,$s=kt?kt.toStringTag:void 0;function dg(i){var t=lg.call(i,$s),e=i[$s];try{i[$s]=void 0;var s=!0}catch{}var r=ug.call(i);return s&&(t?i[$s]=e:delete i[$s]),r}var gg=Object.prototype,fg=gg.toString;function pg(i){return fg.call(i)}var mg="[object Null]",vg="[object Undefined]",Oc=kt?kt.toStringTag:void 0;function ps(i){return i==null?i===void 0?vg:mg:Oc&&Oc in Object(i)?dg(i):pg(i)}function Ce(i){return i!=null&&typeof i=="object"}var yg="[object Symbol]";function ci(i){return typeof i=="symbol"||Ce(i)&&ps(i)==yg}function bg(i,t){for(var e=-1,s=i==null?0:i.length,r=Array(s);++e<s;)r[e]=t(i[e],e,i);return r}var qt=Array.isArray,kc=kt?kt.prototype:void 0,Mc=kc?kc.toString:void 0;function Dc(i){if(typeof i=="string")return i;if(qt(i))return bg(i,Dc)+"";if(ci(i))return Mc?Mc.call(i):"";var t=i+"";return t=="0"&&1/i==-1/0?"-0":t}var _g=/\s/;function Tg(i){for(var t=i.length;t--&&_g.test(i.charAt(t)););return t}var xg=/^\s+/;function Sg(i){return i&&i.slice(0,Tg(i)+1).replace(xg,"")}function Kt(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var jc=NaN,wg=/^[-+]0x[0-9a-f]+$/i,Cg=/^0b[01]+$/i,Og=/^0o[0-7]+$/i,kg=parseInt;function Ec(i){if(typeof i=="number")return i;if(ci(i))return jc;if(Kt(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Kt(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Sg(i);var e=Cg.test(i);return e||Og.test(i)?kg(i.slice(2),e?2:8):wg.test(i)?jc:+i}function Mg(i){return i}var Dg="[object AsyncFunction]",jg="[object Function]",Eg="[object GeneratorFunction]",Ig="[object Proxy]";function Ic(i){if(!Kt(i))return!1;var t=ps(i);return t==jg||t==Eg||t==Dg||t==Ig}var Dn=Bt["__core-js_shared__"],Pc=function(){var i=/[^.]+$/.exec(Dn&&Dn.keys&&Dn.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Pg(i){return!!Pc&&Pc in i}var Ag=Function.prototype,Fg=Ag.toString;function Ye(i){if(i!=null){try{return Fg.call(i)}catch{}try{return i+""}catch{}}return""}var Lg=/[\\^$.*+?()[\]{}|]/g,Rg=/^\[object .+?Constructor\]$/,Bg=Function.prototype,Wg=Object.prototype,Xg=Bg.toString,zg=Wg.hasOwnProperty,Hg=RegExp("^"+Xg.call(zg).replace(Lg,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Yg(i){if(!Kt(i)||Pg(i))return!1;var t=Ic(i)?Hg:Rg;return t.test(Ye(i))}function Vg(i,t){return i==null?void 0:i[t]}function Ve(i,t){var e=Vg(i,t);return Yg(e)?e:void 0}var jn=Ve(Bt,"WeakMap"),Ac=Object.create,Gg=function(){function i(){}return function(t){if(!Kt(t))return{};if(Ac)return Ac(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}();function Ng(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Ug=800,$g=16,qg=Date.now;function Kg(i){var t=0,e=0;return function(){var s=qg(),r=$g-(s-e);if(e=s,r>0){if(++t>=Ug)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}function Jg(i){return function(){return i}}var hi=function(){try{var i=Ve(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Zg=hi?function(i,t){return hi(i,"toString",{configurable:!0,enumerable:!1,value:Jg(t),writable:!0})}:Mg,Qg=Kg(Zg);function tf(i,t){for(var e=-1,s=i==null?0:i.length;++e<s&&t(i[e],e,i)!==!1;);return i}var ef=9007199254740991,sf=/^(?:0|[1-9]\d*)$/;function En(i,t){var e=typeof i;return t=t??ef,!!t&&(e=="number"||e!="symbol"&&sf.test(i))&&i>-1&&i%1==0&&i<t}function rf(i,t,e){t=="__proto__"&&hi?hi(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}function In(i,t){return i===t||i!==i&&t!==t}var nf=Object.prototype,of=nf.hasOwnProperty;function Fc(i,t,e){var s=i[t];(!(of.call(i,t)&&In(s,e))||e===void 0&&!(t in i))&&rf(i,t,e)}var Lc=Math.max;function af(i,t,e){return t=Lc(t===void 0?i.length-1:t,0),function(){for(var s=arguments,r=-1,n=Lc(s.length-t,0),o=Array(n);++r<n;)o[r]=s[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=s[r];return a[t]=e(o),Ng(i,this,a)}}var cf=9007199254740991;function Pn(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=cf}function hf(i){return i!=null&&Pn(i.length)&&!Ic(i)}var lf=Object.prototype;function Rc(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||lf;return i===e}function uf(i,t){for(var e=-1,s=Array(i);++e<i;)s[e]=t(e);return s}var df="[object Arguments]";function Bc(i){return Ce(i)&&ps(i)==df}var Wc=Object.prototype,gf=Wc.hasOwnProperty,ff=Wc.propertyIsEnumerable,An=Bc(function(){return arguments}())?Bc:function(i){return Ce(i)&&gf.call(i,"callee")&&!ff.call(i,"callee")};function pf(){return!1}var Xc=typeof M=="object"&&M&&!M.nodeType&&M,zc=Xc&&typeof module=="object"&&module&&!module.nodeType&&module,mf=zc&&zc.exports===Xc,Hc=mf?Bt.Buffer:void 0,vf=Hc?Hc.isBuffer:void 0,li=vf||pf,yf="[object Arguments]",bf="[object Array]",_f="[object Boolean]",Tf="[object Date]",xf="[object Error]",Sf="[object Function]",wf="[object Map]",Cf="[object Number]",Of="[object Object]",kf="[object RegExp]",Mf="[object Set]",Df="[object String]",jf="[object WeakMap]",Ef="[object ArrayBuffer]",If="[object DataView]",Pf="[object Float32Array]",Af="[object Float64Array]",Ff="[object Int8Array]",Lf="[object Int16Array]",Rf="[object Int32Array]",Bf="[object Uint8Array]",Wf="[object Uint8ClampedArray]",Xf="[object Uint16Array]",zf="[object Uint32Array]",X={};X[Pf]=X[Af]=X[Ff]=X[Lf]=X[Rf]=X[Bf]=X[Wf]=X[Xf]=X[zf]=!0,X[yf]=X[bf]=X[Ef]=X[_f]=X[If]=X[Tf]=X[xf]=X[Sf]=X[wf]=X[Cf]=X[Of]=X[kf]=X[Mf]=X[Df]=X[jf]=!1;function Hf(i){return Ce(i)&&Pn(i.length)&&!!X[ps(i)]}function Fn(i){return function(t){return i(t)}}var Yc=typeof M=="object"&&M&&!M.nodeType&&M,qs=Yc&&typeof module=="object"&&module&&!module.nodeType&&module,Yf=qs&&qs.exports===Yc,Ln=Yf&&wc.process,ms=function(){try{var i=qs&&qs.require&&qs.require("util").types;return i||Ln&&Ln.binding&&Ln.binding("util")}catch{}}(),Vc=ms&&ms.isTypedArray,Gc=Vc?Fn(Vc):Hf,Vf=Object.prototype,Gf=Vf.hasOwnProperty;function Nf(i,t){var e=qt(i),s=!e&&An(i),r=!e&&!s&&li(i),n=!e&&!s&&!r&&Gc(i),o=e||s||r||n,a=o?uf(i.length,String):[],c=a.length;for(var h in i)Gf.call(i,h)&&!(o&&(h=="length"||r&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||En(h,c)))&&a.push(h);return a}function Nc(i,t){return function(e){return i(t(e))}}var Uf=Nc(Object.keys,Object),$f=Object.prototype,qf=$f.hasOwnProperty;function Kf(i){if(!Rc(i))return Uf(i);var t=[];for(var e in Object(i))qf.call(i,e)&&e!="constructor"&&t.push(e);return t}function Jf(i){return hf(i)?Nf(i):Kf(i)}var Zf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qf=/^\w*$/;function tp(i,t){if(qt(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||ci(i)?!0:Qf.test(i)||!Zf.test(i)||t!=null&&i in Object(t)}var Ks=Ve(Object,"create");function ep(){this.__data__=Ks?Ks(null):{},this.size=0}function sp(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var rp="__lodash_hash_undefined__",ip=Object.prototype,np=ip.hasOwnProperty;function op(i){var t=this.__data__;if(Ks){var e=t[i];return e===rp?void 0:e}return np.call(t,i)?t[i]:void 0}var ap=Object.prototype,cp=ap.hasOwnProperty;function hp(i){var t=this.__data__;return Ks?t[i]!==void 0:cp.call(t,i)}var lp="__lodash_hash_undefined__";function up(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Ks&&t===void 0?lp:t,this}function Ge(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}Ge.prototype.clear=ep,Ge.prototype.delete=sp,Ge.prototype.get=op,Ge.prototype.has=hp,Ge.prototype.set=up;function dp(){this.__data__=[],this.size=0}function ui(i,t){for(var e=i.length;e--;)if(In(i[e][0],t))return e;return-1}var gp=Array.prototype,fp=gp.splice;function pp(i){var t=this.__data__,e=ui(t,i);if(e<0)return!1;var s=t.length-1;return e==s?t.pop():fp.call(t,e,1),--this.size,!0}function mp(i){var t=this.__data__,e=ui(t,i);return e<0?void 0:t[e][1]}function vp(i){return ui(this.__data__,i)>-1}function yp(i,t){var e=this.__data__,s=ui(e,i);return s<0?(++this.size,e.push([i,t])):e[s][1]=t,this}function le(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}le.prototype.clear=dp,le.prototype.delete=pp,le.prototype.get=mp,le.prototype.has=vp,le.prototype.set=yp;var Js=Ve(Bt,"Map");function bp(){this.size=0,this.__data__={hash:new Ge,map:new(Js||le),string:new Ge}}function _p(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}function di(i,t){var e=i.__data__;return _p(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Tp(i){var t=di(this,i).delete(i);return this.size-=t?1:0,t}function xp(i){return di(this,i).get(i)}function Sp(i){return di(this,i).has(i)}function wp(i,t){var e=di(this,i),s=e.size;return e.set(i,t),this.size+=e.size==s?0:1,this}function ue(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var s=i[t];this.set(s[0],s[1])}}ue.prototype.clear=bp,ue.prototype.delete=Tp,ue.prototype.get=xp,ue.prototype.has=Sp,ue.prototype.set=wp;var Cp="Expected a function";function Rn(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(Cp);var e=function(){var s=arguments,r=t?t.apply(this,s):s[0],n=e.cache;if(n.has(r))return n.get(r);var o=i.apply(this,s);return e.cache=n.set(r,o)||n,o};return e.cache=new(Rn.Cache||ue),e}Rn.Cache=ue;var Op=500;function kp(i){var t=Rn(i,function(s){return e.size===Op&&e.clear(),s}),e=t.cache;return t}var Mp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Dp=/\\(\\)?/g,jp=kp(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(Mp,function(e,s,r,n){t.push(r?n.replace(Dp,"$1"):s||e)}),t});function Ep(i){return i==null?"":Dc(i)}function gi(i,t){return qt(i)?i:tp(i,t)?[i]:jp(Ep(i))}function Bn(i){if(typeof i=="string"||ci(i))return i;var t=i+"";return t=="0"&&1/i==-1/0?"-0":t}function Ip(i,t){t=gi(t,i);for(var e=0,s=t.length;i!=null&&e<s;)i=i[Bn(t[e++])];return e&&e==s?i:void 0}function Uc(i,t){for(var e=-1,s=t.length,r=i.length;++e<s;)i[r+e]=t[e];return i}var $c=kt?kt.isConcatSpreadable:void 0;function Pp(i){return qt(i)||An(i)||!!($c&&i&&i[$c])}function Ap(i,t,e,s,r){var n=-1,o=i.length;for(e||(e=Pp),r||(r=[]);++n<o;){var a=i[n];e(a)?Uc(r,a):r[r.length]=a}return r}function Wn(i){var t=i==null?0:i.length;return t?Ap(i):[]}function Fp(i){return Qg(af(i,void 0,Wn),i+"")}var Lp=Nc(Object.getPrototypeOf,Object);function Rp(){this.__data__=new le,this.size=0}function Bp(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}function Wp(i){return this.__data__.get(i)}function Xp(i){return this.__data__.has(i)}var zp=200;function Hp(i,t){var e=this.__data__;if(e instanceof le){var s=e.__data__;if(!Js||s.length<zp-1)return s.push([i,t]),this.size=++e.size,this;e=this.__data__=new ue(s)}return e.set(i,t),this.size=e.size,this}function de(i){var t=this.__data__=new le(i);this.size=t.size}de.prototype.clear=Rp,de.prototype.delete=Bp,de.prototype.get=Wp,de.prototype.has=Xp,de.prototype.set=Hp;var qc=typeof M=="object"&&M&&!M.nodeType&&M,Kc=qc&&typeof module=="object"&&module&&!module.nodeType&&module,Yp=Kc&&Kc.exports===qc,Jc=Yp?Bt.Buffer:void 0;Jc&&Jc.allocUnsafe;function Vp(i,t){return i.slice()}function Gp(i,t){for(var e=-1,s=i==null?0:i.length,r=0,n=[];++e<s;){var o=i[e];t(o,e,i)&&(n[r++]=o)}return n}function Np(){return[]}var Up=Object.prototype,$p=Up.propertyIsEnumerable,Zc=Object.getOwnPropertySymbols,qp=Zc?function(i){return i==null?[]:(i=Object(i),Gp(Zc(i),function(t){return $p.call(i,t)}))}:Np;function Kp(i,t,e){var s=t(i);return qt(i)?s:Uc(s,e(i))}function Xn(i){return Kp(i,Jf,qp)}var zn=Ve(Bt,"DataView"),Hn=Ve(Bt,"Promise"),Yn=Ve(Bt,"Set"),Qc="[object Map]",Jp="[object Object]",th="[object Promise]",eh="[object Set]",sh="[object WeakMap]",rh="[object DataView]",Zp=Ye(zn),Qp=Ye(Js),tm=Ye(Hn),em=Ye(Yn),sm=Ye(jn),Wt=ps;(zn&&Wt(new zn(new ArrayBuffer(1)))!=rh||Js&&Wt(new Js)!=Qc||Hn&&Wt(Hn.resolve())!=th||Yn&&Wt(new Yn)!=eh||jn&&Wt(new jn)!=sh)&&(Wt=function(i){var t=ps(i),e=t==Jp?i.constructor:void 0,s=e?Ye(e):"";if(s)switch(s){case Zp:return rh;case Qp:return Qc;case tm:return th;case em:return eh;case sm:return sh}return t});var rm=Object.prototype,im=rm.hasOwnProperty;function nm(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&im.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var fi=Bt.Uint8Array;function Vn(i){var t=new i.constructor(i.byteLength);return new fi(t).set(new fi(i)),t}function om(i,t){var e=Vn(i.buffer);return new i.constructor(e,i.byteOffset,i.byteLength)}var am=/\w*$/;function cm(i){var t=new i.constructor(i.source,am.exec(i));return t.lastIndex=i.lastIndex,t}var ih=kt?kt.prototype:void 0,nh=ih?ih.valueOf:void 0;function hm(i){return nh?Object(nh.call(i)):{}}function lm(i,t){var e=Vn(i.buffer);return new i.constructor(e,i.byteOffset,i.length)}var um="[object Boolean]",dm="[object Date]",gm="[object Map]",fm="[object Number]",pm="[object RegExp]",mm="[object Set]",vm="[object String]",ym="[object Symbol]",bm="[object ArrayBuffer]",_m="[object DataView]",Tm="[object Float32Array]",xm="[object Float64Array]",Sm="[object Int8Array]",wm="[object Int16Array]",Cm="[object Int32Array]",Om="[object Uint8Array]",km="[object Uint8ClampedArray]",Mm="[object Uint16Array]",Dm="[object Uint32Array]";function jm(i,t,e){var s=i.constructor;switch(t){case bm:return Vn(i);case um:case dm:return new s(+i);case _m:return om(i);case Tm:case xm:case Sm:case wm:case Cm:case Om:case km:case Mm:case Dm:return lm(i);case gm:return new s;case fm:case vm:return new s(i);case pm:return cm(i);case mm:return new s;case ym:return hm(i)}}function Em(i){return typeof i.constructor=="function"&&!Rc(i)?Gg(Lp(i)):{}}var Im="[object Map]";function Pm(i){return Ce(i)&&Wt(i)==Im}var oh=ms&&ms.isMap,Am=oh?Fn(oh):Pm,Fm="[object Set]";function Lm(i){return Ce(i)&&Wt(i)==Fm}var ah=ms&&ms.isSet,Rm=ah?Fn(ah):Lm,ch="[object Arguments]",Bm="[object Array]",Wm="[object Boolean]",Xm="[object Date]",zm="[object Error]",hh="[object Function]",Hm="[object GeneratorFunction]",Ym="[object Map]",Vm="[object Number]",lh="[object Object]",Gm="[object RegExp]",Nm="[object Set]",Um="[object String]",$m="[object Symbol]",qm="[object WeakMap]",Km="[object ArrayBuffer]",Jm="[object DataView]",Zm="[object Float32Array]",Qm="[object Float64Array]",tv="[object Int8Array]",ev="[object Int16Array]",sv="[object Int32Array]",rv="[object Uint8Array]",iv="[object Uint8ClampedArray]",nv="[object Uint16Array]",ov="[object Uint32Array]",W={};W[ch]=W[Bm]=W[Km]=W[Jm]=W[Wm]=W[Xm]=W[Zm]=W[Qm]=W[tv]=W[ev]=W[sv]=W[Ym]=W[Vm]=W[lh]=W[Gm]=W[Nm]=W[Um]=W[$m]=W[rv]=W[iv]=W[nv]=W[ov]=!0,W[zm]=W[hh]=W[qm]=!1;function pi(i,t,e,s,r,n){var o;if(o!==void 0)return o;if(!Kt(i))return i;var a=qt(i);if(a)o=nm(i);else{var c=Wt(i),h=c==hh||c==Hm;if(li(i))return Vp(i);if(c==lh||c==ch||h&&!r)o=h?{}:Em(i);else{if(!W[c])return r?i:{};o=jm(i,c)}}n||(n=new de);var l=n.get(i);if(l)return l;n.set(i,o),Rm(i)?i.forEach(function(g){o.add(pi(g,t,e,g,i,n))}):Am(i)&&i.forEach(function(g,f){o.set(f,pi(g,t,e,f,i,n))});var u=Xn,d=a?void 0:u(i);return tf(d||i,function(g,f){d&&(f=g,g=i[f]),Fc(o,f,pi(g,t,e,f,i,n))}),o}var av=1,cv=4;function Ne(i){return pi(i,av|cv)}var hv="__lodash_hash_undefined__";function lv(i){return this.__data__.set(i,hv),this}function uv(i){return this.__data__.has(i)}function mi(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new ue;++t<e;)this.add(i[t])}mi.prototype.add=mi.prototype.push=lv,mi.prototype.has=uv;function dv(i,t){for(var e=-1,s=i==null?0:i.length;++e<s;)if(t(i[e],e,i))return!0;return!1}function gv(i,t){return i.has(t)}var fv=1,pv=2;function uh(i,t,e,s,r,n){var o=e&fv,a=i.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var h=n.get(i),l=n.get(t);if(h&&l)return h==t&&l==i;var u=-1,d=!0,g=e&pv?new mi:void 0;for(n.set(i,t),n.set(t,i);++u<a;){var f=i[u],p=t[u];if(s)var m=o?s(p,f,u,t,i,n):s(f,p,u,i,t,n);if(m!==void 0){if(m)continue;d=!1;break}if(g){if(!dv(t,function(b,T){if(!gv(g,T)&&(f===b||r(f,b,e,s,n)))return g.push(T)})){d=!1;break}}else if(!(f===p||r(f,p,e,s,n))){d=!1;break}}return n.delete(i),n.delete(t),d}function mv(i){var t=-1,e=Array(i.size);return i.forEach(function(s,r){e[++t]=[r,s]}),e}function vv(i){var t=-1,e=Array(i.size);return i.forEach(function(s){e[++t]=s}),e}var yv=1,bv=2,_v="[object Boolean]",Tv="[object Date]",xv="[object Error]",Sv="[object Map]",wv="[object Number]",Cv="[object RegExp]",Ov="[object Set]",kv="[object String]",Mv="[object Symbol]",Dv="[object ArrayBuffer]",jv="[object DataView]",dh=kt?kt.prototype:void 0,Gn=dh?dh.valueOf:void 0;function Ev(i,t,e,s,r,n,o){switch(e){case jv:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case Dv:return!(i.byteLength!=t.byteLength||!n(new fi(i),new fi(t)));case _v:case Tv:case wv:return In(+i,+t);case xv:return i.name==t.name&&i.message==t.message;case Cv:case kv:return i==t+"";case Sv:var a=mv;case Ov:var c=s&yv;if(a||(a=vv),i.size!=t.size&&!c)return!1;var h=o.get(i);if(h)return h==t;s|=bv,o.set(i,t);var l=uh(a(i),a(t),s,r,n,o);return o.delete(i),l;case Mv:if(Gn)return Gn.call(i)==Gn.call(t)}return!1}var Iv=1,Pv=Object.prototype,Av=Pv.hasOwnProperty;function Fv(i,t,e,s,r,n){var o=e&Iv,a=Xn(i),c=a.length,h=Xn(t),l=h.length;if(c!=l&&!o)return!1;for(var u=c;u--;){var d=a[u];if(!(o?d in t:Av.call(t,d)))return!1}var g=n.get(i),f=n.get(t);if(g&&f)return g==t&&f==i;var p=!0;n.set(i,t),n.set(t,i);for(var m=o;++u<c;){d=a[u];var b=i[d],T=t[d];if(s)var x=o?s(T,b,d,t,i,n):s(b,T,d,i,t,n);if(!(x===void 0?b===T||r(b,T,e,s,n):x)){p=!1;break}m||(m=d=="constructor")}if(p&&!m){var S=i.constructor,O=t.constructor;S!=O&&"constructor"in i&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof O=="function"&&O instanceof O)&&(p=!1)}return n.delete(i),n.delete(t),p}var Lv=1,gh="[object Arguments]",fh="[object Array]",vi="[object Object]",Rv=Object.prototype,ph=Rv.hasOwnProperty;function Bv(i,t,e,s,r,n){var o=qt(i),a=qt(t),c=o?fh:Wt(i),h=a?fh:Wt(t);c=c==gh?vi:c,h=h==gh?vi:h;var l=c==vi,u=h==vi,d=c==h;if(d&&li(i)){if(!li(t))return!1;o=!0,l=!1}if(d&&!l)return n||(n=new de),o||Gc(i)?uh(i,t,e,s,r,n):Ev(i,t,c,e,s,r,n);if(!(e&Lv)){var g=l&&ph.call(i,"__wrapped__"),f=u&&ph.call(t,"__wrapped__");if(g||f){var p=g?i.value():i,m=f?t.value():t;return n||(n=new de),r(p,m,e,s,n)}}return d?(n||(n=new de),Fv(i,t,e,s,r,n)):!1}function mh(i,t,e,s,r){return i===t?!0:i==null||t==null||!Ce(i)&&!Ce(t)?i!==i&&t!==t:Bv(i,t,e,s,mh,r)}function Wv(i,t){return i!=null&&t in Object(i)}function Xv(i,t,e){t=gi(t,i);for(var s=-1,r=t.length,n=!1;++s<r;){var o=Bn(t[s]);if(!(n=i!=null&&e(i,o)))break;i=i[o]}return n||++s!=r?n:(r=i==null?0:i.length,!!r&&Pn(r)&&En(o,r)&&(qt(i)||An(i)))}function zv(i,t){return i!=null&&Xv(i,t,Wv)}var Nn=function(){return Bt.Date.now()},Hv="Expected a function",Yv=Math.max,Vv=Math.min;function Gv(i,t,e){var s,r,n,o,a,c,h=0,l=!1,u=!1,d=!0;if(typeof i!="function")throw new TypeError(Hv);t=Ec(t)||0,Kt(e)&&(l=!!e.leading,u="maxWait"in e,n=u?Yv(Ec(e.maxWait)||0,t):n,d="trailing"in e?!!e.trailing:d);function g(k){var j=s,D=r;return s=r=void 0,h=k,o=i.apply(D,j),o}function f(k){return h=k,a=setTimeout(b,t),l?g(k):o}function p(k){var j=k-c,D=k-h,F=t-j;return u?Vv(F,n-D):F}function m(k){var j=k-c,D=k-h;return c===void 0||j>=t||j<0||u&&D>=n}function b(){var k=Nn();if(m(k))return T(k);a=setTimeout(b,p(k))}function T(k){return a=void 0,d&&s?g(k):(s=r=void 0,o)}function x(){a!==void 0&&clearTimeout(a),h=0,s=c=r=a=void 0}function S(){return a===void 0?o:T(Nn())}function O(){var k=Nn(),j=m(k);if(s=arguments,r=this,c=k,j){if(a===void 0)return f(c);if(u)return clearTimeout(a),a=setTimeout(b,t),g(c)}return a===void 0&&(a=setTimeout(b,t)),o}return O.cancel=x,O.flush=S,O}function Nv(i,t){return mh(i,t)}function Uv(i,t,e,s){if(!Kt(i))return i;t=gi(t,i);for(var r=-1,n=t.length,o=n-1,a=i;a!=null&&++r<n;){var c=Bn(t[r]),h=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return i;if(r!=o){var l=a[c];h=void 0,h===void 0&&(h=Kt(l)?l:En(t[r+1])?[]:{})}Fc(a,c,h),a=a[c]}return i}function $v(i,t,e){for(var s=-1,r=t.length,n={};++s<r;){var o=t[s],a=Ip(i,o);e(a,o)&&Uv(n,gi(o,i),a)}return n}function qv(i,t){return $v(i,t,function(e,s){return zv(i,s)})}var Kv=Fp(function(i,t){return i==null?{}:qv(i,t)}),Jv="Expected a function";function Zv(i,t,e){var s=!0,r=!0;if(typeof i!="function")throw new TypeError(Jv);return Kt(e)&&(s="leading"in e?!!e.leading:s,r="trailing"in e?!!e.trailing:r),Gv(i,t,{leading:s,maxWait:t,trailing:r})}class Qv{addTrackItem(t){const e=cg(t,{tScale:this.tScale,sizesMap:this.sizesMap});this.add(e)}alignItemsToTrack(){this.pauseEventListeners();const t=new Map(this.getObjects("Track").map(r=>[r.id,r])),e=this.getTrackItems(),s=this.getObjects("Transition");this.trackItemIds.forEach(r=>{const n=this.tracks.find(c=>c.items.includes(r));if(!n)return;const o=t.get(n.id),a=this.getTrackItems().find(c=>c.id===r);a&&o&&(a.isMain=o.magnetic,this.trackItemsMap[r].isMain=o.magnetic,a.set({top:o.top}),a.setCoords())}),t.forEach(r=>{r.items=e.filter(n=>n.top===r.top).map(n=>n.id)}),s.forEach(r=>{const n=r.fromId,o=e.find(a=>a.id===n);o&&(r.set({top:o.top}),r.setCoords())}),this.resumeEventListeners()}updateTrackItemsToHistory(){this.pauseEventListeners(),this.trackItemIds.forEach(t=>{const e=this.tracks.find(c=>c.items.includes(t)),s=this.getObjects().find(c=>c.id===(e==null?void 0:e.id)).top,r=this.trackItemsMap[t],n=this.getObjects().find(c=>c.id===t),o=nt(r.display.from,this.tScale),a=nt(r.display.to-r.display.from,this.tScale,r.playbackRate);if(n.set({left:o,width:a,top:s}),n instanceof $t){const c=n.display.to-n.display.from;n.setDuration?n.setDuration(c):n.set({duration:c}),r.trim=n.trim,r.display=n.display}n.setCoords()}),this.requestRenderAll(),this.resumeEventListeners()}deleteTrackItemToHistory(t){this.getObjects().filter(e=>t.includes(e.id)).map(e=>this.remove(e)),this.alignItemsToTrack(),this.requestRenderAll()}uodateTrackItemIdsOrdering(){const t=this.getTrackItems();t.sort((e,s)=>e.top-s.top),this.trackItemIds=t.map(e=>e.id).reverse()}selectTrackItemByIds(t){const e=this.getActiveObjects().map(n=>n.id);if(Nv(e,t))return;const r=this.getObjects(...ys.objectTypes,"Transition").filter(n=>t.includes(n.id));if(!r.length)this.discardActiveObject();else if(r.length===1)this.setActiveObject(r[0]);else{const n=new Ct(r);this.setActiveObject(n)}this.requestRenderAll()}synchronizeTrackItemsState(){this.pauseEventListeners();const t=this.getTrackItems(),e={};t.forEach(s=>{const{id:r,left:n,width:o}=s,a=this.trackItemsMap[r],c=B(n,this.tScale),h=B(o,this.tScale),l={from:c,to:c+h},u={display:l};s instanceof $t&&(u.trim=s.trim),s.display=l,e[r]={...a,...u}}),this.trackItemsMap={...this.trackItemsMap,...e},this.resumeEventListeners()}deleteTrackItemById(t){const e=t,s=this.getObjects().filter(a=>t.includes(a.id)),r=Us(this.tracks,e),n={};Object.keys(this.trackItemsMap).forEach(a=>{e.includes(a)||(n[a]=this.trackItemsMap[a])});const o=this.trackItemIds.filter(a=>!e.includes(a));this.tracks=r,this.trackItemsMap=n,this.trackItemIds=o,this.discardActiveObject(),this.remove(...s),this.renderTracks(),this.alignItemsToTrack()}deleteActiveTrackItem(){const t=this.getActiveObjects();if(!t.length)return!1;const e=t.map(o=>o.id),s=Us(this.tracks,e),r={};Object.keys(this.trackItemsMap).forEach(o=>{e.includes(o)||(r[o]=this.trackItemsMap[o])});const n=this.trackItemIds.filter(o=>!e.includes(o));this.tracks=s,this.trackItemsMap=r,this.trackItemIds=n,this.discardActiveObject(),this.remove(...t),this.setActiveIds([]),this.renderTracks(),this.alignItemsToTrack(),this.updateState({updateHistory:!0,kind:"remove"})}updateTrackItemCoords(t){const e=t?this.getActiveObjects().map(s=>s.id):[];!t&&this.pauseEventListeners(),this.trackItemIds.forEach(s=>{if(e.includes(s))return;const r=this.getObjects().find(c=>c.id===s),n=this.trackItemsMap[s],o=nt(n.display.from,this.tScale),a=nt(n.display.to-n.display.from,this.tScale);r.set({left:o,width:a}),r.setCoords()}),!t&&this.resumeEventListeners()}getTrackItems(){return this.getObjects(...ys.objectTypes)}setTrackItemCoords(){this.getTrackItems().forEach(t=>{t.setCoords()})}setActiveTrackItemCoords(){this.getActiveObjects().forEach(e=>e.setCoords())}}const vh=i=>{switch(i){case"top":return 1e3;case"bottom":return 1e3;case"center":return 8;default:return 1e3}};class t0{findOrCreateTrack(t,{trackId:e,trackIndex:s}){if(e){const o=this.tracks.find(a=>a.id===e);if(o)return o.items.push(t.id),e}const r=this.getItemAccepts(t.type),n={id:Ns(),items:[t.id],type:t.type,accepts:r,magnetic:!1,static:!1};return s!==void 0?this.tracks.splice(s,0,n):this.tracks.push(n),this.renderTracks(),n.id}removeTracks(){this.getObjects("Track","Helper").forEach(e=>this.remove(e))}renderTracks(){this.filterEmptyTracks(),this.removeTracks();const t=this.width,e=this.tracks.flatMap(a=>[a,{id:`helper-${a.id}`,type:"helper",items:[],accepts:[]}]).slice(0,-1);let s=-970;const r=C.getClass("Helper")||ce,n=new r({top:s,selectable:!1,evented:!1,tScale:this.tScale,id:"helper-line-top",width:t,kind:"top",height:1e3,metadata:{}});s+=vh("top"),this.insertAt(0,n),e.forEach((a,c)=>{if(a.type==="helper"){const h=vh("center"),l=new r({id:a.id,top:s,tScale:this.tScale,width:t,height:h,metadata:{order:(c+1)/2},kind:"center"});s+=h,this.insertAt(0,l)}else{const h=this.getItemSize(a.type),l=C.getClass("Track")||Lt,u=this.getItemAccepts(a.type),d=new l({id:a.id,top:s,left:0,height:h,width:t,tScale:this.tScale,accepts:u,items:a.items,magnetic:a.magnetic,static:a.static});s+=h,this.insertAt(0,d)}});const o=new r({id:"helper-line-bottom",top:s,selectable:!1,evented:!1,tScale:this.tScale,width:t,kind:"bottom",height:1e3,metadata:{}});this.insertAt(0,o)}filterEmptyTracks(){const t=new Set;this.tracks=this.tracks.filter(e=>(e.items.length||e.static)&&!t.has(e.id)?(t.add(e.id),!0):!1)}refreshTrackLayout(){const t=this.bounding.width+this.spacing.right;this.getObjects("Track","Helper").forEach(e=>{e.updateCoords(t),e.setCoords()})}adjustMagneticTrack(){this.pauseEventListeners();const t=this.tracks.filter(e=>e.magnetic);t.length>0&&t.forEach(e=>{const s=e.accepts||[],r=this.getObjects(...s).filter(o=>e.items.includes(o.id)).sort((o,a)=>o.left-a.left);let n=0;r.forEach(o=>{o.left=n,n+=o.width})}),this.resumeEventListeners()}}function yh(i){const t=this,e=i.target,s=i.transform;if(s.action==="resizing"){const r=t.getObjects().filter(l=>l!==e&&!["Track","Helper","Transition","Placeholder"].includes(l.type)),n=10,o=e.left,a=e.width*e.scaleX,c=o+a;let h=!1;r.forEach(l=>{if(h)return;const u=l.getBoundingRect(),d=u.left,g=u.left+u.width;if(s.corner==="mr"){const f=Math.abs(c-g),p=Math.abs(c-d),m=B(1,e.tScale);if(f<n)if(e instanceof $t){const b=g-e.left,T=b-a,x=B(T,e.tScale,e.playbackRate),S=e.trim.to+x;if(b<m||b<m)return;S<=e.duration&&(e.set({width:b,scaleX:1}),e.trim.to=S,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({width:g-e.left,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0;else if(p<n)if(e instanceof $t){const b=d-e.left,T=b-a,x=B(T,e.tScale,e.playbackRate),S=e.trim.to+x;if(b<m)return;S<=e.duration&&(e.set({width:b,scaleX:1}),e.trim.to=S,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({width:d-e.left,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0}else if(s.corner==="ml"){const f=Math.abs(o-d),p=Math.abs(o-g);if(f<n)if(e instanceof $t){const m=c-d,b=m-a,T=B(b,e.tScale,e.playbackRate),x=e.trim.from-T;x>=0&&(e.set({left:d,width:m,scaleX:1}),e.trim.from=x,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({left:d,width:c-d,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0;else if(p<n)if(e instanceof $t){const m=c-g,b=m-a,T=B(b,e.tScale,e.playbackRate),x=e.trim.from-T;x>=0&&(e.set({left:g,width:m,scaleX:1}),e.trim.from=x,e.onResizeSnap&&e.onResizeSnap(),h=!0)}else e.set({left:g,width:c-g,scaleX:1}),e.onResizeSnap&&e.onResizeSnap(),h=!0}}),h&&(e.setCoords(),t.requestRenderAll())}}function e0(i){i.on("object:resizing",yh.bind(i))}function s0(i){i.off("object:resizing",yh.bind(i))}const Zs=100,Un=0,yi=5,bh=3,r0=25,vs={scrollInterval:null};function _h(i){const t=r0-bh,e=(Zs-i)/Zs;return bh+t*e}function i0(i,t){vs.scrollInterval&&clearInterval(vs.scrollInterval);const e=t.target,s=e.getBoundingRect();vs.scrollInterval=setInterval(()=>{const r=i.viewportTransform,n=i.getViewportPoint(t.e);if(n.x>i.width-Zs&&e.left+s.width<i.bounding.width){const o=_h(i.width-n.x);e.set("left",e.left+o),i.setViewportPos(r[4]-o,r[5])}if(n.x<Zs&&e.left>0&&r[4]<Zs&&r[4]<i.spacing.left){const o=_h(n.x);e.set("left",e.left-o),i.setViewportPos(r[4]+o,r[5])}n.y>i.height-Un&&e.top+s.height<i.bounding.height+80&&(e.set("top",e.top+yi),i.setViewportPos(r[4],r[5]-yi)),n.y<Un&&e.top>-80&&-r[5]>Un&&(e.set("top",e.top-yi),i.setViewportPos(r[4],r[5]+yi)),e.setCoords(),i.requestRenderAll()},16)}function n0(){vs.scrollInterval&&(clearInterval(vs.scrollInterval),vs.scrollInterval=null)}function Th(){n0()}function xh(i){i0(this,i)}function o0(i){i.on("mouse:up",Th),i.on("object:moving",xh.bind(i))}function a0(i){i.off("mouse:up",Th),i.off("object:moving",xh.bind(i))}function Sh(i){const t=i.target,e=i.target.canvas;if(i.action==="resizing"&&t instanceof Rt&&e){const s=t.id,r=e.getObjects("Transition").find(n=>n.id===s);if(r&&r instanceof Rt){const n=Ne(this.transitionsMap),o={...n,[s]:{...n[s],width:r.width,duration:r.duration}};this.transitionsMap=o,this.updateState()}}}function c0(i){i.on("object:modified",Sh)}function h0(i){i.off("object:modified",Sh)}const wh={canvas:null,enableGuideRedraw:!0,isPointerOverHelperTrack:!1,draggingOverTrack:null,placeholderMovingObjects:[],primaryMovingObjects:[],secondaryMovingObjects:[],objectInitialPositions:{},originTrack:{},trackToItemsMap:{},activeTrackToItemsMap:{},trackTopToIdMap:{},trackTops:[],activeObjects:[],primaryTracks:{},secondaryTracks:{},isDragOver:!1,initialTrackPoints:[],updateItemsInTrack:null,orderNormalTrack:!1},Q=()=>wh,ct=i=>{Object.assign(wh,i)},Ch=10,bi=(i,t)=>{t.forEach(e=>e.isAlignmentAuxiliary&&i.remove(e))},Oh=(i,t)=>{const e=[],s=[];return t.getObjects().filter(r=>r.visible).forEach(r=>{if(i.find(o=>o.id===r.id)||r.isAlignmentAuxiliary)return;const n=r.getBoundingRect();e.push(Eh(n.left,n.width,n.top,n.height)),s.push(Eh(n.top,n.height,n.left,n.width))}),{vertical:e.flat(),horizontal:[]}},kh=(i,t)=>{const e=[],s=[];i.vertical.forEach(a=>{t.vertical.forEach(c=>{const h=Math.abs(a.val-c.guide);h<Ch&&e.push({lineGuide:a.val,diff:h,orientation:"V",snap:c.snap,offset:c.offset,targetDim:{start:a.start,end:a.end}})})}),i.horizontal.forEach(a=>{t.horizontal.forEach(c=>{const h=Math.abs(a.val-c.guide);h<Ch&&s.push({lineGuide:a.val,diff:h,orientation:"H",snap:c.snap,offset:c.offset,targetDim:{start:a.start,end:a.end}})})});const r=[],n=e.sort((a,c)=>a.diff-c.diff)[0],o=s.sort((a,c)=>a.diff-c.diff)[0];return n&&r.push({lineGuide:n.lineGuide,offset:n.offset,orientation:"V",snap:n.snap,targetDim:n.targetDim}),o&&r.push({lineGuide:o.lineGuide,offset:o.offset,orientation:"H",snap:o.snap,targetDim:o.targetDim}),r},Mh=(i,t,e)=>{i.forEach(s=>{const r=l0(e.getZoom());s.orientation==="H"?e.add(Dh([0,s.lineGuide-r.strokeWidth/2,2e3,s.lineGuide-r.strokeWidth/2],{...r,stroke:e.guideLineColor})):s.orientation==="V"&&e.add(Dh([s.lineGuide-r.strokeWidth/2,0,s.lineGuide-r.strokeWidth/2,2e3],{...r,stroke:e.guideLineColor}))})},l0=i=>({strokeWidth:2/i}),Dh=(i,t)=>new Se(i,{...t,strokeLineCap:"square",excludeFromExport:!0,isAlignmentAuxiliary:!0,selectable:!1,objectCaching:!1}),jh=i=>{const t=i.getBoundingRect();return{vertical:[{guide:Math.round(t.left),offset:Math.round(i.left-t.left),snap:"start"},{guide:Math.round(t.left+t.width),offset:Math.round(i.left-t.left-t.width),snap:"end"}],horizontal:[{guide:Math.round(t.top),offset:Math.round(i.top-t.top),snap:"start"},{guide:Math.round(t.top+t.height),offset:Math.round(i.top-t.top-t.height),snap:"end"}]}},Eh=(i,t,e,s)=>[i,i+t].map(n=>({val:n,start:e,end:e+s})),Ih=(i,t)=>{i.remove(...t),t=[]},Ph=i=>{i.forEach(t=>t.setSelected(!1))},Ah=i=>i instanceof ce,u0=i=>Object.assign({},{left:16,right:80},i),d0=["touchstart","touchmove","touchend"],g0=i=>d0.includes(i.type)||i.pointerType==="touch";function Fh(i){const t=this;if(!t)return;const s=Q().enableGuideRedraw,r=t.getScenePoint(i.e),n=t.getObjects("Helper","Track"),o=n.find(f=>{const p=f.getBoundingRect();return r.x>=p.left&&r.x<=p.left+p.width&&r.y>=p.top&&r.y<=p.top+p.height});ct({draggingOverTrack:o}),n.forEach(f=>{Ah(f)&&(f===o?f.setSelected(!0):f.setSelected(!1))}),Ah(o)?ct({isPointerOverHelperTrack:!0}):ct({isPointerOverHelperTrack:!1});const a=t.getObjects(),c=i.target,h=c.getBoundingRect();c.setCoords();const l=[c,...t.getActiveObjects(),...t.getObjects("Track","Helper","Transition","Placeholder")],u=Oh(l,t),d=jh(c),g=kh(u,d);s&&(bi(t,a),g.length&&Mh(g,h,t),ct({enableGuideRedraw:!1}),setTimeout(()=>ct({enableGuideRedraw:!0}),50)),g.forEach(f=>{f.orientation==="V"?c.left=f.lineGuide+f.offset:c.top=f.lineGuide+f.offset})}function Lh(i){const t=i.target.canvas;t&&(bi(t,t.getObjects()),Ph(t.getObjects("Helper")),ct({draggingOverTrack:null,isPointerOverHelperTrack:!1}))}function Rh(i){var a;const t=this,e=t.getObjects(),s=i.target,r=i.transform,n=(a=t._currentTransform)==null?void 0:a.corner,o=s.getBoundingRect();if(r.action==="resizing"){const c=[s,...t.getActiveObjects(),...t.getObjects("Track","Helper","Transition","Placeholder")],h=Oh(c,t),l=h.vertical.filter(g=>{const f=g.val;if(n==="ml")return f<=o.left;if(n==="mr")return f>=o.left+o.width});h.vertical=l;const u=jh(s),d=kh(h,u);bi(t,e),d.length&&Mh(d,o,t)}}function f0(i){i.on("object:moving",Fh.bind(i)),i.on("object:modified",Lh.bind(i)),i.on("object:resizing",Rh.bind(i))}function p0(i){i.off("object:moving",Fh.bind(i)),i.off("object:modified",Lh.bind(i)),i.off("object:resizing",Rh.bind(i))}function $n(i,t,e){const s=i.indexOf(t),r=i.indexOf(e);return s===-1||r===-1?null:r-s}function Bh(i,t){const e=t.sort((r,n)=>r.tempIndex-n.tempIndex),s=[];for(const r of e)r.tempIndex<0&&s.push(r);s.push(i);for(const r of e)r.tempIndex>=0&&s.push(r);return s}function Wh(i){const t=Q(),e=t.canvas;ct({activeTrackToItemsMap:{},primaryTracks:{},secondaryTracks:{},trackTops:[],trackToItemsMap:{},activeObjects:[],trackTopToIdMap:{},isDragOver:!1,initialTrackPoints:[],updateItemsInTrack:null}),e.trackIdAfterTransform="",e.positionAfterTransform={};const s=e.getActiveObject(),r=s instanceof Ct?s.getObjects():[s];ct({activeObjects:r});const n=e.getScenePoint(i.e),o=e.getObjects("Track"),a=e.getActiveObjects().map(u=>u.id);let h=o.filter(u=>{const d=u.items;return a.some(g=>d.includes(g))}).find(u=>{const d=u.getBoundingRect();return n.x>=d.left&&n.x<=d.left+d.width&&n.y>=d.top&&n.y<=d.top+d.height});ct({originTrack:h});const l=e.getObjects(...this.itemTypes);o.forEach(u=>{const d=l.filter(g=>u.items.includes(g.id));t.trackToItemsMap[u.id]=d,t.trackTopToIdMap[u.top]=u.id,t.trackTops.push(u.top)}),t.trackTops.sort((u,d)=>u-d),r.forEach(u=>{const d=o.find(f=>f.items.includes(u.id));if(!d)return;const g=d.id;t.activeTrackToItemsMap[g]?t.activeTrackToItemsMap[g].push(u):t.activeTrackToItemsMap[g]=[u]}),t.primaryMovingObjects=r.filter(u=>{const d=u.getBoundingRect();return n.y>=d.top&&n.y<=d.top+d.height&&!(u instanceof Rt)}),t.primaryMovingObjects.length!==0&&(t.primaryMovingObjects.forEach(u=>{const d=u.getBoundingRect().top,g=t.trackTopToIdMap[d];if(t.primaryTracks[g])t.primaryTracks[g].objects.push(u);else{const f=$n(t.trackTops,h==null?void 0:h.top,d);t.primaryTracks[g]={objects:[u],index:f}}}),t.primaryMovingObjects=t.primaryMovingObjects.sort((u,d)=>u.left-d.left),t.secondaryMovingObjects=r.filter(u=>!t.primaryMovingObjects.includes(u)),t.secondaryMovingObjects.forEach(u=>{const d=u.getBoundingRect().top,g=t.trackTopToIdMap[u.getBoundingRect().top];if(t.secondaryTracks[g])t.secondaryTracks[g].objects.push(u);else{const f=$n(t.trackTops,h.top,d);t.secondaryTracks[g]={objects:[u],index:f}}}),h&&(e.trackOriginBeforeTransform=h.id),s&&(e.positionBeforeTransform={top:s.top,left:s.left}),i.transform.action==="drag"&&(t.placeholderMovingObjects=t.primaryMovingObjects.map(u=>{const d=u.getBoundingRect();t.objectInitialPositions[u.id]={top:d.top,left:d.left};const g=new ls({id:`${u.id}-placeholder`,left:d.left,top:d.top,width:d.width,height:d.height});return g.draggedObject=u,g}),e.add(...t.placeholderMovingObjects)))}function m0(i){i.on("before:transform",Wh.bind(i))}function v0(i){i.off("before:transform",Wh.bind(i))}const Cs=class Cs extends Z{constructor(e){super(e);w(this,"duration");w(this,"fromId");w(this,"toId");w(this,"itemType","none");w(this,"isSelected",!1);Object.assign(this,Cs.ownDefaults),this.id=e.id}static createControls(){return{controls:kn()}}static getDefaults(){return{...super.getDefaults(),...Cs.ownDefaults}}updateCoords(){const e=this.canvas;if(!e)return;const s=e.getObjects().find(o=>o.id===this.fromId);if(!s)return;const r=nt(this.duration,this.tScale),n=s.left+s.width-r/2;this.set({width:r,left:n})}_render(e){super._render(e),this.drawTextIdentity(e),this.updateSelected(e)}drawTextIdentity(e){const s=new Path2D("M3 5.30359C3 3.93159 4.659 3.24359 5.629 4.21359L11.997 10.5826L10.583 11.9966L5 6.41359V17.5856L10.586 11.9996L10.583 11.9966L11.997 10.5826L12 10.5856L18.371 4.21459C19.341 3.24459 21 3.93159 21 5.30359V18.6956C21 20.0676 19.341 20.7556 18.371 19.7856L12 13.5L13.414 11.9996L19 17.5866V6.41359L13.414 11.9996L13.421 12.0056L12.006 13.4206L12 13.4136L5.629 19.7846C4.659 20.7546 3 20.0676 3 18.6956V5.30359Z");e.save(),e.translate(-12,-12),e.fillStyle="#ffffff",e.fill(s),e.restore()}setSelected(e){this.isSelected=e,this.set({dirty:!0})}updateSelected(e){this.isSelected&&(e.save(),e.beginPath(),e.roundRect(-this.width/2,-this.height/2,this.width,this.height,this.rx),e.lineWidth=Ys,e.strokeStyle=He,e.stroke(),e.restore())}};w(Cs,"type","TransitionGuide"),w(Cs,"ownDefaults",{objectCaching:!1,borderColor:"transparent",stroke:"transparent",strokeWidth:1.5,fill:"rgba(0,0,0, 0.85)",borderOpacityWhenMoving:1,hoverCursor:"default",lockMovementX:!0,lockMovementY:!0,duration:1500,rx:8,ry:8});let Qs=Cs;const y0=i=>{const{trackItemIds:t,transitionsMap:e,trackItemsMap:s}=i,r=new Map;Object.values(e).forEach(h=>{var g,f;const{fromId:l,toId:u,kind:d}=h;d!=="none"&&(r.has(l)||r.set(l,[]),r.has(u)||r.set(u,[]),(g=r.get(l))==null||g.push(h),(f=r.get(u))==null||f.push(h))});const n=[],o=new Set,a=h=>{const l=[];let u=h;for(;u&&!o.has(u);){o.add(u);const d=s[u];l.push(d);const g=Object.values(e).find(f=>f.fromId===u&&f.kind!=="none");if(!g)break;l.push(g),u=g.toId}return l},c=Object.values(e).filter(h=>h.kind!=="none");for(const h of t)if(!o.has(h)&&(!r.has(h)||!c.some(l=>l.toId===h))){const l=a(h);l.length>0&&n.push(l)}return n.forEach(h=>{h.sort((l,u)=>"display"in l&&"display"in u?l.display.from-u.display.from:0)}),n},b0=["text","image","video","audio","caption","template"];function Xh(){const i=Q();Ih(this,i.placeholderMovingObjects)}function _0(i){const t=i.target.left;i.target.left=Math.max(t,0)}function zh(i,t){return i.find(s=>{const r=s.getBoundingRect();return t.left<r.left+r.width&&t.left+t.width-1>r.left&&t.top<r.top+r.height&&t.top+t.height>r.top})}function T0(i,t){const s=i.canvas.getActiveObject(),r=s.left+s.width/2,n=t.left+t.width/2;return r<n?t.left-s.width:(r>n,t.left+t.width)}const x0=(i,t,e)=>!(e<0||zh(i,{...t.getBoundingRect(),left:e})),Hh=i=>{const e=Q().draggingOverTrack,s=e==null?void 0:e.accepts.map(n=>n.toLowerCase()),r=i.type.toLowerCase();return i instanceof he,e&&(s==null?void 0:s.includes(r))};function S0(i){Q().isPointerOverHelperTrack?i.opacity=0:i.opacity=1}function w0(){const i=Q(),t=i.primaryMovingObjects[0];return{top:i.objectInitialPositions[t.id].top,left:i.objectInitialPositions[t.id].left}}function C0(i){const t=i.getBoundingRect(),e=Q(),s=e.draggingOverTrack;if(e.primaryMovingObjects.map(n=>n.id).includes(i.id)){const o=e.primaryMovingObjects[0].getBoundingRect();return{top:s.top,left:o.left}}return{top:s.top,left:t.left}}function O0(i,t,e,s){const n=i.canvas.getActiveObjects().map(l=>l.id),o=T0(i,t),a=e.filter(l=>!n.includes(l.id)),c=x0(a,i,o),h=Q();if(h.orderNormalTrack=!0,!c||s.x-20<0){const l=h.draggingOverTrack;return{left:h.initialTrackPoints.reduce((d,g)=>Math.abs(g-s.x)<Math.abs(d-s.x)?g:d),top:l.top}}return{left:o,top:t.top}}const k0=(i,t)=>{i.forEach((e,s)=>{e.set({left:t[s]})})},Yh=Zv(i=>{const t=i.target.canvas;_0(i);const e=Q(),s=e.draggingOverTrack;if(s){const a=e.primaryMovingObjects[0];b0.includes(a.type)&&e.placeholderMovingObjects.forEach(c=>{c.visible=!0})}else{e.placeholderMovingObjects.forEach(a=>{a.visible=!1});return}const r=e.placeholderMovingObjects.map(a=>a.draggedObject),n=(e.trackToItemsMap[s.id]||[]).filter(a=>!r.includes(a)),o=Hh(e.primaryMovingObjects[0]);if(s.magnetic&&o){e.updateItemsInTrack?e.updateItemsInTrack!==s.id&&(e.updateItemsInTrack=s.id,e.initialTrackPoints=[]):(e.updateItemsInTrack=s.id,e.initialTrackPoints=[]),e.initialTrackPoints.length===0&&(e.updateItemsInTrack=s.id,e.initialTrackPoints=Vh(e,s));let a=0;for(const[c,h]of e.initialTrackPoints.entries()){const l=h,u=e.initialTrackPoints[c+1],d=e.initialTrackPoints[c-1],g=u-l,f=l-d;if(!u)a=l;else if(l<=i.pointer.x&&l+g/2>=i.pointer.x){a=l;break}else if(l-f/2<=i.pointer.x&&i.pointer.x<=l){a=l;break}}e.placeholderMovingObjects.forEach(c=>{c.opacity=1,c.left=a,c.top=s.top,a+=c.width}),e.placeholderMovingObjects.forEach(c=>{const h=c.draggedObject;t.positionAfterTransform[h.id]={top:c.top,left:c.left}}),t.trackIdAfterTransform=e.trackTopToIdMap[s.top]}else{if(e.orderNormalTrack=!1,e.updateItemsInTrack&&e.updateItemsInTrack!==s.id){const d=t.getObjects().find(g=>g.id===e.updateItemsInTrack);d!=null&&d.magnetic?M0(t,e):t.updateTrackItemCoords(!0),e.updateItemsInTrack=null,e.initialTrackPoints=[]}e.initialTrackPoints.length===0&&s instanceof Lt&&(e.updateItemsInTrack=s.id,e.initialTrackPoints=Vh(e,s));const a=n.find(d=>zh(r,d.getBoundingRect())),c=[],l=e.primaryMovingObjects.sort((d,g)=>d.left-g.left),u=l[0];l.forEach((d,g)=>{if(!l[g-1])return;const f=d.left-u.left;c.push(f)}),e.placeholderMovingObjects.forEach((d,g)=>{const f=d.draggedObject;if(f instanceof Qs){d.visible=!1;return}f.setCoords(),S0(d);let p=I0(f,n,i.pointer,a);if(e.draggingOverTrack instanceof ce?d.opacity=0:d.opacity=1,f instanceof he&&p.isInvalidDrop&&e.draggingOverTrack instanceof Lt){const m=i.pointer,b=[...t.viewportTransform],T=m.y-b[5];E0(t,T)}else e.primaryMovingObjects.length>1?(t.trackIdAfterTransform=e.trackTopToIdMap[p.top],t.positionAfterTransform[f.id]={top:p.top,left:p.left+(c[g-1]||0)},d.left=p.left+(c[g-1]||0),d.top=p.top):(t.trackIdAfterTransform=e.trackTopToIdMap[p.top],t.positionAfterTransform[f.id]={top:p.top,left:p.left},d.left=p.left,d.top=p.top)})}}),Vh=(i,t)=>{const e=i.canvas,s=[];t.items.forEach(h=>{const l=e.getObjects().find(u=>u.id===h);l&&s.push(l)});const r=i.activeObjects.map(h=>h.id),o=s.filter(h=>!r.includes(h.id)).sort((h,l)=>h.left-l.left);let a=0;const c=[];return t.magnetic?D0(o,a,c):j0(t,c,e),c};function M0(i,t){const e=[];i.getObjects().find(a=>a.id===t.updateItemsInTrack).items.forEach(a=>{const c=i.getObjects().find(h=>h.id===a);c&&e.push(c)});const r=t.activeObjects.map(a=>a.id),o=e.filter(a=>!r.includes(a.id)).sort((a,c)=>a.left-c.left);t.initialTrackPoints.length>o.length&&k0(o,t.initialTrackPoints)}function D0(i,t,e){var h;const s=Q(),r=(h=i[0])==null?void 0:h.canvas,n=s.draggingOverTrack,o=s.primaryMovingObjects.map(l=>l.id);if(!r)return;const a=r.transitionIds.filter(l=>r.transitionsMap[l].kind!=="none");i.forEach(l=>{l.set({left:t}),t+=l.width,a.find(d=>r.transitionsMap[d].toId===l.id)||e.push(l.left)});const c=i[i.length-1];if(e.push(((c==null?void 0:c.left)||0)+((c==null?void 0:c.width)||0)),n!=null&&n.items.includes(o[0])){const l=s.primaryMovingObjects[0],u=[...e];if(l){const d=u.findIndex(g=>g>(l==null?void 0:l.left));d!==-1&&e.splice(d,0,nt(l.display.from,r.tScale))}}}function j0(i,t,e){const s=i.items,r={},n={},o=e.getActiveObjects().map(h=>h.id);Object.values(e.trackItemsMap).forEach(h=>{s.includes(h.id)&&(r[h.id]=h)});const a=e.getObjects("Transition").filter(h=>h.top===i.top).map(h=>h.id);Object.values(e.transitionsMap).forEach(h=>{a.includes(h.id)&&(n[h.id]=h)});const c=y0({trackItemIds:Ne(s),transitionsMap:Ne(n),trackItemsMap:Ne(r)});t.push(0),c.forEach(h=>{if(h.length===1){const l=e.getObjects().find(u=>u.id===h[0].id);o.includes(l.id)||t.push(l.left+l.width)}else{const l=h[h.length-1],u=e.getObjects().find(d=>d.id===l.id);t.push(u.width+u.left)}})}function E0(i,t){i.getObjects("Helper").reduce((r,n)=>Math.abs(n.top-t)<Math.abs(r.top-t)?n:r).setSelected(!0)}const I0=(i,t,e,s)=>{const r=Hh(i);return!r&&i instanceof he?{top:0,left:0,isInvalidDrop:!0}:r?s?i instanceof he?{top:0,left:0,isInvalidDrop:!0}:O0(i,s,t,e):C0(i):w0()};function P0(i){i.on("mouse:up",Xh.bind(i)),i.on("object:moving",Yh)}function A0(i){i.off("mouse:up",Xh.bind(i)),i.off("object:moving",Yh)}const F0=i=>{Q().canvas.fire("track:create",i)},L0=i=>{Q().canvas.fire("track-items:moved",i)},Gh=i=>{var a,c,h;const t=(a=i.target)==null?void 0:a.canvas;if(!t)return;const e=Q(),s=t.getActiveObject();if(!s||!t.positionBeforeTransform)return;const r=t.getScenePoint(i.e),o=t.getObjects("Track","Helper").find(l=>{const u=l.getBoundingRect();return r.x>=u.left&&r.x<=u.left+u.width&&r.y>=u.top&&r.y<=u.top+u.height});if(i.action==="resizing"){const l=(e.trackToItemsMap[(c=e.originTrack)==null?void 0:c.id]||[]).filter(d=>d!==s);s.setCoords();const u=Nh(l,s.getBoundingRect());return t.fire("track-items:resized",{trackId:(h=e.originTrack)==null?void 0:h.id,trackItemIds:[s.id],isOverlapped:!!u}),!1}if(!o)return s==null||s.set(t.positionBeforeTransform),s==null||s.setCoords(),!1;if(o instanceof ce){let l;switch(o.kind){case"top":l=0;break;case"center":l=o.metadata.order||0;break;case"bottom":l=-1;break;default:return}const u={isSecondaryOverlapped:!1,secondaryTracks:e.secondaryTracks,primaryTracks:e.primaryTracks,primaryPositions:{trackIndex:l,trackId:t.trackIdAfterTransform,positions:t.positionAfterTransform}};F0(u)}else if(o instanceof Lt){const u={isSecondaryOverlapped:B0(),secondaryTracks:e.secondaryTracks,primaryTracks:e.primaryTracks,primaryPositions:{trackId:t.trackIdAfterTransform,positions:t.positionAfterTransform}};L0(u)}};function R0(){const i=Q(),t=i.canvas,[e]=i.primaryMovingObjects,s=e.id,r=t.positionAfterTransform[s],n=e.getBoundingRect().top,o=r.top-n,a={};return i.secondaryMovingObjects.forEach(c=>{const h=c.getBoundingRect().top+o,l=i.trackTopToIdMap[h],u=$n(i.trackTops,i.originTrack.top,h);a[l]?a[l].objects.push(c):a[l]={objects:[c],index:u}}),a}function B0(){const i=R0(),t=Q();return Object.keys(i).some(e=>{const s=t.trackToItemsMap[e],r=i[e].objects;return!s||!s.length?!0:s.filter(n=>!r.includes(n)).some(n=>Nh(r,n.getBoundingRect()))})}function Nh(i,t){return i.find(s=>{const r=s.getBoundingRect();return t.left<r.left+r.width&&t.left+t.width>r.left&&t.top<r.top+r.height&&t.top+t.height>r.top})}const W0=i=>{i.on("object:modified",Gh)},X0=i=>{i.off("object:modified",Gh)},qn="drag",Uh=`${qn}:start`,Kn=`${qn}:end`,Jn="timeline",$h=`${Jn}:boundingChanged`,qh=`${Jn}:seek`,z0=i=>{const{trackItemIds:t,transitionsMap:e,trackItemsMap:s}=i,r=new Map;Object.values(e).forEach(c=>{var u,d;if(c.kind==="none")return;const{fromId:h,toId:l}=c;r.has(h)||r.set(h,[]),r.has(l)||r.set(l,[]),(u=r.get(h))==null||u.push(c),(d=r.get(l))==null||d.push(c)});const n=[],o=new Set,a=c=>{const h=[];let l=c;for(;l&&!o.has(l);){o.add(l);const u=s[l];h.push(u);const d=Object.values(e).find(g=>g.fromId===l&&g.kind!=="none");if(!d)break;h.push(d),l=d.toId}return h};for(const c of t)if(!o.has(c)&&(!r.has(c)||!Object.values(e).some(h=>h.toId===c&&h.kind!=="none"))){const h=a(c);h.length>0&&n.push(h)}return n.forEach(c=>{c.sort((h,l)=>"display"in h&&"display"in l?h.display.from-l.display.from:0)}),n},H0="add:audio",Y0="add:video",V0="add:image",G0="add:text",N0=["transition","image","video","audio","caption","text"];let st,tr,Ue=[],er="";function U0(i,t){let e=1/0,s=null;const r=new _(i.x,i.y);return t.forEach(n=>{const o=Math.sqrt(Math.pow(n.left-r.x,2)+Math.pow(n.top-r.y,2));o<e&&(e=o,s=n)}),s}const $0=({width:i,height:t,id:e,left:s,top:r,type:n,duration:o})=>{if(n==="transition")return new Qs({top:0,left:0,height:48,width:48,id:"TransitionGuide"});const a=C.getClass("PreviewTrackItem")||he;return new a({top:r,left:s,height:t,width:i,id:e,type:n,duration:o})};function Kh(i){var f;const t=(f=i.e.dataTransfer)==null?void 0:f.types[0];if(!t)return;const e=JSON.parse(t),s=e.type;if(!N0.includes(s))return;const r=e.duration||5e3,n=this;n.discardActiveObject(),n.setActiveIds([]);const o=nt(r,this.tScale),a=n.getItemSize(s),c=n.getTrackItems();if(st=$0({width:o,height:a,id:"TransitionGuide",left:0,top:0,type:s,duration:r}),st.visible=!1,er=s,s==="transition"){Ue=n.getObjects("Transition");const p=Ue.filter(m=>m.kind!=="none");Ue.forEach(m=>{const b=c.find(k=>k.id===m.toId),T=c.find(k=>k.id===m.fromId),x=m.width;((b==null?void 0:b.width)||0)>=x/2&&((T==null?void 0:T.width)||0)>=x/2||(m.availableDrop=!1);const S=p.find(k=>k.fromId===m.toId);S&&S.width+x/2>=((b==null?void 0:b.width)||0)&&(m.availableDrop=!1);const O=p.find(k=>k.toId===m.fromId);O&&O.width+x/2>=((T==null?void 0:T.width)||0)&&(m.availableDrop=!1),m.visible=!0})}const h=Q();n.trackIdAfterTransform="",n.positionAfterTransform={};const l=st,u=[st];ct({activeTrackToItemsMap:{},primaryTracks:{},secondaryTracks:{},trackTops:[],trackToItemsMap:{},activeObjects:[],trackTopToIdMap:{},isDragOver:!1}),ct({activeObjects:u});const d=n.getObjects("Track"),g=n.getTrackItems();d.forEach(p=>{const m=g.filter(b=>p.items.includes(b.id));h.trackToItemsMap[p.id]=m,h.trackTopToIdMap[p.top]=p.id,h.trackTops.push(p.top)}),h.trackTops.sort((p,m)=>p-m),h.primaryMovingObjects=u,h.primaryMovingObjects=h.primaryMovingObjects.sort((p,m)=>p.left-m.left),l&&(n.positionBeforeTransform={top:l.top,left:l.left}),h.placeholderMovingObjects=h.primaryMovingObjects.map(p=>{const m=p.getBoundingRect();h.objectInitialPositions[p.id]={top:m.top,left:m.left};const b=new ls({id:`${p.id}-placeholder`,left:m.left,top:m.top,width:m.width,height:m.height});return b.visible=!1,b.draggedObject=p,b}),n.add(...h.placeholderMovingObjects),n.add(st),K.dispatch(Uh)}const Jh=i=>{const t=Q();Ih(i,t.placeholderMovingObjects),i&&(bi(i,i.getObjects()),Ph(i.getObjects("Helper")))};function Zh(){if(er="",Jh(this),ct({draggingOverTrack:null,isPointerOverHelperTrack:!1}),!st)return;K.dispatch(Kn);const i=this;Ue.forEach(t=>{t.strokeDashArray=[],t.setSelected(!1),t.kind==="none"&&(t.visible=!1)}),i.getObjects("Helper","Track").forEach(t=>{t.setSelected&&t.setSelected(!1)}),i.remove(st)}function Qh(i){const t=Q(),e=t.placeholderMovingObjects[0];if(e.visible||(st.visible=!0,e.visible=!0),t.activeObjects[0]instanceof Qs&&(e.visible=!1),!st)return!1;i.e.preventDefault();const s=this,r=s.getViewportPoint(i.e),n=[...this.viewportTransform];st.set({left:r.x-16-n[4],top:r.y-n[5]-st.height/2});const o=U0(r,Ue.filter(h=>h.availableDrop));o&&(tr=o,o.strokeDashArray=[5,1],o.setSelected(!0)),Ue.forEach(h=>{h!==o&&h.setSelected(!1)}),ct({isDragOver:!0}),st.setCoords();const a={target:st,action:"drag",originX:"center",originY:"center",offsetX:r.x-st.left,offsetY:r.y-st.top,scaleX:st.scaleX,scaleY:st.scaleY};if(t.activeObjects[0].type!=="transitionguide"&&s.fire("object:moving",{target:st,e:i.e,pointer:r,transform:a}),this.itemTypes.includes(er))if(t.draggingOverTrack instanceof Lt){ct({isPointerOverHelperTrack:!1});const h=t.activeObjects[0].left,l=t.activeObjects[0].left+t.activeObjects[0].width;let u=!1;const d=t.draggingOverTrack.items;s.getObjects().filter(g=>d.includes(g.id)).forEach(g=>{(g.left<=h&&g.left+g.width>=h||g.left<=l&&g.left+g.width>=l||h<=g.left&&l>=g.left+g.width)&&(u=!0)}),t.draggingOverTrack.accepts.includes(er)&&!u?(t.placeholderMovingObjects[0].left=t.activeObjects[0].left,t.placeholderMovingObjects[0].top=t.draggingOverTrack.top,s.getObjects("Helper").forEach(g=>{g.setSelected&&g.setSelected(!1)})):t.placeholderMovingObjects.forEach(g=>{g.opacity=0})}else t.draggingOverTrack instanceof ce&&(ct({isPointerOverHelperTrack:!0}),t.draggingOverTrack.setSelected(!0));s.requestRenderAll()}function tl(i){var o;er="";const t=this;Jh(t);const e=Q(),s=e.draggingOverTrack;ct({draggingOverTrack:null,isPointerOverHelperTrack:!1});const r=(o=i.e.dataTransfer)==null?void 0:o.types[0],n=JSON.parse(i.e.dataTransfer.getData(r));if(n.type!=="transition"){const a=e.activeObjects[0],c=B(a.left,t.tScale);if(s instanceof Lt)if(e.placeholderMovingObjects[0].opacity!==0){const l=Zn(s,this.getObjects("Track"));if(s.magnetic){const u=e.initialTrackPoints[e.initialTrackPoints.length-1],d=B(u,t.tScale);_i(n,l,d)}else _i(n,l,c)}else{const l=i.viewportPoint,u=[...t.viewportTransform],d=l.y-u[5],f=t.getObjects("Helper").reduce((m,b)=>Math.abs(b.top-d)<Math.abs(m.top-d)?b:m),p=Zn(f,this.getObjects("Track"));_i(n,p,c,!0)}else{const h=Zn(s,this.getObjects("Track"));_i(n,h,c,!0)}this.remove(a),this.requestRenderAll();return}if(st){if(tr){const a=tr.id,c=Kv(n,["kind","direction"]);Object.keys(c).forEach(T=>{T==="kind"?tr.kind=c[T]:tr[T]=c[T]});const h=Ne(this.trackItemIds),l=Ne(this.transitionsMap),u=Ne(this.trackItemsMap);l[a]={...l[a],...c};const d=z0({trackItemIds:h,transitionsMap:l,trackItemsMap:u}),f=l[a].fromId,p=d.find(T=>T.find(x=>x.id===f))||[],m=q0(p),b=K0(this.trackItemsMap,m);this.trackItemsMap=b,this.transitionsMap[a]={...this.transitionsMap[a],...c},this.adjustMagneticTrack(),this.calcBounding(),this.updateTransitions(),this.refreshTrackLayout(),this.updateState({kind:"add:transition",updateHistory:!0})}Ue.forEach(a=>{a.strokeDashArray=[],a.setSelected(!1),a.kind==="none"&&(a.visible=!1)}),t.remove(st),t.requestRenderAll(),K.dispatch(Kn)}}const q0=i=>{const[t]=i,e=i.filter(r=>r.type!=="transition");let s=t.display.from;return e.map(r=>{const n=r.display.to-r.display.from,o={from:s,to:s+n};return s=o.to,{...r,display:o}})},K0=(i,t)=>{let e=i;return t.forEach(s=>{e[s.id]=s}),e},Zn=(i,t)=>{const e=t.sort((o,a)=>o.top-a.top);if(e.length===0)return 0;const s=e[e.length-1];if(s.top+s.height<=i.top)return e.length;const r=i.top;return e.reduce((o,a,c)=>{const h=Math.abs(a.top-r),l=Math.abs(e[o].top-r);return h<l?c:o},0)},_i=(i,t,e,s)=>{i.type==="image"?K.dispatch(V0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}}):i.type==="video"?K.dispatch(Y0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}}):i.type==="audio"?K.dispatch(H0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}}):i.type==="text"&&K.dispatch(G0,{payload:{...i,id:fs(),display:{from:e}},options:{trackIndex:t,isNewTrack:s}})};function J0(i){i.on("dragover",Qh),i.on("dragenter",Kh),i.on("dragleave",Zh),i.on("drop",tl)}function Z0(i){i.off("dragover",Qh),i.off("dragenter",Kh),i.off("dragleave",Zh),i.off("drop",tl)}function el(i){const t=this.height<this.bounding.height;if(!(this.width<this.bounding.width)&&!t)return;const s=this.viewportTransform;let r=s[4],n=s[5];const o=2;i.e.shiftKey?r=r-i.e.deltaY*o:(t&&(n=n-i.e.deltaY*o),r=r-i.e.deltaX*o),this.setViewportPos(r,n)}function sl(){const i=this,t=i.getActiveObject(),e=i.getActiveObjects(),s=e.map(n=>n.id),r=e.filter(n=>{if(e.length===1)return!0;if(n.id&&!(n instanceof Rt))return!0;if(n instanceof Rt&&s.includes(n.fromId)&&s.includes(n.toId))return!0}).map(n=>n.id);t instanceof Ct?(t.borderColor="rgba(0, 216, 214,0.75)",t.hasControls=!1,t.hoverCursor="default",t.borderScaleFactor=1,t.padding=0,t.getObjects().forEach(n=>{n.setSelected(!0)})):t==null||t.setSelected(!0),this.setActiveIds(r)}function rl(i){const t=this,e=t.getActiveObject();e instanceof Ct&&(e.borderColor="transparent",e.hasControls=!1,e.hoverCursor="default"),i.selected.forEach(n=>{n.setSelected(!0)}),i.deselected.forEach(n=>{n.setSelected(!1)});const r=t.getActiveObjects().map(n=>n.id);this.setActiveIds(r)}function il(i){i.deselected.forEach(t=>{t.setSelected(!1)})}const Q0=i=>{i.on("selection:created",sl),i.on("selection:updated",rl),i.on("selection:cleared",il),i.on("mouse:wheel",el)},ty=i=>{i.off("mouse:wheel",el),i.off("selection:created",sl),i.off("selection:updated",rl),i.off("selection:cleared",il)},nl=()=>{var n;const i=Q(),t=i.canvas,e=i.draggingOverTrack;t.updateTrackItemCoords(!0);const s=e==null?void 0:e.magnetic,r=new Set(i.activeObjects.map(o=>o.id));if(s){const o=e.id,c=i.trackToItemsMap[o].sort((f,p)=>f.left-p.left),h=i.placeholderMovingObjects,l=((n=h[0])==null?void 0:n.top)||0,u=h.reduce((f,p)=>f+p.width,0),d=Math.min(...h.map(f=>f.left));let g=0;c.forEach(f=>{r.has(f.id)||f.top===l&&(Math.abs(d-g)<1&&(g+=u),f.left=g,g+=f.width)})}else if(e instanceof Lt&&i.orderNormalTrack){const o=e.items,a=t.getTrackItems().filter(p=>!r.has(p.id)&&o.includes(p.id)),c=a.sort((p,m)=>p.left-m.left),h=i.placeholderMovingObjects[0],l=i.placeholderMovingObjects[i.placeholderMovingObjects.length-1],u=h.left,d=l.left-h.left+l.width,g=c.find((p,m)=>{if(p.left>=u-1)return c[m]}),f=a.filter(p=>p.left>=u-1);if(h.left+d>(g==null?void 0:g.left)){const p=d-(g.left-h.left);f.forEach(m=>{const b=nt(m.display.from,t.tScale);m.left=b+p})}}t.alignTransitionsToTrack(!1)};function ey(i){i.on("object:moving",nl)}function sy(i){i.off("object:moving",nl)}let Xt,Qn=!1;function ry(i,t){const e=i.canvas;if(e.objectTypes.includes(i.type)){Xt||(Xt=i);const r=i.top,n=i.height,o=i.left,a=i.width,c=t.x,h=t.y,l=Math.abs(h-(r+n/2))<=Yd;Math.abs(c-o)<=bc&&l||Math.abs(c-o-a)<=bc&&l?(e.hoverCornerItem=!0,i.hoverCursor="ew-resize"):(e.hoverCornerItem=!1,i.hoverCursor="move"),e.requestRenderAll()}}function ol(i){const t=this,e=t.findTarget(i.e),s=t.getScenePoint(i.e);e&&(e.isSelected&&Xt&&(e.hoverCursor="default"),ry(e,s))}function al(){Xt&&(Xt.lockMovementX=!1,Xt.lockMovementY=!1,Xt=void 0)}function cl(i){Xt&&(Qn||Xt._renderControls(i.ctx))}function hl(){Xt&&(Xt=void 0,this.requestRenderAll())}function ll(){Qn=!0}function ul(){Qn=!1}function iy(i){i.on("mouse:out",hl.bind(i)),i.on("mouse:up",al.bind(i)),i.on("mouse:move",ol.bind(i)),i.on("after:render",cl.bind(i)),i.on("object:resizing",ll.bind(i)),i.on("object:modified",ul.bind(i))}function ny(i){i.off("mouse:out",hl.bind(i)),i.off("mouse:up",al.bind(i)),i.off("mouse:move",ol.bind(i)),i.off("after:render",cl.bind(i)),i.off("object:resizing",ll.bind(i)),i.off("object:modified",ul.bind(i))}const oy=i=>{ct({canvas:i}),o0(i),e0(i),c0(i),f0(i),m0(i),P0(i),W0(i),J0(i),Q0(i),ey(i),iy(i)},ay=i=>{ct({canvas:null}),a0(i),s0(i),h0(i),p0(i),v0(i),A0(i),X0(i),Z0(i),ty(i),sy(i),ny(i)};class cy{removeTransitions(){const t=this.getObjects("Transition");this.remove(...t)}renderTransitions(){this.removeTransitions(),this.transitionIds.forEach(t=>{const e=this.transitionsMap[t],s=e.fromId,r=e.toId,n=this.getObjects(),o=n.find(d=>d.id===s),a=n.find(d=>d.id===r);if(!o||!a)return;const c=nt(e.duration,this.tScale),h=o.left+o.width-c/2,l=o.height,u=new Rt({id:e.id,left:h,top:o.top,height:l,width:c,tScale:this.tScale,duration:e.duration,fromId:o.id,toId:a.id,kind:e.kind});e.kind==="none"&&(u.visible=!1),u&&this.add(u)})}updateTrackTransitionsItemCoords(){this.pauseEventListeners(),this.getObjects("Transition").forEach(e=>{e.tScale=this.tScale,e.updateCoords(),e.setCoords()}),this.resumeEventListeners()}alignTransitionsToTrack(t=!0){const e=t?[]:this.getActiveObjects().map(s=>s.id);this.transitionIds.forEach(s=>{const r=this.getObjects("Transition").find(n=>n.id===s);if(r instanceof Rt){const n=this.getObjects().find(c=>c.id===r.fromId&&!e.includes(c.id));if(!n)return;const o=nt(r.duration,this.tScale),a=n.left+n.width-o/2;r.set({left:a,top:n.top}),r.setCoords()}})}updateTransitions(t=!0){t&&this.pauseEventListeners();const e=this.getObjects("Track"),s=this.getObjects(...this.withTransitions);this.removeTransitions();const r={},n=[];e.forEach(a=>{const c=s.filter(h=>a.items.includes(h.id)).sort((h,l)=>h.left-l.left);for(let h=0;h<c.length-1;h++){const l=c[h],u=c[h+1];if(Math.abs(l.left+l.width-u.left)<=1){const d=`${l.id}-${u.id}`;if(this.transitionIds.includes(d)){const f=this.transitionsMap[d];r[d]=f}else{const f={id:d,duration:1500,fromId:l.id,toId:u.id,kind:"none",trackId:a.id,type:"transition"};r[d]=f}n.push(d)}}}),this.transitionIds=n,this.transitionsMap=r,this.renderTransitions();const o=this.getObjects("Transition");this.updateCachingActiveObjects(o),t&&this.resumeEventListeners()}}function dl(i){const{secondaryTracks:t,primaryTracks:e,primaryPositions:s}=i,{positions:r,trackIndex:n}=s,o=n===-1?this.tracks.length:n,[a]=Object.keys(e),c=this.tracks.find(p=>p.id===a),h=e[a],l={id:fs(),items:h.objects.map(p=>p.id),type:c.type,accepts:c.accepts},u=Wn(Object.keys(t).map(p=>t[p].objects.map(m=>m.id)));let d=Us(this.tracks,[...Object.keys(r),...u]);const g=[];Object.keys(t).forEach(p=>{const{objects:m,index:b}=t[p],T=this.tracks.find(O=>O.id===p),x=m.map(O=>O.id).filter(O=>!this.transitionIds.includes(O)),S={id:Ns(),items:x,type:T.type,accepts:T.accepts,tempIndex:b};g.push(S)});const f=Bh(l,g);f.length&&d.splice(o,0,...f),this.tracks=d,this.renderTracks(),this.refreshTrackLayout(),this.alignItemsToTrack(),this.uodateTrackItemIdsOrdering(),this.adjustMagneticTrack(),this.updateTransitions(!0),this.updateState({updateHistory:!0,kind:"update"})}function gl(i){const{isSecondaryOverlapped:t,secondaryTracks:e,primaryTracks:s,primaryPositions:r}=i,{trackId:n,positions:o}=r,a=this.tracks.find(b=>b.id===n),l=Q().primaryMovingObjects.sort((b,T)=>b.left-T.left);l.forEach((b,T)=>{l[T-1]&&b.left-l[T-1].left});const u=this.tracks.findIndex(b=>b.id===n),d=Wn(Object.keys(e).map(b=>e[b].objects.map(T=>T.id)));let g=Us(this.tracks,[...Object.keys(o),...d]);Object.keys(s).forEach(b=>{this.pauseEventListeners();const{objects:T}=s[b];T.forEach(O=>{if(O.isMain&&(a!=null&&a.magnetic))return;const k=o[O.id];O.left=k==null?void 0:k.left}),this.resumeEventListeners();const x=r.trackId,S=g.find(O=>O.id===x);S==null||S.items.push(...Object.keys(o)),this.tracks=g});const f=this.tracks[u],p=[];Object.keys(e).forEach(b=>{const{objects:T,index:x}=e[b],S=T.filter(j=>j.type!=="transition").map(j=>j.id),[O]=S,k=this.trackItemsMap[O];if(t&&k){const j=this.getItemAccepts(k.type),D={id:Ns(),items:S,type:k.type,accepts:j,tempIndex:x};p.push(D)}else{const j=g[u+x];j==null||j.items.push(...S),this.tracks=g}});const m=Bh(f,p);m.length&&g.splice(u,1,...m),this.tracks=g,this.renderTracks(),this.alignItemsToTrack(),this.uodateTrackItemIdsOrdering(),this.adjustMagneticTrack(),this.updateTransitions(!0),this.updateState({updateHistory:!0,kind:"update"})}function fl({trackItemIds:i,isOverlapped:t}){var o,a;const[e]=i;if(!e)return;const s=this.getObjects("Transition");if(!s.find(c=>c.id===e)){const c=this.tracks.find(h=>h.items.includes(e));if(t){const h=Us(this.tracks,i),l={id:Ns(),items:[e],type:c.type,accepts:c.accepts},u=this.tracks.findIndex(d=>d.id===c.id);h.splice(u,0,l),this.tracks=h}}const n=s.filter(c=>c.fromId===e||c.toId===e);if(n){const c=this.getTrackItems().find(g=>g.id===e),h=c==null?void 0:c.width;n.forEach(g=>{if(g.width/2>h){this.transitionIds=this.transitionIds.filter(p=>p!==g.id);const f={};Object.keys(this.transitionsMap).forEach(p=>{p!==g.id&&(f[p]=this.transitionsMap[p])}),this.transitionsMap=f}});const l=((o=n[0])==null?void 0:o.width)||0,u=((a=n[1])==null?void 0:a.width)||0,d=n[1];if(h<=l/2+u/2){this.transitionIds=this.transitionIds.filter(f=>f!==(d==null?void 0:d.id));const g={};Object.keys(this.transitionsMap).forEach(f=>{f!==(d==null?void 0:d.id)&&(g[f]=this.transitionsMap[f])}),this.transitionsMap=g}}this.renderTracks(),this.alignItemsToTrack(),this.adjustMagneticTrack(),this.updateTransitions(!0),this.uodateTrackItemIdsOrdering(),this.updateState({updateHistory:!0,kind:"update"})}let to={x:0,y:0};function hy(i){to=i.scenePoint}function pl(i){const t=i.scenePoint;if((to.x===t.x||to.y===t.y)&&!i.target){const s=this.getElement().getBoundingClientRect(),r=this.viewportTransform,n=i.e.clientX-s.left-r[4],o=B(n,this.scale.zoom);K.dispatch(qh,{payload:{time:o}})}}const ly=i=>{i.on("track:create",dl.bind(i)),i.on("track-items:resized",fl.bind(i)),i.on("track-items:moved",gl.bind(i)),i.on("mouse:up",pl.bind(i)),i.on("mouse:down",hy.bind(i))};function uy(i){i.off("track:create",dl.bind(i)),i.off("track-items:resized",fl.bind(i)),i.off("track-items:moved",gl.bind(i)),i.off("mouse:up",pl.bind(i))}function dy(i,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(s=>{s!=="constructor"&&Object.defineProperty(i.prototype,s,Object.getOwnPropertyDescriptor(e.prototype,s)||Object.create(null))})}),i}let ml,vl,yl,bl,_l,Tl,xl,Sl;const gy=i=>{ml=i.state.subscribeToActiveIds(({activeIds:t})=>{const e=i.activeIds;if(t.length===1&&e.length===1){const s=t[0],r=e[0],o=i.state.getState().structure;let a="";if(o.forEach(c=>{c.id===r&&c.items.includes(s)&&(a=c.id)}),a!=="")return;i.selectTrackItemByIds([s])}else i.selectTrackItemByIds(t)}),Sl=i.state.subscribeToTracks(({tracks:t,changedTracks:e})=>{e.length&&(i.tracks=t,i.renderTracks(),i.refreshTrackLayout())}),xl=i.state.subscribeToUpdateAnimations(({trackItemsMap:t,changedAnimationIds:e})=>{if(e!=null&&e.length){const s=i.getTrackItems();i.trackItemsMap=t,s.forEach(r=>{if(e.includes(r.id)){const n=t[r.id].animations;n&&r.set({animations:n})}})}}),Tl=i.state.subscribeToUpdateTrackItemTiming(({trackItemsMap:t,changedTrimIds:e,changedDisplayIds:s})=>{if(e&&i.getTrackItems().forEach(n=>{if(e.includes(n.id)){const o=t[n.id].trim;o&&n.set({trim:{from:o.from,to:o.to}})}}),s){const r=i.getTrackItems();i.pauseEventListeners(),r.forEach(n=>{if(s.includes(n.id)){const o=t[n.id].display;i.trackItemsMap[n.id].display=o,t[n.id].playbackRate!==i.trackItemsMap[n.id].playbackRate&&(i.trackItemsMap[n.id].playbackRate=t[n.id].playbackRate,n.playbackRate=t[n.id].playbackRate,n.onScale&&n.onScale()),o&&n.set({display:o})}}),i.resumeEventListeners()}i.updateTrackItemCoords(),i.adjustMagneticTrack(),i.updateTransitions(),i.requestRenderAll()}),_l=i.state.subscribeToScale(t=>{i.setScale(t.scale)}),bl=i.state.subscribeToUpdateItemDetails(t=>{const e=i.getTrackItems();if(e.length===0)return;const s=i.state.getState(),r=t.trackItemsMap,n=s.trackItemsMap;i.trackItemsMap=r,e.forEach(o=>{const a=r[o.id];if(a)if(o.hasSrc){const c=n[o.id];if(o.src!==a.details.src&&o.setSrc&&o.setSrc(a.details.src),a.type==="video"||a.type==="audio"){const l=c.display.to-c.display.from,u=nt(l,i.scale.zoom,c.playbackRate);o.set({duration:c.duration,display:c.display,trim:c.trim,width:u}),o.setCoords()}}else(a.type==="text"||a.type==="caption")&&(a.type==="text"||a.type==="caption")&&o.set({text:a.details.text})}),i.requestRenderAll()}),yl=i.state.subscribeToHistory(t=>{i.tracks=t.tracks,i.trackItemsMap=t.trackItemsMap,i.trackItemIds=t.trackItemIds,i.transitionIds=t.transitionIds,i.transitionsMap=t.transitionsMap,i.renderTracks(),i.refreshTrackLayout(),i.updateTrackItemCoords(),i.alignItemsToTrack(),i.alignTransitionsToTrack(),i.adjustMagneticTrack(),i.updateTransitions(),i.calcBounding(),i.duration=Gs(i.trackItemsMap)}),vl=i.state.subscribeToAddOrRemoveItems(()=>{const t=i.getTrackItems().map(n=>n.id),e=i.state.getState(),s=e.trackItemIds,r=[];t.forEach(n=>{s.includes(n)||r.push(n)}),i.deleteTrackItemById(r),i.tracks=e.tracks,i.trackItemsMap=e.trackItemsMap,i.transitionIds=e.transitionIds,i.transitionsMap=e.transitionsMap,s.forEach(n=>{if(!t.includes(n)){const a={...e.trackItemsMap[n]};i.addTrackItem(a)}}),i.trackItemIds=e.trackItemIds,i.activeIds=e.activeIds,i.renderTracks(),i.alignItemsToTrack(),i.updateTrackItemCoords(),i.calcBounding(),i.updateTransitions(),i.refreshTrackLayout(),i.selectTrackItemByIds(e.activeIds)})},fy=i=>{ml.unsubscribe(),vl.unsubscribe(),yl.unsubscribe(),bl.unsubscribe(),_l.unsubscribe(),Tl.unsubscribe(),xl.unsubscribe(),Sl.unsubscribe()},wl=(i,t)=>{let e=!1;const s=[];return t.forEach(r=>{r.containsPoint(i)&&(s.push(r),e=!0)}),{isOverObject:e,overObjects:s}};function py(i){return JSON.parse(JSON.stringify(i))}const rr=class rr extends pn{constructor(e,s){var r;super(e,s);w(this,"itemTypes",[]);w(this,"acceptsMap");w(this,"sizesMap",{});w(this,"objectTypes",[]);w(this,"tracks",[]);w(this,"hoverCornerItem",!1);w(this,"trackItemsMap",{});w(this,"trackItemIds",[]);w(this,"transitionIds",[]);w(this,"transitionsMap",{});w(this,"scale");w(this,"duration");w(this,"bounding");w(this,"onScroll");w(this,"onResizeCanvas");w(this,"tScale");w(this,"state");w(this,"activeIds",[]);w(this,"spacing");w(this,"guideLineColor");w(this,"withTransitions",[]);this.bounding=s.bounding||{width:s.width||0,height:s.height||0},this.tScale=((r=s.scale)==null?void 0:r.zoom)||1,this.state=s.state,this.onScroll=s.onScroll,this.onResizeCanvas=s.onResizeCanvas,this.acceptsMap=s.acceptsMap||{},this.sizesMap=s.sizesMap||{},this.itemTypes=s.itemTypes||[],this.objectTypes=rr.objectTypes,this.spacing=u0(s.spacing),this.itemTypes=s.itemTypes||[],this.positionAfterTransform={},this.initializeCanvasDefaults(),this.scale=s.scale,this.duration=s.duration,this.guideLineColor=s.guideLineColor||He,this.initEventListeners(),this.withTransitions=s.withTransitions||[]}static registerItems(e){Object.keys(e).forEach(s=>{C.setClass(e[s],s)}),rr.objectTypes=Object.keys(e).filter(s=>!Ld.includes(s))}getItemAccepts(e){return this.acceptsMap[e]||this.itemTypes}getItemSize(e){return this.sizesMap[e]||42}initializeCanvasDefaults(){const e=this.viewportTransform;e[4]=this.spacing.left,Object.assign(at.ownDefaults,{borderColor:"transparent",cornerColor:"white",cornerStrokeColor:"transparent",strokeWidth:0,borderOpacityWhenMoving:1,borderScaleFactor:1,cornerSize:8,cornerStyle:"rect",centeredScaling:!1,centeredRotation:!0,transparentCorners:!1})}__onMouseDown(e){const s=this.getScenePoint(e),r=this._activeObject,n=this.getActiveObjects();if(n.length===0){super.__onMouseDown(e);return}const{isOverObject:o}=wl(s,n);if(r&&(r==null?void 0:r.findControl(this.getViewportPoint(e),g0(e)))){super.__onMouseDown(e);return}const a=this.getTrackItems(),c=this.getObjects("Transition"),{isOverObject:h,overObjects:l}=wl(s,[...c,...a]);h?o?super.__onMouseDown(e):(this.setActiveIds([l[0].id]),super.__onMouseDown(e)):(this.discardActiveObject(),this.requestRenderAll(),this.setActiveIds([]),this._groupSelector={x:s.x,y:s.y,deltaY:0,deltaX:0},super.__onMouseDown(e))}_setupCurrentTransform(e,s,r){var n;if(this.hoverCornerItem){const o=this.getScenePoint(e),{key:a="",control:c}=s.getActiveControl()||{},h=c&&((n=c.getActionHandler(e,s,c))==null?void 0:n.bind(c)),l=this._getOriginFromCorner(s,a),u={target:s,action:"resizing",actionHandler:h,actionPerformed:!1,corner:a,scaleX:s.scaleX,scaleY:s.scaleY,skewX:s.skewX,skewY:s.skewY,offsetX:o.x-s.left,offsetY:o.y-s.top,originX:l.x,originY:l.y,ex:o.x,ey:o.y,lastX:o.x,lastY:o.y,theta:s.angle*Math.PI/180,width:s.width,height:s.height,shiftKey:e.shiftKey,altKey:!1,original:{scaleX:s.scaleX,scaleY:s.scaleY,skewX:s.skewX,skewY:s.skewY,angle:s.angle,left:s.left,flipX:s.flipX,flipY:s.flipY,top:s.top,originX:l.x,originY:l.y}};this._currentTransform=u,this.fire("before:transform",{e,transform:u})}else super._setupCurrentTransform(e,s,r)}initEventListeners(){ly(this),oy(this),gy(this)}setActiveIds(e){this.activeIds=e,this.state.updateState({activeIds:py(this.activeIds)},{kind:"layer:selection",updateHistory:!1})}updateState(e={updateHistory:!1}){this.filterEmptyTracks(),this.synchronizeTrackItemsState(),this.requestRenderAll(),this.duration=Gs(this.trackItemsMap),this.calcBounding(),this.refreshTrackLayout(),this.setTrackItemCoords();const s=this.getUpdatedState();this.state.updateState(s,e)}getUpdatedState(){const e=Gs(this.trackItemsMap);return{tracks:this.tracks,trackItemIds:this.trackItemIds,trackItemsMap:this.trackItemsMap,transitionIds:this.transitionIds,transitionsMap:this.transitionsMap,scale:this.scale,duration:e}}getDurationBasedOnTrackItemsPosition(){const e=this.getTrackItems().map(n=>n.getBoundingRect()),s=e.reduce((n,o)=>n.left+n.width<o.left+o.width?o:n,e[0]),r=s.left+s.width;return B(r,this.tScale)}notify(e={updateHistory:!1}){const s=this.getUpdatedState();this.state.updateState(s,e)}getState(){const e=Gs(this.trackItemsMap);return{tracks:this.tracks,trackItemIds:this.trackItemIds,trackItemsMap:this.trackItemsMap,transitionIds:this.transitionIds,transitionsMap:this.transitionsMap,scale:this.scale,duration:e}}purge(){ay(this),uy(this),fy(),this.dispose()}scrollTo({scrollLeft:e,scrollTop:s}){var o;const r=[...this.viewportTransform];let n=!1;typeof e=="number"&&(r[4]=-e+this.spacing.left,n=!0),typeof s=="number"&&(r[5]=-s,n=!0),n&&(this.viewportTransform=r,(o=this.getActiveObject())==null||o.setCoords(),this.requestRenderAll())}setBounding(e){this.bounding=e}calcBounding(){const e=this.getObjects("Track").filter(c=>c.static),s=[...this.getTrackItems(),...e].reduce((c,h)=>{const{top:l,height:u}=h.getBoundingRect();return{top:Math.min(c.top,l),height:Math.max(c.height,l+u)}},{top:1/0,height:0}),r=[...this.getTrackItems()].reduce((c,h)=>{const{left:l,width:u}=h.getBoundingRect();return{left:Math.min(c.left,l),width:Math.max(c.width,l+u)}},{left:1/0,width:this.width}),n=this.bounding.width,o=r.width,a=o-n;if(a<0){const c=this.getTrackItems(),h=this.getElement().clientWidth,l=c.reduce((u,d)=>d.left+d.width>u.left+u.width?d:u,c[0]);Math.abs(a)>h?this.setViewportPos(-(o-h)+this.spacing.right,this.viewportTransform[5]):l.left+l.width<=h?this.setViewportPos(16,this.viewportTransform[5]):this.setViewportPos(this.viewportTransform[4]-a,this.viewportTransform[5])}this.bounding={...s,...r},K.dispatch($h,{payload:{bounding:{...s,...r}}})}setViewportPos(e,s){var o;const r=this.getViewportPos(e,s),n=this.viewportTransform;n[4]=r.x,n[5]=r.y,this.requestRenderAll(),this.setActiveTrackItemCoords(),(o=this.onScroll)==null||o.call(this,{scrollTop:r.y,scrollLeft:r.x-this.spacing.left})}getViewportPos(e,s){const r=this,n=this.bounding.width-100>=r.width?this.spacing.right:0,o=r.width-this.bounding.width-n,a=this.spacing.left,c=Math.max(o,Math.min(e,a));if(this.bounding.height<this.height)return{x:c,y:0};const h=r.height-this.bounding.height-40,u=Math.max(h,Math.min(s,0));return{x:c,y:u}}setScale(e){this.pauseEventListeners(),this.tScale=e.zoom,this.scale=e,this.getTrackItems().forEach(r=>{const n=nt(r.display.from,this.tScale),o=nt(r.display.to-r.display.from,this.tScale,r.playbackRate);r.set({left:n,width:o,tScale:e.zoom}),r.onScale&&r.onScale(),r.setCoords()}),this.requestRenderAll(),this.calcBounding(),this.refreshTrackLayout(),this.updateTransitions(!1),this.resumeEventListeners()}};w(rr,"objectTypes",[]);let ys=rr;dy(ys,[ag,t0,Qv,cy]);const my={audio:Cn,media:Mn,common:oi,transition:On};M.BOTTOM=zd,M.CENTER=we,M.Control=Y,M.DRAG_END=Kn,M.DRAG_PREFIX=qn,M.DRAG_START=Uh,M.FabricObject=at,M.Helper=ce,M.LEFT=us,M.NONE=Hd,M.Pattern=Fr,M.Placeholder=ls,M.PreviewTrackItem=he,M.RIGHT=ds,M.Rect=Z,M.Resizable=ai,M.TIMELINE_BOUNDING_CHANGED=$h,M.TIMELINE_PREFIX=Jn,M.TIMELINE_SEEK=qh,M.TOP=Xd,M.Track=Lt,M.Transition=Rt,M.Trimmable=$t,M.calculateTimelineWidth=Gd,M.changeWidth=oi,M.classRegistry=C,M.controlsUtils=Xe,M.createAudioControls=sg,M.createMediaControls=Sc,M.createResizeControls=xc,M.createTemplateControls=eg,M.createTransitionControls=kn,M.default=ys,M.drawVerticalLine=Ft,M.generateId=fs,M.getDuration=Gs,M.isTransformCentered=gs,M.resize=my,M.resolveOrigin=I,M.timeMsToUnits=nt,M.unitsToTimeMs=B,M.util=Ga,M.wrapWithFixedAnchor=Vs,Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cliquify.me/timeline",
3
- "version": "4.0.25",
3
+ "version": "5.0.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -37,7 +37,7 @@
37
37
  "peerDependencies": {
38
38
  "@types/lodash-es": "^4.17.12",
39
39
  "@designcombo/events": "^1.0.2",
40
- "@cliquify.me/types": "4.0.25"
40
+ "@cliquify.me/types": "5.0.1"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "vite",