This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
mfunsAdvanceDanmaku.js
2 lines (2 loc) · 33.7 KB
/
mfunsAdvanceDanmaku.js
1
2
(()=>{"use strict";var t={705:t=>{t.exports=function(t){var n=[];return n.toString=function(){return this.map((function(n){var e=t(n);return n[2]?"@media ".concat(n[2]," {").concat(e,"}"):e})).join("")},n.i=function(t,e,r){"string"==typeof t&&(t=[[null,t,""]]);var i={};if(r)for(var o=0;o<this.length;o++){var a=this[o][0];null!=a&&(i[a]=!0)}for(var s=0;s<t.length;s++){var u=[].concat(t[s]);r&&i[u[0]]||(e&&(u[2]?u[2]="".concat(e," and ").concat(u[2]):u[2]=e),n.push(u))}},n}},880:t=>{function n(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}t.exports=function(t){var e,r,i=(r=4,function(t){if(Array.isArray(t))return t}(e=t)||function(t,n){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var e=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return e}}(e,r)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=i[1],a=i[3];if("function"==typeof btoa){var s=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),c="/*# ".concat(u," */"),l=a.sources.map((function(t){return"/*# sourceURL=".concat(a.sourceRoot||"").concat(t," */")}));return[o].concat(l).concat([c]).join("\n")}return[o].join("\n")}},945:(t,n,e)=>{e.d(n,{Z:()=>s});var r=e(880),i=e.n(r),o=e(705),a=e.n(o)()(i());a.push([t.id,".danmaku-containers{\n position: relative;\n}\n.danmaku-containers *{\n box-sizing: border-box;\n transform-style: preserve-3d;\n margin: 0;\n padding: 0;\n font-size: 40px;\n image-rendering: pixelated; /* 小图片放大后像素不虚化 */\n image-rendering: -moz-crisp-edges;\n}\n.danmaku-containers .stage{\n position: absolute;\n overflow: hidden;\n perspective:1000px;\n transform-style: preserve-3d;\n}\n.danmaku-containers-debug *{\n outline: 1px solid red;\n}\n\n","",{version:3,sources:["webpack://./src/css/base.css"],names:[],mappings:"AAAA;IACI,kBAAkB;AACtB;AACA;IACI,sBAAsB;IACtB,4BAA4B;IAC5B,SAAS;IACT,UAAU;IACV,eAAe;IACf,0BAA0B,EAAE,gBAAgB;IAC5C,iCAAiC;AACrC;AACA;IACI,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,4BAA4B;AAChC;AACA;IACI,sBAAsB;AAC1B",sourcesContent:[".danmaku-containers{\n position: relative;\n}\n.danmaku-containers *{\n box-sizing: border-box;\n transform-style: preserve-3d;\n margin: 0;\n padding: 0;\n font-size: 40px;\n image-rendering: pixelated; /* 小图片放大后像素不虚化 */\n image-rendering: -moz-crisp-edges;\n}\n.danmaku-containers .stage{\n position: absolute;\n overflow: hidden;\n perspective:1000px;\n transform-style: preserve-3d;\n}\n.danmaku-containers-debug *{\n outline: 1px solid red;\n}\n\n"],sourceRoot:""}]);const s=a},379:(t,n,e)=>{var r,i=function(){var t={};return function(n){if(void 0===t[n]){var e=document.querySelector(n);if(window.HTMLIFrameElement&&e instanceof window.HTMLIFrameElement)try{e=e.contentDocument.head}catch(t){e=null}t[n]=e}return t[n]}}(),o=[];function a(t){for(var n=-1,e=0;e<o.length;e++)if(o[e].identifier===t){n=e;break}return n}function s(t,n){for(var e={},r=[],i=0;i<t.length;i++){var s=t[i],u=n.base?s[0]+n.base:s[0],c=e[u]||0,l="".concat(u," ").concat(c);e[u]=c+1;var p=a(l),h={css:s[1],media:s[2],sourceMap:s[3]};-1!==p?(o[p].references++,o[p].updater(h)):o.push({identifier:l,updater:d(h,n),references:1}),r.push(l)}return r}function u(t){var n=document.createElement("style"),r=t.attributes||{};if(void 0===r.nonce){var o=e.nc;o&&(r.nonce=o)}if(Object.keys(r).forEach((function(t){n.setAttribute(t,r[t])})),"function"==typeof t.insert)t.insert(n);else{var a=i(t.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(n)}return n}var c,l=(c=[],function(t,n){return c[t]=n,c.filter(Boolean).join("\n")});function p(t,n,e,r){var i=e?"":r.media?"@media ".concat(r.media," {").concat(r.css,"}"):r.css;if(t.styleSheet)t.styleSheet.cssText=l(n,i);else{var o=document.createTextNode(i),a=t.childNodes;a[n]&&t.removeChild(a[n]),a.length?t.insertBefore(o,a[n]):t.appendChild(o)}}function h(t,n,e){var r=e.css,i=e.media,o=e.sourceMap;if(i?t.setAttribute("media",i):t.removeAttribute("media"),o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleSheet)t.styleSheet.cssText=r;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(r))}}var f=null,y=0;function d(t,n){var e,r,i;if(n.singleton){var o=y++;e=f||(f=u(n)),r=p.bind(null,e,o,!1),i=p.bind(null,e,o,!0)}else e=u(n),r=h.bind(null,e,n),i=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)};return r(t),function(n){if(n){if(n.css===t.css&&n.media===t.media&&n.sourceMap===t.sourceMap)return;r(t=n)}else i()}}t.exports=function(t,n){(n=n||{}).singleton||"boolean"==typeof n.singleton||(n.singleton=(void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r));var e=s(t=t||[],n);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var r=0;r<e.length;r++){var i=a(e[r]);o[i].references--}for(var u=s(t,n),c=0;c<e.length;c++){var l=a(e[c]);0===o[l].references&&(o[l].updater(),o.splice(l,1))}e=u}}}}},n={};function e(r){var i=n[r];if(void 0!==i)return i.exports;var o=n[r]={id:r,exports:{}};return t[r](o,o.exports,e),o.exports}e.n=t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},e.d=(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},e.o=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),(()=>{var t=e(379),n=e.n(t),r=e(945);n()(r.Z,{insert:"head",singleton:!1}),r.Z.locals;var i=function(){function t(){}return t.language="zh-cn",t.debug=!1,t}();const o={"Containers is null":"容器为空","Start mount stage":"开始挂载舞台","Renderer type is null":"没有找到合适的渲染器","matrix3d param less than 16":"matrix3d 参数小于16个","Unknown danmaku format":"未知的弹幕格式","Danmaku parser fail":"高级弹幕解析失败,json格式可能存在问题"};var a=function(){function t(){}return t.t=function(t){return this.tranTxt[this.language]&&this.tranTxt[this.language][t]?this.tranTxt[this.language][t]:t},t.tranTxt={"zh-cn":o},t.language=i.language,t}(),s=function(){function t(){}return t.prototype.reset=function(){throw new Error("Method not implemented.")},t.prototype.addDanmaku=function(t){return!1},t.prototype.refresh=function(){return!1},t.prototype.setCanvasContainer=function(t){return this.canvas=t,!0},t.prototype.updateCanvasStyle=function(t){return!!this.canvas&&(this.canvas.style.width=t.size.width.string(),this.canvas.style.height=t.size.height.string(),this.canvas.style.left=t.position.x.string(),this.canvas.style.top=t.position.y.string(),this.canvas.style.backgroundColor=t.color.string(),!0)},t}(),u=function(){function t(){}return t.lengthSrting=function(t){return t+"px"},t.Matrix3dString=function(t){if(16!==t.length)throw SyntaxError(a.t("matrix3d param less than 16"));return"Matrix3d("+t.join(",")+")"},t}(),c=function(){function t(t){this.length=t}return t.prototype.string=function(){return this.length+"px"},t}(),l=function(){function t(){}return t.recursionDanmaku=function(t){var n=this,e=[];return t.forEach((function(t){var r=n.createDiv(t.getContent());n.setStyle(r,t.getStyle());var i,o={element:r,animation:t.getAnimation(),style:t.getStyle(),child:[],start:t.startTime()},a=t.getChild();a&&(i=n.recursionDanmaku(a)),o.child=i,e.push(o)})),e},t.createDiv=function(t){var n=document.createElement("div");return n.style.position="absolute",n.innerText=t,n},t.recursionDiv=function(t){var n=this,e=[];return t.forEach((function(t){var r=t.element;t.child&&n.recursionDiv(t.child).forEach((function(t){r.appendChild(t)})),e.push(r)})),e},t.setStyle=function(t,n){Object.assign(t.style,n)},t.recursionStyle=function(t,n,e,r){var i=this;void 0===r&&(r=0),t.forEach((function(o,a){var s,c,l=0===r?e-o.start:r-o.start;(s=o.animation.getStyle(l))&&i.setStyle(o.element,s),(c=o.animation.getMatrix(l))&&(o.element.style.transform=u.Matrix3dString(c)),s||c||(o.element.parentElement?o.element.parentElement.removeChild(o.element):n.removeChild(o.element),delete t[a]),i.recursionStyle(o.child,n,e,l)}))},t}(),p=function(){function t(){this.canvasSize={width:new c(1920),height:new c(1080)},this.danmakuList=[]}return t.prototype.setCanvasContainer=function(t){return this.canvas=t,!0},t.prototype.updateCanvasStyle=function(t){if(this.canvas){this.canvas.style.width=this.canvasSize.width.string(),this.canvas.style.height=this.canvasSize.height.string(),this.canvas.style.left=u.lengthSrting((t.size.width.length-this.canvasSize.width.length)/2),this.canvas.style.top=u.lengthSrting((t.size.height.length-this.canvasSize.height.length)/2),this.canvas.style.backgroundColor=t.color.string();var n;return n=t.size.width.length/t.size.height.length>=this.canvasSize.width.length/this.canvasSize.height.length?t.size.height.length/this.canvasSize.height.length:t.size.width.length/this.canvasSize.width.length,this.canvas.style.transform="scale("+n+","+n+")",!0}return!1},t.prototype.addDanmaku=function(t){var n,e=this;if(!this.canvas)return!1;var r=l.recursionDanmaku([t]);return l.recursionDiv(r).forEach((function(t){var n;null===(n=e.canvas)||void 0===n||n.appendChild(t)})),(n=this.danmakuList).push.apply(n,r),!0},t.prototype.refresh=function(t){return!!this.canvas&&(l.recursionStyle(this.danmakuList,this.canvas,t),!0)},t.prototype.reset=function(){return this.canvas&&(this.canvas.innerHTML=""),this.danmakuList=[],!0},t}(),h=function(){function t(){}return t.getRenderInstance=function(t){if(this.rendererList[t])return new this.rendererList[t];throw ReferenceError(a.t("Renderer type is null"))},t.rendererList={base:s,css3:p},t}(),f=function(){function t(){this.lastTime=0,this.danmakuList=[]}return t.prototype.addDanmaku=function(t,n,e){n=n||t.startTime(),e=e||t.getAnimation().getDuration()+n;var r=this.timeToIndex(n);this.danmakuList[r]||(this.danmakuList[r]=[]),this.danmakuList[r].push({danmaku:t,start:n,end:e})},t.prototype.timeToIndex=function(t){return Math.floor(t/16)},t.prototype.getDanmakuList=function(t){if((t=this.timeToIndex(t))<0)return{skip:!1,DanmakuList:[]};var n=[],e=!1;if(this.lastTime<=t&&t-this.lastTime<5)for(var r=this.lastTime;r<t;r++)this.danmakuList[r]&&n.push.apply(n,this.danmakuList[r]);else{for(var i=0;i<t;i++)if(this.danmakuList[i])for(var o=0;o<this.danmakuList[i].length;o++)this.danmakuList[i][o]&&this.timeToIndex(this.danmakuList[i][o].end)>t&&n.push(this.danmakuList[i][o]);e=!0}return this.lastTime=t,{skip:e,DanmakuList:n}},t.prototype.reset=function(){return this.danmakuList=[],!0},t}(),y=function(){function t(){}return t.getTimeLine=function(t){return this.list[t]||(t="default"),new this.list[t]},t.list={defult:f,advance:f},t}();function d(t,n){var e;for(e in n)t[e]=t[e]&&"[object Object]"===t[e].toString()&&n[e]&&"[object Object]"===n[e].toString()?d(t[e],n[e]):t[e]=n[e];return t}var g,m,v=function(){function t(t,n,e,r){this.px3=3*t,this.px2=3*(e-t)-this.px3,this.px1=1-this.px3-this.px2,this.py3=3*n,this.py2=3*(r-n)-this.py3,this.py1=1-this.py3-this.py2,this.epsilon=1e-7}return t.prototype.getX=function(t){return((this.px1*t+this.px2)*t+this.px3)*t},t.prototype.getY=function(t){return((this.py1*t+this.py2)*t+this.py3)*t},t.prototype.solve=function(t){if(0===t||1===t)return this.getY(t);for(var n=t,e=0;e<8;e++){var r=this.getX(n)-t;if(Math.abs(r)<this.epsilon)return this.getY(n);var i=(3*this.px1*n+2*this.px2)*n+this.px3;if(Math.abs(i)<1e-6)break;n-=r/i}return this.getY(n)},t}(),A=function(){function t(){this.cubic=[0,0,1,1],this.duration=1e3}return t.prototype.getMatrix=function(t){if(this.isEnd(t))return!1;var n=this.getProgress(t);return this.getMatrixForCubic(n,this.duration*n)},t.prototype.getStyle=function(t){if(this.isEnd(t))return!1;var n=this.getProgress(t);return this.getCubicStyle(n,this.duration*n)},t.prototype.setParams=function(t){return this.cubic=(null==t?void 0:t.cubic)?null==t?void 0:t.cubic:this.cubic,this.duration=(null==t?void 0:t.duration)?null==t?void 0:t.duration:this.duration,!0},t.prototype.getDuration=function(){return this.duration},t.prototype.getProgress=function(t){var n=t/this.duration;return this.getCubic().solve(n)},t.prototype.getProgressValue=function(t,n,e){return t+(n-t)*e},t.prototype.isEnd=function(t){return t>this.duration},t.prototype.getCubic=function(){return this.cubicFunc||(this.cubicFunc=new(v.bind.apply(v,function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t}([void 0],this.cubic)))),this.cubicFunc},t}(),b=function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t},w=function(){function t(){}return t.add=function(t,n){for(var e=[],r=0;r<t.length;r++)e[r]=t[r]+n[r];return e},t.sub=function(t,n){for(var e=[],r=0;r<t.length;r++)e[r]=t[r]-n[r];return e},t.mult=function(t,n){var e=this.tran(t),r=this.tran(n);if(e[0].length!==r.length)throw new Error;for(var i=e.length,o=e[0].length,a=r[0].length,s=new Array(i).fill(0).map((function(){return new Array(a).fill(0)})),u=0;u<i;u++)for(var c=0;c<a;c++)for(var l=0;l<o;l++)s[u][c]+=e[u][l]*r[l][c];return b(b(b(b([],s[0]),s[1]),s[2]),s[3])},t.tran=function(t){for(var n=[],e=0;e<4;e++)for(var r=0;r<4;r++){var i=4*e+r;n[e]||(n[e]=[]),n[e][r]=t[i]}return n},t.getNullMatrix=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},t}(),_=(g=function(t,n){return(g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}g(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),x=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.animations=[],n.cumulativeMatrix=[],n}return _(n,t),n.prototype.setParams=function(n){var e=this;return t.prototype.setParams.call(this,n),this.animations=G.getAnimationsList((null==n?void 0:n.animations)||[]),this.animations.forEach((function(t,n){var r=t.getDuration();e.cumulativeMatrix[n]=t.getMatrix(r)||w.getNullMatrix(),r>e.duration&&(e.duration=t.getDuration())})),!0},n.prototype.getCubicStyle=function(t,n){for(var e={boxStyle:{},fontStyle:{}},r=!0,i=0,o=this.animations;i<o.length;i++){var a=o[i].getStyle(n);a&&(r=!1,e=d(e,a))}return!r&&e},n.prototype.getMatrixForCubic=function(t,n){for(var e=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],r=this.animations.length-1;r>=0;r--){var i=this.animations[r].getMatrix(n);e=i?w.mult(e,i):w.mult(e,this.cumulativeMatrix[r])}return e},n}(A),S=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),C=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.animations=[],n.cumulativeMatrix=[],n.cumulativeTime=[],n}return S(n,t),n.prototype.setParams=function(n){var e=this;t.prototype.setParams.call(this,n),this.animations=G.getAnimationsList((null==n?void 0:n.animations)||[]);var r=0;return this.cumulativeMatrix[0]=w.getNullMatrix(),this.cumulativeTime[0]=r,this.animations.forEach((function(t,n){var i=t.getDuration();n++;var o=t.getMatrix(i)||w.getNullMatrix();e.cumulativeMatrix[n]=w.mult(o,e.cumulativeMatrix[n-1]),r+=i,e.cumulativeTime[n]=r})),this.duration<r&&(this.duration=r),!0},n.prototype.getCubicStyle=function(t,n){var e=this.getCurAnimation(n);return!!e&&e.animation.getStyle(n)},n.prototype.getMatrixForCubic=function(t,n){var e=this.getCurAnimation(n);if(e){n-=this.cumulativeTime[e.key];var r=e.animation.getMatrix(n)||w.getNullMatrix();return w.mult(r,this.cumulativeMatrix[e.key])}return!1},n.prototype.getCurAnimation=function(t){for(var n=this.animations.length-1;n>=0;n--)if(t>this.cumulativeTime[n])return{key:n,animation:this.animations[n]};return!1},n}(A),O=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),k=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.opacity=[0,1],n}return O(n,t),n.prototype.setParams=function(n){return t.prototype.setParams.call(this,n),this.opacity=(null==n?void 0:n.opacity)||this.opacity,!0},n.prototype.getCubicStyle=function(t,n){return{opacity:this.getProgressValue(this.opacity[0],this.opacity[1],t)}},n.prototype.getMatrixForCubic=function(t,n){return!1},n}(A),T=function(){function t(){this.duration=1e3,this.x=0,this.y=0,this.z=0}return t.prototype.getDuration=function(){return this.duration},t.prototype.setParams=function(t){return this.duration=(null==t?void 0:t.duration)||this.duration,this.x=(null==t?void 0:t.x)||0,this.y=(null==t?void 0:t.y)||0,this.z=(null==t?void 0:t.z)||0,!0},t.prototype.getMatrix=function(t){return!(t>this.duration)&&[1,0,0,0,0,1,0,0,0,0,1,0,this.x,this.y,this.z,1]},t.prototype.getStyle=function(){return!1},t}(),M=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),D=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.repeat=1,n}return M(n,t),n.prototype.getCubicStyle=function(t,n){return this.animation.getStyle(this.getCurTime(n))},n.prototype.getMatrixForCubic=function(t,n){return this.animation.getMatrix(this.getCurTime(n))},n.prototype.setParams=function(n){return t.prototype.setParams.call(this,n),(null==n?void 0:n.animation)?this.animation=G.getAnimations(null==n?void 0:n.animation.type,null==n?void 0:n.animation.params)||new T:this.animation=new T,console.log(this.animation),this.repeat=(null==n?void 0:n.repeat)||this.repeat,this.animationTime=this.animation.getDuration(),this.duration=this.animationTime*this.repeat,console.log(this.duration),!0},n.prototype.getCurTime=function(t){return t%this.animationTime},n}(A),L=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),E=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.origin=[0,0,0],n}return L(n,t),n.prototype.setParams=function(n){return!!t.prototype.setParams.call(this,n)&&(this.origin=(null==n?void 0:n.origin)||this.origin,!0)},n.prototype.getMatrixForCubic=function(t){var n=this.getMatrixForOrigin(t);return!!n&&(n=w.mult([1,0,0,0,0,1,0,0,0,0,1,0,-this.origin[0],-this.origin[1],-this.origin[2],1],n),w.mult(n,[1,0,0,0,0,1,0,0,0,0,1,0,this.origin[0],this.origin[1],this.origin[2],1]))},n}(A),P=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),j=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.scale={x1:1,y1:1,z1:1,x2:1,y2:1,z2:1},n}return P(n,t),n.prototype.setParams=function(n){return!!t.prototype.setParams.call(this,n)&&(this.scale=Object.assign(this.scale,null==n?void 0:n.scale),!0)},n.prototype.getMatrixForOrigin=function(t){return[this.getProgressValue(this.scale.x1,this.scale.x2,t),0,0,0,0,this.getProgressValue(this.scale.y1,this.scale.y2,t),0,0,0,0,this.getProgressValue(this.scale.z1,this.scale.z2,t),0,0,0,0,1]},n.prototype.getCubicStyle=function(t){return!1},n}(E),z=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),R=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.path={x1:0,y1:0,x2:0,y2:0,z1:0,z2:0},n}return z(n,t),n.prototype.setParams=function(n){return!!t.prototype.setParams.call(this,n)&&(this.path=Object.assign(this.path,null==n?void 0:n.path),!0)},n.prototype.getCubicStyle=function(){return!1},n.prototype.getMatrixForCubic=function(t){return[1,0,0,0,0,1,0,0,0,0,1,0,this.getProgressValue(this.path.x1,this.path.x2,t),this.getProgressValue(this.path.y1,this.path.y2,t),this.getProgressValue(this.path.z1,this.path.z2,t),1]},n}(A),I=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),N=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.angle={start:0,end:360},n}return I(n,t),n.prototype.setParams=function(n){return!!t.prototype.setParams.call(this,n)&&(this.angle=Object.assign(this.angle,null==n?void 0:n.angle),!0)},n.prototype.getCubicStyle=function(t){return!1},n.prototype.A2R=function(t){return t*(Math.PI/180)},n}(E),B=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),F=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return B(n,t),n.prototype.getMatrixForOrigin=function(t){var n=this.getProgressValue(this.angle.start,this.angle.end,t),e=Math.sin(this.A2R(n)),r=Math.cos(this.A2R(n));return[1,0,0,0,0,r,e,0,0,-e,r,0,0,0,0,1]},n}(N),U=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),V=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return U(n,t),n.prototype.getMatrixForOrigin=function(t){var n=this.getProgressValue(this.angle.start,this.angle.end,t),e=Math.sin(this.A2R(n)),r=Math.cos(this.A2R(n));return[r,0,e,0,0,1,0,0,-e,0,r,0,0,0,0,1]},n}(N),K=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),J=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return K(n,t),n.prototype.getMatrixForOrigin=function(t){var n=this.getProgressValue(this.angle.start,this.angle.end,t),e=Math.sin(this.A2R(n)),r=Math.cos(this.A2R(n));return[r,e,0,0,-e,r,0,0,0,0,1,0,0,0,0,1]},n}(N),G=function(){function t(){}return t.getAnimations=function(t,n){if(this.animationList[t]){var e=new this.animationList[t];return e.setParams(n),e}return!1},t.getAnimationsList=function(t){var n=this,e=[];return null==t||t.forEach((function(t){var r=n.getAnimations(t.type,t);r&&e.push(r)})),e},t.animationList={static:T,translate:R,rotateX:F,rotateY:V,rotateZ:J,scale:j,list:C,group:x,repeat:D,opacity:k},t}(),Y=function(){function t(){this.style={},this.start=0,this.content="",this.child=[]}return t.prototype.setParams=function(t){try{(null==t?void 0:t.start)&&(this.start=null==t?void 0:t.start),(null==t?void 0:t.animation)&&(this.animation=(null==t?void 0:t.animation)||new T),(null==t?void 0:t.child)&&(this.child=t.child),(null==t?void 0:t.style)&&(this.style=null==t?void 0:t.style),(null==t?void 0:t.content)&&(this.content=null==t?void 0:t.content)}catch(t){return console.warn(t),!1}return!0},t.prototype.getType=function(){return"base"},t.prototype.getContent=function(){return this.content},t.prototype.getChild=function(){return this.child},t.prototype.getAnimation=function(){return this.animation||(this.animation=new T),this.animation},t.prototype.getStyle=function(){return this.style},t.prototype.startTime=function(){return this.start},t}(),Z=function(){function t(){}return t.getDanmakuInstance=function(t){return this.list[t]||(t="text"),new this.list[t]},t.list={text:Y},t}(),H=function(){function t(){}return t.buildPrefix=function(t){return this.prefix+t},t.listener=function(t,n){window.addEventListener(this.buildPrefix(t),(function(t){n(t.detail)}))},t.dispatch=function(t,n){var e=new CustomEvent(this.buildPrefix(t),{detail:n});window.dispatchEvent(e)},t.prefix="_danmakuevent_",t}();!function(t){t.DANMAKU_JSON_INVALID="DANMAKU_JSON_INVALID",t.DANMAKU_FORMAT_ERROR="DANMAKU_FORMAT_ERROR",t.DANMAKU_LOAD_START="DANMAKU_LOAD_START",t.DANMAKU_LOAD_DONE="DANMAKU_LOAD_DONE",t.DANMAKU_STAGE_RESET="DANMAKU_STAGE_RESET"}(m||(m={}));var X=function(){function t(){}return t.prototype.parser=function(t){try{var n=JSON.parse(t);return this.getDanmaku(n)}catch(t){return H.dispatch(m.DANMAKU_JSON_INVALID,a.t("Danmaku parser fail")),console.warn(a.t("Danmaku parser fail")),console.warn(t),[]}},t.prototype.getDanmaku=function(t){var n=this,e=[];return null==t||t.forEach((function(t,r){if("object"!=typeof t)console.warn(a.t("Unknown danmaku format")+" : "+t+" index: + "+r),H.dispatch(m.DANMAKU_FORMAT_ERROR,{content:t,index:r});else{var i=Z.getDanmakuInstance(t.type);(null==t?void 0:t.animations)&&(null==t?void 0:t.animations)!==[]||(t.animations=[{type:"static"}]),i.setParams({start:null==t?void 0:t.start,content:null==t?void 0:t.content,style:null==t?void 0:t.style,animation:G.getAnimations("list",{animations:null==t?void 0:t.animations}),child:n.getDanmaku(t.childs)}),e.push(i)}})),e},t}(),q=function(){function t(t){this.stageList=[],this.pauseStatus=!0,this.timeStamp=0,this.time=0,this.skipStatus=!1,this.danmakuFunction={},this.containers=t,this.canvasStyle=window.getComputedStyle(t),this.initContainer();var n=this;!function t(){n.pauseStatus||n.refresh(),requestAnimationFrame(t)}()}return t.prototype.getContainersSize=function(){return{width:new c(parseInt(this.canvasStyle.width,10)),height:new c(parseInt(this.canvasStyle.height,10))}},t.prototype.registStage=function(t,n){return!this.stageList[n]&&(this.stageList[n]=t,!0)},t.prototype.mount=function(){var t=this;console.info(a.t("Start mount stage")),this.stageList.forEach((function(n,e){var r=t.getDIV(),i=h.getRenderInstance(n.rendererType());i.setCanvasContainer(r),n.stageRenderer(i);var o=n.timeLineType(),s=y.getTimeLine(o);n.timeLine(s),t.danmakuFunction[o]?t.resetDanmaku(e):console.warn(a.t("danmaku get function is null :"+o)),i.updateCanvasStyle(t.getCanvasStylByStage(n))}))},t.prototype.initContainer=function(){i.debug&&this.containers.classList.add("danmaku-containers-debug"),this.containers.classList.add("danmaku-containers")},t.prototype.resize=function(){var t=this;this.stageList.forEach((function(n){var e=n.getRenderer();e&&e.updateCanvasStyle(t.getCanvasStylByStage(n))}))},t.prototype.getDIV=function(){var t=document.createElement("div");return t.classList.add("stage"),this.containers.appendChild(t),t},t.prototype.getCanvasStylByStage=function(t){var n=t.stageSize(this.getContainersSize()),e=t.stageBackgroundColor(this.getContainersSize());return{position:t.stagePosition(this.getContainersSize(),n),color:e,size:n}},t.prototype.refresh=function(){var t=this;this.time=Date.now()-this.timeStamp,this.stageList.forEach((function(n){n.refresh(t.time)}))},t.prototype.pause=function(){this.pauseStatus||(this.pauseStatus=!0)},t.prototype.start=function(){this.pauseStatus&&(this.timeStamp=Date.now()-this.time,this.pauseStatus=!1)},t.prototype.skip=function(t){this.pauseStatus?this.time=t:this.timeStamp=Date.now()-t},t.prototype.reset=function(){this.stageList.forEach((function(t){t.reset()})),H.dispatch(m.DANMAKU_STAGE_RESET,{}),this.pauseStatus=!0,this.timeStamp=0,this.time=0,this.skipStatus=!1},t.prototype.getTime=function(){return this.time},t.prototype.addGetDanmakuFunction=function(t,n){this.danmakuFunction[t]=n},t.prototype.resetDanmaku=function(t){if(this.stageList[t]){H.dispatch(m.DANMAKU_LOAD_START,{});var n=this.stageList[t],e=n.getTimeLine();e.reset();var r=this.danmakuFunction[n.timeLineType()];r&&r((function(t){var n=new X;t.forEach((function(t){n.parser(t).forEach((function(t){e.addDanmaku(t)})),H.dispatch(m.DANMAKU_LOAD_DONE,{})}))}))}},t}(),$=function(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t},Q=function(){function t(t,n,e,r){this.r=t,this.g=n,this.b=e,this.a=r}return t.prototype.string=function(){return"rgba("+this.r+","+this.g+","+this.b+","+this.a+")"},t.getColor=function(t){return this.color[t]?new(this.bind.apply(this,$([void 0],this.color[t]))):new(this.bind.apply(this,$([void 0],this.color.black)))},t.color={black:[0,0,0,1],white:[255,255,255,1],red:[255,0,0,1],green:[0,255,0,1],blue:[0,0,255,1],pink:[255,105,108,1],yellow:[255,255,0,1],grey:[130,130,130,1]},t}(),W=function(){function t(){}return t.prototype.stageSize=function(t){return{width:t.width,height:t.height}},t.prototype.stagePosition=function(){return{x:new c(0),y:new c(0)}},t.prototype.stageBackgroundColor=function(){return new Q(0,0,0,0)},t.prototype.stageRenderer=function(t){return this.renderer=t,!0},t.prototype.getRenderer=function(){if(this.renderer)return this.renderer;throw ReferenceError(a.t("renderer is null"))},t.prototype.timeLine=function(t){return this.timeLineObj=t,!0},t.prototype.refresh=function(t){var n,e,r,i=this;return!!this.renderer&&((r=(null===(n=this.timeLineObj)||void 0===n?void 0:n.getDanmakuList(t))||{skip:!1,DanmakuList:[]})&&(r.skip&&(null===(e=this.renderer)||void 0===e||e.reset()),r.DanmakuList.forEach((function(t){var n;null===(n=i.renderer)||void 0===n||n.addDanmaku(t.danmaku)}))),this.renderer.refresh(t),!0)},t.prototype.rendererType=function(){return"css3"},t.prototype.timeLineType=function(){return"advance"},t.prototype.reset=function(){var t;return null===(t=null==this?void 0:this.renderer)||void 0===t||t.reset(),!0},t.prototype.getTimeLine=function(){if(!this.timeLineObj)throw ReferenceError(a.t("Time line is null"));return this.timeLineObj},t}(),tt=function(){var t=function(n,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),nt=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return tt(n,t),n}(W),et=function(){function t(t){var n=this;if(!t.containers)throw ReferenceError(a.t("Containers is null"));this.controller=new q(t.containers),this.controller.addGetDanmakuFunction("advance",t.danmaku),this.controller.registStage(new nt,1),this.controller.mount(),window.addEventListener("resize",(function(){n.controller.resize()}))}return t.prototype.pause=function(){this.controller.pause()},t.prototype.start=function(){this.controller.start()},t.prototype.skip=function(t){this.controller.skip(t)},t.prototype.time=function(){return this.controller.getTime()},t.prototype.resize=function(){this.controller.resize()},t.prototype.reset=function(){this.controller.resetDanmaku(1),this.controller.reset()},t.prototype.listenerEvent=function(t,n){H.listener(t,n)},t}();"undefined"!=typeof globalThis?globalThis.MFADE=et:window.MFADE=et})()})();
//# sourceMappingURL=mfunsAdvanceDanmaku.js.map