/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{typeof as t,toConsumableArray as e}from"../_virtual/_rollupPluginBabelHelpers.js";import n from"./debug.js";import r from"./xgplayerTimeRange.js";var o={};function a(e){var n=t(e);return null!==e&&("object"===n||"function"===n)}function i(t,e,n){var r,o,i,c,u,l,s=0,f=!1,m=!1,d=!0,g=!e&&0!==e&&"function"==typeof window.requestAnimationFrame;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=r,a=o;return r=o=void 0,s=e,c=t.apply(a,n)}function v(t,e){return g?(window.cancelAnimationFrame(u),window.requestAnimationFrame(t)):setTimeout(t,e)}function h(t){var n=t-l;return void 0===l||n>=e||n<0||m&&t-s>=i}function y(){var t=Date.now();if(h(t))return w(t);u=v(y,function(t){var n=t-s,r=e-(t-l);return m?Math.min(r,i-n):r}(t))}function w(t){return u=void 0,d&&r?p(t):(r=o=void 0,c)}function x(){for(var t=Date.now(),n=h(t),a=arguments.length,i=new Array(a),d=0;d<a;d++)i[d]=arguments[d];if(r=i,o=this,l=t,n){if(void 0===u)return function(t){return s=t,u=v(y,e),f?p(t):c}(l);if(m)return u=v(y,e),p(l)}return void 0===u&&(u=v(y,e)),c}return e=+e||0,a(n)&&(f=!!n.leading,i=(m="maxWait"in n)?Math.max(+n.maxWait||0,e):i,d="trailing"in n?!!n.trailing:d),x.cancel=function(){void 0!==u&&function(t){if(g)return window.cancelAnimationFrame(t);clearTimeout(t)}(u),s=0,r=l=o=u=void 0},x.flush=function(){return void 0===u?c:w(Date.now())},x.pending=function(){return void 0!==u},x}function c(t,e,n){var r=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return a(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),i(t,e,{leading:r,trailing:o,maxWait:e})}function u(){var t=(document.documentElement.getAttribute("lang")||navigator.language||"zh-cn").toLocaleLowerCase();return"zh-cn"===t&&(t="zh"),t}function l(t,e,n){if(t){var r=t.getAttribute(n);return!(!r||r!==e||"VIDEO"!==t.tagName&&"AUDIO"!==t.tagName)}}o.createDom=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=document.createElement(t);return o.className=r,o.innerHTML=e,Object.keys(n).forEach(function(e){var r=e,a=n[e];"video"===t||"audio"===t||"live-video"===t?a&&o.setAttribute(r,a):o.setAttribute(r,a)}),o},o.createDomFromHtml=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{var a=document.createElement("div");a.innerHTML=t;var i=a.children;return a=null,i.length>0?(i=i[0],r&&o.addClass(i,r),e&&Object.keys(e).forEach(function(t){i.setAttribute(t,e[t])}),i):null}catch(c){return n.logError("util.createDomFromHtml",c),null}},o.hasClass=function(e,n){if(!e||!n)return!1;try{return Array.prototype.some.call(e.classList,function(t){return t===n})}catch(o){var r=e.className&&"object"===t(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+n+"(\\s|$)"))}},o.addClass=function(e,n){if(e&&n)try{n.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(t){t&&e.classList.add(t)})}catch(r){o.hasClass(e,n)||(e.className&&"object"===t(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+n):e.className+=" "+n)}},o.removeClass=function(e,n){if(e&&n)try{n.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(t){t&&e.classList.remove(t)})}catch(r){o.hasClass(e,n)&&n.split(/\s+/g).forEach(function(n){var r=new RegExp("(\\s|^)"+n+"(\\s|$)");e.className&&"object"===t(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")})}},o.toggleClass=function(t,e){t&&e.split(/\s+/g).forEach(function(e){o.hasClass(t,e)?o.removeClass(t,e):o.addClass(t,e)})},o.classNames=function(){for(var t=arguments,e=[],n=function(n){"String"===o.typeOf(t[n])?e.push(t[n]):"Object"===o.typeOf(t[n])&&Object.keys(t[n]).map(function(r){t[n][r]&&e.push(r)})},r=0;r<arguments.length;r++)n(r);return e.join(" ")},o.findDom=function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,r=arguments.length>1?arguments[1]:void 0;try{t=e.querySelector(r)}catch(o){n.logError("util.findDom",o),0===r.indexOf("#")&&(t=e.getElementById(r.slice(1)))}return t},o.getCss=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,!1)[e]},o.padStart=function(t,e,n){for(var r=String(n),o=e|0,a=Math.ceil(o/r.length),i=[],c=String(t);a--;)i.push(r);return i.join("").substring(0,o-c.length)+c},o.format=function(t){if(window.isNaN(t))return"";t=Math.round(t);var e=o.padStart(Math.floor(t/3600),2,0),n=o.padStart(Math.floor((t-3600*e)/60),2,0),r=o.padStart(Math.floor(t-3600*e-60*n),2,0);return("00"===e?[n,r]:[e,n,r]).join(":")},o.event=function(t){if(t.touches){var e=t.touches[0]||t.changedTouches[0];t.clientX=e.clientX||0,t.clientY=e.clientY||0,t.offsetX=e.pageX-e.target.offsetLeft,t.offsetY=e.pageY-e.target.offsetTop}t._target=t.target||t.srcElement},o.typeOf=function(t){return Object.prototype.toString.call(t).match(/([^\s.*]+)(?=]$)/g)[0]},o.deepCopy=function(t,e){if("Object"===o.typeOf(e)&&"Object"===o.typeOf(t))return Object.keys(e).forEach(function(n){"Object"!==o.typeOf(e[n])||e[n]instanceof Node?"Array"===o.typeOf(e[n])?t[n]="Array"===o.typeOf(t[n])?t[n].concat(e[n]):e[n]:t[n]=e[n]:void 0===t[n]||void 0===t[n]?t[n]=e[n]:o.deepCopy(t[n],e[n])}),t},o.deepMerge=function(t,n){return Object.keys(n).map(function(r){var a;"Array"===o.typeOf(n[r])&&"Array"===o.typeOf(t[r])?"Array"===o.typeOf(t[r])&&(a=t[r]).push.apply(a,e(n[r])):o.typeOf(t[r])!==o.typeOf(n[r])||null===t[r]||"Object"!==o.typeOf(t[r])||n[r]instanceof window.Node?null!==n[r]&&(t[r]=n[r]):o.deepMerge(t[r],n[r])}),t},o.getBgImage=function(t){var e=(t.currentStyle||window.getComputedStyle(t,null)).backgroundImage;if(!e||"none"===e)return"";var n=document.createElement("a");return n.href=e.replace(/url\("|"\)/g,""),n.href},o.copyDom=function(t){if(t&&1===t.nodeType){var e=document.createElement(t.tagName);return Array.prototype.forEach.call(t.attributes,function(t){e.setAttribute(t.name,t.value)}),t.innerHTML&&(e.innerHTML=t.innerHTML),e}return""},o.setInterval=function(t,e,n,r){t._interval[e]||(t._interval[e]=window.setInterval(n.bind(t),r))},o.clearInterval=function(t,e){clearInterval(t._interval[e]),t._interval[e]=null},o.setTimeout=function(t,e,n){t._timers||(t._timers=[]);var r=setTimeout(function(){e(),o.clearTimeout(t,r)},n);return t._timers.push(r),r},o.clearTimeout=function(t,e){var n=t._timers;if("Array"===o.typeOf(n)){for(var r=0;r<n.length;r++)if(n[r]===e){n.splice(r,1),clearTimeout(e);break}}else clearTimeout(e)},o.clearAllTimers=function(t){var e=t._timers;"Array"===o.typeOf(e)&&(e.map(function(t){clearTimeout(t)}),t._timerIds=[])},o.createImgBtn=function(t,e,n,r){var a,i,c,u=o.createDom("xg-".concat(t),"",{},"xgplayer-".concat(t,"-img"));(u.style.backgroundImage='url("'.concat(e,'")'),n&&r)&&(["px","rem","em","pt","dp","vw","vh","vm","%"].every(function(t){return!(n.indexOf(t)>-1&&r.indexOf(t)>-1)||(a=parseFloat(n.slice(0,n.indexOf(t)).trim()),i=parseFloat(r.slice(0,r.indexOf(t)).trim()),c=t,!1)}),u.style.width="".concat(a).concat(c),u.style.height="".concat(i).concat(c),u.style.backgroundSize="".concat(a).concat(c," ").concat(i).concat(c),u.style.margin="start"===t?"-".concat(i/2).concat(c," auto auto -").concat(a/2).concat(c):"auto 5px auto 5px");return u},o.Hex2RGBA=function(t,e){var n=[];if(/^\#[0-9A-F]{3}$/i.test(t)){var r="#";t.replace(/[0-9A-F]/gi,function(t){r+=t+t}),t=r}return/^#[0-9A-F]{6}$/i.test(t)?(t.replace(/[0-9A-F]{2}/gi,function(t){n.push(parseInt(t,16))}),"rgba(".concat(n.join(","),", ").concat(e,")")):"rgba(255, 255, 255, 0.1)"},o.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},o.checkIsFunction=function(t){return t&&"function"==typeof t},o.checkIsObject=function(e){return null!==e&&"object"===t(e)},o.hide=function(t){t.style.display="none"},o.show=function(t,e){t.style.display=e||"block"},o.isUndefined=function(t){if(null==t)return!0},o.isNotNull=function(t){return!(null==t)},o.setStyleFromCsstext=function(t,e){e&&("String"===o.typeOf(e)?e.replace(/\s+/g,"").split(";").map(function(e){if(e){var n=e.split(":");n.length>1&&(t.style[n[0]]=n[1])}}):Object.keys(e).map(function(n){t.style[n]=e[n]}))},o.filterStyleFromText=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height","top","left","bottom","right","position","z-index","padding","margin","transform"],n=t.style.cssText;if(!n)return{};var r=n.replace(/\s+/g,"").split(";"),o={},a={};return r.map(function(t){if(t){var n=t.split(":");n.length>1&&(!function(t,e){for(var n=0,r=e.length;n<r;n++)if(t.indexOf(e[n])>-1)return!0;return!1}(n[0],e)?a[n[0]]=n[1]:o[n[0]]=n[1])}}),t.setAttribute("style",""),Object.keys(a).map(function(e){t.style[e]=a[e]}),o},o.getStyleFromCsstext=function(t){var e=t.style.cssText;if(!e)return{};var n=e.replace(/\s+/g,"").split(";"),r={};return n.map(function(t){if(t){var e=t.split(":");e.length>1&&(r[e[0]]=e[1])}}),r},o.preloadImg=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(t){var r=new window.Image;r.onload=function(t){r=null,e&&e(t)},r.onerror=function(t){r=null,n&&n(t)},r.src=t}},o.stopPropagation=function(t){t&&t.stopPropagation()},o.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},o.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},o.checkTouchSupport=function(){return"ontouchstart"in window},o.getBuffered2=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,n=[],o=0;o<t.length;o++)n.push({start:t.start(o)<.5?0:t.start(o),end:t.end(o)});n.sort(function(t,e){var n=t.start-e.start;return n||e.end-t.end});var a=[];if(e)for(var i=0;i<n.length;i++){var c=a.length;if(c){var u=a[c-1].end;n[i].start-u<e?n[i].end>u&&(a[c-1].end=n[i].end):a.push(n[i])}else a.push(n[i])}else a=n;return new r(a)},o.getEventPos=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t.touches&&t.touches.length>0&&(t=t.touches[0]),{x:t.x/e,y:t.y/e,clientX:t.clientX/e,clientY:t.clientY/e,offsetX:t.offsetX/e,offsetY:t.offsetY/e,pageX:t.pageX/e,pageY:t.pageY/e}},o.requestAnimationFrame=function(t){var e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(e)return e(t)},o.getHostFromUrl=function(t){if("String"!==o.typeOf(t))return"";var e=t.split("/"),n="";return e.length>3&&e[2]&&(n=e[2]),n},o.cancelAnimationFrame=function(t){var e=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;e&&e(t)},o.isMSE=function(t){return t.media&&(t=t.media),!!(t&&t instanceof HTMLMediaElement)&&(/^blob/.test(t.currentSrc)||/^blob/.test(t.src))},o.isBlob=function(t){return"string"==typeof t&&/^blob/.test(t)},o.generateSessionId=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=/* @__PURE__ */(new Date).getTime();try{t=parseInt(t)}catch(n){t=0}return e+=t,window.performance&&"function"==typeof window.performance.now&&(e+=parseInt(window.performance.now())),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)})},o.createEvent=function(t){var e;return"function"==typeof window.Event?e=new Event(t):(e=document.createEvent("Event")).initEvent(t,!0,!0),e},o.adjustTimeByDuration=function(t,e,n){return e&&t&&(t>e||n&&t<e)?e:t},o.createPositionBar=function(t,e){var n=o.createDom("xg-bar","",{"data-index":-1},t);return e.appendChild(n),n},o.getTransformStyle=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0,scale:1,rotate:0},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n={scale:"".concat(t.scale||1),translate:"".concat(t.x||0,"%, ").concat(t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")};return Object.keys(n).forEach(function(t){var r=new RegExp("".concat(t,"\\([^\\(]+\\)"),"g"),o="".concat(t,"(").concat(n[t],")");r.test(e)?(r.lastIndex=-1,e=e.replace(r,o)):e+="".concat(o," ")}),e},o.convertDeg=function(t){return Math.abs(t)<=1?360*t:t%360},o.getIndexByTime=function(t,e){var n=e.length,r=-1;if(n<1)return r;if(t<=e[0].end||n<2)r=0;else if(t>e[n-1].end)r=n-1;else for(var o=1;o<n;o++)if(t>e[o-1].end&&t<=e[o].end){r=o;break}return r},o.getOffsetCurrentTime=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=-1;if((r=n>=0&&n<e.length?n:o.getIndexByTime(t,e))<0)return-1;var a=e.length,i=e[r],c=i.start,u=i.end,l=i.cTime,s=i.offset;return t<c?l:t>=c&&t<=u?t-s:t>u&&r>=a-1?u:-1},o.getCurrentTimeByOffset=function(t,e){var n=-1;if(!e||e.length<0)return t;for(var r=0;r<e.length;r++)if(t<=e[r].duration){n=r;break}if(-1!==n){var o=e[n].start;return n-1<0?o+t:o+(t-e[n-1].duration)}return t};export{l as checkIsCurrentVideo,i as debounce,o as default,u as getLang,c as throttle};