import Color from"../../Core/Color.js";import defined from"../../Core/defined.js";import destroyObject from"../../Core/destroyObject.js";import DeveloperError from"../../Core/DeveloperError.js";import getElement from"../getElement.js";import subscribeAndEvaluate from"../subscribeAndEvaluate.js";const svgNS="http://www.w3.org/2000/svg",xlinkNS="http://www.w3.org/1999/xlink";let widgetForDrag;const gradientEnabledColor0=Color.fromCssColorString("rgba(247,250,255,0.384)"),gradientEnabledColor1=Color.fromCssColorString("rgba(143,191,255,0.216)"),gradientEnabledColor2=Color.fromCssColorString("rgba(153,197,255,0.098)"),gradientEnabledColor3=Color.fromCssColorString("rgba(255,255,255,0.086)"),gradientDisabledColor0=Color.fromCssColorString("rgba(255,255,255,0.267)"),gradientDisabledColor1=Color.fromCssColorString("rgba(255,255,255,0)"),gradientKnobColor=Color.fromCssColorString("rgba(66,67,68,0.3)"),gradientPointerColor=Color.fromCssColorString("rgba(0,0,0,0.5)");function getElementColor(t){return Color.fromCssColorString(window.getComputedStyle(t).getPropertyValue("color"))}const svgIconsById={animation_pathReset:{tagName:"path",transform:"translate(16,16) scale(0.85) translate(-16,-16)",d:"M24.316,5.318,9.833,13.682,9.833,5.5,5.5,5.5,5.5,25.5,9.833,25.5,9.833,17.318,24.316,25.682z"},animation_pathPause:{tagName:"path",transform:"translate(16,16) scale(0.85) translate(-16,-16)",d:"M13,5.5,7.5,5.5,7.5,25.5,13,25.5zM24.5,5.5,19,5.5,19,25.5,24.5,25.5z"},animation_pathPlay:{tagName:"path",transform:"translate(16,16) scale(0.85) translate(-16,-16)",d:"M6.684,25.682L24.316,15.5L6.684,5.318V25.682z"},animation_pathPlayReverse:{tagName:"path",transform:"translate(16,16) scale(-0.85,0.85) translate(-16,-16)",d:"M6.684,25.682L24.316,15.5L6.684,5.318V25.682z"},animation_pathLoop:{tagName:"path",transform:"translate(16,16) scale(0.85) translate(-16,-16)",d:"M24.249,15.499c-0.009,4.832-3.918,8.741-8.75,8.75c-2.515,0-4.768-1.064-6.365-2.763l2.068-1.442l-7.901-3.703l0.744,8.694l2.193-1.529c2.244,2.594,5.562,4.242,9.26,4.242c6.767,0,12.249-5.482,12.249-12.249H24.249zM15.499,6.75c2.516,0,4.769,1.065,6.367,2.764l-2.068,1.443l7.901,3.701l-0.746-8.693l-2.192,1.529c-2.245-2.594-5.562-4.245-9.262-4.245C8.734,3.25,3.25,8.734,3.249,15.499H6.75C6.758,10.668,10.668,6.758,15.499,6.75z"},animation_pathClock:{tagName:"path",transform:"translate(16,16) scale(0.85) translate(-16,-15.5)",d:"M15.5,2.374C8.251,2.375,2.376,8.251,2.374,15.5C2.376,22.748,8.251,28.623,15.5,28.627c7.249-0.004,13.124-5.879,13.125-13.127C28.624,8.251,22.749,2.375,15.5,2.374zM15.5,25.623C9.909,25.615,5.385,21.09,5.375,15.5C5.385,9.909,9.909,5.384,15.5,5.374c5.59,0.01,10.115,4.535,10.124,10.125C25.615,21.09,21.091,25.615,15.5,25.623zM8.625,15.5c-0.001-0.552-0.448-0.999-1.001-1c-0.553,0-1,0.448-1,1c0,0.553,0.449,1,1,1C8.176,16.5,8.624,16.053,8.625,15.5zM8.179,18.572c-0.478,0.277-0.642,0.889-0.365,1.367c0.275,0.479,0.889,0.641,1.365,0.365c0.479-0.275,0.643-0.887,0.367-1.367C9.27,18.461,8.658,18.297,8.179,18.572zM9.18,10.696c-0.479-0.276-1.09-0.112-1.366,0.366s-0.111,1.09,0.365,1.366c0.479,0.276,1.09,0.113,1.367-0.366C9.821,11.584,9.657,10.973,9.18,10.696zM22.822,12.428c0.478-0.275,0.643-0.888,0.366-1.366c-0.275-0.478-0.89-0.642-1.366-0.366c-0.479,0.278-0.642,0.89-0.366,1.367C21.732,12.54,22.344,12.705,22.822,12.428zM12.062,21.455c-0.478-0.275-1.089-0.111-1.366,0.367c-0.275,0.479-0.111,1.09,0.366,1.365c0.478,0.277,1.091,0.111,1.365-0.365C12.704,22.344,12.54,21.732,12.062,21.455zM12.062,9.545c0.479-0.276,0.642-0.888,0.366-1.366c-0.276-0.478-0.888-0.642-1.366-0.366s-0.642,0.888-0.366,1.366C10.973,9.658,11.584,9.822,12.062,9.545zM22.823,18.572c-0.48-0.275-1.092-0.111-1.367,0.365c-0.275,0.479-0.112,1.092,0.367,1.367c0.477,0.275,1.089,0.113,1.365-0.365C23.464,19.461,23.3,18.848,22.823,18.572zM19.938,7.813c-0.477-0.276-1.091-0.111-1.365,0.366c-0.275,0.48-0.111,1.091,0.366,1.367s1.089,0.112,1.366-0.366C20.581,8.702,20.418,8.089,19.938,7.813zM23.378,14.5c-0.554,0.002-1.001,0.45-1.001,1c0.001,0.552,0.448,1,1.001,1c0.551,0,1-0.447,1-1C24.378,14.949,23.929,14.5,23.378,14.5zM15.501,6.624c-0.552,0-1,0.448-1,1l-0.466,7.343l-3.004,1.96c-0.478,0.277-0.642,0.889-0.365,1.365c0.275,0.479,0.889,0.643,1.365,0.367l3.305-1.676C15.39,16.99,15.444,17,15.501,17c0.828,0,1.5-0.671,1.5-1.5l-0.5-7.876C16.501,7.072,16.053,6.624,15.501,6.624zM15.501,22.377c-0.552,0-1,0.447-1,1s0.448,1,1,1s1-0.447,1-1S16.053,22.377,15.501,22.377zM18.939,21.455c-0.479,0.277-0.643,0.889-0.366,1.367c0.275,0.477,0.888,0.643,1.366,0.365c0.478-0.275,0.642-0.889,0.366-1.365C20.028,21.344,19.417,21.18,18.939,21.455z"},animation_pathWingButton:{tagName:"path",d:"m 4.5,0.5 c -2.216,0 -4,1.784 -4,4 l 0,24 c 0,2.216 1.784,4 4,4 l 13.71875,0 C 22.478584,27.272785 27.273681,22.511272 32.5,18.25 l 0,-13.75 c 0,-2.216 -1.784,-4 -4,-4 l -24,0 z"},animation_pathPointer:{tagName:"path",d:"M-15,-65,-15,-55,15,-55,15,-65,0,-95z"},animation_pathSwooshFX:{tagName:"path",d:"m 85,0 c 0,16.617 -4.813944,35.356 -13.131081,48.4508 h 6.099803 c 8.317138,-13.0948 13.13322,-28.5955 13.13322,-45.2124 0,-46.94483 -38.402714,-85.00262 -85.7743869,-85.00262 -1.0218522,0 -2.0373001,0.0241 -3.0506131,0.0589 45.958443,1.59437 82.723058,35.77285 82.723058,81.70532 z"}};function svgFromObject(t){const e=document.createElementNS(svgNS,t.tagName);for(const o in t)if(t.hasOwnProperty(o)&&"tagName"!==o)if("children"===o){const o=t.children.length;for(let n=0;nr.right||lr.bottom))return;const m=t._shuttleRingPointer.getBoundingClientRect(),d=l-i-r.left,h=c-s-r.top;let g=180*Math.atan2(h,d)/Math.PI+90;g>180&&(g-=360);const u=o.shuttleRingAngle;n||lm.left&&c>m.top&&cu&&o.faster(),e.preventDefault()}else t===widgetForDrag&&(widgetForDrag=void 0),o.shuttleRingDragging=!1}function SvgButton(t,e){this._viewModel=e,this.svgElement=t,this._enabled=void 0,this._toggled=void 0;const o=this;this._clickFunction=function(){const t=o._viewModel.command;t.canExecute&&t()},t.addEventListener("click",this._clickFunction,!0),this._subscriptions=[subscribeAndEvaluate(e,"toggled",this.setToggled,this),subscribeAndEvaluate(e,"tooltip",this.setTooltip,this),subscribeAndEvaluate(e.command,"canExecute",this.setEnabled,this)]}function Animation(t,e){if(!defined(t))throw new DeveloperError("container is required.");if(!defined(e))throw new DeveloperError("viewModel is required.");t=getElement(t),this._viewModel=e,this._container=t,this._centerX=0,this._centerY=0,this._defsElement=void 0,this._svgNode=void 0,this._topG=void 0,this._lastHeight=void 0,this._lastWidth=void 0;const o=t.ownerDocument,n=document.createElement("style");n.textContent=".cesium-animation-rectButton .cesium-animation-buttonGlow { filter: url(#animation_blurred); }.cesium-animation-rectButton .cesium-animation-buttonMain { fill: url(#animation_buttonNormal); }.cesium-animation-buttonToggled .cesium-animation-buttonMain { fill: url(#animation_buttonToggled); }.cesium-animation-rectButton:hover .cesium-animation-buttonMain { fill: url(#animation_buttonHovered); }.cesium-animation-buttonDisabled .cesium-animation-buttonMain { fill: url(#animation_buttonDisabled); }.cesium-animation-shuttleRingG .cesium-animation-shuttleRingSwoosh { fill: url(#animation_shuttleRingSwooshGradient); }.cesium-animation-shuttleRingG:hover .cesium-animation-shuttleRingSwoosh { fill: url(#animation_shuttleRingSwooshHovered); }.cesium-animation-shuttleRingPointer { fill: url(#animation_shuttleRingPointerGradient); }.cesium-animation-shuttleRingPausePointer { fill: url(#animation_shuttleRingPointerPaused); }.cesium-animation-knobOuter { fill: url(#animation_knobOuter); }.cesium-animation-knobInner { fill: url(#animation_knobInner); }",o.head.insertBefore(n,o.head.childNodes[0]);const i=document.createElement("div");i.className="cesium-animation-theme",i.innerHTML='
',this._theme=i,this._themeNormal=i.childNodes[0],this._themeHover=i.childNodes[1],this._themeSelect=i.childNodes[2],this._themeDisabled=i.childNodes[3],this._themeKnob=i.childNodes[4],this._themePointer=i.childNodes[5],this._themeSwoosh=i.childNodes[6],this._themeSwooshHover=i.childNodes[7];const s=document.createElementNS(svgNS,"svg:svg");this._svgNode=s,s.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink",xlinkNS);const a=document.createElementNS(svgNS,"g");this._topG=a,this._realtimeSVG=new SvgButton(wingButton(3,4,"animation_pathClock"),e.playRealtimeViewModel),this._playReverseSVG=new SvgButton(rectButton(44,99,"animation_pathPlayReverse"),e.playReverseViewModel),this._playForwardSVG=new SvgButton(rectButton(124,99,"animation_pathPlay"),e.playForwardViewModel),this._pauseSVG=new SvgButton(rectButton(84,99,"animation_pathPause"),e.pauseViewModel);const r=document.createElementNS(svgNS,"g");r.appendChild(this._realtimeSVG.svgElement),r.appendChild(this._playReverseSVG.svgElement),r.appendChild(this._playForwardSVG.svgElement),r.appendChild(this._pauseSVG.svgElement);const l=svgFromObject({tagName:"circle",class:"cesium-animation-shuttleRingBack",cx:100,cy:100,r:99});this._shuttleRingBackPanel=l;const c=svgIconsById["animation_pathSwooshFX"],m=svgIconsById["animation_pathPointer"],d=svgFromObject({tagName:"g",class:"cesium-animation-shuttleRingSwoosh",children:[{tagName:c.tagName,transform:"translate(100,97) scale(-1,1)",id:"animation_pathSwooshFX",d:c.d},{tagName:c.tagName,transform:"translate(100,97)",id:"animation_pathSwooshFX",d:c.d},{tagName:"line",x1:100,y1:8,x2:100,y2:22}]});this._shuttleRingSwooshG=d,this._shuttleRingPointer=svgFromObject({class:"cesium-animation-shuttleRingPointer",id:"animation_pathPointer",tagName:m.tagName,d:m.d});const h=svgFromObject({tagName:"g",transform:"translate(100,100)"});this._knobOuter=svgFromObject({tagName:"circle",class:"cesium-animation-knobOuter",cx:0,cy:0,r:71});const g=61,u=svgFromObject({tagName:"circle",class:"cesium-animation-knobInner",cx:0,cy:0,r:g});this._knobDate=svgText(0,-24,""),this._knobTime=svgText(0,-7,""),this._knobStatus=svgText(0,-41,"");const p=svgFromObject({tagName:"circle",class:"cesium-animation-blank",cx:0,cy:0,r:g}),v=document.createElementNS(svgNS,"g");v.setAttribute("class","cesium-animation-shuttleRingG"),t.appendChild(i),a.appendChild(v),a.appendChild(h),a.appendChild(r),v.appendChild(l),v.appendChild(d),v.appendChild(this._shuttleRingPointer),h.appendChild(this._knobOuter),h.appendChild(u),h.appendChild(this._knobDate),h.appendChild(this._knobTime),h.appendChild(this._knobStatus),h.appendChild(p),s.appendChild(a),t.appendChild(s);const C=this;function b(t){setShuttleRingFromMouseOrTouch(C,t)}this._mouseCallback=b,l.addEventListener("mousedown",b,!0),l.addEventListener("touchstart",b,!0),d.addEventListener("mousedown",b,!0),d.addEventListener("touchstart",b,!0),o.addEventListener("mousemove",b,!0),o.addEventListener("touchmove",b,!0),o.addEventListener("mouseup",b,!0),o.addEventListener("touchend",b,!0),o.addEventListener("touchcancel",b,!0),this._shuttleRingPointer.addEventListener("mousedown",b,!0),this._shuttleRingPointer.addEventListener("touchstart",b,!0),this._knobOuter.addEventListener("mousedown",b,!0),this._knobOuter.addEventListener("touchstart",b,!0);const f=this._knobTime.childNodes[0],_=this._knobDate.childNodes[0],N=this._knobStatus.childNodes[0];let S;this._subscriptions=[subscribeAndEvaluate(e.pauseViewModel,"toggled",(function(t){S!==t&&(S=t,S?C._shuttleRingPointer.setAttribute("class","cesium-animation-shuttleRingPausePointer"):C._shuttleRingPointer.setAttribute("class","cesium-animation-shuttleRingPointer"))})),subscribeAndEvaluate(e,"shuttleRingAngle",(function(t){setShuttleRingPointer(C._shuttleRingPointer,C._knobOuter,t)})),subscribeAndEvaluate(e,"dateLabel",(function(t){_.textContent!==t&&(_.textContent=t)})),subscribeAndEvaluate(e,"timeLabel",(function(t){f.textContent!==t&&(f.textContent=t)})),subscribeAndEvaluate(e,"multiplierLabel",(function(t){N.textContent!==t&&(N.textContent=t)}))],this.applyThemeChanges(),this.resize()}SvgButton.prototype.destroy=function(){this.svgElement.removeEventListener("click",this._clickFunction,!0);const t=this._subscriptions;for(let e=0,o=t.length;e