import{a as e,d as t,i as n,n as r,t as i}from"./objectSpread2-DtFdQpqy.js";import{a,i as o,n as s}from"./preload-helper-EQ20WQt-.js";import{d as c,u as l}from"./prop-types-DdDwMzX7.js";import{t as u}from"./locales-DVVnY6uc.js";import{n as d,t as f}from"./poll-9cD-z1op.js";import{_o as p,do as m,yo as h}from"./time-BE5vfriQ.js";import{t as g}from"./audio-C-0vg_jO.js";import{t as _}from"./video-9uucZKqv.js";import{a as v,t as y}from"./media_modal-DyGvTihb.js";import{r as b}from"./hashtag-C7Jzvxbz.js";import{t as x}from"./media_gallery-ck0BgSSg.js";var S=t(a()),C=t(o());h();var w=s();e(),c(),r();var T=[`media`,`card`,`poll`,`hashtag`],E={MediaGallery:x,Video:_,Card:d,Poll:f,Hashtag:b,Audio:g},D=class extends S.PureComponent{constructor(...e){super(...e),n(this,`state`,{media:null,index:null,lang:null,time:null,backgroundColor:null,options:null}),n(this,`handleOpenMedia`,(e,t,n)=>{this.setState({media:e,index:t,lang:n})}),n(this,`handleOpenVideo`,(e,t)=>{let{components:n}=this.props,{media:r}=JSON.parse(n[t.componentIndex].getAttribute(`data-props`)),i=p(r);this.setState({media:i,lang:e,options:t})}),n(this,`handleCloseMedia`,()=>{this.setState({media:null,index:null,time:null,backgroundColor:null,options:null})}),n(this,`setBackgroundColor`,e=>{this.setState({backgroundColor:e})})}render(){var e,t,n;let{components:r}=this.props,a;return window.self===window.top&&(a=this.handleOpenVideo),(0,w.jsx)(u,{children:(0,w.jsxs)(w.Fragment,{children:[Array.from(r).map((e,t)=>{let n=e.getAttribute(`data-component`),r=E[n],o=JSON.parse(e.getAttribute(`data-props`)),{media:s,card:c,poll:u,hashtag:d}=o,f=l(o,T);return Object.assign(f,i(i(i(i(i({},s?{media:p(s)}:{}),c?{card:p(c)}:{}),u?{poll:m(u)}:{}),d?{hashtag:p(d)}:{}),n===`Video`?{componentIndex:t,onOpenVideo:a}:{onOpenMedia:this.handleOpenMedia})),(0,C.createPortal)((0,S.createElement)(r,i(i({},f),{},{key:`media-${t}`})),e)}),(0,w.jsx)(v,{backgroundColor:this.state.backgroundColor,onClose:this.handleCloseMedia,children:this.state.media&&(0,w.jsx)(y,{media:this.state.media,index:this.state.index||0,lang:this.state.lang,currentTime:(e=this.state.options)==null?void 0:e.startTime,autoPlay:(t=this.state.options)==null?void 0:t.autoPlay,volume:(n=this.state.options)==null?void 0:n.defaultVolume,onClose:this.handleCloseMedia,onChangeBackgroundColor:this.setBackgroundColor})})]})})}};export{D as default};
//# sourceMappingURL=media_container-D0Fhc95n.js.map