import{v as l}from"./DCUV69GJ.chunk.js";import{a as d}from"./B31bqZwo.chunk.js";const I={getInteractiveTrack(r,e){var c;const t=r.addTextTrack("metadata","interactive"),i=e.additionalData.interactive,a=(c=e.additionalData.clipData)==null?void 0:c.startTime;return i.timepoints.forEach(n=>{var h;let s=n.visibleAt/1e3,o=n.visibleFor?s+n.visibleFor/1e3:s+1;a&&(s+=a,o+=a),(h=n.interactions)!=null&&h.length&&t.addCue({startTime:Math.max(.001,s-.001),endTime:o,text:n.id})}),t}},u=l.getComponent("Button");class m extends u{constructor(e,t){super(e,t),this.timepoint_=t.timepoint,this.time_=t.timepoint.visibleAt/1e3;const i=t.timepoint.interactions[0];i||this.hide();const{bgClassName:a}=d.getTypeInfo(i.typeId);this.$(".vjs-icon-placeholder").classList.add(a),this.controlText(i.name),this.update()}buildCSSClass(){return`cv-interactive-bar-item ${super.buildCSSClass()}`}createEl(e,t,i){return super.createEl(e,{...t,className:this.buildCSSClass()},{...i,tabindex:0})}update(){const e=this.player_.duration(),t=this.time_/e;this.el().style.left=t*100+"%",t>100||t<0?this.hide():this.show()}handleClick(e){e.stopPropagation(),this.player_.currentTime(this.time_)}}const p=l.getComponent("Component");class f extends p{constructor(e,t){super(e,t),this.track_=t.track,this.interactive_=t.interactive,this.onDurationChange=this.onDurationChange.bind(this),this.createInteractionItems=this.createInteractionItems.bind(this),this.createInteractionItems(),this.track_.on("cv:cuechange",this.createInteractionItems),this.player_.on("durationchange",this.onDurationChange),this.player_.on("dispose",()=>{this.track_.off("cv:cuechange"),this.player_.off("durationchange",this.onDurationChange)})}buildCSSClass(){return`cv-interactive-bar-items ${super.buildCSSClass()}`}createEl(e,t,i){return super.createEl(e,{...t,className:this.buildCSSClass()},i)}update(){this.children_.forEach(e=>{e.update()})}createInteractionItems(){var e;if(this.track_){[...this.children_].forEach(t=>{this.removeChild(t)});for(let t=0;t<this.track_.cues.length;t++){const i=this.track_.cues[t],a=this.getTimepointById(i.text);!a||!((e=a.interactions)!=null&&e.length)||this.addChild(new m(this.player_,{timepoint:a}))}}}onDurationChange(){this.update()}getTimepointById(e){var t;return(t=this.interactive_.timepoints)==null?void 0:t.find(i=>i.id.toString()===e.toString())}}export{f as I,I as a};
//# sourceMappingURL=Cu7pgtf6.chunk.js.map
