UNPKG

db-lgtv-focus-engine

Version:

the Best TV focus engine

1 lines 27.5 kB
(()=>{var __webpack_modules__={18:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=class{constructor(e,t){this.engine=e,this.id=t.getAttribute("db-id")||window.getIdByDom(t),this.el=t,this.cacheable=!!t.hasAttribute("db-cacheable")&&(t.getAttribute("db-cacheable")||"focus"),this.left_exit=null===t.getAttribute("db-left-forbid"),this.right_exit=null===t.getAttribute("db-right-forbid"),this.top_exit=null===t.getAttribute("db-top-forbid"),this.bottom_exit=null===t.getAttribute("db-bottom-forbid"),this.rect=t.getBoundingClientRect(),this.initLeafs()}initLeafs(){this.child=[],this.engine.leaf_pool.forEach((e=>{if(this.el.contains(e.el)){if(this.child.push(e),e.parent)return e.parent.el.contains(this.el)?(this.parent=e.parent,void(e.parent=this)):void(e.parent.parent=this);e.parent=this}})),setTimeout((()=>{this.cacheable&&!this.cache&&this.child.length>0&&(this.child.find((e=>e.el.hasAttribute("db-default-cache")))||this.child[0]).cache()}),0),this.el.hasAttribute("db-freeze")&&this.freeze()}focus(){let e=this.engine.findFocusedLeaf();e&&e.parent===this||(this.el.setAttribute("db-child-focus",""),this.el.dispatchEvent(new Event("focus")))}blur(){this.el.removeAttribute("db-child-focus"),this.el.dispatchEvent(new Event("blur"))}freeze(){this.child.forEach((e=>e.freeze({render:!1}))),this.engine.render()}unfreeze(){this.child.forEach((e=>e.unfreeze({render:!1}))),this.engine.render()}clear(){this.child.forEach((e=>{e.el.removeAttribute("db-focus")}))}}},782:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var _Trunk__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(18);function getRealWidth(e){let t=getComputedStyle(e);return parseInt(t.marginRight)+parseInt(t.marginLeft)+e.offsetWidth}function getRealHeight(e){let t=getComputedStyle(e);return parseInt(t.marginTop)+parseInt(t.marginBottom)+e.offsetHeight}class LongScroll extends _Trunk__WEBPACK_IMPORTED_MODULE_0__.Z{constructor(e,t){super(e,t),this.key=this.el.getAttribute("db-data"),e||(e={}),e[this.key]&&e[this.key].scroll.el===this.el||this.initScroll()}render(){let _o=this.engine[this.key],current_row=Math.floor(_o.focused_index/_o.row_sum),start_index=_o.row_sum*(current_row-_o.column_sum);start_index<0&&(start_index=0);let end_index=_o.row_sum*(current_row+_o.column_sum+1);end_index>this.engine[this.key].data.length&&(end_index=this.engine[this.key].data.length,this.el.dispatchEvent(new Event("touchBottom")));let el_list=_o.data.slice(start_index,end_index).map((e=>(e.dom||(e.dom=this.convertDataToDom(e)),e.dom))),_f=document.createDocumentFragment(),top=document.createElement("div");top.style.width="100%",top.style.height=start_index/_o.row_sum*_o.item_height+"px";let bottom=document.createElement("div");bottom.style.width="100%",bottom.style.height="50px",_f.appendChild(top),el_list.forEach((e=>{_f.appendChild(e)})),_f.appendChild(bottom);let if_el_list=_f.querySelectorAll("[db-if]");if_el_list.forEach((element=>{eval(element.getAttribute("db-if"))||element.remove()}));let style_el_list=_f.querySelectorAll("[db-style]");style_el_list.forEach((e=>{e.style.cssText=e.getAttribute("db-style")}));let class_el_list=_f.querySelectorAll("[db-class]");return class_el_list.forEach((e=>{let t=e.getAttribute("class"),i=" "+e.getAttribute("db-class"),n=t.concat(i);e.setAttribute("class",n)})),this.el.innerHTML="",this.el.appendChild(_f),this.el.children.forEach(((e,t)=>{let i=start_index+t-1,n=()=>{_o.focused_index=i,this.render()};e.handler&&e.removeEventListener("focus",e.handler),e.addEventListener("focus",n),e.handler=n})),!0}convertDataToDom(data){if(!data)return"";let _d=document.createElement("div");return _d.innerHTML=this.engine[this.key].template.replace("db-focus","").replace(/\[item.*?\]/g,(function(key){return eval("data"+key.slice(5,key.length-1))})),_d.children[0]}initScroll(){this.engine[this.key]={scroll:this,template:this.el.innerHTML,focused_index:0,row_sum:Math.floor(this.el.offsetWidth/getRealWidth(this.el.children[0])),column_sum:Math.ceil(this.el.offsetHeight/getRealHeight(this.el.children[0])),item_height:getRealHeight(this.el.children[0]),data:[]},this.el.innerHTML="",Object.defineProperty(this.engine[this.key],"data",{get:()=>this.engine["$"+this.el.getAttribute("db-data")]||[],set:e=>{this.engine["$"+this.el.getAttribute("db-data")]=e,this.render()},configurable:!0})}}const __WEBPACK_DEFAULT_EXPORT__=LongScroll},731:(e,t,i)=>{"use strict";function n(e,t){this.x=e,this.y=t}n.prototype.getDistance=function(e){let t=Math.abs(e.x-this.x),i=Math.abs(e.y-this.y);return Math.sqrt(Math.pow(t,2)+Math.pow(i,2))},n.prototype.getWeightDistance=function(e,t){let i=Math.abs(e.x-this.x),n=Math.abs(e.y-this.y);return["top","bottom"].includes(t)&&(n*=4),["left","right"].includes(t)&&(i*=2),Math.sqrt(Math.pow(i,2)+Math.pow(n,2))};const o=n,l=class{constructor(e,t){this.engine=e,this.id=t.getAttribute("db-id")||window.getIdByDom(t),this.rect=t.getBoundingClientRect(),this.el=t,this.parent=null,t.hasAttribute("db-freeze")&&this.freeze(),t.hasAttribute("db-block")&&(this.block=t.getAttribute("db-block")),t.hasAttribute("db-inline")&&(this.inline=t.getAttribute("db-inline")),t.onclick=()=>{this.engine.focused_map[window.location.href]===this.id?this.ok():this.focus()},e.options.MOUSE_FOCUS&&(t.onmouseenter=()=>{window._onmouseenter_t&&clearTimeout(window._onmouseenter_t),window._onmouseenter_t=setTimeout((()=>{window.is_scrolling||this.focus({noquick:!0})}),300)})}findAllNeighbor(){this.findNeighbor("top"),this.findNeighbor("bottom"),this.findNeighbor("left"),this.findNeighbor("right")}clearAllNeighbor(){this.left=null,this.right=null,this.top=null,this.bottom=null}isLeafVisibleFor(e=this){if(!this.el)return!1;if("none"===this.el.style.display)return!1;if(null===this.el.offsetParent)return!1;if(this.parent&&this.parent instanceof this.engine.Trunk){if(this.parent===e.parent)return!0;if(this.rect.left-this.parent.rect.left>this.parent.el.offsetWidth-this.el.offsetWidth/2)return!1;if(this.rect.left-this.parent.rect.left<-this.el.offsetWidth/2)return!1;if(this.rect.top-this.parent.rect.top>this.parent.el.offsetHeight-this.el.offsetHeight/2)return!1;if(this.rect.top-this.parent.rect.top<-this.el.offsetHeight/2)return!1}return!0}findNeighbor(e,t=this.parent){if(this[e]=null,function(e){if(!this.el)return;let t=this.el.getAttribute(`db-${e}`);if("null"==t)return!0;if(!t)return;let i=this.engine.leaf_pool.find((e=>e.id===t));return i?(this[e]=i,i):void 0}.apply(this,arguments))return;let i=(t?t.child:null)||this.engine.leaf_pool;i=i.filter((e=>e.isLeafVisibleFor(this)));let n={top:this.rect.left+this.rect.width/2,bottom:this.rect.left+this.rect.width/2,left:this.rect.left,right:this.rect.left+this.rect.width}[e],l={top:this.rect.top,bottom:this.rect.top+this.rect.height,left:this.rect.top+this.rect.height/2,right:this.rect.top+this.rect.height/2}[e];this.point=new o(n,l);let r=null;if(i.filter((e=>!e.freezed)).forEach((t=>{let i={top:t.rect.left+t.rect.width/2,bottom:t.rect.left+t.rect.width/2,left:t.rect.left+t.rect.width,right:t.rect.left}[e],s={top:t.rect.top+t.rect.height,bottom:t.rect.top,left:t.rect.top+t.rect.height/2,right:t.rect.top+t.rect.height/2}[e],c=new o(i,s).getWeightDistance(this.point,e);"top"===e&&s>l+2||"bottom"===e&&s<l-2||"left"===e&&i>n+2||"right"===e&&i<n-2||(null===r||c<r)&&(r=c,this[e]=t)})),t&&!this[e]){if(t[`${e}_exit`]&&this.findNeighbor(e,t.parent||0),t instanceof this.engine.LongScroll)return;let i="touch"+e.charAt(0).toUpperCase()+e.slice(1);t.el.dispatchEvent(new Event(i))}}blur(){this.el.removeAttribute("db-focus"),this.el.dispatchEvent(new Event("blur")),this.engine.focused_map[window.location.href]=void 0}focus({behavior:e,noquick:t}={}){if(this.engine.leaf_pool.includes(this)){if(this.engine.focused_map[window.location.href]!==this.id){this.engine.onFocus&&this.engine.onFocus(this);let i=this.engine.findFocusedLeaf(),n=this;for(;n.parent;){n=n.parent,n.focus();let e=new Event("change");e.leaf=this,n.el.dispatchEvent(e)}if(i){i.blur();let e=i;for(;e.parent;)e=e.parent,e.el.contains(this.el)||e.blur()}let o=document.querySelectorAll("[db-focus]");Array.from(o).forEach((e=>{e.removeAttribute("db-focus")})),this.engine.history.push({url:window.location.href,cmd:"focus",leaf_id:this.id}),setTimeout((()=>{this.el.dispatchEvent(new Event("focus"))})),this.engine.focused_map[window.location.href]=this.id,this.el.scrollIntoView({behavior:e||this.engine.options.SCROLL_BEHAVIOR,block:this.block||"center",inline:this.inline||"center",speed:!t&&this.engine.is_smooth_scrolling?this.engine.options.KEY_SPEED:void 0,msg:"常规移动"}),this.engine.$nextScroll((()=>{this.engine.leaf_pool.forEach((e=>e.rect=e.el.getBoundingClientRect())),this.engine.trunk_pool.forEach((e=>e.rect=e.el.getBoundingClientRect())),this.findAllNeighbor()}))}this.parent&&"focus"===this.parent.cacheable&&this.cache(),this.el.setAttribute("db-focus","")}}cache(){this.parent&&this.parent.cacheable&&(this.parent.cache&&this.parent.cache.uncache(),this.engine.cached_map[window.location.href]||(this.engine.cached_map[window.location.href]={}),this.engine.cached_map[window.location.href][this.id]=!0,this.parent.cache=this,this.el.setAttribute("db-cache",""))}uncache(){this.parent&&this.parent.cacheable&&(this.engine.cached_map[window.location.href]||(this.engine.cached_map[window.location.href]={}),delete this.engine.cached_map[window.location.href][this.id],this.el.removeAttribute("db-cache"))}freeze({render:e=!0}={}){this.freezed=!0,this.engine.freezed_map[window.location.href]||(this.engine.freezed_map[window.location.href]={}),this.engine.freezed_map[window.location.href][this.id]||(this.engine.freezed_map[window.location.href][this.id]=!0,e&&this.engine.render())}unfreeze({render:e=!0}={}){this.freezed=!1,this.engine.freezed_map[window.location.href]||(this.engine.freezed_map[window.location.href]={}),this.engine.freezed_map[window.location.href][this.id]&&(delete this.engine.freezed_map[window.location.href][this.id],e&&this.engine.render())}ok(){this.parent&&"click"===this.parent.cacheable&&this.cache(),this.el.dispatchEvent(new Event("ok"));let e=this;for(;e.parent;){e=e.parent;let t=new Event("ok");t.leaf=this,e.el.dispatchEvent(t)}}};var r=i(18),s=i(782);const c=class extends l{constructor(e,t){super(e,t)}focus(){l.prototype.focus.call(this),this.el.focus()}blur(){l.prototype.blur.call(this),this.el.blur()}},a={install:function(e){let t,i;e.options.LOADING?t=e.options.LOADING:(t=document.createElement("div"),t.className="db-loading"),i=document.createElement("div"),i.className="db-loading-shadow",e.options.SHADOW?i.style.background="string"==typeof e.options.SHADOW?e.options.SHADOW:"#22272B":i.style.background="transparent",i.appendChild(t);let n=document.createElement("style");n.type="text/css",n.innerHTML='\n .db-loading-shadow {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 1000;\n height: 100vh;\n width: 100vw;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .db-loading {\n width: 0.8rem;\n height: 0.8rem;\n background: url("https://jt.dangbei.net/lg/series/images/loading.png");\n background-size: 100% 100%;\n animation: load-effect 2s infinite linear;\n }\n \n @keyframes load-effect {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n \n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n }',document.body.appendChild(i),document.body.appendChild(n),i.style.display="none",window["焦点框架-loading-加载中"]=!1,window["焦点框架-loading-加载栈"]=0,e.$startLoading=({LOADING:e,SHADOW:n=!0}={SHADOW:!0})=>{window["焦点框架-loading-加载栈"]++,1===window["焦点框架-loading-加载栈"]&&(i.style.display="flex",e&&(t=e),i.style.background=n?"string"==typeof n?n:"#22272B":"transparent",window["焦点框架-loading-加载中"]=!0)},e.$endLoading=()=>{window["焦点框架-loading-加载栈"]--,window["焦点框架-loading-加载栈"]<=0&&(window["焦点框架-loading-加载栈"]=0,i.style.display="none",window["焦点框架-loading-加载中"]=!1)}}},d=a,h={install:function(e){let t=document.createElement("div"),i=document.createElement("style");i.type="text/css",i.innerHTML="\n .db-dialog-shadow {\n height: 100vh;\n width: 100vw;\n position: fixed;\n z-index: 9999;\n top: 0;\n left: 0;\n background-color: rgba(0, 0, 0, 0.7);\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .db-dialog-shadow-box {\n width: 3.9375rem;\n height: 2.14583rem;\n background: #3d3d3d;\n border-radius: 0.05208rem;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n .db-dialog-shadow-box-title {\n font-size: 0.20833rem;\n font-weight: 400;\n color: #ffffff;\n }\n .db-dialog-shadow-box-content {\n margin-top: 0.20833rem;\n font-size: 0.16667rem;\n font-weight: 400;\n color: rgba(238, 238, 238, 0.8);\n }\n .db-dialog-shadow-box-btns {\n width: 90%;\n display: flex;\n align-items: center;\n justify-content: space-around;\n margin-top: 0.20833rem;\n }\n .db-dialog-shadow-box-btns-item {\n width: 1.39583rem;\n height: 0.41667rem;\n background: rgba(255, 255, 255, 0.1);\n box-shadow: 0 0.02604rem 0.02604rem 0 rgb(0 0 0 / 25%);\n border-radius: 0.26042rem;\n border-width: 0;\n font-size: 0.16667rem;\n font-weight: 400;\n color: rgba(238, 238, 238, 0.6);\n line-height: 0.23438rem;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .db-dialog-shadow-box-btns-item[db-focus] {\n color: #000000;\n background: #ffffff;\n }",e.$dialog=function(e){t.innerHTML=`\n <div class="db-dialog-shadow">\n <div class="db-dialog-shadow-box">\n <div class="db-dialog-shadow-box-title">${e.title}</div>\n <div class="db-dialog-shadow-box-content">${e.content}</div>\n <div class="db-dialog-shadow-box-btns"></div>\n </div>\n </div>\n `;let n=t.getElementsByClassName("db-dialog-shadow-box-btns")[0];e.buttons.map((e=>{let n=document.createElement("div");n.innerHTML=`<div class="db-dialog-shadow-box-btns-item ${e.class}" db-leaf>${e.label}</div>`;let o=n.children[0],l=e.callback;return e.callback=()=>{document.body.removeChild(t),document.body.removeChild(i),this.leaf_pool.forEach((e=>{e.unfreeze()})),l()},o.addEventListener("ok",e.callback||(()=>{})),e.el=o,o})).forEach((e=>{n.appendChild(e)})),this.leaf_pool.forEach((e=>{e.freeze()})),setTimeout((()=>{let t=e.buttons.find((e=>e.default))||e.buttons[0];if(!t)return;let i=this.findLeafByDom(t.el);i&&i.focus()})),document.body.appendChild(t),document.body.appendChild(i)}}},f=h;const u=JSON.parse('{"SCROLL_BEHAVIOR":"smooth","ROUTER_CACHE":true,"MOUSE_FOCUS":true,"KEY_TYPE":"down","KEY_SPEED":70,"SCROLL_SPEED":400,"KEYS":{"left":[37],"top":[38],"bottom":[40],"right":[39],"ok":[83,13]},"SHADOW":true}');class p{constructor(e={}){let t={...u,...e};this.initData(t),this.use(d),this.use(f),this.activated(),window.$engine=this}use(e){e.install(this)}initData(e){this.options=e,this.history=[],this.leaf_pool=[],this.trunk_pool=[],this.cached_map={},this.focused_map={},this.freezed_map={},this.last_key_down=null,this.last_key_up=null,this.history_focused_id=null,this.$tick_callback_stack=[],this.$scroll_callback_stack=[]}findLeafById(e){return this.leaf_pool.find((t=>t.id===e))}findLeafByDom(e){let t=e.getAttribute("db-id")||window.getIdByDom(e);return this.findLeafById(t)}findTrunkById(e){return this.trunk_pool.find((t=>t.id===e))}findTrunkByDom(e){let t=window.getIdByDom(e);return this.findTrunkById(t)}findFocusedLeaf(){return this.focused_map[window.location.href]?this.findLeafById(this.focused_map[window.location.href]):null}activated(){var e;(function(e){let t=(i=t=>{if(e.last_key_down=t,window["焦点框架-loading-加载中"])return;let i=e.findFocusedLeaf();if(!i)return;let n={};for(let t in e.options.KEYS)for(let i of e.options.KEYS[t])n[i]=t;let o=new Event("keydown"),l=!0;if(o.code=t.which,o.preventDefault=()=>{l=!1},i.el.dispatchEvent(o),l&&n[t.which])switch(t.preventDefault(),n[t.which]){case"left":case"right":case"top":case"bottom":{i.el.dispatchEvent(new Event(n[t.which]));let o=i[n[t.which]];if(!o&&(e.leaf_pool.forEach((e=>e.rect=e.el.getBoundingClientRect())),e.trunk_pool.forEach((e=>e.rect=e.el.getBoundingClientRect())),i.findAllNeighbor(),o=i[n[t.which]],!o))break;o.parent&&o.parent!==i.parent&&o.parent.cacheable&&o.parent.cache?o.parent.cache.focus():o.focus();break}case"ok":setTimeout((()=>{"down"===e.options.KEY_TYPE&&i.ok()}),0)}},n=e.options.KEY_SPEED,o=Date.now(),function(){var e=this,t=arguments;Date.now()-o>=n&&(i.apply(e,t),o=Date.now())});var i,n,o;document.onkeydown=t})(this),e=this,document.onkeyup=t=>{if(e.last_key_up=t,window["焦点框架-loading-加载中"])return;let i=e.findFocusedLeaf();if(!i)return;let n={};for(let t in e.options.KEYS)for(let i of e.options.KEYS[t])n[i]=t;let o=new Event("keyup"),l=!0;o.code=t.which,o.preventDefault=()=>{l=!1},i.el.dispatchEvent(o),l&&n[t.which]&&(t.preventDefault(),"ok"===n[t.which])&&setTimeout((()=>{if("up"===e.options.KEY_TYPE&&(i.el.dispatchEvent(new Event("ok")),i.parent)){let e=new Event("ok");e.leaf=i,i.parent.el.dispatchEvent(e)}}))},window.scroll_sum=0,document.onmousewheel=function(e){if(e.preventDefault(),clearTimeout(window._onscroll_t),window.is_scrolling=!0,window._onscroll_t=setTimeout((()=>{window.is_scrolling=!1}),1500),(e=e||window.event).wheelDelta){if(e.wheelDelta>0&&(window.scroll_sum+=e.wheelDelta,window.scroll_sum>100)){window.scroll_sum=0;let e=new Event("keydown");e.which=38,e.keyCode=38,e.key="ArrowUp",e.code="ArrowUp",document.dispatchEvent(e)}if(e.wheelDelta<0&&(window.scroll_sum+=e.wheelDelta,window.scroll_sum<-100)){window.scroll_sum=0;let e=new Event("keydown");e.which=40,e.keyCode=40,e.key="ArrowDown",e.code="ArrowDown",document.dispatchEvent(e)}}else e.detail&&(e.detail,e.detail)},function(e){e._observer&&e._observer.disconnect();const t=document.getElementsByTagName("html")[0],i=new MutationObserver((function(t){e.dont_render?e.dont_render=!1:e.render()}));i.observe(t,{childList:!0,subtree:!0}),e._observer=i}(this),function(e){window.onhashchange=function(t){e.options.ROUTER_CACHE||delete e.focused_map[window.location.href],window.cancelAnimationFrame(e.animation_id),window.$engine.is_smooth_scrolling=!1,e.findFocusedLeaf().el.scrollIntoView({behavior:"instant",block:this.block||"center",inline:this.inline||"center",msg:"瞬移初始化焦点位置"})}}(this),this.render()}deactivated(){document.onkeydown=e=>{},document.onkeyup=e=>{},document.onmousewheel=e=>{},this._observer.disconnect(),window.onhashchange=e=>{}}destroyed(){this.deactivated(),this.forget()}forget({cache:e,focus:t,freeze:i}={cache:!0,focus:!0,freeze:!0}){e&&delete this.cached_map[window.location.href],t&&delete this.focused_map[window.location.href],i&&delete this.freezed_map[window.location.href],this.render()}clear(){let e=document.querySelectorAll("[db-focus]");Array.from(e).forEach((e=>{e.removeAttribute("db-focus")}));let t=document.querySelectorAll("[db-child-focus]");Array.from(t).forEach((e=>{e.removeAttribute("db-child-focus")}));let i=document.querySelectorAll("[db-freeze]");Array.from(i).forEach((e=>{e.removeAttribute("db-freeze")}));let n=document.querySelectorAll("[db-cache]");Array.from(n).forEach((e=>{e.removeAttribute("db-cache")}))}render(){this.clear();let e=document.querySelectorAll("[db-leaf]");this.leaf_pool=Array.from(e).map((e=>"INPUT"===e.tagName?new c(this,e):new l(this,e))).filter((e=>e));let t=[...Array.from(document.querySelectorAll("[db-trunk]")),...Array.from(document.querySelectorAll("[db-scroll]")),...Array.from(document.querySelectorAll("[db-long-scroll]"))];this.trunk_pool=t.map((e=>e.hasAttribute("db-scroll")?new r.Z(this,e):e.hasAttribute("db-long-scroll")?new s.Z(this,e):new r.Z(this,e))),this.remember(),this.$tickCallback()}remember(){let e=this.cached_map[window.location.href];for(let t in e){let e=this.findLeafById(t);e&&e.cache()}let t=this.freezed_map[window.location.href];for(let e in t){let t=this.findLeafById(e);t&&t.freeze()}let i=this.focused_map[window.location.href],n=this.findLeafById(i);n&&!n.freezed||(n=this.leaf_pool.filter((e=>!e.freezed&&e.isLeafVisibleFor()&&e.el.hasAttribute("db-default")))[0]||this.leaf_pool.filter((e=>!e.freezed&&e.isLeafVisibleFor()))[0]),n&&n.focus()}freeze(){this.leaf_pool.forEach((e=>e.freeze({render:!1}))),this.render()}unfreeze(){this.leaf_pool.forEach((e=>e.unfreeze({render:!1}))),this.render()}$nextTick(e){this.$tick_callback_stack.push(e)}$tickCallback(){let e=this.$tick_callback_stack;this.$tick_callback_stack=[],e.forEach((e=>{e()}))}$nextScroll(e){this.$scroll_callback_stack.push(e)}$scrollCallback(){let e=this.$scroll_callback_stack;this.$scroll_callback_stack=[],e.forEach((e=>{e()}))}reverse(){let e=null,t=0;for(;t<2;){let i=this.history.pop();"focus"===i.cmd&&(e=i,t++)}if(e.leaf_id){let t=this.findLeafById(e.leaf_id);t&&t.focus()}}}p.prototype.Leaf=l,p.prototype.Trunk=r.Z,p.prototype.LongScroll=s.Z;const _=p;var b=i(905),w=i.n(b);let g=document.body.innerHTML,m=document.createElement("style");document.head.appendChild(m),m.sheet.insertRule(".db-focus-engine::-webkit-scrollbar { width: 0 }",0);let y=document.createElement("div");y.className="db-focus-engine",y.style.height="100vh",y.style["overflow-y"]="scroll",y.style.width="100vw",y.style["overflow-x"]="hidden",y.innerHTML=g,document.body.innerHTML="",document.body.appendChild(y),_.prototype.$box=y,w().polyfill(),window.FEngine=_,window.getIdByDom=e=>{let t="db",i=e,n=e.parentNode;for(;n;)t=`${Array.prototype.indexOf.call(n.childNodes,i)}-${t}`,i=n,n=n.parentNode;return t}},905:e=>{!function(){"use strict";e.exports={polyfill:function(){var e,t=window,i=document,n=t.HTMLElement||t.Element,o={scroll:t.scroll||t.scrollTo,scrollBy:t.scrollBy,elementScroll:n.prototype.scroll||s,scrollIntoView:n.prototype.scrollIntoView},l=t.performance&&t.performance.now?t.performance.now.bind(t.performance):Date.now,r=(e=t.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(e)?1:0);function s(e,t){this.scrollLeft=e,this.scrollTop=t}function c(e){if(null===e||"object"!=typeof e||void 0===e.behavior||"auto"===e.behavior||"instant"===e.behavior)return!0;if("object"==typeof e&&"smooth"===e.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+e.behavior+" is not a valid value for enumeration ScrollBehavior.")}function a(e,t){if(e)return"Y"===t?e.clientHeight+r<e.scrollHeight:"X"===t?e.clientWidth+r<e.scrollWidth:void 0}function d(e,i){var n=t.getComputedStyle(e,null)["overflow"+i];return"auto"===n||"scroll"===n}function h(e){var t=a(e,"Y")&&d(e,"Y"),i=a(e,"X")&&d(e,"X");return t||i}function f(e){for(e=e.parentNode;e!==i.body&&!1===h(e);)e=e.parentNode||e.host;return e===i.body?null:e}function u(e){if(!e)return!1;for(;e!==i.body&&"fixed"!==t.getComputedStyle(e).position;)e=e.parentNode;return e!==i.body}function p(e){var i,n,o,r,s=(l()-e.startTime)/(window.$engine.scroll_speed||window.$engine.options.SCROLL_SPEED);r=s=s>1?1:s,i=.5*(1-Math.cos(Math.PI*r)),n=e.startX+(e.x-e.startX)*i,o=e.startY+(e.y-e.startY)*i,e.method.call(e.scrollable,n,o),n!==e.x||o!==e.y?window.$engine.animation_id=t.requestAnimationFrame(p.bind(t,e)):window.$engine.$scrollCallback()}function _(e,n,r){var c,a,d,h,f=l();clearTimeout(window.is_smooth_scrolling_t),window.$engine.is_smooth_scrolling=!0,window.is_smooth_scrolling_t=setTimeout((()=>{window.$engine.scroll_speed&&(window.$engine.scroll_speed=null),window.$engine.is_smooth_scrolling=!1}),window.$engine.options.SCROLL_SPEED/2),e===i.body?(c=t,a=t.scrollX||t.pageXOffset,d=t.scrollY||t.pageYOffset,h=o.scroll):(c=e,a=e.scrollLeft,d=e.scrollTop,h=s),p({scrollable:c,method:h,startTime:f,startX:a,startY:d,x:n,y:r})}t.scroll=t.scrollTo=function(){void 0!==arguments[0]&&(!0!==c(arguments[0])?_.call(t,i.body,void 0!==arguments[0].left?~~arguments[0].left:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:t.scrollY||t.pageYOffset):o.scroll.call(t,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:t.scrollY||t.pageYOffset))},t.scrollBy=function(){void 0!==arguments[0]&&(c(arguments[0])?o.scrollBy.call(t,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):_.call(t,i.body,~~arguments[0].left+(t.scrollX||t.pageXOffset),~~arguments[0].top+(t.scrollY||t.pageYOffset)))},n.prototype.scroll=n.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==c(arguments[0])){var e=arguments[0].left,t=arguments[0].top;_.call(this,this,void 0===e?this.scrollLeft:~~e,void 0===t?this.scrollTop:~~t)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},n.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==c(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},n.prototype.scrollIntoView=function(e){e.speed&&(window.$engine.scroll_speed=e.speed);let t=f(this);if(!t)return;let i=t.getBoundingClientRect(),n=this.getBoundingClientRect(),o=0,l=0;switch(e.inline){case"start":o=0;break;case void 0:case"center":o=(i.width-n.width)/2;break;case"end":o=i.width;break;default:if(!(t.scrollWidth-t.clientWidth>parseInt(e.inline)))break;o=parseInt(e.inline)?Math.floor(parseInt(e.inline)/100*i.width):0,delete e.inline}switch(e.block){case"start":l=0;break;case void 0:case"center":l=(i.height-n.height)/2;break;case"end":l=i.height;break;default:if(!(t.scrollHeight-t.clientHeight>parseInt(e.block)))break;l=parseInt(e.block)?Math.floor(parseInt(e.block)/100*i.height):0,delete e.block}t.scrollBy({left:n.left-i.left-o,top:n.top-i.top-l,behavior:e.behavior}),(!u(t)||u(t)&&u(f(t)))&&t.scrollIntoView(e)}}}}()}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](i,i.exports,__webpack_require__),i.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__=__webpack_require__(731)})();