/*!
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{inherits as t,createSuper as i,classCallCheck as e,createClass as n}from"../../_virtual/_rollupPluginBabelHelpers.js";import a from"../../utils/util.js";import{DURATION_CHANGE as r}from"../../events.js";import l from"../../plugin/plugin.js";var o=/* @__PURE__ */function(){t(u,l);var o=i(u);function u(t){var i;return e(this,u),(i=o.call(this,t)).ratio=1,i.interval=null,i._preloadMark={},i}return n(u,[{key:"afterCreate",value:function(){var t=this;this.usable&&this.initThumbnail(),this.on([r],function(){var i=t.config,e=i.pic_num,n=i.interval;t.usable&&(t.interval=n>0?n:Math.round(1e3*t.player.duration/e)/1e3)})}},{key:"setConfig",value:function(t){var i=this;if(t){var e=Object.keys(t);e.length<1||(e.forEach(function(e){i.config[e]=t[e]}),this.usable&&this.initThumbnail())}}},{key:"usable",get:function(){var t=this.config,i=t.urls,e=t.pic_num;return i&&i.length>0&&e>0}},{key:"initThumbnail",value:function(){var t=this.config,i=t.width,e=t.height,n=t.pic_num,a=t.interval;this.ratio=i/e*100,this.interval=a||Math.round(this.player.duration/n),this._preloadMark={}}},{key:"getUrlByIndex",value:function(t){return t>=0&&t<this.config.urls.length?this.config.urls[t]:""}},{key:"preload",value:function(t){var i=this;if(!this._preloadMark[t]){var e=this.config.urls,n=e.length,r=[];t>0&&r.push(t-1),r.push(t),t>0&&t<n-1&&r.push(t+1),r.map(function(t){!i._preloadMark[t]&&t>=0&&t<n&&(i._preloadMark[t]=1,a.preloadImg(e[t],function(){i._preloadMark[t]=2}))})}}},{key:"getPosition",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.config,a=n.pic_num,r=n.row,l=n.col,o=n.width,u=n.height;this.interval=Math.round(this.player.duration/a);var h=Math.ceil(t/this.interval),s=(h=h>a?a:h)<r*l?0:Math.ceil(h/(r*l))-1,c=h-s*(l*r),g=c>0?Math.ceil(c/l)-1:0,f=c>0?c-g*l-1:0,p=0,v=0;i&&e?i/e<o/u?p=(v=e)*(o/u):v=(p=i)/(o/u):e?i||(p=(v=e||u)*(o/u)):v=(p=i||o)/(o/u);var d=this.getUrlByIndex(s);return{urlIndex:s,rowIndex:g,colIndex:f,url:d,height:v,width:p,style:{backgroundImage:"url(".concat(d,")"),backgroundSize:"".concat(p*l,"px auto"),backgroundPosition:"-".concat(f*p,"px -").concat(g*v,"px"),width:"".concat(p,"px"),height:"".concat(v,"px")}}}},{key:"update",value:function(t,i){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=this.config,l=r.pic_num,o=r.urls;if(!(l<=0)&&o&&0!==o.length){var u=this.getPosition(i,e,n);this.preload(u.urlIndex),Object.keys(u.style).map(function(i){t.style[i]=u.style[i]}),Object.keys(a).map(function(i){t.style[i]=a[i]})}}},{key:"changeConfig",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setConfig(t)}},{key:"createThumbnail",value:function(t,i){var e=a.createDom("xg-thumbnail","",{},"thumbnail ".concat(i));return t&&t.appendChild(e),e}}],[{key:"pluginName",get:function(){return"thumbnail"}},{key:"defaultConfig",get:function(){return{isShow:!1,urls:[],pic_num:0,col:0,row:0,height:90,width:160,scale:1,className:"",hidePortrait:!1}}}]),u}();export{o as default};