@besovideo/webrtc-player 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.browser.js +9 -9
- package/dist/main.es.js +9 -9
- package/package.json +1 -1
package/dist/main.browser.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var bvPlayerCore=(()=>{var
|
|
1
|
+
var bvPlayerCore=(()=>{var je=Object.defineProperty,Jt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var et=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var tt=(t,e,n)=>e in t?je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,k=(t,e)=>{for(var n in e||(e={}))Xt.call(e,n)&&tt(t,n,e[n]);if(et)for(var n of et(e))qt.call(e,n)&&tt(t,n,e[n]);return t},z=(t,e)=>Jt(t,Gt(e));var Qt=(t,e)=>{for(var n in e)je(t,n,{get:e[n],enumerable:!0})};var u=(t,e,n)=>new Promise((o,i)=>{var s=l=>{try{g(n.next(l))}catch(f){i(f)}},c=l=>{try{g(n.throw(l))}catch(f){i(f)}},g=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,c);g((n=n.apply(t,e)).next())});var Yo={};Qt(Yo,{Conference:()=>Kt,Intercom:()=>Ut,PuPlayer:()=>$t,RemoteSdpFetcher:()=>ne,clearAllDialog:()=>Zo});var Zt="production",Yt="@besovideo/webrtc-player",jt="0.3.2",d={NODE_ENV:Zt,SH_LIB_NAME:Yt,SH_LIB_VERSION:jt};var en=Object.defineProperty,tn=Object.defineProperties,nn=Object.getOwnPropertyDescriptors,nt=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable,ot=(t,e,n)=>e in t?en(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,X=(t,e)=>{for(var n in e||(e={}))on.call(e,n)&&ot(t,n,e[n]);if(nt)for(var n of nt(e))rn.call(e,n)&&ot(t,n,e[n]);return t},sn=(t,e)=>tn(t,nn(e)),T;(function(t){t.red="#e72528",t.blue="#2a79af",t.weakBlue="#6eb6f4",t.geekblue="#85a5ff",t.gold="#ffd666",t.orange="#ffa940",t.cyan="#13c2c2",t.green="#52c41a",t.volcano="#fa541c",t.lime="#389e0d",t.pink="#eb2f96",t.purple="#722ed1",t.darkPurple="#292F4C",t.gray="#8c8c8c"})(T||(T={}));var rt=class{constructor(){this.colors=T,this.shapes={slider:new it}}},it=class{constructor(){}title(t=""){return q`
|
|
2
2
|
color: ${t};
|
|
3
3
|
border-left: 3px solid ${t};
|
|
4
4
|
padding: 2px;
|
|
5
5
|
font-weight: 600;
|
|
6
|
-
`}message(t=""){return
|
|
6
|
+
`}message(t=""){return q`
|
|
7
7
|
color: ${t};
|
|
8
|
-
`}message_button(t="#eee",e=
|
|
8
|
+
`}message_button(t="#eee",e=T.darkPurple,n="#fff"){return q`
|
|
9
9
|
background-color: ${e};
|
|
10
10
|
color: ${t};
|
|
11
11
|
padding: 2px 5px;
|
|
12
12
|
border-radius: 3px;
|
|
13
13
|
text-shadow: 0 0 2px ${n};
|
|
14
|
-
`}},
|
|
15
|
-
`,...e)},this.key=(t,...e)=>{let n=
|
|
14
|
+
`}},q=(t,...e)=>{if(e.length===0)return t[0];let n="";return e.forEach((o,i)=>{n+=t[i]+o}),n+=t[t.length-1],n},U;(function(t){t[t.title=1]="title",t[t.message=2]="message",t[t.message_button=3]="message_button"})(U||(U={}));var re=({color:t},e=new it,n)=>{switch(n){case 1:return e.title(t);case 2:return e.message(t);case 3:return e.message_button();default:return""}},an=class{constructor(t){let e={log:window.console.log,enable:!0};this._option=sn(X({},e),{enable:typeof(t==null?void 0:t.enable)=="boolean"?t.enable:e.enable,log:(t==null?void 0:t.log)||e.log})}log(...t){let{enable:e,log:n}=this._option;e&&n&&n(...t)}set baseOption(t){this._option=t}get baseOption(){return this._option}setEnable(t){this._option.enable=!!t}},st=class{constructor(t){let e={enable:!0,log:window.console.log,level:39,shape:new rt().shapes.slider};this.enable=t&&typeof t.enable=="boolean"?t.enable:e.enable,this.log=t&&t.log||e.log,this.level=t&&typeof t.level=="number"?t.level:e.level,this.shape=t&&t.shape?t.shape:e.shape}},ln=class extends an{constructor(t){super(t||new st);this.loggerOption=X(X({},new st),t)}setLoggerOption(t){let e=X(X({},this.loggerOption),t);this.loggerOption=e,super.baseOption={enable:e.enable,log:e.log}}getLoggerOption(){return this.loggerOption}setLevel(t){typeof t=="number"&&(this.loggerOption.level=t)}formatLog(t,e,n,o,i,...s){!this.loggerOption.level&&this.loggerOption.level!==0||this.loggerOption.level<t||super.log(`%c${e}%c${n}`,o,i,...s)}},at;(function(t){t[t.log=0]="log",t[t.version=0]="version",t[t.error=0]="error",t[t.key=0]="key",t[t.warn=1]="warn",t[t.interval=1]="interval",t[t.service=2]="service",t[t.api=3]="api",t[t.http=3]="http",t[t.debug=3]="debug"})(at||(at={}));var A={debug:{name:"debug",title:" Debug :",color:T.lime,level:3},http:{name:"http",title:" Http :",color:T.weakBlue,level:3},api:{name:"api",title:" Api :",color:T.cyan,level:3},service:{name:"service",title:" Service :",color:T.purple,level:2},interval:{name:"interval",title:" Interval :",color:T.pink,level:1},warn:{name:"warn",title:" WARN :",color:T.orange,level:1},error:{name:"error",title:" ERR :",color:T.red,level:0},key:{name:"key",title:" Key :",color:T.darkPurple,level:0}},ye=class extends ln{constructor(){super(...arguments);this.error=(t,...e)=>{this.formatShapeLog(A.error,`${t instanceof Error?t.stack:t}
|
|
15
|
+
`,...e)},this.key=(t,...e)=>{let n=A.key;this.formatLog(n.level,n.title,t.toUpperCase(),re({color:n.color},this.getLoggerOption().shape,U.title),re({},this.getLoggerOption().shape,U.message_button),...e)},this.version=(t="",e,...n)=>{this.formatLog(0,t.toUpperCase(),e,q`
|
|
16
16
|
background: linear-gradient(to right, #009fff, #ec2f4b);
|
|
17
17
|
color: white;
|
|
18
18
|
padding: 2px 5px;
|
|
19
19
|
border-top-left-radius: 3px;
|
|
20
20
|
border-bottom-left-radius: 3px;
|
|
21
|
-
`,
|
|
22
|
-
background-color: ${
|
|
21
|
+
`,q`
|
|
22
|
+
background-color: ${T.darkPurple};
|
|
23
23
|
color: white;
|
|
24
24
|
padding: 2px 5px;
|
|
25
|
-
`,...n)}}formatShapeLog({level:t,title:e,color:n},o,...r){this.formatLog(t,e,o,oe({color:n},this.getLoggerOption().shape,$.title),oe({color:n},this.getLoggerOption().shape,$.message),...r)}debug(t,...e){this.formatShapeLog(B.debug,t,...e)}http(t,...e){this.formatShapeLog(B.http,t,...e)}api(t,...e){this.formatShapeLog(B.api,t,...e)}service(t,...e){this.formatShapeLog(B.service,t,...e)}interval(t,...e){this.formatShapeLog(B.interval,t,...e)}warn(t,...e){this.formatShapeLog(B.warn,t,...e)}},qo=new rt,cn=new be,dn=cn,N=dn;var lt=class extends be{constructor(){super(...arguments);this.test=(e,...n)=>{let o=4;this.formatShapeLog({level:o,title:" Test ",color:"#3f6600"},e,...n)};this.libWarn=(e,...n)=>{this.warn("bvplayer-core ",e,...n),console.warn(new Error().stack)};this.libError=(e,...n)=>{this.error(new Error(`bvplayer-core ${e}`),...n)}}},Ie=new lt;Ie.debug("player-core env:",c);Ie.version(c.SH_LIB_NAME,c.SH_LIB_VERSION||"");var s=Ie;var ct=(t,e,n)=>{let o={value:e,expire:n},r=JSON.stringify(o);return localStorage.setItem(t,r),o},un=(t,e,n)=>{let r=ye.getUTCSecond()+n;return ct(t,e,r)},pn=(t,e=!1)=>{let n=localStorage.getItem(t);if(!n)return null;try{let o=JSON.parse(n);return e?o:o.expire?ye.compare(o.expire)?o.value:null:o.value}catch(o){s.error(o,n,"Storage\u8BFB\u53D6\u6570\u636E\u65F6\uFF0C JSON\u89E3\u6790\u51FA\u9519")}},mn=t=>localStorage.removeItem(t),gn={set:ct,setTimeout:un,get:pn,remove:mn},D=gn;var re;(function(n){n.GET="GET",n.POST="POST"})(re||(re={}));var dt=(t,e)=>d(void 0,null,function*(){let n=new AbortController;if(e.signal&&e.signal.addEventListener("abort",()=>{n.abort()}),e.timeout){let l=setTimeout(()=>{n.abort()},e.timeout);n.signal.addEventListener("abort",()=>{clearTimeout(l)})}let o=e.bodyData,r=o&&(typeof o=="object"?JSON.stringify(o):o),i={credentials:"same-origin",method:e.method,headers:new Headers(R({},e.headers)),signal:n.signal};r&&(i.body=r),s.http("\u53D1\u9001\u8BF7\u6C42\uFF1A",t,j(R({},i),{body:o}));try{let l=yield fetch(t,i);if(s.http("\u8BF7\u6C42\u54CD\u5E94\uFF1A",t,l,yield l.clone().text()),l.ok||l.status>=200&&l.status<300){let m=l.headers.get("content-type")||"";if(/application\/json/i.test(m))return yield l.json()}else throw new Error(`${l.status} ${l.statusText}`)}catch(l){if(l.name==="AbortError"){s.http("\u8BF7\u6C42\u53D6\u6D88\uFF1A",i);return}throw l}}),fn=(t,e,n)=>d(void 0,null,function*(){let o=e?e.toString():"";return yield dt(t+o,{method:re.GET,headers:n==null?void 0:n.headers})}),hn=(t,e,n)=>d(void 0,null,function*(){return yield dt(t,{method:re.POST,headers:R({"Content-Type":"application/json;charset=UTF-8"},n==null?void 0:n.headers),bodyData:e})}),vn={get:fn,post:hn},ie=vn;var yn=Array.isArray,bn=t=>t!==t,ut=t=>typeof t=="number",pt=t=>typeof t=="string",In=t=>ut(t)||pt(t),Cn=t=>typeof t=="function",Pn=t=>typeof t=="undefined",wn=t=>t?!1:!!(t!=null?t:!0),xn={isArr:yn,baseIsNaN:bn,isString:pt,isNumber:ut,isText:In,isFn:Cn,isUndefined:Pn,isNullOrUndefined:wn},O=xn;function En(t,e=[]){let n=-1,o=t.length;for(e||(e=Array(o));++n<o;)e[n]=t[n];return e}function _n(t,e,n){let o=n-1,r=t.length;for(;++o<r;)if(t[o]===e)return o;return-1}function Sn(t,e,n,o=!1){let r=t.length,i=n+(o?1:-1);for(;o?i--:++i<r;)if(e(t[i],i,t))return i;return-1}function Tn(t,e,n){return e===e?_n(t,e,n):Sn(t,O.baseIsNaN,n)}function Rn(t,e){let n=-1,o=e.length,r=t;for(t===e&&(e=En(e));++n<o;){let i=0,l=e[n],m=l;for(;(i=Tn(r,m,i))>-1;)r!==t&&[].splice.call(r,i,1),[].splice.call(t,i,1)}return t}var kn=t=>t?O.isArr(t)?t:[t]:[],Fn=(t,e)=>!t||!t.length||!e||!e.length?t:Rn(t,e),Mn=(t,e="")=>{let n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0,n.width,n.height),n.toBlob(o=>{if(!o){s.libError("util screenshot canvas\u7684\u8F93\u51FA\u4E3A\u7A7A\u503C");return}let r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}.png`,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)})},Ln={pullAll:Fn,toArray:kn,screenshot:Mn},G=Ln;var mt={BVCSP_V1:{path:"/bvcsp/v1",prefix:""}},Ce=t=>{let e=mt[t];return e.prefix+e.path},Nn=(t,e)=>{let n=mt[t];return n.prefix=e||"",Ce(t)},X={setApiPrefix:Nn,getApiURL:Ce,bvscpV1:()=>Ce("BVCSP_V1")},q=t=>{X.setApiPrefix("BVCSP_V1",t)};var On=t=>{if(!t)return null;if(t.nodeType===Node.DOCUMENT_NODE)return t.documentElement;if(t.nodeType===Node.ELEMENT_NODE){let e=t;return e.hasChildNodes()&&e.childNodes.forEach(n=>{let o=n;o.className&&new RegExp(".*bvplayer-core-player.*").test(o.className)&&e.removeChild(o)}),t}return null},Dn=(t,e,n)=>{if(!t)return;let o=document.createDocumentFragment();o.appendChild(t);let r=On(e);!r||(r.appendChild(o),n==null||n())},gt=Dn;var se=(...t)=>{let e=[];for(let n=0;n<t.length;n++){let o=t[n];if(!o)continue;let r=typeof o;if(O.isText(o))e.push(o);else if(Array.isArray(o)){if(o.length){let i=se(...o);i&&e.push(i)}}else if(r==="object")if(o.toString==={}.toString)for(let i in o)({}).hasOwnProperty.call(o,i)&&o[i]&&e.push(i);else e.push(o.toString())}return e.join(" ")},ft=t=>t?t.replace(/\s*(;|\{|\})+\s*[\n\r]*/g,"$1"):"",Vn=(t,...e)=>{if(!e.length)return ft(t[0]);let n="";return e.forEach((o,r)=>{n+=t[r]+o}),n+=t[t.length-1],ft(n)},Pe="bvplayer-",Bn="common-",ht=t=>new RegExp(Pe).test(t),An=(...t)=>se(t).split(" ").map(e=>ht(e)?e:Pe+e).join(" "),Wn=(...t)=>se(t).split(" ").map(e=>ht(e)?e:Pe+Bn+e).join(" ");var Hn={cls:se,css:Vn,prefixCls:An,commonCls:Wn},Q=Hn;function jn(t={},e){if(!e)return;Object.keys(t).forEach(o=>{if(o==="children")return;let r=t[o];O.isNullOrUndefined(r)||(o.startsWith("on")?e.addEventListener(o.substring(2).toLowerCase(),r):e instanceof Element?e.setAttribute(o==="className"?"class":o,r):e[o]=r)})}function $n(t,e){return t===""?document.createTextNode(""):e?document.createElementNS(e,t):document.createElement(t)}function Z(t,e,n){let o=e?e(t):t;if(!o)return null;if(O.isArr(o)){let l=document.createDocumentFragment();return o.forEach(m=>{let a=Z(m,e);a&&l.appendChild(a)}),l}let{props:r,type:i}=o;if(!r)return o instanceof Node||o instanceof Text?(s.libWarn("jsx grow","\u63D0\u793A",o,"\u5E76\u4E0D\u662F\u6709\u6548\u7684jsx element \u5DF2\u7ECF\u539F\u6837\u8F93\u51FA\uFF0C\u4E0D\u5F71\u54CDui \u4F46\u5C3D\u91CF\u5C11\u6DF7\u7528jsx\u548Cdom"),o):(s.libWarn("jsx grow","\u672A\u89E3\u6790",o,"\u56E0\u4E3A\u5B83\u4E0D\u662F\u6709\u6548\u7684jsx element\uFF0C\u5E76\u4E14\u4E5F\u4E0D\u662FRenderTarget\u7C7B\u578B"),null);if(O.isString(i)){let l=$n(i,r.xmlns||n);return jn(r,l),(r.children||[]).forEach(a=>{let g=Z(a,e,r.xmlns);!g||l.appendChild(g)}),l}if(O.isFn(i)){let l=i(r);return Z(l,e)}return null}function zn(t){return document.createRange().createContextualFragment(t)}function Un(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function we(){return document.createDocumentFragment()}function Kn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function Jn(t,...e){if(!t)return;let n=we();n.append(...e.filter(o=>o)),t.appendChild(n)}function Gn(t){if(!!t)if(t instanceof Element){t.innerHTML="";return}else for(;t.firstChild;)t.removeChild(t.firstChild)}function Xn(t,...e){if(!e.length||!(t==null?void 0:t.parentNode))return;let n=e.filter(o=>o);if(t instanceof Element)t.replaceWith(...n);else{let o=we();o.append(...n),t.parentNode.replaceChild(o,t)}}function qn(t){var e;if(!!t)if(t instanceof Element){t.remove();return}else(e=t.parentNode)==null||e.removeChild(t)}function Qn(t){if(!t||!t.props)return t;let{props:e}=t;return e.withCommonNamespace&&(e.className=Q.commonCls(e.className),delete e.withCommonNamespace),e.withNamespace&&(e.className=Q.prefixCls(e.className),delete e.withNamespace),t}function Zn(t){return t?Z(t,Qn):null}var Yn={parseHtml:zn,create:Un,createFragment:we,createHtmlElement:Kn,createByJsx:Zn,append:Jn,empty:Gn,replace:Xn,removeSelf:qn},vt=Yn;var eo="bvplayerCore",to=t=>eo+t,no={createPrefixStorageField:to},yt=no;var oo={render:gt,style:Q,dom:vt,field:yt},u=oo;var A=u.field.createPrefixStorageField("DialogIds"),ro=(t,e)=>d(void 0,null,function*(){var l;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},r=yield ie.post(`${X.bvscpV1()}/dialog/device/webrtc`,o,{headers:n});if(s.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:r}),!r||r.code!==0||!((l=r.data)==null?void 0:l.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${r.msg}`);let{data:i}=r;if(i.dialogid){let m=D.get(A)||[];m.push(i.dialogid),D.set(A,m)}return{dialogId:i.dialogid,sdp:i.sdp}}),io=(t,e)=>d(void 0,null,function*(){var m;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},r=yield ie.post(`${X.bvscpV1()}/dialog/conference/webrtc`,o,{headers:n});if(s.api("\u4F1A\u8BAE\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:r}),!r||r.code!==0||!((m=r.data)==null?void 0:m.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${r==null?void 0:r.msg}`);let{data:i}=r,l=D.get(A)||[];return l.push(i.dialogid),D.set(A,l),{dialogId:i.dialogid,sdp:i.sdp}}),so=(t,e)=>d(void 0,null,function*(){if(!t)return;let n={Authorization:e||""};return s.api("\u5173\u95EDdialog\uFF1A",t),yield ie.post(`${X.bvscpV1()}/dialog/close/${t}`,{},{headers:n})}),bt=(t,e)=>d(void 0,null,function*(){let n=D.get(A)||[];G.pullAll(n,t),D.set(A,n,0);let r=(yield Promise.allSettled(t.map(i=>so(i,e)))).filter(i=>i.status==="rejected");r&&r.length>0&&s.error(new Error(`"\u5173\u95ED\u5B58\u50A8\u7684dialog\u65F6\u5931\u8D25\uFF1A", ${r}`))}),ao=t=>d(void 0,null,function*(){let e=D.get(A);!e||e.length<1||(D.remove(A),yield bt(e,t))}),lo={getDeviceWebrtc:ro,getConferenceWebrtc:io,closeDialogs:bt,closeAllStorageDialog:ao},k=lo;var It=class{constructor(){this._map=new Map}findExecutor(e,n){let o=this._map.get(e);return{index:o?o.findIndex(i=>Object.is(n,i)):-1,que:o}}publish(e,n){let o=this._map.get(e)||[],r=o.length;for(let i=0;i<r;i++){let l=o[i];l&&l(n)}}subscribe(e,n){let{index:o,que:r=[]}=this.findExecutor(e,n);return o>=0?r[o]=n:r.push(n),this._map.set(e,r),{unSubscribe:()=>{this.unSubscribe(e,n)}}}unSubscribe(e,n){let{index:o,que:r=[]}=this.findExecutor(e,n);o<0||(r.splice(o,1),this._map.set(e,r))}},Y=class{constructor(){this._notifier=new It}addEventListener(e,n){this._notifier.subscribe(e,n)}removeEventListener(e,n){this._notifier.unSubscribe(e,n)}dispatch(e,n){this._notifier.publish(e,n)}};var w=class extends Y{constructor(e,n,o){super();this.name="";let r=n.trim().toLowerCase(),i=o?o.trim():r,l=u.dom.create(e,u.style.prefixCls(i));this.name=r,this.el=l}empty(){u.dom.empty(this.el)}unmount(){var e;s.debug("unmount",this.el,(e=this.el)==null?void 0:e.parentNode),u.dom.removeSelf(this.el)}destroy(){if(this.beforeDestroy(),this.empty(),this.unmount(),this.el=null,this.dispatch("destroy"),!!this){for(let e in this)this[e]=void 0;s.debug("destroy complete",this)}}getEl(){return this.el}};var Ct=class extends w{constructor(e){super("div","mask",u.style.cls("mask"));this._visible=!!(e==null?void 0:e.visible),this._text=e==null?void 0:e.text,this._textEl=u.dom.create("span",u.style.cls("text"))}set visible(e){this._visible=e,this.el.style.display=this._visible?"grid":"none"}set text(e){this._text=e,this._textEl.textContent=e}beforeDestroy(){}init(){s.debug("mask visible: ",this._visible);let e=this.el;return e.style.display=this._visible?"block":"none",this._textEl.textContent=this._text||"",u.dom.append(e,this._textEl),e}},Pt=Ct;var wt=class extends w{constructor(e){super("div","spinner",u.style.cls("spinner"));this._spin=!!(e==null?void 0:e.spin)}set spin(e){this._spin=e,this.el.style.display=this._spin?"block":"none"}beforeDestroy(){}init(){s.debug("spinner spin: ",this._spin);let e=this.el;e.style.display=this._spin?"block":"none";let n=u.dom.create("span");return n.style.backgroundColor="#FFF",u.dom.append(e,n),e}},xt=wt;var Et={contain:"contain",fill:"fill"},_t=class extends w{constructor(e){super("video","video",u.style.cls("video"));this._url=e==null?void 0:e.url,this._srcObject=(e==null?void 0:e.srcObject)||null,this._fit=(e==null?void 0:e.fit)||Et.contain,this._autoPlay=!!(e==null?void 0:e.autoPlay),this._muted=!!(e==null?void 0:e.muted)}set url(e){typeof this._url!="undefined"&&(this.el.src=this._url),this._url=e}set srcObject(e){this._srcObject=e||null,this.el.srcObject=this._srcObject}set muted(e){let n=this.el;this._muted=e,n.muted=e}set paused(e){let n=this.el;e?n.pause():n.play()}get paused(){var e;return!!((e=this.el)==null?void 0:e.paused)}set autoPlay(e){if(!e!==this._autoPlay)return;this._autoPlay=e,this.muted=e;let n=this.el;n.autoplay=this._autoPlay}set fit(e){this._fit=Et[e],this.el.style.objectFit=this._fit}getVideoFit(){return this._fit}init(){s.debug("\u6E32\u67D3VideoPlugin\u89C6\u9891\u5BF9\u8C61dom\u7684children",this,this.el);let e=this.el;return e.addEventListener("play",()=>this.dispatch("play",{target:this})),e.addEventListener("pause",()=>this.dispatch("pause",{target:this})),e.addEventListener("loadedmetadata",n=>{s.debug("video loadedmetadata",n),this.dispatch("loadedmetadata",{target:this})}),typeof this._url!="undefined"&&(e.src=this._url),e.srcObject=this._srcObject,e.autoplay=this._autoPlay,e.muted=this._muted,e.style.objectFit=this._fit,e.playsInline=!0,e}play(){return d(this,null,function*(){let e=this.el;try{s.debug("video \u5C1D\u8BD5\u64AD\u653E"),yield e.play()}catch(n){s.error(n,"video \u64AD\u653E \u5931\u8D25")}})}beforeDestroy(){}},St=_t;function ee(t){return class extends t{constructor(...e){super(...e);this._visible=!1}get visible(){return this._visible}set visible(e){let n=!!e;if(this._visible===n)return;this._visible=n;let o=u.style.commonCls("is-visible");this._visible?(this.show&&this.show(),this.el.setAttribute("aria-hidden","false"),this.el.classList.add(o)):(this.hide&&this.hide(),this.el.setAttribute("aria-hidden","true"),this.el.classList.remove(o))}}}function xe({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function Ee({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 0 1-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 0 1 .947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 0 1 2.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 0 1 2.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 0 1 .947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 0 1-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 0 1-2.287-.947zM10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function _e({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 9a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 10.07 4h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 18.07 7H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9z"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 13a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function Se({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M4 5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-1.586a1 1 0 0 1-.707-.293l-1.121-1.121A2 2 0 0 0 11.172 3H8.828a2 2 0 0 0-1.414.586L6.293 4.707A1 1 0 0 1 5.586 5H4zm6 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function Te({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0-5 5M4 16v4m0 0h4m-4 0 5-5m11 5-5-5m5 5v-4m0 4h-4"}))}function Re({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M3 4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 2H6.414l2.293 2.293a1 1 0 0 1-1.414 1.414L5 6.414V8a1 1 0 0 1-2 0V4zm9 1a1 1 0 1 1 0-2h4a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V6.414l-2.293 2.293a1 1 0 1 1-1.414-1.414L13.586 5H12zm-9 7a1 1 0 1 1 2 0v1.586l2.293-2.293a1 1 0 0 1 1.414 1.414L6.414 15H8a1 1 0 1 1 0 2H4a1 1 0 0 1-1-1v-4zm13-1a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 1 1 0-2h1.586l-2.293-2.293a1 1 0 0 1 1.414-1.414L15 13.586V12a1 1 0 0 1 1-1z","clip-rule":"evenodd"}))}function ke({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Fe({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zm-7-4a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM9 9a1 1 0 0 0 0 2v3a1 1 0 0 0 1 1h1a1 1 0 1 0 0-2v-3a1 1 0 0 0-1-1H9z","clip-rule":"evenodd"}))}function Me({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m10 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2m7-2a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Le({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM8.707 7.293a1 1 0 0 0-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 1 0 1.414 1.414L10 11.414l1.293 1.293a1 1 0 0 0 1.414-1.414L11.414 10l1.293-1.293a1 1 0 0 0-1.414-1.414L10 8.586 8.707 7.293z","clip-rule":"evenodd"}))}function Ne({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18 18 6M6 6l12 12"}))}function Oe({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 0 1 1.414 0L10 8.586l4.293-4.293a1 1 0 1 1 1.414 1.414L11.414 10l4.293 4.293a1 1 0 0 1-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 0 1-1.414-1.414L8.586 10 4.293 5.707a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function De({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 0 1 0 7.072m2.828-9.9a9 9 0 0 1 0 12.728M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}))}function Ve({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm5.274-.147a1 1 0 0 1 1.414 0A9.972 9.972 0 0 1 19 10a9.972 9.972 0 0 1-2.929 7.071 1 1 0 0 1-1.414-1.414A7.971 7.971 0 0 0 17 10a7.97 7.97 0 0 0-2.343-5.657 1 1 0 0 1 0-1.414zm-2.829 2.828a1 1 0 0 1 1.415 0A5.983 5.983 0 0 1 15 10a5.984 5.984 0 0 1-1.757 4.243 1 1 0 0 1-1.415-1.415A3.984 3.984 0 0 0 13 10a3.983 3.983 0 0 0-1.172-2.828 1 1 0 0 1 0-1.415z","clip-rule":"evenodd"}))}function Be({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z","clip-rule":"evenodd"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m17 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2"}))}function Ae({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm2.91 4.217a1 1 0 0 1 1.414 0L15 8.586l1.293-1.293a1 1 0 1 1 1.414 1.414L16.414 10l1.293 1.293a1 1 0 0 1-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 0 1-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function We({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14.752 11.168-3.197-2.132A1 1 0 0 0 10 9.87v4.263a1 1 0 0 0 1.555.832l3.197-2.132a1 1 0 0 0 0-1.664z"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function He({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM9.555 7.168A1 1 0 0 0 8 8v4a1 1 0 0 0 1.555.832l3-2a1 1 0 0 0 0-1.664l-3-2z","clip-rule":"evenodd"}))}function je({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 9v6m4-6v6m7-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function $e({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zM7 8a1 1 0 0 1 2 0v4a1 1 0 1 1-2 0V8zm5-1a1 1 0 0 0-1 1v4a1 1 0 1 0 2 0V8a1 1 0 0 0-1-1z","clip-rule":"evenodd"}))}function ze({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 33",fill:"currentColor"},jsx.h("path",{d:"M6.667 28H1.334c-.8 0-1.333-.533-1.333-1.333v-5.333c0-.8.533-1.333 1.333-1.333s1.333.533 1.333 1.333v4h4c.8 0 1.333.533 1.333 1.333S7.467 28 6.667 28zm24 0h-5.333c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h4v-4c0-.8.533-1.333 1.333-1.333S32 20.534 32 21.334v5.333c0 .8-.533 1.333-1.333 1.333zm0-16c-.8 0-1.333-.533-1.333-1.333v-4h-4c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333v5.333c0 .8-.533 1.333-1.333 1.333zM1.333 12C.533 12 0 11.467 0 10.667V5.334c0-.8.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333s-.533 1.333-1.333 1.333h-4v4c0 .8-.533 1.333-1.333 1.333z"}))}var F=({children:t,className:e})=>{let n=u.style.cls(["icon",e]);return jsx.h("span",{className:n,withNamespace:!0},t)},co=({filled:t})=>jsx.h(F,null,jsx.h(t?Ee:xe,null)),uo=({filled:t})=>jsx.h(F,null,jsx.h(t?Se:_e,null)),po=({filled:t})=>jsx.h(F,null,jsx.h(t?Fe:ke,null)),mo=({filled:t})=>jsx.h(F,null,jsx.h(t?Re:Te,null)),go=({filled:t,circle:e})=>e?jsx.h(F,null,jsx.h(t?Le:Me,null)):jsx.h(F,null,jsx.h(t?Oe:Ne,null)),fo=({filled:t,off:e})=>e?jsx.h(F,null,jsx.h(t?Ae:Be,null)):jsx.h(F,null,jsx.h(t?Ve:De,null)),ho=({filled:t,off:e})=>e?jsx.h(F,null,jsx.h(t?$e:je,null)):jsx.h(F,null,jsx.h(t?He:We,null)),vo=()=>jsx.h(F,null,jsx.h(ze,null)),yo={Cog:co,Camera:uo,Info:po,ArrowsExpand:mo,X:go,Volume:fo,Play:ho,Full:vo};var x=yo;var W="modal",Tt=class extends w{constructor(e){super("div",W,u.style.cls([W,e.className,{[`${W}--center`]:e.center}]));this.container=e.container,this.title=e.title,this._content=e.content||u.dom.create("div","test"),this._center=!!e.center}set content(e){let n=u.dom.createByJsx(e);s.debug("modal update content",n,this._content),u.dom.replace(this._content,n),this._content=n}show(){var e;(e=this.el)==null||e.classList.toggle(u.style.prefixCls(`${W}--center`),!!this._center),u.dom.append(this.container,this.el)}hide(){}clear(){!this.el||(this.el.innerHTML="")}beforeDestroy(){}init(){this.clear(),s.debug("\u6E32\u67D3ModalPlugin \u5F39\u7A97\u5BF9\u8C61",this,this.el);let e=this.el,n=u.dom.createByJsx(jsx.h(jsx.Fragment,null,jsx.h("div",{className:`${W}_title-bar`,onClick:()=>this.dispatch("hide"),withNamespace:!0},jsx.h("span",{className:`${W}_title-bar_title`,withNamespace:!0},this.title),jsx.h("span",{className:`${W}_title-bar_close`,withNamespace:!0},jsx.h(x.X,null))),jsx.h("div",{className:`${W}_body`,withNamespace:!0},this._content)));return u.dom.append(e,n),e}},bo=ee(Tt),Ue=class extends bo{},Rt=Ue;var Io="controller_button",kt=class extends w{constructor(e,n){super("button",Io);this._Children=e,this.title=n}set Children(e){!this.el||(this._Children=e,this.empty(),u.dom.append(this.el,u.dom.createByJsx(e)))}beforeDestroy(){}init(){let e=this.el;return e.addEventListener("click",()=>this.dispatch("click")),e.title=this.title||"",u.dom.append(e,u.dom.createByJsx(this._Children)),e}},z=kt;var Ft="controller",Mt=class extends w{constructor(e){super("div",Ft,u.style.cls(Ft));this._controls=(e==null?void 0:e.controls)||[],this.PlayButton=new z(jsx.h(x.Play,null)),this.VolumeButton=new z(jsx.h(x.Volume,{off:!0}),"volume"),this.InformationButton=new z(jsx.h(x.Info,null),"information"),this.ScreenshotButton=new z(jsx.h(x.Camera,null),"screenshot"),this.FullscreenButton=new z(jsx.h(x.ArrowsExpand,null),"fullscreen"),this.PlayButton.addEventListener("click",()=>{this.dispatch("play")}),this.VolumeButton.addEventListener("click",()=>{this.dispatch("volume")}),this.InformationButton.addEventListener("click",()=>this.dispatch("information")),this.ScreenshotButton.addEventListener("click",()=>this.dispatch("screenshot")),this.FullscreenButton.addEventListener("click",()=>this.dispatch("fullscreen"))}beforeDestroy(){}init(){s.debug("\u6E32\u67D3ControllerPlugin \u64AD\u653E\u63A7\u5236\u5668\u5BF9\u8C61",this,this.el,this._controls);let e=this.el,n=u.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_left`]),o=u.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_right`]),r=u.dom.createByJsx(jsx.h(jsx.Fragment,null,jsx.h("div",{className:`${this.name}_mask`,withNamespace:!0}),jsx.h("div",{className:`${this.name}_inner`,withNamespace:!0},jsx.h("div",{className:n,withNamespace:!0},this.PlayButton.init(),this.VolumeButton.init()),jsx.h("div",{className:"flex-space",withCommonNamespace:!0}),jsx.h("div",{className:o,withNamespace:!0},this.InformationButton.init(),this.ScreenshotButton.init(),this.FullscreenButton.init()))));return u.dom.append(e,r),e}},Co=ee(Mt),Ke=class extends Co{},Lt=Ke;var Nt=class{constructor(){this._els=[];this.disableAutoHide=!1;this._controller=new Lt}init(){let e=this._controller.init();return this._els.push(e),this._els}get els(){return this._els}get controller(){return this._controller}show(){this._controller.visible=!0}hide(){window.clearTimeout(this._autoHideTimeout),this._controller.visible=!1}showThenHide(){this.show(),window.clearTimeout(this._autoHideTimeout),this._autoHideTimeout=window.setTimeout(()=>{this.disableAutoHide||this.hide()},3e3)}},Ot=Nt;var ae=class{constructor(e){this.pc=e}getReceiversMap(){let e=new Map([["audio",[]],["video",[]]]),n=this.pc.getReceivers();return(n==null?void 0:n.length)&&n.forEach(o=>{let{kind:r}=o.track,i=e.get(r)||[];i.push(o),e.set(r,i)}),e}getStatsInfos(){return d(this,null,function*(){let e=this.getReceiversMap();s.debug("receivers map : ",e);let n=yield Promise.all(e.get("audio").map(r=>d(this,null,function*(){let i={},l=yield r.getStats(),m=[];return l.forEach(a=>{m.push(a),a.type==="codec"&&(i.mimeType=a.mimeType,i.clockRate=a.clockRate,i.channels=a.channels),a.type==="track"&&(i.totalSamplesReceived=a.totalSamplesReceived,i.totalSamplesDuration=a.totalSamplesDuration)}),s.debug("audio stats report: ",m),i}))),o=yield Promise.all(e.get("video").map(r=>d(this,null,function*(){let i={},l=yield r.getStats(),m=[];return l.forEach(a=>{m.push(a),a.type==="codec"&&(i.mimeType=a.mimeType,i.clockRate=a.clockRate),a.type==="inbound-rtp"&&(i.frameWidth=a.frameWidth,i.frameHeight=a.frameHeight,i.framesPerSecond=a.framesPerSecond,i.framesReceived=a.framesReceived,i.framesDecoded=a.framesDecoded,i.totalInterFrameDelay=a.totalInterFrameDelay,i.keyFramesDecoded=a.keyFramesDecoded,i.packetsLost=a.packetsLost,i.lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp,i.bytesReceived=a.bytesReceived,i.totalDecodeTime=a.totalDecodeTime)}),s.debug("video stats report: ",m),i})));return{audios:n,videos:o}})}};var Po=(t,e)=>{N.debug(`webrtc my ICE candidate:
|
|
26
|
-
${e.candidate?e.candidate.candidate:"(null)"}`)},wo=(t,e,n)=>{N.debug("webrtc ICE state change event: ",e),N.debug(`webrtc my ICE state: ${t==null?void 0:t.iceConnectionState}`),t&&t.iceConnectionState==="disconnected"&&n&&n()},xo=(t,e)=>{N.debug("webrtc Connection state change, \u5F53\u524D\u8FDE\u63A5\u72B6\u6001: ",t,t.connectionState)},Eo=(t,e,n)=>{N.debug("webrtc \u5F53\u524D\u7684 stream: ",e.streams[0]);let o=e.streams[0];n(o)},_o=(t,e)=>d(void 0,null,function*(){let{offerParam:n,productRemoteSdp:o,customerRTCPeerConnection:r,onConnected:i,onConnectedFailed:l,onIceDisconnected:m,onPcEventAdded:a,onLocalDescriptionReady:g}=t,y=!!r&&r instanceof RTCPeerConnection,b={},v=y?r:new RTCPeerConnection(b);if(v.addEventListener("icecandidate",f=>Po(v,f)),v.addEventListener("iceconnectionstatechange",f=>wo(v,f,m)),v.addEventListener("connectionstatechange",f=>xo(v,f)),v.addEventListener("track",f=>Eo(v,f,e)),a&&(yield a(v)),y)return new ae(v);try{let f=yield v.createOffer(n);N.debug("\u521B\u5EFAoffer\uFF0C\u53C2\u6570\uFF1A",n,"\uFF0C \u7ED3\u679C\uFF1A",f),yield v.setLocalDescription(f),g&&g(v);let I=yield o(new RTCSessionDescription(f));N.debug("webrtc recv open answer",I);let T=new RTCSessionDescription({type:"answer",sdp:I});yield v.setRemoteDescription(T),N.debug("getTransceivers",v.getTransceivers()),i&&i(v)}catch(f){throw l&&l(v),N.error(new Error(`webrtc Failed to create session description: ${f.toString()}`)),v.close(),f}return new ae(v)}),So=t=>{if(!t)return;let{pc:e}=t;e.close()},To={connect:_o,disconnect:So},Je=To;var U=document.documentElement,le="requestFullscreen",ce="exitFullscreen",de="fullscreenElement",ue="onfullscreenchange";if("webkitRequestFullScreen"in U)le="webkitRequestFullScreen",ce="webkitExitFullscreen",de="webkitFullscreenElement",ue="onwebkitfullscreenchange";else if("msRequestFullscreen"in U)le="msRequestFullscreen",ce="msExitFullscreen",de="msFullscreenElement",ue="MSFullscreenChange";else if("mozRequestFullScreen"in U)le="mozRequestFullScreen",ce="mozCancelFullScreen",de="mozFullScreenElement",ue="onmozfullscreenchange";else if(!("requestFullscreen"in U))throw"\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";function Ro(t=U,e){return t[le](e)}function ko(){return document[ce]()}function Dt(t){return t===document[de]}function Fo(t=U,e){return Dt(t)?ko():Ro(t,e)}function Mo(t,e){let n=()=>{t.onfullscreenchange=null},o=r=>{r.target!==null&&e(Dt(r.target))};return t[ue]=o,{cancel:n}}var Lo={toggle:Fo,watch:Mo},pe=Lo;var No=({label:t,value:e,suffix:n})=>jsx.h("div",{className:"player_info-modal_list_item",withNamespace:!0},jsx.h("span",{className:"player_info-modal_list_item_label",withNamespace:!0},t),jsx.h("span",{className:"player_info-modal_list_item_value",withNamespace:!0},e),jsx.h("span",{className:"player_info-modal_list_item_suffix",withNamespace:!0},n)),Vt=({list:t,factory:e})=>(t==null?void 0:t.length)?e?jsx.h(jsx.Fragment,null,t.map(n=>jsx.h(Vt,{list:Object.keys(n).map(o=>e[o]?e[o](n[o],n):!1).filter(o=>o!==!1)}))):jsx.h("div",{className:"player_info-modal_list",withNamespace:!0},t.map(n=>jsx.h(No,R({},n)))):null,Ge=Vt;var M;(function(o){o.DIRECT="direct",o.PLUGIN="plugin",o.REJECT="reject"})(M||(M={}));var me;(function(i){i.MP4="MP4",i.FLAC="FLAC",i.OGG="OGG",i.WEBM="WEBM",i.AUTO="AUTO"})(me||(me={}));var Xe;(function(e){e.WEBRTC="WEBRTC"})(Xe||(Xe={}));var Bt="player",At=class extends w{constructor(e){super("div",Bt);this._lastTotalReceivedBytes=0;this._video=new St,this._spinner=new xt({spin:!1}),this._mask=new Pt({visible:!1}),this._panel=new Ot,this._infoModal=new Rt({container:this.el,title:"Info",center:!0,className:`${Bt}_info-modal`}),this._videoOption=e==null?void 0:e.video,this._pluginOption=e==null?void 0:e.pluginOption,this._playerConfig=e==null?void 0:e.playerConfig,this._mode=this._restrictPlayerMode(e==null?void 0:e.video,e==null?void 0:e.pluginOption),s.debug("PlayerMode",this._mode)}justifyVideoType(e,n){if((e==null?void 0:e.url)&&!e.type)return me.AUTO;let o="".toUpperCase.call((e==null?void 0:e.type)||Object.keys(n||{})[0]||"");return s.debug("justifyVideoType ",e,o),o}_restrictPlayerMode(e,n){let o=this.justifyVideoType(e,n);if(!o&&!(e==null?void 0:e.url))return M.REJECT;if(!o)return M.DIRECT;let r=Object.keys(me),i=Object.keys(Xe);return r.includes(o)?M.DIRECT:i.includes(o)?M.PLUGIN:M.DIRECT}init(){s.debug("\u6E32\u67D3PlayerPlugin",this.el),this.prepare();let e=this._video.init(),n=this._spinner.init(),o=this._mask.init(),r=this._panel.init(),i=this._infoModal.init();return u.dom.append(this.el,e,n,o,...r,i),this.initEvents(),this.dispatch("init",{name:"initEvent",target:this,mode:this._mode}),this.el}get video(){return this._video}get spinner(){return this._spinner}get mask(){return this._mask}play(e){return d(this,null,function*(){this.mute(!0),yield this._video.play(),this.mute(e)})}mute(e){var n;this._video.muted=!!e,s.debug("player mute: ",(n=this._video.getEl())==null?void 0:n.muted)}setProductRemoteSdp(e){!this._pluginOption||!this._pluginOption.webrtc||(this._pluginOption.webrtc.productRemoteSdp=e)}prepareWebrtc(){return d(this,null,function*(){var n;if(this._mode!==M.PLUGIN)return;s.debug("PuPlayer Plugin prepareWebrtc");let e=(n=this._pluginOption)==null?void 0:n.webrtc;!e||(this._video.autoPlay=!0,this._spinner.spin=!0,this._webrtcConnect=yield Je.connect(e,o=>{var i;if(!o)return;(i=this.video.getEl())==null||i.addEventListener("canplay",()=>{s.debug("Video canplay"),this.video.play()}),this._video.srcObject=o;let r=o.getTracks()[0];r.onended=l=>{s.debug("\u6D41\u89C6\u9891\u8F68\u9053\u5DF2\u7ECF\u7EC8\u6B62",l)},r.onmute=l=>{s.debug("\u6D41\u89C6\u9891\u8F68\u9053\u6682\u65F6\u65E0\u6CD5\u63D0\u4F9B\u5A92\u4F53",l),this.onMuted()},r.onunmute=l=>{s.debug("\u6D41\u89C6\u9891\u8F68\u9053\u63D0\u4F9B\u5A92\u4F53",l),this.onUnMuted()}}))})}close(){this.closeWebrtc()}beforeDestroy(){this.close()}onMuted(){}onUnMuted(){}loadPlayerConfig(){var e;this.video.autoPlay=!!((e=this._playerConfig)==null?void 0:e.autoPlay)}initEvents(){var o,r,i,l,m;(o=this.video.getEl())==null||o.addEventListener("canplay",()=>{this._spinner.spin=!1,this._mask.visible=!1}),(r=this.video.getEl())==null||r.addEventListener("waiting",()=>{s.debug("Video is waiting for more data."),this._spinner.spin=!0}),(i=this.el)==null||i.addEventListener("mousemove",()=>{this._panel.showThenHide()}),(l=this.el)==null||l.addEventListener("click",()=>{this._panel.showThenHide()});let e=(a=!1)=>{let g=this._panel.controller.PlayButton;a||(this._video.paused=!this._video.paused),console.log("oalyer,",this._video.paused),this._video.paused?g.Children=jsx.h(x.Play,null):g.Children=jsx.h(x.Play,{off:!0})};e(!0),this._panel.controller.addEventListener("play",()=>e()),this._video.addEventListener("play",()=>{s.debug("video play"),this._panel.showThenHide();let a=this._panel.controller.PlayButton;a.Children=jsx.h(x.Play,{off:!0})}),this._video.addEventListener("pause",()=>{s.debug("video pause"),this._panel.showThenHide();let a=this._panel.controller.PlayButton;a.Children=jsx.h(x.Play,null)}),this._panel.controller.addEventListener("screenshot",()=>{let a=this._video.getEl();if(!a){s.libError("playerPlugin screenshot videoEl\u4E3A\u7A7A\u503C");return}G.screenshot(a,`screenshot_${Date.now()}`)}),this._panel.controller.addEventListener("fullscreen",()=>{if(!this.el){s.libError("playerPlugin fullscreen playerEL\u4E3A\u7A7A\u503C");return}pe.toggle(this.el)}),(m=this._infoModal)==null||m.addEventListener("hide",()=>{this._infoModal.visible=!1,window.clearInterval(this._timer)}),this._panel.controller.addEventListener("information",()=>d(this,null,function*(){if(!this._video.getEl()){s.libError("playerPlugin information videoEl\u4E3A\u7A7A\u503C");return}this.refreshInfoModal()}));let n=(a=!1)=>{var b;let g=this._panel.controller.VolumeButton,y=(b=this._video.getEl())==null?void 0:b.muted;a||(this._video.muted=!y),y?g.Children=jsx.h(x.Volume,null):g.Children=jsx.h(x.Volume,{off:!0})};n(!0),this._panel.controller.addEventListener("volume",()=>n())}prepare(){if(s.debug("PlayerPlugin mode: ",this._mode),this.loadPlayerConfig(),this._mode===M.REJECT){s.error(new Error("\u4E0D\u652F\u6301\u7684\u89C6\u9891\u7C7B\u578B"),this._mode,this._videoOption);return}if(this._mode===M.DIRECT){this.prepareDirect();return}if(this._mode===M.PLUGIN){switch(this.justifyVideoType(this._videoOption,this._pluginOption)){case"webrtc":break;default:break}return}}prepareDirect(){var e;this._video.url=((e=this._videoOption)==null?void 0:e.url)||"",setTimeout(()=>{this.play()},300)}closeWebrtc(){var e;Je.disconnect(this._webrtcConnect),this.dispatch("closeWebrtc",{name:"closeWebrtcEvent",target:this,peerConnection:(e=this._webrtcConnect)==null?void 0:e.pc}),this._webrtcConnect=null,this._video.srcObject=null}refreshInfoModal(){return d(this,null,function*(){if(window.clearInterval(this._timer),!this._webrtcConnect)return;let e=3,n=()=>d(this,null,function*(){if(!this._webrtcConnect)return;let o=yield this._webrtcConnect.getStatsInfos();s.debug("player get result: ",o);let r={mimeType:(a="")=>({label:"Mime Type:",value:a}),totalSamplesReceived:(a=0,g)=>{let y={label:"Sample Rate:",value:""};return!a||!g.totalSamplesDuration||(y.value=Number(a/g.totalSamplesDuration).toFixed(3)+"Hz"),y}},i={mimeType:(a="")=>({label:"Mime Type:",value:a}),framesPerSecond:(a,g)=>({label:"Resolution:",value:`${g.frameWidth} x ${g.frameHeight}@${a}`}),bytesReceived:(a,g)=>{let y=a||0,b=(y-this._lastTotalReceivedBytes)*8/(e*1e3);return this._lastTotalReceivedBytes=y,{label:"Data Received:",value:`${Math.round(b)} kbps , lost ${g.packetsLost}`}}},l=jsx.h(Ge,{list:o.audios,factory:r}),m=jsx.h(Ge,{list:o.videos,factory:i});s.debug("audioInfoList",u.dom.createByJsx(l)),!!this._infoModal&&(this._infoModal.content=jsx.h("div",{style:"padding-left: 24px;"},jsx.h("section",{className:"player_info-modal_section",withNamespace:!0},jsx.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Audio"),l),jsx.h("section",{className:"player_info-modal_section",withNamespace:!0},jsx.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Video"),m)),this._infoModal.visible=!0)});n(),this._timer=window.setInterval(n,e*1e3)})}},ge=At;var Oo=(t,e,n)=>o=>d(void 0,null,function*(){if(o.type==="offer"){s.debug("\u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C \u8BBE\u5907\u914D\u7F6E\u4FE1\u606F\uFF1A",t,"token: ",e),s.debug("\u672C\u5730sdp",o);try{let{id:r,index:i}=t||{},l=yield k.getDeviceWebrtc({id:r,index:i,sdp:o.sdp},e);return n&&n(l.dialogId),l.sdp}catch(r){throw s.error(r,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`PUPlayer open \u5931\u8D25 , ${r.message}`)}}}),Do=t=>{let{container:e,token:n,puOption:o,defaultMediaOption:r={audio:!0,video:!0},testUrl:i,videoFit:l="fill",muted:m,apiPrefix:a,onConnected:g,onConnectedFailed:y,onDisConnected:b,fullScreenOnDblclick:v=!0}=t||{},f,I=n,T=o,L=e,E=typeof m=="boolean"?m:!r.audio;q(a);let C=()=>d(void 0,null,function*(){if(!!f&&(s.debug("PuPlayer close",f),p.mask.visible=!0,p.mask.text="Video Closed",p.close(),f))try{yield k.closeDialogs([f],I)}catch(h){throw s.error(h,"PuPlayer close \u5931\u8D25"),new Error(`PuPlayer close \u5931\u8D25 , ${h.message}`)}}),p=new ge({video:{url:i},pluginOption:{webrtc:{offerParam:{offerToReceiveAudio:r.audio,offerToReceiveVideo:r.video},productRemoteSdp:h=>d(void 0,null,function*(){return Oo(T,I,H=>{f=H})(h)}),onIceDisconnected:()=>{p.mask.visible=!0,p.mask.text="lost connection",p.close(),b&&b()},onConnected:()=>{g&&g()},onConnectedFailed:()=>{y&&y()}}},playerConfig:{autoPlay:!0}});p.addEventListener("init",h=>{s.debug("\u76D1\u542C\u5230\u4E86 player\u5DF2\u7ECF\u521D\u59CB\u5316",h)}),p.mute(E),p.video.fit=l;let P=p.init();v&&(P==null||P.addEventListener("dblclick",()=>{s.debug("\u53CC\u51FBplayer\uFF1A",P),pe.toggle(P)}));let V={instance:{getVideoElement:()=>p.video.getEl(),getPlayerElement:()=>p.getEl(),open:(h=!1)=>d(void 0,null,function*(){s.debug("PuPlayer open"),yield C(),s.debug("PuPlayer close before open"),p.mask.visible=!1,p.mask.text="connecting",p.mute(!!h);try{yield p.prepareWebrtc()}catch(_){throw p.mask.visible=!0,p.mask.text="connect failed",_}if(typeof h=="boolean"&&h){let _=()=>{s.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",E),s.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),p.mute(E),document.removeEventListener("click",_),document.removeEventListener("touchend",_)};document.addEventListener("click",_),document.addEventListener("touchend",_)}}),play:()=>d(void 0,null,function*(){yield p.play(E)}),mute:(h=!1)=>{E=h,p.mute(h)},hidden:h=>d(void 0,null,function*(){let _=P,H=p.video.getEl();_.style.display="none",document.body.appendChild(_),H.muted=!0;try{typeof h!="undefined"&&(E=h),yield p.play(E)}catch(Ko){s.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}s.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",H.paused)}),display:h=>d(void 0,null,function*(){let _=P,H=p.video.getEl();u.render(_,L,()=>d(void 0,null,function*(){_.style.display="block",typeof h!="undefined"&&(E=h),yield p.play(E)})),s.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",H.paused)}),moveTo:h=>{s.debug("\u79FB\u52A8\u81F3\uFF1A",h),L=h,u.render(P,L,()=>d(void 0,null,function*(){}))},getCurrentContainer:()=>L,setPuOption:h=>{T=h},setVideoFit:h=>{s.debug("PuPlayer setVideoFit",h),p.video.fit=h},setToken:h=>{s.debug("PuPlayer setToken",h),I=h},setApiPrefix:q,close:C,render:p.init,destroy:()=>d(void 0,null,function*(){s.debug("PuPlayer destroy"),yield C(),p.destroy()})},element:P};return L&&(u.render(P,L),V.element=null),V},Wt=Do;var qe=class extends Y{constructor(e,n){super();this._plugin=e,this._el=this._plugin.init(),this._currentContainer=n}moveTo(e,n){s.debug("\u79FB\u52A8\u81F3\uFF1A",e),this._currentContainer=e,u.render(this._el,this._currentContainer,n)}getCurrentContainer(){return this._currentContainer}render(){return this._plugin.init()}destroy(){s.debug("destroy",this._plugin),this._plugin.destroy(),this.dispatch("destroy")}};var te=class{constructor(e,n,o,r){this.token="";this.fetchSdpFunc=e,this.token=n||"",this.param=o,this.prefix=r}fetch(e){return d(this,null,function*(){s.debug("RemoteSdpFetcher fetch \u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C param\uFF1A",this.param,"token: ",this.token);let n=yield this.fetchSdpFunc(e,this.param,this.token,this.prefix),{sdp:o,dialogId:r}=n||{};return this.dialogId=r,s.debug(`RemoteSdpFetcher fetch \u83B7\u5F97\u7684remoteSdp ${o}, dialogId: ${r}`),o})}close(){return d(this,null,function*(){s.debug(`remoteSdpFetcher close\uFF0C \u68C0\u67E5dialogId: ${this.dialogId}`),this.dialogId&&(yield k.closeDialogs([this.dialogId]))})}},Qe=class extends qe{constructor(e,n,o,r,i){super(e,i);this._muted=!1;this._videoFit="contain";this.setRemoteSdpFetcher(r),this.setVideoFit(n),this.setMuted(o)}get player(){return this._plugin}getPlayerElement(){return this.player.getEl()}getVideoElement(){return this.player.video.getEl()}setRemoteSdpFetcher(e){this._remoteSdpFetcher=e,this._plugin.setProductRemoteSdp(n=>d(this,null,function*(){var o;return(o=this._remoteSdpFetcher)==null?void 0:o.fetch(n)}))}getRemoteSdpFetcher(){return this._remoteSdpFetcher}setVideoFit(e){s.debug("BvWebrtcInstance setVideoFit",e),this._videoFit=e,this.player.video.fit=e}getVideoFit(){return this._videoFit}setMuted(e=!1){this._muted=e,this.player.mute(e)}getMuted(){return this._muted}mute(e=!1){return this.setMuted(e)}open(e=!1){return d(this,null,function*(){s.debug("BvWebrtc open"),yield this.close(),this.player.mask.visible=!1,this.player.mask.text="connecting",this.player.mute(!!e);try{yield this.player.prepareWebrtc()}catch(n){throw this.player.mask.visible=!0,this.player.mask.text="connect failed",n}if(e){let n=()=>{s.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",this._muted),s.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),this.player.mute(this._muted),document.removeEventListener("click",n),document.removeEventListener("touchend",n)};document.addEventListener("click",n),document.addEventListener("touchend",n)}})}play(){return d(this,null,function*(){yield this.player.play(this._muted)})}hidden(e){return d(this,null,function*(){let n=this._el,o=this.player.video.getEl();n.style.display="none",document.body.appendChild(n),o.muted=!0;try{typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)}catch(r){s.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}s.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}display(e){return d(this,null,function*(){let n=this._el,o=this.player.video.getEl();u.render(n,this._currentContainer,()=>d(this,null,function*(){n.style.display="block",typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)})),s.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}close(){return d(this,null,function*(){if(s.debug("BvWebrtcInstance close",`_dialogId: ${this._dialogId}`),this.player.mask.visible=!0,this.player.mask.text="Video Closed",this.player.close(),s.debug("BvWebrtcInstance close\uFF0C player closed\uFF0C\u68C0\u67E5 remoteSdpFetcher: ",this._remoteSdpFetcher),this.dispatch("close"),this._remoteSdpFetcher)try{yield this._remoteSdpFetcher.close()}catch(e){throw s.error(e,"BvWebrtcInstance close \u5931\u8D25"),new Error(`BvWebrtcInstance close \u5931\u8D25 , ${e.message}`)}})}destroy(){s.debug("PuPlayer destroy"),this.close(),this.player.destroy()}};var Vo=t=>{let{container:e,sdpFetcher:n,offerParam:o,videoFit:r,muted:i,autoPlay:l,onConnected:m,onClose:a,onDestroy:g,onConnectedFailed:y,onDisConnected:b,onPcEventAdded:v}=t,f=new ge({pluginOption:{webrtc:{offerParam:o,productRemoteSdp:()=>d(void 0,null,function*(){return""}),onIceDisconnected:()=>{f.mask.visible=!0,f.mask.text="lost connection",f.close(),b&&b()},onPcEventAdded:v,onConnected:()=>{f.mask.visible=!1,f.mask.text="connected",m&&m()},onConnectedFailed:()=>{y&&y()}}},playerConfig:{autoPlay:l}}),I=new Qe(f,r,i,n,e);I.addEventListener("close",()=>{a&&a()}),I.addEventListener("destroy",()=>{g&&g()});let T={open:()=>d(void 0,null,function*(){s.debug("BvWebrtc open"),yield I.open()}),setOption:C=>{s.debug("BvWebrtc setOption");let p=I.getRemoteSdpFetcher();p&&(p.param=C)},setToken:C=>{s.debug("BvWebrtc setToken",C);let p=I.getRemoteSdpFetcher();p&&(p.token=C)},setApiPrefix:C=>{s.debug("BvWebrtc setApiPrefix",C);let p=I.getRemoteSdpFetcher();p&&(p.prefix=C)},getRemoteSdpFetcher:()=>I.getRemoteSdpFetcher(),close:()=>d(void 0,null,function*(){s.debug("BvWebrtc close"),yield I.close()}),render:()=>(s.debug("BvWebrtc render"),I.render()),destroy:()=>{s.debug("BvWebrtc destroy"),I.destroy()}},L=I.render(),E={instance:T,element:L};return e&&(u.render(L,e),E.element=null),E},Ht=Vo;var Bo=()=>d(void 0,null,function*(){s.debug("\u8BF7\u6C42\u9EA6\u514B\u98CE...");let t=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),e=t.getAudioTracks();return s.debug("\u9EA6\u514B\u98CE \u97F3\u9891\u8F68\u9053\uFF1A",e),t}),Ao=t=>{let{container:e,token:n,getRemoteSdpParam:o,apiPrefix:r,getRemoteSdpResult:i,onConnected:l,onClose:m,onDestroy:a,onConnectedFailed:g,onDisConnected:y,onGetUserMediaFailed:b}=t||{},v=(C,p,P,he)=>d(void 0,null,function*(){if(s.debug("audioPlayer productRemoteSdp",{param:{localDescription:C,param:p,token:P,prefix:he}}),C.type==="offer"&&(q(he),s.debug("\u672C\u5730sdp",C),!!i))try{let{sdp:V,dialogId:h}=yield i(C.sdp,P,p);return{sdp:V,dialogId:h}}catch(V){throw s.error(V,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`productRemoteSdp \u5931\u8D25 , ${V.message}`)}}),f=new te(v,n,o,r),{instance:I,element:T}=Ht({container:e,sdpFetcher:f,offerParam:{offerToReceiveAudio:!0},videoFit:"contain",muted:!1,autoPlay:!0,onConnected:l,onClose:m,onDestroy:a,onConnectedFailed:g,onDisConnected:y,onPcEventAdded:C=>d(void 0,null,function*(){try{let p=yield Bo();p.getTracks().forEach(P=>C.addTrack(P,p))}catch(p){b&&b()}})});return{instance:R({},I),element:T}},fe=Ao;var Wo=(t,e,n)=>d(void 0,null,function*(){let{id:o,index:r}=n||{};return yield k.getDeviceWebrtc({id:o,index:r,sdp:t},e)}),Ho=t=>{let{container:e,token:n,puOption:o,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}=t||{},{instance:b,element:v}=fe({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:Wo,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}),f=j(R({},b),{setPuOption:T=>b.setOption&&b.setOption(T)});return delete f.setOption,{instance:f,element:v}},jt=Ho;var jo=(t,e,n)=>d(void 0,null,function*(){let{id:o,index:r}=n||{};return yield k.getConferenceWebrtc({id:o,index:r,sdp:t},e)}),$o=t=>{let{container:e,token:n,confOption:o,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}=t||{},{instance:b,element:v}=fe({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:jo,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}),f=j(R({},b),{setConfOption:T=>b.setOption&&b.setOption(T)});return delete f.setOption,{instance:f,element:v}},$t=$o;var zo=k.closeAllStorageDialog;return Uo;})();
|
|
25
|
+
`,...n)}}formatShapeLog({level:t,title:e,color:n},o,...i){this.formatLog(t,e,o,re({color:n},this.getLoggerOption().shape,U.title),re({color:n},this.getLoggerOption().shape,U.message),...i)}debug(t,...e){this.formatShapeLog(A.debug,t,...e)}http(t,...e){this.formatShapeLog(A.http,t,...e)}api(t,...e){this.formatShapeLog(A.api,t,...e)}service(t,...e){this.formatShapeLog(A.service,t,...e)}interval(t,...e){this.formatShapeLog(A.interval,t,...e)}warn(t,...e){this.formatShapeLog(A.warn,t,...e)}},nr=new rt,cn=new ye,dn=cn,D=dn;var lt=class extends ye{constructor(){super(...arguments);this.test=(e,...n)=>{let o=4;this.formatShapeLog({level:o,title:" Test ",color:"#3f6600"},e,...n)};this.libWarn=(e,...n)=>{this.warn("bvplayer-core ",e,...n),console.warn(new Error().stack)};this.libError=(e,...n)=>{this.error(new Error(`bvplayer-core ${e}`),...n)}}},be=new lt;be.debug("player-core env:",d);be.version(d.SH_LIB_NAME,d.SH_LIB_VERSION||"");var a=be;var un=Array.isArray,pn=t=>t!==t,ct=t=>typeof t=="number",dt=t=>typeof t=="string",mn=t=>ct(t)||dt(t),gn=t=>typeof t=="function",fn=t=>typeof t=="undefined",hn=t=>t?!1:!!(t!=null?t:!0),vn={isArr:un,baseIsNaN:pn,isString:dt,isNumber:ct,isText:mn,isFn:gn,isUndefined:fn,isNullOrUndefined:hn},F=vn;function yn(t,e=[]){let n=-1,o=t.length;for(e||(e=Array(o));++n<o;)e[n]=t[n];return e}function bn(t,e,n){let o=n-1,i=t.length;for(;++o<i;)if(t[o]===e)return o;return-1}function In(t,e,n,o=!1){let i=t.length,s=n+(o?1:-1);for(;o?s--:++s<i;)if(e(t[s],s,t))return s;return-1}function Cn(t,e,n){return e===e?bn(t,e,n):In(t,F.baseIsNaN,n)}function Pn(t,e){let n=-1,o=e.length,i=t;for(t===e&&(e=yn(e));++n<o;){let s=0,c=e[n],g=c;for(;(s=Cn(i,g,s))>-1;)i!==t&&[].splice.call(i,s,1),[].splice.call(t,s,1)}return t}var wn=t=>t?F.isArr(t)?t:[t]:[],En=(t,e)=>!t||!t.length||!e||!e.length?t:Pn(t,e),_n=(t,e="")=>{let n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0,n.width,n.height),n.toBlob(o=>{if(!o){a.libError("util screenshot canvas\u7684\u8F93\u51FA\u4E3A\u7A7A\u503C");return}let i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=`${e}.png`,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)})},xn={pullAll:En,toArray:wn,screenshot:_n},K=xn;function Sn(t){return t!=null&&t!==!0&&t!==!1}function ut(t,e=[]){return t.forEach(n=>{F.isArr(n)?ut(n,e):Sn(n)&&e.push(F.isText(n)?Rn(n):n)}),e}function Tn(t={},e){if(!e)return;Object.keys(t).forEach(o=>{if(o==="children")return;let i=t[o];F.isNullOrUndefined(i)||(o.startsWith("on")?e.addEventListener(o.substring(2).toLowerCase(),i):e instanceof Element?e.setAttribute(o==="className"?"class":o,i):e[o]=i)})}function Rn(t){return{type:"",props:{nodeValue:String(t)+""}}}function kn(t,e){return t===""?document.createTextNode(""):e?document.createElementNS(e,t):document.createElement(t)}function Q(t,e,n){let o=e?e(t):t;if(!o)return null;if(F.isArr(o)){let c=document.createDocumentFragment();return o.forEach(g=>{let l=Q(g,e);l&&c.appendChild(l)}),c}let{props:i,type:s}=o;if(!i)return o instanceof Node||o instanceof Text?(a.libWarn("jsx grow","\u63D0\u793A",o,"\u5E76\u4E0D\u662F\u6709\u6548\u7684jsx element \u5DF2\u7ECF\u539F\u6837\u8F93\u51FA\uFF0C\u4E0D\u5F71\u54CDui \u4F46\u5C3D\u91CF\u5C11\u6DF7\u7528jsx\u548Cdom"),o):(a.libWarn("jsx grow","\u672A\u89E3\u6790",o,"\u56E0\u4E3A\u5B83\u4E0D\u662F\u6709\u6548\u7684jsx element\uFF0C\u5E76\u4E14\u4E5F\u4E0D\u662FRenderTarget\u7C7B\u578B"),null);if(F.isString(s)){let c=kn(s,i.xmlns||n);return Tn(i,c),(i.children||[]).forEach(l=>{let f=Q(l,e,i.xmlns);!f||c.appendChild(f)}),c}if(F.isFn(s)){let c=s(i);return Q(c,e)}return null}function Fn(t,e,...n){return e=e||{},n=ut(K.toArray(e.children||n)),e.children=n,{type:t,props:e}}var Mn=t=>t.children,Ln={h:Fn,Fragment:Mn},r=Ln;var Ie=t=>{let e;return t?e=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()):e=Date.now(),Math.floor(e/1e3)},pt=t=>{let e=typeof t=="number"?t:Ie(t),n=Ie();return e-n},Nn=t=>pt(t)>0,On={getUTCSecond:Ie,pastNow:pt,compare:Nn},Ce=On;var mt=(t,e,n)=>{let o={value:e,expire:n},i=JSON.stringify(o);return localStorage.setItem(t,i),o},Dn=(t,e,n)=>{let i=Ce.getUTCSecond()+n;return mt(t,e,i)},Vn=(t,e=!1)=>{let n=localStorage.getItem(t);if(!n)return null;try{let o=JSON.parse(n);return e?o:o.expire?Ce.compare(o.expire)?o.value:null:o.value}catch(o){a.error(o,n,"Storage\u8BFB\u53D6\u6570\u636E\u65F6\uFF0C JSON\u89E3\u6790\u51FA\u9519")}},Bn=t=>localStorage.removeItem(t),An={set:mt,setTimeout:Dn,get:Vn,remove:Bn},V=An;var ie;(function(n){n.GET="GET",n.POST="POST"})(ie||(ie={}));var gt=(t,e)=>u(void 0,null,function*(){let n=new AbortController;if(e.signal&&e.signal.addEventListener("abort",()=>{n.abort()}),e.timeout){let c=setTimeout(()=>{n.abort()},e.timeout);n.signal.addEventListener("abort",()=>{clearTimeout(c)})}let o=e.bodyData,i=o&&(typeof o=="object"?JSON.stringify(o):o),s={credentials:"same-origin",method:e.method,headers:new Headers(k({},e.headers)),signal:n.signal};i&&(s.body=i),a.http("\u53D1\u9001\u8BF7\u6C42\uFF1A",t,z(k({},s),{body:o}));try{let c=yield fetch(t,s);if(a.http("\u8BF7\u6C42\u54CD\u5E94\uFF1A",t,c,yield c.clone().text()),c.ok||c.status>=200&&c.status<300){let g=c.headers.get("content-type")||"";if(/application\/json/i.test(g))return yield c.json()}else throw new Error(`${c.status} ${c.statusText}`)}catch(c){if(c.name==="AbortError"){a.http("\u8BF7\u6C42\u53D6\u6D88\uFF1A",s);return}throw c}}),Wn=(t,e,n)=>u(void 0,null,function*(){let o=e?e.toString():"";return yield gt(t+o,{method:ie.GET,headers:n==null?void 0:n.headers})}),Hn=(t,e,n)=>u(void 0,null,function*(){return yield gt(t,{method:ie.POST,headers:k({"Content-Type":"application/json;charset=UTF-8"},n==null?void 0:n.headers),bodyData:e})}),$n={get:Wn,post:Hn},se=$n;var ft={BVCSP_V1:{path:"/bvcsp/v1",prefix:""}},Pe=t=>{let e=ft[t];return e.prefix+e.path},zn=(t,e)=>{let n=ft[t];return n.prefix=e||"",Pe(t)},Z={setApiPrefix:zn,getApiURL:Pe,bvscpV1:()=>Pe("BVCSP_V1")},Y=t=>{Z.setApiPrefix("BVCSP_V1",t)};var Un=t=>{if(!t)return null;if(t.nodeType===Node.DOCUMENT_NODE)return t.documentElement;if(t.nodeType===Node.ELEMENT_NODE){let e=t;return e.hasChildNodes()&&e.childNodes.forEach(n=>{let o=n;o.className&&new RegExp(".*bvplayer-core-player.*").test(o.className)&&e.removeChild(o)}),t}return null},Kn=(t,e,n)=>{if(!t)return;let o=document.createDocumentFragment();o.appendChild(t);let i=Un(e);!i||(i.appendChild(o),n==null||n())},ht=Kn;var ae=(...t)=>{let e=[];for(let n=0;n<t.length;n++){let o=t[n];if(!o)continue;let i=typeof o;if(F.isText(o))e.push(o);else if(Array.isArray(o)){if(o.length){let s=ae(...o);s&&e.push(s)}}else if(i==="object")if(o.toString==={}.toString)for(let s in o)({}).hasOwnProperty.call(o,s)&&o[s]&&e.push(s);else e.push(o.toString())}return e.join(" ")},vt=t=>t?t.replace(/\s*(;|\{|\})+\s*[\n\r]*/g,"$1"):"",Jn=(t,...e)=>{if(!e.length)return vt(t[0]);let n="";return e.forEach((o,i)=>{n+=t[i]+o}),n+=t[t.length-1],vt(n)},we="bvplayer-",Gn="common-",yt=t=>new RegExp(we).test(t),Xn=(...t)=>ae(t).split(" ").map(e=>yt(e)?e:we+e).join(" "),qn=(...t)=>ae(t).split(" ").map(e=>yt(e)?e:we+Gn+e).join(" ");var Qn={cls:ae,css:Jn,prefixCls:Xn,commonCls:qn},j=Qn;function Zn(t){return document.createRange().createContextualFragment(t)}function Yn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function Ee(){return document.createDocumentFragment()}function jn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function eo(t,...e){if(!t)return;let n=Ee();n.append(...e.filter(o=>o)),t.appendChild(n)}function to(t){if(!!t)if(t instanceof Element){t.innerHTML="";return}else for(;t.firstChild;)t.removeChild(t.firstChild)}function no(t,...e){if(!e.length||!(t==null?void 0:t.parentNode))return;let n=e.filter(o=>o);if(t instanceof Element)t.replaceWith(...n);else{let o=Ee();o.append(...n),t.parentNode.replaceChild(o,t)}}function oo(t){var e;if(!!t)if(t instanceof Element){t.remove();return}else(e=t.parentNode)==null||e.removeChild(t)}function ro(t){if(!t||!t.props)return t;let{props:e}=t;return e.withCommonNamespace&&(e.className=j.commonCls(e.className),delete e.withCommonNamespace),e.withNamespace&&(e.className=j.prefixCls(e.className),delete e.withNamespace),t}function io(t){return t?Q(t,ro):null}var so={parseHtml:Zn,create:Yn,createFragment:Ee,createHtmlElement:jn,createByJsx:io,append:eo,empty:to,replace:no,removeSelf:oo},bt=so;var ao="bvplayerCore",lo=t=>ao+t,co={createPrefixStorageField:lo},It=co;var uo={render:ht,style:j,dom:bt,field:It},p=uo;var W=p.field.createPrefixStorageField("DialogIds"),po=(t,e)=>u(void 0,null,function*(){var c;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},i=yield se.post(`${Z.bvscpV1()}/dialog/device/webrtc`,o,{headers:n});if(a.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:i}),!i||i.code!==0||!((c=i.data)==null?void 0:c.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${i.msg}`);let{data:s}=i;if(s.dialogid){let g=V.get(W)||[];g.push(s.dialogid),V.set(W,g)}return{dialogId:s.dialogid,sdp:s.sdp}}),mo=(t,e)=>u(void 0,null,function*(){var g;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},i=yield se.post(`${Z.bvscpV1()}/dialog/conference/webrtc`,o,{headers:n});if(a.api("\u4F1A\u8BAE\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:i}),!i||i.code!==0||!((g=i.data)==null?void 0:g.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${i==null?void 0:i.msg}`);let{data:s}=i,c=V.get(W)||[];return c.push(s.dialogid),V.set(W,c),{dialogId:s.dialogid,sdp:s.sdp}}),go=(t,e)=>u(void 0,null,function*(){if(!t)return;let n={Authorization:e||""};return a.api("\u5173\u95EDdialog\uFF1A",t),yield se.post(`${Z.bvscpV1()}/dialog/close/${t}`,{},{headers:n})}),Ct=(t,e)=>u(void 0,null,function*(){let n=V.get(W)||[];K.pullAll(n,t),V.set(W,n,0);let i=(yield Promise.allSettled(t.map(s=>go(s,e)))).filter(s=>s.status==="rejected");i&&i.length>0&&a.error(new Error(`"\u5173\u95ED\u5B58\u50A8\u7684dialog\u65F6\u5931\u8D25\uFF1A", ${i}`))}),fo=t=>u(void 0,null,function*(){let e=V.get(W);!e||e.length<1||(V.remove(W),yield Ct(e,t))}),ho={getDeviceWebrtc:po,getConferenceWebrtc:mo,closeDialogs:Ct,closeAllStorageDialog:fo},M=ho;var Pt=class{constructor(){this._map=new Map}findExecutor(e,n){let o=this._map.get(e);return{index:o?o.findIndex(s=>Object.is(n,s)):-1,que:o}}publish(e,n){let o=this._map.get(e)||[],i=o.length;for(let s=0;s<i;s++){let c=o[s];c&&c(n)}}subscribe(e,n){let{index:o,que:i=[]}=this.findExecutor(e,n);return o>=0?i[o]=n:i.push(n),this._map.set(e,i),{unSubscribe:()=>{this.unSubscribe(e,n)}}}unSubscribe(e,n){let{index:o,que:i=[]}=this.findExecutor(e,n);o<0||(i.splice(o,1),this._map.set(e,i))}},ee=class{constructor(){this._notifier=new Pt}addEventListener(e,n){this._notifier.subscribe(e,n)}removeEventListener(e,n){this._notifier.unSubscribe(e,n)}dispatch(e,n){this._notifier.publish(e,n)}};var E=class extends ee{constructor(e,n,o){super();this.name="";let i=n.trim().toLowerCase(),s=o?o.trim():i,c=p.dom.create(e,p.style.prefixCls(s));this.name=i,this.el=c}empty(){p.dom.empty(this.el)}unmount(){var e;a.debug("unmount",this.el,(e=this.el)==null?void 0:e.parentNode),p.dom.removeSelf(this.el)}destroy(){if(this.beforeDestroy(),this.empty(),this.unmount(),this.el=null,this.dispatch("destroy"),!!this){for(let e in this)this[e]=void 0;a.debug("destroy complete",this)}}getEl(){return this.el}};var wt=class extends E{constructor(e){super("div","mask",p.style.cls("mask"));this._visible=!!(e==null?void 0:e.visible),this._text=e==null?void 0:e.text,this._textEl=p.dom.create("span",p.style.cls("text"))}set visible(e){this._visible=e,this.el.style.display=this._visible?"grid":"none"}set text(e){this._text=e,this._textEl.textContent=e}beforeDestroy(){}init(){a.debug("mask visible: ",this._visible);let e=this.el;return e.style.display=this._visible?"block":"none",this._textEl.textContent=this._text||"",p.dom.append(e,this._textEl),e}},Et=wt;var _t=class extends E{constructor(e){super("div","spinner",p.style.cls("spinner"));this._spin=!!(e==null?void 0:e.spin)}set spin(e){this._spin=e,this.el.style.display=this._spin?"block":"none"}beforeDestroy(){}init(){a.debug("spinner spin: ",this._spin);let e=this.el;e.style.display=this._spin?"block":"none";let n=p.dom.create("span");return n.style.backgroundColor="#FFF",p.dom.append(e,n),e}},xt=_t;var St={contain:"contain",fill:"fill"},Tt=class extends E{constructor(e){super("video","video",p.style.cls("video"));this._url=e==null?void 0:e.url,this._srcObject=(e==null?void 0:e.srcObject)||null,this._fit=(e==null?void 0:e.fit)||St.contain,this._autoPlay=!!(e==null?void 0:e.autoPlay),this._muted=!!(e==null?void 0:e.muted)}set url(e){typeof this._url!="undefined"&&(this.el.src=this._url),this._url=e}set srcObject(e){this._srcObject=e||null,this.el.srcObject=this._srcObject}set muted(e){let n=this.el;this._muted=e,n.muted=e}set paused(e){let n=this.el;e?n.pause():n.play()}get paused(){var e;return!!((e=this.el)==null?void 0:e.paused)}set autoPlay(e){if(!e!==this._autoPlay)return;this._autoPlay=e,this.muted=e;let n=this.el;n.autoplay=this._autoPlay}set fit(e){this._fit=St[e],this.el.style.objectFit=this._fit}getVideoFit(){return this._fit}init(){a.debug("\u6E32\u67D3VideoPlugin\u89C6\u9891\u5BF9\u8C61dom\u7684children",this,this.el);let e=this.el;return e.addEventListener("play",()=>this.dispatch("play",{target:this})),e.addEventListener("pause",()=>this.dispatch("pause",{target:this})),e.addEventListener("loadedmetadata",n=>{a.debug("video loadedmetadata",n),this.dispatch("loadedmetadata",{target:this})}),typeof this._url!="undefined"&&(e.src=this._url),e.srcObject=this._srcObject,e.autoplay=this._autoPlay,e.muted=this._muted,e.style.objectFit=this._fit,e.playsInline=!0,e}play(){return u(this,null,function*(){let e=this.el;try{a.debug("video \u5C1D\u8BD5\u64AD\u653E"),yield e.play()}catch(n){a.error(n,"video \u64AD\u653E \u5931\u8D25")}})}beforeDestroy(){}},Rt=Tt;function te(t){return class extends t{constructor(...e){super(...e);this._visible=!1}get visible(){return this._visible}set visible(e){let n=!!e;if(this._visible===n)return;this._visible=n;let o=p.style.commonCls("is-visible");this._visible?(this.show&&this.show(),this.el.setAttribute("aria-hidden","false"),this.el.classList.add(o)):(this.hide&&this.hide(),this.el.setAttribute("aria-hidden","true"),this.el.classList.remove(o))}}}function _e({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function xe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 0 1-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 0 1 .947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 0 1 2.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 0 1 2.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 0 1 .947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 0 1-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 0 1-2.287-.947zM10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function Se({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 9a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 10.07 4h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 18.07 7H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 13a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function Te({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M4 5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-1.586a1 1 0 0 1-.707-.293l-1.121-1.121A2 2 0 0 0 11.172 3H8.828a2 2 0 0 0-1.414.586L6.293 4.707A1 1 0 0 1 5.586 5H4zm6 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function Re({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0-5 5M4 16v4m0 0h4m-4 0 5-5m11 5-5-5m5 5v-4m0 4h-4"}))}function ke({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M3 4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 2H6.414l2.293 2.293a1 1 0 0 1-1.414 1.414L5 6.414V8a1 1 0 0 1-2 0V4zm9 1a1 1 0 1 1 0-2h4a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V6.414l-2.293 2.293a1 1 0 1 1-1.414-1.414L13.586 5H12zm-9 7a1 1 0 1 1 2 0v1.586l2.293-2.293a1 1 0 0 1 1.414 1.414L6.414 15H8a1 1 0 1 1 0 2H4a1 1 0 0 1-1-1v-4zm13-1a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 1 1 0-2h1.586l-2.293-2.293a1 1 0 0 1 1.414-1.414L15 13.586V12a1 1 0 0 1 1-1z","clip-rule":"evenodd"}))}function Fe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Me({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zm-7-4a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM9 9a1 1 0 0 0 0 2v3a1 1 0 0 0 1 1h1a1 1 0 1 0 0-2v-3a1 1 0 0 0-1-1H9z","clip-rule":"evenodd"}))}function Le({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m10 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2m7-2a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Ne({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM8.707 7.293a1 1 0 0 0-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 1 0 1.414 1.414L10 11.414l1.293 1.293a1 1 0 0 0 1.414-1.414L11.414 10l1.293-1.293a1 1 0 0 0-1.414-1.414L10 8.586 8.707 7.293z","clip-rule":"evenodd"}))}function Oe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18 18 6M6 6l12 12"}))}function De({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 0 1 1.414 0L10 8.586l4.293-4.293a1 1 0 1 1 1.414 1.414L11.414 10l4.293 4.293a1 1 0 0 1-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 0 1-1.414-1.414L8.586 10 4.293 5.707a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function Ve({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 0 1 0 7.072m2.828-9.9a9 9 0 0 1 0 12.728M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}))}function Be({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm5.274-.147a1 1 0 0 1 1.414 0A9.972 9.972 0 0 1 19 10a9.972 9.972 0 0 1-2.929 7.071 1 1 0 0 1-1.414-1.414A7.971 7.971 0 0 0 17 10a7.97 7.97 0 0 0-2.343-5.657 1 1 0 0 1 0-1.414zm-2.829 2.828a1 1 0 0 1 1.415 0A5.983 5.983 0 0 1 15 10a5.984 5.984 0 0 1-1.757 4.243 1 1 0 0 1-1.415-1.415A3.984 3.984 0 0 0 13 10a3.983 3.983 0 0 0-1.172-2.828 1 1 0 0 1 0-1.415z","clip-rule":"evenodd"}))}function Ae({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z","clip-rule":"evenodd"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m17 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2"}))}function We({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm2.91 4.217a1 1 0 0 1 1.414 0L15 8.586l1.293-1.293a1 1 0 1 1 1.414 1.414L16.414 10l1.293 1.293a1 1 0 0 1-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 0 1-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function He({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14.752 11.168-3.197-2.132A1 1 0 0 0 10 9.87v4.263a1 1 0 0 0 1.555.832l3.197-2.132a1 1 0 0 0 0-1.664z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function $e({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM9.555 7.168A1 1 0 0 0 8 8v4a1 1 0 0 0 1.555.832l3-2a1 1 0 0 0 0-1.664l-3-2z","clip-rule":"evenodd"}))}function ze({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 9v6m4-6v6m7-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Ue({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zM7 8a1 1 0 0 1 2 0v4a1 1 0 1 1-2 0V8zm5-1a1 1 0 0 0-1 1v4a1 1 0 1 0 2 0V8a1 1 0 0 0-1-1z","clip-rule":"evenodd"}))}function Ke({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 33",fill:"currentColor"},r.h("path",{d:"M6.667 28H1.334c-.8 0-1.333-.533-1.333-1.333v-5.333c0-.8.533-1.333 1.333-1.333s1.333.533 1.333 1.333v4h4c.8 0 1.333.533 1.333 1.333S7.467 28 6.667 28zm24 0h-5.333c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h4v-4c0-.8.533-1.333 1.333-1.333S32 20.534 32 21.334v5.333c0 .8-.533 1.333-1.333 1.333zm0-16c-.8 0-1.333-.533-1.333-1.333v-4h-4c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333v5.333c0 .8-.533 1.333-1.333 1.333zM1.333 12C.533 12 0 11.467 0 10.667V5.334c0-.8.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333s-.533 1.333-1.333 1.333h-4v4c0 .8-.533 1.333-1.333 1.333z"}))}var L=({children:t,className:e})=>{let n=p.style.cls(["icon",e]);return r.h("span",{className:n,withNamespace:!0},t)},vo=({filled:t})=>r.h(L,null,t?r.h(xe,null):r.h(_e,null)),yo=({filled:t})=>r.h(L,null,t?r.h(Te,null):r.h(Se,null)),bo=({filled:t})=>r.h(L,null,t?r.h(Me,null):r.h(Fe,null)),Io=({filled:t})=>r.h(L,null,t?r.h(ke,null):r.h(Re,null)),Co=({filled:t,circle:e})=>e?r.h(L,null,t?r.h(Ne,null):r.h(Le,null)):r.h(L,null,t?r.h(De,null):r.h(Oe,null)),Po=({filled:t,off:e})=>e?r.h(L,null,t?r.h(We,null):r.h(Ae,null)):r.h(L,null,t?r.h(Be,null):r.h(Ve,null)),wo=({filled:t,off:e})=>e?r.h(L,null,t?r.h(Ue,null):r.h(ze,null)):r.h(L,null,t?r.h($e,null):r.h(He,null)),Eo=()=>r.h(L,null,r.h(Ke,null)),_o={Cog:vo,Camera:yo,Info:bo,ArrowsExpand:Io,X:Co,Volume:Po,Play:wo,Full:Eo};var _=_o;var H="modal",kt=class extends E{constructor(e){super("div",H,p.style.cls([H,e.className,{[`${H}--center`]:e.center}]));this.container=e.container,this.title=e.title,this._content=e.content||p.dom.create("div","test"),this._center=!!e.center}set content(e){let n=p.dom.createByJsx(e);a.debug("modal update content",n,this._content),p.dom.replace(this._content,n),this._content=n}show(){var e;(e=this.el)==null||e.classList.toggle(p.style.prefixCls(`${H}--center`),!!this._center),p.dom.append(this.container,this.el)}hide(){}clear(){!this.el||(this.el.innerHTML="")}beforeDestroy(){}init(){this.clear(),a.debug("\u6E32\u67D3ModalPlugin \u5F39\u7A97\u5BF9\u8C61",this,this.el);let e=this.el,n=p.dom.createByJsx(r.h(r.Fragment,null,r.h("div",{className:`${H}_title-bar`,onClick:()=>this.dispatch("hide"),withNamespace:!0},r.h("span",{className:`${H}_title-bar_title`,withNamespace:!0},this.title),r.h("span",{className:`${H}_title-bar_close`,withNamespace:!0},r.h(_.X,null))),r.h("div",{className:`${H}_body`,withNamespace:!0},this._content)));return p.dom.append(e,n),e}},xo=te(kt),Je=class extends xo{},Ft=Je;var So="controller_button",Mt=class extends E{constructor(e,n){super("button",So);this._Children=e,this.title=n}set Children(e){!this.el||(this._Children=e,this.empty(),p.dom.append(this.el,p.dom.createByJsx(e)))}beforeDestroy(){}init(){let e=this.el;return e.addEventListener("click",()=>this.dispatch("click")),e.title=this.title||"",p.dom.append(e,p.dom.createByJsx(this._Children)),e}},J=Mt;var Lt="controller",Nt=class extends E{constructor(e){super("div",Lt,p.style.cls(Lt));this._controls=(e==null?void 0:e.controls)||[],this.PlayButton=new J(r.h(_.Play,null)),this.VolumeButton=new J(r.h(_.Volume,{off:!0}),"volume"),this.InformationButton=new J(r.h(_.Info,null),"information"),this.ScreenshotButton=new J(r.h(_.Camera,null),"screenshot"),this.FullscreenButton=new J(r.h(_.ArrowsExpand,null),"fullscreen"),this.PlayButton.addEventListener("click",()=>{this.dispatch("play")}),this.VolumeButton.addEventListener("click",()=>{this.dispatch("volume")}),this.InformationButton.addEventListener("click",()=>this.dispatch("information")),this.ScreenshotButton.addEventListener("click",()=>this.dispatch("screenshot")),this.FullscreenButton.addEventListener("click",()=>this.dispatch("fullscreen"))}beforeDestroy(){}init(){a.debug("\u6E32\u67D3ControllerPlugin \u64AD\u653E\u63A7\u5236\u5668\u5BF9\u8C61",this,this.el,this._controls);let e=this.el,n=p.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_left`]),o=p.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_right`]),i=p.dom.createByJsx(r.h(r.Fragment,null,r.h("div",{className:`${this.name}_mask`,withNamespace:!0}),r.h("div",{className:`${this.name}_inner`,withNamespace:!0},r.h("div",{className:n,withNamespace:!0},this.PlayButton.init(),this.VolumeButton.init()),r.h("div",{className:"flex-space",withCommonNamespace:!0}),r.h("div",{className:o,withNamespace:!0},this.InformationButton.init(),this.ScreenshotButton.init(),this.FullscreenButton.init()))));return p.dom.append(e,i),e}},To=te(Nt),Ge=class extends To{},Ot=Ge;var Dt=class{constructor(){this._els=[];this.disableAutoHide=!1;this._controller=new Ot}init(){let e=this._controller.init();return this._els.push(e),this._els}get els(){return this._els}get controller(){return this._controller}show(){this._controller.visible=!0}hide(){window.clearTimeout(this._autoHideTimeout),this._controller.visible=!1}showThenHide(){this.show(),window.clearTimeout(this._autoHideTimeout),this._autoHideTimeout=window.setTimeout(()=>{this.disableAutoHide||this.hide()},3e3)}},Vt=Dt;var le=class{constructor(e){this.pc=e}getReceiversMap(){let e=new Map([["audio",[]],["video",[]]]),n=this.pc.getReceivers();return(n==null?void 0:n.length)&&n.forEach(o=>{let{kind:i}=o.track,s=e.get(i)||[];s.push(o),e.set(i,s)}),e}getStatsInfos(){return u(this,null,function*(){let e=this.getReceiversMap();a.debug("receivers map : ",e);let n=yield Promise.all(e.get("audio").map(i=>u(this,null,function*(){let s={},c=yield i.getStats(),g=[];return c.forEach(l=>{g.push(l),l.type==="codec"&&(s.mimeType=l.mimeType,s.clockRate=l.clockRate,s.channels=l.channels),l.type==="track"&&(s.totalSamplesReceived=l.totalSamplesReceived,s.totalSamplesDuration=l.totalSamplesDuration)}),a.debug("audio stats report: ",g),s}))),o=yield Promise.all(e.get("video").map(i=>u(this,null,function*(){let s={},c=yield i.getStats(),g=[];return c.forEach(l=>{g.push(l),l.type==="codec"&&(s.mimeType=l.mimeType,s.clockRate=l.clockRate),l.type==="inbound-rtp"&&(s.frameWidth=l.frameWidth,s.frameHeight=l.frameHeight,s.framesPerSecond=l.framesPerSecond,s.framesReceived=l.framesReceived,s.framesDecoded=l.framesDecoded,s.totalInterFrameDelay=l.totalInterFrameDelay,s.keyFramesDecoded=l.keyFramesDecoded,s.packetsLost=l.packetsLost,s.lastPacketReceivedTimestamp=l.lastPacketReceivedTimestamp,s.bytesReceived=l.bytesReceived,s.totalDecodeTime=l.totalDecodeTime)}),a.debug("video stats report: ",g),s})));return{audios:n,videos:o}})}};var Ro=(t,e)=>{D.debug(`webrtc my ICE candidate:
|
|
26
|
+
${e.candidate?e.candidate.candidate:"(null)"}`)},ko=(t,e,n)=>{D.debug("webrtc ICE state change event: ",e),D.debug(`webrtc my ICE state: ${t==null?void 0:t.iceConnectionState}`),t&&t.iceConnectionState==="disconnected"&&n&&n()},Fo=(t,e)=>{D.debug("webrtc Connection state change, \u5F53\u524D\u8FDE\u63A5\u72B6\u6001: ",t,t.connectionState)},Mo=(t,e,n)=>{D.debug("webrtc \u5F53\u524D\u7684 stream: ",e.streams[0]);let o=e.streams[0];n(o)},Lo=(t,e)=>u(void 0,null,function*(){let{offerParam:n,productRemoteSdp:o,customerRTCPeerConnection:i,onConnected:s,onConnectedFailed:c,onIceDisconnected:g,onPcEventAdded:l,onLocalDescriptionReady:f}=t,b=!!i&&i instanceof RTCPeerConnection,I={},y=b?i:new RTCPeerConnection(I);if(y.addEventListener("icecandidate",h=>Ro(y,h)),y.addEventListener("iceconnectionstatechange",h=>ko(y,h,g)),y.addEventListener("connectionstatechange",h=>Fo(y,h)),y.addEventListener("track",h=>Mo(y,h,e)),l&&(yield l(y)),b)return new le(y);try{let h=yield y.createOffer(n);D.debug("\u521B\u5EFAoffer\uFF0C\u53C2\u6570\uFF1A",n,"\uFF0C \u7ED3\u679C\uFF1A",h),yield y.setLocalDescription(h),f&&f(y);let C=yield o(new RTCSessionDescription(h));D.debug("webrtc recv open answer",C);let R=new RTCSessionDescription({type:"answer",sdp:C});yield y.setRemoteDescription(R),D.debug("getTransceivers",y.getTransceivers()),s&&s(y)}catch(h){throw c&&c(y),D.error(new Error(`webrtc Failed to create session description: ${h.toString()}`)),y.close(),h}return new le(y)}),No=t=>{if(!t)return;let{pc:e}=t;e.close()},Oo={connect:Lo,disconnect:No},Xe=Oo;var G=document.documentElement,ce="requestFullscreen",de="exitFullscreen",ue="fullscreenElement",pe="onfullscreenchange";if("webkitRequestFullScreen"in G)ce="webkitRequestFullScreen",de="webkitExitFullscreen",ue="webkitFullscreenElement",pe="onwebkitfullscreenchange";else if("msRequestFullscreen"in G)ce="msRequestFullscreen",de="msExitFullscreen",ue="msFullscreenElement",pe="MSFullscreenChange";else if("mozRequestFullScreen"in G)ce="mozRequestFullScreen",de="mozCancelFullScreen",ue="mozFullScreenElement",pe="onmozfullscreenchange";else if(!("requestFullscreen"in G))throw"\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";function Do(t=G,e){return t[ce](e)}function Vo(){return document[de]()}function Bt(t){return t===document[ue]}function Bo(t=G,e){return Bt(t)?Vo():Do(t,e)}function Ao(t,e){let n=()=>{t.onfullscreenchange=null},o=i=>{i.target!==null&&e(Bt(i.target))};return t[pe]=o,{cancel:n}}var Wo={toggle:Bo,watch:Ao},me=Wo;var Ho=({label:t,value:e,suffix:n})=>r.h("div",{className:"player_info-modal_list_item",withNamespace:!0},r.h("span",{className:"player_info-modal_list_item_label",withNamespace:!0},t),r.h("span",{className:"player_info-modal_list_item_value",withNamespace:!0},e),r.h("span",{className:"player_info-modal_list_item_suffix",withNamespace:!0},n)),At=({list:t,factory:e})=>(t==null?void 0:t.length)?e?r.h(r.Fragment,null,t.map(n=>r.h(At,{list:Object.keys(n).map(o=>e[o]?e[o](n[o],n):!1).filter(o=>o!==!1)}))):r.h("div",{className:"player_info-modal_list",withNamespace:!0},t.map(n=>r.h(Ho,k({},n)))):null,qe=At;var N;(function(o){o.DIRECT="direct",o.PLUGIN="plugin",o.REJECT="reject"})(N||(N={}));var ge;(function(s){s.MP4="MP4",s.FLAC="FLAC",s.OGG="OGG",s.WEBM="WEBM",s.AUTO="AUTO"})(ge||(ge={}));var Qe;(function(e){e.WEBRTC="WEBRTC"})(Qe||(Qe={}));var Wt="player",Ht=class extends E{constructor(e){super("div",Wt);this._lastTotalReceivedBytes=0;this._video=new Rt,this._spinner=new xt({spin:!1}),this._mask=new Et({visible:!1}),this._panel=new Vt,this._infoModal=new Ft({container:this.el,title:"Info",center:!0,className:`${Wt}_info-modal`}),this._videoOption=e==null?void 0:e.video,this._pluginOption=e==null?void 0:e.pluginOption,this._playerConfig=e==null?void 0:e.playerConfig,this._mode=this._restrictPlayerMode(e==null?void 0:e.video,e==null?void 0:e.pluginOption),a.debug("PlayerMode",this._mode)}justifyVideoType(e,n){if((e==null?void 0:e.url)&&!e.type)return ge.AUTO;let o="".toUpperCase.call((e==null?void 0:e.type)||Object.keys(n||{})[0]||"");return a.debug("justifyVideoType ",e,o),o}_restrictPlayerMode(e,n){let o=this.justifyVideoType(e,n);if(!o&&!(e==null?void 0:e.url))return N.REJECT;if(!o)return N.DIRECT;let i=Object.keys(ge),s=Object.keys(Qe);return i.includes(o)?N.DIRECT:s.includes(o)?N.PLUGIN:N.DIRECT}init(){a.debug("\u6E32\u67D3PlayerPlugin",this.el),this.prepare();let e=this._video.init(),n=this._spinner.init(),o=this._mask.init(),i=this._panel.init(),s=this._infoModal.init();return p.dom.append(this.el,e,n,o,...i,s),this.initEvents(),this.dispatch("init",{name:"initEvent",target:this,mode:this._mode}),this.el}get video(){return this._video}get spinner(){return this._spinner}get mask(){return this._mask}play(e){return u(this,null,function*(){this.mute(!0),yield this._video.play(),this.mute(e)})}mute(e){var n;this._video.muted=!!e,a.debug("player mute: ",(n=this._video.getEl())==null?void 0:n.muted)}setProductRemoteSdp(e){!this._pluginOption||!this._pluginOption.webrtc||(this._pluginOption.webrtc.productRemoteSdp=e)}prepareWebrtc(){return u(this,null,function*(){var n;if(this._mode!==N.PLUGIN)return;a.debug("PuPlayer Plugin prepareWebrtc");let e=(n=this._pluginOption)==null?void 0:n.webrtc;!e||(this._video.autoPlay=!0,this._spinner.spin=!0,this._webrtcConnect=yield Xe.connect(e,o=>{var s;if(!o)return;(s=this.video.getEl())==null||s.addEventListener("canplay",()=>{a.debug("Video canplay"),this.video.play()}),this._video.srcObject=o;let i=o.getTracks()[0];i.onended=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u5DF2\u7ECF\u7EC8\u6B62",c)},i.onmute=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u6682\u65F6\u65E0\u6CD5\u63D0\u4F9B\u5A92\u4F53",c),this.onMuted()},i.onunmute=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u63D0\u4F9B\u5A92\u4F53",c),this.onUnMuted()}}))})}close(){this.closeWebrtc()}beforeDestroy(){this.close()}onMuted(){}onUnMuted(){}loadPlayerConfig(){var e;this.video.autoPlay=!!((e=this._playerConfig)==null?void 0:e.autoPlay)}initEvents(){var o,i,s,c,g;(o=this.video.getEl())==null||o.addEventListener("canplay",()=>{this._spinner.spin=!1,this._mask.visible=!1}),(i=this.video.getEl())==null||i.addEventListener("waiting",()=>{a.debug("Video is waiting for more data."),this._spinner.spin=!0}),(s=this.el)==null||s.addEventListener("mousemove",()=>{this._panel.showThenHide()}),(c=this.el)==null||c.addEventListener("click",()=>{this._panel.showThenHide()});let e=(l=!1)=>{let f=this._panel.controller.PlayButton;l||(this._video.paused=!this._video.paused),console.log("oalyer,",this._video.paused),this._video.paused?f.Children=r.h(_.Play,null):f.Children=r.h(_.Play,{off:!0})};e(!0),this._panel.controller.addEventListener("play",()=>e()),this._video.addEventListener("play",()=>{a.debug("video play"),this._panel.showThenHide();let l=this._panel.controller.PlayButton;l.Children=r.h(_.Play,{off:!0})}),this._video.addEventListener("pause",()=>{a.debug("video pause"),this._panel.showThenHide();let l=this._panel.controller.PlayButton;l.Children=r.h(_.Play,null)}),this._panel.controller.addEventListener("screenshot",()=>{let l=this._video.getEl();if(!l){a.libError("playerPlugin screenshot videoEl\u4E3A\u7A7A\u503C");return}K.screenshot(l,`screenshot_${Date.now()}`)}),this._panel.controller.addEventListener("fullscreen",()=>{if(!this.el){a.libError("playerPlugin fullscreen playerEL\u4E3A\u7A7A\u503C");return}me.toggle(this.el)}),(g=this._infoModal)==null||g.addEventListener("hide",()=>{this._infoModal.visible=!1,window.clearInterval(this._timer)}),this._panel.controller.addEventListener("information",()=>u(this,null,function*(){if(!this._video.getEl()){a.libError("playerPlugin information videoEl\u4E3A\u7A7A\u503C");return}this.refreshInfoModal()}));let n=(l=!1)=>{var I;let f=this._panel.controller.VolumeButton,b=(I=this._video.getEl())==null?void 0:I.muted;l||(this._video.muted=!b),b?f.Children=r.h(_.Volume,null):f.Children=r.h(_.Volume,{off:!0})};n(!0),this._panel.controller.addEventListener("volume",()=>n())}prepare(){if(a.debug("PlayerPlugin mode: ",this._mode),this.loadPlayerConfig(),this._mode===N.REJECT){a.error(new Error("\u4E0D\u652F\u6301\u7684\u89C6\u9891\u7C7B\u578B"),this._mode,this._videoOption);return}if(this._mode===N.DIRECT){this.prepareDirect();return}if(this._mode===N.PLUGIN){switch(this.justifyVideoType(this._videoOption,this._pluginOption)){case"webrtc":break;default:break}return}}prepareDirect(){var e;this._video.url=((e=this._videoOption)==null?void 0:e.url)||"",setTimeout(()=>{this.play()},300)}closeWebrtc(){var e;Xe.disconnect(this._webrtcConnect),this.dispatch("closeWebrtc",{name:"closeWebrtcEvent",target:this,peerConnection:(e=this._webrtcConnect)==null?void 0:e.pc}),this._webrtcConnect=null,this._video.srcObject=null}refreshInfoModal(){return u(this,null,function*(){if(window.clearInterval(this._timer),!this._webrtcConnect)return;let e=3,n=()=>u(this,null,function*(){if(!this._webrtcConnect)return;let o=yield this._webrtcConnect.getStatsInfos();a.debug("player get result: ",o);let i={mimeType:(l="")=>({label:"Mime Type:",value:l}),totalSamplesReceived:(l=0,f)=>{let b={label:"Sample Rate:",value:""};return!l||!f.totalSamplesDuration||(b.value=Number(l/f.totalSamplesDuration).toFixed(3)+"Hz"),b}},s={mimeType:(l="")=>({label:"Mime Type:",value:l}),framesPerSecond:(l,f)=>({label:"Resolution:",value:`${f.frameWidth} x ${f.frameHeight}@${l}`}),bytesReceived:(l,f)=>{let b=l||0,I=(b-this._lastTotalReceivedBytes)*8/(e*1e3);return this._lastTotalReceivedBytes=b,{label:"Data Received:",value:`${Math.round(I)} kbps , lost ${f.packetsLost}`}}},c=r.h(qe,{list:o.audios,factory:i}),g=r.h(qe,{list:o.videos,factory:s});a.debug("audioInfoList",p.dom.createByJsx(c)),!!this._infoModal&&(this._infoModal.content=r.h("div",{style:"padding-left: 24px;"},r.h("section",{className:"player_info-modal_section",withNamespace:!0},r.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Audio"),c),r.h("section",{className:"player_info-modal_section",withNamespace:!0},r.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Video"),g)),this._infoModal.visible=!0)});n(),this._timer=window.setInterval(n,e*1e3)})}},fe=Ht;var $o=(t,e,n)=>o=>u(void 0,null,function*(){if(o.type==="offer"){a.debug("\u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C \u8BBE\u5907\u914D\u7F6E\u4FE1\u606F\uFF1A",t,"token: ",e),a.debug("\u672C\u5730sdp",o);try{let{id:i,index:s}=t||{},c=yield M.getDeviceWebrtc({id:i,index:s,sdp:o.sdp},e);return n&&n(c.dialogId),c.sdp}catch(i){throw a.error(i,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`PUPlayer open \u5931\u8D25 , ${i.message}`)}}}),zo=t=>{let{container:e,token:n,puOption:o,defaultMediaOption:i={audio:!0,video:!0},testUrl:s,videoFit:c="fill",muted:g,apiPrefix:l,onConnected:f,onConnectedFailed:b,onDisConnected:I,fullScreenOnDblclick:y=!0}=t||{},h,C=n,R=o,O=e,x=typeof g=="boolean"?g:!i.audio;Y(l);let P=()=>u(void 0,null,function*(){if(!!h&&(a.debug("PuPlayer close",h),m.mask.visible=!0,m.mask.text="Video Closed",m.close(),h))try{yield M.closeDialogs([h],C)}catch(v){throw a.error(v,"PuPlayer close \u5931\u8D25"),new Error(`PuPlayer close \u5931\u8D25 , ${v.message}`)}}),m=new fe({video:{url:s},pluginOption:{webrtc:{offerParam:{offerToReceiveAudio:i.audio,offerToReceiveVideo:i.video},productRemoteSdp:v=>u(void 0,null,function*(){return $o(R,C,$=>{h=$})(v)}),onIceDisconnected:()=>{m.mask.visible=!0,m.mask.text="lost connection",m.close(),I&&I()},onConnected:()=>{f&&f()},onConnectedFailed:()=>{b&&b()}}},playerConfig:{autoPlay:!0}});m.addEventListener("init",v=>{a.debug("\u76D1\u542C\u5230\u4E86 player\u5DF2\u7ECF\u521D\u59CB\u5316",v)}),m.mute(x),m.video.fit=c;let w=m.init();y&&(w==null||w.addEventListener("dblclick",()=>{a.debug("\u53CC\u51FBplayer\uFF1A",w),me.toggle(w)}));let B={instance:{getVideoElement:()=>m.video.getEl(),getPlayerElement:()=>m.getEl(),open:(v=!1)=>u(void 0,null,function*(){a.debug("PuPlayer open"),yield P(),a.debug("PuPlayer close before open"),m.mask.visible=!1,m.mask.text="connecting",m.mute(!!v);try{yield m.prepareWebrtc()}catch(S){throw m.mask.visible=!0,m.mask.text="connect failed",S}if(typeof v=="boolean"&&v){let S=()=>{a.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",x),a.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),m.mute(x),document.removeEventListener("click",S),document.removeEventListener("touchend",S)};document.addEventListener("click",S),document.addEventListener("touchend",S)}}),play:()=>u(void 0,null,function*(){yield m.play(x)}),mute:(v=!1)=>{x=v,m.mute(v)},hidden:v=>u(void 0,null,function*(){let S=w,$=m.video.getEl();S.style.display="none",document.body.appendChild(S),$.muted=!0;try{typeof v!="undefined"&&(x=v),yield m.play(x)}catch(jo){a.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}a.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",$.paused)}),display:v=>u(void 0,null,function*(){let S=w,$=m.video.getEl();p.render(S,O,()=>u(void 0,null,function*(){S.style.display="block",typeof v!="undefined"&&(x=v),yield m.play(x)})),a.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",$.paused)}),moveTo:v=>{a.debug("\u79FB\u52A8\u81F3\uFF1A",v),O=v,p.render(w,O,()=>u(void 0,null,function*(){}))},getCurrentContainer:()=>O,setPuOption:v=>{R=v},setVideoFit:v=>{a.debug("PuPlayer setVideoFit",v),m.video.fit=v},setToken:v=>{a.debug("PuPlayer setToken",v),C=v},setApiPrefix:Y,close:P,render:m.init,destroy:()=>u(void 0,null,function*(){a.debug("PuPlayer destroy"),yield P(),m.destroy()})},element:w};return O&&(p.render(w,O),B.element=null),B},$t=zo;var Ze=class extends ee{constructor(e,n){super();this._plugin=e,this._el=this._plugin.init(),this._currentContainer=n}moveTo(e,n){a.debug("\u79FB\u52A8\u81F3\uFF1A",e),this._currentContainer=e,p.render(this._el,this._currentContainer,n)}getCurrentContainer(){return this._currentContainer}render(){return this._plugin.init()}destroy(){a.debug("destroy",this._plugin),this._plugin.destroy(),this.dispatch("destroy")}};var ne=class{constructor(e,n,o,i){this.token="";this.fetchSdpFunc=e,this.token=n||"",this.param=o,this.prefix=i}fetch(e){return u(this,null,function*(){a.debug("RemoteSdpFetcher fetch \u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C param\uFF1A",this.param,"token: ",this.token);let n=yield this.fetchSdpFunc(e,this.param,this.token,this.prefix),{sdp:o,dialogId:i}=n||{};return this.dialogId=i,a.debug(`RemoteSdpFetcher fetch \u83B7\u5F97\u7684remoteSdp ${o}, dialogId: ${i}`),o})}close(){return u(this,null,function*(){a.debug(`remoteSdpFetcher close\uFF0C \u68C0\u67E5dialogId: ${this.dialogId}`),this.dialogId&&(yield M.closeDialogs([this.dialogId]))})}},Ye=class extends Ze{constructor(e,n,o,i,s){super(e,s);this._muted=!1;this._videoFit="contain";this.setRemoteSdpFetcher(i),this.setVideoFit(n),this.setMuted(o)}get player(){return this._plugin}getPlayerElement(){return this.player.getEl()}getVideoElement(){return this.player.video.getEl()}setRemoteSdpFetcher(e){this._remoteSdpFetcher=e,this._plugin.setProductRemoteSdp(n=>u(this,null,function*(){var o;return(o=this._remoteSdpFetcher)==null?void 0:o.fetch(n)}))}getRemoteSdpFetcher(){return this._remoteSdpFetcher}setVideoFit(e){a.debug("BvWebrtcInstance setVideoFit",e),this._videoFit=e,this.player.video.fit=e}getVideoFit(){return this._videoFit}setMuted(e=!1){this._muted=e,this.player.mute(e)}getMuted(){return this._muted}mute(e=!1){return this.setMuted(e)}open(e=!1){return u(this,null,function*(){a.debug("BvWebrtc open"),yield this.close(),this.player.mask.visible=!1,this.player.mask.text="connecting",this.player.mute(!!e);try{yield this.player.prepareWebrtc()}catch(n){throw this.player.mask.visible=!0,this.player.mask.text="connect failed",n}if(e){let n=()=>{a.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",this._muted),a.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),this.player.mute(this._muted),document.removeEventListener("click",n),document.removeEventListener("touchend",n)};document.addEventListener("click",n),document.addEventListener("touchend",n)}})}play(){return u(this,null,function*(){yield this.player.play(this._muted)})}hidden(e){return u(this,null,function*(){let n=this._el,o=this.player.video.getEl();n.style.display="none",document.body.appendChild(n),o.muted=!0;try{typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)}catch(i){a.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}a.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}display(e){return u(this,null,function*(){let n=this._el,o=this.player.video.getEl();p.render(n,this._currentContainer,()=>u(this,null,function*(){n.style.display="block",typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)})),a.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}close(){return u(this,null,function*(){if(a.debug("BvWebrtcInstance close",`_dialogId: ${this._dialogId}`),this.player.mask.visible=!0,this.player.mask.text="Video Closed",this.player.close(),a.debug("BvWebrtcInstance close\uFF0C player closed\uFF0C\u68C0\u67E5 remoteSdpFetcher: ",this._remoteSdpFetcher),this.dispatch("close"),this._remoteSdpFetcher)try{yield this._remoteSdpFetcher.close()}catch(e){throw a.error(e,"BvWebrtcInstance close \u5931\u8D25"),new Error(`BvWebrtcInstance close \u5931\u8D25 , ${e.message}`)}})}destroy(){a.debug("PuPlayer destroy"),this.close(),this.player.destroy()}};var Uo=t=>{let{container:e,sdpFetcher:n,offerParam:o,videoFit:i,muted:s,autoPlay:c,onConnected:g,onClose:l,onDestroy:f,onConnectedFailed:b,onDisConnected:I,onPcEventAdded:y}=t,h=new fe({pluginOption:{webrtc:{offerParam:o,productRemoteSdp:()=>u(void 0,null,function*(){return""}),onIceDisconnected:()=>{h.mask.visible=!0,h.mask.text="lost connection",h.close(),I&&I()},onPcEventAdded:y,onConnected:()=>{h.mask.visible=!1,h.mask.text="connected",g&&g()},onConnectedFailed:()=>{b&&b()}}},playerConfig:{autoPlay:c}}),C=new Ye(h,i,s,n,e);C.addEventListener("close",()=>{l&&l()}),C.addEventListener("destroy",()=>{f&&f()});let R={open:()=>u(void 0,null,function*(){a.debug("BvWebrtc open"),yield C.open()}),setOption:P=>{a.debug("BvWebrtc setOption");let m=C.getRemoteSdpFetcher();m&&(m.param=P)},setToken:P=>{a.debug("BvWebrtc setToken",P);let m=C.getRemoteSdpFetcher();m&&(m.token=P)},setApiPrefix:P=>{a.debug("BvWebrtc setApiPrefix",P);let m=C.getRemoteSdpFetcher();m&&(m.prefix=P)},getRemoteSdpFetcher:()=>C.getRemoteSdpFetcher(),close:()=>u(void 0,null,function*(){a.debug("BvWebrtc close"),yield C.close()}),render:()=>(a.debug("BvWebrtc render"),C.render()),destroy:()=>{a.debug("BvWebrtc destroy"),C.destroy()}},O=C.render(),x={instance:R,element:O};return e&&(p.render(O,e),x.element=null),x},zt=Uo;var Ko=()=>u(void 0,null,function*(){a.debug("\u8BF7\u6C42\u9EA6\u514B\u98CE...");let t=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),e=t.getAudioTracks();return a.debug("\u9EA6\u514B\u98CE \u97F3\u9891\u8F68\u9053\uFF1A",e),t}),Jo=t=>{let{container:e,token:n,getRemoteSdpParam:o,apiPrefix:i,getRemoteSdpResult:s,onConnected:c,onClose:g,onDestroy:l,onConnectedFailed:f,onDisConnected:b,onGetUserMediaFailed:I}=t||{},y=(P,m,w,ve)=>u(void 0,null,function*(){if(a.debug("audioPlayer productRemoteSdp",{param:{localDescription:P,param:m,token:w,prefix:ve}}),P.type==="offer"&&(Y(ve),a.debug("\u672C\u5730sdp",P),!!s))try{let{sdp:B,dialogId:v}=yield s(P.sdp,w,m);return{sdp:B,dialogId:v}}catch(B){throw a.error(B,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`productRemoteSdp \u5931\u8D25 , ${B.message}`)}}),h=new ne(y,n,o,i),{instance:C,element:R}=zt({container:e,sdpFetcher:h,offerParam:{offerToReceiveAudio:!0},videoFit:"contain",muted:!1,autoPlay:!0,onConnected:c,onClose:g,onDestroy:l,onConnectedFailed:f,onDisConnected:b,onPcEventAdded:P=>u(void 0,null,function*(){try{let m=yield Ko();m.getTracks().forEach(w=>P.addTrack(w,m))}catch(m){I&&I()}})});return{instance:k({},C),element:R}},he=Jo;var Go=(t,e,n)=>u(void 0,null,function*(){let{id:o,index:i}=n||{};return yield M.getDeviceWebrtc({id:o,index:i,sdp:t},e)}),Xo=t=>{let{container:e,token:n,puOption:o,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}=t||{},{instance:I,element:y}=he({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:Go,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}),h=z(k({},I),{setPuOption:R=>I.setOption&&I.setOption(R)});return delete h.setOption,{instance:h,element:y}},Ut=Xo;var qo=(t,e,n)=>u(void 0,null,function*(){let{id:o,index:i}=n||{};return yield M.getConferenceWebrtc({id:o,index:i,sdp:t},e)}),Qo=t=>{let{container:e,token:n,confOption:o,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}=t||{},{instance:I,element:y}=he({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:qo,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}),h=z(k({},I),{setConfOption:R=>I.setOption&&I.setOption(R)});return delete h.setOption,{instance:h,element:y}},Kt=Qo;var Zo=M.closeAllStorageDialog;return Yo;})();
|
package/dist/main.es.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $t=Object.defineProperty,zt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var je=Object.getOwnPropertySymbols;var Kt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var et=(t,e,n)=>e in t?$t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,k=(t,e)=>{for(var n in e||(e={}))Kt.call(e,n)&&et(t,n,e[n]);if(je)for(var n of je(e))Jt.call(e,n)&&et(t,n,e[n]);return t},z=(t,e)=>zt(t,Ut(e));var u=(t,e,n)=>new Promise((o,i)=>{var s=l=>{try{g(n.next(l))}catch(f){i(f)}},c=l=>{try{g(n.throw(l))}catch(f){i(f)}},g=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,c);g((n=n.apply(t,e)).next())});var Gt="production",Xt="@besovideo/webrtc-player",qt="0.3.2",d={NODE_ENV:Gt,SH_LIB_NAME:Xt,SH_LIB_VERSION:qt};var Qt=Object.defineProperty,Zt=Object.defineProperties,Yt=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,jt=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable,nt=(t,e,n)=>e in t?Qt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,X=(t,e)=>{for(var n in e||(e={}))jt.call(e,n)&&nt(t,n,e[n]);if(tt)for(var n of tt(e))en.call(e,n)&&nt(t,n,e[n]);return t},tn=(t,e)=>Zt(t,Yt(e)),T;(function(t){t.red="#e72528",t.blue="#2a79af",t.weakBlue="#6eb6f4",t.geekblue="#85a5ff",t.gold="#ffd666",t.orange="#ffa940",t.cyan="#13c2c2",t.green="#52c41a",t.volcano="#fa541c",t.lime="#389e0d",t.pink="#eb2f96",t.purple="#722ed1",t.darkPurple="#292F4C",t.gray="#8c8c8c"})(T||(T={}));var ot=class{constructor(){this.colors=T,this.shapes={slider:new rt}}},rt=class{constructor(){}title(t=""){return q`
|
|
2
2
|
color: ${t};
|
|
3
3
|
border-left: 3px solid ${t};
|
|
4
4
|
padding: 2px;
|
|
5
5
|
font-weight: 600;
|
|
6
|
-
`}message(t=""){return
|
|
6
|
+
`}message(t=""){return q`
|
|
7
7
|
color: ${t};
|
|
8
|
-
`}message_button(t="#eee",e=
|
|
8
|
+
`}message_button(t="#eee",e=T.darkPurple,n="#fff"){return q`
|
|
9
9
|
background-color: ${e};
|
|
10
10
|
color: ${t};
|
|
11
11
|
padding: 2px 5px;
|
|
12
12
|
border-radius: 3px;
|
|
13
13
|
text-shadow: 0 0 2px ${n};
|
|
14
|
-
`}},
|
|
15
|
-
`,...e)},this.key=(t,...e)=>{let n=
|
|
14
|
+
`}},q=(t,...e)=>{if(e.length===0)return t[0];let n="";return e.forEach((o,i)=>{n+=t[i]+o}),n+=t[t.length-1],n},U;(function(t){t[t.title=1]="title",t[t.message=2]="message",t[t.message_button=3]="message_button"})(U||(U={}));var oe=({color:t},e=new rt,n)=>{switch(n){case 1:return e.title(t);case 2:return e.message(t);case 3:return e.message_button();default:return""}},nn=class{constructor(t){let e={log:window.console.log,enable:!0};this._option=tn(X({},e),{enable:typeof(t==null?void 0:t.enable)=="boolean"?t.enable:e.enable,log:(t==null?void 0:t.log)||e.log})}log(...t){let{enable:e,log:n}=this._option;e&&n&&n(...t)}set baseOption(t){this._option=t}get baseOption(){return this._option}setEnable(t){this._option.enable=!!t}},it=class{constructor(t){let e={enable:!0,log:window.console.log,level:39,shape:new ot().shapes.slider};this.enable=t&&typeof t.enable=="boolean"?t.enable:e.enable,this.log=t&&t.log||e.log,this.level=t&&typeof t.level=="number"?t.level:e.level,this.shape=t&&t.shape?t.shape:e.shape}},on=class extends nn{constructor(t){super(t||new it);this.loggerOption=X(X({},new it),t)}setLoggerOption(t){let e=X(X({},this.loggerOption),t);this.loggerOption=e,super.baseOption={enable:e.enable,log:e.log}}getLoggerOption(){return this.loggerOption}setLevel(t){typeof t=="number"&&(this.loggerOption.level=t)}formatLog(t,e,n,o,i,...s){!this.loggerOption.level&&this.loggerOption.level!==0||this.loggerOption.level<t||super.log(`%c${e}%c${n}`,o,i,...s)}},st;(function(t){t[t.log=0]="log",t[t.version=0]="version",t[t.error=0]="error",t[t.key=0]="key",t[t.warn=1]="warn",t[t.interval=1]="interval",t[t.service=2]="service",t[t.api=3]="api",t[t.http=3]="http",t[t.debug=3]="debug"})(st||(st={}));var A={debug:{name:"debug",title:" Debug :",color:T.lime,level:3},http:{name:"http",title:" Http :",color:T.weakBlue,level:3},api:{name:"api",title:" Api :",color:T.cyan,level:3},service:{name:"service",title:" Service :",color:T.purple,level:2},interval:{name:"interval",title:" Interval :",color:T.pink,level:1},warn:{name:"warn",title:" WARN :",color:T.orange,level:1},error:{name:"error",title:" ERR :",color:T.red,level:0},key:{name:"key",title:" Key :",color:T.darkPurple,level:0}},ye=class extends on{constructor(){super(...arguments);this.error=(t,...e)=>{this.formatShapeLog(A.error,`${t instanceof Error?t.stack:t}
|
|
15
|
+
`,...e)},this.key=(t,...e)=>{let n=A.key;this.formatLog(n.level,n.title,t.toUpperCase(),oe({color:n.color},this.getLoggerOption().shape,U.title),oe({},this.getLoggerOption().shape,U.message_button),...e)},this.version=(t="",e,...n)=>{this.formatLog(0,t.toUpperCase(),e,q`
|
|
16
16
|
background: linear-gradient(to right, #009fff, #ec2f4b);
|
|
17
17
|
color: white;
|
|
18
18
|
padding: 2px 5px;
|
|
19
19
|
border-top-left-radius: 3px;
|
|
20
20
|
border-bottom-left-radius: 3px;
|
|
21
|
-
`,
|
|
22
|
-
background-color: ${
|
|
21
|
+
`,q`
|
|
22
|
+
background-color: ${T.darkPurple};
|
|
23
23
|
color: white;
|
|
24
24
|
padding: 2px 5px;
|
|
25
|
-
`,...n)}}formatShapeLog({level:t,title:e,color:n},o,...r){this.formatLog(t,e,o,ne({color:n},this.getLoggerOption().shape,$.title),ne({color:n},this.getLoggerOption().shape,$.message),...r)}debug(t,...e){this.formatShapeLog(B.debug,t,...e)}http(t,...e){this.formatShapeLog(B.http,t,...e)}api(t,...e){this.formatShapeLog(B.api,t,...e)}service(t,...e){this.formatShapeLog(B.service,t,...e)}interval(t,...e){this.formatShapeLog(B.interval,t,...e)}warn(t,...e){this.formatShapeLog(B.warn,t,...e)}},Jo=new ot,rn=new be,sn=rn,N=sn;var at=class extends be{constructor(){super(...arguments);this.test=(e,...n)=>{let o=4;this.formatShapeLog({level:o,title:" Test ",color:"#3f6600"},e,...n)};this.libWarn=(e,...n)=>{this.warn("bvplayer-core ",e,...n),console.warn(new Error().stack)};this.libError=(e,...n)=>{this.error(new Error(`bvplayer-core ${e}`),...n)}}},Ie=new at;Ie.debug("player-core env:",c);Ie.version(c.SH_LIB_NAME,c.SH_LIB_VERSION||"");var s=Ie;var lt=(t,e,n)=>{let o={value:e,expire:n},r=JSON.stringify(o);return localStorage.setItem(t,r),o},an=(t,e,n)=>{let r=ye.getUTCSecond()+n;return lt(t,e,r)},ln=(t,e=!1)=>{let n=localStorage.getItem(t);if(!n)return null;try{let o=JSON.parse(n);return e?o:o.expire?ye.compare(o.expire)?o.value:null:o.value}catch(o){s.error(o,n,"Storage\u8BFB\u53D6\u6570\u636E\u65F6\uFF0C JSON\u89E3\u6790\u51FA\u9519")}},cn=t=>localStorage.removeItem(t),dn={set:lt,setTimeout:an,get:ln,remove:cn},D=dn;var oe;(function(n){n.GET="GET",n.POST="POST"})(oe||(oe={}));var ct=(t,e)=>d(void 0,null,function*(){let n=new AbortController;if(e.signal&&e.signal.addEventListener("abort",()=>{n.abort()}),e.timeout){let l=setTimeout(()=>{n.abort()},e.timeout);n.signal.addEventListener("abort",()=>{clearTimeout(l)})}let o=e.bodyData,r=o&&(typeof o=="object"?JSON.stringify(o):o),i={credentials:"same-origin",method:e.method,headers:new Headers(R({},e.headers)),signal:n.signal};r&&(i.body=r),s.http("\u53D1\u9001\u8BF7\u6C42\uFF1A",t,j(R({},i),{body:o}));try{let l=yield fetch(t,i);if(s.http("\u8BF7\u6C42\u54CD\u5E94\uFF1A",t,l,yield l.clone().text()),l.ok||l.status>=200&&l.status<300){let m=l.headers.get("content-type")||"";if(/application\/json/i.test(m))return yield l.json()}else throw new Error(`${l.status} ${l.statusText}`)}catch(l){if(l.name==="AbortError"){s.http("\u8BF7\u6C42\u53D6\u6D88\uFF1A",i);return}throw l}}),un=(t,e,n)=>d(void 0,null,function*(){let o=e?e.toString():"";return yield ct(t+o,{method:oe.GET,headers:n==null?void 0:n.headers})}),pn=(t,e,n)=>d(void 0,null,function*(){return yield ct(t,{method:oe.POST,headers:R({"Content-Type":"application/json;charset=UTF-8"},n==null?void 0:n.headers),bodyData:e})}),mn={get:un,post:pn},re=mn;var gn=Array.isArray,fn=t=>t!==t,dt=t=>typeof t=="number",ut=t=>typeof t=="string",hn=t=>dt(t)||ut(t),vn=t=>typeof t=="function",yn=t=>typeof t=="undefined",bn=t=>t?!1:!!(t!=null?t:!0),In={isArr:gn,baseIsNaN:fn,isString:ut,isNumber:dt,isText:hn,isFn:vn,isUndefined:yn,isNullOrUndefined:bn},O=In;function Cn(t,e=[]){let n=-1,o=t.length;for(e||(e=Array(o));++n<o;)e[n]=t[n];return e}function Pn(t,e,n){let o=n-1,r=t.length;for(;++o<r;)if(t[o]===e)return o;return-1}function wn(t,e,n,o=!1){let r=t.length,i=n+(o?1:-1);for(;o?i--:++i<r;)if(e(t[i],i,t))return i;return-1}function xn(t,e,n){return e===e?Pn(t,e,n):wn(t,O.baseIsNaN,n)}function En(t,e){let n=-1,o=e.length,r=t;for(t===e&&(e=Cn(e));++n<o;){let i=0,l=e[n],m=l;for(;(i=xn(r,m,i))>-1;)r!==t&&[].splice.call(r,i,1),[].splice.call(t,i,1)}return t}var _n=t=>t?O.isArr(t)?t:[t]:[],Sn=(t,e)=>!t||!t.length||!e||!e.length?t:En(t,e),Tn=(t,e="")=>{let n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0,n.width,n.height),n.toBlob(o=>{if(!o){s.libError("util screenshot canvas\u7684\u8F93\u51FA\u4E3A\u7A7A\u503C");return}let r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=`${e}.png`,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)})},Rn={pullAll:Sn,toArray:_n,screenshot:Tn},G=Rn;var pt={BVCSP_V1:{path:"/bvcsp/v1",prefix:""}},Ce=t=>{let e=pt[t];return e.prefix+e.path},kn=(t,e)=>{let n=pt[t];return n.prefix=e||"",Ce(t)},X={setApiPrefix:kn,getApiURL:Ce,bvscpV1:()=>Ce("BVCSP_V1")},q=t=>{X.setApiPrefix("BVCSP_V1",t)};var Fn=t=>{if(!t)return null;if(t.nodeType===Node.DOCUMENT_NODE)return t.documentElement;if(t.nodeType===Node.ELEMENT_NODE){let e=t;return e.hasChildNodes()&&e.childNodes.forEach(n=>{let o=n;o.className&&new RegExp(".*bvplayer-core-player.*").test(o.className)&&e.removeChild(o)}),t}return null},Mn=(t,e,n)=>{if(!t)return;let o=document.createDocumentFragment();o.appendChild(t);let r=Fn(e);!r||(r.appendChild(o),n==null||n())},mt=Mn;var ie=(...t)=>{let e=[];for(let n=0;n<t.length;n++){let o=t[n];if(!o)continue;let r=typeof o;if(O.isText(o))e.push(o);else if(Array.isArray(o)){if(o.length){let i=ie(...o);i&&e.push(i)}}else if(r==="object")if(o.toString==={}.toString)for(let i in o)({}).hasOwnProperty.call(o,i)&&o[i]&&e.push(i);else e.push(o.toString())}return e.join(" ")},gt=t=>t?t.replace(/\s*(;|\{|\})+\s*[\n\r]*/g,"$1"):"",Ln=(t,...e)=>{if(!e.length)return gt(t[0]);let n="";return e.forEach((o,r)=>{n+=t[r]+o}),n+=t[t.length-1],gt(n)},Pe="bvplayer-",Nn="common-",ft=t=>new RegExp(Pe).test(t),On=(...t)=>ie(t).split(" ").map(e=>ft(e)?e:Pe+e).join(" "),Dn=(...t)=>ie(t).split(" ").map(e=>ft(e)?e:Pe+Nn+e).join(" ");var Vn={cls:ie,css:Ln,prefixCls:On,commonCls:Dn},Q=Vn;function Bn(t={},e){if(!e)return;Object.keys(t).forEach(o=>{if(o==="children")return;let r=t[o];O.isNullOrUndefined(r)||(o.startsWith("on")?e.addEventListener(o.substring(2).toLowerCase(),r):e instanceof Element?e.setAttribute(o==="className"?"class":o,r):e[o]=r)})}function An(t,e){return t===""?document.createTextNode(""):e?document.createElementNS(e,t):document.createElement(t)}function Z(t,e,n){let o=e?e(t):t;if(!o)return null;if(O.isArr(o)){let l=document.createDocumentFragment();return o.forEach(m=>{let a=Z(m,e);a&&l.appendChild(a)}),l}let{props:r,type:i}=o;if(!r)return o instanceof Node||o instanceof Text?(s.libWarn("jsx grow","\u63D0\u793A",o,"\u5E76\u4E0D\u662F\u6709\u6548\u7684jsx element \u5DF2\u7ECF\u539F\u6837\u8F93\u51FA\uFF0C\u4E0D\u5F71\u54CDui \u4F46\u5C3D\u91CF\u5C11\u6DF7\u7528jsx\u548Cdom"),o):(s.libWarn("jsx grow","\u672A\u89E3\u6790",o,"\u56E0\u4E3A\u5B83\u4E0D\u662F\u6709\u6548\u7684jsx element\uFF0C\u5E76\u4E14\u4E5F\u4E0D\u662FRenderTarget\u7C7B\u578B"),null);if(O.isString(i)){let l=An(i,r.xmlns||n);return Bn(r,l),(r.children||[]).forEach(a=>{let g=Z(a,e,r.xmlns);!g||l.appendChild(g)}),l}if(O.isFn(i)){let l=i(r);return Z(l,e)}return null}function Wn(t){return document.createRange().createContextualFragment(t)}function Hn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function we(){return document.createDocumentFragment()}function jn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function $n(t,...e){if(!t)return;let n=we();n.append(...e.filter(o=>o)),t.appendChild(n)}function zn(t){if(!!t)if(t instanceof Element){t.innerHTML="";return}else for(;t.firstChild;)t.removeChild(t.firstChild)}function Un(t,...e){if(!e.length||!(t==null?void 0:t.parentNode))return;let n=e.filter(o=>o);if(t instanceof Element)t.replaceWith(...n);else{let o=we();o.append(...n),t.parentNode.replaceChild(o,t)}}function Kn(t){var e;if(!!t)if(t instanceof Element){t.remove();return}else(e=t.parentNode)==null||e.removeChild(t)}function Jn(t){if(!t||!t.props)return t;let{props:e}=t;return e.withCommonNamespace&&(e.className=Q.commonCls(e.className),delete e.withCommonNamespace),e.withNamespace&&(e.className=Q.prefixCls(e.className),delete e.withNamespace),t}function Gn(t){return t?Z(t,Jn):null}var Xn={parseHtml:Wn,create:Hn,createFragment:we,createHtmlElement:jn,createByJsx:Gn,append:$n,empty:zn,replace:Un,removeSelf:Kn},ht=Xn;var qn="bvplayerCore",Qn=t=>qn+t,Zn={createPrefixStorageField:Qn},vt=Zn;var Yn={render:mt,style:Q,dom:ht,field:vt},u=Yn;var A=u.field.createPrefixStorageField("DialogIds"),eo=(t,e)=>d(void 0,null,function*(){var l;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},r=yield re.post(`${X.bvscpV1()}/dialog/device/webrtc`,o,{headers:n});if(s.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:r}),!r||r.code!==0||!((l=r.data)==null?void 0:l.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${r.msg}`);let{data:i}=r;if(i.dialogid){let m=D.get(A)||[];m.push(i.dialogid),D.set(A,m)}return{dialogId:i.dialogid,sdp:i.sdp}}),to=(t,e)=>d(void 0,null,function*(){var m;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},r=yield re.post(`${X.bvscpV1()}/dialog/conference/webrtc`,o,{headers:n});if(s.api("\u4F1A\u8BAE\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:r}),!r||r.code!==0||!((m=r.data)==null?void 0:m.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${r==null?void 0:r.msg}`);let{data:i}=r,l=D.get(A)||[];return l.push(i.dialogid),D.set(A,l),{dialogId:i.dialogid,sdp:i.sdp}}),no=(t,e)=>d(void 0,null,function*(){if(!t)return;let n={Authorization:e||""};return s.api("\u5173\u95EDdialog\uFF1A",t),yield re.post(`${X.bvscpV1()}/dialog/close/${t}`,{},{headers:n})}),yt=(t,e)=>d(void 0,null,function*(){let n=D.get(A)||[];G.pullAll(n,t),D.set(A,n,0);let r=(yield Promise.allSettled(t.map(i=>no(i,e)))).filter(i=>i.status==="rejected");r&&r.length>0&&s.error(new Error(`"\u5173\u95ED\u5B58\u50A8\u7684dialog\u65F6\u5931\u8D25\uFF1A", ${r}`))}),oo=t=>d(void 0,null,function*(){let e=D.get(A);!e||e.length<1||(D.remove(A),yield yt(e,t))}),ro={getDeviceWebrtc:eo,getConferenceWebrtc:to,closeDialogs:yt,closeAllStorageDialog:oo},k=ro;var bt=class{constructor(){this._map=new Map}findExecutor(e,n){let o=this._map.get(e);return{index:o?o.findIndex(i=>Object.is(n,i)):-1,que:o}}publish(e,n){let o=this._map.get(e)||[],r=o.length;for(let i=0;i<r;i++){let l=o[i];l&&l(n)}}subscribe(e,n){let{index:o,que:r=[]}=this.findExecutor(e,n);return o>=0?r[o]=n:r.push(n),this._map.set(e,r),{unSubscribe:()=>{this.unSubscribe(e,n)}}}unSubscribe(e,n){let{index:o,que:r=[]}=this.findExecutor(e,n);o<0||(r.splice(o,1),this._map.set(e,r))}},Y=class{constructor(){this._notifier=new bt}addEventListener(e,n){this._notifier.subscribe(e,n)}removeEventListener(e,n){this._notifier.unSubscribe(e,n)}dispatch(e,n){this._notifier.publish(e,n)}};var w=class extends Y{constructor(e,n,o){super();this.name="";let r=n.trim().toLowerCase(),i=o?o.trim():r,l=u.dom.create(e,u.style.prefixCls(i));this.name=r,this.el=l}empty(){u.dom.empty(this.el)}unmount(){var e;s.debug("unmount",this.el,(e=this.el)==null?void 0:e.parentNode),u.dom.removeSelf(this.el)}destroy(){if(this.beforeDestroy(),this.empty(),this.unmount(),this.el=null,this.dispatch("destroy"),!!this){for(let e in this)this[e]=void 0;s.debug("destroy complete",this)}}getEl(){return this.el}};var It=class extends w{constructor(e){super("div","mask",u.style.cls("mask"));this._visible=!!(e==null?void 0:e.visible),this._text=e==null?void 0:e.text,this._textEl=u.dom.create("span",u.style.cls("text"))}set visible(e){this._visible=e,this.el.style.display=this._visible?"grid":"none"}set text(e){this._text=e,this._textEl.textContent=e}beforeDestroy(){}init(){s.debug("mask visible: ",this._visible);let e=this.el;return e.style.display=this._visible?"block":"none",this._textEl.textContent=this._text||"",u.dom.append(e,this._textEl),e}},Ct=It;var Pt=class extends w{constructor(e){super("div","spinner",u.style.cls("spinner"));this._spin=!!(e==null?void 0:e.spin)}set spin(e){this._spin=e,this.el.style.display=this._spin?"block":"none"}beforeDestroy(){}init(){s.debug("spinner spin: ",this._spin);let e=this.el;e.style.display=this._spin?"block":"none";let n=u.dom.create("span");return n.style.backgroundColor="#FFF",u.dom.append(e,n),e}},wt=Pt;var xt={contain:"contain",fill:"fill"},Et=class extends w{constructor(e){super("video","video",u.style.cls("video"));this._url=e==null?void 0:e.url,this._srcObject=(e==null?void 0:e.srcObject)||null,this._fit=(e==null?void 0:e.fit)||xt.contain,this._autoPlay=!!(e==null?void 0:e.autoPlay),this._muted=!!(e==null?void 0:e.muted)}set url(e){typeof this._url!="undefined"&&(this.el.src=this._url),this._url=e}set srcObject(e){this._srcObject=e||null,this.el.srcObject=this._srcObject}set muted(e){let n=this.el;this._muted=e,n.muted=e}set paused(e){let n=this.el;e?n.pause():n.play()}get paused(){var e;return!!((e=this.el)==null?void 0:e.paused)}set autoPlay(e){if(!e!==this._autoPlay)return;this._autoPlay=e,this.muted=e;let n=this.el;n.autoplay=this._autoPlay}set fit(e){this._fit=xt[e],this.el.style.objectFit=this._fit}getVideoFit(){return this._fit}init(){s.debug("\u6E32\u67D3VideoPlugin\u89C6\u9891\u5BF9\u8C61dom\u7684children",this,this.el);let e=this.el;return e.addEventListener("play",()=>this.dispatch("play",{target:this})),e.addEventListener("pause",()=>this.dispatch("pause",{target:this})),e.addEventListener("loadedmetadata",n=>{s.debug("video loadedmetadata",n),this.dispatch("loadedmetadata",{target:this})}),typeof this._url!="undefined"&&(e.src=this._url),e.srcObject=this._srcObject,e.autoplay=this._autoPlay,e.muted=this._muted,e.style.objectFit=this._fit,e.playsInline=!0,e}play(){return d(this,null,function*(){let e=this.el;try{s.debug("video \u5C1D\u8BD5\u64AD\u653E"),yield e.play()}catch(n){s.error(n,"video \u64AD\u653E \u5931\u8D25")}})}beforeDestroy(){}},_t=Et;function ee(t){return class extends t{constructor(...e){super(...e);this._visible=!1}get visible(){return this._visible}set visible(e){let n=!!e;if(this._visible===n)return;this._visible=n;let o=u.style.commonCls("is-visible");this._visible?(this.show&&this.show(),this.el.setAttribute("aria-hidden","false"),this.el.classList.add(o)):(this.hide&&this.hide(),this.el.setAttribute("aria-hidden","true"),this.el.classList.remove(o))}}}function xe({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function Ee({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 0 1-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 0 1 .947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 0 1 2.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 0 1 2.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 0 1 .947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 0 1-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 0 1-2.287-.947zM10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function _e({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 9a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 10.07 4h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 18.07 7H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9z"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 13a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function Se({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M4 5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-1.586a1 1 0 0 1-.707-.293l-1.121-1.121A2 2 0 0 0 11.172 3H8.828a2 2 0 0 0-1.414.586L6.293 4.707A1 1 0 0 1 5.586 5H4zm6 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function Te({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0-5 5M4 16v4m0 0h4m-4 0 5-5m11 5-5-5m5 5v-4m0 4h-4"}))}function Re({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M3 4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 2H6.414l2.293 2.293a1 1 0 0 1-1.414 1.414L5 6.414V8a1 1 0 0 1-2 0V4zm9 1a1 1 0 1 1 0-2h4a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V6.414l-2.293 2.293a1 1 0 1 1-1.414-1.414L13.586 5H12zm-9 7a1 1 0 1 1 2 0v1.586l2.293-2.293a1 1 0 0 1 1.414 1.414L6.414 15H8a1 1 0 1 1 0 2H4a1 1 0 0 1-1-1v-4zm13-1a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 1 1 0-2h1.586l-2.293-2.293a1 1 0 0 1 1.414-1.414L15 13.586V12a1 1 0 0 1 1-1z","clip-rule":"evenodd"}))}function ke({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Fe({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zm-7-4a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM9 9a1 1 0 0 0 0 2v3a1 1 0 0 0 1 1h1a1 1 0 1 0 0-2v-3a1 1 0 0 0-1-1H9z","clip-rule":"evenodd"}))}function Me({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m10 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2m7-2a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Le({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM8.707 7.293a1 1 0 0 0-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 1 0 1.414 1.414L10 11.414l1.293 1.293a1 1 0 0 0 1.414-1.414L11.414 10l1.293-1.293a1 1 0 0 0-1.414-1.414L10 8.586 8.707 7.293z","clip-rule":"evenodd"}))}function Ne({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18 18 6M6 6l12 12"}))}function Oe({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 0 1 1.414 0L10 8.586l4.293-4.293a1 1 0 1 1 1.414 1.414L11.414 10l4.293 4.293a1 1 0 0 1-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 0 1-1.414-1.414L8.586 10 4.293 5.707a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function De({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 0 1 0 7.072m2.828-9.9a9 9 0 0 1 0 12.728M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}))}function Ve({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm5.274-.147a1 1 0 0 1 1.414 0A9.972 9.972 0 0 1 19 10a9.972 9.972 0 0 1-2.929 7.071 1 1 0 0 1-1.414-1.414A7.971 7.971 0 0 0 17 10a7.97 7.97 0 0 0-2.343-5.657 1 1 0 0 1 0-1.414zm-2.829 2.828a1 1 0 0 1 1.415 0A5.983 5.983 0 0 1 15 10a5.984 5.984 0 0 1-1.757 4.243 1 1 0 0 1-1.415-1.415A3.984 3.984 0 0 0 13 10a3.983 3.983 0 0 0-1.172-2.828 1 1 0 0 1 0-1.415z","clip-rule":"evenodd"}))}function Be({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z","clip-rule":"evenodd"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m17 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2"}))}function Ae({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm2.91 4.217a1 1 0 0 1 1.414 0L15 8.586l1.293-1.293a1 1 0 1 1 1.414 1.414L16.414 10l1.293 1.293a1 1 0 0 1-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 0 1-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function We({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14.752 11.168-3.197-2.132A1 1 0 0 0 10 9.87v4.263a1 1 0 0 0 1.555.832l3.197-2.132a1 1 0 0 0 0-1.664z"}),jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function He({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM9.555 7.168A1 1 0 0 0 8 8v4a1 1 0 0 0 1.555.832l3-2a1 1 0 0 0 0-1.664l-3-2z","clip-rule":"evenodd"}))}function je({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},jsx.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 9v6m4-6v6m7-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function $e({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},jsx.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zM7 8a1 1 0 0 1 2 0v4a1 1 0 1 1-2 0V8zm5-1a1 1 0 0 0-1 1v4a1 1 0 1 0 2 0V8a1 1 0 0 0-1-1z","clip-rule":"evenodd"}))}function ze({className:t}){return jsx.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 33",fill:"currentColor"},jsx.h("path",{d:"M6.667 28H1.334c-.8 0-1.333-.533-1.333-1.333v-5.333c0-.8.533-1.333 1.333-1.333s1.333.533 1.333 1.333v4h4c.8 0 1.333.533 1.333 1.333S7.467 28 6.667 28zm24 0h-5.333c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h4v-4c0-.8.533-1.333 1.333-1.333S32 20.534 32 21.334v5.333c0 .8-.533 1.333-1.333 1.333zm0-16c-.8 0-1.333-.533-1.333-1.333v-4h-4c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333v5.333c0 .8-.533 1.333-1.333 1.333zM1.333 12C.533 12 0 11.467 0 10.667V5.334c0-.8.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333s-.533 1.333-1.333 1.333h-4v4c0 .8-.533 1.333-1.333 1.333z"}))}var F=({children:t,className:e})=>{let n=u.style.cls(["icon",e]);return jsx.h("span",{className:n,withNamespace:!0},t)},io=({filled:t})=>jsx.h(F,null,jsx.h(t?Ee:xe,null)),so=({filled:t})=>jsx.h(F,null,jsx.h(t?Se:_e,null)),ao=({filled:t})=>jsx.h(F,null,jsx.h(t?Fe:ke,null)),lo=({filled:t})=>jsx.h(F,null,jsx.h(t?Re:Te,null)),co=({filled:t,circle:e})=>e?jsx.h(F,null,jsx.h(t?Le:Me,null)):jsx.h(F,null,jsx.h(t?Oe:Ne,null)),uo=({filled:t,off:e})=>e?jsx.h(F,null,jsx.h(t?Ae:Be,null)):jsx.h(F,null,jsx.h(t?Ve:De,null)),po=({filled:t,off:e})=>e?jsx.h(F,null,jsx.h(t?$e:je,null)):jsx.h(F,null,jsx.h(t?He:We,null)),mo=()=>jsx.h(F,null,jsx.h(ze,null)),go={Cog:io,Camera:so,Info:ao,ArrowsExpand:lo,X:co,Volume:uo,Play:po,Full:mo};var x=go;var W="modal",St=class extends w{constructor(e){super("div",W,u.style.cls([W,e.className,{[`${W}--center`]:e.center}]));this.container=e.container,this.title=e.title,this._content=e.content||u.dom.create("div","test"),this._center=!!e.center}set content(e){let n=u.dom.createByJsx(e);s.debug("modal update content",n,this._content),u.dom.replace(this._content,n),this._content=n}show(){var e;(e=this.el)==null||e.classList.toggle(u.style.prefixCls(`${W}--center`),!!this._center),u.dom.append(this.container,this.el)}hide(){}clear(){!this.el||(this.el.innerHTML="")}beforeDestroy(){}init(){this.clear(),s.debug("\u6E32\u67D3ModalPlugin \u5F39\u7A97\u5BF9\u8C61",this,this.el);let e=this.el,n=u.dom.createByJsx(jsx.h(jsx.Fragment,null,jsx.h("div",{className:`${W}_title-bar`,onClick:()=>this.dispatch("hide"),withNamespace:!0},jsx.h("span",{className:`${W}_title-bar_title`,withNamespace:!0},this.title),jsx.h("span",{className:`${W}_title-bar_close`,withNamespace:!0},jsx.h(x.X,null))),jsx.h("div",{className:`${W}_body`,withNamespace:!0},this._content)));return u.dom.append(e,n),e}},fo=ee(St),Ue=class extends fo{},Tt=Ue;var ho="controller_button",Rt=class extends w{constructor(e,n){super("button",ho);this._Children=e,this.title=n}set Children(e){!this.el||(this._Children=e,this.empty(),u.dom.append(this.el,u.dom.createByJsx(e)))}beforeDestroy(){}init(){let e=this.el;return e.addEventListener("click",()=>this.dispatch("click")),e.title=this.title||"",u.dom.append(e,u.dom.createByJsx(this._Children)),e}},z=Rt;var kt="controller",Ft=class extends w{constructor(e){super("div",kt,u.style.cls(kt));this._controls=(e==null?void 0:e.controls)||[],this.PlayButton=new z(jsx.h(x.Play,null)),this.VolumeButton=new z(jsx.h(x.Volume,{off:!0}),"volume"),this.InformationButton=new z(jsx.h(x.Info,null),"information"),this.ScreenshotButton=new z(jsx.h(x.Camera,null),"screenshot"),this.FullscreenButton=new z(jsx.h(x.ArrowsExpand,null),"fullscreen"),this.PlayButton.addEventListener("click",()=>{this.dispatch("play")}),this.VolumeButton.addEventListener("click",()=>{this.dispatch("volume")}),this.InformationButton.addEventListener("click",()=>this.dispatch("information")),this.ScreenshotButton.addEventListener("click",()=>this.dispatch("screenshot")),this.FullscreenButton.addEventListener("click",()=>this.dispatch("fullscreen"))}beforeDestroy(){}init(){s.debug("\u6E32\u67D3ControllerPlugin \u64AD\u653E\u63A7\u5236\u5668\u5BF9\u8C61",this,this.el,this._controls);let e=this.el,n=u.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_left`]),o=u.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_right`]),r=u.dom.createByJsx(jsx.h(jsx.Fragment,null,jsx.h("div",{className:`${this.name}_mask`,withNamespace:!0}),jsx.h("div",{className:`${this.name}_inner`,withNamespace:!0},jsx.h("div",{className:n,withNamespace:!0},this.PlayButton.init(),this.VolumeButton.init()),jsx.h("div",{className:"flex-space",withCommonNamespace:!0}),jsx.h("div",{className:o,withNamespace:!0},this.InformationButton.init(),this.ScreenshotButton.init(),this.FullscreenButton.init()))));return u.dom.append(e,r),e}},vo=ee(Ft),Ke=class extends vo{},Mt=Ke;var Lt=class{constructor(){this._els=[];this.disableAutoHide=!1;this._controller=new Mt}init(){let e=this._controller.init();return this._els.push(e),this._els}get els(){return this._els}get controller(){return this._controller}show(){this._controller.visible=!0}hide(){window.clearTimeout(this._autoHideTimeout),this._controller.visible=!1}showThenHide(){this.show(),window.clearTimeout(this._autoHideTimeout),this._autoHideTimeout=window.setTimeout(()=>{this.disableAutoHide||this.hide()},3e3)}},Nt=Lt;var se=class{constructor(e){this.pc=e}getReceiversMap(){let e=new Map([["audio",[]],["video",[]]]),n=this.pc.getReceivers();return(n==null?void 0:n.length)&&n.forEach(o=>{let{kind:r}=o.track,i=e.get(r)||[];i.push(o),e.set(r,i)}),e}getStatsInfos(){return d(this,null,function*(){let e=this.getReceiversMap();s.debug("receivers map : ",e);let n=yield Promise.all(e.get("audio").map(r=>d(this,null,function*(){let i={},l=yield r.getStats(),m=[];return l.forEach(a=>{m.push(a),a.type==="codec"&&(i.mimeType=a.mimeType,i.clockRate=a.clockRate,i.channels=a.channels),a.type==="track"&&(i.totalSamplesReceived=a.totalSamplesReceived,i.totalSamplesDuration=a.totalSamplesDuration)}),s.debug("audio stats report: ",m),i}))),o=yield Promise.all(e.get("video").map(r=>d(this,null,function*(){let i={},l=yield r.getStats(),m=[];return l.forEach(a=>{m.push(a),a.type==="codec"&&(i.mimeType=a.mimeType,i.clockRate=a.clockRate),a.type==="inbound-rtp"&&(i.frameWidth=a.frameWidth,i.frameHeight=a.frameHeight,i.framesPerSecond=a.framesPerSecond,i.framesReceived=a.framesReceived,i.framesDecoded=a.framesDecoded,i.totalInterFrameDelay=a.totalInterFrameDelay,i.keyFramesDecoded=a.keyFramesDecoded,i.packetsLost=a.packetsLost,i.lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp,i.bytesReceived=a.bytesReceived,i.totalDecodeTime=a.totalDecodeTime)}),s.debug("video stats report: ",m),i})));return{audios:n,videos:o}})}};var yo=(t,e)=>{N.debug(`webrtc my ICE candidate:
|
|
26
|
-
${e.candidate?e.candidate.candidate:"(null)"}`)},bo=(t,e,n)=>{N.debug("webrtc ICE state change event: ",e),N.debug(`webrtc my ICE state: ${t==null?void 0:t.iceConnectionState}`),t&&t.iceConnectionState==="disconnected"&&n&&n()},Io=(t,e)=>{N.debug("webrtc Connection state change, \u5F53\u524D\u8FDE\u63A5\u72B6\u6001: ",t,t.connectionState)},Co=(t,e,n)=>{N.debug("webrtc \u5F53\u524D\u7684 stream: ",e.streams[0]);let o=e.streams[0];n(o)},Po=(t,e)=>d(void 0,null,function*(){let{offerParam:n,productRemoteSdp:o,customerRTCPeerConnection:r,onConnected:i,onConnectedFailed:l,onIceDisconnected:m,onPcEventAdded:a,onLocalDescriptionReady:g}=t,y=!!r&&r instanceof RTCPeerConnection,b={},v=y?r:new RTCPeerConnection(b);if(v.addEventListener("icecandidate",f=>yo(v,f)),v.addEventListener("iceconnectionstatechange",f=>bo(v,f,m)),v.addEventListener("connectionstatechange",f=>Io(v,f)),v.addEventListener("track",f=>Co(v,f,e)),a&&(yield a(v)),y)return new se(v);try{let f=yield v.createOffer(n);N.debug("\u521B\u5EFAoffer\uFF0C\u53C2\u6570\uFF1A",n,"\uFF0C \u7ED3\u679C\uFF1A",f),yield v.setLocalDescription(f),g&&g(v);let I=yield o(new RTCSessionDescription(f));N.debug("webrtc recv open answer",I);let T=new RTCSessionDescription({type:"answer",sdp:I});yield v.setRemoteDescription(T),N.debug("getTransceivers",v.getTransceivers()),i&&i(v)}catch(f){throw l&&l(v),N.error(new Error(`webrtc Failed to create session description: ${f.toString()}`)),v.close(),f}return new se(v)}),wo=t=>{if(!t)return;let{pc:e}=t;e.close()},xo={connect:Po,disconnect:wo},Je=xo;var U=document.documentElement,ae="requestFullscreen",le="exitFullscreen",ce="fullscreenElement",de="onfullscreenchange";if("webkitRequestFullScreen"in U)ae="webkitRequestFullScreen",le="webkitExitFullscreen",ce="webkitFullscreenElement",de="onwebkitfullscreenchange";else if("msRequestFullscreen"in U)ae="msRequestFullscreen",le="msExitFullscreen",ce="msFullscreenElement",de="MSFullscreenChange";else if("mozRequestFullScreen"in U)ae="mozRequestFullScreen",le="mozCancelFullScreen",ce="mozFullScreenElement",de="onmozfullscreenchange";else if(!("requestFullscreen"in U))throw"\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";function Eo(t=U,e){return t[ae](e)}function _o(){return document[le]()}function Ot(t){return t===document[ce]}function So(t=U,e){return Ot(t)?_o():Eo(t,e)}function To(t,e){let n=()=>{t.onfullscreenchange=null},o=r=>{r.target!==null&&e(Ot(r.target))};return t[de]=o,{cancel:n}}var Ro={toggle:So,watch:To},ue=Ro;var ko=({label:t,value:e,suffix:n})=>jsx.h("div",{className:"player_info-modal_list_item",withNamespace:!0},jsx.h("span",{className:"player_info-modal_list_item_label",withNamespace:!0},t),jsx.h("span",{className:"player_info-modal_list_item_value",withNamespace:!0},e),jsx.h("span",{className:"player_info-modal_list_item_suffix",withNamespace:!0},n)),Dt=({list:t,factory:e})=>(t==null?void 0:t.length)?e?jsx.h(jsx.Fragment,null,t.map(n=>jsx.h(Dt,{list:Object.keys(n).map(o=>e[o]?e[o](n[o],n):!1).filter(o=>o!==!1)}))):jsx.h("div",{className:"player_info-modal_list",withNamespace:!0},t.map(n=>jsx.h(ko,R({},n)))):null,Ge=Dt;var M;(function(o){o.DIRECT="direct",o.PLUGIN="plugin",o.REJECT="reject"})(M||(M={}));var pe;(function(i){i.MP4="MP4",i.FLAC="FLAC",i.OGG="OGG",i.WEBM="WEBM",i.AUTO="AUTO"})(pe||(pe={}));var Xe;(function(e){e.WEBRTC="WEBRTC"})(Xe||(Xe={}));var Vt="player",Bt=class extends w{constructor(e){super("div",Vt);this._lastTotalReceivedBytes=0;this._video=new _t,this._spinner=new wt({spin:!1}),this._mask=new Ct({visible:!1}),this._panel=new Nt,this._infoModal=new Tt({container:this.el,title:"Info",center:!0,className:`${Vt}_info-modal`}),this._videoOption=e==null?void 0:e.video,this._pluginOption=e==null?void 0:e.pluginOption,this._playerConfig=e==null?void 0:e.playerConfig,this._mode=this._restrictPlayerMode(e==null?void 0:e.video,e==null?void 0:e.pluginOption),s.debug("PlayerMode",this._mode)}justifyVideoType(e,n){if((e==null?void 0:e.url)&&!e.type)return pe.AUTO;let o="".toUpperCase.call((e==null?void 0:e.type)||Object.keys(n||{})[0]||"");return s.debug("justifyVideoType ",e,o),o}_restrictPlayerMode(e,n){let o=this.justifyVideoType(e,n);if(!o&&!(e==null?void 0:e.url))return M.REJECT;if(!o)return M.DIRECT;let r=Object.keys(pe),i=Object.keys(Xe);return r.includes(o)?M.DIRECT:i.includes(o)?M.PLUGIN:M.DIRECT}init(){s.debug("\u6E32\u67D3PlayerPlugin",this.el),this.prepare();let e=this._video.init(),n=this._spinner.init(),o=this._mask.init(),r=this._panel.init(),i=this._infoModal.init();return u.dom.append(this.el,e,n,o,...r,i),this.initEvents(),this.dispatch("init",{name:"initEvent",target:this,mode:this._mode}),this.el}get video(){return this._video}get spinner(){return this._spinner}get mask(){return this._mask}play(e){return d(this,null,function*(){this.mute(!0),yield this._video.play(),this.mute(e)})}mute(e){var n;this._video.muted=!!e,s.debug("player mute: ",(n=this._video.getEl())==null?void 0:n.muted)}setProductRemoteSdp(e){!this._pluginOption||!this._pluginOption.webrtc||(this._pluginOption.webrtc.productRemoteSdp=e)}prepareWebrtc(){return d(this,null,function*(){var n;if(this._mode!==M.PLUGIN)return;s.debug("PuPlayer Plugin prepareWebrtc");let e=(n=this._pluginOption)==null?void 0:n.webrtc;!e||(this._video.autoPlay=!0,this._spinner.spin=!0,this._webrtcConnect=yield Je.connect(e,o=>{var i;if(!o)return;(i=this.video.getEl())==null||i.addEventListener("canplay",()=>{s.debug("Video canplay"),this.video.play()}),this._video.srcObject=o;let r=o.getTracks()[0];r.onended=l=>{s.debug("\u6D41\u89C6\u9891\u8F68\u9053\u5DF2\u7ECF\u7EC8\u6B62",l)},r.onmute=l=>{s.debug("\u6D41\u89C6\u9891\u8F68\u9053\u6682\u65F6\u65E0\u6CD5\u63D0\u4F9B\u5A92\u4F53",l),this.onMuted()},r.onunmute=l=>{s.debug("\u6D41\u89C6\u9891\u8F68\u9053\u63D0\u4F9B\u5A92\u4F53",l),this.onUnMuted()}}))})}close(){this.closeWebrtc()}beforeDestroy(){this.close()}onMuted(){}onUnMuted(){}loadPlayerConfig(){var e;this.video.autoPlay=!!((e=this._playerConfig)==null?void 0:e.autoPlay)}initEvents(){var o,r,i,l,m;(o=this.video.getEl())==null||o.addEventListener("canplay",()=>{this._spinner.spin=!1,this._mask.visible=!1}),(r=this.video.getEl())==null||r.addEventListener("waiting",()=>{s.debug("Video is waiting for more data."),this._spinner.spin=!0}),(i=this.el)==null||i.addEventListener("mousemove",()=>{this._panel.showThenHide()}),(l=this.el)==null||l.addEventListener("click",()=>{this._panel.showThenHide()});let e=(a=!1)=>{let g=this._panel.controller.PlayButton;a||(this._video.paused=!this._video.paused),console.log("oalyer,",this._video.paused),this._video.paused?g.Children=jsx.h(x.Play,null):g.Children=jsx.h(x.Play,{off:!0})};e(!0),this._panel.controller.addEventListener("play",()=>e()),this._video.addEventListener("play",()=>{s.debug("video play"),this._panel.showThenHide();let a=this._panel.controller.PlayButton;a.Children=jsx.h(x.Play,{off:!0})}),this._video.addEventListener("pause",()=>{s.debug("video pause"),this._panel.showThenHide();let a=this._panel.controller.PlayButton;a.Children=jsx.h(x.Play,null)}),this._panel.controller.addEventListener("screenshot",()=>{let a=this._video.getEl();if(!a){s.libError("playerPlugin screenshot videoEl\u4E3A\u7A7A\u503C");return}G.screenshot(a,`screenshot_${Date.now()}`)}),this._panel.controller.addEventListener("fullscreen",()=>{if(!this.el){s.libError("playerPlugin fullscreen playerEL\u4E3A\u7A7A\u503C");return}ue.toggle(this.el)}),(m=this._infoModal)==null||m.addEventListener("hide",()=>{this._infoModal.visible=!1,window.clearInterval(this._timer)}),this._panel.controller.addEventListener("information",()=>d(this,null,function*(){if(!this._video.getEl()){s.libError("playerPlugin information videoEl\u4E3A\u7A7A\u503C");return}this.refreshInfoModal()}));let n=(a=!1)=>{var b;let g=this._panel.controller.VolumeButton,y=(b=this._video.getEl())==null?void 0:b.muted;a||(this._video.muted=!y),y?g.Children=jsx.h(x.Volume,null):g.Children=jsx.h(x.Volume,{off:!0})};n(!0),this._panel.controller.addEventListener("volume",()=>n())}prepare(){if(s.debug("PlayerPlugin mode: ",this._mode),this.loadPlayerConfig(),this._mode===M.REJECT){s.error(new Error("\u4E0D\u652F\u6301\u7684\u89C6\u9891\u7C7B\u578B"),this._mode,this._videoOption);return}if(this._mode===M.DIRECT){this.prepareDirect();return}if(this._mode===M.PLUGIN){switch(this.justifyVideoType(this._videoOption,this._pluginOption)){case"webrtc":break;default:break}return}}prepareDirect(){var e;this._video.url=((e=this._videoOption)==null?void 0:e.url)||"",setTimeout(()=>{this.play()},300)}closeWebrtc(){var e;Je.disconnect(this._webrtcConnect),this.dispatch("closeWebrtc",{name:"closeWebrtcEvent",target:this,peerConnection:(e=this._webrtcConnect)==null?void 0:e.pc}),this._webrtcConnect=null,this._video.srcObject=null}refreshInfoModal(){return d(this,null,function*(){if(window.clearInterval(this._timer),!this._webrtcConnect)return;let e=3,n=()=>d(this,null,function*(){if(!this._webrtcConnect)return;let o=yield this._webrtcConnect.getStatsInfos();s.debug("player get result: ",o);let r={mimeType:(a="")=>({label:"Mime Type:",value:a}),totalSamplesReceived:(a=0,g)=>{let y={label:"Sample Rate:",value:""};return!a||!g.totalSamplesDuration||(y.value=Number(a/g.totalSamplesDuration).toFixed(3)+"Hz"),y}},i={mimeType:(a="")=>({label:"Mime Type:",value:a}),framesPerSecond:(a,g)=>({label:"Resolution:",value:`${g.frameWidth} x ${g.frameHeight}@${a}`}),bytesReceived:(a,g)=>{let y=a||0,b=(y-this._lastTotalReceivedBytes)*8/(e*1e3);return this._lastTotalReceivedBytes=y,{label:"Data Received:",value:`${Math.round(b)} kbps , lost ${g.packetsLost}`}}},l=jsx.h(Ge,{list:o.audios,factory:r}),m=jsx.h(Ge,{list:o.videos,factory:i});s.debug("audioInfoList",u.dom.createByJsx(l)),!!this._infoModal&&(this._infoModal.content=jsx.h("div",{style:"padding-left: 24px;"},jsx.h("section",{className:"player_info-modal_section",withNamespace:!0},jsx.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Audio"),l),jsx.h("section",{className:"player_info-modal_section",withNamespace:!0},jsx.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Video"),m)),this._infoModal.visible=!0)});n(),this._timer=window.setInterval(n,e*1e3)})}},me=Bt;var Fo=(t,e,n)=>o=>d(void 0,null,function*(){if(o.type==="offer"){s.debug("\u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C \u8BBE\u5907\u914D\u7F6E\u4FE1\u606F\uFF1A",t,"token: ",e),s.debug("\u672C\u5730sdp",o);try{let{id:r,index:i}=t||{},l=yield k.getDeviceWebrtc({id:r,index:i,sdp:o.sdp},e);return n&&n(l.dialogId),l.sdp}catch(r){throw s.error(r,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`PUPlayer open \u5931\u8D25 , ${r.message}`)}}}),Mo=t=>{let{container:e,token:n,puOption:o,defaultMediaOption:r={audio:!0,video:!0},testUrl:i,videoFit:l="fill",muted:m,apiPrefix:a,onConnected:g,onConnectedFailed:y,onDisConnected:b,fullScreenOnDblclick:v=!0}=t||{},f,I=n,T=o,L=e,E=typeof m=="boolean"?m:!r.audio;q(a);let C=()=>d(void 0,null,function*(){if(!!f&&(s.debug("PuPlayer close",f),p.mask.visible=!0,p.mask.text="Video Closed",p.close(),f))try{yield k.closeDialogs([f],I)}catch(h){throw s.error(h,"PuPlayer close \u5931\u8D25"),new Error(`PuPlayer close \u5931\u8D25 , ${h.message}`)}}),p=new me({video:{url:i},pluginOption:{webrtc:{offerParam:{offerToReceiveAudio:r.audio,offerToReceiveVideo:r.video},productRemoteSdp:h=>d(void 0,null,function*(){return Fo(T,I,H=>{f=H})(h)}),onIceDisconnected:()=>{p.mask.visible=!0,p.mask.text="lost connection",p.close(),b&&b()},onConnected:()=>{g&&g()},onConnectedFailed:()=>{y&&y()}}},playerConfig:{autoPlay:!0}});p.addEventListener("init",h=>{s.debug("\u76D1\u542C\u5230\u4E86 player\u5DF2\u7ECF\u521D\u59CB\u5316",h)}),p.mute(E),p.video.fit=l;let P=p.init();v&&(P==null||P.addEventListener("dblclick",()=>{s.debug("\u53CC\u51FBplayer\uFF1A",P),ue.toggle(P)}));let V={instance:{getVideoElement:()=>p.video.getEl(),getPlayerElement:()=>p.getEl(),open:(h=!1)=>d(void 0,null,function*(){s.debug("PuPlayer open"),yield C(),s.debug("PuPlayer close before open"),p.mask.visible=!1,p.mask.text="connecting",p.mute(!!h);try{yield p.prepareWebrtc()}catch(_){throw p.mask.visible=!0,p.mask.text="connect failed",_}if(typeof h=="boolean"&&h){let _=()=>{s.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",E),s.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),p.mute(E),document.removeEventListener("click",_),document.removeEventListener("touchend",_)};document.addEventListener("click",_),document.addEventListener("touchend",_)}}),play:()=>d(void 0,null,function*(){yield p.play(E)}),mute:(h=!1)=>{E=h,p.mute(h)},hidden:h=>d(void 0,null,function*(){let _=P,H=p.video.getEl();_.style.display="none",document.body.appendChild(_),H.muted=!0;try{typeof h!="undefined"&&(E=h),yield p.play(E)}catch($o){s.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}s.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",H.paused)}),display:h=>d(void 0,null,function*(){let _=P,H=p.video.getEl();u.render(_,L,()=>d(void 0,null,function*(){_.style.display="block",typeof h!="undefined"&&(E=h),yield p.play(E)})),s.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",H.paused)}),moveTo:h=>{s.debug("\u79FB\u52A8\u81F3\uFF1A",h),L=h,u.render(P,L,()=>d(void 0,null,function*(){}))},getCurrentContainer:()=>L,setPuOption:h=>{T=h},setVideoFit:h=>{s.debug("PuPlayer setVideoFit",h),p.video.fit=h},setToken:h=>{s.debug("PuPlayer setToken",h),I=h},setApiPrefix:q,close:C,render:p.init,destroy:()=>d(void 0,null,function*(){s.debug("PuPlayer destroy"),yield C(),p.destroy()})},element:P};return L&&(u.render(P,L),V.element=null),V},Lo=Mo;var qe=class extends Y{constructor(e,n){super();this._plugin=e,this._el=this._plugin.init(),this._currentContainer=n}moveTo(e,n){s.debug("\u79FB\u52A8\u81F3\uFF1A",e),this._currentContainer=e,u.render(this._el,this._currentContainer,n)}getCurrentContainer(){return this._currentContainer}render(){return this._plugin.init()}destroy(){s.debug("destroy",this._plugin),this._plugin.destroy(),this.dispatch("destroy")}};var ge=class{constructor(e,n,o,r){this.token="";this.fetchSdpFunc=e,this.token=n||"",this.param=o,this.prefix=r}fetch(e){return d(this,null,function*(){s.debug("RemoteSdpFetcher fetch \u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C param\uFF1A",this.param,"token: ",this.token);let n=yield this.fetchSdpFunc(e,this.param,this.token,this.prefix),{sdp:o,dialogId:r}=n||{};return this.dialogId=r,s.debug(`RemoteSdpFetcher fetch \u83B7\u5F97\u7684remoteSdp ${o}, dialogId: ${r}`),o})}close(){return d(this,null,function*(){s.debug(`remoteSdpFetcher close\uFF0C \u68C0\u67E5dialogId: ${this.dialogId}`),this.dialogId&&(yield k.closeDialogs([this.dialogId]))})}},Qe=class extends qe{constructor(e,n,o,r,i){super(e,i);this._muted=!1;this._videoFit="contain";this.setRemoteSdpFetcher(r),this.setVideoFit(n),this.setMuted(o)}get player(){return this._plugin}getPlayerElement(){return this.player.getEl()}getVideoElement(){return this.player.video.getEl()}setRemoteSdpFetcher(e){this._remoteSdpFetcher=e,this._plugin.setProductRemoteSdp(n=>d(this,null,function*(){var o;return(o=this._remoteSdpFetcher)==null?void 0:o.fetch(n)}))}getRemoteSdpFetcher(){return this._remoteSdpFetcher}setVideoFit(e){s.debug("BvWebrtcInstance setVideoFit",e),this._videoFit=e,this.player.video.fit=e}getVideoFit(){return this._videoFit}setMuted(e=!1){this._muted=e,this.player.mute(e)}getMuted(){return this._muted}mute(e=!1){return this.setMuted(e)}open(e=!1){return d(this,null,function*(){s.debug("BvWebrtc open"),yield this.close(),this.player.mask.visible=!1,this.player.mask.text="connecting",this.player.mute(!!e);try{yield this.player.prepareWebrtc()}catch(n){throw this.player.mask.visible=!0,this.player.mask.text="connect failed",n}if(e){let n=()=>{s.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",this._muted),s.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),this.player.mute(this._muted),document.removeEventListener("click",n),document.removeEventListener("touchend",n)};document.addEventListener("click",n),document.addEventListener("touchend",n)}})}play(){return d(this,null,function*(){yield this.player.play(this._muted)})}hidden(e){return d(this,null,function*(){let n=this._el,o=this.player.video.getEl();n.style.display="none",document.body.appendChild(n),o.muted=!0;try{typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)}catch(r){s.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}s.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}display(e){return d(this,null,function*(){let n=this._el,o=this.player.video.getEl();u.render(n,this._currentContainer,()=>d(this,null,function*(){n.style.display="block",typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)})),s.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}close(){return d(this,null,function*(){if(s.debug("BvWebrtcInstance close",`_dialogId: ${this._dialogId}`),this.player.mask.visible=!0,this.player.mask.text="Video Closed",this.player.close(),s.debug("BvWebrtcInstance close\uFF0C player closed\uFF0C\u68C0\u67E5 remoteSdpFetcher: ",this._remoteSdpFetcher),this.dispatch("close"),this._remoteSdpFetcher)try{yield this._remoteSdpFetcher.close()}catch(e){throw s.error(e,"BvWebrtcInstance close \u5931\u8D25"),new Error(`BvWebrtcInstance close \u5931\u8D25 , ${e.message}`)}})}destroy(){s.debug("PuPlayer destroy"),this.close(),this.player.destroy()}};var No=t=>{let{container:e,sdpFetcher:n,offerParam:o,videoFit:r,muted:i,autoPlay:l,onConnected:m,onClose:a,onDestroy:g,onConnectedFailed:y,onDisConnected:b,onPcEventAdded:v}=t,f=new me({pluginOption:{webrtc:{offerParam:o,productRemoteSdp:()=>d(void 0,null,function*(){return""}),onIceDisconnected:()=>{f.mask.visible=!0,f.mask.text="lost connection",f.close(),b&&b()},onPcEventAdded:v,onConnected:()=>{f.mask.visible=!1,f.mask.text="connected",m&&m()},onConnectedFailed:()=>{y&&y()}}},playerConfig:{autoPlay:l}}),I=new Qe(f,r,i,n,e);I.addEventListener("close",()=>{a&&a()}),I.addEventListener("destroy",()=>{g&&g()});let T={open:()=>d(void 0,null,function*(){s.debug("BvWebrtc open"),yield I.open()}),setOption:C=>{s.debug("BvWebrtc setOption");let p=I.getRemoteSdpFetcher();p&&(p.param=C)},setToken:C=>{s.debug("BvWebrtc setToken",C);let p=I.getRemoteSdpFetcher();p&&(p.token=C)},setApiPrefix:C=>{s.debug("BvWebrtc setApiPrefix",C);let p=I.getRemoteSdpFetcher();p&&(p.prefix=C)},getRemoteSdpFetcher:()=>I.getRemoteSdpFetcher(),close:()=>d(void 0,null,function*(){s.debug("BvWebrtc close"),yield I.close()}),render:()=>(s.debug("BvWebrtc render"),I.render()),destroy:()=>{s.debug("BvWebrtc destroy"),I.destroy()}},L=I.render(),E={instance:T,element:L};return e&&(u.render(L,e),E.element=null),E},At=No;var Oo=()=>d(void 0,null,function*(){s.debug("\u8BF7\u6C42\u9EA6\u514B\u98CE...");let t=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),e=t.getAudioTracks();return s.debug("\u9EA6\u514B\u98CE \u97F3\u9891\u8F68\u9053\uFF1A",e),t}),Do=t=>{let{container:e,token:n,getRemoteSdpParam:o,apiPrefix:r,getRemoteSdpResult:i,onConnected:l,onClose:m,onDestroy:a,onConnectedFailed:g,onDisConnected:y,onGetUserMediaFailed:b}=t||{},v=(C,p,P,he)=>d(void 0,null,function*(){if(s.debug("audioPlayer productRemoteSdp",{param:{localDescription:C,param:p,token:P,prefix:he}}),C.type==="offer"&&(q(he),s.debug("\u672C\u5730sdp",C),!!i))try{let{sdp:V,dialogId:h}=yield i(C.sdp,P,p);return{sdp:V,dialogId:h}}catch(V){throw s.error(V,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`productRemoteSdp \u5931\u8D25 , ${V.message}`)}}),f=new ge(v,n,o,r),{instance:I,element:T}=At({container:e,sdpFetcher:f,offerParam:{offerToReceiveAudio:!0},videoFit:"contain",muted:!1,autoPlay:!0,onConnected:l,onClose:m,onDestroy:a,onConnectedFailed:g,onDisConnected:y,onPcEventAdded:C=>d(void 0,null,function*(){try{let p=yield Oo();p.getTracks().forEach(P=>C.addTrack(P,p))}catch(p){b&&b()}})});return{instance:R({},I),element:T}},fe=Do;var Vo=(t,e,n)=>d(void 0,null,function*(){let{id:o,index:r}=n||{};return yield k.getDeviceWebrtc({id:o,index:r,sdp:t},e)}),Bo=t=>{let{container:e,token:n,puOption:o,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}=t||{},{instance:b,element:v}=fe({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:Vo,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}),f=j(R({},b),{setPuOption:T=>b.setOption&&b.setOption(T)});return delete f.setOption,{instance:f,element:v}},Ao=Bo;var Wo=(t,e,n)=>d(void 0,null,function*(){let{id:o,index:r}=n||{};return yield k.getConferenceWebrtc({id:o,index:r,sdp:t},e)}),Ho=t=>{let{container:e,token:n,confOption:o,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}=t||{},{instance:b,element:v}=fe({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:Wo,apiPrefix:r,onConnected:i,onClose:l,onDestroy:m,onConnectedFailed:a,onDisConnected:g,onGetUserMediaFailed:y}),f=j(R({},b),{setConfOption:T=>b.setOption&&b.setOption(T)});return delete f.setOption,{instance:f,element:v}},jo=Ho;var Va=k.closeAllStorageDialog;export{jo as Conference,Ao as Intercom,Lo as PuPlayer,ge as RemoteSdpFetcher,Va as clearAllDialog};
|
|
25
|
+
`,...n)}}formatShapeLog({level:t,title:e,color:n},o,...i){this.formatLog(t,e,o,oe({color:n},this.getLoggerOption().shape,U.title),oe({color:n},this.getLoggerOption().shape,U.message),...i)}debug(t,...e){this.formatShapeLog(A.debug,t,...e)}http(t,...e){this.formatShapeLog(A.http,t,...e)}api(t,...e){this.formatShapeLog(A.api,t,...e)}service(t,...e){this.formatShapeLog(A.service,t,...e)}interval(t,...e){this.formatShapeLog(A.interval,t,...e)}warn(t,...e){this.formatShapeLog(A.warn,t,...e)}},jo=new ot,rn=new ye,sn=rn,D=sn;var at=class extends ye{constructor(){super(...arguments);this.test=(e,...n)=>{let o=4;this.formatShapeLog({level:o,title:" Test ",color:"#3f6600"},e,...n)};this.libWarn=(e,...n)=>{this.warn("bvplayer-core ",e,...n),console.warn(new Error().stack)};this.libError=(e,...n)=>{this.error(new Error(`bvplayer-core ${e}`),...n)}}},be=new at;be.debug("player-core env:",d);be.version(d.SH_LIB_NAME,d.SH_LIB_VERSION||"");var a=be;var an=Array.isArray,ln=t=>t!==t,lt=t=>typeof t=="number",ct=t=>typeof t=="string",cn=t=>lt(t)||ct(t),dn=t=>typeof t=="function",un=t=>typeof t=="undefined",pn=t=>t?!1:!!(t!=null?t:!0),mn={isArr:an,baseIsNaN:ln,isString:ct,isNumber:lt,isText:cn,isFn:dn,isUndefined:un,isNullOrUndefined:pn},F=mn;function gn(t,e=[]){let n=-1,o=t.length;for(e||(e=Array(o));++n<o;)e[n]=t[n];return e}function fn(t,e,n){let o=n-1,i=t.length;for(;++o<i;)if(t[o]===e)return o;return-1}function hn(t,e,n,o=!1){let i=t.length,s=n+(o?1:-1);for(;o?s--:++s<i;)if(e(t[s],s,t))return s;return-1}function vn(t,e,n){return e===e?fn(t,e,n):hn(t,F.baseIsNaN,n)}function yn(t,e){let n=-1,o=e.length,i=t;for(t===e&&(e=gn(e));++n<o;){let s=0,c=e[n],g=c;for(;(s=vn(i,g,s))>-1;)i!==t&&[].splice.call(i,s,1),[].splice.call(t,s,1)}return t}var bn=t=>t?F.isArr(t)?t:[t]:[],In=(t,e)=>!t||!t.length||!e||!e.length?t:yn(t,e),Cn=(t,e="")=>{let n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0,n.width,n.height),n.toBlob(o=>{if(!o){a.libError("util screenshot canvas\u7684\u8F93\u51FA\u4E3A\u7A7A\u503C");return}let i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=`${e}.png`,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)})},Pn={pullAll:In,toArray:bn,screenshot:Cn},K=Pn;function wn(t){return t!=null&&t!==!0&&t!==!1}function dt(t,e=[]){return t.forEach(n=>{F.isArr(n)?dt(n,e):wn(n)&&e.push(F.isText(n)?_n(n):n)}),e}function En(t={},e){if(!e)return;Object.keys(t).forEach(o=>{if(o==="children")return;let i=t[o];F.isNullOrUndefined(i)||(o.startsWith("on")?e.addEventListener(o.substring(2).toLowerCase(),i):e instanceof Element?e.setAttribute(o==="className"?"class":o,i):e[o]=i)})}function _n(t){return{type:"",props:{nodeValue:String(t)+""}}}function xn(t,e){return t===""?document.createTextNode(""):e?document.createElementNS(e,t):document.createElement(t)}function Q(t,e,n){let o=e?e(t):t;if(!o)return null;if(F.isArr(o)){let c=document.createDocumentFragment();return o.forEach(g=>{let l=Q(g,e);l&&c.appendChild(l)}),c}let{props:i,type:s}=o;if(!i)return o instanceof Node||o instanceof Text?(a.libWarn("jsx grow","\u63D0\u793A",o,"\u5E76\u4E0D\u662F\u6709\u6548\u7684jsx element \u5DF2\u7ECF\u539F\u6837\u8F93\u51FA\uFF0C\u4E0D\u5F71\u54CDui \u4F46\u5C3D\u91CF\u5C11\u6DF7\u7528jsx\u548Cdom"),o):(a.libWarn("jsx grow","\u672A\u89E3\u6790",o,"\u56E0\u4E3A\u5B83\u4E0D\u662F\u6709\u6548\u7684jsx element\uFF0C\u5E76\u4E14\u4E5F\u4E0D\u662FRenderTarget\u7C7B\u578B"),null);if(F.isString(s)){let c=xn(s,i.xmlns||n);return En(i,c),(i.children||[]).forEach(l=>{let f=Q(l,e,i.xmlns);!f||c.appendChild(f)}),c}if(F.isFn(s)){let c=s(i);return Q(c,e)}return null}function Sn(t,e,...n){return e=e||{},n=dt(K.toArray(e.children||n)),e.children=n,{type:t,props:e}}var Tn=t=>t.children,Rn={h:Sn,Fragment:Tn},r=Rn;var Ie=t=>{let e;return t?e=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()):e=Date.now(),Math.floor(e/1e3)},ut=t=>{let e=typeof t=="number"?t:Ie(t),n=Ie();return e-n},kn=t=>ut(t)>0,Fn={getUTCSecond:Ie,pastNow:ut,compare:kn},Ce=Fn;var pt=(t,e,n)=>{let o={value:e,expire:n},i=JSON.stringify(o);return localStorage.setItem(t,i),o},Mn=(t,e,n)=>{let i=Ce.getUTCSecond()+n;return pt(t,e,i)},Ln=(t,e=!1)=>{let n=localStorage.getItem(t);if(!n)return null;try{let o=JSON.parse(n);return e?o:o.expire?Ce.compare(o.expire)?o.value:null:o.value}catch(o){a.error(o,n,"Storage\u8BFB\u53D6\u6570\u636E\u65F6\uFF0C JSON\u89E3\u6790\u51FA\u9519")}},Nn=t=>localStorage.removeItem(t),On={set:pt,setTimeout:Mn,get:Ln,remove:Nn},V=On;var re;(function(n){n.GET="GET",n.POST="POST"})(re||(re={}));var mt=(t,e)=>u(void 0,null,function*(){let n=new AbortController;if(e.signal&&e.signal.addEventListener("abort",()=>{n.abort()}),e.timeout){let c=setTimeout(()=>{n.abort()},e.timeout);n.signal.addEventListener("abort",()=>{clearTimeout(c)})}let o=e.bodyData,i=o&&(typeof o=="object"?JSON.stringify(o):o),s={credentials:"same-origin",method:e.method,headers:new Headers(k({},e.headers)),signal:n.signal};i&&(s.body=i),a.http("\u53D1\u9001\u8BF7\u6C42\uFF1A",t,z(k({},s),{body:o}));try{let c=yield fetch(t,s);if(a.http("\u8BF7\u6C42\u54CD\u5E94\uFF1A",t,c,yield c.clone().text()),c.ok||c.status>=200&&c.status<300){let g=c.headers.get("content-type")||"";if(/application\/json/i.test(g))return yield c.json()}else throw new Error(`${c.status} ${c.statusText}`)}catch(c){if(c.name==="AbortError"){a.http("\u8BF7\u6C42\u53D6\u6D88\uFF1A",s);return}throw c}}),Dn=(t,e,n)=>u(void 0,null,function*(){let o=e?e.toString():"";return yield mt(t+o,{method:re.GET,headers:n==null?void 0:n.headers})}),Vn=(t,e,n)=>u(void 0,null,function*(){return yield mt(t,{method:re.POST,headers:k({"Content-Type":"application/json;charset=UTF-8"},n==null?void 0:n.headers),bodyData:e})}),Bn={get:Dn,post:Vn},ie=Bn;var gt={BVCSP_V1:{path:"/bvcsp/v1",prefix:""}},Pe=t=>{let e=gt[t];return e.prefix+e.path},An=(t,e)=>{let n=gt[t];return n.prefix=e||"",Pe(t)},Z={setApiPrefix:An,getApiURL:Pe,bvscpV1:()=>Pe("BVCSP_V1")},Y=t=>{Z.setApiPrefix("BVCSP_V1",t)};var Wn=t=>{if(!t)return null;if(t.nodeType===Node.DOCUMENT_NODE)return t.documentElement;if(t.nodeType===Node.ELEMENT_NODE){let e=t;return e.hasChildNodes()&&e.childNodes.forEach(n=>{let o=n;o.className&&new RegExp(".*bvplayer-core-player.*").test(o.className)&&e.removeChild(o)}),t}return null},Hn=(t,e,n)=>{if(!t)return;let o=document.createDocumentFragment();o.appendChild(t);let i=Wn(e);!i||(i.appendChild(o),n==null||n())},ft=Hn;var se=(...t)=>{let e=[];for(let n=0;n<t.length;n++){let o=t[n];if(!o)continue;let i=typeof o;if(F.isText(o))e.push(o);else if(Array.isArray(o)){if(o.length){let s=se(...o);s&&e.push(s)}}else if(i==="object")if(o.toString==={}.toString)for(let s in o)({}).hasOwnProperty.call(o,s)&&o[s]&&e.push(s);else e.push(o.toString())}return e.join(" ")},ht=t=>t?t.replace(/\s*(;|\{|\})+\s*[\n\r]*/g,"$1"):"",$n=(t,...e)=>{if(!e.length)return ht(t[0]);let n="";return e.forEach((o,i)=>{n+=t[i]+o}),n+=t[t.length-1],ht(n)},we="bvplayer-",zn="common-",vt=t=>new RegExp(we).test(t),Un=(...t)=>se(t).split(" ").map(e=>vt(e)?e:we+e).join(" "),Kn=(...t)=>se(t).split(" ").map(e=>vt(e)?e:we+zn+e).join(" ");var Jn={cls:se,css:$n,prefixCls:Un,commonCls:Kn},j=Jn;function Gn(t){return document.createRange().createContextualFragment(t)}function Xn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function Ee(){return document.createDocumentFragment()}function qn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function Qn(t,...e){if(!t)return;let n=Ee();n.append(...e.filter(o=>o)),t.appendChild(n)}function Zn(t){if(!!t)if(t instanceof Element){t.innerHTML="";return}else for(;t.firstChild;)t.removeChild(t.firstChild)}function Yn(t,...e){if(!e.length||!(t==null?void 0:t.parentNode))return;let n=e.filter(o=>o);if(t instanceof Element)t.replaceWith(...n);else{let o=Ee();o.append(...n),t.parentNode.replaceChild(o,t)}}function jn(t){var e;if(!!t)if(t instanceof Element){t.remove();return}else(e=t.parentNode)==null||e.removeChild(t)}function eo(t){if(!t||!t.props)return t;let{props:e}=t;return e.withCommonNamespace&&(e.className=j.commonCls(e.className),delete e.withCommonNamespace),e.withNamespace&&(e.className=j.prefixCls(e.className),delete e.withNamespace),t}function to(t){return t?Q(t,eo):null}var no={parseHtml:Gn,create:Xn,createFragment:Ee,createHtmlElement:qn,createByJsx:to,append:Qn,empty:Zn,replace:Yn,removeSelf:jn},yt=no;var oo="bvplayerCore",ro=t=>oo+t,io={createPrefixStorageField:ro},bt=io;var so={render:ft,style:j,dom:yt,field:bt},p=so;var W=p.field.createPrefixStorageField("DialogIds"),ao=(t,e)=>u(void 0,null,function*(){var c;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},i=yield ie.post(`${Z.bvscpV1()}/dialog/device/webrtc`,o,{headers:n});if(a.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:i}),!i||i.code!==0||!((c=i.data)==null?void 0:c.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${i.msg}`);let{data:s}=i;if(s.dialogid){let g=V.get(W)||[];g.push(s.dialogid),V.set(W,g)}return{dialogId:s.dialogid,sdp:s.sdp}}),lo=(t,e)=>u(void 0,null,function*(){var g;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},i=yield ie.post(`${Z.bvscpV1()}/dialog/conference/webrtc`,o,{headers:n});if(a.api("\u4F1A\u8BAE\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:i}),!i||i.code!==0||!((g=i.data)==null?void 0:g.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${i==null?void 0:i.msg}`);let{data:s}=i,c=V.get(W)||[];return c.push(s.dialogid),V.set(W,c),{dialogId:s.dialogid,sdp:s.sdp}}),co=(t,e)=>u(void 0,null,function*(){if(!t)return;let n={Authorization:e||""};return a.api("\u5173\u95EDdialog\uFF1A",t),yield ie.post(`${Z.bvscpV1()}/dialog/close/${t}`,{},{headers:n})}),It=(t,e)=>u(void 0,null,function*(){let n=V.get(W)||[];K.pullAll(n,t),V.set(W,n,0);let i=(yield Promise.allSettled(t.map(s=>co(s,e)))).filter(s=>s.status==="rejected");i&&i.length>0&&a.error(new Error(`"\u5173\u95ED\u5B58\u50A8\u7684dialog\u65F6\u5931\u8D25\uFF1A", ${i}`))}),uo=t=>u(void 0,null,function*(){let e=V.get(W);!e||e.length<1||(V.remove(W),yield It(e,t))}),po={getDeviceWebrtc:ao,getConferenceWebrtc:lo,closeDialogs:It,closeAllStorageDialog:uo},M=po;var Ct=class{constructor(){this._map=new Map}findExecutor(e,n){let o=this._map.get(e);return{index:o?o.findIndex(s=>Object.is(n,s)):-1,que:o}}publish(e,n){let o=this._map.get(e)||[],i=o.length;for(let s=0;s<i;s++){let c=o[s];c&&c(n)}}subscribe(e,n){let{index:o,que:i=[]}=this.findExecutor(e,n);return o>=0?i[o]=n:i.push(n),this._map.set(e,i),{unSubscribe:()=>{this.unSubscribe(e,n)}}}unSubscribe(e,n){let{index:o,que:i=[]}=this.findExecutor(e,n);o<0||(i.splice(o,1),this._map.set(e,i))}},ee=class{constructor(){this._notifier=new Ct}addEventListener(e,n){this._notifier.subscribe(e,n)}removeEventListener(e,n){this._notifier.unSubscribe(e,n)}dispatch(e,n){this._notifier.publish(e,n)}};var E=class extends ee{constructor(e,n,o){super();this.name="";let i=n.trim().toLowerCase(),s=o?o.trim():i,c=p.dom.create(e,p.style.prefixCls(s));this.name=i,this.el=c}empty(){p.dom.empty(this.el)}unmount(){var e;a.debug("unmount",this.el,(e=this.el)==null?void 0:e.parentNode),p.dom.removeSelf(this.el)}destroy(){if(this.beforeDestroy(),this.empty(),this.unmount(),this.el=null,this.dispatch("destroy"),!!this){for(let e in this)this[e]=void 0;a.debug("destroy complete",this)}}getEl(){return this.el}};var Pt=class extends E{constructor(e){super("div","mask",p.style.cls("mask"));this._visible=!!(e==null?void 0:e.visible),this._text=e==null?void 0:e.text,this._textEl=p.dom.create("span",p.style.cls("text"))}set visible(e){this._visible=e,this.el.style.display=this._visible?"grid":"none"}set text(e){this._text=e,this._textEl.textContent=e}beforeDestroy(){}init(){a.debug("mask visible: ",this._visible);let e=this.el;return e.style.display=this._visible?"block":"none",this._textEl.textContent=this._text||"",p.dom.append(e,this._textEl),e}},wt=Pt;var Et=class extends E{constructor(e){super("div","spinner",p.style.cls("spinner"));this._spin=!!(e==null?void 0:e.spin)}set spin(e){this._spin=e,this.el.style.display=this._spin?"block":"none"}beforeDestroy(){}init(){a.debug("spinner spin: ",this._spin);let e=this.el;e.style.display=this._spin?"block":"none";let n=p.dom.create("span");return n.style.backgroundColor="#FFF",p.dom.append(e,n),e}},_t=Et;var xt={contain:"contain",fill:"fill"},St=class extends E{constructor(e){super("video","video",p.style.cls("video"));this._url=e==null?void 0:e.url,this._srcObject=(e==null?void 0:e.srcObject)||null,this._fit=(e==null?void 0:e.fit)||xt.contain,this._autoPlay=!!(e==null?void 0:e.autoPlay),this._muted=!!(e==null?void 0:e.muted)}set url(e){typeof this._url!="undefined"&&(this.el.src=this._url),this._url=e}set srcObject(e){this._srcObject=e||null,this.el.srcObject=this._srcObject}set muted(e){let n=this.el;this._muted=e,n.muted=e}set paused(e){let n=this.el;e?n.pause():n.play()}get paused(){var e;return!!((e=this.el)==null?void 0:e.paused)}set autoPlay(e){if(!e!==this._autoPlay)return;this._autoPlay=e,this.muted=e;let n=this.el;n.autoplay=this._autoPlay}set fit(e){this._fit=xt[e],this.el.style.objectFit=this._fit}getVideoFit(){return this._fit}init(){a.debug("\u6E32\u67D3VideoPlugin\u89C6\u9891\u5BF9\u8C61dom\u7684children",this,this.el);let e=this.el;return e.addEventListener("play",()=>this.dispatch("play",{target:this})),e.addEventListener("pause",()=>this.dispatch("pause",{target:this})),e.addEventListener("loadedmetadata",n=>{a.debug("video loadedmetadata",n),this.dispatch("loadedmetadata",{target:this})}),typeof this._url!="undefined"&&(e.src=this._url),e.srcObject=this._srcObject,e.autoplay=this._autoPlay,e.muted=this._muted,e.style.objectFit=this._fit,e.playsInline=!0,e}play(){return u(this,null,function*(){let e=this.el;try{a.debug("video \u5C1D\u8BD5\u64AD\u653E"),yield e.play()}catch(n){a.error(n,"video \u64AD\u653E \u5931\u8D25")}})}beforeDestroy(){}},Tt=St;function te(t){return class extends t{constructor(...e){super(...e);this._visible=!1}get visible(){return this._visible}set visible(e){let n=!!e;if(this._visible===n)return;this._visible=n;let o=p.style.commonCls("is-visible");this._visible?(this.show&&this.show(),this.el.setAttribute("aria-hidden","false"),this.el.classList.add(o)):(this.hide&&this.hide(),this.el.setAttribute("aria-hidden","true"),this.el.classList.remove(o))}}}function _e({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function xe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 0 1-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 0 1 .947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 0 1 2.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 0 1 2.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 0 1 .947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 0 1-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 0 1-2.287-.947zM10 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function Se({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 9a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 10.07 4h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 18.07 7H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 13a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"}))}function Te({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M4 5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-1.586a1 1 0 0 1-.707-.293l-1.121-1.121A2 2 0 0 0 11.172 3H8.828a2 2 0 0 0-1.414.586L6.293 4.707A1 1 0 0 1 5.586 5H4zm6 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","clip-rule":"evenodd"}))}function Re({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0-5 5M4 16v4m0 0h4m-4 0 5-5m11 5-5-5m5 5v-4m0 4h-4"}))}function ke({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M3 4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 2H6.414l2.293 2.293a1 1 0 0 1-1.414 1.414L5 6.414V8a1 1 0 0 1-2 0V4zm9 1a1 1 0 1 1 0-2h4a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0V6.414l-2.293 2.293a1 1 0 1 1-1.414-1.414L13.586 5H12zm-9 7a1 1 0 1 1 2 0v1.586l2.293-2.293a1 1 0 0 1 1.414 1.414L6.414 15H8a1 1 0 1 1 0 2H4a1 1 0 0 1-1-1v-4zm13-1a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 1 1 0-2h1.586l-2.293-2.293a1 1 0 0 1 1.414-1.414L15 13.586V12a1 1 0 0 1 1-1z","clip-rule":"evenodd"}))}function Fe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Me({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zm-7-4a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM9 9a1 1 0 0 0 0 2v3a1 1 0 0 0 1 1h1a1 1 0 1 0 0-2v-3a1 1 0 0 0-1-1H9z","clip-rule":"evenodd"}))}function Le({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m10 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2m7-2a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Ne({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM8.707 7.293a1 1 0 0 0-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 1 0 1.414 1.414L10 11.414l1.293 1.293a1 1 0 0 0 1.414-1.414L11.414 10l1.293-1.293a1 1 0 0 0-1.414-1.414L10 8.586 8.707 7.293z","clip-rule":"evenodd"}))}function Oe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18 18 6M6 6l12 12"}))}function De({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 0 1 1.414 0L10 8.586l4.293-4.293a1 1 0 1 1 1.414 1.414L11.414 10l4.293 4.293a1 1 0 0 1-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 0 1-1.414-1.414L8.586 10 4.293 5.707a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function Ve({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 0 1 0 7.072m2.828-9.9a9 9 0 0 1 0 12.728M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}))}function Be({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm5.274-.147a1 1 0 0 1 1.414 0A9.972 9.972 0 0 1 19 10a9.972 9.972 0 0 1-2.929 7.071 1 1 0 0 1-1.414-1.414A7.971 7.971 0 0 0 17 10a7.97 7.97 0 0 0-2.343-5.657 1 1 0 0 1 0-1.414zm-2.829 2.828a1 1 0 0 1 1.415 0A5.983 5.983 0 0 1 15 10a5.984 5.984 0 0 1-1.757 4.243 1 1 0 0 1-1.415-1.415A3.984 3.984 0 0 0 13 10a3.983 3.983 0 0 0-1.172-2.828 1 1 0 0 1 0-1.415z","clip-rule":"evenodd"}))}function Ae({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5.586 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z","clip-rule":"evenodd"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m17 14 2-2m0 0 2-2m-2 2-2-2m2 2 2 2"}))}function We({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0 1 10 4v12a1 1 0 0 1-1.707.707L4.586 13H2a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2.586l3.707-3.707a1 1 0 0 1 1.09-.217zm2.91 4.217a1 1 0 0 1 1.414 0L15 8.586l1.293-1.293a1 1 0 1 1 1.414 1.414L16.414 10l1.293 1.293a1 1 0 0 1-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 0 1-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 0 1 0-1.414z","clip-rule":"evenodd"}))}function He({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14.752 11.168-3.197-2.132A1 1 0 0 0 10 9.87v4.263a1 1 0 0 0 1.555.832l3.197-2.132a1 1 0 0 0 0-1.664z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function $e({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM9.555 7.168A1 1 0 0 0 8 8v4a1 1 0 0 0 1.555.832l3-2a1 1 0 0 0 0-1.664l-3-2z","clip-rule":"evenodd"}))}function ze({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 9v6m4-6v6m7-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"}))}function Ue({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0zM7 8a1 1 0 0 1 2 0v4a1 1 0 1 1-2 0V8zm5-1a1 1 0 0 0-1 1v4a1 1 0 1 0 2 0V8a1 1 0 0 0-1-1z","clip-rule":"evenodd"}))}function Ke({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 33",fill:"currentColor"},r.h("path",{d:"M6.667 28H1.334c-.8 0-1.333-.533-1.333-1.333v-5.333c0-.8.533-1.333 1.333-1.333s1.333.533 1.333 1.333v4h4c.8 0 1.333.533 1.333 1.333S7.467 28 6.667 28zm24 0h-5.333c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h4v-4c0-.8.533-1.333 1.333-1.333S32 20.534 32 21.334v5.333c0 .8-.533 1.333-1.333 1.333zm0-16c-.8 0-1.333-.533-1.333-1.333v-4h-4c-.8 0-1.333-.533-1.333-1.333s.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333v5.333c0 .8-.533 1.333-1.333 1.333zM1.333 12C.533 12 0 11.467 0 10.667V5.334c0-.8.533-1.333 1.333-1.333h5.333c.8 0 1.333.533 1.333 1.333s-.533 1.333-1.333 1.333h-4v4c0 .8-.533 1.333-1.333 1.333z"}))}var L=({children:t,className:e})=>{let n=p.style.cls(["icon",e]);return r.h("span",{className:n,withNamespace:!0},t)},mo=({filled:t})=>r.h(L,null,t?r.h(xe,null):r.h(_e,null)),go=({filled:t})=>r.h(L,null,t?r.h(Te,null):r.h(Se,null)),fo=({filled:t})=>r.h(L,null,t?r.h(Me,null):r.h(Fe,null)),ho=({filled:t})=>r.h(L,null,t?r.h(ke,null):r.h(Re,null)),vo=({filled:t,circle:e})=>e?r.h(L,null,t?r.h(Ne,null):r.h(Le,null)):r.h(L,null,t?r.h(De,null):r.h(Oe,null)),yo=({filled:t,off:e})=>e?r.h(L,null,t?r.h(We,null):r.h(Ae,null)):r.h(L,null,t?r.h(Be,null):r.h(Ve,null)),bo=({filled:t,off:e})=>e?r.h(L,null,t?r.h(Ue,null):r.h(ze,null)):r.h(L,null,t?r.h($e,null):r.h(He,null)),Io=()=>r.h(L,null,r.h(Ke,null)),Co={Cog:mo,Camera:go,Info:fo,ArrowsExpand:ho,X:vo,Volume:yo,Play:bo,Full:Io};var _=Co;var H="modal",Rt=class extends E{constructor(e){super("div",H,p.style.cls([H,e.className,{[`${H}--center`]:e.center}]));this.container=e.container,this.title=e.title,this._content=e.content||p.dom.create("div","test"),this._center=!!e.center}set content(e){let n=p.dom.createByJsx(e);a.debug("modal update content",n,this._content),p.dom.replace(this._content,n),this._content=n}show(){var e;(e=this.el)==null||e.classList.toggle(p.style.prefixCls(`${H}--center`),!!this._center),p.dom.append(this.container,this.el)}hide(){}clear(){!this.el||(this.el.innerHTML="")}beforeDestroy(){}init(){this.clear(),a.debug("\u6E32\u67D3ModalPlugin \u5F39\u7A97\u5BF9\u8C61",this,this.el);let e=this.el,n=p.dom.createByJsx(r.h(r.Fragment,null,r.h("div",{className:`${H}_title-bar`,onClick:()=>this.dispatch("hide"),withNamespace:!0},r.h("span",{className:`${H}_title-bar_title`,withNamespace:!0},this.title),r.h("span",{className:`${H}_title-bar_close`,withNamespace:!0},r.h(_.X,null))),r.h("div",{className:`${H}_body`,withNamespace:!0},this._content)));return p.dom.append(e,n),e}},Po=te(Rt),Je=class extends Po{},kt=Je;var wo="controller_button",Ft=class extends E{constructor(e,n){super("button",wo);this._Children=e,this.title=n}set Children(e){!this.el||(this._Children=e,this.empty(),p.dom.append(this.el,p.dom.createByJsx(e)))}beforeDestroy(){}init(){let e=this.el;return e.addEventListener("click",()=>this.dispatch("click")),e.title=this.title||"",p.dom.append(e,p.dom.createByJsx(this._Children)),e}},J=Ft;var Mt="controller",Lt=class extends E{constructor(e){super("div",Mt,p.style.cls(Mt));this._controls=(e==null?void 0:e.controls)||[],this.PlayButton=new J(r.h(_.Play,null)),this.VolumeButton=new J(r.h(_.Volume,{off:!0}),"volume"),this.InformationButton=new J(r.h(_.Info,null),"information"),this.ScreenshotButton=new J(r.h(_.Camera,null),"screenshot"),this.FullscreenButton=new J(r.h(_.ArrowsExpand,null),"fullscreen"),this.PlayButton.addEventListener("click",()=>{this.dispatch("play")}),this.VolumeButton.addEventListener("click",()=>{this.dispatch("volume")}),this.InformationButton.addEventListener("click",()=>this.dispatch("information")),this.ScreenshotButton.addEventListener("click",()=>this.dispatch("screenshot")),this.FullscreenButton.addEventListener("click",()=>this.dispatch("fullscreen"))}beforeDestroy(){}init(){a.debug("\u6E32\u67D3ControllerPlugin \u64AD\u653E\u63A7\u5236\u5668\u5BF9\u8C61",this,this.el,this._controls);let e=this.el,n=p.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_left`]),o=p.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_right`]),i=p.dom.createByJsx(r.h(r.Fragment,null,r.h("div",{className:`${this.name}_mask`,withNamespace:!0}),r.h("div",{className:`${this.name}_inner`,withNamespace:!0},r.h("div",{className:n,withNamespace:!0},this.PlayButton.init(),this.VolumeButton.init()),r.h("div",{className:"flex-space",withCommonNamespace:!0}),r.h("div",{className:o,withNamespace:!0},this.InformationButton.init(),this.ScreenshotButton.init(),this.FullscreenButton.init()))));return p.dom.append(e,i),e}},Eo=te(Lt),Ge=class extends Eo{},Nt=Ge;var Ot=class{constructor(){this._els=[];this.disableAutoHide=!1;this._controller=new Nt}init(){let e=this._controller.init();return this._els.push(e),this._els}get els(){return this._els}get controller(){return this._controller}show(){this._controller.visible=!0}hide(){window.clearTimeout(this._autoHideTimeout),this._controller.visible=!1}showThenHide(){this.show(),window.clearTimeout(this._autoHideTimeout),this._autoHideTimeout=window.setTimeout(()=>{this.disableAutoHide||this.hide()},3e3)}},Dt=Ot;var ae=class{constructor(e){this.pc=e}getReceiversMap(){let e=new Map([["audio",[]],["video",[]]]),n=this.pc.getReceivers();return(n==null?void 0:n.length)&&n.forEach(o=>{let{kind:i}=o.track,s=e.get(i)||[];s.push(o),e.set(i,s)}),e}getStatsInfos(){return u(this,null,function*(){let e=this.getReceiversMap();a.debug("receivers map : ",e);let n=yield Promise.all(e.get("audio").map(i=>u(this,null,function*(){let s={},c=yield i.getStats(),g=[];return c.forEach(l=>{g.push(l),l.type==="codec"&&(s.mimeType=l.mimeType,s.clockRate=l.clockRate,s.channels=l.channels),l.type==="track"&&(s.totalSamplesReceived=l.totalSamplesReceived,s.totalSamplesDuration=l.totalSamplesDuration)}),a.debug("audio stats report: ",g),s}))),o=yield Promise.all(e.get("video").map(i=>u(this,null,function*(){let s={},c=yield i.getStats(),g=[];return c.forEach(l=>{g.push(l),l.type==="codec"&&(s.mimeType=l.mimeType,s.clockRate=l.clockRate),l.type==="inbound-rtp"&&(s.frameWidth=l.frameWidth,s.frameHeight=l.frameHeight,s.framesPerSecond=l.framesPerSecond,s.framesReceived=l.framesReceived,s.framesDecoded=l.framesDecoded,s.totalInterFrameDelay=l.totalInterFrameDelay,s.keyFramesDecoded=l.keyFramesDecoded,s.packetsLost=l.packetsLost,s.lastPacketReceivedTimestamp=l.lastPacketReceivedTimestamp,s.bytesReceived=l.bytesReceived,s.totalDecodeTime=l.totalDecodeTime)}),a.debug("video stats report: ",g),s})));return{audios:n,videos:o}})}};var _o=(t,e)=>{D.debug(`webrtc my ICE candidate:
|
|
26
|
+
${e.candidate?e.candidate.candidate:"(null)"}`)},xo=(t,e,n)=>{D.debug("webrtc ICE state change event: ",e),D.debug(`webrtc my ICE state: ${t==null?void 0:t.iceConnectionState}`),t&&t.iceConnectionState==="disconnected"&&n&&n()},So=(t,e)=>{D.debug("webrtc Connection state change, \u5F53\u524D\u8FDE\u63A5\u72B6\u6001: ",t,t.connectionState)},To=(t,e,n)=>{D.debug("webrtc \u5F53\u524D\u7684 stream: ",e.streams[0]);let o=e.streams[0];n(o)},Ro=(t,e)=>u(void 0,null,function*(){let{offerParam:n,productRemoteSdp:o,customerRTCPeerConnection:i,onConnected:s,onConnectedFailed:c,onIceDisconnected:g,onPcEventAdded:l,onLocalDescriptionReady:f}=t,b=!!i&&i instanceof RTCPeerConnection,I={},y=b?i:new RTCPeerConnection(I);if(y.addEventListener("icecandidate",h=>_o(y,h)),y.addEventListener("iceconnectionstatechange",h=>xo(y,h,g)),y.addEventListener("connectionstatechange",h=>So(y,h)),y.addEventListener("track",h=>To(y,h,e)),l&&(yield l(y)),b)return new ae(y);try{let h=yield y.createOffer(n);D.debug("\u521B\u5EFAoffer\uFF0C\u53C2\u6570\uFF1A",n,"\uFF0C \u7ED3\u679C\uFF1A",h),yield y.setLocalDescription(h),f&&f(y);let C=yield o(new RTCSessionDescription(h));D.debug("webrtc recv open answer",C);let R=new RTCSessionDescription({type:"answer",sdp:C});yield y.setRemoteDescription(R),D.debug("getTransceivers",y.getTransceivers()),s&&s(y)}catch(h){throw c&&c(y),D.error(new Error(`webrtc Failed to create session description: ${h.toString()}`)),y.close(),h}return new ae(y)}),ko=t=>{if(!t)return;let{pc:e}=t;e.close()},Fo={connect:Ro,disconnect:ko},Xe=Fo;var G=document.documentElement,le="requestFullscreen",ce="exitFullscreen",de="fullscreenElement",ue="onfullscreenchange";if("webkitRequestFullScreen"in G)le="webkitRequestFullScreen",ce="webkitExitFullscreen",de="webkitFullscreenElement",ue="onwebkitfullscreenchange";else if("msRequestFullscreen"in G)le="msRequestFullscreen",ce="msExitFullscreen",de="msFullscreenElement",ue="MSFullscreenChange";else if("mozRequestFullScreen"in G)le="mozRequestFullScreen",ce="mozCancelFullScreen",de="mozFullScreenElement",ue="onmozfullscreenchange";else if(!("requestFullscreen"in G))throw"\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";function Mo(t=G,e){return t[le](e)}function Lo(){return document[ce]()}function Vt(t){return t===document[de]}function No(t=G,e){return Vt(t)?Lo():Mo(t,e)}function Oo(t,e){let n=()=>{t.onfullscreenchange=null},o=i=>{i.target!==null&&e(Vt(i.target))};return t[ue]=o,{cancel:n}}var Do={toggle:No,watch:Oo},pe=Do;var Vo=({label:t,value:e,suffix:n})=>r.h("div",{className:"player_info-modal_list_item",withNamespace:!0},r.h("span",{className:"player_info-modal_list_item_label",withNamespace:!0},t),r.h("span",{className:"player_info-modal_list_item_value",withNamespace:!0},e),r.h("span",{className:"player_info-modal_list_item_suffix",withNamespace:!0},n)),Bt=({list:t,factory:e})=>(t==null?void 0:t.length)?e?r.h(r.Fragment,null,t.map(n=>r.h(Bt,{list:Object.keys(n).map(o=>e[o]?e[o](n[o],n):!1).filter(o=>o!==!1)}))):r.h("div",{className:"player_info-modal_list",withNamespace:!0},t.map(n=>r.h(Vo,k({},n)))):null,qe=Bt;var N;(function(o){o.DIRECT="direct",o.PLUGIN="plugin",o.REJECT="reject"})(N||(N={}));var me;(function(s){s.MP4="MP4",s.FLAC="FLAC",s.OGG="OGG",s.WEBM="WEBM",s.AUTO="AUTO"})(me||(me={}));var Qe;(function(e){e.WEBRTC="WEBRTC"})(Qe||(Qe={}));var At="player",Wt=class extends E{constructor(e){super("div",At);this._lastTotalReceivedBytes=0;this._video=new Tt,this._spinner=new _t({spin:!1}),this._mask=new wt({visible:!1}),this._panel=new Dt,this._infoModal=new kt({container:this.el,title:"Info",center:!0,className:`${At}_info-modal`}),this._videoOption=e==null?void 0:e.video,this._pluginOption=e==null?void 0:e.pluginOption,this._playerConfig=e==null?void 0:e.playerConfig,this._mode=this._restrictPlayerMode(e==null?void 0:e.video,e==null?void 0:e.pluginOption),a.debug("PlayerMode",this._mode)}justifyVideoType(e,n){if((e==null?void 0:e.url)&&!e.type)return me.AUTO;let o="".toUpperCase.call((e==null?void 0:e.type)||Object.keys(n||{})[0]||"");return a.debug("justifyVideoType ",e,o),o}_restrictPlayerMode(e,n){let o=this.justifyVideoType(e,n);if(!o&&!(e==null?void 0:e.url))return N.REJECT;if(!o)return N.DIRECT;let i=Object.keys(me),s=Object.keys(Qe);return i.includes(o)?N.DIRECT:s.includes(o)?N.PLUGIN:N.DIRECT}init(){a.debug("\u6E32\u67D3PlayerPlugin",this.el),this.prepare();let e=this._video.init(),n=this._spinner.init(),o=this._mask.init(),i=this._panel.init(),s=this._infoModal.init();return p.dom.append(this.el,e,n,o,...i,s),this.initEvents(),this.dispatch("init",{name:"initEvent",target:this,mode:this._mode}),this.el}get video(){return this._video}get spinner(){return this._spinner}get mask(){return this._mask}play(e){return u(this,null,function*(){this.mute(!0),yield this._video.play(),this.mute(e)})}mute(e){var n;this._video.muted=!!e,a.debug("player mute: ",(n=this._video.getEl())==null?void 0:n.muted)}setProductRemoteSdp(e){!this._pluginOption||!this._pluginOption.webrtc||(this._pluginOption.webrtc.productRemoteSdp=e)}prepareWebrtc(){return u(this,null,function*(){var n;if(this._mode!==N.PLUGIN)return;a.debug("PuPlayer Plugin prepareWebrtc");let e=(n=this._pluginOption)==null?void 0:n.webrtc;!e||(this._video.autoPlay=!0,this._spinner.spin=!0,this._webrtcConnect=yield Xe.connect(e,o=>{var s;if(!o)return;(s=this.video.getEl())==null||s.addEventListener("canplay",()=>{a.debug("Video canplay"),this.video.play()}),this._video.srcObject=o;let i=o.getTracks()[0];i.onended=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u5DF2\u7ECF\u7EC8\u6B62",c)},i.onmute=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u6682\u65F6\u65E0\u6CD5\u63D0\u4F9B\u5A92\u4F53",c),this.onMuted()},i.onunmute=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u63D0\u4F9B\u5A92\u4F53",c),this.onUnMuted()}}))})}close(){this.closeWebrtc()}beforeDestroy(){this.close()}onMuted(){}onUnMuted(){}loadPlayerConfig(){var e;this.video.autoPlay=!!((e=this._playerConfig)==null?void 0:e.autoPlay)}initEvents(){var o,i,s,c,g;(o=this.video.getEl())==null||o.addEventListener("canplay",()=>{this._spinner.spin=!1,this._mask.visible=!1}),(i=this.video.getEl())==null||i.addEventListener("waiting",()=>{a.debug("Video is waiting for more data."),this._spinner.spin=!0}),(s=this.el)==null||s.addEventListener("mousemove",()=>{this._panel.showThenHide()}),(c=this.el)==null||c.addEventListener("click",()=>{this._panel.showThenHide()});let e=(l=!1)=>{let f=this._panel.controller.PlayButton;l||(this._video.paused=!this._video.paused),console.log("oalyer,",this._video.paused),this._video.paused?f.Children=r.h(_.Play,null):f.Children=r.h(_.Play,{off:!0})};e(!0),this._panel.controller.addEventListener("play",()=>e()),this._video.addEventListener("play",()=>{a.debug("video play"),this._panel.showThenHide();let l=this._panel.controller.PlayButton;l.Children=r.h(_.Play,{off:!0})}),this._video.addEventListener("pause",()=>{a.debug("video pause"),this._panel.showThenHide();let l=this._panel.controller.PlayButton;l.Children=r.h(_.Play,null)}),this._panel.controller.addEventListener("screenshot",()=>{let l=this._video.getEl();if(!l){a.libError("playerPlugin screenshot videoEl\u4E3A\u7A7A\u503C");return}K.screenshot(l,`screenshot_${Date.now()}`)}),this._panel.controller.addEventListener("fullscreen",()=>{if(!this.el){a.libError("playerPlugin fullscreen playerEL\u4E3A\u7A7A\u503C");return}pe.toggle(this.el)}),(g=this._infoModal)==null||g.addEventListener("hide",()=>{this._infoModal.visible=!1,window.clearInterval(this._timer)}),this._panel.controller.addEventListener("information",()=>u(this,null,function*(){if(!this._video.getEl()){a.libError("playerPlugin information videoEl\u4E3A\u7A7A\u503C");return}this.refreshInfoModal()}));let n=(l=!1)=>{var I;let f=this._panel.controller.VolumeButton,b=(I=this._video.getEl())==null?void 0:I.muted;l||(this._video.muted=!b),b?f.Children=r.h(_.Volume,null):f.Children=r.h(_.Volume,{off:!0})};n(!0),this._panel.controller.addEventListener("volume",()=>n())}prepare(){if(a.debug("PlayerPlugin mode: ",this._mode),this.loadPlayerConfig(),this._mode===N.REJECT){a.error(new Error("\u4E0D\u652F\u6301\u7684\u89C6\u9891\u7C7B\u578B"),this._mode,this._videoOption);return}if(this._mode===N.DIRECT){this.prepareDirect();return}if(this._mode===N.PLUGIN){switch(this.justifyVideoType(this._videoOption,this._pluginOption)){case"webrtc":break;default:break}return}}prepareDirect(){var e;this._video.url=((e=this._videoOption)==null?void 0:e.url)||"",setTimeout(()=>{this.play()},300)}closeWebrtc(){var e;Xe.disconnect(this._webrtcConnect),this.dispatch("closeWebrtc",{name:"closeWebrtcEvent",target:this,peerConnection:(e=this._webrtcConnect)==null?void 0:e.pc}),this._webrtcConnect=null,this._video.srcObject=null}refreshInfoModal(){return u(this,null,function*(){if(window.clearInterval(this._timer),!this._webrtcConnect)return;let e=3,n=()=>u(this,null,function*(){if(!this._webrtcConnect)return;let o=yield this._webrtcConnect.getStatsInfos();a.debug("player get result: ",o);let i={mimeType:(l="")=>({label:"Mime Type:",value:l}),totalSamplesReceived:(l=0,f)=>{let b={label:"Sample Rate:",value:""};return!l||!f.totalSamplesDuration||(b.value=Number(l/f.totalSamplesDuration).toFixed(3)+"Hz"),b}},s={mimeType:(l="")=>({label:"Mime Type:",value:l}),framesPerSecond:(l,f)=>({label:"Resolution:",value:`${f.frameWidth} x ${f.frameHeight}@${l}`}),bytesReceived:(l,f)=>{let b=l||0,I=(b-this._lastTotalReceivedBytes)*8/(e*1e3);return this._lastTotalReceivedBytes=b,{label:"Data Received:",value:`${Math.round(I)} kbps , lost ${f.packetsLost}`}}},c=r.h(qe,{list:o.audios,factory:i}),g=r.h(qe,{list:o.videos,factory:s});a.debug("audioInfoList",p.dom.createByJsx(c)),!!this._infoModal&&(this._infoModal.content=r.h("div",{style:"padding-left: 24px;"},r.h("section",{className:"player_info-modal_section",withNamespace:!0},r.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Audio"),c),r.h("section",{className:"player_info-modal_section",withNamespace:!0},r.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Video"),g)),this._infoModal.visible=!0)});n(),this._timer=window.setInterval(n,e*1e3)})}},ge=Wt;var Bo=(t,e,n)=>o=>u(void 0,null,function*(){if(o.type==="offer"){a.debug("\u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C \u8BBE\u5907\u914D\u7F6E\u4FE1\u606F\uFF1A",t,"token: ",e),a.debug("\u672C\u5730sdp",o);try{let{id:i,index:s}=t||{},c=yield M.getDeviceWebrtc({id:i,index:s,sdp:o.sdp},e);return n&&n(c.dialogId),c.sdp}catch(i){throw a.error(i,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`PUPlayer open \u5931\u8D25 , ${i.message}`)}}}),Ao=t=>{let{container:e,token:n,puOption:o,defaultMediaOption:i={audio:!0,video:!0},testUrl:s,videoFit:c="fill",muted:g,apiPrefix:l,onConnected:f,onConnectedFailed:b,onDisConnected:I,fullScreenOnDblclick:y=!0}=t||{},h,C=n,R=o,O=e,x=typeof g=="boolean"?g:!i.audio;Y(l);let P=()=>u(void 0,null,function*(){if(!!h&&(a.debug("PuPlayer close",h),m.mask.visible=!0,m.mask.text="Video Closed",m.close(),h))try{yield M.closeDialogs([h],C)}catch(v){throw a.error(v,"PuPlayer close \u5931\u8D25"),new Error(`PuPlayer close \u5931\u8D25 , ${v.message}`)}}),m=new ge({video:{url:s},pluginOption:{webrtc:{offerParam:{offerToReceiveAudio:i.audio,offerToReceiveVideo:i.video},productRemoteSdp:v=>u(void 0,null,function*(){return Bo(R,C,$=>{h=$})(v)}),onIceDisconnected:()=>{m.mask.visible=!0,m.mask.text="lost connection",m.close(),I&&I()},onConnected:()=>{f&&f()},onConnectedFailed:()=>{b&&b()}}},playerConfig:{autoPlay:!0}});m.addEventListener("init",v=>{a.debug("\u76D1\u542C\u5230\u4E86 player\u5DF2\u7ECF\u521D\u59CB\u5316",v)}),m.mute(x),m.video.fit=c;let w=m.init();y&&(w==null||w.addEventListener("dblclick",()=>{a.debug("\u53CC\u51FBplayer\uFF1A",w),pe.toggle(w)}));let B={instance:{getVideoElement:()=>m.video.getEl(),getPlayerElement:()=>m.getEl(),open:(v=!1)=>u(void 0,null,function*(){a.debug("PuPlayer open"),yield P(),a.debug("PuPlayer close before open"),m.mask.visible=!1,m.mask.text="connecting",m.mute(!!v);try{yield m.prepareWebrtc()}catch(S){throw m.mask.visible=!0,m.mask.text="connect failed",S}if(typeof v=="boolean"&&v){let S=()=>{a.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",x),a.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),m.mute(x),document.removeEventListener("click",S),document.removeEventListener("touchend",S)};document.addEventListener("click",S),document.addEventListener("touchend",S)}}),play:()=>u(void 0,null,function*(){yield m.play(x)}),mute:(v=!1)=>{x=v,m.mute(v)},hidden:v=>u(void 0,null,function*(){let S=w,$=m.video.getEl();S.style.display="none",document.body.appendChild(S),$.muted=!0;try{typeof v!="undefined"&&(x=v),yield m.play(x)}catch(Qo){a.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}a.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",$.paused)}),display:v=>u(void 0,null,function*(){let S=w,$=m.video.getEl();p.render(S,O,()=>u(void 0,null,function*(){S.style.display="block",typeof v!="undefined"&&(x=v),yield m.play(x)})),a.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",$.paused)}),moveTo:v=>{a.debug("\u79FB\u52A8\u81F3\uFF1A",v),O=v,p.render(w,O,()=>u(void 0,null,function*(){}))},getCurrentContainer:()=>O,setPuOption:v=>{R=v},setVideoFit:v=>{a.debug("PuPlayer setVideoFit",v),m.video.fit=v},setToken:v=>{a.debug("PuPlayer setToken",v),C=v},setApiPrefix:Y,close:P,render:m.init,destroy:()=>u(void 0,null,function*(){a.debug("PuPlayer destroy"),yield P(),m.destroy()})},element:w};return O&&(p.render(w,O),B.element=null),B},Wo=Ao;var Ze=class extends ee{constructor(e,n){super();this._plugin=e,this._el=this._plugin.init(),this._currentContainer=n}moveTo(e,n){a.debug("\u79FB\u52A8\u81F3\uFF1A",e),this._currentContainer=e,p.render(this._el,this._currentContainer,n)}getCurrentContainer(){return this._currentContainer}render(){return this._plugin.init()}destroy(){a.debug("destroy",this._plugin),this._plugin.destroy(),this.dispatch("destroy")}};var fe=class{constructor(e,n,o,i){this.token="";this.fetchSdpFunc=e,this.token=n||"",this.param=o,this.prefix=i}fetch(e){return u(this,null,function*(){a.debug("RemoteSdpFetcher fetch \u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C param\uFF1A",this.param,"token: ",this.token);let n=yield this.fetchSdpFunc(e,this.param,this.token,this.prefix),{sdp:o,dialogId:i}=n||{};return this.dialogId=i,a.debug(`RemoteSdpFetcher fetch \u83B7\u5F97\u7684remoteSdp ${o}, dialogId: ${i}`),o})}close(){return u(this,null,function*(){a.debug(`remoteSdpFetcher close\uFF0C \u68C0\u67E5dialogId: ${this.dialogId}`),this.dialogId&&(yield M.closeDialogs([this.dialogId]))})}},Ye=class extends Ze{constructor(e,n,o,i,s){super(e,s);this._muted=!1;this._videoFit="contain";this.setRemoteSdpFetcher(i),this.setVideoFit(n),this.setMuted(o)}get player(){return this._plugin}getPlayerElement(){return this.player.getEl()}getVideoElement(){return this.player.video.getEl()}setRemoteSdpFetcher(e){this._remoteSdpFetcher=e,this._plugin.setProductRemoteSdp(n=>u(this,null,function*(){var o;return(o=this._remoteSdpFetcher)==null?void 0:o.fetch(n)}))}getRemoteSdpFetcher(){return this._remoteSdpFetcher}setVideoFit(e){a.debug("BvWebrtcInstance setVideoFit",e),this._videoFit=e,this.player.video.fit=e}getVideoFit(){return this._videoFit}setMuted(e=!1){this._muted=e,this.player.mute(e)}getMuted(){return this._muted}mute(e=!1){return this.setMuted(e)}open(e=!1){return u(this,null,function*(){a.debug("BvWebrtc open"),yield this.close(),this.player.mask.visible=!1,this.player.mask.text="connecting",this.player.mute(!!e);try{yield this.player.prepareWebrtc()}catch(n){throw this.player.mask.visible=!0,this.player.mask.text="connect failed",n}if(e){let n=()=>{a.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",this._muted),a.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),this.player.mute(this._muted),document.removeEventListener("click",n),document.removeEventListener("touchend",n)};document.addEventListener("click",n),document.addEventListener("touchend",n)}})}play(){return u(this,null,function*(){yield this.player.play(this._muted)})}hidden(e){return u(this,null,function*(){let n=this._el,o=this.player.video.getEl();n.style.display="none",document.body.appendChild(n),o.muted=!0;try{typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)}catch(i){a.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}a.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}display(e){return u(this,null,function*(){let n=this._el,o=this.player.video.getEl();p.render(n,this._currentContainer,()=>u(this,null,function*(){n.style.display="block",typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)})),a.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}close(){return u(this,null,function*(){if(a.debug("BvWebrtcInstance close",`_dialogId: ${this._dialogId}`),this.player.mask.visible=!0,this.player.mask.text="Video Closed",this.player.close(),a.debug("BvWebrtcInstance close\uFF0C player closed\uFF0C\u68C0\u67E5 remoteSdpFetcher: ",this._remoteSdpFetcher),this.dispatch("close"),this._remoteSdpFetcher)try{yield this._remoteSdpFetcher.close()}catch(e){throw a.error(e,"BvWebrtcInstance close \u5931\u8D25"),new Error(`BvWebrtcInstance close \u5931\u8D25 , ${e.message}`)}})}destroy(){a.debug("PuPlayer destroy"),this.close(),this.player.destroy()}};var Ho=t=>{let{container:e,sdpFetcher:n,offerParam:o,videoFit:i,muted:s,autoPlay:c,onConnected:g,onClose:l,onDestroy:f,onConnectedFailed:b,onDisConnected:I,onPcEventAdded:y}=t,h=new ge({pluginOption:{webrtc:{offerParam:o,productRemoteSdp:()=>u(void 0,null,function*(){return""}),onIceDisconnected:()=>{h.mask.visible=!0,h.mask.text="lost connection",h.close(),I&&I()},onPcEventAdded:y,onConnected:()=>{h.mask.visible=!1,h.mask.text="connected",g&&g()},onConnectedFailed:()=>{b&&b()}}},playerConfig:{autoPlay:c}}),C=new Ye(h,i,s,n,e);C.addEventListener("close",()=>{l&&l()}),C.addEventListener("destroy",()=>{f&&f()});let R={open:()=>u(void 0,null,function*(){a.debug("BvWebrtc open"),yield C.open()}),setOption:P=>{a.debug("BvWebrtc setOption");let m=C.getRemoteSdpFetcher();m&&(m.param=P)},setToken:P=>{a.debug("BvWebrtc setToken",P);let m=C.getRemoteSdpFetcher();m&&(m.token=P)},setApiPrefix:P=>{a.debug("BvWebrtc setApiPrefix",P);let m=C.getRemoteSdpFetcher();m&&(m.prefix=P)},getRemoteSdpFetcher:()=>C.getRemoteSdpFetcher(),close:()=>u(void 0,null,function*(){a.debug("BvWebrtc close"),yield C.close()}),render:()=>(a.debug("BvWebrtc render"),C.render()),destroy:()=>{a.debug("BvWebrtc destroy"),C.destroy()}},O=C.render(),x={instance:R,element:O};return e&&(p.render(O,e),x.element=null),x},Ht=Ho;var $o=()=>u(void 0,null,function*(){a.debug("\u8BF7\u6C42\u9EA6\u514B\u98CE...");let t=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),e=t.getAudioTracks();return a.debug("\u9EA6\u514B\u98CE \u97F3\u9891\u8F68\u9053\uFF1A",e),t}),zo=t=>{let{container:e,token:n,getRemoteSdpParam:o,apiPrefix:i,getRemoteSdpResult:s,onConnected:c,onClose:g,onDestroy:l,onConnectedFailed:f,onDisConnected:b,onGetUserMediaFailed:I}=t||{},y=(P,m,w,ve)=>u(void 0,null,function*(){if(a.debug("audioPlayer productRemoteSdp",{param:{localDescription:P,param:m,token:w,prefix:ve}}),P.type==="offer"&&(Y(ve),a.debug("\u672C\u5730sdp",P),!!s))try{let{sdp:B,dialogId:v}=yield s(P.sdp,w,m);return{sdp:B,dialogId:v}}catch(B){throw a.error(B,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`productRemoteSdp \u5931\u8D25 , ${B.message}`)}}),h=new fe(y,n,o,i),{instance:C,element:R}=Ht({container:e,sdpFetcher:h,offerParam:{offerToReceiveAudio:!0},videoFit:"contain",muted:!1,autoPlay:!0,onConnected:c,onClose:g,onDestroy:l,onConnectedFailed:f,onDisConnected:b,onPcEventAdded:P=>u(void 0,null,function*(){try{let m=yield $o();m.getTracks().forEach(w=>P.addTrack(w,m))}catch(m){I&&I()}})});return{instance:k({},C),element:R}},he=zo;var Uo=(t,e,n)=>u(void 0,null,function*(){let{id:o,index:i}=n||{};return yield M.getDeviceWebrtc({id:o,index:i,sdp:t},e)}),Ko=t=>{let{container:e,token:n,puOption:o,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}=t||{},{instance:I,element:y}=he({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:Uo,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}),h=z(k({},I),{setPuOption:R=>I.setOption&&I.setOption(R)});return delete h.setOption,{instance:h,element:y}},Jo=Ko;var Go=(t,e,n)=>u(void 0,null,function*(){let{id:o,index:i}=n||{};return yield M.getConferenceWebrtc({id:o,index:i,sdp:t},e)}),Xo=t=>{let{container:e,token:n,confOption:o,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}=t||{},{instance:I,element:y}=he({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:Go,apiPrefix:i,onConnected:s,onClose:c,onDestroy:g,onConnectedFailed:l,onDisConnected:f,onGetUserMediaFailed:b}),h=z(k({},I),{setConfOption:R=>I.setOption&&I.setOption(R)});return delete h.setOption,{instance:h,element:y}},qo=Xo;var Ja=M.closeAllStorageDialog;export{qo as Conference,Jo as Intercom,Wo as PuPlayer,fe as RemoteSdpFetcher,Ja as clearAllDialog};
|