-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathN.min.js
1 lines (1 loc) · 21.2 KB
/
N.min.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.NDanmaku=e():t.NDanmaku=e()}(self,(function(){return function(){"use strict";var t={421:function(t,e,n){var i=n(81),r=n.n(i),s=n(645),a=n.n(s)()(r());a.push([t.id,"@-webkit-keyframes Ndm-forward{0%{left:100%}to{left:0;-webkit-transform:translateX(-100%);transform:translateX(-100%)}}@keyframes Ndm-forward{0%{left:100%}to{left:0;-webkit-transform:translateX(-100%);transform:translateX(-100%)}}@-webkit-keyframes Ndm-reversed{0%{right:100%}to{right:0;-webkit-transform:translateX(100%);transform:translateX(100%)}}@keyframes Ndm-reversed{0%{right:100%}to{right:0;-webkit-transform:translateX(100%);transform:translateX(100%)}}.N-outline{text-shadow:#000 .5px 0 0,#000 0 .5px 0,#000 -.5px 0 0,#000 0 -.5px 0}.N-scroll{-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-timing-function:linear;animation-timing-function:linear;z-index:1}.N-hanging{left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);z-index:2}.N-scroll-forward{-webkit-animation-name:Ndm-forward;animation-name:Ndm-forward}.N-scroll-reversed{-webkit-animation-name:Ndm-reversed;animation-name:Ndm-reversed}.N-scroll-playing{-webkit-animation-play-state:running;animation-play-state:running}.N-scroll-paused,.N-scroll-paused>.N-scroll{-webkit-animation-play-state:paused;animation-play-state:paused}.N-dmLayer{left:0;overflow:hidden;pointer-events:none;position:absolute;top:0}",""]),e.Z=a},645:function(t){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,r,s){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(i)for(var o=0;o<this.length;o++){var l=this[o][0];null!=l&&(a[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);i&&a[h[0]]||(void 0!==s&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=s),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),r&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=r):h[4]="".concat(r)),e.push(h))}},e}},81:function(t){t.exports=function(t){return t[1]}},379:function(t){var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},a=[],o=0;o<t.length;o++){var l=t[o],c=i.base?l[0]+i.base:l[0],h=s[c]||0,u="".concat(c," ").concat(h);s[c]=h+1;var d=n(u),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(m);else{var f=r(m,i);i.byIndex=o,e.splice(o,0,{identifier:u,updater:f,references:1})}a.push(u)}return a}function r(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,r){var s=i(t=t||[],r=r||{});return function(t){t=t||[];for(var a=0;a<s.length;a++){var o=n(s[a]);e[o].references--}for(var l=i(t,r),c=0;c<s.length;c++){var h=n(s[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}s=l}}},569:function(t){var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},216:function(t){t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:function(t,e,n){t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:function(t){t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,r&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:function(t){t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var s=e[i]={id:i,exports:{}};return t[i](s,s.exports,n),s.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.nc=void 0;var i={};return function(){n.d(i,{default:function(){return C}});var t=n(379),e=n.n(t),r=n(795),s=n.n(r),a=n(569),o=n.n(a),l=n(565),c=n.n(l),h=n(216),u=n.n(h),d=n(589),m=n.n(d),f=n(421),g={};function p(t,e,n){t instanceof Array||(t=[t]),"string"==typeof e&&(e=[e]),n instanceof Array||(n=[n]);for(let i=0,r=t.length;i<r;i++)if(e instanceof Array)for(let r=0,s=e.length;r<s;r++)t[i].style[e[r]]=n[r];else for(let n in e)t[i].style[n]=e[n]}function b(t,e=1){let n="";switch(e){case 2:n="color:#F5DA81";break;case 3:n="color:#FE2E2E;font-weight:bold"}console.log(`[N.js-Danmaku]%c ${t}`,n)}function y(t,e){for(let n in e){if(!t[n])return!1;{let i="!"===e[n][0],r=i?e[n].slice(1):e[n];if(!i&&t[n]!==r||i&&t[n]==r)return!1}}return!0}function v(t){for(let e in t)"object"!=typeof t[e]||t[e]instanceof Array?t[e]=0:v(t[e])}function k(t,e=4,n=-1){-1===n&&(n=e);let i="{",r=" ".repeat(n);for(let s in t){let a=t[s],o="";if("function"==typeof a)o=a.toString();else if(a instanceof Array)o=JSON.stringify(a);else switch(typeof a){case"object":o=k(a,e,n+e);break;case"number":case"boolean":o=a.toString();break;default:o=`"${a.replaceAll('"','\\"')}"`}i+=`\n${r}${r}"${s}": ${o},`}return i+=`\n${r}}`,i}function w(){return(new Date).getTime()}g.styleTagTransform=m(),g.setAttributes=c(),g.insert=o().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),e()(f.Z,g),f.Z&&f.Z.locals&&f.Z.locals;class S{constructor(t,e){this.state="running",this.callback=t,this.timer=setTimeout(this.finished.bind(this),e),this.start=w(),this.remaining=e}finished(){this.state="done",this.callback()}pause(){"running"==this.state&&(this.state="paused",clearTimeout(this.timer),this.remaining-=w()-this.start)}resume(){this.remaining>0&&"paused"==this.state&&(this.state="running",this.start=w(),this.timer=setTimeout(this.finished.bind(this),this.remaining))}}const L={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"},x={color:"white",size:null,scale:1,opacity:100,weight:"normal",bottom_space:2,outline:!0,reverse:!1,type:"scroll",life:5e3,pointer_events:!0,custom_css:{},carry_sheet:""},N={top:0,bottom:0,scroll:0,random:0},A={top:70,bottom:70,scroll:100,random:100};class E{constructor(t){this.target=t,this.hitSets={top:[],bottom:[],scroll:[]},this.resetHitSets()}resetHitSets(){this.danmakuMinHeight=N,this.danmakuMaxHeight=A,this.refreshHitSets()}getMinHeight(t){return.01*this.danmakuMinHeight[t]*this.target.getBoundingClientRect().height}getMaxHeight(t){return.01*this.danmakuMaxHeight[t]*this.target.getBoundingClientRect().height}refreshHitSets(t=""){if("random"==t)return;let e=this,n=t=>{e.hitSets[t].length=0,e.hitSets[t][0]={from:Math.floor(100*e.getMinHeight(t)),to:Math.floor(100*e.getMaxHeight(t)),available:!0,dm:null}};if(t)n(t);else for(let t in this.hitSets)n(t)}setDanmakuPos(t,e){switch(e.type){case"midscroll":case"midhang":p(t,"top",`calc(50% - ${t.offsetHeight/2}px)`);break;case"random":p(t,"top",`${this.danmakuRandom(t)}px`);break;case"top":case"scroll":p(t,"top",`${this.danmakuAnchor(t,e)}px`);break;case"bottom":p(t,"bottom",`${this.danmakuAnchor(t,e)}px`)}}danmakuRandom(t){return this.target.offsetHeight,e=this.getMinHeight("random"),n=this.getMaxHeight("random")-t.offsetHeight,Math.random()*(n-e)+e;var e,n}danmakuAnchor(t,e,n=!1){let i=this.target.getBoundingClientRect(),r=t.getBoundingClientRect().height,s=this.hitSets[e.type],a=e.bottom_space,o=-1;for(let n=0,l=s.length;n<l;n++){let c=s[n];if(c.available){let i=c.to-c.from+1,l=Math.floor(100*(r+a));if(-1===o&&i>=l){let i=Object.assign({},c),r=c.from+l;o=c.from/100,c.to=r-1,c.available=!1,c.dm={start:w(),life:e.life,reversed:e.reverse,element:t},i.from=r,s.splice(n+1,0,i)}}else{let t=c.dm.start,r=c.dm.life,a=c.dm.reversed,o=c.dm.element,h=o.getBoundingClientRect(),u=!1;switch(e.type){case"scroll":u=a?h.left-i.left>0:h.left+h.width<i.width+i.left;break;case"top":case"bottom":u=w()-t>=r}if(0!=o.offsetWidth&&null!=o.parentNode||(u=!0),u){let t=s[n-1]||{},e=s[n+1]||{};t.available&&e.available?(t.to=e.to,s.splice(n,2),n--,l-=2):t.available?(t.to=c.to,s.splice(n,1),n--,l--):e.available?(c.to=e.to,c.available=!0,c.dm=null,s.splice(n+1,1),l--):(c.available=!0,c.dm=null),n--}}}if(-1===o){if(!n)return this.refreshHitSets(e.type),this.danmakuAnchor(t,e,!0);o=0}return o}}const H="N-scroll-paused",$="N-scroll-playing";class D{constructor(t,e,n,i){this.id=t,this.element=e,this.allDanmaku=i;for(let t in n)this[t]=n[t];i[t]=this}revoke(t=!1){let e=this.element;switch(this.category){case"hanging":case"freeing":this.timer.pause(),e.parentNode&&e.parentNode.removeChild(e);break;case"scrolling":t?e.dispatchEvent(new Event(this.clearEvent)):e.dispatchEvent(new Event(this.endEvent))}delete this.allDanmaku[this.id]}pause(){let t=this.element;switch(this.category){case"hanging":case"freeing":return this.timer.pause(),!0;case"scrolling":if(t.classList.contains($))return t.classList.replace($,H),!0}return!1}resume(){let t=this.element;switch(this.category){case"hanging":case"freeing":return this.timer.resume(),!0;case"scrolling":if(t.classList.contains(H))return t.classList.replace(H,$),!0}return!1}get finished(){if(["hanging","freeing"].includes(this.category)){if("done"===this.timer.state)return!0}else if(this.element.offsetWidth<=0||null==this.element.parentNode)return!0;return!1}}console.log("Hey there!👋 Thank you for using %cN.js%c - SomeBottle","color:#81BEF7;font-weight:bold","");var C=class{constructor(t,e="",n="auto"){const i=t instanceof Element?t:document.getElementById(t);if(!i)return b("Error: container element not found",3),null;let r;this.target=i,this.prefix=e,this.resetAttrs(),this.state="running",p(i,"position","relative"),i.querySelector(".N-dmLayer")?r=i.querySelector(".N-dmLayer"):(r=document.createElement("div"),p(r,["width","height","top","left"],["100%","100%","0px","0px"]),r.className="N-dmLayer",i.appendChild(r)),p(r,"z-index",n),this.dmLayer=r,this.hitBox=new E(r),this.monitor=new class{constructor(){this.dmSerial=0,this.allDanmaku=new Object,this.hanging=[],this.scrolling=[],this.freeing=[],this.createdReport={total:0,scrolling:{total:0,scroll:{total:0},random:{total:0},midscroll:{total:0}},hanging:{total:0,top:{total:0},bottom:{total:0},midhang:{total:0}},freeing:{total:0}}}resetStatistics(t=""){"created"===t&&v(this.createdReport)}statistics(){let t={total:0,garbages:0,freeing:{total:0,garbages:0},scrolling:{total:0,reversed:0,garbages:0,scroll:{total:0,reversed:0,garbages:0},random:{total:0,reversed:0,garbages:0},midscroll:{total:0,reversed:0,garbages:0}},hanging:{total:0,garbages:0,top:{total:0,garbages:0},bottom:{total:0,garbages:0},midhang:{total:0,garbages:0}}};for(let e in this.allDanmaku){let n=this.allDanmaku[e],i=n.category,r=n.type;n.finished?(t.garbages++,t[i].garbages++,n.type&&t[i][r].garbages++):(t.total++,t[i].total++,n.type&&t[i][r].total++,n.reversed&&(t.scrolling.reversed++,t.scrolling[r].reversed++))}return{current:t,created:this.createdReport}}garbageCollect(t=""){let e=t=>{for(let e=0,n=t.length;e<n;e++)t[e].finished&&(t[e].revoke(),t.splice(e,1),e--,n--)};t&&"scrolling"!==t||e(this.scrolling),t&&"hanging"!==t||e(this.hanging),t&&"freeing"!==t||e(this.freeing),e=void 0}newScroll(t,e,n,i=null){let r="",s=this.createdReport;for(let e in L)if(e in t.style){r=L[e];break}if(!r)return void b("Oops, your browser is outdated.",3);let a=this.dmSerial,o=function(){this.removeEventListener(r,o),this.removeEventListener("danmakuclear",l),this.parentNode.removeChild(this),i&&i(a)}.bind(t),l=function(){this.removeEventListener(r,o),this.removeEventListener("danmakuclear",l),this.parentNode.removeChild(this)}.bind(t),c=this.scrolling;t.addEventListener(r,o),t.addEventListener("danmakuclear",l),this.garbageCollect("scrolling");let h=new D(a,t,{category:"scrolling",type:e,reversed:n,endEvent:r,clearEvent:"danmakuclear"},this.allDanmaku);return c.push(h),this.dmSerial++,s.total++,s.scrolling.total++,s.scrolling[e].total++,a}newHang(t,e,n,i=null){let r=this.dmSerial,s=new S((()=>{t.parentNode.removeChild(t),i&&i(r)}),n),a=this.hanging,o=this.createdReport;this.garbageCollect("hanging");let l=new D(r,t,{category:"hanging",timer:s,type:e},this.allDanmaku);return a.push(l),this.dmSerial++,o.total++,o.hanging.total++,o.hanging[e].total++,r}newFree(t,e,n=null){let i=this.dmSerial,r=new S((()=>{t.parentNode.removeChild(t),n&&n(i)}),e),s=this.freeing,a=this.createdReport;this.garbageCollect("freeing");let o=new D(i,t,{category:"freeing",timer:r,type:null},this.allDanmaku);return s.push(o),this.dmSerial++,a.total++,a.freeing.total++,i}clearSomeScrolling(t="",e=!1){let n=this.scrolling;for(let i=0,r=n.length;i<r;i++){let s=n[i];(!t||"all"==t&&"all"==e||"all"==t&&s.reversed==e||s.type==t&&"all"==e||s.type==t&&s.reversed==e)&&(s.revoke(!0),n.splice(i,1),i--,r--)}}clearSomeHanging(t=""){let e=this.hanging;for(let n=0,i=e.length;n<i;n++){let r=e[n];t&&"all"!=t&&r.type!=t||(r.revoke(!0),e.splice(n,1),n--,i--)}}clearFreeing(){let t=this.freeing;for(let e=0,n=t.length;e<n;e++)t[e].revoke(!0),t.splice(e,1),e--,n--}clearStyled(t){let e=e=>{for(let n=0,i=e.length;n<i;n++)y(e[n].element.style,t)&&(e[n].revoke(!0),e.splice(n,1),n--,i--)};e(this.hanging),e(this.scrolling),e(this.freeing),e=void 0}clearSingle(t){let e=this.allDanmaku[t];return e?e.revoke(!0):(b(`DanmakuID:${t} not found.`,2),!1)}pauseSingle(t){let e=this.allDanmaku[t];return e?e.pause():(b(`DanmakuID:${t} not found.`,2),!1)}resumeSingle(t){let e=this.allDanmaku[t];return e?e.resume():(b(`DanmakuID:${t} not found.`,2),!1)}pauseAll(t="hanging"){let e=this[t];for(let t=0,n=e.length;t<n;t++)e[t].pause()}resumeAll(t="hanging"){let e=this[t];for(let t=0,n=e.length;t<n;t++)e[t].resume()}},this.list=new class{constructor(t,e){this.danmaku=e,this.target=t,this.lists={},this.usingList=null,this.lastTickRange=[0,0]}uncertainty(t){if(!this.usingList)return b("Use one list first.",2),null;t>=0?this.usingList.uncertainty=t:b("Uncertainty should be a positive number",2)}load(t){if(this.usingList){for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.time;i&&(delete n.time,this.addDm(n,i))}return b("Successfully loaded."),!0}return b("Use one list first.",2),!1}tick(t){let e=this.usingList,n=e.timeLine,i=e.uncertainty;if(e){let r=t-i,s=t+i,a=t,o=this.lastTickRange[1]-r,l=this.lastTickRange[1]-s;if(o>=0&&l<0){let t=o+1;t>i?(a+=t-i,r=a):r+=t}let c=0,h=n.length-1,u=[];for(;c<=h;){let e=Math.floor((c+h)/2),i=n[e][0],s=n[e][1];if(i==t){r<=t&&u.push(s),c=e+1,h=e-1;break}i<t?c=e+1:i>t&&(h=e-1)}for(let t=n.length;c<t&&n[c][0]<=s;c++)n[c][0]<a||u.push(n[c][1]);for(;h>=0&&n[h][0]>=r;h--)u.unshift(n[h][1]);this.lastTickRange=[r,s];let d=e.danmakuLine;for(let t=0,e=u.length;t<e;t++){let e=d[u[t]],n=this.danmaku;e.reset_styles&&n.resetAttrs(),e.styles&&n.attrs(e.styles),n.create(e.text,e.created instanceof Function?e.created:null,e.callback instanceof Function?e.callback:null)}}else b("Use one list first.",2)}addDm(t,e){let n=this.usingList;if(n){if(!(t instanceof Object&&"number"==typeof e&&e>=0))return b("Invalid parameters!",3),null;if(!t.hasOwnProperty("text"))return b("Lack of necessary properties in danmakuData!",3),null;let i=`ld${n.dmSerial}`;e=Math.round(e),n.danmakuLine[i]=t;let r=0,s=n.timeLine.length,a=!1;do{let t=n.timeLine[r];if(!t||t[0]>e){n.timeLine.splice(r,0,[e,i]),a=!0;break}r++}while(r<s);return a||n.timeLine.push([e,i]),n.dmSerial++,i}return b("Use one list first.",2),null}delDm(t){let e=this.usingList;if(e){if(e.danmakuLine[t]){delete e.danmakuLine[t];for(let n=0,i=e.timeLine.length;n<i;n++)if(e.timeLine[n][1]==t){e.timeLine.splice(n,1);break}return!0}}else b("Use one list first.",2);return!1}use(t){this.lists[t]?this.usingList=this.lists[t]:b(`List ${t} not found!`,3)}new(t){this.lists[t]?b(`List ${t} already exists!`,3):this.lists[t]={timeLine:new Array,danmakuLine:new Object,uncertainty:200,dmSerial:0}}export(t,e="js",n=!1){let i=this.usingList;if(i){if(!/^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(t))return b("Illegal output name for List!",3),"";let r=i.timeLine,s=`const ${t} = [`,a=[],o="";for(let t=0,e=r.length;t<e;t++){let[e,n]=r[t],o=Object.assign({},i.danmakuLine[n]);o.time=e,a.push(o),s+=`\n ${k(o)},`}return s+="\n]",o="json"===e?JSON.stringify(a,null,4):s,n&&function(t,e,n){console.log("Hello");let i=document.createElement("a"),r=new Blob([n],{type:e});i.setAttribute("download",t),i.setAttribute("href",URL.createObjectURL(r)),i.style.display="none",document.body.appendChild(i),i.click(),URL.revokeObjectURL(i.href),document.body.removeChild(i)}(`${t}.${e}`,"json"===e?"application/json":"application/javascript",o),o}return b("Use one list first.",2),""}del(t){this.lists[t]?delete this.lists[t]:b(`List ${t} not found!`,3)}}(r,this)}get statistics(){let t=this.monitor.statistics();return t.global_state=this.state,t}resetStatistics(t=""){return this.monitor.resetStatistics(t),this}resetAttrs(){return this.currentAttrs=Object.assign({},x),this.currentAttrs.custom_css=Object.assign({},this.currentAttrs.custom_css),this}resetRanges(){return this.hitBox.resetHitSets(),this}create(t,e=null,n=null){if(this.dmLayer.offsetWidth<=0||null===this.dmLayer.parentNode)return b("Warning: Danmaku layer not found.",2),this;let i=this.currentAttrs,r=document.createElement("div"),s=document.createTextNode(t),a=i.size,o=i.carry_sheet,l=i.life,c=i.reverse,h=i.pointer_events;if(this.height=this.target.offsetHeight,this.width=this.target.offsetWidth,r.appendChild(s),!a){let t=function(t){let e=t.offsetWidth/180*5;return e>5?e:5}(this.target);i.scale>0&&(t*=i.scale),a=`${t}px`}p(r,{position:"absolute","pointer-events":h?"auto":"none","font-size":a,color:i.color,"font-weight":i.weight,opacity:.01*i.opacity,"word-break":"keep-all","white-space":"pre"}),"free"!==i.type&&p(r,{"animation-duration":`${l}ms`,"-webkit-animation-duration":`${l}ms`,"-moz-animation-duration":`${l}ms`,"-o-animation-duration":`${l}ms`}),i.outline&&r.classList.add("N-outline"),p(r,i.custom_css),this.dmLayer.appendChild(r);let u=null;switch(i.type){case"scroll":case"random":case"midscroll":r.classList.add("N-scroll-playing",c?"N-scroll-reversed":"N-scroll-forward","N-scroll"),u=this.monitor.newScroll(r,i.type,c,n);break;case"top":case"bottom":case"midhang":r.classList.add("N-hanging"),u=this.monitor.newHang(r,i.type,i.life,n);break;case"free":u=this.monitor.newFree(r,i.life,n);break;default:return b("Error: Unknown danmaku type.",3),this.dmLayer.removeChild(r),this}this.hitBox.setDanmakuPos(r,i);let d="";if(this.prefix&&(d=`N-danmaku-${this.prefix}-${u}`,r.id=d),o){let t=document.createElement("style");d&&(o=o.replace(/\[selfId\]/g,d)),t.appendChild(document.createTextNode(o)),r.appendChild(t)}return"function"==typeof e&&e(r,u),this}clearSome(t="",e="all"){switch(t){case"random":case"scroll":case"midscroll":this.monitor.clearSomeScrolling(t,e);break;case"top":case"bottom":case"midhang":this.monitor.clearSomeHanging(t);break;case"all":this.monitor.clearSomeScrolling("all",e),this.monitor.clearSomeHanging("all");break;case"scrolling":this.monitor.clearSomeScrolling("all",e);break;case"hanging":this.monitor.clearSomeHanging();break;case"free":case"freeing":this.monitor.clearFreeing();break;default:this.monitor.clearSomeScrolling(),this.monitor.clearSomeHanging(),this.monitor.clearFreeing()}return this}clearStyled(t){this.monitor.clearStyled(t)}clear(t=null){return"number"==typeof t?this.monitor.clearSingle(t):this.clearSome(),this}pause(t=null){return"number"==typeof t?(this.monitor.pauseSingle(t),this):("running"==this.state&&(this.dmLayer.classList.add("N-scroll-paused"),this.monitor.pauseAll("hanging"),this.monitor.pauseAll("freeing"),this.state="paused"),this)}resume(t=null){return"number"==typeof t?(this.monitor.resumeSingle(t),this):("paused"==this.state&&(this.dmLayer.classList.remove("N-scroll-paused"),this.monitor.resumeAll("hanging"),this.monitor.resumeAll("freeing"),this.state="running"),this)}attrs(t,e=null){if(t instanceof Object)for(let e in t)this.currentAttrs[e]=t[e];else void 0!==this.currentAttrs[t]?this.currentAttrs[t]=e:b(`Error: Danmaku attribute not found: ${t}`,3);return this}ranges(t,e=null){let n=this.hitBox.danmakuMaxHeight,i=this.hitBox.danmakuMinHeight;if(t instanceof Object)for(let e in t)void 0!==n[e]&&(i[e]=t[e][0],n[e]=t[e][1],this.hitBox.refreshHitSets(e));else void 0!==n[t]?(i[t]=e[0],n[t]=e[1],this.hitBox.refreshHitSets(t)):b(`Error: Danmaku type not found: ${t}`,3);return this}}}(),i.default}()}));