/*! * artplayer-plugin-document-pip.js v1.0.0 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ !function(e,t,r,n,o,i,c,a){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof u[n]&&u[n],s=l.i||{},f=l.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!f[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[n]&&u[n];if(!r&&i)return i(t,!0);if(l)return l(t,!0);if(p&&"string"==typeof t)return p(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}s.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},s.cache={};var a=f[t]=new d.Module(t);e[t][0].call(a.exports,s,a,a.exports,u)}return f[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=p,this.exports={}},d.modules=e,d.cache=f,d.parent=l,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=s,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return u[n]}}),u[n]=d;for(var y=0;y0&&void 0!==arguments[0]?arguments[0]:{},t=(0,c._)({width:480,height:270,fallbackToVideoPiP:!0,placeholder:"Playing in Document Picture-in-Picture"},e);return function(e){var r,n="documentPictureInPicture"in window&&"function"==typeof(null==(r=window.documentPictureInPicture)?void 0:r.requestWindow),o=e.proxy,c=e.icons,u=e.i18n,l=e.template.$player,s=e.constructor.utils,f=s.append,p=s.tooltip,d=s.addClass,y=s.removeClass,h={win:null,originalParent:null,originalNext:null,currentDoc:null,placeholder:null};function _(){return(0,i._)(function(){var r,o,i,c,u,s,f,p;return(0,a._)(this,function(a){switch(a.label){case 0:if(!n&&t.fallbackToVideoPiP)return e.pip=!0,console.warn("[artplayer-plugin-document-pip] Document Picture-in-Picture is not supported, falling back to Video Picture-in-Picture"),[2];if(h.win)return[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,window.documentPictureInPicture.requestWindow({width:t.width,height:t.height})];case 2:h.win=i=a.sent(),h.currentDoc=i.document,h.placeholder=document.createElement("div"),h.placeholder.className="artplayer-document-pip-placeholder",h.placeholder.style.cssText="display:flex;justify-content:center;align-items:center;width:100%;height:100%;",h.placeholder.textContent=t.placeholder,h.originalParent=l.parentNode,h.originalNext=l.nextSibling,h.originalParent.insertBefore(h.placeholder,h.originalNext),(c=i.document.createElement("div")).id="__art_dpip_root",i.document.body.appendChild(c);var y=i.document,_=y.createElement("style");if(_.textContent="\n html, body { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; }\n #__art_dpip_root { position:absolute; inset:0; display:flex; }\n #__art_dpip_root > * { width:100% !important; height:100% !important; }\n ",y.head.appendChild(_),!y.querySelector('meta[name="viewport"]')){var v=y.createElement("meta");v.name="viewport",v.content="width=device-width,initial-scale=1",y.head.appendChild(v)}try{document.querySelectorAll('link[rel="stylesheet"]').forEach(function(e){var t=y.createElement("link");t.rel="stylesheet",t.href=e.href,e.media&&(t.media=e.media),e.crossOrigin&&(t.crossOrigin=e.crossOrigin),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),y.head.appendChild(t)})}catch(e){}try{document.querySelectorAll("style").forEach(function(e){var t=y.createElement("style");t.textContent=e.textContent,y.head.appendChild(t)})}catch(e){}return u=i.document.adoptNode(l),c.appendChild(u),h.currentDoc=i.document,s=function(){var t;return null==(t=e.resize)?void 0:t.call(e)},f=function(){return m()},i.addEventListener("resize",s),i.addEventListener("pagehide",f),i.addEventListener("unload",f),h.cleanup=function(){i.removeEventListener("resize",s),i.removeEventListener("pagehide",f),i.removeEventListener("unload",f)},d(l,"artplayer-document-pip"),null==(r=(o=e.events).bindGlobalEvents)||r.call(o),e.emit("document-pip",!0),[3,4];case 3:return p=a.sent(),e.notice.show="Document Picture-in-Picture open failed",console.warn("[artplayer-plugin-document-pip] open failed:",p),[3,4];case 4:return[2]}})})()}function m(){if(h.win)try{var t,r,n;if(null==(t=h.cleanup)||t.call(h),h.placeholder){var o=h.placeholder.ownerDocument||document,i=o.adoptNode(l);h.originalParent.insertBefore(i,h.placeholder),h.placeholder.remove(),h.placeholder=null,h.currentDoc=o}h.win.close(),h.win=null,y(l,"artplayer-document-pip"),null==(r=(n=e.events).bindGlobalEvents)||r.call(n),e.emit("document-pip",!1)}catch(t){e.notice.show="Document Picture-in-Picture close failed",console.warn("[artplayer-plugin-document-pip] close failed:",t)}}function v(){h.win?m():_()}return e.controls.add({name:"document-pip",position:"right",index:40,tooltip:e.i18n.get("PIP Mode"),mounted:function(t){f(t,c.pip),o(t,"click",v),e.on("document-pip",function(e){p(t,u.get(e?"Exit PIP Mode":"PIP Mode"))})}}),e.on("destroy",m),{name:"artplayerPluginDocumentPip",get isSupported(){return n},get isActive(){return!!h.win},open:_,close:m,toggle:v}}}if("undefined"!=typeof window&&(window.artplayerPluginDocumentPip=s),"undefined"!=typeof document){var f="artplayer-plugin-document-pip",p=document.getElementById(f);p||((p=document.createElement("style")).id=f,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){document.head.appendChild(p)}):(document.head||document.documentElement).appendChild(p)),p.textContent=l.default}},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","bundle-text:./style.less":"kgQZb","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,t,r,n){"use strict";function o(e,t,r,n,o,i,c){try{var a=e[i](c),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}r._=function(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var c=e.apply(t,r);function a(e){o(c,n,i,a,u,"next",e)}function u(e){o(c,n,i,a,u,"throw",e)}a(void 0)})}}},{}],kyoEj:[function(e,t,r,n){"use strict";var o=e("9f9b8a24218ee51e");r._=function(e){for(var t=1;tt.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,n=Object.getOwnPropertySymbols(e);ot.indexOf(n[o])&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function s(e,t,r,n){var o,c=arguments.length,a=c<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if(("undefined"==typeof Reflect?"undefined":(0,i._)(Reflect))==="object"&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(a=(c<3?o(a):c>3?o(t,r,a):o(t,r))||a);return c>3&&a&&Object.defineProperty(t,r,a),a}function f(e,t){return function(r,n){t(r,n,e)}}function p(e,t,r,n,o,c){function a(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var u,l=n.kind,s="getter"===l?"get":"setter"===l?"set":"value",f=!t&&e?n.static?e:e.prototype:null,p=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),d=!1,y=r.length-1;y>=0;y--){var h={};for(var _ in n)h[_]="access"===_?{}:n[_];for(var _ in n.access)h.access[_]=n.access[_];h.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");c.push(a(e||null))};var m=(0,r[y])("accessor"===l?{get:p.get,set:p.set}:p[s],h);if("accessor"===l){if(void 0===m)continue;if(null===m||(void 0===m?"undefined":(0,i._)(m))!=="object")throw TypeError("Object expected");(u=a(m.get))&&(p.get=u),(u=a(m.set))&&(p.set=u),(u=a(m.init))&&o.unshift(u)}else(u=a(m))&&("field"===l?o.unshift(u):p[s]=u)}f&&Object.defineProperty(f,n.name,p),d=!0}function d(e,t,r){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c}function j(){for(var e=[],t=0;t1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=o[e](t)).value instanceof E?Promise.resolve(r.value.v).then(u,l):s(i[0][2],r)}catch(e){s(i[0][3],e)}}function u(e){a("next",e)}function l(e){a("throw",e)}function s(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function D(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:E(e[n](t)),done:!1}:o?o(t):t}:o}}function I(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=g(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,o){var i,c,a;i=n,c=o,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){i({value:e,done:a})},c)})}}}function T(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var k=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},C=function(e){return(C=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function M(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=C(e),n=0;n