1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3761],{53761:function(e,t,i){"use strict";i.r(t),i.d(t,{EditorCanvas:function(){return tC}});var n=i(52322),o=i(2784),s=i(25237),r=i.n(s),a=i(21749),l=i(79130),h=i.n(l),u=i(54073),c=i.n(u),d=i(19458),p=i(38986),m=i(52305),f=i(28687),v=i(11080),g=i(94133),y=i(43034),b=i(118),C=i(84884),x=i(77237),w=i.n(x),S=i(30118),E=i(16991),A=i(48025),R=i(78958),O=i(87767),T=i(96335),I=i(3741),G=i(21571),P=i(27818),W=i(46301),_=i(8769),j=i(65089),F=i(72818),k=i(17847),M=i(58904),L=i(36810);class D extends o.PureComponent{componentDidMount(){this.context.onRegistered(this.name),this.rect=new a.fabric.Rect({...(0,F.CE)(this.props,"zIndex","clip"),strokeWidth:0,name:this.name}),this.context.mountObject(this.rect,{zIndex:this.props.zIndex})}componentDidUpdate(e){(0,M.v)({fields:[...Object.keys(k.RectAttributes),"clip","fill","shadow"],object:this.rect,props:this.props,prevProps:e,canvas:this.context.canvas})}componentWillUnmount(){this.context.unmountObject(this.rect)}render(){return null}constructor(e){super(e),this.name=e.name||(0,L.l)()}}D.contextType=E.FX;var N=i(18997),B=i(72215),z=i(78938);class U extends o.PureComponent{setRect(e){let{width:t,height:i}=this.props;void 0!==i&&1.25*i>=(t||0)?this.rect.scaleToHeight(i):void 0!==t&&t>(i||0)&&this.rect.scaleToWidth(t),(0,M.v)({fields:Object.values(k.RectAttributes),object:this.rect,props:this.props,prevProps:e||{},canvas:this.context.canvas,scaleToSize:!1})}animate(){if(!this.mounted)return;let{canvas:e}=this.context,t=(Date.now()-this.startedAt)%600,i=Math.floor((Date.now()-this.startedAt)/600)%2==0;this.rect.set("fill","rgba(209, 213, 219, ".concat(.4+.29999999999999993*(i?t:600-t)/600,")")),e.renderAll(),window.requestAnimationFrame(()=>{this.animate()})}componentDidMount(){this.context.mountObject(this.rect,{zIndex:this.props.zIndex}),window.requestAnimationFrame(()=>{this.animate()})}componentDidUpdate(e){this.setRect(e),this.props.zIndex!==e.zIndex&&"number"==typeof this.props.zIndex&&this.context.updateObjectZIndex(this.props.name,this.props.zIndex)}componentWillUnmount(){this.context.unmountObject(this.rect),this.mounted=!1}render(){return null}constructor(e){super(e),this.mounted=!0,this.startedAt=Date.now(),this.rect=new a.fabric.Rect({...e,name:e.name,fill:"#e5e7eb",selectable:!1,evented:!1})}}U.contextType=E.FX;var X=i(46620);let Y=k.ImageRectAttributes.filter(e=>"clip"!==e);class H extends o.PureComponent{setRect(e){this.fabricGroup&&((0,M.v)({fields:Y,object:this.fabricGroup,props:this.props,prevProps:e||{},canvas:this.context.canvas,scaleToSize:!1}),this.syncImageGeometry(e),this.props.lockRotation&&this.fabricGroup.setControlVisible("mtr",!1),this.props.lockUniScaling&&this.fabricGroup.setControlsVisibility({mt:!1,mb:!1,ml:!1,mr:!1}),this.props.hideControls&&this.fabricGroup.setControlsVisibility({mt:!1,mb:!1,ml:!1,mr:!1,bl:!1,br:!1,tl:!1,tr:!1,mtr:!1}))}syncImageGeometry(e){if(!this.fabricGroup)return;let t=this.fabricGroup.getObjects()[0];if(!(t instanceof a.fabric.Image))return;let i=null!=e&&(e.width!==this.props.width||e.height!==this.props.height),n=null!=e&&e.clip!==this.props.clip;if(!i&&!n)return;let{width:o,height:s,clip:r}=this.props;"number"==typeof o&&"number"==typeof s&&s>0&&((t.width||0)/(t.height||1)>o/s?t.scaleToHeight(s):t.scaleToWidth(o)),r?t.clipPath=new a.fabric.Rect({width:r.width,height:r.height,scaleX:1/(t.scaleX||1),scaleY:1/(t.scaleY||1),top:0,left:0,originX:"center",originY:"center"}):t.clipPath=void 0,this.fabricGroup._calcBounds(!0),this.fabricGroup.set("dirty",!0),this.fabricGroup.setCoords(),this.context.canvas.requestRenderAll()}async setSrc(e){var t;(null===(t=this.context)||void 0===t?void 0:t.canvas)||(0,N.H)("canvas is not defined");let i=this.props.src,n=null!=e&&null!=i&&i===e.src,o=null!=e&&(e.width!==this.props.width||e.height!==this.props.height);if(i&&n&&o){this.fabricGroup&&this.setRect(e);return}if(i&&(null==e||i!==e.src)){let e;this.setState({isLoading:!0}),this.cleanup();try{e=await (0,B.AJ)(i)}catch(e){(0,N.H)(e instanceof Error?e:Error(String(e)),{extra:{fabricImageName:this.props.name,src:i}}),this.mounted&&this.setState({isLoading:!1});return}if(!this.mounted||this.props.src!==i){this.mounted&&this.setState({isLoading:!1});return}this.setState({isLoading:!1}),this.fabricGroup=(0,z.createImageObject)(this.props,e),this.context.mountObject(this.fabricGroup,{zIndex:this.props.zIndex});return}this.setRect(e)}componentDidMount(){this.context.onRegistered(this.name),this.setSrc()}componentDidUpdate(e){this.setSrc(e),this.fabricGroup&&this.props.zIndex!==e.zIndex&&"number"==typeof this.props.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentWillUnmount(){this.mounted=!1,this.cleanup()}cleanup(){this.fabricGroup&&this.context.unmountObject(this.fabricGroup)}render(){let{top:e=0,left:t=0,width:i=0,height:o=0,originX:s="center",originY:r="center",uploadProgress:a}=this.props,l=i||0,h=o||0,u=t;"center"===s?u=t-l/2:"right"===s&&(u=t-l);let c=e;return"center"===r?c=e-h/2:"bottom"===r&&(c=e-h),(0,n.jsxs)(n.Fragment,{children:[this.state.isLoading&&(0,n.jsx)(U,{name:"".concat(this.name,"-skeleton"),zIndex:this.props.zIndex,top:e,left:t,width:Math.max(i,40),height:Math.max(o,40),originX:s,originY:r,angle:this.props.angle,scaleX:this.props.scaleX,scaleY:this.props.scaleY,skewX:this.props.skewX,skewY:this.props.skewY}),"number"==typeof a&&a<100&&(0,n.jsx)("div",{className:"absolute select-none pointer-events-none z-50",style:{to
1p:c+(o||0)-28,left:u+16,width:Math.max((i||120)-32,80)},children:(0,n.jsx)(X.E,{percent:a,className:"h-2"})})]})}constructor(e){super(e),this.mounted=!0,this.name=e.name||(0,L.l)(),this.state={isLoading:!1}}}H.contextType=E.FX;let q=()=>{var e,t,i,o,s,r,a,l,h,u,c,d;let{frameConfig:m,editorSize:f,background:{colors:v,gradientDirection:g,imageURL:y,imageRect:b,backgroundSize:C,imageResourceId:x}}=(0,S._i)(),{resources:w}=(0,j.o0)(),{offsetLeft:E,offsetTop:A}=m,R=null!==(o=null!=y?y:x?null===(e=w[x])||void 0===e?void 0:e.publicURL:void 0)&&void 0!==o?o:null,O=(0,_.D)(C,f,m,b),T=[R,null!=C?C:"free",null!==(s=O.left)&&void 0!==s?s:0,null!==(r=O.top)&&void 0!==r?r:0,null!==(a=O.width)&&void 0!==a?a:0,null!==(l=O.height)&&void 0!==l?l:0,null!==(h=O.scaleX)&&void 0!==h?h:1,null!==(u=O.scaleY)&&void 0!==u?u:1,null!==(c=null===(t=O.clip)||void 0===t?void 0:t.width)&&void 0!==c?c:0,null!==(d=null===(i=O.clip)||void 0===i?void 0:i.height)&&void 0!==d?d:0].join(":");return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(D,{zIndex:0,top:A,left:E,width:f.width,height:f.height,originX:"left",originY:"top",selectable:!1,evented:!1,padding:0,name:p.BG_COLOR_OBJECT_NAME,fill:(0,W.generateFillBackground)(f,v,g)}),R&&(0,n.jsx)(H,{zIndex:1,name:p.BG_IMAGE_OBJECT_NAME,src:R,lockRotation:!0,...O},T)]})};var K=i(83096),V=i(59311),J=i(33237),$=i(71414),Q=i(18149),Z=i.n(Q),ee=i(13888),et=i.n(ee),ei=i(64253),en=i(91162),eo=i(89291),es=i(63596),er=i(74194),ea=i(59571),el=i(14890),eh=i(71651),eu=i(32945),ec=i(65685),ed=i(60665),ep=i(44074),em=i(50996),ef=i(63775);function ev(e,t,i,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:10,s=[],r=t+i;for(let i=0;i<e;i+=o){var l;let o=(l=function(e,t){let i=e/t;i**=ef.LOW_FREQ_COMPRESSION;let n=Math.log10(ef.SPECTRUM_MIN_FREQ);return 10**(n+i*(Math.log10(ef.SPECTRUM_MAX_FREQ)-n))}(i,e))>=1e3?"".concat((l/1e3).toFixed(1),"k"):"".concat(Math.round(l)),h=new a.fabric.Text(o,{fontSize:8,fill:"#666666",fontFamily:"Arial",originX:"center",originY:"top",left:i*r+t/2,top:n+4,name:"freq-label-".concat(i),selectable:!1,evented:!1});s.push(h)}return s}class eg extends o.PureComponent{animateForFrame(e,t,i){var n,o;if(e===this.lastAnimatedFrame)return;this.lastAnimatedFrame=e;let s=null===(n=this.props.waveformConfig)||void 0===n?void 0:n.trim,r="number"==typeof(null==s?void 0:s.startRatio)&&"number"==typeof(null==s?void 0:s.endRatio)&&s.startRatio<s.endRatio,a=null===(o=this.props.audio)||void 0===o?void 0:o.duration,l=a&&!Number.isNaN(a)&&Number.isFinite(a),h=r&&l?Math.floor(s.startRatio*a*i.fps)+e:e,u=(0,ef.getFrequencyDataFromAudio)({audioData:t,currentFrame:h,fps:i.fps,numBars:this.cachedNumBars,optimizeFor:"speed"});u.length>0&&this.animateSpectrum(u)}updateCachedNumBars(){this.cachedNumBars=(0,em.calculateNumBars)(this.soundWaveGroup)}disableSpectrumObjectCaching(){this.soundWaveGroup.set("objectCaching",!1),this.soundWaveGroup.forEachObject(e=>{e.set("objectCaching",!1)})}animateSpectrum(e){let{waveformConfig:t}=this.props,{spectrumReactivity:i}=eu.EM.getState();!function(e){let{frequencyData:t,soundWaveGroup:i,referenceHeight:n,canvas:o,numBars:s,heightMultiplier:r=1,isDottedBars:a,dotDiameter:l,roundedRectCorners:h,spectrumReactivity:u,mirrored:c=!0}=e;if(!t.length||!i)return;let d=null!=s?s:(0,em.calculateNumBars)(i),p=(0,ef.processSpectrumData)({frequencyData:t,numBars:d,spectrumReactivity:u});(0,em.applyBarHeightsToCanvas)({barHeights:p,soundWaveGroup:i,referenceHeight:n,heightMultiplier:r,canvas:o,isDottedBars:a,dotDiameter:l,roundedRectCorners:h,mirrored:c})}({frequencyData:e,soundWaveGroup:this.soundWaveGroup,referenceHeight:t.reference.height,heightMultiplier:(0,ec.getEffectiveHeightMultiplier)(t),canvas:this.context.canvas,numBars:this.cachedNumBars,isDottedBars:(0,ep.isDottedBarsStyle)(t.style),dotDiameter:Math.max(p.MIN_DOTTED_BAR_THICKNESS,t.thickness),roundedRectCorners:(0,ed.shouldRoundSoundWaveRectCorners)(t),spectrumReactivity:i,mirrored:(0,ep.isMirroredSoundWaveStyle)(t.style)})}getWaveformObjects(){return(0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)?(0,ea.B)(this.props,1):(0,er.v)(this.props,1)}recreate(){let e;let{clip:t,waveformConfig:i}=this.props,n=(0,el.a)(i.glow),o=this.getWaveformObjects();e=(0,ep.isDottedBarsStyle)(i.style)?(0,em.calculateNumBars)(new a.fabric.Group(o)):Array.isArray(o)?o.length:1;let s=I.featureFlags.spectrumHzRepresentation?ev(e,i.thickness,i.space,i.reference.height,20):[];this.soundWaveGroup=new a.fabric.Group([...o,...s],{...(0,T.rE)(this.props),snapAngle:90,snapThreshold:5,lockScalingFlip:!0,name:this.name,objectCaching:!1,...n?{shadow:n.shadow}:{}}),t&&this.soundWaveGroup.set("clipPath",new a.fabric.Rect({width:t.width,height:t.height,scaleX:1/(this.props.scaleX||1),scaleY:1/(this.props.scaleY||1),top:0,left:0,originX:"center",originY:"center"})),this.context.mountObject(this.soundWaveGroup,{zIndex:this.props.zIndex}
1),this.disableSpectrumObjectCaching(),this.updateCachedNumBars(),this.lastAnimatedFrame=-1}updateWaveformDataOnly(){let e;let{waveformConfig:t}=this.props;if((0,ep.isDottedBarsStyle)(t.style)&&this.soundWaveGroup){(0,en.t)(this.soundWaveGroup,this.props),this.props.top&&this.soundWaveGroup.set("top",this.props.top),this.updateCachedNumBars(),this.context.canvas.requestRenderAll();return}let i=this.getWaveformObjects();e=(0,ep.isDottedBarsStyle)(t.style)?(0,em.calculateNumBars)(new a.fabric.Group(i)):Array.isArray(i)?i.length:1;let n=I.featureFlags.spectrumHzRepresentation?ev(e,t.thickness,t.space,t.reference.height,20):[];this.soundWaveGroup.remove(...this.soundWaveGroup.getObjects()),this.soundWaveGroup.addWithUpdate(...i,...n),this.disableSpectrumObjectCaching(),this.props.top&&this.soundWaveGroup.set("top",this.props.top),this.updateCachedNumBars(),this.context.canvas.requestRenderAll()}recreateWithOptionalCenterPin(e){this.soundWaveGroup&&(this.context.unmountObject(this.soundWaveGroup),this.context.onRegistered(this.name)),this.recreate(),e&&this.soundWaveGroup&&((0,eh.q0)(this.soundWaveGroup,e,(0,eh.fi)(this.props.waveformConfig)),this.context.canvas.requestRenderAll())}handleUpdate(e){let t=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),i=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig);if(null===this.prevLayoutKey||!Z()(i,this.prevLayoutKey)){this.prevConfig=t,this.prevLayoutKey=i;let n=(0,eh.wS)(e.waveformConfig,this.props.waveformConfig)&&this.soundWaveGroup?(0,eh.su)(this.soundWaveGroup,(0,eh.fi)(e.waveformConfig)):void 0;this.recreateWithOptionalCenterPin(n);return}let n=(0,es.i)({prevProps:e,nextProps:this.props,prevLayoutKey:this.prevLayoutKey});switch(Z()(t,this.prevConfig)||(this.prevConfig=t),n.type){case"RECREATE":{let t=(0,eh.wS)(e.waveformConfig,this.props.waveformConfig)&&this.soundWaveGroup?(0,eh.su)(this.soundWaveGroup,(0,eh.fi)(e.waveformConfig)):void 0;this.recreateWithOptionalCenterPin(t);return}case"REPAINT_COLORS":this.soundWaveGroup&&((0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)?(0,en.Jd)(this.soundWaveGroup,this.props.waveformConfig):(0,eo.updateSoundWaveColorsInPlace)(this.soundWaveGroup,this.props.waveformConfig),this.soundWaveGroup.setCoords(),this.context.canvas.requestRenderAll());return;case"RESHAPE_DATA":this.soundWaveGroup&&this.updateWaveformDataOnly();return;case"SYNC_ATTRS":case"UPDATE_CENTER_IMAGE_POSITION":break;default:throw Error("Unexpected waveform update intent: ".concat(JSON.stringify(n)))}(0,M.v)({fields:(0,T.$A)(),object:this.soundWaveGroup,prevProps:e,props:this.props,canvas:this.context.canvas}),"number"==typeof this.props.zIndex&&this.props.zIndex!==e.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.prevLayoutKey=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig),this.prevConfig=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),eu.EM.addComponent(this),this.loadAudioData()}componentDidUpdate(e){this.handleUpdate(e)}loadAudioData(){let{audioData:e}=eu.EM.getState();e&&(this.audioData=e)}componentWillUnmount(){eu.EM.removeComponent(this),this.context.unmountObject(this.soundWaveGroup)}render(){return null}constructor(e){super(e),this.audioData=null,this.cachedNumBars=128,this.lastAnimatedFrame=-1,this.start=0,this.end=1/0,this.prevConfig={waveformConfig:{},audioFileName:"",canvasAspectRatio:d.AspectRatio["2/1"]},this.prevLayoutKey=null,this.animate=(e,t)=>
1{if("spectrum"!==t.animationStyle)return;let i=t.audioData||this.audioData;if(!i)return;let{currentFrame:n}=t;this.animateForFrame(n,i,t)},this.name=e.name||(0,L.l)()}}eg.contextType=E.FX;class ey{static findPolygon(e){return(0,em.findSoundWavePolygon)(e)}static findSoundWavePolygon(e){return(0,em.findSoundWavePolygon)(e)}initializeOverlayClipPath(e){return this.overlayClipPath=new a.fabric.Rect({left:e.left,top:e.top,width:e.width,height:e.height,originX:e.originX,originY:e.originY,selectable:!1}),this.overlayClipPath}updateOverlayClipPath(e,t){if(!this.overlayClipPath||!this.polygonOverlay)return;let i=e.width||0;this.overlayClipPath.set("width",i*t),this.polygonOverlay.dirty=!0,this.polygonOverlay.setCoords()}createPolygonOverlay(e,t){var i;let n=(null===(i=e.points)||void 0===i?void 0:i.map(e=>({...e})))||[];return this.polygonOverlay=new a.fabric.Polygon(n,{fill:e.fill,name:"polygon-sound-wave-progress",opacity:1,left:e.left,top:e.top,originX:e.originX,originY:e.originY,selectable:!1,evented:!1,excludeFromExport:!1,shadow:e.shadow}),this.overlayClipPath=this.initializeOverlayClipPath(e),this.polygonOverlay.set("clipPath",this.overlayClipPath),t.add(this.polygonOverlay),this.polygonOverlay.moveTo(10),this.polygonOverlay}ensurePolygonOverlay(e,t){let i=t.getObjects().find(e=>e===this.polygonOverlay||"polygon-sound-wave-progress"===e.name);this.polygonOverlay&&i&&this.overlayClipPath||(this.polygonOverlay&&!i&&(this.polygonOverlay=null,this.overlayClipPath=null),this.createPolygonOverlay(e,t))}initializePolygonTimeline(e,t){e.set("opacity",.5),this.createPolygonOverlay(e,t)}updatePolygonTimelineVisuals(e,t,i){this.ensurePolygonOverlay(e,t),this.polygonOverlay&&this.overlayClipPath&&this.updateOverlayClipPath(e,i)}cleanup(){this.polygonOverlay=null,this.overlayClipPath=null}removeOverlay(e){this.polygonOverlay&&(e.remove(this.polygonOverlay),this.cleanup())}getOverlay(){return this.polygonOverlay}getClipPath(){return this.overlayClipPath}constructor(){this.polygonOverlay=null,this.overlayClipPath=null}}class eb extends o.PureComponent{isPolygonMode(){return(0,ed.usesHorizontalPolygonSoundWave)(this.props.waveformConfig)}isDottedBarsMode(){return(0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)}handleAnimate(e,t){let i=t.seekerPosition;this.updateTimelineVisuals(i)}updateTimelineVisuals(e){var t;this.isPolygonMode()?this.updatePolygonTimelineVisuals(e):this.isDottedBarsMode()?this.updateDottedBarsTimelineVisuals(e):this.updateBarTimelineVisuals(e);let i=this.soundWaveGroup.width||0,n=(null===(t=this.soundWaveGroup.getObjects()[0])||void 0===t?void 0:t.left)||0;this.seekerLine&&(this.seekerLine.set("left",n+i*e),this.seekerLine.setCoords()),this.context.canvas.requestRenderAll()}updateBarTimelineVisuals(e){let t=this.soundWaveGroup.getObjects(),i=Math.round((t.length-1)*e);for(let e=0;e<i&&e<t.length;e++)"seeker-line"!==t[e].name&&1!==t[e].opacity&&t[e].set("opacity",1);for(let e=i;e<t.length;e++)"seeker-line"!==t[e].name&&.5!==t[e].opacity&&t[e].set("opacity",.5)}updateDottedBarsTimelineVisuals(e){(0,en.JF)(this.soundWaveGroup,e,this.props)}updatePolygonTimelineVisuals(e){let t=ey.findPolygon(this.soundWaveGroup);t&&this.polygonHelper.updatePolygonTimelineVisuals(t,this.soundWaveGroup,e)}initializePolygonTimeline(){let e=ey.findPolygon(this.soundWaveGroup);e&&this.polygonHelper.initializePolygonTimeline(e,this.soundWaveGroup)}createSeekerLine(){let e=this.getSeekerLineSeekRatio();this.seekerLine=new a.fabric.Rect({left:-((this.soundWaveGroup.width||0)/2)+(this.soundWaveGroup.width||0)*e,top:-(((this.soundWaveGroup.height||0)-2)/2),width:0,height:(this.soundWaveGroup.height||0)-4,backgroundColor:"#FFFFFF",strokeWidth:2,originX:"left",originY:"top",name:"seeker-line",objectCaching:!1}),this.seekerLine.moveTo(10),this.soundWaveGroup.add(this.seekerLine)}getWaveformObjects(){return(0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)?(0,ea.B)(this.props,1):(0,er.v)(this.props,1)}recreate(){let{clip:e}=this.props,t=(0,el.a)(this.props.waveformConfig.glow);this.polygonHelper.cleanup(),this.soundWaveGroup=new a.fabric.Group(this.getWaveformObjects(),{...(0,T.rE)(this.props),snapAngle:90,snapThreshold:5,lockScalingFlip:!0,name:this.name,...t?{shadow:t.shadow}:{}}),e&&this.soundWaveGroup.set("clipPath",new a.fabric.Rect({width:e.width,height:e.height,scaleX:1/(this.props.scaleX||1),scaleY:1/(this.props.scaleY||1),top:0,left:0,originX:"center",originY:"center"})),this.seekerLine&&this.soundWaveGroup.add(this.seekerLine),this.context.mountObject(this.soundWaveGroup,{zIndex:this.props.zIndex})}updateWaveformDataOnly(){if((0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)&&this.soundWaveGroup){(0,en.t)(this.soundWaveGroup,this.props),this.props.top&&this.soundWaveGroup.set("top",this.props.top),this.context.canvas.requestRenderAll();return}this.polygonHelper.removeOverlay(this.soundWaveGroup);let e=this.getWaveformObjects();this.soundWaveGroup.remove(...this.soundWaveGroup.getObjects()),this.soundWaveGroup.addWithUpdate(...e),this.props.top&&this.soundWaveGroup.set("top",this.props.top),this.context.canvas.requestRenderAll()}recreateWithOptionalCenterPin(e){this.soundWaveGroup&&(this.context.unmountObject(this.soundWaveGroup),this.context.onRegistered(this.name)),this.recreate(),e&&this.soundWaveGroup&&((0,eh.q0)(this.soundWaveGroup,e,(0,eh.fi)(this.props.waveformConfig)),this.context.canvas.requestRenderAll())}handleUpdate(e){let t=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),i=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig);if(null===this.prevLayoutKey||!Z()(i,this.prevLayoutKey)){this.prevConfig=t,this.prevLayoutKey=i;let n=(0,eh.wS)(e.waveformConfig,this.props.waveformConfig)&&this.soundWaveGroup?(0,eh.su)(this.soundWaveGroup,(0,eh.fi)(e.waveformConfig)):void 0;this.recreateWithOptionalCenterPin(n);return}let n=(0,es.i)({prevProps:e,nextProps:this.props,prevLayoutKey:this.prevLayoutKey});switch(Z()(t,this.prevConfig)||(this.prevConfig=t),n.type){case"RECREATE":{let t=(0,eh.wS)(e.waveformConfig,this.props.waveformConfig)&&this.soundWaveGroup?(0,eh.su)(this.soundWaveGroup,(0,eh.fi)(e.waveformConfig)):void 0;this.recreateWithOptionalCenterPin(t);return}case"REPAINT_COLORS":this.soundWaveGroup&&((0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)?(0,en.Jd)(this.soundWaveGroup,this.props.waveformConfig):(0,eo.updateSoundWaveColorsInPlace)(this.soundWaveGroup,this.props.waveformConfig),this.soundWaveGroup.setCoords(),this.context.canvas.requestRenderAll());return;case"RESHAPE_DATA":this.soundWaveGroup&&this.updateWaveformDataOnly();return;case"SYNC_ATTRS":case"UPDATE_CENTER_IMAGE_POSITION":break;default:throw Error("Unexpected waveform update intent: ".concat(JSON.stringify(n)))}(0,M.v)({fields:(0,T.$A)(),object:this.soundWaveGroup,prevProps:e,props:this.props,canvas:this.context.canvas}),"number"==typeof this.props.zIndex&&this.props.zIndex!==e.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentDidUpdate(e){this.handleUpdate(e)}componentWillUnmount(){eu.EM.removeComponent(this),this.context.unmountObject(this.soundWaveGroup)}render(){return null}constructor(e){super(e),this.seekerLine=null,this.polygonHelper=new ey,this.start=0,this.end=1/0,this.prevConfig={waveformConfig:{},audioFileName:"",canvasAspectRatio:d.AspectRatio["2/1"]},this.prevLayoutKey=null,this.animate=(e,t)=>
1{"timeline"===t.animationStyle&&this.handleAnimate(e,t)},this.name=e.name||(0,L.l)()}}eb.contextType=E.FX;class eC extends eb{getSeekerLineSeekRatio(){var e;if(!this.props.audio||!this.props.audio.duration||Number.isNaN(this.props.audio.duration))return 0;let t=null===(e=this.props.waveformConfig)||void 0===e?void 0:e.trim,i=this.props.audio.currentTime,n=this.props.audio.duration;if(t&&void 0!==t.startRatio&&void 0!==t.endRatio){let{startRatio:e=0,endRatio:o=1}=t;i=Math.max(0,i=this.props.audio.currentTime-e*this.props.audio.duration),n*=o-e}return n<=0?0:Math.min(1,Math.max(0,i/n))}handleAnimate(e,t){if(this.props.audio&&!this.props.audio.paused){var i;let e=null===(i=this.props.waveformConfig)||void 0===i?void 0:i.trim,t=this.props.audio.currentTime;if(e&&void 0!==e.startRatio&&this.props.audio.duration>0){let{startRatio:i=0}=e;t=Math.max(0,t=this.props.audio.currentTime-i*this.props.audio.duration)}eu.EM.setTime(t)}super.handleAnimate(e,t)}initializeAnimation(){if(this.props.audio){if(this.props.audio.duration&&!Number.isNaN(this.props.audio.duration)&&Number.isFinite(this.props.audio.duration)){var e;let t=null===(e=this.props.waveformConfig)||void 0===e?void 0:e.trim,{duration:i}=this.props.audio;if(t&&void 0!==t.startRatio&&void 0!==t.endRatio){let{startRatio:e=0,endRatio:n=1}=t;i*=n-e}eu.EM.setDuration(i)}this.isPolygonMode()?this.initializePolygonTimeline():this.isDottedBarsMode()?this.updateDottedBarsTimelineVisuals(this.getSeekerLineSeekRatio()):this.soundWaveGroup.forEachObject(e=>{"seeker-line"!==e.name&&e.set("opacity",.5)}),this.createSeekerLine(),this.context.canvas.requestRenderAll()}}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.prevLayoutKey=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig),this.prevConfig=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),eu.EM.addComponent(this),this.initializeAnimation()}}var ex=i(49527),ew=i(48905),eS=i(27099),eE=i(78963),eA=i(90575);let eR=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(!e||0===e.length)return[];let n=e.length,o=Math.floor(t*i%n);return e.map((t,i)=>e[(i+o)%n])};function eO(e,t,i,n){let o=new a.fabric.Circle({radius:t,left:0,top:0,originX:"center",originY:"center",fill:"#e5e7eb",selectable:!1,evented:!1,name:i});e.insertAt(o,0,!1),e.setCoords(),n.requestRenderAll();let s=function(e,t,i){let n=Date.now(),o=null,s=()=>{if(!i())return;let r=Date.now()-n,a=r%600;e.set("fill","rgba(209, 213, 219, ".concat(.4+.29999999999999993*(Math.floor(r/600)%2==0?a:600-a)/600,")")),t.requestRenderAll(),o=requestAnimationFrame(s)};return o=requestAnimationFrame(s),()=>{null!==o&&(cancelAnimationFrame(o),o=null)}}(o,n,()=>e.contains(o));return{circle:o,stopAnimation:s}}function eT(e,t){t&&(t.stopAnimation(),null==e||e.remove(t.circle),null==e||e.setCoords())}class eI extends o.PureComponent{playTheWave(){if(!this.props.audio)return;this.soundWaveGroup.forEachObject(e=>e.set("opacity",.5));let e=()=>{if(!this.props.audio||this.props.audio.paused)return;let t=this.soundWaveGroup.getObjects(),i=this.props.audio.duration>0?this.props.audio.currentTime/this.props.audio.duration:0,n=Math.round((t.length-1)*i);for(let e=this.lastStart;e<n;e++)t[e].set("opacity",1);for(let e=n;e<t.length;e++){let i=t[e];.5!==i.opacity&&i.set("opacity",.5)}this.context.canvas.requestRenderAll(),this.lastStart=n,this.animationFrameHandle=requestAnimationFrame(e)};e()}stopTheWave(){null!==this.animationFrameHandle&&(cancelAnimationFrame(this.animationFrameHandle),this.animationFrameHandle=null),this.soundWaveGroup.forEachObject(e=>e.set("opacity",1)),this.context.canvas.requestRenderAll()}animateForFrame(e){if(void 0===e||e===this.lastAnimatedFrame)return;this.lastAnimatedFrame=e;let{shownWaveformData:t}=this.props;if(!t||0===t.length||!this.soundWaveGroup)return;let i=eR(t,e,1),n=(0,ew.p)({...this.props,shownWaveformData:i});this.soundWaveGroup.remove(...this.soundWaveGroup.getObjects()),this.soundWaveGroup.addWithUpdate(...n),this.context.canvas.requestRenderAll()}unmountCenterImage(){if(this.centerImageClipGroup){var e,t;null===(e=this.wrapperGroup)||void 0===e||e.remove(this.centerImageClipGroup),null===(t=this.wrapperGroup)||void 0===t||t.setCoords(),this.centerImageClipGroup=null,this.centerImageFabricObject=null}}showCenterImageLoading(){if(!this.wrapperGroup||this.centerImageLoadingPlaceholder)return;let e=this.props.waveformConfig.circleRadius||0;e<=0||(this.centerImageLoadingPlaceholder=eO(this.wrapperGroup,e,"".concat(this.centerImageName,"-loading"),this.context.canvas))}hideCenterImageLoading(){eT(this.wrapperGroup,this.centerImageLoadingPlaceholder),this.centerImageLoadingPlaceholder=null}resolveCenterImageLayoutFromProps(e){let t=this.props.waveformConfig.circleRadius||0;return(0,eS.resolveCenterImageLayoutForFabric)(this.props.centerImage,e.width,e.height,t)}updateCenterImageTransform(){var e,t;if(!this.centerImageFabricObject)return;let i=(0,eA.$B)(this.centerImageFabricObject),n=this.resolveCenterImageLayoutFromProps(i);(0,eE.O$)(this.centerImageFabricObject,this.centerImageName,n),this.centerImageFabricObject.
1setCoords(),null===(e=this.centerImageClipGroup)||void 0===e||e.setCoords(),null===(t=this.wrapperGroup)||void 0===t||t.setCoords(),this.context.canvas.requestRenderAll()}async loadAndMountCenterImage(e){var t,i;let n;try{n=await (0,B.AJ)(e)}catch(t){(null===(i=this.props.centerImage)||void 0===i?void 0:i.url)===e&&this.hideCenterImageLoading();return}if(!this.wrapperGroup||(null===(t=this.props.centerImage)||void 0===t?void 0:t.url)!==e)return;this.hideCenterImageLoading();let o=(0,eA.$B)(n),s=this.resolveCenterImageLayoutFromProps(o),r=(0,eE.a7)(n,this.props.waveformConfig.circleRadius||0,this.centerImageName,s);this.centerImageClipGroup=r,this.centerImageFabricObject=n,this.wrapperGroup.insertAt(r,0,!1),this.wrapperGroup.setCoords(),this.context.canvas.requestRenderAll(),(0,eA.pB)(n,()=>this.updateCenterImageTransform(),()=>!!(this.wrapperGroup&&this.centerImageFabricObject===n))}recreate(){var e,t;this.hideCenterImageLoading(),this.unmountCenterImage();let i=(0,el.a)(this.props.waveformConfig.glow),n=(0,ex.P)(this.props.waveformConfig,!!(null===(e=this.props.centerImage)||void 0===e?void 0:e.url));this.soundWaveGroup=new a.fabric.Group((0,ew.p)(this.props),{left:0,top:0,originX:"center",originY:"center",snapAngle:1,snapThreshold:1,lockScalingFlip:!0,...n?{clipPath:n}:{},name:"".concat(this.name,"-wave"),...i?{shadow:i.shadow}:{}});let o=null===(t=this.props.centerImage)||void 0===t?void 0:t.url,s=o?(0,B.Hh)(o):null,r=null;if(s){let e=this.props.waveformConfig.circleRadius||0,t=(0,eA.$B)(s),i=this.resolveCenterImageLayoutFromProps(t);r=(0,eE.a7)(s,e,this.centerImageName,i),this.centerImageClipGroup=r,this.centerImageFabricObject=s}this.wrapperGroup=new a.fabric.Group(r?[r,this.soundWaveGroup]:[this.soundWaveGroup],{...et()(this.props,k.ImageRectAttributes),name:this.name}),this.context.mountObject(this.wrapperGroup,{zIndex:this.props.zIndex}),s&&(0,eA.pB)(s,()=>this.updateCenterImageTransform(),()=>!!(this.wrapperGroup&&this.centerImageFabricObject===s)),o&&!s&&(this.showCenterImageLoading(),this.loadAndMountCenterImage(o))}updateWaveformDataOnly(){let e=(0,ew.p)(this.props);this.soundWaveGroup.remove(...this.soundWaveGroup.getObjects()),this.soundWaveGroup.addWithUpdate(...e),this.wrapperGroup.setCoords(),this.context.canvas.requestRenderAll()}handleUpdate(e){let t=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),i=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig);if(null===this.prevLayoutKey||!Z()(i,this.prevLayoutKey)){this.prevConfig=t,this.prevLayoutKey=i,this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.context.onRegistered(this.name)),this.recreate();return}let n=(0,es.i)({prevProps:e,nextProps:this.props,prevLayoutKey:this.prevLayoutKey});switch(Z()(t,this.prevConfig)||(this.prevConfig=t),n.type){case"RECREATE":this.updateWaveformDataOnly(),this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.context.onRegistered(this.name)),this.recreate();return;case"REPAINT_COLORS":this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.context.onRegistered(this.name)),this.recreate();return;case"RESHAPE_DATA":this.updateWaveformDataOnly();return;case"SYNC_ATTRS":break;case"UPDATE_CENTER_IMAGE_POSITION":this.updateCenterImageTransform();break;default:throw Error("Unexpected waveform update intent: ".concat(JSON.stringify(n)))}(0,M.v)({fields:[...k.ImageRectAttributes,"zIndex"],object:this.wrapperGroup,prevProps:e,props:this.props,canvas:this.context.canvas}),"number"==typeof this.props.zIndex&&this.props.zIndex!==e.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.prevLayoutKey=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig),this.prevConfig=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),this.props.isAudioPlaying&&this.playTheWave()}componentDidUpdate(e){this.handleUpdate(e);let t=this.props.frame,i=e.frame;void 0!==t&&t!==i&&this.animateForFrame(t),this.props.isAudioPlaying&&null===this.animationFrameHandle?this.playTheWave():this.props.isAudioPlaying||null===this.animationFrameHandle||this.stopTheWave()}componentWillUnmount(){null!==this.animationFrameHandle&&(cancelAnimationFrame(this.animationFrameHandle),this.animationFrameHandle=null),this.hideCenterImageLoading(),this.unmountCenterImage(),this.context.unmountObject(this.wrapperGroup)}render(){return null}constructor(e){super(e),this.centerImageFabricObject=null,this.centerImageClipGroup=null,this.centerImageLoadingPlaceholder=null,this.lastAnimatedFrame=-1,this.lastStart=0,this.animationFrameHandle=null,this.prevConfig={waveformConfig:{},audioFileName:"",canvasAspectRatio:d.AspectRatio["2/1"]},this.prevLayoutKey=null,this.name=e.name||(0,L.l)(),this.centerImageName="".concat(this.name,"-center-image")}}eI.contextType=E.FX;var eG=i(60740);class eP extends o.PureComponent{isRadialPolygonMode(){return(0,ep.isRadialPolygonSoundWaveStyle)(this.props.waveformConfig.style)}updateTimelineVisuals(e){if(this.isRadialPolygonMode()){(0,eG.bi)(this.soundWaveGroup,e),this.context.canvas.requestRenderAll();return}let t=this.soundWaveGroup.getObjects().filter(e=>{var t,i;return null===(i=e.name)||void 0===i?void 0:null===(t=i.startsWith)||void 0===t?void 0:t.call(i,"sound-bar-")}),i=Math.round((t.length-1)*e);for(let e=0;e<i&&e<t.length;e++)1!==t[e].opacity&&t[e].set("opacity",1);for(let e=i;e<t.length;e++).5!==t[e].opacity&&t[e].set("opacity",.5);this.context.canvas.requestRenderAll()}unmountCenterImage(){this.centerImageClipGroup&&this.wrapperGroup&&(this.wrapperGroup.remove(this.centerImageClipGroup),this.wrapperGroup.setCoords(),this.centerImageClipGroup=null,this.centerImageFabricObject=null)}showCenterImageLoading(){if(!this.wrapperGroup||this.centerImageLoadingPlaceholder)return;let e=this.props.waveformConfig.circleRadius||0;e<=0||(this.centerImageLoadingPlaceholder=eO(this.wrapperGroup,e,"".concat(this.centerImageName,"-loading"),this.context.canvas))}hideCenterImageLoading(){eT(this.wrapperGroup,this.centerImageLoadingPlaceholder),this.centerImageLoadingPlaceholder=null}resolveCenterImageLayoutFromProps(e){let t=this.props.waveformConfig.circleRadius||0;return(0,eS.resolveCenterImageLayoutForFabric)(this.props.centerImage,e.width,e.height,t)}updateCenterImagePan(){var e;if(!this.centerImageFabricObject)return;let t=(0,eA.$B)(this.centerImageFabricObject),i=this.resolveCenterImageLayoutFromProps(t);(0,eE.O$)(this.centerImageFabricObject,this.centerImageName,i),this.centerImageFabricObject.
1setCoords(),null===(e=this.centerImageClipGroup)||void 0===e||e.setCoords(),this.context.canvas.requestRenderAll()}async loadAndMountCenterImage(e){var t,i;let n;try{n=await (0,B.AJ)(e)}catch(t){(null===(i=this.props.centerImage)||void 0===i?void 0:i.url)===e&&this.hideCenterImageLoading();return}if(!this.wrapperGroup||(null===(t=this.props.centerImage)||void 0===t?void 0:t.url)!==e)return;this.hideCenterImageLoading();let o=(0,eA.$B)(n),s=this.resolveCenterImageLayoutFromProps(o),r=(0,eE.a7)(n,this.props.waveformConfig.circleRadius||0,this.centerImageName,s);r.set({objectCaching:!1}),n.set({objectCaching:!1}),this.centerImageClipGroup=r,this.centerImageFabricObject=n,this.wrapperGroup.insertAt(r,0,!1),this.wrapperGroup.setCoords(),this.context.canvas.requestRenderAll(),(0,eA.pB)(n,()=>this.updateCenterImagePan(),()=>!!(this.wrapperGroup&&this.centerImageFabricObject===n))}recreate(){var e,t;this.hideCenterImageLoading(),this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.wrapperGroup=null),this.centerImageClipGroup=null,this.centerImageFabricObject=null;let i=(0,el.a)(this.props.waveformConfig.glow),n=(0,ex.P)(this.props.waveformConfig,!!(null===(e=this.props.centerImage)||void 0===e?void 0:e.url));this.soundWaveGroup=new a.fabric.Group((0,ew.p)(this.props),{left:0,top:0,originX:"center",originY:"center",snapAngle:1,snapThreshold:1,lockScalingFlip:!0,objectCaching:!1,...n?{clipPath:n}:{},name:"".concat(this.name,"-wave"),...i?{shadow:i.shadow}:{}});let o=null===(t=this.props.centerImage)||void 0===t?void 0:t.url,s=o?(0,B.Hh)(o):null,r=null;if(s){let e=this.props.waveformConfig.circleRadius||0,t=(0,eA.$B)(s),i=this.resolveCenterImageLayoutFromProps(t);(r=(0,eE.a7)(s,e,this.centerImageName,i)).set({objectCaching:!1}),s.set({objectCaching:!1}),this.centerImageClipGroup=r,this.centerImageFabricObject=s}this.wrapperGroup=new a.fabric.Group(r?[r,this.soundWaveGroup]:[this.soundWaveGroup],{...et()(this.props,k.ImageRectAttributes),name:this.name,objectCaching:!1}),this.context.mountObject(this.wrapperGroup,{zIndex:this.props.zIndex}),s&&(0,eA.pB)(s,()=>this.updateCenterImagePan(),()=>!!(this.wrapperGroup&&this.centerImageFabricObject===s)),o&&!s&&(this.showCenterImageLoading(),this.loadAndMountCenterImage(o))}updateWaveformDataOnly(){let e=(0,ew.p)(this.props);this.soundWaveGroup.remove(...this.soundWaveGroup.getObjects()),this.soundWaveGroup.addWithUpdate(...e),this.context.canvas.requestRenderAll()}syncFabricUpdateBaselineFromProps(){this.prevLayoutKey=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig),this.prevConfig=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio")}handleUpdate(e){let t=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),i=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig);if(null===this.prevLayoutKey||!Z()(i,this.prevLayoutKey)){this.prevConfig=t,this.prevLayoutKey=i,this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.context.onRegistered(this.name)),this.recreate();return}let n=(0,es.i)({prevProps:e,nextProps:this.props,prevLayoutKey:this.prevLayoutKey});switch(Z()(t,this.prevConfig)||(this.prevConfig=t),n.type){case"RECREATE":this.updateWaveformDataOnly(),this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.context.onRegistered(this.name)),this.recreate();return;case"REPAINT_COLORS":this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.context.onRegistered(this.name)),this.recreate();return;case"RESHAPE_DATA":this.updateWaveformDataOnly();return;case"SYNC_ATTRS":break;case"UPDATE_CENTER_IMAGE_POSITION":this.updateCenterImagePan();break;default:throw Error("Unexpected waveform update intent: ".concat(JSON.stringify(n)))}if(this.wrapperGroup&&(0,M.v)({fields:[...k.ImageRectAttributes,"zIndex"],object:this.wrapperGroup,prevProps:e,props:this.props,canvas:this.context.canvas}),"number"==typeof this.props.zIndex&&this.props.zIndex!==e.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex),this.centerImageClipGroup&&this.centerImageFabricObject&&(this.props.left!==e.left||this.props.top!==e.top||this.props.angle!==e.angle||this.props.scaleX!==e.scaleX||this.props.scaleY!==e.scaleY||this.props.waveformConfig.circleRadius!==e.waveformConfig.circleRadius)){var o;let e=this.props.waveformConfig.circleRadius||0,t=(0,eA.$B)(this.centerImageFabricObject),i=this.resolveCenterImageLayoutFromProps(t);(0,eE.O$)(this.centerImageFabricObject,this.centerImageName,i);let n=this.centerImageClipGroup.clipPath;n&&n.set({radius:e}
1),this.centerImageFabricObject.setCoords(),this.centerImageClipGroup.setCoords(),null===(o=this.wrapperGroup)||void 0===o||o.setCoords(),this.context.canvas.requestRenderAll()}}onCircleClientAnimationPaused(){this.updateWaveformDataOnly()}componentDidUpdate(e){this.handleUpdate(e),e.isAudioPlaying&&!this.props.isAudioPlaying&&this.onCircleClientAnimationPaused()}componentWillUnmount(){eu.EM.removeComponent(this),this.hideCenterImageLoading(),this.wrapperGroup&&(this.context.unmountObject(this.wrapperGroup),this.wrapperGroup=null),this.centerImageClipGroup=null,this.centerImageFabricObject=null}render(){return null}constructor(e){super(e),this.wrapperGroup=null,this.centerImageFabricObject=null,this.centerImageClipGroup=null,this.centerImageLoadingPlaceholder=null,this.start=0,this.end=1/0,this.prevConfig={waveformConfig:{},audioFileName:"",canvasAspectRatio:d.AspectRatio["2/1"]},this.prevLayoutKey=null,this.animate=(e,t)=>{t.animationStyle===this.getExpectedAnimationStyle()&&this.handleAnimate(e,t)},this.name=e.name||(0,L.l)(),this.centerImageName="".concat(this.name,"-center-image")}}eP.contextType=E.FX;class eW extends eP{getExpectedAnimationStyle(){return"timeline"}handleAnimate(e,t){if(this.props.audio&&!this.props.audio.paused){var i;let e=null===(i=this.props.waveformConfig)||void 0===i?void 0:i.trim,t=this.props.audio.currentTime;if(e&&void 0!==e.startRatio&&this.props.audio.duration>0){let{startRatio:i=0}=e;t=Math.max(0,t=this.props.audio.currentTime-i*this.props.audio.duration)}eu.EM.setTime(t)}let n=t.seekerPosition;this.updateTimelineVisuals(n)}recreate(){super.recreate(),this.initializeAnimation()}initializeAnimation(){var e,t;let{audio:i}=this.props;if((null==i?void 0:i.duration)&&!Number.isNaN(i.duration)&&Number.isFinite(i.duration)){let t=null===(e=this.props.waveformConfig)||void 0===e?void 0:e.trim,{duration:n}=i;if(t&&void 0!==t.startRatio&&void 0!==t.endRatio){let{startRatio:e=0,endRatio:o=1}=t;n=(o-e)*i.duration}eu.EM.setDuration(n)}if(this.isRadialPolygonMode()){let e=null!==(t=eu.EM.getState().seekerPosition)&&void 0!==t?t:0;(0,eG.bi)(this.soundWaveGroup,e)}else this.soundWaveGroup.forEachObject(e=>{var t,i;(null===(i=e.name)||void 0===i?void 0:null===(t=i.startsWith)||void 0===t?void 0:t.call(i,"sound-bar-"))&&e.set("opacity",.5)});this.context.canvas.requestRenderAll()}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.syncFabricUpdateBaselineFromProps(),eu.EM.addComponent(this)}}class e_ extends eP{getExpectedAnimationStyle(){return"spectrum"}handleAnimate(e,t){let i=t.audioData||this.audioData;if(!i)return;let{currentFrame:n,fps:o}=t;this.animateForFrame(n,i,o)}captureRadialPolygonBaselineIfNeeded(){var e,t;if(!(0,ep.isRadialPolygonSoundWaveStyle)(this.props.waveformConfig.style)){this.radialPolygonBaselinePoints=null;return}if(null===(e=this.radialPolygonBaselinePoints)||void 0===e?void 0:e.length)return;let i=(0,em.findRadialPolygon)(this.soundWaveGroup);(null==i?void 0:null===(t=i.points)||void 0===t?void 0:t.length)&&(this.radialPolygonBaselinePoints=i.points.map(e=>({x:e.x,y:e.y})))}animateForFrame(e,t,i){var n,o;if(e===this.lastProcessedFrame||(this.lastProcessedFrame=e,!this.soundWaveGroup))return;this.captureRadialPolygonBaselineIfNeeded();let s=(0,em.calculateNumBars)(this.soundWaveGroup),r=null===(n=this.props.waveformConfig)||void 0===n?void 0:n.trim,a="number"==typeof(null==r?void 0:r.startRatio)&&"number"==typeof(null==r?void 0:r.endRatio)&&r.startRatio<r.endRatio,l=null===(o=this.props.audio)||void 0===o?void 0:o.duration,h=l&&!Number.isNaN(l)&&Number.isFinite(l),u=a&&h?Math.floor(r.startRatio*l*i)+e:e,c=(0,ef.getFrequencyDataFromAudio)({audioData:t,currentFrame:u,fps:i,numBars:s,optimizeFor:"speed"});c.length>0&&this.animateRadialSpectrum(c,s)}animateRadialSpectrum(e,t){if(!this.soundWaveGroup)return;let i=(0,ef.processSpectrumData)({frequencyData:e,numBars:Math.ceil(t/2),radialSpectrum:(0,ep.isCircleSoundWaveStyle)(this.props.waveformConfig.style),spectrumReactivity:eu.EM.getState().spectrumReactivity}),n=[...i,...i.slice().reverse()];if((0,ep.isRadialPolygonSoundWaveStyle)(this.props.waveformConfig.style)){let{circleRadius:e=0,circleBarHeight:i=100,reference:o}=this.props.waveformConfig;(0,em.applyBarHeightsToCanvas)({barHeights:n,soundWaveGroup:this.soundWaveGroup,referenceHeight:o.height,canvas:this.context.canvas,isCircleWaveform:!1,
1circleRadius:e,circleBarHeight:i,heightMultiplier:this.props.waveformConfig.heightMultiplier,spectrumPolygonBaselinePoints:this.radialPolygonBaselinePoints,numBars:t});return}this.applyRadialBarHeights(n)}applyRadialBarHeights(e){let{circleRadius:t=0,circleBarHeight:i=100}=this.props.waveformConfig;(0,em.applyBarHeightsToCanvas)({barHeights:e,soundWaveGroup:this.soundWaveGroup,referenceHeight:this.props.waveformConfig.reference.height,canvas:this.context.canvas,isCircleWaveform:!0,circleRadius:t,circleBarHeight:i,heightMultiplier:this.props.waveformConfig.heightMultiplier,roundedRectCorners:this.props.waveformConfig.roundedBars})}initializeAnimation(){this.loadAudioData()}loadAudioData(){let{audioData:e}=eu.EM.getState();e&&(this.audioData=e)}recreate(){this.radialPolygonBaselinePoints=null,super.recreate()}onCircleClientAnimationPaused(){this.radialPolygonBaselinePoints=null,super.onCircleClientAnimationPaused(),this.captureRadialPolygonBaselineIfNeeded()}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.syncFabricUpdateBaselineFromProps(),eu.EM.addComponent(this),this.initializeAnimation()}constructor(...e){super(...e),this.audioData=null,this.lastProcessedFrame=-1,this.radialPolygonBaselinePoints=null}}var ej=i(48799);class eF extends o.PureComponent{recreate(){let{clip:e}=this.props;this.soundWaveGroup=new a.fabric.Group((0,ej.z)(this.props),{...et()(this.props,Object.keys(k.RectAttributes)),snapAngle:90,snapThreshold:5,lockScalingFlip:!0}),e&&this.soundWaveGroup.set("clipPath",new a.fabric.Rect({width:e.width,height:e.height,scaleX:1/(this.props.scaleX||1),scaleY:1/(this.props.scaleY||1),top:0,left:0,originX:"center",originY:"center"})),this.seekerLine&&this.soundWaveGroup.add(this.seekerLine),this.context.mountObject(this.soundWaveGroup,{zIndex:this.props.zIndex})}handleUpdate(e){let t=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),i=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig);if(null===this.prevLayoutKey||!Z()(i,this.prevLayoutKey)){this.prevConfig=t,this.prevLayoutKey=i,this.soundWaveGroup&&(this.context.unmountObject(this.soundWaveGroup),this.context.onRegistered(this.name)),this.recreate();return}let n=(0,es.i)({prevProps:e,nextProps:this.props,prevLayoutKey:this.prevLayoutKey});switch(Z()(t,this.prevConfig)||(this.prevConfig=t),n.type){case"RECREATE":case"REPAINT_COLORS":case"RESHAPE_DATA":this.soundWaveGroup&&(this.context.unmountObject(this.soundWaveGroup),this.context.onRegistered(this.name)),this.recreate();return;case"SYNC_ATTRS":case"UPDATE_CENTER_IMAGE_POSITION":break;default:throw Error("Unexpected waveform update intent: ".concat(JSON.stringify(n)))}(0,M.v)({fields:[...Object.keys(k.RectAttributes),"zIndex"],object:this.soundWaveGroup,prevProps:e,props:this.props,canvas:this.context.canvas}),"number"==typeof this.props.zIndex&&this.props.zIndex!==e.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.prevLayoutKey=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig),this.prevConfig=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio")}componentDidUpdate(e){this.handleUpdate(e)}componentWillUnmount(){this.context.unmountObject(this.soundWaveGroup)}render(){return null}constructor(e){super(e),this.seekerLine=null,this.prevConfig={waveformConfig:{},audioFileName:"",canvasAspectRatio:d.AspectRatio["2/1"]},this.prevLayoutKey=null,this.name=e.name||(0,L.l)()}}eF.contextType=E.FX;class ek{async connect(e){if(this.audioContext&&this.disconnect(),e.readyState<2&&await new Promise((t,i)=>{let n=setTimeout(()=>{i(Error("Audio element not ready after timeout"))},5e3),o=()=>{clearTimeout(n),e.removeEventListener("canplay",o),e.removeEventListener("error",s),t()},s=()=>{clearTimeout(n),e.removeEventListener("canplay",o),e.removeEventListener("error",s),i(Error("Audio element error"))};e.readyState>=2?(clearTimeout(n),t()):(e.addEventListener("canplay",o),e.addEventListener("error",s))}),this.audioContext=new(window.AudioContext||window.webkitAudioContext),"suspended"===this.audioContext.state)try{await this.audioContext.resume()}catch(e){console.error("\uD83D\uDD35Failed to resume AudioContext:",e)}this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=this.fftSize,this.analyser.smoothingTimeConstant=.8;let t=new ArrayBuffer(this.analyser.fftSize*Float32Array.BYTES_PER_ELEMENT);this.floatTimeDomainData=new Float32Array(t);let i=new ArrayBuffer(this.analyser.frequencyBinCount);this.dataArray=new Uint8Array(i),await this.connectViaBufferSource(e)}
1async connectViaBufferSource(e){if(!this.audioContext||!this.analyser)throw Error("AudioContext or AnalyserNode not initialized");try{let{src:t}=e,i=t.startsWith("blob:")||t.startsWith("data:")?{mode:"same-origin"}:{mode:"cors"},n=await fetch(t,i);if(!n.ok)throw Error("Failed to fetch audio: ".concat(n.statusText));let o=await n.arrayBuffer();this.audioBuffer=await this.audioContext.decodeAudioData(o),this.silentGain=this.audioContext.createGain(),this.silentGain.gain.value=0,this.analyser.connect(this.silentGain),this.silentGain.connect(this.audioContext.destination),this.syncBufferSourceWithAudioElement(e)}catch(e){throw console.error("\uD83D\uDD35Failed to connect via AudioBufferSourceNode:",e),Error("Failed to connect audio analyser: ".concat(e instanceof Error?e.message:String(e)))}}syncBufferSourceWithAudioElement(e){if(!this.audioContext||!this.analyser||!this.audioBuffer)return;let t=()=>{if(this.audioContext&&this.audioBuffer&&e){if(this.bufferSource){try{this.bufferSource.stop()}catch(e){}this.bufferSource.disconnect()}if(!e.paused&&e.readyState>=2){this.bufferSource=this.audioContext.createBufferSource(),this.bufferSource.buffer=this.audioBuffer,this.analyser&&this.bufferSource.connect(this.analyser);let t=e.currentTime%this.audioBuffer.duration;this.playbackOffset=t,this.startTime=this.audioContext.currentTime,this.bufferSource.start(0,t),this.bufferSource.onended=()=>{!e.paused&&e.readyState>=2&&this.syncBufferSourceWithAudioElement(e)}}}},i=()=>{this.audioContext&&"suspended"===this.audioContext.state&&this.audioContext.resume(),t()},n=()=>
1{if(this.bufferSource){try{this.bufferSource.stop()}catch(e){}this.bufferSource.disconnect(),this.bufferSource=null}},o=()=>{this.bufferSource&&this.audioContext&&this.audioBuffer&&Math.abs((this.audioContext.currentTime-this.startTime+this.playbackOffset)%this.audioBuffer.duration-e.currentTime%this.audioBuffer.duration)>.1&&t()};e.addEventListener("play",i),e.addEventListener("pause",n),e.addEventListener("timeupdate",o),t(),this.cleanupBufferSource=()=>{e.removeEventListener("play",i),e.removeEventListener("pause",n),e.removeEventListener("timeupdate",o)}}getSampleRate(){var e;return(null===(e=this.audioContext)||void 0===e?void 0:e.sampleRate)||44100}getTimeDomainData(){if(!this.analyser||!this.dataArray||!this.bufferSource||this.audioContext&&"suspended"===this.audioContext.state)return[];let e=new Uint8Array(this.analyser.fftSize);try{this.analyser.getByteTimeDomainData(e)}catch(e){return console.warn("\uD83D\uDD35Error getting time domain data:",e),[]}return Array.from(e)}getFloatTimeDomainData(){if(!this.analyser||!this.floatTimeDomainData||!this.bufferSource||this.audioContext&&"suspended"===this.audioContext.state)return new Float32Array(0);try{this.analyser.getFloatTimeDomainData(this.floatTimeDomainData)}catch(e){return console.warn("\uD83D\uDD35Error getting float time domain data:",e),new Float32Array(0)}return this.floatTimeDomainData}getFrequencyData(){if(!this.analyser||!this.dataArray||!this.bufferSource)return[];if(this.audioContext&&"suspended"===this.audioContext.state)return this.audioContext.resume().catch(e=>{console.warn("\uD83D\uDD35AudioContext resume failed:",e)}),[];try{this.analyser.getByteFrequencyData(this.dataArray)}catch(e){return console.warn("\uD83D\uDD35Error getting frequency data:",e),[]}return Array.from(this.dataArray)}disconnect(){if(this.cleanupBufferSource&&(this.cleanupBufferSource(),this.cleanupBufferSource=null),this.bufferSource){try{this.bufferSource.stop()}catch(e){}try{this.bufferSource.disconnect()}catch(e){}this.bufferSource=null}if(this.silentGain){try{this.silentGain.disconnect()}catch(e){}this.silentGain=null}if(this.analyser){try{this.analyser.disconnect()}catch(e){}this.analyser=null}if(this.audioContext&&"closed"!==this.audioContext.state)try{this.audioContext.close()}catch(e){console.warn("\uD83D\uDD35Error closing AudioContext:",e)}this.audioContext=null,this.audioBuffer=null,this.dataArray=null,this.floatTimeDomainData=null,this.playbackOffset=0,this.startTime=0}constructor({fftSize:e=256}={}){this.audioContext=null,this.analyser=null,this.dataArray=null,this.floatTimeDomainData=null,this.bufferSource=null,this.audioBuffer=null,this.playbackOffset=0,this.startTime=0,this.cleanupBufferSource=null,this.silentGain=null,this.fftSize=e}}class eM extends o.PureComponent{setupAudioAnalyser(){this.props.audio&&(this.audioAnalyser&&(this.audioAnalyser.disconnect(),this.audioAnalyser=null),this.resetBarsToOriginal(),this.audioAnalyser=new ek,this.audioAnalyser.connect(this.props.audio).catch(e=>{console.error("\uD83D\uDD35Failed to connect AudioAnalyser:",e),this.audioAnalyser&&(this.audioAnalyser.disconnect(),this.audioAnalyser=null)}))}updateTimelineVisuals(e){let t=this.soundWaveGroup.getObjects(),i=Math.round((t.length-1)*e);for(let e=0;e<i&&e<t.length;e++)1!==t[e].opacity&&t[e].set("opacity",1);for(let e=i;e<t.length;e++).5!==t[e].opacity&&t[e].set("opacity",.5);let n=this.soundWaveGroup.width||0,o=this.soundWaveGroup.getObjects()[0].left||0;this.seekerLine&&(this.seekerLine.set("left",o+n*e),this.seekerLine.setCoords()),this.context.canvas.requestRenderAll(),this.lastStart=i}initializeTimeline(){this.props.audio&&(this.soundWaveGroup.forEachObject(e=>e.set("opacity",.5)),this.createSeekerLine(0),this.context.canvas.requestRenderAll())}resetBarsToOriginal(){if(!this.soundWaveGroup)return;let e=this.soundWaveGroup.getObjects(),t=0;e.forEach(e=>{var i;if("seeker-line"===e.name)return;let n=this.objectOriginalProperties.get(e);if(n){e.set({opacity:n.opacity,strokeWidth:n.strokeWidth}),e.setCoords(),t++;return}this.objectOriginalProperties.set(e,{opacity:null!==(i=e.opacity)&&void 0!==i?i:1,strokeWidth:e.strokeWidth}),e.setCoords(),t++}),t>0&&(this.context.canvas.requestRenderAll(),requestAnimationFrame(()=>{this.context.canvas.requestRenderAll()}))}animateSpectrum(e){if(!e.length||!this.soundWaveGroup)return;let t=this.soundWaveGroup.getObjects(),i=t.length,n=e.length;t.forEach((t,o)=>{var s,r;if("seeker-line"===t.name)return;let a=this.objectOriginalProperties.get(t)||{opacity:null!==(s=t.opacity)&&void 0!==s?s:1,strokeWidth:t.strokeWidth};this.objectOriginalProperties.has(t)||this.objectOriginalProperties.set(t,a);let l=(e[Math.min(Math.floor((o/Math.max(1,i))**.5*n),n-1)]||0)/255,h=.85+.15*Math.sin(.004*Date.now()+o/Math.max(1,i-1)*8);t.set({opacity:Math.min(1,a.opacity*(.75+.75*l*h)),strokeWidth:(null!==(r=a.strokeWidth)&&void 0!==r?r:1)*(1+.4*l)}),t.setCoords()}),this.context.canvas.requestRenderAll()}createSeekerLine(e){let t=this.props.audio&&this.props.audio.duration>0?this.props.audio.currentTime/this.props.audio.duration:e;this.seekerLine=new a.fabric.Rect({left:-((this.soundWaveGroup.width||0)/2)+(this.soundWaveGroup.width||0)*t,top:-(((this.soundWaveGroup.height||0)-2)/2),width:0,height:(this.soundWaveGroup.height||0)-4,backgroundColor:"#FFFFFF",strokeWidth:2,originX:"left",originY:"top",name:"seeker-line",objectCaching:!1}),this.seekerLine.moveTo(10),this.soundWaveGroup.add(this.seekerLine)}recreate(){let{clip:e}=this.props;this.soundWaveGroup=new a.fabric.Group((0,ej.z)(this.props),{...et()(this.props,Object.keys(k.RectAttributes)),snapAngle:90,snapThreshold:5,lockScalingFlip:!0}),e&&this.soundWaveGroup.set("clipPath",new a.fabric.Rect({width:e.width,height:e.height,scaleX:1/(this.props.scaleX||1),scaleY:1/(this.props.scaleY||1),top:0,left:0,originX:"center",originY:"center"})),this.seekerLine&&this.soundWaveGroup.add(this.seekerLine),this.lastStart=0,this.context.mountObject(this.soundWaveGroup,{zIndex:this.props.zIndex})}handleUpdate(e){let t=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),i=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig);if(null===this.prevLayoutKey||!Z()(i,this.prevLayoutKey)){this.prevConfig=t,this.prevLayoutKey=i,this.soundWaveGroup&&(this.context.unmountObject(this.soundWaveGroup),this.context.onRegistered(this.name)),this.recreate();return}let n=(0,es.i)({prevProps:e,nextProps:this.props,prevLayoutKey:this.prevLayoutKey});switch(Z()(t,this.prevConfig)||(this.prevConfig=t),n.type){case"RECREATE":case"REPAINT_COLORS":case"RESHAPE_DATA":this.soundWaveGroup&&(this.context.unmountObject(this.soundWaveGroup),this.context.onRegistered(this.name)),this.recreate();return;case"SYNC_ATTRS":case"UPDATE_CENTER_IMAGE_POSITION":break;default:throw Error("Unexpected waveform update intent: ".concat(JSON.stringify(n)))}(0,M.v)({fields:[...Object.keys(k.RectAttributes),"zIndex"],object:this.soundWaveGroup,prevProps:e,props:this.props,canvas:this.context.canvas}),"number"==typeof this.props.zIndex&&this.props.zIndex!==e.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.prevLayoutKey=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig),this.prevConfig=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),eu.EM.addComponent(this);let{isVideoRendering:e,animationStyle:t}=eu.EM.getState();e?this.animateForFrame():"spectrum"===t?this.setupAudioAnalyser():this.initializeTimeline()}componentDidUpdate(e){this.handleUpdate(e);let{isVideoRendering:t,currentFrame:i,animationStyle:n}=eu.EM.getState();if(t&&void 0!==i)this.animateForFrame();else{let e=eu.EM.getState().animationStyle;"spectrum"===n&&"spectrum"!==e?this.setupAudioAnalyser():"timeline"===n&&"timeline"!==e&&this.initializeTimeline()}}animateForFrame(e){let t=eu.EM.getState(),i=void 0!==e?e:t.currentFrame;if(void 0!==i){if("spectrum"===t.animationStyle){let{shownWaveformData:e}=this.props,{durationInFrames:n}=t;if(!e||0===e.length||0===n)return;let o=Math.floor(i/n*e.length),s=Array(128).fill(0),r=Math.min(e.length,256),a=Math.max(0,o-r/2),l=Math.min(e.length,o+r/2);for(let t=0;t<128;t++){let i=Math.floor((t/128)**.5*(l-a)),n=a+i;if(n>=0&&n<e.length){let i=e[n];s[t]=Math.floor(255*i)}}this.animateSpectrum(s)}else this.animateTimelineForFrame(i)}}animateTimelineForFrame(e){let t=eu.EM.getState(),i=void 0!==e?e:t.currentFrame;if(void 0===i||i<0)return;let n=t.seekerPosition,o=this.soundWaveGroup.getObjects(),s=Math.round((o.length-1)*n);this.seekerLine||this.createSeekerLine(n);for(let e=0;e<s&&e<o.length;e++)1!==o[e].opacity&&o[e].set("opacity",1);for(let e=s;e<o.length;e++).5!==o[e].opacity&&o[e].set("opacity",.5);let r=this.soundWaveGroup.width||0,a=this.soundWaveGroup.getObjects()[0].left||0;this.seekerLine&&(this.seekerLine.set("left",a+r*n),this.seekerLine.setCoords()),this.context.canvas.requestRenderAll(),this.lastStart=s}componentWillUnmount(){eu.EM.removeComponent(this),this.audioAnalyser&&(this.audioAnalyser.disconnect(),this.audioAnalyser=null),this.context.unmountObject(this.soundWaveGroup)}render(){return null}constructor(e){super(e),this.seekerLine=null,this.lastStart=0,this.audioAnalyser=null,this.start=0,this.end=1/0,this.objectOriginalProperties=new WeakMap,this.prevConfig={waveformConfig:{},audioFileName:"",canvasAspectRatio:d.AspectRatio["2/1"]},this.prevLayoutKey=null,this.animate=(e,t)=>
1{var i,n,o;if(t.isVideoRendering){this.animateForFrame(e);return}if("spectrum"===t.animationStyle){if(!this.props.audio||this.props.audio.paused||this.props.audio.readyState<2)return;let e=null!==(n=null===(i=this.audioAnalyser)||void 0===i?void 0:i.getFrequencyData())&&void 0!==n?n:[];this.animateSpectrum(e)}else{if(this.props.audio&&!this.props.audio.paused){let e=null===(o=this.props.waveformConfig)||void 0===o?void 0:o.trim,t=this.props.audio.currentTime;if(e&&void 0!==e.startRatio&&this.props.audio.duration>0){let{startRatio:i=0}=e;t=Math.max(0,t=this.props.audio.currentTime-i*this.props.audio.duration)}eu.EM.setTime(t)}let e=t.seekerPosition;this.updateTimelineVisuals(e)}},this.name=e.name||(0,L.l)()}}eM.contextType=E.FX;var eL=i(10283),eD=i(15793),eN=i(64345);class eB extends o.PureComponent{resolvedAnimationStyle(e){var t,i;return null!==(i=null!==(t=this.props.animationStyle)&&void 0!==t?t:null==e?void 0:e.animationStyle)&&void 0!==i?i:eu.EM.getState().animationStyle}shouldDrawSine(e){return"recorder-sine"===e&&(0,eN.MY)()}sineEnvelopeFromShownData(){let{waveformConfig:e,shownWaveformData:t}=this.props,{reference:i,thickness:n,space:o}=e;return(0,eL.zQ)(null!=t?t:[],{numBars:(0,eD.pH)({width:i.width,thickness:n,space:o}),heightMultiplier:(0,ec.getEffectiveHeightMultiplier)(e),referenceWidth:i.width,thickness:n,space:o})}applySineEnvelope(e){let{waveformConfig:t}=this.props;(0,eD.Ii)({envelope:e,soundWaveGroup:this.soundWaveGroup,referenceWidth:t.reference.width,referenceHeight:t.reference.height,canvas:this.context.canvas,waveColors:t.waveColors,waveGradientDirection:t.waveGradientDirection,thickness:t.thickness,mirrored:(0,ep.isMirroredSoundWaveStyle)(t.style)}),this.lastRecorderLook="sine"}restoreBarsLook(){if("sine"!==this.lastRecorderLook||!this.soundWaveGroup){this.lastRecorderLook="bars";return}(0,eD.UK)({soundWaveGroup:this.soundWaveGroup,canvas:this.context.canvas}),this.lastRecorderLook="bars"}syncRecorderLook(){if(this.soundWaveGroup){if(this.shouldDrawSine(this.resolvedAnimationStyle())){this.applySineEnvelope(this.sineEnvelopeFromShownData());return}this.restoreBarsLook()}}applyLiveRecorderLook(e,t){if(this.shouldDrawSine(e)){let{waveformConfig:e}=this.props,{reference:i,thickness:n,space:o}=e,s=(0,eL.P3)(t,{numBars:(0,eD.pH)({width:i.width,thickness:n,space:o}),heightMultiplier:(0,ec.getEffectiveHeightMultiplier)(e),referenceWidth:i.width,thickness:n,space:o});this.applySineEnvelope(s);return}this.restoreBarsLook(),this.animateWaveform(t)}animateWaveform(e){let{waveformConfig:t}=this.props,{reference:i,thickness:n,space:o}=t,s=(0,ec.getEffectiveHeightMultiplier)(t),r=(0,em.calculateNumBars)(this.soundWaveGroup),a=(0,eL.P3)(e,{numBars:r,heightMultiplier:s,referenceWidth:i.width,thickness:n,space:o});(0,em.applyBarHeightsToCanvas)({barHeights:a,soundWaveGroup:this.soundWaveGroup,referenceHeight:t.reference.height,heightMultiplier:1,canvas:this.context.canvas,isDottedBars:(0,ep.isDottedBarsStyle)(t.style),dotDiameter:Math.max(p.MIN_DOTTED_BAR_THICKNESS,t.thickness),roundedRectCorners:(0,ed.shouldRoundSoundWaveRectCorners)(t),mirrored:(0,ep.isMirroredSoundWaveStyle)(t.style)})}setupAudioAnalyser(){this.props.audio&&(this.audioAnalyser&&(this.audioAnalyser.disconnect(),this.audioAnalyser=null),this.lastSnapshotUpdateMs=0,this.audioAnalyser=new ek({fftSize:1024}),this.audioAnalyser.connect(this.props.audio).catch(e=>{console.error("\uD83D\uDD35AnimatedSoundWaveOscillator: failed to connect AudioAnalyser:",e),this.audioAnalyser&&(this.audioAnalyser.disconnect(),this.audioAnalyser=null)}))}disableObjectCaching(){this.soundWaveGroup.set("objectCaching",!1),this.soundWaveGroup.forEachObject(e=>{e.set("objectCaching",!1)})}getWaveformObjects(){return(0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)?(0,ea.B)(this.props,1):(0,er.v)(this.props,1)}recreate(){let{clip:e,waveformConfig:t}=this.props,i=(0,el.a)(t.glow),n=this.getWaveformObjects();this.soundWaveGroup=new a.fabric.Group(n,{...(0,T.rE)(this.props),snapAngle:90,snapThreshold:5,lockScalingFlip:!0,name:this.name,objectCaching:!1,...i?{shadow:i.shadow}:{}}),e&&this.soundWaveGroup.set("clipPath",new a.fabric.Rect({width:e.width,height:e.height,scaleX:1/(this.props.scaleX||1),scaleY:1/(this.props.scaleY||1),top:0,left:0,originX:"center",originY:"center"})),this.context.mountObject(this.soundWaveGroup,{zIndex:this.props.zIndex}),this.disableObjectCaching(),this.lastSnapshotUpdateMs=0,this.lastRecorderLook="bars",this.syncRecorderLook()}updateWaveformDataOnly(){let{waveformConfig:e}=this.props;if((0,ep.isDottedBarsStyle)(e.style)&&this.soundWaveGroup){(0,en.t)(this.soundWaveGroup,this.props),this.props.top&&this.soundWaveGroup.set("top",this.props.top),this.context.canvas.requestRenderAll();return}let t=this.getWaveformObjects();this.soundWaveGroup.remove(...this.soundWaveGroup.getObjects()),this.soundWaveGroup.addWithUpdate(...t),this.disableObjectCaching(),this.props.top&&this.soundWaveGroup.set("top",this.props.top),this.context.canvas.requestRenderAll()}recreateWithOptionalCenterPin(e){this.soundWaveGroup&&(this.context.unmountObject(this.soundWaveGroup),this.context.onRegistered(this.name)),this.recreate(),e&&this.soundWaveGroup&&((0,eh.q0)(this.soundWaveGroup,e,(0,eh.fi)(this.props.waveformConfig)),this.context.canvas.requestRenderAll())}handleUpdate(e){let t=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),i=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig);if(null===this.prevLayoutKey||!Z()(i,this.prevLayoutKey)){this.prevConfig=t,this.prevLayoutKey=i;let n=(0,eh.wS)(e.waveformConfig,this.props.waveformConfig)&&this.soundWaveGroup?(0,eh.su)(this.soundWaveGroup,(0,eh.fi)(e.waveformConfig)):void 0;this.recreateWithOptionalCenterPin(n);return}let n=(0,es.i)({prevProps:e,nextProps:this.props,prevLayoutKey:this.prevLayoutKey});switch(Z()(t,this.prevConfig)||(this.prevConfig=t),n.type){case"RECREATE":{let t=(0,eh.wS)(e.waveformConfig,this.props.waveformConfig)&&this.soundWaveGroup?(0,eh.su)(this.soundWaveGroup,(0,eh.fi)(e.waveformConfig)):void 0;this.recreateWithOptionalCenterPin(t);return}case"REPAINT_COLORS":this.soundWaveGroup&&((0,ep.isDottedBarsStyle)(this.props.waveformConfig.style)?(0,en.Jd)(this.soundWaveGroup,this.props.waveformConfig):(0,eo.updateSoundWaveColorsInPlace)(this.soundWaveGroup,this.props.waveformConfig),this.soundWaveGroup.setCoords(),this.syncRecorderLook(),this.context.canvas.requestRenderAll());return;case"RESHAPE_DATA":this.soundWaveGroup&&(this.updateWaveformDataOnly(),this.syncRecorderLook());return;case"SYNC_ATTRS":case"UPDATE_CENTER_IMAGE_POSITION":break;default:throw Error("Unexpected waveform update intent: ".concat(JSON.stringify(n)))}(0,M.v)({fields:(0,T.$A)(),object:this.soundWaveGroup,prevProps:e,props:this.props,canvas:this.context.canvas}),"number"==typeof this.props.zIndex&&this.props.zIndex!==e.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentDidMount(){this.context.onRegistered(this.name),this.recreate(),this.prevLayoutKey=(0,ei.getWaveformLayoutKey)(this.props.waveformConfig),this.prevConfig=et()(this.props,"audioFileName","waveformConfig","canvasAspectRatio"),eu.EM.addComponent(this),this.setupAudioAnalyser()}componentDidUpdate(e){this.handleUpdate(e),e.animationStyle!==this.props.animationStyle&&this.syncRecorderLook()}componentWillUnmount(){eu.EM.removeComponent(this),this.audioAnalyser&&(this.audioAnalyser.disconnect(),this.audioAnalyser=null),this.context.unmountObject(this.soundWaveGroup)}render(){return null}constructor(e){super(e),this.lastSnapshotUpdateMs=0,this.audioAnalyser=null,this.lastRecorderLook=null,this.start=0,this.end=1/0,this.prevConfig={waveformConfig:{},audioFileName:"",canvasAspectRatio:d.AspectRatio["2/1"]},this.prevLayoutKey=null,this.animate=(e,t)=>
1{var i;let n=this.resolvedAnimationStyle(t);if(!(0,J.isRecorderAnimationStyle)(n)||!this.props.audio||this.props.audio.paused)return;let o=performance.now();if(o-this.lastSnapshotUpdateMs<eB.HISTORY_UPDATE_INTERVAL_MS)return;let s=null===(i=this.audioAnalyser)||void 0===i?void 0:i.getFloatTimeDomainData();s&&s.length>0&&(this.applyLiveRecorderLook(n,s),this.lastSnapshotUpdateMs=o)},this.name=e.name||(0,L.l)()}}eB.contextType=E.FX,eB.HISTORY_UPDATE_INTERVAL_MS=32;var ez=i(64820),eU=i(34989);let eX=new Map,eY=new Map;async function eH(e,t){if(!(null==e?void 0:e.trim()))throw TypeError("loadSpectrumAudioData requires a non-empty src");let i=eX.get(e);if(i)return i;let n=eY.get(e);if(n)return n;let o=(async()=>{var i;let n=new(window.AudioContext||window.webkitAudioContext)({sampleRate:null!==(i=null==t?void 0:t.sampleRate)&&void 0!==i?i:48e3}),o=e.startsWith("blob:")||e.startsWith("data:")?{mode:"same-origin"}:{mode:"cors"},s=await fetch(e,o);if(!s.ok)throw Error("Failed to fetch audio data from ".concat(e,": ").concat(s.status," ").concat(s.statusText));let r=await s.arrayBuffer(),a=await n.decodeAudioData(r),l=(0,eU.eS)(a,String(Math.random()),e.startsWith("http://")||e.startsWith("https://"));return eX.set(e,l),eY.delete(e),l})();return eY.set(e,o),o}let eq=e=>{let{audioSrc:t,onAudioDataLoaded:i}=e,n=(0,o.useRef)(i);return n.current=i,(0,o.useEffect)(()=>{let e=!1;return eH(t).then(t=>{e||n.current(t)}).catch(t=>{console.error("Failed to load spectrum audio data:",t),e||n.current(null)}),()=>{e=!0}},[t]),null},eK=e=>{let{waveforms:t,waveformConfig:i,waveformRects:s,canvasAspectRatio:r,audioElement:a,playerStatus:l,isStatic:h,animationStyle:u}=e,c=null==a?void 0:a.src,p=c&&c.trim()&&!c.startsWith("about:"),m=(0,o.useCallback)(e=>{eu.EM.setAudioData(e)},[]);(0,o.useEffect)(()=>{p||eu.EM.setAudioData(null)},[p]);let f=(0,eN.ck)(null!=u?u:eu.EM.getState().animationStyle),v=()=>(0,ep.isCircleSoundWaveStyle)(i.style)?eI:i.style===d.SoundWaveStyle.horizontal_bezier?eF:$.i,g=()=>(0,ep.isCircleSoundWaveStyle)(i.style)?"spectrum"===f?e_:eW:(0,J.isRecorderAnimationStyle)(f)?eB:i.style===d.SoundWaveStyle.horizontal_bezier?eM:"spectrum"===f?eg:eC;return(0,n.jsxs)(n.Fragment,{children:[p&&(0,n.jsx)(eq,{audioSrc:c,onAudioDataLoaded:m}),t.map((e,t)=>{var o,u,c;let d=v(),p=g(),m=null==s?void 0:s[t],y=0===t&&l===P.c.playing,b=0===t&&(0,J.isRecorderAnimationStyle)(f)&&!(0,ep.isCircleSoundWaveStyle)(i.style),C=d;b?C=eB:y&&(C=p);let x=null!==(u=e.trim)&&void 0!==u?u:i.trim,w=x?{...i,trim:x}:i;return(0,n.jsx)(C,{zIndex:null!==(c=null===(o=e.rect)||void 0===o?void 0:o.zIndex)&&void 0!==c?c:ez.LAYER_ZINDEX.full.waveform+.01*t,static:h,name:e.id,waveformConfig:w,shownWaveformData:e.shownWaveformData,canvasAspectRatio:r,audioFileName:e.audioFileName,audioResourceId:e.audioResourceId,audio:0===t?a:void 0,isAudioPlaying:0===t&&l===P.c.playing,centerImage:e.centerImage,...m,animationStyle:f,recreateOnDataChange:!0},function(e){var t,i;let n=e.waveformData,o=null!==(t=null==n?void 0:n.length)&&void 0!==t?t:0,s=o>0?n[0]:"",r=o>1?n[Math.floor(o/2)]:"",a=o>0?n[o-1]:"";return"".concat(e.id,":").concat(e.audioFileName,":").concat(o,":").concat(s,":").concat(r,":").concat(a,":").concat(null!==(i=e.audioResourceId)&&void 0!==i?i:"")}(e))})]})};var eV=i(86767);let eJ=(e,t)=>{let i=(t||"A").replace(/[\r\n]+/g," ");return document.fonts.check("1em ".concat(e),i)};class e$ extends o.PureComponent{async componentDidMount(){this.mounted=!0,this.context.onRegistered(this.name),eJ(this.props.fontFamily,this.props.text)||await this.waitForCurrentFont(),this.recreate()}componentDidUpdate(e){this.syncObject(e),this.groupObject&&this.props.zIndex!==e.zIndex&&"number"==typeof this.props.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentWillUnmount(){this.mounted=!1,this.cleanup()}captionPatchFromProps(e){return{text:e.text,fontSize:e.fontSize,fontFamily:e.fontFamily,fillColor:e.fillColor,left:e.left,top:e.top,originX:e.originX,originY:e.originY,angle:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,lineHeight:e.lineHeight,shadow:e.shadow}}applyKaraokePreview(){var e,t,i;if(!this.groupObject)return!1;let n=this.props.karaokePreview;if(!(null==n?void 0:n.enabled)||!(null===(e=n.cue)||void 0===e?void 0:e.text)){let[e,t]=(0,f.captionLineTexts)(this.groupObject);return null==e||e.set("styles",{}),null==t||t.set("styles",{}),this.groupObject.dirty=!0,!0}let[o]=(0,f.captionLineTexts)(this.groupObject),s=null!==(i=null!==(t=null==o?void 0:o.fill)&&void 0!==t?t:this.props.fillColor)&&void 0!==i?i:"#000000";return(0,f.applyCaptionLineGroupWordHighlight)(this.groupObject,n.cue.text,n.cue.wordTimings,n.timeMs,f.CAPTION_KARAOKE_HIGHLIGHT_FILL,s),!0}async syncObject(e){var t,i,n,o,s,r,a,l,h,u,c,d;if(eJ(this.props.fontFamily,this.props.text)||await this.waitForCurrentFont(),!this.groupObject)return;let p=(0,f.diffCaptionLineGroupPatch)(this.captionPatchFromProps(this.props),e?this.captionPatchFromProps(e):void 0);Object.keys(p).length>0&&(0,f.applyCaptionLineGroupPatch)(this.groupObject,p),this.groupObject.
1set({selectable:!1!==this.props.selectable,evented:!1!==this.props.evented});let m=null!=e&&e.fillColor!==this.props.fillColor,v=(!!((null==e?void 0:null===(t=e.karaokePreview)||void 0===t?void 0:t.timeMs)!==(null===(i=this.props.karaokePreview)||void 0===i?void 0:i.timeMs)||(null==e?void 0:null===(n=e.karaokePreview)||void 0===n?void 0:n.enabled)!==(null===(o=this.props.karaokePreview)||void 0===o?void 0:o.enabled)||(null==e?void 0:null===(r=e.karaokePreview)||void 0===r?void 0:null===(s=r.cue)||void 0===s?void 0:s.text)!==(null===(l=this.props.karaokePreview)||void 0===l?void 0:null===(a=l.cue)||void 0===a?void 0:a.text)||(null==e?void 0:null===(u=e.karaokePreview)||void 0===u?void 0:null===(h=u.cue)||void 0===h?void 0:h.wordTimings)!==(null===(d=this.props.karaokePreview)||void 0===d?void 0:null===(c=d.cue)||void 0===c?void 0:c.wordTimings))||!!m)&&this.applyKaraokePreview();(Object.keys(p).length>0||v)&&this.context.canvas.requestRenderAll()}recreate(){this.cleanup();let e=(0,f.buildCaptionLineGroup)({...this.props,name:this.name});e.setControlsVisibility({mt:!1,mb:!1,ml:!1,mr:!1,bl:!1,br:!1,tl:!1,tr:!1}),e.set({selectable:!1!==this.props.selectable,evented:!1!==this.props.evented}),this.groupObject=e,this.context.mountObject(e,{zIndex:this.props.zIndex}),this.applyKaraokePreview()}cleanup(){this.groupObject&&(this.context.unmountObject(this.groupObject),this.groupObject=void 0)}render(){return null}constructor(e){super(e),this.mounted=!1,this.waitForCurrentFont=()=>new Promise(e=>{document.fonts.ready.then(()=>{eJ(this.props.fontFamily,this.props.text)?e():this.mounted&&(0,eV.wait)(250).then(()=>this.waitForCurrentFont())})}),this.name=e.name||(0,L.l)()}}e$.contextType=E.FX;var eQ=i(6196),eZ=i(85858);class e0 extends o.PureComponent{async componentDidMount(){this.mounted=!0,this.context.onRegistered(this.name),eJ(this.props.fontFamily,this.props.text)||await this.waitForCurrentFont(),this.recreate()}componentDidUpdate(e){this.syncObject(e),this.textObject&&this.props.zIndex!==e.zIndex&&"number"==typeof this.props.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentWillUnmount(){this.mounted=!1,this.cleanup()}async syncObject(e){var t,i;if(eJ(this.props.fontFamily,this.props.text)||await this.waitForCurrentFont(),!this.textObject)return;let n=[...Object.keys((0,F.CE)(k.RectAttributes,"width","height")),"text","fontSize","fontFamily","fillColor","lineHeight","textAlign"];this.props.textAlign&&n.push("width"),(0,M.v)({fields:n,object:this.textObject,props:this.props,prevProps:e,canvas:this.context.canvas});let o=null!==(t=e.shadow)&&void 0!==t?t:null,s=null!==(i=this.props.shadow)&&void 0!==i?i:null;Z()(o,s)||(this.textObject.set("shadow",(0,eQ.textNodeShadowToFabric)(this.props.shadow)),this.textObject.setCoords(),this.context.canvas.requestRenderAll())}recreate(e){var t;let i={...this.props,...e};this.cleanup();let n=!!i.textAlign;if(this.textObject=new a.fabric.IText(null!==(t=i.text)&&void 0!==t?t:"",Object.fromEntries(Object.entries({lockScalingX:!0,lockScalingY:!0,lockScalingFlip:!0,...et()(i,"fontFamily","fontSize","lineHeight","text","left","top","angle","originX","originY","textAlign","selectable","skewX","skewY","scaleX","scaleY",...n?["width"]:[]),fill:i.fillColor,name:this.name}).filter(e=>{let[,t]=e;return void 0!==t}))),this.textObject.setControlsVisibility({mt:!1,mb:!1,ml:!1,mr:!1,bl:!1,br:!1,tl:!1,tr:!1}),this.textObject.set("shadow",(0,eQ.textNodeShadowToFabric)(i.shadow)),i.static||this.textObject.on("changed",()=>{var e;(null===(e=this.textObject)||void 0===e?void 0:e.text)&&this.props.updateText(this.textObject.text)}),this.context.mountObject(this.textObject,{zIndex:this.props.zIndex}),!i.static&&(0,eZ.bK)(this.name)){let{canvas:e}=this.context;try{e instanceof a.fabric.Canvas&&e.setActiveObject(this.textObject),this.textObject.enterEditing(),this.textObject.selectAll(),this.context.canvas.requestRenderAll()}catch(e){}}}cleanup(){this.textObject&&(this.textObject.off("changed"),this.context.unmountObject(this.textObject))}render(){return null}constructor(e){super(e),this.mounted=!1,this.waitForCurrentFont=()=>new Promise(e=>{document.fonts.ready.then(()=>{eJ(this.props.fontFamily,this.props.text)?e():this.mounted&&(0,eV.wait)(250).then(()=>this.waitForCurrentFont())})}),this.name=e.name||(0,L.l)()}}e0.contextType=E.FX;var e1=i(43372),e2=i(26515);let e9=Object.values(k.RectAttributes).filter(e=>"width"!==e&&"height"!==e);class e8 extends o.PureComponent{setRect(e){if(!this.fabricGroup)return;let{width:t,height:i}=this.props,n=this.fabricGroup.getObjects()[0];void 0!==i&&1.25*i>=(t||0)?n.scaleToHeight(i):void 0!==t&&t>(i||0)&&n.scaleToWidth(t),(0,M.v)({fields:e9,object:this.fabricGroup,props:this.props,prevProps:e||{},canvas:this.context.canvas,scaleToSize:!1}),this.props.fillColor!==(null==e?void 0:e.fillColor)&&(0,e2.Q)(this.fabricGroup.getObjects(),this.props.fillColor),this.props.lockRotation&&this.fabricGroup.setControlVisible("mtr",!1),this.props.lockUniScaling&&this.fabricGroup.setControlsVisibility({mt:!1,mb:!1,ml:!1,mr:!1}),this.props.hideControls&&this.fabricGroup.setControlsVisibility({mt:!1,mb:!1,ml:!1,mr:!1,bl:!1,br:!1,tl:!1,tr:!1,mtr:!1})}async setSrc(e){var t;let{svg:i}=this.props;if(!(null===(t=this.context)||void 0===t?void 0:t.canvas)){(0,N.H)("canvas is not defined");return}if(i!==(null==e?void 0:e.svg)||e.scaleX!==this.props.scaleX||e.scaleY!==this.props.scaleY){this.setState({isLoading:!0});let t=(0,e2.Q)(await (0,e1.K)(i),this.props.fillColor);if(this.setState({isLoading:!1}),this.cleanup(),!this.mounted)return;this.fabricGroup=new a.fabric.Group(t.slice(1),{fill:"transparent",snapAngle:90,snapThreshold:5,name:this.name,...et()(this.props,...e9)}),this.context.mountObject(this.fabricGroup,{zIndex:this.props.zIndex}),this.setRect(e);return}this.setRect(e)}componentDidMount(){this.context.onRegistered(this.name),this.setSrc()}componentDidUpdate(e){this.setSrc(e),this.fabricGroup&&this.props.zIndex!==e.zIndex&&"number"==typeof this.props.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex)}componentWillUnmount(){this.mounted=!1,this.cleanup()}cleanup(){this.fabricGroup&&this.context.unmountObject(this.fabricGroup)}render(){return null}constructor(e){super(e),this.mounted=!0,this.state={isLoading:!1},this.name=e.name||(0,L.l)()}}e8.contextType=E.FX;var e3=i(63359),e5=i(90204);let e6=k.ImageRectAttributes.filter(e=>"clip"!==e);class e4 extends o.PureComponent{getOwnedVideoElement(){var e;return null!==(e=this.ownedVideoEl)&&void 0!==e?e:null}getSyncTargetTime(){let{syncPlaybackElement:e,playbackTime:t}=this.props;if(e&&!e.paused){let t=e.currentTime;if(Number.isFinite(t))return t}return void 0!==t&&Number.isFinite(t)?t:e&&Number.isFinite(e.currentTime)?e.currentTime:void 0}paintFrame(){var e;this.fabricGroup&&((0,e3.Kt)(this.fabricGroup),null===(e=this.context.canvas)||void 0===e||e.requestRenderAll())}seekOwnedVideoToTargetTime(e){let t=this.getOwnedVideoElement();t&&Number.isFinite(e)&&!t.seeking&&Math.abs(t.currentTime-e)>e5.wr&&(t.currentTime=e)}syncDecoderPlayback(){let e=this.getOwnedVideoElement(),t=this.props.syncPlaybackElement;if(!e)return;if(!t||t.paused){this.playGeneration+=1,this.playInFlight=!1,e.paused||e.pause();return}if(!e.paused||e.seeking||this.playInFlight)return;let i=this.playGeneration+1;this.playGeneration=i,this.playInFlight=!0;let n=t.currentTime,o=Number.isFinite(n)&&Math.abs(e.currentTime-n)>e5.wr,s=()=>
1{if(!this.mounted||this.playGeneration!==i){this.playInFlight=!1;return}e.play().catch(()=>void 0).finally(()=>{this.playGeneration===i&&(this.playInFlight=!1)})};if(o){let t=()=>{e.removeEventListener("seeked",t),s()};e.addEventListener("seeked",t),e.currentTime=n;return}s()}bindTransport(e){this.transportBound!==e&&(this.unbindTransport(),this.transportBound=null!=e?e:null,e&&(e.addEventListener("play",this.onTransportPlay),e.addEventListener("pause",this.onTransportPause),e.addEventListener("ended",this.onTransportPause),e.addEventListener("seeked",this.onTransportSeeked),this.syncDecoderPlayback()))}unbindTransport(){var e;this.transportBound&&(this.transportBound.removeEventListener("play",this.onTransportPlay),this.transportBound.removeEventListener("pause",this.onTransportPause),this.transportBound.removeEventListener("ended",this.onTransportPause),this.transportBound.removeEventListener("seeked",this.onTransportSeeked),this.transportBound=null,this.playGeneration+=1,this.playInFlight=!1,null===(e=this.ownedVideoEl)||void 0===e||e.pause())}attachVideoListeners(e){e.addEventListener("seeked",this.onVideoSeeked),e.addEventListener("loadeddata",this.onVideoLoadedData)}detachVideoListeners(e){e.removeEventListener("seeked",this.onVideoSeeked),e.removeEventListener("loadeddata",this.onVideoLoadedData)}mountFabricFromVideo(e){this.cleanupFabricOnly();try{this.fabricGroup=(0,e3.qC)(this.props,e),this.context.mountObject(this.fabricGroup,{zIndex:this.props.zIndex}),this.setState({isLoading:!1}),this.syncDecoderPlayback(),e.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&this.paintFrame()}catch(e){(0,N.H)(e instanceof Error?e:Error(String(e)),{extra:{fabricVideoName:this.name}}),this.mounted&&this.setState({isLoading:!1})}}disposeOwnedVideo(){this.ownedVideoEl&&(this.detachVideoListeners(this.ownedVideoEl),this.ownedVideoEl.pause(),this.ownedVideoEl.removeAttribute("src"),this.ownedVideoEl.load(),this.ownedVideoEl.remove(),this.ownedVideoEl=void 0)}async ensureOwnedVideo(e){this.disposeOwnedVideo();let t=document.createElement("video");return t.muted=!0,t.defaultMuted=!0,t.playsInline=!0,t.preload="auto",t.setAttribute("playsinline",""),t.setAttribute("muted",""),t.style.cssText="position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none;",e.startsWith("blob:")||(t.crossOrigin="anonymous"),document.body.appendChild(t),this.ownedVideoEl=t,this.attachVideoListeners(t),new Promise(i=>{let n=()=>{if(t.removeEventListener("loadedmetadata",n),t.removeEventListener("error",o),!this.mounted||this.props.src!==e){i(null);return}i(t)},o=()=>{t.removeEventListener("loadedmetadata",n),t.removeEventListener("error",o),i(null)};t.addEventListener("loadedmetadata",n),t.addEventListener("error",o),t.src=e,t.load()})}async setupVideo(e){let{src:t}=this.props;if(!t)return;if(null!=e&&t===e.src&&this.fabricGroup){this.setRect(e);return}this.setState({isLoading:!0});let i=await this.ensureOwnedVideo(t);if(!i||!this.mounted||this.props.src!==t){this.mounted&&this.setState({isLoading:!1});return}this.mountFabricFromVideo(i)}setRect(e){this.fabricGroup&&((0,M.v)({fields:e6,object:this.fabricGroup,props:this.props,prevProps:e||{},canvas:this.context.canvas,scaleToSize:!1}),this.context.canvas.requestRenderAll())}componentDidMount(){this.mounted=!0,this.context.onRegistered(this.name),eu.EM.addComponent(this.animatedComponent),this.bindTransport(this.props.syncPlaybackElement),this.setupVideo()}componentDidUpdate(e){e.syncPlaybackElement!==this.props.syncPlaybackElement&&this.bindTransport(this.props.syncPlaybackElement),e.src!==this.props.src?this.setupVideo(e):this.setRect(e),this.fabricGroup&&this.props.zIndex!==e.zIndex&&"number"==typeof this.props.zIndex&&this.context.updateObjectZIndex(this.name,this.props.zIndex),e.playbackTime!==this.props.playbackTime&&void 0!==this.props.playbackTime&&this.seekOwnedVideoToTargetTime(this.props.playbackTime)}componentWillUnmount(){this.mounted=!1,eu.EM.removeComponent(this.animatedComponent),this.unbindTransport(),this.disposeOwnedVideo(),this.cleanup()}cleanupFabricOnly(){this.fabricGroup&&(this.context.unmountObject(this.fabricGroup),this.fabricGroup=void 0)}cleanup(){this.cleanupFabricOnly()}render(){let{top:e=0,left:t=0,width:i=0,height:o=0,originX:s="center",originY:r="center"}=this.props;return(0,n.jsx)(n.Fragment,{children:this.state.isLoading&&(0,n.jsx)(U,{name:"".concat(this.name,"-skeleton"),zIndex:this.props.zIndex,top:e,left:t,width:Math.max(i,40),height:Math.max(o,40),originX:s,originY:r,angle:this.props.angle,scaleX:this.props.scaleX,scaleY:this.props.scaleY,skewX:this.props.skewX,skewY:this.props.skewY})})}constructor(e){super(e),this.mounted=!1,this.transportBound=null,this.playGeneration=0,this.playInFlight=!1,this.onAnimate=()=>{let e=this.getOwnedVideoElement();if(!e||!this.fabricGroup)return;let{syncPlaybackElement:t}=this.props;t&&!t.paused&&e.paused&&this.syncDecoderPlayback();let i=this.getSyncTargetTime();void 0!==i&&this.seekOwnedVideoToTargetTime(i),this.paintFrame()},this.onVideoSeeked=()=>{this.paintFrame()},this.onVideoLoadedData=()=>{this.paintFrame()},this.onTransportPlay=()=>{this.syncDecoderPlayback()},this.onTransportPause=()=>{this.syncDecoderPlayback()},this.onTransportSeeked=()=>{let e=this.props.syncPlaybackElement;e&&e.paused&&this.seekOwnedVideoToTargetTime(e.currentTime)},this.name=e.name||(0,L.l)(),this.state={isLoading:!1},this.animatedComponent={start:0,end:Number.POSITIVE_INFINITY,animate:this.onAnimate}}}e4.contextType=E.FX;var e7=i(26493),te=i(91883),tt=i(8667);class ti extends o.PureComponent{lockSelection(){var e,t;let{canvas:i}=this.context;i instanceof a.fabric.Canvas&&(this.previousSkipTargetFind=null!==(e=i.skipTargetFind)&&void 0!==e&&e,this.previousSelection=null===(t=i.selection)||void 0===t||t,i.discardActiveObject(),i.skipTargetFind=!0,i.selection=!1,i.requestRenderAll())}unlockSelection(){let{canvas:e}=this.context;e instanceof a.fabric.Canvas&&(e.skipTargetFind=this.previousSkipTargetFind,e.selection=this.previousSelection)}componentDidMount(){let{canvas:e}=this.context;
1e instanceof a.fabric.Canvas&&(0,tt.applyCssArtboardClip)(e,this.props.frameBounds),this.lockSelection(),eu.EM.addComponent(this)}componentWillUnmount(){eu.EM.removeComponent(this);let{canvas:e}=this.context;e&&((0,e7.Hp)(e),e instanceof a.fabric.Canvas&&(0,tt.clearCssArtboardClip)(e),this.unlockSelection(),e.requestRenderAll())}render(){return null}constructor(...e){super(...e),this.lastAnimatedFrame=-1,this.shakeSpectrumState=new ef.SpectrumState,this.previousSkipTargetFind=!1,this.previousSelection=!0,this.start=0,this.end=1/0,this.animate=(e,t)=>{let i;let{canvas:n}=this.context;if(!n)return;let{cameraShake:o}=this.props;if(!(0,te.shouldApplyCameraShake)(o)){(0,e7.Hp)(n);return}if(e!==this.lastAnimatedFrame){if(this.lastAnimatedFrame=e,o.audioReactive&&t.audioData){let n=(0,ef.getFrequencyDataFromAudio)({audioData:t.audioData,currentFrame:e,fps:t.fps,numBars:64,optimizeFor:"speed"});i=(0,ef.processSpectrumData)({frequencyData:n,numBars:64,state:this.shakeSpectrumState,disableSmoothing:!0})}(0,e7.CH)(n,e,o,void 0,i,this.props.frameBounds),n.requestRenderAll()}}}}ti.contextType=E.FX;var tn=i(36427),to=i(82497);class ts extends o.PureComponent{componentDidMount(){eu.EM.addComponent(this)}componentWillUnmount(){eu.EM.removeComponent(this);let{canvas:e}=this.context;e&&((0,tn.aQ)(e),e.requestRenderAll())}render(){return null}constructor(...e){super(...e),this.lastAnimatedFrame=-1,this.pulseSpectrumState=new ef.SpectrumState,this.start=0,this.end=1/0,this.animate=(e,t)=>
1{let i;let{canvas:n}=this.context;if(!n)return;let{backgroundPulse:o}=this.props;if(!(0,to.shouldApplyBackgroundPulse)(o)){(0,tn.aQ)(n);return}if(e!==this.lastAnimatedFrame){if(this.lastAnimatedFrame=e,o.audioReactive&&t.audioData){let n=(0,ef.getFrequencyDataFromAudio)({audioData:t.audioData,currentFrame:e,fps:t.fps,numBars:64,optimizeFor:"speed"});i=(0,ef.processSpectrumData)({frequencyData:n,numBars:64,state:this.pulseSpectrumState,disableSmoothing:!0})}(0,tn.qw)(n,e,o,void 0,i),n.requestRenderAll()}}}}ts.contextType=E.FX;var tr=i(28179),ta=i(74932),tl=i(96014),th=i(80920),tu=i(16867),tc=i(17088),td=i(96205),tp=i(40568),tm=i(96434);let tf=e=>{var t,i,s;let{editorContext:r,static:a}=e,l=(0,tu.RN)(),h=(0,tu.Sq)(),u=I.featureFlags.canvasVideoLayers||!!h,c=(0,th.kH)(),{updateTextNode:d,canvasAspectRatio:m,editorSize:f,frameConfig:g,captions:y}=r,b=(0,tm.z)(e=>e.previewTimeMs),C=(0,tm.z)(e=>e.focusedCueIndex),x=null!==(i=null==h?void 0:h.updateTextLayer)&&void 0!==i?i:(e,t)=>d(e,t),{textNodes:w,waveformConfig:S,qr:E,images:A,cameraShake:R,backgroundPulse:O,waveforms:G,background:W,soundwaveRect:_}=h?l:{textNodes:r.textNodes,waveformConfig:r.waveformConfig,qr:r.qr,images:r.images,cameraShake:r.cameraShake,backgroundPulse:r.backgroundPulse,waveforms:c,background:r.background,soundwaveRect:r.soundwaveRect},{audioElement:F}=(0,K.FI)(),{resources:k}=(0,j.o0)(),M=(0,ta.Y)(e=>e.placeholders),{playbackElement:L,playbackTime:N,effectivePlayerStatus:B}=function(){let{audioElement:e,playerStatus:t}=(0,K.FI)(),{videoElement:i,mediaType:n,currentTime:s,isPlaying:r}=(0,tl.r)();return{playbackElement:(0,o.useMemo)(()=>"video"===n&&i?i:null!=e?e:null,[n,i,e]),playbackTime:"video"===n&&!r&&Number.isFinite(s)?s:void 0,effectivePlayerStatus:function(e){let{mediaType:t,isPlaying:i,playerStatus:n}=e;return null==t?n:i?P.c.playing:n===P.c.loading||n===P.c.error?n:P.c.paused}({mediaType:n,isPlaying:r,playerStatus:t})}}(),z=(0,tc.G)(e=>e.document),U=(0,td.S)(e=>e.currentTime),X=z?(0,v.cameraShakeConfigAtTime)(z,1e3*U):void 0,Y=z?X:R,{waveformRects:J,textNodeRects:$,qrRect:Q,imageLayerRects:Z}=(0,o.useMemo)(()=>(function(e,t){let{soundwaveRect:i,frameConfig:n,qr:o,background:s,textNodes:r,waveforms:a,images:l}=e,h=a&&a.length>0?a.map(e=>(0,V.convertReferenceObjectToActual)(e.rect,t,n)):[(0,V.convertReferenceObjectToActual)(i,t,n)],u=o?(0,V.convertReferenceObjectToActual)(o,t,n):{};return{waveformRects:h,imageRect:(null==s?void 0:s.imageRect)?(0,V.convertReferenceObjectToActual)(s.imageRect,t,n):{},textNodeRects:r.map(e=>(0,V.convertReferenceObjectToActual)((0,T.Gc)(e),t,n)),qrRect:u,imageLayerRects:(l||[]).filter(e=>"asset"===e.kind).map(e=>e.rect?(0,V.convertReferenceObjectToActual)(e.rect,t,n):{}),swRect:h[0]}})({soundwaveRect:_,frameConfig:g,qr:E,background:W,textNodes:w,images:A,waveforms:G},f.ratioToReference),[_,E,g,w,A,W,G,f.ratioToReference]),ee=(A||[]).filter(e=>"asset"===e.kind),et=e=>{var t,i,n;return null!==(n=null!==(i=e.url)&&void 0!==i?i:e.resourceId&&(null===(t=k[e.resourceId])||void 0===t?void 0:t.publicURL))&&void 0!==n?n:null},{offsetLeft:ei,offsetTop:en,wrapperWidth:eo,wrapperHeight:es}=g,er=Math.max(0,es-en-f.height),ea=(0,o.useMemo)(()=>{if(!I.featureFlags.editorCaptions)return;let e=(0,tp.resolveCaptionKaraokePreviewCue)(y,b,C);return{timeMs:b,cue:null!=e?e:null,enabled:(0,tp.isCaptionsKaraokeModeEnabled)(y)}},[y,C,b]),el=(0,o.useMemo)(()=>a?"#D1D5DB":B===P.c.playing?"#E2E8F0":"#E2E8F099",[B,a]);if(!F&&!L)return null;let eh=.07*f.width/tr.N.width,eu=I.featureFlags.cameraShake&&(null==Y?void 0:Y.enabled)===!0&&B===P.c.playing,ec=I.featureFlags.backgroundPulse&&!z&&(null==O?void 0:O.enabled)===!0&&B===P.c.playing;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(q,{}),ec&&O?(0,n.jsx)(ts,{backgroundPulse:O}):null,eu&&Y?(0,n.jsx)(ti,{cameraShake:Y,frameBounds:{left:ei,top:en,width:f.width,height:f.height}}):null,ee.map((e,t)=>{var i,o,s,r;let l=(0,e5.PM)(e),h=et(e),c=null!==(o=Z[t])&&void 0!==o?o:{};if(!h||!1===e.visible)return null;let d=M[e.id],p=null!==(r=null!==(s=null===(i=e.rect)||void 0===i?void 0:i.zIndex)&&void 0!==s?s:e.zIndex)&&void 0!==r?r:ez.LAYER_ZINDEX.full.assetImage;return l&&!u?null:l?(0,n.jsx)(e4,{name:e.id,src:h,syncPlaybackElement:L,playbackTime:N,zIndex:p,selectable:!a,lockRotation:!1,...c},e.id):(0,n.jsx)(H,{name:e.id,src:h,zIndex:p,selectable:!a,lockRotation:!1,uploadProgress:null==d?void 0:d.progress,...c},e.id)}),(0,n.jsx)(eK,{waveforms:G,waveformConfig:S,waveformRects:J,canvasAspectRatio:m,audioElement:null!=F?F:void 0,playerStatus:B,isStatic:a,animationStyle:null===(t=l.animation)||void 0===t?void 0:t.style}),w.map((e,t)=>{var i;let o={zIndex:null!==(i=e.zIndex)&&void 0!==i?i:ez.LAYER_ZINDEX.full.textNodes,updateText:t=>x(e.name,{text:t}),...e,...null==$?void 0:$[t]};return e.name===v.CAPTION_TEXT_NODE_NAME?(0,n.jsx)(e$,{...o,karaokePreview:ea,selectable:!a,evented:!a},e.name):(0,n.jsx)(e0,{...o},e.name)}),(null==E?void 0:E.imported)&&E.svg&&(0,n.jsx)(e8,{zIndex:null!==(s=E.zIndex)&&void 0!==s?s:ez.LAYER_ZINDEX.full.qr,selectable:!0,lockUniScaling:!0,lockRotation:!0,name:p.QRCODE_OBJECT_NAME,svg:E.svg,fillColor:E.fillColor||tr.N.fillColor,...E,...Q,minScaleLimit:eh}),!eu&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(D,{fill:el,width:ei,height:f.height,top:en,left
1:0,zIndex:4,name:p.LEFT_RECT_OBJECT_NAME,selectable:!1,evented:!1}),(0,n.jsx)(D,{fill:el,width:eo,height:en,top:0,left:0,zIndex:4,name:p.TOP_RECT_OBJECT_NAME,selectable:!1,evented:!1}),(0,n.jsx)(D,{fill:el,width:ei,height:f.height,top:en,left:ei+f.width,zIndex:4,name:p.RIGHT_RECT_OBJECT_NAME,selectable:!1,evented:!1}),(0,n.jsx)(D,{fill:el,width:eo,height:er,top:en+f.height,left:0,zIndex:4,name:p.BOTTOM_RECT_OBJECT_NAME,selectable:!1,evented:!1})]})]})};var tv=i(2803);let tg=h().bind(w()),ty=r()(()=>i.e(3790).then(i.bind(i,23790)).then(e=>e.PrintPreview),{loadableGenerated:{webpack:()=>[23790]},ssr:!1});function tb(){return(0,G.g)().printPreview?(0,n.jsx)(ty,{}):null}a.fabric.Object.prototype.set({borderColor:"#9663f5",cornerColor:"#ffffff",cornerSize:12,transparentCorners:!1,borderScaleFactor:2,cornerStrokeColor:"#9663f5"});class tC extends o.Component{componentDidUpdate(){let e=this.context.pendingSelectionObjectName;if(!e){this.lastRequestedSelectionName=void 0,this.clearPendingSelectionTimers();return}e!==this.lastRequestedSelectionName&&(this.lastRequestedSelectionName=e,this.startPendingSelection(e))}componentWillUnmount(){this.clearPendingSelectionTimers()}render(){let{status:e,editorSize:t,frameConfig:i}=this.context;return(0,n.jsx)(y.q5.Consumer,{children:o=>(this.tabContext=o,(0,n.jsx)(tv.mD.Consumer,{children:o=>(this.canvasDocumentApi=o,(0,n.jsx)(O.a.Consumer,{children:o=>(this.qrContext=o,(0,n.jsxs)("div",{className:tg(this.props.transparent?"bg-transparent":"editorCanvas","w-full z-0 relative m-0",{"h-screen":this.props.stretchHeight,"h-full":!this.props.stretchHeight}),"data-testid":"editor-canvas","data-ph-no-autocapture":!0,children:[(e===d.EditorStatus.LOADING||e===d.EditorStatus.INITIAL)&&(0,n.jsx)("div",{className:"absolute top-0 left-0 z-10 flex items-center justify-center w-full h-full bg-white/60","data-testid":"editor-canvas-loading",children:(0,n.jsx)(g.p,{fontSize:72})}),(0,n.jsx)(tb,{}),!this.props.transparent&&(0,n.jsx)("div",{className:tg("frameCheckerBackground"),style:{left:i.offsetLeft,top:i.offsetTop,width:t.width,height:t.height},"aria-hidden":!0}),(0,n.jsxs)(E.Xz,{id:"waveform-canvas",onObjectChanged:this.handleObjectChanged,onReady:this.handleCanvasReady,static:this.props.static,onObjectSelected:this.onObjectSelected,onSelectionCleared:this.handleSelectionCleared,objectAlignPadding:.05*t.width,frameWidth:t.width,frameHeight:t.height,...this.context.frameConfig,children:[(0,n.jsx)(tf,{static:this.props.static,editorContext:this.context}),this.props.static&&(0,n.jsx)("div",{id:"canvas-overlay",className:"absolute top-0 w-full h-full bg-transparent"})]}),!this.props.transparent&&t.width>0&&t.height>0&&(0,n.jsx)("div",{className:tg("artboardEdgeShadow"),style:{left:i.offsetLeft,top:i.offsetTop,width:t.width,height:t.height},"aria-hidden":!0})]}))}))}))})}constructor(e){super(e),this.tabContext=null,this.canvasDocumentApi=null,this.qrContext=null,this.canvasInstance=null,this.clearPendingSelectionTimers=()=>{this.pendingSelectionInterval&&(clearInterval(this.pendingSelectionInterval),this.pendingSelectionInterval=void 0),this.pendingSelectionTimeout&&(clearTimeout(this.pendingSelectionTimeout),this.pendingSelectionTimeout=void 0)},this.trySelectObjectByName=e=>{if(!this.canvasInstance||!("setActiveObject"in this.canvasInstance)||"function"!=typeof this.canvasInstance.setActiveObject)return!1;let t=this.canvasInstance,i=A.P.findObjectByName(t,e);return!!i&&(t.setActiveObject(i),t.requestRenderAll(),this.context.clearPendingObjectSelection(),this.clearPendingSelectionTimers(),!0)},this.startPendingSelection=e=>{this.clearPendingSelectionTimers(),this.trySelectObjectByName(e)||(this.pendingSelectionInterval=setInterval(()=>{this.trySelectObjectByName(e)},100),this.pendingSelectionTimeout=setTimeout(()=>{this.clearPendingSelectionTimers(),this.context.clearPendingObjectSelection()},5e3))},this.handleCanvasReady=e=>{var t,i;this.canvasInstance=e,null===(t=(i=this.props).setCanvas)||void 0===t||t.call(i,e),this.context.pendingSelectionObjectName&&this.startPendingSelection(this.context.pendingSelectionObjectName)},this.syncSoundWaveRect=e=>{var t,i,n;let o=null!==(n=this.context.selectedWaveformId)&&void 0!==n?n:null===(i=this.context.waveforms)||void 0===i?void 0:null===(t=i[0])||void 0===t?void 0:t.id;if(!o||this.context.editorSize.ratioToReference<=0)return;let{reference:s}=this.context.waveformConfig,r={...(0,m.convertActualToReferenceObject)(e,this.context.editorSize.ratioToReference,this.context.frameConfig),width:s.width,height:s.height};this.canvasDocumentApi?this.canvasDocumentApi.updateWaveformLayer(o,{rect:r}):this.context.updateWaveform(o,{rect:r})},this.syncTextNodeRect=(e,t)=>
1{if(this.context.editorSize.ratioToReference>0){let i=(0,m.convertActualToReferenceObject)(t,this.context.editorSize.ratioToReference,this.context.frameConfig);this.canvasDocumentApi?this.canvasDocumentApi.updateTextLayer(e,i):this.context.updateTextNode(e,i)}},this.syncQRCodeRect=e=>{e&&this.context.editorSize.ratioToReference>0&&this.qrContext&&this.qrContext.updateQRCode((0,m.convertActualToReferenceObject)({...e,name:p.QRCODE_OBJECT_NAME},this.context.editorSize.ratioToReference,this.context.frameConfig))},this.syncBgImageRect=e=>{if(e&&this.context.editorSize.ratioToReference>0){let t={imageRect:(0,m.convertActualToReferenceObject)(e,this.context.editorSize.ratioToReference,this.context.frameConfig)};this.canvasDocumentApi?this.canvasDocumentApi.updateBackground(t):this.context.updateBackground(t)}},this.syncGivenObjectWithState=e=>{var t,i,n;if(null===(t=e.name)||void 0===t?void 0:t.startsWith(p.WAVEFORM_NODE_PREFIX)){let t=e.name,i=(0,m.convertActualToReferenceObject)((0,T.y$)(e),this.context.editorSize.ratioToReference,this.context.frameConfig),{reference:n}=this.context.waveformConfig,o={...i,width:n.width,height:n.height};return this.canvasDocumentApi?this.canvasDocumentApi.updateWaveformLayer(t,{rect:o}):this.context.updateWaveform(t,{rect:o}),!0}if(e.name===p.SOUNDWAVE_OBJECT_NAME)return this.syncSoundWaveRect((0,T.y$)(e)),!0;if((null===(i=e.name)||void 0===i?void 0:i.startsWith(p.TEXT_NODE_OBJECT_NAME_PREFIX))||e.name===v.CAPTION_TEXT_NODE_NAME)return this.syncTextNodeRect(e.name,(0,T.y$)(e)),!0;if(e.name===p.QRCODE_OBJECT_NAME)return this.syncQRCodeRect((0,T.y$)(e)),!0;if(e.name===p.BG_IMAGE_OBJECT_NAME)return this.syncBgImageRect((0,T.y$)(e)),!0;if(null===(n=e.name)||void 0===n?void 0:n.startsWith(p.IMAGE_LAYER_OBJECT_NAME_PREFIX)){let t=(0,m.convertActualToReferenceObject)((0,T.y$)(e),this.context.editorSize.ratioToReference,this.context.frameConfig);return this.canvasDocumentApi?this.canvasDocumentApi.updateImageLayer(e.name,{rect:t}):this.context.updateImageLayer(e.name,{rect:t}),!0}},this.debouncedSyncObjectsWithState=c()(e=>{if(e){if(this.syncGivenObjectWithState(e)){this.props.static||b.r.getState().setNotSaved();return}if(e instanceof a.fabric.Group){let t=!1;e.forEachObject(e=>{this.syncGivenObjectWithState(e)&&(t=!0)}),t&&!this.props.static&&b.r.getState().setNotSaved()}}},100),this.handleObjectChanged=e=>{if(this.props.static||b.r.getState().setNotSaved(),"activeSelection"===e.type||void 0!==a.fabric.ActiveSelection&&e instanceof a.fabric.ActiveSelection){let i=this.collectActiveSelectionNames();if(0===i.length&&e instanceof a.fabric.ActiveSelection&&(i=e.getObjects().map(e=>e.name).filter(e=>"string"==typeof e&&e.length>0)),i.length>0){var t;let e=null!==(t=this.pendingMultiSelectSyncNames)&&void 0!==t?t:[];this.pendingMultiSelectSyncNames=[...new Set([...e,...i])]}return}this.debouncedSyncObjectsWithState(e)},this.flushPendingMultiSelectSyncToState=()=>{let e=this.canvasInstance,t=this.pendingMultiSelectSyncNames;if(this.pendingMultiSelectSyncNames=void 0,!e||this.props.static||!(null==t?void 0:t.length))return;let i=!1;t.forEach(t=>{let n=A.P.findObjectByName(e,t);n&&this.syncGivenObjectWithState(n)&&(i=!0)}),i&&!this.props.static&&b.r.getState().setNotSaved()},this.handleSelectionCleared=e=>{this.flushPendingMultiSelectSyncToState();let t=null==e?void 0:e.deselected,i=null==e?void 0:e.target,n=!!(null==i?void 0:i.name)&&void 0===t,o=n&&"string"==typeof(null==i?void 0:i.name)?i.name:void 0;if(n&&I.featureFlags.mobileEditorChrome&&this.props.isMobile&&"string"==typeof o&&o.startsWith(p.WAVEFORM_NODE_PREFIX)&&!this.props.static){let e=0,t=()=>{this.trySelectObjectByName(o)||((e+=1)<8?requestAnimationFrame(t):C.l.getState().setSelectedElement(void 0))};requestAnimationFrame(t);return}C.l.getState().setSelectedElement(void 0)},this.collectActiveSelectionNames=()=>{let e=this.canvasInstance;return e&&"getActiveObjects"in e&&"function"==typeof e.getActiveObjects?e.getActiveObjects().map(e=>e.name).filter(e=>"string"==typeof e&&e.length>0):[]},this.onObjectSelected=(e,t)=>{var i,n,o,s,r,a;if(!t||this.props.static){C.l.getState().setSelectedElement(void 0,[]);return}let l=this.collectActiveSelectionNames(),h=t.type;if(l.length>1||"activeSelection"===h){C.l.getState().setSelectedElement(t,l);return}let{name:u}=t;if(null==u?void 0:u.startsWith(p.WAVEFORM_NODE_PREFIX)){this.context.updateEditorState({selectedWaveformId:u},!1),null===(i=this.tabContext)||void 0===i||i.setShownTab(R.e.soundwave),C.l.getState().setSelectedElement(t,l);return}if(u===p.SOUNDWAVE_OBJECT_NAME){null===(n=this.tabContext)||void 0===n||n.setShownTab(R.e.soundwave),C.l.getState().setSelectedElement(void 0,[]);return}if((0,f.isEditorTextSelection)(t)||(null==u?void 0:u.startsWith(p.TEXT_NODE_OBJECT_NAME_PREFIX))){(null==u?void 0:u.startsWith(p.TEXT_NODE_OBJECT_NAME_PREFIX))&&(null===(o=this.tabContext)||void 0===o||o.setShownTab(R.e.text)),C.l.getState().setSelectedElement(t,l);return}if(u===p.BG_IMAGE_OBJECT_NAME){null===(s=this.tabContext)||void 0===s||s.setShownTab(R.e.background),C.l.getState().setSelectedElement(t,l);return}if(null==u?void 0:u.startsWith(p.IMAGE_LAYER_OBJECT_NAME_PREFIX)){null===(r=this.tabContext)||void 0===r||r.setShownTab(R.e.layers),C.l.getState().setSelectedElement(t,l);return}if(u===p.QRCODE_OBJECT_NAME){null===(a=this.tabContext)||void 0===a||a.setShownTab(R.e.qr),C.l.getState().setSelectedElement(t,l);return}C.l.getState().setSelectedElement(void 0,[])},this.state={}}}tC.contextType=S.rU},43372:function(e,t,i){"use strict";t.K=void 0;let n=i(21749);t.K=e=>
1new Promise(t=>{n.fabric.loadSVGFromString(e,t)})},63359:function(e,t,i){"use strict";t.qC=function(e,t){t.width=t.videoWidth,t.height=t.videoHeight;let i=new n.fabric.Image(t,{objectCaching:!1}),s=(0,o.createImageObject)(e,i);return s.set("objectCaching",!1),i.set("objectCaching",!1),s},t.Kt=function(e){e.set("dirty",!0);let t=e.getObjects()[0];t&&t.set("dirty",!0)};let n=i(21749),o=i(78938)},36427:function(e,t,i){"use strict";t.aQ=m,t.qw=function(e,t,i,n,o){if(!(0,r.shouldApplyBackgroundPulse)(i)||!i){f(e)&&m(e);return}let s=null!=o?o:(0,a.getPrecomputedSpectrumBars)(n,t),l=(0,r.backgroundPulsePoseFromBins)(i,s);if(0===l.extraScale&&0===l.brightness){f(e)&&m(e);return}e.__wavevisualBackgroundPulseUsed=!0;let h=(0,r.circleCenterImagePulsePose)(l);u(e).forEach(e=>v(e,l)),c(e).forEach(e=>v(e,h))};let n=i(21749),o=i(38986),s=i(28687),r=i(82497),a=i(95727);function l(e){return"function"==typeof e.applyFilters}function h(e,t){e&&(t(e),(0,s.fabricGroupChildren)(e).forEach(e=>h(e,t)))}function u(e){let t=[];return e.getObjects().forEach(e=>{h(e,e=>{(e.name===o.BG_COLOR_OBJECT_NAME||e.name===o.BG_IMAGE_OBJECT_NAME)&&t.push(e)})}),t}function c(e){let t=[];return e.getObjects().forEach(e=>{h(e,e=>{e.name===o.CIRCLE_CENTER_IMAGE_CLIP_GROUP_NAME&&(0,s.fabricGroupChildren)(e).forEach(e=>{"image"===e.type&&t.push(e)})})}),t}function d(e){return[...u(e),...c(e)]}function p(e){var t;e.__backgroundPulseCaptured&&(e.set({left:e.__backgroundPulseRestLeft,top:e.__backgroundPulseRestTop,scaleX:e.__backgroundPulseRestScaleX,scaleY:e.__backgroundPulseRestScaleY,fill:e.__backgroundPulseRestFill}),h(e,e=>{var t;l(e)&&(e.filters=e.__backgroundPulseRestFilters?[...e.__backgroundPulseRestFilters]:[],null===(t=e.applyFilters)||void 0===t||t.call(e))}),null===(t=e.setCoords)||void 0===t||t.call(e))}function m(e){d(e).forEach(p),f(e)||(e.__wavevisualBackgroundPulseUsed=!1)}function f(e){return d(e).some(e=>e.__backgroundPulseCaptured)}function v(e,t){var i,o,s,a,u,c,d,p,m,f,v,g,y,b,C;e.__backgroundPulseCaptured||(e.__backgroundPulseRestLeft=null!==(g=e.left)&&void 0!==g?g:0,e.__backgroundPulseRestTop=null!==(y=e.top)&&void 0!==y?y:0,e.__backgroundPulseRestScaleX=null!==(b=e.scaleX)&&void 0!==b?b:1,e.__backgroundPulseRestScaleY=null!==(C=e.scaleY)&&void 0!==C?C:1,e.__backgroundPulseRestFill=e.fill,e.__backgroundPulseCaptured=!0,h(e,e=>{l(e)&&void 0===e.__backgroundPulseRestFilters&&(e.__backgroundPulseRestFilters=e.filters?[...e.filters]:[])}));let x=null!==(a=e.__backgroundPulseRestScaleX)&&void 0!==a?a:1,w=null!==(u=e.__backgroundPulseRestScaleY)&&void 0!==u?u:1,S=null!==(c=e.__backgroundPulseRestLeft)&&void 0!==c?c:0,E=null!==(d=e.__backgroundPulseRestTop)&&void 0!==d?d:0,A=1+t.extraScale,R=null!==(p=e.originX)&&void 0!==p?p:"left",O=null!==(m=e.originY)&&void 0!==m?m:"top",T={scaleX:x*A,scaleY:w*A};if("left"===R||"right"===R){let i=(null!==(f=e.width)&&void 0!==f?f:0)*x*t.extraScale/2;T.left="left"===R?S-i:S+i}else T.left=S;if("top"===O||"bottom"===O){let i=(null!==(v=e.height)&&void 0!==v?v:0)*w*t.extraScale/2;T.top="top"===O?E-i:E+i}else T.top=E;e.set(T);let I=e.__backgroundPulseRestFill;"string"==typeof I&&e.set({fill:(0,r.lightenCssColor)(I,t.brightness)});let G=null===(o=n.fabric.Image)||void 0===o?void 0:null===(i=o.filters)||void 0===i?void 0:i.Brightness;h(e,e=>{var i,n;if(!l(e)||!G)return;let o=null!==(n=e.__backgroundPulseRestFilters)&&void 0!==n?n:[];e.filters=t.brightness>0?[...o,new G({brightness:t.brightness})]:[...o],null===(i=e.applyFilters)||void 0===i||i.call(e)}),null===(s=e.setCoords)||void 0===s||s.call(e)}i(82497)},26493:function(e,t,i){"use strict";t.CH=function(e,t,i,r,d,p){if(!(0,o.shouldApplyCameraShake)(i)){c(e);return}let m=l(e);if(m){u(e),(0,s.resetEditorRigidShake)(e),function(e,t,i,s,r,l,u){var c,d,p,m,f,v,g,y,b,C,x;let{width:w,height:S}=a(e),E=function(e){let t=e.getObjects().find(e=>e.name===n.WRAPPER_GROUP_NAME);return null!=t?t:null}(e),A=u&&!E?u.width:w,R=u&&!E?u.height:S,O=(0,o.computeOverscanScale)(A,R,s.intensity),T=null!==(c=s.seed)&&void 0!==c?c:42,I=h(s,i,r,l),{x:G,y:P}=(0,o.computeShakeOffset)(i,I,s.frequency,T),W=null!==(d=null==E?void 0:E.scaleX)&&void 0!==d?d:1;
1void 0===(g=t).__cameraShakeRestLeft&&(g.__cameraShakeRestLeft=null!==(y=g.left)&&void 0!==y?y:0,g.__cameraShakeRestTop=null!==(b=g.top)&&void 0!==b?b:0,g.__cameraShakeRestScaleX=null!==(C=g.scaleX)&&void 0!==C?C:1,g.__cameraShakeRestScaleY=null!==(x=g.scaleY)&&void 0!==x?x:1),t.set({scaleX:(null!==(p=t.__cameraShakeRestScaleX)&&void 0!==p?p:1)*O,scaleY:(null!==(m=t.__cameraShakeRestScaleY)&&void 0!==m?m:1)*O,left:(null!==(f=t.__cameraShakeRestLeft)&&void 0!==f?f:0)+(W>0?G/W:G),top:(null!==(v=t.__cameraShakeRestTop)&&void 0!==v?v:0)+(W>0?P/W:P)}),t.setCoords()}(e,m,t,i,r,d,p);return}if(u(e),p){(0,s.applyEditorRigidShake)(e,p,t,i,r,d);return}let f=function(e,t){if(t&&t.width>0&&t.height>0)return t;let{width:i,height:n}=a(e);return{left:0,top:0,width:i,height:n}}(e,p);!function(e,t,i,n,s,r){var a;let{left:l,top:u,width:c,height:d}=t,p=(0,o.computeOverscanScale)(c,d,n.intensity),m=null!==(a=n.seed)&&void 0!==a?a:42,f=h(n,i,s,r),{x:v,y:g}=(0,o.computeShakeOffset)(i,f,n.frequency,m),y=(l+c/2)*(1-p)+v,b=(u+d/2)*(1-p)+g;e.setViewportTransform([p,0,0,p,y,b])}(e,f,t,i,r,d)},t.Hp=c;let n=i(38986),o=i(91883),s=i(8667),r=[1,0,0,1,0,0];function a(e){return{width:e.getWidth()||0,height:e.getHeight()||0}}function l(e){let t=e.getObjects().find(e=>e.name===n.CAMERA_SHAKE_GROUP_NAME);if(t)return t;let i=e.getObjects().find(e=>e.name===n.WRAPPER_GROUP_NAME);if(!i)return null;let o=i.getObjects().find(e=>e.name===n.CONTENT_GROUP_NAME),s=(o?o.getObjects():i.getObjects()).find(e=>e.name===n.CAMERA_SHAKE_GROUP_NAME);return null!=s?s:null}function h(e,t,i,n){return null!=n?(0,o.effectiveCameraShakeIntensityFromBins)(e,n):(0,o.effectiveCameraShakeIntensity)(e,i,t)}function u(e){var t;let i=null!==(t=e.viewportTransform)&&void 0!==t?t:r;(1!==i[0]||0!==i[1]||0!==i[2]||1!==i[3]||0!==i[4]||0!==i[5])&&e.setViewportTransform([...r])}function c(e){var t,i,n;u(e),(0,s.resetEditorRigidShake)(e);let o=l(e);o&&void 0!==o.__cameraShakeRestLeft&&(o.set({left:o.__cameraShakeRestLeft,top:null!==(t=o.__cameraShakeRestTop)&&void 0!==t?t:0,scaleX:null!==(i=o.__cameraShakeRestScaleX)&&void 0!==i?i:1,scaleY:null!==(n=o.__cameraShakeRestScaleY)&&void 0!==n?n:1}),o.setCoords(),delete o.__cameraShakeRestLeft,delete o.__cameraShakeRestTop,delete o.__cameraShakeRestScaleX,delete o.__cameraShakeRestScaleY)}},60740:function(e,t,i){"use strict";t.qj=void 0,t.bi=function(e,i){var c;let d=(0,s.findRadialPolygon)(e);if(!(null==d?void 0:null===(c=d.points)||void 0===c?void 0:c.length))return!1;d.set({opacity:.5,objectCaching:!1});let p=function(e,t){let i=Math.min(1,Math.max(0,t));if(!e.length||i<=0)return[];if(i>=1)return e.map(u);let n=e.length/2;if(!Number.isInteger(n)||n<2)return[];let o=n>1&&l(e[0],e[n-1])&&l(e[n],e[e.length-1])?n-1:n;if(o<1)return[];let s=360*i,r=t=>e[t],c=t=>e[e.length-1-t],d=o-1,p=1;for(let e=0;e<o;e+=1){let t=0===e?0:a(r(e)),i=e+1<o?a(r(e+1)):360;if(s<=i||e===o-1){d=e;let n=i-t;p=n<=0?1:Math.min(1,Math.max(0,(s-t)/n));break}}let m=r(d+1<o?d+1:0),f=c(d+1<o?d+1:0),v=[],g=[];for(let e=0;e<=d;e+=1)v.push(u(r(e))),g.push(u(c(e)));return v.push(h(r(d),m,p)),g.push(h(c(d),f,p)),[...v,...g.slice().reverse()]}(d.points,i),m=e.getObjects().find(e=>e.name===t.qj&&"polygon"===e.type);if(!p.length)return m&&e.remove(m),e.dirty=!0,!0;let f=function(e){let t=e.getObjects().find(e=>e.name===o.CIRCLE_SOUNDWAVE_FRAME_RECT_NAME);return(null==t?void 0:t.width)&&(null==t?void 0:t.height)?{width:t.width,height:t.height}:{width:0,height:0}}(e),v=d.fill;return m?m.set({points:p,opacity:1,objectCaching:!1,shadow:d.shadow}):(m=new n.fabric.Polygon(p,{fill:v,name:t.qj,opacity:1,originX:"center",originY:"center",selectable:!1,evented:!1,excludeFromExport:!1,shadow:d.shadow,objectCaching:!1}),e.add(m),m.moveTo(10)),function(e,t,i){var n,o,s;e._setPositionDimensions({});let a=null!==(n=e.pathOffset)&&void 0!==n?n:{x:0,y:0};e.set({left:a.x,top:a.y}),i.width&&i.height&&e.set("fill",(0,r.alignCircleFillToPolarOrigin)(t,{frameDimensions:i,polygonWidth:null!==(o=e.width)&&void 0!==o?o:i.width,polygonHeight:null!==(s=e.height)&&void 0!==s?s:i.height,pathOffsetX:a.x,pathOffsetY:a.y}))}(m,v,f),m.dirty=!0,m.setCoords(),e.dirty=!0,!0};let n=i(21749),o=i(38986),s=i(50996),r=i(68889);function a(e){let t=180*Math.atan2(e.x,-e.y)/Math.PI;return t<0&&(t+=360),t}function l(e,t){return!!e&&!!t&&1e-4>Math.abs(e.x-t.x)&&1e-4>Math.abs(e.y-t.y)}function h(e,t,i){return{x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}}function u(e){return{x:e.x,y:e.y}}t.qj="polygon-sound-wave-progress"},26515:function(e,t,i){"use strict";t.Q=function(e,t){return e.map(e=>(e instanceof n.fabric.Path&&e.fill!==t&&e.set({fill:t}),e))};let n=i(21749)},8769:function(e,t,i){"use strict";t.D=void 0;
1let n=i(59311),o=i(54530);t.D=(e,t,i,s)=>{let r=(0,o.getDefaultImageRectParams)(t.width,t.height,i.offsetTop,i.offsetLeft);if("cover"===e){let e=t.width/t.height;return e>1?(r.width=t.width,r.height=t.width/e):(r.width=t.height*e,r.height=t.height),{...r,selectable:!1,clip:{width:t.width,height:t.height}}}let a=null!=s&&(null!=s.top||null!=s.left||null!=s.scaleX||null!=s.scaleY||null!=s.width||null!=s.height||null!=s.angle);return{...r,...a?(0,n.convertReferenceObjectToActual)(s,t.ratioToReference,i,!1):{}}}},59311:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertReferenceObjectToActual=function(e,t,i,n){var o,s;let r="number"!=typeof t||!Number.isFinite(t)||t<=0?1:t,a={...e};return(null==a?void 0:a.top)&&(a.top=a.top*r+((null==i?void 0:i.offsetTop)||0)),(null==a?void 0:a.left)&&(a.left=a.left*r+((null==i?void 0:i.offsetLeft)||0)),n||(a.scaleX=(null!==(o=a.scaleX)&&void 0!==o?o:1)*r,a.scaleY=(null!==(s=a.scaleY)&&void 0!==s?s:1)*r),a}},49527:function(e,t,i){"use strict";t.P=function(e,t){if(!t||(0,o.isRadialPolygonSoundWaveStyle)(e.style))return;let i=e.circleRadius||0;return new n.fabric.Circle({top:0,left:0,originX:"center",originY:"center",radius:i+2,inverted:!0})};let n=i(21749),o=i(44074)},78963:function(e,t,i){"use strict";t.O$=s,t.a7=function(e,t,i,r){s(e,i,r);let a=new n.fabric.Group([e],{left:0,top:0,originX:"center",originY:"center",clipPath:new n.fabric.Circle({radius:t,originX:"center",originY:"center",left:0,top:0}),name:o.CIRCLE_CENTER_IMAGE_CLIP_GROUP_NAME,selectable:!1,evented:!1});return s(e,i,r),e.setCoords(),a.setCoords(),a};let n=i(21749),o=i(38986);function s(e,t,i){e.set({left:i.left,top:i.top,originX:"center",originY:"center",scaleX:i.scaleX,scaleY:i.scaleY,width:i.width,height:i.height,angle:0,selectable:!1,evented:!1,name:t,clipPath:void 0})}},78938:function(e,t,i){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.createImageObject=function(e,t){let i=e.width||0,n=e.height||0;return((null==t?void 0:t.width)||0)/((null==t?void 0:t.height)||1)>i/n?t.scaleToHeight(n):t.scaleToWidth(i),e.clip&&(t.clipPath=new s.fabric.Rect({width:e.clip.width,height:e.clip.height,scaleX:1/(t.scaleX||1),scaleY:1/(t.scaleY||1),top:0,left:0,originX:"center",originY:"center"})),new s.fabric.Group([t],{fill:"transparent",snapAngle:90,snapThreshold:5,name:e.name,...(0,r.default)(e,...o.ImageRectAttributes)})};let o=i(17847),s=i(21749),r=(n=i(13888))&&n.__esModule?n:{default:n}},8667:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BG_IMAGE_OBJECT_NAME=t.BG_COLOR_OBJECT_NAME=void 0,t.isPinnedEditorShakeObject=l,t.collectEditorShakeTargets=h,t.applyEditorRigidShake=function(e,t,i,n,o,r){var l;let{left:c,top:d,width:p,height:m}=t,f=c+p/2,v=d+m/2,g=(0,s.computeOverscanScale)(p,m,n.intensity),y=null!==(l=n.seed)&&void 0!==l?l:42,b=null!=r?(0,s.effectiveCameraShakeIntensityFromBins)(n,r):(0,s.effectiveCameraShakeIntensity)(n,o,i),{x:C,y:x}=(0,s.computeShakeOffset)(i,b,n.frequency,y);h(e).forEach(e=>{let t=function(e){let t=a.get(e);if(!t){var i,n,o,s,r,l,h;t={left:null!==(i=e.left)&&void 0!==i?i:0,top:null!==(n=e.top)&&void 0!==n?n:0,scaleX:null!==(o=e.scaleX)&&void 0!==o?o:1,scaleY:null!==(s=e.scaleY)&&void 0!==s?s:1,angle:null!==(r=e.angle)&&void 0!==r?r:0,flipX:null!==(l=e.flipX)&&void 0!==l&&l,flipY:null!==(h=e.flipY)&&void 0!==h&&h},a.set(e,t)}return t}(e);!function(e,t,i,n,o,s,r){var a,l;e.set(t),e.setCoords();let h=u(e),c=i+(h.x-i)*o+s,d=n+(h.y-n)*o+r;e.set({scaleX:t.scaleX*o,scaleY:t.scaleY*o}),e.setCoords();let p=u(e);e.set({left:(null!==(a=e.left)&&void 0!==a?a:0)+(c-p.x),top:(null!==(l=e.top)&&void 0!==l?l:0)+(d-p.y)}),e.setCoords()}(e,t,f,v,g,C,x)})},t.resetEditorRigidShake=function(e){h(e).forEach(e=>{let t=a.get(e);t&&(e.set(t),e.setCoords(),a.delete(e))})},t.applyCssArtboardClip=function(e,t){let i=e.getWidth(),n=e.getHeight(),{left:o,top:s,width:r,height:a}=t,l="inset(".concat(s,"px ").concat(Math.max(0,i-o-r),"px ").concat(Math.max(0,n-s-a),"px ").concat(o,"px)");c(e).forEach(e=>{e.style.clipPath=l})}
1,t.clearCssArtboardClip=function(e){c(e).forEach(e=>{e.style.clipPath=""})};let n=i(21749),o=i(38986);Object.defineProperty(t,"BG_COLOR_OBJECT_NAME",{enumerable:!0,get:function(){return o.BG_COLOR_OBJECT_NAME}}),Object.defineProperty(t,"BG_IMAGE_OBJECT_NAME",{enumerable:!0,get:function(){return o.BG_IMAGE_OBJECT_NAME}});let s=i(91883),r=new Set([o.BG_COLOR_OBJECT_NAME,o.BG_IMAGE_OBJECT_NAME,o.LEFT_RECT_OBJECT_NAME,o.RIGHT_RECT_OBJECT_NAME,o.TOP_RECT_OBJECT_NAME,o.BOTTOM_RECT_OBJECT_NAME]),a=new WeakMap;function l(e){let{name:t}=e;return!!(t&&r.has(t))}function h(e){return e.getObjects().filter(e=>!l(e))}function u(e){return e.setCoords(),n.fabric.util.transformPoint(e.getCenterPoint(),e.calcTransformMatrix())}function c(e){let t=[];return e.lowerCanvasEl&&t.push(e.lowerCanvasEl),e.upperCanvasEl&&t.push(e.upperCanvasEl),t}},48799:function(e,t,i){"use strict";t.z=function(e){var t;let{waveformConfig:{space:i,thickness:h,reference:u,waveColors:c,...d},shownWaveformData:p}=e,m=(0,s.getEffectiveHeightMultiplier)(d),f=null!==(t=u.height)&&void 0!==t?t:o.SOUNDWAVE_REFERENCE_HEIGHT,v=f/2,g=c[1]||c[0]||"#22d3ee",y=c[0]||"#67e8f9",b=function(e){let{shownWaveformData:t,width:i,midY:o,refHeight:r,sampleDistance:l,effectiveMultiplier:h}=e,u=[],c=Math.max(i,1),d=.46*r;for(let e=0;e<=c;e+=l){let i=Math.floor(e/c*Math.max(t.length-1,0)),l=t[i]||0,p=t[Math.max(0,i-1)]||l,m=t[Math.min(t.length-1,i+1)]||l,f=(p+l+m)/3,{height:v}=(0,s.dataToBarGeometry)(f,r,h),g=o+Math.sin(e/c*Math.PI*11)*a(.05,1,v/r)*d;u.push(new n.fabric.Point(e,g))}return u.length<2&&u.push(new n.fabric.Point(c,o)),u}({shownWaveformData:p,width:u.width,midY:v,refHeight:f,sampleDistance:Math.max(4,Math.round(i+h)),effectiveMultiplier:m});if(!b.length)return[];let C=Math.max(14,Math.round(.16*f)),x=[];for(let e=-16;e<=16;e+=1){if(0===e)continue;let t=Math.abs(e)/16,i=a(.06,.42,.45*Math.exp(-(2.6*t))),n=e/16*C;x.push(r(b,{offsetY:n,stroke:g,strokeWidth:.8+(1-t)*.8,opacity:i,name:"neon-trail"}))}let w=new n.fabric.Path("M 0 ".concat(v," L ").concat(u.width," ").concat(v),{fill:"transparent",selectable:!1,evented:!1,stroke:g,opacity:.85,strokeWidth:1.5,name:"neon-horizon",objectCaching:!1});return[w,r(b,{offsetY:0,stroke:l(g,.35),strokeWidth:6,opacity:.26,name:"neon-glow"}),r(b,{offsetY:0,stroke:l(g,.5),strokeWidth:3.5,opacity:.3,name:"neon-glow"}),...x,r(b,{offsetY:0,stroke:y,strokeWidth:1.8,opacity:.95,name:"neon-core"})]};let n=i(21749),o=i(38986),s=i(65685);function r(e,t){let i=function(e){if(0===e.length)return"";if(1===e.length)return"M ".concat(e[0].x," ").concat(e[0].y);let t="M ".concat(e[0].x," ").concat(e[0].y," ");for(let i=1;i<e.length-2;i+=1){let n=(e[i].x+e[i+1].x)/2,o=(e[i].y+e[i+1].y)/2;t+="Q ".concat(e[i].x," ").concat(e[i].y,", ").concat(n," ").concat(o," ")}return t+"Q ".concat(e[e.length-2].x," ").concat(e[e.length-2].y,", ").concat(e[e.length-1].x," ").concat(e[e.length-1].y)}(e.map(e=>new n.fabric.Point(e.x,e.y+t.offsetY)));return new n.fabric.Path(i,{fill:"transparent",selectable:!1,evented:!1,stroke:t.stroke,strokeWidth:t.strokeWidth,opacity:t.opacity,cornerStrokeColor:t.stroke,name:t.name,objectCaching:!1})}function a(e,t,i){return Math.min(t,Math.max(e,i))}function l(e,t){if(!e.startsWith("#"))return e;let i=e.slice(1);if(6!==i.length)return e;let n=parseInt(i.slice(0,2),16),o=parseInt(i.slice(2,4),16),s=parseInt(i.slice(4,6),16);return"rgba(".concat(n,", ").concat(o,", ").concat(s,", ").concat(a(0,1,t),")")}},48905:function(e,t,i){"use strict";t.p=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return(0,s.isRadialPolygonSoundWaveStyle)(e.waveformConfig.style)?(0,n.generateRadialPolygonSoundWave)(e,t):(0,o.generateRadialSoundWaveRects)(e,t)};let n=i(41879),o=i(3746),s=i(44074)},90575:function(e,t){"use strict";t.$B=function(e){var t,i,n;if("function"==typeof e.getOriginalSize){let t=e.getOriginalSize();if((null==t?void 0:t.width)&&(null==t?void 0:t.height))return{width:t.width,height:t.height}}let o=null!==(n=null!==(i=null===(t=e.getElement)||void 0===t?void 0:t.call(e))&&void 0!==i?i:e._element)&&void 0!==n?n:null;
1return o&&"naturalWidth"in o&&o.naturalWidth>0&&o.naturalHeight>0?{width:o.naturalWidth,height:o.naturalHeight}:{width:e.width||0,height:e.height||0}},t.pB=function(e,t,i){var n,o,s;let r=()=>{(!i||i())&&t()};r();let a=null!==(s=null!==(o=null===(n=e.getElement)||void 0===n?void 0:n.call(e))&&void 0!==o?o:e._element)&&void 0!==s?s:null;a instanceof HTMLImageElement&&(0===a.naturalWidth&&a.addEventListener("load",r,{once:!0}),"function"==typeof a.decode&&a.decode().then(r).catch(r)),requestAnimationFrame(r)}},72215:function(e,t,i){"use strict";t.AJ=t.Hh=void 0;let n=i(21749),o=i(22449),s=e=>{let t=(0,o.rewriteUserMediaUrlToCdn)(e);if(t!==e)return t;try{let t=new URL(e);if("dimg.wavevisual.com"===t.hostname)return t.hostname="image-server-proxy.wavevisual.workers.dev",t.toString()}catch(e){}return e},r=new Map;t.Hh=e=>{var t,i;let o=s(e),a=r.get(o);if(!a)return null;let l=new n.fabric.Image(a);return(null!==(t=l.width)&&void 0!==t?t:0)<=0||(null!==(i=l.height)&&void 0!==i?i:0)<=0?null:l};let a=async e=>new Promise((t,i)=>{let o=s(e),a=r.get(o);if(a){var l,h;let e=new n.fabric.Image(a);if((null!==(l=e.width)&&void 0!==l?l:0)>0&&(null!==(h=e.height)&&void 0!==h?h:0)>0){t(e);return}}n.fabric.util.loadImage(o,(e,s)=>{var a,l;if(s||null==e){i(Error("Failed to load image: ".concat(o)));return}r.set(o,e);let h=new n.fabric.Image(e);if((null!==(a=h.width)&&void 0!==a?a:0)<=0||(null!==(l=h.height)&&void 0!==l?l:0)<=0){i(Error("Loaded image has invalid dimensions: ".concat(o)));return}t(h)},void 0,"anonymous")});t.AJ=a},15793:function(e,t,i){"use strict";t.q0=void 0,t.pH=function(e){let t=Math.max(.5,e.thickness+e.space);return Math.max(16,Math.floor(e.width/t))},t.Ii=function(e){let{envelope:i,soundWaveGroup:d,referenceWidth:p,referenceHeight:m,waveColors:f,waveGradientDirection:v,thickness:g,mirrored:y=!0,skipRender:b}=e,C=c(e.canvas,b);if(!i.length||!d)return;let x=y?d.getCenterPoint():null,w=h(d),S=w?u(d,w):(0,r.measureSoundWaveLocalVisualBounds)((0,r.getHorizontalRectBars)(d.getObjects())),E=!y&&S?n.fabric.util.transformPoint((0,r.soundWaveGroupLocalAnchorPoint)(S,y),d.calcTransformMatrix()):null,A=function(e){let{envelope:i,width:n,height:o,thickness:s,mirrored:r=!0,cycles:a=t.q0}=e,h=Math.max(2,i.length),u=o/2,c=.46*u,d=Math.max(2,.5*Math.max(1,s),.012*o),p=Math.max(n,1),m=[],f=[];for(let e=0;e<h;e++){var v;let t=1===h?0:e/(h-1),n=(t-.5)*p,o=Math.max(d,Math.abs(Math.sin(t*Math.PI*2*a))*Math.min(1,Math.max(0,null!==(v=i[e])&&void 0!==v?v:0))*c),s=l(-u,u,0-o),g=l(-u,u,r?0+o:0);m.push({x:n,y:s}),f.push({x:n,y:g})}return[...m,...f.reverse()]}({envelope:i,width:p,height:o.SOUNDWAVE_REFERENCE_HEIGHT,thickness:g,mirrored:y}),R=(0,s.generateFillBackground)({width:p,height:m},f.length?f:["#ffffff"],v);d.getObjects().forEach(e=>{let{name:t}=e;t!==o.RECORDER_SINE_POLYGON_NAME&&t!==a&&e.set("opacity",0)});let O=h(d);if(O?(O.set("objectCaching",!1),O.set("points",A),O.set("fill",R),O.set("opacity",1),O.dirty=!0):(O=new n.fabric.Polygon(A,{fill:R,name:o.RECORDER_SINE_POLYGON_NAME,objectCaching:!1,opacity:1,originX:"center",originY:"center",left:0,top:0}),d.add(O)),function(e){var t;e.set({originX:"center",originY:"center"}),e._setPositionDimensions({});let i=null!==(t=e.pathOffset)&&void 0!==t?t:{x:0,y:0};e.set({left:i.x,top:i.y}),e.setCoords()}(O),O){if((0,r.refreshSoundWaveGroupLayoutBounds)(d),y&&x)d.setPositionByOrigin(x,"center","center"),d.setCoords();else{let e=u(d,O);E&&e&&(0,r.pinGroupLocalAnchorToCanvas)(d,(0,r.soundWaveGroupLocalAnchorPoint)(e,y),E)}}else(0,r.refreshSoundWaveGroupLayoutBounds)(d);C.requestRenderAll()},t.UK=function(e){let{soundWaveGroup:t,skipRender:i}=e,n=c(e.canvas,i),o=h(t);o&&t.remove(o),t.getObjects().forEach(e=>{let{name:t}=e;t!==a&&e.set("opacity",1)}),(0,r.refreshSoundWaveGroupLayoutBounds)(t),n.requestRenderAll()};let n=i(21749),o=i(38986),s=i(46301),r=i(50996);t.q0=6;let a="seeker-line";function l(e,t,i){return Math.min(t,Math.max(e,i))}function h(e){return e.getObjects().find(e=>e.name===o.RECORDER_SINE_POLYGON_NAME&&"polygon"===e.type)}function u(e,t){let{points:i}=t;if(!(null==i?void 0:i.length))return null;let o=1/0,s=-1/0;
1return i.forEach(i=>{let r=function(e,t,i){var o;let s=null!==(o=t.pathOffset)&&void 0!==o?o:{x:0,y:0},r=new n.fabric.Point(i.x-s.x,i.y-s.y),a=n.fabric.util.transformPoint(r,t.calcTransformMatrix()),l=n.fabric.util.invertTransform(e.calcTransformMatrix());return n.fabric.util.transformPoint(a,l)}(e,t,i).y;o=Math.min(o,r),s=Math.max(s,r)}),{top:o,bottom:s,center:(o+s)/2}}function c(e,t){return t?{requestRenderAll:()=>void 0}:e}},10283:function(e,t,i){"use strict";t.eK=t.TT=void 0,t.zQ=r,t.P3=function(e,i){return r(function(e,i){var o,s,r,a,l;let h=null!==(o=null==i?void 0:i.boostBy)&&void 0!==o?o:t.eK,u=Math.max(1,null!==(s=null==i?void 0:i.granularity)&&void 0!==s?s:t.TT);if(!e||0===e.length)return Array(u).fill(n.SAMPLE_HEIGHT);let c=[],d=e.length/u;for(let t=0;t<e.length;t+=d){let i=Number.MIN_SAFE_INTEGER,o=Math.min(e.length,t+d);for(let n=Math.floor(t);n<o;n++){let t=null!==(r=e[n])&&void 0!==r?r:0;t>i&&(i=t)}let s=(a=(i===Number.MIN_SAFE_INTEGER?0:i)*h,Math.max(0,Math.min(l=n.SAMPLE_HEIGHT,l*(a-0)/1)));c.push(Math.floor(n.SAMPLE_HEIGHT-s))}return c}(e,{boostBy:i.boostBy,granularity:i.granularity}),i)};let n=i(38986),o=i(65685),s=i(97373);function r(e,t){let{numBars:i,heightMultiplier:n,referenceWidth:r,thickness:a,space:l}=t,h=[];for((0,s.eachWorkableWaveformData)({waveformData:e,sampleDistance:l+a,width:r,iterator:e=>{let{data:t}=e;h.length<i&&h.push((0,o.dataToScaledAmplitude)(t,n))}});h.length<i;)h.push(0);return h.slice(0,i)}i(67818),t.TT=1024,t.eK=3,t.TT},67818:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sampleWaveformWindow=function(e){let{audioData:t,frame:i,fps:n,windowInSeconds:o,numberOfSamples:s,channel:r=0}=e;if(r<0||r>=t.numberOfChannels)throw TypeError("Channel ".concat(r," is out of range"));if(o*t.sampleRate<s)throw TypeError("".concat(o,"s audiodata does not have ").concat(s," bars. Increase windowInSeconds or decrease numberOfSamples"));let a=t.channelWaveforms[r],l=i/n-o/2,h=Math.floor(l*t.sampleRate),u=Math.floor((l+o)*t.sampleRate),c=Math.max(0,-h),d=Math.max(0,u-a.length),p=Math.max(h,0),m=Math.min(a.length,u),f=new Float32Array(c+(m-p)+d);f.set(a.subarray(p,m),c);let v=Math.floor(f.length/s);if(0===v)return[];let g=[];for(let e=0;e<s;e++){let t=v*e,i=0;for(let e=0;e<v;e++){var y;i+=Math.abs(null!==(y=f[t+e])&&void 0!==y?y:0)}let n=i/v;g.push(e%2==0?-n:n)}return g}},34989:function(e,t){"use strict";t.eS=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(Math.random()),i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{channelWaveforms:Array.from({length:e.numberOfChannels},(t,i)=>e.getChannelData(i)),sampleRate:e.sampleRate,durationInSeconds:e.duration,numberOfChannels:e.numberOfChannels,resultId:t,isRemote:i}}},22449:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.USER_MEDIA_CDN_ORIGIN=t.USER_MEDIA_GCS_BUCKET=void 0,t.isAllowedUserMediaObjectKey=n,t.buildUserMediaProxyUrl=o,t.tryUserMediaCdnUrlForPath=function(e){return e&&n(e)?o(e):null},t.parseUserMediaObjectKeyFromHttpUrl=s,t.rewriteUserMediaUrlToCdn=function(e){let t=s(e);return t?o(t):e},t.USER_MEDIA_GCS_BUCKET="wavevisual-36d2f.appspot.com",t.USER_MEDIA_CDN_ORIGIN="https://image-server-proxy.wavevisual.workers.dev";let i=["uploads/","public/"];function n(e){return!(!e||e.startsWith("/")||e.split("/").some(e=>".."===e||""===e))&&i.some(t=>e.startsWith(t))}function o(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.USER_MEDIA_CDN_ORIGIN,n=i.replace(/\/$/,""),o=e.split("/").map(e=>encodeURIComponent(e)).join("/");return"".concat(n,"/u/").concat(o)}function s(e){try{let i=new URL(e);if("storage.googleapis.com"===i.hostname){let e=i.pathname.split("/").filter(Boolean);if(e.length<2||e[0]!==t.USER_MEDIA_GCS_BUCKET)return null;let o=e.slice(1).map(e=>decodeURIComponent(e)).join("/");return n(o)?o:null}if("firebasestorage.googleapis.com"===i.hostname){let e=i.pathname.match(/^\/v0\/b\/([^/]+)\/o\/(.+)$/);if(!e||e[1]!==t.USER_MEDIA_GCS_BUCKET)return null;let o=decodeURIComponent(e[2]);return n(o)?o:null}}catch(e){}return null}}
1,77237:function(e){e.exports={editorCanvas:"EditorCanvas_editorCanvas__fwjC4",artboardEdgeShadow:"EditorCanvas_artboardEdgeShadow__C_Dpz",frameCheckerBackground:"EditorCanvas_frameCheckerBackground__4CLNd"}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.