!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/default-location"]=t():e["video/default-location"]=t()}(self,(function(){return function(){var e={543:function(e,t,n){"use strict";n.d(t,{component:function(){return u},E:function(){return r},F:function(){return l}});var o=coreApis.utils.urls,i=coreApis.spinQuery,a=n(492);const s="//www.bilibili.com/video/",l={withTitle:{displayName:"带标题视频页",urls:[s,...o.mediaListUrls]},noTitle:{displayName:"无标题视频页",urls:[...o.bangumiUrls,...o.cheeseUrls]},bnj:{displayName:"拜年纪视频页",urls:[/\/\/www\.bilibili\.com\/festival\/(\d+)bnj/]}},r=lodash.once((()=>{for(const[e,{urls:t}]of Object.entries(l))if((0,o.matchCurrentPage)(t))return e;return null}));class c{constructor(e,t){this.lastMoment=e,this.result=t}}const d=async()=>{const e=6e4,t=(0,i.select)(".bb-comment",{maxRetry:50,queryInterval:600}),n=[e/2,e,3*e].map((e=>({time:e,callback:async e=>{console.warn(`[videoDefaultLocation] waiting more than ${e}ms for the page to load`)}})));return null!==(await async function(e,t){let n={time:0,callback:none},o=null;const i=t[Symbol.iterator](),a=()=>{const e=i.next();if(!e.done){const t=e.value;o=setTimeout((()=>{o=null,n.callback(n.time),n=t,a()}),t.time-n.time)}};a();const s=await e;return null!==o&&clearTimeout(o),new c(n.time,s)}(t,n)).result||(console.error("[videoDefaultLocation] waiting for page load timeout"),!1)},u={name:"videoDefaultLocation",displayName:"视频页默认定位",tags:[componentsTags.video],urlInclude:o.allVideoUrls,description:{"zh-CN":a},extraOptions:()=>Promise.resolve().then(n.bind(n,108)).then((e=>e.default)),options:{locations:{defaultValue:lodash.mapValues(l,(()=>0)),hidden:!0}},entry:async({settings:{options:{locations:e}}})=>{const t=window?.performance?.getEntriesByType("navigation");if(1!==t?.length)return void console.error(`[videoDefaultLocation] 无法处理 PerformanceNavigationTiming 不是一个的情况。url: ${window.location.href}`);if("navigate"!==t[0].type)return;if((0,o.matchCurrentPage)(s)){const e=unsafeWindow.scrollTo;unsafeWindow.scrollTo=()=>{unsafeWindow.scrollTo=e}}const n=r();if(null===n)return void console.error(`[videoDefaultLocation] unknown page type. url: ${window.location.href}`);const i=e[n],a=document.documentElement;(ie?"mdi-unfold-more-horizontal":"mdi-unfold-less-horizontal",r="video-default-location-extend-box-bar-btn-animation";var c=Vue.extend({components:{VIcon:a.VIcon},model:{prop:"hidden",event:"change"},props:{title:{type:String,default:""},size:{type:Number,default:12},hidden:{type:Boolean,default:!0}},data(){return{realHidden:this.hidden,barBottom:!this.hidden,btnIcon:l(this.hidden),btnClass:{[r]:!1}}},watch:{hidden(e){this.setRealHidden(e)}},methods:{setRealHidden(e){e!==this.realHidden&&(this.realHidden=!this.realHidden,this.$emit("change",this.realHidden),this.btnClass[r]=!1,this.$nextTick((()=>{this.btnClass[r]=!0,setTimeout((()=>{this.btnIcon=l(this.realHidden)}),150)})))},onBarBtnAnimationEnd(){this.btnClass[r]=!1}}}),d=n(379),u=n.n(d),f=n(135),v=n.n(f),p={insert:"head",singleton:!1};u()(v(),p),v().locals;function m(e,t,n,o,i,a,s,l){var r,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),o&&(c.functional=!0),a&&(c._scopeId="data-v-"+a),s?(r=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=r):i&&(r=l?function(){i.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:i),r)if(c.functional){c._injectStyles=r;var d=c.render;c.render=function(e,t){return r.call(t),d(e,t)}}else{var u=c.beforeCreate;c.beforeCreate=u?[].concat(u,r):[r]}return{exports:e,options:c}}var h=m(c,s,[],!1,null,null,null);h.options.__file="registry/lib/components/video/default-location/ExtendBox.vue";var b=h.exports,x=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{staticClass:"video-default-location-form-line"},[n("div",{staticClass:"video-default-location-form-item-not-grow"},[e._v("\n 当前位置\n ")]),e._v(" "),n("TextBox",{staticClass:"video-default-location-form-item-grow",attrs:{text:String(e.curPosition),"change-on-blur":"",readonly:"",linear:""}})],1),e._v(" "),n("div",{staticClass:"video-default-location-vertical-space"}),e._v(" "),n("div",{staticClass:"video-default-location-form-line"},[n("VButton",{staticClass:"video-default-location-form-item-grow",on:{click:function(t){return e.$emit("set-default-location",e.curPosition)}}},[e._v("\n 将当前位置设为默认值\n ")])],1),e._v(" "),n("div",{staticClass:"video-default-location-vertical-space"}),e._v(" "),n("div",{staticClass:"video-default-location-form-line"},[n("TextBox",{staticClass:"video-default-location-form-item-grow",attrs:{linear:"","change-on-blur":""},on:{change:e.onLocationInput},model:{value:e.locationInput,callback:function(t){e.locationInput=t},expression:"locationInput"}}),e._v(" "),n("VButton",{on:{click:e.locateTo}},[e._v("\n 定位\n ")])],1),e._v(" "),n("div",{staticClass:"video-default-location-vertical-space"}),e._v(" "),n("div",{staticClass:"video-default-location-form-line"},[n("TextBox",{staticClass:"video-default-location-form-item-grow",attrs:{linear:"","change-on-blur":""},on:{change:e.onOffsetInput},model:{value:e.offsetInput,callback:function(t){e.offsetInput=t},expression:"offsetInput"}}),e._v(" "),n("VButton",{on:{click:e.offsetTo}},[e._v("\n 偏移\n ")])],1)])};x._withStripped=!0;let g=null;const y=()=>Math.round(window.scrollY),w=e=>{const t=parseFloat(e);return isNaN(t)?null:Math.round(t)};var _=m(Vue.extend({components:{VButton:a.VButton,TextBox:a.TextBox},props:{observePosition:{type:Boolean,default:!1},locationLimit:{type:Number,required:!0}},data:()=>({curPosition:y(),locationInput:"0",offsetInput:"0",location:0,offset:0}),created(){this.setupObserveScroll()},beforeDestroy(){g.stop()},methods:{setLocation(e){this.location=e,this.locationInput=String(e)},onLocationInput(e){let t=w(e);null===t?this.setLocation(0):(t=lodash.clamp(t,0,this.locationLimit),this.setLocation(t))},locateTo(){unsafeWindow.scrollTo(0,this.location)},setOffset(e){this.offset=e,this.offsetInput=String(e)},onOffsetInput(e){let t=w(e);null===t?this.setOffset(0):(t=lodash.clamp(t,-this.locationLimit,this.locationLimit),this.setOffset(t))},offsetTo(){unsafeWindow.scrollBy(0,this.offset)},setupObserveScroll(){const e=()=>{this.curPosition=y()};let t=!1;g={start:()=>{t||(e(),window.addEventListener("scroll",e),t=!0)},stop:()=>{t&&(window.removeEventListener("scroll",e),t=!1)}},this.$watch("observePosition",(e=>g[e?"start":"stop"]()),{immediate:!0})}}}),x,[],!1,null,null,null);_.options.__file="registry/lib/components/video/default-location/Advanced.vue";var C=_.exports,T=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"video-default-location-page-type-selector"},[n("VDropdown",{attrs:{items:e.items},on:{change:e.onChange},scopedSlots:e._u([{key:"arrow",fn:function(){return[n("div",{staticClass:"video-default-location-page-type-selector-icon"},[n("VIcon",{attrs:{size:15,icon:"mdi-chevron-down"}})],1)]},proxy:!0}]),model:{value:e.curItem,callback:function(t){e.curItem=t},expression:"curItem"}})],1)};T._withStripped=!0;var S=n(543);const I=lodash.mapValues(S.F,((e,t)=>({name:t,displayName:e.displayName})));var L=Vue.extend({components:{VDropdown:a.VDropdown,VIcon:a.VIcon},model:{prop:"value",event:"change"},props:{value:{type:String,required:!0}},data(){return{items:Object.values(I),curItem:I[this.value]}},watch:{value(e){this.curItem.name!==e&&(this.curItem=I[e])}},methods:{onChange(e){this.$emit("change",e.name)}}}),P=n(786),B=n.n(P),O={insert:"head",singleton:!1},V=(u()(B(),O),B().locals,m(L,T,[],!1,null,null,null));V.options.__file="registry/lib/components/video/default-location/PageTypeSelector.vue";var E=V.exports;let j=null;var N=Vue.extend({components:{TextBox:a.TextBox,ExtendBox:b,Advanced:C,PageTypeSelector:E},props:{componentData:{type:Object,required:!0}},data(){const{options:{locations:e}}=(0,i.getComponentSettings)(this.componentData),t=(0,S.E)()??Object.keys(S.F)[0];return{locations:e,defaultLocation:String(e[t]),hiddenAdvance:!0,observePosition:!1,locationLimit:4e3,pageType:t}},created(){this.setupPanelSwitch()},mounted(){j&&j.start()},beforeDestroy(){j&&j.stop()},methods:{onChangePageType(e){this.defaultLocation=String(this.locations[e])},setDefaultLocation(e){this.locations[this.pageType]=e,this.defaultLocation=String(e)},onChangeDefaultLocation(e){let t=(e=>{const t=parseFloat(e);return isNaN(t)?null:Math.round(t)})(e);null===t?this.setDefaultLocation(0):(t=lodash.clamp(t,0,4e3),this.setDefaultLocation(t))},resetObservePosition(){this.observePosition=!this.hiddenAdvance},setupPanelSwitch(){const e=dq(".component-detail-panel");if(!e)return void console.error("[videoPageOrientation] Could not find element '.component-detail-panel'");const t=()=>{e.classList.contains("open")?this.resetObservePosition():this.observePosition=!1},n=new MutationObserver(t),o={attributeFilter:["class"],attributes:!0};j={start:()=>{t(),n.observe(e,o)},stop:()=>n.disconnect()}}}}),k=n(561),D=n.n(k),A={insert:"head",singleton:!1},$=(u()(D(),A),D().locals,m(N,o,[],!1,null,null,null));$.options.__file="registry/lib/components/video/default-location/Options.vue";var H=$.exports},492:function(e){"use strict";e.exports='打开视频/番剧时自动定位到指定位置\n\n
\n\n位置:距离页面顶部的像素距离\\\n默认位置:打开视频时自动定位到此处\\\n位置测试:查看、调整当前页面所在位置\n\n当前版本限制默认位置的最大值为 4000。\\\n若有其他希望支持的页面,请提交反馈。\\\n脚本不会等待评论完全加载,因此较大的默认位置将无法正确定位。\n\n
\n\n\n'}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var a=t[o]={id:o,exports:{}};return e[o](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o=n(543);return o=o.component}()}));