@aarsteinmedia/dotlottie-player 2.1.6 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,1030 @@
1
- "use strict";var lit=require("lit"),decorators_js=require("lit/decorators.js"),Lottie=require("lottie-web"),fflate=require("fflate");exports.PlayerState=void 0,function(e){e.Completed="completed",e.Destroyed="destroyed",e.Error="error",e.Frozen="frozen",e.Loading="loading",e.Paused="paused",e.Playing="playing",e.Stopped="stopped"}(exports.PlayerState||(exports.PlayerState={})),exports.PlayMode=void 0,function(e){e.Bounce="bounce",e.Normal="normal"}(exports.PlayMode||(exports.PlayMode={})),exports.PlayerEvents=void 0,function(e){e.Complete="complete",e.Destroyed="destroyed",e.Error="error",e.Frame="frame",e.Freeze="freeze",e.Load="load",e.Loop="loop",e.Pause="pause",e.Play="play",e.Ready="ready",e.Rendered="rendered",e.Stop="stop"}(exports.PlayerEvents||(exports.PlayerEvents={}));class CustomError extends Error{}function asyncGeneratorStep$1(e,t,r,o,i,s,n){try{var a=e[s](n),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(o,i)}function _async_to_generator$1(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var s=e.apply(t,r);function n(e){asyncGeneratorStep$1(s,o,i,n,a,"next",e)}function a(e){asyncGeneratorStep$1(s,o,i,n,a,"throw",e)}n(void 0)})}}const addExt=(e,t)=>{if(t)return getExt(t)?getExt(t)===e?t:`${getFilename(t)}.${e}`:`${t}.${e}`},aspectRatio=e=>{switch(e){case"contain":case"scale-down":default:return"xMidYMid meet";case"cover":return"xMidYMid slice";case"fill":return"none";case"none":return"xMinYMin slice"}},base64ToU8=e=>{let t=e.substring(e.indexOf(",")+1);return strToU8(isServer()?Buffer.from(t,"base64").toString("binary"):atob(t))},createDotLottie=function(){var e=_async_to_generator$1(function*(e,t,r,o=!0){try{var i;if(!(null==e?void 0:e.length)||!t)throw Error(`Missing or malformed required parameter(s):
2
- ${(null==e?void 0:e.length)?"":"- animations\n"} ${t?"":"- manifest \n"}`);let s=addExt("lottie",r)||`${useId()}.lottie`,n={"manifest.json":[strToU8(JSON.stringify(t)),{level:0}]};for(let[r,o]of e.entries()){if(null===(i=o.assets)||void 0===i?void 0:i.length)for(let e of o.assets){let{id:t,p:r}=e;if(t&&r){let o=getExtFromB64(r);e.p=`${t}.${o}`,e.e=0,n[`images/${t}.${o}`]=[base64ToU8(r),{level:9}]}}n[`animations/${t.animations[r].id}.json`]=[strToU8(JSON.stringify(o)),{level:9}]}let a=yield getArrayBuffer(n);return o?download(a,{name:s,mimeType:"application/zip"}):a}catch(e){console.error(`❌ ${handleErrors(e).message}`)}});return function(t,r,o){return e.apply(this,arguments)}}(),download=(e,t)=>{let r=new Blob([e],{type:null==t?void 0:t.mimeType}),o=(null==t?void 0:t.name)||useId(),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=o,s.hidden=!0,document.body.appendChild(s),s.click(),setTimeout(()=>{s.remove(),URL.revokeObjectURL(i)},1e3)},handleErrors=e=>{let t={message:"Unknown error",status:isServer()?500:400};return e&&"object"==typeof e&&("message"in e&&"string"==typeof e.message&&(t.message=e.message),"status"in e&&(t.status=Number(e.status))),t},frameOutput=e=>((null!=e?e:0)+1).toString().padStart(3,"0"),getAnimationData=function(){var e=_async_to_generator$1(function*(e){try{if(!e||"string"!=typeof e&&"object"!=typeof e)throw Error("Broken file or invalid file format");if("string"!=typeof e){let t=Array.isArray(e)?e:[e];return{animations:t,manifest:null}}let t=yield fetch(e);if(!t.ok){let e=new CustomError(t.statusText);throw e.status=t.status,e}let r=getExt(e);if("json"===r||!r){if(r){let e=yield t.json();return{animations:[e],manifest:null}}let e=yield t.clone().text();try{let t=JSON.parse(e);return{animations:[t],manifest:null}}catch(e){}}let{data:o,manifest:i}=yield getLottieJSON(t);return{animations:o,manifest:i,isDotLottie:!0}}catch(e){return console.error(`❌ ${handleErrors(e).message}`),{animations:null,manifest:null}}});return function(t){return e.apply(this,arguments)}}(),getArrayBuffer=function(){var e=_async_to_generator$1(function*(e){let t=yield new Promise((t,r)=>{fflate.zip(e,{level:9},(e,o)=>{if(e){r(e);return}t(o.buffer)})});return t});return function(t){return e.apply(this,arguments)}}(),getExt=e=>{var t;if(e&&hasExt(e))return null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase()},getExtFromB64=e=>{let t=e.split(":")[1].split(";")[0];return t.split("/")[1].split("+")[0]},getFilename=(e,t)=>{let r=getExt(e);return`${e.replace(/\.[^.]*$/,"").replace(/\W+/g,"")}${t&&r?`.${r}`:""}`.toLowerCase()},getLottieJSON=function(){var e=_async_to_generator$1(function*(e){let t=yield unzip(e),r=getManifest(t),o=[];for(let{id:e}of r.animations){let r=fflate.strFromU8(t[`animations/${e}.json`]),i=JSON.parse(r);yield resolveAssets(t,i.assets),o.push(i)}return{data:o,manifest:r}});return function(t){return e.apply(this,arguments)}}(),getManifest=e=>{let t=fflate.strFromU8(e["manifest.json"],!1),r=JSON.parse(t);if(!("animations"in r))throw Error("Manifest not found");if(!r.animations.length)throw Error("No animations listed in manifest");return r},getMimeFromExt=e=>{switch(e){case"svg":case"svg+xml":return"image/svg+xml";case"jpg":case"jpeg":return"image/jpeg";case"png":case"gif":case"webp":return`image/${e}`;case"mp3":case"mpeg":case"wav":return`audio/${e}`;default:return""}},hasExt=e=>{var t;let r=null==e?void 0:null===(t=e.split("/").pop())||void 0===t?void 0:t.lastIndexOf(".");return(null!=r?r:0)>1&&e&&e.length-1>(null!=r?r:0)},isAudio=e=>!("h"in e)&&!("w"in e)&&"p"in e&&"e"in e&&"u"in e&&"id"in e,isImage=e=>"w"in e&&"h"in e&&!("xt"in e)&&"p"in e,isServer=()=>!("undefined"!=typeof window&&window.document),strToU8=e=>{let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},resolveAssets=function(){var e=_async_to_generator$1(function*(e,t){if(!Array.isArray(t))return;let r=[];for(let o of t){if(!isAudio(o)&&!isImage(o))continue;let t=isImage(o)?"images":"audio",i=null==e?void 0:e[`${t}/${o.p}`];i&&r.push(new Promise(e=>{let t=isServer()?Buffer.from(i).toString("base64"):btoa(i.reduce((e,t)=>e+String.fromCharCode(t),""));o.p=`data:${getMimeFromExt(getExt(o.p))};base64,${t}`,o.e=1,o.u="",e()}))}yield Promise.all(r)});return function(t,r){return e.apply(this,arguments)}}(),unzip=function(){var e=_async_to_generator$1(function*(e){let t=new Uint8Array((yield e.arrayBuffer())),r=yield new Promise((e,r)=>{fflate.unzip(t,(t,o)=>{t&&r(t),e(o)})});return r});return function(t){return e.apply(this,arguments)}}(),useId=e=>{let t=()=>((1+Math.random())*65536|0).toString(16).substring(1);return`${null!=e?e:`:${t()}`}-${t()}`};var name="@aarsteinmedia/dotlottie-player",version="2.1.6",description="Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player",exports$1={".":{import:"./dist/esm/index.js",node:"./dist/esm/index.js",require:"./dist/cjs/index.js",types:"./dist/index.d.ts"}},main="./dist/index.js",unpkg="./dist/index.js",module$1="./dist/esm/index.js",types="./dist/index.d.ts",type="module",homepage="https://www.aarstein.media/en/dotlottie-player",repository={url:"https://github.com/aarsteinmedia/dotlottie-player.git",type:"git"},bugs="https://github.com/aarsteinmedia/dotlottie-player/issues",author={name:"Johan Martin Aarstein",email:"johan@aarstein.media",url:"https://www.aarstein.media",organization:"Aarstein Media"},license="GPL-2.0-or-later",scripts={build:"pnpm cleanup && rollup -c","build:types":"pnpm cleanup:types && tsc","build:cem":"npx cem analyze --config 'cem.config.mjs'",prod:"pnpm build:types && pnpm build && pnpm build:cem",dev:"pnpm cleanup && rollup -c --watch",lint:"tsc && eslint . --ext .ts,.js","lint:fix":"eslint . --ext .ts,.js --fix","cleanup:types":"shx rm -rf types && shx mkdir types",cleanup:"shx rm -rf dist && shx mkdir dist"},dependencies={fflate:"^0.8.1",lit:"^2.8.0","lottie-web":"^5.12.2"},peerDependencies={"@types/react":"^18.2.28"},devDependencies={"@custom-elements-manifest/analyzer":"^0.6.9","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.1","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.4","@swc/core":"1.3.75","@types/node":"^20.8.8","@typescript-eslint/eslint-plugin":"^5.62.0","@typescript-eslint/parser":"^5.62.0",eslint:"^8.52.0",rollup:"^3.29.4","rollup-plugin-dts":"^6.1.0","rollup-plugin-html-literals":"^1.1.8","rollup-plugin-summary":"^2.0.0","rollup-plugin-swc3":"^0.9.1",shx:"^0.3.4","ts-lit-plugin":"^1.2.1",typescript:"^5.2.2"},customElements="dist/custom-elements.json",files=["dist","README.md"],keywords=["lottie","dotlottie","animation","web component","component","lit-element","svg","vector","player"],publishConfig={access:"public"},engines={node:">= 7.6.0"},funding={type:"paypal",url:"https://www.paypal.com/donate/?hosted_button_id=E7C7DMN8KSQ6A"},pkg={name:name,version:version,description:description,exports:exports$1,main:main,unpkg:unpkg,module:module$1,types:types,type:type,homepage:homepage,repository:repository,bugs:bugs,author:author,license:license,scripts:scripts,dependencies:dependencies,peerDependencies:peerDependencies,devDependencies:devDependencies,customElements:customElements,files:files,keywords:keywords,publishConfig:publishConfig,engines:engines,funding:funding},styles=lit.css`*{box-sizing:border-box}:host{--lottie-player-toolbar-height:35px;--lottie-player-toolbar-background-color:#FFF;--lottie-player-toolbar-icon-color:#000;--lottie-player-toolbar-icon-hover-color:#000;--lottie-player-toolbar-icon-active-color:#4285f4;--lottie-player-seeker-track-color:rgba(0, 0, 0, 0.2);--lottie-player-seeker-thumb-color:#4285f4;--lottie-player-seeker-display:block;display:block;width:100%;height:100%}@media (prefers-color-scheme:dark){:host{--lottie-player-toolbar-background-color:#000;--lottie-player-toolbar-icon-color:#FFF;--lottie-player-toolbar-icon-hover-color:#FFF;--lottie-player-seeker-track-color:rgba(255, 255, 255, 0.6)}}.main{display:flex;flex-direction:column;height:100%;width:100%;margin:0}.animation{width:100%;height:100%;display:flex}[data-controls=true] .animation{height:calc(100% - 35px)}.animation-container{position:relative}.popover{position:absolute;right:5px;bottom:40px;background-color:var(--lottie-player-toolbar-background-color);border-radius:5px;padding:10px 15px;border:solid 2px var(--lottie-player-toolbar-icon-color);animation:fadeIn .2s ease-in-out}.popover::before{content:"";right:10px;border:7px solid transparent;border-top-color:transparent;margin-right:-7px;height:0;width:0;position:absolute;pointer-events:none;top:100%;border-top-color:var(--lottie-player-toolbar-icon-color)}.toolbar{display:flex;align-items:center;justify-items:center;background:var(--lottie-player-toolbar-background-color);margin:0;height:35px;padding:5px;border-radius:5px;gap:5px}.toolbar.has-error{pointer-events:none;opacity:.5}.toolbar button{cursor:pointer;fill:var(--lottie-player-toolbar-icon-color);color:var(--lottie-player-toolbar-icon-color);display:flex;background:0 0;border:0;padding:0;outline:0;height:100%;margin:0;align-items:center;gap:5px;opacity:.9}.toolbar button:hover{opacity:1}.toolbar button[data-active=true]{opacity:1;fill:var(--lottie-player-toolbar-icon-active-color)}.toolbar button:disabled{opacity:.5}.toolbar button:focus{outline:0}.toolbar button svg{pointer-events:none}.toolbar button svg>*{fill:inherit}.toolbar button.disabled svg{display:none}.progress-container{position:relative;width:100%}.progress-container.simple{margin-right:12px}.seeker,.seeker::-webkit-slider-runnable-track,.seeker::-webkit-slider-thumb,progress{-webkit-appearance:none;appearance:none;outline:0}.seeker{width:100%;height:20px;border-radius:3px;border:0;cursor:pointer;background-color:transparent;display:var(--lottie-player-seeker-display);color:var(--lottie-player-seeker-thumb-color);margin:0;padding:7.5px 0;position:relative;z-index:1}progress{position:absolute;width:100%;height:5px;border-radius:3px;border:0;top:0;left:0;margin:7.5px 0;background-color:var(--lottie-player-seeker-track-color);pointer-events:none}::-moz-progress-bar{background-color:var(--lottie-player-seeker-thumb-color)}::-webkit-progress-inner-element{border-radius:3px;overflow:hidden}::-webkit-slider-runnable-track{background-color:transparent}::-webkit-progress-value{background-color:var(--lottie-player-seeker-thumb-color)}.seeker::-webkit-slider-thumb{height:15px;width:15px;border-radius:50%;border:0;background-color:var(--lottie-player-seeker-thumb-color);cursor:pointer;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-webkit-slider-thumb,.seeker:hover::-webkit-slider-thumb{transform:scale(1)}.seeker::-moz-range-progress{background-color:var(--lottie-player-seeker-thumb-color);height:5px;border-radius:3px}.seeker::-moz-range-thumb{height:15px;width:15px;border-radius:50%;background-color:var(--lottie-player-seeker-thumb-color);border:0;cursor:pointer;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-moz-range-thumb,.seeker:hover::-moz-range-thumb{transform:scale(1)}.seeker::-ms-track{width:100%;height:5px;cursor:pointer;background:0 0;border-color:transparent;color:transparent}.seeker::-ms-fill-upper{background:var(--lottie-player-seeker-track-color);border-radius:3px}.seeker::-ms-fill-lower{background-color:var(--lottie-player-seeker-thumb-color);border-radius:3px}.seeker::-ms-thumb{border:0;height:15px;width:15px;border-radius:50%;background:var(--lottie-player-seeker-thumb-color);cursor:pointer;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-ms-thumb,.seeker:hover::-ms-thumb{transform:scale(1)}.seeker:focus::-ms-fill-lower{background:var(--lottie-player-seeker-track-color)}.seeker:focus::-ms-fill-upper{background:var(--lottie-player-seeker-track-color)}.error{display:flex;margin:auto;justify-content:center;height:100%;align-items:center}.error svg{width:100%;height:auto}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}`;function asyncGeneratorStep(e,t,r,o,i,s,n){try{var a=e[s](n),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(o,i)}function _async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var s=e.apply(t,r);function n(e){asyncGeneratorStep(s,o,i,n,a,"next",e)}function a(e){asyncGeneratorStep(s,o,i,n,a,"throw",e)}n(void 0)})}}function _define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){_define_property(e,t,r[t])})}return e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function _ts_decorate(e,t,r,o){for(var i,s=arguments.length,n=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o,a=e.length-1;a>=0;a--)(i=e[a])&&(n=(s<3?i(n):s>3?i(t,r,n):i(t,r))||n);return s>3&&n&&Object.defineProperty(t,r,n),n}exports.DotLottiePlayer=class extends lit.LitElement{_getOptions(){var e;let t=null!==(e=this.preserveAspectRatio)&&void 0!==e?e:this.objectfit&&aspectRatio(this.objectfit),r=!this.segment||this.segment.some(e=>e<0)?void 0:this.segment.every(e=>e>0)?[this.segment[0]-1,this.segment[1]-1]:this.segment,o={container:this.container,loop:!!this.loop,autoplay:!!this.autoplay,renderer:this.renderer,initialSegment:r,rendererSettings:{imagePreserveAspectRatio:t}};switch(this.renderer){case"svg":o.rendererSettings=_object_spread_props(_object_spread({},o.rendererSettings),{hideOnTransparent:!0,preserveAspectRatio:t,progressiveLoad:!0});break;case"canvas":o.rendererSettings=_object_spread_props(_object_spread({},o.rendererSettings),{clearCanvas:!0,preserveAspectRatio:t,progressiveLoad:!0});break;case"html":o.rendererSettings=_object_spread_props(_object_spread({},o.rendererSettings),{hideOnTransparent:!0})}return o}load(e){var t=this;return _async_to_generator(function*(){var r;if(t.shadowRoot){try{let{animations:r,manifest:o,isDotLottie:i}=yield getAnimationData(e);if(!r||r.some(e=>!t._isLottie(e)))throw Error("Broken or corrupted file");t._isDotLottie=!!i,t._animations=r,t._manifest=null!=o?o:{animations:[{id:useId(),autoplay:t.autoplay,loop:t.loop,direction:t.direction,mode:t.mode,speed:t.speed}]},t._lottieInstance&&t._lottieInstance.destroy(),t._lottieInstance=Lottie.loadAnimation(_object_spread_props(_object_spread({},t._getOptions()),{animationData:r[t._currentAnimation]}))}catch(e){t._errorMessage=handleErrors(e).message,t.currentState=exports.PlayerState.Error,t.dispatchEvent(new CustomEvent(exports.PlayerEvents.Error));return}t._addEventListeners(),t.setSpeed(t.speed),t.setDirection(null!==(r=t.direction)&&void 0!==r?r:1),t.setSubframe(!!t.subframe),t.autoplay&&(-1===t.direction&&t.seek("99%"),t.play())}})()}_addEventListeners(){this._lottieInstance&&(this._lottieInstance.addEventListener("enterFrame",()=>{if(this._lottieInstance){let{currentFrame:e,totalFrames:t}=this._lottieInstance;this._seeker=Math.floor(e/t*100),this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Frame,{detail:{frame:e,seeker:this._seeker}}))}}),this._lottieInstance.addEventListener("complete",()=>{var e,t;this.currentState=exports.PlayerState.Completed,this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Complete)),(null===(e=this._animations)||void 0===e?void 0:e.length)>1&&this.autoplay&&this._currentAnimation<(null===(t=this._animations)||void 0===t?void 0:t.length)-1&&this.next()}),this._lottieInstance.addEventListener("loopComplete",()=>{var e,t,r;if(!this._lottieInstance)return;let{firstFrame:o,totalFrames:i,playDirection:s}=this._lottieInstance;if(this.count&&(this.mode===exports.PlayMode.Bounce?this._playerState.count+=1:this._playerState.count+=.5,this._playerState.count>=this.count)){this.setLooping(!1),this.currentState=exports.PlayerState.Completed,this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Complete));return}return(this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Loop)),this.mode===exports.PlayMode.Bounce)?(null===(t=this._lottieInstance)||void 0===t||t.goToAndStop(-1===s?o:.99*i,!0),null===(r=this._lottieInstance)||void 0===r||r.setDirection(-1*s),setTimeout(()=>{var e;null===(e=this._lottieInstance)||void 0===e||e.play()},this.intermission)):(null===(e=this._lottieInstance)||void 0===e||e.goToAndStop(-1===s?.99*i:o,!0),setTimeout(()=>{var e;null===(e=this._lottieInstance)||void 0===e||e.play()},this.intermission))}),this._lottieInstance.addEventListener("DOMLoaded",()=>{this._playerState.loaded=!0,this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Ready))}),this._lottieInstance.addEventListener("data_ready",()=>{this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Load))}),this._lottieInstance.addEventListener("data_failed",()=>{this.currentState=exports.PlayerState.Error,this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Error))}),this.container&&(this.container.addEventListener("mouseenter",()=>{this.hover&&this.currentState!==exports.PlayerState.Playing&&this.play()}),this.container.addEventListener("mouseleave",()=>{this.hover&&this.currentState===exports.PlayerState.Playing&&this.stop()})))}_onVisibilityChange(){document.hidden&&this.currentState===exports.PlayerState.Playing?this._freeze():this.currentState===exports.PlayerState.Frozen&&this.play()}_handleSeekChange({target:e}){!(!(e instanceof HTMLInputElement)||!this._lottieInstance||isNaN(Number(e.value)))&&(this.seek(Math.floor(Number(e.value)/100*this._lottieInstance.totalFrames)),setTimeout(()=>{e.parentElement instanceof HTMLFormElement&&e.parentElement.reset()},100))}_isLottie(e){return["v","ip","op","layers","fr","w","h"].every(t=>Object.prototype.hasOwnProperty.call(e,t))}addAnimation(e,t,r=!0){var o=this;return _async_to_generator(function*(){try{let i=o._manifest||{animations:[]},s=_object_spread_props(_object_spread({},i),{generator:pkg.name}),n=o._animations||[];for(let t of e){let{url:e}=t,{animations:r}=yield getAnimationData(e);if(!r)throw Error("No animation loaded");if(s.animations.some(({id:e})=>e===t.id))throw Error("Duplicate id for animation");s=_object_spread_props(_object_spread({},s),{animations:[...s.animations,t]}),n=[...n,...r]}return createDotLottie(n,s,t,r)}catch(e){console.error(handleErrors(e).message)}})()}getLottie(){return this._lottieInstance}play(){this._lottieInstance&&(this.currentState&&(this._playerState.prev=this.currentState),this._lottieInstance.play(),setTimeout(()=>{this.currentState=exports.PlayerState.Playing},0),this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Play)))}pause(){this._lottieInstance&&(this.currentState&&(this._playerState.prev=this.currentState),this._lottieInstance.pause(),setTimeout(()=>{this.currentState=exports.PlayerState.Paused},0),this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Pause)))}stop(){this._lottieInstance&&(this.currentState&&(this._playerState.prev=this.currentState),this._playerState.count=0,this._lottieInstance.stop(),setTimeout(()=>{this.currentState=exports.PlayerState.Stopped},0),this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Stop)))}destroy(){this._lottieInstance&&(this.currentState=exports.PlayerState.Destroyed,this._lottieInstance.destroy(),this._lottieInstance=null,this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Destroyed)),this.remove())}seek(e){if(!this._lottieInstance)return;let t=e.toString().match(/^([0-9]+)(%?)$/);if(!t)return;let r=Math.floor("%"===t[2]?this._lottieInstance.totalFrames*Number(t[1])/100:Number(t[1]));this._seeker=r,this.currentState===exports.PlayerState.Playing||this.currentState===exports.PlayerState.Frozen&&this._playerState.prev===exports.PlayerState.Playing?(this._lottieInstance.goToAndPlay(r,!0),this.currentState=exports.PlayerState.Playing):(this._lottieInstance.goToAndStop(r,!0),this._lottieInstance.pause())}snapshot(){if(!this.shadowRoot)return;let e=this.shadowRoot.querySelector(".animation svg"),t=e instanceof Node?new XMLSerializer().serializeToString(e):null;if(!t){console.error("Could not serialize data");return}return download(t,{name:`${getFilename(this.src)}-${frameOutput(this._seeker)}.svg`,mimeType:"image/svg+xml"}),t}setSubframe(e){this._lottieInstance&&(this.subframe=e,this._lottieInstance.setSubframe(e))}_freeze(){this._lottieInstance&&(this.currentState&&(this._playerState.prev=this.currentState),this._lottieInstance.pause(),setTimeout(()=>{this.currentState=exports.PlayerState.Frozen},0),this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Freeze)))}reload(){var e=this;return _async_to_generator(function*(){e._lottieInstance&&(e._lottieInstance.destroy(),e.src&&(yield e.load(e.src)))})()}setSpeed(e=1){this._lottieInstance&&(this.speed=e,this._lottieInstance.setSpeed(e))}setDirection(e){this._lottieInstance&&(this.direction=e,this._lottieInstance.setDirection(e))}setLooping(e){this._lottieInstance&&(this.loop=e,this._lottieInstance.setLoop(e))}togglePlay(){if(!this._lottieInstance)return;let{currentFrame:e,playDirection:t,totalFrames:r}=this._lottieInstance;return this.currentState===exports.PlayerState.Playing?this.pause():this.currentState===exports.PlayerState.Completed?(this.currentState=exports.PlayerState.Playing,this.mode===exports.PlayMode.Bounce)?(this.setDirection(-1*t),this._lottieInstance.goToAndPlay(e,!0)):-1===t?this._lottieInstance.goToAndPlay(r,!0):this._lottieInstance.goToAndPlay(0,!0):this.play()}toggleLooping(){this.setLooping(!this.loop)}toggleBoomerang(){this.mode===exports.PlayMode.Normal?this.mode=exports.PlayMode.Bounce:this.mode=exports.PlayMode.Normal}_toggleSettings(e){void 0===e?this._isSettingsOpen=!this._isSettingsOpen:this._isSettingsOpen=e}_switchInstance(){this._lottieInstance&&this._lottieInstance.destroy(),this._lottieInstance=Lottie.loadAnimation(_object_spread_props(_object_spread({},this._getOptions()),{animationData:this._animations[this._currentAnimation]})),this._addEventListeners(),this.autoplay?(this._lottieInstance.goToAndPlay(0,!0),this.currentState=exports.PlayerState.Playing):this._lottieInstance.goToAndStop(0,!0)}next(){this._currentAnimation++,this._switchInstance()}prev(){this._currentAnimation--,this._switchInstance()}convert(e,t,r,o,i=!0){if(e||this._isDotLottie)return;let s=t||this._manifest,n=_object_spread_props(_object_spread({},s),{generator:pkg.name});return createDotLottie(r||this._animations,n,`${getFilename(o||this.src)}.lottie`,i)}static get styles(){return styles}connectedCallback(){super.connectedCallback(),void 0!==document.hidden&&document.addEventListener("visibilitychange",this._onVisibilityChange)}firstUpdated(){var e=this;return _async_to_generator(function*(){"IntersectionObserver"in window&&(e._intersectionObserver=new IntersectionObserver(t=>{t[0].isIntersecting?document.hidden||e.currentState!==exports.PlayerState.Frozen||e.play():e.currentState===exports.PlayerState.Playing&&e._freeze()}),e._intersectionObserver.observe(e.container)),e.src&&(yield e.load(e.src)),e.dispatchEvent(new CustomEvent(exports.PlayerEvents.Rendered))})()}disconnectedCallback(){super.disconnectedCallback(),this._intersectionObserver&&(this._intersectionObserver.disconnect(),this._intersectionObserver=void 0),this._lottieInstance&&this._lottieInstance.destroy(),document.removeEventListener("visibilitychange",this._onVisibilityChange)}renderControls(){var e,t;let r=this.currentState===exports.PlayerState.Playing,o=this.currentState===exports.PlayerState.Paused,i=this.currentState===exports.PlayerState.Stopped,s=this.currentState===exports.PlayerState.Error;return lit.html`<div class="${`lottie-controls toolbar ${s?"has-error":""}`}" aria-label="Lottie Animation controls"><button @click="${this.togglePlay}" data-active="${r||o}" tabindex="0" aria-label="Toggle Play/Pause">${r?lit.html`<svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M14.016 5.016H18v13.969h-3.984V5.016zM6 18.984V5.015h3.984v13.969H6z"/></svg>`:lit.html`<svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M8.016 5.016L18.985 12 8.016 18.984V5.015z"/></svg>`}</button> <button @click="${this.stop}" data-active="${i}" tabindex="0" aria-label="Stop"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M6 6h12v12H6V6z"/></svg></button> ${(null===(e=this._animations)||void 0===e?void 0:e.length)>1?lit.html`${this._currentAnimation>0?lit.html`<button @click="${this.prev}" tabindex="0" aria-label="Previous animation"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M17.9 18.2 8.1 12l9.8-6.2v12.4zm-10.3 0H6.1V5.8h1.5v12.4z"/></svg></button>`:lit.nothing} ${this._currentAnimation+1<(null===(t=this._animations)||void 0===t?void 0:t.length)?lit.html`<button @click="${this.next}" tabindex="0" aria-label="Next animation"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="m6.1 5.8 9.8 6.2-9.8 6.2V5.8zM16.4 5.8h1.5v12.4h-1.5z"/></svg></button>`:lit.nothing}`:lit.nothing}<form class="progress-container${this.simple?" simple":""}"><input class="seeker" type="range" min="0" max="100" step="1" value="${this._seeker}" @change="${this._handleSeekChange}" @mousedown="${this._freeze}" aria-valuemin="0" aria-valuemax="100" role="slider" aria-valuenow="${this._seeker}" tabindex="0" aria-label="Slider for search"><progress min="0" max="100" value="${this._seeker}"></progress></form>${this.simple?lit.nothing:lit.html`<button @click="${this.toggleLooping}" data-active="${this.loop}" tabindex="0" aria-label="Toggle looping"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M17.016 17.016v-4.031h1.969v6h-12v3l-3.984-3.984 3.984-3.984v3h10.031zM6.984 6.984v4.031H5.015v-6h12v-3l3.984 3.984-3.984 3.984v-3H6.984z"/></svg></button> <button @click="${this.toggleBoomerang}" data-active="${this.mode===exports.PlayMode.Bounce}" aria-label="Toggle boomerang" tabindex="0"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="m11.8 13.2-.3.3c-.5.5-1.1 1.1-1.7 1.5-.5.4-1 .6-1.5.8-.5.2-1.1.3-1.6.3s-1-.1-1.5-.3c-.6-.2-1-.5-1.4-1-.5-.6-.8-1.2-.9-1.9-.2-.9-.1-1.8.3-2.6.3-.7.8-1.2 1.3-1.6.3-.2.6-.4 1-.5.2-.2.5-.2.8-.3.3 0 .7-.1 1 0 .3 0 .6.1.9.2.9.3 1.7.9 2.4 1.5.4.4.8.7 1.1 1.1l.1.1.4-.4c.6-.6 1.2-1.2 1.9-1.6.5-.3 1-.6 1.5-.7.4-.1.7-.2 1-.2h.9c1 .1 1.9.5 2.6 1.4.4.5.7 1.1.8 1.8.2.9.1 1.7-.2 2.5-.4.9-1 1.5-1.8 2-.4.2-.7.4-1.1.4-.4.1-.8.1-1.2.1-.5 0-.9-.1-1.3-.3-.8-.3-1.5-.9-2.1-1.5-.4-.4-.8-.7-1.1-1.1h-.3zm-1.1-1.1c-.1-.1-.1-.1 0 0-.3-.3-.6-.6-.8-.9-.5-.5-1-.9-1.6-1.2-.4-.3-.8-.4-1.3-.4-.4 0-.8 0-1.1.2-.5.2-.9.6-1.1 1-.2.3-.3.7-.3 1.1 0 .3 0 .6.1.9.1.5.4.9.8 1.2.5.4 1.1.5 1.7.5.5 0 1-.2 1.5-.5.6-.4 1.1-.8 1.6-1.3.1-.3.3-.5.5-.6zM13 12c.5.5 1 1 1.5 1.4.5.5 1.1.9 1.9 1 .4.1.8 0 1.2-.1.3-.1.6-.3.9-.5.4-.4.7-.9.8-1.4.1-.5 0-.9-.1-1.4-.3-.8-.8-1.2-1.7-1.4-.4-.1-.8-.1-1.2 0-.5.1-1 .4-1.4.7-.5.4-1 .8-1.4 1.2-.2.2-.4.3-.5.5z"/></svg></button> <button @click="${({target:e})=>{this._toggleSettings(),e instanceof HTMLElement&&e.focus()}}" @blur="${()=>setTimeout(()=>this._toggleSettings(!1),200)}" aria-label="Settings" aria-haspopup="true" aria-expanded="${!!this._isSettingsOpen}" aria-controls="${`${this._identifier}-settings`}"><svg width="24" height="24" aria-hidden="true" focusable="false"><circle cx="12" cy="5.4" r="2.5"/><circle cx="12" cy="12" r="2.5"/><circle cx="12" cy="18.6" r="2.5"/></svg></button><div id="${`${this._identifier}-settings`}" class="popover" style="display:${this._isSettingsOpen?"block":"none"}">${this._isDotLottie?lit.nothing:lit.html`<button @click="${this.convert}" aria-label="Convert JSON animation to dotLottie format" tabindex="0"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M17.016 17.016v-4.031h1.969v6h-12v3l-3.984-3.984 3.984-3.984v3h10.031zM6.984 6.984v4.031H5.015v-6h12v-3l3.984 3.984-3.984 3.984v-3H6.984z"/></svg> Convert to dotLottie</button>`} <button @click="${this.snapshot}" aria-label="Download still image" tabindex="0"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M16.8 10.8 12 15.6l-4.8-4.8h3V3.6h3.6v7.2h3zM12 15.6H3v4.8h18v-4.8h-9zm7.8 2.4h-2.4v-1.2h2.4V18z"/></svg> Download still image</button></div>`}</div>`}render(){var e,t,r;return lit.html`<figure class="${"animation-container main"}" data-controls="${this.controls}" lang="${this.description?null===(t=document)||void 0===t?void 0:null===(e=t.documentElement)||void 0===e?void 0:e.lang:"en"}" role="img" aria-label="${null!==(r=this.description)&&void 0!==r?r:"Lottie animation"}" data-loaded="${this._playerState.loaded}"><div class="animation" style="background:${this.background}">${this.currentState===exports.PlayerState.Error?lit.html`<div class="error"><svg preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="1920" height="1080" viewBox="0 0 1920 1080"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>`:lit.nothing}</div>${this.controls?this.renderControls():lit.nothing}</figure>`}constructor(...e){super(...e),this.background="transparent",this.controls=!1,this.currentState=exports.PlayerState.Loading,this.direction=1,this.hover=!1,this.intermission=0,this.loop=!1,this.mode=exports.PlayMode.Normal,this.objectfit="contain",this.renderer="svg",this.simple=!1,this.speed=1,this.subframe=!0,this._isSettingsOpen=!1,this._seeker=0,this._currentAnimation=0,this._lottieInstance=null,this._identifier=this.id||useId("dotlottie"),this._errorMessage="Something went wrong",this._isDotLottie=!1,this._playerState={prev:exports.PlayerState.Loading,count:0,loaded:!1}}},_ts_decorate([decorators_js.property({type:Boolean,reflect:!0})],exports.DotLottiePlayer.prototype,"autoplay",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"background",void 0),_ts_decorate([decorators_js.property({type:Boolean,reflect:!0})],exports.DotLottiePlayer.prototype,"controls",void 0),_ts_decorate([decorators_js.property({type:Number})],exports.DotLottiePlayer.prototype,"count",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"currentState",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"description",void 0),_ts_decorate([decorators_js.property({type:Number})],exports.DotLottiePlayer.prototype,"direction",void 0),_ts_decorate([decorators_js.property({type:Boolean})],exports.DotLottiePlayer.prototype,"hover",void 0),_ts_decorate([decorators_js.property({type:Number})],exports.DotLottiePlayer.prototype,"intermission",void 0),_ts_decorate([decorators_js.property({type:Boolean,reflect:!0})],exports.DotLottiePlayer.prototype,"loop",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"mode",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"objectfit",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"preserveAspectRatio",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"renderer",void 0),_ts_decorate([decorators_js.property({type:Array})],exports.DotLottiePlayer.prototype,"segment",void 0),_ts_decorate([decorators_js.property({type:Boolean})],exports.DotLottiePlayer.prototype,"simple",void 0),_ts_decorate([decorators_js.property({type:Number})],exports.DotLottiePlayer.prototype,"speed",void 0),_ts_decorate([decorators_js.property({type:String})],exports.DotLottiePlayer.prototype,"src",void 0),_ts_decorate([decorators_js.property({type:Boolean})],exports.DotLottiePlayer.prototype,"subframe",void 0),_ts_decorate([decorators_js.query(".animation")],exports.DotLottiePlayer.prototype,"container",void 0),_ts_decorate([decorators_js.state()],exports.DotLottiePlayer.prototype,"_isSettingsOpen",void 0),_ts_decorate([decorators_js.state()],exports.DotLottiePlayer.prototype,"_seeker",void 0),_ts_decorate([decorators_js.state()],exports.DotLottiePlayer.prototype,"_currentAnimation",void 0),_ts_decorate([decorators_js.state()],exports.DotLottiePlayer.prototype,"_animations",void 0),exports.DotLottiePlayer=_ts_decorate([decorators_js.customElement("dotlottie-player")],exports.DotLottiePlayer),globalThis.dotLottiePlayer=()=>new exports.DotLottiePlayer;
1
+ 'use strict';
2
+
3
+ var lit = require('lit');
4
+ var decorators_js = require('lit/decorators.js');
5
+ var Lottie = require('lottie-web');
6
+ var fflate = require('fflate');
7
+
8
+ exports.PlayerState = void 0;
9
+ (function(PlayerState) {
10
+ PlayerState["Completed"] = "completed";
11
+ PlayerState["Destroyed"] = "destroyed";
12
+ PlayerState["Error"] = "error";
13
+ PlayerState["Frozen"] = "frozen";
14
+ PlayerState["Loading"] = "loading";
15
+ PlayerState["Paused"] = "paused";
16
+ PlayerState["Playing"] = "playing";
17
+ PlayerState["Stopped"] = "stopped";
18
+ })(exports.PlayerState || (exports.PlayerState = {}));
19
+ exports.PlayMode = void 0;
20
+ (function(PlayMode) {
21
+ PlayMode["Bounce"] = "bounce";
22
+ PlayMode["Normal"] = "normal";
23
+ })(exports.PlayMode || (exports.PlayMode = {}));
24
+ exports.PlayerEvents = void 0;
25
+ (function(PlayerEvents) {
26
+ PlayerEvents["Complete"] = "complete";
27
+ PlayerEvents["Destroyed"] = "destroyed";
28
+ PlayerEvents["Error"] = "error";
29
+ PlayerEvents["Frame"] = "frame";
30
+ PlayerEvents["Freeze"] = "freeze";
31
+ PlayerEvents["Load"] = "load";
32
+ PlayerEvents["Loop"] = "loop";
33
+ PlayerEvents["Pause"] = "pause";
34
+ PlayerEvents["Play"] = "play";
35
+ PlayerEvents["Ready"] = "ready";
36
+ PlayerEvents["Rendered"] = "rendered";
37
+ PlayerEvents["Stop"] = "stop";
38
+ })(exports.PlayerEvents || (exports.PlayerEvents = {}));
39
+ class CustomError extends Error {
40
+ }
41
+
42
+ const addExt = (ext, str)=>{
43
+ if (!str) return;
44
+ if (getExt(str)) {
45
+ if (getExt(str) === ext) return str;
46
+ return `${getFilename(str)}.${ext}`;
47
+ }
48
+ return `${str}.${ext}`;
49
+ }, aspectRatio = (objectFit)=>{
50
+ switch(objectFit){
51
+ case 'contain':
52
+ case 'scale-down':
53
+ return 'xMidYMid meet';
54
+ case 'cover':
55
+ return 'xMidYMid slice';
56
+ case 'fill':
57
+ return 'none';
58
+ case 'none':
59
+ return 'xMinYMin slice';
60
+ default:
61
+ return 'xMidYMid meet';
62
+ }
63
+ }, base64ToU8 = (str)=>{
64
+ const parsedStr = str.substring(str.indexOf(',') + 1);
65
+ return strToU8(isServer() ? Buffer.from(parsedStr, 'base64').toString('binary') : atob(parsedStr));
66
+ }, createDotLottie = async (animations, manifest, filename, triggerDownload = true)=>{
67
+ try {
68
+ if (!animations?.length || !manifest) {
69
+ throw new Error(`Missing or malformed required parameter(s):\n ${!animations?.length ? '- animations\n' : ''} ${!manifest ? '- manifest \n' : ''}`);
70
+ }
71
+ const name = addExt('lottie', filename) || `${useId()}.lottie`, dotlottie = {
72
+ 'manifest.json': [
73
+ strToU8(JSON.stringify(manifest)),
74
+ {
75
+ level: 0
76
+ }
77
+ ]
78
+ };
79
+ for (const [i, animation] of animations.entries()){
80
+ if (animation.assets?.length) {
81
+ for (const asset of animation.assets){
82
+ const { id, p } = asset;
83
+ if (id && p) {
84
+ const ext = getExtFromB64(p);
85
+ asset.p = `${id}.${ext}`;
86
+ asset.e = 0;
87
+ dotlottie[`images/${id}.${ext}`] = [
88
+ base64ToU8(p),
89
+ {
90
+ level: 9
91
+ }
92
+ ];
93
+ }
94
+ }
95
+ }
96
+ dotlottie[`animations/${manifest.animations[i].id}.json`] = [
97
+ strToU8(JSON.stringify(animation)),
98
+ {
99
+ level: 9
100
+ }
101
+ ];
102
+ }
103
+ const buffer = await getArrayBuffer(dotlottie);
104
+ return triggerDownload ? download(buffer, {
105
+ name,
106
+ mimeType: 'application/zip'
107
+ }) : buffer;
108
+ } catch (err) {
109
+ console.error(`❌ ${handleErrors(err).message}`);
110
+ }
111
+ }, download = (data, options)=>{
112
+ const blob = new Blob([
113
+ data
114
+ ], {
115
+ type: options?.mimeType
116
+ }), fileName = options?.name || useId(), dataURL = URL.createObjectURL(blob), link = document.createElement('a');
117
+ link.href = dataURL;
118
+ link.download = fileName;
119
+ link.hidden = true;
120
+ document.body.appendChild(link);
121
+ link.click();
122
+ setTimeout(()=>{
123
+ link.remove();
124
+ URL.revokeObjectURL(dataURL);
125
+ }, 1000);
126
+ }, handleErrors = (err)=>{
127
+ const res = {
128
+ message: 'Unknown error',
129
+ status: isServer() ? 500 : 400
130
+ };
131
+ if (err && typeof err === 'object') {
132
+ if ('message' in err && typeof err.message === 'string') {
133
+ res.message = err.message;
134
+ }
135
+ if ('status' in err) {
136
+ res.status = Number(err.status);
137
+ }
138
+ }
139
+ return res;
140
+ }, frameOutput = (frame)=>{
141
+ return ((frame ?? 0) + 1).toString().padStart(3, '0');
142
+ }, getAnimationData = async (input)=>{
143
+ try {
144
+ if (!input || typeof input !== 'string' && typeof input !== 'object') {
145
+ throw new Error('Broken file or invalid file format');
146
+ }
147
+ if (typeof input !== 'string') {
148
+ const animations = Array.isArray(input) ? input : [
149
+ input
150
+ ];
151
+ return {
152
+ animations,
153
+ manifest: null
154
+ };
155
+ }
156
+ const result = await fetch(input);
157
+ if (!result.ok) {
158
+ const error = new CustomError(result.statusText);
159
+ error.status = result.status;
160
+ throw error;
161
+ }
162
+ const ext = getExt(input);
163
+ if (ext === 'json' || !ext) {
164
+ if (ext) {
165
+ const lottie = await result.json();
166
+ return {
167
+ animations: [
168
+ lottie
169
+ ],
170
+ manifest: null
171
+ };
172
+ }
173
+ const text = await result.clone().text();
174
+ try {
175
+ const lottie = JSON.parse(text);
176
+ return {
177
+ animations: [
178
+ lottie
179
+ ],
180
+ manifest: null
181
+ };
182
+ } catch {}
183
+ }
184
+ const { data, manifest } = await getLottieJSON(result);
185
+ return {
186
+ animations: data,
187
+ manifest,
188
+ isDotLottie: true
189
+ };
190
+ } catch (err) {
191
+ console.error(`❌ ${handleErrors(err).message}`);
192
+ return {
193
+ animations: null,
194
+ manifest: null
195
+ };
196
+ }
197
+ }, getArrayBuffer = async (zippable)=>{
198
+ const arrayBuffer = await new Promise((resolve, reject)=>{
199
+ fflate.zip(zippable, {
200
+ level: 9
201
+ }, (err, data)=>{
202
+ if (err) {
203
+ reject(err);
204
+ return;
205
+ }
206
+ resolve(data.buffer);
207
+ });
208
+ });
209
+ return arrayBuffer;
210
+ }, getExt = (str)=>{
211
+ if (!str || !hasExt(str)) return;
212
+ return str.split('.').pop()?.toLowerCase();
213
+ }, getExtFromB64 = (str)=>{
214
+ const mime = str.split(':')[1].split(';')[0];
215
+ return mime.split('/')[1].split('+')[0];
216
+ }, getFilename = (src, keepExt)=>{
217
+ const ext = getExt(src);
218
+ return `${src.replace(/\.[^.]*$/, '').replace(/\W+/g, '')}${keepExt && ext ? `.${ext}` : ''}`.toLowerCase();
219
+ }, getLottieJSON = async (resp)=>{
220
+ const unzipped = await unzip(resp), manifest = getManifest(unzipped), data = [];
221
+ for (const { id } of manifest.animations){
222
+ const str = fflate.strFromU8(unzipped[`animations/${id}.json`]), lottie = JSON.parse(str);
223
+ await resolveAssets(unzipped, lottie.assets);
224
+ data.push(lottie);
225
+ }
226
+ return {
227
+ data,
228
+ manifest
229
+ };
230
+ }, getManifest = (unzipped)=>{
231
+ const file = fflate.strFromU8(unzipped['manifest.json'], false), manifest = JSON.parse(file);
232
+ if (!('animations' in manifest)) throw new Error('Manifest not found');
233
+ if (!manifest.animations.length) throw new Error('No animations listed in manifest');
234
+ return manifest;
235
+ }, getMimeFromExt = (ext)=>{
236
+ switch(ext){
237
+ case 'svg':
238
+ case 'svg+xml':
239
+ return 'image/svg+xml';
240
+ case 'jpg':
241
+ case 'jpeg':
242
+ return 'image/jpeg';
243
+ case 'png':
244
+ case 'gif':
245
+ case 'webp':
246
+ return `image/${ext}`;
247
+ case 'mp3':
248
+ case 'mpeg':
249
+ case 'wav':
250
+ return `audio/${ext}`;
251
+ default:
252
+ return '';
253
+ }
254
+ }, hasExt = (path)=>{
255
+ const lastDotIndex = path?.split('/').pop()?.lastIndexOf('.');
256
+ return (lastDotIndex ?? 0) > 1 && path && path.length - 1 > (lastDotIndex ?? 0);
257
+ }, isAudio = (asset)=>{
258
+ return !('h' in asset) && !('w' in asset) && 'p' in asset && 'e' in asset && 'u' in asset && 'id' in asset;
259
+ }, isImage = (asset)=>{
260
+ return 'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset;
261
+ }, isServer = ()=>{
262
+ return !(typeof window !== 'undefined' && window.document);
263
+ }, strToU8 = (str)=>{
264
+ const u8 = new Uint8Array(str.length);
265
+ for(let i = 0; i < str.length; i++){
266
+ u8[i] = str.charCodeAt(i);
267
+ }
268
+ return u8;
269
+ }, resolveAssets = async (unzipped, assets)=>{
270
+ if (!Array.isArray(assets)) return;
271
+ const toResolve = [];
272
+ for (const asset of assets){
273
+ if (!isAudio(asset) && !isImage(asset)) continue;
274
+ const type = isImage(asset) ? 'images' : 'audio', u8 = unzipped?.[`${type}/${asset.p}`];
275
+ if (!u8) continue;
276
+ toResolve.push(new Promise((resolveAsset)=>{
277
+ const assetB64 = isServer() ? Buffer.from(u8).toString('base64') : btoa(u8.reduce((dat, byte)=>dat + String.fromCharCode(byte), ''));
278
+ asset.p = `data:${getMimeFromExt(getExt(asset.p))};base64,${assetB64}`;
279
+ asset.e = 1;
280
+ asset.u = '';
281
+ resolveAsset();
282
+ }));
283
+ }
284
+ await Promise.all(toResolve);
285
+ }, unzip = async (resp)=>{
286
+ const u8 = new Uint8Array(await resp.arrayBuffer()), unzipped = await new Promise((resolve, reject)=>{
287
+ fflate.unzip(u8, (err, file)=>{
288
+ if (err) {
289
+ reject(err);
290
+ }
291
+ resolve(file);
292
+ });
293
+ });
294
+ return unzipped;
295
+ }, useId = (prefix)=>{
296
+ const s4 = ()=>{
297
+ return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
298
+ };
299
+ return `${prefix ?? `:${s4()}`}-${s4()}`;
300
+ };
301
+
302
+ var name = "@aarsteinmedia/dotlottie-player";
303
+ var version = "2.1.8";
304
+ var description = "Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";
305
+ var exports$1 = {
306
+ ".": {
307
+ "import": "./dist/esm/index.js",
308
+ node: "./dist/esm/index.js",
309
+ require: "./dist/cjs/index.js",
310
+ types: "./dist/index.d.ts"
311
+ }
312
+ };
313
+ var main = "./dist/esm/index.js";
314
+ var unpkg = "./dist/index.js";
315
+ var module$1 = "./dist/esm/index.js";
316
+ var types = "./dist/index.d.ts";
317
+ var type = "module";
318
+ var homepage = "https://www.aarstein.media/en/dotlottie-player";
319
+ var repository = {
320
+ url: "https://github.com/aarsteinmedia/dotlottie-player.git",
321
+ type: "git"
322
+ };
323
+ var bugs = "https://github.com/aarsteinmedia/dotlottie-player/issues";
324
+ var author = {
325
+ name: "Johan Martin Aarstein",
326
+ email: "johan@aarstein.media",
327
+ url: "https://www.aarstein.media",
328
+ organization: "Aarstein Media"
329
+ };
330
+ var license = "GPL-2.0-or-later";
331
+ var scripts = {
332
+ build: "pnpm cleanup && rollup -c",
333
+ "build:types": "pnpm cleanup:types && tsc",
334
+ "build:cem": "npx cem analyze --config 'cem.config.mjs'",
335
+ prod: "pnpm build:types && pnpm build && pnpm build:cem",
336
+ dev: "pnpm cleanup && rollup -c --watch",
337
+ lint: "tsc && eslint . --ext .ts,.js",
338
+ "lint:fix": "eslint . --ext .ts,.js --fix",
339
+ "cleanup:types": "shx rm -rf types && shx mkdir types",
340
+ cleanup: "shx rm -rf dist && shx mkdir dist"
341
+ };
342
+ var dependencies = {
343
+ fflate: "^0.8.1",
344
+ lit: "^2.8.0",
345
+ "lottie-web": "^5.12.2"
346
+ };
347
+ var peerDependencies = {
348
+ "@types/react": ">= 16.0.0"
349
+ };
350
+ var devDependencies = {
351
+ "@custom-elements-manifest/analyzer": "^0.6.9",
352
+ "@rollup/plugin-commonjs": "^25.0.7",
353
+ "@rollup/plugin-json": "^6.0.1",
354
+ "@rollup/plugin-node-resolve": "^15.2.3",
355
+ "@rollup/plugin-replace": "^5.0.5",
356
+ "@swc/core": "^1.3.99",
357
+ "@types/node": "^20.10.0",
358
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
359
+ "@typescript-eslint/parser": "^5.62.0",
360
+ eslint: "^8.54.0",
361
+ "eslint-plugin-lit": "^1.10.1",
362
+ rollup: "^3.29.4",
363
+ "rollup-plugin-dts": "^6.1.0",
364
+ "rollup-plugin-html-literals": "^1.1.8",
365
+ "rollup-plugin-summary": "^2.0.0",
366
+ "rollup-plugin-swc3": "^0.9.1",
367
+ shx: "^0.3.4",
368
+ "ts-lit-plugin": "^1.2.1",
369
+ typescript: "^5.3.2"
370
+ };
371
+ var customElements = "dist/custom-elements.json";
372
+ var files = [
373
+ "dist",
374
+ "README.md"
375
+ ];
376
+ var keywords = [
377
+ "lottie",
378
+ "dotlottie",
379
+ "animation",
380
+ "web component",
381
+ "component",
382
+ "lit-element",
383
+ "svg",
384
+ "vector",
385
+ "player"
386
+ ];
387
+ var publishConfig = {
388
+ access: "public"
389
+ };
390
+ var engines = {
391
+ node: ">= 7.6.0"
392
+ };
393
+ var funding = {
394
+ type: "paypal",
395
+ url: "https://www.paypal.com/donate/?hosted_button_id=E7C7DMN8KSQ6A"
396
+ };
397
+ var pkg = {
398
+ name: name,
399
+ version: version,
400
+ description: description,
401
+ exports: exports$1,
402
+ main: main,
403
+ unpkg: unpkg,
404
+ module: module$1,
405
+ types: types,
406
+ type: type,
407
+ homepage: homepage,
408
+ repository: repository,
409
+ bugs: bugs,
410
+ author: author,
411
+ license: license,
412
+ scripts: scripts,
413
+ dependencies: dependencies,
414
+ peerDependencies: peerDependencies,
415
+ devDependencies: devDependencies,
416
+ customElements: customElements,
417
+ files: files,
418
+ keywords: keywords,
419
+ publishConfig: publishConfig,
420
+ engines: engines,
421
+ funding: funding
422
+ };
423
+
424
+ var styles = lit.css`*{box-sizing:border-box}:host{--lottie-player-toolbar-height:35px;--lottie-player-toolbar-background-color:#FFF;--lottie-player-toolbar-icon-color:#000;--lottie-player-toolbar-icon-hover-color:#000;--lottie-player-toolbar-icon-active-color:#4285f4;--lottie-player-seeker-track-color:rgba(0, 0, 0, 0.2);--lottie-player-seeker-thumb-color:#4285f4;--lottie-player-seeker-display:block;display:block;width:100%;height:100%}@media (prefers-color-scheme:dark){:host{--lottie-player-toolbar-background-color:#000;--lottie-player-toolbar-icon-color:#FFF;--lottie-player-toolbar-icon-hover-color:#FFF;--lottie-player-seeker-track-color:rgba(255, 255, 255, 0.6)}}.main{display:flex;flex-direction:column;height:100%;width:100%;margin:0}.animation{width:100%;height:100%;display:flex}[data-controls=true] .animation{height:calc(100% - 35px)}.animation-container{position:relative}.popover{position:absolute;right:5px;bottom:40px;background-color:var(--lottie-player-toolbar-background-color);border-radius:5px;padding:10px 15px;border:solid 2px var(--lottie-player-toolbar-icon-color);animation:fadeIn .2s ease-in-out}.popover::before{content:"";right:10px;border:7px solid transparent;border-top-color:transparent;margin-right:-7px;height:0;width:0;position:absolute;pointer-events:none;top:100%;border-top-color:var(--lottie-player-toolbar-icon-color)}.toolbar{display:flex;align-items:center;justify-items:center;background:var(--lottie-player-toolbar-background-color);margin:0;height:35px;padding:5px;border-radius:5px;gap:5px}.toolbar.has-error{pointer-events:none;opacity:.5}.toolbar button{cursor:pointer;fill:var(--lottie-player-toolbar-icon-color);color:var(--lottie-player-toolbar-icon-color);display:flex;background:0 0;border:0;padding:0;outline:0;height:100%;margin:0;align-items:center;gap:5px;opacity:.9}.toolbar button:hover{opacity:1}.toolbar button[data-active=true]{opacity:1;fill:var(--lottie-player-toolbar-icon-active-color)}.toolbar button:disabled{opacity:.5}.toolbar button:focus{outline:0}.toolbar button svg{pointer-events:none}.toolbar button svg>*{fill:inherit}.toolbar button.disabled svg{display:none}.progress-container{position:relative;width:100%}.progress-container.simple{margin-right:12px}.seeker,.seeker::-webkit-slider-runnable-track,.seeker::-webkit-slider-thumb,progress{-webkit-appearance:none;appearance:none;outline:0}.seeker{width:100%;height:20px;border-radius:3px;border:0;cursor:pointer;background-color:transparent;display:var(--lottie-player-seeker-display);color:var(--lottie-player-seeker-thumb-color);margin:0;padding:7.5px 0;position:relative;z-index:1}progress{position:absolute;width:100%;height:5px;border-radius:3px;border:0;top:0;left:0;margin:7.5px 0;background-color:var(--lottie-player-seeker-track-color);pointer-events:none}::-moz-progress-bar{background-color:var(--lottie-player-seeker-thumb-color)}::-webkit-progress-inner-element{border-radius:3px;overflow:hidden}::-webkit-slider-runnable-track{background-color:transparent}::-webkit-progress-value{background-color:var(--lottie-player-seeker-thumb-color)}.seeker::-webkit-slider-thumb{height:15px;width:15px;border-radius:50%;border:0;background-color:var(--lottie-player-seeker-thumb-color);cursor:pointer;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-webkit-slider-thumb,.seeker:hover::-webkit-slider-thumb{transform:scale(1)}.seeker::-moz-range-progress{background-color:var(--lottie-player-seeker-thumb-color);height:5px;border-radius:3px}.seeker::-moz-range-thumb{height:15px;width:15px;border-radius:50%;background-color:var(--lottie-player-seeker-thumb-color);border:0;cursor:pointer;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-moz-range-thumb,.seeker:hover::-moz-range-thumb{transform:scale(1)}.seeker::-ms-track{width:100%;height:5px;cursor:pointer;background:0 0;border-color:transparent;color:transparent}.seeker::-ms-fill-upper{background:var(--lottie-player-seeker-track-color);border-radius:3px}.seeker::-ms-fill-lower{background-color:var(--lottie-player-seeker-thumb-color);border-radius:3px}.seeker::-ms-thumb{border:0;height:15px;width:15px;border-radius:50%;background:var(--lottie-player-seeker-thumb-color);cursor:pointer;transition:transform .2s ease-in-out;transform:scale(0)}.seeker:focus::-ms-thumb,.seeker:hover::-ms-thumb{transform:scale(1)}.seeker:focus::-ms-fill-lower{background:var(--lottie-player-seeker-track-color)}.seeker:focus::-ms-fill-upper{background:var(--lottie-player-seeker-track-color)}.error{display:flex;margin:auto;justify-content:center;height:100%;align-items:center}.error svg{width:100%;height:auto}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}`;
425
+
426
+ function _ts_decorate(decorators, target, key, desc) {
427
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
428
+ if (typeof Reflect === "object" && typeof undefined === "function") r = undefined(decorators, target, key, desc);
429
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
430
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
431
+ }
432
+ class DotLottiePlayer extends lit.LitElement {
433
+ _getOptions() {
434
+ const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)), initialSegment = !this.segment || this.segment.some((val)=>val < 0) ? undefined : this.segment.every((val)=>val > 0) ? [
435
+ this.segment[0] - 1,
436
+ this.segment[1] - 1
437
+ ] : this.segment, options = {
438
+ container: this.container,
439
+ loop: !!this.loop,
440
+ autoplay: !!this.autoplay,
441
+ renderer: this.renderer,
442
+ initialSegment,
443
+ rendererSettings: {
444
+ imagePreserveAspectRatio: preserveAspectRatio
445
+ }
446
+ };
447
+ switch(this.renderer){
448
+ case 'svg':
449
+ options.rendererSettings = {
450
+ ...options.rendererSettings,
451
+ hideOnTransparent: true,
452
+ preserveAspectRatio,
453
+ progressiveLoad: true
454
+ };
455
+ break;
456
+ case 'canvas':
457
+ options.rendererSettings = {
458
+ ...options.rendererSettings,
459
+ clearCanvas: true,
460
+ preserveAspectRatio,
461
+ progressiveLoad: true
462
+ };
463
+ break;
464
+ case 'html':
465
+ options.rendererSettings = {
466
+ ...options.rendererSettings,
467
+ hideOnTransparent: true
468
+ };
469
+ }
470
+ return options;
471
+ }
472
+ async load(src) {
473
+ if (!this.shadowRoot) return;
474
+ try {
475
+ const { animations, manifest, isDotLottie } = await getAnimationData(src);
476
+ if (!animations || animations.some((animation)=>!this._isLottie(animation))) {
477
+ throw new Error('Broken or corrupted file');
478
+ }
479
+ this._isDotLottie = !!isDotLottie;
480
+ this._animations = animations;
481
+ this._manifest = manifest ?? {
482
+ animations: [
483
+ {
484
+ id: useId(),
485
+ autoplay: this.autoplay,
486
+ loop: this.loop,
487
+ direction: this.direction,
488
+ mode: this.mode,
489
+ speed: this.speed
490
+ }
491
+ ]
492
+ };
493
+ if (this._lottieInstance) this._lottieInstance.destroy();
494
+ this._lottieInstance = Lottie.loadAnimation({
495
+ ...this._getOptions(),
496
+ animationData: animations[this._currentAnimation]
497
+ });
498
+ } catch (err) {
499
+ this._errorMessage = handleErrors(err).message;
500
+ this.currentState = exports.PlayerState.Error;
501
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Error));
502
+ return;
503
+ }
504
+ this._addEventListeners();
505
+ this.setSpeed(this.speed);
506
+ this.setDirection(this.direction ?? 1);
507
+ this.setSubframe(!!this.subframe);
508
+ if (this.autoplay) {
509
+ if (this.direction === -1) this.seek('99%');
510
+ this.play();
511
+ }
512
+ }
513
+ getManifest() {
514
+ return this._manifest;
515
+ }
516
+ _addEventListeners() {
517
+ if (!this._lottieInstance) return;
518
+ this._lottieInstance.addEventListener('enterFrame', ()=>{
519
+ if (this._lottieInstance) {
520
+ const { currentFrame, totalFrames } = this._lottieInstance;
521
+ this._seeker = Math.floor(currentFrame / totalFrames * 100);
522
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Frame, {
523
+ detail: {
524
+ frame: currentFrame,
525
+ seeker: this._seeker
526
+ }
527
+ }));
528
+ }
529
+ });
530
+ this._lottieInstance.addEventListener('complete', ()=>{
531
+ this.currentState = exports.PlayerState.Completed;
532
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Complete));
533
+ if (this._animations?.length > 1 && this.autoplay && this._currentAnimation < this._animations?.length - 1) {
534
+ this.next();
535
+ }
536
+ });
537
+ const loopComplete = ()=>{
538
+ if (!this._lottieInstance) {
539
+ return;
540
+ }
541
+ const { firstFrame, totalFrames, playDirection } = this._lottieInstance;
542
+ if (this.count) {
543
+ this.mode === exports.PlayMode.Bounce ? this._playerState.count += 1 : this._playerState.count += 0.5;
544
+ if (this._playerState.count >= this.count) {
545
+ this.setLooping(false);
546
+ this.currentState = exports.PlayerState.Completed;
547
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Complete));
548
+ return;
549
+ }
550
+ }
551
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Loop));
552
+ if (this.mode === exports.PlayMode.Bounce) {
553
+ this._lottieInstance?.goToAndStop(playDirection === -1 ? firstFrame : totalFrames * 0.99, true);
554
+ this._lottieInstance?.setDirection(playDirection * -1);
555
+ return setTimeout(()=>{
556
+ this._lottieInstance?.play();
557
+ }, this.intermission);
558
+ }
559
+ this._lottieInstance?.goToAndStop(playDirection === -1 ? totalFrames * 0.99 : firstFrame, true);
560
+ return setTimeout(()=>{
561
+ this._lottieInstance?.play();
562
+ }, this.intermission);
563
+ };
564
+ this._lottieInstance.addEventListener('loopComplete', loopComplete);
565
+ this._lottieInstance.addEventListener('DOMLoaded', ()=>{
566
+ this._playerState.loaded = true;
567
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Ready));
568
+ });
569
+ this._lottieInstance.addEventListener('data_ready', ()=>{
570
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Load));
571
+ });
572
+ this._lottieInstance.addEventListener('data_failed', ()=>{
573
+ this.currentState = exports.PlayerState.Error;
574
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Error));
575
+ });
576
+ if (this.container) {
577
+ this.container.addEventListener('mouseenter', ()=>{
578
+ if (this.hover && this.currentState !== exports.PlayerState.Playing) {
579
+ this.play();
580
+ }
581
+ });
582
+ this.container.addEventListener('mouseleave', ()=>{
583
+ if (this.hover && this.currentState === exports.PlayerState.Playing) {
584
+ this.stop();
585
+ }
586
+ });
587
+ }
588
+ }
589
+ _onVisibilityChange() {
590
+ if (document.hidden && this.currentState === exports.PlayerState.Playing) {
591
+ this._freeze();
592
+ } else if (this.currentState === exports.PlayerState.Frozen) {
593
+ this.play();
594
+ }
595
+ }
596
+ _handleSeekChange({ target }) {
597
+ if (!(target instanceof HTMLInputElement) || !this._lottieInstance || isNaN(Number(target.value))) return;
598
+ this.seek(Math.floor(Number(target.value) / 100 * this._lottieInstance.totalFrames));
599
+ setTimeout(()=>{
600
+ if (target.parentElement instanceof HTMLFormElement) {
601
+ target.parentElement.reset();
602
+ }
603
+ }, 100);
604
+ }
605
+ _isLottie(json) {
606
+ const mandatory = [
607
+ 'v',
608
+ 'ip',
609
+ 'op',
610
+ 'layers',
611
+ 'fr',
612
+ 'w',
613
+ 'h'
614
+ ];
615
+ return mandatory.every((field)=>Object.prototype.hasOwnProperty.call(json, field));
616
+ }
617
+ async addAnimation(configs, fileName, triggerDownload = true) {
618
+ try {
619
+ const oldManifest = this._manifest || {
620
+ animations: []
621
+ };
622
+ let manifest = {
623
+ ...oldManifest,
624
+ generator: pkg.name
625
+ }, animations = this._animations || [];
626
+ for (const config of configs){
627
+ const { url } = config, { animations: animationsToAdd } = await getAnimationData(url);
628
+ if (!animationsToAdd) {
629
+ throw new Error('No animation loaded');
630
+ }
631
+ if (manifest.animations.some(({ id })=>id === config.id)) {
632
+ throw new Error('Duplicate id for animation');
633
+ }
634
+ manifest = {
635
+ ...manifest,
636
+ animations: [
637
+ ...manifest.animations,
638
+ config
639
+ ]
640
+ };
641
+ animations = [
642
+ ...animations,
643
+ ...animationsToAdd
644
+ ];
645
+ }
646
+ return createDotLottie(animations, manifest, fileName, triggerDownload);
647
+ } catch (err) {
648
+ console.error(handleErrors(err).message);
649
+ }
650
+ }
651
+ getLottie() {
652
+ return this._lottieInstance;
653
+ }
654
+ play() {
655
+ if (!this._lottieInstance) return;
656
+ if (this.currentState) {
657
+ this._playerState.prev = this.currentState;
658
+ }
659
+ this._lottieInstance.play();
660
+ setTimeout(()=>{
661
+ this.currentState = exports.PlayerState.Playing;
662
+ }, 0);
663
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Play));
664
+ }
665
+ pause() {
666
+ if (!this._lottieInstance) return;
667
+ if (this.currentState) {
668
+ this._playerState.prev = this.currentState;
669
+ }
670
+ this._lottieInstance.pause();
671
+ setTimeout(()=>{
672
+ this.currentState = exports.PlayerState.Paused;
673
+ }, 0);
674
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Pause));
675
+ }
676
+ stop() {
677
+ if (!this._lottieInstance) return;
678
+ if (this.currentState) {
679
+ this._playerState.prev = this.currentState;
680
+ }
681
+ this._playerState.count = 0;
682
+ this._lottieInstance.stop();
683
+ setTimeout(()=>{
684
+ this.currentState = exports.PlayerState.Stopped;
685
+ }, 0);
686
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Stop));
687
+ }
688
+ destroy() {
689
+ if (!this._lottieInstance) return;
690
+ this.currentState = exports.PlayerState.Destroyed;
691
+ this._lottieInstance.destroy();
692
+ this._lottieInstance = null;
693
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Destroyed));
694
+ this.remove();
695
+ }
696
+ seek(value) {
697
+ if (!this._lottieInstance) return;
698
+ const matches = value.toString().match(/^([0-9]+)(%?)$/);
699
+ if (!matches) {
700
+ return;
701
+ }
702
+ const frame = Math.floor(matches[2] === '%' ? this._lottieInstance.totalFrames * Number(matches[1]) / 100 : Number(matches[1]));
703
+ this._seeker = frame;
704
+ if (this.currentState === exports.PlayerState.Playing || this.currentState === exports.PlayerState.Frozen && this._playerState.prev === exports.PlayerState.Playing) {
705
+ this._lottieInstance.goToAndPlay(frame, true);
706
+ this.currentState = exports.PlayerState.Playing;
707
+ } else {
708
+ this._lottieInstance.goToAndStop(frame, true);
709
+ this._lottieInstance.pause();
710
+ }
711
+ }
712
+ snapshot() {
713
+ if (!this.shadowRoot) return;
714
+ const svgElement = this.shadowRoot.querySelector('.animation svg'), data = svgElement instanceof Node ? new XMLSerializer().serializeToString(svgElement) : null;
715
+ if (!data) {
716
+ console.error('Could not serialize data');
717
+ return;
718
+ }
719
+ download(data, {
720
+ name: `${getFilename(this.src)}-${frameOutput(this._seeker)}.svg`,
721
+ mimeType: 'image/svg+xml'
722
+ });
723
+ return data;
724
+ }
725
+ setSubframe(value) {
726
+ if (!this._lottieInstance) return;
727
+ this.subframe = value;
728
+ this._lottieInstance.setSubframe(value);
729
+ }
730
+ _freeze() {
731
+ if (!this._lottieInstance) return;
732
+ if (this.currentState) {
733
+ this._playerState.prev = this.currentState;
734
+ }
735
+ this._lottieInstance.pause();
736
+ setTimeout(()=>{
737
+ this.currentState = exports.PlayerState.Frozen;
738
+ }, 0);
739
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Freeze));
740
+ }
741
+ async reload() {
742
+ if (!this._lottieInstance) return;
743
+ this._lottieInstance.destroy();
744
+ if (this.src) {
745
+ await this.load(this.src);
746
+ }
747
+ }
748
+ setSpeed(value = 1) {
749
+ if (!this._lottieInstance) return;
750
+ this.speed = value;
751
+ this._lottieInstance.setSpeed(value);
752
+ }
753
+ setDirection(value) {
754
+ if (!this._lottieInstance) return;
755
+ this.direction = value;
756
+ this._lottieInstance.setDirection(value);
757
+ }
758
+ setLooping(value) {
759
+ if (this._lottieInstance) {
760
+ this.loop = value;
761
+ this._lottieInstance.setLoop(value);
762
+ }
763
+ }
764
+ togglePlay() {
765
+ if (!this._lottieInstance) return;
766
+ const { currentFrame, playDirection, totalFrames } = this._lottieInstance;
767
+ if (this.currentState === exports.PlayerState.Playing) {
768
+ return this.pause();
769
+ }
770
+ if (this.currentState === exports.PlayerState.Completed) {
771
+ this.currentState = exports.PlayerState.Playing;
772
+ if (this.mode === exports.PlayMode.Bounce) {
773
+ this.setDirection(playDirection * -1);
774
+ return this._lottieInstance.goToAndPlay(currentFrame, true);
775
+ }
776
+ if (playDirection === -1) {
777
+ return this._lottieInstance.goToAndPlay(totalFrames, true);
778
+ }
779
+ return this._lottieInstance.goToAndPlay(0, true);
780
+ }
781
+ return this.play();
782
+ }
783
+ toggleLooping() {
784
+ this.setLooping(!this.loop);
785
+ }
786
+ toggleBoomerang() {
787
+ if (this.mode === exports.PlayMode.Normal) {
788
+ this.mode = exports.PlayMode.Bounce;
789
+ } else {
790
+ this.mode = exports.PlayMode.Normal;
791
+ }
792
+ }
793
+ _toggleSettings(flag) {
794
+ if (flag === undefined) {
795
+ this._isSettingsOpen = !this._isSettingsOpen;
796
+ } else {
797
+ this._isSettingsOpen = flag;
798
+ }
799
+ }
800
+ _handleBlur() {
801
+ setTimeout(()=>this._toggleSettings(false), 200);
802
+ }
803
+ _switchInstance() {
804
+ if (this._lottieInstance) this._lottieInstance.destroy();
805
+ this._lottieInstance = Lottie.loadAnimation({
806
+ ...this._getOptions(),
807
+ animationData: this._animations[this._currentAnimation]
808
+ });
809
+ this._addEventListeners();
810
+ if (this.autoplay) {
811
+ this._lottieInstance?.goToAndPlay(0, true);
812
+ this.currentState = exports.PlayerState.Playing;
813
+ } else {
814
+ this._lottieInstance?.goToAndStop(0, true);
815
+ }
816
+ }
817
+ next() {
818
+ this._currentAnimation++;
819
+ this._switchInstance();
820
+ }
821
+ prev() {
822
+ this._currentAnimation--;
823
+ this._switchInstance();
824
+ }
825
+ convert(typeCheck, manifest, animations, fileName, download = true) {
826
+ if (typeCheck || this._isDotLottie) return;
827
+ const oldManifest = manifest || this._manifest, newManifest = {
828
+ ...oldManifest,
829
+ generator: pkg.name
830
+ };
831
+ return createDotLottie(animations || this._animations, newManifest, `${getFilename(fileName || this.src)}.lottie`, download);
832
+ }
833
+ static get styles() {
834
+ return styles;
835
+ }
836
+ connectedCallback() {
837
+ super.connectedCallback();
838
+ if (typeof document.hidden !== 'undefined') {
839
+ document.addEventListener('visibilitychange', this._onVisibilityChange);
840
+ }
841
+ }
842
+ async firstUpdated() {
843
+ if ('IntersectionObserver' in window) {
844
+ this._intersectionObserver = new IntersectionObserver((entries)=>{
845
+ if (entries[0].isIntersecting) {
846
+ if (!document.hidden && this.currentState === exports.PlayerState.Frozen) {
847
+ this.play();
848
+ }
849
+ } else if (this.currentState === exports.PlayerState.Playing) {
850
+ this._freeze();
851
+ }
852
+ });
853
+ this._intersectionObserver.observe(this.container);
854
+ }
855
+ if (this.src) {
856
+ await this.load(this.src);
857
+ }
858
+ this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Rendered));
859
+ }
860
+ disconnectedCallback() {
861
+ super.disconnectedCallback();
862
+ if (this._intersectionObserver) {
863
+ this._intersectionObserver.disconnect();
864
+ this._intersectionObserver = undefined;
865
+ }
866
+ if (this._lottieInstance) this._lottieInstance.destroy();
867
+ document.removeEventListener('visibilitychange', this._onVisibilityChange);
868
+ }
869
+ renderControls() {
870
+ const isPlaying = this.currentState === exports.PlayerState.Playing, isPaused = this.currentState === exports.PlayerState.Paused, isStopped = this.currentState === exports.PlayerState.Stopped, isError = this.currentState === exports.PlayerState.Error;
871
+ return lit.html`<div class="${`lottie-controls toolbar ${isError ? 'has-error' : ''}`}" aria-label="Lottie Animation controls"><button @click="${this.togglePlay}" data-active="${isPlaying || isPaused}" tabindex="0" aria-label="Toggle Play/Pause">${isPlaying ? lit.html`<svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M14.016 5.016H18v13.969h-3.984V5.016zM6 18.984V5.015h3.984v13.969H6z"/></svg>` : lit.html`<svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M8.016 5.016L18.985 12 8.016 18.984V5.015z"/></svg>`}</button> <button @click="${this.stop}" data-active="${isStopped}" tabindex="0" aria-label="Stop"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M6 6h12v12H6V6z"/></svg></button> ${this._animations?.length > 1 ? lit.html`${this._currentAnimation > 0 ? lit.html`<button @click="${this.prev}" tabindex="0" aria-label="Previous animation"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M17.9 18.2 8.1 12l9.8-6.2v12.4zm-10.3 0H6.1V5.8h1.5v12.4z"/></svg></button>` : lit.nothing} ${this._currentAnimation + 1 < this._animations?.length ? lit.html`<button @click="${this.next}" tabindex="0" aria-label="Next animation"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="m6.1 5.8 9.8 6.2-9.8 6.2V5.8zM16.4 5.8h1.5v12.4h-1.5z"/></svg></button>` : lit.nothing}` : lit.nothing}<form class="progress-container${this.simple ? ' simple' : ''}"><input class="seeker" type="range" min="0" max="100" step="1" value="${this._seeker}" @change="${this._handleSeekChange}" @mousedown="${this._freeze}" aria-valuemin="0" aria-valuemax="100" role="slider" aria-valuenow="${this._seeker}" tabindex="0" aria-label="Slider for search"><progress max="100" value="${this._seeker}"></progress></form>${this.simple ? lit.nothing : lit.html`<button @click="${this.toggleLooping}" data-active="${this.loop ?? lit.nothing}" tabindex="0" aria-label="Toggle looping"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M17.016 17.016v-4.031h1.969v6h-12v3l-3.984-3.984 3.984-3.984v3h10.031zM6.984 6.984v4.031H5.015v-6h12v-3l3.984 3.984-3.984 3.984v-3H6.984z"/></svg></button> <button @click="${this.toggleBoomerang}" data-active="${this.mode === exports.PlayMode.Bounce}" aria-label="Toggle boomerang" tabindex="0"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="m11.8 13.2-.3.3c-.5.5-1.1 1.1-1.7 1.5-.5.4-1 .6-1.5.8-.5.2-1.1.3-1.6.3s-1-.1-1.5-.3c-.6-.2-1-.5-1.4-1-.5-.6-.8-1.2-.9-1.9-.2-.9-.1-1.8.3-2.6.3-.7.8-1.2 1.3-1.6.3-.2.6-.4 1-.5.2-.2.5-.2.8-.3.3 0 .7-.1 1 0 .3 0 .6.1.9.2.9.3 1.7.9 2.4 1.5.4.4.8.7 1.1 1.1l.1.1.4-.4c.6-.6 1.2-1.2 1.9-1.6.5-.3 1-.6 1.5-.7.4-.1.7-.2 1-.2h.9c1 .1 1.9.5 2.6 1.4.4.5.7 1.1.8 1.8.2.9.1 1.7-.2 2.5-.4.9-1 1.5-1.8 2-.4.2-.7.4-1.1.4-.4.1-.8.1-1.2.1-.5 0-.9-.1-1.3-.3-.8-.3-1.5-.9-2.1-1.5-.4-.4-.8-.7-1.1-1.1h-.3zm-1.1-1.1c-.1-.1-.1-.1 0 0-.3-.3-.6-.6-.8-.9-.5-.5-1-.9-1.6-1.2-.4-.3-.8-.4-1.3-.4-.4 0-.8 0-1.1.2-.5.2-.9.6-1.1 1-.2.3-.3.7-.3 1.1 0 .3 0 .6.1.9.1.5.4.9.8 1.2.5.4 1.1.5 1.7.5.5 0 1-.2 1.5-.5.6-.4 1.1-.8 1.6-1.3.1-.3.3-.5.5-.6zM13 12c.5.5 1 1 1.5 1.4.5.5 1.1.9 1.9 1 .4.1.8 0 1.2-.1.3-.1.6-.3.9-.5.4-.4.7-.9.8-1.4.1-.5 0-.9-.1-1.4-.3-.8-.8-1.2-1.7-1.4-.4-.1-.8-.1-1.2 0-.5.1-1 .4-1.4.7-.5.4-1 .8-1.4 1.2-.2.2-.4.3-.5.5z"/></svg></button> <button @click="${this._handleSettingsClick}" @blur="${this._handleBlur}" aria-label="Settings" aria-haspopup="true" aria-expanded="${!!this._isSettingsOpen}" aria-controls="${`${this._identifier}-settings`}"><svg width="24" height="24" aria-hidden="true" focusable="false"><circle cx="12" cy="5.4" r="2.5"/><circle cx="12" cy="12" r="2.5"/><circle cx="12" cy="18.6" r="2.5"/></svg></button><div id="${`${this._identifier}-settings`}" class="popover" style="display:${this._isSettingsOpen ? 'block' : 'none'}">${this._isDotLottie ? lit.nothing : lit.html`<button @click="${this.convert}" aria-label="Convert JSON animation to dotLottie format" tabindex="0"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M17.016 17.016v-4.031h1.969v6h-12v3l-3.984-3.984 3.984-3.984v3h10.031zM6.984 6.984v4.031H5.015v-6h12v-3l3.984 3.984-3.984 3.984v-3H6.984z"/></svg> Convert to dotLottie</button>`} <button @click="${this.snapshot}" aria-label="Download still image" tabindex="0"><svg width="24" height="24" aria-hidden="true" focusable="false"><path d="M16.8 10.8 12 15.6l-4.8-4.8h3V3.6h3.6v7.2h3zM12 15.6H3v4.8h18v-4.8h-9zm7.8 2.4h-2.4v-1.2h2.4V18z"/></svg> Download still image</button></div>`}</div>`;
872
+ }
873
+ render() {
874
+ return lit.html`<figure class="${'animation-container main'}" data-controls="${this.controls ?? lit.nothing}" lang="${this.description ? document?.documentElement?.lang : 'en'}" role="img" aria-label="${this.description ?? 'Lottie animation'}" data-loaded="${this._playerState.loaded}"><div class="animation" style="background:${this.background}">${this.currentState === exports.PlayerState.Error ? lit.html`<div class="error"><svg preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="1920" height="1080" viewBox="0 0 1920 1080"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>` : lit.nothing}</div>${this.controls ? this.renderControls() : lit.nothing}</figure>`;
875
+ }
876
+ constructor(...args){
877
+ super(...args);
878
+ this.background = 'transparent';
879
+ this.controls = false;
880
+ this.currentState = exports.PlayerState.Loading;
881
+ this.direction = 1;
882
+ this.hover = false;
883
+ this.intermission = 0;
884
+ this.loop = false;
885
+ this.mode = exports.PlayMode.Normal;
886
+ this.objectfit = 'contain';
887
+ this.renderer = 'svg';
888
+ this.simple = false;
889
+ this.speed = 1;
890
+ this.subframe = true;
891
+ this._isSettingsOpen = false;
892
+ this._seeker = 0;
893
+ this._currentAnimation = 0;
894
+ this._lottieInstance = null;
895
+ this._identifier = this.id || useId('dotlottie');
896
+ this._errorMessage = 'Something went wrong';
897
+ this._isDotLottie = false;
898
+ this._playerState = {
899
+ prev: exports.PlayerState.Loading,
900
+ count: 0,
901
+ loaded: false
902
+ };
903
+ this._handleSettingsClick = ({ target })=>{
904
+ this._toggleSettings();
905
+ if (target instanceof HTMLElement) {
906
+ target.focus();
907
+ }
908
+ };
909
+ }
910
+ }
911
+ _ts_decorate([
912
+ decorators_js.property({
913
+ type: Boolean,
914
+ reflect: true
915
+ })
916
+ ], DotLottiePlayer.prototype, "autoplay", void 0);
917
+ _ts_decorate([
918
+ decorators_js.property({
919
+ type: String
920
+ })
921
+ ], DotLottiePlayer.prototype, "background", void 0);
922
+ _ts_decorate([
923
+ decorators_js.property({
924
+ type: Boolean,
925
+ reflect: true
926
+ })
927
+ ], DotLottiePlayer.prototype, "controls", void 0);
928
+ _ts_decorate([
929
+ decorators_js.property({
930
+ type: Number
931
+ })
932
+ ], DotLottiePlayer.prototype, "count", void 0);
933
+ _ts_decorate([
934
+ decorators_js.property({
935
+ type: String
936
+ })
937
+ ], DotLottiePlayer.prototype, "currentState", void 0);
938
+ _ts_decorate([
939
+ decorators_js.property({
940
+ type: String
941
+ })
942
+ ], DotLottiePlayer.prototype, "description", void 0);
943
+ _ts_decorate([
944
+ decorators_js.property({
945
+ type: Number
946
+ })
947
+ ], DotLottiePlayer.prototype, "direction", void 0);
948
+ _ts_decorate([
949
+ decorators_js.property({
950
+ type: Boolean
951
+ })
952
+ ], DotLottiePlayer.prototype, "hover", void 0);
953
+ _ts_decorate([
954
+ decorators_js.property({
955
+ type: Number
956
+ })
957
+ ], DotLottiePlayer.prototype, "intermission", void 0);
958
+ _ts_decorate([
959
+ decorators_js.property({
960
+ type: Boolean,
961
+ reflect: true
962
+ })
963
+ ], DotLottiePlayer.prototype, "loop", void 0);
964
+ _ts_decorate([
965
+ decorators_js.property({
966
+ type: String
967
+ })
968
+ ], DotLottiePlayer.prototype, "mode", void 0);
969
+ _ts_decorate([
970
+ decorators_js.property({
971
+ type: String
972
+ })
973
+ ], DotLottiePlayer.prototype, "objectfit", void 0);
974
+ _ts_decorate([
975
+ decorators_js.property({
976
+ type: String
977
+ })
978
+ ], DotLottiePlayer.prototype, "preserveAspectRatio", void 0);
979
+ _ts_decorate([
980
+ decorators_js.property({
981
+ type: String
982
+ })
983
+ ], DotLottiePlayer.prototype, "renderer", void 0);
984
+ _ts_decorate([
985
+ decorators_js.property({
986
+ type: Array
987
+ })
988
+ ], DotLottiePlayer.prototype, "segment", void 0);
989
+ _ts_decorate([
990
+ decorators_js.property({
991
+ type: Boolean
992
+ })
993
+ ], DotLottiePlayer.prototype, "simple", void 0);
994
+ _ts_decorate([
995
+ decorators_js.property({
996
+ type: Number
997
+ })
998
+ ], DotLottiePlayer.prototype, "speed", void 0);
999
+ _ts_decorate([
1000
+ decorators_js.property({
1001
+ type: String
1002
+ })
1003
+ ], DotLottiePlayer.prototype, "src", void 0);
1004
+ _ts_decorate([
1005
+ decorators_js.property({
1006
+ type: Boolean
1007
+ })
1008
+ ], DotLottiePlayer.prototype, "subframe", void 0);
1009
+ _ts_decorate([
1010
+ decorators_js.query('.animation')
1011
+ ], DotLottiePlayer.prototype, "container", void 0);
1012
+ _ts_decorate([
1013
+ decorators_js.state()
1014
+ ], DotLottiePlayer.prototype, "_isSettingsOpen", void 0);
1015
+ _ts_decorate([
1016
+ decorators_js.state()
1017
+ ], DotLottiePlayer.prototype, "_seeker", void 0);
1018
+ _ts_decorate([
1019
+ decorators_js.state()
1020
+ ], DotLottiePlayer.prototype, "_currentAnimation", void 0);
1021
+ _ts_decorate([
1022
+ decorators_js.state()
1023
+ ], DotLottiePlayer.prototype, "_animations", void 0);
1024
+ DotLottiePlayer = _ts_decorate([
1025
+ decorators_js.customElement('dotlottie-player')
1026
+ ], DotLottiePlayer);
1027
+
1028
+ globalThis.dotLottiePlayer = ()=>new DotLottiePlayer();
1029
+
1030
+ exports.DotLottiePlayer = DotLottiePlayer;