(()=>{"use strict";function t(t,e){var n=t.split(".");"isekai"in window||(window.isekai={});for(var o=window.isekai,i=0;i]+)>/g,(function(t,e){var n=r[e];return"$"+(Array.isArray(n)?n.join("$"):n)})))}if("function"==typeof i){var l=this;return t[Symbol.replace].call(this,o,(function(){var t=arguments;return"object"!=e(t[t.length-1])&&(t=[].slice.call(t)).push(a(t,l)),i.apply(this,t)}))}return t[Symbol.replace].call(this,o,i)},o.apply(this,arguments)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}var r,a=!(!(r=navigator.userAgent.match(o(/Version\/(\S+) Mobile\/\S+/,{version:1})))||!r.groups.version),l=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.menuItems=[],this.menuItemsUpdated=!0,this.initDom()}var e,o;return e=t,o=[{key:"initDom",value:function(){var t=this,e=document.createElement("div");e.id="iseai-contextmenu",e.className="oo-ui-toolGroup-tools oo-ui-popupToolGroup-tools oo-ui-listToolGroup-tools oo-ui-toolGroup-enabled-tools oo-ui-popupToolGroup-active-tools",e.style.minWidth="unset",e.style.display="none",this.menuContainer=e;var n=document.createElement("div");n.className="isekai-contextmenu-cover",n.style.display="none",n.addEventListener("click",(function(){t.hide()})),this.menuCover=n,document.body.appendChild(e),document.body.appendChild(n)}},{key:"setMenuItem",value:function(t){this.menuItems=t,this.menuItemsUpdated=!0}},{key:"updateMenuItemDom",value:function(){var t=this;this.menuItemsUpdated&&(this.menuContainer.innerHTML="",this.menuItems.sort((function(t,e){var n,o;return(null!==(n=e.priority)&&void 0!==n?n:0)-(null!==(o=t.priority)&&void 0!==o?o:0)})).forEach((function(e){var n=document.createElement("span");n.className="oo-ui-widget oo-ui-widget-enabled oo-ui-tool";var o=document.createElement("a");o.className="oo-ui-tool-link",o.tabIndex=0,o.role="button",o.addEventListener("click",(function(n){var o;n.preventDefault(),null===(o=e.onClick)||void 0===o||o.call(e),t.hide()}));var i=document.createElement("span");i.className="oo-ui-tool-title",i.innerText=e.label,o.appendChild(i),n.appendChild(o),t.menuContainer.appendChild(n)})),this.menuItemsUpdated=!1)}},{key:"show",value:function(){for(var t=0,e=0,n=arguments.length,o=new Array(n),i=0;iwindow.innerWidth&&(t-=a),e+l>window.innerHeight&&(e-=l),this.menuContainer.style.left=t+"px",this.menuContainer.style.top=e+"px"}},{key:"hide",value:function(){this.menuContainer.style.display="none",this.menuCover.style.display="none"}},{key:"bindToDom",value:function(t){var e,n=this;t.addEventListener("contextmenu",(function(t){t.preventDefault(),n.show(t)})),a&&(t.addEventListener("touchstart",(function(t){document.body.classList.add("isekai-contextmenu-ios-longpress"),e=setTimeout((function(){t.preventDefault(),n.show({x:t.pageX-window.scrollX,y:t.pageY-window.scrollY})}),200)})),t.addEventListener("touchend",(function(t){document.body.classList.remove("isekai-contextmenu-ios-longpress"),e&&clearInterval(e)})))}}],o&&n(e.prototype,o),Object.defineProperty(e,"prototype",{writable:!1}),t}();function s(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);nt.length)&&(e=t.length);for(var n=0,o=new Array(e);n=0&&l.priority